OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
10 #include "ui/views/animation/ink_drop_host.h" | 10 #include "ui/views/animation/ink_drop_host.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 bool IsMenuShowing() const; | 41 bool IsMenuShowing() const; |
42 | 42 |
43 // views::LabelButton: | 43 // views::LabelButton: |
44 gfx::Size GetPreferredSize() const override; | 44 gfx::Size GetPreferredSize() const override; |
45 void Layout() override; | 45 void Layout() override; |
46 bool OnMousePressed(const ui::MouseEvent& event) override; | 46 bool OnMousePressed(const ui::MouseEvent& event) override; |
47 bool OnMouseDragged(const ui::MouseEvent& event) override; | 47 bool OnMouseDragged(const ui::MouseEvent& event) override; |
48 void OnMouseReleased(const ui::MouseEvent& event) override; | 48 void OnMouseReleased(const ui::MouseEvent& event) override; |
49 // Showing the drop down results in a MouseCaptureLost, we need to ignore it. | 49 // Showing the drop down results in a MouseCaptureLost, we need to ignore it. |
50 void OnMouseCaptureLost() override; | 50 void OnMouseCaptureLost() override; |
| 51 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 52 void OnMouseMoved(const ui::MouseEvent& event) override; |
51 void OnMouseExited(const ui::MouseEvent& event) override; | 53 void OnMouseExited(const ui::MouseEvent& event) override; |
52 void OnGestureEvent(ui::GestureEvent* event) override; | 54 void OnGestureEvent(ui::GestureEvent* event) override; |
53 void GetAccessibleState(ui::AXViewState* state) override; | 55 void GetAccessibleState(ui::AXViewState* state) override; |
54 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; | 56 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; |
| 57 void OnEnabledChanged() override; |
55 | 58 |
56 // views::ContextMenuController: | 59 // views::ContextMenuController: |
57 void ShowContextMenuForView(View* source, | 60 void ShowContextMenuForView(View* source, |
58 const gfx::Point& point, | 61 const gfx::Point& point, |
59 ui::MenuSourceType source_type) override; | 62 ui::MenuSourceType source_type) override; |
60 | 63 |
61 // views::InkDropHost: | 64 // views::InkDropHost: |
62 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | 65 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |
63 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; | 66 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; |
64 | 67 |
65 protected: | 68 protected: |
66 // views::LabelButton: | 69 // views::LabelButton: |
67 bool ShouldEnterPushedState(const ui::Event& event) override; | 70 bool ShouldEnterPushedState(const ui::Event& event) override; |
68 void NotifyClick(const ui::Event& event) override; | 71 void NotifyClick(const ui::Event& event) override; |
69 | 72 |
70 // Returns if menu should be shown. Override this to change default behavior. | 73 // Returns if menu should be shown. Override this to change default behavior. |
71 virtual bool ShouldShowMenu(); | 74 virtual bool ShouldShowMenu(); |
72 | 75 |
73 // Function to show the dropdown menu. | 76 // Function to show the dropdown menu. |
74 virtual void ShowDropDownMenu(ui::MenuSourceType source_type); | 77 virtual void ShowDropDownMenu(ui::MenuSourceType source_type); |
75 | 78 |
76 // Returns the Point where the ink drop should be centered. | 79 // Returns the Point where the ink drop should be centered. |
77 virtual gfx::Point CalculateInkDropCenter() const; | 80 virtual gfx::Point CalculateInkDropCenter() const; |
78 | 81 |
79 views::InkDropAnimationController* ink_drop_animation_controller() { | 82 views::InkDropAnimationController* ink_drop_animation_controller() { |
80 return ink_drop_animation_controller_.get(); | 83 return ink_drop_animation_controller_.get(); |
81 } | 84 } |
82 | 85 |
83 private: | 86 private: |
| 87 // Updates the |ink_drop_animation_controller_|'s hover state. |
| 88 void UpdateInkDropHoverState(); |
| 89 |
84 // views::LabelButton: | 90 // views::LabelButton: |
85 const char* GetClassName() const override; | 91 const char* GetClassName() const override; |
86 | 92 |
87 // The model that populates the attached menu. | 93 // The model that populates the attached menu. |
88 scoped_ptr<ui::MenuModel> model_; | 94 scoped_ptr<ui::MenuModel> model_; |
89 | 95 |
90 // Indicates if menu is currently showing. | 96 // Indicates if menu is currently showing. |
91 bool menu_showing_; | 97 bool menu_showing_; |
92 | 98 |
93 // Y position of mouse when left mouse button is pressed | 99 // Y position of mouse when left mouse button is pressed |
94 int y_position_on_lbuttondown_; | 100 int y_position_on_lbuttondown_; |
95 | 101 |
96 // Menu runner to display drop down menu. | 102 // Menu runner to display drop down menu. |
97 scoped_ptr<views::MenuRunner> menu_runner_; | 103 scoped_ptr<views::MenuRunner> menu_runner_; |
98 | 104 |
99 // Animation controller for the ink drop ripple effect. | 105 // Animation controller for the mouse hover and ink drop ripple effect. |
100 scoped_ptr<views::InkDropAnimationController> ink_drop_animation_controller_; | 106 scoped_ptr<views::InkDropAnimationController> ink_drop_animation_controller_; |
101 | 107 |
102 // A factory for tasks that show the dropdown context menu for the button. | 108 // A factory for tasks that show the dropdown context menu for the button. |
103 base::WeakPtrFactory<ToolbarButton> show_menu_factory_; | 109 base::WeakPtrFactory<ToolbarButton> show_menu_factory_; |
104 | 110 |
105 DISALLOW_COPY_AND_ASSIGN(ToolbarButton); | 111 DISALLOW_COPY_AND_ASSIGN(ToolbarButton); |
106 }; | 112 }; |
107 | 113 |
108 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ | 114 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_BUTTON_H_ |
OLD | NEW |