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

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

Issue 1550443002: Pushed InkDropHost inheritence up to CustomButton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed doc typo. Created 4 years, 11 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
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"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ToolbarButton::CreateDefaultBorder() const { 166 ToolbarButton::CreateDefaultBorder() const {
167 scoped_ptr<views::LabelButtonBorder> border = 167 scoped_ptr<views::LabelButtonBorder> border =
168 views::LabelButton::CreateDefaultBorder(); 168 views::LabelButton::CreateDefaultBorder();
169 169
170 if (ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme()) 170 if (ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme())
171 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); 171 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON));
172 172
173 return border.Pass(); 173 return border.Pass();
174 } 174 }
175 175
176 void ToolbarButton::ShowContextMenuForView(View* source,
177 const gfx::Point& point,
178 ui::MenuSourceType source_type) {
179 if (!enabled())
180 return;
181
182 show_menu_factory_.InvalidateWeakPtrs();
183 ShowDropDownMenu(source_type);
184 }
185
186 void ToolbarButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { 176 void ToolbarButton::AddInkDropLayer(ui::Layer* ink_drop_layer) {
187 SetPaintToLayer(true); 177 SetPaintToLayer(true);
188 SetFillsBoundsOpaquely(false); 178 SetFillsBoundsOpaquely(false);
189 image()->SetPaintToLayer(true); 179 image()->SetPaintToLayer(true);
190 image()->SetFillsBoundsOpaquely(false); 180 image()->SetFillsBoundsOpaquely(false);
191 181
192 layer()->Add(ink_drop_layer); 182 layer()->Add(ink_drop_layer);
193 layer()->StackAtBottom(ink_drop_layer); 183 layer()->StackAtBottom(ink_drop_layer);
194 184
195 // Invalidates the contents of the parent's layer which may contain 185 // Invalidates the contents of the parent's layer which may contain
196 // a stale close/reload icon that should not remain visible. 186 // a stale close/reload icon that should not remain visible.
197 parent()->SchedulePaint(); 187 parent()->SchedulePaint();
198 } 188 }
199 189
200 void ToolbarButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 190 void ToolbarButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
201 layer()->Remove(ink_drop_layer); 191 layer()->Remove(ink_drop_layer);
202 192
203 image()->SetFillsBoundsOpaquely(true); 193 image()->SetFillsBoundsOpaquely(true);
204 image()->SetPaintToLayer(false); 194 image()->SetPaintToLayer(false);
205 SetPaintToLayer(false); 195 SetPaintToLayer(false);
206 } 196 }
207 197
198 void ToolbarButton::ShowContextMenuForView(View* source,
199 const gfx::Point& point,
200 ui::MenuSourceType source_type) {
201 if (!enabled())
202 return;
203
204 show_menu_factory_.InvalidateWeakPtrs();
205 ShowDropDownMenu(source_type);
206 }
207
208 bool ToolbarButton::ShouldEnterPushedState(const ui::Event& event) { 208 bool ToolbarButton::ShouldEnterPushedState(const ui::Event& event) {
209 // Enter PUSHED state on press with Left or Right mouse button or on taps. 209 // Enter PUSHED state on press with Left or Right mouse button or on taps.
210 // Remain in this state while the context menu is open. 210 // Remain in this state while the context menu is open.
211 return event.type() == ui::ET_GESTURE_TAP || 211 return event.type() == ui::ET_GESTURE_TAP ||
212 event.type() == ui::ET_GESTURE_TAP_DOWN || 212 event.type() == ui::ET_GESTURE_TAP_DOWN ||
213 (event.IsMouseEvent() && ((ui::EF_LEFT_MOUSE_BUTTON | 213 (event.IsMouseEvent() && ((ui::EF_LEFT_MOUSE_BUTTON |
214 ui::EF_RIGHT_MOUSE_BUTTON) & event.flags()) != 0); 214 ui::EF_RIGHT_MOUSE_BUTTON) & event.flags()) != 0);
215 } 215 }
216 216
217 bool ToolbarButton::ShouldShowMenu() { 217 bool ToolbarButton::ShouldShowMenu() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 SetMouseHandler(nullptr); 294 SetMouseHandler(nullptr);
295 295
296 // Set the state back to normal after the drop down menu is closed. 296 // Set the state back to normal after the drop down menu is closed.
297 if (state_ != STATE_DISABLED) 297 if (state_ != STATE_DISABLED)
298 SetState(STATE_NORMAL); 298 SetState(STATE_NORMAL);
299 } 299 }
300 300
301 const char* ToolbarButton::GetClassName() const { 301 const char* ToolbarButton::GetClassName() const {
302 return "ToolbarButton"; 302 return "ToolbarButton";
303 } 303 }
304
305 gfx::Point ToolbarButton::CalculateInkDropCenter() const {
306 return GetLocalBounds().CenterPoint();
307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698