Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: ash/system/tray/tray_background_view.h

Issue 2807693002: Make LogoutButtonTray a regular View (Closed)
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/tray/system_tray_item.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 5 #ifndef ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/public/cpp/shelf_types.h"
12 #include "ash/shelf/shelf_background_animator_observer.h" 11 #include "ash/shelf/shelf_background_animator_observer.h"
13 #include "ash/system/tray/actionable_view.h" 12 #include "ash/system/tray/actionable_view.h"
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "ui/compositor/layer_animation_observer.h" 14 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/gfx/geometry/insets.h" 15 #include "ui/gfx/geometry/insets.h"
17 #include "ui/views/bubble/tray_bubble_view.h" 16 #include "ui/views/bubble/tray_bubble_view.h"
18 17
19 namespace ash { 18 namespace ash {
19 class TrayBackground;
20 class TrayContainer;
20 class TrayEventFilter; 21 class TrayEventFilter;
21 class TrayBackground;
22 class WmShelf; 22 class WmShelf;
23 23
24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, 24 // Base class for some children of StatusAreaWidget. This class handles setting
25 // LogoutButtonTray, OverviewButtonTray. 25 // and animating the background when the Launcher is shown/hidden. It also
26 // This class handles setting and animating the background when the Launcher 26 // inherits from ActionableView so that the tray items can override
27 // is shown/hidden. It also inherits from ActionableView so that the tray 27 // PerformAction when clicked on.
28 // items can override PerformAction when clicked on.
29 class ASH_EXPORT TrayBackgroundView : public ActionableView, 28 class ASH_EXPORT TrayBackgroundView : public ActionableView,
30 public ui::ImplicitAnimationObserver, 29 public ui::ImplicitAnimationObserver,
31 public ShelfBackgroundAnimatorObserver { 30 public ShelfBackgroundAnimatorObserver {
32 public: 31 public:
33 static const char kViewClassName[]; 32 static const char kViewClassName[];
34 33
35 // Base class for tray containers. Sets the border and layout. The container 34 explicit TrayBackgroundView(WmShelf* wm_shelf);
36 // auto-resizes the widget when necessary.
37 class TrayContainer : public views::View {
38 public:
39 explicit TrayContainer(ShelfAlignment alignment);
40 ~TrayContainer() override {}
41
42 void SetAlignment(ShelfAlignment alignment);
43
44 void SetMargin(int main_axis_margin, int cross_axis_margin);
45
46 protected:
47 // views::View:
48 void ChildPreferredSizeChanged(views::View* child) override;
49 void ChildVisibilityChanged(View* child) override;
50 void ViewHierarchyChanged(
51 const ViewHierarchyChangedDetails& details) override;
52
53 private:
54 void UpdateLayout();
55
56 ShelfAlignment alignment_;
57 int main_axis_margin_ = 0;
58 int cross_axis_margin_ = 0;
59
60 DISALLOW_COPY_AND_ASSIGN(TrayContainer);
61 };
62
63 // TODO(mohsen): Remove |draws_background| paramter when LogoutButtonTray, as
64 // the only reason for existence of this parameter, is no longer a
65 // TrayBackgroundView. See https://crbug.com/698134.
66 TrayBackgroundView(WmShelf* wm_shelf, bool draws_background);
67 ~TrayBackgroundView() override; 35 ~TrayBackgroundView() override;
68 36
69 // Called after the tray has been added to the widget containing it. 37 // Called after the tray has been added to the widget containing it.
70 virtual void Initialize(); 38 virtual void Initialize();
71 39
72 // Initializes animations for the bubble. 40 // Initializes animations for the bubble.
73 static void InitializeBubbleAnimations(views::Widget* bubble_widget); 41 static void InitializeBubbleAnimations(views::Widget* bubble_widget);
74 42
75 // views::View: 43 // views::View:
76 void SetVisible(bool visible) override; 44 void SetVisible(bool visible) override;
77 const char* GetClassName() const override; 45 const char* GetClassName() const override;
78 void ChildPreferredSizeChanged(views::View* child) override; 46 void ChildPreferredSizeChanged(views::View* child) override;
79 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 47 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
80 void AboutToRequestFocusFromTabTraversal(bool reverse) override; 48 void AboutToRequestFocusFromTabTraversal(bool reverse) override;
81 void OnPaint(gfx::Canvas* canvas) override; 49 void OnPaint(gfx::Canvas* canvas) override;
82 50
83 // ActionableView: 51 // ActionableView:
84 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; 52 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
85 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 53 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
86 const override; 54 const override;
87 55
88 // Called whenever the shelf alignment changes. 56 // Called whenever the shelf alignment changes.
89 virtual void SetShelfAlignment(ShelfAlignment alignment); 57 virtual void UpdateAfterShelfAlignmentChange();
90 58
91 // Called when the anchor (tray or bubble) may have moved or changed. 59 // Called when the anchor (tray or bubble) may have moved or changed.
92 virtual void AnchorUpdated() {} 60 virtual void AnchorUpdated() {}
93 61
94 // Called from GetAccessibleNodeData, must return a valid accessible name. 62 // Called from GetAccessibleNodeData, must return a valid accessible name.
95 virtual base::string16 GetAccessibleNameForTray() = 0; 63 virtual base::string16 GetAccessibleNameForTray() = 0;
96 64
97 // Called when the bubble is resized. 65 // Called when the bubble is resized.
98 virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {} 66 virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {}
99 67
100 // Hides the bubble associated with |bubble_view|. Called when the widget 68 // Hides the bubble associated with |bubble_view|. Called when the widget
101 // is closed. 69 // is closed.
102 virtual void HideBubbleWithView(const views::TrayBubbleView* bubble_view) = 0; 70 virtual void HideBubbleWithView(const views::TrayBubbleView* bubble_view) = 0;
103 71
104 // Called by the bubble wrapper when a click event occurs outside the bubble. 72 // Called by the bubble wrapper when a click event occurs outside the bubble.
105 // May close the bubble. 73 // May close the bubble.
106 virtual void ClickedOutsideBubble() = 0; 74 virtual void ClickedOutsideBubble() = 0;
107 75
108 // Returns the bubble anchor alignment based on |shelf_alignment_|. 76 // Returns the bubble anchor alignment based on |shelf_alignment_|.
109 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const; 77 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const;
110 78
111 void SetIsActive(bool is_active); 79 void SetIsActive(bool is_active);
112 bool is_active() const { return is_active_; } 80 bool is_active() const { return is_active_; }
113 81
114 TrayContainer* tray_container() const { return tray_container_; } 82 TrayContainer* tray_container() const { return tray_container_; }
115 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
116 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } 83 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); }
117 WmShelf* shelf() { return wm_shelf_; } 84 WmShelf* shelf() { return wm_shelf_; }
118 85
119 // Updates the arrow visibility based on the launcher visibility. 86 // Updates the arrow visibility based on the launcher visibility.
120 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); 87 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
121 88
122 // ShelfBackgroundAnimatorObserver: 89 // ShelfBackgroundAnimatorObserver:
123 void UpdateShelfItemBackground(SkColor color) override; 90 void UpdateShelfItemBackground(SkColor color) override;
124 91
125 // Updates the visibility of this tray's separator. 92 // Updates the visibility of this tray's separator.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Helper function that calculates background bounds relative to local bounds 125 // Helper function that calculates background bounds relative to local bounds
159 // based on background insets returned from GetBackgroundInsets(). 126 // based on background insets returned from GetBackgroundInsets().
160 gfx::Rect GetBackgroundBounds() const; 127 gfx::Rect GetBackgroundBounds() const;
161 128
162 // The shelf containing the system tray for this view. 129 // The shelf containing the system tray for this view.
163 WmShelf* wm_shelf_; 130 WmShelf* wm_shelf_;
164 131
165 // Convenience pointer to the contents view. 132 // Convenience pointer to the contents view.
166 TrayContainer* tray_container_; 133 TrayContainer* tray_container_;
167 134
168 // Shelf alignment.
169 // TODO(jamescook): Don't cache this, get it from WmShelf.
170 ShelfAlignment shelf_alignment_;
171
172 // Owned by the view passed to SetContents(). 135 // Owned by the view passed to SetContents().
173 TrayBackground* background_; 136 TrayBackground* background_;
174 137
175 // Determines if the view is active. This changes how the ink drop ripples 138 // Determines if the view is active. This changes how the ink drop ripples
176 // behave. 139 // behave.
177 bool is_active_; 140 bool is_active_;
178 141
179 // Visibility of this tray's separator which is a line of 1x32px and 4px to 142 // Visibility of this tray's separator which is a line of 1x32px and 4px to
180 // right of tray. 143 // right of tray.
181 bool separator_visible_; 144 bool separator_visible_;
182 145
183 std::unique_ptr<TrayWidgetObserver> widget_observer_; 146 std::unique_ptr<TrayWidgetObserver> widget_observer_;
184 std::unique_ptr<TrayEventFilter> tray_event_filter_; 147 std::unique_ptr<TrayEventFilter> tray_event_filter_;
185 148
186 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); 149 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView);
187 }; 150 };
188 151
189 } // namespace ash 152 } // namespace ash
190 153
191 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 154 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_item.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698