| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/tabs/tab_overview_grid.h" | 5 #include "chrome/browser/views/tabs/tab_overview_grid.h" |
| 6 | 6 |
| 7 #include "chrome/browser/views/tabs/tab_overview_cell.h" | 7 #include "chrome/browser/views/tabs/tab_overview_cell.h" |
| 8 #include "chrome/browser/views/tabs/tab_overview_controller.h" | 8 #include "chrome/browser/views/tabs/tab_overview_controller.h" |
| 9 #include "chrome/browser/views/tabs/tab_overview_drag_controller.h" | 9 #include "chrome/browser/views/tabs/tab_overview_drag_controller.h" |
| 10 #include "views/screen.h" | 10 #include "views/screen.h" |
| 11 | 11 |
| 12 TabOverviewGrid::TabOverviewGrid(TabOverviewController* controller) | 12 TabOverviewGrid::TabOverviewGrid(TabOverviewController* controller) |
| 13 : controller_(controller) { | 13 : controller_(controller) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 TabOverviewGrid::~TabOverviewGrid() { | 16 TabOverviewGrid::~TabOverviewGrid() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool TabOverviewGrid::modifying_model() const { | 19 bool TabOverviewGrid::modifying_model() const { |
| 20 return drag_controller_.get() && drag_controller_->modifying_model(); | 20 return drag_controller_.get() && drag_controller_->modifying_model(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 TabOverviewCell* TabOverviewGrid::GetTabOverviewCellAt(int index) { | 23 TabOverviewCell* TabOverviewGrid::GetTabOverviewCellAt(int index) { |
| 24 return static_cast<TabOverviewCell*>(GetChildViewAt(index)); | 24 return static_cast<TabOverviewCell*>(GetChildViewAt(index)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 TabOverviewDragController* TabOverviewGrid::drag_controller() const { |
| 28 return drag_controller_.get(); |
| 29 } |
| 30 |
| 27 void TabOverviewGrid::CancelDrag() { | 31 void TabOverviewGrid::CancelDrag() { |
| 28 drag_controller_.reset(NULL); | 32 drag_controller_.reset(NULL); |
| 29 } | 33 } |
| 30 | 34 |
| 31 void TabOverviewGrid::UpdateDragController() { | 35 void TabOverviewGrid::UpdateDragController() { |
| 32 if (drag_controller_.get()) { | 36 if (drag_controller_.get()) { |
| 33 gfx::Point mouse_loc = views::Screen::GetCursorScreenPoint(); | 37 gfx::Point mouse_loc = views::Screen::GetCursorScreenPoint(); |
| 34 ConvertPointToView(NULL, this, &mouse_loc); | 38 ConvertPointToView(NULL, this, &mouse_loc); |
| 35 drag_controller_->Drag(mouse_loc); | 39 drag_controller_->Drag(mouse_loc); |
| 36 } | 40 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 drag_controller_->Drag(event.location()); | 62 drag_controller_->Drag(event.location()); |
| 59 return true; | 63 return true; |
| 60 } | 64 } |
| 61 | 65 |
| 62 void TabOverviewGrid::OnMouseReleased(const views::MouseEvent& event, | 66 void TabOverviewGrid::OnMouseReleased(const views::MouseEvent& event, |
| 63 bool canceled) { | 67 bool canceled) { |
| 64 if (!drag_controller_.get()) | 68 if (!drag_controller_.get()) |
| 65 return; | 69 return; |
| 66 | 70 |
| 67 if (canceled) | 71 if (canceled) |
| 68 drag_controller_->RevertDrag(); | 72 drag_controller_->RevertDrag(false); |
| 69 else | 73 else |
| 70 drag_controller_->CommitDrag(event.location()); | 74 drag_controller_->CommitDrag(event.location()); |
| 71 drag_controller_.reset(NULL); | 75 drag_controller_.reset(NULL); |
| 72 } | 76 } |
| 73 | 77 |
| 74 void TabOverviewGrid::AnimationEnded(const Animation* animation) { | 78 void TabOverviewGrid::AnimationEnded(const Animation* animation) { |
| 75 Grid::AnimationEnded(animation); | 79 Grid::AnimationEnded(animation); |
| 76 controller_->GridAnimationEnded(); | 80 controller_->GridAnimationEnded(); |
| 77 } | 81 } |
| 78 | 82 |
| 79 void TabOverviewGrid::AnimationProgressed(const Animation* animation) { | 83 void TabOverviewGrid::AnimationProgressed(const Animation* animation) { |
| 80 Grid::AnimationProgressed(animation); | 84 Grid::AnimationProgressed(animation); |
| 81 controller_->GridAnimationProgressed(); | 85 controller_->GridAnimationProgressed(); |
| 82 } | 86 } |
| 83 | 87 |
| 84 void TabOverviewGrid::AnimationCanceled(const Animation* animation) { | 88 void TabOverviewGrid::AnimationCanceled(const Animation* animation) { |
| 85 Grid::AnimationCanceled(animation); | 89 Grid::AnimationCanceled(animation); |
| 86 controller_->GridAnimationCanceled(); | 90 controller_->GridAnimationCanceled(); |
| 87 } | 91 } |
| OLD | NEW |