summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 20:02:54 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 20:02:54 +0000
commitbf952c3b72a9dbccd0f823e4630e287adce45453 (patch)
tree6ccaf0aa28bd3f8c9b4619a311aca5da78457bfb /chrome/browser/ui
parentcd72aa30add98d2fd9c61b72f44910d19f5d8039 (diff)
downloadchromium_src-bf952c3b72a9dbccd0f823e4630e287adce45453.zip
chromium_src-bf952c3b72a9dbccd0f823e4630e287adce45453.tar.gz
chromium_src-bf952c3b72a9dbccd0f823e4630e287adce45453.tar.bz2
Use new Ash-style tabs and toolbar icons on Windows
We still need the existing art assets for Mac and Linux/GTK in some cases, but this simplifies the views C++ code. I'll delete the orphaned browser_actions_overflow_win*.png and newtab_views*.png assets in a subsequent CL. BUG=125005 TEST=visual Review URL: http://codereview.chromium.org/10238011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/tabs/tab_resources.cc36
-rw-r--r--chrome/browser/ui/views/frame/glass_browser_frame_view.cc13
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc10
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc30
-rw-r--r--chrome/browser/ui/views/tabs/tab.cc35
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.cc11
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.h4
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc32
8 files changed, 69 insertions, 102 deletions
diff --git a/chrome/browser/ui/tabs/tab_resources.cc b/chrome/browser/ui/tabs/tab_resources.cc
index aad9e1e..8a7902f 100644
--- a/chrome/browser/ui/tabs/tab_resources.cc
+++ b/chrome/browser/ui/tabs/tab_resources.cc
@@ -13,11 +13,14 @@ namespace {
const SkScalar kTabCapWidth = 15;
const SkScalar kTabTopCurveWidth = 4;
const SkScalar kTabBottomCurveWidth = 3;
-#if defined(USE_ASH)
-// Ash has shadows in the left and right part of the tab.
+#if defined(TOOLKIT_VIEWS)
+// Windows and Ash have shadows in the left, right and top parts of the tab.
const SkScalar kTabInset = 6;
+const SkScalar kTabTop = 2;
#else
+// Linux GTK and Mac don't have the shadows.
const SkScalar kTabInset = 0;
+const SkScalar kTabTop = 0;
#endif
} // namespace
@@ -26,27 +29,30 @@ const SkScalar kTabInset = 0;
void TabResources::GetHitTestMask(int width, int height, gfx::Path* path) {
DCHECK(path);
- SkScalar h = SkIntToScalar(height);
- SkScalar w = SkIntToScalar(width);
-
SkScalar left = kTabInset;
- path->moveTo(left, h);
+ SkScalar top = kTabTop;
+ SkScalar right = SkIntToScalar(width) - kTabInset;
+ SkScalar bottom = SkIntToScalar(height);
+
+ // Start in the lower-left corner.
+ path->moveTo(left, bottom);
// Left end cap.
- path->lineTo(left + kTabBottomCurveWidth, h - kTabBottomCurveWidth);
- path->lineTo(left + kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth);
- path->lineTo(left + kTabCapWidth, 0);
+ path->lineTo(left + kTabBottomCurveWidth, bottom - kTabBottomCurveWidth);
+ path->lineTo(left + kTabCapWidth - kTabTopCurveWidth,
+ top + kTabTopCurveWidth);
+ path->lineTo(left + kTabCapWidth, top);
// Connect to the right cap.
- SkScalar right = w - kTabInset;
- path->lineTo(right - kTabCapWidth, 0);
+ path->lineTo(right - kTabCapWidth, top);
// Right end cap.
- path->lineTo(right - kTabCapWidth + kTabTopCurveWidth, kTabTopCurveWidth);
- path->lineTo(right - kTabBottomCurveWidth, h - kTabBottomCurveWidth);
- path->lineTo(right, h);
+ path->lineTo(right - kTabCapWidth + kTabTopCurveWidth,
+ top + kTabTopCurveWidth);
+ path->lineTo(right - kTabBottomCurveWidth, bottom - kTabBottomCurveWidth);
+ path->lineTo(right, bottom);
// Close out the path.
- path->lineTo(left, h);
+ path->lineTo(left, bottom);
path->close();
}
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
index d396a5f..180a6b6 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -36,9 +36,9 @@ HICON GlassBrowserFrameView::throbber_icons_[
namespace {
// There are 3 px of client edge drawn inside the outer frame borders.
const int kNonClientBorderThickness = 3;
-// Besides the frame border, there's another 11 px of empty space atop the
+// Besides the frame border, there's another 9 px of empty space atop the
// window in restored mode, to use to drag the window around.
-const int kNonClientRestoredExtraThickness = 11;
+const int kNonClientRestoredExtraThickness = 9;
// In the window corners, the resize areas don't actually expand bigger, but the
// 16 px at the end of the top and bottom edges triggers diagonal resizing.
const int kResizeAreaCornerSize = 16;
@@ -51,9 +51,9 @@ const int kAvatarBottomSpacing = 2;
const int kAvatarSideSpacing = 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 3 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;
+const int kTabstripTopShadowThickness = 3;
// In restored mode, the New Tab button isn't at the same height as the caption
// buttons, but the space will look cluttered if it actually slides under them,
// so we stop it when the gap between the two is down to 5 px.
@@ -62,6 +62,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 avatar icon.
+const int kTabStripIndent = -4;
}
///////////////////////////////////////////////////////////////////////////////
@@ -94,7 +97,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
std::min(frame()->GetMinimizeButtonOffset(), width());
int tabstrip_x = browser_view()->ShouldShowAvatar() ?
(avatar_bounds_.right() + kAvatarSideSpacing) :
- NonClientBorderThickness();
+ NonClientBorderThickness() + kTabStripIndent;
// In RTL languages, we have moved an avatar icon left by the size of window
// controls to prevent it from being rendered over them. So, we use its x
// position to move this tab strip left when maximized. Also, we can render
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index dacb1a8..b98c7f3 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -53,9 +53,9 @@ namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
// each side regardless of the system window border size.
const int kFrameBorderThickness = 4;
-// Besides the frame border, there's another 11 px of empty space atop the
+// Besides the frame border, there's another 9 px of empty space atop the
// window in restored mode, to use to drag the window around.
-const int kNonClientRestoredExtraThickness = 11;
+const int kNonClientRestoredExtraThickness = 9;
// While resize areas on Windows are normally the same size as the window
// borders, our top area is shrunk by 1 px to make it easier to move the window
// around with our thinner top grabbable strip. (Incidentally, our side and
@@ -87,9 +87,9 @@ const int kAvatarBottomSpacing = 2;
// There are 2 px on each side of the avatar (between the frame border and
// it on the left, and between it and the tabstrip on the right).
const int kAvatarSideSpacing = 2;
-// The top 1 px of the tabstrip is shadow; in maximized mode we push this off
+// The top 3 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;
+const int kTabstripTopShadowThickness = 3;
// In restored mode, the New Tab button isn't at the same height as the caption
// buttons, but the space will look cluttered if it actually slides under them,
// so we stop it when the gap between the two is down to 5 px.
@@ -100,7 +100,7 @@ const int kNewTabCaptionRestoredSpacing = 5;
const int kNewTabCaptionMaximizedSpacing = 16;
// How far to indent the tabstrip from the left side of the screen when there
// is no avatar icon.
-const int kTabStripIndent = 1;
+const int kTabStripIndent = -4;
// Converts |bounds| from |src|'s coordinate system to |dst|, and checks if
// |pt| is contained within.
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index c9d0cca..6303632 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -83,36 +83,17 @@ OmniboxViewViews* AsViews(OmniboxView* view) {
}
// Height of the location bar's round corner region.
-// TODO(jamescook): Update all Chrome platforms to use the new art and metrics
-// from Ash, crbug.com/118228
-#if defined(USE_ASH)
const int kBorderRoundCornerHeight = 5;
-#else
-const int kBorderRoundCornerHeight = 6;
-#endif
-
// Width of location bar's round corner region.
-#if defined(USE_ASH)
const int kBorderRoundCornerWidth = 4;
-#else
-const int kBorderRoundCornerWidth = 5;
-#endif
-
// Radius of the round corners inside the location bar.
-#if defined(USE_ASH)
const int kBorderCornerRadius = 2;
-#endif
} // namespace
// static
-#if defined(USE_ASH)
const int LocationBarView::kNormalHorizontalEdgeThickness = 2;
const int LocationBarView::kVerticalEdgeThickness = 3;
-#else
-const int LocationBarView::kNormalHorizontalEdgeThickness = 1;
-const int LocationBarView::kVerticalEdgeThickness = 2;
-#endif // defined(USE_ASH)
const int LocationBarView::kItemPadding = 3;
const int LocationBarView::kIconInternalPadding = 2;
const int LocationBarView::kEdgeItemPadding = kItemPadding;
@@ -778,15 +759,9 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) {
paint.setColor(color);
paint.setStyle(SkPaint::kFill_Style);
paint.setAntiAlias(true);
-#if defined(USE_ASH)
- // On Ash the omnibox uses smaller corners.
+ // TODO(jamescook): Make the corners of the dropdown match the corners of
+ // the omnibox.
const SkScalar radius(SkIntToScalar(kBorderCornerRadius));
-#else
- // The round corners of the omnibox match the round corners of the dropdown
- // below, and all our other bubbles.
- const SkScalar radius(SkIntToScalar(
- views::BubbleBorder::GetCornerRadius()));
-#endif
bounds.Inset(kNormalHorizontalEdgeThickness, 0);
canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius,
radius, paint);
@@ -796,6 +771,7 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) {
if (show_focus_rect_ && HasFocus()) {
gfx::Rect r = location_entry_view_->bounds();
+ // TODO(jamescook): Is this still needed?
#if defined(OS_WIN)
r.Inset(-1, -1);
#else
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 202e36d..3675cdb 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -39,13 +39,14 @@ const int GetLeftPadding() {
if (value == -1) {
switch (ui::GetDisplayLayout()) {
case ui::LAYOUT_ASH:
- value = 21;
+ case ui::LAYOUT_DESKTOP:
+ value = 22;
break;
case ui::LAYOUT_TOUCH:
value = 20;
break;
default:
- value = 16;
+ NOTREACHED();
}
}
return value;
@@ -56,13 +57,14 @@ const int GetTopPadding() {
if (value == -1) {
switch (ui::GetDisplayLayout()) {
case ui::LAYOUT_ASH:
+ case ui::LAYOUT_DESKTOP:
value = 8;
break;
case ui::LAYOUT_TOUCH:
value = 12;
break;
default:
- value = 6;
+ NOTREACHED();
}
}
return value;
@@ -73,13 +75,12 @@ const int GetRightPadding() {
if (value == -1) {
switch (ui::GetDisplayLayout()) {
case ui::LAYOUT_ASH:
- value = 20;
- break;
+ case ui::LAYOUT_DESKTOP:
case ui::LAYOUT_TOUCH:
value = 21;
break;
default:
- value = 15;
+ NOTREACHED();
}
}
return value;
@@ -89,46 +90,44 @@ const int GetBottomPadding() {
static int value = -1;
if (value == -1) {
switch (ui::GetDisplayLayout()) {
+ case ui::LAYOUT_ASH:
+ case ui::LAYOUT_DESKTOP:
+ value = 5;
+ break;
case ui::LAYOUT_TOUCH:
value = 7;
break;
- case ui::LAYOUT_ASH:
default:
- value = 5;
+ NOTREACHED();
}
}
return value;
}
// Height of the shadow at the top of the tab image assets.
-#if defined(USE_ASH)
static const int kDropShadowHeight = 4;
-#else
-static const int kDropShadowHeight = 2;
-#endif
static const int kToolbarOverlap = 1;
static const int kFaviconTitleSpacing = 4;
-// Additional vertical offset for title text relative to top of tab.
#if defined(USE_ASH)
+// Additional vertical offset for title text relative to top of tab.
+// Ash text rendering may be different than Windows.
+// TODO(jamescook): Make this Chrome OS or Linux only?
static const int kTitleTextOffsetY = 1;
#else
static const int kTitleTextOffsetY = 0;
#endif
static const int kTitleCloseButtonSpacing = 3;
static const int kStandardTitleWidth = 175;
-// Additional vertical offset for close button relative to top of tab.
#if defined(USE_ASH)
+// Additional vertical offset for close button relative to top of tab.
+// Ash needs this to match the text vertical position.
static const int kCloseButtonVertFuzz = 1;
#else
static const int kCloseButtonVertFuzz = 0;
#endif
static const int kTabIconSize = gfx::kFaviconSize;
// Additional horizontal offset for close button relative to title text.
-#if defined(USE_ASH)
static const int kCloseButtonHorzFuzz = 7;
-#else
-static const int kCloseButtonHorzFuzz = 5;
-#endif
// When a non-mini-tab becomes a mini-tab the width of the tab animates. If
// the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 449fe44..a740327 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -91,13 +91,14 @@ const int GetNewTabButtonHOffset() {
if (value == -1) {
switch (ui::GetDisplayLayout()) {
case ui::LAYOUT_ASH:
+ case ui::LAYOUT_DESKTOP:
value = -11;
break;
case ui::LAYOUT_TOUCH:
value = -6;
break;
default:
- value = -5;
+ NOTREACHED();
}
}
return value;
@@ -110,13 +111,14 @@ const int GetNewTabButtonVOffset() {
if (value == -1) {
switch (ui::GetDisplayLayout()) {
case ui::LAYOUT_ASH:
+ case ui::LAYOUT_DESKTOP:
value = 7;
break;
case ui::LAYOUT_TOUCH:
value = 10;
break;
default:
- value = 5;
+ NOTREACHED();
}
}
return value;
@@ -129,13 +131,14 @@ const int GetTabHOffset() {
if (value == -1) {
switch (ui::GetDisplayLayout()) {
case ui::LAYOUT_ASH:
- value = -27;
+ case ui::LAYOUT_DESKTOP:
+ value = -29;
break;
case ui::LAYOUT_TOUCH:
value = -16;
break;
default:
- value = -16;
+ NOTREACHED();
}
}
return value;
diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h
index 27e8168..c38a385 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.h
+++ b/chrome/browser/ui/views/tabs/tab_strip.h
@@ -469,11 +469,7 @@ class TabStrip : public AbstractTabStripView,
// able to lay it out before we are able to get its image from the
// ui::ThemeProvider. It also makes sense to do this, because the size of the
// new tab button should not need to be calculated dynamically.
-#if defined(USE_ASH)
static const int kNewTabButtonWidth = 34;
-#else
- static const int kNewTabButtonWidth = 28;
-#endif
static const int kNewTabButtonHeight = 18;
// Valid for the lifetime of a drag over us.
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index 819e964..309950e 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -55,40 +55,24 @@ using content::WebContents;
// static
const char ToolbarView::kViewClassName[] = "browser/ui/views/ToolbarView";
-// The space between items is 4 px in general.
-// TODO(jamescook): Update all Chrome platforms to use the new art and metrics
-// from Ash, crbug.com/118228
-#if defined(USE_ASH)
+// The space between items is 3 px in general.
const int ToolbarView::kStandardSpacing = 3;
-#else
-const int ToolbarView::kStandardSpacing = 4;
-#endif
-
-// The top of the toolbar has an edge we have to skip over in addition to the 4
-// px of spacing.
-const int ToolbarView::kVertSpacing = 5;
+// The top of the toolbar has an edge we have to skip over in addition to the
+// above spacing.
+const int ToolbarView::kVertSpacing = 4;
// The edge graphics have some built-in spacing/shadowing, so we have to adjust
-// our spacing to make it still appear to be 4 px.
-#if defined(USE_ASH)
+// our spacing to make it match.
static const int kLeftEdgeSpacing = 3;
static const int kRightEdgeSpacing = 2;
-#else
-static const int kLeftEdgeSpacing = 3;
-static const int kRightEdgeSpacing = 3;
-#endif
// The buttons to the left of the omnibox are close together.
-#if defined(USE_ASH)
static const int kButtonSpacing = 0;
-#else
-static const int kButtonSpacing = 1;
-#endif
-// The content area line has a shadow that extends a couple of pixels above
-// the toolbar bounds.
#if defined(USE_ASH)
+// Ash doesn't use a rounded content area and its top edge has an extra shadow.
const int kContentShadowHeight = 2;
#else
+// Windows uses a rounded content area with no shadow in the assets.
const int kContentShadowHeight = 0;
#endif
@@ -591,7 +575,7 @@ void ToolbarView::Layout() {
int available_width = width() - kRightEdgeSpacing - app_menu_width -
browser_actions_width - location_x;
int location_y = child_y;
- int location_bar_height = child_height;
+ int location_bar_height = location_bar_->GetPreferredSize().height();
location_bar_->SetBounds(location_x, location_y, std::max(available_width, 0),
location_bar_height);