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

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

Issue 9042: Adds support for autoscrolling on drag to bookmark tree/table.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/bookmark_bar_view.h" 5 #include "chrome/browser/views/bookmark_bar_view.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/base_drag_source.h" 9 #include "base/base_drag_source.h"
10 #include "base/gfx/skia_utils.h" 10 #include "base/gfx/skia_utils.h"
(...skipping 26 matching lines...) Expand all
37 #include "chrome/common/os_exchange_data.h" 37 #include "chrome/common/os_exchange_data.h"
38 #include "chrome/common/page_transition_types.h" 38 #include "chrome/common/page_transition_types.h"
39 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
40 #include "chrome/common/pref_service.h" 40 #include "chrome/common/pref_service.h"
41 #include "chrome/common/resource_bundle.h" 41 #include "chrome/common/resource_bundle.h"
42 #include "chrome/common/win_util.h" 42 #include "chrome/common/win_util.h"
43 #include "chrome/views/chrome_menu.h" 43 #include "chrome/views/chrome_menu.h"
44 #include "chrome/views/container.h" 44 #include "chrome/views/container.h"
45 #include "chrome/views/menu_button.h" 45 #include "chrome/views/menu_button.h"
46 #include "chrome/views/tooltip_manager.h" 46 #include "chrome/views/tooltip_manager.h"
47 #include "chrome/views/view_constants.h"
47 #include "chrome/views/window.h" 48 #include "chrome/views/window.h"
48 #include "generated_resources.h" 49 #include "generated_resources.h"
49 50
50 using views::BaseButton; 51 using views::BaseButton;
51 using views::DropTargetEvent; 52 using views::DropTargetEvent;
52 using views::MenuButton; 53 using views::MenuButton;
53 using views::MenuItemView; 54 using views::MenuItemView;
54 using views::View; 55 using views::View;
55 56
56 // Margins around the content. 57 // Margins around the content.
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 // Mouse is over 'other' folder. 1663 // Mouse is over 'other' folder.
1663 *is_over_other = true; 1664 *is_over_other = true;
1664 *drop_on = true; 1665 *drop_on = true;
1665 found = true; 1666 found = true;
1666 } else if (!GetBookmarkButtonCount()) { 1667 } else if (!GetBookmarkButtonCount()) {
1667 // No bookmarks, accept the drop. 1668 // No bookmarks, accept the drop.
1668 *index = 0; 1669 *index = 0;
1669 int ops = data.GetFirstNode(profile_) 1670 int ops = data.GetFirstNode(profile_)
1670 ? DragDropTypes::DRAG_MOVE 1671 ? DragDropTypes::DRAG_MOVE
1671 : DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK; 1672 : DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK;
1672 return bookmark_utils::PreferredDropOperation(event, ops); 1673 return
1674 bookmark_utils::PreferredDropOperation(event.GetSourceOperations(),
1675 ops);
1673 } 1676 }
1674 1677
1675 for (int i = 0; i < GetBookmarkButtonCount() && 1678 for (int i = 0; i < GetBookmarkButtonCount() &&
1676 GetBookmarkButton(i)->IsVisible() && !found; i++) { 1679 GetBookmarkButton(i)->IsVisible() && !found; i++) {
1677 views::TextButton* button = GetBookmarkButton(i); 1680 views::TextButton* button = GetBookmarkButton(i);
1678 int button_x = mirrored_x - button->x(); 1681 int button_x = mirrored_x - button->x();
1679 int button_w = button->width(); 1682 int button_w = button->width();
1680 if (button_x < button_w) { 1683 if (button_x < button_w) {
1681 found = true; 1684 found = true;
1682 BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(i); 1685 BookmarkNode* node = model_->GetBookmarkBarNode()->GetChild(i);
1683 if (node->GetType() != history::StarredEntry::URL) { 1686 if (node->GetType() != history::StarredEntry::URL) {
1684 if (button_x <= MenuItemView::kDropBetweenPixels) { 1687 if (button_x <= views::kDropBetweenPixels) {
1685 *index = i; 1688 *index = i;
1686 } else if (button_x < button_w - MenuItemView::kDropBetweenPixels) { 1689 } else if (button_x < button_w - views::kDropBetweenPixels) {
1687 *index = i; 1690 *index = i;
1688 *drop_on = true; 1691 *drop_on = true;
1689 } else { 1692 } else {
1690 *index = i + 1; 1693 *index = i + 1;
1691 } 1694 }
1692 } else if (button_x < button_w / 2) { 1695 } else if (button_x < button_w / 2) {
1693 *index = i; 1696 *index = i;
1694 } else { 1697 } else {
1695 *index = i + 1; 1698 *index = i + 1;
1696 } 1699 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 1755
1753 if (!bookmark_utils::IsValidDropLocation(profile_, data, parent, index)) 1756 if (!bookmark_utils::IsValidDropLocation(profile_, data, parent, index))
1754 return DragDropTypes::DRAG_NONE; 1757 return DragDropTypes::DRAG_NONE;
1755 1758
1756 if (data.GetFirstNode(profile_)) { 1759 if (data.GetFirstNode(profile_)) {
1757 // User is dragging from this profile: move. 1760 // User is dragging from this profile: move.
1758 return DragDropTypes::DRAG_MOVE; 1761 return DragDropTypes::DRAG_MOVE;
1759 } else { 1762 } else {
1760 // User is dragging from another app, copy. 1763 // User is dragging from another app, copy.
1761 return bookmark_utils::PreferredDropOperation( 1764 return bookmark_utils::PreferredDropOperation(
1762 event, DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK); 1765 event.GetSourceOperations(),
1766 DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK);
1763 } 1767 }
1764 } 1768 }
1765 1769
1766 int BookmarkBarView::PerformDropImpl(const BookmarkDragData& data, 1770 int BookmarkBarView::PerformDropImpl(const BookmarkDragData& data,
1767 BookmarkNode* parent_node, 1771 BookmarkNode* parent_node,
1768 int index) { 1772 int index) {
1769 BookmarkNode* dragged_node = data.GetFirstNode(profile_); 1773 BookmarkNode* dragged_node = data.GetFirstNode(profile_);
1770 if (dragged_node) { 1774 if (dragged_node) {
1771 // Drag from same profile, do a move. 1775 // Drag from same profile, do a move.
1772 model_->Move(dragged_node, parent_node, index); 1776 model_->Move(dragged_node, parent_node, index);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 } 1838 }
1835 1839
1836 void BookmarkBarView::StopThrobbing(bool immediate) { 1840 void BookmarkBarView::StopThrobbing(bool immediate) {
1837 if (!throbbing_view_) 1841 if (!throbbing_view_)
1838 return; 1842 return;
1839 1843
1840 // If not immediate, cycle through 2 more complete cycles. 1844 // If not immediate, cycle through 2 more complete cycles.
1841 throbbing_view_->StartThrobbing(immediate ? 0 : 4); 1845 throbbing_view_->StartThrobbing(immediate ? 0 : 4);
1842 throbbing_view_ = NULL; 1846 throbbing_view_ = NULL;
1843 } 1847 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698