| 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/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return bounds; | 103 return bounds; |
| 104 } | 104 } |
| 105 | 105 |
| 106 // The transparent button which holds a button state but is not rendered. | 106 // The transparent button which holds a button state but is not rendered. |
| 107 class TransparentButton : public CustomButton { | 107 class TransparentButton : public CustomButton { |
| 108 public: | 108 public: |
| 109 TransparentButton(ButtonListener* listener) | 109 TransparentButton(ButtonListener* listener) |
| 110 : CustomButton(listener) { | 110 : CustomButton(listener) { |
| 111 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs); | 111 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs); |
| 112 SetFocusBehavior(FocusBehavior::NEVER); | 112 SetFocusBehavior(FocusBehavior::NEVER); |
| 113 set_notify_action(PlatformStyle::kMenuNotifyActivationAction); |
| 113 } | 114 } |
| 114 ~TransparentButton() override {} | 115 ~TransparentButton() override {} |
| 115 | 116 |
| 117 #if !defined(OS_MACOSX) |
| 118 // Override OnMousePressed() to transfer focus to the parent() on a click |
| 119 // except on Mac, which doesn't transfer focus when buttons are clicked. |
| 116 bool OnMousePressed(const ui::MouseEvent& mouse_event) override { | 120 bool OnMousePressed(const ui::MouseEvent& mouse_event) override { |
| 117 parent()->RequestFocus(); | 121 parent()->RequestFocus(); |
| 118 return true; | 122 return true; |
| 119 } | 123 } |
| 124 #endif |
| 120 | 125 |
| 121 double GetAnimationValue() const { | 126 double GetAnimationValue() const { |
| 122 return hover_animation().GetCurrentValue(); | 127 return hover_animation().GetCurrentValue(); |
| 123 } | 128 } |
| 124 | 129 |
| 125 private: | 130 private: |
| 126 DISALLOW_COPY_AND_ASSIGN(TransparentButton); | 131 DISALLOW_COPY_AND_ASSIGN(TransparentButton); |
| 127 }; | 132 }; |
| 128 | 133 |
| 129 // Returns the next or previous valid index (depending on |increment|'s value). | 134 // Returns the next or previous valid index (depending on |increment|'s value). |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } | 899 } |
| 895 | 900 |
| 896 int Combobox::GetArrowContainerWidth() const { | 901 int Combobox::GetArrowContainerWidth() const { |
| 897 int padding = style_ == STYLE_NORMAL | 902 int padding = style_ == STYLE_NORMAL |
| 898 ? PlatformStyle::kComboboxNormalArrowPadding * 2 | 903 ? PlatformStyle::kComboboxNormalArrowPadding * 2 |
| 899 : kActionLeftPadding + kActionRightPadding; | 904 : kActionLeftPadding + kActionRightPadding; |
| 900 return ArrowSize().width() + padding; | 905 return ArrowSize().width() + padding; |
| 901 } | 906 } |
| 902 | 907 |
| 903 } // namespace views | 908 } // namespace views |
| OLD | NEW |