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

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 1682893002: Color the ink drop ripple and hover effects based on theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit tests Created 4 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/button/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
11 #include "ui/gfx/animation/throb_animation.h" 11 #include "ui/gfx/animation/throb_animation.h"
12 #include "ui/gfx/color_palette.h"
12 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
13 #include "ui/views/animation/ink_drop_delegate.h" 14 #include "ui/views/animation/ink_drop_delegate.h"
14 #include "ui/views/controls/button/blue_button.h" 15 #include "ui/views/controls/button/blue_button.h"
15 #include "ui/views/controls/button/checkbox.h" 16 #include "ui/views/controls/button/checkbox.h"
16 #include "ui/views/controls/button/image_button.h" 17 #include "ui/views/controls/button/image_button.h"
17 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/button/label_button.h"
18 #include "ui/views/controls/button/menu_button.h" 19 #include "ui/views/controls/button/menu_button.h"
19 #include "ui/views/controls/button/radio_button.h" 20 #include "ui/views/controls/button/radio_button.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 22
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 361 }
361 362
362 gfx::Point CustomButton::CalculateInkDropCenter() const { 363 gfx::Point CustomButton::CalculateInkDropCenter() const {
363 return GetLocalBounds().CenterPoint(); 364 return GetLocalBounds().CenterPoint();
364 } 365 }
365 366
366 bool CustomButton::ShouldShowInkDropHover() const { 367 bool CustomButton::ShouldShowInkDropHover() const {
367 return enabled() && IsMouseHovered() && !InDrag(); 368 return enabled() && IsMouseHovered() && !InDrag();
368 } 369 }
369 370
371 SkColor CustomButton::GetInkDropBaseColor() const {
372 return ink_drop_base_color_;
373 }
374
370 //////////////////////////////////////////////////////////////////////////////// 375 ////////////////////////////////////////////////////////////////////////////////
371 // CustomButton, protected: 376 // CustomButton, protected:
372 377
373 CustomButton::CustomButton(ButtonListener* listener) 378 CustomButton::CustomButton(ButtonListener* listener)
374 : Button(listener), 379 : Button(listener),
375 state_(STATE_NORMAL), 380 state_(STATE_NORMAL),
376 hover_animation_(this), 381 hover_animation_(this),
377 animate_on_state_change_(true), 382 animate_on_state_change_(true),
378 is_throbbing_(false), 383 is_throbbing_(false),
379 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), 384 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON),
380 request_focus_on_press_(true), 385 request_focus_on_press_(true),
381 ink_drop_delegate_(nullptr), 386 ink_drop_delegate_(nullptr),
382 notify_action_(NOTIFY_ON_RELEASE), 387 notify_action_(NOTIFY_ON_RELEASE),
383 has_ink_drop_action_on_click_(false), 388 has_ink_drop_action_on_click_(false),
384 ink_drop_action_on_click_(InkDropState::QUICK_ACTION) { 389 ink_drop_action_on_click_(InkDropState::QUICK_ACTION),
390 ink_drop_base_color_(gfx::kPlaceholderColor) {
385 hover_animation_.SetSlideDuration(kHoverFadeDurationMs); 391 hover_animation_.SetSlideDuration(kHoverFadeDurationMs);
386 } 392 }
387 393
388 void CustomButton::StateChanged() { 394 void CustomButton::StateChanged() {
389 } 395 }
390 396
391 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { 397 bool CustomButton::IsTriggerableEvent(const ui::Event& event) {
392 return event.type() == ui::ET_GESTURE_TAP_DOWN || 398 return event.type() == ui::ET_GESTURE_TAP_DOWN ||
393 event.type() == ui::ET_GESTURE_TAP || 399 event.type() == ui::ET_GESTURE_TAP ||
394 (event.IsMouseEvent() && 400 (event.IsMouseEvent() &&
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); 470 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget();
465 } 471 }
466 472
467 bool CustomButton::FocusInChildWidget() const { 473 bool CustomButton::FocusInChildWidget() const {
468 return GetWidget() && 474 return GetWidget() &&
469 GetWidget()->GetRootView()->Contains( 475 GetWidget()->GetRootView()->Contains(
470 GetFocusManager()->GetFocusedView()); 476 GetFocusManager()->GetFocusedView());
471 } 477 }
472 478
473 } // namespace views 479 } // namespace views
OLDNEW
« ui/views/animation/ink_drop_hover.cc ('K') | « ui/views/controls/button/custom_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698