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

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

Issue 8539035: Fix 3 panel related bugs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 void PanelBrowserView::DestroyPanelBrowser() { 375 void PanelBrowserView::DestroyPanelBrowser() {
376 DestroyBrowser(); 376 DestroyBrowser();
377 } 377 }
378 378
379 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { 379 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const {
380 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); 380 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView());
381 } 381 }
382 382
383 bool PanelBrowserView::OnTitlebarMousePressed(const gfx::Point& location) { 383 bool PanelBrowserView::OnTitlebarMousePressed(const gfx::Point& location) {
384 // |location| is in the view's coordinate system. Convert it to the screen
385 // coordinate system.
386 mouse_location_ = location;
387 views::View::ConvertPointToScreen(this, &mouse_location_);
388
384 mouse_pressed_ = true; 389 mouse_pressed_ = true;
385 mouse_pressed_point_ = location;
386 mouse_pressed_time_ = base::TimeTicks::Now(); 390 mouse_pressed_time_ = base::TimeTicks::Now();
387 mouse_dragging_state_ = NO_DRAGGING; 391 mouse_dragging_state_ = NO_DRAGGING;
388 return true; 392 return true;
389 } 393 }
390 394
391 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) { 395 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) {
392 if (!mouse_pressed_) 396 if (!mouse_pressed_)
393 return false; 397 return false;
394 398
395 int delta_x = location.x() - mouse_pressed_point_.x(); 399 gfx::Point last_mouse_location = mouse_location_;
396 int delta_y = location.y() - mouse_pressed_point_.y(); 400
401 // |location| is in the view's coordinate system. Convert it to the screen
402 // coordinate system.
403 mouse_location_ = location;
Dmitry Titov 2011/11/12 01:34:54 The way it's written it can easily look like mixin
jianli 2011/11/15 19:26:24 'location' is passed by const reference. So I can'
404 views::View::ConvertPointToScreen(this, &mouse_location_);
405
406 int delta_x = mouse_location_.x() - last_mouse_location.x();
407 int delta_y = mouse_location_.y() - last_mouse_location.y();
397 if (mouse_dragging_state_ == NO_DRAGGING && 408 if (mouse_dragging_state_ == NO_DRAGGING &&
398 ExceededDragThreshold(delta_x, delta_y)) { 409 ExceededDragThreshold(delta_x, delta_y)) {
399 // When a drag begins, we do not want to the client area to still receive 410 // When a drag begins, we do not want to the client area to still receive
400 // the focus. 411 // the focus.
401 old_focused_view_ = GetFocusManager()->GetFocusedView(); 412 old_focused_view_ = GetFocusManager()->GetFocusedView();
402 GetFocusManager()->SetFocusedView(GetFrameView()); 413 GetFocusManager()->SetFocusedView(GetFrameView());
403 414
404 panel_->manager()->StartDragging(panel_.get()); 415 panel_->manager()->StartDragging(panel_.get());
405 mouse_dragging_state_ = DRAGGING_STARTED; 416 mouse_dragging_state_ = DRAGGING_STARTED;
406 } 417 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( 509 void NativePanelTestingWin::PressLeftMouseButtonTitlebar(
499 const gfx::Point& point) { 510 const gfx::Point& point) {
500 panel_browser_view_->OnTitlebarMousePressed(point); 511 panel_browser_view_->OnTitlebarMousePressed(point);
501 } 512 }
502 513
503 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() { 514 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() {
504 panel_browser_view_->OnTitlebarMouseReleased(); 515 panel_browser_view_->OnTitlebarMouseReleased();
505 } 516 }
506 517
507 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) { 518 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) {
508 // TODO(jianli): Need a comment here that explains why we use 519 gfx::Point new_mouse_location = panel_browser_view_->mouse_location_;
509 // mouse_pressed_point_ and not current bounds as obtained by 520 new_mouse_location.Offset(delta_x, delta_y);
510 // GetRestoredBounds(). http://crbug.com/102730 521
511 panel_browser_view_->OnTitlebarMouseDragged(gfx::Point( 522 // Convert from the screen coordinate system to the view's coordinate system
512 panel_browser_view_->mouse_pressed_point_.x() + delta_x, 523 // since OnTitlebarMouseDragged takes the point in the latter.
513 panel_browser_view_->mouse_pressed_point_.y() + delta_y)); 524 views::View::ConvertPointToView(NULL, panel_browser_view_,
525 &new_mouse_location);
526 panel_browser_view_->OnTitlebarMouseDragged(new_mouse_location);
514 } 527 }
515 528
516 void NativePanelTestingWin::CancelDragTitlebar() { 529 void NativePanelTestingWin::CancelDragTitlebar() {
517 panel_browser_view_->OnTitlebarMouseCaptureLost(); 530 panel_browser_view_->OnTitlebarMouseCaptureLost();
518 } 531 }
519 532
520 void NativePanelTestingWin::FinishDragTitlebar() { 533 void NativePanelTestingWin::FinishDragTitlebar() {
521 panel_browser_view_->OnTitlebarMouseReleased(); 534 panel_browser_view_->OnTitlebarMouseReleased();
522 } 535 }
523 536
(...skipping 18 matching lines...) Expand all
542 } 555 }
543 556
544 bool NativePanelTestingWin::IsWindowSizeKnown() const { 557 bool NativePanelTestingWin::IsWindowSizeKnown() const {
545 return true; 558 return true;
546 } 559 }
547 560
548 bool NativePanelTestingWin::IsAnimatingBounds() const { 561 bool NativePanelTestingWin::IsAnimatingBounds() const {
549 return panel_browser_view_->bounds_animator_.get() && 562 return panel_browser_view_->bounds_animator_.get() &&
550 panel_browser_view_->bounds_animator_->is_animating(); 563 panel_browser_view_->bounds_animator_->is_animating();
551 } 564 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view.h ('k') | chrome/browser/ui/panels/panel_settings_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698