Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 #include "ui/gfx/geometry/rect.h" | 83 #include "ui/gfx/geometry/rect.h" |
| 84 #include "ui/gfx/image/image_skia_operations.h" | 84 #include "ui/gfx/image/image_skia_operations.h" |
| 85 #include "ui/gfx/paint_vector_icon.h" | 85 #include "ui/gfx/paint_vector_icon.h" |
| 86 #include "ui/gfx/scoped_canvas.h" | 86 #include "ui/gfx/scoped_canvas.h" |
| 87 #include "ui/gfx/text_constants.h" | 87 #include "ui/gfx/text_constants.h" |
| 88 #include "ui/gfx/text_elider.h" | 88 #include "ui/gfx/text_elider.h" |
| 89 #include "ui/resources/grit/ui_resources.h" | 89 #include "ui/resources/grit/ui_resources.h" |
| 90 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 90 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 91 #include "ui/views/animation/ink_drop_highlight.h" | 91 #include "ui/views/animation/ink_drop_highlight.h" |
| 92 #include "ui/views/animation/ink_drop_impl.h" | 92 #include "ui/views/animation/ink_drop_impl.h" |
| 93 #include "ui/views/animation/ink_drop_mask.h" | |
| 93 #include "ui/views/button_drag_utils.h" | 94 #include "ui/views/button_drag_utils.h" |
| 94 #include "ui/views/controls/button/label_button.h" | 95 #include "ui/views/controls/button/label_button.h" |
| 95 #include "ui/views/controls/button/label_button_border.h" | 96 #include "ui/views/controls/button/label_button_border.h" |
| 96 #include "ui/views/controls/button/menu_button.h" | 97 #include "ui/views/controls/button/menu_button.h" |
| 97 #include "ui/views/controls/label.h" | 98 #include "ui/views/controls/label.h" |
| 98 #include "ui/views/drag_utils.h" | 99 #include "ui/views/drag_utils.h" |
| 99 #include "ui/views/metrics.h" | 100 #include "ui/views/metrics.h" |
| 100 #include "ui/views/view_constants.h" | 101 #include "ui/views/view_constants.h" |
| 101 #include "ui/views/widget/tooltip_manager.h" | 102 #include "ui/views/widget/tooltip_manager.h" |
| 102 #include "ui/views/widget/widget.h" | 103 #include "ui/views/widget/widget.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 114 using views::LabelButtonBorder; | 115 using views::LabelButtonBorder; |
| 115 using views::MenuButton; | 116 using views::MenuButton; |
| 116 using views::View; | 117 using views::View; |
| 117 | 118 |
| 118 // How inset the bookmarks bar is when displayed on the new tab page. | 119 // How inset the bookmarks bar is when displayed on the new tab page. |
| 119 static const int kNewTabHorizontalPadding = 2; | 120 static const int kNewTabHorizontalPadding = 2; |
| 120 | 121 |
| 121 // Maximum size of buttons on the bookmark bar. | 122 // Maximum size of buttons on the bookmark bar. |
| 122 static const int kMaxButtonWidth = 150; | 123 static const int kMaxButtonWidth = 150; |
| 123 | 124 |
| 125 // Corner radius for masking the ink drop effects on buttons. | |
| 126 static const int kInkDropCornerRadius = 2; | |
| 127 | |
| 124 // Number of pixels the attached bookmark bar overlaps with the toolbar. | 128 // Number of pixels the attached bookmark bar overlaps with the toolbar. |
| 125 static const int kToolbarAttachedBookmarkBarOverlap = 3; | 129 static const int kToolbarAttachedBookmarkBarOverlap = 3; |
| 126 | 130 |
| 127 // Margins around the content. | 131 // Margins around the content. |
| 128 static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the | 132 static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the |
| 129 // toolbar above serve as the margin. | 133 // toolbar above serve as the margin. |
| 130 static const int kBottomMargin = 2; | 134 static const int kBottomMargin = 2; |
| 131 static const int kHorizontalMargin = 4; | 135 static const int kHorizontalMargin = 4; |
| 132 | 136 |
| 133 // Padding between buttons. | 137 // Padding between buttons. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 const override { | 239 const override { |
| 236 gfx::RectF bounds((gfx::Rect(size()))); | 240 gfx::RectF bounds((gfx::Rect(size()))); |
| 237 bounds.Inset(gfx::InsetsF( | 241 bounds.Inset(gfx::InsetsF( |
| 238 kInkDropVerticalInsetPx / | 242 kInkDropVerticalInsetPx / |
| 239 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), | 243 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), |
| 240 0)); | 244 0)); |
| 241 return base::MakeUnique<views::InkDropHighlight>( | 245 return base::MakeUnique<views::InkDropHighlight>( |
| 242 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); | 246 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); |
| 243 } | 247 } |
| 244 | 248 |
| 249 // Ink drop masks don't work on Windows. See crbug.com/713359 | |
| 250 #if !defined(OS_WIN) | |
| 251 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override { | |
| 252 return base::MakeUnique<views::RoundRectInkDropMask>(size(), kInkDropInsets, | |
| 253 kInkDropCornerRadius); | |
| 254 } | |
| 255 #endif | |
| 256 | |
| 245 SkColor GetInkDropBaseColor() const override { | 257 SkColor GetInkDropBaseColor() const override { |
| 246 return GetThemeProvider()->GetColor( | 258 return GetThemeProvider()->GetColor( |
| 247 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 259 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 248 } | 260 } |
| 249 | 261 |
| 250 private: | 262 private: |
| 251 std::unique_ptr<gfx::SlideAnimation> show_animation_; | 263 std::unique_ptr<gfx::SlideAnimation> show_animation_; |
| 252 | 264 |
| 253 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); | 265 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); |
| 254 }; | 266 }; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 const override { | 372 const override { |
| 361 gfx::RectF bounds((gfx::Rect(size()))); | 373 gfx::RectF bounds((gfx::Rect(size()))); |
| 362 bounds.Inset(gfx::InsetsF( | 374 bounds.Inset(gfx::InsetsF( |
| 363 kInkDropVerticalInsetPx / | 375 kInkDropVerticalInsetPx / |
| 364 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), | 376 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), |
| 365 0)); | 377 0)); |
| 366 return base::MakeUnique<views::InkDropHighlight>( | 378 return base::MakeUnique<views::InkDropHighlight>( |
| 367 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); | 379 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); |
| 368 } | 380 } |
| 369 | 381 |
| 382 // Ink drop masks don't work on Windows. See crbug.com/713359 | |
| 383 #if !defined(OS_WIN) | |
|
sky
2017/04/27 22:32:04
Are we generally doing ifdefs for this? Is it wort
Evan Stade
2017/04/27 22:36:31
I think this may be the first time we're doing thi
sky
2017/04/27 22:54:08
So, would it be better to move the ifdef as you sa
| |
| 384 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override { | |
| 385 return base::MakeUnique<views::RoundRectInkDropMask>(size(), kInkDropInsets, | |
| 386 kInkDropCornerRadius); | |
| 387 } | |
| 388 #endif | |
| 389 | |
| 370 SkColor GetInkDropBaseColor() const override { | 390 SkColor GetInkDropBaseColor() const override { |
| 371 return GetThemeProvider()->GetColor( | 391 return GetThemeProvider()->GetColor( |
| 372 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 392 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 373 } | 393 } |
| 374 | 394 |
| 375 private: | 395 private: |
| 376 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase); | 396 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase); |
| 377 }; | 397 }; |
| 378 | 398 |
| 379 // BookmarkFolderButton ------------------------------------------------------- | 399 // BookmarkFolderButton ------------------------------------------------------- |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2151 return; | 2171 return; |
| 2152 apps_page_shortcut_->SetVisible(visible); | 2172 apps_page_shortcut_->SetVisible(visible); |
| 2153 UpdateBookmarksSeparatorVisibility(); | 2173 UpdateBookmarksSeparatorVisibility(); |
| 2154 LayoutAndPaint(); | 2174 LayoutAndPaint(); |
| 2155 } | 2175 } |
| 2156 | 2176 |
| 2157 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2177 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2158 if (UpdateOtherAndManagedButtonsVisibility()) | 2178 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2159 LayoutAndPaint(); | 2179 LayoutAndPaint(); |
| 2160 } | 2180 } |
| OLD | NEW |