summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/views/avatar_menu_bubble_view.cc47
-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
7 files changed, 67 insertions, 47 deletions
diff --git a/chrome/browser/ui/views/avatar_menu_bubble_view.cc b/chrome/browser/ui/views/avatar_menu_bubble_view.cc
index b0d6570..ee8638d 100644
--- a/chrome/browser/ui/views/avatar_menu_bubble_view.cc
+++ b/chrome/browser/ui/views/avatar_menu_bubble_view.cc
@@ -35,6 +35,7 @@ const int kItemMarginY = 4;
const int kIconMarginX = 6;
const int kSeparatorPaddingY = 5;
const int kMaxItemTextWidth = 200;
+const SkColor kHighlightColor = 0xFFE3EDF6;
inline int Round(double x) {
return static_cast<int>(x + 0.5);
@@ -199,8 +200,7 @@ class ProfileItemView : public views::CustomButton,
public HighlightDelegate {
public:
ProfileItemView(const AvatarMenuModel::Item& item,
- views::ButtonListener* switch_profile_listener,
- views::LinkListener* edit_profile_listener);
+ AvatarMenuBubbleView* parent);
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE;
@@ -212,34 +212,35 @@ class ProfileItemView : public views::CustomButton,
virtual void OnHighlightStateChanged() OVERRIDE;
virtual void OnFocusStateChanged(bool has_focus) OVERRIDE;
+ const AvatarMenuModel::Item& item() const { return item_; }
EditProfileLink* edit_link() { return edit_link_; }
- const AvatarMenuModel::Item& item() { return item_; }
private:
static gfx::ImageSkia GetBadgedIcon(const gfx::ImageSkia& icon);
bool IsHighlighted();
- EditProfileLink* edit_link_;
- views::ImageView* image_view_;
AvatarMenuModel::Item item_;
+ AvatarMenuBubbleView* parent_;
+ views::ImageView* image_view_;
views::Label* name_label_;
views::Label* sync_state_label_;
+ EditProfileLink* edit_link_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProfileItemView);
};
ProfileItemView::ProfileItemView(const AvatarMenuModel::Item& item,
- views::ButtonListener* switch_profile_listener,
- views::LinkListener* edit_profile_listener)
- : views::CustomButton(switch_profile_listener),
- item_(item) {
+ AvatarMenuBubbleView* parent)
+ : views::CustomButton(parent),
+ item_(item),
+ parent_(parent) {
image_view_ = new ProfileImageView();
gfx::ImageSkia profile_icon = *item_.icon.ToImageSkia();
- if (item_.active) {
- gfx::ImageSkia badged_icon(GetBadgedIcon(profile_icon));
- image_view_->SetImage(badged_icon);
- } else {
+ if (item_.active)
+ image_view_->SetImage(GetBadgedIcon(profile_icon));
+ else
image_view_->SetImage(profile_icon);
- }
AddChildView(image_view_);
// Add a label to show the profile name.
@@ -265,9 +266,8 @@ ProfileItemView::ProfileItemView(const AvatarMenuModel::Item& item,
// Add an edit profile link.
edit_link_ = new EditProfileLink(
l10n_util::GetStringUTF16(IDS_PROFILES_EDIT_PROFILE_LINK), this);
- edit_link_->set_listener(edit_profile_listener);
+ edit_link_->set_listener(parent);
edit_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- edit_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6));
edit_link_->SetHasFocusBorder(true);
AddChildView(edit_link_);
@@ -342,13 +342,11 @@ void ProfileItemView::OnBlur() {
}
void ProfileItemView::OnHighlightStateChanged() {
- set_background(IsHighlighted() ? views::Background::CreateSolidBackground(
- SkColorSetRGB(0xe3, 0xed, 0xf6)) : NULL);
- SkColor background_color = background() ?
- background()->get_color() : views::BubbleDelegateView::kBackgroundColor;
- name_label_->SetBackgroundColor(background_color);
- sync_state_label_->SetBackgroundColor(background_color);
- edit_link_->SetBackgroundColor(background_color);
+ const SkColor color = IsHighlighted() ? kHighlightColor : parent_->color();
+ set_background(views::Background::CreateSolidBackground(color));
+ name_label_->SetBackgroundColor(color);
+ sync_state_label_->SetBackgroundColor(color);
+ edit_link_->SetBackgroundColor(color);
bool show_edit = IsHighlighted() && item_.active;
sync_state_label_->SetVisible(!show_edit);
@@ -532,7 +530,7 @@ void AvatarMenuBubbleView::OnAvatarMenuModelChanged(
for (size_t i = 0; i < avatar_menu_model->GetNumberOfItems(); ++i) {
const AvatarMenuModel::Item& item = avatar_menu_model->GetItemAt(i);
- ProfileItemView* item_view = new ProfileItemView(item, this, this);
+ ProfileItemView* item_view = new ProfileItemView(item, this);
item_view->SetAccessibleName(l10n_util::GetStringFUTF16(
IDS_PROFILES_SWITCH_TO_PROFILE_ACCESSIBLE_NAME, item.name));
item_view->set_focusable(true);
@@ -548,7 +546,6 @@ void AvatarMenuBubbleView::OnAvatarMenuModelChanged(
add_profile_link_->set_listener(this);
add_profile_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
add_profile_link_->SetBackgroundColor(color());
- add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6));
AddChildView(add_profile_link_);
// If the bubble has already been shown then resize and reposition the bubble.
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: