| 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" |
| 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/animation/ink_drop_hover.h" | 15 #include "ui/views/animation/ink_drop_hover.h" |
| 15 #include "ui/views/controls/button/blue_button.h" | 16 #include "ui/views/controls/button/blue_button.h" |
| 16 #include "ui/views/controls/button/checkbox.h" | 17 #include "ui/views/controls/button/checkbox.h" |
| 17 #include "ui/views/controls/button/image_button.h" | 18 #include "ui/views/controls/button/image_button.h" |
| 18 #include "ui/views/controls/button/label_button.h" | 19 #include "ui/views/controls/button/label_button.h" |
| 19 #include "ui/views/controls/button/menu_button.h" | 20 #include "ui/views/controls/button/menu_button.h" |
| 20 #include "ui/views/controls/button/radio_button.h" | 21 #include "ui/views/controls/button/radio_button.h" |
| 21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { | 324 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { |
| 324 if (state_ == STATE_DISABLED) | 325 if (state_ == STATE_DISABLED) |
| 325 return; | 326 return; |
| 326 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); | 327 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); |
| 327 } | 328 } |
| 328 | 329 |
| 329 scoped_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { | 330 scoped_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { |
| 330 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; | 331 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; |
| 331 } | 332 } |
| 332 | 333 |
| 334 SkColor CustomButton::GetInkDropBaseColor() const { |
| 335 return ink_drop_base_color_; |
| 336 } |
| 337 |
| 333 //////////////////////////////////////////////////////////////////////////////// | 338 //////////////////////////////////////////////////////////////////////////////// |
| 334 // CustomButton, gfx::AnimationDelegate implementation: | 339 // CustomButton, gfx::AnimationDelegate implementation: |
| 335 | 340 |
| 336 void CustomButton::AnimationProgressed(const gfx::Animation* animation) { | 341 void CustomButton::AnimationProgressed(const gfx::Animation* animation) { |
| 337 SchedulePaint(); | 342 SchedulePaint(); |
| 338 } | 343 } |
| 339 | 344 |
| 340 //////////////////////////////////////////////////////////////////////////////// | 345 //////////////////////////////////////////////////////////////////////////////// |
| 341 // CustomButton, protected: | 346 // CustomButton, protected: |
| 342 | 347 |
| 343 CustomButton::CustomButton(ButtonListener* listener) | 348 CustomButton::CustomButton(ButtonListener* listener) |
| 344 : Button(listener), | 349 : Button(listener), |
| 345 state_(STATE_NORMAL), | 350 state_(STATE_NORMAL), |
| 346 hover_animation_(this), | 351 hover_animation_(this), |
| 347 animate_on_state_change_(true), | 352 animate_on_state_change_(true), |
| 348 is_throbbing_(false), | 353 is_throbbing_(false), |
| 349 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), | 354 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), |
| 350 request_focus_on_press_(true), | 355 request_focus_on_press_(true), |
| 351 ink_drop_delegate_(nullptr), | 356 ink_drop_delegate_(nullptr), |
| 352 notify_action_(NOTIFY_ON_RELEASE), | 357 notify_action_(NOTIFY_ON_RELEASE), |
| 353 has_ink_drop_action_on_click_(false), | 358 has_ink_drop_action_on_click_(false), |
| 354 ink_drop_action_on_click_(InkDropState::QUICK_ACTION) { | 359 ink_drop_action_on_click_(InkDropState::QUICK_ACTION), |
| 360 ink_drop_base_color_(gfx::kPlaceholderColor) { |
| 355 hover_animation_.SetSlideDuration(kHoverFadeDurationMs); | 361 hover_animation_.SetSlideDuration(kHoverFadeDurationMs); |
| 356 } | 362 } |
| 357 | 363 |
| 358 void CustomButton::StateChanged() { | 364 void CustomButton::StateChanged() { |
| 359 } | 365 } |
| 360 | 366 |
| 361 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { | 367 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { |
| 362 return event.type() == ui::ET_GESTURE_TAP_DOWN || | 368 return event.type() == ui::ET_GESTURE_TAP_DOWN || |
| 363 event.type() == ui::ET_GESTURE_TAP || | 369 event.type() == ui::ET_GESTURE_TAP || |
| 364 (event.IsMouseEvent() && | 370 (event.IsMouseEvent() && |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (ink_drop_delegate()) | 423 if (ink_drop_delegate()) |
| 418 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 424 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 419 Button::OnClickCanceled(event); | 425 Button::OnClickCanceled(event); |
| 420 } | 426 } |
| 421 | 427 |
| 422 bool CustomButton::ShouldShowInkDropHover() const { | 428 bool CustomButton::ShouldShowInkDropHover() const { |
| 423 return enabled() && IsMouseHovered() && !InDrag(); | 429 return enabled() && IsMouseHovered() && !InDrag(); |
| 424 } | 430 } |
| 425 | 431 |
| 426 } // namespace views | 432 } // namespace views |
| OLD | NEW |