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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 GetFrameView()->OnFocusChanged(focused); | 136 GetFrameView()->OnFocusChanged(focused); |
137 | 137 |
138 // Clear the attention state if the panel is on focus. | 138 // Clear the attention state if the panel is on focus. |
139 if (is_drawing_attention_ && focused_) | 139 if (is_drawing_attention_ && focused_) |
140 StopDrawingAttention(); | 140 StopDrawingAttention(); |
141 } | 141 } |
142 | 142 |
143 bool PanelBrowserView::AcceleratorPressed( | 143 bool PanelBrowserView::AcceleratorPressed( |
144 const views::Accelerator& accelerator) { | 144 const views::Accelerator& accelerator) { |
145 if (mouse_pressed_ && accelerator.key_code() == ui::VKEY_ESCAPE) { | 145 if (mouse_pressed_ && accelerator.key_code() == ui::VKEY_ESCAPE) { |
146 OnTitleBarMouseCaptureLost(); | 146 OnTitlebarMouseCaptureLost(); |
147 return true; | 147 return true; |
148 } | 148 } |
149 return BrowserView::AcceleratorPressed(accelerator); | 149 return BrowserView::AcceleratorPressed(accelerator); |
150 } | 150 } |
151 | 151 |
152 void PanelBrowserView::AnimationProgressed(const ui::Animation* animation) { | 152 void PanelBrowserView::AnimationProgressed(const ui::Animation* animation) { |
153 gfx::Rect new_bounds = bounds_animator_->CurrentValueBetween( | 153 gfx::Rect new_bounds = bounds_animator_->CurrentValueBetween( |
154 animation_start_bounds_, bounds_); | 154 animation_start_bounds_, bounds_); |
155 ::BrowserView::SetBounds(new_bounds); | 155 ::BrowserView::SetBounds(new_bounds); |
156 } | 156 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 height = original_height_; | 209 height = original_height_; |
210 break; | 210 break; |
211 } | 211 } |
212 | 212 |
213 gfx::Rect bounds = bounds_; | 213 gfx::Rect bounds = bounds_; |
214 bounds.set_y(bounds.y() + bounds.height() - height); | 214 bounds.set_y(bounds.y() + bounds.height() - height); |
215 bounds.set_height(height); | 215 bounds.set_height(height); |
216 SetBounds(bounds); | 216 SetBounds(bounds); |
217 } | 217 } |
218 | 218 |
219 bool PanelBrowserView::ShouldBringUpPanelTitleBar(int mouse_x, | 219 bool PanelBrowserView::ShouldBringUpPanelTitlebar(int mouse_x, |
220 int mouse_y) const { | 220 int mouse_y) const { |
221 // We do not want to bring up other minimized panels if the mouse is over the | 221 // We do not want to bring up other minimized panels if the mouse is over the |
222 // panel that pops up the title-bar to attract attention. | 222 // panel that pops up the title-bar to attract attention. |
223 if (is_drawing_attention_) | 223 if (is_drawing_attention_) |
224 return false; | 224 return false; |
225 | 225 |
226 return bounds_.x() <= mouse_x && mouse_x <= bounds_.right() && | 226 return bounds_.x() <= mouse_x && mouse_x <= bounds_.right() && |
227 mouse_y >= bounds_.y(); | 227 mouse_y >= bounds_.y(); |
228 } | 228 } |
229 | 229 |
(...skipping 10 matching lines...) Expand all Loading... | |
240 } | 240 } |
241 | 241 |
242 bool PanelBrowserView::IsPanelActive() const { | 242 bool PanelBrowserView::IsPanelActive() const { |
243 return IsActive(); | 243 return IsActive(); |
244 } | 244 } |
245 | 245 |
246 gfx::NativeWindow PanelBrowserView::GetNativePanelHandle() { | 246 gfx::NativeWindow PanelBrowserView::GetNativePanelHandle() { |
247 return GetNativeHandle(); | 247 return GetNativeHandle(); |
248 } | 248 } |
249 | 249 |
250 void PanelBrowserView::UpdatePanelTitleBar() { | 250 void PanelBrowserView::UpdatePanelTitlebar() { |
jianli
2011/08/12 21:34:51
ditto.
prasadt
2011/08/12 21:59:30
Done.
| |
251 UpdateTitleBar(); | 251 UpdateTitleBar(); |
252 } | 252 } |
253 | 253 |
254 void PanelBrowserView::ShowTaskManagerForPanel() { | 254 void PanelBrowserView::ShowTaskManagerForPanel() { |
255 ShowTaskManager(); | 255 ShowTaskManager(); |
256 } | 256 } |
257 | 257 |
258 FindBar* PanelBrowserView::CreatePanelFindBar() { | 258 FindBar* PanelBrowserView::CreatePanelFindBar() { |
259 return CreateFindBar(); | 259 return CreateFindBar(); |
260 } | 260 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 306 } |
307 | 307 |
308 void PanelBrowserView::DestroyPanelBrowser() { | 308 void PanelBrowserView::DestroyPanelBrowser() { |
309 DestroyBrowser(); | 309 DestroyBrowser(); |
310 } | 310 } |
311 | 311 |
312 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { | 312 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { |
313 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); | 313 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); |
314 } | 314 } |
315 | 315 |
316 bool PanelBrowserView::OnTitleBarMousePressed(const gfx::Point& location) { | 316 bool PanelBrowserView::OnTitlebarMousePressed(const gfx::Point& location) { |
317 mouse_pressed_ = true; | 317 mouse_pressed_ = true; |
318 mouse_pressed_point_ = location; | 318 mouse_pressed_point_ = location; |
319 mouse_dragging_ = false; | 319 mouse_dragging_ = false; |
320 return true; | 320 return true; |
321 } | 321 } |
322 | 322 |
323 bool PanelBrowserView::OnTitleBarMouseDragged(const gfx::Point& location) { | 323 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) { |
324 if (!mouse_pressed_) | 324 if (!mouse_pressed_) |
325 return false; | 325 return false; |
326 | 326 |
327 // We do not allow dragging vertically. | 327 // We do not allow dragging vertically. |
328 int delta_x = location.x() - mouse_pressed_point_.x(); | 328 int delta_x = location.x() - mouse_pressed_point_.x(); |
329 if (!mouse_dragging_ && ExceededDragThreshold(delta_x, 0)) { | 329 if (!mouse_dragging_ && ExceededDragThreshold(delta_x, 0)) { |
330 panel_->manager()->StartDragging(panel_.get()); | 330 panel_->manager()->StartDragging(panel_.get()); |
331 mouse_dragging_ = true; | 331 mouse_dragging_ = true; |
332 } | 332 } |
333 if (mouse_dragging_) | 333 if (mouse_dragging_) |
334 panel_->manager()->Drag(delta_x); | 334 panel_->manager()->Drag(delta_x); |
335 return true; | 335 return true; |
336 } | 336 } |
337 | 337 |
338 bool PanelBrowserView::OnTitleBarMouseReleased() { | 338 bool PanelBrowserView::OnTitlebarMouseReleased() { |
339 if (mouse_dragging_) | 339 if (mouse_dragging_) |
340 return EndDragging(false); | 340 return EndDragging(false); |
341 | 341 |
342 // Do not minimize the panel when we just clear the attention state. This is | 342 // Do not minimize the panel when we just clear the attention state. This is |
343 // a hack to prevent the panel from being minimized when the user clicks on | 343 // a hack to prevent the panel from being minimized when the user clicks on |
344 // the title-bar to clear the attention. | 344 // the title-bar to clear the attention. |
345 if (panel_->expansion_state() == Panel::EXPANDED && | 345 if (panel_->expansion_state() == Panel::EXPANDED && |
346 base::TimeTicks::Now() < attention_cleared_time_ + | 346 base::TimeTicks::Now() < attention_cleared_time_ + |
347 kSuspendMinimizeOnClickIntervalMs) { | 347 kSuspendMinimizeOnClickIntervalMs) { |
348 return true; | 348 return true; |
349 } | 349 } |
350 | 350 |
351 Panel::ExpansionState new_expansion_state = | 351 Panel::ExpansionState new_expansion_state = |
352 (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED | 352 (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED |
353 : Panel::MINIMIZED; | 353 : Panel::MINIMIZED; |
354 panel_->SetExpansionState(new_expansion_state); | 354 panel_->SetExpansionState(new_expansion_state); |
355 return true; | 355 return true; |
356 } | 356 } |
357 | 357 |
358 bool PanelBrowserView::OnTitleBarMouseCaptureLost() { | 358 bool PanelBrowserView::OnTitlebarMouseCaptureLost() { |
359 return EndDragging(true); | 359 return EndDragging(true); |
360 } | 360 } |
361 | 361 |
362 bool PanelBrowserView::EndDragging(bool cancelled) { | 362 bool PanelBrowserView::EndDragging(bool cancelled) { |
363 // Only handle clicks that started in our window. | 363 // Only handle clicks that started in our window. |
364 if (!mouse_pressed_) | 364 if (!mouse_pressed_) |
365 return false; | 365 return false; |
366 mouse_pressed_ = false; | 366 mouse_pressed_ = false; |
367 | 367 |
368 if (!mouse_dragging_) | 368 if (!mouse_dragging_) |
(...skipping 25 matching lines...) Expand all Loading... | |
394 native_panel)); | 394 native_panel)); |
395 } | 395 } |
396 | 396 |
397 NativePanelTestingWin::NativePanelTestingWin( | 397 NativePanelTestingWin::NativePanelTestingWin( |
398 PanelBrowserView* panel_browser_view) : | 398 PanelBrowserView* panel_browser_view) : |
399 panel_browser_view_(panel_browser_view) { | 399 panel_browser_view_(panel_browser_view) { |
400 } | 400 } |
401 | 401 |
402 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( | 402 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( |
403 const gfx::Point& point) { | 403 const gfx::Point& point) { |
404 panel_browser_view_->OnTitleBarMousePressed(point); | 404 panel_browser_view_->OnTitlebarMousePressed(point); |
405 } | 405 } |
406 | 406 |
407 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() { | 407 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() { |
408 panel_browser_view_->OnTitleBarMouseReleased(); | 408 panel_browser_view_->OnTitlebarMouseReleased(); |
409 } | 409 } |
410 | 410 |
411 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) { | 411 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) { |
412 gfx::Rect current_bounds = panel_browser_view_->panel()->GetRestoredBounds(); | 412 gfx::Rect current_bounds = panel_browser_view_->panel()->GetRestoredBounds(); |
413 panel_browser_view_->OnTitleBarMouseDragged(gfx::Point( | 413 panel_browser_view_->OnTitlebarMouseDragged(gfx::Point( |
414 current_bounds.x() + delta_x, current_bounds.y() + delta_y)); | 414 current_bounds.x() + delta_x, current_bounds.y() + delta_y)); |
415 } | 415 } |
416 | 416 |
417 void NativePanelTestingWin::CancelDragTitlebar() { | 417 void NativePanelTestingWin::CancelDragTitlebar() { |
418 panel_browser_view_->OnTitleBarMouseCaptureLost(); | 418 panel_browser_view_->OnTitlebarMouseCaptureLost(); |
419 } | 419 } |
420 | 420 |
421 void NativePanelTestingWin::FinishDragTitlebar() { | 421 void NativePanelTestingWin::FinishDragTitlebar() { |
422 panel_browser_view_->OnTitleBarMouseReleased(); | 422 panel_browser_view_->OnTitlebarMouseReleased(); |
423 } | 423 } |
OLD | NEW |