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

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

Issue 1566563002: Vectorize CrOS window control icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dummy GetIcon impl in TestToolbarModel Created 4 years, 11 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
« no previous file with comments | « ash/frame/default_header_painter.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/default_header_painter.h" 5 #include "ash/frame/default_header_painter.h"
6 6
7 #include "ash/ash_layout_constants.h" 7 #include "ash/ash_layout_constants.h"
8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
9 #include "ash/frame/header_painter_util.h" 9 #include "ash/frame/header_painter_util.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
11 #include "base/logging.h" // DCHECK 11 #include "base/logging.h" // DCHECK
12 #include "grit/ash_resources.h" 12 #include "grit/ash_resources.h"
13 #include "third_party/skia/include/core/SkPaint.h" 13 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkPath.h" 14 #include "third_party/skia/include/core/SkPath.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/animation/slide_animation.h" 16 #include "ui/gfx/animation/slide_animation.h"
17 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
19 #include "ui/gfx/font_list.h" 19 #include "ui/gfx/font_list.h"
20 #include "ui/gfx/geometry/rect.h" 20 #include "ui/gfx/geometry/rect.h"
21 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/scoped_canvas.h" 22 #include "ui/gfx/scoped_canvas.h"
23 #include "ui/gfx/skia_util.h" 23 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/vector_icons_public.h"
24 #include "ui/views/view.h" 25 #include "ui/views/view.h"
25 #include "ui/views/widget/native_widget_aura.h" 26 #include "ui/views/widget/native_widget_aura.h"
26 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
27 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
28 29
29 using views::Widget; 30 using views::Widget;
30 31
31 namespace { 32 namespace {
32 33
33 // Color for the window title text. 34 // Color for the window title text.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 152 }
152 if (frame_->widget_delegate() && 153 if (frame_->widget_delegate() &&
153 frame_->widget_delegate()->ShouldShowWindowTitle()) { 154 frame_->widget_delegate()->ShouldShowWindowTitle()) {
154 PaintTitleBar(canvas); 155 PaintTitleBar(canvas);
155 } 156 }
156 if (!UsesCustomFrameColors()) 157 if (!UsesCustomFrameColors())
157 PaintHeaderContentSeparator(canvas); 158 PaintHeaderContentSeparator(canvas);
158 } 159 }
159 160
160 void DefaultHeaderPainter::LayoutHeader() { 161 void DefaultHeaderPainter::LayoutHeader() {
161 UpdateSizeButtonImages(ShouldUseLightImages()); 162 caption_button_container_->SetUseLightImages(ShouldUseLightImages());
163 UpdateSizeButtonImages();
162 caption_button_container_->Layout(); 164 caption_button_container_->Layout();
163 165
164 gfx::Size caption_button_container_size = 166 gfx::Size caption_button_container_size =
165 caption_button_container_->GetPreferredSize(); 167 caption_button_container_->GetPreferredSize();
166 caption_button_container_->SetBounds( 168 caption_button_container_->SetBounds(
167 view_->width() - caption_button_container_size.width(), 169 view_->width() - caption_button_container_size.width(),
168 0, 170 0,
169 caption_button_container_size.width(), 171 caption_button_container_size.width(),
170 caption_button_container_size.height()); 172 caption_button_container_size.height());
171 173
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 290 }
289 } 291 }
290 292
291 bool DefaultHeaderPainter::ShouldUseLightImages() { 293 bool DefaultHeaderPainter::ShouldUseLightImages() {
292 int luminance = color_utils::GetLuminanceForColor( 294 int luminance = color_utils::GetLuminanceForColor(
293 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_); 295 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_);
294 return luminance < kMaxLuminanceForLightButtons; 296 return luminance < kMaxLuminanceForLightButtons;
295 } 297 }
296 298
297 void DefaultHeaderPainter::UpdateAllButtonImages() { 299 void DefaultHeaderPainter::UpdateAllButtonImages() {
298 bool use_light_images = ShouldUseLightImages(); 300 caption_button_container_->SetUseLightImages(ShouldUseLightImages());
299 caption_button_container_->SetButtonImage( 301 caption_button_container_->SetButtonImage(
300 CAPTION_BUTTON_ICON_MINIMIZE, 302 CAPTION_BUTTON_ICON_MINIMIZE, gfx::VectorIconId::WINDOW_CONTROL_MINIMIZE);
301 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE_WHITE
302 : IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE);
303 303
304 UpdateSizeButtonImages(use_light_images); 304 UpdateSizeButtonImages();
305 305
306 caption_button_container_->SetButtonImage( 306 caption_button_container_->SetButtonImage(
307 CAPTION_BUTTON_ICON_CLOSE, use_light_images 307 CAPTION_BUTTON_ICON_CLOSE, gfx::VectorIconId::WINDOW_CONTROL_CLOSE);
308 ? IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_WHITE
309 : IDR_AURA_WINDOW_CONTROL_ICON_CLOSE);
310 308
311 caption_button_container_->SetButtonImage( 309 caption_button_container_->SetButtonImage(
312 CAPTION_BUTTON_ICON_LEFT_SNAPPED, 310 CAPTION_BUTTON_ICON_LEFT_SNAPPED,
313 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED_WHITE 311 gfx::VectorIconId::WINDOW_CONTROL_LEFT_SNAPPED);
314 : IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED);
315 312
316 caption_button_container_->SetButtonImage( 313 caption_button_container_->SetButtonImage(
317 CAPTION_BUTTON_ICON_RIGHT_SNAPPED, 314 CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
318 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED_WHITE 315 gfx::VectorIconId::WINDOW_CONTROL_RIGHT_SNAPPED);
319 : IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED);
320 } 316 }
321 317
322 void DefaultHeaderPainter::UpdateSizeButtonImages(bool use_light_images) { 318 void DefaultHeaderPainter::UpdateSizeButtonImages() {
323 int icon_id = 0; 319 gfx::VectorIconId icon_id = frame_->IsMaximized() || frame_->IsFullscreen()
324 if (frame_->IsMaximized() || frame_->IsFullscreen()) { 320 ? gfx::VectorIconId::WINDOW_CONTROL_RESTORE
325 icon_id = use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_RESTORE_WHITE 321 : gfx::VectorIconId::WINDOW_CONTROL_MAXIMIZE;
326 : IDR_AURA_WINDOW_CONTROL_ICON_RESTORE;
327 } else {
328 icon_id = use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE_WHITE
329 : IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE;
330 }
331 caption_button_container_->SetButtonImage( 322 caption_button_container_->SetButtonImage(
332 CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon_id); 323 CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon_id);
333 } 324 }
334 325
335 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { 326 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const {
336 return gfx::Rect(view_->width(), painted_height_); 327 return gfx::Rect(view_->width(), painted_height_);
337 } 328 }
338 329
339 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { 330 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const {
340 return HeaderPainterUtil::GetTitleBounds( 331 return HeaderPainterUtil::GetTitleBounds(
341 left_header_view_, caption_button_container_, GetTitleFontList()); 332 left_header_view_, caption_button_container_, GetTitleFontList());
342 } 333 }
343 334
344 bool DefaultHeaderPainter::UsesCustomFrameColors() const { 335 bool DefaultHeaderPainter::UsesCustomFrameColors() const {
345 return active_frame_color_ != kDefaultFrameColor || 336 return active_frame_color_ != kDefaultFrameColor ||
346 inactive_frame_color_ != kDefaultFrameColor; 337 inactive_frame_color_ != kDefaultFrameColor;
347 } 338 }
348 339
349 } // namespace ash 340 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/default_header_painter.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698