Skip to content

Commit

Permalink
Make the header/content separator into a hairline for apps in hidpi
Browse files Browse the repository at this point in the history
In order to make the hairline header/content separator look good in HiDPI
- The header/content separator overlays the window controls (to avoid a 1 physical pixel gap between the window controls and the header/content separator in 2x)
- This CL makes the window controls 2 physical pixels taller in 2x
- The bottom 1 physical pixel of the window control images is transparent. This is necessary because the window controls paint on top of the header/content separator

BUG=340135
TEST=Manual, see bug
R=jamescook@chromium.org

Review URL: https://codereview.chromium.org/200493004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258301 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
pkotwicz@chromium.org committed Mar 20, 2014
1 parent 077eb5e commit ccd9b37
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 29 deletions.
4 changes: 2 additions & 2 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@
'frame/frame_border_hit_test_controller.h',
'frame/default_header_painter.cc',
'frame/default_header_painter.h',
'frame/frame_util.cc',
'frame/frame_util.h',
'frame/frame_util.cc',
'frame/frame_util.h',
'frame/header_painter.h',
'frame/header_painter_util.cc',
'frame/header_painter_util.h',
Expand Down
16 changes: 3 additions & 13 deletions ash/frame/custom_frame_view_ash_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,9 @@ TEST_F(CustomFrameViewAshTest, HeaderHeight) {
gfx::ImageSkia* close_button =
rb.GetImageSkiaNamed(IDR_AURA_WINDOW_CONTROL_BACKGROUND_H);

// |kSeparatorSize| should match |kHeaderContentSeparatorSize| in
// default_header_painter.cc
// TODO(pkotwicz): Clean this test up once the separator overlays the window
// controls.
const int kSeparatorSize = 1;

// The header should have enough room for the window controls and the
// separator line.
EXPECT_EQ(close_button->height() + kSeparatorSize,
delegate->custom_frame_view()->GetHeaderView()->height());

widget->Maximize();
EXPECT_EQ(close_button->height() + kSeparatorSize,
// The header should have enough room for the window controls. The
// header/content separator line overlays the window controls.
EXPECT_EQ(close_button->height(),
delegate->custom_frame_view()->GetHeaderView()->height());
}

Expand Down
22 changes: 12 additions & 10 deletions ash/frame/default_header_painter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ namespace {

// Color for the window title text.
const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40);
// Size of header/content separator line.
const int kHeaderContentSeparatorSize = 1;
// Color of the active window header/content separator line.
const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(180, 180, 182);
// Color of the inactive window header/content separator line.
Expand Down Expand Up @@ -218,13 +216,14 @@ void DefaultHeaderPainter::LayoutHeader() {
// Vertically center the window icon with respect to the caption button
// container.
int icon_size = HeaderPainterUtil::GetIconSize();
int icon_offset_y = (caption_button_container_->height() - icon_size) / 2;
// Floor when computing the center of |caption_button_container_|.
int icon_offset_y = caption_button_container_->height() / 2 - icon_size / 2;
window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y,
icon_size, icon_size);
}

SetHeaderHeightForPainting(caption_button_container_->height() +
kHeaderContentSeparatorSize);
// The header/content separator line overlays the caption buttons.
SetHeaderHeightForPainting(caption_button_container_->height());
}

int DefaultHeaderPainter::GetHeaderHeightForPainting() const {
Expand Down Expand Up @@ -300,11 +299,14 @@ void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) {
kHeaderContentSeparatorColor :
kHeaderContentSeparatorInactiveColor;

canvas->FillRect(gfx::Rect(0,
height_ - kHeaderContentSeparatorSize,
view_->width(),
kHeaderContentSeparatorSize),
color);
SkPaint paint;
paint.setColor(color);
// Draw the line as 1px thick regardless of scale factor.
paint.setStrokeWidth(0);

float thickness = 1 / canvas->image_scale();
SkScalar y = SkIntToScalar(height_) - SkFloatToScalar(thickness);
canvas->sk_canvas()->drawLine(0, y, SkIntToScalar(view_->width()), y, paint);
}

gfx::Rect DefaultHeaderPainter::GetLocalBounds() const {
Expand Down
7 changes: 3 additions & 4 deletions ash/frame/header_painter_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ gfx::Rect HeaderPainterUtil::GetTitleBounds(
int x = icon ?
icon->bounds().right() + kTitleIconOffsetX : kTitleNoIconOffsetX;
int height = title_font_list.GetHeight();
int y = std::max(
0,
static_cast<int>(std::ceil(
(caption_button_container->height() - height) / 2.0f)));
// Floor when computing the center of |caption_button_container| and when
// computing the center of the text.
int y = std::max(0, (caption_button_container->height() / 2) - (height / 2));
int width = std::max(
0, caption_button_container->x() - kTitleCaptionButtonSpacing - x);
return gfx::Rect(x, y, width, height);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ccd9b37

Please sign in to comment.