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

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

Issue 2533053002: Handle view resize for ripple (Closed)
Patch Set: Created 4 years 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "ui/base/l10n/l10n_util.h" 72 #include "ui/base/l10n/l10n_util.h"
73 #include "ui/base/page_transition_types.h" 73 #include "ui/base/page_transition_types.h"
74 #include "ui/base/resource/resource_bundle.h" 74 #include "ui/base/resource/resource_bundle.h"
75 #include "ui/base/theme_provider.h" 75 #include "ui/base/theme_provider.h"
76 #include "ui/base/window_open_disposition.h" 76 #include "ui/base/window_open_disposition.h"
77 #include "ui/compositor/paint_recorder.h" 77 #include "ui/compositor/paint_recorder.h"
78 #include "ui/gfx/animation/slide_animation.h" 78 #include "ui/gfx/animation/slide_animation.h"
79 #include "ui/gfx/canvas.h" 79 #include "ui/gfx/canvas.h"
80 #include "ui/gfx/color_utils.h" 80 #include "ui/gfx/color_utils.h"
81 #include "ui/gfx/favicon_size.h" 81 #include "ui/gfx/favicon_size.h"
82 #include "ui/gfx/geometry/insets.h"
82 #include "ui/gfx/geometry/rect.h" 83 #include "ui/gfx/geometry/rect.h"
83 #include "ui/gfx/image/image_skia_operations.h" 84 #include "ui/gfx/image/image_skia_operations.h"
84 #include "ui/gfx/paint_vector_icon.h" 85 #include "ui/gfx/paint_vector_icon.h"
85 #include "ui/gfx/scoped_canvas.h" 86 #include "ui/gfx/scoped_canvas.h"
86 #include "ui/gfx/text_constants.h" 87 #include "ui/gfx/text_constants.h"
87 #include "ui/gfx/text_elider.h" 88 #include "ui/gfx/text_elider.h"
88 #include "ui/gfx/vector_icons_public.h" 89 #include "ui/gfx/vector_icons_public.h"
89 #include "ui/resources/grit/ui_resources.h" 90 #include "ui/resources/grit/ui_resources.h"
90 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 91 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
91 #include "ui/views/animation/ink_drop_highlight.h" 92 #include "ui/views/animation/ink_drop_highlight.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 namespace { 159 namespace {
159 160
160 // To enable/disable BookmarkBar animations during testing. In production 161 // To enable/disable BookmarkBar animations during testing. In production
161 // animations are enabled by default. 162 // animations are enabled by default.
162 bool animations_enabled = true; 163 bool animations_enabled = true;
163 164
164 gfx::ImageSkia* GetImageSkiaNamed(int id) { 165 gfx::ImageSkia* GetImageSkiaNamed(int id) {
165 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); 166 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
166 } 167 }
167 168
169 const gfx::Insets kInkDropInsets(1, 0);
170
168 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) { 171 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) {
bruthig 2016/11/28 22:13:45 :( I kind of wish I had left myself a comment as t
mohsen 2016/11/29 00:07:12 Apparently, this is because https://crbug.com/5953
bruthig 2016/11/29 01:37:48 lgtm, thx!
169 gfx::Rect ink_drop_bounds(size); 172 gfx::Rect ink_drop_bounds(size);
170 ink_drop_bounds.Inset(0, 1); 173 ink_drop_bounds.Inset(kInkDropInsets);
171 return ink_drop_bounds; 174 return ink_drop_bounds;
172 } 175 }
173 176
174 // BookmarkButtonBase ----------------------------------------------- 177 // BookmarkButtonBase -----------------------------------------------
175 178
176 // 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.
177 180
178 class BookmarkButtonBase : public views::LabelButton { 181 class BookmarkButtonBase : public views::LabelButton {
179 public: 182 public:
180 BookmarkButtonBase(views::ButtonListener* listener, 183 BookmarkButtonBase(views::ButtonListener* listener,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // LabelButton: 221 // LabelButton:
219 std::unique_ptr<views::InkDrop> CreateInkDrop() override { 222 std::unique_ptr<views::InkDrop> CreateInkDrop() override {
220 std::unique_ptr<views::InkDropImpl> ink_drop = 223 std::unique_ptr<views::InkDropImpl> ink_drop =
221 CreateDefaultFloodFillInkDropImpl(); 224 CreateDefaultFloodFillInkDropImpl();
222 ink_drop->SetShowHighlightOnFocus(true); 225 ink_drop->SetShowHighlightOnFocus(true);
223 return std::move(ink_drop); 226 return std::move(ink_drop);
224 } 227 }
225 228
226 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 229 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
227 return base::MakeUnique<views::FloodFillInkDropRipple>( 230 return base::MakeUnique<views::FloodFillInkDropRipple>(
228 CalculateInkDropBounds(size()), GetInkDropCenterBasedOnLastEvent(), 231 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(),
229 GetInkDropBaseColor(), ink_drop_visible_opacity()); 232 GetInkDropBaseColor(), ink_drop_visible_opacity());
230 } 233 }
231 234
232 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 235 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
233 const override { 236 const override {
234 const gfx::Rect bounds = CalculateInkDropBounds(size()); 237 const gfx::Rect bounds = CalculateInkDropBounds(size());
235 return base::MakeUnique<views::InkDropHighlight>( 238 return base::MakeUnique<views::InkDropHighlight>(
236 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), 239 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(),
237 GetInkDropBaseColor()); 240 GetInkDropBaseColor());
238 } 241 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // MenuButton: 344 // MenuButton:
342 std::unique_ptr<views::InkDrop> CreateInkDrop() override { 345 std::unique_ptr<views::InkDrop> CreateInkDrop() override {
343 std::unique_ptr<views::InkDropImpl> ink_drop = 346 std::unique_ptr<views::InkDropImpl> ink_drop =
344 CreateDefaultFloodFillInkDropImpl(); 347 CreateDefaultFloodFillInkDropImpl();
345 ink_drop->SetShowHighlightOnFocus(true); 348 ink_drop->SetShowHighlightOnFocus(true);
346 return std::move(ink_drop); 349 return std::move(ink_drop);
347 } 350 }
348 351
349 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { 352 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override {
350 return base::MakeUnique<views::FloodFillInkDropRipple>( 353 return base::MakeUnique<views::FloodFillInkDropRipple>(
351 CalculateInkDropBounds(size()), GetInkDropCenterBasedOnLastEvent(), 354 size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(),
352 GetInkDropBaseColor(), ink_drop_visible_opacity()); 355 GetInkDropBaseColor(), ink_drop_visible_opacity());
353 } 356 }
354 357
355 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() 358 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
356 const override { 359 const override {
357 const gfx::Rect bounds = CalculateInkDropBounds(size()); 360 const gfx::Rect bounds = CalculateInkDropBounds(size());
358 return base::MakeUnique<views::InkDropHighlight>( 361 return base::MakeUnique<views::InkDropHighlight>(
359 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(), 362 bounds.size(), 0, gfx::RectF(bounds).CenterPoint(),
360 GetInkDropBaseColor()); 363 GetInkDropBaseColor());
361 } 364 }
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 return; 2146 return;
2144 apps_page_shortcut_->SetVisible(visible); 2147 apps_page_shortcut_->SetVisible(visible);
2145 UpdateBookmarksSeparatorVisibility(); 2148 UpdateBookmarksSeparatorVisibility();
2146 LayoutAndPaint(); 2149 LayoutAndPaint();
2147 } 2150 }
2148 2151
2149 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2152 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2150 if (UpdateOtherAndManagedButtonsVisibility()) 2153 if (UpdateOtherAndManagedButtonsVisibility())
2151 LayoutAndPaint(); 2154 LayoutAndPaint();
2152 } 2155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698