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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 1757993004: Added ink drop hover/ripple to menu hosting bookmark buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated the ripple to behave resonably when showing context menus. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index fbe276202a5ce54b8c9ae9f291f50a3b0d0bb240..66aa4055540b305df368bec6a649dd8bfbac271a 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -94,6 +94,8 @@
#include "ui/gfx/vector_icons_public.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/animation/button_ink_drop_delegate.h"
+#include "ui/views/animation/flood_fill_ink_drop_animation.h"
+#include "ui/views/animation/ink_drop_hover.h"
#include "ui/views/button_drag_utils.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/label_button_border.h"
@@ -188,7 +190,7 @@ int GetHorizontalMargin() {
// BookmarkButtonBase -----------------------------------------------
-// Base class for buttons used on the bookmark bar.
+// Base class for non-menu hosting buttons used on the bookmark bar.
class BookmarkButtonBase : public views::LabelButton {
public:
@@ -227,9 +229,23 @@ class BookmarkButtonBase : public views::LabelButton {
event_utils::IsPossibleDispositionEvent(e);
}
+ scoped_ptr<views::InkDropAnimation> CreateInkDropAnimation() const override {
+ return make_scoped_ptr(new views::FloodFillInkDropAnimation(
+ size(), GetInkDropCenter(), GetInkDropBaseColor()));
+ }
+
+ scoped_ptr<views::InkDropHover> CreateInkDropHover() const override {
+ if (!ShouldShowInkDropHover())
+ return nullptr;
+ return make_scoped_ptr(new views::InkDropHover(
+ size(), 0, GetInkDropCenter(), GetInkDropBaseColor()));
+ }
+
SkColor GetInkDropBaseColor() const override {
- return GetThemeProvider()->GetColor(
- ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
+ return GetThemeProvider()
varkha 2016/03/11 17:57:17 When is there no ThemeProvider? Maybe a comment.
bruthig 2016/03/11 21:58:20 Done.
+ ? GetThemeProvider()->GetColor(
+ ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON)
+ : views::LabelButton::GetInkDropBaseColor();
}
private:
@@ -302,14 +318,51 @@ const char ShortcutButton::kViewClassName[] = "ShortcutButton";
// BookmarkFolderButton -------------------------------------------------------
varkha 2016/03/11 17:57:17 Move this down and add another section.
bruthig 2016/03/11 21:58:20 Done.
+// Base class for menu hosting buttons used on the bookmark bar.
+class BookmarkMenuButtonBase : public views::MenuButton {
+ public:
+ BookmarkMenuButtonBase(const base::string16& title,
+ views::MenuButtonListener* menu_button_listener,
+ bool show_menu_marker)
+ : MenuButton(title, menu_button_listener, show_menu_marker),
+ ink_drop_delegate_(this, this) {
+ set_ink_drop_delegate(&ink_drop_delegate_);
+ }
+
+ scoped_ptr<views::InkDropAnimation> CreateInkDropAnimation() const override {
+ return make_scoped_ptr(new views::FloodFillInkDropAnimation(
+ size(), GetInkDropCenter(), GetInkDropBaseColor()));
+ }
+
+ scoped_ptr<views::InkDropHover> CreateInkDropHover() const override {
+ if (!ShouldShowInkDropHover())
+ return nullptr;
+ return make_scoped_ptr(new views::InkDropHover(
+ size(), 0, GetInkDropCenter(), GetInkDropBaseColor()));
+ }
+
+ SkColor GetInkDropBaseColor() const override {
+ return GetThemeProvider()
+ ? GetThemeProvider()->GetColor(
+ ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON)
+ : views::LabelButton::GetInkDropBaseColor();
+ }
+
+ private:
+ // Controls the visual feedback for the button state.
+ views::ButtonInkDropDelegate ink_drop_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase);
+};
+
// Buttons used for folders on the bookmark bar, including the 'other folders'
// button.
-class BookmarkFolderButton : public views::MenuButton {
+class BookmarkFolderButton : public BookmarkMenuButtonBase {
public:
BookmarkFolderButton(const base::string16& title,
views::MenuButtonListener* menu_button_listener,
bool show_menu_marker)
- : MenuButton(title, menu_button_listener, show_menu_marker) {
+ : BookmarkMenuButtonBase(title, menu_button_listener, show_menu_marker) {
SetElideBehavior(kElideBehavior);
show_animation_.reset(new gfx::SlideAnimation(this));
if (!animations_enabled) {
@@ -328,13 +381,23 @@ class BookmarkFolderButton : public views::MenuButton {
return !tooltip->empty();
}
+ bool OnMousePressed(const ui::MouseEvent& event) override {
+ if (event.IsOnlyLeftMouseButton()) {
+ // TODO(bruthig): The ACTION_PENDING triggering logic should be in
+ // MenuButton::OnPressed() however there is a bug with the pressed state
+ // logic in MenuButton. See http://crbug.com/567252.
+ ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING);
+ }
+ return MenuButton::OnMousePressed(event);
+ }
+
bool IsTriggerableEventType(const ui::Event& e) override {
// Bookmark folders handle normal menu button events (i.e., left click) as
// well as clicks to open bookmarks in new tabs that would otherwise be
// ignored.
- return views::MenuButton::IsTriggerableEventType(e) ||
+ return BookmarkMenuButtonBase::IsTriggerableEventType(e) ||
(e.IsMouseEvent() &&
- ui::DispositionFromEventFlags(e.flags()) != CURRENT_TAB);
+ ui::DispositionFromEventFlags(e.flags()) != CURRENT_TAB);
}
private:
@@ -345,14 +408,14 @@ class BookmarkFolderButton : public views::MenuButton {
// OverflowButton (chevron) --------------------------------------------------
-class OverflowButton : public views::MenuButton {
+class OverflowButton : public BookmarkMenuButtonBase {
public:
explicit OverflowButton(BookmarkBarView* owner)
- : MenuButton(base::string16(), owner, false), owner_(owner) {}
+ : BookmarkMenuButtonBase(base::string16(), owner, false), owner_(owner) {}
bool OnMousePressed(const ui::MouseEvent& e) override {
owner_->StopThrobbing(true);
- return views::MenuButton::OnMousePressed(e);
+ return BookmarkMenuButtonBase::OnMousePressed(e);
}
private:
« no previous file with comments | « no previous file | ui/views/animation/button_ink_drop_delegate.h » ('j') | ui/views/animation/ink_drop_animation_controller.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698