| 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_GRADIENT_BUTTON_CELL_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_GRADIENT_BUTTON_CELL_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_GRADIENT_BUTTON_CELL_H_ | 6 #define CHROME_BROWSER_UI_COCOA_GRADIENT_BUTTON_CELL_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 typedef enum { | 41 typedef enum { |
| 42 // Stable states. | 42 // Stable states. |
| 43 kPulsedOn, | 43 kPulsedOn, |
| 44 kPulsedOff, | 44 kPulsedOff, |
| 45 // In motion which will end in a stable state. | 45 // In motion which will end in a stable state. |
| 46 kPulsingOn, | 46 kPulsingOn, |
| 47 kPulsingOff, | 47 kPulsingOff, |
| 48 // Continuously illuminated, used to highlight buttons. | 48 // Continuously illuminated, used to highlight buttons. |
| 49 kPulsingStuckOn, | 49 kPulsingStuckOn, |
| 50 } PulseState; | 50 } PulseState; |
| 51 | |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 | 53 |
| 55 @interface GradientButtonCell : NSButtonCell { | 54 @interface GradientButtonCell : NSButtonCell { |
| 56 @private | 55 @private |
| 57 // Custom drawing means we need to perform our own mouse tracking if | 56 // Custom drawing means we need to perform our own mouse tracking if |
| 58 // the cell is setShowsBorderOnlyWhileMouseInside:YES. | 57 // the cell is setShowsBorderOnlyWhileMouseInside:YES. |
| 59 BOOL isMouseInside_; | 58 BOOL isMouseInside_; |
| 60 base::scoped_nsobject<NSTrackingArea> trackingArea_; | 59 base::scoped_nsobject<NSTrackingArea> trackingArea_; |
| 61 BOOL shouldTheme_; | 60 BOOL shouldTheme_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 83 // Let the view know when the mouse moves in and out. A timer will update | 82 // Let the view know when the mouse moves in and out. A timer will update |
| 84 // the current hoverAlpha_ based on these events. | 83 // the current hoverAlpha_ based on these events. |
| 85 - (void)setMouseInside:(BOOL)flag animate:(BOOL)animate; | 84 - (void)setMouseInside:(BOOL)flag animate:(BOOL)animate; |
| 86 | 85 |
| 87 // Gets the path which tightly bounds the outside of the button. This is needed | 86 // Gets the path which tightly bounds the outside of the button. This is needed |
| 88 // to produce images of clear buttons which only include the area inside, since | 87 // to produce images of clear buttons which only include the area inside, since |
| 89 // the background of the button is drawn by someone else. | 88 // the background of the button is drawn by someone else. |
| 90 - (NSBezierPath*)clipPathForFrame:(NSRect)cellFrame | 89 - (NSBezierPath*)clipPathForFrame:(NSRect)cellFrame |
| 91 inView:(NSView*)controlView; | 90 inView:(NSView*)controlView; |
| 92 | 91 |
| 92 // Returns the amount by which the control frame is inset on all sides for |
| 93 // drawing. |
| 94 - (CGFloat)insetInView:(NSView*)controlView; |
| 95 |
| 93 // Turn on or off pulse sticking. When turning off sticking, leave our pulse | 96 // Turn on or off pulse sticking. When turning off sticking, leave our pulse |
| 94 // state in the correct ending position for our isMouseInside_ property. Public | 97 // state in the correct ending position for our isMouseInside_ property. Public |
| 95 // since it's called from the bookmark bubble. | 98 // since it's called from the bookmark bubble. |
| 96 - (void)setPulseIsStuckOn:(BOOL)continuous; | 99 - (void)setPulseIsStuckOn:(BOOL)continuous; |
| 97 | 100 |
| 98 // Returns continuous pulse state. | 101 // Returns continuous pulse state. |
| 99 - (BOOL)isPulseStuckOn; | 102 - (BOOL)isPulseStuckOn; |
| 100 | 103 |
| 101 // Safely stop continuous pulsing by turning off all timers. | 104 // Safely stop continuous pulsing by turning off all timers. |
| 102 // May leave the cell in an odd state. | 105 // May leave the cell in an odd state. |
| 103 // Needed by an owning control's dealloc routine. | 106 // Needed by an owning control's dealloc routine. |
| 104 - (void)safelyStopPulsing; | 107 - (void)safelyStopPulsing; |
| 105 | 108 |
| 106 // Actually fetches current mouse position and does a hit test. | 109 // Actually fetches current mouse position and does a hit test. |
| 107 - (BOOL)isMouseReallyInside; | 110 - (BOOL)isMouseReallyInside; |
| 108 | 111 |
| 109 // Returns the offset of the start of the text in the cell. | |
| 110 - (CGFloat)textStartXOffset; | |
| 111 | |
| 112 // Defines the top offset of text within the cell. Used by drawTitle and can | 112 // Defines the top offset of text within the cell. Used by drawTitle and can |
| 113 // be overriden by objects that inherit this class for placement of text. | 113 // be overriden by objects that inherit this class for placement of text. |
| 114 - (int)verticalTextOffset; | 114 - (int)verticalTextOffset; |
| 115 | 115 |
| 116 // The amount by which the gradient button cell should nudge the path used to | 116 // The amount by which the gradient button cell should nudge the path used to |
| 117 // draw the hover (and pressed) state background path. | 117 // draw the hover (and pressed) state background path. |
| 118 - (CGFloat)hoverBackgroundVerticalOffsetInControlView:(NSView*)controlView; | 118 - (CGFloat)hoverBackgroundVerticalOffsetInControlView:(NSView*)controlView; |
| 119 | 119 |
| 120 // Returns YES if the cell's tag indicates a Material Design button type. | 120 // Returns YES if the cell's tag indicates a Material Design button type. |
| 121 - (BOOL)isMaterialDesignButtonType; | 121 - (BOOL)isMaterialDesignButtonType; |
| 122 | 122 |
| 123 @property(assign, nonatomic) CGFloat hoverAlpha; | 123 @property(assign, nonatomic) CGFloat hoverAlpha; |
| 124 | 124 |
| 125 // An image that will be drawn after the normal content of the button cell, | 125 // An image that will be drawn after the normal content of the button cell, |
| 126 // overlaying it. Never themed. | 126 // overlaying it. Never themed. |
| 127 @property(retain, nonatomic) NSImage* overlayImage; | 127 @property(retain, nonatomic) NSImage* overlayImage; |
| 128 | 128 |
| 129 @end | 129 @end |
| 130 | 130 |
| 131 @interface GradientButtonCell(TestingAPI) | 131 @interface GradientButtonCell(TestingAPI) |
| 132 - (BOOL)isMouseInside; | 132 - (BOOL)isMouseInside; |
| 133 - (BOOL)pulsing; | 133 - (BOOL)pulsing; |
| 134 - (gradient_button_cell::PulseState)pulseState; | 134 - (gradient_button_cell::PulseState)pulseState; |
| 135 - (void)setPulseState:(gradient_button_cell::PulseState)pstate; | 135 - (void)setPulseState:(gradient_button_cell::PulseState)pstate; |
| 136 @end | 136 @end |
| 137 | 137 |
| 138 #endif // CHROME_BROWSER_UI_COCOA_GRADIENT_BUTTON_CELL_H_ | 138 #endif // CHROME_BROWSER_UI_COCOA_GRADIENT_BUTTON_CELL_H_ |
| OLD | NEW |