| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
| 6 #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // A button that shows a menu when the left mouse button is pushed | 25 // A button that shows a menu when the left mouse button is pushed |
| 26 // | 26 // |
| 27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
| 28 class VIEWS_EXPORT MenuButton : public LabelButton { | 28 class VIEWS_EXPORT MenuButton : public LabelButton { |
| 29 public: | 29 public: |
| 30 // A scoped lock for keeping the MenuButton in STATE_PRESSED e.g., while a | 30 // A scoped lock for keeping the MenuButton in STATE_PRESSED e.g., while a |
| 31 // menu is running. These are cumulative. | 31 // menu is running. These are cumulative. |
| 32 class VIEWS_EXPORT PressedLock { | 32 class VIEWS_EXPORT PressedLock { |
| 33 public: | 33 public: |
| 34 explicit PressedLock(MenuButton* menu_button); | 34 explicit PressedLock(MenuButton* menu_button); |
| 35 PressedLock(MenuButton* menu_button, bool is_sibling_menu_show); | 35 // |event| is the event that caused the button to be pressed. May be null. |
| 36 PressedLock(MenuButton* menu_button, |
| 37 bool is_sibling_menu_show, |
| 38 const ui::LocatedEvent* event); |
| 36 ~PressedLock(); | 39 ~PressedLock(); |
| 37 | 40 |
| 38 private: | 41 private: |
| 39 base::WeakPtr<MenuButton> menu_button_; | 42 base::WeakPtr<MenuButton> menu_button_; |
| 40 | 43 |
| 41 DISALLOW_COPY_AND_ASSIGN(PressedLock); | 44 DISALLOW_COPY_AND_ASSIGN(PressedLock); |
| 42 }; | 45 }; |
| 43 | 46 |
| 44 static const char kViewClassName[]; | 47 static const char kViewClassName[]; |
| 45 | 48 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 104 |
| 102 // Offset of the associated menu position. | 105 // Offset of the associated menu position. |
| 103 gfx::Point menu_offset_; | 106 gfx::Point menu_offset_; |
| 104 | 107 |
| 105 private: | 108 private: |
| 106 friend class PressedLock; | 109 friend class PressedLock; |
| 107 | 110 |
| 108 // Increment/decrement the number of "pressed" locks this button has, and | 111 // Increment/decrement the number of "pressed" locks this button has, and |
| 109 // set the state accordingly. The ink drop is snapped to the final ACTIVATED | 112 // set the state accordingly. The ink drop is snapped to the final ACTIVATED |
| 110 // state if |snap_ink_drop_to_activated| is true, otherwise the ink drop will | 113 // state if |snap_ink_drop_to_activated| is true, otherwise the ink drop will |
| 111 // be animated to the ACTIVATED node_data. | 114 // be animated to the ACTIVATED node_data. The ink drop is animated at the |
| 112 void IncrementPressedLocked(bool snap_ink_drop_to_activated); | 115 // location of |event| if non-null, otherwise at the default location. |
| 116 void IncrementPressedLocked(bool snap_ink_drop_to_activated, |
| 117 const ui::LocatedEvent* event); |
| 113 void DecrementPressedLocked(); | 118 void DecrementPressedLocked(); |
| 114 | 119 |
| 115 // Compute the maximum X coordinate for the current screen. MenuButtons | 120 // Compute the maximum X coordinate for the current screen. MenuButtons |
| 116 // use this to make sure a menu is never shown off screen. | 121 // use this to make sure a menu is never shown off screen. |
| 117 int GetMaximumScreenXCoordinate(); | 122 int GetMaximumScreenXCoordinate(); |
| 118 | 123 |
| 119 // We use a time object in order to keep track of when the menu was closed. | 124 // We use a time object in order to keep track of when the menu was closed. |
| 120 // The time is used for simulating menu behavior for the menu button; that | 125 // The time is used for simulating menu behavior for the menu button; that |
| 121 // is, if the menu is shown and the button is pressed, we need to close the | 126 // is, if the menu is shown and the button is pressed, we need to close the |
| 122 // menu. There is no clean way to get the second click event because the | 127 // menu. There is no clean way to get the second click event because the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 bool should_disable_after_press_; | 154 bool should_disable_after_press_; |
| 150 | 155 |
| 151 base::WeakPtrFactory<MenuButton> weak_factory_; | 156 base::WeakPtrFactory<MenuButton> weak_factory_; |
| 152 | 157 |
| 153 DISALLOW_COPY_AND_ASSIGN(MenuButton); | 158 DISALLOW_COPY_AND_ASSIGN(MenuButton); |
| 154 }; | 159 }; |
| 155 | 160 |
| 156 } // namespace views | 161 } // namespace views |
| 157 | 162 |
| 158 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 163 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
| OLD | NEW |