Index: views/view.cc |
diff --git a/views/view.cc b/views/view.cc |
index 35a0ccf3e917f26f1a8fb26815a03afa86dba958..ec8db2332d5df5b181b2bf2873fcbbb3b8792172 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(view->parent() == this); |
tfarina
2011/06/16 14:58:05
view->parent_ please!
DCHECK_EQ(view->parent_, th
sadrul
2011/06/16 15:37:13
Done.
|
+ 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); |
} |