X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fui%2Fviews%2Fcontrols%2Fbutton%2Fmenu_button.h;h=1eedc0f7d6b0fc03654765fdf9020102460992a5;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=da67506ca45ec3244520b05b199ca5c6e1e08c15;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ui/views/controls/button/menu_button.h b/src/ui/views/controls/button/menu_button.h index da67506..1eedc0f 100644 --- a/src/ui/views/controls/button/menu_button.h +++ b/src/ui/views/controls/button/menu_button.h @@ -7,6 +7,7 @@ #include +#include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "base/time/time.h" #include "ui/views/background.h" @@ -25,6 +26,19 @@ class MenuButtonListener; //////////////////////////////////////////////////////////////////////////////// class VIEWS_EXPORT MenuButton : public LabelButton { public: + // A scoped lock for keeping the MenuButton in STATE_PRESSED e.g., while a + // menu is running. These are cumulative. + class VIEWS_EXPORT PressedLock { + public: + explicit PressedLock(MenuButton* menu_button); + ~PressedLock(); + + private: + base::WeakPtr menu_button_; + + DISALLOW_COPY_AND_ASSIGN(PressedLock); + }; + static const char kViewClassName[]; // How much padding to put on the left and right of the menu marker. @@ -56,7 +70,9 @@ class VIEWS_EXPORT MenuButton : public LabelButton { virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const ui::MouseEvent& event) 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 void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; @@ -69,13 +85,17 @@ class VIEWS_EXPORT MenuButton : public LabelButton { // Overridden from LabelButton: virtual gfx::Rect GetChildAreaBounds() OVERRIDE; - // True if the menu is currently visible. - bool menu_visible_; - // Offset of the associated menu position. gfx::Point menu_offset_; private: + friend class PressedLock; + + // Increment/decrement the number of "pressed" locks this button has, and + // set the state accordingly. + void IncrementPressedLocked(); + void DecrementPressedLocked(); + // Compute the maximum X coordinate for the current screen. MenuButtons // use this to make sure a menu is never shown off screen. int GetMaximumScreenXCoordinate(); @@ -101,6 +121,11 @@ class VIEWS_EXPORT MenuButton : public LabelButton { // showing and used to detect if the menu was deleted while running. bool* destroyed_flag_; + // The current number of "pressed" locks this button has. + int pressed_lock_count_; + + base::WeakPtrFactory weak_factory_; + DISALLOW_COPY_AND_ASSIGN(MenuButton); };