Chromium Code Reviews| 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_ |