0

CustomButton cleanup: make protected members private, create accessors

Also delete some old file that's not in use.

BUG=none
TBR=erg@chromium.org

Review URL: https://codereview.chromium.org/1534303002

Cr-Commit-Position: refs/heads/master@{#367093}
This commit is contained in:
estade
2015-12-29 11:37:38 -08:00
committed by Commit bot
parent 1c5c483221
commit a1dbae6db9
15 changed files with 89 additions and 105 deletions

@ -110,9 +110,11 @@ const char* FrameCaptionButton::GetClassName() const {
} }
void FrameCaptionButton::OnPaint(gfx::Canvas* canvas) { void FrameCaptionButton::OnPaint(gfx::Canvas* canvas) {
if (hover_animation_->is_animating() || state() == STATE_HOVERED) { if (hover_animation().is_animating() || state() == STATE_HOVERED) {
int hovered_background_alpha = hover_animation_->is_animating() ? int hovered_background_alpha =
hover_animation_->CurrentValueBetween(0, 255) : 255; hover_animation().is_animating()
? hover_animation().CurrentValueBetween(0, 255)
: 255;
SkPaint paint; SkPaint paint;
paint.setAlpha(hovered_background_alpha); paint.setAlpha(hovered_background_alpha);
canvas->DrawImageInt(hovered_background_image_, 0, 0, paint); canvas->DrawImageInt(hovered_background_image_, 0, 0, paint);
@ -173,9 +175,9 @@ void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas,
if (!paint_as_active_) { if (!paint_as_active_) {
// Paint icons as active when they are hovered over or pressed. // Paint icons as active when they are hovered over or pressed.
double inactive_alpha = kInactiveIconAlpha; double inactive_alpha = kInactiveIconAlpha;
if (hover_animation_->is_animating()) { if (hover_animation().is_animating()) {
inactive_alpha = inactive_alpha =
hover_animation_->CurrentValueBetween(inactive_alpha, 1.0f); hover_animation().CurrentValueBetween(inactive_alpha, 1.0f);
} else if (state() == STATE_PRESSED || state() == STATE_HOVERED) { } else if (state() == STATE_PRESSED || state() == STATE_HOVERED) {
inactive_alpha = 1.0f; inactive_alpha = 1.0f;
} }

@ -71,9 +71,9 @@ void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) {
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kFill_Style); paint.setStyle(SkPaint::kFill_Style);
paint.setColor(SkColorSetARGB( paint.setColor(
kButtonHoverAlpha * hover_animation_->GetCurrentValue(), SkColorSetA(SK_ColorBLACK,
0, 0, 0)); hover_animation().CurrentValueBetween(0, kButtonHoverAlpha)));
const SkScalar radius = SkIntToScalar(kButtonCornerRadius); const SkScalar radius = SkIntToScalar(kButtonCornerRadius);
SkPath path; SkPath path;

@ -149,7 +149,7 @@ bool MediaIndicatorButton::OnMousePressed(const ui::MouseEvent& event) {
// pressed or when any modifier keys are being held down. Instead, the Tab // pressed or when any modifier keys are being held down. Instead, the Tab
// should react (e.g., middle-click for close, right-click for context menu). // should react (e.g., middle-click for close, right-click for context menu).
if (event.flags() != ui::EF_LEFT_MOUSE_BUTTON) { if (event.flags() != ui::EF_LEFT_MOUSE_BUTTON) {
if (state_ != views::CustomButton::STATE_DISABLED) if (state() != views::CustomButton::STATE_DISABLED)
SetState(views::CustomButton::STATE_NORMAL); // Turn off hover. SetState(views::CustomButton::STATE_NORMAL); // Turn off hover.
return false; // Event to be handled by Tab. return false; // Event to be handled by Tab.
} }
@ -167,7 +167,7 @@ bool MediaIndicatorButton::OnMouseDragged(const ui::MouseEvent& event) {
void MediaIndicatorButton::OnMouseEntered(const ui::MouseEvent& event) { void MediaIndicatorButton::OnMouseEntered(const ui::MouseEvent& event) {
// If any modifier keys are being held down, do not turn on hover. // If any modifier keys are being held down, do not turn on hover.
if (state_ != views::CustomButton::STATE_DISABLED && if (state() != views::CustomButton::STATE_DISABLED &&
event.flags() != ui::EF_NONE) { event.flags() != ui::EF_NONE) {
SetState(views::CustomButton::STATE_NORMAL); SetState(views::CustomButton::STATE_NORMAL);
return; return;
@ -177,7 +177,7 @@ void MediaIndicatorButton::OnMouseEntered(const ui::MouseEvent& event) {
void MediaIndicatorButton::OnMouseMoved(const ui::MouseEvent& event) { void MediaIndicatorButton::OnMouseMoved(const ui::MouseEvent& event) {
// If any modifier keys are being held down, turn off hover. // If any modifier keys are being held down, turn off hover.
if (state_ != views::CustomButton::STATE_DISABLED && if (state() != views::CustomButton::STATE_DISABLED &&
event.flags() != ui::EF_NONE) { event.flags() != ui::EF_NONE) {
SetState(views::CustomButton::STATE_NORMAL); SetState(views::CustomButton::STATE_NORMAL);
return; return;

@ -313,7 +313,6 @@ class NewTabButton : public views::ImageButton,
// Paints the fill region of the button into |canvas|, according to the // Paints the fill region of the button into |canvas|, according to the
// supplied values from GetImage() and the given |fill| path. // supplied values from GetImage() and the given |fill| path.
void PaintFill(bool pressed, void PaintFill(bool pressed,
double hover_value,
float scale, float scale,
const SkPath& fill, const SkPath& fill,
gfx::Canvas* canvas) const; gfx::Canvas* canvas) const;
@ -378,10 +377,6 @@ void NewTabButton::OnPaint(gfx::Canvas* canvas) {
canvas->Translate(gfx::Vector2d(0, height() - visible_height)); canvas->Translate(gfx::Vector2d(0, height() - visible_height));
const bool pressed = state() == views::CustomButton::STATE_PRESSED; const bool pressed = state() == views::CustomButton::STATE_PRESSED;
double hover_value =
(state() == views::CustomButton::STATE_HOVERED) ? 1 : 0;
if (hover_animation_->is_animating())
hover_value = hover_animation_->GetCurrentValue();
const float scale = canvas->image_scale(); const float scale = canvas->image_scale();
SkPath fill; SkPath fill;
@ -401,7 +396,7 @@ void NewTabButton::OnPaint(gfx::Canvas* canvas) {
fill.rLineTo(diag_width, diag_height); fill.rLineTo(diag_width, diag_height);
fill.rCubicTo(0, 0.5 * scale, -0.25 * scale, scale, -scale, scale); fill.rCubicTo(0, 0.5 * scale, -0.25 * scale, scale, -scale, scale);
fill.close(); fill.close();
PaintFill(pressed, hover_value, scale, fill, canvas); PaintFill(pressed, scale, fill, canvas);
// Stroke. // Stroke.
gfx::ScopedCanvas scoped_canvas(canvas); gfx::ScopedCanvas scoped_canvas(canvas);
@ -433,7 +428,7 @@ void NewTabButton::OnPaint(gfx::Canvas* canvas) {
scale : ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_100P); scale : ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_100P);
gfx::Canvas fill_canvas(GetLayoutSize(NEW_TAB_BUTTON), fill_canvas_scale, gfx::Canvas fill_canvas(GetLayoutSize(NEW_TAB_BUTTON), fill_canvas_scale,
false); false);
PaintFill(pressed, hover_value, fill_canvas_scale, fill, &fill_canvas); PaintFill(pressed, fill_canvas_scale, fill, &fill_canvas);
gfx::ImageSkia image(fill_canvas.ExtractImageRep()); gfx::ImageSkia image(fill_canvas.ExtractImageRep());
canvas->DrawImageInt( canvas->DrawImageInt(
gfx::ImageSkiaOperations::CreateMaskedImage(image, *mask), 0, 0); gfx::ImageSkiaOperations::CreateMaskedImage(image, *mask), 0, 0);
@ -527,7 +522,6 @@ void NewTabButton::GetBorderPath(float button_y,
} }
void NewTabButton::PaintFill(bool pressed, void NewTabButton::PaintFill(bool pressed,
double hover_value,
float scale, float scale,
const SkPath& fill, const SkPath& fill,
gfx::Canvas* canvas) const { gfx::Canvas* canvas) const {
@ -606,12 +600,10 @@ void NewTabButton::PaintFill(bool pressed,
} }
// White highlight on hover. // White highlight on hover.
if (hover_value) { const SkAlpha alpha = static_cast<SkAlpha>(
const int alpha = hover_animation().CurrentValueBetween(0x00, md ? 0x4D : 0x40));
gfx::Tween::LinearIntValueBetween(hover_value, 0x00, md ? 0x4D : 0x40); if (alpha != SK_AlphaTRANSPARENT)
canvas->FillRect(GetLocalBounds(), canvas->FillRect(GetLocalBounds(), SkColorSetA(SK_ColorWHITE, alpha));
SkColorSetA(SK_ColorWHITE, static_cast<SkAlpha>(alpha)));
}
// For MD, most states' opacities are adjusted using an opacity recorder in // For MD, most states' opacities are adjusted using an opacity recorder in
// TabStrip::PaintChildren(), but the pressed state is excluded there and // TabStrip::PaintChildren(), but the pressed state is excluded there and

@ -142,7 +142,7 @@ void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) {
// Starting a drag results in a MouseExited, we need to ignore it. // Starting a drag results in a MouseExited, we need to ignore it.
// A right click release triggers an exit event. We want to // A right click release triggers an exit event. We want to
// remain in a PUSHED state until the drop down menu closes. // remain in a PUSHED state until the drop down menu closes.
if (state_ != STATE_DISABLED && !InDrag() && state_ != STATE_PRESSED) if (state() != STATE_DISABLED && !InDrag() && state() != STATE_PRESSED)
SetState(STATE_NORMAL); SetState(STATE_NORMAL);
} }
@ -295,7 +295,7 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) {
SetMouseHandler(nullptr); SetMouseHandler(nullptr);
// Set the state back to normal after the drop down menu is closed. // Set the state back to normal after the drop down menu is closed.
if (state_ != STATE_DISABLED) if (state() != STATE_DISABLED)
SetState(STATE_NORMAL); SetState(STATE_NORMAL);
} }

@ -111,11 +111,9 @@ const char* FrameCaptionButton::GetClassName() const {
} }
void FrameCaptionButton::OnPaint(gfx::Canvas* canvas) { void FrameCaptionButton::OnPaint(gfx::Canvas* canvas) {
if (hover_animation_->is_animating() || state() == STATE_HOVERED) { if (hover_animation().is_animating() || state() == STATE_HOVERED) {
int hovered_background_alpha = int hovered_background_alpha =
hover_animation_->is_animating() hover_animation().CurrentValueBetween(0, 255);
? hover_animation_->CurrentValueBetween(0, 255)
: 255;
SkPaint paint; SkPaint paint;
paint.setAlpha(hovered_background_alpha); paint.setAlpha(hovered_background_alpha);
canvas->DrawImageInt(hovered_background_image_, 0, 0, paint); canvas->DrawImageInt(hovered_background_image_, 0, 0, paint);
@ -176,9 +174,9 @@ void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas,
if (!paint_as_active_) { if (!paint_as_active_) {
// Paint icons as active when they are hovered over or pressed. // Paint icons as active when they are hovered over or pressed.
double inactive_alpha = kInactiveIconAlpha; double inactive_alpha = kInactiveIconAlpha;
if (hover_animation_->is_animating()) { if (hover_animation().is_animating()) {
inactive_alpha = inactive_alpha =
hover_animation_->CurrentValueBetween(inactive_alpha, 1.0f); hover_animation().CurrentValueBetween(inactive_alpha, 1.0f);
} else if (state() == STATE_PRESSED || state() == STATE_HOVERED) { } else if (state() == STATE_PRESSED || state() == STATE_HOVERED) {
inactive_alpha = 1.0f; inactive_alpha = 1.0f;
} }

@ -144,11 +144,11 @@ void AppListItemView::SetIcon(const gfx::ImageSkia& icon) {
shadow_animator_.SetOriginalImage(resized); shadow_animator_.SetOriginalImage(resized);
} }
void AppListItemView::SetUIState(UIState state) { void AppListItemView::SetUIState(UIState ui_state) {
if (ui_state_ == state) if (ui_state_ == ui_state)
return; return;
ui_state_ = state; ui_state_ = ui_state;
switch (ui_state_) { switch (ui_state_) {
case UI_STATE_NORMAL: case UI_STATE_NORMAL:
@ -467,14 +467,14 @@ void AppListItemView::OnGestureEvent(ui::GestureEvent* event) {
} }
break; break;
case ui::ET_GESTURE_TAP_DOWN: case ui::ET_GESTURE_TAP_DOWN:
if (::switches::IsTouchFeedbackEnabled() && state_ != STATE_DISABLED) { if (::switches::IsTouchFeedbackEnabled() && state() != STATE_DISABLED) {
SetState(STATE_PRESSED); SetState(STATE_PRESSED);
event->SetHandled(); event->SetHandled();
} }
break; break;
case ui::ET_GESTURE_TAP: case ui::ET_GESTURE_TAP:
case ui::ET_GESTURE_TAP_CANCEL: case ui::ET_GESTURE_TAP_CANCEL:
if (::switches::IsTouchFeedbackEnabled() && state_ != STATE_DISABLED) if (::switches::IsTouchFeedbackEnabled() && state() != STATE_DISABLED)
SetState(STATE_NORMAL); SetState(STATE_NORMAL);
break; break;
case ui::ET_GESTURE_LONG_PRESS: case ui::ET_GESTURE_LONG_PRESS:

@ -105,7 +105,7 @@ class SearchBoxImageButton : public views::ImageButton {
private: private:
// views::View overrides: // views::View overrides:
void OnPaintBackground(gfx::Canvas* canvas) override { void OnPaintBackground(gfx::Canvas* canvas) override {
if (state_ == STATE_HOVERED || state_ == STATE_PRESSED || selected_) if (state() == STATE_HOVERED || state() == STATE_PRESSED || selected_)
canvas->FillRect(gfx::Rect(size()), kSelectedColor); canvas->FillRect(gfx::Rect(size()), kSelectedColor);
} }

@ -62,21 +62,21 @@ void CustomButton::SetState(ButtonState state) {
return; return;
if (animate_on_state_change_ && if (animate_on_state_change_ &&
(!is_throbbing_ || !hover_animation_->is_animating())) { (!is_throbbing_ || !hover_animation_.is_animating())) {
is_throbbing_ = false; is_throbbing_ = false;
if ((state_ == STATE_HOVERED) && (state == STATE_NORMAL)) { if ((state_ == STATE_HOVERED) && (state == STATE_NORMAL)) {
// For HOVERED -> NORMAL, animate from hovered (1) to not hovered (0). // For HOVERED -> NORMAL, animate from hovered (1) to not hovered (0).
hover_animation_->Hide(); hover_animation_.Hide();
} else if (state != STATE_HOVERED) { } else if (state != STATE_HOVERED) {
// For HOVERED -> PRESSED/DISABLED, or any transition not involving // For HOVERED -> PRESSED/DISABLED, or any transition not involving
// HOVERED at all, simply set the state to not hovered (0). // HOVERED at all, simply set the state to not hovered (0).
hover_animation_->Reset(); hover_animation_.Reset();
} else if (state_ == STATE_NORMAL) { } else if (state_ == STATE_NORMAL) {
// For NORMAL -> HOVERED, animate from not hovered (0) to hovered (1). // For NORMAL -> HOVERED, animate from not hovered (0) to hovered (1).
hover_animation_->Show(); hover_animation_.Show();
} else { } else {
// For PRESSED/DISABLED -> HOVERED, simply set the state to hovered (1). // For PRESSED/DISABLED -> HOVERED, simply set the state to hovered (1).
hover_animation_->Reset(1); hover_animation_.Reset(1);
} }
} }
@ -87,18 +87,18 @@ void CustomButton::SetState(ButtonState state) {
void CustomButton::StartThrobbing(int cycles_til_stop) { void CustomButton::StartThrobbing(int cycles_til_stop) {
is_throbbing_ = true; is_throbbing_ = true;
hover_animation_->StartThrobbing(cycles_til_stop); hover_animation_.StartThrobbing(cycles_til_stop);
} }
void CustomButton::StopThrobbing() { void CustomButton::StopThrobbing() {
if (hover_animation_->is_animating()) { if (hover_animation_.is_animating()) {
hover_animation_->Stop(); hover_animation_.Stop();
SchedulePaint(); SchedulePaint();
} }
} }
void CustomButton::SetAnimationDuration(int duration) { void CustomButton::SetAnimationDuration(int duration) {
hover_animation_->SetSlideDuration(duration); hover_animation_.SetSlideDuration(duration);
} }
void CustomButton::SetHotTracked(bool is_hot_tracked) { void CustomButton::SetHotTracked(bool is_hot_tracked) {
@ -243,7 +243,7 @@ void CustomButton::OnGestureEvent(ui::GestureEvent* event) {
// STATE_NORMAL beginning the fade out animation. See // STATE_NORMAL beginning the fade out animation. See
// http://crbug.com/131184. // http://crbug.com/131184.
SetState(STATE_HOVERED); SetState(STATE_HOVERED);
hover_animation_->Reset(1.0); hover_animation_.Reset(1.0);
NotifyClick(*event); NotifyClick(*event);
event->StopPropagation(); event->StopPropagation();
} else if (event->type() == ui::ET_GESTURE_TAP_DOWN && } else if (event->type() == ui::ET_GESTURE_TAP_DOWN &&
@ -336,6 +336,7 @@ void CustomButton::AnimationProgressed(const gfx::Animation* animation) {
CustomButton::CustomButton(ButtonListener* listener) CustomButton::CustomButton(ButtonListener* listener)
: Button(listener), : Button(listener),
state_(STATE_NORMAL), state_(STATE_NORMAL),
hover_animation_(this),
animate_on_state_change_(true), animate_on_state_change_(true),
is_throbbing_(false), is_throbbing_(false),
triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON),
@ -344,8 +345,7 @@ CustomButton::CustomButton(ButtonListener* listener)
notify_action_(NOTIFY_ON_RELEASE), notify_action_(NOTIFY_ON_RELEASE),
has_ink_drop_action_on_click_(false), has_ink_drop_action_on_click_(false),
ink_drop_action_on_click_(InkDropState::QUICK_ACTION) { ink_drop_action_on_click_(InkDropState::QUICK_ACTION) {
hover_animation_.reset(new gfx::ThrobAnimation(this)); hover_animation_.SetSlideDuration(kHoverFadeDurationMs);
hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
} }
void CustomButton::StateChanged() { void CustomButton::StateChanged() {

@ -9,13 +9,10 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/animation/throb_animation.h"
#include "ui/views/animation/ink_drop_state.h" #include "ui/views/animation/ink_drop_state.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
namespace gfx {
class ThrobAnimation;
}
namespace views { namespace views {
class InkDropDelegate; class InkDropDelegate;
@ -147,11 +144,9 @@ class VIEWS_EXPORT CustomButton : public Button,
void NotifyClick(const ui::Event& event) override; void NotifyClick(const ui::Event& event) override;
void OnClickCanceled(const ui::Event& event) override; void OnClickCanceled(const ui::Event& event) override;
// The button state (defined in implementation) const gfx::ThrobAnimation& hover_animation() const {
ButtonState state_; return hover_animation_;
}
// Hover animation.
scoped_ptr<gfx::ThrobAnimation> hover_animation_;
private: private:
// Returns true if this is not a top level widget. Virtual for tests. // Returns true if this is not a top level widget. Virtual for tests.
@ -159,6 +154,10 @@ class VIEWS_EXPORT CustomButton : public Button,
// Returns true if the focus is not in a top level widget. Virtual for tests. // Returns true if the focus is not in a top level widget. Virtual for tests.
virtual bool FocusInChildWidget() const; virtual bool FocusInChildWidget() const;
ButtonState state_;
gfx::ThrobAnimation hover_animation_;
// Should we animate when the state changes? Defaults to true. // Should we animate when the state changes? Defaults to true.
bool animate_on_state_change_; bool animate_on_state_change_;

@ -145,11 +145,12 @@ void ImageButton::OnBlur() {
gfx::ImageSkia ImageButton::GetImageToPaint() { gfx::ImageSkia ImageButton::GetImageToPaint() {
gfx::ImageSkia img; gfx::ImageSkia img;
if (!images_[STATE_HOVERED].isNull() && hover_animation_->is_animating()) { if (!images_[STATE_HOVERED].isNull() && hover_animation().is_animating()) {
img = gfx::ImageSkiaOperations::CreateBlendedImage(images_[STATE_NORMAL], img = gfx::ImageSkiaOperations::CreateBlendedImage(
images_[STATE_HOVERED], hover_animation_->GetCurrentValue()); images_[STATE_NORMAL], images_[STATE_HOVERED],
hover_animation().GetCurrentValue());
} else { } else {
img = images_[state_]; img = images_[state()];
} }
return !img.isNull() ? img : images_[STATE_NORMAL]; return !img.isNull() ? img : images_[STATE_NORMAL];
@ -212,14 +213,14 @@ void ToggleImageButton::SetToggled(bool toggled) {
NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true);
} }
void ToggleImageButton::SetToggledImage(ButtonState state, void ToggleImageButton::SetToggledImage(ButtonState image_state,
const gfx::ImageSkia* image) { const gfx::ImageSkia* image) {
if (toggled_) { if (toggled_) {
images_[state] = image ? *image : gfx::ImageSkia(); images_[image_state] = image ? *image : gfx::ImageSkia();
if (state_ == state) if (state() == image_state)
SchedulePaint(); SchedulePaint();
} else { } else {
alternate_images_[state] = image ? *image : gfx::ImageSkia(); alternate_images_[image_state] = image ? *image : gfx::ImageSkia();
} }
} }
@ -230,19 +231,20 @@ void ToggleImageButton::SetToggledTooltipText(const base::string16& tooltip) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// ToggleImageButton, ImageButton overrides: // ToggleImageButton, ImageButton overrides:
const gfx::ImageSkia& ToggleImageButton::GetImage(ButtonState state) const { const gfx::ImageSkia& ToggleImageButton::GetImage(
ButtonState image_state) const {
if (toggled_) if (toggled_)
return alternate_images_[state]; return alternate_images_[image_state];
return images_[state]; return images_[image_state];
} }
void ToggleImageButton::SetImage(ButtonState state, void ToggleImageButton::SetImage(ButtonState image_state,
const gfx::ImageSkia* image) { const gfx::ImageSkia* image) {
if (toggled_) { if (toggled_) {
alternate_images_[state] = image ? *image : gfx::ImageSkia(); alternate_images_[image_state] = image ? *image : gfx::ImageSkia();
} else { } else {
images_[state] = image ? *image : gfx::ImageSkia(); images_[image_state] = image ? *image : gfx::ImageSkia();
if (state_ == state) if (state() == image_state)
SchedulePaint(); SchedulePaint();
} }
PreferredSizeChanged(); PreferredSizeChanged();

@ -501,7 +501,7 @@ ui::NativeTheme::State LabelButton::GetThemeState(
} }
const gfx::Animation* LabelButton::GetThemeAnimation() const { const gfx::Animation* LabelButton::GetThemeAnimation() const {
return hover_animation_.get(); return &hover_animation();
} }
ui::NativeTheme::State LabelButton::GetBackgroundThemeState( ui::NativeTheme::State LabelButton::GetBackgroundThemeState(

@ -101,7 +101,7 @@ class TransparentButton : public CustomButton {
} }
double GetAnimationValue() const { double GetAnimationValue() const {
return hover_animation_->GetCurrentValue(); return hover_animation().GetCurrentValue();
} }
private: private:

@ -96,7 +96,7 @@ ui::NativeTheme::ExtraParams
ScrollBarButton::GetNativeThemeParams() const { ScrollBarButton::GetNativeThemeParams() const {
ui::NativeTheme::ExtraParams params; ui::NativeTheme::ExtraParams params;
switch (state_) { switch (state()) {
case CustomButton::STATE_HOVERED: case CustomButton::STATE_HOVERED:
params.scrollbar_arrow.is_hovering = true; params.scrollbar_arrow.is_hovering = true;
break; break;
@ -119,32 +119,29 @@ ui::NativeTheme::Part
return ui::NativeTheme::kScrollbarLeftArrow; return ui::NativeTheme::kScrollbarLeftArrow;
case RIGHT: case RIGHT:
return ui::NativeTheme::kScrollbarRightArrow; return ui::NativeTheme::kScrollbarRightArrow;
default:
return ui::NativeTheme::kScrollbarUpArrow;
} }
NOTREACHED();
return ui::NativeTheme::kScrollbarUpArrow;
} }
ui::NativeTheme::State ui::NativeTheme::State
ScrollBarButton::GetNativeThemeState() const { ScrollBarButton::GetNativeThemeState() const {
ui::NativeTheme::State state; switch (state()) {
switch (state_) {
case CustomButton::STATE_HOVERED: case CustomButton::STATE_HOVERED:
state = ui::NativeTheme::kHovered; return ui::NativeTheme::kHovered;
break;
case CustomButton::STATE_PRESSED: case CustomButton::STATE_PRESSED:
state = ui::NativeTheme::kPressed; return ui::NativeTheme::kPressed;
break;
case CustomButton::STATE_DISABLED: case CustomButton::STATE_DISABLED:
state = ui::NativeTheme::kDisabled; return ui::NativeTheme::kDisabled;
break;
case CustomButton::STATE_NORMAL: case CustomButton::STATE_NORMAL:
default: return ui::NativeTheme::kNormal;
state = ui::NativeTheme::kNormal; case CustomButton::STATE_COUNT:
break; break;
} }
return state; NOTREACHED();
return ui::NativeTheme::kNormal;
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -197,25 +194,21 @@ ui::NativeTheme::Part ScrollBarThumb::GetNativeThemePart() const {
} }
ui::NativeTheme::State ScrollBarThumb::GetNativeThemeState() const { ui::NativeTheme::State ScrollBarThumb::GetNativeThemeState() const {
ui::NativeTheme::State state;
switch (GetState()) { switch (GetState()) {
case CustomButton::STATE_HOVERED: case CustomButton::STATE_HOVERED:
state = ui::NativeTheme::kHovered; return ui::NativeTheme::kHovered;
break;
case CustomButton::STATE_PRESSED: case CustomButton::STATE_PRESSED:
state = ui::NativeTheme::kPressed; return ui::NativeTheme::kPressed;
break;
case CustomButton::STATE_DISABLED: case CustomButton::STATE_DISABLED:
state = ui::NativeTheme::kDisabled; return ui::NativeTheme::kDisabled;
break;
case CustomButton::STATE_NORMAL: case CustomButton::STATE_NORMAL:
default: return ui::NativeTheme::kNormal;
state = ui::NativeTheme::kNormal; case CustomButton::STATE_COUNT:
break; break;
} }
return state; NOTREACHED();
return ui::NativeTheme::kNormal;
} }
} // namespace } // namespace

@ -170,8 +170,6 @@
'controls/scrollbar/base_scroll_bar_button.h', 'controls/scrollbar/base_scroll_bar_button.h',
'controls/scrollbar/base_scroll_bar_thumb.cc', 'controls/scrollbar/base_scroll_bar_thumb.cc',
'controls/scrollbar/base_scroll_bar_thumb.h', 'controls/scrollbar/base_scroll_bar_thumb.h',
'controls/scrollbar/kennedy_scroll_bar.cc',
'controls/scrollbar/kennedy_scroll_bar.h',
'controls/scrollbar/native_scroll_bar.cc', 'controls/scrollbar/native_scroll_bar.cc',
'controls/scrollbar/native_scroll_bar.h', 'controls/scrollbar/native_scroll_bar.h',
'controls/scrollbar/native_scroll_bar_views.cc', 'controls/scrollbar/native_scroll_bar_views.cc',