diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-10 01:44:21 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-10 01:44:21 +0000 |
commit | c20add7be6d28fe0aa9325a73b3dcaeca8c07d89 (patch) | |
tree | 621c7eab02451d0dc0049372b2776454a13a3f81 | |
parent | 8f5602c711b0ae644c8935a12f74429cd339c5ad (diff) | |
download | chromium_src-c20add7be6d28fe0aa9325a73b3dcaeca8c07d89.zip chromium_src-c20add7be6d28fe0aa9325a73b3dcaeca8c07d89.tar.gz chromium_src-c20add7be6d28fe0aa9325a73b3dcaeca8c07d89.tar.bz2 |
Round the top left and right edges of the toolbar.
BUG=40022
TEST=Make sure the top left and right eges of the toolbar are rounded.
Review URL: http://codereview.chromium.org/1606021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44177 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/theme/theme_resources.grd | 2 | ||||
-rw-r--r-- | chrome/browser/browser_theme_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/frame/glass_browser_frame_view.cc | 47 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.cc | 69 |
5 files changed, 108 insertions, 18 deletions
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 8c9d7f8..c38c3b2 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -23,7 +23,9 @@ <include name="IDR_CONTENT_STAR_ON" file="content_star_on.png" type="BINDATA" /> <include name="IDR_CONTENT_TOP_CENTER" file="content_top_center.png" type="BINDATA" /> <include name="IDR_CONTENT_TOP_LEFT_CORNER" file="content_top_left_corner.png" type="BINDATA" /> + <include name="IDR_CONTENT_TOP_LEFT_CORNER_MASK" file="content_top_left_corner_mask.png" type="BINDATA" /> <include name="IDR_CONTENT_TOP_RIGHT_CORNER" file="content_top_right_corner.png" type="BINDATA" /> + <include name="IDR_CONTENT_TOP_RIGHT_CORNER_MASK" file="content_top_right_corner_mask.png" type="BINDATA" /> <include name="IDR_DROP" file="drop.png" type="BINDATA" /> <include name="IDR_DROP_H" file="drop_h.png" type="BINDATA" /> <include name="IDR_DROP_P" file="drop_p.png" type="BINDATA" /> diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index cf20cae..92fefc3 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -51,7 +51,7 @@ const SkColor kDefaultColorFrameIncognitoInactive = #if defined(OS_MACOSX) const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230); #else -const SkColor kDefaultColorToolbar = SkColorSetRGB(214, 214, 214); +const SkColor kDefaultColorToolbar = SkColorSetRGB(223, 223, 223); #endif const SkColor kDefaultColorTabText = SK_ColorBLACK; #if defined(OS_MACOSX) diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc index d12963f..0092fa7 100644 --- a/chrome/browser/views/frame/browser_frame_win.cc +++ b/chrome/browser/views/frame/browser_frame_win.cc @@ -28,6 +28,9 @@ // static static const int kClientEdgeThickness = 3; static const int kTabDragWindowAlpha = 200; +// We need to offset the DWMFrame into the toolbar so that the blackness +// doesn't show up on our rounded corners. +static const int kDWMFrameTopOffset = 3; // static (Factory method.) BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, @@ -303,7 +306,8 @@ void BrowserFrameWin::UpdateDWMFrame() { margins.cyTopHeight += GetSystemMetrics(SM_CYSIZEFRAME); } else { margins.cyTopHeight = - GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); + GetBoundsForTabStrip(browser_view_->tabstrip()).bottom() + + kDWMFrameTopOffset; } } } else { diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index 608fea9..9a665f7 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -40,6 +40,8 @@ const int kOTRBottomSpacing = 2; // There are 2 px on each side of the OTR avatar (between the frame border and // it on the left, and between it and the tabstrip on the right). const int kOTRSideSpacing = 2; +// The content left/right images have a shadow built into them. +const int kContentEdgeShadowThickness = 2; // The top 1 px of the tabstrip is shadow; in maximized mode we push this off // the top of the screen so the tabs appear flush against the screen edge. const int kTabstripTopShadowThickness = 1; @@ -261,19 +263,46 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_bounds.x() - 1, toolbar_bounds.y() + 2, toolbar_bounds.width() + 2, theme_toolbar->height()); - SkBitmap* toolbar_left = - tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); - canvas->DrawBitmapInt(*toolbar_left, - toolbar_bounds.x() - toolbar_left->width(), - toolbar_bounds.y()); - + // Draw rounded corners for the tab. + SkBitmap* toolbar_left_mask = + tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); + SkBitmap* toolbar_right_mask = + tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); + + // We mask out the corners by using the DestinationIn transfer mode, + // which keeps the RGB pixels from the destination and the alpha from + // the source. + SkPaint paint; + paint.setXfermodeMode(SkXfermode::kDstIn_Mode); + + // Mask out the top left corner. + int left_x = toolbar_bounds.x() - kContentEdgeShadowThickness - + kClientEdgeThickness; + canvas->DrawBitmapInt(*toolbar_left_mask, + left_x, toolbar_bounds.y(), paint); + + // Mask out the top right corner. + int right_x = toolbar_bounds.right() - toolbar_right_mask->width() + + kContentEdgeShadowThickness + kClientEdgeThickness; + canvas->DrawBitmapInt(*toolbar_right_mask, + right_x, toolbar_bounds.y(), + paint); + + // Draw left edge. + SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); + canvas->DrawBitmapInt(*toolbar_left, left_x, toolbar_bounds.y()); + + // Draw center edge. SkBitmap* toolbar_center = tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); - canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(), - toolbar_bounds.width(), toolbar_center->height()); + canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), + toolbar_bounds.y(), + right_x - (left_x + toolbar_left->width()), + toolbar_center->height()); + // Right edge. canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER), - toolbar_bounds.right(), toolbar_bounds.y()); + right_x, toolbar_bounds.y()); // Draw the content/toolbar separator. canvas->DrawLineInt(ResourceBundle::toolbar_separator_color, diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index 6d993d9..c91cb51 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -59,6 +59,8 @@ const int kResizeAreaCornerSize = 16; // The titlebar never shrinks too short to show the caption button plus some // padding below it. const int kCaptionButtonHeightWithPadding = 19; +// The content left/right images have a shadow built into them. +const int kContentEdgeShadowThickness = 2; // The titlebar has a 2 px 3D edge along the top and bottom. const int kTitlebarTopAndBottomEdgeThickness = 2; // The icon is inset 2 px from the left frame border. @@ -90,6 +92,9 @@ const int kNewTabCaptionRestoredSpacing = 5; // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid // looking too cluttered. const int kNewTabCaptionMaximizedSpacing = 16; +// How far to indent the tabstrip from the left side of the screen when there +// is no OTR icon. +const int kTabStripIndent = 1; } /////////////////////////////////////////////////////////////////////////////// @@ -189,7 +194,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( BaseTabStrip* tabstrip) const { int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_avatar_icon_->bounds().right() + kOTRSideSpacing) : - NonClientBorderThickness(); + NonClientBorderThickness() + kTabStripIndent; int tabstrip_width = minimize_button_->x() - tabstrip_x - (frame_->GetWindow()->IsMaximized() ? kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); @@ -702,6 +707,17 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { int bottom_edge_height = std::min(toolbar_left->height(), toolbar_bounds.height()) - split_point; + // Split our canvas out so we can mask out the corners of the toolbar + // without masking out the frame. + SkRect bounds; + bounds.set(SkIntToScalar(toolbar_bounds.x() - kClientEdgeThickness), + SkIntToScalar(toolbar_bounds.y()), + SkIntToScalar(toolbar_bounds.x() + toolbar_bounds.width() + + kClientEdgeThickness * 2), + SkIntToScalar(toolbar_bounds.y() + toolbar_bounds.height())); + canvas->saveLayerAlpha(&bounds, 255); + canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); + SkColor theme_toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); canvas->FillRectInt(theme_toolbar_color, toolbar_bounds.x(), bottom_y, @@ -717,26 +733,65 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_bounds.width() + (2 * kClientEdgeThickness), theme_toolbar->height()); + // Draw rounded corners for the tab. + SkBitmap* toolbar_left_mask = + tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); + SkBitmap* toolbar_right_mask = + tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); + + // We mask out the corners by using the DestinationIn transfer mode, + // which keeps the RGB pixels from the destination and the alpha from + // the source. + SkPaint paint; + paint.setXfermodeMode(SkXfermode::kDstIn_Mode); + + // Make the left edge. + int left_x = toolbar_bounds.x() - kClientEdgeThickness - + kContentEdgeShadowThickness; + canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, + toolbar_left_mask->width(), split_point, + left_x, toolbar_bounds.y(), + toolbar_left_mask->width(), split_point, false, paint); + canvas->DrawBitmapInt(*toolbar_left_mask, 0, + toolbar_left_mask->height() - bottom_edge_height, + toolbar_left_mask->width(), bottom_edge_height, + left_x, bottom_y, + toolbar_left_mask->width(), bottom_edge_height, false, paint); + + // Mask the right edge. + int right_x = toolbar_bounds.right() - + toolbar_right_mask->width() + kClientEdgeThickness + + kContentEdgeShadowThickness; + canvas->DrawBitmapInt(*toolbar_right_mask, 0, 0, + toolbar_right_mask->width(), split_point, right_x, toolbar_bounds.y(), + toolbar_right_mask->width(), split_point, false, paint); + canvas->DrawBitmapInt(*toolbar_right_mask, 0, + toolbar_right_mask->height() - bottom_edge_height, + toolbar_right_mask->width(), bottom_edge_height, right_x, bottom_y, + toolbar_right_mask->width(), bottom_edge_height, false, paint); + canvas->restore(); + canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, - toolbar_bounds.x() - toolbar_left->width(), toolbar_bounds.y(), + left_x, toolbar_bounds.y(), toolbar_left->width(), split_point, false); canvas->DrawBitmapInt(*toolbar_left, 0, toolbar_left->height() - bottom_edge_height, toolbar_left->width(), - bottom_edge_height, toolbar_bounds.x() - toolbar_left->width(), bottom_y, + bottom_edge_height, left_x, bottom_y, toolbar_left->width(), bottom_edge_height, false); SkBitmap* toolbar_center = tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); - canvas->TileImageInt(*toolbar_center, 0, 0, toolbar_bounds.x(), - toolbar_bounds.y(), toolbar_bounds.width(), split_point); + canvas->TileImageInt(*toolbar_center, 0, 0, left_x + toolbar_left->width(), + toolbar_bounds.y(), right_x - (left_x + toolbar_left->width()), + split_point); SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), - split_point, toolbar_bounds.right(), toolbar_bounds.y(), + split_point, right_x, toolbar_bounds.y(), toolbar_right->width(), split_point, false); canvas->DrawBitmapInt(*toolbar_right, 0, toolbar_right->height() - bottom_edge_height, toolbar_right->width(), - bottom_edge_height, toolbar_bounds.right(), bottom_y, + bottom_edge_height, right_x, bottom_y, toolbar_right->width(), bottom_edge_height, false); // Draw the content/toolbar separator. |