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 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 const gfx::Point& press_pt, | 998 const gfx::Point& press_pt, |
999 ui::OSExchangeData* data) { | 999 ui::OSExchangeData* data) { |
1000 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); | 1000 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); |
1001 | 1001 |
1002 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 1002 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
1003 if (sender == GetBookmarkButton(i)) { | 1003 if (sender == GetBookmarkButton(i)) { |
1004 views::TextButton* button = GetBookmarkButton(i); | 1004 views::TextButton* button = GetBookmarkButton(i); |
1005 scoped_ptr<gfx::Canvas> canvas( | 1005 scoped_ptr<gfx::Canvas> canvas( |
1006 views::GetCanvasForDragImage(button->GetWidget(), button->size())); | 1006 views::GetCanvasForDragImage(button->GetWidget(), button->size())); |
1007 button->PaintButton(canvas.get(), views::TextButton::PB_FOR_DRAG); | 1007 button->PaintButton(canvas.get(), views::TextButton::PB_FOR_DRAG); |
1008 drag_utils::SetDragImageOnDataObject(*canvas, button->size(), press_pt, | 1008 drag_utils::SetDragImageOnDataObject(*canvas, button->size(), |
| 1009 press_pt.OffsetFromOrigin(), |
1009 data); | 1010 data); |
1010 WriteBookmarkDragData(model_->bookmark_bar_node()->GetChild(i), data); | 1011 WriteBookmarkDragData(model_->bookmark_bar_node()->GetChild(i), data); |
1011 return; | 1012 return; |
1012 } | 1013 } |
1013 } | 1014 } |
1014 NOTREACHED(); | 1015 NOTREACHED(); |
1015 } | 1016 } |
1016 | 1017 |
1017 int BookmarkBarView::GetDragOperationsForView(View* sender, | 1018 int BookmarkBarView::GetDragOperationsForView(View* sender, |
1018 const gfx::Point& p) { | 1019 const gfx::Point& p) { |
(...skipping 15 matching lines...) Expand all Loading... |
1034 } | 1035 } |
1035 NOTREACHED(); | 1036 NOTREACHED(); |
1036 return ui::DragDropTypes::DRAG_NONE; | 1037 return ui::DragDropTypes::DRAG_NONE; |
1037 } | 1038 } |
1038 | 1039 |
1039 bool BookmarkBarView::CanStartDragForView(views::View* sender, | 1040 bool BookmarkBarView::CanStartDragForView(views::View* sender, |
1040 const gfx::Point& press_pt, | 1041 const gfx::Point& press_pt, |
1041 const gfx::Point& p) { | 1042 const gfx::Point& p) { |
1042 // Check if we have not moved enough horizontally but we have moved downward | 1043 // Check if we have not moved enough horizontally but we have moved downward |
1043 // vertically - downward drag. | 1044 // vertically - downward drag. |
1044 if (!View::ExceededDragThreshold(press_pt.x() - p.x(), 0) && | 1045 gfx::Vector2d move_offset = p - press_pt; |
1045 press_pt.y() < p.y()) { | 1046 gfx::Vector2d horizontal_offset(move_offset.x(), 0); |
| 1047 if (!View::ExceededDragThreshold(horizontal_offset) && move_offset.y() > 0) { |
1046 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 1048 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
1047 if (sender == GetBookmarkButton(i)) { | 1049 if (sender == GetBookmarkButton(i)) { |
1048 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); | 1050 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); |
1049 // If the folder button was dragged, show the menu instead. | 1051 // If the folder button was dragged, show the menu instead. |
1050 if (node && node->is_folder()) { | 1052 if (node && node->is_folder()) { |
1051 views::MenuButton* menu_button = | 1053 views::MenuButton* menu_button = |
1052 static_cast<views::MenuButton*>(sender); | 1054 static_cast<views::MenuButton*>(sender); |
1053 menu_button->Activate(); | 1055 menu_button->Activate(); |
1054 return false; | 1056 return false; |
1055 } | 1057 } |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 (1 - size_animation_->GetCurrentValue()))); | 1739 (1 - size_animation_->GetCurrentValue()))); |
1738 } else { | 1740 } else { |
1739 prefsize.set_height( | 1741 prefsize.set_height( |
1740 static_cast<int>( | 1742 static_cast<int>( |
1741 browser_defaults::kBookmarkBarHeight * | 1743 browser_defaults::kBookmarkBarHeight * |
1742 size_animation_->GetCurrentValue())); | 1744 size_animation_->GetCurrentValue())); |
1743 } | 1745 } |
1744 } | 1746 } |
1745 return prefsize; | 1747 return prefsize; |
1746 } | 1748 } |
OLD | NEW |