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

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

Issue 1505223004: Do not use assets for Ash window control button backgrounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing 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/custom_frame_view_ash_unittest.cc ('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/frame/caption_buttons/frame_caption_button_container_view.h" 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
8 #include "ash/frame/header_painter_util.h" 9 #include "ash/frame/header_painter_util.h"
9 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
10 #include "base/logging.h" // DCHECK 11 #include "base/logging.h" // DCHECK
11 #include "grit/ash_resources.h" 12 #include "grit/ash_resources.h"
12 #include "third_party/skia/include/core/SkPaint.h" 13 #include "third_party/skia/include/core/SkPaint.h"
13 #include "third_party/skia/include/core/SkPath.h" 14 #include "third_party/skia/include/core/SkPath.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/animation/slide_animation.h" 16 #include "ui/gfx/animation/slide_animation.h"
16 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void DefaultHeaderPainter::Init( 95 void DefaultHeaderPainter::Init(
95 views::Widget* frame, 96 views::Widget* frame,
96 views::View* header_view, 97 views::View* header_view,
97 FrameCaptionButtonContainerView* caption_button_container) { 98 FrameCaptionButtonContainerView* caption_button_container) {
98 DCHECK(frame); 99 DCHECK(frame);
99 DCHECK(header_view); 100 DCHECK(header_view);
100 DCHECK(caption_button_container); 101 DCHECK(caption_button_container);
101 frame_ = frame; 102 frame_ = frame;
102 view_ = header_view; 103 view_ = header_view;
103 caption_button_container_ = caption_button_container; 104 caption_button_container_ = caption_button_container;
105 caption_button_container_->SetButtonSize(
106 GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON));
104 UpdateAllButtonImages(); 107 UpdateAllButtonImages();
105 } 108 }
106 109
107 int DefaultHeaderPainter::GetMinimumHeaderWidth() const { 110 int DefaultHeaderPainter::GetMinimumHeaderWidth() const {
108 // Ensure we have enough space for the window icon and buttons. We allow 111 // Ensure we have enough space for the window icon and buttons. We allow
109 // the title string to collapse to zero width. 112 // the title string to collapse to zero width.
110 return GetTitleBounds().x() + 113 return GetTitleBounds().x() +
111 caption_button_container_->GetMinimumSize().width(); 114 caption_button_container_->GetMinimumSize().width();
112 } 115 }
113 116
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 289 }
287 290
288 bool DefaultHeaderPainter::ShouldUseLightImages() { 291 bool DefaultHeaderPainter::ShouldUseLightImages() {
289 int luminance = color_utils::GetLuminanceForColor( 292 int luminance = color_utils::GetLuminanceForColor(
290 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_); 293 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_);
291 return luminance < kMaxLuminanceForLightButtons; 294 return luminance < kMaxLuminanceForLightButtons;
292 } 295 }
293 296
294 void DefaultHeaderPainter::UpdateAllButtonImages() { 297 void DefaultHeaderPainter::UpdateAllButtonImages() {
295 bool use_light_images = ShouldUseLightImages(); 298 bool use_light_images = ShouldUseLightImages();
296 caption_button_container_->SetButtonImages( 299 caption_button_container_->SetButtonImage(
297 CAPTION_BUTTON_ICON_MINIMIZE, 300 CAPTION_BUTTON_ICON_MINIMIZE,
298 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE_WHITE 301 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE_WHITE
299 : IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE, 302 : IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE);
300 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
301 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
302 303
303 UpdateSizeButtonImages(use_light_images); 304 UpdateSizeButtonImages(use_light_images);
304 305
305 caption_button_container_->SetButtonImages( 306 caption_button_container_->SetButtonImage(
306 CAPTION_BUTTON_ICON_CLOSE, 307 CAPTION_BUTTON_ICON_CLOSE, use_light_images
307 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_WHITE 308 ? IDR_AURA_WINDOW_CONTROL_ICON_CLOSE_WHITE
308 : IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, 309 : IDR_AURA_WINDOW_CONTROL_ICON_CLOSE);
309 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
310 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
311 310
312 caption_button_container_->SetButtonImages( 311 caption_button_container_->SetButtonImage(
313 CAPTION_BUTTON_ICON_LEFT_SNAPPED, 312 CAPTION_BUTTON_ICON_LEFT_SNAPPED,
314 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED_WHITE 313 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED_WHITE
315 : IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED, 314 : IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED);
316 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
317 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
318 315
319 caption_button_container_->SetButtonImages( 316 caption_button_container_->SetButtonImage(
320 CAPTION_BUTTON_ICON_RIGHT_SNAPPED, 317 CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
321 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED_WHITE 318 use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED_WHITE
322 : IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED, 319 : IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED);
323 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
324 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
325 } 320 }
326 321
327 void DefaultHeaderPainter::UpdateSizeButtonImages(bool use_light_images) { 322 void DefaultHeaderPainter::UpdateSizeButtonImages(bool use_light_images) {
328 int icon_id = 0; 323 int icon_id = 0;
329 if (frame_->IsMaximized() || frame_->IsFullscreen()) { 324 if (frame_->IsMaximized() || frame_->IsFullscreen()) {
330 icon_id = use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_RESTORE_WHITE 325 icon_id = use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_RESTORE_WHITE
331 : IDR_AURA_WINDOW_CONTROL_ICON_RESTORE; 326 : IDR_AURA_WINDOW_CONTROL_ICON_RESTORE;
332 } else { 327 } else {
333 icon_id = use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE_WHITE 328 icon_id = use_light_images ? IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE_WHITE
334 : IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE; 329 : IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE;
335 } 330 }
336 caption_button_container_->SetButtonImages( 331 caption_button_container_->SetButtonImage(
337 CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, 332 CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon_id);
338 icon_id,
339 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
340 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
341 } 333 }
342 334
343 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { 335 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const {
344 return gfx::Rect(view_->width(), painted_height_); 336 return gfx::Rect(view_->width(), painted_height_);
345 } 337 }
346 338
347 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { 339 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const {
348 return HeaderPainterUtil::GetTitleBounds( 340 return HeaderPainterUtil::GetTitleBounds(
349 left_header_view_, caption_button_container_, GetTitleFontList()); 341 left_header_view_, caption_button_container_, GetTitleFontList());
350 } 342 }
351 343
352 bool DefaultHeaderPainter::UsesCustomFrameColors() const { 344 bool DefaultHeaderPainter::UsesCustomFrameColors() const {
353 return active_frame_color_ != kDefaultFrameColor || 345 return active_frame_color_ != kDefaultFrameColor ||
354 inactive_frame_color_ != kDefaultFrameColor; 346 inactive_frame_color_ != kDefaultFrameColor;
355 } 347 }
356 348
357 } // namespace ash 349 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/custom_frame_view_ash_unittest.cc ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698