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

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

Issue 265713007: views: Update event-related API to use PointF/RectF instead of Point/Rect. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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 "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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // detached states. 661 // detached states.
662 return detached_overlap + static_cast<int>( 662 return detached_overlap + static_cast<int>(
663 (attached_overlap - detached_overlap) * 663 (attached_overlap - detached_overlap) *
664 size_animation_->GetCurrentValue()); 664 size_animation_->GetCurrentValue());
665 } 665 }
666 666
667 gfx::Size BookmarkBarView::GetPreferredSize() { 667 gfx::Size BookmarkBarView::GetPreferredSize() {
668 return LayoutItems(true); 668 return LayoutItems(true);
669 } 669 }
670 670
671 bool BookmarkBarView::HitTestRect(const gfx::Rect& rect) const { 671 bool BookmarkBarView::HitTestRect(const gfx::RectF& rect) const {
672 // If bookmark bar is attached and omnibox popup is open (on top of the bar), 672 // If bookmark bar is attached and omnibox popup is open (on top of the bar),
673 // force hit-testing to fail. This prevents hovers/clicks just above the 673 // force hit-testing to fail. This prevents hovers/clicks just above the
674 // omnibox popup from activating the top few pixels of items on the bookmark 674 // omnibox popup from activating the top few pixels of items on the bookmark
675 // bar. 675 // bar.
676 if (!IsDetached() && browser_view_ && 676 if (!IsDetached() && browser_view_ &&
677 browser_view_->GetLocationBar()->GetOmniboxView()->model()-> 677 browser_view_->GetLocationBar()->GetOmniboxView()->model()->
678 popup_model()->IsOpen()) { 678 popup_model()->IsOpen()) {
679 return false; 679 return false;
680 } 680 }
681 return DetachableToolbarView::HitTestRect(rect); 681 return DetachableToolbarView::HitTestRect(rect);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 Layout(); 1070 Layout();
1071 SchedulePaint(); 1071 SchedulePaint();
1072 } 1072 }
1073 1073
1074 void BookmarkBarView::BookmarkNodeFaviconChanged(BookmarkModel* model, 1074 void BookmarkBarView::BookmarkNodeFaviconChanged(BookmarkModel* model,
1075 const BookmarkNode* node) { 1075 const BookmarkNode* node) {
1076 BookmarkNodeChangedImpl(model, node); 1076 BookmarkNodeChangedImpl(model, node);
1077 } 1077 }
1078 1078
1079 void BookmarkBarView::WriteDragDataForView(View* sender, 1079 void BookmarkBarView::WriteDragDataForView(View* sender,
1080 const gfx::Point& press_pt, 1080 const gfx::PointF& press_pt,
1081 ui::OSExchangeData* data) { 1081 ui::OSExchangeData* data) {
1082 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); 1082 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton"));
1083 1083
1084 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 1084 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
1085 if (sender == GetBookmarkButton(i)) { 1085 if (sender == GetBookmarkButton(i)) {
1086 views::TextButton* button = GetBookmarkButton(i); 1086 views::TextButton* button = GetBookmarkButton(i);
1087 scoped_ptr<gfx::Canvas> canvas( 1087 scoped_ptr<gfx::Canvas> canvas(
1088 views::GetCanvasForDragImage(button->GetWidget(), button->size())); 1088 views::GetCanvasForDragImage(button->GetWidget(), button->size()));
1089 button->PaintButton(canvas.get(), views::TextButton::PB_FOR_DRAG); 1089 button->PaintButton(canvas.get(), views::TextButton::PB_FOR_DRAG);
1090 drag_utils::SetDragImageOnDataObject(*canvas, button->size(), 1090 drag_utils::SetDragImageOnDataObject(
1091 press_pt.OffsetFromOrigin(), 1091 *canvas,
1092 data); 1092 button->size(),
1093 gfx::ToFlooredPoint(press_pt).OffsetFromOrigin(),
1094 data);
1093 WriteBookmarkDragData(model_->bookmark_bar_node()->GetChild(i), data); 1095 WriteBookmarkDragData(model_->bookmark_bar_node()->GetChild(i), data);
1094 return; 1096 return;
1095 } 1097 }
1096 } 1098 }
1097 NOTREACHED(); 1099 NOTREACHED();
1098 } 1100 }
1099 1101
1100 int BookmarkBarView::GetDragOperationsForView(View* sender, 1102 int BookmarkBarView::GetDragOperationsForView(View* sender,
1101 const gfx::Point& p) { 1103 const gfx::PointF& p) {
1102 if (size_animation_->is_animating() || 1104 if (size_animation_->is_animating() ||
1103 (size_animation_->GetCurrentValue() == 0 && 1105 (size_animation_->GetCurrentValue() == 0 &&
1104 bookmark_bar_state_ != BookmarkBar::DETACHED)) { 1106 bookmark_bar_state_ != BookmarkBar::DETACHED)) {
1105 // Don't let the user drag while animating open or we're closed (and not 1107 // Don't let the user drag while animating open or we're closed (and not
1106 // detached, when detached size_animation_ is always 0). This typically is 1108 // detached, when detached size_animation_ is always 0). This typically is
1107 // only hit if the user does something to inadvertently trigger DnD such as 1109 // only hit if the user does something to inadvertently trigger DnD such as
1108 // pressing the mouse and hitting control-b. 1110 // pressing the mouse and hitting control-b.
1109 return ui::DragDropTypes::DRAG_NONE; 1111 return ui::DragDropTypes::DRAG_NONE;
1110 } 1112 }
1111 1113
1112 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 1114 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
1113 if (sender == GetBookmarkButton(i)) { 1115 if (sender == GetBookmarkButton(i)) {
1114 return chrome::GetBookmarkDragOperation( 1116 return chrome::GetBookmarkDragOperation(
1115 browser_->profile(), model_->bookmark_bar_node()->GetChild(i)); 1117 browser_->profile(), model_->bookmark_bar_node()->GetChild(i));
1116 } 1118 }
1117 } 1119 }
1118 NOTREACHED(); 1120 NOTREACHED();
1119 return ui::DragDropTypes::DRAG_NONE; 1121 return ui::DragDropTypes::DRAG_NONE;
1120 } 1122 }
1121 1123
1122 bool BookmarkBarView::CanStartDragForView(views::View* sender, 1124 bool BookmarkBarView::CanStartDragForView(views::View* sender,
1123 const gfx::Point& press_pt, 1125 const gfx::PointF& press_pt,
1124 const gfx::Point& p) { 1126 const gfx::PointF& p) {
1125 // Check if we have not moved enough horizontally but we have moved downward 1127 // Check if we have not moved enough horizontally but we have moved downward
1126 // vertically - downward drag. 1128 // vertically - downward drag.
1127 gfx::Vector2d move_offset = p - press_pt; 1129 gfx::Vector2dF move_offset = p - press_pt;
1128 gfx::Vector2d horizontal_offset(move_offset.x(), 0); 1130 gfx::Vector2dF horizontal_offset(move_offset.x(), 0);
1129 if (!View::ExceededDragThreshold(horizontal_offset) && move_offset.y() > 0) { 1131 if (!View::ExceededDragThreshold(horizontal_offset) && move_offset.y() > 0) {
1130 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 1132 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
1131 if (sender == GetBookmarkButton(i)) { 1133 if (sender == GetBookmarkButton(i)) {
1132 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); 1134 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i);
1133 // If the folder button was dragged, show the menu instead. 1135 // If the folder button was dragged, show the menu instead.
1134 if (node && node->is_folder()) { 1136 if (node && node->is_folder()) {
1135 views::MenuButton* menu_button = 1137 views::MenuButton* menu_button =
1136 static_cast<views::MenuButton*>(sender); 1138 static_cast<views::MenuButton*>(sender);
1137 menu_button->Activate(); 1139 menu_button->Activate();
1138 return false; 1140 return false;
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 DCHECK(apps_page_shortcut_); 1852 DCHECK(apps_page_shortcut_);
1851 // Only perform layout if required. 1853 // Only perform layout if required.
1852 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( 1854 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar(
1853 browser_->profile(), browser_->host_desktop_type()); 1855 browser_->profile(), browser_->host_desktop_type());
1854 if (apps_page_shortcut_->visible() == visible) 1856 if (apps_page_shortcut_->visible() == visible)
1855 return; 1857 return;
1856 apps_page_shortcut_->SetVisible(visible); 1858 apps_page_shortcut_->SetVisible(visible);
1857 UpdateBookmarksSeparatorVisibility(); 1859 UpdateBookmarksSeparatorVisibility();
1858 Layout(); 1860 Layout();
1859 } 1861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698