Commit 6da08a80 authored by Alexandre Lision's avatar Alexandre Lision Committed by gerrit2

ui: update button style

fit with wireframes. Blue circles and white icons.
Add this changes in the Person View Controller as well.

Issue: #79400
Change-Id: I82fd0189da0ead41e87de91d4a8123a968d79fea
parent 235890c6
......@@ -131,7 +131,9 @@ SET(ringclient_VIEWS
src/views/NSColor+RingTheme.mm
src/views/NSColor+RingTheme.h
src/views/ContextualTableCellView.mm
src/views/ContextualTableCellView.h)
src/views/ContextualTableCellView.h
src/views/IconButton.h
src/views/IconButton.mm)
SET(ringclient_OTHERS
src/main.mm
......@@ -168,6 +170,7 @@ SET_SOURCE_FILES_PROPERTIES(${myApp_ICON} PROPERTIES
SET(ring_ICONS
${CMAKE_CURRENT_SOURCE_DIR}/data/symbol_name.png
${CMAKE_CURRENT_SOURCE_DIR}/data/background_tile.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_accept.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_call.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_cancel.png
......
......@@ -37,6 +37,7 @@
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
#import "views/HoverTableRowView.h"
#import "views/ContextualTableCellView.h"
class ReachablePersonModel : public QSortFilterProxyModel
{
......@@ -167,12 +168,14 @@ NSInteger const CALL_BUTTON_TAG = 400;
[result setLayer:[CALayer layer]];
[result.layer setBackgroundColor:[NSColor selectedControlColor].CGColor];
} else if(((NSTreeNode*)item).indexPath.length == 2) {
result = [outlineView makeViewWithIdentifier:@"MainCell" owner:outlineView];
result = [outlineView makeViewWithIdentifier:@"PersonCell" owner:outlineView];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(35,35));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
[((ContextualTableCellView*) result) setContextualsControls:[NSMutableArray arrayWithObject:[result viewWithTag:CALL_BUTTON_TAG]]];
NSTextField* details = [result viewWithTag:DETAILS_TAG];
if (p && p->phoneNumbers().size() > 0)
[details setStringValue:p->phoneNumbers().first()->uri().toNSString()];
......
/*
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
@interface IconButton : NSButton
@property (nonatomic) BOOL mouseDown;
/*
* This properties can be overriden in IB in User Defined Runtime Attributes
* By default this values will be initialized in awakeFromNib with:
* bgColor -> [NSColor ringBlue]
* cornerRadius to view frame width / 2 (circle)
*/
@property (nonatomic, strong) NSColor* bgColor;
@property (nonatomic, strong) NSNumber* cornerRadius;
@end
/*
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "IconButton.h"
#import "NSColor+RingTheme.h"
@implementation IconButton
-(void) awakeFromNib {
if (!self.bgColor) {
self.bgColor = [NSColor ringBlue];
}
if (!self.cornerRadius) {
self.cornerRadius = @(NSWidth(self.frame) / 2);
}
}
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
NSColor* backgroundColor6;
NSColor* backgroundStrokeColor5;
if (self.mouseDown || self.state == NSOnState) {
backgroundColor6 = [self.bgColor darkenColorByValue:0.3];
backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.4];
} else {
backgroundColor6 = self.bgColor;
backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.1];
}
//// Subframes
NSRect group = NSMakeRect(NSMinX(dirtyRect) + floor(NSWidth(dirtyRect) * 0.03333) + 0.5, NSMinY(dirtyRect) + floor(NSHeight(dirtyRect) * 0.03333) + 0.5, floor(NSWidth(dirtyRect) * 0.96667) - floor(NSWidth(dirtyRect) * 0.03333), floor(NSHeight(dirtyRect) * 0.96667) - floor(NSHeight(dirtyRect) * 0.03333));
//// Group
{
//// Oval Drawing
// NSBezierPath* ovalPath = [NSBezierPath bezierPathWithOvalInRect: NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5))];
NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5)) xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
[backgroundColor6 setFill];
[ovalPath fill];
[backgroundStrokeColor5 setStroke];
[ovalPath setLineWidth: 0.5];
[ovalPath stroke];
[NSGraphicsContext saveGraphicsState];
NSBezierPath *path = [NSBezierPath bezierPathWithRect:dirtyRect];
[path addClip];
[self setImagePosition:NSImageOnly];
auto rect2 = NSInsetRect(dirtyRect, 5, 5);
[[NSColor image:self.image tintedWithColor:[NSColor whiteColor]]
drawInRect:rect2
fromRect:NSZeroRect
operation:NSCompositeSourceOver
fraction:1.0
respectFlipped:YES
hints:nil];
[NSGraphicsContext restoreGraphicsState];
}
}
-(void)mouseDown:(NSEvent *)theEvent
{
self.mouseDown = TRUE;
[self setNeedsDisplay:YES];
[super mouseDown:theEvent];
self.mouseDown = FALSE;
[self setNeedsDisplay:YES];
}
@end
......@@ -27,6 +27,12 @@
+ (NSColor*) ringDarkBlue;
+ (NSColor*) ringGreyHighlight;
+ (NSColor*) ringDarkGrey;
- (NSColor *)lightenColorByValue:(float)value;
- (NSColor *)darkenColorByValue:(float)value;
- (BOOL)isLightColor;
+ (NSImage*) image:(NSImage*) img tintedWithColor:(NSColor *)tint;
@end
......@@ -41,4 +41,62 @@
return [NSColor colorWithCalibratedRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1.0];
}
+ (NSColor*) ringDarkGrey
{
return [NSColor colorWithCalibratedRed:41/255.0 green:41/255.0 blue:41/255.0 alpha:1.0];
}
- (NSColor *)lightenColorByValue:(float)value {
float red = [self redComponent];
red += value;
float green = [self greenComponent];
green += value;
float blue = [self blueComponent];
blue += value;
return [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1.0f];
}
- (NSColor *)darkenColorByValue:(float)value {
float red = [self redComponent];
red -= value;
float green = [self greenComponent];
green -= value;
float blue = [self blueComponent];
blue -= value;
return [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1.0f];
}
- (BOOL)isLightColor {
NSInteger totalComponents = [self numberOfComponents];
bool isGreyscale = totalComponents == 2 ? YES : NO;
CGFloat sum;
if (isGreyscale) {
sum = [self redComponent];
} else {
sum = ([self redComponent]+[self greenComponent]+[self blueComponent])/3.0;
}
return (sum > 0.8);
}
+ (NSImage*) image:(NSImage*) img tintedWithColor:(NSColor *)tint
{
if (tint) {
[img lockFocus];
[tint set];
NSRect imageRect = {NSZeroPoint, [img size]};
NSRectFillUsingOperation(imageRect, NSCompositeSourceAtop);
[img unlockFocus];
}
return img;
}
@end
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment