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_IMAGE_BUTTON_CELL_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
6 #define CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ | 6 #define CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 @optional | 29 @optional |
30 // Sent from an ImageButtonCell to its view when the mouse enters or exits the | 30 // Sent from an ImageButtonCell to its view when the mouse enters or exits the |
31 // cell. | 31 // cell. |
32 - (void)mouseInsideStateDidChange:(BOOL)isInside; | 32 - (void)mouseInsideStateDidChange:(BOOL)isInside; |
33 @end | 33 @end |
34 | 34 |
35 // A button cell that can disable a different image for each possible button | 35 // A button cell that can disable a different image for each possible button |
36 // state. Images are specified by image IDs. | 36 // state. Images are specified by image IDs. |
37 @interface ImageButtonCell : NSButtonCell { | 37 @interface ImageButtonCell : NSButtonCell { |
38 @private | 38 @private |
39 scoped_nsobject<NSImage> image_[image_button_cell::kButtonStateCount]; | 39 struct { |
| 40 // At most one of these two fields will be non-null. |
| 41 int imageId; |
| 42 scoped_nsobject<NSImage> image; |
| 43 } image_[image_button_cell::kButtonStateCount]; |
40 NSInteger overlayImageID_; | 44 NSInteger overlayImageID_; |
41 BOOL isMouseInside_; | 45 BOOL isMouseInside_; |
42 } | 46 } |
43 | 47 |
44 @property(assign, nonatomic) NSInteger overlayImageID; | 48 @property(assign, nonatomic) NSInteger overlayImageID; |
45 @property(assign, nonatomic) BOOL isMouseInside; | 49 @property(assign, nonatomic) BOOL isMouseInside; |
46 | 50 |
47 // Sets the image for the given button state using an image ID. | 51 // Sets the image for the given button state using an image ID. |
48 // The image will be loaded from a resource pak. | 52 // The image will be lazy loaded from a resource pak -- important because |
| 53 // this is in the hot path for startup. |
49 - (void)setImageID:(NSInteger)imageID | 54 - (void)setImageID:(NSInteger)imageID |
50 forButtonState:(image_button_cell::ButtonState)state; | 55 forButtonState:(image_button_cell::ButtonState)state; |
51 | 56 |
52 // Sets the image for the given button state using an image. | 57 // Sets the image for the given button state using an image. |
53 - (void)setImage:(NSImage*)image | 58 - (void)setImage:(NSImage*)image |
54 forButtonState:(image_button_cell::ButtonState)state; | 59 forButtonState:(image_button_cell::ButtonState)state; |
55 | 60 |
56 @end | 61 @end |
57 | 62 |
58 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ | 63 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
OLD | NEW |