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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 original_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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 } | 172 } |
171 | 173 |
172 void PanelBrowserView::ShowPanel() { | 174 void PanelBrowserView::ShowPanel() { |
173 Show(); | 175 Show(); |
174 } | 176 } |
175 | 177 |
176 void PanelBrowserView::ShowPanelInactive() { | 178 void PanelBrowserView::ShowPanelInactive() { |
177 ShowInactive(); | 179 ShowInactive(); |
178 } | 180 } |
179 | 181 |
182 gfx::Rect PanelBrowserView::GetPanelRestoredBounds() const { | |
183 if (panel_->expansion_state() == Panel::EXPANDED) | |
184 return bounds_; | |
185 | |
186 gfx::Rect bounds(bounds_); | |
187 bounds.set_height(original_height_); | |
188 return bounds; | |
189 } | |
190 | |
180 gfx::Rect PanelBrowserView::GetPanelBounds() const { | 191 gfx::Rect PanelBrowserView::GetPanelBounds() const { |
181 return bounds_; | 192 return bounds_; |
182 } | 193 } |
183 | 194 |
195 void PanelBrowserView::SetPanelRestoredBounds(const gfx::Rect& bounds) { | |
196 if (panel_->expansion_state() == Panel::EXPANDED) { | |
197 SetBounds(bounds); | |
198 return; | |
199 } | |
200 | |
201 // We only allow changing width and height. | |
202 original_height_ = bounds.height(); | |
203 | |
204 if (bounds.width() != bounds_.width()) { | |
Dmitry Titov
2011/08/05 19:02:20
This calc should be in PanelManager, and it will b
jianli
2011/08/09 19:56:16
Done.
| |
205 gfx::Rect new_bounds(bounds_); | |
206 new_bounds.set_x(bounds_.x() + bounds_.width() - bounds.width()); | |
207 new_bounds.set_width(bounds.width()); | |
208 SetBounds(new_bounds); | |
209 } | |
210 } | |
211 | |
184 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { | 212 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { |
185 SetBounds(bounds); | 213 SetBounds(bounds); |
186 } | 214 } |
187 | 215 |
188 void PanelBrowserView::OnPanelExpansionStateChanged( | 216 void PanelBrowserView::OnPanelExpansionStateChanged( |
189 Panel::ExpansionState expansion_state) { | 217 Panel::ExpansionState expansion_state) { |
190 int height; | 218 int height; |
191 switch (expansion_state) { | 219 switch (expansion_state) { |
192 case Panel::EXPANDED: | 220 case Panel::EXPANDED: |
193 height = original_height_; | 221 height = original_height_; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 // user clicks on it to mean to clear the attention. | 318 // user clicks on it to mean to clear the attention. |
291 attention_cleared_time_ = base::TimeTicks::Now(); | 319 attention_cleared_time_ = base::TimeTicks::Now(); |
292 | 320 |
293 // Bring up the title bar. | 321 // Bring up the title bar. |
294 if (panel_->expansion_state() == Panel::TITLE_ONLY) | 322 if (panel_->expansion_state() == Panel::TITLE_ONLY) |
295 panel_->SetExpansionState(Panel::EXPANDED); | 323 panel_->SetExpansionState(Panel::EXPANDED); |
296 | 324 |
297 GetFrameView()->SchedulePaint(); | 325 GetFrameView()->SchedulePaint(); |
298 } | 326 } |
299 | 327 |
328 gfx::Size PanelBrowserView::GetNonClientAreaSize() const { | |
329 return GetFrameView()->NonClientAreaSize(); | |
330 } | |
331 | |
300 Browser* PanelBrowserView::GetPanelBrowser() const { | 332 Browser* PanelBrowserView::GetPanelBrowser() const { |
301 return browser(); | 333 return browser(); |
302 } | 334 } |
303 | 335 |
304 void PanelBrowserView::DestroyPanelBrowser() { | 336 void PanelBrowserView::DestroyPanelBrowser() { |
305 DestroyBrowser(); | 337 DestroyBrowser(); |
306 } | 338 } |
307 | 339 |
308 NativePanelTesting* PanelBrowserView::GetNativePanelTesting() { | 340 NativePanelTesting* PanelBrowserView::GetNativePanelTesting() { |
309 return this; | 341 return this; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 if (!mouse_pressed_) | 398 if (!mouse_pressed_) |
367 return false; | 399 return false; |
368 mouse_pressed_ = false; | 400 mouse_pressed_ = false; |
369 | 401 |
370 if (!mouse_dragging_) | 402 if (!mouse_dragging_) |
371 cancelled = true; | 403 cancelled = true; |
372 mouse_dragging_ = false; | 404 mouse_dragging_ = false; |
373 panel_->manager()->EndDragging(cancelled); | 405 panel_->manager()->EndDragging(cancelled); |
374 return true; | 406 return true; |
375 } | 407 } |
OLD | NEW |