OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/view.h" | 5 #include "views/view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 UpdateTooltip(); | 169 UpdateTooltip(); |
170 if (GetWidget()) | 170 if (GetWidget()) |
171 RegisterChildrenForVisibleBoundsNotification(view); | 171 RegisterChildrenForVisibleBoundsNotification(view); |
172 | 172 |
173 if (layout_manager_.get()) | 173 if (layout_manager_.get()) |
174 layout_manager_->ViewAdded(this, view); | 174 layout_manager_->ViewAdded(this, view); |
175 | 175 |
176 view->MarkTextureDirty(); | 176 view->MarkTextureDirty(); |
177 } | 177 } |
178 | 178 |
179 void View::ReorderChildView(View* view, int index) { | |
180 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.
| |
181 if (index < 0) | |
182 index = child_count() - 1; | |
183 else if (index >= child_count()) | |
184 return; | |
185 if (children_[index] == view) | |
186 return; | |
187 | |
188 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); | |
189 DCHECK(i != children_.end()); | |
190 children_.erase(i); | |
191 | |
192 // Unlink the view first | |
193 View* next_focusable = view->next_focusable_view_; | |
194 View* prev_focusable = view->previous_focusable_view_; | |
195 if (prev_focusable) | |
196 prev_focusable->next_focusable_view_ = next_focusable; | |
197 if (next_focusable) | |
198 next_focusable->previous_focusable_view_ = prev_focusable; | |
199 | |
200 // Add it in the specified index now. | |
201 InitFocusSiblings(view, index); | |
202 children_.insert(children_.begin() + index, view); | |
203 } | |
204 | |
179 void View::RemoveChildView(View* view) { | 205 void View::RemoveChildView(View* view) { |
180 DoRemoveChildView(view, true, true, false); | 206 DoRemoveChildView(view, true, true, false); |
181 } | 207 } |
182 | 208 |
183 void View::RemoveAllChildViews(bool delete_children) { | 209 void View::RemoveAllChildViews(bool delete_children) { |
184 while (!children_.empty()) | 210 while (!children_.empty()) |
185 DoRemoveChildView(children_.front(), false, false, delete_children); | 211 DoRemoveChildView(children_.front(), false, false, delete_children); |
186 UpdateTooltip(); | 212 UpdateTooltip(); |
187 } | 213 } |
188 | 214 |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1828 result.append(GetChildViewAt(i)->PrintViewGraph(false)); | 1854 result.append(GetChildViewAt(i)->PrintViewGraph(false)); |
1829 | 1855 |
1830 if (first) | 1856 if (first) |
1831 result.append("}\n"); | 1857 result.append("}\n"); |
1832 | 1858 |
1833 return result; | 1859 return result; |
1834 } | 1860 } |
1835 #endif | 1861 #endif |
1836 | 1862 |
1837 } // namespace views | 1863 } // namespace views |
OLD | NEW |