| 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/app/theme/theme_resources.h" | 7 #include "chrome/app/theme/theme_resources.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents.h" | 8 #include "chrome/browser/tab_contents/tab_contents.h" |
| 9 #include "chrome/browser/views/frame/browser_view.h" | 9 #include "chrome/browser/views/frame/browser_view.h" |
| 10 #include "chrome/browser/views/tabs/tab_strip.h" | 10 #include "chrome/browser/views/tabs/tab_strip.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 const int kFrameBorderThickness = 4; | 292 const int kFrameBorderThickness = 4; |
| 293 // In maximized mode, where no frame border is otherwise visible, we draw a | 293 // In maximized mode, where no frame border is otherwise visible, we draw a |
| 294 // different, 1 px high border along the bottom of the screen. | 294 // different, 1 px high border along the bottom of the screen. |
| 295 const int kFrameBorderMaximizedExtraBottomThickness = 1; | 295 const int kFrameBorderMaximizedExtraBottomThickness = 1; |
| 296 // Various edges of the frame border have a 1 px shadow along their edges; in a | 296 // Various edges of the frame border have a 1 px shadow along their edges; in a |
| 297 // few cases we shift elements based on this amount for visual appeal. | 297 // few cases we shift elements based on this amount for visual appeal. |
| 298 const int kFrameShadowThickness = 1; | 298 const int kFrameShadowThickness = 1; |
| 299 // Besides the frame border, there's another 11 px of empty space atop the | 299 // Besides the frame border, there's another 11 px of empty space atop the |
| 300 // window in restored mode, to use to drag the window around. | 300 // window in restored mode, to use to drag the window around. |
| 301 const int kNonClientRestoredExtraThickness = 11; | 301 const int kNonClientRestoredExtraThickness = 11; |
| 302 // In restored mode, we draw a 1 px edge around the content area inside the | |
| 303 // frame border. | |
| 304 const int kClientEdgeThickness = 1; | |
| 305 // While resize areas on Windows are normally the same size as the window | 302 // While resize areas on Windows are normally the same size as the window |
| 306 // borders, our top area is shrunk by 1 px to make it easier to move the window | 303 // borders, our top area is shrunk by 1 px to make it easier to move the window |
| 307 // around with our thinner top grabbable strip. (Incidentally, our side and | 304 // around with our thinner top grabbable strip. (Incidentally, our side and |
| 308 // bottom resize areas don't match the frame border thickness either -- they | 305 // bottom resize areas don't match the frame border thickness either -- they |
| 309 // span the whole nonclient area, so there's no "dead zone" for the mouse.) | 306 // span the whole nonclient area, so there's no "dead zone" for the mouse.) |
| 310 const int kTopResizeAdjust = 1; | 307 const int kTopResizeAdjust = 1; |
| 311 // In the window corners, the resize areas don't actually expand bigger, but the | 308 // In the window corners, the resize areas don't actually expand bigger, but the |
| 312 // 16 px at the end of each edge triggers diagonal resizing. | 309 // 16 px at the end of each edge triggers diagonal resizing. |
| 313 const int kResizeAreaCornerSize = 16; | 310 const int kResizeAreaCornerSize = 16; |
| 314 // The titlebar never shrinks to less than 19 px tall, plus the height of the | 311 // The titlebar never shrinks to less than 18 px tall, plus the height of the |
| 315 // frame border. | 312 // frame border and any bottom edge. |
| 316 const int kTitlebarMinimumHeight = 19; | 313 const int kTitlebarMinimumHeight = 18; |
| 317 // The icon is inset 2 px from the left frame border. | 314 // The icon is inset 2 px from the left frame border. |
| 318 const int kIconLeftSpacing = 2; | 315 const int kIconLeftSpacing = 2; |
| 319 // The icon takes up 16/25th of the available titlebar height. (This is | 316 // The icon takes up 16/25th of the available titlebar height. (This is |
| 320 // expressed as two ints to avoid precision losses leading to off-by-one pixel | 317 // expressed as two ints to avoid precision losses leading to off-by-one pixel |
| 321 // errors.) | 318 // errors.) |
| 322 const int kIconHeightFractionNumerator = 16; | 319 const int kIconHeightFractionNumerator = 16; |
| 323 const int kIconHeightFractionDenominator = 25; | 320 const int kIconHeightFractionDenominator = 25; |
| 324 // The icon never shrinks below 16 px on a side. | 321 // The icon never shrinks below 16 px on a side. |
| 325 const int kIconMinimumSize = 16; | 322 const int kIconMinimumSize = 16; |
| 326 // Because our frame border has a different "3D look" than Windows', with a less | 323 // Because our frame border has a different "3D look" than Windows', with a less |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 GetSystemMetrics(SM_CYSIZEFRAME) : kFrameBorderThickness; | 700 GetSystemMetrics(SM_CYSIZEFRAME) : kFrameBorderThickness; |
| 704 } | 701 } |
| 705 | 702 |
| 706 int OpaqueNonClientView::TopResizeHeight() const { | 703 int OpaqueNonClientView::TopResizeHeight() const { |
| 707 return FrameTopBorderHeight() - kTopResizeAdjust; | 704 return FrameTopBorderHeight() - kTopResizeAdjust; |
| 708 } | 705 } |
| 709 | 706 |
| 710 int OpaqueNonClientView::NonClientBorderWidth() const { | 707 int OpaqueNonClientView::NonClientBorderWidth() const { |
| 711 // In maximized mode, we don't show a client edge. | 708 // In maximized mode, we don't show a client edge. |
| 712 return FrameBorderWidth() + | 709 return FrameBorderWidth() + |
| 713 (frame_->IsMaximized() ? 0 : kClientEdgeThickness); | 710 (frame_->IsMaximized() ? 0 : BrowserView::kClientEdgeThickness); |
| 714 } | 711 } |
| 715 | 712 |
| 716 int OpaqueNonClientView::NonClientTopBorderHeight() const { | 713 int OpaqueNonClientView::NonClientTopBorderHeight() const { |
| 717 if (!frame_->window_delegate()->ShouldShowWindowTitle()) { | 714 if (!frame_->window_delegate()->ShouldShowWindowTitle()) { |
| 718 return FrameTopBorderHeight() + | 715 return FrameTopBorderHeight() + |
| 719 (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); | 716 (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); |
| 720 } | 717 } |
| 721 | 718 |
| 722 int title_top_spacing, title_thickness; | 719 int title_top_spacing, title_thickness; |
| 723 return TitleCoordinates(&title_top_spacing, &title_thickness); | 720 return TitleCoordinates(&title_top_spacing, &title_thickness); |
| 724 } | 721 } |
| 725 | 722 |
| 726 int OpaqueNonClientView::NonClientBottomBorderHeight() const { | 723 int OpaqueNonClientView::NonClientBottomBorderHeight() const { |
| 727 // In maximized mode, we don't show a client edge, but the frame border is | 724 // In maximized mode, we don't show a client edge, but the frame border is |
| 728 // extended slightly. | 725 // extended slightly. |
| 729 return frame_->IsMaximized() ? (GetSystemMetrics(SM_CYSIZEFRAME) + | 726 return frame_->IsMaximized() ? (GetSystemMetrics(SM_CYSIZEFRAME) + |
| 730 kFrameBorderMaximizedExtraBottomThickness) : | 727 kFrameBorderMaximizedExtraBottomThickness) : |
| 731 (kFrameBorderThickness + kClientEdgeThickness); | 728 (kFrameBorderThickness + BrowserView::kClientEdgeThickness); |
| 732 } | 729 } |
| 733 | 730 |
| 734 int OpaqueNonClientView::ClientEdgeThicknessWithinNonClientHeight() const { | 731 int OpaqueNonClientView::BottomEdgeThicknessWithinNonClientHeight() const { |
| 735 return (frame_->IsMaximized() || browser_view_->IsToolbarVisible()) ? | 732 if (browser_view_->IsToolbarVisible()) |
| 736 0 : kClientEdgeThickness; | 733 return 0; |
| 734 return kFrameShadowThickness + |
| 735 (frame_->IsMaximized() ? 0 : BrowserView::kClientEdgeThickness); |
| 737 } | 736 } |
| 738 | 737 |
| 739 int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing, | 738 int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing, |
| 740 int* title_thickness) const { | 739 int* title_thickness) const { |
| 741 int top_height = FrameTopBorderHeight(); | 740 int top_height = FrameTopBorderHeight(); |
| 742 int min_titlebar_height = kTitlebarMinimumHeight + top_height; | 741 int min_titlebar_height = kTitlebarMinimumHeight + top_height; |
| 743 *title_top_spacing = top_height + kTitleTopSpacing; | 742 *title_top_spacing = top_height + kTitleTopSpacing; |
| 744 // The bottom spacing should be the same apparent height as the top spacing. | 743 // The bottom spacing should be the same apparent height as the top spacing. |
| 745 // Because the actual top spacing height varies based on the system border | 744 // Because the actual top spacing height varies based on the system border |
| 746 // thickness, we calculate this based on the restored top spacing and then | 745 // thickness, we calculate this based on the restored top spacing and then |
| 747 // adjust for maximized mode. | 746 // adjust for maximized mode. We also don't include the frame shadow here, |
| 748 int title_bottom_spacing = kFrameBorderThickness + kTitleTopSpacing; | 747 // since while it's part of the bottom spacing it will be added in at the end |
| 748 // as necessary (when a toolbar is present, the "shadow" is actually drawn by |
| 749 // the toolbar). |
| 750 int title_bottom_spacing = |
| 751 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness; |
| 749 if (frame_->IsMaximized()) { | 752 if (frame_->IsMaximized()) { |
| 750 // When we maximize, the top border appears to be chopped off; shift the | 753 // When we maximize, the top border appears to be chopped off; shift the |
| 751 // title down to stay centered within the remaining space. | 754 // title down to stay centered within the remaining space. |
| 752 int title_adjust = (kFrameBorderThickness / 2); | 755 int title_adjust = (kFrameBorderThickness / 2); |
| 753 *title_top_spacing += title_adjust; | 756 *title_top_spacing += title_adjust; |
| 754 title_bottom_spacing -= title_adjust; | 757 title_bottom_spacing -= title_adjust; |
| 755 } | 758 } |
| 756 *title_thickness = std::max(title_font_.height(), | 759 *title_thickness = std::max(title_font_.height(), |
| 757 min_titlebar_height - *title_top_spacing - title_bottom_spacing); | 760 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 758 return *title_top_spacing + *title_thickness + title_bottom_spacing + | 761 return *title_top_spacing + *title_thickness + title_bottom_spacing + |
| 759 ClientEdgeThicknessWithinNonClientHeight(); | 762 BottomEdgeThicknessWithinNonClientHeight(); |
| 760 } | 763 } |
| 761 | 764 |
| 762 void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { | 765 void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { |
| 763 SkBitmap* top_left_corner = | 766 SkBitmap* top_left_corner = |
| 764 resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); | 767 resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); |
| 765 SkBitmap* top_right_corner = | 768 SkBitmap* top_right_corner = |
| 766 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); | 769 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); |
| 767 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); | 770 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); |
| 768 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); | 771 SkBitmap* right_edge = resources()->GetPartBitmap(FRAME_RIGHT_EDGE); |
| 769 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); | 772 SkBitmap* left_edge = resources()->GetPartBitmap(FRAME_LEFT_EDGE); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 813 |
| 811 void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { | 814 void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { |
| 812 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_MAXIMIZED_TOP_EDGE); | 815 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_MAXIMIZED_TOP_EDGE); |
| 813 canvas->TileImageInt(*top_edge, 0, FrameTopBorderHeight(), width(), | 816 canvas->TileImageInt(*top_edge, 0, FrameTopBorderHeight(), width(), |
| 814 top_edge->height()); | 817 top_edge->height()); |
| 815 | 818 |
| 816 if (!browser_view_->IsToolbarVisible()) { | 819 if (!browser_view_->IsToolbarVisible()) { |
| 817 // There's no toolbar to edge the frame border, so we need to draw a bottom | 820 // There's no toolbar to edge the frame border, so we need to draw a bottom |
| 818 // edge. The App Window graphic we use for this has a built in client edge, | 821 // edge. The App Window graphic we use for this has a built in client edge, |
| 819 // so we clip it off the bottom. | 822 // so we clip it off the bottom. |
| 820 int edge_height = app_top_center_.height() - kClientEdgeThickness; | 823 int edge_height = |
| 824 app_top_center_.height() - BrowserView::kClientEdgeThickness; |
| 821 canvas->TileImageInt(app_top_center_, 0, | 825 canvas->TileImageInt(app_top_center_, 0, |
| 822 frame_->client_view()->y() - edge_height, width(), edge_height); | 826 frame_->client_view()->y() - edge_height, width(), edge_height); |
| 823 } | 827 } |
| 824 | 828 |
| 825 SkBitmap* bottom_edge = | 829 SkBitmap* bottom_edge = |
| 826 resources()->GetPartBitmap(FRAME_MAXIMIZED_BOTTOM_EDGE); | 830 resources()->GetPartBitmap(FRAME_MAXIMIZED_BOTTOM_EDGE); |
| 827 // We draw the bottom edge of this image. | 831 // We draw the bottom edge of this image. |
| 828 canvas->TileImageInt(*bottom_edge, 0, | 832 canvas->TileImageInt(*bottom_edge, 0, |
| 829 bottom_edge->height() - kFrameBorderMaximizedExtraBottomThickness, 0, | 833 bottom_edge->height() - kFrameBorderMaximizedExtraBottomThickness, 0, |
| 830 height() - NonClientBottomBorderHeight(), width(), | 834 height() - NonClientBottomBorderHeight(), width(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 850 /* TODO(pkasting): If this window is active, we should also draw a drop | 854 /* TODO(pkasting): If this window is active, we should also draw a drop |
| 851 * shadow on the title. This is tricky, because we don't want to hardcode a | 855 * shadow on the title. This is tricky, because we don't want to hardcode a |
| 852 * shadow color (since we want to work with various themes), but we can't | 856 * shadow color (since we want to work with various themes), but we can't |
| 853 * alpha-blend either (since the Windows text APIs don't really do this). | 857 * alpha-blend either (since the Windows text APIs don't really do this). |
| 854 * So we'd need to sample the background color at the right location and | 858 * So we'd need to sample the background color at the right location and |
| 855 * synthesize a good shadow color. */ | 859 * synthesize a good shadow color. */ |
| 856 } | 860 } |
| 857 } | 861 } |
| 858 | 862 |
| 859 void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { | 863 void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { |
| 860 if (!browser_view_->IsToolbarVisible() && !browser_view_->IsTabStripVisible()) | 864 if (!browser_view_->IsToolbarVisible() || |
| 865 !browser_view_->IsToolbarDisplayModeNormal()) |
| 861 return; | 866 return; |
| 862 | 867 |
| 863 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 868 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 864 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 869 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 865 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); | 870 View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); |
| 866 toolbar_bounds.set_origin(toolbar_origin); | 871 toolbar_bounds.set_origin(toolbar_origin); |
| 867 | 872 |
| 868 SkBitmap* toolbar_left = | 873 SkBitmap* toolbar_left = |
| 869 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); | 874 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT); |
| 870 canvas->DrawBitmapInt(*toolbar_left, | 875 canvas->DrawBitmapInt(*toolbar_left, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 887 | 892 |
| 888 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 893 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 889 canvas->DrawBitmapInt(otr_avatar_icon, 0, | 894 canvas->DrawBitmapInt(otr_avatar_icon, 0, |
| 890 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, | 895 (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2, |
| 891 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), | 896 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), |
| 892 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), | 897 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(), |
| 893 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); | 898 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); |
| 894 } | 899 } |
| 895 | 900 |
| 896 void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) { | 901 void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) { |
| 897 int client_area_top = frame_->client_view()->y(); | 902 int client_area_top = |
| 903 frame_->client_view()->y() + browser_view_->GetToolbarBounds().bottom(); |
| 898 | 904 |
| 899 // The toolbar draws a client edge along its own bottom edge when it's | |
| 900 // visible. However, it only draws this for the width of the actual client | |
| 901 // area, leaving a gap at the left and right edges: | |
| 902 // | |
| 903 // | Toolbar | <-- part of toolbar | |
| 904 // ----- (toolbar client edge) ----- <-- gap | |
| 905 // | Client area | <-- right client edge | |
| 906 // | |
| 907 // To address this, we extend the left and right client edges up to fill the | |
| 908 // gap, by pretending the toolbar is shorter than it really is. | |
| 909 // | |
| 910 // Note: We can get away with this hackery because we only draw a top edge | |
| 911 // when there is no toolbar. If we tried to draw a client edge over the | |
| 912 // toolbar's bottom edge, we'd need a different solution. | |
| 913 if (browser_view_->IsToolbarVisible()) { | |
| 914 client_area_top += | |
| 915 browser_view_->GetToolbarBounds().bottom() - kClientEdgeThickness; | |
| 916 } | |
| 917 | |
| 918 // When we don't have a toolbar to draw a top edge for us, draw a top edge. | |
| 919 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 905 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 920 if (!browser_view_->IsToolbarVisible()) { | 906 if (browser_view_->IsToolbarVisible() && |
| 907 browser_view_->IsToolbarDisplayModeNormal()) { |
| 908 // The toolbar draws a client edge along its own bottom edge when it's |
| 909 // visible and in normal mode. However, it only draws this for the width of |
| 910 // the actual client area, leaving a gap at the left and right edges: |
| 911 // |
| 912 // | Toolbar | <-- part of toolbar |
| 913 // ----- (toolbar client edge) ----- <-- gap |
| 914 // | Client area | <-- right client edge |
| 915 // |
| 916 // To address this, we extend the left and right client edges up to fill the |
| 917 // gap, by pretending the toolbar is shorter than it really is. |
| 918 client_area_top -= BrowserView::kClientEdgeThickness; |
| 919 } else { |
| 920 // The toolbar isn't going to draw a client edge for us, so draw one |
| 921 // ourselves. |
| 922 int top_edge_y = client_area_top - app_top_center_.height(); |
| 921 // This is necessary because the top center bitmap is shorter than the top | 923 // This is necessary because the top center bitmap is shorter than the top |
| 922 // left and right bitmaps. We need their top edges to line up, and we | 924 // left and right bitmaps. We need their top edges to line up, and we |
| 923 // need the left and right edges to start below the corners' bottoms. | 925 // need the left and right edges to start below the corners' bottoms. |
| 924 int top_edge_y = client_area_top - app_top_center_.height(); | |
| 925 client_area_top = top_edge_y + app_top_left_.height(); | 926 client_area_top = top_edge_y + app_top_left_.height(); |
| 926 canvas->DrawBitmapInt(app_top_left_, | 927 canvas->DrawBitmapInt(app_top_left_, |
| 927 client_area_bounds.x() - app_top_left_.width(), | 928 client_area_bounds.x() - app_top_left_.width(), |
| 928 top_edge_y); | 929 top_edge_y); |
| 929 canvas->TileImageInt(app_top_center_, client_area_bounds.x(), top_edge_y, | 930 canvas->TileImageInt(app_top_center_, client_area_bounds.x(), top_edge_y, |
| 930 client_area_bounds.width(), app_top_center_.height()); | 931 client_area_bounds.width(), app_top_center_.height()); |
| 931 canvas->DrawBitmapInt(app_top_right_, client_area_bounds.right(), | 932 canvas->DrawBitmapInt(app_top_right_, client_area_bounds.right(), |
| 932 top_edge_y); | 933 top_edge_y); |
| 933 } | 934 } |
| 934 | 935 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 logo_bounds_.SetRect(logo_x, TopResizeHeight(), distributor_logo_.width(), | 1018 logo_bounds_.SetRect(logo_x, TopResizeHeight(), distributor_logo_.width(), |
| 1018 distributor_logo_.height()); | 1019 distributor_logo_.height()); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 void OpaqueNonClientView::LayoutTitleBar() { | 1022 void OpaqueNonClientView::LayoutTitleBar() { |
| 1022 // Always lay out the icon, even when it's not present, so we can lay out the | 1023 // Always lay out the icon, even when it's not present, so we can lay out the |
| 1023 // window title based on its position. | 1024 // window title based on its position. |
| 1024 int icon_x = FrameBorderWidth() + kIconLeftSpacing; | 1025 int icon_x = FrameBorderWidth() + kIconLeftSpacing; |
| 1025 | 1026 |
| 1026 // The usable height of the titlebar area is the total height minus the top | 1027 // The usable height of the titlebar area is the total height minus the top |
| 1027 // resize border, the one shadow pixel at the bottom, and any client edge area | 1028 // resize border and any edge area we draw at its bottom. |
| 1028 // we draw below that shadow pixel. | |
| 1029 int title_top_spacing, title_thickness; | 1029 int title_top_spacing, title_thickness; |
| 1030 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); | 1030 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); |
| 1031 int top_border_height = FrameTopBorderHeight(); | 1031 int top_border_height = FrameTopBorderHeight(); |
| 1032 int available_height = top_height - top_border_height - | 1032 int available_height = top_height - top_border_height - |
| 1033 kFrameShadowThickness - ClientEdgeThicknessWithinNonClientHeight(); | 1033 BottomEdgeThicknessWithinNonClientHeight(); |
| 1034 | 1034 |
| 1035 // The icon takes up a constant fraction of the available height, down to a | 1035 // The icon takes up a constant fraction of the available height, down to a |
| 1036 // minimum size, and is always an even number of pixels on a side (presumably | 1036 // minimum size, and is always an even number of pixels on a side (presumably |
| 1037 // to make scaled icons look better). It's centered within the usable height. | 1037 // to make scaled icons look better). It's centered within the usable height. |
| 1038 int icon_size = std::max((available_height * kIconHeightFractionNumerator / | 1038 int icon_size = std::max((available_height * kIconHeightFractionNumerator / |
| 1039 kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize); | 1039 kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize); |
| 1040 int icon_y = ((available_height - icon_size) / 2) + top_border_height; | 1040 int icon_y = ((available_height - icon_size) / 2) + top_border_height; |
| 1041 | 1041 |
| 1042 // Hack: Our frame border has a different "3D look" than Windows'. Theirs has | 1042 // Hack: Our frame border has a different "3D look" than Windows'. Theirs has |
| 1043 // a more complex gradient on the top that they push their icon/title below; | 1043 // a more complex gradient on the top that they push their icon/title below; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 // static | 1108 // static |
| 1109 void OpaqueNonClientView::InitAppWindowResources() { | 1109 void OpaqueNonClientView::InitAppWindowResources() { |
| 1110 static bool initialized = false; | 1110 static bool initialized = false; |
| 1111 if (!initialized) { | 1111 if (!initialized) { |
| 1112 title_font_ = win_util::GetWindowTitleFont(); | 1112 title_font_ = win_util::GetWindowTitleFont(); |
| 1113 initialized = true; | 1113 initialized = true; |
| 1114 } | 1114 } |
| 1115 } | 1115 } |
| OLD | NEW |