summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/native_theme/native_theme.h2
-rw-r--r--ui/native_theme/native_theme_aura.cc10
-rw-r--r--ui/native_theme/native_theme_win.cc4
-rw-r--r--ui/views/bubble/bubble_delegate.cc32
-rw-r--r--ui/views/bubble/bubble_delegate.h15
-rw-r--r--ui/views/bubble/bubble_frame_view.h4
6 files changed, 45 insertions, 22 deletions
diff --git a/ui/native_theme/native_theme.h b/ui/native_theme/native_theme.h
index 3ee74a2..021cf3c 100644
--- a/ui/native_theme/native_theme.h
+++ b/ui/native_theme/native_theme.h
@@ -218,6 +218,8 @@ class NATIVE_THEME_EXPORT NativeTheme {
// Colors for GetSystemColor().
enum ColorId {
+ // Windows
+ kColorId_WindowBackground,
// Dialogs
kColorId_DialogBackground,
// FocusableBorder
diff --git a/ui/native_theme/native_theme_aura.cc b/ui/native_theme/native_theme_aura.cc
index 8cfdb31..01f61c5 100644
--- a/ui/native_theme/native_theme_aura.cc
+++ b/ui/native_theme/native_theme_aura.cc
@@ -20,8 +20,8 @@ const SkColor kMenuBackgroundColor = SK_ColorWHITE;
// Theme colors returned by GetSystemColor().
const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
-// Dialogs:
-const SkColor kDialogBackgroundColor = SK_ColorWHITE;
+// Windows:
+const SkColor kWindowBackgroundColor = SK_ColorWHITE;
// FocusableBorder:
const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
@@ -84,9 +84,13 @@ SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const {
}
switch (color_id) {
+ // Windows
+ case kColorId_WindowBackground:
+ return kWindowBackgroundColor;
+
// Dialogs
case kColorId_DialogBackground:
- return kDialogBackgroundColor;
+ return kWindowBackgroundColor;
// FocusableBorder
case kColorId_FocusedBorderColor:
diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc
index e4065a7..00636ff 100644
--- a/ui/native_theme/native_theme_win.cc
+++ b/ui/native_theme/native_theme_win.cc
@@ -450,6 +450,10 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
}
switch (color_id) {
+ // Windows
+ case kColorId_WindowBackground:
+ return system_colors_[COLOR_WINDOW];
+
// Dialogs
case kColorId_DialogBackground:
// TODO(benrg): Should this use the new Windows theme functions? The old
diff --git a/ui/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc
index 28dbb09..3e15b85 100644
--- a/ui/views/bubble/bubble_delegate.cc
+++ b/ui/views/bubble/bubble_delegate.cc
@@ -7,6 +7,7 @@
#include "ui/base/animation/slide_animation.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/rect.h"
+#include "ui/native_theme/native_theme.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
@@ -98,14 +99,6 @@ Widget* CreateBorderWidget(BubbleDelegateView* bubble) {
} // namespace
-#if defined(OS_WIN) && !defined(USE_AURA)
-const SkColor BubbleDelegateView::kBackgroundColor =
- color_utils::GetSysSkColor(COLOR_WINDOW);
-#else
-// TODO(beng): source from theme provider.
-const SkColor BubbleDelegateView::kBackgroundColor = SK_ColorWHITE;
-#endif
-
BubbleDelegateView::BubbleDelegateView()
: close_on_esc_(true),
close_on_deactivate_(true),
@@ -114,7 +107,7 @@ BubbleDelegateView::BubbleDelegateView()
move_with_anchor_(false),
arrow_location_(BubbleBorder::TOP_LEFT),
shadow_(BubbleBorder::SMALL_SHADOW),
- color_(kBackgroundColor),
+ color_explicitly_set_(false),
margins_(kDefaultMargin, kDefaultMargin, kDefaultMargin, kDefaultMargin),
original_opacity_(255),
border_widget_(NULL),
@@ -122,8 +115,8 @@ BubbleDelegateView::BubbleDelegateView()
accept_events_(true),
adjust_if_offscreen_(true),
parent_window_(NULL) {
- set_background(Background::CreateSolidBackground(color_));
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
+ UpdateColorsFromTheme(GetNativeTheme());
}
BubbleDelegateView::BubbleDelegateView(
@@ -136,7 +129,7 @@ BubbleDelegateView::BubbleDelegateView(
move_with_anchor_(false),
arrow_location_(arrow_location),
shadow_(BubbleBorder::SMALL_SHADOW),
- color_(kBackgroundColor),
+ color_explicitly_set_(false),
margins_(kDefaultMargin, kDefaultMargin, kDefaultMargin, kDefaultMargin),
original_opacity_(255),
border_widget_(NULL),
@@ -144,8 +137,8 @@ BubbleDelegateView::BubbleDelegateView(
accept_events_(true),
adjust_if_offscreen_(true),
parent_window_(NULL) {
- set_background(Background::CreateSolidBackground(color_));
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
+ UpdateColorsFromTheme(GetNativeTheme());
}
BubbleDelegateView::~BubbleDelegateView() {
@@ -287,6 +280,10 @@ bool BubbleDelegateView::AcceleratorPressed(
return true;
}
+void BubbleDelegateView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
+ UpdateColorsFromTheme(theme);
+}
+
void BubbleDelegateView::AnimationEnded(const ui::Animation* animation) {
if (animation != fade_animation_.get())
return;
@@ -346,6 +343,17 @@ gfx::Rect BubbleDelegateView::GetBubbleBounds() {
GetPreferredSize(), adjust_if_offscreen_);
}
+void BubbleDelegateView::UpdateColorsFromTheme(const ui::NativeTheme* theme) {
+ if (!color_explicitly_set_) {
+ color_ = GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_WindowBackground);
+ }
+ set_background(Background::CreateSolidBackground(color()));
+ BubbleFrameView* frame_view = GetBubbleFrameView();
+ if (frame_view)
+ frame_view->bubble_border()->set_background_color(color());
+}
+
#if defined(OS_WIN) && !defined(USE_AURA)
gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const {
gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView());
diff --git a/ui/views/bubble/bubble_delegate.h b/ui/views/bubble/bubble_delegate.h
index 7789b41..0a7ad8e 100644
--- a/ui/views/bubble/bubble_delegate.h
+++ b/ui/views/bubble/bubble_delegate.h
@@ -31,9 +31,6 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
public ui::AnimationDelegate,
public WidgetObserver {
public:
- // The default bubble background color.
- static const SkColor kBackgroundColor;
-
BubbleDelegateView();
BubbleDelegateView(View* anchor_view,
BubbleBorder::ArrowLocation arrow_location);
@@ -78,7 +75,10 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
void set_shadow(BubbleBorder::Shadow shadow) { shadow_ = shadow; }
SkColor color() const { return color_; }
- void set_color(SkColor color) { color_ = color; }
+ void set_color(SkColor color) {
+ color_ = color;
+ color_explicitly_set_ = true;
+ }
const gfx::Insets& margins() const { return margins_; }
void set_margins(const gfx::Insets& margins) { margins_ = margins; }
@@ -123,6 +123,7 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// View overrides:
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
+ virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
// ui::AnimationDelegate overrides:
virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
@@ -156,6 +157,9 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, NonClientHitTest);
FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate);
+ // Update the bubble color from |theme|, unless it was explicitly set.
+ void UpdateColorsFromTheme(const ui::NativeTheme* theme);
+
#if defined(OS_WIN) && !defined(USE_AURA)
// Get bounds for the Windows-only widget that hosts the bubble's contents.
gfx::Rect GetBubbleClientBounds() const;
@@ -184,8 +188,9 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// Bubble border shadow to use.
BubbleBorder::Shadow shadow_;
- // The background color of the bubble.
+ // The background color of the bubble; and flag for when it's explicitly set.
SkColor color_;
+ bool color_explicitly_set_;
// The margins between the content and the inside of the border.
gfx::Insets margins_;
diff --git a/ui/views/bubble/bubble_frame_view.h b/ui/views/bubble/bubble_frame_view.h
index 1349920..3a8b4df 100644
--- a/ui/views/bubble/bubble_frame_view.h
+++ b/ui/views/bubble/bubble_frame_view.h
@@ -8,13 +8,13 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
-#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/insets.h"
-#include "ui/views/bubble/bubble_border.h"
#include "ui/views/window/non_client_view.h"
namespace views {
+class BubbleBorder;
+
// This is a NonClientFrameView used to render the BubbleBorder.
class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView {
public: