diff options
Diffstat (limited to 'chromium/ui/views/controls/button/button.h')
-rw-r--r-- | chromium/ui/views/controls/button/button.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/chromium/ui/views/controls/button/button.h b/chromium/ui/views/controls/button/button.h index 050512ffa34..6cdedf42582 100644 --- a/chromium/ui/views/controls/button/button.h +++ b/chromium/ui/views/controls/button/button.h @@ -15,6 +15,7 @@ #include "ui/views/animation/ink_drop_state.h" #include "ui/views/controls/focus_ring.h" #include "ui/views/painter.h" +#include "ui/views/widget/widget_observer.h" namespace views { @@ -87,7 +88,7 @@ class VIEWS_EXPORT Button : public InkDropHostView, void set_tag(int tag) { tag_ = tag; } void SetAccessibleName(const base::string16& name); - const base::string16& accessible_name() const { return accessible_name_; } + const base::string16& GetAccessibleName() const; // Get/sets the current display state of the button. ButtonState state() const { return state_; } @@ -96,6 +97,9 @@ class VIEWS_EXPORT Button : public InkDropHostView, // like event dispatching, focus traversals, etc. Calling SetEnabled(false) // will also set the state of |this| to STATE_DISABLED. void SetState(ButtonState state); + // Returns the visual appearance state of the button. This takes into account + // both the button's display state and the state of the containing widget. + ButtonState GetVisualState() const; // Starts throbbing. See HoverAnimation for a description of cycles_til_stop. // This method does nothing if |animate_on_state_change_| is false. @@ -183,6 +187,8 @@ class VIEWS_EXPORT Button : public InkDropHostView, const ViewHierarchyChangedDetails& details) override; void OnFocus() override; void OnBlur() override; + void AddedToWidget() override; + void RemovedFromWidget() override; // Overridden from InkDropHostView: std::unique_ptr<InkDrop> CreateInkDrop() override; @@ -261,6 +267,28 @@ class VIEWS_EXPORT Button : public InkDropHostView, private: FRIEND_TEST_ALL_PREFIXES(BlueButtonTest, Border); + // Bridge class to allow Button to observe a Widget without being a + // WidgetObserver. This is desirable because many Button subclasses are + // themselves WidgetObservers, and if Button is a WidgetObserver, any change + // to its WidgetObserver overrides requires updating all the subclasses as + // well. + class WidgetObserverButtonBridge : public WidgetObserver { + public: + WidgetObserverButtonBridge(Button* owner); + ~WidgetObserverButtonBridge() override; + + // WidgetObserver: + void OnWidgetActivationChanged(Widget* widget, bool active) override; + void OnWidgetDestroying(Widget* widget) override; + + private: + Button* owner_; + + DISALLOW_COPY_AND_ASSIGN(WidgetObserverButtonBridge); + }; + + void WidgetActivationChanged(Widget* widget, bool active); + // The text shown in a tooltip. base::string16 tooltip_text_; @@ -306,6 +334,8 @@ class VIEWS_EXPORT Button : public InkDropHostView, std::unique_ptr<Painter> focus_painter_; + std::unique_ptr<WidgetObserverButtonBridge> widget_observer_; + DISALLOW_COPY_AND_ASSIGN(Button); }; |