Chromium Code Reviews| 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 first_menu_show); | |
|
sky
2016/03/11 20:41:32
Rather than explicitly supplying the state can you
bruthig
2016/03/11 21:58:20
Naively, I'm not aware of any way for a MenuButton
sky
2016/03/11 23:11:14
MenuController::GetActiveInstance, but you're righ
| |
| 35 ~PressedLock(); | 36 ~PressedLock(); |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 base::WeakPtr<MenuButton> menu_button_; | 39 base::WeakPtr<MenuButton> menu_button_; |
| 39 | 40 |
| 40 DISALLOW_COPY_AND_ASSIGN(PressedLock); | 41 DISALLOW_COPY_AND_ASSIGN(PressedLock); |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 static const char kViewClassName[]; | 44 static const char kViewClassName[]; |
| 44 | 45 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 void StateChanged() override; | 99 void StateChanged() override; |
| 99 void NotifyClick(const ui::Event& event) override; | 100 void NotifyClick(const ui::Event& event) override; |
| 100 | 101 |
| 101 // Offset of the associated menu position. | 102 // Offset of the associated menu position. |
| 102 gfx::Point menu_offset_; | 103 gfx::Point menu_offset_; |
| 103 | 104 |
| 104 private: | 105 private: |
| 105 friend class PressedLock; | 106 friend class PressedLock; |
| 106 | 107 |
| 107 // Increment/decrement the number of "pressed" locks this button has, and | 108 // Increment/decrement the number of "pressed" locks this button has, and |
| 108 // set the state accordingly. | 109 // set the state accordingly. The ink drop is animated to the ACTIVATED state |
| 109 void IncrementPressedLocked(); | 110 // if |animate_ink_drop| is true and will be snapped to it's final frame if |
| 111 // false. | |
| 112 void IncrementPressedLocked(bool animate_ink_drop); | |
| 110 void DecrementPressedLocked(); | 113 void DecrementPressedLocked(); |
| 111 | 114 |
| 112 // Compute the maximum X coordinate for the current screen. MenuButtons | 115 // Compute the maximum X coordinate for the current screen. MenuButtons |
| 113 // use this to make sure a menu is never shown off screen. | 116 // use this to make sure a menu is never shown off screen. |
| 114 int GetMaximumScreenXCoordinate(); | 117 int GetMaximumScreenXCoordinate(); |
| 115 | 118 |
| 116 // We use a time object in order to keep track of when the menu was closed. | 119 // We use a time object in order to keep track of when the menu was closed. |
| 117 // The time is used for simulating menu behavior for the menu button; that | 120 // The time is used for simulating menu behavior for the menu button; that |
| 118 // is, if the menu is shown and the button is pressed, we need to close the | 121 // is, if the menu is shown and the button is pressed, we need to close the |
| 119 // menu. There is no clean way to get the second click event because the | 122 // menu. There is no clean way to get the second click event because the |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 146 bool should_disable_after_press_; | 149 bool should_disable_after_press_; |
| 147 | 150 |
| 148 base::WeakPtrFactory<MenuButton> weak_factory_; | 151 base::WeakPtrFactory<MenuButton> weak_factory_; |
| 149 | 152 |
| 150 DISALLOW_COPY_AND_ASSIGN(MenuButton); | 153 DISALLOW_COPY_AND_ASSIGN(MenuButton); |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 } // namespace views | 156 } // namespace views |
| 154 | 157 |
| 155 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 158 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
| OLD | NEW |