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

Unified Diff: ash/common/system/tray/tri_view.cc

Issue 2538513002: [ash-md] Fixed TriView to relayout child Views when their preferred size changed. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | ash/common/system/tray/tri_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tri_view.cc
diff --git a/ash/common/system/tray/tri_view.cc b/ash/common/system/tray/tri_view.cc
index ea2ca9327d8fc3a902f91dbca1a7114bd81c77b9..c71666f681bc39b58d5c72e550d78e0ccccd674a 100644
--- a/ash/common/system/tray/tri_view.cc
+++ b/ash/common/system/tray/tri_view.cc
@@ -27,6 +27,18 @@ views::BoxLayout::Orientation GetOrientation(TriView::Orientation orientation) {
return views::BoxLayout::kHorizontal;
}
+// A View that will perform a layout if a child view's preferred size changes.
+class RelayoutView : public views::View {
tdanderson 2016/11/28 21:47:37 Hm, I'm a bit surprised there isn't something like
+ public:
+ RelayoutView() {}
+
+ // views::View:
+ void ChildPreferredSizeChanged(View* child) override { Layout(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RelayoutView);
+};
+
} // namespace
TriView::TriView() : TriView(0) {}
@@ -44,9 +56,9 @@ TriView::TriView(Orientation orientation, int padding_between_containers)
start_container_layout_manager_(new SizeRangeLayout),
center_container_layout_manager_(new SizeRangeLayout),
end_container_layout_manager_(new SizeRangeLayout) {
- AddChildView(new views::View);
- AddChildView(new views::View);
- AddChildView(new views::View);
+ AddChildView(new RelayoutView);
+ AddChildView(new RelayoutView);
+ AddChildView(new RelayoutView);
GetContainer(Container::START)
->SetLayoutManager(GetLayoutManager(Container::START));
« no previous file with comments | « no previous file | ash/common/system/tray/tri_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698