diff options
Diffstat (limited to 'views/controls/button')
-rw-r--r-- | views/controls/button/checkbox.cc | 6 | ||||
-rw-r--r-- | views/controls/button/checkbox.h | 2 | ||||
-rw-r--r-- | views/controls/button/custom_button.cc | 8 | ||||
-rw-r--r-- | views/controls/button/custom_button.h | 4 | ||||
-rw-r--r-- | views/controls/button/native_button.cc | 4 | ||||
-rw-r--r-- | views/controls/button/native_button.h | 2 | ||||
-rw-r--r-- | views/controls/button/text_button.cc | 7 | ||||
-rw-r--r-- | views/controls/button/text_button.h | 2 |
8 files changed, 16 insertions, 19 deletions
diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index 71116cd..8221b56 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -90,10 +90,10 @@ int Checkbox::GetHeightForWidth(int w) { return label_->GetHeightForWidth(std::max(prefsize.height(), w - width)); } -void Checkbox::SetEnabled(bool enabled) { - NativeButtonBase::SetEnabled(enabled); +void Checkbox::OnEnabledChanged() { + NativeButtonBase::OnEnabledChanged(); if (label_) - label_->SetEnabled(enabled); + label_->SetEnabled(IsEnabled()); } void Checkbox::Layout() { diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index cc4a3e0..430e558 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -45,7 +45,7 @@ class Checkbox : public NativeButtonBase { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual int GetHeightForWidth(int w) OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void Layout() OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index 95ecb98..dab4e32 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -91,11 +91,11 @@ bool CustomButton::IsHotTracked() const { return state_ == BS_HOT; } -void CustomButton::SetEnabled(bool enabled) { - if (enabled ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) +void CustomButton::OnEnabledChanged() { + if (View::IsEnabled() ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) return; - if (enabled) + if (View::IsEnabled()) SetState(IsMouseHovered() ? BS_HOT : BS_NORMAL); else SetState(BS_DISABLED); @@ -196,7 +196,7 @@ bool CustomButton::OnKeyReleased(const KeyEvent& event) { } bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { - if (!enabled_) + if (!View::IsEnabled()) return false; SetState(BS_NORMAL); diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h index b898483..8309751 100644 --- a/views/controls/button/custom_button.h +++ b/views/controls/button/custom_button.h @@ -6,8 +6,8 @@ #define VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ #pragma once -#include "views/controls/button/button.h" #include "ui/base/animation/animation_delegate.h" +#include "views/controls/button/button.h" namespace ui { class ThrobAnimation; @@ -75,7 +75,7 @@ class CustomButton : public Button, // Overridden from View: virtual void SetHotTracked(bool flag) OVERRIDE; virtual bool IsHotTracked() const OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual bool IsEnabled() const OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc index 0e2c1f5..679841a 100644 --- a/views/controls/button/native_button.cc +++ b/views/controls/button/native_button.cc @@ -164,8 +164,8 @@ void NativeButtonBase::Layout() { } } -void NativeButtonBase::SetEnabled(bool flag) { - Button::SetEnabled(flag); +void NativeButtonBase::OnEnabledChanged() { + Button::OnEnabledChanged(); if (native_wrapper_) native_wrapper_->UpdateEnabled(); } diff --git a/views/controls/button/native_button.h b/views/controls/button/native_button.h index 019bb77..a2f97cc 100644 --- a/views/controls/button/native_button.h +++ b/views/controls/button/native_button.h @@ -58,7 +58,7 @@ class NativeButtonBase : public Button { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; - virtual void SetEnabled(bool flag) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index e72deb3..e232763 100644 --- a/views/controls/button/text_button.cc +++ b/views/controls/button/text_button.cc @@ -560,14 +560,11 @@ gfx::Size TextButtonBase::GetMinimumSize() { return max_text_size_; } -void TextButtonBase::SetEnabled(bool enabled) { - if (enabled != IsEnabled()) { - CustomButton::SetEnabled(enabled); - } +void TextButtonBase::OnEnabledChanged() { // We should always call UpdateColor() since the state of the button might be // changed by other functions like CustomButton::SetState(). UpdateColor(); - SchedulePaint(); + CustomButton::OnEnabledChanged(); } std::string TextButtonBase::GetClassName() const { diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h index c878eb1..126c545 100644 --- a/views/controls/button/text_button.h +++ b/views/controls/button/text_button.h @@ -188,7 +188,7 @@ class TextButtonBase : public CustomButton, public NativeThemeDelegate { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetMinimumSize() OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; // Text colors. |