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

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

Issue 2786543002: Make updates to InkDropHighlight to pave the way for improved ink drops (Closed)
Patch Set: improved docs Created 3 years, 8 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
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_highlight.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 namespace { 159 namespace {
160 160
161 // To enable/disable BookmarkBar animations during testing. In production 161 // To enable/disable BookmarkBar animations during testing. In production
162 // animations are enabled by default. 162 // animations are enabled by default.
163 bool animations_enabled = true; 163 bool animations_enabled = true;
164 164
165 gfx::ImageSkia* GetImageSkiaNamed(int id) { 165 gfx::ImageSkia* GetImageSkiaNamed(int id) {
166 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); 166 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
167 } 167 }
168 168
169 constexpr int kInkDropVerticalInsetPx = 1;
170
169 // Ink drop ripple/highlight for bookmark buttons should be inset 1px vertically 171 // Ink drop ripple/highlight for bookmark buttons should be inset 1px vertically
170 // so that they do not touch the bookmark bar borders. 172 // so that they do not touch the bookmark bar borders.
171 constexpr gfx::Insets kInkDropInsets(1, 0); 173 // TODO(estade): currently this is used as DIP rather than pixels. This should
172 174 // be fixed: see crbug.com/706228
173 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) { 175 constexpr gfx::Insets kInkDropInsets(kInkDropVerticalInsetPx, 0);
174 gfx::Rect ink_drop_bounds(size);
175 ink_drop_bounds.Inset(kInkDropInsets);
176 return ink_drop_bounds;
177 }
178 176
179 // BookmarkButtonBase ----------------------------------------------- 177 // BookmarkButtonBase -----------------------------------------------
180 178
181 // Base class for non-menu hosting buttons used on the bookmark bar. 179 // Base class for non-menu hosting buttons used on the bookmark bar.
182 180
183 class BookmarkButtonBase : public views::LabelButton { 181 class BookmarkButtonBase : public views::LabelButton {
184 public: 182 public:
185 BookmarkButtonBase(views::ButtonListener* listener, 183 BookmarkButtonBase(views::ButtonListener* listener,
186 const base::string16& title) 184 const base::string16& title)
187 : LabelButton(listener, title) { 185 : LabelButton(listener, title) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 227 }
230 228
231 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 229 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
232 return base::MakeUnique<views::FloodFillInkDropRipple>( 230 return base::MakeUnique<views::FloodFillInkDropRipple>(
233 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(), 231 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(),
234 GetInkDropBaseColor(), ink_drop_visible_opacity()); 232 GetInkDropBaseColor(), ink_drop_visible_opacity());
235 } 233 }
236 234
237 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 235 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
238 const override { 236 const override {
239 const gfx::Rect bounds = CalculateInkDropBounds(size()); 237 gfx::RectF bounds((gfx::Rect(size())));
bruthig 2017/03/30 16:37:08 nit: One too many '()' set
Evan Stade 2017/03/30 17:49:38 that is actually necessary or the compiler complai
sky 2017/03/30 20:37:54 optional: creating a rect just to create a rectf i
Evan Stade 2017/03/31 00:04:12 Perhaps there should be a RectF ctor that takes a
238 bounds.Inset(gfx::InsetsF(
239 kInkDropVerticalInsetPx /
240 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(),
bruthig 2017/03/30 16:37:08 Will we be doing this enough to warrant a util fun
Evan Stade 2017/03/30 17:49:38 maybe, ui/compositor/dip_util.h has similar things
241 0));
240 return base::MakeUnique<views::InkDropHighlight>( 242 return base::MakeUnique<views::InkDropHighlight>(
241 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), 243 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor());
242 GetInkDropBaseColor());
243 } 244 }
244 245
245 SkColor GetInkDropBaseColor() const override { 246 SkColor GetInkDropBaseColor() const override {
246 return GetThemeProvider()->GetColor( 247 return GetThemeProvider()->GetColor(
247 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 248 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
248 } 249 }
249 250
250 private: 251 private:
251 std::unique_ptr<gfx::SlideAnimation> show_animation_; 252 std::unique_ptr<gfx::SlideAnimation> show_animation_;
252 253
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 352 }
352 353
353 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 354 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
354 return base::MakeUnique<views::FloodFillInkDropRipple>( 355 return base::MakeUnique<views::FloodFillInkDropRipple>(
355 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(), 356 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(),
356 GetInkDropBaseColor(), ink_drop_visible_opacity()); 357 GetInkDropBaseColor(), ink_drop_visible_opacity());
357 } 358 }
358 359
359 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 360 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
360 const override { 361 const override {
361 const gfx::Rect bounds = CalculateInkDropBounds(size()); 362 gfx::RectF bounds((gfx::Rect(size())));
bruthig 2017/03/30 16:37:08 nit: Too many '()'
363 bounds.Inset(gfx::InsetsF(
364 kInkDropVerticalInsetPx /
365 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(),
366 0));
362 return base::MakeUnique<views::InkDropHighlight>( 367 return base::MakeUnique<views::InkDropHighlight>(
363 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), 368 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor());
364 GetInkDropBaseColor());
365 } 369 }
366 370
367 SkColor GetInkDropBaseColor() const override { 371 SkColor GetInkDropBaseColor() const override {
368 return GetThemeProvider()->GetColor( 372 return GetThemeProvider()->GetColor(
369 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 373 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
370 } 374 }
371 375
372 private: 376 private:
373 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase); 377 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase);
374 }; 378 };
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 return; 2151 return;
2148 apps_page_shortcut_->SetVisible(visible); 2152 apps_page_shortcut_->SetVisible(visible);
2149 UpdateBookmarksSeparatorVisibility(); 2153 UpdateBookmarksSeparatorVisibility();
2150 LayoutAndPaint(); 2154 LayoutAndPaint();
2151 } 2155 }
2152 2156
2153 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2157 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2154 if (UpdateOtherAndManagedButtonsVisibility()) 2158 if (UpdateOtherAndManagedButtonsVisibility())
2155 LayoutAndPaint(); 2159 LayoutAndPaint();
2156 } 2160 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/animation/ink_drop_highlight.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698