OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_VIEWS_VIEW_MODEL_H_ | 5 #ifndef UI_VIEWS_VIEW_MODEL_H_ |
6 #define UI_VIEWS_VIEW_MODEL_H_ | 6 #define UI_VIEWS_VIEW_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 void Add(View* view, int index); | 32 void Add(View* view, int index); |
33 | 33 |
34 // Removes the view at the specified index. This does not actually remove the | 34 // Removes the view at the specified index. This does not actually remove the |
35 // view from the view hierarchy. | 35 // view from the view hierarchy. |
36 void Remove(int index); | 36 void Remove(int index); |
37 | 37 |
38 // Moves the view at |index| to |target_index|. |target_index| is in terms | 38 // Moves the view at |index| to |target_index|. |target_index| is in terms |
39 // of the model *after* the view at |index| is removed. | 39 // of the model *after* the view at |index| is removed. |
40 void Move(int index, int target_index); | 40 void Move(int index, int target_index); |
41 | 41 |
| 42 // Variant of Move() that leaves the bounds as is. That is, after invoking |
| 43 // this the bounds of the view at |target_index| (and all other indices) are |
| 44 // exactly the same as the bounds of the view at |target_index| before |
| 45 // invoking this. |
| 46 void MoveViewOnly(int index, int target_index); |
| 47 |
42 // Returns the number of views. | 48 // Returns the number of views. |
43 int view_size() const { return static_cast<int>(entries_.size()); } | 49 int view_size() const { return static_cast<int>(entries_.size()); } |
44 | 50 |
45 // Removes and deletes all the views. | 51 // Removes and deletes all the views. |
46 void Clear(); | 52 void Clear(); |
47 | 53 |
48 // Returns the view at the specified index. | 54 // Returns the view at the specified index. |
49 View* view_at(int index) const { | 55 View* view_at(int index) const { |
50 check_index(index); | 56 check_index(index); |
51 return entries_[index].view; | 57 return entries_[index].view; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #endif | 90 #endif |
85 | 91 |
86 Entries entries_; | 92 Entries entries_; |
87 | 93 |
88 DISALLOW_COPY_AND_ASSIGN(ViewModel); | 94 DISALLOW_COPY_AND_ASSIGN(ViewModel); |
89 }; | 95 }; |
90 | 96 |
91 } // namespace views | 97 } // namespace views |
92 | 98 |
93 #endif // UI_VIEWS_VIEW_MODEL_H_ | 99 #endif // UI_VIEWS_VIEW_MODEL_H_ |
OLD | NEW |