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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/ui/panels/panel.h" | 9 #include "chrome/browser/ui/panels/panel.h" |
10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 bool PanelBrowserView::CanResize() const { | 102 bool PanelBrowserView::CanResize() const { |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 bool PanelBrowserView::CanMaximize() const { | 106 bool PanelBrowserView::CanMaximize() const { |
107 return false; | 107 return false; |
108 } | 108 } |
109 | 109 |
110 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { | 110 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { |
111 if (bounds_ == bounds) | 111 SetPanelBounds(bounds, true); // use animation. |
112 return; | |
113 bounds_ = bounds; | |
114 | |
115 // No animation if the panel is being dragged. | |
116 if (mouse_dragging_state_ == DRAGGING_STARTED) { | |
117 ::BrowserView::SetBounds(bounds); | |
118 return; | |
119 } | |
120 | |
121 animation_start_bounds_ = GetBounds(); | |
122 | |
123 if (!bounds_animator_.get()) { | |
124 bounds_animator_.reset(new ui::SlideAnimation(this)); | |
125 bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs); | |
126 } | |
127 | |
128 if (bounds_animator_->IsShowing()) | |
129 bounds_animator_->Reset(); | |
130 bounds_animator_->Show(); | |
131 } | 112 } |
132 | 113 |
133 void PanelBrowserView::UpdateTitleBar() { | 114 void PanelBrowserView::UpdateTitleBar() { |
134 ::BrowserView::UpdateTitleBar(); | 115 ::BrowserView::UpdateTitleBar(); |
135 GetFrameView()->UpdateTitleBar(); | 116 GetFrameView()->UpdateTitleBar(); |
136 } | 117 } |
137 | 118 |
138 bool PanelBrowserView::GetSavedWindowPlacement( | 119 bool PanelBrowserView::GetSavedWindowPlacement( |
139 gfx::Rect* bounds, | 120 gfx::Rect* bounds, |
140 ui::WindowShowState* show_state) const { | 121 ui::WindowShowState* show_state) const { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 206 } |
226 | 207 |
227 void PanelBrowserView::ShowPanelInactive() { | 208 void PanelBrowserView::ShowPanelInactive() { |
228 ShowInactive(); | 209 ShowInactive(); |
229 } | 210 } |
230 | 211 |
231 gfx::Rect PanelBrowserView::GetPanelBounds() const { | 212 gfx::Rect PanelBrowserView::GetPanelBounds() const { |
232 return bounds_; | 213 return bounds_; |
233 } | 214 } |
234 | 215 |
235 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { | 216 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds, bool animate) { |
236 SetBounds(bounds); | 217 if (bounds_ == bounds) |
| 218 return; |
| 219 bounds_ = bounds; |
| 220 |
| 221 // No animation if the panel is being dragged. |
| 222 if (!animate || mouse_dragging_state_ == DRAGGING_STARTED) { |
| 223 ::BrowserView::SetBounds(bounds); |
| 224 return; |
| 225 } |
| 226 |
| 227 animation_start_bounds_ = GetBounds(); |
| 228 |
| 229 if (!bounds_animator_.get()) { |
| 230 bounds_animator_.reset(new ui::SlideAnimation(this)); |
| 231 bounds_animator_->SetSlideDuration(kSetBoundsAnimationMs); |
| 232 } |
| 233 |
| 234 if (bounds_animator_->IsShowing()) |
| 235 bounds_animator_->Reset(); |
| 236 bounds_animator_->Show(); |
237 } | 237 } |
238 | 238 |
239 void PanelBrowserView::ClosePanel() { | 239 void PanelBrowserView::ClosePanel() { |
240 Close(); | 240 Close(); |
241 } | 241 } |
242 | 242 |
243 void PanelBrowserView::ActivatePanel() { | 243 void PanelBrowserView::ActivatePanel() { |
244 Activate(); | 244 Activate(); |
245 } | 245 } |
246 | 246 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } | 556 } |
557 | 557 |
558 bool NativePanelTestingWin::IsWindowSizeKnown() const { | 558 bool NativePanelTestingWin::IsWindowSizeKnown() const { |
559 return true; | 559 return true; |
560 } | 560 } |
561 | 561 |
562 bool NativePanelTestingWin::IsAnimatingBounds() const { | 562 bool NativePanelTestingWin::IsAnimatingBounds() const { |
563 return panel_browser_view_->bounds_animator_.get() && | 563 return panel_browser_view_->bounds_animator_.get() && |
564 panel_browser_view_->bounds_animator_->is_animating(); | 564 panel_browser_view_->bounds_animator_->is_animating(); |
565 } | 565 } |
OLD | NEW |