summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authoryefim@chromium.org <yefim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 00:52:29 +0000
committeryefim@chromium.org <yefim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 00:52:29 +0000
commita673f35eda3aa6859420688dae2e2b08fe126818 (patch)
treea55b37ba7dfd614d75855bd37f48a67f8d07d76b /ui
parent3d95e54652070dacfdb9188c3f6f48111bcc007e (diff)
downloadchromium_src-a673f35eda3aa6859420688dae2e2b08fe126818.zip
chromium_src-a673f35eda3aa6859420688dae2e2b08fe126818.tar.gz
chromium_src-a673f35eda3aa6859420688dae2e2b08fe126818.tar.bz2
Added flag to enable new menu style.
Changed so far: menu background, no gutter, separator, border with round corners (corners are not transparent yet). This is work in progress, just want to keep change size manageable. BUG=157692 Review URL: https://chromiumcodereview.appspot.com/11348055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168671 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/ui_base_switches.cc3
-rw-r--r--ui/base/ui_base_switches.h1
-rw-r--r--ui/native_theme/common_theme.cc87
-rw-r--r--ui/native_theme/common_theme.h37
-rw-r--r--ui/native_theme/native_theme.cc23
-rw-r--r--ui/native_theme/native_theme.gyp2
-rw-r--r--ui/native_theme/native_theme.h4
-rw-r--r--ui/native_theme/native_theme_win.cc25
-rw-r--r--ui/views/border.cc13
-rw-r--r--ui/views/border.h4
-rw-r--r--ui/views/controls/menu/menu_config.cc11
-rw-r--r--ui/views/controls/menu/menu_config.h10
-rw-r--r--ui/views/controls/menu/menu_config_views.cc3
-rw-r--r--ui/views/controls/menu/menu_config_win.cc3
-rw-r--r--ui/views/controls/menu/menu_controller.cc2
-rw-r--r--ui/views/controls/menu/menu_item_view_win.cc22
-rw-r--r--ui/views/controls/menu/menu_scroll_view_container.cc26
-rw-r--r--ui/views/controls/menu/menu_separator_win.cc1
-rw-r--r--ui/views/round_rect_painter.cc35
-rw-r--r--ui/views/round_rect_painter.h36
-rw-r--r--ui/views/views.gyp2
21 files changed, 304 insertions, 46 deletions
diff --git a/ui/base/ui_base_switches.cc b/ui/base/ui_base_switches.cc
index be4639b..98ee735 100644
--- a/ui/base/ui_base_switches.cc
+++ b/ui/base/ui_base_switches.cc
@@ -56,6 +56,9 @@ const char kTouchOptimizedUIEnabled[] = "enabled";
// disabled: never optimized for touch.
const char kTouchOptimizedUIDisabled[] = "disabled";
+// Enables new menu UI.
+const char kEnableNewMenuStyle[] = "enable-new-menu-style";
+
#if defined(USE_XI2_MT)
// The calibration factors given as "<left>,<right>,<top>,<bottom>".
const char kTouchCalibration[] = "touch-calibration";
diff --git a/ui/base/ui_base_switches.h b/ui/base/ui_base_switches.h
index df51831..1b649cf 100644
--- a/ui/base/ui_base_switches.h
+++ b/ui/base/ui_base_switches.h
@@ -25,6 +25,7 @@ UI_EXPORT extern const char kTouchOptimizedUI[];
UI_EXPORT extern const char kTouchOptimizedUIAuto[];
UI_EXPORT extern const char kTouchOptimizedUIDisabled[];
UI_EXPORT extern const char kTouchOptimizedUIEnabled[];
+UI_EXPORT extern const char kEnableNewMenuStyle[];
#if defined(USE_XI2_MT)
UI_EXPORT extern const char kTouchCalibration[];
diff --git a/ui/native_theme/common_theme.cc b/ui/native_theme/common_theme.cc
new file mode 100644
index 0000000..fb1fea9
--- /dev/null
+++ b/ui/native_theme/common_theme.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/native_theme/common_theme.h"
+
+#include "base/logging.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/skia_util.h"
+#include "ui/views/controls/menu/menu_config.h"
+
+namespace {
+
+// Theme colors returned by GetSystemColor().
+
+// MenuItem:
+const SkColor kMenuBackgroundColor = SK_ColorWHITE;
+const SkColor kMenuHighlightBackgroundColor = SkColorSetA(SK_ColorBLACK, 15);
+const SkColor kMenuBorderColor = SkColorSetRGB(0xBA, 0xBA, 0xBA);
+const SkColor kMenuSeparatorColor = SkColorSetRGB(0xE9, 0xE9, 0xE9);
+
+} // namespace
+
+namespace ui {
+
+bool CommonThemeGetSystemColor(NativeTheme::ColorId color_id, SkColor* color) {
+ switch (color_id) {
+ // MenuItem
+ case NativeTheme::kColorId_MenuBorderColor:
+ *color = kMenuBorderColor;
+ break;
+ case NativeTheme::kColorId_MenuSeparatorColor:
+ *color = kMenuSeparatorColor;
+ break;
+ case NativeTheme::kColorId_MenuBackgroundColor:
+ *color = kMenuBackgroundColor;
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+void CommonThemePaintMenuSeparator(
+ SkCanvas* canvas,
+ const gfx::Rect& rect,
+ const NativeTheme::MenuSeparatorExtraParams& extra) {
+ SkPaint paint;
+ paint.setColor(kMenuSeparatorColor);
+ int position_y = rect.y() + rect.height() / 2;
+ canvas->drawLine(rect.x(), position_y, rect.right(), position_y, paint);
+}
+
+void CommonThemePaintMenuGutter(SkCanvas* canvas, const gfx::Rect& rect) {
+ SkPaint paint;
+ paint.setColor(kMenuSeparatorColor);
+ int position_x = rect.x() + rect.width() / 2;
+ canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint);
+}
+
+void CommonThemePaintMenuBackground(SkCanvas* canvas, const gfx::Rect& rect) {
+ SkPaint paint;
+ paint.setColor(kMenuBackgroundColor);
+ canvas->drawRect(gfx::RectToSkRect(rect), paint);
+}
+
+void CommonThemePaintMenuItemBackground(SkCanvas* canvas,
+ NativeTheme::State state,
+ const gfx::Rect& rect) {
+ SkPaint paint;
+ switch (state) {
+ case NativeTheme::kNormal:
+ case NativeTheme::kDisabled:
+ paint.setColor(kMenuBackgroundColor);
+ break;
+ case NativeTheme::kHovered:
+ paint.setColor(kMenuHighlightBackgroundColor);
+ break;
+ default:
+ NOTREACHED() << "Invalid state " << state;
+ break;
+ }
+ canvas->drawRect(gfx::RectToSkRect(rect), paint);
+}
+
+} // namespace ui
diff --git a/ui/native_theme/common_theme.h b/ui/native_theme/common_theme.h
new file mode 100644
index 0000000..9a021c4
--- /dev/null
+++ b/ui/native_theme/common_theme.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_NATIVE_THEME_COMMON_THEME_H_
+#define UI_NATIVE_THEME_COMMON_THEME_H_
+
+#include "ui/native_theme/native_theme.h"
+
+class SkCanvas;
+namespace views {
+struct MenuConfig;
+}
+
+namespace ui {
+
+// Drawing code that is common for all platforms.
+
+// Returns true and |color| if |color_id| is found, or false otherwise.
+bool CommonThemeGetSystemColor(NativeTheme::ColorId color_id, SkColor* color);
+
+void CommonThemePaintMenuSeparator(
+ SkCanvas* canvas,
+ const gfx::Rect& rect,
+ const NativeTheme::MenuSeparatorExtraParams& extra);
+
+void CommonThemePaintMenuGutter(SkCanvas* canvas, const gfx::Rect& rect);
+
+void CommonThemePaintMenuBackground(SkCanvas* canvas, const gfx::Rect& rect);
+
+void CommonThemePaintMenuItemBackground(SkCanvas* canvas,
+ NativeTheme::State state,
+ const gfx::Rect& rect);
+
+} // namespace ui
+
+#endif // UI_NATIVE_THEME_COMMON_THEME_H_
diff --git a/ui/native_theme/native_theme.cc b/ui/native_theme/native_theme.cc
index 85b58e9..6bc7a93 100644
--- a/ui/native_theme/native_theme.cc
+++ b/ui/native_theme/native_theme.cc
@@ -4,13 +4,10 @@
#include "ui/native_theme/native_theme.h"
-namespace ui {
+#include "base/command_line.h"
+#include "ui/base/ui_base_switches.h"
-NativeTheme::NativeTheme()
- : thumb_inactive_color_(0xeaeaea),
- thumb_active_color_(0xf4f4f4),
- track_color_(0xd3d3d3) {
-}
+namespace ui {
void NativeTheme::SetScrollbarColors(unsigned inactive_color,
unsigned active_color,
@@ -23,4 +20,18 @@ void NativeTheme::SetScrollbarColors(unsigned inactive_color,
// NativeTheme::instance() is implemented in the platform specific source files,
// such as native_theme_win.cc or native_theme_linux.cc
+// static
+bool NativeTheme::IsNewMenuStyleEnabled() {
+ static bool enable_new_menu_style =
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNewMenuStyle);
+ return enable_new_menu_style;
+}
+
+NativeTheme::NativeTheme()
+ : thumb_inactive_color_(0xeaeaea),
+ thumb_active_color_(0xf4f4f4),
+ track_color_(0xd3d3d3) {
+}
+
} // namespace ui
diff --git a/ui/native_theme/native_theme.gyp b/ui/native_theme/native_theme.gyp
index c236a97..f4a603ad 100644
--- a/ui/native_theme/native_theme.gyp
+++ b/ui/native_theme/native_theme.gyp
@@ -21,6 +21,8 @@
'NATIVE_THEME_IMPLEMENTATION',
],
'sources': [
+ 'common_theme.cc',
+ 'common_theme.h',
'native_theme.cc',
'native_theme.h',
'native_theme_android.cc',
diff --git a/ui/native_theme/native_theme.h b/ui/native_theme/native_theme.h
index b3b9fc3..ed3ed35 100644
--- a/ui/native_theme/native_theme.h
+++ b/ui/native_theme/native_theme.h
@@ -234,6 +234,8 @@ class NATIVE_THEME_EXPORT NativeTheme {
kColorId_DisabledMenuItemForegroundColor,
kColorId_FocusedMenuItemBackgroundColor,
kColorId_MenuSeparatorColor,
+ kColorId_MenuBackgroundColor,
+ kColorId_MenuBorderColor,
// Label
kColorId_LabelEnabledColor,
kColorId_LabelDisabledColor,
@@ -257,6 +259,8 @@ class NATIVE_THEME_EXPORT NativeTheme {
// function, returning the port's subclass.
static NativeTheme* instance();
+ static bool IsNewMenuStyleEnabled();
+
protected:
NativeTheme();
virtual ~NativeTheme() {}
diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc
index d83f396..27a00a5 100644
--- a/ui/native_theme/native_theme_win.cc
+++ b/ui/native_theme/native_theme_win.cc
@@ -26,6 +26,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/gdi_util.h"
#include "ui/gfx/rect.h"
+#include "ui/native_theme/common_theme.h"
namespace {
@@ -247,6 +248,23 @@ void NativeThemeWin::Paint(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ExtraParams& extra) const {
+ if (IsNewMenuStyleEnabled()) {
+ switch (part) {
+ case kMenuPopupGutter:
+ CommonThemePaintMenuGutter(canvas, rect);
+ return;
+ case kMenuPopupSeparator:
+ CommonThemePaintMenuSeparator(canvas, rect, extra.menu_separator);
+ return;
+ case kMenuPopupBackground:
+ CommonThemePaintMenuBackground(canvas, rect);
+ return;
+ case kMenuItemBackground:
+ CommonThemePaintMenuItemBackground(canvas, state, rect);
+ return;
+ }
+ }
+
bool needs_paint_indirect = false;
if (!skia::SupportsPlatformPaint(canvas)) {
// This block will only get hit with --enable-accelerated-drawing flag.
@@ -412,8 +430,13 @@ void NativeThemeWin::PaintDirect(SkCanvas* canvas,
}
SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
- switch (color_id) {
+ SkColor color;
+ if (IsNewMenuStyleEnabled() &&
+ CommonThemeGetSystemColor(color_id, &color)) {
+ return color;
+ }
+ switch (color_id) {
// Dialogs
case kColorId_DialogBackground:
// TODO(benrg): Should this use the new Windows theme functions? The old
diff --git a/ui/views/border.cc b/ui/views/border.cc
index 8964c691..9f86fc4 100644
--- a/ui/views/border.cc
+++ b/ui/views/border.cc
@@ -86,8 +86,9 @@ class EmptyBorder : public Border {
class BorderPainter : public Border {
public:
- explicit BorderPainter(Painter* painter)
- : painter_(painter) {
+ explicit BorderPainter(Painter* painter, const gfx::Insets& insets)
+ : painter_(painter),
+ insets_(insets) {
DCHECK(painter);
}
@@ -99,11 +100,12 @@ class BorderPainter : public Border {
}
virtual gfx::Insets GetInsets() const OVERRIDE {
- return gfx::Insets();
+ return insets_;
}
private:
scoped_ptr<Painter> painter_;
+ const gfx::Insets insets_;
DISALLOW_COPY_AND_ASSIGN(BorderPainter);
};
@@ -136,8 +138,9 @@ Border* Border::CreateSolidSidedBorder(int top,
}
// static
-Border* Border::CreateBorderPainter(Painter* painter) {
- return new BorderPainter(painter);
+Border* Border::CreateBorderPainter(Painter* painter,
+ const gfx::Insets& insets) {
+ return new BorderPainter(painter, insets);
}
} // namespace views
diff --git a/ui/views/border.h b/ui/views/border.h
index 8a0a55e2..d1431fb 100644
--- a/ui/views/border.h
+++ b/ui/views/border.h
@@ -59,7 +59,9 @@ class VIEWS_EXPORT Border {
// Creates a Border from the specified Painter. The border owns the painter,
// thus the painter is deleted when the Border is deleted.
- static Border* CreateBorderPainter(Painter* painter);
+ // |insets| define size of an area allocated for a Border.
+ static Border* CreateBorderPainter(Painter* painter,
+ const gfx::Insets& insets);
// Renders the border for the specified view.
virtual void Paint(const View& view, gfx::Canvas* canvas) = 0;
diff --git a/ui/views/controls/menu/menu_config.cc b/ui/views/controls/menu/menu_config.cc
index 5c951c8..84abe5d 100644
--- a/ui/views/controls/menu/menu_config.cc
+++ b/ui/views/controls/menu/menu_config.cc
@@ -13,8 +13,7 @@ namespace views {
MenuConfig::MenuConfig(const ui::NativeTheme* theme)
: text_color(SK_ColorBLACK),
arrow_color(SK_ColorBLACK),
- submenu_horizontal_margin_size(3),
- submenu_vertical_margin_size(3),
+ menu_border_size(3),
submenu_horizontal_inset(3),
item_top_margin(3),
item_bottom_margin(4),
@@ -57,4 +56,12 @@ MenuConfig::MenuConfig(const ui::NativeTheme* theme)
MenuConfig::~MenuConfig() {}
+void MenuConfig::AdjustForCommonTheme() {
+ render_gutter = false;
+ item_top_margin = 6;
+ item_bottom_margin = 6;
+ separator_height = 15;
+ menu_border_size = 2;
+}
+
} // namespace views
diff --git a/ui/views/controls/menu/menu_config.h b/ui/views/controls/menu/menu_config.h
index 9be9921..79a8659 100644
--- a/ui/views/controls/menu/menu_config.h
+++ b/ui/views/controls/menu/menu_config.h
@@ -32,11 +32,8 @@ struct VIEWS_EXPORT MenuConfig {
// Color for the arrow to scroll bookmarks.
SkColor arrow_color;
- // Submenu horizontal margin size.
- int submenu_horizontal_margin_size;
-
- // Submenu vertical margin size.
- int submenu_vertical_margin_size;
+ // Menu border size.
+ int menu_border_size;
// Submenu horizontal inset with parent menu. This is the horizontal overlap
// between the submenu and its parent menu, not including the borders of
@@ -134,6 +131,9 @@ struct VIEWS_EXPORT MenuConfig {
#if defined(USE_AURA)
void InitAura();
#endif
+
+ // Adjust some values for a new UI style.
+ void AdjustForCommonTheme();
};
} // namespace views
diff --git a/ui/views/controls/menu/menu_config_views.cc b/ui/views/controls/menu/menu_config_views.cc
index 15e849a..a0285d6 100644
--- a/ui/views/controls/menu/menu_config_views.cc
+++ b/ui/views/controls/menu/menu_config_views.cc
@@ -23,8 +23,7 @@ void MenuConfig::InitAura() {
ui::NativeTheme* theme = ui::NativeThemeAura::instance();
text_color = theme->GetSystemColor(
ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
- submenu_horizontal_margin_size = 0;
- submenu_vertical_margin_size = 0;
+ menu_border_size = 0;
submenu_horizontal_inset = 1;
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
arrow_to_edge_padding = 20;
diff --git a/ui/views/controls/menu/menu_config_win.cc b/ui/views/controls/menu/menu_config_win.cc
index d7ae562..c35e976 100644
--- a/ui/views/controls/menu/menu_config_win.cc
+++ b/ui/views/controls/menu/menu_config_win.cc
@@ -99,6 +99,9 @@ void MenuConfig::Init(const NativeTheme* theme) {
separator_height = GetSystemMetrics(SM_CYMENU) / 2 - 1;
}
+ if (NativeTheme::IsNewMenuStyleEnabled())
+ AdjustForCommonTheme();
+
// On Windows, having some menus use wider spacing than others looks wrong.
// See http://crbug.com/88875
item_no_icon_bottom_margin = item_bottom_margin;
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index 9151c34..d7077e9 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -1695,7 +1695,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
x = item_loc.x() + item->width() - submenu_horizontal_inset;
}
}
- y = item_loc.y() - menu_config.submenu_vertical_margin_size;
+ y = item_loc.y() - menu_config.menu_border_size;
if (state_.monitor_bounds.width() != 0) {
pref.set_height(std::min(pref.height(), state_.monitor_bounds.height()));
if (y + pref.height() > state_.monitor_bounds.bottom())
diff --git a/ui/views/controls/menu/menu_item_view_win.cc b/ui/views/controls/menu/menu_item_view_win.cc
index 5d543ba..461b9fe9 100644
--- a/ui/views/controls/menu/menu_item_view_win.cc
+++ b/ui/views/controls/menu/menu_item_view_win.cc
@@ -57,7 +57,17 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
control_state = NativeTheme::kDisabled;
}
- // The gutter is rendered before the background.
+ // Render the background.
+ if (mode == PB_NORMAL) {
+ gfx::Rect item_bounds(0, 0, width(), height());
+ AdjustBoundsForRTLUI(&item_bounds);
+ NativeTheme::ExtraParams extra;
+ extra.menu_item.is_selected = render_selection;
+ config.native_theme->Paint(canvas->sk_canvas(),
+ NativeTheme::kMenuItemBackground, control_state, item_bounds, extra);
+ }
+
+ // Render the gutter.
if (config.render_gutter && mode == PB_NORMAL) {
gfx::Rect gutter_bounds(label_start_ - config.gutter_to_label -
config.gutter_width, 0, config.gutter_width,
@@ -71,16 +81,6 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
extra);
}
- // Render the background.
- if (mode == PB_NORMAL) {
- gfx::Rect item_bounds(0, 0, width(), height());
- NativeTheme::ExtraParams extra;
- extra.menu_item.is_selected = render_selection;
- AdjustBoundsForRTLUI(&item_bounds);
- config.native_theme->Paint(canvas->sk_canvas(),
- NativeTheme::kMenuItemBackground, control_state, item_bounds, extra);
- }
-
int top_margin = GetTopMargin();
int bottom_margin = GetBottomMargin();
diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc
index 8a85d60..73dbaca 100644
--- a/ui/views/controls/menu/menu_scroll_view_container.cc
+++ b/ui/views/controls/menu/menu_scroll_view_container.cc
@@ -4,12 +4,6 @@
#include "ui/views/controls/menu/menu_scroll_view_container.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#include <uxtheme.h>
-#include <Vssym32.h>
-#endif
-
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/base/accessibility/accessible_view_state.h"
@@ -20,6 +14,7 @@
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/submenu_view.h"
+#include "ui/views/round_rect_painter.h"
using ui::NativeTheme;
@@ -179,11 +174,20 @@ MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view)
const MenuConfig& menu_config =
content_view_->GetMenuItem()->GetMenuConfig();
- set_border(Border::CreateEmptyBorder(
- menu_config.submenu_vertical_margin_size,
- menu_config.submenu_horizontal_margin_size,
- menu_config.submenu_vertical_margin_size,
- menu_config.submenu_horizontal_margin_size));
+
+ if (NativeTheme::IsNewMenuStyleEnabled()) {
+ set_border(views::Border::CreateBorderPainter(
+ new views::RoundRectPainter(
+ ui::NativeTheme::instance()->GetSystemColor(
+ ui::NativeTheme::kColorId_MenuBorderColor)),
+ gfx::Insets(menu_config.menu_border_size, menu_config.menu_border_size,
+ menu_config.menu_border_size, menu_config.menu_border_size)));
+ } else {
+ set_border(Border::CreateEmptyBorder(menu_config.menu_border_size,
+ menu_config.menu_border_size,
+ menu_config.menu_border_size,
+ menu_config.menu_border_size));
+ }
}
void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) {
diff --git a/ui/views/controls/menu/menu_separator_win.cc b/ui/views/controls/menu/menu_separator_win.cc
index 89db94a..6f95334 100644
--- a/ui/views/controls/menu/menu_separator_win.cc
+++ b/ui/views/controls/menu/menu_separator_win.cc
@@ -30,7 +30,6 @@ void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
}
#endif
- // The gutter is rendered before the background.
int start_x = 0;
if (config.render_gutter) {
// If render_gutter is true, we're on Vista and need to render the
diff --git a/ui/views/round_rect_painter.cc b/ui/views/round_rect_painter.cc
new file mode 100644
index 0000000..ec8c179
--- /dev/null
+++ b/ui/views/round_rect_painter.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/round_rect_painter.h"
+
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/skia_util.h"
+
+namespace views {
+
+static const int kRadius = 2;
+
+RoundRectPainter::RoundRectPainter(SkColor border_color)
+ : border_color_(border_color) {
+}
+
+RoundRectPainter::~RoundRectPainter() {
+}
+
+void RoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
+ SkPaint paint;
+ paint.setColor(border_color_);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(1);
+ paint.setFlags(SkPaint::kAntiAlias_Flag);
+ gfx::Rect rect(size);
+ rect.Inset(0, 0, 1, 1);
+ SkRect skia_rect = gfx::RectToSkRect(rect);
+ skia_rect.offset(.5, .5);
+ canvas->sk_canvas()->drawRoundRect(skia_rect, SkIntToScalar(kRadius),
+ SkIntToScalar(kRadius), paint);
+}
+
+} // namespace views
diff --git a/ui/views/round_rect_painter.h b/ui/views/round_rect_painter.h
new file mode 100644
index 0000000..3e4b5ca
--- /dev/null
+++ b/ui/views/round_rect_painter.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_ROUNDED_RECT_PAINTER_H_
+#define UI_VIEWS_ROUNDED_RECT_PAINTER_H_
+
+#include "ui/gfx/rect.h"
+#include "ui/views/painter.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class Canvas;
+class Size;
+}
+
+namespace views {
+
+// Painter to draw a border with rounded corners.
+class VIEWS_EXPORT RoundRectPainter : public Painter {
+ public:
+ explicit RoundRectPainter(SkColor border_color);
+ virtual ~RoundRectPainter();
+
+ // Painter overrides:
+ virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE;
+
+ private:
+ const SkColor border_color_;
+
+ DISALLOW_COPY_AND_ASSIGN(RoundRectPainter);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_ROUNDED_RECT_PAINTER_H_
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index 57b1767..599e039 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -307,6 +307,8 @@
'painter.h',
'repeat_controller.cc',
'repeat_controller.h',
+ 'round_rect_painter.cc',
+ 'round_rect_painter.h',
'touchui/touch_selection_controller.cc',
'touchui/touch_selection_controller.h',
'view.cc',