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

Side by Side Diff: ui/views/view_model.cc

Issue 10267023: Gets tab dragging to work in touch mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/view_model.h ('k') | ui/views/view_model_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/views/view_model.h" 5 #include "ui/views/view_model.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/views/view.h" 8 #include "ui/views/view.h"
9 9
10 namespace views { 10 namespace views {
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 void ViewModel::Move(int index, int target_index) { 35 void ViewModel::Move(int index, int target_index) {
36 if (index == target_index) 36 if (index == target_index)
37 return; 37 return;
38 Entry entry(entries_[index]); 38 Entry entry(entries_[index]);
39 entries_.erase(entries_.begin() + index); 39 entries_.erase(entries_.begin() + index);
40 entries_.insert(entries_.begin() + target_index, entry); 40 entries_.insert(entries_.begin() + target_index, entry);
41 } 41 }
42 42
43 void ViewModel::MoveViewOnly(int index, int target_index) {
44 if (index == target_index)
45 return;
46 if (target_index < index) {
47 View* view = entries_[index].view;
48 for (int i = index; i > target_index; --i)
49 entries_[i].view = entries_[i - 1].view;
50 entries_[target_index].view = view;
51 } else {
52 View* view = entries_[index].view;
53 for (int i = index; i < target_index; ++i)
54 entries_[i].view = entries_[i + 1].view;
55 entries_[target_index].view = view;
56 }
57 }
58
43 void ViewModel::Clear() { 59 void ViewModel::Clear() {
44 Entries entries; 60 Entries entries;
45 entries.swap(entries_); 61 entries.swap(entries_);
46 for (size_t i = 0; i < entries.size(); ++i) 62 for (size_t i = 0; i < entries.size(); ++i)
47 delete entries[i].view; 63 delete entries[i].view;
48 } 64 }
49 65
50 int ViewModel::GetIndexOfView(const View* view) const { 66 int ViewModel::GetIndexOfView(const View* view) const {
51 for (size_t i = 0; i < entries_.size(); ++i) { 67 for (size_t i = 0; i < entries_.size(); ++i) {
52 if (entries_[i].view == view) 68 if (entries_[i].view == view)
53 return static_cast<int>(i); 69 return static_cast<int>(i);
54 } 70 }
55 return -1; 71 return -1;
56 } 72 }
57 73
58 } // namespace views 74 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view_model.h ('k') | ui/views/view_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698