Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/ui/panels/panel_browser_window_cocoa.mm

Issue 7981012: Add Mouse hover behavior to Mac Panels when minimized (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cr feedback Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" 5 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 9 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
10 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 10 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
11 #include "chrome/browser/ui/panels/panel.h" 11 #include "chrome/browser/ui/panels/panel.h"
12 #include "chrome/browser/ui/panels/panel_manager.h" 12 #include "chrome/browser/ui/panels/panel_manager.h"
13 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
13 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" 14 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
14 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" 15 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
15 #include "content/common/native_web_keyboard_event.h" 16 #include "content/common/native_web_keyboard_event.h"
16 17
17 namespace { 18 namespace {
18 19
19 // Use this instead of 0 for minimum size of a window when doing opening and 20 // Use this instead of 0 for minimum size of a window when doing opening and
20 // closing animations, since OSX window manager does not like 0-sized windows 21 // closing animations, since OSX window manager does not like 0-sized windows
21 // (according to avi@). 22 // (according to avi@).
22 const int kMinimumWindowSize = 1; 23 const int kMinimumWindowSize = 1;
(...skipping 28 matching lines...) Expand all
51 : browser_(browser), 52 : browser_(browser),
52 panel_(panel), 53 panel_(panel),
53 bounds_(bounds), 54 bounds_(bounds),
54 restored_height_(bounds.height()), 55 restored_height_(bounds.height()),
55 is_shown_(false), 56 is_shown_(false),
56 has_find_bar_(false) { 57 has_find_bar_(false) {
57 controller_ = [[PanelWindowControllerCocoa alloc] initWithBrowserWindow:this]; 58 controller_ = [[PanelWindowControllerCocoa alloc] initWithBrowserWindow:this];
58 } 59 }
59 60
60 PanelBrowserWindowCocoa::~PanelBrowserWindowCocoa() { 61 PanelBrowserWindowCocoa::~PanelBrowserWindowCocoa() {
62 PanelMouseWatcher* watcher = PanelMouseWatcher::GetInstance();
63 if (watcher->IsSubscribed(this))
64 watcher->RemoveSubscriber(this);
61 } 65 }
62 66
63 bool PanelBrowserWindowCocoa::isClosed() { 67 bool PanelBrowserWindowCocoa::isClosed() {
64 return !controller_; 68 return !controller_;
65 } 69 }
66 70
67 void PanelBrowserWindowCocoa::ShowPanel() { 71 void PanelBrowserWindowCocoa::ShowPanel() {
68 if (isClosed()) 72 if (isClosed())
69 return; 73 return;
70 74
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Store the expanded height for subsequent minimize/restore operations. 106 // Store the expanded height for subsequent minimize/restore operations.
103 if (panel_->expansion_state() == Panel::EXPANDED) 107 if (panel_->expansion_state() == Panel::EXPANDED)
104 restored_height_ = NSHeight(frame); 108 restored_height_ = NSHeight(frame);
105 } 109 }
106 110
107 void PanelBrowserWindowCocoa::OnPanelExpansionStateChanged( 111 void PanelBrowserWindowCocoa::OnPanelExpansionStateChanged(
108 Panel::ExpansionState expansion_state) { 112 Panel::ExpansionState expansion_state) {
109 int height; // New height of the Panel in screen coordinates. 113 int height; // New height of the Panel in screen coordinates.
110 switch (expansion_state) { 114 switch (expansion_state) {
111 case Panel::EXPANDED: 115 case Panel::EXPANDED:
116 PanelMouseWatcher::GetInstance()->RemoveSubscriber(this);
112 height = restored_height_; 117 height = restored_height_;
113 break; 118 break;
114 case Panel::TITLE_ONLY: 119 case Panel::TITLE_ONLY:
115 height = [controller_ titlebarHeightInScreeenCoordinates]; 120 height = [controller_ titlebarHeightInScreeenCoordinates];
116 break; 121 break;
117 case Panel::MINIMIZED: 122 case Panel::MINIMIZED:
118 height = 3; // TODO(dimich) merge with GTK patch which defines it better. 123 PanelMouseWatcher::GetInstance()->AddSubscriber(this);
124 height = PanelManager::minimized_panel_height();
119 break; 125 break;
120 default: 126 default:
121 NOTREACHED(); 127 NOTREACHED();
122 height = restored_height_; 128 height = restored_height_;
123 break; 129 break;
124 } 130 }
125 131
126 int bottom = panel_->manager()->GetBottomPositionForExpansionState( 132 int bottom = panel_->manager()->GetBottomPositionForExpansionState(
127 expansion_state); 133 expansion_state);
128 // This math is in platform-independent screen coordinates (inverted), 134 // This math is in platform-independent screen coordinates (inverted),
129 // because it's what SetPanelBounds expects. 135 // because it's what SetPanelBounds expects.
130 gfx::Rect bounds = bounds_; 136 gfx::Rect bounds = bounds_;
131 bounds.set_y(bottom - height); 137 bounds.set_y(bottom - height);
132 bounds.set_height(height); 138 bounds.set_height(height);
133 SetPanelBounds(bounds); 139 SetPanelBounds(bounds);
134 } 140 }
135 141
142 // Coordinates are in gfx coordinate system (screen, with 0,0 at the top left).
136 bool PanelBrowserWindowCocoa::ShouldBringUpPanelTitlebar(int mouse_x, 143 bool PanelBrowserWindowCocoa::ShouldBringUpPanelTitlebar(int mouse_x,
137 int mouse_y) const { 144 int mouse_y) const {
138 NOTIMPLEMENTED(); 145 return bounds_.x() <= mouse_x && mouse_x <= bounds_.right() &&
139 return false; 146 mouse_y >= bounds_.y();
140 } 147 }
141 148
142 void PanelBrowserWindowCocoa::ClosePanel() { 149 void PanelBrowserWindowCocoa::ClosePanel() {
143 if (isClosed()) 150 if (isClosed())
144 return; 151 return;
145 152
146 NSWindow* window = [controller_ window]; 153 NSWindow* window = [controller_ window];
147 [window performClose:controller_]; 154 [window performClose:controller_];
148 } 155 }
149 156
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 PanelBrowserWindowCocoa* native_panel_window_; 300 PanelBrowserWindowCocoa* native_panel_window_;
294 }; 301 };
295 302
296 // static 303 // static
297 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { 304 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) {
298 return new NativePanelTestingCocoa(native_panel); 305 return new NativePanelTestingCocoa(native_panel);
299 } 306 }
300 307
301 // static 308 // static
302 PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() { 309 PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() {
303 return NULL; 310 return PanelMouseWatcher::GetInstance();
304 } 311 }
305 312
306 NativePanelTestingCocoa::NativePanelTestingCocoa(NativePanel* native_panel) 313 NativePanelTestingCocoa::NativePanelTestingCocoa(NativePanel* native_panel)
307 : native_panel_window_(static_cast<PanelBrowserWindowCocoa*>(native_panel)) { 314 : native_panel_window_(static_cast<PanelBrowserWindowCocoa*>(native_panel)) {
308 } 315 }
309 316
310 PanelTitlebarViewCocoa* NativePanelTestingCocoa::titlebar() { 317 PanelTitlebarViewCocoa* NativePanelTestingCocoa::titlebar() {
311 return [native_panel_window_->controller_ titlebarView]; 318 return [native_panel_window_->controller_ titlebarView];
312 } 319 }
313 320
(...skipping 11 matching lines...) Expand all
325 } 332 }
326 333
327 void NativePanelTestingCocoa::CancelDragTitlebar() { 334 void NativePanelTestingCocoa::CancelDragTitlebar() {
328 [titlebar() cancelDragTitlebar]; 335 [titlebar() cancelDragTitlebar];
329 } 336 }
330 337
331 void NativePanelTestingCocoa::FinishDragTitlebar() { 338 void NativePanelTestingCocoa::FinishDragTitlebar() {
332 [titlebar() finishDragTitlebar]; 339 [titlebar() finishDragTitlebar];
333 } 340 }
334 341
342 // TODO(dimich) this method is platform-independent. Reuse it.
335 void NativePanelTestingCocoa::SetMousePositionForMinimizeRestore( 343 void NativePanelTestingCocoa::SetMousePositionForMinimizeRestore(
336 const gfx::Point& hover_point) { 344 const gfx::Point& hover_point) {
337 NOTIMPLEMENTED(); 345 PanelMouseWatcher::GetInstance()->HandleMouseMovement(hover_point);
346 MessageLoopForUI::current()->RunAllPending();
338 } 347 }
339 348
340 int NativePanelTestingCocoa::TitleOnlyHeight() const { 349 int NativePanelTestingCocoa::TitleOnlyHeight() const {
341 NOTIMPLEMENTED(); 350 return [native_panel_window_->controller_ titlebarHeightInScreeenCoordinates];
342 return -1;
343 } 351 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698