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 #include "chrome/browser/ui/panels/panel_browser_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/panels/panel.h" | 8 #include "chrome/browser/ui/panels/panel.h" |
9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); | 30 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); |
31 (new BrowserFrame(view))->InitBrowserFrame(); | 31 (new BrowserFrame(view))->InitBrowserFrame(); |
32 return view; | 32 return view; |
33 } | 33 } |
34 | 34 |
35 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, | 35 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, |
36 const gfx::Rect& bounds) | 36 const gfx::Rect& bounds) |
37 : BrowserView(browser), | 37 : BrowserView(browser), |
38 panel_(panel), | 38 panel_(panel), |
39 bounds_(bounds), | 39 bounds_(bounds), |
40 original_height_(bounds.height()), | 40 restored_height_(bounds.height()), |
41 closed_(false), | 41 closed_(false), |
42 focused_(false), | 42 focused_(false), |
43 mouse_pressed_(false), | 43 mouse_pressed_(false), |
44 mouse_dragging_(false), | 44 mouse_dragging_(false), |
45 is_drawing_attention_(false) { | 45 is_drawing_attention_(false) { |
46 } | 46 } |
47 | 47 |
48 PanelBrowserView::~PanelBrowserView() { | 48 PanelBrowserView::~PanelBrowserView() { |
49 } | 49 } |
50 | 50 |
(...skipping 24 matching lines...) Expand all Loading... |
75 | 75 |
76 bool PanelBrowserView::CanResize() const { | 76 bool PanelBrowserView::CanResize() const { |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 bool PanelBrowserView::CanMaximize() const { | 80 bool PanelBrowserView::CanMaximize() const { |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { | 84 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { |
| 85 if (bounds_ == bounds) |
| 86 return; |
85 bounds_ = bounds; | 87 bounds_ = bounds; |
86 | 88 |
| 89 if (panel_->expansion_state() == Panel::EXPANDED) |
| 90 restored_height_ = bounds.height(); |
| 91 |
87 // No animation if the panel is being dragged. | 92 // No animation if the panel is being dragged. |
88 if (mouse_dragging_) { | 93 if (mouse_dragging_) { |
89 ::BrowserView::SetBounds(bounds); | 94 ::BrowserView::SetBounds(bounds); |
90 return; | 95 return; |
91 } | 96 } |
92 | 97 |
93 animation_start_bounds_ = GetBounds(); | 98 animation_start_bounds_ = GetBounds(); |
94 | 99 |
95 if (!bounds_animator_.get()) { | 100 if (!bounds_animator_.get()) { |
96 bounds_animator_.reset(new ui::SlideAnimation(this)); | 101 bounds_animator_.reset(new ui::SlideAnimation(this)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 185 |
181 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { | 186 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { |
182 SetBounds(bounds); | 187 SetBounds(bounds); |
183 } | 188 } |
184 | 189 |
185 void PanelBrowserView::OnPanelExpansionStateChanged( | 190 void PanelBrowserView::OnPanelExpansionStateChanged( |
186 Panel::ExpansionState expansion_state) { | 191 Panel::ExpansionState expansion_state) { |
187 int height; | 192 int height; |
188 switch (expansion_state) { | 193 switch (expansion_state) { |
189 case Panel::EXPANDED: | 194 case Panel::EXPANDED: |
190 height = original_height_; | 195 height = restored_height_; |
191 break; | 196 break; |
192 case Panel::TITLE_ONLY: | 197 case Panel::TITLE_ONLY: |
193 height = GetFrameView()->NonClientTopBorderHeight(); | 198 height = GetFrameView()->NonClientTopBorderHeight(); |
194 break; | 199 break; |
195 case Panel::MINIMIZED: | 200 case Panel::MINIMIZED: |
196 height = PanelBrowserFrameView::MinimizedPanelHeight(); | 201 height = PanelBrowserFrameView::MinimizedPanelHeight(); |
197 | 202 |
198 // Start the mouse watcher so that we can bring up the minimized panels. | 203 // Start the mouse watcher so that we can bring up the minimized panels. |
199 // TODO(jianli): Need to support mouse watching in ChromeOS. | 204 // TODO(jianli): Need to support mouse watching in ChromeOS. |
200 #if defined(OS_WIN) | 205 #if defined(OS_WIN) |
201 EnsureMouseWatcherStarted(); | 206 EnsureMouseWatcherStarted(); |
202 #endif | 207 #endif |
203 break; | 208 break; |
204 default: | 209 default: |
205 NOTREACHED(); | 210 NOTREACHED(); |
206 height = original_height_; | 211 height = restored_height_; |
207 break; | 212 break; |
208 } | 213 } |
209 | 214 |
210 int bottom = panel_->manager()->GetBottomPositionForExpansionState( | 215 int bottom = panel_->manager()->GetBottomPositionForExpansionState( |
211 expansion_state); | 216 expansion_state); |
212 gfx::Rect bounds = bounds_; | 217 gfx::Rect bounds = bounds_; |
213 bounds.set_y(bottom - height); | 218 bounds.set_y(bottom - height); |
214 bounds.set_height(height); | 219 bounds.set_height(height); |
215 SetBounds(bounds); | 220 SetBounds(bounds); |
216 } | 221 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 const NativeWebKeyboardEvent& event, | 309 const NativeWebKeyboardEvent& event, |
305 bool* is_keyboard_shortcut) { | 310 bool* is_keyboard_shortcut) { |
306 return PreHandleKeyboardEvent(event, is_keyboard_shortcut); | 311 return PreHandleKeyboardEvent(event, is_keyboard_shortcut); |
307 } | 312 } |
308 | 313 |
309 void PanelBrowserView::HandlePanelKeyboardEvent( | 314 void PanelBrowserView::HandlePanelKeyboardEvent( |
310 const NativeWebKeyboardEvent& event) { | 315 const NativeWebKeyboardEvent& event) { |
311 HandleKeyboardEvent(event); | 316 HandleKeyboardEvent(event); |
312 } | 317 } |
313 | 318 |
| 319 gfx::Size PanelBrowserView::GetNonClientAreaExtent() const { |
| 320 return GetFrameView()->NonClientAreaSize(); |
| 321 } |
| 322 |
| 323 int PanelBrowserView::GetRestoredHeight() const { |
| 324 return restored_height_; |
| 325 } |
| 326 |
| 327 void PanelBrowserView::SetRestoredHeight(int height) { |
| 328 restored_height_ = height; |
| 329 } |
| 330 |
314 Browser* PanelBrowserView::GetPanelBrowser() const { | 331 Browser* PanelBrowserView::GetPanelBrowser() const { |
315 return browser(); | 332 return browser(); |
316 } | 333 } |
317 | 334 |
318 void PanelBrowserView::DestroyPanelBrowser() { | 335 void PanelBrowserView::DestroyPanelBrowser() { |
319 DestroyBrowser(); | 336 DestroyBrowser(); |
320 } | 337 } |
321 | 338 |
322 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { | 339 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { |
323 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); | 340 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 panel_browser_view_->mouse_pressed_point_.y() + delta_y)); | 446 panel_browser_view_->mouse_pressed_point_.y() + delta_y)); |
430 } | 447 } |
431 | 448 |
432 void NativePanelTestingWin::CancelDragTitlebar() { | 449 void NativePanelTestingWin::CancelDragTitlebar() { |
433 panel_browser_view_->OnTitlebarMouseCaptureLost(); | 450 panel_browser_view_->OnTitlebarMouseCaptureLost(); |
434 } | 451 } |
435 | 452 |
436 void NativePanelTestingWin::FinishDragTitlebar() { | 453 void NativePanelTestingWin::FinishDragTitlebar() { |
437 panel_browser_view_->OnTitlebarMouseReleased(); | 454 panel_browser_view_->OnTitlebarMouseReleased(); |
438 } | 455 } |
OLD | NEW |