OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PANELS_PANEL_TITLEBAR_VIEW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_VIEW_COCOA_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_VIEW_COCOA_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_VIEW_COCOA_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #import "base/mac/cocoa_protocols.h" | 10 #import "base/mac/cocoa_protocols.h" |
11 #import "chrome/browser/ui/cocoa/tracking_area.h" | 11 #import "chrome/browser/ui/cocoa/tracking_area.h" |
12 | 12 |
13 @class CrTrackingArea; | 13 @class CrTrackingArea; |
14 @class HoverImageButton; | 14 @class HoverImageButton; |
15 @class PanelWindowControllerCocoa; | 15 @class PanelWindowControllerCocoa; |
16 | 16 |
17 // A class that works as a custom titlebar for Panels. It is placed on top of | 17 // A class that works as a custom titlebar for Panels. It is placed on top of |
18 // the regular Cocoa titlebar. We paint theme image on it, and it's | 18 // the regular Cocoa titlebar. We paint theme image on it, and it's |
19 // the place for the close button, wrench button, page favicon, title label. | 19 // the place for the close button, page favicon, title label. |
20 // It also facilitates dragging and minimization of the panels, and changes | 20 // It also facilitates dragging and minimization of the panels, and changes |
21 // color as 'new activity' indicator. | 21 // color as 'new activity' indicator. |
22 // One way to have custom titlebar would be to use NSBorderlessWindow, | 22 // One way to have custom titlebar would be to use NSBorderlessWindow, |
23 // but it seems to affect too many other behaviors (for example, it draws shadow | 23 // but it seems to affect too many other behaviors (for example, it draws shadow |
24 // differently based on being key window) so it appears easier to simply overlay | 24 // differently based on being key window) so it appears easier to simply overlay |
25 // the standard titlebar. | 25 // the standard titlebar. |
26 | 26 |
27 // When Drag is cancelled by hitting ESC key, we may still receive | 27 // When Drag is cancelled by hitting ESC key, we may still receive |
28 // the mouseDragged events but should ignore them until the mouse button is | 28 // the mouseDragged events but should ignore them until the mouse button is |
29 // released. Use these simple states to track this condition. | 29 // released. Use these simple states to track this condition. |
(...skipping 19 matching lines...) Expand all Loading... |
49 } | 49 } |
50 - (id)initWithView:(NSView*)targetView duration:(double) duration; | 50 - (id)initWithView:(NSView*)targetView duration:(double) duration; |
51 - (void)setCurrentProgress:(NSAnimationProgress)progress; | 51 - (void)setCurrentProgress:(NSAnimationProgress)progress; |
52 @end | 52 @end |
53 | 53 |
54 @interface PanelTitlebarViewCocoa : NSView<NSAnimationDelegate> { | 54 @interface PanelTitlebarViewCocoa : NSView<NSAnimationDelegate> { |
55 @private | 55 @private |
56 IBOutlet PanelWindowControllerCocoa* controller_; | 56 IBOutlet PanelWindowControllerCocoa* controller_; |
57 IBOutlet NSView* icon_; | 57 IBOutlet NSView* icon_; |
58 IBOutlet NSTextField* title_; | 58 IBOutlet NSTextField* title_; |
59 // Since HoverImageButton manages its own alpha value, we wrap it in a subview | |
60 // so we can animate it with a fade in/fade out effect. | |
61 IBOutlet NSView* settingsButtonWrapper_; | |
62 IBOutlet HoverImageButton* settingsButton_; | |
63 // Transparent view on top of entire titlebar. It catches mouse events to | 59 // Transparent view on top of entire titlebar. It catches mouse events to |
64 // prevent window activation by the system on mouseDown. | 60 // prevent window activation by the system on mouseDown. |
65 IBOutlet NSView* overlay_; | 61 IBOutlet NSView* overlay_; |
66 NSButton* closeButton_; // Created explicitly, not from NIB. Weak, destroyed | 62 NSButton* closeButton_; // Created explicitly, not from NIB. Weak, destroyed |
67 // when view is destroyed, as a subview. | 63 // when view is destroyed, as a subview. |
68 ScopedCrTrackingArea closeButtonTrackingArea_; | 64 ScopedCrTrackingArea closeButtonTrackingArea_; |
69 PanelDragState dragState_; | 65 PanelDragState dragState_; |
70 BOOL isDrawingAttention_; | 66 BOOL isDrawingAttention_; |
71 | 67 |
72 // "Glint" animation is used in "Draw Attention" mode. | 68 // "Glint" animation is used in "Draw Attention" mode. |
(...skipping 10 matching lines...) Expand all Loading... |
83 // Capture the visible frame and full screen bounds used during drag. | 79 // Capture the visible frame and full screen bounds used during drag. |
84 // These are used to prevent dragging the panel under the system menu bar in | 80 // These are used to prevent dragging the panel under the system menu bar in |
85 // the way the system drag does. | 81 // the way the system drag does. |
86 NSRect visibleFrameForDrag_; | 82 NSRect visibleFrameForDrag_; |
87 NSRect screenBoundsForDrag_; | 83 NSRect screenBoundsForDrag_; |
88 } | 84 } |
89 | 85 |
90 // Callback from Close button. | 86 // Callback from Close button. |
91 - (void)onCloseButtonClick:(id)sender; | 87 - (void)onCloseButtonClick:(id)sender; |
92 | 88 |
93 // Callback from Settings button. | |
94 - (void)onSettingsButtonClick:(id)sender; | |
95 | |
96 // Attaches this view to the controller_'s window as a titlebar. | 89 // Attaches this view to the controller_'s window as a titlebar. |
97 - (void)attach; | 90 - (void)attach; |
98 | 91 |
99 - (void)setTitle:(NSString*)newTitle; | 92 - (void)setTitle:(NSString*)newTitle; |
100 - (void)setIcon:(NSView*)newIcon; | 93 - (void)setIcon:(NSView*)newIcon; |
101 | 94 |
102 - (NSView*)icon; | 95 - (NSView*)icon; |
103 | 96 |
104 // Should be called when size of the titlebar changes. | 97 // Should be called when size of the titlebar changes. |
105 - (void)updateCloseButtonLayout; | 98 - (void)updateCloseButtonLayout; |
106 - (void)updateIconAndTitleLayout; | 99 - (void)updateIconAndTitleLayout; |
107 | 100 |
108 // Various events that we'll need to redraw our titlebar for. | 101 // Various events that we'll need to redraw our titlebar for. |
109 - (void)didChangeFrame:(NSNotification*)notification; | 102 - (void)didChangeFrame:(NSNotification*)notification; |
110 - (void)didChangeTheme:(NSNotification*)notification; | 103 - (void)didChangeTheme:(NSNotification*)notification; |
111 - (void)didChangeMainWindow:(NSNotification*)notification; | 104 - (void)didChangeMainWindow:(NSNotification*)notification; |
112 | 105 |
113 // Helpers to control title drag operation, called from more then one place. | 106 // Helpers to control title drag operation, called from more then one place. |
114 // |mouseLocation| is in Cocoa's screen coordinates. | 107 // |mouseLocation| is in Cocoa's screen coordinates. |
115 - (void)startDrag:(NSPoint)mouseLocation; | 108 - (void)startDrag:(NSPoint)mouseLocation; |
116 - (void)endDrag:(BOOL)cancelled; | 109 - (void)endDrag:(BOOL)cancelled; |
117 - (void)drag:(NSPoint)mouseLocation; | 110 - (void)drag:(NSPoint)mouseLocation; |
118 | 111 |
119 // Update the visibility of settings button. | |
120 - (void)updateSettingsButtonVisibility:(BOOL)mouseOverWindow; | |
121 - (void)checkMouseAndUpdateSettingsButtonVisibility; | |
122 | |
123 // Draw Attention methods - change appearance of titlebar to attract user. | 112 // Draw Attention methods - change appearance of titlebar to attract user. |
124 - (void)drawAttention; | 113 - (void)drawAttention; |
125 - (void)stopDrawingAttention; | 114 - (void)stopDrawingAttention; |
126 - (BOOL)isDrawingAttention; | 115 - (BOOL)isDrawingAttention; |
127 - (void)startGlintAnimation; | 116 - (void)startGlintAnimation; |
128 - (void)restartGlintAnimation:(NSTimer*)timer; | 117 - (void)restartGlintAnimation:(NSTimer*)timer; |
129 - (void)stopGlintAnimation; | 118 - (void)stopGlintAnimation; |
130 | 119 |
131 // Returns width of titlebar when shown in "icon only" mode. | 120 // Returns width of titlebar when shown in "icon only" mode. |
132 - (int)iconOnlyWidthInScreenCoordinates; | 121 - (int)iconOnlyWidthInScreenCoordinates; |
(...skipping 15 matching lines...) Expand all Loading... |
148 - (void)pressLeftMouseButtonTitlebar:(NSPoint)mouseLocation | 137 - (void)pressLeftMouseButtonTitlebar:(NSPoint)mouseLocation |
149 modifiers:(int)modifierFlags; | 138 modifiers:(int)modifierFlags; |
150 - (void)releaseLeftMouseButtonTitlebar:(int)modifierFlags; | 139 - (void)releaseLeftMouseButtonTitlebar:(int)modifierFlags; |
151 - (void)dragTitlebar:(NSPoint)mouseLocation; | 140 - (void)dragTitlebar:(NSPoint)mouseLocation; |
152 - (void)cancelDragTitlebar; | 141 - (void)cancelDragTitlebar; |
153 - (void)finishDragTitlebar; | 142 - (void)finishDragTitlebar; |
154 | 143 |
155 @end // @interface PanelTitlebarViewCocoa(TestingAPI) | 144 @end // @interface PanelTitlebarViewCocoa(TestingAPI) |
156 | 145 |
157 #endif // CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_VIEW_COCOA_H_ | 146 #endif // CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_VIEW_COCOA_H_ |
OLD | NEW |