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

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

Issue 1772183002: Resets hover state when ToolbarActionView is dragged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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 | « no previous file | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/events/event.h" 9 #include "ui/events/event.h"
9 #include "ui/events/event_utils.h" 10 #include "ui/events/event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 11 #include "ui/events/keycodes/keyboard_codes.h"
11 #include "ui/gfx/animation/throb_animation.h" 12 #include "ui/gfx/animation/throb_animation.h"
12 #include "ui/gfx/color_palette.h" 13 #include "ui/gfx/color_palette.h"
13 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
14 #include "ui/views/animation/ink_drop_delegate.h" 15 #include "ui/views/animation/ink_drop_delegate.h"
15 #include "ui/views/animation/ink_drop_hover.h" 16 #include "ui/views/animation/ink_drop_hover.h"
16 #include "ui/views/controls/button/blue_button.h" 17 #include "ui/views/controls/button/blue_button.h"
17 #include "ui/views/controls/button/checkbox.h" 18 #include "ui/views/controls/button/checkbox.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // handler). 179 // handler).
179 return; 180 return;
180 } 181 }
181 } 182 }
182 } 183 }
183 if (notify_action_ == NOTIFY_ON_RELEASE) 184 if (notify_action_ == NOTIFY_ON_RELEASE)
184 OnClickCanceled(event); 185 OnClickCanceled(event);
185 } 186 }
186 187
187 void CustomButton::OnMouseCaptureLost() { 188 void CustomButton::OnMouseCaptureLost() {
188 // Starting a drag results in a MouseCaptureLost, we need to ignore it. 189 // Starting a drag results in a MouseCaptureLost. Reset button state.
189 if (state_ != STATE_DISABLED && !InDrag()) 190 // TODO(varkha) While in drag only reset the state with Material Design.
191 // The same logic may applies everywhere so gather any feedback and update.
192 bool reset_button_state =
193 !InDrag() || ui::MaterialDesignController::IsModeMaterial();
194 if (state_ != STATE_DISABLED && reset_button_state)
190 SetState(STATE_NORMAL); 195 SetState(STATE_NORMAL);
191 if (ink_drop_delegate_) 196 if (ink_drop_delegate_)
192 ink_drop_delegate_->OnAction(views::InkDropState::HIDDEN); 197 ink_drop_delegate_->OnAction(views::InkDropState::HIDDEN);
193 } 198 }
194 199
195 void CustomButton::OnMouseEntered(const ui::MouseEvent& event) { 200 void CustomButton::OnMouseEntered(const ui::MouseEvent& event) {
196 if (state_ != STATE_DISABLED) 201 if (state_ != STATE_DISABLED)
197 SetState(STATE_HOVERED); 202 SetState(STATE_HOVERED);
198 } 203 }
199 204
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 Button::NotifyClick(event); 428 Button::NotifyClick(event);
424 } 429 }
425 430
426 void CustomButton::OnClickCanceled(const ui::Event& event) { 431 void CustomButton::OnClickCanceled(const ui::Event& event) {
427 if (ink_drop_delegate()) 432 if (ink_drop_delegate())
428 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); 433 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
429 Button::OnClickCanceled(event); 434 Button::OnClickCanceled(event);
430 } 435 }
431 436
432 } // namespace views 437 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/custom_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698