Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 if (frame_->IsMaximized() || frame_->IsFullscreen()) { | |
| 406 hover_background_id = | |
| 407 IDR_ASH_BROWSER_WINDOW_CONTROL_BACKGROUND_MAXIMIZED_H; | |
| 408 pressed_background_id = | |
| 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 } | |
| 416 caption_button_container_->SetButtonImages( | |
| 417 ash::CAPTION_BUTTON_ICON_MINIMIZE, | 405 ash::CAPTION_BUTTON_ICON_MINIMIZE, |
| 418 IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE, | 406 IDR_AURA_WINDOW_CONTROL_ICON_MINIMIZE); |
| 419 hover_background_id, | |
| 420 pressed_background_id); | |
| 421 | 407 |
| 422 int size_icon_id = 0; | 408 int size_icon_id = 0; |
| 423 if (frame_->IsMaximized() || frame_->IsFullscreen()) | 409 gfx::Size button_size; |
| 410 if (frame_->IsMaximized() || frame_->IsFullscreen()) { | |
| 424 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_RESTORE; | 411 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_RESTORE; |
| 425 else | 412 button_size = GetAshLayoutSize(BROWSER_MAXIMIZED_HEADER_BUTTON); |
| 413 } else { | |
| 426 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE; | 414 size_icon_id = IDR_AURA_WINDOW_CONTROL_ICON_MAXIMIZE; |
| 427 caption_button_container_->SetButtonImages( | 415 button_size = GetAshLayoutSize(BROWSER_RESTORED_HEADER_BUTTON); |
| 416 } | |
|
Peter Kasting
2015/12/18 18:59:15
Nit: Shorter:
int size_icon_id = IDR_AURA_WINDO
tdanderson
2016/01/04 23:11:15
Done.
| |
| 417 caption_button_container_->SetButtonImage( | |
| 428 ash::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, | 418 ash::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, |
| 429 size_icon_id, | 419 size_icon_id); |
| 430 hover_background_id, | 420 caption_button_container_->SetButtonSize(button_size); |
|
Peter Kasting
2015/12/18 18:59:15
Nit: I'd put this call either above or below all t
tdanderson
2016/01/04 23:11:15
Done.
| |
| 431 pressed_background_id); | |
| 432 | 421 |
| 433 caption_button_container_->SetButtonImages( | 422 caption_button_container_->SetButtonImage( |
| 434 ash::CAPTION_BUTTON_ICON_CLOSE, | 423 ash::CAPTION_BUTTON_ICON_CLOSE, |
| 435 IDR_AURA_WINDOW_CONTROL_ICON_CLOSE, | 424 IDR_AURA_WINDOW_CONTROL_ICON_CLOSE); |
| 436 hover_background_id, | 425 caption_button_container_->SetButtonImage( |
| 437 pressed_background_id); | |
| 438 caption_button_container_->SetButtonImages( | |
| 439 ash::CAPTION_BUTTON_ICON_LEFT_SNAPPED, | 426 ash::CAPTION_BUTTON_ICON_LEFT_SNAPPED, |
| 440 IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED, | 427 IDR_AURA_WINDOW_CONTROL_ICON_LEFT_SNAPPED); |
| 441 hover_background_id, | 428 caption_button_container_->SetButtonImage( |
| 442 pressed_background_id); | |
| 443 caption_button_container_->SetButtonImages( | |
| 444 ash::CAPTION_BUTTON_ICON_RIGHT_SNAPPED, | 429 ash::CAPTION_BUTTON_ICON_RIGHT_SNAPPED, |
| 445 IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED, | 430 IDR_AURA_WINDOW_CONTROL_ICON_RIGHT_SNAPPED); |
| 446 hover_background_id, | |
| 447 pressed_background_id); | |
| 448 } | 431 } |
| 449 | 432 |
| 450 gfx::Rect BrowserHeaderPainterAsh::GetPaintedBounds() const { | 433 gfx::Rect BrowserHeaderPainterAsh::GetPaintedBounds() const { |
| 451 return gfx::Rect(view_->width(), painted_height_); | 434 return gfx::Rect(view_->width(), painted_height_); |
| 452 } | 435 } |
| 453 | 436 |
| 454 gfx::Rect BrowserHeaderPainterAsh::GetTitleBounds() const { | 437 gfx::Rect BrowserHeaderPainterAsh::GetTitleBounds() const { |
| 455 return ash::HeaderPainterUtil::GetTitleBounds(window_icon_, | 438 return ash::HeaderPainterUtil::GetTitleBounds(window_icon_, |
| 456 caption_button_container_, BrowserFrame::GetTitleFontList()); | 439 caption_button_container_, BrowserFrame::GetTitleFontList()); |
| 457 } | 440 } |
| OLD | NEW |