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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/checkbox.cc ('k') | ui/views/controls/button/custom_button.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/custom_button.h
diff --git a/ui/views/controls/button/custom_button.h b/ui/views/controls/button/custom_button.h
deleted file mode 100644
index 5b2935850b483187c9d6b2d3f3cfd0fcb9db7a6b..0000000000000000000000000000000000000000
--- a/ui/views/controls/button/custom_button.h
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_
-#define UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "ui/events/event_constants.h"
-#include "ui/gfx/animation/animation_delegate.h"
-#include "ui/views/controls/button/button.h"
-
-namespace gfx {
-class ThrobAnimation;
-}
-
-namespace views {
-
-class CustomButtonStateChangedDelegate;
-
-// A button with custom rendering. The base of ImageButton and LabelButton.
-// Note that this type of button is not focusable by default and will not be
-// part of the focus chain. Call SetFocusable(true) to make it part of the
-// focus chain.
-class VIEWS_EXPORT CustomButton : public Button,
- public gfx::AnimationDelegate {
- public:
- // The menu button's class name.
- static const char kViewClassName[];
-
- static const CustomButton* AsCustomButton(const views::View* view);
- static CustomButton* AsCustomButton(views::View* view);
-
- virtual ~CustomButton();
-
- // Get/sets the current display state of the button.
- ButtonState state() const { return state_; }
- void SetState(ButtonState state);
-
- // Starts throbbing. See HoverAnimation for a description of cycles_til_stop.
- void StartThrobbing(int cycles_til_stop);
-
- // Stops throbbing immediately.
- void StopThrobbing();
-
- // Set how long the hover animation will last for.
- void SetAnimationDuration(int duration);
-
- void set_triggerable_event_flags(int triggerable_event_flags) {
- triggerable_event_flags_ = triggerable_event_flags;
- }
- int triggerable_event_flags() const { return triggerable_event_flags_; }
-
- // Sets whether |RequestFocus| should be invoked on a mouse press. The default
- // is true.
- void set_request_focus_on_press(bool value) {
- request_focus_on_press_ = value;
- }
- bool request_focus_on_press() const { return request_focus_on_press_; }
-
- // See description above field.
- void set_animate_on_state_change(bool value) {
- animate_on_state_change_ = value;
- }
-
- void SetHotTracked(bool is_hot_tracked);
- bool IsHotTracked() const;
-
- // Overridden from View:
- virtual void OnEnabledChanged() override;
- virtual const char* GetClassName() const override;
- virtual bool OnMousePressed(const ui::MouseEvent& event) override;
- virtual bool OnMouseDragged(const ui::MouseEvent& event) override;
- virtual void OnMouseReleased(const ui::MouseEvent& event) override;
- virtual void OnMouseCaptureLost() override;
- virtual void OnMouseEntered(const ui::MouseEvent& event) override;
- virtual void OnMouseExited(const ui::MouseEvent& event) override;
- virtual void OnMouseMoved(const ui::MouseEvent& event) override;
- virtual bool OnKeyPressed(const ui::KeyEvent& event) override;
- virtual bool OnKeyReleased(const ui::KeyEvent& event) override;
- virtual void OnGestureEvent(ui::GestureEvent* event) override;
- virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
- virtual void ShowContextMenu(const gfx::Point& p,
- ui::MenuSourceType source_type) override;
- virtual void OnDragDone() override;
- virtual void GetAccessibleState(ui::AXViewState* state) override;
- virtual void VisibilityChanged(View* starting_from, bool is_visible) override;
-
- // Overridden from gfx::AnimationDelegate:
- virtual void AnimationProgressed(const gfx::Animation* animation) override;
-
- // Takes ownership of the delegate.
- void set_state_changed_delegate(CustomButtonStateChangedDelegate* delegate) {
- state_changed_delegate_.reset(delegate);
- }
-
- protected:
- // Construct the Button with a Listener. See comment for Button's ctor.
- explicit CustomButton(ButtonListener* listener);
-
- // Invoked from SetState() when SetState() is passed a value that differs from
- // the current state. CustomButton's implementation of StateChanged() does
- // nothing; this method is provided for subclasses that wish to do something
- // on state changes.
- virtual void StateChanged();
-
- // Returns true if the event is one that can trigger notifying the listener.
- // This implementation returns true if the left mouse button is down.
- virtual bool IsTriggerableEvent(const ui::Event& event);
-
- // Returns true if the button should become pressed when the user
- // holds the mouse down over the button. For this implementation,
- // we simply return IsTriggerableEvent(event).
- virtual bool ShouldEnterPushedState(const ui::Event& event);
-
- // Overridden from View:
- virtual void ViewHierarchyChanged(
- const ViewHierarchyChangedDetails& details) override;
- virtual void OnBlur() override;
-
- // The button state (defined in implementation)
- ButtonState state_;
-
- // Hover animation.
- scoped_ptr<gfx::ThrobAnimation> hover_animation_;
-
- private:
- // Should we animate when the state changes? Defaults to true.
- bool animate_on_state_change_;
-
- // Is the hover animation running because StartThrob was invoked?
- bool is_throbbing_;
-
- // Mouse event flags which can trigger button actions.
- int triggerable_event_flags_;
-
- // See description above setter.
- bool request_focus_on_press_;
-
- scoped_ptr<CustomButtonStateChangedDelegate> state_changed_delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(CustomButton);
-};
-
-// Delegate for actions taken on state changes by CustomButton.
-class VIEWS_EXPORT CustomButtonStateChangedDelegate {
-public:
- virtual ~CustomButtonStateChangedDelegate() {}
- virtual void StateChanged(Button::ButtonState state) = 0;
-
-protected:
- CustomButtonStateChangedDelegate() {}
-
-private:
- DISALLOW_COPY_AND_ASSIGN(CustomButtonStateChangedDelegate);
-};
-
-} // namespace views
-
-#endif // UI_VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_
« no previous file with comments | « ui/views/controls/button/checkbox.cc ('k') | ui/views/controls/button/custom_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698