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

Unified Diff: ui/views/controls/button/custom_button.cc

Issue 1534303002: CustomButton cleanup: make protected members private, create accessors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy up Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/custom_button.cc
diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc
index e8ce4a003e394c3ff8f5ae260888f8806ddf8b1c..b23d02acf7904c5b4c416dbd93196253b7d9f8a9 100644
--- a/ui/views/controls/button/custom_button.cc
+++ b/ui/views/controls/button/custom_button.cc
@@ -66,21 +66,21 @@ void CustomButton::SetState(ButtonState state) {
return;
if (animate_on_state_change_ &&
- (!is_throbbing_ || !hover_animation_->is_animating())) {
+ (!is_throbbing_ || !hover_animation_.is_animating())) {
is_throbbing_ = false;
if ((state_ == STATE_HOVERED) && (state == STATE_NORMAL)) {
// For HOVERED -> NORMAL, animate from hovered (1) to not hovered (0).
- hover_animation_->Hide();
+ hover_animation_.Hide();
} else if (state != STATE_HOVERED) {
// For HOVERED -> PRESSED/DISABLED, or any transition not involving
// HOVERED at all, simply set the state to not hovered (0).
- hover_animation_->Reset();
+ hover_animation_.Reset();
} else if (state_ == STATE_NORMAL) {
// For NORMAL -> HOVERED, animate from not hovered (0) to hovered (1).
- hover_animation_->Show();
+ hover_animation_.Show();
} else {
// For PRESSED/DISABLED -> HOVERED, simply set the state to hovered (1).
- hover_animation_->Reset(1);
+ hover_animation_.Reset(1);
}
}
@@ -91,18 +91,18 @@ void CustomButton::SetState(ButtonState state) {
void CustomButton::StartThrobbing(int cycles_til_stop) {
is_throbbing_ = true;
- hover_animation_->StartThrobbing(cycles_til_stop);
+ hover_animation_.StartThrobbing(cycles_til_stop);
}
void CustomButton::StopThrobbing() {
- if (hover_animation_->is_animating()) {
- hover_animation_->Stop();
+ if (hover_animation_.is_animating()) {
+ hover_animation_.Stop();
SchedulePaint();
}
}
void CustomButton::SetAnimationDuration(int duration) {
- hover_animation_->SetSlideDuration(duration);
+ hover_animation_.SetSlideDuration(duration);
}
void CustomButton::SetHotTracked(bool is_hot_tracked) {
@@ -244,7 +244,7 @@ void CustomButton::OnGestureEvent(ui::GestureEvent* event) {
// STATE_NORMAL beginning the fade out animation. See
// http://crbug.com/131184.
SetState(STATE_HOVERED);
- hover_animation_->Reset(1.0);
+ hover_animation_.Reset(1.0);
NotifyClick(*event);
event->StopPropagation();
} else if (event->type() == ui::ET_GESTURE_TAP_DOWN &&
@@ -337,14 +337,14 @@ void CustomButton::AnimationProgressed(const gfx::Animation* animation) {
CustomButton::CustomButton(ButtonListener* listener)
: Button(listener),
state_(STATE_NORMAL),
+ hover_animation_(this),
animate_on_state_change_(true),
is_throbbing_(false),
triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON),
request_focus_on_press_(true),
ink_drop_delegate_(nullptr),
notify_action_(NOTIFY_ON_RELEASE) {
- hover_animation_.reset(new gfx::ThrobAnimation(this));
- hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
+ hover_animation_.SetSlideDuration(kHoverFadeDurationMs);
}
void CustomButton::StateChanged() {

Powered by Google App Engine
This is Rietveld 408576698