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
......@@ -101,12 +101,13 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button hidden="YES" verticalHuggingPriority="750" tag="400" translatesAutoresizingMaskIntoConstraints="NO" id="gTf-JZ-Zll" userLabel="Call Button">
<rect key="frame" x="282" y="13" width="40" height="32"/>
<button hidden="YES" verticalHuggingPriority="750" tag="400" translatesAutoresizingMaskIntoConstraints="NO" id="gTf-JZ-Zll" userLabel="Call Button" customClass="IconButton">
<rect key="frame" x="288" y="18" width="25" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="p0N-dq-1Do"/>
<constraint firstAttribute="width" constant="25" id="Rl9-Vn-KBH"/>
<constraint firstAttribute="height" constant="25" id="Wlh-yZ-5MW"/>
</constraints>
<buttonCell key="cell" type="push" bezelStyle="rounded" image="ic_action_call" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="CzS-gQ-e2I">
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="ic_action_call" imagePosition="overlaps" alignment="center" allowsMixedState="YES" transparent="YES" imageScaling="proportionallyDown" inset="2" id="CzS-gQ-e2I">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
......@@ -116,9 +117,8 @@
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="gTf-JZ-Zll" secondAttribute="trailing" constant="5" id="hD5-8g-CCJ"/>
<constraint firstAttribute="bottom" secondItem="gTf-JZ-Zll" secondAttribute="bottom" constant="20" id="iVi-g6-XyZ"/>
<constraint firstAttribute="trailing" secondItem="gTf-JZ-Zll" secondAttribute="trailing" constant="5" id="xJ7-L2-S5f"/>
<constraint firstItem="gTf-JZ-Zll" firstAttribute="centerY" secondItem="Z6G-mQ-L3J" secondAttribute="centerY" constant="-0.5" id="NWc-3P-z2v"/>
<constraint firstAttribute="trailing" secondItem="gTf-JZ-Zll" secondAttribute="trailing" constant="8" id="QCB-Ce-DCU"/>
</constraints>
<connections>
<outlet property="textField" destination="epa-Ih-aKF" id="ISN-G3-Hxj"/>
......@@ -339,7 +339,7 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="MainCell" id="b38-tQ-FEz">
<tableCellView identifier="PersonCell" id="b38-tQ-FEz" customClass="ContextualTableCellView">
<rect key="frame" x="1" y="1" width="321" height="60"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
......@@ -359,12 +359,21 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" misplaced="YES" tag="400" translatesAutoresizingMaskIntoConstraints="NO" id="D2v-io-eAw" userLabel="Call Button">
<rect key="frame" x="267" y="-1" width="40" height="32"/>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" tag="100" translatesAutoresizingMaskIntoConstraints="NO" id="akc-1J-SlS">
<rect key="frame" x="11" y="10" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="CrK-Ie-5bf"/>
<constraint firstAttribute="width" constant="40" id="UI6-4M-0El"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="uT7-b3-sLX"/>
</imageView>
<button verticalHuggingPriority="750" tag="400" translatesAutoresizingMaskIntoConstraints="NO" id="D2v-io-eAw" userLabel="Call Button" customClass="IconButton">
<rect key="frame" x="291" y="18" width="25" height="25"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="bdZ-tS-TTd"/>
<constraint firstAttribute="width" constant="25" id="GrO-uI-c46"/>
<constraint firstAttribute="height" constant="25" id="InT-OX-mtQ"/>
</constraints>
<buttonCell key="cell" type="push" bezelStyle="rounded" image="ic_action_call" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="LSh-Ow-NcP">
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="ic_action_call" imagePosition="overlaps" alignment="center" transparent="YES" imageScaling="proportionallyDown" inset="2" id="LSh-Ow-NcP">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
......@@ -372,25 +381,17 @@
<action selector="callClickedAtRow:" target="-1" id="3lv-9D-TpH"/>
</connections>
</button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" tag="100" translatesAutoresizingMaskIntoConstraints="NO" id="akc-1J-SlS">
<rect key="frame" x="11" y="10" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="CrK-Ie-5bf"/>
<constraint firstAttribute="width" constant="40" id="UI6-4M-0El"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="uT7-b3-sLX"/>
</imageView>
</subviews>
<constraints>
<constraint firstItem="D2v-io-eAw" firstAttribute="centerY" secondItem="b38-tQ-FEz" secondAttribute="centerY" id="164-he-Pvx"/>
<constraint firstItem="akc-1J-SlS" firstAttribute="leading" secondItem="b38-tQ-FEz" secondAttribute="leading" constant="11" id="5kx-HC-bBU"/>
<constraint firstItem="eGe-4R-pNq" firstAttribute="top" secondItem="b38-tQ-FEz" secondAttribute="top" constant="6" id="8Wv-Vg-yRP"/>
<constraint firstAttribute="trailing" secondItem="D2v-io-eAw" secondAttribute="trailing" constant="18" id="Bfw-dI-wa0"/>
<constraint firstAttribute="bottom" secondItem="D2v-io-eAw" secondAttribute="bottom" constant="6" id="GeS-Oz-Wwv"/>
<constraint firstAttribute="trailing" secondItem="D2v-io-eAw" secondAttribute="trailing" constant="5" id="Bfw-dI-wa0"/>
<constraint firstAttribute="bottom" secondItem="akc-1J-SlS" secondAttribute="bottom" constant="10" id="Kqx-IH-Vuf"/>
<constraint firstItem="eXn-EJ-bSE" firstAttribute="leading" secondItem="eGe-4R-pNq" secondAttribute="leading" id="bap-6e-vDW"/>
<constraint firstItem="akc-1J-SlS" firstAttribute="top" secondItem="b38-tQ-FEz" secondAttribute="top" constant="10" id="oTf-L2-iEw"/>
<constraint firstItem="eGe-4R-pNq" firstAttribute="leading" secondItem="akc-1J-SlS" secondAttribute="trailing" constant="8" id="rmh-vN-PlS"/>
<constraint firstItem="D2v-io-eAw" firstAttribute="leading" secondItem="eXn-EJ-bSE" secondAttribute="trailing" constant="8" id="sGh-EP-Jxj"/>
<constraint firstItem="D2v-io-eAw" firstAttribute="leading" secondItem="eXn-EJ-bSE" secondAttribute="trailing" constant="26" id="sGh-EP-Jxj"/>
</constraints>
<connections>
<outlet property="textField" destination="eGe-4R-pNq" id="VAp-mO-qUH"/>
......@@ -464,12 +465,9 @@
</tabViewItem>
</tabViewItems>
</tabView>
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cdA-vB-N6F">
<rect key="frame" x="255" y="614" width="40" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="cX3-9F-oek"/>
</constraints>
<buttonCell key="cell" type="push" bezelStyle="rounded" image="ic_persons" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" id="JbK-0S-rd1">
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cdA-vB-N6F" customClass="IconButton">
<rect key="frame" x="257" y="616" width="30" height="30"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="ic_persons" imagePosition="only" alignment="center" transparent="YES" imageScaling="proportionallyDown" id="JbK-0S-rd1">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
......@@ -477,12 +475,9 @@
<action selector="showContacts:" target="jrf-42-1l2" id="SBF-5u-2lU"/>
</connections>
</button>
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kNx-Cu-Fo6">
<rect key="frame" x="285" y="614" width="40" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="0ER-vH-9QB"/>
</constraints>
<buttonCell key="cell" type="push" bezelStyle="rounded" image="ic_history" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" id="IYd-UZ-6MC">
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kNx-Cu-Fo6" customClass="IconButton">
<rect key="frame" x="291" y="616" width="30" height="30"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="ic_history" imagePosition="only" alignment="center" transparent="YES" imageScaling="proportionallyDown" id="IYd-UZ-6MC">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
......@@ -539,7 +534,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="f62-JV-dgr">
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="f62-JV-dgr">
<rect key="frame" x="251" y="379" width="225" height="75"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="symbol_name" id="9ti-Q4-TAv"/>
</imageView>
......
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