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

Side by Side Diff: chrome/browser/views/frame/opaque_browser_frame_view.cc

Issue 93099: Merge 13773 - For some Indian locales, the automatic font fallback by Windows... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: Created 11 years, 8 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
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/views/frame/opaque_browser_frame_view.cc:r13773
OLDNEW
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_browser_frame_view.h" 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h"
6 6
7 #include "chrome/browser/views/frame/browser_frame.h" 7 #include "chrome/browser/views/frame/browser_frame.h"
8 #include "chrome/browser/views/frame/browser_view.h" 8 #include "chrome/browser/views/frame/browser_view.h"
9 #include "chrome/browser/views/tabs/tab_strip.h" 9 #include "chrome/browser/views/tabs/tab_strip.h"
10 #include "chrome/common/gfx/chrome_canvas.h" 10 #include "chrome/common/gfx/chrome_canvas.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 SkBitmap* ActiveWindowResources::standard_frame_bitmaps_[]; 252 SkBitmap* ActiveWindowResources::standard_frame_bitmaps_[];
253 SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[]; 253 SkBitmap* InactiveWindowResources::standard_frame_bitmaps_[];
254 SkBitmap* OTRActiveWindowResources::standard_frame_bitmaps_[]; 254 SkBitmap* OTRActiveWindowResources::standard_frame_bitmaps_[];
255 SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[]; 255 SkBitmap* OTRInactiveWindowResources::standard_frame_bitmaps_[];
256 256
257 views::WindowResources* OpaqueBrowserFrameView::active_resources_ = NULL; 257 views::WindowResources* OpaqueBrowserFrameView::active_resources_ = NULL;
258 views::WindowResources* OpaqueBrowserFrameView::inactive_resources_ = NULL; 258 views::WindowResources* OpaqueBrowserFrameView::inactive_resources_ = NULL;
259 views::WindowResources* OpaqueBrowserFrameView::active_otr_resources_ = NULL; 259 views::WindowResources* OpaqueBrowserFrameView::active_otr_resources_ = NULL;
260 views::WindowResources* OpaqueBrowserFrameView::inactive_otr_resources_ = NULL; 260 views::WindowResources* OpaqueBrowserFrameView::inactive_otr_resources_ = NULL;
261 SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL; 261 SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL;
262 ChromeFont OpaqueBrowserFrameView::title_font_; 262 ChromeFont* OpaqueBrowserFrameView::title_font_ = NULL;
263 263
264 namespace { 264 namespace {
265 // The frame border is only visible in restored mode and is hardcoded to 4 px on 265 // The frame border is only visible in restored mode and is hardcoded to 4 px on
266 // each side regardless of the system window border size. 266 // each side regardless of the system window border size.
267 const int kFrameBorderThickness = 4; 267 const int kFrameBorderThickness = 4;
268 // Besides the frame border, there's another 11 px of empty space atop the 268 // Besides the frame border, there's another 11 px of empty space atop the
269 // window in restored mode, to use to drag the window around. 269 // window in restored mode, to use to drag the window around.
270 const int kNonClientRestoredExtraThickness = 11; 270 const int kNonClientRestoredExtraThickness = 11;
271 // While resize areas on Windows are normally the same size as the window 271 // While resize areas on Windows are normally the same size as the window
272 // borders, our top area is shrunk by 1 px to make it easier to move the window 272 // borders, our top area is shrunk by 1 px to make it easier to move the window
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 // the toolbar). 696 // the toolbar).
697 int title_bottom_spacing = 697 int title_bottom_spacing =
698 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness; 698 kFrameBorderThickness + kTitleTopSpacing - kFrameShadowThickness;
699 if (frame_->IsMaximized()) { 699 if (frame_->IsMaximized()) {
700 // When we maximize, the top border appears to be chopped off; shift the 700 // When we maximize, the top border appears to be chopped off; shift the
701 // title down to stay centered within the remaining space. 701 // title down to stay centered within the remaining space.
702 int title_adjust = (kFrameBorderThickness / 2); 702 int title_adjust = (kFrameBorderThickness / 2);
703 *title_top_spacing += title_adjust; 703 *title_top_spacing += title_adjust;
704 title_bottom_spacing -= title_adjust; 704 title_bottom_spacing -= title_adjust;
705 } 705 }
706 *title_thickness = std::max(title_font_.height(), 706 *title_thickness = std::max(title_font_->height(),
707 min_titlebar_height - *title_top_spacing - title_bottom_spacing); 707 min_titlebar_height - *title_top_spacing - title_bottom_spacing);
708 return *title_top_spacing + *title_thickness + title_bottom_spacing + 708 return *title_top_spacing + *title_thickness + title_bottom_spacing +
709 UnavailablePixelsAtBottomOfNonClientHeight(); 709 UnavailablePixelsAtBottomOfNonClientHeight();
710 } 710 }
711 711
712 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { 712 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
713 SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER); 713 SkBitmap* top_left_corner = resources()->GetPartBitmap(FRAME_TOP_LEFT_CORNER);
714 SkBitmap* top_right_corner = 714 SkBitmap* top_right_corner =
715 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); 715 resources()->GetPartBitmap(FRAME_TOP_RIGHT_CORNER);
716 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); 716 SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 if (!frame_->IsMaximized() && distributor_logo_) { 780 if (!frame_->IsMaximized() && distributor_logo_) {
781 canvas->DrawBitmapInt(*distributor_logo_, 781 canvas->DrawBitmapInt(*distributor_logo_,
782 MirroredLeftPointForRect(logo_bounds_), logo_bounds_.y()); 782 MirroredLeftPointForRect(logo_bounds_), logo_bounds_.y());
783 } 783 }
784 } 784 }
785 785
786 void OpaqueBrowserFrameView::PaintTitleBar(ChromeCanvas* canvas) { 786 void OpaqueBrowserFrameView::PaintTitleBar(ChromeCanvas* canvas) {
787 // The window icon is painted by the TabIconView. 787 // The window icon is painted by the TabIconView.
788 views::WindowDelegate* d = frame_->GetDelegate(); 788 views::WindowDelegate* d = frame_->GetDelegate();
789 if (d->ShouldShowWindowTitle()) { 789 if (d->ShouldShowWindowTitle()) {
790 canvas->DrawStringInt(d->GetWindowTitle(), title_font_, SK_ColorWHITE, 790 canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE,
791 MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), 791 MirroredLeftPointForRect(title_bounds_), title_bounds_.y(),
792 title_bounds_.width(), title_bounds_.height()); 792 title_bounds_.width(), title_bounds_.height());
793 /* TODO(pkasting): If this window is active, we should also draw a drop 793 /* TODO(pkasting): If this window is active, we should also draw a drop
794 * shadow on the title. This is tricky, because we don't want to hardcode a 794 * shadow on the title. This is tricky, because we don't want to hardcode a
795 * shadow color (since we want to work with various themes), but we can't 795 * shadow color (since we want to work with various themes), but we can't
796 * alpha-blend either (since the Windows text APIs don't really do this). 796 * alpha-blend either (since the Windows text APIs don't really do this).
797 * So we'd need to sample the background color at the right location and 797 * So we'd need to sample the background color at the right location and
798 * synthesize a good shadow color. */ 798 * synthesize a good shadow color. */
799 } 799 }
800 } 800 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 962
963 void OpaqueBrowserFrameView::LayoutTitleBar() { 963 void OpaqueBrowserFrameView::LayoutTitleBar() {
964 // Always lay out the icon, even when it's not present, so we can lay out the 964 // Always lay out the icon, even when it's not present, so we can lay out the
965 // window title based on its position. 965 // window title based on its position.
966 int frame_thickness = FrameBorderThickness(); 966 int frame_thickness = FrameBorderThickness();
967 int icon_x = frame_thickness + kIconLeftSpacing; 967 int icon_x = frame_thickness + kIconLeftSpacing;
968 968
969 // The usable height of the titlebar area is the total height minus the top 969 // The usable height of the titlebar area is the total height minus the top
970 // resize border and any edge area we draw at its bottom. 970 // resize border and any edge area we draw at its bottom.
971 int title_top_spacing, title_thickness; 971 int title_top_spacing, title_thickness;
972 InitAppWindowResources();
972 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); 973 int top_height = TitleCoordinates(&title_top_spacing, &title_thickness);
973 int available_height = top_height - frame_thickness - 974 int available_height = top_height - frame_thickness -
974 UnavailablePixelsAtBottomOfNonClientHeight(); 975 UnavailablePixelsAtBottomOfNonClientHeight();
975 976
976 // The icon takes up a constant fraction of the available height, down to a 977 // The icon takes up a constant fraction of the available height, down to a
977 // minimum size, and is always an even number of pixels on a side (presumably 978 // minimum size, and is always an even number of pixels on a side (presumably
978 // to make scaled icons look better). It's centered within the usable height. 979 // to make scaled icons look better). It's centered within the usable height.
979 int icon_size = std::max((available_height * kIconHeightFractionNumerator / 980 int icon_size = std::max((available_height * kIconHeightFractionNumerator /
980 kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize); 981 kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize);
981 int icon_y = ((available_height - icon_size) / 2) + frame_thickness; 982 int icon_y = ((available_height - icon_size) / 2) + frame_thickness;
(...skipping 11 matching lines...) Expand all
993 if (!d->ShouldShowWindowIcon()) 994 if (!d->ShouldShowWindowIcon())
994 icon_size = 0; 995 icon_size = 0;
995 if (window_icon_) 996 if (window_icon_)
996 window_icon_->SetBounds(icon_x, icon_y, icon_size, icon_size); 997 window_icon_->SetBounds(icon_x, icon_y, icon_size, icon_size);
997 998
998 // Size the title, if visible. 999 // Size the title, if visible.
999 if (d->ShouldShowWindowTitle()) { 1000 if (d->ShouldShowWindowTitle()) {
1000 int title_x = icon_x + icon_size + 1001 int title_x = icon_x + icon_size +
1001 (d->ShouldShowWindowIcon() ? kIconTitleSpacing : 0); 1002 (d->ShouldShowWindowIcon() ? kIconTitleSpacing : 0);
1002 title_bounds_.SetRect(title_x, 1003 title_bounds_.SetRect(title_x,
1003 title_top_spacing + ((title_thickness - title_font_.height()) / 2), 1004 title_top_spacing + ((title_thickness - title_font_->height()) / 2),
1004 std::max(0, logo_bounds_.x() - kTitleLogoSpacing - title_x), 1005 std::max(0, logo_bounds_.x() - kTitleLogoSpacing - title_x),
1005 title_font_.height()); 1006 title_font_->height());
1006 } 1007 }
1007 } 1008 }
1008 1009
1009 void OpaqueBrowserFrameView::LayoutOTRAvatar() { 1010 void OpaqueBrowserFrameView::LayoutOTRAvatar() {
1010 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); 1011 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
1011 int top_height = NonClientTopBorderHeight(); 1012 int top_height = NonClientTopBorderHeight();
1012 int tabstrip_height, otr_height; 1013 int tabstrip_height, otr_height;
1013 if (browser_view_->IsTabStripVisible()) { 1014 if (browser_view_->IsTabStripVisible()) {
1014 tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; 1015 tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
1015 otr_height = frame_->IsMaximized() ? 1016 otr_height = frame_->IsMaximized() ?
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 #endif 1050 #endif
1050 1051
1051 initialized = true; 1052 initialized = true;
1052 } 1053 }
1053 } 1054 }
1054 1055
1055 // static 1056 // static
1056 void OpaqueBrowserFrameView::InitAppWindowResources() { 1057 void OpaqueBrowserFrameView::InitAppWindowResources() {
1057 static bool initialized = false; 1058 static bool initialized = false;
1058 if (!initialized) { 1059 if (!initialized) {
1059 title_font_ = win_util::GetWindowTitleFont(); 1060 title_font_ = new ChromeFont(win_util::GetWindowTitleFont());
1060 initialized = true; 1061 initialized = true;
1061 } 1062 }
1062 } 1063 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/opaque_browser_frame_view.h ('k') | chrome/browser/views/sad_tab_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698