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

Side by Side Diff: chrome/browser/ui/views/bookmark_bar_view.cc

Issue 6250014: Move more dnd related files to ui/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
OLDNEW
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 "chrome/browser/ui/views/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 drop_info_.reset(); 667 drop_info_.reset();
668 } 668 }
669 669
670 int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) { 670 int BookmarkBarView::OnPerformDrop(const DropTargetEvent& event) {
671 StopShowFolderDropMenuTimer(); 671 StopShowFolderDropMenuTimer();
672 672
673 if (bookmark_drop_menu_) 673 if (bookmark_drop_menu_)
674 bookmark_drop_menu_->Cancel(); 674 bookmark_drop_menu_->Cancel();
675 675
676 if (!drop_info_.get() || !drop_info_->drag_operation) 676 if (!drop_info_.get() || !drop_info_->drag_operation)
677 return DragDropTypes::DRAG_NONE; 677 return ui::DragDropTypes::DRAG_NONE;
678 678
679 const BookmarkNode* root = 679 const BookmarkNode* root =
680 drop_info_->is_over_other ? model_->other_node() : 680 drop_info_->is_over_other ? model_->other_node() :
681 model_->GetBookmarkBarNode(); 681 model_->GetBookmarkBarNode();
682 int index = drop_info_->drop_index; 682 int index = drop_info_->drop_index;
683 const bool drop_on = drop_info_->drop_on; 683 const bool drop_on = drop_info_->drop_on;
684 const BookmarkNodeData data = drop_info_->data; 684 const BookmarkNodeData data = drop_info_->data;
685 const bool is_over_other = drop_info_->is_over_other; 685 const bool is_over_other = drop_info_->is_over_other;
686 DCHECK(data.is_valid()); 686 DCHECK(data.is_valid());
687 687
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 NOTREACHED(); 1127 NOTREACHED();
1128 } 1128 }
1129 1129
1130 int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) { 1130 int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) {
1131 if (size_animation_->is_animating() || 1131 if (size_animation_->is_animating() ||
1132 (size_animation_->GetCurrentValue() == 0 && !OnNewTabPage())) { 1132 (size_animation_->GetCurrentValue() == 0 && !OnNewTabPage())) {
1133 // Don't let the user drag while animating open or we're closed (and not on 1133 // Don't let the user drag while animating open or we're closed (and not on
1134 // the new tab page, on the new tab page size_animation_ is always 0). This 1134 // the new tab page, on the new tab page size_animation_ is always 0). This
1135 // typically is only hit if the user does something to inadvertanty trigger 1135 // typically is only hit if the user does something to inadvertanty trigger
1136 // dnd, such as pressing the mouse and hitting control-b. 1136 // dnd, such as pressing the mouse and hitting control-b.
1137 return DragDropTypes::DRAG_NONE; 1137 return ui::DragDropTypes::DRAG_NONE;
1138 } 1138 }
1139 1139
1140 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 1140 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
1141 if (sender == GetBookmarkButton(i)) { 1141 if (sender == GetBookmarkButton(i)) {
1142 return bookmark_utils::BookmarkDragOperation( 1142 return bookmark_utils::BookmarkDragOperation(
1143 model_->GetBookmarkBarNode()->GetChild(i)); 1143 model_->GetBookmarkBarNode()->GetChild(i));
1144 } 1144 }
1145 } 1145 }
1146 NOTREACHED(); 1146 NOTREACHED();
1147 return DragDropTypes::DRAG_NONE; 1147 return ui::DragDropTypes::DRAG_NONE;
1148 } 1148 }
1149 1149
1150 bool BookmarkBarView::CanStartDrag(views::View* sender, 1150 bool BookmarkBarView::CanStartDrag(views::View* sender,
1151 const gfx::Point& press_pt, 1151 const gfx::Point& press_pt,
1152 const gfx::Point& p) { 1152 const gfx::Point& p) {
1153 // Check if we have not moved enough horizontally but we have moved downward 1153 // Check if we have not moved enough horizontally but we have moved downward
1154 // vertically - downward drag. 1154 // vertically - downward drag.
1155 if (!View::ExceededDragThreshold(press_pt.x() - p.x(), 0) && 1155 if (!View::ExceededDragThreshold(press_pt.x() - p.x(), 0) &&
1156 press_pt.y() < p.y()) { 1156 press_pt.y() < p.y()) {
1157 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 1157 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 int mirrored_x = MirroredXCoordinateInsideView(event.x()); 1419 int mirrored_x = MirroredXCoordinateInsideView(event.x());
1420 1420
1421 *index = -1; 1421 *index = -1;
1422 *drop_on = false; 1422 *drop_on = false;
1423 *is_over_other = *is_over_overflow = false; 1423 *is_over_other = *is_over_overflow = false;
1424 1424
1425 if (event.y() < other_bookmarked_button_->y() || 1425 if (event.y() < other_bookmarked_button_->y() ||
1426 event.y() >= other_bookmarked_button_->y() + 1426 event.y() >= other_bookmarked_button_->y() +
1427 other_bookmarked_button_->height()) { 1427 other_bookmarked_button_->height()) {
1428 // Mouse isn't over a button. 1428 // Mouse isn't over a button.
1429 return DragDropTypes::DRAG_NONE; 1429 return ui::DragDropTypes::DRAG_NONE;
1430 } 1430 }
1431 1431
1432 bool found = false; 1432 bool found = false;
1433 const int other_delta_x = mirrored_x - other_bookmarked_button_->x(); 1433 const int other_delta_x = mirrored_x - other_bookmarked_button_->x();
1434 if (other_delta_x >= 0 && 1434 if (other_delta_x >= 0 &&
1435 other_delta_x < other_bookmarked_button_->width()) { 1435 other_delta_x < other_bookmarked_button_->width()) {
1436 // Mouse is over 'other' folder. 1436 // Mouse is over 'other' folder.
1437 *is_over_other = true; 1437 *is_over_other = true;
1438 *drop_on = true; 1438 *drop_on = true;
1439 found = true; 1439 found = true;
1440 } else if (!GetBookmarkButtonCount()) { 1440 } else if (!GetBookmarkButtonCount()) {
1441 // No bookmarks, accept the drop. 1441 // No bookmarks, accept the drop.
1442 *index = 0; 1442 *index = 0;
1443 int ops = data.GetFirstNode(profile_) 1443 int ops = data.GetFirstNode(profile_)
1444 ? DragDropTypes::DRAG_MOVE 1444 ? ui::DragDropTypes::DRAG_MOVE
1445 : DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK; 1445 : ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK;
1446 return 1446 return
1447 bookmark_utils::PreferredDropOperation(event.GetSourceOperations(), 1447 bookmark_utils::PreferredDropOperation(event.GetSourceOperations(),
1448 ops); 1448 ops);
1449 } 1449 }
1450 1450
1451 for (int i = 0; i < GetBookmarkButtonCount() && 1451 for (int i = 0; i < GetBookmarkButtonCount() &&
1452 GetBookmarkButton(i)->IsVisible() && !found; i++) { 1452 GetBookmarkButton(i)->IsVisible() && !found; i++) {
1453 views::TextButton* button = GetBookmarkButton(i); 1453 views::TextButton* button = GetBookmarkButton(i);
1454 int button_x = mirrored_x - button->x(); 1454 int button_x = mirrored_x - button->x();
1455 int button_w = button->width(); 1455 int button_w = button->width();
(...skipping 25 matching lines...) Expand all
1481 if (overflow_delta_x >= 0 && 1481 if (overflow_delta_x >= 0 &&
1482 overflow_delta_x < overflow_button_->width()) { 1482 overflow_delta_x < overflow_button_->width()) {
1483 // Mouse is over overflow button. 1483 // Mouse is over overflow button.
1484 *index = GetFirstHiddenNodeIndex(); 1484 *index = GetFirstHiddenNodeIndex();
1485 *is_over_overflow = true; 1485 *is_over_overflow = true;
1486 } else if (overflow_delta_x < 0) { 1486 } else if (overflow_delta_x < 0) {
1487 // Mouse is after the last visible button but before overflow button; 1487 // Mouse is after the last visible button but before overflow button;
1488 // use the last visible index. 1488 // use the last visible index.
1489 *index = GetFirstHiddenNodeIndex(); 1489 *index = GetFirstHiddenNodeIndex();
1490 } else { 1490 } else {
1491 return DragDropTypes::DRAG_NONE; 1491 return ui::DragDropTypes::DRAG_NONE;
1492 } 1492 }
1493 } else if (mirrored_x < other_bookmarked_button_->x()) { 1493 } else if (mirrored_x < other_bookmarked_button_->x()) {
1494 // Mouse is after the last visible button but before more recently 1494 // Mouse is after the last visible button but before more recently
1495 // bookmarked; use the last visible index. 1495 // bookmarked; use the last visible index.
1496 *index = GetFirstHiddenNodeIndex(); 1496 *index = GetFirstHiddenNodeIndex();
1497 } else { 1497 } else {
1498 return DragDropTypes::DRAG_NONE; 1498 return ui::DragDropTypes::DRAG_NONE;
1499 } 1499 }
1500 } 1500 }
1501 1501
1502 if (*drop_on) { 1502 if (*drop_on) {
1503 const BookmarkNode* parent = 1503 const BookmarkNode* parent =
1504 *is_over_other ? model_->other_node() : 1504 *is_over_other ? model_->other_node() :
1505 model_->GetBookmarkBarNode()->GetChild(*index); 1505 model_->GetBookmarkBarNode()->GetChild(*index);
1506 int operation = 1506 int operation =
1507 bookmark_utils::BookmarkDropOperation(profile_, event, data, parent, 1507 bookmark_utils::BookmarkDropOperation(profile_, event, data, parent,
1508 parent->GetChildCount()); 1508 parent->GetChildCount());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 // The tooltip is the only way we have to display text explaining the error 1734 // The tooltip is the only way we have to display text explaining the error
1735 // to the user. 1735 // to the user.
1736 sync_error_button->SetTooltipText( 1736 sync_error_button->SetTooltipText(
1737 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); 1737 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)));
1738 sync_error_button->SetAccessibleName( 1738 sync_error_button->SetAccessibleName(
1739 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); 1739 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON));
1740 sync_error_button->SetIcon( 1740 sync_error_button->SetIcon(
1741 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); 1741 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING));
1742 return sync_error_button; 1742 return sync_error_button;
1743 } 1743 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmark_bar_view.h ('k') | chrome/browser/ui/views/browser_actions_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698