| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/frame/opaque_non_client_view.h" | 5 #include "chrome/browser/views/frame/opaque_non_client_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/views/frame/browser_view.h" | 7 #include "chrome/browser/views/frame/browser_view.h" |
| 8 #include "chrome/browser/views/tabs/tab_strip.h" | 8 #include "chrome/browser/views/tabs/tab_strip.h" |
| 9 #include "chrome/common/gfx/chrome_font.h" | 9 #include "chrome/common/gfx/chrome_font.h" |
| 10 #include "chrome/common/gfx/path.h" | 10 #include "chrome/common/gfx/path.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 FRAME_CLIENT_EDGE_BOTTOM_RIGHT, | 54 FRAME_CLIENT_EDGE_BOTTOM_RIGHT, |
| 55 FRAME_CLIENT_EDGE_BOTTOM, | 55 FRAME_CLIENT_EDGE_BOTTOM, |
| 56 FRAME_CLIENT_EDGE_BOTTOM_LEFT, | 56 FRAME_CLIENT_EDGE_BOTTOM_LEFT, |
| 57 FRAME_CLIENT_EDGE_LEFT, | 57 FRAME_CLIENT_EDGE_LEFT, |
| 58 | 58 |
| 59 // No-toolbar client edge. | 59 // No-toolbar client edge. |
| 60 FRAME_NO_TOOLBAR_TOP_LEFT, | 60 FRAME_NO_TOOLBAR_TOP_LEFT, |
| 61 FRAME_NO_TOOLBAR_TOP_CENTER, | 61 FRAME_NO_TOOLBAR_TOP_CENTER, |
| 62 FRAME_NO_TOOLBAR_TOP_RIGHT, | 62 FRAME_NO_TOOLBAR_TOP_RIGHT, |
| 63 | 63 |
| 64 // Popup-mode toolbar edges. | |
| 65 FRAME_TOOLBAR_POPUP_EDGE_LEFT, | |
| 66 FRAME_TOOLBAR_POPUP_EDGE_RIGHT, | |
| 67 | |
| 68 FRAME_PART_BITMAP_COUNT // Must be last. | 64 FRAME_PART_BITMAP_COUNT // Must be last. |
| 69 }; | 65 }; |
| 70 | 66 |
| 71 class ActiveWindowResources : public views::WindowResources { | 67 class ActiveWindowResources : public views::WindowResources { |
| 72 public: | 68 public: |
| 73 ActiveWindowResources() { | 69 ActiveWindowResources() { |
| 74 InitClass(); | 70 InitClass(); |
| 75 } | 71 } |
| 76 virtual ~ActiveWindowResources() { } | 72 virtual ~ActiveWindowResources() { } |
| 77 | 73 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, | 88 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, |
| 93 IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER, | 89 IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER, |
| 94 IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE, | 90 IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE, |
| 95 IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER, | 91 IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER, |
| 96 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER, | 92 IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER, |
| 97 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, | 93 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, |
| 98 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, | 94 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, |
| 99 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, | 95 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, |
| 100 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, | 96 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, |
| 101 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, | 97 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, |
| 102 IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT, | |
| 103 }; | 98 }; |
| 104 | 99 |
| 105 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 100 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 106 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) | 101 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) |
| 107 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); | 102 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); |
| 108 initialized = true; | 103 initialized = true; |
| 109 } | 104 } |
| 110 } | 105 } |
| 111 | 106 |
| 112 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; | 107 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 138 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, | 133 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, |
| 139 IDR_DEWINDOW_BOTTOM_CENTER, IDR_DEWINDOW_BOTTOM_LEFT_CORNER, | 134 IDR_DEWINDOW_BOTTOM_CENTER, IDR_DEWINDOW_BOTTOM_LEFT_CORNER, |
| 140 IDR_DEWINDOW_BOTTOM_RIGHT_CORNER, IDR_DEWINDOW_LEFT_SIDE, | 135 IDR_DEWINDOW_BOTTOM_RIGHT_CORNER, IDR_DEWINDOW_LEFT_SIDE, |
| 141 IDR_DEWINDOW_RIGHT_SIDE, IDR_DEWINDOW_TOP_CENTER, | 136 IDR_DEWINDOW_RIGHT_SIDE, IDR_DEWINDOW_TOP_CENTER, |
| 142 IDR_DEWINDOW_TOP_LEFT_CORNER, IDR_DEWINDOW_TOP_RIGHT_CORNER, | 137 IDR_DEWINDOW_TOP_LEFT_CORNER, IDR_DEWINDOW_TOP_RIGHT_CORNER, |
| 143 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, | 138 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, |
| 144 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, | 139 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, |
| 145 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, | 140 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, |
| 146 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, | 141 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, |
| 147 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, | 142 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, |
| 148 IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT, | |
| 149 }; | 143 }; |
| 150 | 144 |
| 151 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 145 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 152 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) | 146 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) |
| 153 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); | 147 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); |
| 154 initialized = true; | 148 initialized = true; |
| 155 } | 149 } |
| 156 } | 150 } |
| 157 | 151 |
| 158 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; | 152 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 184 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, | 178 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P, |
| 185 IDR_WINDOW_BOTTOM_CENTER_OTR, IDR_WINDOW_BOTTOM_LEFT_CORNER_OTR, | 179 IDR_WINDOW_BOTTOM_CENTER_OTR, IDR_WINDOW_BOTTOM_LEFT_CORNER_OTR, |
| 186 IDR_WINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_WINDOW_LEFT_SIDE_OTR, | 180 IDR_WINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_WINDOW_LEFT_SIDE_OTR, |
| 187 IDR_WINDOW_RIGHT_SIDE_OTR, IDR_WINDOW_TOP_CENTER_OTR, | 181 IDR_WINDOW_RIGHT_SIDE_OTR, IDR_WINDOW_TOP_CENTER_OTR, |
| 188 IDR_WINDOW_TOP_LEFT_CORNER_OTR, IDR_WINDOW_TOP_RIGHT_CORNER_OTR, | 182 IDR_WINDOW_TOP_LEFT_CORNER_OTR, IDR_WINDOW_TOP_RIGHT_CORNER_OTR, |
| 189 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, | 183 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, |
| 190 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, | 184 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, |
| 191 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, | 185 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, |
| 192 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, | 186 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, |
| 193 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, | 187 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, |
| 194 IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT, | |
| 195 }; | 188 }; |
| 196 | 189 |
| 197 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 190 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 198 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) | 191 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) |
| 199 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); | 192 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); |
| 200 initialized = true; | 193 initialized = true; |
| 201 } | 194 } |
| 202 } | 195 } |
| 203 | 196 |
| 204 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; | 197 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 231 IDR_DEWINDOW_BOTTOM_CENTER_OTR, IDR_DEWINDOW_BOTTOM_LEFT_CORNER_OTR, | 224 IDR_DEWINDOW_BOTTOM_CENTER_OTR, IDR_DEWINDOW_BOTTOM_LEFT_CORNER_OTR, |
| 232 IDR_DEWINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_DEWINDOW_LEFT_SIDE_OTR, | 225 IDR_DEWINDOW_BOTTOM_RIGHT_CORNER_OTR, IDR_DEWINDOW_LEFT_SIDE_OTR, |
| 233 IDR_DEWINDOW_RIGHT_SIDE_OTR, IDR_DEWINDOW_TOP_CENTER_OTR, | 226 IDR_DEWINDOW_RIGHT_SIDE_OTR, IDR_DEWINDOW_TOP_CENTER_OTR, |
| 234 IDR_DEWINDOW_TOP_LEFT_CORNER_OTR, | 227 IDR_DEWINDOW_TOP_LEFT_CORNER_OTR, |
| 235 IDR_DEWINDOW_TOP_RIGHT_CORNER_OTR, | 228 IDR_DEWINDOW_TOP_RIGHT_CORNER_OTR, |
| 236 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, | 229 IDR_CONTENT_TOP_LEFT_CORNER, IDR_CONTENT_TOP_CENTER, |
| 237 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, | 230 IDR_CONTENT_TOP_RIGHT_CORNER, IDR_CONTENT_RIGHT_SIDE, |
| 238 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, | 231 IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER, |
| 239 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, | 232 IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE, |
| 240 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, | 233 IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT, |
| 241 IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT, | |
| 242 }; | 234 }; |
| 243 | 235 |
| 244 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 236 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 245 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) | 237 for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) |
| 246 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); | 238 standard_frame_bitmaps_[i] = rb.GetBitmapNamed(kFramePartBitmapIds[i]); |
| 247 initialized = true; | 239 initialized = true; |
| 248 } | 240 } |
| 249 } | 241 } |
| 250 | 242 |
| 251 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; | 243 static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 int border_thickness = NonClientBorderThickness(); | 467 int border_thickness = NonClientBorderThickness(); |
| 476 return gfx::Size(width + (2 * border_thickness), | 468 return gfx::Size(width + (2 * border_thickness), |
| 477 height + NonClientTopBorderHeight() + border_thickness); | 469 height + NonClientTopBorderHeight() + border_thickness); |
| 478 } | 470 } |
| 479 | 471 |
| 480 gfx::Point OpaqueNonClientView::GetSystemMenuPoint() const { | 472 gfx::Point OpaqueNonClientView::GetSystemMenuPoint() const { |
| 481 int tabstrip_height = browser_view_->IsTabStripVisible() ? | 473 int tabstrip_height = browser_view_->IsTabStripVisible() ? |
| 482 browser_view_->GetTabStripHeight() : 0; | 474 browser_view_->GetTabStripHeight() : 0; |
| 483 gfx::Point system_menu_point(FrameBorderThickness(), | 475 gfx::Point system_menu_point(FrameBorderThickness(), |
| 484 NonClientTopBorderHeight() + tabstrip_height - | 476 NonClientTopBorderHeight() + tabstrip_height - |
| 485 BottomEdgeThicknessWithinNonClientHeight()); | 477 UnavailablePixelsAtBottomOfNonClientHeight()); |
| 486 ConvertPointToScreen(this, &system_menu_point); | 478 ConvertPointToScreen(this, &system_menu_point); |
| 487 return system_menu_point; | 479 return system_menu_point; |
| 488 } | 480 } |
| 489 | 481 |
| 490 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { | 482 int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { |
| 491 if (!bounds().Contains(point)) | 483 if (!bounds().Contains(point)) |
| 492 return HTNOWHERE; | 484 return HTNOWHERE; |
| 493 | 485 |
| 494 int frame_component = frame_->client_view()->NonClientHitTest(point); | 486 int frame_component = frame_->client_view()->NonClientHitTest(point); |
| 495 if (frame_component != HTNOWHERE) | 487 if (frame_component != HTNOWHERE) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 if (frame_->window_delegate()->ShouldShowWindowTitle()) { | 681 if (frame_->window_delegate()->ShouldShowWindowTitle()) { |
| 690 int title_top_spacing, title_thickness; | 682 int title_top_spacing, title_thickness; |
| 691 return TitleCoordinates(&title_top_spacing, &title_thickness); | 683 return TitleCoordinates(&title_top_spacing, &title_thickness); |
| 692 } | 684 } |
| 693 | 685 |
| 694 return FrameBorderThickness() + | 686 return FrameBorderThickness() + |
| 695 ((frame_->IsMaximized() || browser_view_->IsFullscreen()) ? | 687 ((frame_->IsMaximized() || browser_view_->IsFullscreen()) ? |
| 696 0 : kNonClientRestoredExtraThickness); | 688 0 : kNonClientRestoredExtraThickness); |
| 697 } | 689 } |
| 698 | 690 |
| 699 int OpaqueNonClientView::BottomEdgeThicknessWithinNonClientHeight() const { | 691 int OpaqueNonClientView::UnavailablePixelsAtBottomOfNonClientHeight() const { |
| 692 // Tricky: When a toolbar is edging the titlebar, it not only draws its own |
| 693 // shadow and client edge, but an extra, light "shadow" pixel as well, which |
| 694 // is treated as available space. Thus the nonclient area actually _fails_ to |
| 695 // include some available pixels, leading to a negative number here. |
| 700 if (browser_view_->IsToolbarVisible()) | 696 if (browser_view_->IsToolbarVisible()) |
| 701 return 0; | 697 return -kFrameShadowThickness; |
| 698 |
| 702 return kFrameShadowThickness + | 699 return kFrameShadowThickness + |
| 703 (frame_->IsMaximized() ? 0 : kClientEdgeThickness); | 700 (frame_->IsMaximized() ? 0 : kClientEdgeThickness); |
| 704 } | 701 } |
| 705 | 702 |
| 706 int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing, | 703 int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing, |
| 707 int* title_thickness) const { | 704 int* title_thickness) const { |
| 708 int frame_thickness = FrameBorderThickness(); | 705 int frame_thickness = FrameBorderThickness(); |
| 709 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; | 706 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; |
| 710 *title_top_spacing = frame_thickness + kTitleTopSpacing; | 707 *title_top_spacing = frame_thickness + kTitleTopSpacing; |
| 711 // The bottom spacing should be the same apparent height as the top spacing. | 708 // The bottom spacing should be the same apparent height as the top spacing. |
| 712 // Because the actual top spacing height varies based on the system border | 709 // Because the actual top spacing height varies based on the system border |
| 713 // thickness, we calculate this based on the restored top spacing and then | 710 // thickness, we calculate this based on the restored top spacing and then |
| 714 // adjust for maximized mode. We also don't include the frame shadow here, | 711 // adjust for maximized mode. We also don't include the frame shadow here, |
| 715 // since while it's part of the bottom spacing it will be added in at the end | 712 // since while it's part of the bottom spacing it will be added in at the end |
| 716 // as necessary (when a toolbar is present, the "shadow" is actually drawn by | 713 // as necessary (when a toolbar is present, the "shadow" is actually drawn by |
| 717 // the toolbar). | 714 // the toolbar). |
| 718 int title_bottom_spacing = | 715 int title_bottom_spacing = |
| 719 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness; | 716 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness; |
| 720 if (frame_->IsMaximized()) { | 717 if (frame_->IsMaximized()) { |
| 721 // When we maximize, the top border appears to be chopped off; shift the | 718 // When we maximize, the top border appears to be chopped off; shift the |
| 722 // title down to stay centered within the remaining space. | 719 // title down to stay centered within the remaining space. |
| 723 int title_adjust = (kFrameBorderThickness / 2); | 720 int title_adjust = (kFrameBorderThickness / 2); |
| 724 *title_top_spacing += title_adjust; | 721 *title_top_spacing += title_adjust; |
| 725 title_bottom_spacing -= title_adjust; | 722 title_bottom_spacing -= title_adjust; |
| 726 } | 723 } |
| 727 *title_thickness = std::max(title_font_.height(), | 724 *title_thickness = std::max(title_font_.height(), |
| 728 min_titlebar_height - *title_top_spacing - title_bottom_spacing); | 725 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 729 return *title_top_spacing + *title_thickness + title_bottom_spacing + | 726 return *title_top_spacing + *title_thickness + title_bottom_spacing + |
| 730 BottomEdgeThicknessWithinNonClientHeight(); | 727 UnavailablePixelsAtBottomOfNonClientHeight(); |
| 731 } | 728 } |
| 732 | 729 |
| 733 void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { | 730 void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { |
| 734 SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); | 731 SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); |
| 735 SkBitmap* top_right_corner = | 732 SkBitmap* top_right_corner = |
| 736 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); | 733 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); |
| 737 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); | 734 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); |
| 738 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); | 735 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); |
| 739 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); | 736 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); |
| 740 SkBitmap* bottom_left_corner = | 737 SkBitmap* bottom_left_corner = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 * shadow color (since we want to work with various themes), but we can't | 813 * shadow color (since we want to work with various themes), but we can't |
| 817 * alpha-blend either (since the Windows text APIs don't really do this). | 814 * alpha-blend either (since the Windows text APIs don't really do this). |
| 818 * So we'd need to sample the background color at the right location and | 815 * So we'd need to sample the background color at the right location and |
| 819 * synthesize a good shadow color. */ | 816 * synthesize a good shadow color. */ |
| 820 } | 817 } |
| 821 } | 818 } |
| 822 | 819 |
| 823 void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { | 820 void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { |
| 824 if (!browser_view_->IsToolbarVisible()) | 821 if (!browser_view_->IsToolbarVisible()) |
| 825 return; | 822 return; |
| 826 | 823 |
| 827 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 824 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 828 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 825 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 829 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); | 826 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); |
| 830 toolbar_bounds.set_origin(toolbar_origin); | 827 toolbar_bounds.set_origin(toolbar_origin); |
| 831 | 828 |
| 832 bool normal_mode = browser_view_->IsToolbarDisplayModeNormal(); | 829 SkBitmap* toolbar_left = |
| 833 SkBitmap* toolbar_left = resources()->GetPartBitmap(normal_mode ? | 830 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); |
| 834 FRAME_CLIENT_EDGE_TOP_LEFT : FRAME_TOOLBAR_POPUP_EDGE_LEFT); | |
| 835 canvas->DrawBitmapInt(*toolbar_left, | 831 canvas->DrawBitmapInt(*toolbar_left, |
| 836 toolbar_bounds.x() - toolbar_left->width(), | 832 toolbar_bounds.x() - toolbar_left->width(), |
| 837 toolbar_bounds.y()); | 833 toolbar_bounds.y()); |
| 838 | 834 |
| 839 if (normal_mode) { | 835 // Gross hack: We split the toolbar image into two pieces, since sometimes |
| 840 SkBitmap* toolbar_center = | 836 // (popup mode) the toolbar isn't tall enough to show the whole image. The |
| 841 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); | 837 // split happens between the top shadow section and the bottom gradient |
| 842 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), | 838 // section so that we never break the gradient. |
| 843 toolbar_bounds.y(), toolbar_bounds.width(), toolbar_center->height()); | 839 int split_point = kFrameShadowThickness * 2; |
| 844 } | 840 SkBitmap* toolbar_center = |
| 841 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); |
| 842 canvas->TileImageInt(*toolbar_center, 0, 0, toolbar_bounds.x(), |
| 843 toolbar_bounds.y(), toolbar_bounds.width(), split_point); |
| 844 canvas->TileImageInt(*toolbar_center, 0, |
| 845 toolbar_center->height() - toolbar_bounds.height() + split_point, |
| 846 toolbar_bounds.x(), toolbar_bounds.y() + split_point, |
| 847 toolbar_bounds.width(), toolbar_bounds.height() - split_point); |
| 845 | 848 |
| 846 canvas->DrawBitmapInt(*resources()->GetPartBitmap(normal_mode ? | 849 canvas->DrawBitmapInt( |
| 847 FRAME_CLIENT_EDGE_TOP_RIGHT : FRAME_TOOLBAR_POPUP_EDGE_RIGHT), | 850 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT), |
| 848 toolbar_bounds.right(), toolbar_bounds.y()); | 851 toolbar_bounds.right(), toolbar_bounds.y()); |
| 849 } | 852 } |
| 850 | 853 |
| 851 void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) { | 854 void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) { |
| 852 if (!browser_view_->ShouldShowOffTheRecordAvatar()) | 855 if (!browser_view_->ShouldShowOffTheRecordAvatar()) |
| 853 return; | 856 return; |
| 854 | 857 |
| 855 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 858 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 856 canvas->DrawBitmapInt(otr_avatar_icon, 0, | 859 canvas->DrawBitmapInt(otr_avatar_icon, 0, |
| 857 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, | 860 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, |
| 858 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), | 861 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), |
| 859 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), | 862 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), |
| 860 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); | 863 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); |
| 861 } | 864 } |
| 862 | 865 |
| 863 void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) { | 866 void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) { |
| 864 int client_area_top = | 867 int client_area_top = frame_->client_view()->y(); |
| 865 frame_->client_view()->y() + browser_view_->GetToolbarBounds().bottom(); | |
| 866 | 868 |
| 867 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 869 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 868 if (browser_view_->IsToolbarVisible() && | 870 if (browser_view_->IsToolbarVisible()) { |
| 869 browser_view_->IsToolbarDisplayModeNormal()) { | 871 // The client edges start below the toolbar upper corner images regardless |
| 870 // The toolbar draws a client edge along its own bottom edge when it's | 872 // of how tall the toolbar itself is. |
| 871 // visible and in normal mode. However, it only draws this for the width of | 873 client_area_top += browser_view_->GetToolbarBounds().y() + |
| 872 // the actual client area, leaving a gap at the left and right edges: | 874 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height(); |
| 873 // | |
| 874 // | Toolbar | <-- part of toolbar | |
| 875 // ----- (toolbar client edge) ----- <-- gap | |
| 876 // | Client area | <-- right client edge | |
| 877 // | |
| 878 // To address this, we extend the left and right client edges up to fill the | |
| 879 // gap, by pretending the toolbar is shorter than it really is. | |
| 880 client_area_top -= kClientEdgeThickness; | |
| 881 } else { | 875 } else { |
| 882 // The toolbar isn't going to draw a client edge for us, so draw one | 876 // The toolbar isn't going to draw a client edge for us, so draw one |
| 883 // ourselves. | 877 // ourselves. |
| 884 // This next calculation is necessary because the top center bitmap is | 878 // This next calculation is necessary because the top center bitmap is |
| 885 // shorter than the top left and right bitmaps. We need their top edges to | 879 // shorter than the top left and right bitmaps. We need their top edges to |
| 886 // line up, and we need the left and right edges to start below the corners' | 880 // line up, and we need the left and right edges to start below the corners' |
| 887 // bottoms. | 881 // bottoms. |
| 888 SkBitmap* top_center = | 882 SkBitmap* top_center = |
| 889 resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_CENTER); | 883 resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_CENTER); |
| 890 SkBitmap* top_left = resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_LEFT); | 884 SkBitmap* top_left = resources()->GetPartBitmap(FRAME_NO_TOOLBAR_TOP_LEFT); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 // Always lay out the icon, even when it's not present, so we can lay out the | 984 // Always lay out the icon, even when it's not present, so we can lay out the |
| 991 // window title based on its position. | 985 // window title based on its position. |
| 992 int frame_thickness = FrameBorderThickness(); | 986 int frame_thickness = FrameBorderThickness(); |
| 993 int icon_x = frame_thickness + kIconLeftSpacing; | 987 int icon_x = frame_thickness + kIconLeftSpacing; |
| 994 | 988 |
| 995 // The usable height of the titlebar area is the total height minus the top | 989 // The usable height of the titlebar area is the total height minus the top |
| 996 // resize border and any edge area we draw at its bottom. | 990 // resize border and any edge area we draw at its bottom. |
| 997 int title_top_spacing, title_thickness; | 991 int title_top_spacing, title_thickness; |
| 998 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); | 992 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); |
| 999 int available_height = top_height - frame_thickness - | 993 int available_height = top_height - frame_thickness - |
| 1000 BottomEdgeThicknessWithinNonClientHeight(); | 994 UnavailablePixelsAtBottomOfNonClientHeight(); |
| 1001 | 995 |
| 1002 // The icon takes up a constant fraction of the available height, down to a | 996 // The icon takes up a constant fraction of the available height, down to a |
| 1003 // minimum size, and is always an even number of pixels on a side (presumably | 997 // minimum size, and is always an even number of pixels on a side (presumably |
| 1004 // to make scaled icons look better). It's centered within the usable height. | 998 // to make scaled icons look better). It's centered within the usable height. |
| 1005 int icon_size = std::max((available_height * kIconHeightFractionNumerator / | 999 int icon_size = std::max((available_height * kIconHeightFractionNumerator / |
| 1006 kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize); | 1000 kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize); |
| 1007 int icon_y = ((available_height - icon_size) / 2) + frame_thickness; | 1001 int icon_y = ((available_height - icon_size) / 2) + frame_thickness; |
| 1008 | 1002 |
| 1009 // Hack: Our frame border has a different "3D look" than Windows'. Theirs has | 1003 // Hack: Our frame border has a different "3D look" than Windows'. Theirs has |
| 1010 // a more complex gradient on the top that they push their icon/title below; | 1004 // a more complex gradient on the top that they push their icon/title below; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 } | 1060 } |
| 1067 | 1061 |
| 1068 // static | 1062 // static |
| 1069 void OpaqueNonClientView::InitAppWindowResources() { | 1063 void OpaqueNonClientView::InitAppWindowResources() { |
| 1070 static bool initialized = false; | 1064 static bool initialized = false; |
| 1071 if (!initialized) { | 1065 if (!initialized) { |
| 1072 title_font_ = win_util::GetWindowTitleFont(); | 1066 title_font_ = win_util::GetWindowTitleFont(); |
| 1073 initialized = true; | 1067 initialized = true; |
| 1074 } | 1068 } |
| 1075 } | 1069 } |
| OLD | NEW |