Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 1 | /* |
Alexandre Lision | 9fe374b | 2016-01-06 10:17:31 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 Savoir-faire Linux Inc. |
Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 19 | #import <Cocoa/Cocoa.h> |
| 20 | |
Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 21 | @interface IconButton : NSButton |
| 22 | |
| 23 | @property (nonatomic) BOOL mouseDown; |
| 24 | |
| 25 | /* |
| 26 | * This properties can be overriden in IB in User Defined Runtime Attributes |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 27 | * By default this values will be initialized in awakeFromNib |
| 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * Background color of the button |
Kateryna Kostiuk | e28a038 | 2019-10-25 16:29:08 -0400 | [diff] [blame] | 32 | * default value : [NSColor clearColor] |
Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 33 | */ |
| 34 | @property (nonatomic, strong) NSColor* bgColor; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 35 | |
| 36 | /* |
| 37 | * Background color of the button when highlighted |
Kateryna Kostiuk | e28a038 | 2019-10-25 16:29:08 -0400 | [diff] [blame] | 38 | * default value bgColor |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 39 | */ |
| 40 | @property (nonatomic, strong) NSColor* highlightColor; |
| 41 | |
| 42 | /* |
| 43 | * Background color of the button when highlighted |
| 44 | * default value : view frame width / 2 (circle) |
| 45 | */ |
Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 46 | @property (nonatomic, strong) NSNumber* cornerRadius; |
| 47 | |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 48 | /* |
Alexandre Lision | 4baba4c | 2016-02-11 13:00:57 -0500 | [diff] [blame] | 49 | * Define pressed state of the button |
| 50 | */ |
| 51 | @property (atomic, getter=isPressed) BOOL pressed; |
| 52 | |
| 53 | /* |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 54 | * Padding |
Andreas Traczyk | 252a94a | 2018-04-20 16:36:20 -0400 | [diff] [blame] | 55 | * default value : 8.0 |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 56 | */ |
| 57 | @property CGFloat imageInsets; |
| 58 | |
Kateryna Kostiuk | 3c960bf | 2017-06-01 12:11:54 -0400 | [diff] [blame] | 59 | /* |
Kateryna Kostiuk | 88a6ee8 | 2019-09-10 17:55:08 -0400 | [diff] [blame] | 60 | * Channging of image size when mouse is down |
| 61 | * default value : 0.0 |
| 62 | */ |
| 63 | @property CGFloat imageIncreaseOnClick; |
| 64 | |
| 65 | /* |
Kateryna Kostiuk | 958cd07 | 2017-07-14 15:56:35 -0400 | [diff] [blame] | 66 | * Button image color |
Kateryna Kostiuk | e28a038 | 2019-10-25 16:29:08 -0400 | [diff] [blame] | 67 | * default value : [NSColor ringDarkBlue]; |
Kateryna Kostiuk | 958cd07 | 2017-07-14 15:56:35 -0400 | [diff] [blame] | 68 | */ |
| 69 | |
| 70 | @property (nonatomic, strong) NSColor* imageColor; |
| 71 | |
Kateryna Kostiuk | db95b47 | 2018-04-17 16:35:57 -0400 | [diff] [blame] | 72 | /* |
| 73 | * Image color when button is disabled |
| 74 | * default value : [[NSColor grayColor] colorWithAlphaComponent:0.3]; |
| 75 | */ |
| 76 | |
| 77 | @property (nonatomic, strong) NSColor* buttonDisableColor; |
| 78 | |
Kateryna Kostiuk | efc665d | 2018-09-17 15:42:43 -0400 | [diff] [blame] | 79 | /* |
| 80 | * Color of the button corners. Draw circle with cornerRadius filled with bgColor |
| 81 | * and fill corner with cornerColor |
| 82 | */ |
| 83 | @property (nonatomic, strong) NSColor* cornerColor; |
Kateryna Kostiuk | 4f37d95 | 2018-12-04 13:19:17 -0500 | [diff] [blame] | 84 | /* |
| 85 | * Font size of the button title. |
| 86 | */ |
| 87 | @property CGFloat fontSize; |
| 88 | |
Kateryna Kostiuk | 88a6ee8 | 2019-09-10 17:55:08 -0400 | [diff] [blame] | 89 | -(void)startBlinkAnimationfrom:(NSColor*)startColor |
| 90 | to:(NSColor*)endColor |
| 91 | scaleFactor:(CGFloat)scaleFactor |
| 92 | duration:(CGFloat) duration; |
Kateryna Kostiuk | efc665d | 2018-09-17 15:42:43 -0400 | [diff] [blame] | 93 | |
Kateryna Kostiuk | 88a6ee8 | 2019-09-10 17:55:08 -0400 | [diff] [blame] | 94 | -(void)stopBlinkAnimation; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 95 | |
Kateryna Kostiuk | 88a6ee8 | 2019-09-10 17:55:08 -0400 | [diff] [blame] | 96 | @property BOOL animating; |
Kateryna Kostiuk | e28a038 | 2019-10-25 16:29:08 -0400 | [diff] [blame] | 97 | @property BOOL isDarkMode; |
| 98 | |
| 99 | /* |
| 100 | * Button image color when in dark mode |
| 101 | * default value : [NSColor whiteColor]; |
| 102 | */ |
| 103 | |
| 104 | @property (nonatomic, strong) NSColor* imageDarkColor; |
| 105 | |
| 106 | /* |
| 107 | * Button image color |
| 108 | * default value : [NSColor ringDarkBlue]; |
| 109 | */ |
| 110 | |
| 111 | @property (nonatomic, strong) NSColor* imageLightColor; |
| 112 | |
| 113 | /* |
| 114 | * Button highlight color when in dark mode |
| 115 | * default value : highlightColor; |
| 116 | */ |
| 117 | |
| 118 | @property (nonatomic, strong) NSColor* highlightDarkColor; |
| 119 | |
| 120 | /* |
| 121 | * Button highlight color when in light mode |
| 122 | * default value : highlightColor; |
| 123 | */ |
| 124 | |
| 125 | @property (nonatomic, strong) NSColor* highlightLightColor; |
| 126 | |
| 127 | /* |
| 128 | * Define if should draw boreder |
| 129 | * default value false; |
| 130 | */ |
| 131 | @property (atomic) BOOL shouldDrawBorder; |
| 132 | |
| 133 | /* |
| 134 | * Image coler when button pressed |
| 135 | * default value : imageColor; |
| 136 | */ |
| 137 | |
| 138 | @property (nonatomic, strong) NSColor* imagePressedColor; |
| 139 | |
| 140 | /* |
| 141 | * Image coler when button pressed in dark mode |
| 142 | * default value : imagePressedColor; |
| 143 | */ |
| 144 | |
| 145 | @property (nonatomic, strong) NSColor* imagePressedDarkColor; |
| 146 | |
| 147 | /* |
| 148 | * Image coler when button pressed in light mode |
| 149 | * default value : imagePressedColor; |
| 150 | */ |
| 151 | |
| 152 | @property (nonatomic, strong) NSColor* imagePressedLightColor; |
| 153 | |
| 154 | -(void) onAppearanceChanged; |
| 155 | |
Alexandre Lision | 6da08a8 | 2015-09-24 17:09:24 -0400 | [diff] [blame] | 156 | @end |