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

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

Issue 2147143002: [Chrome OS MD] Draw a 1px separator between 2 tray items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 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
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_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 6 #define ASH_COMMON_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/common/shelf/shelf_background_animator_observer.h" 11 #include "ash/common/shelf/shelf_background_animator_observer.h"
12 #include "ash/common/shelf/shelf_types.h" 12 #include "ash/common/shelf/shelf_types.h"
13 #include "ash/common/system/tray/actionable_view.h" 13 #include "ash/common/system/tray/actionable_view.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/views/bubble/tray_bubble_view.h" 16 #include "ui/views/bubble/tray_bubble_view.h"
17 17
18 namespace ash { 18 namespace ash {
19 class ShelfLayoutManager; 19 class ShelfLayoutManager;
20 class TrayEventFilter; 20 class TrayEventFilter;
21 class TrayBackground; 21 class TrayBackground;
22 class WmShelf; 22 class WmShelf;
23 class WmShelfObserver;
James Cook 2016/08/11 20:36:55 not needed
yiyix 2016/08/18 00:43:00 Done.
23 24
24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, 25 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray,
25 // LogoutButtonTray, OverviewButtonTray. 26 // LogoutButtonTray, OverviewButtonTray.
26 // This class handles setting and animating the background when the Launcher 27 // This class handles setting and animating the background when the Launcher
27 // his shown/hidden. It also inherits from ActionableView so that the tray 28 // is shown/hidden. It also inherits from ActionableView so that the tray
28 // items can override PerformAction when clicked on. 29 // items can override PerformAction when clicked on.
29 class ASH_EXPORT TrayBackgroundView : public ActionableView, 30 class ASH_EXPORT TrayBackgroundView : public ActionableView,
30 public ui::ImplicitAnimationObserver, 31 public ui::ImplicitAnimationObserver,
31 public ShelfBackgroundAnimatorObserver { 32 public ShelfBackgroundAnimatorObserver {
32 public: 33 public:
33 static const char kViewClassName[]; 34 static const char kViewClassName[];
34 35
35 // Base class for tray containers. Sets the border and layout. The container 36 // Base class for tray containers. Sets the border and layout. The container
36 // auto-resizes the widget when necessary. 37 // auto-resizes the widget when necessary.
37 class TrayContainer : public views::View { 38 class TrayContainer : public views::View {
(...skipping 17 matching lines...) Expand all
55 56
56 private: 57 private:
57 void UpdateLayout(); 58 void UpdateLayout();
58 59
59 ShelfAlignment alignment_; 60 ShelfAlignment alignment_;
60 gfx::Size size_; 61 gfx::Size size_;
61 62
62 DISALLOW_COPY_AND_ASSIGN(TrayContainer); 63 DISALLOW_COPY_AND_ASSIGN(TrayContainer);
63 }; 64 };
64 65
65 explicit TrayBackgroundView(WmShelf* wm_shelf); 66 // Creates a TrayBackgroundView and adds a |tray_background_view_observer| to
James Cook 2016/08/11 20:36:55 Remove this comment.
yiyix 2016/08/18 00:43:00 Done.
67 // observe when this tray visibility changes, so that the separator visibility
68 // can be updated accordingly.
69 TrayBackgroundView(WmShelf* wm_shelf);
66 ~TrayBackgroundView() override; 70 ~TrayBackgroundView() override;
67 71
68 // Called after the tray has been added to the widget containing it. 72 // Called after the tray has been added to the widget containing it.
69 virtual void Initialize(); 73 virtual void Initialize();
70 74
71 // Initializes animations for the bubble. 75 // Initializes animations for the bubble.
72 static void InitializeBubbleAnimations(views::Widget* bubble_widget); 76 static void InitializeBubbleAnimations(views::Widget* bubble_widget);
73 77
74 // views::View: 78 // views::View:
75 void SetVisible(bool visible) override; 79 void SetVisible(bool visible) override;
76 const char* GetClassName() const override; 80 const char* GetClassName() const override;
77 void ChildPreferredSizeChanged(views::View* child) override; 81 void ChildPreferredSizeChanged(views::View* child) override;
78 void GetAccessibleState(ui::AXViewState* state) override; 82 void GetAccessibleState(ui::AXViewState* state) override;
79 void AboutToRequestFocusFromTabTraversal(bool reverse) override; 83 void AboutToRequestFocusFromTabTraversal(bool reverse) override;
84 void OnPaint(gfx::Canvas* canvas) override;
80 85
81 // ActionableView: 86 // ActionableView:
82 bool PerformAction(const ui::Event& event) override; 87 bool PerformAction(const ui::Event& event) override;
83 gfx::Rect GetFocusBounds() override; 88 gfx::Rect GetFocusBounds() override;
84 void OnGestureEvent(ui::GestureEvent* event) override; 89 void OnGestureEvent(ui::GestureEvent* event) override;
85 90
86 // Called whenever the shelf alignment changes. 91 // Called whenever the shelf alignment changes.
87 virtual void SetShelfAlignment(ShelfAlignment alignment); 92 virtual void SetShelfAlignment(ShelfAlignment alignment);
88 93
89 // Called when the anchor (tray or bubble) may have moved or changed. 94 // Called when the anchor (tray or bubble) may have moved or changed.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } 133 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
129 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } 134 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); }
130 WmShelf* shelf() { return wm_shelf_; } 135 WmShelf* shelf() { return wm_shelf_; }
131 136
132 // Updates the arrow visibility based on the launcher visibility. 137 // Updates the arrow visibility based on the launcher visibility.
133 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); 138 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
134 139
135 // ShelfBackgroundAnimatorObserver: 140 // ShelfBackgroundAnimatorObserver:
136 void UpdateShelfItemBackground(int alpha) override; 141 void UpdateShelfItemBackground(int alpha) override;
137 142
143 // Updates the visibility of this tray's separator.
144 void SetSeparatorVisibility(bool is_show);
145
146 protected:
147 // In the given |canvas|, draws a 1px wide and 32dp tall separator line to the
James Cook 2016/08/11 20:36:55 super nit: I would mention the dimensions here, si
yiyix 2016/08/18 00:43:00 Done.
148 // right of the TrayBackgroundView.
149 void DrawSeparator(gfx::Canvas* canvas);
150
138 private: 151 private:
139 class TrayWidgetObserver; 152 class TrayWidgetObserver;
140 153
141 // Called from Initialize after all status area trays have been created.
142 // Sets the border based on the position of the view.
143 void SetTrayBorder();
144
145 // ui::ImplicitAnimationObserver: 154 // ui::ImplicitAnimationObserver:
146 void OnImplicitAnimationsCompleted() override; 155 void OnImplicitAnimationsCompleted() override;
147 bool RequiresNotificationWhenAnimatorDestroyed() const override; 156 bool RequiresNotificationWhenAnimatorDestroyed() const override;
148 157
149 // Applies transformations to the |layer()| to animate the view when 158 // Applies transformations to the |layer()| to animate the view when
150 // SetVisible(false) is called. 159 // SetVisible(false) is called.
151 void HideTransformation(); 160 void HideTransformation();
152 161
162 // For Material Design, extra padding is added to tray items so there is
163 // enough places to draw separator between this tray and the tray to the left
164 // (if horizontally aligned) or to the bottom (if vertically aligned) if a
165 // separator is needed. No border is set for non-MD.
166 void CalculateAndSetTrayContainerBorder();
167
153 // The shelf containing the system tray for this view. 168 // The shelf containing the system tray for this view.
154 WmShelf* wm_shelf_; 169 WmShelf* wm_shelf_;
155 170
156 // Convenience pointer to the contents view. 171 // Convenience pointer to the contents view.
157 TrayContainer* tray_container_; 172 TrayContainer* tray_container_;
158 173
159 // Shelf alignment. 174 // Shelf alignment.
160 // TODO(jamescook): Don't cache this, get it from WmShelf. 175 // TODO(jamescook): Don't cache this, get it from WmShelf.
161 ShelfAlignment shelf_alignment_; 176 ShelfAlignment shelf_alignment_;
162 177
163 // Owned by the view passed to SetContents(). 178 // Owned by the view passed to SetContents().
164 TrayBackground* background_; 179 TrayBackground* background_;
165 180
166 // This variable stores the activation override which will tint the background 181 // This variable stores the activation override which will tint the background
167 // differently if set to true. 182 // differently if set to true.
168 bool draw_background_as_active_; 183 bool draw_background_as_active_;
169 184
185 bool is_separator_visible_;
170 std::unique_ptr<TrayWidgetObserver> widget_observer_; 186 std::unique_ptr<TrayWidgetObserver> widget_observer_;
171 std::unique_ptr<TrayEventFilter> tray_event_filter_; 187 std::unique_ptr<TrayEventFilter> tray_event_filter_;
172 188
173 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); 189 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView);
174 }; 190 };
175 191
176 } // namespace ash 192 } // namespace ash
177 193
178 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 194 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698