diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 17:49:04 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 17:49:04 +0000 |
commit | ea1fc4b19a5eac5d072646932e06205d6e51b08c (patch) | |
tree | 46f339940327014094152621ef255132215101f8 /views/view.cc | |
parent | cc5e6d0e30b7d0b51d1d84e2286626f3b0fb79a1 (diff) | |
download | chromium_src-ea1fc4b19a5eac5d072646932e06205d6e51b08c.zip chromium_src-ea1fc4b19a5eac5d072646932e06205d6e51b08c.tar.gz chromium_src-ea1fc4b19a5eac5d072646932e06205d6e51b08c.tar.bz2 |
Add View::ReorderChildView and Widget::MoveToTop.
The z-ordering of child views is currently maintained (implicitly?) by the order
they are added to the parent view. It may often be necessary to change the
z-order of views, and View::ReorderChildView can be used to do that.
I changed views_desktop to have the two pure-views windows to have overlapping
regions, and View::ReorderChildView is used to change the z-ordering of the two
windows. So it is possible to click a window to activate it and bring it on top
of the other. It could have been done without adding Widget::MoveToTop, but
given Widget::MoveAbove and MoveAboveWidget, it sounded like a good idea to have
Widget::MoveToTop (MoveToFront?). I do now know what the implementation for
windows should be, though. So left it as NOTIMPLEMENTED.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7185005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/view.cc')
-rw-r--r-- | views/view.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/views/view.cc b/views/view.cc index c411621..a89ee23 100644 --- a/views/view.cc +++ b/views/view.cc @@ -176,6 +176,32 @@ void View::AddChildViewAt(View* view, int index) { view->MarkTextureDirty(); } +void View::ReorderChildView(View* view, int index) { + DCHECK_EQ(view->parent_, this); + if (index < 0) + index = child_count() - 1; + else if (index >= child_count()) + return; + if (children_[index] == view) + return; + + const Views::iterator i(std::find(children_.begin(), children_.end(), view)); + DCHECK(i != children_.end()); + children_.erase(i); + + // Unlink the view first + View* next_focusable = view->next_focusable_view_; + View* prev_focusable = view->previous_focusable_view_; + if (prev_focusable) + prev_focusable->next_focusable_view_ = next_focusable; + if (next_focusable) + next_focusable->previous_focusable_view_ = prev_focusable; + + // Add it in the specified index now. + InitFocusSiblings(view, index); + children_.insert(children_.begin() + index, view); +} + void View::RemoveChildView(View* view) { DoRemoveChildView(view, true, true, false); } |