diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-27 01:39:13 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-27 01:39:13 +0000 |
commit | 8b9a8f156c4f0038012718378dab89416731f2f5 (patch) | |
tree | 22e90a98d3d1f3773c6cb952d35cea7000342378 /views | |
parent | dd29fbe689b366ac754837d5b2f2956650cf6e45 (diff) | |
download | chromium_src-8b9a8f156c4f0038012718378dab89416731f2f5.zip chromium_src-8b9a8f156c4f0038012718378dab89416731f2f5.tar.gz chromium_src-8b9a8f156c4f0038012718378dab89416731f2f5.tar.bz2 |
Make theme change notifications auto-propagate through the view hierarchy, instead of forcing subclasses to manually call their superclass implementation. This fixes some problems where not all views would get notified of a theme change.
Make naming for theme and locale changes consistent and clear.
BUG=50107
TEST=none
Review URL: http://codereview.chromium.org/2878055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/view.cc | 11 | ||||
-rw-r--r-- | views/view.h | 22 | ||||
-rw-r--r-- | views/widget/root_view.cc | 7 | ||||
-rw-r--r-- | views/widget/root_view.h | 4 | ||||
-rw-r--r-- | views/window/non_client_view.cc | 2 |
5 files changed, 25 insertions, 21 deletions
diff --git a/views/view.cc b/views/view.cc index 2c92338..c8e35de 100644 --- a/views/view.cc +++ b/views/view.cc @@ -667,15 +667,16 @@ bool View::IsFocusable() const { return focusable_ && IsEnabled() && IsVisible(); } -void View::ThemeChanged() { +void View::PropagateThemeChanged() { for (int i = GetChildViewCount() - 1; i >= 0; --i) - GetChildViewAt(i)->ThemeChanged(); + GetChildViewAt(i)->PropagateThemeChanged(); + OnThemeChanged(); } -void View::NotifyLocaleChanged() { - LocaleChanged(); +void View::PropagateLocaleChanged() { for (int i = GetChildViewCount() - 1; i >= 0; --i) - GetChildViewAt(i)->NotifyLocaleChanged(); + GetChildViewAt(i)->PropagateLocaleChanged(); + OnLocaleChanged(); } #ifndef NDEBUG diff --git a/views/view.h b/views/view.h index fcd0ee7..22c38d0 100644 --- a/views/view.h +++ b/views/view.h @@ -976,15 +976,15 @@ class View : public AcceleratorTarget { // Called when the UI theme has changed, overriding allows individual Views to // do special cleanup and processing (such as dropping resource caches). - // Subclasses that override this method must call the base class - // implementation to ensure child views are processed. - // Can only be called by subclasses. To dispatch a theme changed notification, - // call this method on the RootView. - virtual void ThemeChanged(); + // To dispatch a theme changed notification, call + // RootView::NotifyThemeChanged(). + virtual void OnThemeChanged() { } // Called when the locale has changed, overriding allows individual Views to // update locale-dependent strings. - virtual void LocaleChanged() { } + // To dispatch a locale changed notification, call + // RootView::NotifyLocaleChanged(). + virtual void OnLocaleChanged() { } #ifndef NDEBUG // Returns true if the View is currently processing a paint. @@ -1138,9 +1138,13 @@ class View : public AcceleratorTarget { gfx::Point start_pt; }; - // Propagates locale changed notification from the root view downside. - // Invokes LocaleChanged() for every view in the hierarchy. - virtual void NotifyLocaleChanged(); + // Used to propagate theme changed notifications from the root view to all + // views in the hierarchy. + virtual void PropagateThemeChanged(); + + // Used to propagate locale changed notifications from the root view to all + // views in the hierarchy. + virtual void PropagateLocaleChanged(); // RootView invokes these. These in turn invoke the appropriate OnMouseXXX // method. If a drag is detected, DoDrag is invoked. diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index cfe7505..91ba511 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -238,13 +238,12 @@ Widget* RootView::GetWidget() const { return widget_; } -void RootView::ThemeChanged() { - View::ThemeChanged(); +void RootView::NotifyThemeChanged() { + View::PropagateThemeChanged(); } void RootView::NotifyLocaleChanged() { - // Propagate downside. Note that View::NotifyLocaleChanged() is private. - View::NotifyLocaleChanged(); + View::PropagateLocaleChanged(); } ///////////////////////////////////////////////////////////////////////////// diff --git a/views/widget/root_view.h b/views/widget/root_view.h index 6694f6a..c749bc8 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -80,11 +80,11 @@ class RootView : public View, // Public API for broadcasting theme change notifications to this View // hierarchy. - virtual void ThemeChanged(); + void NotifyThemeChanged(); // Public API for broadcasting locale change notifications to this View // hierarchy. - virtual void NotifyLocaleChanged(); + void NotifyLocaleChanged(); // The following event methods are overridden to propagate event to the // control tree diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc index 8fe3346..cf3833e 100644 --- a/views/window/non_client_view.cc +++ b/views/window/non_client_view.cc @@ -61,7 +61,7 @@ void NonClientView::WindowClosing() { void NonClientView::UpdateFrame() { SetFrameView(frame_->CreateFrameViewForWindow()); - GetRootView()->ThemeChanged(); + GetRootView()->NotifyThemeChanged(); Layout(); SchedulePaint(); frame_->UpdateFrameAfterFrameChange(); |