diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-27 20:24:07 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-27 20:24:07 +0000 |
commit | 6ed82bb82a0cc1ed5b337534406080e79e141cef (patch) | |
tree | 7f37fece429884a193fa59046523f94191260791 /views | |
parent | 817498d34ca487bd6c8791ed8efa104b2ab38ebf (diff) | |
download | chromium_src-6ed82bb82a0cc1ed5b337534406080e79e141cef.zip chromium_src-6ed82bb82a0cc1ed5b337534406080e79e141cef.tar.gz chromium_src-6ed82bb82a0cc1ed5b337534406080e79e141cef.tar.bz2 |
views: Add OnEnabledChanged() method to View class.
Changes done here:
- Override OnEnabledChanged() in the derived classes from View instead of SetEnable().
- Make SetEnable() a member function not a virtual one.
- Make |enabled_| a private data member variable not a protected one.
- Some other misc cleanups.
Note: The third item was a TODO for beng.
BUG=72040
TEST=None
R=ben@chromium.org
Review URL: http://codereview.chromium.org/6976048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
27 files changed, 89 insertions, 99 deletions
diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index 71116cd..8221b56 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -90,10 +90,10 @@ int Checkbox::GetHeightForWidth(int w) { return label_->GetHeightForWidth(std::max(prefsize.height(), w - width)); } -void Checkbox::SetEnabled(bool enabled) { - NativeButtonBase::SetEnabled(enabled); +void Checkbox::OnEnabledChanged() { + NativeButtonBase::OnEnabledChanged(); if (label_) - label_->SetEnabled(enabled); + label_->SetEnabled(IsEnabled()); } void Checkbox::Layout() { diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index cc4a3e0..430e558 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -45,7 +45,7 @@ class Checkbox : public NativeButtonBase { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual int GetHeightForWidth(int w) OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void Layout() OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index 95ecb98..dab4e32 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -91,11 +91,11 @@ bool CustomButton::IsHotTracked() const { return state_ == BS_HOT; } -void CustomButton::SetEnabled(bool enabled) { - if (enabled ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) +void CustomButton::OnEnabledChanged() { + if (View::IsEnabled() ? (state_ != BS_DISABLED) : (state_ == BS_DISABLED)) return; - if (enabled) + if (View::IsEnabled()) SetState(IsMouseHovered() ? BS_HOT : BS_NORMAL); else SetState(BS_DISABLED); @@ -196,7 +196,7 @@ bool CustomButton::OnKeyReleased(const KeyEvent& event) { } bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { - if (!enabled_) + if (!View::IsEnabled()) return false; SetState(BS_NORMAL); diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h index b898483..8309751 100644 --- a/views/controls/button/custom_button.h +++ b/views/controls/button/custom_button.h @@ -6,8 +6,8 @@ #define VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ #pragma once -#include "views/controls/button/button.h" #include "ui/base/animation/animation_delegate.h" +#include "views/controls/button/button.h" namespace ui { class ThrobAnimation; @@ -75,7 +75,7 @@ class CustomButton : public Button, // Overridden from View: virtual void SetHotTracked(bool flag) OVERRIDE; virtual bool IsHotTracked() const OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual bool IsEnabled() const OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc index 0e2c1f5..679841a 100644 --- a/views/controls/button/native_button.cc +++ b/views/controls/button/native_button.cc @@ -164,8 +164,8 @@ void NativeButtonBase::Layout() { } } -void NativeButtonBase::SetEnabled(bool flag) { - Button::SetEnabled(flag); +void NativeButtonBase::OnEnabledChanged() { + Button::OnEnabledChanged(); if (native_wrapper_) native_wrapper_->UpdateEnabled(); } diff --git a/views/controls/button/native_button.h b/views/controls/button/native_button.h index 019bb77..a2f97cc 100644 --- a/views/controls/button/native_button.h +++ b/views/controls/button/native_button.h @@ -58,7 +58,7 @@ class NativeButtonBase : public Button { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; - virtual void SetEnabled(bool flag) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index e72deb3..e232763 100644 --- a/views/controls/button/text_button.cc +++ b/views/controls/button/text_button.cc @@ -560,14 +560,11 @@ gfx::Size TextButtonBase::GetMinimumSize() { return max_text_size_; } -void TextButtonBase::SetEnabled(bool enabled) { - if (enabled != IsEnabled()) { - CustomButton::SetEnabled(enabled); - } +void TextButtonBase::OnEnabledChanged() { // We should always call UpdateColor() since the state of the button might be // changed by other functions like CustomButton::SetState(). UpdateColor(); - SchedulePaint(); + CustomButton::OnEnabledChanged(); } std::string TextButtonBase::GetClassName() const { diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h index c878eb1..126c545 100644 --- a/views/controls/button/text_button.h +++ b/views/controls/button/text_button.h @@ -188,7 +188,7 @@ class TextButtonBase : public CustomButton, public NativeThemeDelegate { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetMinimumSize() OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; // Text colors. diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc index fefa36a..23df9fa 100644 --- a/views/controls/combobox/combobox.cc +++ b/views/controls/combobox/combobox.cc @@ -78,8 +78,8 @@ void Combobox::Layout() { } } -void Combobox::SetEnabled(bool flag) { - View::SetEnabled(flag); +void Combobox::OnEnabledChanged() { + View::OnEnabledChanged(); if (native_wrapper_) native_wrapper_->UpdateEnabled(); } diff --git a/views/controls/combobox/combobox.h b/views/controls/combobox/combobox.h index 547db31..483238d 100644 --- a/views/controls/combobox/combobox.h +++ b/views/controls/combobox/combobox.h @@ -78,7 +78,7 @@ class Combobox : public View { // Overridden from View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE; diff --git a/views/controls/label.cc b/views/controls/label.cc index 627dd98..dc5c4de 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -206,11 +206,9 @@ int Label::GetHeightForWidth(int w) { return h + GetInsets().height(); } -void Label::SetEnabled(bool enabled) { - if (enabled == enabled_) - return; - View::SetEnabled(enabled); - SetColor(enabled ? kEnabledColor : kDisabledColor); +void Label::OnEnabledChanged() { + View::OnEnabledChanged(); + SetColor(IsEnabled() ? kEnabledColor : kDisabledColor); } std::string Label::GetClassName() const { diff --git a/views/controls/label.h b/views/controls/label.h index c1ccb52..2c3060d 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -161,7 +161,7 @@ class Label : public View { // GetPreferredSize().height() if the receiver is not multi-line. virtual int GetHeightForWidth(int w); // Sets the enabled state. Setting the enabled state resets the color. - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual std::string GetClassName() const OVERRIDE; // Mouse enter/exit are overridden to render mouse over background color. // These invoke SetContainsMouse as necessary. diff --git a/views/controls/link.cc b/views/controls/link.cc index 3c8bceac..1ffbf56 100644 --- a/views/controls/link.cc +++ b/views/controls/link.cc @@ -88,12 +88,9 @@ void Link::Init() { Link::~Link() { } -void Link::SetEnabled(bool flag) { - if (flag != enabled_) { - enabled_ = flag; - ValidateStyle(); - SchedulePaint(); - } +void Link::OnEnabledChanged() { + ValidateStyle(); + View::OnEnabledChanged(); } std::string Link::GetClassName() const { @@ -101,7 +98,7 @@ std::string Link::GetClassName() const { } gfx::NativeCursor Link::GetCursor(const MouseEvent& event) { - if (!enabled_) + if (!IsEnabled()) return NULL; #if defined(OS_WIN) static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); @@ -112,14 +109,15 @@ gfx::NativeCursor Link::GetCursor(const MouseEvent& event) { } bool Link::OnMousePressed(const MouseEvent& event) { - if (!enabled_ || (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) + if (!IsEnabled() || + (!event.IsLeftMouseButton() && !event.IsMiddleMouseButton())) return false; SetHighlighted(true); return true; } bool Link::OnMouseDragged(const MouseEvent& event) { - SetHighlighted(enabled_ && + SetHighlighted(IsEnabled() && (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && HitTest(event.location())); return true; @@ -129,7 +127,8 @@ void Link::OnMouseReleased(const MouseEvent& event) { // Change the highlight first just in case this instance is deleted // while calling the controller OnMouseCaptureLost(); - if (enabled_ && (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && + if (IsEnabled() && + (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && HitTest(event.location())) { // Focus the link on click. RequestFocus(); @@ -205,7 +204,7 @@ void Link::SetHighlighted(bool f) { } void Link::ValidateStyle() { - if (enabled_) { + if (IsEnabled()) { if (!(font().GetStyle() & gfx::Font::UNDERLINED)) { Label::SetFont( font().DeriveFont(0, font().GetStyle() | gfx::Font::UNDERLINED)); diff --git a/views/controls/link.h b/views/controls/link.h index 2a356bd..3803bbc 100644 --- a/views/controls/link.h +++ b/views/controls/link.h @@ -32,7 +32,7 @@ class Link : public Label { void set_listener(LinkListener* listener) { listener_ = listener; } // Overridden from View: - virtual void SetEnabled(bool flag) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc index 83a67e5..06878f4 100644 --- a/views/controls/native_control.cc +++ b/views/controls/native_control.cc @@ -13,8 +13,8 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "ui/base/accessibility/accessibility_types.h" -#include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/keycodes/keyboard_code_conversion_win.h" +#include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util_win.h" #include "ui/base/view_prop.h" #include "ui/base/win/hwnd_util.h" @@ -178,7 +178,6 @@ NativeControl::NativeControl() : hwnd_view_(NULL), horizontal_alignment_(CENTER), fixed_height_(-1), vertical_alignment_(CENTER) { - enabled_ = true; focusable_ = true; } @@ -199,8 +198,8 @@ void NativeControl::ValidateNativeControl() { container_ = new NativeControlContainer(this); container_->Init(); hwnd_view_->Attach(*container_); - if (!enabled_) - EnableWindow(GetNativeControlHWND(), enabled_); + if (!IsEnabled()) + EnableWindow(GetNativeControlHWND(), IsEnabled()); // This message ensures that the focus border is shown. ::SendMessage(container_->GetControl(), @@ -312,13 +311,10 @@ void NativeControl::SetVisible(bool f) { } } -void NativeControl::SetEnabled(bool enabled) { - if (enabled_ != enabled) { - View::SetEnabled(enabled); - if (GetNativeControlHWND()) { - EnableWindow(GetNativeControlHWND(), enabled_); - } - } +void NativeControl::OnEnabledChanged() { + View::OnEnabledChanged(); + if (GetNativeControlHWND()) + EnableWindow(GetNativeControlHWND(), IsEnabled()); } void NativeControl::OnPaint(gfx::Canvas* canvas) { diff --git a/views/controls/native_control.h b/views/controls/native_control.h index 1273920..9cf604e 100644 --- a/views/controls/native_control.h +++ b/views/controls/native_control.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -38,7 +38,7 @@ class NativeControl : public View { // Overridden to properly set the native control state. virtual void SetVisible(bool f); - virtual void SetEnabled(bool enabled); + virtual void OnEnabledChanged(); // Overridden to do nothing. virtual void OnPaint(gfx::Canvas* canvas); diff --git a/views/controls/native_control_gtk.cc b/views/controls/native_control_gtk.cc index 5a2bed16..0c21a9e 100644 --- a/views/controls/native_control_gtk.cc +++ b/views/controls/native_control_gtk.cc @@ -151,12 +151,10 @@ NativeControlGtk::~NativeControlGtk() { //////////////////////////////////////////////////////////////////////////////// // NativeControlGtk, View overrides: -void NativeControlGtk::SetEnabled(bool enabled) { - if (IsEnabled() != enabled) { - View::SetEnabled(enabled); - if (native_view()) - gtk_widget_set_sensitive(native_view(), IsEnabled()); - } +void NativeControlGtk::OnEnabledChanged() { + View::OnEnabledChanged(); + if (native_view()) + gtk_widget_set_sensitive(native_view(), IsEnabled()); } void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent, diff --git a/views/controls/native_control_gtk.h b/views/controls/native_control_gtk.h index 32a34f6..05582fb 100644 --- a/views/controls/native_control_gtk.h +++ b/views/controls/native_control_gtk.h @@ -19,7 +19,7 @@ class NativeControlGtk : public NativeViewHost { virtual ~NativeControlGtk(); // Overridden from View: - virtual void SetEnabled(bool enabled); + virtual void OnEnabledChanged(); protected: virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc index cd1ac0b..9630bd6 100644 --- a/views/controls/native_control_win.cc +++ b/views/controls/native_control_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -58,12 +58,10 @@ bool NativeControlWin::ProcessMessage(UINT message, //////////////////////////////////////////////////////////////////////////////// // NativeControlWin, View overrides: -void NativeControlWin::SetEnabled(bool enabled) { - if (IsEnabled() != enabled) { - View::SetEnabled(enabled); - if (native_view()) - EnableWindow(native_view(), IsEnabled()); - } +void NativeControlWin::OnEnabledChanged() { + View::OnEnabledChanged(); + if (native_view()) + EnableWindow(native_view(), IsEnabled()); } void NativeControlWin::ViewHierarchyChanged(bool is_add, View* parent, diff --git a/views/controls/native_control_win.h b/views/controls/native_control_win.h index 5d7e949..d58a77b 100644 --- a/views/controls/native_control_win.h +++ b/views/controls/native_control_win.h @@ -37,7 +37,7 @@ class NativeControlWin : public ChildWindowMessageProcessor, virtual bool OnKeyDown(int vkey) { return false; } // Overridden from View: - virtual void SetEnabled(bool enabled); + virtual void OnEnabledChanged(); protected: virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); diff --git a/views/controls/progress_bar.cc b/views/controls/progress_bar.cc index b8353b6..46b89a2 100644 --- a/views/controls/progress_bar.cc +++ b/views/controls/progress_bar.cc @@ -9,8 +9,8 @@ #include "base/logging.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "third_party/skia/include/effects/SkGradientShader.h" #include "third_party/skia/include/effects/SkBlurMaskFilter.h" +#include "third_party/skia/include/effects/SkGradientShader.h" #include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/color_utils.h" @@ -304,10 +304,8 @@ bool ProgressBar::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { return !tooltip_text_.empty(); } -void ProgressBar::SetEnabled(bool enabled) { - if (enabled == enabled_) - return; - View::SetEnabled(enabled); +void ProgressBar::OnEnabledChanged() { + View::OnEnabledChanged(); // TODO(denisromanov): Need to switch progress bar color here? } diff --git a/views/controls/progress_bar.h b/views/controls/progress_bar.h index 4366519..601186d 100644 --- a/views/controls/progress_bar.h +++ b/views/controls/progress_bar.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -56,7 +56,7 @@ class ProgressBar : public View { OVERRIDE; // Sets the enabled state. - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; // Accessibility accessors, overridden from View. virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; diff --git a/views/controls/resize_area.cc b/views/controls/resize_area.cc index a0a62ee..dd38286 100644 --- a/views/controls/resize_area.cc +++ b/views/controls/resize_area.cc @@ -32,7 +32,7 @@ std::string ResizeArea::GetClassName() const { } gfx::NativeCursor ResizeArea::GetCursor(const MouseEvent& event) { - if (!enabled_) + if (!IsEnabled()) return NULL; #if defined(OS_WIN) static HCURSOR g_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 1d6b078..a883d28 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -377,8 +377,8 @@ TextInputClient* Textfield::GetTextInputClient() { return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL; } -void Textfield::SetEnabled(bool enabled) { - View::SetEnabled(enabled); +void Textfield::OnEnabledChanged() { + View::OnEnabledChanged(); if (native_wrapper_) native_wrapper_->UpdateEnabled(); } diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index 9ef8711..a07b6f1 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -207,7 +207,7 @@ class Textfield : public View { virtual bool IsFocusable() const OVERRIDE; virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) OVERRIDE; - virtual void SetEnabled(bool enabled) OVERRIDE; + virtual void OnEnabledChanged() OVERRIDE; virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE; diff --git a/views/view.cc b/views/view.cc index 88e3ce3..eb6bd04 100644 --- a/views/view.cc +++ b/views/view.cc @@ -95,13 +95,13 @@ Widget* View::GetChildWidget() { // Creation and lifetime ------------------------------------------------------- View::View() - : enabled_(true), - focusable_(false), + : focusable_(false), parent_owned_(true), id_(0), group_(-1), parent_(NULL), is_visible_(true), + enabled_(true), registered_for_visible_bounds_notification_(false), clip_x_(0.0), clip_y_(0.0), @@ -353,22 +353,21 @@ int View::GetHeightForWidth(int w) { return GetPreferredSize().height(); } -void View::SetVisible(bool flag) { - if (flag != is_visible_) { - // If the tab is currently visible, schedule paint to - // refresh parent - if (IsVisible()) +void View::SetVisible(bool visible) { + if (visible != is_visible_) { + // If the tab is currently visible, schedule paint to refresh parent. + if (is_visible_) SchedulePaint(); else ResetTexture(); - is_visible_ = flag; + is_visible_ = visible; // This notifies all sub-views recursively. - PropagateVisibilityNotifications(this, flag); + PropagateVisibilityNotifications(this, is_visible_); // If we are newly visible, schedule paint. - if (IsVisible()) + if (is_visible_) SchedulePaint(); } } @@ -381,10 +380,10 @@ bool View::IsVisibleInRootView() const { return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false; } -void View::SetEnabled(bool state) { - if (enabled_ != state) { - enabled_ = state; - SchedulePaint(); +void View::SetEnabled(bool enabled) { + if (enabled != enabled_) { + enabled_ = enabled; + OnEnabledChanged(); } } @@ -392,6 +391,10 @@ bool View::IsEnabled() const { return enabled_; } +void View::OnEnabledChanged() { + SchedulePaint(); +} + // Transformations ------------------------------------------------------------- const ui::Transform& View::GetTransform() const { diff --git a/views/view.h b/views/view.h index 25b6e0f..957e195 100644 --- a/views/view.h +++ b/views/view.h @@ -305,7 +305,7 @@ class View : public AcceleratorTarget { virtual int GetHeightForWidth(int w); // Set whether the receiving view is visible. Painting is scheduled as needed - virtual void SetVisible(bool flag); + virtual void SetVisible(bool visible); // Return whether a view is visible virtual bool IsVisible() const; @@ -317,7 +317,7 @@ class View : public AcceleratorTarget { // Set whether this view is enabled. A disabled view does not receive keyboard // or mouse inputs. If flag differs from the current value, SchedulePaint is // invoked. - virtual void SetEnabled(bool flag); + void SetEnabled(bool enabled); // Returns whether the view is enabled. virtual bool IsEnabled() const; @@ -938,9 +938,9 @@ class View : public AcceleratorTarget { // its ancestors. This is used for clipping NativeViewHost. virtual void OnVisibleBoundsChanged(); - // TODO(beng): eliminate in protected. - // Whether this view is enabled. - bool enabled_; + // Override to be notified when the enabled state of this View has + // changed. The default implementation calls SchedulePaint() on this View. + virtual void OnEnabledChanged(); // Tree operations ----------------------------------------------------------- @@ -1321,9 +1321,12 @@ class View : public AcceleratorTarget { // This View's bounds in the parent coordinate system. gfx::Rect bounds_; - // Visible state + // Whether this view is visible. bool is_visible_; + // Whether this view is enabled. + bool enabled_; + // Whether or not RegisterViewForVisibleBoundsNotification on the RootView // has been invoked. bool registered_for_visible_bounds_notification_; |