summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-27 02:43:07 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-27 02:43:07 +0000
commitbb1889548091c80f27af9bebf6478272b8daae2b (patch)
treeebd215e4c593855ceea2ab800796c07d256eaaa2 /ash
parenta6b74c21e00d523ac3f7ff609a8df269278a8799 (diff)
downloadchromium_src-bb1889548091c80f27af9bebf6478272b8daae2b.zip
chromium_src-bb1889548091c80f27af9bebf6478272b8daae2b.tar.gz
chromium_src-bb1889548091c80f27af9bebf6478272b8daae2b.tar.bz2
Add LauncherView::SameDragType()
Followup for https://chromiumcodereview.appspot.com/9853020 to include panels wtih tabbed browsers for dragging. BUG=120096 TEST=Test that panel and tabbed browser launcher icons can be dragged within the same (entire) range. Review URL: http://codereview.chromium.org/9865005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/launcher/launcher_view.cc17
-rw-r--r--ash/launcher/launcher_view.h3
2 files changed, 19 insertions, 1 deletions
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index b34bc38..23a3e36 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -485,12 +485,27 @@ void LauncherView::ContinueDrag(const views::MouseEvent& event) {
bounds_animator_->StopAnimatingView(drag_view_);
}
+bool LauncherView::SameDragType(LauncherItemType typea,
+ LauncherItemType typeb) const {
+ switch(typea) {
+ case TYPE_TABBED:
+ case TYPE_APP_PANEL:
+ return (typeb == TYPE_TABBED || typeb == TYPE_APP_PANEL);
+ case TYPE_APP_SHORTCUT:
+ case TYPE_APP_LIST:
+ case TYPE_BROWSER_SHORTCUT:
+ return typeb == typea;
+ }
+ NOTREACHED();
+ return false;
+}
+
std::pair<int,int> LauncherView::GetDragRange(int index) {
int min_index = -1;
int max_index = -1;
LauncherItemType type = model_->items()[index].type;
for (int i = 0; i < model_->item_count(); ++i) {
- if (type == model_->items()[i].type) {
+ if (SameDragType(model_->items()[i].type, type)) {
if (min_index == -1)
min_index = i;
max_index = i;
diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h
index 7f7c49b..59cff17 100644
--- a/ash/launcher/launcher_view.h
+++ b/ash/launcher/launcher_view.h
@@ -102,6 +102,9 @@ class ASH_EXPORT LauncherView : public views::View,
// Invoked when the mouse is dragged. Updates the models as appropriate.
void ContinueDrag(const views::MouseEvent& event);
+ // Returns true if |typea| and |typeb| should be in the same drag range.
+ bool SameDragType(LauncherItemType typea, LauncherItemType typeb) const;
+
// Returns the range (in the model) the item at the specified index can be
// dragged to.
std::pair<int,int> GetDragRange(int index);