Chromium Code Reviews| Index: ash/frame/default_header_painter.cc |
| diff --git a/ash/frame/default_header_painter.cc b/ash/frame/default_header_painter.cc |
| index fd31d776e91913c78bc0c304370793280d4db70e..3985ecf8982830b0304a66ffb08b339cb00b561c 100644 |
| --- a/ash/frame/default_header_painter.cc |
| +++ b/ash/frame/default_header_painter.cc |
| @@ -74,8 +74,9 @@ namespace ash { |
| DefaultHeaderPainter::DefaultHeaderPainter() |
| : frame_(NULL), |
| view_(NULL), |
| - window_icon_(NULL), |
| - window_icon_size_(HeaderPainterUtil::GetDefaultIconSize()), |
| + left_header_view_(NULL), |
| + left_header_view_size_(0), |
| + left_header_view_offset_(0), |
| caption_button_container_(NULL), |
| height_(0), |
| mode_(MODE_INACTIVE), |
| @@ -89,15 +90,12 @@ DefaultHeaderPainter::~DefaultHeaderPainter() { |
| void DefaultHeaderPainter::Init( |
| views::Widget* frame, |
| views::View* header_view, |
| - views::View* window_icon, |
| FrameCaptionButtonContainerView* caption_button_container) { |
| DCHECK(frame); |
| DCHECK(header_view); |
| - // window_icon may be NULL. |
| DCHECK(caption_button_container); |
| frame_ = frame; |
| view_ = header_view; |
| - window_icon_ = window_icon; |
| caption_button_container_ = caption_button_container; |
| caption_button_container_->SetButtonImages( |
| @@ -210,15 +208,7 @@ void DefaultHeaderPainter::LayoutHeader() { |
| caption_button_container_size.width(), |
| caption_button_container_size.height()); |
| - if (window_icon_) { |
| - // Vertically center the window icon with respect to the caption button |
| - // container. |
| - // Floor when computing the center of |caption_button_container_|. |
| - int icon_offset_y = |
| - caption_button_container_->height() / 2 - window_icon_size_ / 2; |
| - window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y, |
| - window_icon_size_, window_icon_size_); |
| - } |
| + LayoutLeftHeaderView(); |
| // The header/content separator line overlays the caption buttons. |
| SetHeaderHeightForPainting(caption_button_container_->height()); |
| @@ -236,10 +226,17 @@ void DefaultHeaderPainter::SchedulePaintForTitle() { |
| view_->SchedulePaintInRect(GetTitleBounds()); |
| } |
| -void DefaultHeaderPainter::UpdateWindowIcon(views::View* window_icon, |
| - int window_icon_size) { |
| - window_icon_ = window_icon; |
| - window_icon_size_ = window_icon_size; |
| +void DefaultHeaderPainter::UpdateHeaderOffset(int left_header_view_offset) { |
|
pkotwicz
2014/08/13 01:19:47
I think that |left_view_x_inset| is a better name.
benwells
2014/08/13 08:09:28
Done.
|
| + int old_offset = left_header_view_offset_; |
| + left_header_view_offset_ = left_header_view_offset; |
| + if (old_offset != left_header_view_offset_) |
| + LayoutLeftHeaderView(); |
| +} |
| + |
| +void DefaultHeaderPainter::UpdateLeftHeaderView(views::View* left_header_view, |
| + int left_header_view_size) { |
| + left_header_view_ = left_header_view; |
| + left_header_view_size_ = left_header_view_size; |
| } |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -313,13 +310,27 @@ void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { |
| canvas->sk_canvas()->drawLine(0, y, SkIntToScalar(view_->width()), y, paint); |
| } |
| +void DefaultHeaderPainter::LayoutLeftHeaderView() { |
| + if (left_header_view_) { |
| + // Vertically center the window icon with respect to the caption button |
| + // container. |
| + // Floor when computing the center of |caption_button_container_|. |
| + int icon_offset_y = caption_button_container_->height() / 2 - |
| + left_header_view_->height() / 2; |
| + int offset = left_header_view_offset_ ? left_header_view_offset_ |
| + : HeaderPainterUtil::GetIconXOffset(); |
|
pkotwicz
2014/08/13 01:19:47
Nit: I think that checking equality to zero here w
benwells
2014/08/13 08:09:28
Done.
|
| + left_header_view_->SetBounds( |
| + offset, icon_offset_y, left_header_view_size_, left_header_view_size_); |
|
pkotwicz
2014/08/13 01:19:47
Can we use left_header_view_->GetPreferredSize() a
benwells
2014/08/13 08:09:28
Seems so. The code sure is nicer! I hope it doesn'
|
| + } |
| +} |
| + |
| gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { |
| return gfx::Rect(view_->width(), height_); |
| } |
| gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { |
| return HeaderPainterUtil::GetTitleBounds( |
| - window_icon_, caption_button_container_, GetTitleFontList()); |
| + left_header_view_, caption_button_container_, GetTitleFontList()); |
| } |
| gfx::ImageSkia* DefaultHeaderPainter::GetActiveFrameImage() const { |