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

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

Issue 2028303004: Hide hover effect on hidden ink drop host views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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/base/material_design/material_design_controller.h" 8 #include "ui/base/material_design/material_design_controller.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_utils.h" 10 #include "ui/events/event_utils.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 //////////////////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////////////////
125 // CustomButton, View overrides: 125 // CustomButton, View overrides:
126 126
127 void CustomButton::OnEnabledChanged() { 127 void CustomButton::OnEnabledChanged() {
128 // TODO(bruthig): Is there any reason we are not calling 128 // TODO(bruthig): Is there any reason we are not calling
129 // Button::OnEnabledChanged() here? 129 // Button::OnEnabledChanged() here?
130 if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED)) 130 if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED))
131 return; 131 return;
132 132
133 if (enabled()) 133 if (enabled()) {
134 SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); 134 bool should_enter_hover_state = ShouldEnterHoveredState();
135 else 135 SetState(should_enter_hover_state ? STATE_HOVERED : STATE_NORMAL);
136 if (ink_drop_delegate())
137 ink_drop_delegate()->SetHovered(should_enter_hover_state);
138 } else {
136 SetState(STATE_DISABLED); 139 SetState(STATE_DISABLED);
137 140 }
138 if (ink_drop_delegate())
139 ink_drop_delegate()->SetHovered(ShouldShowInkDropHover());
140 } 141 }
141 142
142 const char* CustomButton::GetClassName() const { 143 const char* CustomButton::GetClassName() const {
143 return kViewClassName; 144 return kViewClassName;
144 } 145 }
145 146
146 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { 147 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) {
147 if (state_ == STATE_DISABLED) 148 if (state_ == STATE_DISABLED)
148 return true; 149 return true;
149 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) && 150 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) &&
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 state->AddStateFlag(ui::AX_STATE_DISABLED); 343 state->AddStateFlag(ui::AX_STATE_DISABLED);
343 break; 344 break;
344 case STATE_NORMAL: 345 case STATE_NORMAL:
345 case STATE_COUNT: 346 case STATE_COUNT:
346 // No additional accessibility state set for this button state. 347 // No additional accessibility state set for this button state.
347 break; 348 break;
348 } 349 }
349 } 350 }
350 351
351 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { 352 void CustomButton::VisibilityChanged(View* starting_from, bool visible) {
353 Button::VisibilityChanged(starting_from, visible);
352 if (state_ == STATE_DISABLED) 354 if (state_ == STATE_DISABLED)
353 return; 355 return;
354 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); 356 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL);
355 } 357 }
356 358
357 std::unique_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { 359 std::unique_ptr<InkDropHover> CustomButton::CreateInkDropHover() const {
358 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; 360 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr;
359 } 361 }
360 362
361 SkColor CustomButton::GetInkDropBaseColor() const { 363 SkColor CustomButton::GetInkDropBaseColor() const {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 Button::NotifyClick(event); 470 Button::NotifyClick(event);
469 } 471 }
470 472
471 void CustomButton::OnClickCanceled(const ui::Event& event) { 473 void CustomButton::OnClickCanceled(const ui::Event& event) {
472 if (ink_drop_delegate()) 474 if (ink_drop_delegate())
473 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); 475 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
474 Button::OnClickCanceled(event); 476 Button::OnClickCanceled(event);
475 } 477 }
476 478
477 } // namespace views 479 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698