Commit 45110436 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Make detailed view sub header transparent.

This CL makes sub headers in detailed view transparent. As sub headers
in detailed view sticks to the top, we should clip the contents behind
the sub header when it's sticking.

Screenshot (before): http://screen/VdTYhhOnzmB
Screenshot (after): http://screen/42SJVs7U1RF

TEST=manual
BUG=850396

Change-Id: If112681997014c5bf7696dea775d414250e67f39
Reviewed-on: https://chromium-review.googlesource.com/1094853
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565994}
parent f7451e31
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "third_party/skia/include/core/SkDrawLooper.h" #include "third_party/skia/include/core/SkDrawLooper.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/clip_recorder.h"
#include "ui/compositor/paint_context.h" #include "ui/compositor/paint_context.h"
#include "ui/compositor/paint_recorder.h" #include "ui/compositor/paint_recorder.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
...@@ -66,7 +67,38 @@ class ScrollContentsView : public views::View { ...@@ -66,7 +67,38 @@ class ScrollContentsView : public views::View {
} }
void PaintChildren(const views::PaintInfo& paint_info) override { void PaintChildren(const views::PaintInfo& paint_info) override {
views::View::PaintChildren(paint_info); int sticky_header_height = 0;
for (const auto& header : headers_) {
// Sticky header is at the top.
if (header.view->y() != header.natural_offset) {
sticky_header_height = header.view->bounds().height();
DCHECK_EQ(VIEW_ID_STICKY_HEADER, header.view->id());
break;
}
}
// Paint contents other than sticky headers. If sticky header is at the top,
// it clips the header's height so that nothing is shown behind the header.
{
ui::ClipRecorder clip_recorder(paint_info.context());
gfx::Rect clip_rect = gfx::Rect(paint_info.paint_recording_size()) -
paint_info.offset_from_parent();
gfx::Insets clip_insets(sticky_header_height, 0, 0, 0);
clip_rect.Inset(clip_insets.Scale(paint_info.paint_recording_scale_x(),
paint_info.paint_recording_scale_y()));
clip_recorder.ClipRect(clip_rect);
for (int i = 0; i < child_count(); ++i) {
auto* child = child_at(i);
if (child->id() != VIEW_ID_STICKY_HEADER && !child->layer())
child->Paint(paint_info);
}
}
// Paint sticky headers.
for (int i = 0; i < child_count(); ++i) {
auto* child = child_at(i);
if (child->id() == VIEW_ID_STICKY_HEADER && !child->layer())
child->Paint(paint_info);
}
bool did_draw_shadow = false; bool did_draw_shadow = false;
// Paint header row separators. // Paint header row separators.
for (auto& header : headers_) for (auto& header : headers_)
......
...@@ -226,11 +226,11 @@ void TrayPopupUtils::ConfigureTrayPopupButton(views::Button* button) { ...@@ -226,11 +226,11 @@ void TrayPopupUtils::ConfigureTrayPopupButton(views::Button* button) {
void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) { void TrayPopupUtils::ConfigureAsStickyHeader(views::View* view) {
view->set_id(VIEW_ID_STICKY_HEADER); view->set_id(VIEW_ID_STICKY_HEADER);
view->SetBackground(
features::IsSystemTrayUnifiedEnabled() if (!features::IsSystemTrayUnifiedEnabled()) {
? views::CreateSolidBackground(kUnifiedMenuBackgroundColor) view->SetBackground(views::CreateThemedSolidBackground(
: views::CreateThemedSolidBackground(
view, ui::NativeTheme::kColorId_BubbleBackground)); view, ui::NativeTheme::kColorId_BubbleBackground));
}
view->SetBorder( view->SetBorder(
views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0))); views::CreateEmptyBorder(gfx::Insets(kMenuSeparatorVerticalPadding, 0)));
view->SetPaintToLayer(); view->SetPaintToLayer();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment