OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_COMMON_SYSTEM_TRAY_HEADER_LIST_SCROLL_VIEW_H_ | |
6 #define ASH_COMMON_SYSTEM_TRAY_HEADER_LIST_SCROLL_VIEW_H_ | |
7 | |
8 #include "ash/ash_export.h" | |
9 #include "base/macros.h" | |
10 #include "ui/views/controls/button/button.h" | |
11 #include "ui/views/view.h" | |
12 | |
13 namespace ash { | |
14 | |
15 // A view that is used as ScrollView contents. It supports designating some of | |
16 // the children as sticky header rows. The sticky header rows are not scrolled | |
17 // above the top of the visible viewport and are stacked above other children. | |
18 // 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.
| |
19 class HeaderListScrollView : public views::View { | |
20 public: | |
21 HeaderListScrollView(); | |
22 ~HeaderListScrollView() override; | |
23 | |
24 // Sets |view| as a sticky header view for all items with the same group. | |
25 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.
| |
26 | |
27 protected: | |
28 // views::View. | |
29 void Layout() override; | |
30 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | |
31 void ViewHierarchyChanged( | |
32 const ViewHierarchyChangedDetails& details) override; | |
33 const char* GetClassName() const override; | |
34 | |
35 private: | |
36 class HeaderListLayout; | |
37 | |
38 class Header { | |
39 public: | |
40 explicit Header(views::View* header) | |
41 : view(header), offset(header->bounds().y()) {} | |
42 bool operator==(views::View* other) { return view == other; } | |
43 | |
44 views::View* view; | |
45 int offset; | |
46 }; | |
47 | |
48 // Sets decorations on a header row to indicate whether it is sticky. | |
49 static void ShowHeaderSticky(views::View* header, bool show_sticky); | |
50 | |
51 // Adjusts y-position of header rows allowing one or two rows to stick to the | |
52 // top of the visible viewport. | |
53 void ScrollChildren(); | |
54 | |
55 // Header child views that stick to the top of visible viewport when scrolled. | |
56 std::vector<Header> headers_; | |
57 HeaderListLayout* header_list_layout_ = nullptr; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(HeaderListScrollView); | |
60 }; | |
61 | |
62 } // namespace ash | |
63 | |
64 #endif // ASH_COMMON_SYSTEM_TRAY_HEADER_LIST_SCROLL_VIEW_H_ | |
OLD | NEW |