summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 09:39:40 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 09:39:40 +0000
commitd7bd6563eba1a5575bb6a12d985dace47c57423f (patch)
tree5b0b2f7bddb849f651367e7794f4af585209ae38 /ui
parentb9ff6038225f41483a19f61cc2f5290a4da7ad30 (diff)
downloadchromium_src-d7bd6563eba1a5575bb6a12d985dace47c57423f.zip
chromium_src-d7bd6563eba1a5575bb6a12d985dace47c57423f.tar.gz
chromium_src-d7bd6563eba1a5575bb6a12d985dace47c57423f.tar.bz2
Update Views tab modal dialogs when nativetheme changes
BUG=347832 Review URL: https://codereview.chromium.org/266673013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/bubble/bubble_border.cc3
-rw-r--r--ui/views/bubble/bubble_border.h8
-rw-r--r--ui/views/bubble/bubble_frame_view.cc9
-rw-r--r--ui/views/bubble/bubble_frame_view.h1
-rw-r--r--ui/views/window/dialog_client_view.cc18
-rw-r--r--ui/views/window/dialog_client_view.h1
-rw-r--r--ui/views/window/dialog_delegate.cc8
7 files changed, 36 insertions, 12 deletions
diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc
index aa9064e..03b422a 100644
--- a/ui/views/bubble/bubble_border.cc
+++ b/ui/views/bubble/bubble_border.cc
@@ -156,7 +156,8 @@ BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, SkColor color)
arrow_paint_type_(PAINT_NORMAL),
alignment_(ALIGN_ARROW_TO_MID_ANCHOR),
shadow_(shadow),
- background_color_(color) {
+ background_color_(color),
+ use_theme_background_color_(false) {
DCHECK(shadow < SHADOW_COUNT);
images_ = GetBorderImages(shadow);
}
diff --git a/ui/views/bubble/bubble_border.h b/ui/views/bubble/bubble_border.h
index 4fb961e..15f0f85 100644
--- a/ui/views/bubble/bubble_border.h
+++ b/ui/views/bubble/bubble_border.h
@@ -136,6 +136,13 @@ class VIEWS_EXPORT BubbleBorder : public Border {
void set_background_color(SkColor color) { background_color_ = color; }
SkColor background_color() const { return background_color_; }
+ // If true, the background color should be determined by the host's
+ // NativeTheme.
+ void set_use_theme_background_color(bool use_theme_background_color) {
+ use_theme_background_color_ = use_theme_background_color;
+ }
+ bool use_theme_background_color() { return use_theme_background_color_; }
+
// Sets a desired pixel distance between the arrow tip and the outside edge of
// the neighboring border image. For example: |----offset----|
// '(' represents shadow around the '{' edge: ((({ ^ })))
@@ -178,6 +185,7 @@ class VIEWS_EXPORT BubbleBorder : public Border {
Shadow shadow_;
internal::BorderImages* images_;
SkColor background_color_;
+ bool use_theme_background_color_;
DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
};
diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc
index 8bad29e..1c4d70c 100644
--- a/ui/views/bubble/bubble_frame_view.cc
+++ b/ui/views/bubble/bubble_frame_view.cc
@@ -12,6 +12,7 @@
#include "ui/gfx/path.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/skia_util.h"
+#include "ui/native_theme/native_theme.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/widget/widget.h"
@@ -223,6 +224,14 @@ void BubbleFrameView::OnThemeChanged() {
UpdateWindowIcon();
}
+void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
+ if (bubble_border_ && bubble_border_->use_theme_background_color()) {
+ bubble_border_->set_background_color(GetNativeTheme()->
+ GetSystemColor(ui::NativeTheme::kColorId_DialogBackground));
+ SchedulePaint();
+ }
+}
+
void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) {
if (sender == close_)
GetWidget()->Close();
diff --git a/ui/views/bubble/bubble_frame_view.h b/ui/views/bubble/bubble_frame_view.h
index b72867b..6521343 100644
--- a/ui/views/bubble/bubble_frame_view.h
+++ b/ui/views/bubble/bubble_frame_view.h
@@ -51,6 +51,7 @@ class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView,
virtual const char* GetClassName() const OVERRIDE;
virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
virtual void OnThemeChanged() OVERRIDE;
+ virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
// Overridden from ButtonListener:
virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE;
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index cdcc98ef..e100fd1 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -265,13 +265,6 @@ void DialogClientView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
ClientView::ViewHierarchyChanged(details);
if (details.is_add && details.child == this) {
- // The old dialog style needs an explicit background color, while the new
- // dialog style simply inherits the bubble's frame view color.
- const DialogDelegate* dialog = GetDialogDelegate();
- if (dialog && !dialog->UseNewStyleForThisDialog())
- set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
- GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
-
focus_manager_ = GetFocusManager();
if (focus_manager_)
GetFocusManager()->AddFocusChangeListener(this);
@@ -304,6 +297,17 @@ void DialogClientView::NativeViewHierarchyChanged() {
}
}
+void DialogClientView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
+ // The old dialog style needs an explicit background color, while the new
+ // dialog style simply inherits the bubble's frame view color.
+ const DialogDelegate* dialog = GetDialogDelegate();
+
+ if (dialog && !dialog->UseNewStyleForThisDialog()) {
+ set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
+ GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// DialogClientView, ButtonListener implementation:
diff --git a/ui/views/window/dialog_client_view.h b/ui/views/window/dialog_client_view.h
index d780806..e6f0ca2 100644
--- a/ui/views/window/dialog_client_view.h
+++ b/ui/views/window/dialog_client_view.h
@@ -63,6 +63,7 @@ class VIEWS_EXPORT DialogClientView : public ClientView,
virtual void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) OVERRIDE;
virtual void NativeViewHierarchyChanged() OVERRIDE;
+ virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE;
// ButtonListener implementation:
virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE;
diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc
index 8177be4..7af50a4 100644
--- a/ui/views/window/dialog_delegate.cc
+++ b/ui/views/window/dialog_delegate.cc
@@ -156,10 +156,10 @@ NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) {
// static
NonClientFrameView* DialogDelegate::CreateDialogFrameView(Widget* widget) {
BubbleFrameView* frame = new BubbleFrameView(gfx::Insets());
- const SkColor color = widget->GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_DialogBackground);
- frame->SetBubbleBorder(scoped_ptr<BubbleBorder>(new BubbleBorder(
- BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, color)));
+ scoped_ptr<BubbleBorder> border(new BubbleBorder(
+ BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, SK_ColorRED));
+ border->set_use_theme_background_color(true);
+ frame->SetBubbleBorder(border.Pass());
DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate();
if (delegate) {
View* titlebar_view = delegate->CreateTitlebarExtraView();