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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 DCHECK_EQ(bounds.width(), arrow_size.width()); | 107 DCHECK_EQ(bounds.width(), arrow_size.width()); |
108 } | 108 } |
109 | 109 |
110 bounds.ClampToCenteredSize(arrow_size); | 110 bounds.ClampToCenteredSize(arrow_size); |
111 return bounds; | 111 return bounds; |
112 } | 112 } |
113 | 113 |
114 // The transparent button which holds a button state but is not rendered. | 114 // The transparent button which holds a button state but is not rendered. |
115 class TransparentButton : public CustomButton { | 115 class TransparentButton : public CustomButton { |
116 public: | 116 public: |
117 TransparentButton(ButtonListener* listener) | 117 TransparentButton(ButtonListener* listener, bool animate_state_change) |
118 : CustomButton(listener) { | 118 : CustomButton(listener) { |
119 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs); | 119 set_animate_on_state_change(animate_state_change); |
| 120 if (animate_state_change) |
| 121 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs); |
120 SetFocusBehavior(FocusBehavior::NEVER); | 122 SetFocusBehavior(FocusBehavior::NEVER); |
121 set_notify_action(PlatformStyle::kMenuNotifyActivationAction); | 123 set_notify_action(PlatformStyle::kMenuNotifyActivationAction); |
122 | 124 |
123 if (UseMd()) { | 125 if (UseMd()) { |
124 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON | 126 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON |
125 : InkDropMode::OFF); | 127 : InkDropMode::OFF); |
126 set_has_ink_drop_action_on_click(true); | 128 set_has_ink_drop_action_on_click(true); |
127 } | 129 } |
128 } | 130 } |
129 ~TransparentButton() override {} | 131 ~TransparentButton() override {} |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 //////////////////////////////////////////////////////////////////////////////// | 389 //////////////////////////////////////////////////////////////////////////////// |
388 // Combobox, public: | 390 // Combobox, public: |
389 | 391 |
390 Combobox::Combobox(ui::ComboboxModel* model, Style style) | 392 Combobox::Combobox(ui::ComboboxModel* model, Style style) |
391 : model_(model), | 393 : model_(model), |
392 style_(style), | 394 style_(style), |
393 listener_(NULL), | 395 listener_(NULL), |
394 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), | 396 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), |
395 invalid_(false), | 397 invalid_(false), |
396 menu_model_(new ComboboxMenuModel(this, model)), | 398 menu_model_(new ComboboxMenuModel(this, model)), |
397 text_button_(new TransparentButton(this)), | 399 text_button_(new TransparentButton(this, style_ == STYLE_ACTION)), |
398 arrow_button_(new TransparentButton(this)), | 400 arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)), |
399 size_to_largest_label_(style_ == STYLE_NORMAL), | 401 size_to_largest_label_(style_ == STYLE_NORMAL), |
400 weak_ptr_factory_(this) { | 402 weak_ptr_factory_(this) { |
401 ModelChanged(); | 403 ModelChanged(); |
402 #if defined(OS_MACOSX) | 404 #if defined(OS_MACOSX) |
403 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 405 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
404 #else | 406 #else |
405 SetFocusBehavior(FocusBehavior::ALWAYS); | 407 SetFocusBehavior(FocusBehavior::ALWAYS); |
406 #endif | 408 #endif |
407 | 409 |
408 UpdateBorder(); | 410 UpdateBorder(); |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 } | 991 } |
990 | 992 |
991 int Combobox::GetArrowContainerWidth() const { | 993 int Combobox::GetArrowContainerWidth() const { |
992 int padding = style_ == STYLE_NORMAL | 994 int padding = style_ == STYLE_NORMAL |
993 ? PlatformStyle::kComboboxNormalArrowPadding * 2 | 995 ? PlatformStyle::kComboboxNormalArrowPadding * 2 |
994 : kActionLeftPadding + kActionRightPadding; | 996 : kActionLeftPadding + kActionRightPadding; |
995 return ArrowSize().width() + padding; | 997 return ArrowSize().width() + padding; |
996 } | 998 } |
997 | 999 |
998 } // namespace views | 1000 } // namespace views |
OLD | NEW |