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

Side by Side Diff: ash/frame/header_painter.cc

Issue 200483004: Show avatar icon on V2 app's frame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/frame/header_painter.h" 5 #include "ash/frame/header_painter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
10 #include "base/logging.h" // DCHECK 10 #include "base/logging.h" // DCHECK
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 namespace ash { 137 namespace ash {
138 138
139 /////////////////////////////////////////////////////////////////////////////// 139 ///////////////////////////////////////////////////////////////////////////////
140 // HeaderPainter, public: 140 // HeaderPainter, public:
141 141
142 HeaderPainter::HeaderPainter() 142 HeaderPainter::HeaderPainter()
143 : frame_(NULL), 143 : frame_(NULL),
144 header_view_(NULL), 144 header_view_(NULL),
145 window_icon_(NULL), 145 window_icon_(NULL),
146 window_icon_size_(kIconSize, kIconSize),
146 caption_button_container_(NULL), 147 caption_button_container_(NULL),
147 header_height_(0), 148 header_height_(0),
148 previous_theme_frame_id_(0), 149 previous_theme_frame_id_(0),
149 previous_theme_frame_overlay_id_(0), 150 previous_theme_frame_overlay_id_(0),
150 crossfade_theme_frame_id_(0), 151 crossfade_theme_frame_id_(0),
151 crossfade_theme_frame_overlay_id_(0) {} 152 crossfade_theme_frame_overlay_id_(0) {}
152 153
153 HeaderPainter::~HeaderPainter() { 154 HeaderPainter::~HeaderPainter() {
154 } 155 }
155 156
156 void HeaderPainter::Init( 157 void HeaderPainter::Init(
157 Style style, 158 Style style,
158 views::Widget* frame, 159 views::Widget* frame,
159 views::View* header_view, 160 views::View* header_view,
160 views::View* window_icon, 161 views::View* window_icon,
161 FrameCaptionButtonContainerView* caption_button_container) { 162 FrameCaptionButtonContainerView* caption_button_container) {
162 DCHECK(frame); 163 DCHECK(frame);
163 DCHECK(header_view); 164 DCHECK(header_view);
164 // window_icon may be NULL. 165 // window_icon may be NULL.
165 DCHECK(caption_button_container); 166 DCHECK(caption_button_container);
166 style_ = style; 167 style_ = style;
167 frame_ = frame; 168 frame_ = frame;
168 header_view_ = header_view; 169 header_view_ = header_view;
169 window_icon_ = window_icon; 170 window_icon_ = window_icon;
170 caption_button_container_ = caption_button_container; 171 caption_button_container_ = caption_button_container;
171 } 172 }
172 173
174 void HeaderPainter::UpdateWindowIcon(views::View* window_icon,
175 const gfx::Size& window_icon_size) {
176 window_icon_ = window_icon;
177 window_icon_size_ = window_icon_size;
178 }
179
173 // static 180 // static
174 gfx::Rect HeaderPainter::GetBoundsForClientView( 181 gfx::Rect HeaderPainter::GetBoundsForClientView(
175 int header_height, 182 int header_height,
176 const gfx::Rect& window_bounds) { 183 const gfx::Rect& window_bounds) {
177 gfx::Rect client_bounds(window_bounds); 184 gfx::Rect client_bounds(window_bounds);
178 client_bounds.Inset(0, header_height, 0, 0); 185 client_bounds.Inset(0, header_height, 0, 0);
179 return client_bounds; 186 return client_bounds;
180 } 187 }
181 188
182 // static 189 // static
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 header_view_->width() - caption_button_container_size.width(), 368 header_view_->width() - caption_button_container_size.width(),
362 0, 369 0,
363 caption_button_container_size.width(), 370 caption_button_container_size.width(),
364 caption_button_container_size.height()); 371 caption_button_container_size.height());
365 372
366 if (window_icon_) { 373 if (window_icon_) {
367 // Vertically center the window icon with respect to the caption button 374 // Vertically center the window icon with respect to the caption button
368 // container. 375 // container.
369 int icon_offset_y = 376 int icon_offset_y =
370 GetCaptionButtonContainerCenterY() - window_icon_->height() / 2; 377 GetCaptionButtonContainerCenterY() - window_icon_->height() / 2;
371 window_icon_->SetBounds(kIconOffsetX, icon_offset_y, kIconSize, kIconSize); 378 window_icon_->SetBounds(kIconOffsetX, icon_offset_y,
379 window_icon_size_.width(),
380 window_icon_size_.height());
372 } 381 }
373 } 382 }
374 383
375 void HeaderPainter::SchedulePaintForTitle( 384 void HeaderPainter::SchedulePaintForTitle(
376 const gfx::FontList& title_font_list) { 385 const gfx::FontList& title_font_list) {
377 header_view_->SchedulePaintInRect(GetTitleBounds(title_font_list)); 386 header_view_->SchedulePaintInRect(GetTitleBounds(title_font_list));
378 } 387 }
379 388
380 void HeaderPainter::OnThemeChanged() { 389 void HeaderPainter::OnThemeChanged() {
381 // We do not cache the images for |previous_theme_frame_id_| and 390 // We do not cache the images for |previous_theme_frame_id_| and
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 int title_y = 625 int title_y =
617 GetCaptionButtonContainerCenterY() - title_font_list.GetHeight() / 2; 626 GetCaptionButtonContainerCenterY() - title_font_list.GetHeight() / 2;
618 return gfx::Rect( 627 return gfx::Rect(
619 title_x, 628 title_x,
620 std::max(0, title_y), 629 std::max(0, title_y),
621 std::max(0, caption_button_container_->x() - kTitleLogoSpacing - title_x), 630 std::max(0, caption_button_container_->x() - kTitleLogoSpacing - title_x),
622 title_font_list.GetHeight()); 631 title_font_list.GetHeight());
623 } 632 }
624 633
625 } // namespace ash 634 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698