diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 21:09:11 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-08 21:09:11 +0000 |
commit | 7ccc52b7e9a9792bc72e4852de9ac7e3ac189235 (patch) | |
tree | 42d4ad23dc0ae33cd3d5e465b5bc2ee5b56a0029 /views | |
parent | efc6544b43973ee7dfed1f7e56986982e42ebee0 (diff) | |
download | chromium_src-7ccc52b7e9a9792bc72e4852de9ac7e3ac189235.zip chromium_src-7ccc52b7e9a9792bc72e4852de9ac7e3ac189235.tar.gz chromium_src-7ccc52b7e9a9792bc72e4852de9ac7e3ac189235.tar.bz2 |
Add PreferredSizeChanged() to View to allow subviews to notify their parents that they'd really like another layout.R=skyTEST=none
Review URL: http://codereview.chromium.org/113133
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15680 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/native_view_host.cc | 5 | ||||
-rw-r--r-- | views/controls/native_view_host.h | 4 | ||||
-rw-r--r-- | views/controls/table/table_view.cc | 5 | ||||
-rw-r--r-- | views/controls/table/table_view.h | 2 | ||||
-rw-r--r-- | views/view.cc | 5 | ||||
-rw-r--r-- | views/view.h | 7 |
6 files changed, 24 insertions, 4 deletions
diff --git a/views/controls/native_view_host.cc b/views/controls/native_view_host.cc index 3fc5fba..0e00aee 100644 --- a/views/controls/native_view_host.cc +++ b/views/controls/native_view_host.cc @@ -27,6 +27,11 @@ gfx::Size NativeViewHost::GetPreferredSize() { return preferred_size_; } +void NativeViewHost::SetPreferredSize(const gfx::Size& size) { + preferred_size_ = size; + PreferredSizeChanged(); +} + void NativeViewHost::Layout() { if (!native_view_) return; diff --git a/views/controls/native_view_host.h b/views/controls/native_view_host.h index 99b85b6..15cf98e 100644 --- a/views/controls/native_view_host.h +++ b/views/controls/native_view_host.h @@ -19,9 +19,7 @@ class NativeViewHost : public View { NativeViewHost(); virtual ~NativeViewHost(); - void set_preferred_size(const gfx::Size& size) { preferred_size_ = size; } - - // Returns the preferred size set via set_preferred_size. + void SetPreferredSize(const gfx::Size& size); virtual gfx::Size GetPreferredSize(); // Overriden to invoke Layout. diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc index f8c7303..434b355 100644 --- a/views/controls/table/table_view.cc +++ b/views/controls/table/table_view.cc @@ -1372,6 +1372,11 @@ gfx::Size TableView::GetPreferredSize() { return preferred_size_; } +void TableView::SetPreferredSize(const gfx::Size& size) { + preferred_size_ = size; + PreferredSizeChanged(); +} + void TableView::UpdateListViewCache0(int start, int length, bool add) { if (is_sorted()) { if (add) diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h index 8061d27..20514c3 100644 --- a/views/controls/table/table_view.h +++ b/views/controls/table/table_view.h @@ -420,7 +420,7 @@ class TableView : public NativeControl, // Sometimes we may want to size the TableView to a specific width and // height. virtual gfx::Size GetPreferredSize(); - void set_preferred_size(const gfx::Size& size) { preferred_size_ = size; } + void SetPreferredSize(const gfx::Size& size); // Is the table sorted? bool is_sorted() const { return !sort_descriptors_.empty(); } diff --git a/views/view.cc b/views/view.cc index cb73d74..b2951d9 100644 --- a/views/view.cc +++ b/views/view.cc @@ -171,6 +171,11 @@ void View::SizeToPreferredSize() { SetBounds(x(), y(), prefsize.width(), prefsize.height()); } +void View::PreferredSizeChanged() { + if (parent_) + parent_->ChildPreferredSizeChanged(this); +} + gfx::Size View::GetMinimumSize() { return GetPreferredSize(); } diff --git a/views/view.h b/views/view.h index d2d8e52..e004e03 100644 --- a/views/view.h +++ b/views/view.h @@ -1056,6 +1056,13 @@ class View : public AcceleratorTarget { // invoked for that view as well as all the children recursively. virtual void VisibilityChanged(View* starting_from, bool is_visible); + // Called when the preferred size of a child view changed. This gives the + // parent an opportunity to do a fresh layout if that makes sense. + virtual void ChildPreferredSizeChanged(View* child) {} + + // Simply calls ChildPreferredSizeChanged on the parent if there is one. + virtual void PreferredSizeChanged(); + // Views must invoke this when the tooltip text they are to display changes. void TooltipTextChanged(); |