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

Side by Side Diff: chrome/browser/views/tabs/tab_strip.cc

Issue 215047: Gets the drop arrow to show when dragging URLs over the tab strip.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months 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
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_strip.h" 5 #include "chrome/browser/views/tabs/tab_strip.h"
6 6
7 #include "app/drag_drop_types.h" 7 #include "app/drag_drop_types.h"
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/os_exchange_data.h" 11 #include "app/os_exchange_data.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "app/slide_animation.h" 13 #include "app/slide_animation.h"
14 #if defined(OS_WIN)
15 #include "app/win_util.h"
16 #endif
17 #include "base/gfx/size.h" 14 #include "base/gfx/size.h"
18 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
19 #include "chrome/browser/browser_theme_provider.h" 16 #include "chrome/browser/browser_theme_provider.h"
20 #include "chrome/browser/metrics/user_metrics.h" 17 #include "chrome/browser/metrics/user_metrics.h"
21 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
22 #include "chrome/browser/tab_contents/tab_contents.h" 19 #include "chrome/browser/tab_contents/tab_contents.h"
23 #include "chrome/browser/tabs/tab_strip_model.h" 20 #include "chrome/browser/tabs/tab_strip_model.h"
24 #include "chrome/browser/view_ids.h" 21 #include "chrome/browser/view_ids.h"
25 #include "chrome/browser/views/tabs/dragged_tab_controller.h" 22 #include "chrome/browser/views/tabs/dragged_tab_controller.h"
26 #include "chrome/browser/views/tabs/tab.h" 23 #include "chrome/browser/views/tabs/tab.h"
27 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
28 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
29 #include "grit/theme_resources.h" 26 #include "grit/theme_resources.h"
30 #include "views/controls/image_view.h" 27 #include "views/controls/image_view.h"
31 #include "views/painter.h" 28 #include "views/painter.h"
32 #include "views/widget/default_theme_provider.h" 29 #include "views/widget/default_theme_provider.h"
33 #include "views/window/non_client_view.h" 30 #include "views/window/non_client_view.h"
34 #include "views/window/window.h" 31 #include "views/window/window.h"
35 32
33 #if defined(OS_WIN)
34 #include "app/win_util.h"
35 #include "views/widget/widget_win.h"
36 #elif defined(OS_LINUX)
37 #include "views/widget/widget_gtk.h"
38 #endif
39
36 #undef min 40 #undef min
37 #undef max 41 #undef max
38 42
39 #if defined(COMPILER_GCC) 43 #if defined(COMPILER_GCC)
40 // Squash false positive signed overflow warning in GenerateStartAndEndWidths 44 // Squash false positive signed overflow warning in GenerateStartAndEndWidths
41 // when doing 'start_tab_count < end_tab_count'. 45 // when doing 'start_tab_count < end_tab_count'.
42 #pragma GCC diagnostic ignored "-Wstrict-overflow" 46 #pragma GCC diagnostic ignored "-Wstrict-overflow"
43 #endif 47 #endif
44 48
45 using views::DropTargetEvent; 49 using views::DropTargetEvent;
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 } 1677 }
1674 1678
1675 // Reposition the window. Need to show it too as the window is initially 1679 // Reposition the window. Need to show it too as the window is initially
1676 // hidden. 1680 // hidden.
1677 1681
1678 #if defined(OS_WIN) 1682 #if defined(OS_WIN)
1679 drop_info_->arrow_window->SetWindowPos( 1683 drop_info_->arrow_window->SetWindowPos(
1680 HWND_TOPMOST, drop_bounds.x(), drop_bounds.y(), drop_bounds.width(), 1684 HWND_TOPMOST, drop_bounds.x(), drop_bounds.y(), drop_bounds.width(),
1681 drop_bounds.height(), SWP_NOACTIVATE | SWP_SHOWWINDOW); 1685 drop_bounds.height(), SWP_NOACTIVATE | SWP_SHOWWINDOW);
1682 #else 1686 #else
1683 NOTIMPLEMENTED(); 1687 drop_info_->arrow_window->SetBounds(drop_bounds);
1688 drop_info_->arrow_window->Show();
1684 #endif 1689 #endif
1685 } 1690 }
1686 1691
1687 int TabStrip::GetDropEffect(const views::DropTargetEvent& event) { 1692 int TabStrip::GetDropEffect(const views::DropTargetEvent& event) {
1688 const int source_ops = event.GetSourceOperations(); 1693 const int source_ops = event.GetSourceOperations();
1689 if (source_ops & DragDropTypes::DRAG_COPY) 1694 if (source_ops & DragDropTypes::DRAG_COPY)
1690 return DragDropTypes::DRAG_COPY; 1695 return DragDropTypes::DRAG_COPY;
1691 if (source_ops & DragDropTypes::DRAG_LINK) 1696 if (source_ops & DragDropTypes::DRAG_LINK)
1692 return DragDropTypes::DRAG_LINK; 1697 return DragDropTypes::DRAG_LINK;
1693 return DragDropTypes::DRAG_MOVE; 1698 return DragDropTypes::DRAG_MOVE;
1694 } 1699 }
1695 1700
1696 // static 1701 // static
1697 SkBitmap* TabStrip::GetDropArrowImage(bool is_down) { 1702 SkBitmap* TabStrip::GetDropArrowImage(bool is_down) {
1698 return ResourceBundle::GetSharedInstance().GetBitmapNamed( 1703 return ResourceBundle::GetSharedInstance().GetBitmapNamed(
1699 is_down ? IDR_TAB_DROP_DOWN : IDR_TAB_DROP_UP); 1704 is_down ? IDR_TAB_DROP_DOWN : IDR_TAB_DROP_UP);
1700 } 1705 }
1701 1706
1702 // TabStrip::DropInfo ---------------------------------------------------------- 1707 // TabStrip::DropInfo ----------------------------------------------------------
1703 1708
1704 TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down) 1709 TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
1705 : drop_index(drop_index), 1710 : drop_index(drop_index),
1706 drop_before(drop_before), 1711 drop_before(drop_before),
1707 point_down(point_down) { 1712 point_down(point_down) {
1713 arrow_view = new views::ImageView;
1714 arrow_view->SetImage(GetDropArrowImage(point_down));
1715
1708 #if defined(OS_WIN) 1716 #if defined(OS_WIN)
1709 arrow_window = new views::WidgetWin; 1717 arrow_window = new views::WidgetWin;
1718 arrow_window->Init(
1719 NULL,
1720 gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height));
1710 arrow_window->set_window_style(WS_POPUP); 1721 arrow_window->set_window_style(WS_POPUP);
1711 arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE | 1722 arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE |
1712 WS_EX_LAYERED | WS_EX_TRANSPARENT); 1723 WS_EX_LAYERED | WS_EX_TRANSPARENT);
1713 1724 #else
1714 arrow_view = new views::ImageView; 1725 arrow_window = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP);
1715 arrow_view->SetImage(GetDropArrowImage(point_down)); 1726 arrow_window->MakeTransparent();
1716
1717 arrow_window->Init( 1727 arrow_window->Init(
1718 NULL, 1728 NULL,
1719 gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height)); 1729 gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height));
1730 #endif
1720 arrow_window->SetContentsView(arrow_view); 1731 arrow_window->SetContentsView(arrow_view);
1721 #else
1722 NOTIMPLEMENTED();
1723 #endif
1724 } 1732 }
1725 1733
1726 TabStrip::DropInfo::~DropInfo() { 1734 TabStrip::DropInfo::~DropInfo() {
1727 // Close eventually deletes the window, which deletes arrow_view too. 1735 // Close eventually deletes the window, which deletes arrow_view too.
1728 #if defined(OS_WIN)
1729 arrow_window->Close(); 1736 arrow_window->Close();
1730 #endif
1731 } 1737 }
1732 1738
1733 /////////////////////////////////////////////////////////////////////////////// 1739 ///////////////////////////////////////////////////////////////////////////////
1734 1740
1735 // Called from: 1741 // Called from:
1736 // - BasicLayout 1742 // - BasicLayout
1737 // - Tab insertion/removal 1743 // - Tab insertion/removal
1738 // - Tab reorder 1744 // - Tab reorder
1739 void TabStrip::GenerateIdealBounds() { 1745 void TabStrip::GenerateIdealBounds() {
1740 int tab_count = GetTabCount(); 1746 int tab_count = GetTabCount();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 &TabStrip::ResizeLayoutTabs), 1948 &TabStrip::ResizeLayoutTabs),
1943 kResizeTabsTimeMs); 1949 kResizeTabsTimeMs);
1944 } 1950 }
1945 } else { 1951 } else {
1946 // Mouse moved quickly out of the tab strip and then into it again, so 1952 // Mouse moved quickly out of the tab strip and then into it again, so
1947 // cancel the timer so that the strip doesn't move when the mouse moves 1953 // cancel the timer so that the strip doesn't move when the mouse moves
1948 // back over it. 1954 // back over it.
1949 resize_layout_factory_.RevokeAll(); 1955 resize_layout_factory_.RevokeAll();
1950 } 1956 }
1951 } 1957 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/tab_strip.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698