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 22 matching lines...) Expand all Loading... |
33 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); | 33 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); |
34 (new BrowserFrame(view))->InitBrowserFrame(); | 34 (new BrowserFrame(view))->InitBrowserFrame(); |
35 return view; | 35 return view; |
36 } | 36 } |
37 | 37 |
38 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, | 38 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, |
39 const gfx::Rect& bounds) | 39 const gfx::Rect& bounds) |
40 : BrowserView(browser), | 40 : BrowserView(browser), |
41 panel_(panel), | 41 panel_(panel), |
42 bounds_(bounds), | 42 bounds_(bounds), |
43 original_height_(bounds.height()), | 43 restored_height_(bounds.height()), |
44 closed_(false), | 44 closed_(false), |
45 focused_(false), | 45 focused_(false), |
46 mouse_pressed_(false), | 46 mouse_pressed_(false), |
47 mouse_dragging_(false), | 47 mouse_dragging_(false), |
48 is_drawing_attention_(false) { | 48 is_drawing_attention_(false) { |
49 } | 49 } |
50 | 50 |
51 PanelBrowserView::~PanelBrowserView() { | 51 PanelBrowserView::~PanelBrowserView() { |
52 } | 52 } |
53 | 53 |
(...skipping 25 matching lines...) Expand all Loading... |
79 bool PanelBrowserView::CanResize() const { | 79 bool PanelBrowserView::CanResize() const { |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 bool PanelBrowserView::CanMaximize() const { | 83 bool PanelBrowserView::CanMaximize() const { |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { | 87 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { |
88 bounds_ = bounds; | 88 bounds_ = bounds; |
| 89 if (panel_->expansion_state() == Panel::EXPANDED) |
| 90 restored_height_ = bounds.height(); |
89 | 91 |
90 //// No animation if the panel is being dragged. | 92 //// No animation if the panel is being dragged. |
91 if (mouse_dragging_) { | 93 if (mouse_dragging_) { |
92 ::BrowserView::SetBounds(bounds); | 94 ::BrowserView::SetBounds(bounds); |
93 return; | 95 return; |
94 } | 96 } |
95 | 97 |
96 animation_start_bounds_ = GetBounds(); | 98 animation_start_bounds_ = GetBounds(); |
97 | 99 |
98 if (!bounds_animator_.get()) { | 100 if (!bounds_animator_.get()) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 185 |
184 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { | 186 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { |
185 SetBounds(bounds); | 187 SetBounds(bounds); |
186 } | 188 } |
187 | 189 |
188 void PanelBrowserView::OnPanelExpansionStateChanged( | 190 void PanelBrowserView::OnPanelExpansionStateChanged( |
189 Panel::ExpansionState expansion_state) { | 191 Panel::ExpansionState expansion_state) { |
190 int height; | 192 int height; |
191 switch (expansion_state) { | 193 switch (expansion_state) { |
192 case Panel::EXPANDED: | 194 case Panel::EXPANDED: |
193 height = original_height_; | 195 height = restored_height_; |
194 break; | 196 break; |
195 case Panel::TITLE_ONLY: | 197 case Panel::TITLE_ONLY: |
196 height = GetFrameView()->NonClientTopBorderHeight(); | 198 height = GetFrameView()->NonClientTopBorderHeight(); |
197 break; | 199 break; |
198 case Panel::MINIMIZED: | 200 case Panel::MINIMIZED: |
199 height = kFullyMinimizedHeight; | 201 height = kFullyMinimizedHeight; |
200 | 202 |
201 // 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. |
202 // TODO(jianli): Need to support mouse watching in ChromeOS. | 204 // TODO(jianli): Need to support mouse watching in ChromeOS. |
203 #if defined(OS_WIN) | 205 #if defined(OS_WIN) |
204 EnsureMouseWatcherStarted(); | 206 EnsureMouseWatcherStarted(); |
205 #endif | 207 #endif |
206 break; | 208 break; |
207 default: | 209 default: |
208 NOTREACHED(); | 210 NOTREACHED(); |
209 height = original_height_; | 211 height = restored_height_; |
210 break; | 212 break; |
211 } | 213 } |
212 | 214 |
213 gfx::Rect bounds = bounds_; | 215 gfx::Rect bounds = bounds_; |
214 bounds.set_y(bounds.y() + bounds.height() - height); | 216 bounds.set_y(bounds.y() + bounds.height() - height); |
215 bounds.set_height(height); | 217 bounds.set_height(height); |
216 SetBounds(bounds); | 218 SetBounds(bounds); |
217 } | 219 } |
218 | 220 |
219 bool PanelBrowserView::ShouldBringUpPanelTitleBar(int mouse_x, | 221 bool PanelBrowserView::ShouldBringUpPanelTitleBar(int mouse_x, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // user clicks on it to mean to clear the attention. | 296 // user clicks on it to mean to clear the attention. |
295 attention_cleared_time_ = base::TimeTicks::Now(); | 297 attention_cleared_time_ = base::TimeTicks::Now(); |
296 | 298 |
297 // Bring up the title bar. | 299 // Bring up the title bar. |
298 if (panel_->expansion_state() == Panel::TITLE_ONLY) | 300 if (panel_->expansion_state() == Panel::TITLE_ONLY) |
299 panel_->SetExpansionState(Panel::EXPANDED); | 301 panel_->SetExpansionState(Panel::EXPANDED); |
300 | 302 |
301 GetFrameView()->SchedulePaint(); | 303 GetFrameView()->SchedulePaint(); |
302 } | 304 } |
303 | 305 |
| 306 gfx::Size PanelBrowserView::GetNonClientAreaSize() const { |
| 307 return GetFrameView()->NonClientAreaSize(); |
| 308 } |
| 309 |
| 310 int PanelBrowserView::GetRestoredHeight() const { |
| 311 return restored_height_; |
| 312 } |
| 313 |
| 314 void PanelBrowserView::SetRestoredHeight(int height) { |
| 315 restored_height_ = height; |
| 316 } |
| 317 |
304 Browser* PanelBrowserView::GetPanelBrowser() const { | 318 Browser* PanelBrowserView::GetPanelBrowser() const { |
305 return browser(); | 319 return browser(); |
306 } | 320 } |
307 | 321 |
308 void PanelBrowserView::DestroyPanelBrowser() { | 322 void PanelBrowserView::DestroyPanelBrowser() { |
309 DestroyBrowser(); | 323 DestroyBrowser(); |
310 } | 324 } |
311 | 325 |
312 NativePanelTesting* PanelBrowserView::GetNativePanelTesting() { | 326 NativePanelTesting* PanelBrowserView::GetNativePanelTesting() { |
313 return this; | 327 return this; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 if (!mouse_pressed_) | 384 if (!mouse_pressed_) |
371 return false; | 385 return false; |
372 mouse_pressed_ = false; | 386 mouse_pressed_ = false; |
373 | 387 |
374 if (!mouse_dragging_) | 388 if (!mouse_dragging_) |
375 cancelled = true; | 389 cancelled = true; |
376 mouse_dragging_ = false; | 390 mouse_dragging_ = false; |
377 panel_->manager()->EndDragging(cancelled); | 391 panel_->manager()->EndDragging(cancelled); |
378 return true; | 392 return true; |
379 } | 393 } |
OLD | NEW |