From 123ddd3a69fbdb70f09debaa2d2acf00396dead9 Mon Sep 17 00:00:00 2001 From: "msw@chromium.org" Date: Wed, 13 Nov 2013 00:45:15 +0000 Subject: Activate Views TabbedPane tabs on mouse pressed. SelectTab in OnMousePressed and for ET_GESTURE_TAP_DOWN. Eliminate the intermediate TAB_PRESSED state enum. (Inactive/Active/Hovered cover the available states) BUG=252919 TEST=View TabbedPane tabs change on mouse down. This UI is used in the website settings bubble (via the page icon), and the collected cookies dialog (from the aforementioned bubble) on Windows and ChromeOS. R=sky@chromium.org Review URL: https://codereview.chromium.org/66603013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234682 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/controls/tabbed_pane/tabbed_pane.cc | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'ui/views/controls/tabbed_pane/tabbed_pane.cc') diff --git a/ui/views/controls/tabbed_pane/tabbed_pane.cc b/ui/views/controls/tabbed_pane/tabbed_pane.cc index 65021d2..c328263 100644 --- a/ui/views/controls/tabbed_pane/tabbed_pane.cc +++ b/ui/views/controls/tabbed_pane/tabbed_pane.cc @@ -43,8 +43,6 @@ class Tab : public View { // Overridden from View: virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; - virtual void OnMouseCaptureLost() OVERRIDE; virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; @@ -55,7 +53,6 @@ class Tab : public View { enum TabState { TAB_INACTIVE, TAB_ACTIVE, - TAB_PRESSED, TAB_HOVERED, }; @@ -108,18 +105,10 @@ void Tab::SetSelected(bool selected) { } bool Tab::OnMousePressed(const ui::MouseEvent& event) { - SetState(TAB_PRESSED); - return true; -} - -void Tab::OnMouseReleased(const ui::MouseEvent& event) { - SetState(selected() ? TAB_ACTIVE : TAB_HOVERED); - if (GetLocalBounds().Contains(event.location())) + if (event.IsOnlyLeftMouseButton() && + GetLocalBounds().Contains(event.location())) tabbed_pane_->SelectTab(this); -} - -void Tab::OnMouseCaptureLost() { - SetState(TAB_INACTIVE); + return true; } void Tab::OnMouseEntered(const ui::MouseEvent& event) { @@ -133,8 +122,7 @@ void Tab::OnMouseExited(const ui::MouseEvent& event) { void Tab::OnGestureEvent(ui::GestureEvent* event) { switch (event->type()) { case ui::ET_GESTURE_TAP_DOWN: - SetState(TAB_PRESSED); - break; + // Fallthrough. case ui::ET_GESTURE_TAP: // SelectTab also sets the right tab color. tabbed_pane_->SelectTab(this); @@ -178,9 +166,6 @@ void Tab::SetState(TabState tab_state) { title_->SetEnabledColor(kTabTitleColor_Active); title_->SetFont(gfx::Font().DeriveFont(0, gfx::Font::BOLD)); break; - case TAB_PRESSED: - // No visual distinction for pressed state. - break; case TAB_HOVERED: title_->SetEnabledColor(kTabTitleColor_Hovered); title_->SetFont(gfx::Font()); -- cgit v1.1