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

Unified Diff: ash/common/system/tray/header_list_scroll_view.h

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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/tray/header_list_scroll_view.h
diff --git a/ash/common/system/tray/header_list_scroll_view.h b/ash/common/system/tray/header_list_scroll_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..47903cb7077f1595bdcfa0ec5268c5b4315c8cf0
--- /dev/null
+++ b/ash/common/system/tray/header_list_scroll_view.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_COMMON_SYSTEM_TRAY_HEADER_LIST_SCROLL_VIEW_H_
+#define ASH_COMMON_SYSTEM_TRAY_HEADER_LIST_SCROLL_VIEW_H_
+
+#include "ash/ash_export.h"
+#include "base/macros.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/view.h"
+
+namespace ash {
+
+// A view that is used as ScrollView contents. It supports designating some of
+// the children as sticky header rows. The sticky header rows are not scrolled
+// above the top of the visible viewport and are stacked above other children.
+// To indicate that a child is a sticky header row use set_id(kHeaderRowId).
sadrul 2016/11/01 18:50:16 Where is kHeaderRowId() defined?
varkha 2016/11/02 02:03:21 Acknowledged.
+class HeaderListScrollView : public views::View {
+ public:
+ HeaderListScrollView();
+ ~HeaderListScrollView() override;
+
+ // Sets |view| as a sticky header view for all items with the same group.
+ void SetHeaderView(views::View* child);
sadrul 2016/11/01 18:50:16 This seems odd with the class level description. T
varkha 2016/11/02 02:03:21 Acknowledged.
+
+ protected:
+ // views::View.
+ void Layout() override;
+ void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
+ void ViewHierarchyChanged(
+ const ViewHierarchyChangedDetails& details) override;
+ const char* GetClassName() const override;
+
+ private:
+ class HeaderListLayout;
+
+ class Header {
+ public:
+ explicit Header(views::View* header)
+ : view(header), offset(header->bounds().y()) {}
+ bool operator==(views::View* other) { return view == other; }
+
+ views::View* view;
+ int offset;
+ };
+
+ // Sets decorations on a header row to indicate whether it is sticky.
+ static void ShowHeaderSticky(views::View* header, bool show_sticky);
+
+ // Adjusts y-position of header rows allowing one or two rows to stick to the
+ // top of the visible viewport.
+ void ScrollChildren();
+
+ // Header child views that stick to the top of visible viewport when scrolled.
+ std::vector<Header> headers_;
+ HeaderListLayout* header_list_layout_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(HeaderListScrollView);
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_SYSTEM_TRAY_HEADER_LIST_SCROLL_VIEW_H_

Powered by Google App Engine
This is Rietveld 408576698