| Index: ash/common/system/tray/tray_details_view.cc
|
| diff --git a/ash/common/system/tray/tray_details_view.cc b/ash/common/system/tray/tray_details_view.cc
|
| index d48c0e3608800ba71fd7bb2ba4261fda9c035589..3f630db917093eb69246a2f7f850c7895ee53713 100644
|
| --- a/ash/common/system/tray/tray_details_view.cc
|
| +++ b/ash/common/system/tray/tray_details_view.cc
|
| @@ -69,17 +69,11 @@ class ScrollContentsView : public views::View,
|
| }
|
|
|
| void PaintChildren(const ui::PaintContext& context) override {
|
| - for (int i = 0; i < child_count(); ++i) {
|
| - if (child_at(i)->id() != VIEW_ID_STICKY_HEADER && !child_at(i)->layer())
|
| - child_at(i)->Paint(context);
|
| - }
|
| + views::View::PaintChildren(context);
|
| bool did_draw_shadow = false;
|
| - // Paint header rows above other children in Z-order.
|
| - for (auto& header : headers_) {
|
| - if (!header.view->layer())
|
| - header.view->Paint(context);
|
| + // Paint header row separators.
|
| + for (auto& header : headers_)
|
| did_draw_shadow = PaintDelineation(header, context) || did_draw_shadow;
|
| - }
|
|
|
| // Draw a shadow at the top of the viewport when scrolled, but only if a
|
| // header didn't already draw one. Overlap the shadow with the separator
|
| @@ -100,6 +94,26 @@ class ScrollContentsView : public views::View,
|
| PositionHeaderRows();
|
| }
|
|
|
| + View::Views GetChildrenOrderedByVisualOrder() override {
|
| + // TODO(varkha): Not sure if this is worth it but the array could be a class
|
| + // member |children_in_visual_order_| and only updated in an override of
|
| + // ReorderChildLayers() before calling base View::ReorderChildLayers(). Then
|
| + // this method could simply return |children_in_visual_order_|.
|
| + View::Views children;
|
| + // Iterate over regular children and later over the sticky headers to keep
|
| + // the sticky headers above in Z-order.
|
| + for (int i = 0; i < child_count(); ++i) {
|
| + if (child_at(i)->id() != VIEW_ID_STICKY_HEADER)
|
| + children.push_back(child_at(i));
|
| + }
|
| + for (int i = 0; i < child_count(); ++i) {
|
| + if (child_at(i)->id() == VIEW_ID_STICKY_HEADER)
|
| + children.push_back(child_at(i));
|
| + }
|
| + DCHECK_EQ(child_count(), static_cast<int>(children.size()));
|
| + return children;
|
| + }
|
| +
|
| void ViewHierarchyChanged(
|
| const ViewHierarchyChangedDetails& details) override {
|
| if (!details.is_add && details.parent == this) {
|
| @@ -123,19 +137,6 @@ class ScrollContentsView : public views::View,
|
| }
|
| }
|
|
|
| - // views::ViewTargeterDelegate:
|
| - View* TargetForRect(View* root, const gfx::Rect& rect) override {
|
| - // Give header rows first dibs on events.
|
| - for (auto& header : headers_) {
|
| - views::View* view = header.view;
|
| - gfx::Rect local_to_header = rect;
|
| - local_to_header.Offset(-view->x(), -view->y());
|
| - if (ViewTargeterDelegate::DoesIntersectRect(view, local_to_header))
|
| - return ViewTargeterDelegate::TargetForRect(view, local_to_header);
|
| - }
|
| - return ViewTargeterDelegate::TargetForRect(root, rect);
|
| - }
|
| -
|
| private:
|
| const SkColor kSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F);
|
| const int kShadowOffsetY = 2;
|
| @@ -169,24 +170,31 @@ class ScrollContentsView : public views::View,
|
| Header* previous_header = nullptr;
|
| for (auto& header : base::Reversed(headers_)) {
|
| views::View* header_view = header.view;
|
| - header.draw_separator_below = false;
|
| + bool draw_separator_below = false;
|
| if (header.natural_offset >= scroll_offset) {
|
| previous_header = &header;
|
| header_view->SetY(header.natural_offset);
|
| - continue;
|
| - }
|
| - if (previous_header &&
|
| - previous_header->view->y() <= scroll_offset + header_view->height()) {
|
| - // Lower header displacing the header above.
|
| - header.draw_separator_below = true;
|
| - header_view->SetY(previous_header->view->y() - header_view->height());
|
| } else {
|
| - // A header becomes sticky.
|
| - header_view->SetY(scroll_offset);
|
| - header_view->Layout();
|
| - header_view->SchedulePaint();
|
| + if (previous_header &&
|
| + previous_header->view->y() <=
|
| + scroll_offset + header_view->height()) {
|
| + // Lower header displacing the header above.
|
| + draw_separator_below = true;
|
| + header_view->SetY(previous_header->view->y() - header_view->height());
|
| + } else {
|
| + // A header becomes sticky.
|
| + header_view->SetY(scroll_offset);
|
| + header_view->Layout();
|
| + header_view->SchedulePaint();
|
| + }
|
| }
|
| - break;
|
| + if (header.draw_separator_below != draw_separator_below) {
|
| + header.draw_separator_below = draw_separator_below;
|
| + TrayPopupUtils::ShowStickyHeaderSeparator(header_view,
|
| + draw_separator_below);
|
| + }
|
| + if (header.natural_offset < scroll_offset)
|
| + break;
|
| }
|
| }
|
|
|
| @@ -197,21 +205,10 @@ class ScrollContentsView : public views::View,
|
| bool PaintDelineation(const Header& header, const ui::PaintContext& context) {
|
| const View* view = header.view;
|
|
|
| - // If the header is where it normally belongs, draw nothing.
|
| - if (view->y() == header.natural_offset)
|
| - return false;
|
| -
|
| - // If the header is pushed by a header directly below it, draw a separator.
|
| - if (header.draw_separator_below) {
|
| - // TODO(estade): look better at 1.5x scale.
|
| - ui::PaintRecorder recorder(context, size());
|
| - gfx::Canvas* canvas = recorder.canvas();
|
| - gfx::Rect separator = view->bounds();
|
| - separator.set_y(separator.bottom() - kSeparatorWidth);
|
| - separator.set_height(kSeparatorWidth);
|
| - canvas->FillRect(separator, kSeparatorColor);
|
| + // If the header is where it normally belongs or If the header is pushed by
|
| + // a header directly below it, draw nothing.
|
| + if (view->y() == header.natural_offset || header.draw_separator_below)
|
| return false;
|
| - }
|
|
|
| // Otherwise, draw a shadow below.
|
| DrawShadow(context,
|
|
|