| OLD | NEW |
| 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" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 aura::client::GetCaptureClient(root_window); | 392 aura::client::GetCaptureClient(root_window); |
| 393 aura::Window* capture_window = | 393 aura::Window* capture_window = |
| 394 capture_client ? capture_client->GetGlobalCaptureWindow() : nullptr; | 394 capture_client ? capture_client->GetGlobalCaptureWindow() : nullptr; |
| 395 check_mouse_position = !capture_window || capture_window == root_window; | 395 check_mouse_position = !capture_window || capture_window == root_window; |
| 396 } | 396 } |
| 397 #endif | 397 #endif |
| 398 | 398 |
| 399 return check_mouse_position && IsMouseHovered(); | 399 return check_mouse_position && IsMouseHovered(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 bool CustomButton::ShouldShowInkDropHover() const { |
| 403 return enabled() && IsMouseHovered() && !InDrag(); |
| 404 } |
| 405 |
| 402 //////////////////////////////////////////////////////////////////////////////// | 406 //////////////////////////////////////////////////////////////////////////////// |
| 403 // CustomButton, View overrides (protected): | 407 // CustomButton, View overrides (protected): |
| 404 | 408 |
| 405 void CustomButton::ViewHierarchyChanged( | 409 void CustomButton::ViewHierarchyChanged( |
| 406 const ViewHierarchyChangedDetails& details) { | 410 const ViewHierarchyChangedDetails& details) { |
| 407 if (!details.is_add && state_ != STATE_DISABLED) | 411 if (!details.is_add && state_ != STATE_DISABLED) |
| 408 SetState(STATE_NORMAL); | 412 SetState(STATE_NORMAL); |
| 409 } | 413 } |
| 410 | 414 |
| 411 void CustomButton::OnBlur() { | 415 void CustomButton::OnBlur() { |
| 412 if (IsHotTracked()) | 416 if (IsHotTracked()) |
| 413 SetState(STATE_NORMAL); | 417 SetState(STATE_NORMAL); |
| 414 } | 418 } |
| 415 | 419 |
| 416 void CustomButton::NotifyClick(const ui::Event& event) { | 420 void CustomButton::NotifyClick(const ui::Event& event) { |
| 417 if (ink_drop_delegate() && has_ink_drop_action_on_click_) | 421 if (ink_drop_delegate() && has_ink_drop_action_on_click_) |
| 418 ink_drop_delegate()->OnAction(ink_drop_action_on_click_); | 422 ink_drop_delegate()->OnAction(ink_drop_action_on_click_); |
| 419 Button::NotifyClick(event); | 423 Button::NotifyClick(event); |
| 420 } | 424 } |
| 421 | 425 |
| 422 void CustomButton::OnClickCanceled(const ui::Event& event) { | 426 void CustomButton::OnClickCanceled(const ui::Event& event) { |
| 423 if (ink_drop_delegate()) | 427 if (ink_drop_delegate()) |
| 424 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 428 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 425 Button::OnClickCanceled(event); | 429 Button::OnClickCanceled(event); |
| 426 } | 430 } |
| 427 | 431 |
| 428 bool CustomButton::ShouldShowInkDropHover() const { | |
| 429 return enabled() && IsMouseHovered() && !InDrag(); | |
| 430 } | |
| 431 | |
| 432 } // namespace views | 432 } // namespace views |
| OLD | NEW |