| 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 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "ui/base/animation/animation_container.h" | 29 #include "ui/base/animation/animation_container.h" |
| 30 #include "ui/base/animation/throb_animation.h" | 30 #include "ui/base/animation/throb_animation.h" |
| 31 #include "ui/base/dragdrop/drag_drop_types.h" | 31 #include "ui/base/dragdrop/drag_drop_types.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/gfx/canvas_skia.h" | 34 #include "ui/gfx/canvas_skia.h" |
| 35 #include "ui/gfx/path.h" | 35 #include "ui/gfx/path.h" |
| 36 #include "ui/gfx/skbitmap_operations.h" | 36 #include "ui/gfx/skbitmap_operations.h" |
| 37 #include "ui/gfx/size.h" | 37 #include "ui/gfx/size.h" |
| 38 #include "ui/views/controls/image_view.h" | 38 #include "ui/views/controls/image_view.h" |
| 39 #include "ui/views/mouse_watcher_view_host.h" |
| 39 #include "ui/views/widget/default_theme_provider.h" | 40 #include "ui/views/widget/default_theme_provider.h" |
| 40 #include "ui/views/widget/root_view.h" | 41 #include "ui/views/widget/root_view.h" |
| 41 #include "ui/views/widget/widget.h" | 42 #include "ui/views/widget/widget.h" |
| 42 #include "ui/views/window/non_client_view.h" | 43 #include "ui/views/window/non_client_view.h" |
| 43 | 44 |
| 44 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 45 #include "ui/base/win/hwnd_util.h" | 46 #include "ui/base/win/hwnd_util.h" |
| 46 #include "ui/views/widget/monitor_win.h" | 47 #include "ui/views/widget/monitor_win.h" |
| 47 #endif | 48 #endif |
| 48 | 49 |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 return view && view->id() == VIEW_ID_TAB ? static_cast<BaseTab*>(view) : NULL; | 723 return view && view->id() == VIEW_ID_TAB ? static_cast<BaseTab*>(view) : NULL; |
| 723 } | 724 } |
| 724 | 725 |
| 725 void TabStrip::ClickActiveTab(const BaseTab* tab) const { | 726 void TabStrip::ClickActiveTab(const BaseTab* tab) const { |
| 726 DCHECK(IsActiveTab(tab)); | 727 DCHECK(IsActiveTab(tab)); |
| 727 int index = GetModelIndexOfBaseTab(tab); | 728 int index = GetModelIndexOfBaseTab(tab); |
| 728 if (controller() && IsValidModelIndex(index)) | 729 if (controller() && IsValidModelIndex(index)) |
| 729 controller()->ClickActiveTab(index); | 730 controller()->ClickActiveTab(index); |
| 730 } | 731 } |
| 731 | 732 |
| 732 void TabStrip::MouseMovedOutOfView() { | 733 void TabStrip::MouseMovedOutOfHost() { |
| 733 ResizeLayoutTabs(); | 734 ResizeLayoutTabs(); |
| 734 } | 735 } |
| 735 | 736 |
| 736 //////////////////////////////////////////////////////////////////////////////// | 737 //////////////////////////////////////////////////////////////////////////////// |
| 737 // TabStrip, AbstractTabStripView implementation: | 738 // TabStrip, AbstractTabStripView implementation: |
| 738 | 739 |
| 739 bool TabStrip::IsTabStripEditable() const { | 740 bool TabStrip::IsTabStripEditable() const { |
| 740 return !IsDragSessionActive() && !IsActiveDropTarget(); | 741 return !IsDragSessionActive() && !IsActiveDropTarget(); |
| 741 } | 742 } |
| 742 | 743 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 void TabStrip::SetTabBoundsForDrag(const std::vector<gfx::Rect>& tab_bounds) { | 1395 void TabStrip::SetTabBoundsForDrag(const std::vector<gfx::Rect>& tab_bounds) { |
| 1395 StopAnimating(false); | 1396 StopAnimating(false); |
| 1396 DCHECK_EQ(tab_count(), static_cast<int>(tab_bounds.size())); | 1397 DCHECK_EQ(tab_count(), static_cast<int>(tab_bounds.size())); |
| 1397 for (int i = 0; i < tab_count(); ++i) | 1398 for (int i = 0; i < tab_count(); ++i) |
| 1398 base_tab_at_tab_index(i)->SetBoundsRect(tab_bounds[i]); | 1399 base_tab_at_tab_index(i)->SetBoundsRect(tab_bounds[i]); |
| 1399 } | 1400 } |
| 1400 | 1401 |
| 1401 void TabStrip::AddMessageLoopObserver() { | 1402 void TabStrip::AddMessageLoopObserver() { |
| 1402 if (!mouse_watcher_.get()) { | 1403 if (!mouse_watcher_.get()) { |
| 1403 mouse_watcher_.reset( | 1404 mouse_watcher_.reset( |
| 1404 new views::MouseWatcher(this, this, | 1405 new views::MouseWatcher( |
| 1405 gfx::Insets(0, 0, kTabStripAnimationVSlop, 0))); | 1406 new views::MouseWatcherViewHost( |
| 1407 this, gfx::Insets(0, 0, kTabStripAnimationVSlop, 0)), |
| 1408 this)); |
| 1406 } | 1409 } |
| 1407 mouse_watcher_->Start(); | 1410 mouse_watcher_->Start(); |
| 1408 } | 1411 } |
| 1409 | 1412 |
| 1410 void TabStrip::RemoveMessageLoopObserver() { | 1413 void TabStrip::RemoveMessageLoopObserver() { |
| 1411 mouse_watcher_.reset(NULL); | 1414 mouse_watcher_.reset(NULL); |
| 1412 } | 1415 } |
| 1413 | 1416 |
| 1414 gfx::Rect TabStrip::GetDropBounds(int drop_index, | 1417 gfx::Rect TabStrip::GetDropBounds(int drop_index, |
| 1415 bool drop_before, | 1418 bool drop_before, |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 ui::AnimationDelegate* TabStrip::CreateRemoveTabDelegate(BaseTab* tab) { | 1701 ui::AnimationDelegate* TabStrip::CreateRemoveTabDelegate(BaseTab* tab) { |
| 1699 return new RemoveTabDelegate(this, tab); | 1702 return new RemoveTabDelegate(this, tab); |
| 1700 } | 1703 } |
| 1701 | 1704 |
| 1702 bool TabStrip::IsPointInTab(Tab* tab, | 1705 bool TabStrip::IsPointInTab(Tab* tab, |
| 1703 const gfx::Point& point_in_tabstrip_coords) { | 1706 const gfx::Point& point_in_tabstrip_coords) { |
| 1704 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); | 1707 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); |
| 1705 View::ConvertPointToView(this, tab, &point_in_tab_coords); | 1708 View::ConvertPointToView(this, tab, &point_in_tab_coords); |
| 1706 return tab->HitTest(point_in_tab_coords); | 1709 return tab->HitTest(point_in_tab_coords); |
| 1707 } | 1710 } |
| OLD | NEW |