OLD | NEW |
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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" | 23 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" |
24 #include "chrome/browser/ui/views/tabs/tab.h" | 24 #include "chrome/browser/ui/views/tabs/tab.h" |
25 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 25 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
26 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" | 26 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" |
27 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" | 27 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" |
28 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 28 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
29 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
31 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
32 #include "ui/base/accessibility/accessible_view_state.h" | 32 #include "ui/base/accessibility/accessible_view_state.h" |
33 #include "ui/base/animation/animation_container.h" | |
34 #include "ui/base/animation/throb_animation.h" | |
35 #include "ui/base/default_theme_provider.h" | 33 #include "ui/base/default_theme_provider.h" |
36 #include "ui/base/dragdrop/drag_drop_types.h" | 34 #include "ui/base/dragdrop/drag_drop_types.h" |
37 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/layout.h" | 36 #include "ui/base/layout.h" |
39 #include "ui/base/models/list_selection_model.h" | 37 #include "ui/base/models/list_selection_model.h" |
40 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/animation/animation_container.h" |
| 40 #include "ui/gfx/animation/throb_animation.h" |
41 #include "ui/gfx/canvas.h" | 41 #include "ui/gfx/canvas.h" |
42 #include "ui/gfx/image/image_skia.h" | 42 #include "ui/gfx/image/image_skia.h" |
43 #include "ui/gfx/image/image_skia_operations.h" | 43 #include "ui/gfx/image/image_skia_operations.h" |
44 #include "ui/gfx/path.h" | 44 #include "ui/gfx/path.h" |
45 #include "ui/gfx/screen.h" | 45 #include "ui/gfx/screen.h" |
46 #include "ui/gfx/size.h" | 46 #include "ui/gfx/size.h" |
47 #include "ui/views/controls/image_view.h" | 47 #include "ui/views/controls/image_view.h" |
48 #include "ui/views/mouse_watcher_view_host.h" | 48 #include "ui/views/mouse_watcher_view_host.h" |
49 #include "ui/views/view_model_utils.h" | 49 #include "ui/views/view_model_utils.h" |
50 #include "ui/views/widget/root_view.h" | 50 #include "ui/views/widget/root_view.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 | 234 |
235 // Animation delegate used when a dragged tab is released. When done sets the | 235 // Animation delegate used when a dragged tab is released. When done sets the |
236 // dragging state to false. | 236 // dragging state to false. |
237 class ResetDraggingStateDelegate | 237 class ResetDraggingStateDelegate |
238 : public views::BoundsAnimator::OwnedAnimationDelegate { | 238 : public views::BoundsAnimator::OwnedAnimationDelegate { |
239 public: | 239 public: |
240 explicit ResetDraggingStateDelegate(Tab* tab) : tab_(tab) { | 240 explicit ResetDraggingStateDelegate(Tab* tab) : tab_(tab) { |
241 } | 241 } |
242 | 242 |
243 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE { | 243 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE { |
244 tab_->set_dragging(false); | 244 tab_->set_dragging(false); |
245 } | 245 } |
246 | 246 |
247 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE { | 247 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE { |
248 tab_->set_dragging(false); | 248 tab_->set_dragging(false); |
249 } | 249 } |
250 | 250 |
251 private: | 251 private: |
252 Tab* tab_; | 252 Tab* tab_; |
253 | 253 |
254 DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate); | 254 DISALLOW_COPY_AND_ASSIGN(ResetDraggingStateDelegate); |
255 }; | 255 }; |
256 | 256 |
257 // If |dest| contains the point |point_in_source| the event handler from |dest| | 257 // If |dest| contains the point |point_in_source| the event handler from |dest| |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 /////////////////////////////////////////////////////////////////////////////// | 520 /////////////////////////////////////////////////////////////////////////////// |
521 // TabStrip::RemoveTabDelegate | 521 // TabStrip::RemoveTabDelegate |
522 // | 522 // |
523 // AnimationDelegate used when removing a tab. Does the necessary cleanup when | 523 // AnimationDelegate used when removing a tab. Does the necessary cleanup when |
524 // done. | 524 // done. |
525 class TabStrip::RemoveTabDelegate | 525 class TabStrip::RemoveTabDelegate |
526 : public views::BoundsAnimator::OwnedAnimationDelegate { | 526 : public views::BoundsAnimator::OwnedAnimationDelegate { |
527 public: | 527 public: |
528 RemoveTabDelegate(TabStrip* tab_strip, Tab* tab); | 528 RemoveTabDelegate(TabStrip* tab_strip, Tab* tab); |
529 | 529 |
530 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 530 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
531 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | 531 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
532 | 532 |
533 private: | 533 private: |
534 void CompleteRemove(); | 534 void CompleteRemove(); |
535 | 535 |
536 // When the animation completes, we send the Container a message to simulate | 536 // When the animation completes, we send the Container a message to simulate |
537 // a mouse moved event at the current mouse position. This tickles the Tab | 537 // a mouse moved event at the current mouse position. This tickles the Tab |
538 // the mouse is currently over to show the "hot" state of the close button. | 538 // the mouse is currently over to show the "hot" state of the close button. |
539 void HighlightCloseButton(); | 539 void HighlightCloseButton(); |
540 | 540 |
541 TabStrip* tabstrip_; | 541 TabStrip* tabstrip_; |
542 Tab* tab_; | 542 Tab* tab_; |
543 | 543 |
544 DISALLOW_COPY_AND_ASSIGN(RemoveTabDelegate); | 544 DISALLOW_COPY_AND_ASSIGN(RemoveTabDelegate); |
545 }; | 545 }; |
546 | 546 |
547 TabStrip::RemoveTabDelegate::RemoveTabDelegate(TabStrip* tab_strip, | 547 TabStrip::RemoveTabDelegate::RemoveTabDelegate(TabStrip* tab_strip, |
548 Tab* tab) | 548 Tab* tab) |
549 : tabstrip_(tab_strip), | 549 : tabstrip_(tab_strip), |
550 tab_(tab) { | 550 tab_(tab) { |
551 } | 551 } |
552 | 552 |
553 void TabStrip::RemoveTabDelegate::AnimationEnded( | 553 void TabStrip::RemoveTabDelegate::AnimationEnded( |
554 const ui::Animation* animation) { | 554 const gfx::Animation* animation) { |
555 CompleteRemove(); | 555 CompleteRemove(); |
556 } | 556 } |
557 | 557 |
558 void TabStrip::RemoveTabDelegate::AnimationCanceled( | 558 void TabStrip::RemoveTabDelegate::AnimationCanceled( |
559 const ui::Animation* animation) { | 559 const gfx::Animation* animation) { |
560 CompleteRemove(); | 560 CompleteRemove(); |
561 } | 561 } |
562 | 562 |
563 void TabStrip::RemoveTabDelegate::CompleteRemove() { | 563 void TabStrip::RemoveTabDelegate::CompleteRemove() { |
564 DCHECK(tab_->closing()); | 564 DCHECK(tab_->closing()); |
565 tabstrip_->RemoveAndDeleteTab(tab_); | 565 tabstrip_->RemoveAndDeleteTab(tab_); |
566 HighlightCloseButton(); | 566 HighlightCloseButton(); |
567 } | 567 } |
568 | 568 |
569 void TabStrip::RemoveTabDelegate::HighlightCloseButton() { | 569 void TabStrip::RemoveTabDelegate::HighlightCloseButton() { |
(...skipping 21 matching lines...) Expand all Loading... |
591 // static | 591 // static |
592 const int TabStrip::kMiniToNonMiniGap = 3; | 592 const int TabStrip::kMiniToNonMiniGap = 3; |
593 | 593 |
594 TabStrip::TabStrip(TabStripController* controller) | 594 TabStrip::TabStrip(TabStripController* controller) |
595 : controller_(controller), | 595 : controller_(controller), |
596 newtab_button_(NULL), | 596 newtab_button_(NULL), |
597 current_unselected_width_(Tab::GetStandardSize().width()), | 597 current_unselected_width_(Tab::GetStandardSize().width()), |
598 current_selected_width_(Tab::GetStandardSize().width()), | 598 current_selected_width_(Tab::GetStandardSize().width()), |
599 available_width_for_tabs_(-1), | 599 available_width_for_tabs_(-1), |
600 in_tab_close_(false), | 600 in_tab_close_(false), |
601 animation_container_(new ui::AnimationContainer()), | 601 animation_container_(new gfx::AnimationContainer()), |
602 bounds_animator_(this), | 602 bounds_animator_(this), |
603 layout_type_(TAB_STRIP_LAYOUT_SHRINK), | 603 layout_type_(TAB_STRIP_LAYOUT_SHRINK), |
604 adjust_layout_(false), | 604 adjust_layout_(false), |
605 reset_to_shrink_on_exit_(false), | 605 reset_to_shrink_on_exit_(false), |
606 mouse_move_count_(0), | 606 mouse_move_count_(0), |
607 immersive_style_(false) { | 607 immersive_style_(false) { |
608 Init(); | 608 Init(); |
609 } | 609 } |
610 | 610 |
611 TabStrip::~TabStrip() { | 611 TabStrip::~TabStrip() { |
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 if (!adjust_layout_) | 2712 if (!adjust_layout_) |
2713 return false; | 2713 return false; |
2714 | 2714 |
2715 #if !defined(OS_CHROMEOS) | 2715 #if !defined(OS_CHROMEOS) |
2716 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2716 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
2717 return false; | 2717 return false; |
2718 #endif | 2718 #endif |
2719 | 2719 |
2720 return true; | 2720 return true; |
2721 } | 2721 } |
OLD | NEW |