OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base_tab_strip.h" | 5 #include "chrome/browser/views/tabs/base_tab_strip.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/view_ids.h" | 8 #include "chrome/browser/ui/view_ids.h" |
9 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" | 9 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" |
10 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" | 10 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" |
11 #include "views/widget/root_view.h" | 11 #include "views/widget/root_view.h" |
12 #include "views/window/window.h" | 12 #include "views/window/window.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 #include "views/widget/widget_win.h" | 15 #include "views/widget/widget_win.h" |
16 #endif | 16 #endif |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Animation delegate used when a dragged tab is released. When done sets the | 20 // Animation delegate used when a dragged tab is released. When done sets the |
21 // dragging state to false. | 21 // dragging state to false. |
22 class ResetDraggingStateDelegate | 22 class ResetDraggingStateDelegate |
23 : public views::BoundsAnimator::OwnedAnimationDelegate { | 23 : public views::BoundsAnimator::OwnedAnimationDelegate { |
24 public: | 24 public: |
25 explicit ResetDraggingStateDelegate(BaseTab* tab) : tab_(tab) { | 25 explicit ResetDraggingStateDelegate(BaseTab* tab) : tab_(tab) { |
26 } | 26 } |
27 | 27 |
28 virtual void AnimationEnded(const Animation* animation) { | 28 virtual void AnimationEnded(const ui::Animation* animation) { |
29 tab_->set_dragging(false); | 29 tab_->set_dragging(false); |
30 } | 30 } |
31 | 31 |
32 virtual void AnimationCanceled(const Animation* animation) { | 32 virtual void AnimationCanceled(const ui::Animation* animation) { |
33 tab_->set_dragging(false); | 33 tab_->set_dragging(false); |
34 } | 34 } |
35 | 35 |
36 private: | 36 private: |
37 BaseTab* tab_; | 37 BaseTab* tab_; |
38 | 38 |
39 DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate); | 39 DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate); |
40 }; | 40 }; |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 // AnimationDelegate used when removing a tab. Does the necessary cleanup when | 44 // AnimationDelegate used when removing a tab. Does the necessary cleanup when |
45 // done. | 45 // done. |
46 class BaseTabStrip::RemoveTabDelegate | 46 class BaseTabStrip::RemoveTabDelegate |
47 : public views::BoundsAnimator::OwnedAnimationDelegate { | 47 : public views::BoundsAnimator::OwnedAnimationDelegate { |
48 public: | 48 public: |
49 RemoveTabDelegate(BaseTabStrip* tab_strip, BaseTab* tab) | 49 RemoveTabDelegate(BaseTabStrip* tab_strip, BaseTab* tab) |
50 : tabstrip_(tab_strip), | 50 : tabstrip_(tab_strip), |
51 tab_(tab) { | 51 tab_(tab) { |
52 } | 52 } |
53 | 53 |
54 virtual void AnimationEnded(const Animation* animation) { | 54 virtual void AnimationEnded(const ui::Animation* animation) { |
55 CompleteRemove(); | 55 CompleteRemove(); |
56 } | 56 } |
57 | 57 |
58 virtual void AnimationCanceled(const Animation* animation) { | 58 virtual void AnimationCanceled(const ui::Animation* animation) { |
59 // We can be canceled for two interesting reasons: | 59 // We can be canceled for two interesting reasons: |
60 // . The tab we reference was dragged back into the tab strip. In this case | 60 // . The tab we reference was dragged back into the tab strip. In this case |
61 // we don't want to remove the tab (closing is false). | 61 // we don't want to remove the tab (closing is false). |
62 // . The drag was completed before the animation completed | 62 // . The drag was completed before the animation completed |
63 // (DestroyDraggedSourceTab). In this case we need to remove the tab | 63 // (DestroyDraggedSourceTab). In this case we need to remove the tab |
64 // (closing is true). | 64 // (closing is true). |
65 if (tab_->closing()) | 65 if (tab_->closing()) |
66 CompleteRemove(); | 66 CompleteRemove(); |
67 } | 67 } |
68 | 68 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 true); | 456 true); |
457 } | 457 } |
458 | 458 |
459 void BaseTabStrip::PrepareForAnimation() { | 459 void BaseTabStrip::PrepareForAnimation() { |
460 if (!IsDragSessionActive() && !DraggedTabController::IsAttachedTo(this)) { | 460 if (!IsDragSessionActive() && !DraggedTabController::IsAttachedTo(this)) { |
461 for (int i = 0; i < tab_count(); ++i) | 461 for (int i = 0; i < tab_count(); ++i) |
462 base_tab_at_tab_index(i)->set_dragging(false); | 462 base_tab_at_tab_index(i)->set_dragging(false); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 AnimationDelegate* BaseTabStrip::CreateRemoveTabDelegate(BaseTab* tab) { | 466 ui::AnimationDelegate* BaseTabStrip::CreateRemoveTabDelegate(BaseTab* tab) { |
467 return new RemoveTabDelegate(this, tab); | 467 return new RemoveTabDelegate(this, tab); |
468 } | 468 } |
469 | 469 |
470 void BaseTabStrip::DoLayout() { | 470 void BaseTabStrip::DoLayout() { |
471 last_layout_size_ = size(); | 471 last_layout_size_ = size(); |
472 | 472 |
473 StopAnimating(false); | 473 StopAnimating(false); |
474 | 474 |
475 GenerateIdealBounds(); | 475 GenerateIdealBounds(); |
476 | 476 |
477 for (int i = 0; i < tab_count(); ++i) | 477 for (int i = 0; i < tab_count(); ++i) |
478 tab_data_[i].tab->SetBounds(tab_data_[i].ideal_bounds); | 478 tab_data_[i].tab->SetBounds(tab_data_[i].ideal_bounds); |
479 | 479 |
480 SchedulePaint(); | 480 SchedulePaint(); |
481 } | 481 } |
OLD | NEW |