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

Unified Diff: ash/common/system/tray/tray_details_view.cc

Issue 2489883005: Fix a couple issues with sticky headers (Closed)
Patch Set: rebase 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
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | ash/common/system/tray/tray_popup_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9ca7fafd1f6a6578666e87fa161057232dcda5b3..d6c6ea55df3c980096237ba8bc17f49042491925 100644
--- a/ash/common/system/tray/tray_details_view.cc
+++ b/ash/common/system/tray/tray_details_view.cc
@@ -43,12 +43,14 @@ const int kTitleRowSeparatorIndex = 1;
class ScrollContentsView : public views::View,
public views::ViewTargeterDelegate {
public:
- ScrollContentsView() {
+ ScrollContentsView()
+ : box_layout_(new views::BoxLayout(
+ views::BoxLayout::kVertical,
+ 0,
+ 0,
+ UseMd() ? 0 : kContentsBetweenChildSpacingNonMd)) {
SetEventTargeter(base::MakeUnique<views::ViewTargeter>(this));
- SetLayoutManager(
- new views::BoxLayout(views::BoxLayout::kVertical, 0,
- UseMd() ? kContentsVerticalSpacingMd : 0,
- UseMd() ? 0 : kContentsBetweenChildSpacingNonMd));
+ SetLayoutManager(box_layout_);
}
~ScrollContentsView() override {}
@@ -90,6 +92,18 @@ class ScrollContentsView : public views::View,
return header.view == details.child;
}),
headers_.end());
+ } else if (details.is_add && details.parent == this &&
+ details.child == child_at(0)) {
+ // We always want padding on the bottom of the scroll contents.
+ // We only want padding on the top of the scroll contents if the first
+ // child is not a header (in that case, the padding is built into the
+ // header).
+ DCHECK_EQ(box_layout_, GetLayoutManager());
+ box_layout_->set_inside_border_insets(
+ gfx::Insets(details.child->id() == VIEW_ID_STICKY_HEADER
+ ? 0
+ : kMenuSeparatorVerticalPadding,
+ 0, kMenuSeparatorVerticalPadding, 0));
}
}
@@ -111,7 +125,6 @@ class ScrollContentsView : public views::View,
const SkColor kSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F);
const int kShadowOffsetY = 2;
const int kShadowBlur = 2;
- const int kContentsVerticalSpacingMd = 4;
// TODO(fukino): Remove this constant once we stop maintaining pre-MD design.
// crbug.com/614453.
const int kContentsBetweenChildSpacingNonMd = 1;
@@ -197,6 +210,8 @@ class ScrollContentsView : public views::View,
canvas->DrawRect(rect, paint);
}
+ views::BoxLayout* box_layout_;
+
// Header child views that stick to the top of visible viewport when scrolled.
std::vector<Header> headers_;
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | ash/common/system/tray/tray_popup_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698