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

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: merge 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;
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
67 // observe when this tray visibility changes, so that the separator visibility
68 // can be updated accordingly.
69 explicit TrayBackgroundView(WmShelf* wm_shelf,
James Cook 2016/08/09 00:25:18 no explicit
yiyix 2016/08/11 01:23:20 Done.
70 WmShelfObserver* wm_shelf_observer);
66 ~TrayBackgroundView() override; 71 ~TrayBackgroundView() override;
67 72
68 // Called after the tray has been added to the widget containing it. 73 // Called after the tray has been added to the widget containing it.
69 virtual void Initialize(); 74 virtual void Initialize();
70 75
71 // Initializes animations for the bubble. 76 // Initializes animations for the bubble.
72 static void InitializeBubbleAnimations(views::Widget* bubble_widget); 77 static void InitializeBubbleAnimations(views::Widget* bubble_widget);
73 78
74 // views::View: 79 // views::View:
75 void SetVisible(bool visible) override; 80 void SetVisible(bool visible) override;
76 const char* GetClassName() const override; 81 const char* GetClassName() const override;
77 void ChildPreferredSizeChanged(views::View* child) override; 82 void ChildPreferredSizeChanged(views::View* child) override;
78 void GetAccessibleState(ui::AXViewState* state) override; 83 void GetAccessibleState(ui::AXViewState* state) override;
79 void AboutToRequestFocusFromTabTraversal(bool reverse) override; 84 void AboutToRequestFocusFromTabTraversal(bool reverse) override;
85 void OnPaint(gfx::Canvas* canvas) override;
80 86
81 // ActionableView: 87 // ActionableView:
82 bool PerformAction(const ui::Event& event) override; 88 bool PerformAction(const ui::Event& event) override;
83 gfx::Rect GetFocusBounds() override; 89 gfx::Rect GetFocusBounds() override;
84 void OnGestureEvent(ui::GestureEvent* event) override; 90 void OnGestureEvent(ui::GestureEvent* event) override;
85 91
86 // Called whenever the shelf alignment changes. 92 // Called whenever the shelf alignment changes.
87 virtual void SetShelfAlignment(ShelfAlignment alignment); 93 virtual void SetShelfAlignment(ShelfAlignment alignment);
88 94
89 // Called when the anchor (tray or bubble) may have moved or changed. 95 // 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_; } 134 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
129 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } 135 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); }
130 WmShelf* shelf() { return wm_shelf_; } 136 WmShelf* shelf() { return wm_shelf_; }
131 137
132 // Updates the arrow visibility based on the launcher visibility. 138 // Updates the arrow visibility based on the launcher visibility.
133 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); 139 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
134 140
135 // ShelfBackgroundAnimatorObserver: 141 // ShelfBackgroundAnimatorObserver:
136 void UpdateShelfItemBackground(int alpha) override; 142 void UpdateShelfItemBackground(int alpha) override;
137 143
144 // Updates the visibility of this tray's separator.
145 void SetSeparatorVisibility(bool is_show);
146
147 protected:
148 // In the given |canvas|, draws a 1px wide and 32dp tall separator line to the
149 // right of this TrayBackgeoundView item.
James Cook 2016/08/09 00:25:18 nit: TrayBackgroundView, or just say "item"
yiyix 2016/08/11 01:23:20 Done.
150 void DrawSeparator(gfx::Canvas* canvas);
151
138 private: 152 private:
139 class TrayWidgetObserver; 153 class TrayWidgetObserver;
140 154
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: 155 // ui::ImplicitAnimationObserver:
146 void OnImplicitAnimationsCompleted() override; 156 void OnImplicitAnimationsCompleted() override;
147 bool RequiresNotificationWhenAnimatorDestroyed() const override; 157 bool RequiresNotificationWhenAnimatorDestroyed() const override;
148 158
149 // Applies transformations to the |layer()| to animate the view when 159 // Applies transformations to the |layer()| to animate the view when
150 // SetVisible(false) is called. 160 // SetVisible(false) is called.
151 void HideTransformation(); 161 void HideTransformation();
152 162
163 // For Material Design, extra padding is added to tray items so there is
164 // enough places to draw separator between this tray and the tray to the left
165 // (if horizontally aligned) or to the bottom (if vertically aligned) if a
166 // separator is needed. No border is set for non-MD.
167 void CalculateAndSetTrayContainerBorder();
168
153 // The shelf containing the system tray for this view. 169 // The shelf containing the system tray for this view.
154 WmShelf* wm_shelf_; 170 WmShelf* wm_shelf_;
155 171
156 // Convenience pointer to the contents view. 172 // Convenience pointer to the contents view.
157 TrayContainer* tray_container_; 173 TrayContainer* tray_container_;
158 174
159 // Shelf alignment. 175 // Shelf alignment.
160 // TODO(jamescook): Don't cache this, get it from WmShelf. 176 // TODO(jamescook): Don't cache this, get it from WmShelf.
161 ShelfAlignment shelf_alignment_; 177 ShelfAlignment shelf_alignment_;
162 178
163 // Owned by the view passed to SetContents(). 179 // Owned by the view passed to SetContents().
164 TrayBackground* background_; 180 TrayBackground* background_;
165 181
166 // This variable stores the activation override which will tint the background 182 // This variable stores the activation override which will tint the background
167 // differently if set to true. 183 // differently if set to true.
168 bool draw_background_as_active_; 184 bool draw_background_as_active_;
169 185
186 WmShelfObserver* wm_shelf_observer_;
187 bool is_separator_visible_;
170 std::unique_ptr<TrayWidgetObserver> widget_observer_; 188 std::unique_ptr<TrayWidgetObserver> widget_observer_;
171 std::unique_ptr<TrayEventFilter> tray_event_filter_; 189 std::unique_ptr<TrayEventFilter> tray_event_filter_;
172 190
173 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); 191 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView);
174 }; 192 };
175 193
176 } // namespace ash 194 } // namespace ash
177 195
178 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 196 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698