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

Side by Side Diff: chrome/browser/ui/views/frame/browser_header_painter_ash.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
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 "chrome/browser/ui/views/frame/browser_header_painter_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.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/logging.h" // DCHECK 10 #include "base/logging.h" // DCHECK
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/views/frame/browser_frame.h" 12 #include "chrome/browser/ui/views/frame/browser_frame.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
14 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
15 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 PaintTitleBar(canvas); 232 PaintTitleBar(canvas);
232 } 233 }
233 } 234 }
234 235
235 void BrowserHeaderPainterAsh::LayoutHeader() { 236 void BrowserHeaderPainterAsh::LayoutHeader() {
236 // Purposefully set |painted_height_| to an invalid value. We cannot use 237 // Purposefully set |painted_height_| to an invalid value. We cannot use
237 // |painted_height_| because the computation of |painted_height_| may depend 238 // |painted_height_| because the computation of |painted_height_| may depend
238 // on having laid out the window controls. 239 // on having laid out the window controls.
239 painted_height_ = -1; 240 painted_height_ = -1;
240 241
241 UpdateCaptionButtonImages(); 242 UpdateCaptionButtons();
242 caption_button_container_->Layout(); 243 caption_button_container_->Layout();
243 244
244 gfx::Size caption_button_container_size = 245 gfx::Size caption_button_container_size =
245 caption_button_container_->GetPreferredSize(); 246 caption_button_container_->GetPreferredSize();
246 caption_button_container_->SetBounds( 247 caption_button_container_->SetBounds(
247 view_->width() - caption_button_container_size.width(), 248 view_->width() - caption_button_container_size.width(),
248 0, 249 0,
249 caption_button_container_size.width(), 250 caption_button_container_size.width(),
250 caption_button_container_size.height()); 251 caption_button_container_size.height());
251 252
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // in order to get the default non-themed assets. 393 // in order to get the default non-themed assets.
393 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 394 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
394 if (mode == MODE_ACTIVE) { 395 if (mode == MODE_ACTIVE) {
395 return *rb.GetImageSkiaNamed(is_incognito_ ? 396 return *rb.GetImageSkiaNamed(is_incognito_ ?
396 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME); 397 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME);
397 } 398 }
398 return *rb.GetImageSkiaNamed(is_incognito_ ? 399 return *rb.GetImageSkiaNamed(is_incognito_ ?
399 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE); 400 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE);
400 } 401 }
401 402
402 void BrowserHeaderPainterAsh::UpdateCaptionButtonImages() { 403 void BrowserHeaderPainterAsh::UpdateCaptionButtons() {
403 int hover_background_id = 0; 404 caption_button_container_->SetButtonImage(
404 int pressed_background_id = 0; 405 ash::CAPTION_BUTTON_ICON_MINIMIZE,
406 IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE);
407 caption_button_container_->SetButtonImage(
408 ash::CAPTION_BUTTON_ICON_CLOSE,
409 IDR_AURA_WINDOW_CONTROL_ICON_CLOSE);
410 caption_button_container_->SetButtonImage(
411 ash::CAPTION_BUTTON_ICON_LEFT_SNAPPED,
412 IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED);
413 caption_button_container_->SetButtonImage(
414 ash::CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
415 IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED);
416
417 int size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE;
418 gfx::Size button_size(
419 GetAshLayoutSize(AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON));
405 if (frame_->IsMaximized() || frame_->IsFullscreen()) { 420 if (frame_->IsMaximized() || frame_->IsFullscreen()) {
406 hover_background_id = 421 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_RESTORE;
407 IDR_ASH_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H; 422 button_size =
408 pressed_background_id = 423 GetAshLayoutSize(AshLayoutSize::BROWSER_MAXIMIZED_CAPTION_BUTTON);
409 IDR_ASH_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_P;
410 } else {
411 hover_background_id =
412 IDR_ASH_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_H;
413 pressed_background_id =
414 IDR_ASH_BROWSER_WINDOW_CONTROL_BACKGROUND_RESTORED_P;
415 } 424 }
416 caption_button_container_->SetButtonImages( 425 caption_button_container_->SetButtonImage(
417 ash::CAPTION_BUTTON_ICON_MINIMIZE,
418 IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE,
419 hover_background_id,
420 pressed_background_id);
421
422 int size_icon_id = 0;
423 if (frame_->IsMaximized() || frame_->IsFullscreen())
424 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_RESTORE;
425 else
426 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE;
427 caption_button_container_->SetButtonImages(
428 ash::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, 426 ash::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE,
429 size_icon_id, 427 size_icon_id);
430 hover_background_id, 428 caption_button_container_->SetButtonSize(button_size);
431 pressed_background_id);
432
433 caption_button_container_->SetButtonImages(
434 ash::CAPTION_BUTTON_ICON_CLOSE,
435 IDR_AURA_WINDOW_CONTROL_ICON_CLOSE,
436 hover_background_id,
437 pressed_background_id);
438 caption_button_container_->SetButtonImages(
439 ash::CAPTION_BUTTON_ICON_LEFT_SNAPPED,
440 IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED,
441 hover_background_id,
442 pressed_background_id);
443 caption_button_container_->SetButtonImages(
444 ash::CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
445 IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED,
446 hover_background_id,
447 pressed_background_id);
448 } 429 }
449 430
450 gfx::Rect BrowserHeaderPainterAsh::GetPaintedBounds() const { 431 gfx::Rect BrowserHeaderPainterAsh::GetPaintedBounds() const {
451 return gfx::Rect(view_->width(), painted_height_); 432 return gfx::Rect(view_->width(), painted_height_);
452 } 433 }
453 434
454 gfx::Rect BrowserHeaderPainterAsh::GetTitleBounds() const { 435 gfx::Rect BrowserHeaderPainterAsh::GetTitleBounds() const {
455 return ash::HeaderPainterUtil::GetTitleBounds(window_icon_, 436 return ash::HeaderPainterUtil::GetTitleBounds(window_icon_,
456 caption_button_container_, BrowserFrame::GetTitleFontList()); 437 caption_button_container_, BrowserFrame::GetTitleFontList());
457 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698