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

Side by Side Diff: chrome/browser/ui/views/bar_control_button.cc

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the *InkDropControllerFactory* tests to work with the hover timer. Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/bar_control_button.h" 5 #include "chrome/browser/ui/views/bar_control_button.h"
6 6
7 #include "ui/gfx/color_utils.h" 7 #include "ui/gfx/color_utils.h"
8 #include "ui/gfx/paint_vector_icon.h" 8 #include "ui/gfx/paint_vector_icon.h"
9 #include "ui/gfx/vector_icons_public.h" 9 #include "ui/gfx/vector_icons_public.h"
10 #include "ui/views/animation/ink_drop_animation_controller.h" 10 #include "ui/views/animation/ink_drop_animation_controller.h"
11 #include "ui/views/animation/ink_drop_animation_controller_factory.h" 11 #include "ui/views/animation/ink_drop_animation_controller_factory.h"
12 #include "ui/views/border.h" 12 #include "ui/views/border.h"
13 13
14 namespace { 14 namespace {
15 15
16 // Extra space around the buttons to increase their event target size. 16 // Extra space around the buttons to increase their event target size.
17 const int kButtonExtraTouchSize = 4; 17 const int kButtonExtraTouchSize = 4;
18 18
19 } // namespace 19 } // namespace
20 20
21 BarControlButton::BarControlButton(views::ButtonListener* listener) 21 BarControlButton::BarControlButton(views::ButtonListener* listener)
22 : views::ImageButton(listener), 22 : views::ImageButton(listener),
23 id_(gfx::VectorIconId::VECTOR_ICON_NONE), 23 id_(gfx::VectorIconId::VECTOR_ICON_NONE),
24 ink_drop_animation_controller_( 24 ink_drop_animation_controller_(
25 views::InkDropAnimationControllerFactory:: 25 views::InkDropAnimationControllerFactory::
26 CreateInkDropAnimationController(this)) { 26 CreateInkDropAnimationController(this, this)) {
27 const int kInkDropLargeSize = 32; 27 const int kInkDropLargeSize = 32;
28 const int kInkDropLargeCornerRadius = 4; 28 const int kInkDropLargeCornerRadius = 4;
29 const int kInkDropSmallSize = 24; 29 const int kInkDropSmallSize = 24;
30 const int kInkDropSmallCornerRadius = 2; 30 const int kInkDropSmallCornerRadius = 2;
31 ink_drop_animation_controller_->SetInkDropSize( 31 ink_drop_animation_controller_->SetInkDropSize(
32 gfx::Size(kInkDropLargeSize, kInkDropLargeSize), 32 gfx::Size(kInkDropLargeSize, kInkDropLargeSize),
33 kInkDropLargeCornerRadius, 33 kInkDropLargeCornerRadius,
34 gfx::Size(kInkDropSmallSize, kInkDropSmallSize), 34 gfx::Size(kInkDropSmallSize, kInkDropSmallSize),
35 kInkDropSmallCornerRadius); 35 kInkDropSmallCornerRadius);
36 } 36 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 ImageButton::OnGestureEvent(event); 122 ImageButton::OnGestureEvent(event);
123 } 123 }
124 124
125 void BarControlButton::OnMouseReleased(const ui::MouseEvent& event) { 125 void BarControlButton::OnMouseReleased(const ui::MouseEvent& event) {
126 if (!HitTestPoint(event.location())) 126 if (!HitTestPoint(event.location()))
127 ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); 127 ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN);
128 128
129 ImageButton::OnMouseReleased(event); 129 ImageButton::OnMouseReleased(event);
130 } 130 }
131 131
132 void BarControlButton::OnMouseEntered(const ui::MouseEvent& event) {
133 UpdateInkDropHoverState();
134 }
135
136 void BarControlButton::OnMouseExited(const ui::MouseEvent& event) {
137 UpdateInkDropHoverState();
138 }
139
132 void BarControlButton::NotifyClick(const ui::Event& event) { 140 void BarControlButton::NotifyClick(const ui::Event& event) {
133 ink_drop_animation_controller_->AnimateToState( 141 ink_drop_animation_controller_->AnimateToState(
134 views::InkDropState::QUICK_ACTION); 142 views::InkDropState::QUICK_ACTION);
135 143
136 ImageButton::NotifyClick(event); 144 ImageButton::NotifyClick(event);
137 } 145 }
146
147 void BarControlButton::OnEnabledChanged() {
148 UpdateInkDropHoverState();
149 }
150
151 void BarControlButton::UpdateInkDropHoverState() {
152 ink_drop_animation_controller_->SetHovered(ShouldShowInkDropHover());
153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698