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

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

Issue 2001843002: Use ink drop hover for focus states on toolbar buttons and location (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layout 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 197 }
198 198
199 // BookmarkButtonBase ----------------------------------------------- 199 // BookmarkButtonBase -----------------------------------------------
200 200
201 // Base class for non-menu hosting buttons used on the bookmark bar. 201 // Base class for non-menu hosting buttons used on the bookmark bar.
202 202
203 class BookmarkButtonBase : public views::LabelButton { 203 class BookmarkButtonBase : public views::LabelButton {
204 public: 204 public:
205 BookmarkButtonBase(views::ButtonListener* listener, 205 BookmarkButtonBase(views::ButtonListener* listener,
206 const base::string16& title) 206 const base::string16& title)
207 : LabelButton(listener, title), ink_drop_delegate_(this, this) { 207 : LabelButton(listener, title) {
208 SetElideBehavior(kElideBehavior); 208 SetElideBehavior(kElideBehavior);
209 set_ink_drop_delegate(&ink_drop_delegate_); 209 set_ink_drop_delegate(
210 base::WrapUnique(new views::ButtonInkDropDelegate(this, this)));
210 set_has_ink_drop_action_on_click(true); 211 set_has_ink_drop_action_on_click(true);
211 show_animation_.reset(new gfx::SlideAnimation(this)); 212 show_animation_.reset(new gfx::SlideAnimation(this));
212 if (!animations_enabled) { 213 if (!animations_enabled) {
213 // For some reason during testing the events generated by animating 214 // For some reason during testing the events generated by animating
214 // throw off the test. So, don't animate while testing. 215 // throw off the test. So, don't animate while testing.
215 show_animation_->Reset(1); 216 show_animation_->Reset(1);
216 } else { 217 } else {
217 show_animation_->Show(); 218 show_animation_->Show();
218 } 219 }
219 } 220 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 255 }
255 256
256 SkColor GetInkDropBaseColor() const override { 257 SkColor GetInkDropBaseColor() const override {
257 return GetThemeProvider()->GetColor( 258 return GetThemeProvider()->GetColor(
258 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 259 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
259 } 260 }
260 261
261 private: 262 private:
262 std::unique_ptr<gfx::SlideAnimation> show_animation_; 263 std::unique_ptr<gfx::SlideAnimation> show_animation_;
263 264
264 // Controls the visual feedback for the button state.
265 views::ButtonInkDropDelegate ink_drop_delegate_;
266 265
267 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); 266 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase);
268 }; 267 };
269 268
270 // BookmarkButton ------------------------------------------------------------- 269 // BookmarkButton -------------------------------------------------------------
271 270
272 // Buttons used for the bookmarks on the bookmark bar. 271 // Buttons used for the bookmarks on the bookmark bar.
273 272
274 class BookmarkButton : public BookmarkButtonBase { 273 class BookmarkButton : public BookmarkButtonBase {
275 public: 274 public:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 const char ShortcutButton::kViewClassName[] = "ShortcutButton"; 324 const char ShortcutButton::kViewClassName[] = "ShortcutButton";
326 325
327 // BookmarkMenuButtonBase ----------------------------------------------------- 326 // BookmarkMenuButtonBase -----------------------------------------------------
328 327
329 // Base class for menu hosting buttons used on the bookmark bar. 328 // Base class for menu hosting buttons used on the bookmark bar.
330 class BookmarkMenuButtonBase : public views::MenuButton { 329 class BookmarkMenuButtonBase : public views::MenuButton {
331 public: 330 public:
332 BookmarkMenuButtonBase(const base::string16& title, 331 BookmarkMenuButtonBase(const base::string16& title,
333 views::MenuButtonListener* menu_button_listener, 332 views::MenuButtonListener* menu_button_listener,
334 bool show_menu_marker) 333 bool show_menu_marker)
335 : MenuButton(title, menu_button_listener, show_menu_marker), 334 : MenuButton(title, menu_button_listener, show_menu_marker) {
336 ink_drop_delegate_(this, this) { 335 set_ink_drop_delegate(
337 set_ink_drop_delegate(&ink_drop_delegate_); 336 base::WrapUnique(new views::ButtonInkDropDelegate(this, this)));
338 } 337 }
339 338
340 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 339 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
341 return base::WrapUnique(new views::FloodFillInkDropRipple( 340 return base::WrapUnique(new views::FloodFillInkDropRipple(
342 CalculateInkDropBounds(size()), GetInkDropCenter(), 341 CalculateInkDropBounds(size()), GetInkDropCenter(),
343 GetInkDropBaseColor())); 342 GetInkDropBaseColor()));
344 } 343 }
345 344
346 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { 345 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override {
347 if (!ShouldShowInkDropHover()) 346 if (!ShouldShowInkDropHover())
348 return nullptr; 347 return nullptr;
349 348
350 const gfx::Rect bounds = CalculateInkDropBounds(size()); 349 const gfx::Rect bounds = CalculateInkDropBounds(size());
351 return base::WrapUnique(new views::InkDropHover( 350 return base::WrapUnique(new views::InkDropHover(
352 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor())); 351 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()));
353 } 352 }
354 353
355 SkColor GetInkDropBaseColor() const override { 354 SkColor GetInkDropBaseColor() const override {
356 return GetThemeProvider()->GetColor( 355 return GetThemeProvider()->GetColor(
357 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 356 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
358 } 357 }
359 358
360 private: 359 private:
361 // Controls the visual feedback for the button state.
362 views::ButtonInkDropDelegate ink_drop_delegate_;
363
364 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase); 360 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase);
365 }; 361 };
366 362
367 // BookmarkFolderButton ------------------------------------------------------- 363 // BookmarkFolderButton -------------------------------------------------------
368 364
369 // Buttons used for folders on the bookmark bar, including the 'other folders' 365 // Buttons used for folders on the bookmark bar, including the 'other folders'
370 // button. 366 // button.
371 class BookmarkFolderButton : public BookmarkMenuButtonBase { 367 class BookmarkFolderButton : public BookmarkMenuButtonBase {
372 public: 368 public:
373 BookmarkFolderButton(const base::string16& title, 369 BookmarkFolderButton(const base::string16& title,
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 return; 2155 return;
2160 apps_page_shortcut_->SetVisible(visible); 2156 apps_page_shortcut_->SetVisible(visible);
2161 UpdateBookmarksSeparatorVisibility(); 2157 UpdateBookmarksSeparatorVisibility();
2162 LayoutAndPaint(); 2158 LayoutAndPaint();
2163 } 2159 }
2164 2160
2165 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2161 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2166 if (UpdateOtherAndManagedButtonsVisibility()) 2162 if (UpdateOtherAndManagedButtonsVisibility())
2167 LayoutAndPaint(); 2163 LayoutAndPaint();
2168 } 2164 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bar_control_button.cc ('k') | chrome/browser/ui/views/download/download_item_view_md.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698