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

Unified 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: new approach 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/tray/tray_background_view.h
diff --git a/ash/common/system/tray/tray_background_view.h b/ash/common/system/tray/tray_background_view.h
index 478e427bda77e0b79719747d9decd52ee0a0e6a2..23255aca015ded5d9322b57f1173b6e2c342ed47 100644
--- a/ash/common/system/tray/tray_background_view.h
+++ b/ash/common/system/tray/tray_background_view.h
@@ -19,12 +19,13 @@ namespace ash {
class ShelfLayoutManager;
class TrayEventFilter;
class TrayBackground;
+class ViewObserver;
class WmShelf;
// Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray,
// LogoutButtonTray, OverviewButtonTray.
// This class handles setting and animating the background when the Launcher
-// his shown/hidden. It also inherits from ActionableView so that the tray
+// is shown/hidden. It also inherits from ActionableView so that the tray
// items can override PerformAction when clicked on.
class ASH_EXPORT TrayBackgroundView : public ActionableView,
public BackgroundAnimatorDelegate,
@@ -62,7 +63,10 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
DISALLOW_COPY_AND_ASSIGN(TrayContainer);
};
- explicit TrayBackgroundView(WmShelf* wm_shelf);
+ // Creates a TrayBackgroundView and adds a |view_observer| to observe when
+ // this tray visibility changes, so that the separator visibility can be
+ // updated accordingly.
+ explicit TrayBackgroundView(WmShelf* wm_shelf, ViewObserver* view_observer);
~TrayBackgroundView() override;
// Called after the tray has been added to the widget containing it.
@@ -77,6 +81,7 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
void ChildPreferredSizeChanged(views::View* child) override;
void GetAccessibleState(ui::AXViewState* state) override;
void AboutToRequestFocusFromTabTraversal(bool reverse) override;
+ void OnPaint(gfx::Canvas* canvas) override;
// ActionableView:
bool PerformAction(const ui::Event& event) override;
@@ -135,13 +140,17 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
// Updates the arrow visibility based on the launcher visibility.
void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view);
+ // Updates the visibility of this tray's separator.
+ void SetSeparatorVisibility(bool is_show);
+
+ protected:
+ // In the given |canvas|, draws a 1px wide and 32dp tall separator line to the
+ // right of this TrayBackgeoundView item.
+ void DrawSeparator(gfx::Canvas* canvas);
+
private:
class TrayWidgetObserver;
- // Called from Initialize after all status area trays have been created.
- // Sets the border based on the position of the view.
- void SetTrayBorder();
-
// ui::ImplicitAnimationObserver:
void OnImplicitAnimationsCompleted() override;
bool RequiresNotificationWhenAnimatorDestroyed() const override;
@@ -150,6 +159,12 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
// SetVisible(false) is called.
void HideTransformation();
+ // For Material Design, extra padding is added to tray items so there is
+ // enough places to draw separator between this tray and the tray to the left
+ // (if horizontally aligned) or to the bottom (if vertically aligned) if a
+ // separator is needed. No border is set for non-MD.
+ void CalculateAndSetTrayContainerBorder();
+
// The shelf containing the system tray for this view.
WmShelf* wm_shelf_;
@@ -167,6 +182,8 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
// differently if set to true.
bool draw_background_as_active_;
+ ViewObserver* view_observer_;
+ bool is_separator_visible_;
std::unique_ptr<TrayWidgetObserver> widget_observer_;
std::unique_ptr<TrayEventFilter> tray_event_filter_;

Powered by Google App Engine
This is Rietveld 408576698