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

Unified Diff: ash/system/tray/system_tray.cc

Issue 10386142: ash: Some code-cleanup around tray-resizing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
« no previous file with comments | « ash/system/date/date_view.cc ('k') | ash/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray.cc
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index e0362d57e60cfc0db3328e544eb3cb1a1a91bbc0..ae5c128c47d51ebfab14b579ab70069ba46edb6c 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -85,6 +85,40 @@ class SystemTrayBackground : public views::Background {
DISALLOW_COPY_AND_ASSIGN(SystemTrayBackground);
};
+// Container for all the items in the tray. The container auto-resizes the
+// widget when necessary.
+class SystemTrayContainer : public views::View {
+ public:
+ SystemTrayContainer() {}
+ virtual ~SystemTrayContainer() {}
+
+ private:
+ void UpdateWidgetSize() {
+ if (GetWidget())
+ GetWidget()->SetSize(GetWidget()->GetContentsView()->GetPreferredSize());
+ }
+
+ // Overridden from views::View.
+ virtual void ChildPreferredSizeChanged(views::View* child) {
+ views::View::ChildPreferredSizeChanged(child);
+ UpdateWidgetSize();
+ }
+
+ virtual void ChildVisibilityChanged(View* child) OVERRIDE {
+ views::View::ChildVisibilityChanged(child);
+ UpdateWidgetSize();
+ }
+
+ virtual void ViewHierarchyChanged(bool is_add,
+ View* parent,
+ View* child) OVERRIDE {
+ if (parent == this)
+ UpdateWidgetSize();
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayContainer);
+};
+
// Observe the tray layer animation and update the anchor when it changes.
// TODO(stevenjb): Observe or mirror the actual animation, not just the start
// and end points.
@@ -138,7 +172,7 @@ SystemTray::SystemTray()
0, kTrayBackgroundAlpha)),
ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this,
0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) {
- tray_container_ = new views::View;
+ tray_container_ = new internal::SystemTrayContainer;
tray_container_->SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kHorizontal, 0, 0, 0));
tray_container_->set_background(background_);
« no previous file with comments | « ash/system/date/date_view.cc ('k') | ash/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698