summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-10 22:21:02 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-10 22:21:02 +0000
commite8d6b9f3973dbef4cc61647078015bdea7522a6d (patch)
tree3426cd86f30d21e07d74b53ad1fa78b954a7eb26
parent9193d2f406ce80e36bcb17cdf59badb844e719bc (diff)
downloadchromium_src-e8d6b9f3973dbef4cc61647078015bdea7522a6d.zip
chromium_src-e8d6b9f3973dbef4cc61647078015bdea7522a6d.tar.gz
chromium_src-e8d6b9f3973dbef4cc61647078015bdea7522a6d.tar.bz2
Aura - Add NativeThemeAura, extract NativeThemeGtk, add sample widget window.
+ Add native_theme_aura and native_theme_gtk, fix button background colors + Fix native_theme_chromeos instance generation + Rename button-related image resources + Rename class NativeThemeLinux to NativeThemeBase + Add window showing sample widgets BUG=98305 TEST=manual Review URL: http://codereview.chromium.org/8199021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104803 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/render_view_impl.cc4
-rw-r--r--ui/aura_shell/aura_shell.gyp1
-rw-r--r--ui/aura_shell/examples/example_factory.h3
-rw-r--r--ui/aura_shell/examples/widgets.cc141
-rw-r--r--ui/aura_shell/examples/window_type_launcher.cc12
-rw-r--r--ui/aura_shell/examples/window_type_launcher.h1
-rw-r--r--ui/gfx/gfx_resources.grd40
-rw-r--r--ui/gfx/native_theme.h4
-rw-r--r--ui/gfx/native_theme_aura.cc26
-rw-r--r--ui/gfx/native_theme_aura.h25
-rw-r--r--ui/gfx/native_theme_base.cc (renamed from ui/gfx/native_theme_linux.cc)173
-rw-r--r--ui/gfx/native_theme_base.h (renamed from ui/gfx/native_theme_linux.h)37
-rw-r--r--ui/gfx/native_theme_chromeos.cc31
-rw-r--r--ui/gfx/native_theme_chromeos.h8
-rw-r--r--ui/gfx/native_theme_gtk.cc26
-rw-r--r--ui/gfx/native_theme_gtk.h25
-rw-r--r--ui/ui.gyp36
-rw-r--r--views/controls/button/text_button.cc20
-rw-r--r--views/controls/menu/menu_config_win.cc5
-rw-r--r--views/controls/menu/menu_item_view_win.cc5
20 files changed, 473 insertions, 150 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index e146dd8..03a6615 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -3820,7 +3820,9 @@ void RenderViewImpl::OnClosePage() {
}
void RenderViewImpl::OnThemeChanged() {
-#if defined(OS_WIN)
+#if defined(USE_AURA)
+ // Aura doesn't care if we switch themes.
+#elif defined(OS_WIN)
gfx::NativeThemeWin::instance()->CloseHandles();
if (webview())
webview()->themeChanged();
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index 81f4cf7..e3c5d14 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -103,6 +103,7 @@
'examples/lock_view.cc',
'examples/toplevel_window.cc',
'examples/toplevel_window.h',
+ 'examples/widgets.cc',
'examples/window_type_launcher.cc',
'examples/window_type_launcher.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
diff --git a/ui/aura_shell/examples/example_factory.h b/ui/aura_shell/examples/example_factory.h
index b32c11f..7bb34d2 100644
--- a/ui/aura_shell/examples/example_factory.h
+++ b/ui/aura_shell/examples/example_factory.h
@@ -19,6 +19,9 @@ void CreatePointyBubble(gfx::NativeWindow parent, const gfx::Point& origin);
void CreateLock();
+// Creates a window showing samples of commonly used widgets.
+void CreateWidgetsWindow();
+
} // namespace examples
} // namespace aura_shell
diff --git a/ui/aura_shell/examples/widgets.cc b/ui/aura_shell/examples/widgets.cc
new file mode 100644
index 0000000..5dcd12e
--- /dev/null
+++ b/ui/aura_shell/examples/widgets.cc
@@ -0,0 +1,141 @@
+// Copyright (c) 2011 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 "base/utf_string_conversions.h" // ASCIIToUTF16
+#include "ui/aura/window.h"
+#include "ui/aura_shell/toplevel_frame_view.h"
+#include "ui/gfx/canvas.h"
+#include "views/controls/button/checkbox.h"
+#include "views/controls/button/radio_button.h"
+#include "views/controls/button/text_button.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
+
+namespace {
+
+// Default window position.
+const int kWindowLeft = 170;
+const int kWindowTop = 200;
+
+// Default window size.
+const int kWindowWidth = 400;
+const int kWindowHeight = 400;
+
+// A window showing samples of commonly used widgets.
+class WidgetsWindow : public views::WidgetDelegateView {
+ public:
+ WidgetsWindow();
+ virtual ~WidgetsWindow();
+
+ // Overridden from views::View:
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual void Layout() OVERRIDE;
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ // Overridden from views::WidgetDelegate:
+ virtual views::View* GetContentsView() OVERRIDE;
+ virtual string16 GetWindowTitle() const OVERRIDE;
+ virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
+
+ private:
+ views::NativeTextButton* button_;
+ views::NativeTextButton* disabled_button_;
+ views::Checkbox* checkbox_;
+ views::Checkbox* checkbox_disabled_;
+ views::Checkbox* checkbox_checked_;
+ views::Checkbox* checkbox_checked_disabled_;
+ views::RadioButton* radio_button_;
+ views::RadioButton* radio_button_disabled_;
+ views::RadioButton* radio_button_selected_;
+ views::RadioButton* radio_button_selected_disabled_;
+};
+
+WidgetsWindow::WidgetsWindow()
+ : button_(new views::NativeTextButton(NULL, L"Button")),
+ disabled_button_(new views::NativeTextButton(NULL, L"Disabled button")),
+ checkbox_(new views::Checkbox(L"Checkbox")),
+ checkbox_disabled_(new views::Checkbox(L"Checkbox disabled")),
+ checkbox_checked_(new views::Checkbox(L"Checkbox checked")),
+ checkbox_checked_disabled_(
+ new views::Checkbox(L"Checkbox checked disabled")),
+ radio_button_(new views::RadioButton(L"Radio button", 0)),
+ radio_button_disabled_(
+ new views::RadioButton(L"Radio button disabled", 0)),
+ radio_button_selected_(
+ new views::RadioButton(L"Radio button selected", 0)),
+ radio_button_selected_disabled_(
+ new views::RadioButton(L"Radio button selected disabled", 1)) {
+ AddChildView(button_);
+ disabled_button_->SetEnabled(false);
+ AddChildView(disabled_button_);
+ AddChildView(checkbox_);
+ checkbox_disabled_->SetEnabled(false);
+ AddChildView(checkbox_disabled_);
+ checkbox_checked_->SetChecked(true);
+ AddChildView(checkbox_checked_);
+ checkbox_checked_disabled_->SetChecked(true);
+ checkbox_checked_disabled_->SetEnabled(false);
+ AddChildView(checkbox_checked_disabled_);
+ AddChildView(radio_button_);
+ radio_button_disabled_->SetEnabled(false);
+ AddChildView(radio_button_disabled_);
+ radio_button_selected_->SetChecked(true);
+ AddChildView(radio_button_selected_);
+ radio_button_selected_disabled_->SetChecked(true);
+ radio_button_selected_disabled_->SetEnabled(false);
+ AddChildView(radio_button_selected_disabled_);
+}
+
+WidgetsWindow::~WidgetsWindow() {
+}
+
+void WidgetsWindow::OnPaint(gfx::Canvas* canvas) {
+ canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height());
+}
+
+void WidgetsWindow::Layout() {
+ const int kVerticalPad = 5;
+ int left = 5;
+ int top = kVerticalPad;
+ for (Views::const_iterator it = children_begin();
+ it != children_end();
+ ++it) {
+ views::View* view = *it;
+ gfx::Size preferred = view->GetPreferredSize();
+ view->SetBounds(left, top, preferred.width(), preferred.height());
+ top += preferred.height() + kVerticalPad;
+ }
+}
+
+gfx::Size WidgetsWindow::GetPreferredSize() {
+ return gfx::Size(kWindowWidth, kWindowHeight);
+}
+
+views::View* WidgetsWindow::GetContentsView() {
+ return this;
+}
+
+string16 WidgetsWindow::GetWindowTitle() const {
+ return ASCIIToUTF16("Examples: Widgets");
+}
+
+views::NonClientFrameView* WidgetsWindow::CreateNonClientFrameView() {
+ return new aura_shell::internal::ToplevelFrameView;
+}
+
+} // namespace
+
+namespace aura_shell {
+namespace examples {
+
+void CreateWidgetsWindow() {
+ gfx::Rect bounds(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight);
+ views::Widget* widget =
+ views::Widget::CreateWindowWithBounds(new WidgetsWindow, bounds);
+ widget->GetNativeView()->set_name("WidgetsWindow");
+ widget->Show();
+}
+
+} // namespace examples
+} // namespace aura_shell
diff --git a/ui/aura_shell/examples/window_type_launcher.cc b/ui/aura_shell/examples/window_type_launcher.cc
index 9ee649e..2bf5df8 100644
--- a/ui/aura_shell/examples/window_type_launcher.cc
+++ b/ui/aura_shell/examples/window_type_launcher.cc
@@ -41,11 +41,14 @@ WindowTypeLauncher::WindowTypeLauncher()
ALLOW_THIS_IN_INITIALIZER_LIST(bubble_button_(
new views::NativeTextButton(this, L"Create Pointy Bubble"))),
ALLOW_THIS_IN_INITIALIZER_LIST(lock_button_(
- new views::NativeTextButton(this, L"Lock Screen"))) {
+ new views::NativeTextButton(this, L"Lock Screen"))),
+ ALLOW_THIS_IN_INITIALIZER_LIST(widgets_button_(
+ new views::NativeTextButton(this, L"Show Example Widgets"))) {
AddChildView(create_button_);
AddChildView(create_nonresizable_button_);
AddChildView(bubble_button_);
AddChildView(lock_button_);
+ AddChildView(widgets_button_);
set_context_menu_controller(this);
}
@@ -78,6 +81,11 @@ void WindowTypeLauncher::Layout() {
lock_button_->SetBounds(
5, create_nonresizable_button_->y() - lock_ps.height() - 5,
lock_ps.width(), lock_ps.height());
+
+ gfx::Size widgets_ps = widgets_button_->GetPreferredSize();
+ widgets_button_->SetBounds(
+ 5, lock_button_->y() - widgets_ps.height() - 5,
+ widgets_ps.width(), widgets_ps.height());
}
gfx::Size WindowTypeLauncher::GetPreferredSize() {
@@ -120,6 +128,8 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender,
CreatePointyBubble(GetWidget()->GetNativeWindow(), origin);
} else if (sender == lock_button_) {
CreateLock();
+ } else if (sender == widgets_button_) {
+ CreateWidgetsWindow();
}
}
diff --git a/ui/aura_shell/examples/window_type_launcher.h b/ui/aura_shell/examples/window_type_launcher.h
index ff46ffc..c4210a2 100644
--- a/ui/aura_shell/examples/window_type_launcher.h
+++ b/ui/aura_shell/examples/window_type_launcher.h
@@ -65,6 +65,7 @@ class WindowTypeLauncher : public views::WidgetDelegateView,
views::NativeTextButton* create_nonresizable_button_;
views::NativeTextButton* bubble_button_;
views::NativeTextButton* lock_button_;
+ views::NativeTextButton* widgets_button_;
scoped_ptr<views::MenuRunner> menu_runner_;
DISALLOW_COPY_AND_ASSIGN(WindowTypeLauncher);
diff --git a/ui/gfx/gfx_resources.grd b/ui/gfx/gfx_resources.grd
index 297b0a8..3dba7aaa 100644
--- a/ui/gfx/gfx_resources.grd
+++ b/ui/gfx/gfx_resources.grd
@@ -19,23 +19,41 @@
<include name="IDR_BLUR_FX" file="resources\blur.fx" type="BINDATA" />
</if>
- <if expr="is_posix and not is_macosx">
- <include name="IDR_LINUX_CHECKBOX_DISABLED_INDETERMINATE" file="resources\linux-checkbox-disabled-indeterminate.png" type="BINDATA" />
- <include name="IDR_LINUX_CHECKBOX_DISABLED_OFF" file="resources\linux-checkbox-disabled-off.png" type="BINDATA" />
- <include name="IDR_LINUX_CHECKBOX_DISABLED_ON" file="resources\linux-checkbox-disabled-on.png" type="BINDATA" />
- <include name="IDR_LINUX_CHECKBOX_INDETERMINATE" file="resources\linux-checkbox-indeterminate.png" type="BINDATA" />
- <include name="IDR_LINUX_CHECKBOX_OFF" file="resources\linux-checkbox-off.png" type="BINDATA" />
- <include name="IDR_LINUX_CHECKBOX_ON" file="resources\linux-checkbox-on.png" type="BINDATA" />
- <include name="IDR_LINUX_RADIO_DISABLED_OFF" file="resources\linux-radio-disabled-off.png" type="BINDATA" />
- <include name="IDR_LINUX_RADIO_DISABLED_ON" file="resources\linux-radio-disabled-on.png" type="BINDATA" />
- <include name="IDR_LINUX_RADIO_OFF" file="resources\linux-radio-off.png" type="BINDATA" />
- <include name="IDR_LINUX_RADIO_ON" file="resources\linux-radio-on.png" type="BINDATA" />
+ <if expr="is_posix and not is_macosx and not pp_ifdef('use_aura')">
+ <include name="IDR_CHECKBOX_DISABLED_INDETERMINATE" file="resources\linux-checkbox-disabled-indeterminate.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_DISABLED_OFF" file="resources\linux-checkbox-disabled-off.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_DISABLED_ON" file="resources\linux-checkbox-disabled-on.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_INDETERMINATE" file="resources\linux-checkbox-indeterminate.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_OFF" file="resources\linux-checkbox-off.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_ON" file="resources\linux-checkbox-on.png" type="BINDATA" />
+ <include name="IDR_RADIO_DISABLED_OFF" file="resources\linux-radio-disabled-off.png" type="BINDATA" />
+ <include name="IDR_RADIO_DISABLED_ON" file="resources\linux-radio-disabled-on.png" type="BINDATA" />
+ <include name="IDR_RADIO_OFF" file="resources\linux-radio-off.png" type="BINDATA" />
+ <include name="IDR_RADIO_ON" file="resources\linux-radio-on.png" type="BINDATA" />
<include name="IDR_PROGRESS_BAR" file="resources\linux-progress-bar.png" type="BINDATA" />
<include name="IDR_PROGRESS_BORDER_LEFT" file="resources\linux-progress-border-left.png" type="BINDATA" />
<include name="IDR_PROGRESS_BORDER_RIGHT" file="resources\linux-progress-border-right.png" type="BINDATA" />
<include name="IDR_PROGRESS_VALUE" file="resources\linux-progress-value.png" type="BINDATA" />
</if>
+ <!-- TODO(jamescook): Replace Linux images with Aura-specific ones. -->
+ <if expr="pp_ifdef('use_aura')">
+ <include name="IDR_CHECKBOX_DISABLED_INDETERMINATE" file="resources\linux-checkbox-disabled-indeterminate.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_DISABLED_OFF" file="resources\linux-checkbox-disabled-off.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_DISABLED_ON" file="resources\linux-checkbox-disabled-on.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_INDETERMINATE" file="resources\linux-checkbox-indeterminate.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_OFF" file="resources\linux-checkbox-off.png" type="BINDATA" />
+ <include name="IDR_CHECKBOX_ON" file="resources\linux-checkbox-on.png" type="BINDATA" />
+ <include name="IDR_RADIO_DISABLED_OFF" file="resources\linux-radio-disabled-off.png" type="BINDATA" />
+ <include name="IDR_RADIO_DISABLED_ON" file="resources\linux-radio-disabled-on.png" type="BINDATA" />
+ <include name="IDR_RADIO_OFF" file="resources\linux-radio-off.png" type="BINDATA" />
+ <include name="IDR_RADIO_ON" file="resources\linux-radio-on.png" type="BINDATA" />
+ <include name="IDR_PROGRESS_BAR" file="resources\linux-progress-bar.png" type="BINDATA" />
+ <include name="IDR_PROGRESS_BORDER_LEFT" file="resources\linux-progress-border-left.png" type="BINDATA" />
+ <include name="IDR_PROGRESS_BORDER_RIGHT" file="resources\linux-progress-border-right.png" type="BINDATA" />
+ <include name="IDR_PROGRESS_VALUE" file="resources\linux-progress-value.png" type="BINDATA" />
+ </if>
+
<!-- Images only used by ChromeOS. -->
<if expr="pp_ifdef('chromeos')">
<include name="IDR_SCROLL_ARROW_DOWN" file="resources\chromeos_scroll_arrow_down.png" type="BINDATA" />
diff --git a/ui/gfx/native_theme.h b/ui/gfx/native_theme.h
index da858a3..cc9aa35 100644
--- a/ui/gfx/native_theme.h
+++ b/ui/gfx/native_theme.h
@@ -213,8 +213,10 @@ class UI_EXPORT NativeTheme {
unsigned track_color) const;
// Returns a shared instance of the native theme.
- // The retuned object should not be deleted by the caller. This function
+ // The returned object should not be deleted by the caller. This function
// is not thread safe and should only be called from the UI thread.
+ // Each port of NativeTheme should provide its own implementation of this
+ // function, returning the port's subclass.
static const NativeTheme* instance();
protected:
diff --git a/ui/gfx/native_theme_aura.cc b/ui/gfx/native_theme_aura.cc
new file mode 100644
index 0000000..74691ef
--- /dev/null
+++ b/ui/gfx/native_theme_aura.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2011 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/gfx/native_theme_aura.h"
+
+namespace gfx {
+
+// static
+const NativeTheme* NativeTheme::instance() {
+ return NativeThemeAura::instance();
+}
+
+// static
+const NativeThemeAura* NativeThemeAura::instance() {
+ static const NativeThemeAura s_native_theme;
+ return &s_native_theme;
+}
+
+NativeThemeAura::NativeThemeAura() {
+}
+
+NativeThemeAura::~NativeThemeAura() {
+}
+
+} // namespace gfx
diff --git a/ui/gfx/native_theme_aura.h b/ui/gfx/native_theme_aura.h
new file mode 100644
index 0000000..97c6450
--- /dev/null
+++ b/ui/gfx/native_theme_aura.h
@@ -0,0 +1,25 @@
+// Copyright (c) 2011 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_GFX_NATIVE_THEME_AURA_H_
+#define UI_GFX_NATIVE_THEME_AURA_H_
+#pragma once
+
+#include "ui/gfx/native_theme_base.h"
+
+namespace gfx {
+
+// Aura implementation of native theme support.
+class NativeThemeAura : public NativeThemeBase {
+ public:
+ static const NativeThemeAura* instance();
+
+ private:
+ NativeThemeAura();
+ virtual ~NativeThemeAura();
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_NATIVE_THEME_AURA_H_
diff --git a/ui/gfx/native_theme_linux.cc b/ui/gfx/native_theme_base.cc
index 5ab5fb0..bc00f10 100644
--- a/ui/gfx/native_theme_linux.cc
+++ b/ui/gfx/native_theme_base.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gfx/native_theme_linux.h"
+#include "ui/gfx/native_theme_base.h"
#include <limits>
@@ -16,11 +16,11 @@
namespace gfx {
-unsigned int NativeThemeLinux::button_length_ = 14;
+unsigned int NativeThemeBase::button_length_ = 14;
#if defined(TOUCH_UI)
-unsigned int NativeThemeLinux::scrollbar_width_ = 0;
+unsigned int NativeThemeBase::scrollbar_width_ = 0;
#else
-unsigned int NativeThemeLinux::scrollbar_width_ = 15;
+unsigned int NativeThemeBase::scrollbar_width_ = 15;
#endif
// These are the default dimensions of radio buttons and checkboxes.
@@ -38,21 +38,6 @@ static const SkColor kSliderThumbDarkGrey = SkColorSetRGB(0xea, 0xe5, 0xe0);
static const SkColor kSliderThumbBorderDarkGrey =
SkColorSetRGB(0x9d, 0x96, 0x8e);
-// static
-const NativeTheme* NativeTheme::instance() {
- return NativeThemeLinux::instance();
-}
-
-#if !defined(OS_CHROMEOS)
-// Chromeos has a different look.
-// static
-const NativeThemeLinux* NativeThemeLinux::instance() {
- // The global NativeThemeLinux instance.
- static NativeThemeLinux s_native_theme;
- return &s_native_theme;
-}
-#endif
-
// Get lightness adjusted color.
static SkColor BrightenColor(const color_utils::HSL& hsl, SkAlpha alpha,
double lightness_amount) {
@@ -66,15 +51,15 @@ static SkColor BrightenColor(const color_utils::HSL& hsl, SkAlpha alpha,
return color_utils::HSLToSkColor(adjusted, alpha);
}
-NativeThemeLinux::NativeThemeLinux() {
+NativeThemeBase::NativeThemeBase() {
}
-NativeThemeLinux::~NativeThemeLinux() {
+NativeThemeBase::~NativeThemeBase() {
}
-gfx::Size NativeThemeLinux::GetPartSize(Part part,
- State state,
- const ExtraParams& extra) const {
+gfx::Size NativeThemeBase::GetPartSize(Part part,
+ State state,
+ const ExtraParams& extra) const {
switch (part) {
case kScrollbarDownArrow:
case kScrollbarUpArrow:
@@ -114,7 +99,7 @@ gfx::Size NativeThemeLinux::GetPartSize(Part part,
return gfx::Size();
}
-void NativeThemeLinux::PaintArrowButton(
+void NativeThemeBase::PaintArrowButton(
SkCanvas* canvas,
const gfx::Rect& rect, Part direction, State state) const {
int widthMiddle, lengthMiddle;
@@ -130,16 +115,16 @@ void NativeThemeLinux::PaintArrowButton(
// Calculate button color.
SkScalar trackHSV[3];
SkColorToHSV(track_color_, trackHSV);
- SkColor buttonColor = SaturateAndBrighten(trackHSV, 0, 0.2);
+ SkColor buttonColor = SaturateAndBrighten(trackHSV, 0, 0.2f);
SkColor backgroundColor = buttonColor;
if (state == kPressed) {
SkScalar buttonHSV[3];
SkColorToHSV(buttonColor, buttonHSV);
- buttonColor = SaturateAndBrighten(buttonHSV, 0, -0.1);
+ buttonColor = SaturateAndBrighten(buttonHSV, 0, -0.1f);
} else if (state == kHovered) {
SkScalar buttonHSV[3];
SkColorToHSV(buttonColor, buttonHSV);
- buttonColor = SaturateAndBrighten(buttonHSV, 0, 0.05);
+ buttonColor = SaturateAndBrighten(buttonHSV, 0, 0.05f);
}
SkIRect skrect;
@@ -240,11 +225,11 @@ void NativeThemeLinux::PaintArrowButton(
canvas->drawPath(path, paint);
}
-void NativeThemeLinux::Paint(SkCanvas* canvas,
- Part part,
- State state,
- const gfx::Rect& rect,
- const ExtraParams& extra) const {
+void NativeThemeBase::Paint(SkCanvas* canvas,
+ Part part,
+ State state,
+ const gfx::Rect& rect,
+ const ExtraParams& extra) const {
switch (part) {
case kScrollbarDownArrow:
case kScrollbarUpArrow:
@@ -293,7 +278,7 @@ void NativeThemeLinux::Paint(SkCanvas* canvas,
}
}
-void NativeThemeLinux::PaintScrollbarTrack(SkCanvas* canvas,
+void NativeThemeBase::PaintScrollbarTrack(SkCanvas* canvas,
Part part,
State state,
const ScrollbarTrackExtraParams& extra_params,
@@ -314,7 +299,7 @@ void NativeThemeLinux::PaintScrollbarTrack(SkCanvas* canvas,
DrawBox(canvas, rect, paint);
}
-void NativeThemeLinux::PaintScrollbarThumb(SkCanvas* canvas,
+void NativeThemeBase::PaintScrollbarThumb(SkCanvas* canvas,
Part part,
State state,
const gfx::Rect& rect) const {
@@ -327,7 +312,7 @@ void NativeThemeLinux::PaintScrollbarThumb(SkCanvas* canvas,
SkColorToHSV(hovered ? thumb_active_color_ : thumb_inactive_color_, thumb);
SkPaint paint;
- paint.setColor(SaturateAndBrighten(thumb, 0, 0.02));
+ paint.setColor(SaturateAndBrighten(thumb, 0, 0.02f));
SkIRect skrect;
if (vertical)
@@ -337,7 +322,7 @@ void NativeThemeLinux::PaintScrollbarThumb(SkCanvas* canvas,
canvas->drawIRect(skrect, paint);
- paint.setColor(SaturateAndBrighten(thumb, 0, -0.02));
+ paint.setColor(SaturateAndBrighten(thumb, 0, -0.02f));
if (vertical) {
skrect.set(
@@ -393,24 +378,24 @@ void NativeThemeLinux::PaintScrollbarThumb(SkCanvas* canvas,
}
}
-void NativeThemeLinux::PaintCheckbox(SkCanvas* canvas,
- State state,
- const gfx::Rect& rect,
- const ButtonExtraParams& button) const {
+void NativeThemeBase::PaintCheckbox(SkCanvas* canvas,
+ State state,
+ const gfx::Rect& rect,
+ const ButtonExtraParams& button) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* image = NULL;
if (button.indeterminate) {
image = state == kDisabled ?
- rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_INDETERMINATE) :
- rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_INDETERMINATE);
+ rb.GetBitmapNamed(IDR_CHECKBOX_DISABLED_INDETERMINATE) :
+ rb.GetBitmapNamed(IDR_CHECKBOX_INDETERMINATE);
} else if (button.checked) {
image = state == kDisabled ?
- rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_ON) :
- rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_ON);
+ rb.GetBitmapNamed(IDR_CHECKBOX_DISABLED_ON) :
+ rb.GetBitmapNamed(IDR_CHECKBOX_ON);
} else {
image = state == kDisabled ?
- rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_DISABLED_OFF) :
- rb.GetBitmapNamed(IDR_LINUX_CHECKBOX_OFF);
+ rb.GetBitmapNamed(IDR_CHECKBOX_DISABLED_OFF) :
+ rb.GetBitmapNamed(IDR_CHECKBOX_OFF);
}
gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height()));
@@ -418,7 +403,7 @@ void NativeThemeLinux::PaintCheckbox(SkCanvas* canvas,
bounds.x(), bounds.y(), bounds.width(), bounds.height());
}
-void NativeThemeLinux::PaintRadio(SkCanvas* canvas,
+void NativeThemeBase::PaintRadio(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const {
@@ -426,12 +411,12 @@ void NativeThemeLinux::PaintRadio(SkCanvas* canvas,
SkBitmap* image = NULL;
if (state == kDisabled) {
image = button.checked ?
- rb.GetBitmapNamed(IDR_LINUX_RADIO_DISABLED_ON) :
- rb.GetBitmapNamed(IDR_LINUX_RADIO_DISABLED_OFF);
+ rb.GetBitmapNamed(IDR_RADIO_DISABLED_ON) :
+ rb.GetBitmapNamed(IDR_RADIO_DISABLED_OFF);
} else {
image = button.checked ?
- rb.GetBitmapNamed(IDR_LINUX_RADIO_ON) :
- rb.GetBitmapNamed(IDR_LINUX_RADIO_OFF);
+ rb.GetBitmapNamed(IDR_RADIO_ON) :
+ rb.GetBitmapNamed(IDR_RADIO_OFF);
}
gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height()));
@@ -439,7 +424,7 @@ void NativeThemeLinux::PaintRadio(SkCanvas* canvas,
bounds.x(), bounds.y(), bounds.width(), bounds.height());
}
-void NativeThemeLinux::PaintButton(SkCanvas* canvas,
+void NativeThemeBase::PaintButton(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const {
@@ -508,10 +493,10 @@ void NativeThemeLinux::PaintButton(SkCanvas* canvas,
}
}
-void NativeThemeLinux::PaintTextField(SkCanvas* canvas,
- State state,
- const gfx::Rect& rect,
- const TextFieldExtraParams& text) const {
+void NativeThemeBase::PaintTextField(SkCanvas* canvas,
+ State state,
+ const gfx::Rect& rect,
+ const TextFieldExtraParams& text) const {
// The following drawing code simulates the user-agent css border for
// text area and text input so that we do not break layout tests. Once we
// have decided the desired looks, we should update the code here and
@@ -598,7 +583,7 @@ void NativeThemeLinux::PaintTextField(SkCanvas* canvas,
}
}
-void NativeThemeLinux::PaintMenuList(
+void NativeThemeBase::PaintMenuList(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
@@ -625,10 +610,10 @@ void NativeThemeLinux::PaintMenuList(
canvas->drawPath(path, paint);
}
-void NativeThemeLinux::PaintSliderTrack(SkCanvas* canvas,
- State state,
- const gfx::Rect& rect,
- const SliderExtraParams& slider) const {
+void NativeThemeBase::PaintSliderTrack(SkCanvas* canvas,
+ State state,
+ const gfx::Rect& rect,
+ const SliderExtraParams& slider) const {
const int kMidX = rect.x() + rect.width() / 2;
const int kMidY = rect.y() + rect.height() / 2;
@@ -650,10 +635,10 @@ void NativeThemeLinux::PaintSliderTrack(SkCanvas* canvas,
canvas->drawRect(skrect, paint);
}
-void NativeThemeLinux::PaintSliderThumb(SkCanvas* canvas,
- State state,
- const gfx::Rect& rect,
- const SliderExtraParams& slider) const {
+void NativeThemeBase::PaintSliderThumb(SkCanvas* canvas,
+ State state,
+ const gfx::Rect& rect,
+ const SliderExtraParams& slider) const {
const bool hovered = (state == kHovered) || slider.in_drag;
const int kMidX = rect.x() + rect.width() / 2;
const int kMidY = rect.y() + rect.height() / 2;
@@ -688,7 +673,7 @@ void NativeThemeLinux::PaintSliderThumb(SkCanvas* canvas,
}
}
-void NativeThemeLinux::PaintInnerSpinButton(SkCanvas* canvas,
+void NativeThemeBase::PaintInnerSpinButton(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const InnerSpinButtonExtraParams& spin_button) const {
@@ -710,7 +695,7 @@ void NativeThemeLinux::PaintInnerSpinButton(SkCanvas* canvas,
PaintArrowButton(canvas, half, kScrollbarDownArrow, south_state);
}
-void NativeThemeLinux::PaintProgressBar(SkCanvas* canvas,
+void NativeThemeBase::PaintProgressBar(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ProgressBarExtraParams& progress_bar) const {
@@ -762,7 +747,7 @@ void NativeThemeLinux::PaintProgressBar(SkCanvas* canvas,
canvas->drawBitmapRect(*right_border_image, NULL, dest_rect);
}
-bool NativeThemeLinux::IntersectsClipRectInt(
+bool NativeThemeBase::IntersectsClipRectInt(
SkCanvas* canvas, int x, int y, int w, int h) const {
SkRect clip;
return canvas->getClipBounds(&clip) &&
@@ -770,29 +755,29 @@ bool NativeThemeLinux::IntersectsClipRectInt(
SkIntToScalar(y + h));
}
-void NativeThemeLinux::DrawVertLine(SkCanvas* canvas,
- int x,
- int y1,
- int y2,
- const SkPaint& paint) const {
+void NativeThemeBase::DrawVertLine(SkCanvas* canvas,
+ int x,
+ int y1,
+ int y2,
+ const SkPaint& paint) const {
SkIRect skrect;
skrect.set(x, y1, x + 1, y2 + 1);
canvas->drawIRect(skrect, paint);
}
-void NativeThemeLinux::DrawHorizLine(SkCanvas* canvas,
- int x1,
- int x2,
- int y,
- const SkPaint& paint) const {
+void NativeThemeBase::DrawHorizLine(SkCanvas* canvas,
+ int x1,
+ int x2,
+ int y,
+ const SkPaint& paint) const {
SkIRect skrect;
skrect.set(x1, y, x2 + 1, y + 1);
canvas->drawIRect(skrect, paint);
}
-void NativeThemeLinux::DrawBox(SkCanvas* canvas,
- const gfx::Rect& rect,
- const SkPaint& paint) const {
+void NativeThemeBase::DrawBox(SkCanvas* canvas,
+ const gfx::Rect& rect,
+ const SkPaint& paint) const {
const int right = rect.x() + rect.width() - 1;
const int bottom = rect.y() + rect.height() - 1;
DrawHorizLine(canvas, rect.x(), right, rect.y(), paint);
@@ -801,7 +786,7 @@ void NativeThemeLinux::DrawBox(SkCanvas* canvas,
DrawVertLine(canvas, rect.x(), rect.y(), bottom, paint);
}
-void NativeThemeLinux::DrawBitmapInt(
+void NativeThemeBase::DrawBitmapInt(
SkCanvas* canvas, const SkBitmap& bitmap,
int src_x, int src_y, int src_w, int src_h,
int dest_x, int dest_y, int dest_w, int dest_h) const {
@@ -850,7 +835,7 @@ void NativeThemeLinux::DrawBitmapInt(
canvas->drawRect(dest_rect, p);
}
-void NativeThemeLinux::DrawTiledImage(SkCanvas* canvas,
+void NativeThemeBase::DrawTiledImage(SkCanvas* canvas,
const SkBitmap& bitmap,
int src_x, int src_y, double tile_scale_x, double tile_scale_y,
int dest_x, int dest_y, int w, int h) const {
@@ -879,15 +864,15 @@ void NativeThemeLinux::DrawTiledImage(SkCanvas* canvas,
canvas->restore();
}
-SkScalar NativeThemeLinux::Clamp(SkScalar value,
- SkScalar min,
- SkScalar max) const {
+SkScalar NativeThemeBase::Clamp(SkScalar value,
+ SkScalar min,
+ SkScalar max) const {
return std::min(std::max(value, min), max);
}
-SkColor NativeThemeLinux::SaturateAndBrighten(SkScalar* hsv,
- SkScalar saturate_amount,
- SkScalar brighten_amount) const {
+SkColor NativeThemeBase::SaturateAndBrighten(SkScalar* hsv,
+ SkScalar saturate_amount,
+ SkScalar brighten_amount) const {
SkScalar color[3];
color[0] = hsv[0];
color[1] = Clamp(hsv[1] + saturate_amount, 0.0, 1.0);
@@ -895,7 +880,7 @@ SkColor NativeThemeLinux::SaturateAndBrighten(SkScalar* hsv,
return SkHSVToColor(color);
}
-SkColor NativeThemeLinux::OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const {
+SkColor NativeThemeBase::OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const {
// GTK Theme engines have way too much control over the layout of
// the scrollbar. We might be able to more closely approximate its
// look-and-feel, if we sent whole images instead of just colors
@@ -923,13 +908,13 @@ SkColor NativeThemeLinux::OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const {
//
// The following code has been tested to look OK with all of the
// default GTK themes.
- SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5);
- SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5);
+ SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
+ SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
if (hsv1[2] + hsv2[2] > 1.0)
diff = -diff;
- return SaturateAndBrighten(hsv2, -0.2, diff);
+ return SaturateAndBrighten(hsv2, -0.2f, diff);
}
} // namespace gfx
diff --git a/ui/gfx/native_theme_linux.h b/ui/gfx/native_theme_base.h
index 6af1b2f..3a29700 100644
--- a/ui/gfx/native_theme_linux.h
+++ b/ui/gfx/native_theme_base.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_GFX_NATIVE_THEME_LINUX_H_
-#define UI_GFX_NATIVE_THEME_LINUX_H_
+#ifndef UI_GFX_NATIVE_THEME_BASE_H_
+#define UI_GFX_NATIVE_THEME_BASE_H_
#include "base/basictypes.h"
#include "skia/ext/platform_canvas.h"
@@ -13,12 +13,9 @@ namespace gfx {
class Rect;
class Size;
-// Linux theming API.
-class NativeThemeLinux : public NativeTheme {
+// Theme support for non-Windows toolkits.
+class NativeThemeBase : public NativeTheme {
public:
- // Gets our singleton instance.
- static const NativeThemeLinux* instance();
-
// NativeTheme implementation:
virtual gfx::Size GetPartSize(Part part,
State state,
@@ -30,8 +27,8 @@ class NativeThemeLinux : public NativeTheme {
const ExtraParams& extra) const;
protected:
- NativeThemeLinux();
- virtual ~NativeThemeLinux();
+ NativeThemeBase();
+ virtual ~NativeThemeBase();
// Draw the arrow. Used by scrollbar and inner spin button.
virtual void PaintArrowButton(
@@ -51,47 +48,47 @@ class NativeThemeLinux : public NativeTheme {
Part part,
State state,
const gfx::Rect& rect) const;
- // Draw the checkbox.
+
virtual void PaintCheckbox(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const;
- // Draw the radio.
+
virtual void PaintRadio(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const;
- // Draw the push button.
+
virtual void PaintButton(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const;
- // Draw the text field.
+
virtual void PaintTextField(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const TextFieldExtraParams& text) const;
- // Draw the menu list.
+
virtual void PaintMenuList(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const MenuListExtraParams& menu_list) const;
- // Draw the slider track.
+
virtual void PaintSliderTrack(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const SliderExtraParams& slider) const;
- // Draw the slider thumb.
+
virtual void PaintSliderThumb(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const SliderExtraParams& slider) const;
- // Draw the inner spin button.
+
virtual void PaintInnerSpinButton(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const InnerSpinButtonExtraParams& spin_button) const;
- // Draw the progress bar.
+
virtual void PaintProgressBar(SkCanvas* canvas,
State state,
const gfx::Rect& rect,
@@ -137,9 +134,9 @@ class NativeThemeLinux : public NativeTheme {
static unsigned int scrollbar_width_;
static unsigned int button_length_;
- DISALLOW_COPY_AND_ASSIGN(NativeThemeLinux);
+ DISALLOW_COPY_AND_ASSIGN(NativeThemeBase);
};
} // namespace gfx
-#endif // UI_GFX_NATIVE_THEME_LINUX_H_
+#endif // UI_GFX_NATIVE_THEME_BASE_H_
diff --git a/ui/gfx/native_theme_chromeos.cc b/ui/gfx/native_theme_chromeos.cc
index a12b45f..06f82d4 100644
--- a/ui/gfx/native_theme_chromeos.cc
+++ b/ui/gfx/native_theme_chromeos.cc
@@ -130,9 +130,9 @@ void GetGradientPaintForRect(const gfx::Rect& rect,
}
void GetButtonGradientPaint(const gfx::Rect bounds,
- gfx::NativeThemeLinux::State state,
+ gfx::NativeThemeBase::State state,
SkPaint* paint) {
- if (state == gfx::NativeThemeLinux::kPressed) {
+ if (state == gfx::NativeThemeBase::kPressed) {
static const SkColor kGradientColors[2] = {
kPressedGradient0,
kPressedGradient1
@@ -171,29 +171,29 @@ void GetStrokePaint(SkColor color, SkPaint* paint) {
paint->setColor(color);
}
-void GetStrokePaint(gfx::NativeThemeLinux::State state, SkPaint* paint) {
+void GetStrokePaint(gfx::NativeThemeBase::State state, SkPaint* paint) {
- if (state == gfx::NativeThemeLinux::kDisabled)
+ if (state == gfx::NativeThemeBase::kDisabled)
GetStrokePaint(kDisabledBaseStroke, paint);
else
GetStrokePaint(kBaseStroke, paint);
}
-void GetIndicatorStrokePaint(gfx::NativeThemeLinux::State state,
+void GetIndicatorStrokePaint(gfx::NativeThemeBase::State state,
SkPaint* paint) {
paint->setStyle(SkPaint::kStroke_Style);
paint->setAntiAlias(true);
- if (state == gfx::NativeThemeLinux::kDisabled)
+ if (state == gfx::NativeThemeBase::kDisabled)
paint->setColor(kIndicatorStrokeDisabledColor);
- else if (state == gfx::NativeThemeLinux::kPressed)
+ else if (state == gfx::NativeThemeBase::kPressed)
paint->setColor(kIndicatorStrokePressedColor);
else
paint->setColor(kIndicatorStrokeColor);
}
void GetRadioIndicatorGradientPaint(const gfx::Rect bounds,
- gfx::NativeThemeLinux::State state,
+ gfx::NativeThemeBase::State state,
SkPaint* paint) {
paint->setStyle(SkPaint::kFill_Style);
paint->setAntiAlias(true);
@@ -207,7 +207,7 @@ void GetRadioIndicatorGradientPaint(const gfx::Rect bounds,
SkIntToScalar(1)
};
- if (state == gfx::NativeThemeLinux::kDisabled) {
+ if (state == gfx::NativeThemeBase::kDisabled) {
static const SkColor kGradientColors[2] = {
kRadioIndicatorDisabledGradient0,
kRadioIndicatorDisabledGradient1
@@ -230,8 +230,13 @@ void GetRadioIndicatorGradientPaint(const gfx::Rect bounds,
} // namespace
-/* static */
-const gfx::NativeThemeLinux* gfx::NativeThemeLinux::instance() {
+// static
+const gfx::NativeTheme* gfx::NativeTheme::instance() {
+ return NativeThemeChromeos::instance();
+}
+
+// static
+const NativeThemeChromeos* NativeThemeChromeos::instance() {
// The global NativeThemeChromeos instance.
static NativeThemeChromeos s_native_theme;
return &s_native_theme;
@@ -296,7 +301,7 @@ gfx::Size NativeThemeChromeos::GetPartSize(Part part,
case kInnerSpinButton:
return gfx::Size(kScrollbarWidth, 0);
default:
- return NativeThemeLinux::GetPartSize(part, state, extra);
+ return NativeThemeBase::GetPartSize(part, state, extra);
}
return gfx::Size(width, height);
}
@@ -572,7 +577,7 @@ void NativeThemeChromeos::PaintInnerSpinButton(SkCanvas* canvas,
gfx::Rect bounds = rect;
bounds.Inset(0, -1, -1, -1);
- NativeThemeLinux::PaintInnerSpinButton(canvas, state, bounds, spin_button);
+ NativeThemeBase::PaintInnerSpinButton(canvas, state, bounds, spin_button);
}
void NativeThemeChromeos::PaintProgressBar(SkCanvas* canvas,
diff --git a/ui/gfx/native_theme_chromeos.h b/ui/gfx/native_theme_chromeos.h
index 1e1b84f..f486609 100644
--- a/ui/gfx/native_theme_chromeos.h
+++ b/ui/gfx/native_theme_chromeos.h
@@ -7,13 +7,15 @@
#include <map>
#include "base/compiler_specific.h"
-#include "ui/gfx/native_theme_linux.h"
+#include "ui/gfx/native_theme_base.h"
class SkBitmap;
-class NativeThemeChromeos : public gfx::NativeThemeLinux {
+class NativeThemeChromeos : public gfx::NativeThemeBase {
+ public:
+ static const NativeThemeChromeos* instance();
+
private:
- friend class NativeThemeLinux;
NativeThemeChromeos();
virtual ~NativeThemeChromeos();
diff --git a/ui/gfx/native_theme_gtk.cc b/ui/gfx/native_theme_gtk.cc
new file mode 100644
index 0000000..00ddc5f
--- /dev/null
+++ b/ui/gfx/native_theme_gtk.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2011 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/gfx/native_theme_gtk.h"
+
+namespace gfx {
+
+// static
+const NativeTheme* NativeTheme::instance() {
+ return NativeThemeGtk::instance();
+}
+
+// static
+const NativeThemeGtk* NativeThemeGtk::instance() {
+ static const NativeThemeGtk s_native_theme;
+ return &s_native_theme;
+}
+
+NativeThemeGtk::NativeThemeGtk() {
+}
+
+NativeThemeGtk::~NativeThemeGtk() {
+}
+
+} // namespace gfx
diff --git a/ui/gfx/native_theme_gtk.h b/ui/gfx/native_theme_gtk.h
new file mode 100644
index 0000000..81acf9c
--- /dev/null
+++ b/ui/gfx/native_theme_gtk.h
@@ -0,0 +1,25 @@
+// Copyright (c) 2011 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_GFX_NATIVE_THEME_GTK_H_
+#define UI_GFX_NATIVE_THEME_GTK_H_
+#pragma once
+
+#include "ui/gfx/native_theme_base.h"
+
+namespace gfx {
+
+// GTK implementation of native theme support.
+class NativeThemeGtk : public NativeThemeBase {
+ public:
+ static const NativeThemeGtk* instance();
+
+ private:
+ NativeThemeGtk();
+ virtual ~NativeThemeGtk();
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_NATIVE_THEME_GTK_H_
diff --git a/ui/ui.gyp b/ui/ui.gyp
index b35468e..ce4557b 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -255,6 +255,16 @@
'gfx/mac/scoped_ns_disable_screen_updates.h',
'gfx/native_theme.cc',
'gfx/native_theme.h',
+ 'gfx/native_theme_aura.cc',
+ 'gfx/native_theme_aura.h',
+ 'gfx/native_theme_base.cc',
+ 'gfx/native_theme_base.h',
+ 'gfx/native_theme_chromeos.cc',
+ 'gfx/native_theme_chromeos.h',
+ 'gfx/native_theme_gtk.cc',
+ 'gfx/native_theme_gtk.h',
+ 'gfx/native_theme_win.cc',
+ 'gfx/native_theme_win.h',
'gfx/native_widget_types.h',
'gfx/pango_util.h',
'gfx/pango_util.cc',
@@ -317,10 +327,17 @@
['exclude', 'base/x/active_window_watcher_x.cc'],
['exclude', 'base/x/active_window_watcher_x.h'],
],
+ }, { # use_aura!=1
+ 'sources!': [
+ 'gfx/native_theme_aura.cc',
+ 'gfx/native_theme_aura.h',
+ ]
}],
['use_aura==1 and OS=="win"', {
'sources/': [
['exclude', 'base/dragdrop/os_exchange_data_provider_aura.cc'],
+ ['exclude', 'gfx/native_theme_win.cc'],
+ ['exclude', 'gfx/native_theme_win.h'],
['exclude', 'gfx/path_win.cc'],
],
}],
@@ -336,8 +353,6 @@
'sources': [
'gfx/linux_util.cc',
'gfx/linux_util.h',
- 'gfx/native_theme_linux.cc',
- 'gfx/native_theme_linux.h',
],
'link_settings': {
'libraries': [
@@ -379,6 +394,11 @@
'sources!': [
'base/clipboard/clipboard_aura.cc',
],
+ }, { # toolkit_uses_gtk != 1
+ 'sources!': [
+ 'gfx/native_theme_gtk.cc',
+ 'gfx/native_theme_gtk.h',
+ ]
}],
['use_wayland == 1', {
'sources/': [
@@ -456,6 +476,8 @@
'base/dragdrop/os_exchange_data.cc',
'base/view_prop.cc',
'base/view_prop.h',
+ 'gfx/native_theme_win.cc',
+ 'gfx/native_theme_win.h',
],
'sources/': [
['exclude', '^base/win/*'],
@@ -502,10 +524,16 @@
],
}],
['chromeos==1', {
- 'sources': [
+ # On Chrome OS we replace the default GTK look with a special look.
+ 'sources!': [
+ 'gfx/native_theme_gtk.cc',
+ 'gfx/native_theme_gtk.h',
+ ]
+ }, { # chromeos != 1
+ 'sources!': [
'gfx/native_theme_chromeos.cc',
'gfx/native_theme_chromeos.h',
- ],
+ ]
}],
['toolkit_views==0', {
'sources!': [
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index bd1ad86..58c0030 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -43,6 +43,19 @@ static const int kPreferredPaddingVertical = 5;
static const int kPreferredNativeThemePaddingHorizontal = 12;
static const int kPreferredNativeThemePaddingVertical = 5;
+// Default background color for buttons.
+const SkColor kBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde);
+
+#if defined(USE_AURA)
+// static
+const SkColor TextButtonBase::kEnabledColor = SkColorSetRGB(0x44, 0x44, 0x44);
+// static
+const SkColor TextButtonBase::kHighlightColor = SkColorSetRGB(0, 0, 0);
+// static
+const SkColor TextButtonBase::kDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99);
+// static
+const SkColor TextButtonBase::kHoverColor = TextButton::kEnabledColor;
+#else // !defined(USE_AURA)
// static
const SkColor TextButtonBase::kEnabledColor = SkColorSetRGB(6, 45, 117);
// static
@@ -52,6 +65,7 @@ const SkColor TextButtonBase::kHighlightColor =
const SkColor TextButtonBase::kDisabledColor = SkColorSetRGB(161, 161, 146);
// static
const SkColor TextButtonBase::kHoverColor = TextButton::kEnabledColor;
+#endif // defined(USE_AURA)
// How long the hover fade animation should last.
static const int kHoverAnimationDurationMs = 170;
@@ -449,7 +463,7 @@ void TextButtonBase::GetExtraParams(
params->button.is_default = false;
params->button.has_border = false;
params->button.classic_state = 0;
- params->button.background_color = kEnabledColor;
+ params->button.background_color = kBackgroundColor;
}
gfx::Rect TextButtonBase::GetContentBounds(int extra_width) const {
@@ -609,7 +623,9 @@ gfx::NativeTheme::State TextButtonBase::GetThemeState(
}
const ui::Animation* TextButtonBase::GetThemeAnimation() const {
-#if defined(OS_WIN)
+#if defined(USE_AURA)
+ return hover_animation_.get();
+#elif defined(OS_WIN)
return gfx::NativeThemeWin::instance()->IsThemingActive()
? hover_animation_.get() : NULL;
#else
diff --git a/views/controls/menu/menu_config_win.cc b/views/controls/menu/menu_config_win.cc
index 869d131..762b7a5 100644
--- a/views/controls/menu/menu_config_win.cc
+++ b/views/controls/menu/menu_config_win.cc
@@ -23,9 +23,14 @@ namespace views {
MenuConfig* MenuConfig::Create() {
MenuConfig* config = new MenuConfig();
+ // TODO(jamescook): Create menu_config_aura.cc instead.
+#if defined(USE_AURA)
+ config->text_color = SK_ColorBLACK;
+#else
config->text_color = NativeThemeWin::instance()->GetThemeColorWithDefault(
NativeThemeWin::MENU, MENU_POPUPITEM, MPI_NORMAL, TMT_TEXTCOLOR,
COLOR_MENUTEXT);
+#endif
NONCLIENTMETRICS metrics;
base::win::GetNonClientMetrics(&metrics);
diff --git a/views/controls/menu/menu_item_view_win.cc b/views/controls/menu/menu_item_view_win.cc
index 1755617..f3b38a9 100644
--- a/views/controls/menu/menu_item_view_win.cc
+++ b/views/controls/menu/menu_item_view_win.cc
@@ -95,9 +95,14 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
// Render the foreground.
// Menu color is specific to Vista, fallback to classic colors if can't
// get color.
+#if defined(USE_AURA)
+ // TODO(jamescook): Create menu_item_view_aura.cc
+ SkColor fg_color = SK_ColorBLACK;
+#else
SkColor fg_color = gfx::NativeThemeWin::instance()->GetThemeColorWithDefault(
gfx::NativeThemeWin::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR,
default_sys_color);
+#endif
const gfx::Font& font = GetFont();
int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
int width = this->width() - item_right_margin_ - label_start_ - accel_width;