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

Side by Side Diff: ash/common/system/tray/tray_details_view.cc

Issue 2453133002: [ash-md] Makes Wi-Fi header row sticky when network list is scrolled (Closed)
Patch Set: [ash-md] Makes Wi-Fi header row sticky when network list is scrolled (avoid set_id()) 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 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 #include "ash/common/system/tray/tray_details_view.h" 5 #include "ash/common/system/tray/tray_details_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/tray/fixed_sized_scroll_view.h" 8 #include "ash/common/system/tray/fixed_sized_scroll_view.h"
9 #include "ash/common/system/tray/header_list_scroll_view.h"
9 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
10 #include "ash/common/system/tray/system_tray_item.h" 11 #include "ash/common/system/tray/system_tray_item.h"
11 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
12 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
13 #include "ui/views/background.h" 14 #include "ui/views/background.h"
14 #include "ui/views/border.h" 15 #include "ui/views/border.h"
15 #include "ui/views/controls/progress_bar.h" 16 #include "ui/views/controls/progress_bar.h"
16 #include "ui/views/controls/scroll_view.h" 17 #include "ui/views/controls/scroll_view.h"
17 #include "ui/views/controls/separator.h" 18 #include "ui/views/controls/separator.h"
18 #include "ui/views/layout/box_layout.h" 19 #include "ui/views/layout/box_layout.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 59
59 private: 60 private:
60 int GetMaxHeight(const views::View* host) const { 61 int GetMaxHeight(const views::View* host) const {
61 int max_height = 0; 62 int max_height = 0;
62 for (int i = 0; i < host->child_count(); ++i) 63 for (int i = 0; i < host->child_count(); ++i)
63 max_height = std::max(max_height, host->child_at(i)->height()); 64 max_height = std::max(max_height, host->child_at(i)->height());
64 return max_height; 65 return max_height;
65 } 66 }
66 }; 67 };
67 68
68 } // namespace
69
70 class ScrollSeparator : public views::View { 69 class ScrollSeparator : public views::View {
71 public: 70 public:
72 ScrollSeparator() {} 71 ScrollSeparator() {}
73 72
74 ~ScrollSeparator() override {} 73 ~ScrollSeparator() override {}
75 74
76 private: 75 private:
77 // Overriden from views::View. 76 // views::View.
78 void OnPaint(gfx::Canvas* canvas) override { 77 void OnPaint(gfx::Canvas* canvas) override {
79 canvas->FillRect(gfx::Rect(0, height() / 2, width(), 1), kBorderLightColor); 78 canvas->FillRect(gfx::Rect(0, height() / 2, width(), 1),
79 ash::kBorderLightColor);
80 } 80 }
81 gfx::Size GetPreferredSize() const override { 81 gfx::Size GetPreferredSize() const override {
82 return gfx::Size(1, kTrayPopupScrollSeparatorHeight); 82 return gfx::Size(1, ash::kTrayPopupScrollSeparatorHeight);
83 } 83 }
84 84
85 DISALLOW_COPY_AND_ASSIGN(ScrollSeparator); 85 DISALLOW_COPY_AND_ASSIGN(ScrollSeparator);
86 }; 86 };
87 87
88 } // namespace
89
88 class ScrollBorder : public views::Border { 90 class ScrollBorder : public views::Border {
89 public: 91 public:
90 ScrollBorder() {} 92 ScrollBorder() {}
91 ~ScrollBorder() override {} 93 ~ScrollBorder() override {}
92 94
93 void set_visible(bool visible) { visible_ = visible; } 95 void set_visible(bool visible) { visible_ = visible; }
94 96
95 private: 97 private:
96 // Overridden from views::Border. 98 // views::Border.
97 void Paint(const views::View& view, gfx::Canvas* canvas) override { 99 void Paint(const views::View& view, gfx::Canvas* canvas) override {
98 if (!visible_) 100 if (!visible_)
99 return; 101 return;
100 canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1), 102 canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1),
101 kBorderLightColor); 103 kBorderLightColor);
102 } 104 }
103 105
104 gfx::Insets GetInsets() const override { return gfx::Insets(0, 0, 1, 0); } 106 gfx::Insets GetInsets() const override { return gfx::Insets(0, 0, 1, 0); }
105 107
106 gfx::Size GetMinimumSize() const override { return gfx::Size(0, 1); } 108 gfx::Size GetMinimumSize() const override { return gfx::Size(0, 1); }
107 109
108 bool visible_; 110 bool visible_ = false;
109 111
110 DISALLOW_COPY_AND_ASSIGN(ScrollBorder); 112 DISALLOW_COPY_AND_ASSIGN(ScrollBorder);
111 }; 113 };
112 114
113 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) 115 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner)
114 : owner_(owner), 116 : owner_(owner),
115 title_row_(nullptr), 117 title_row_(nullptr),
116 scroller_(nullptr), 118 scroller_(nullptr),
117 scroll_content_(nullptr), 119 scroll_content_(nullptr),
118 progress_bar_(nullptr), 120 progress_bar_(nullptr),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 CreateExtraTitleRowButtons(); 176 CreateExtraTitleRowButtons();
175 177
176 if (MaterialDesignController::IsSystemTrayMenuMaterial()) 178 if (MaterialDesignController::IsSystemTrayMenuMaterial())
177 back_button_ = title_row_->AddBackButton(this); 179 back_button_ = title_row_->AddBackButton(this);
178 180
179 Layout(); 181 Layout();
180 } 182 }
181 183
182 void TrayDetailsView::CreateScrollableList() { 184 void TrayDetailsView::CreateScrollableList() {
183 DCHECK(!scroller_); 185 DCHECK(!scroller_);
184 scroll_content_ = new views::View; 186 scroll_content_ = new HeaderListScrollView();
185 scroll_content_->SetLayoutManager(
186 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1));
187 scroller_ = new FixedSizedScrollView; 187 scroller_ = new FixedSizedScrollView;
188 scroller_->SetContentsView(scroll_content_); 188 scroller_->SetContentsView(scroll_content_);
189 189
190 // Note: |scroller_| takes ownership of |scroll_border_|. 190 // Note: |scroller_| takes ownership of |scroll_border_|.
191 scroll_border_ = new ScrollBorder; 191 scroll_border_ = new ScrollBorder;
192 scroller_->SetBorder(std::unique_ptr<views::Border>(scroll_border_)); 192 scroller_->SetBorder(std::unique_ptr<views::Border>(scroll_border_));
193 193
194 AddChildView(scroller_); 194 AddChildView(scroller_);
195 } 195 }
196 196
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (index < child_count() - 1 && child_at(index + 1) != title_row_) 279 if (index < child_count() - 1 && child_at(index + 1) != title_row_)
280 scroll_border_->set_visible(true); 280 scroll_border_->set_visible(true);
281 else 281 else
282 scroll_border_->set_visible(false); 282 scroll_border_->set_visible(false);
283 } 283 }
284 284
285 views::View::OnPaintBorder(canvas); 285 views::View::OnPaintBorder(canvas);
286 } 286 }
287 287
288 } // namespace ash 288 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698