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

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: rebase 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 //////////////////////////////////////////////////////////////////////////////// 123 ////////////////////////////////////////////////////////////////////////////////
124 // CustomButton, View overrides: 124 // CustomButton, View overrides:
125 125
126 void CustomButton::OnEnabledChanged() { 126 void CustomButton::OnEnabledChanged() {
127 // TODO(bruthig): Is there any reason we are not calling 127 // TODO(bruthig): Is there any reason we are not calling
128 // Button::OnEnabledChanged() here? 128 // Button::OnEnabledChanged() here?
129 if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED)) 129 if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED))
130 return; 130 return;
131 131
132 if (enabled()) 132 if (enabled()) {
133 SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); 133 bool should_enter_hover_state = ShouldEnterHoveredState();
134 else 134 SetState(should_enter_hover_state ? STATE_HOVERED : STATE_NORMAL);
135 ink_drop()->SetHovered(should_enter_hover_state);
136 } else {
135 SetState(STATE_DISABLED); 137 SetState(STATE_DISABLED);
136 138 }
137 // TODO(bruthig): This should only be using the hover signal only and not the
138 // focus signal as well.
139 ink_drop()->SetHovered(ShouldShowInkDropHighlight());
140 } 139 }
141 140
142 const char* CustomButton::GetClassName() const { 141 const char* CustomButton::GetClassName() const {
143 return kViewClassName; 142 return kViewClassName;
144 } 143 }
145 144
146 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { 145 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) {
147 if (state_ == STATE_DISABLED) 146 if (state_ == STATE_DISABLED)
148 return true; 147 return true;
149 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) && 148 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) &&
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 state->AddStateFlag(ui::AX_STATE_DISABLED); 340 state->AddStateFlag(ui::AX_STATE_DISABLED);
342 break; 341 break;
343 case STATE_NORMAL: 342 case STATE_NORMAL:
344 case STATE_COUNT: 343 case STATE_COUNT:
345 // No additional accessibility state set for this button state. 344 // No additional accessibility state set for this button state.
346 break; 345 break;
347 } 346 }
348 } 347 }
349 348
350 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { 349 void CustomButton::VisibilityChanged(View* starting_from, bool visible) {
350 Button::VisibilityChanged(starting_from, visible);
351 if (state_ == STATE_DISABLED) 351 if (state_ == STATE_DISABLED)
352 return; 352 return;
353 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); 353 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL);
354 } 354 }
355 355
356 std::unique_ptr<InkDropHighlight> CustomButton::CreateInkDropHighlight() const { 356 std::unique_ptr<InkDropHighlight> CustomButton::CreateInkDropHighlight() const {
357 return ShouldShowInkDropHighlight() ? Button::CreateInkDropHighlight() 357 return ShouldShowInkDropHighlight() ? Button::CreateInkDropHighlight()
358 : nullptr; 358 : nullptr;
359 } 359 }
360 360
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 AnimateInkDrop(ink_drop_action_on_click_); 465 AnimateInkDrop(ink_drop_action_on_click_);
466 Button::NotifyClick(event); 466 Button::NotifyClick(event);
467 } 467 }
468 468
469 void CustomButton::OnClickCanceled(const ui::Event& event) { 469 void CustomButton::OnClickCanceled(const ui::Event& event) {
470 AnimateInkDrop(views::InkDropState::HIDDEN); 470 AnimateInkDrop(views::InkDropState::HIDDEN);
471 Button::OnClickCanceled(event); 471 Button::OnClickCanceled(event);
472 } 472 }
473 473
474 } // namespace views 474 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/test/test_ink_drop_delegate.cc ('k') | ui/views/controls/button/menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698