OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_BUTTON_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_BUTTON_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_BUTTON_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_BUTTON_COCOA_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
11 #import "chrome/browser/ui/cocoa/themed_window.h" | 11 #import "chrome/browser/ui/cocoa/themed_window.h" |
12 #import "ui/gfx/color_utils.h" | 12 #import "ui/gfx/color_utils.h" |
13 | 13 #include "ui/gfx/vector_icons_public.h" |
14 namespace gfx { | |
15 struct VectorIcon; | |
16 } | |
17 | 14 |
18 enum class ToolbarButtonImageBackgroundStyle { | 15 enum class ToolbarButtonImageBackgroundStyle { |
19 DEFAULT, | 16 DEFAULT, |
20 HOVER, | 17 HOVER, |
21 HOVER_THEMED, | 18 HOVER_THEMED, |
22 PRESSED, | 19 PRESSED, |
23 PRESSED_THEMED, | 20 PRESSED_THEMED, |
24 }; | 21 }; |
25 | 22 |
26 // NSButton subclass which handles middle mouse clicking. | 23 // NSButton subclass which handles middle mouse clicking. |
27 @interface ToolbarButton : NSButton<ThemedWindowDrawing> { | 24 @interface ToolbarButton : NSButton<ThemedWindowDrawing> { |
28 @protected | 25 @protected |
29 // The toolbar button's image, as assigned by setImage:. | 26 // The toolbar button's image, as assigned by setImage:. |
30 base::scoped_nsobject<NSImage> image_; | 27 base::scoped_nsobject<NSImage> image_; |
31 | 28 |
32 // YES when middle mouse clicks should be handled. | 29 // YES when middle mouse clicks should be handled. |
33 BOOL handleMiddleClick_; | 30 BOOL handleMiddleClick_; |
34 } | 31 } |
35 | 32 |
36 // Return the size of toolbar buttons. | 33 // Return the size of toolbar buttons. |
37 + (NSSize)toolbarButtonSize; | 34 + (NSSize)toolbarButtonSize; |
38 // Whether or not to handle the mouse middle click events. | 35 // Whether or not to handle the mouse middle click events. |
39 @property(assign, nonatomic) BOOL handleMiddleClick; | 36 @property(assign, nonatomic) BOOL handleMiddleClick; |
40 // Override point for subclasses to return their vector icon. | 37 // Override point for subclasses to return their vector icon id. |
41 - (const gfx::VectorIcon*)vectorIcon; | 38 - (gfx::VectorIconId)vectorIconId; |
42 // Override point for subclasses to return their vector icon color. | 39 // Override point for subclasses to return their vector icon color. |
43 - (SkColor)vectorIconColor:(BOOL)themeIsDark; | 40 - (SkColor)vectorIconColor:(BOOL)themeIsDark; |
44 // When in Material Design mode, sets the images for each of the ToolbarButton's | 41 // When in Material Design mode, sets the images for each of the ToolbarButton's |
45 // states from the specified image. | 42 // states from the specified image. |
46 - (void)setImage:(NSImage*)anImage; | 43 - (void)setImage:(NSImage*)anImage; |
47 // Resets the images for each of the ToolbarButton's states from its vector icon | 44 // Resets the images for each of the ToolbarButton's states from its vector icon |
48 // id or its main image. Should only be called when in Material Design mode. | 45 // id or its main image. Should only be called when in Material Design mode. |
49 - (void)resetButtonStateImages; | 46 - (void)resetButtonStateImages; |
50 @end | 47 @end |
51 | 48 |
52 @interface ToolbarButton (ExposedForTesting) | 49 @interface ToolbarButton (ExposedForTesting) |
53 - (BOOL)shouldHandleEvent:(NSEvent*)theEvent; | 50 - (BOOL)shouldHandleEvent:(NSEvent*)theEvent; |
54 @end | 51 @end |
55 | 52 |
56 #endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_BUTTON_COCOA_H_ | 53 #endif // CHROME_BROWSER_UI_COCOA_TOOLBAR_TOOLBAR_BUTTON_COCOA_H_ |
OLD | NEW |