OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_ | 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_ |
6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_ | 6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/common/palette_delegate.h" | 12 #include "ash/common/palette_delegate.h" |
13 #include "ash/common/session/session_state_observer.h" | 13 #include "ash/common/session/session_state_observer.h" |
14 #include "ash/common/shell_observer.h" | 14 #include "ash/common/shell_observer.h" |
15 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 15 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
16 #include "ash/common/system/tray/tray_background_view.h" | 16 #include "ash/common/system/tray/tray_background_view.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "ui/events/devices/input_device_event_observer.h" |
19 | 20 |
20 namespace gfx { | 21 namespace gfx { |
21 class Point; | 22 class Point; |
22 } | 23 } |
23 | 24 |
24 namespace views { | 25 namespace views { |
25 class ImageView; | 26 class ImageView; |
26 class Widget; | 27 class Widget; |
27 } | 28 } |
28 | 29 |
29 namespace ash { | 30 namespace ash { |
30 | 31 |
31 class TrayBubbleWrapper; | 32 class TrayBubbleWrapper; |
32 class PaletteToolManager; | 33 class PaletteToolManager; |
33 | 34 |
34 // The PaletteTray shows the palette in the bottom area of the screen. This | 35 // The PaletteTray shows the palette in the bottom area of the screen. This |
35 // class also controls the lifetime for all of the tools available in the | 36 // class also controls the lifetime for all of the tools available in the |
36 // palette. | 37 // palette. |
37 class ASH_EXPORT PaletteTray : public TrayBackgroundView, | 38 class ASH_EXPORT PaletteTray : public TrayBackgroundView, |
38 public SessionStateObserver, | 39 public SessionStateObserver, |
39 public ShellObserver, | 40 public ShellObserver, |
40 public PaletteToolManager::Delegate, | 41 public PaletteToolManager::Delegate, |
| 42 public ui::InputDeviceEventObserver, |
41 public views::TrayBubbleView::Delegate { | 43 public views::TrayBubbleView::Delegate { |
42 public: | 44 public: |
43 explicit PaletteTray(WmShelf* wm_shelf); | 45 explicit PaletteTray(WmShelf* wm_shelf); |
44 ~PaletteTray() override; | 46 ~PaletteTray() override; |
45 | 47 |
46 // ActionableView: | 48 // ActionableView: |
47 bool PerformAction(const ui::Event& event) override; | 49 bool PerformAction(const ui::Event& event) override; |
48 | 50 |
49 // SessionStateObserver: | 51 // SessionStateObserver: |
50 void SessionStateChanged(session_manager::SessionState state) override; | 52 void SessionStateChanged(session_manager::SessionState state) override; |
(...skipping 20 matching lines...) Expand all Loading... |
71 | 73 |
72 // Opens up the palette if it is not already open. Returns true if the palette | 74 // Opens up the palette if it is not already open. Returns true if the palette |
73 // was opened. | 75 // was opened. |
74 bool ShowPalette(); | 76 bool ShowPalette(); |
75 | 77 |
76 // Returns true if the palette tray contains the given point. This is useful | 78 // Returns true if the palette tray contains the given point. This is useful |
77 // for determining if an event should be propagated through to the palette. | 79 // for determining if an event should be propagated through to the palette. |
78 bool ContainsPointInScreen(const gfx::Point& point); | 80 bool ContainsPointInScreen(const gfx::Point& point); |
79 | 81 |
80 private: | 82 private: |
| 83 // ui::InputDeviceObserver: |
| 84 void OnTouchscreenDeviceConfigurationChanged() override; |
| 85 void OnStylusStateChanged(ui::StylusState stylus_state) override; |
| 86 |
81 // views::TrayBubbleView::Delegate: | 87 // views::TrayBubbleView::Delegate: |
82 void BubbleViewDestroyed() override; | 88 void BubbleViewDestroyed() override; |
83 void OnMouseEnteredView() override; | 89 void OnMouseEnteredView() override; |
84 void OnMouseExitedView() override; | 90 void OnMouseExitedView() override; |
85 base::string16 GetAccessibleNameForBubble() override; | 91 base::string16 GetAccessibleNameForBubble() override; |
86 void OnBeforeBubbleWidgetInit( | 92 void OnBeforeBubbleWidgetInit( |
87 views::Widget* anchor_widget, | 93 views::Widget* anchor_widget, |
88 views::Widget* bubble_widget, | 94 views::Widget* bubble_widget, |
89 views::Widget::InitParams* params) const override; | 95 views::Widget::InitParams* params) const override; |
90 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 96 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
91 | 97 |
92 // PaletteToolManager::Delegate: | 98 // PaletteToolManager::Delegate: |
93 void OnActiveToolChanged() override; | 99 void OnActiveToolChanged() override; |
94 WmWindow* GetWindow() override; | 100 WmWindow* GetWindow() override; |
95 | 101 |
96 // Creates a new border for the icon. The padding is determined based on the | 102 // Creates a new border for the icon. The padding is determined based on the |
97 // alignment of the shelf. | 103 // alignment of the shelf. |
98 void SetIconBorderForShelfAlignment(); | 104 void SetIconBorderForShelfAlignment(); |
99 | 105 |
100 // Updates the tray icon from the palette tool manager. | 106 // Updates the tray icon from the palette tool manager. |
101 void UpdateTrayIcon(); | 107 void UpdateTrayIcon(); |
102 | 108 |
103 // Sets the icon to visible if the palette can be used. | 109 // Sets the icon to visible if the palette can be used. |
104 void UpdateIconVisibility(); | 110 void UpdateIconVisibility(); |
105 | 111 |
106 // Called when a stylus inserted or removed event is received. | |
107 void OnStylusStateChanged(ui::StylusState stylus_state); | |
108 | |
109 // Called when the palette enabled pref has changed. | 112 // Called when the palette enabled pref has changed. |
110 void OnPaletteEnabledPrefChanged(bool enabled); | 113 void OnPaletteEnabledPrefChanged(bool enabled); |
111 | 114 |
112 std::unique_ptr<PaletteToolManager> palette_tool_manager_; | 115 std::unique_ptr<PaletteToolManager> palette_tool_manager_; |
113 std::unique_ptr<TrayBubbleWrapper> bubble_; | 116 std::unique_ptr<TrayBubbleWrapper> bubble_; |
114 | 117 |
115 // Manages the callback OnPaletteEnabledPrefChanged callback registered to | 118 // Manages the callback OnPaletteEnabledPrefChanged callback registered to |
116 // the PaletteDelegate instance. | 119 // the PaletteDelegate instance. |
117 std::unique_ptr<PaletteDelegate::EnableListenerSubscription> | 120 std::unique_ptr<PaletteDelegate::EnableListenerSubscription> |
118 palette_enabled_subscription_; | 121 palette_enabled_subscription_; |
(...skipping 17 matching lines...) Expand all Loading... |
136 int num_actions_in_bubble_ = 0; | 139 int num_actions_in_bubble_ = 0; |
137 | 140 |
138 base::WeakPtrFactory<PaletteTray> weak_factory_; | 141 base::WeakPtrFactory<PaletteTray> weak_factory_; |
139 | 142 |
140 DISALLOW_COPY_AND_ASSIGN(PaletteTray); | 143 DISALLOW_COPY_AND_ASSIGN(PaletteTray); |
141 }; | 144 }; |
142 | 145 |
143 } // namespace ash | 146 } // namespace ash |
144 | 147 |
145 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_ | 148 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_BUTTON_TRAY_H_ |
OLD | NEW |