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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 1242573005: Added the Material Design ink drop ripple effect to the navigation buttons in the browser toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment as to why ripple was on ChromeOS only. Created 5 years, 5 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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/themes/theme_properties.h" 11 #include "chrome/browser/themes/theme_properties.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "ui/accessibility/ax_view_state.h" 13 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/models/menu_model.h" 15 #include "ui/base/models/menu_model.h"
16 #include "ui/base/resource/material_design/material_design_controller.h" 16 #include "ui/base/resource/material_design/material_design_controller.h"
17 #include "ui/base/theme_provider.h" 17 #include "ui/base/theme_provider.h"
18 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
20 #include "ui/strings/grit/ui_strings.h" 20 #include "ui/strings/grit/ui_strings.h"
21 #include "ui/views/animation/ink_drop_animation_controller.h"
21 #include "ui/views/controls/button/label_button_border.h" 22 #include "ui/views/controls/button/label_button_border.h"
22 #include "ui/views/controls/menu/menu_item_view.h" 23 #include "ui/views/controls/menu/menu_item_view.h"
23 #include "ui/views/controls/menu/menu_model_adapter.h" 24 #include "ui/views/controls/menu/menu_model_adapter.h"
24 #include "ui/views/controls/menu/menu_runner.h" 25 #include "ui/views/controls/menu/menu_runner.h"
25 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
26 27
27 ToolbarButton::ToolbarButton(views::ButtonListener* listener, 28 ToolbarButton::ToolbarButton(views::ButtonListener* listener,
28 ui::MenuModel* model) 29 ui::MenuModel* model)
29 : views::LabelButton(listener, base::string16()), 30 : views::LabelButton(listener, base::string16()),
30 model_(model), 31 model_(model),
31 menu_showing_(false), 32 menu_showing_(false),
32 y_position_on_lbuttondown_(0), 33 y_position_on_lbuttondown_(0),
33 show_menu_factory_(this) { 34 show_menu_factory_(this) {
35 #if defined(OS_CHROMEOS)
36 // The ink drop animation is only targeted at ChromeOS because there is
37 // concern it will conflict with OS level touch feedback in a bad way.
38 if (ui::MaterialDesignController::IsModeMaterial()) {
39 ink_drop_animation_controller_.reset(
40 new views::InkDropAnimationController(this));
41 layer()->SetFillsBoundsOpaquely(false);
42 image()->SetPaintToLayer(true);
43 image()->SetFillsBoundsOpaquely(false);
44 }
45 #endif // defined(OS_CHROMEOS)
46
34 set_context_menu_controller(this); 47 set_context_menu_controller(this);
35 } 48 }
36 49
37 ToolbarButton::~ToolbarButton() { 50 ToolbarButton::~ToolbarButton() {
38 } 51 }
39 52
40 void ToolbarButton::Init() { 53 void ToolbarButton::Init() {
41 SetFocusable(false); 54 SetFocusable(false);
42 SetAccessibilityFocusable(true); 55 SetAccessibilityFocusable(true);
43 image()->EnableCanvasFlippingForRTLUI(true); 56 image()->EnableCanvasFlippingForRTLUI(true);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; 154 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN;
142 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 155 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
143 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 156 state->AddStateFlag(ui::AX_STATE_HASPOPUP);
144 } 157 }
145 158
146 scoped_ptr<views::LabelButtonBorder> 159 scoped_ptr<views::LabelButtonBorder>
147 ToolbarButton::CreateDefaultBorder() const { 160 ToolbarButton::CreateDefaultBorder() const {
148 scoped_ptr<views::LabelButtonBorder> border = 161 scoped_ptr<views::LabelButtonBorder> border =
149 LabelButton::CreateDefaultBorder(); 162 LabelButton::CreateDefaultBorder();
150 163
164 if (ui::MaterialDesignController::IsModeMaterial()) {
165 // The material design spec does not include a visual effect for the
166 // STATE_HOVERED button state so we have to remove the default one added by
167 // LabelButton::CreateDefaultBorder().
168 border->SetPainter(true, Button::STATE_HOVERED, nullptr);
169 border->SetPainter(false, Button::STATE_HOVERED, nullptr);
170
171 #if defined(OS_CHROMEOS)
172 // The default STATE_PRESSED painters need to be removed so that they do not
173 // conflict with the ink drop ripple effect.
174 border->SetPainter(true, Button::STATE_PRESSED, nullptr);
Evan Stade 2015/07/22 16:29:46 for my edification, is it intentional that this al
175 border->SetPainter(false, Button::STATE_PRESSED, nullptr);
176 #endif // defined(OS_CHROMEOS)
177 }
178
151 ui::ThemeProvider* provider = GetThemeProvider(); 179 ui::ThemeProvider* provider = GetThemeProvider();
152 if (provider && provider->UsingSystemTheme()) { 180 if (provider && provider->UsingSystemTheme()) {
153 // Theme provided insets. 181 // Theme provided insets.
154 int inset = provider->GetDisplayProperty( 182 int inset = provider->GetDisplayProperty(
155 ThemeProperties::PROPERTY_TOOLBAR_BUTTON_BORDER_INSET); 183 ThemeProperties::PROPERTY_TOOLBAR_BUTTON_BORDER_INSET);
156 border->set_insets(gfx::Insets(inset, inset, inset, inset)); 184 border->set_insets(gfx::Insets(inset, inset, inset, inset));
157 } 185 }
158 186
159 return border.Pass(); 187 return border.Pass();
160 } 188 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 SetMouseHandler(NULL); 289 SetMouseHandler(NULL);
262 290
263 // Set the state back to normal after the drop down menu is closed. 291 // Set the state back to normal after the drop down menu is closed.
264 if (state_ != STATE_DISABLED) 292 if (state_ != STATE_DISABLED)
265 SetState(STATE_NORMAL); 293 SetState(STATE_NORMAL);
266 } 294 }
267 295
268 const char* ToolbarButton::GetClassName() const { 296 const char* ToolbarButton::GetClassName() const {
269 return "ToolbarButton"; 297 return "ToolbarButton";
270 } 298 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698