Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/ui/panels/panel_browser_view.cc

Issue 9403035: Refactor intra-strip panel drags by introducing PanelDragController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/native_window_notification_source.h" 9 #include "chrome/browser/native_window_notification_source.h"
10 #include "chrome/browser/ui/panels/panel.h" 10 #include "chrome/browser/ui/panels/panel.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 mouse_pressed_ = true; 442 mouse_pressed_ = true;
443 mouse_pressed_time_ = base::TimeTicks::Now(); 443 mouse_pressed_time_ = base::TimeTicks::Now();
444 mouse_dragging_state_ = NO_DRAGGING; 444 mouse_dragging_state_ = NO_DRAGGING;
445 return true; 445 return true;
446 } 446 }
447 447
448 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) { 448 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) {
449 if (!mouse_pressed_) 449 if (!mouse_pressed_)
450 return false; 450 return false;
451 451
452 if (!panel_->draggable()) 452 if (!panel_->manager()->CanDrag(panel_.get()))
453 return true; 453 return true;
454 454
455 gfx::Point last_mouse_location = mouse_location_; 455 gfx::Point last_mouse_location = mouse_location_;
456 456
457 // |location| is in the view's coordinate system. Convert it to the screen 457 // |location| is in the view's coordinate system. Convert it to the screen
458 // coordinate system. 458 // coordinate system.
459 mouse_location_ = location; 459 mouse_location_ = location;
460 views::View::ConvertPointToScreen(this, &mouse_location_); 460 views::View::ConvertPointToScreen(this, &mouse_location_);
461 461
462 int delta_x = mouse_location_.x() - last_mouse_location.x(); 462 int delta_x = mouse_location_.x() - last_mouse_location.x();
463 int delta_y = mouse_location_.y() - last_mouse_location.y(); 463 int delta_y = mouse_location_.y() - last_mouse_location.y();
464 if (mouse_dragging_state_ == NO_DRAGGING && 464 if (mouse_dragging_state_ == NO_DRAGGING &&
465 ExceededDragThreshold(delta_x, delta_y)) { 465 ExceededDragThreshold(delta_x, delta_y)) {
466 // When a drag begins, we do not want to the client area to still receive 466 // When a drag begins, we do not want to the client area to still receive
467 // the focus. 467 // the focus.
468 old_focused_view_ = GetFocusManager()->GetFocusedView(); 468 old_focused_view_ = GetFocusManager()->GetFocusedView();
469 GetFocusManager()->SetFocusedView(GetFrameView()); 469 GetFocusManager()->SetFocusedView(GetFrameView());
470 470
471 panel_->manager()->StartDragging(panel_.get()); 471 panel_->manager()->StartDragging(panel_.get());
472 mouse_dragging_state_ = DRAGGING_STARTED; 472 mouse_dragging_state_ = DRAGGING_STARTED;
473 } 473 }
474 if (mouse_dragging_state_ == DRAGGING_STARTED) 474 if (mouse_dragging_state_ == DRAGGING_STARTED)
475 panel_->manager()->Drag(delta_x); 475 panel_->manager()->Drag(delta_x, delta_y);
476 return true; 476 return true;
477 } 477 }
478 478
479 bool PanelBrowserView::OnTitlebarMouseReleased() { 479 bool PanelBrowserView::OnTitlebarMouseReleased() {
480 if (mouse_dragging_state_ == DRAGGING_STARTED) { 480 if (mouse_dragging_state_ == DRAGGING_STARTED) {
481 // When a drag ends, restore the focus. 481 // When a drag ends, restore the focus.
482 if (old_focused_view_) { 482 if (old_focused_view_) {
483 GetFocusManager()->SetFocusedView(old_focused_view_); 483 GetFocusManager()->SetFocusedView(old_focused_view_);
484 old_focused_view_ = NULL; 484 old_focused_view_ = NULL;
485 } 485 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 631 }
632 632
633 bool NativePanelTestingWin::IsWindowSizeKnown() const { 633 bool NativePanelTestingWin::IsWindowSizeKnown() const {
634 return true; 634 return true;
635 } 635 }
636 636
637 bool NativePanelTestingWin::IsAnimatingBounds() const { 637 bool NativePanelTestingWin::IsAnimatingBounds() const {
638 return panel_browser_view_->bounds_animator_.get() && 638 return panel_browser_view_->bounds_animator_.get() &&
639 panel_browser_view_->bounds_animator_->is_animating(); 639 panel_browser_view_->bounds_animator_->is_animating();
640 } 640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698