Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_frame.h" | 10 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 return std::max(FrameBorderThickness(restored) + IconSize(), | 488 return std::max(FrameBorderThickness(restored) + IconSize(), |
| 489 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + | 489 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + |
| 490 TitlebarBottomThickness(restored); | 490 TitlebarBottomThickness(restored); |
| 491 } | 491 } |
| 492 | 492 |
| 493 return FrameBorderThickness(restored) - | 493 return FrameBorderThickness(restored) - |
| 494 ((browser_view_->IsTabStripVisible() && !restored && | 494 ((browser_view_->IsTabStripVisible() && !restored && |
| 495 window->IsMaximized()) ? kTabstripTopShadowThickness : 0); | 495 window->IsMaximized()) ? kTabstripTopShadowThickness : 0); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void OpaqueBrowserFrameView::ModifyMaximizedFramePainting( | |
| 499 int* theme_offset, SkBitmap** left_corner, SkBitmap** right_corner) { | |
| 500 } | |
| 501 | |
| 498 int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const { | 502 int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const { |
| 499 // Maximized buttons start at window top so that even if their images aren't | 503 // Maximized buttons start at window top so that even if their images aren't |
| 500 // drawn flush with the screen edge, they still obey Fitts' Law. | 504 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 501 return (!restored && frame_->GetWindow()->IsMaximized()) ? | 505 return (!restored && frame_->GetWindow()->IsMaximized()) ? |
| 502 FrameBorderThickness(false) : kFrameShadowThickness; | 506 FrameBorderThickness(false) : kFrameShadowThickness; |
| 503 } | 507 } |
| 504 | 508 |
| 505 int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const { | 509 int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const { |
| 506 return kTitlebarTopAndBottomEdgeThickness + | 510 return kTitlebarTopAndBottomEdgeThickness + |
| 507 ((!restored && frame_->GetWindow()->IsMaximized()) ? | 511 ((!restored && frame_->GetWindow()->IsMaximized()) ? |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 661 width() - bottom_left_corner->width() - bottom_right_corner->width(), | 665 width() - bottom_left_corner->width() - bottom_right_corner->width(), |
| 662 bottom_edge->height()); | 666 bottom_edge->height()); |
| 663 canvas->DrawBitmapInt(*bottom_left_corner, 0, | 667 canvas->DrawBitmapInt(*bottom_left_corner, 0, |
| 664 height() - bottom_left_corner->height()); | 668 height() - bottom_left_corner->height()); |
| 665 | 669 |
| 666 // Left. | 670 // Left. |
| 667 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(), | 671 canvas->TileImageInt(*left_edge, 0, top_left_height, left_edge->width(), |
| 668 height() - top_left_height - bottom_left_corner->height()); | 672 height() - top_left_height - bottom_left_corner->height()); |
| 669 } | 673 } |
| 670 | 674 |
| 671 | |
| 672 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { | 675 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { |
| 673 ui::ThemeProvider* tp = GetThemeProvider(); | 676 ui::ThemeProvider* tp = GetThemeProvider(); |
| 674 views::Window* window = frame_->GetWindow(); | 677 views::Window* window = frame_->GetWindow(); |
| 675 | 678 |
| 676 // Window frame mode and color | 679 // Window frame mode and color |
| 677 SkBitmap* theme_frame; | 680 SkBitmap* theme_frame; |
| 681 | |
| 682 // Allow customization of these attributes. | |
| 683 SkBitmap* left = NULL; | |
| 684 SkBitmap* right = NULL; | |
| 685 int top_offset = 0; | |
| 686 ModifyMaximizedFramePainting(&top_offset, &left, &right); | |
| 687 | |
| 678 // Never theme app and popup windows. | 688 // Never theme app and popup windows. |
| 679 if (!browser_view_->IsBrowserTypeNormal()) { | 689 if (!browser_view_->IsBrowserTypeNormal()) { |
| 680 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 690 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 681 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ? | 691 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ? |
| 682 IDR_FRAME : IDR_FRAME_INACTIVE); | 692 IDR_FRAME : IDR_FRAME_INACTIVE); |
| 683 } else if (!browser_view_->IsOffTheRecord()) { | 693 } else if (!browser_view_->IsOffTheRecord()) { |
| 684 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? | 694 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 685 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); | 695 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); |
| 686 } else { | 696 } else { |
| 687 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? | 697 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 688 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME_INCOGNITO_INACTIVE); | 698 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME_INCOGNITO_INACTIVE); |
| 689 } | 699 } |
| 690 // Draw the theme frame. It must be aligned with the tabstrip as if we were | 700 // Draw the theme frame. It must be aligned with the tabstrip as if we were |
| 691 // in restored mode. Note that the top of the tabstrip is | 701 // in restored mode. Note that the top of the tabstrip is |
| 692 // kTabstripTopShadowThickness px off the top of the screen. | 702 // kTabstripTopShadowThickness px off the top of the screen. |
| 693 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + | 703 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + |
| 694 kTabstripTopShadowThickness); | 704 kTabstripTopShadowThickness); |
| 695 canvas->TileImageInt(*theme_frame, 0, theme_background_y, width(), | 705 int left_offset = 0, right_offset = 0; |
| 706 | |
| 707 if (left || right) { | |
| 708 DCHECK(left && right); | |
|
sky
2011/05/02 14:26:27
The DCHECK and if don't match.
| |
| 709 left_offset = left->width(); | |
| 710 right_offset = right->width(); | |
| 711 canvas->DrawBitmapInt(*left, 0, 0); | |
| 712 canvas->DrawBitmapInt(*right, width() - right_offset, 0); | |
| 713 } | |
| 714 | |
| 715 canvas->TileImageInt(*theme_frame, | |
| 716 left_offset, | |
| 717 top_offset, | |
| 718 width() - (left_offset + right_offset), | |
| 696 theme_frame->height()); | 719 theme_frame->height()); |
| 697 | |
| 698 // Draw the theme frame overlay | 720 // Draw the theme frame overlay |
| 699 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 721 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 700 browser_view_->IsBrowserTypeNormal()) { | 722 browser_view_->IsBrowserTypeNormal()) { |
| 701 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ? | 723 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 702 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | 724 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); |
| 703 canvas->DrawBitmapInt(*theme_overlay, 0, theme_background_y); | 725 canvas->DrawBitmapInt(*theme_overlay, 0, theme_background_y); |
| 704 } | 726 } |
| 705 | 727 |
| 706 if (!browser_view_->IsToolbarVisible()) { | 728 if (!browser_view_->IsToolbarVisible()) { |
| 707 // There's no toolbar to edge the frame border, so we need to draw a bottom | 729 // There's no toolbar to edge the frame border, so we need to draw a bottom |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1074 | 1096 |
| 1075 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1097 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1076 int height) const { | 1098 int height) const { |
| 1077 int top_height = NonClientTopBorderHeight(false, false); | 1099 int top_height = NonClientTopBorderHeight(false, false); |
| 1078 int border_thickness = NonClientBorderThickness(); | 1100 int border_thickness = NonClientBorderThickness(); |
| 1079 return gfx::Rect(border_thickness, top_height, | 1101 return gfx::Rect(border_thickness, top_height, |
| 1080 std::max(0, width - (2 * border_thickness)), | 1102 std::max(0, width - (2 * border_thickness)), |
| 1081 std::max(0, height - GetReservedHeight() - | 1103 std::max(0, height - GetReservedHeight() - |
| 1082 top_height - border_thickness)); | 1104 top_height - border_thickness)); |
| 1083 } | 1105 } |
| OLD | NEW |