Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: views/view.cc

Issue 7185005: Add View::ReorderChildView and Widget::MoveToTop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/view.h ('k') | views/widget/native_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/view.cc
diff --git a/views/view.cc b/views/view.cc
index 35a0ccf3e917f26f1a8fb26815a03afa86dba958..46c86d7458e0f6230fee6019548fc6b5fc1d49f2 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) {
tfarina 2011/06/16 15:40:10 Could you add an unittest for this function right
sadrul 2011/06/16 15:55:18 Sounds like a good idea. Done!
+ 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);
}
« no previous file with comments | « views/view.h ('k') | views/widget/native_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698