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

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 2327673003: combobox: don't animate state changes in TransparentButton (Closed)
Patch Set: do animate for action comboboxes Created 4 years, 3 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 | no next file » | 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/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
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 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs);
Evan Stade 2016/09/13 22:03:17 could you make this conditional on the new paramet
120 SetFocusBehavior(FocusBehavior::NEVER); 120 SetFocusBehavior(FocusBehavior::NEVER);
121 set_notify_action(PlatformStyle::kMenuNotifyActivationAction); 121 set_notify_action(PlatformStyle::kMenuNotifyActivationAction);
122 set_animate_on_state_change(animate_state_change);
122 123
123 if (UseMd()) { 124 if (UseMd()) {
124 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON 125 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON
125 : InkDropMode::OFF); 126 : InkDropMode::OFF);
126 set_has_ink_drop_action_on_click(true); 127 set_has_ink_drop_action_on_click(true);
127 } 128 }
128 } 129 }
129 ~TransparentButton() override {} 130 ~TransparentButton() override {}
130 131
131 bool OnMousePressed(const ui::MouseEvent& mouse_event) override { 132 bool OnMousePressed(const ui::MouseEvent& mouse_event) override {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 //////////////////////////////////////////////////////////////////////////////// 388 ////////////////////////////////////////////////////////////////////////////////
388 // Combobox, public: 389 // Combobox, public:
389 390
390 Combobox::Combobox(ui::ComboboxModel* model, Style style) 391 Combobox::Combobox(ui::ComboboxModel* model, Style style)
391 : model_(model), 392 : model_(model),
392 style_(style), 393 style_(style),
393 listener_(NULL), 394 listener_(NULL),
394 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), 395 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()),
395 invalid_(false), 396 invalid_(false),
396 menu_model_(new ComboboxMenuModel(this, model)), 397 menu_model_(new ComboboxMenuModel(this, model)),
397 text_button_(new TransparentButton(this)), 398 text_button_(new TransparentButton(this, style_ == STYLE_ACTION)),
398 arrow_button_(new TransparentButton(this)), 399 arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)),
399 size_to_largest_label_(style_ == STYLE_NORMAL), 400 size_to_largest_label_(style_ == STYLE_NORMAL),
400 weak_ptr_factory_(this) { 401 weak_ptr_factory_(this) {
401 ModelChanged(); 402 ModelChanged();
402 #if defined(OS_MACOSX) 403 #if defined(OS_MACOSX)
403 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 404 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
404 #else 405 #else
405 SetFocusBehavior(FocusBehavior::ALWAYS); 406 SetFocusBehavior(FocusBehavior::ALWAYS);
406 #endif 407 #endif
407 408
408 UpdateBorder(); 409 UpdateBorder();
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 990 }
990 991
991 int Combobox::GetArrowContainerWidth() const { 992 int Combobox::GetArrowContainerWidth() const {
992 int padding = style_ == STYLE_NORMAL 993 int padding = style_ == STYLE_NORMAL
993 ? PlatformStyle::kComboboxNormalArrowPadding * 2 994 ? PlatformStyle::kComboboxNormalArrowPadding * 2
994 : kActionLeftPadding + kActionRightPadding; 995 : kActionLeftPadding + kActionRightPadding;
995 return ArrowSize().width() + padding; 996 return ArrowSize().width() + padding;
996 } 997 }
997 998
998 } // namespace views 999 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698