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

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, 5 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_types.h" 11 #include "ash/common/shelf/shelf_types.h"
12 #include "ash/common/system/tray/actionable_view.h" 12 #include "ash/common/system/tray/actionable_view.h"
13 #include "ash/common/wm/background_animator.h" 13 #include "ash/common/wm/background_animator.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 23
24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray, 24 // Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray,
25 // LogoutButtonTray, OverviewButtonTray. 25 // LogoutButtonTray, OverviewButtonTray.
26 // This class handles setting and animating the background when the Launcher 26 // This class handles setting and animating the background when the Launcher
27 // his shown/hidden. It also inherits from ActionableView so that the tray 27 // his shown/hidden. It also inherits from ActionableView so that the tray
varkha 2016/07/14 21:34:48 nit: s/his/is
yiyix 2016/07/26 20:27:31 Done.
28 // items can override PerformAction when clicked on. 28 // items can override PerformAction when clicked on.
29 class ASH_EXPORT TrayBackgroundView : public ActionableView, 29 class ASH_EXPORT TrayBackgroundView : public ActionableView,
30 public BackgroundAnimatorDelegate, 30 public BackgroundAnimatorDelegate,
31 public ui::ImplicitAnimationObserver { 31 public ui::ImplicitAnimationObserver {
32 public: 32 public:
33 static const char kViewClassName[]; 33 static const char kViewClassName[];
34 34
35 // Base class for tray containers. Sets the border and layout. The container 35 // Base class for tray containers. Sets the border and layout. The container
36 // auto-resizes the widget when necessary. 36 // auto-resizes the widget when necessary.
37 class TrayContainer : public views::View { 37 class TrayContainer : public views::View {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 bool draw_background_as_active() const { return draw_background_as_active_; } 128 bool draw_background_as_active() const { return draw_background_as_active_; }
129 129
130 TrayContainer* tray_container() const { return tray_container_; } 130 TrayContainer* tray_container() const { return tray_container_; }
131 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } 131 ShelfAlignment shelf_alignment() const { return shelf_alignment_; }
132 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } 132 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); }
133 WmShelf* shelf() { return wm_shelf_; } 133 WmShelf* shelf() { return wm_shelf_; }
134 134
135 // Updates the arrow visibility based on the launcher visibility. 135 // Updates the arrow visibility based on the launcher visibility.
136 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); 136 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
137 137
138 protected:
139 // In the given |canvas|, draw a 1px wide and 32dp high separator line to the
varkha 2016/07/14 21:34:48 nit: s/draw/draws nit: s/high/tall
yiyix 2016/07/26 20:27:31 Done.
140 // right of the tray item.
varkha 2016/07/14 21:34:48 nit: clarify which tray item.
yiyix 2016/07/26 20:27:31 Done.
141 void DrawSeparator(gfx::Canvas* canvas);
142
138 private: 143 private:
139 class TrayWidgetObserver; 144 class TrayWidgetObserver;
140 145
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: 146 // ui::ImplicitAnimationObserver:
146 void OnImplicitAnimationsCompleted() override; 147 void OnImplicitAnimationsCompleted() override;
147 bool RequiresNotificationWhenAnimatorDestroyed() const override; 148 bool RequiresNotificationWhenAnimatorDestroyed() const override;
148 149
149 // Applies transformations to the |layer()| to animate the view when 150 // Applies transformations to the |layer()| to animate the view when
150 // SetVisible(false) is called. 151 // SetVisible(false) is called.
151 void HideTransformation(); 152 void HideTransformation();
152 153
154 // For Material Design, some extra padding is added to tray items so there is
varkha 2016/07/14 21:34:48 nit: drop "some"
yiyix 2016/07/26 20:27:31 Done.
155 // enough places to draw separator between this tray and the tray to the left
156 // (if horizontally aligned) or to the bottom (if vertically aligned) if
157 // separator needed. No border is set for non-MD.
varkha 2016/07/14 21:34:48 nit: s/separator/a separator is
yiyix 2016/07/26 20:27:31 Done.
158 void CalculateAndSetTrayContainerBorder();
159
153 // The shelf containing the system tray for this view. 160 // The shelf containing the system tray for this view.
154 WmShelf* wm_shelf_; 161 WmShelf* wm_shelf_;
155 162
156 // Convenience pointer to the contents view. 163 // Convenience pointer to the contents view.
157 TrayContainer* tray_container_; 164 TrayContainer* tray_container_;
158 165
159 // Shelf alignment. 166 // Shelf alignment.
160 // TODO(jamescook): Don't cache this, get it from WmShelf. 167 // TODO(jamescook): Don't cache this, get it from WmShelf.
161 ShelfAlignment shelf_alignment_; 168 ShelfAlignment shelf_alignment_;
162 169
163 // Owned by the view passed to SetContents(). 170 // Owned by the view passed to SetContents().
164 TrayBackground* background_; 171 TrayBackground* background_;
165 172
166 // This variable stores the activation override which will tint the background 173 // This variable stores the activation override which will tint the background
167 // differently if set to true. 174 // differently if set to true.
168 bool draw_background_as_active_; 175 bool draw_background_as_active_;
169 176
170 std::unique_ptr<TrayWidgetObserver> widget_observer_; 177 std::unique_ptr<TrayWidgetObserver> widget_observer_;
171 std::unique_ptr<TrayEventFilter> tray_event_filter_; 178 std::unique_ptr<TrayEventFilter> tray_event_filter_;
172 179
173 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); 180 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView);
174 }; 181 };
175 182
176 } // namespace ash 183 } // namespace ash
177 184
178 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ 185 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698