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

Unified Diff: ash/frame/default_header_painter.cc

Issue 441803004: Introduce new WebApp header style for hosted apps and fizzy apps on ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Real assets, crushed, review feedback Created 6 years, 4 months 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
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..9c99790472a247a7df94b4ddc42fc846acaf7f37 100644
--- a/ash/frame/default_header_painter.cc
+++ b/ash/frame/default_header_painter.cc
@@ -74,8 +74,8 @@ namespace ash {
DefaultHeaderPainter::DefaultHeaderPainter()
: frame_(NULL),
view_(NULL),
- window_icon_(NULL),
- window_icon_size_(HeaderPainterUtil::GetDefaultIconSize()),
+ left_header_view_(NULL),
+ left_view_x_inset_(HeaderPainterUtil::GetDefaultLeftViewXInset()),
caption_button_container_(NULL),
height_(0),
mode_(MODE_INACTIVE),
@@ -89,15 +89,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 +207,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 +225,15 @@ 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::UpdateLeftViewXInset(int left_view_x_inset) {
+ int old_inset = left_view_x_inset_;
+ left_view_x_inset_ = left_view_x_inset;
+ if (old_inset != left_view_x_inset_)
+ LayoutLeftHeaderView();
pkotwicz 2014/08/19 00:17:07 Nit - This is slightly shorter: if (left_view_x_i
benwells 2014/08/19 01:42:42 Done.
+}
+
+void DefaultHeaderPainter::UpdateLeftHeaderView(views::View* left_header_view) {
+ left_header_view_ = left_header_view;
}
///////////////////////////////////////////////////////////////////////////////
@@ -313,13 +307,26 @@ 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 left header view 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;
pkotwicz 2014/08/19 00:17:07 Shouldn't this be size.height() instead of left_he
benwells 2014/08/19 01:42:42 Done.
+ gfx::Size size = left_header_view_->GetPreferredSize();
+ left_header_view_->SetBounds(
+ left_view_x_inset_, icon_offset_y, size.width(), size.height());
+ }
+}
+
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 {

Powered by Google App Engine
This is Rietveld 408576698