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

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

Issue 2041033002: Moved ButtonInkDropDelegate logic into InkDropHostView and deleted InkDropDelegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "ui/gfx/canvas.h" 88 #include "ui/gfx/canvas.h"
89 #include "ui/gfx/color_utils.h" 89 #include "ui/gfx/color_utils.h"
90 #include "ui/gfx/favicon_size.h" 90 #include "ui/gfx/favicon_size.h"
91 #include "ui/gfx/geometry/rect.h" 91 #include "ui/gfx/geometry/rect.h"
92 #include "ui/gfx/paint_vector_icon.h" 92 #include "ui/gfx/paint_vector_icon.h"
93 #include "ui/gfx/scoped_canvas.h" 93 #include "ui/gfx/scoped_canvas.h"
94 #include "ui/gfx/text_constants.h" 94 #include "ui/gfx/text_constants.h"
95 #include "ui/gfx/text_elider.h" 95 #include "ui/gfx/text_elider.h"
96 #include "ui/gfx/vector_icons_public.h" 96 #include "ui/gfx/vector_icons_public.h"
97 #include "ui/resources/grit/ui_resources.h" 97 #include "ui/resources/grit/ui_resources.h"
98 #include "ui/views/animation/button_ink_drop_delegate.h"
99 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 98 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
100 #include "ui/views/animation/ink_drop_highlight.h" 99 #include "ui/views/animation/ink_drop_highlight.h"
101 #include "ui/views/button_drag_utils.h" 100 #include "ui/views/button_drag_utils.h"
102 #include "ui/views/controls/button/label_button.h" 101 #include "ui/views/controls/button/label_button.h"
103 #include "ui/views/controls/button/label_button_border.h" 102 #include "ui/views/controls/button/label_button_border.h"
104 #include "ui/views/controls/button/menu_button.h" 103 #include "ui/views/controls/button/menu_button.h"
105 #include "ui/views/controls/label.h" 104 #include "ui/views/controls/label.h"
106 #include "ui/views/drag_utils.h" 105 #include "ui/views/drag_utils.h"
107 #include "ui/views/metrics.h" 106 #include "ui/views/metrics.h"
108 #include "ui/views/view_constants.h" 107 #include "ui/views/view_constants.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // BookmarkButtonBase ----------------------------------------------- 198 // BookmarkButtonBase -----------------------------------------------
200 199
201 // Base class for non-menu hosting buttons used on the bookmark bar. 200 // Base class for non-menu hosting buttons used on the bookmark bar.
202 201
203 class BookmarkButtonBase : public views::LabelButton { 202 class BookmarkButtonBase : public views::LabelButton {
204 public: 203 public:
205 BookmarkButtonBase(views::ButtonListener* listener, 204 BookmarkButtonBase(views::ButtonListener* listener,
206 const base::string16& title) 205 const base::string16& title)
207 : LabelButton(listener, title) { 206 : LabelButton(listener, title) {
208 SetElideBehavior(kElideBehavior); 207 SetElideBehavior(kElideBehavior);
209 set_ink_drop_delegate( 208 SetHasInkDrop(true);
210 base::WrapUnique(new views::ButtonInkDropDelegate(this, this)));
211 set_has_ink_drop_action_on_click(true); 209 set_has_ink_drop_action_on_click(true);
212 show_animation_.reset(new gfx::SlideAnimation(this)); 210 show_animation_.reset(new gfx::SlideAnimation(this));
213 if (!animations_enabled) { 211 if (!animations_enabled) {
214 // For some reason during testing the events generated by animating 212 // For some reason during testing the events generated by animating
215 // throw off the test. So, don't animate while testing. 213 // throw off the test. So, don't animate while testing.
216 show_animation_->Reset(1); 214 show_animation_->Reset(1);
217 } else { 215 } else {
218 show_animation_->Show(); 216 show_animation_->Show();
219 } 217 }
220 } 218 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 324
327 // BookmarkMenuButtonBase ----------------------------------------------------- 325 // BookmarkMenuButtonBase -----------------------------------------------------
328 326
329 // Base class for menu hosting buttons used on the bookmark bar. 327 // Base class for menu hosting buttons used on the bookmark bar.
330 class BookmarkMenuButtonBase : public views::MenuButton { 328 class BookmarkMenuButtonBase : public views::MenuButton {
331 public: 329 public:
332 BookmarkMenuButtonBase(const base::string16& title, 330 BookmarkMenuButtonBase(const base::string16& title,
333 views::MenuButtonListener* menu_button_listener, 331 views::MenuButtonListener* menu_button_listener,
334 bool show_menu_marker) 332 bool show_menu_marker)
335 : MenuButton(title, menu_button_listener, show_menu_marker) { 333 : MenuButton(title, menu_button_listener, show_menu_marker) {
336 set_ink_drop_delegate( 334 SetHasInkDrop(true);
337 base::WrapUnique(new views::ButtonInkDropDelegate(this, this)));
338 } 335 }
339 336
340 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 337 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
341 return base::WrapUnique(new views::FloodFillInkDropRipple( 338 return base::WrapUnique(new views::FloodFillInkDropRipple(
342 CalculateInkDropBounds(size()), GetInkDropCenter(), 339 CalculateInkDropBounds(size()), GetInkDropCenter(),
343 GetInkDropBaseColor())); 340 GetInkDropBaseColor()));
344 } 341 }
345 342
346 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 343 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
347 const override { 344 const override {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (label()->GetPreferredSize().width() > label()->size().width()) 385 if (label()->GetPreferredSize().width() > label()->size().width())
389 *tooltip = GetText(); 386 *tooltip = GetText();
390 return !tooltip->empty(); 387 return !tooltip->empty();
391 } 388 }
392 389
393 bool OnMousePressed(const ui::MouseEvent& event) override { 390 bool OnMousePressed(const ui::MouseEvent& event) override {
394 if (event.IsOnlyLeftMouseButton()) { 391 if (event.IsOnlyLeftMouseButton()) {
395 // TODO(bruthig): The ACTION_PENDING triggering logic should be in 392 // TODO(bruthig): The ACTION_PENDING triggering logic should be in
396 // MenuButton::OnPressed() however there is a bug with the pressed state 393 // MenuButton::OnPressed() however there is a bug with the pressed state
397 // logic in MenuButton. See http://crbug.com/567252. 394 // logic in MenuButton. See http://crbug.com/567252.
398 ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING); 395 AnimateInkDrop(views::InkDropState::ACTION_PENDING);
399 } 396 }
400 return MenuButton::OnMousePressed(event); 397 return MenuButton::OnMousePressed(event);
401 } 398 }
402 399
403 bool IsTriggerableEventType(const ui::Event& e) override { 400 bool IsTriggerableEventType(const ui::Event& e) override {
404 // Bookmark folders handle normal menu button events (i.e., left click) as 401 // Bookmark folders handle normal menu button events (i.e., left click) as
405 // well as clicks to open bookmarks in new tabs that would otherwise be 402 // well as clicks to open bookmarks in new tabs that would otherwise be
406 // ignored. 403 // ignored.
407 return BookmarkMenuButtonBase::IsTriggerableEventType(e) || 404 return BookmarkMenuButtonBase::IsTriggerableEventType(e) ||
408 (e.IsMouseEvent() && 405 (e.IsMouseEvent() &&
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 return; 2154 return;
2158 apps_page_shortcut_->SetVisible(visible); 2155 apps_page_shortcut_->SetVisible(visible);
2159 UpdateBookmarksSeparatorVisibility(); 2156 UpdateBookmarksSeparatorVisibility();
2160 LayoutAndPaint(); 2157 LayoutAndPaint();
2161 } 2158 }
2162 2159
2163 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2160 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2164 if (UpdateOtherAndManagedButtonsVisibility()) 2161 if (UpdateOtherAndManagedButtonsVisibility())
2165 LayoutAndPaint(); 2162 LayoutAndPaint();
2166 } 2163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698