UI/UX: refactor conversation view
This patch refactor elements placement on send panel and actions
panel of conversation view.
Change-Id: I2a934bc052333770af2d7cbde12ec471c55ca481
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
diff --git a/src/views/HoverButton.mm b/src/views/HoverButton.mm
index 7963527..086d2ad 100644
--- a/src/views/HoverButton.mm
+++ b/src/views/HoverButton.mm
@@ -34,7 +34,9 @@
}
-(void)mouseEntered:(NSEvent *)theEvent {
- self.bgColor = self.hoverColor;
+ if(self.isEnabled) {
+ self.bgColor = self.hoverColor;
+ }
[super setNeedsDisplay:YES];
[super mouseEntered:theEvent];
}
diff --git a/src/views/IconButton.h b/src/views/IconButton.h
index 0701497..66b5350 100644
--- a/src/views/IconButton.h
+++ b/src/views/IconButton.h
@@ -69,5 +69,12 @@
@property (nonatomic, strong) NSColor* imageColor;
+/*
+ * Image color when button is disabled
+ * default value : [[NSColor grayColor] colorWithAlphaComponent:0.3];
+ */
+
+@property (nonatomic, strong) NSColor* buttonDisableColor;
+
@end
diff --git a/src/views/IconButton.mm b/src/views/IconButton.mm
index 0223d02..96c3271 100644
--- a/src/views/IconButton.mm
+++ b/src/views/IconButton.mm
@@ -62,13 +62,21 @@
backgroundColor = self.bgColor ;
backgroundStrokeColor = self.bgColor;
if(!self.isEnabled) {
- tintColor = [[NSColor grayColor] colorWithAlphaComponent:0.3];
+ if (self.buttonDisableColor) {
+ tintColor = self.buttonDisableColor;
+ } else {
+ tintColor = [[NSColor grayColor] colorWithAlphaComponent:0.3];
+ }
}
}
else if (!self.isEnabled) {
backgroundColor = [self.bgColor colorWithAlphaComponent:0.7];
backgroundStrokeColor = [self.bgColor colorWithAlphaComponent:0.7];
- tintColor = [[NSColor grayColor] colorWithAlphaComponent:0.3];
+ if (self.buttonDisableColor) {
+ tintColor = self.buttonDisableColor;
+ } else {
+ tintColor = [[NSColor grayColor] colorWithAlphaComponent:0.3];
+ }
} else if (self.mouseDown || self.isPressed) {
if (self.highlightColor) {
backgroundColor = self.highlightColor;
@@ -84,6 +92,8 @@
backgroundStrokeColor = [self.bgColor darkenColorByValue:0.1];
}
+ backgroundStrokeColor = NSColor.clearColor;
+
//// Subframes
NSRect group = NSMakeRect(NSMinX(dirtyRect) + floor(NSWidth(dirtyRect) * 0.03333) + 0.5,
NSMinY(dirtyRect) + floor(NSHeight(dirtyRect) * 0.03333) + 0.5,
diff --git a/src/views/SendMessageCell.h b/src/views/SendMessageCell.h
deleted file mode 100644
index 635d327..0000000
--- a/src/views/SendMessageCell.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 Savoir-faire Linux Inc.
- * Author: Kateryna Kostiuk <kateryna.kostiuk@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>
-
-@protocol MessageCellDelegate
-
--(void) focusChanged;
-
-@end
-
-@interface SendMessageCell : NSTextFieldCell
-
-@property (strong, nonatomic) id <MessageCellDelegate> viewDelegate;
-
-@end
diff --git a/src/views/SendMessageCell.mm b/src/views/SendMessageCell.mm
deleted file mode 100644
index bfff307..0000000
--- a/src/views/SendMessageCell.mm
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2017 Savoir-faire Linux Inc.
- * Author: Kateryna Kostiuk <kateryna.kostiuk@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 "SendMessageCell.h"
-
-@implementation SendMessageCell
-
-- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
- NSColor* textColor;
-
- [self.viewDelegate focusChanged];
-
- [super drawWithFrame:cellFrame inView:controlView];
-}
-
-@end
-
-
diff --git a/src/views/SendMessagePanel.h b/src/views/SendMessagePanel.h
index c09ca89..0b44e83 100644
--- a/src/views/SendMessagePanel.h
+++ b/src/views/SendMessagePanel.h
@@ -18,10 +18,7 @@
*/
#import <Cocoa/Cocoa.h>
-#import "SendMessageCell.h"
-@interface SendMessagePanel : NSView <MessageCellDelegate>
-
-@property (nonatomic, strong) IBOutlet SendMessageCell* messageCell;
+@interface SendMessagePanel : NSView
@end
diff --git a/src/views/SendMessagePanel.mm b/src/views/SendMessagePanel.mm
index 06d2441..db72816 100644
--- a/src/views/SendMessagePanel.mm
+++ b/src/views/SendMessagePanel.mm
@@ -22,33 +22,14 @@
@implementation SendMessagePanel
--(void) awakeFromNib {
- self.messageCell.viewDelegate = self;
-}
-
-
- (void)drawRect:(NSRect)dirtyRect {
-
NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(40, dirtyRect.size.height)];
- [path lineToPoint:NSMakePoint(dirtyRect.size.width - 40 , dirtyRect.size.height)];
- BOOL isEditing = [(NSTextField *)[self.messageCell controlView] currentEditor] != nil;
- if(isEditing) {
- [[NSColor ringBlue]set];
- [path setLineWidth:3];
- }
- else {
-
- [[NSColor quaternaryLabelColor]set];
- [path setLineWidth:2];
- }
+ [path moveToPoint:NSMakePoint(0, dirtyRect.size.height)];
+ [path lineToPoint:NSMakePoint(dirtyRect.size.width, dirtyRect.size.height)];
+ [[NSColor quaternaryLabelColor]set];
+ [path setLineWidth:2];
[path stroke];
[super drawRect:dirtyRect];
}
--(void) focusChanged {
-
- [self setNeedsDisplay:YES];
-}
-
@end