| 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 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override { |
| 250 return base::MakeUnique<views::RoundRectInkDropMask>(size(), kInkDropInsets, |
| 251 kInkDropCornerRadius); |
| 252 } |
| 253 |
| 245 SkColor GetInkDropBaseColor() const override { | 254 SkColor GetInkDropBaseColor() const override { |
| 246 return GetThemeProvider()->GetColor( | 255 return GetThemeProvider()->GetColor( |
| 247 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 256 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 248 } | 257 } |
| 249 | 258 |
| 250 private: | 259 private: |
| 251 std::unique_ptr<gfx::SlideAnimation> show_animation_; | 260 std::unique_ptr<gfx::SlideAnimation> show_animation_; |
| 252 | 261 |
| 253 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); | 262 DISALLOW_COPY_AND_ASSIGN(BookmarkButtonBase); |
| 254 }; | 263 }; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 const override { | 369 const override { |
| 361 gfx::RectF bounds((gfx::Rect(size()))); | 370 gfx::RectF bounds((gfx::Rect(size()))); |
| 362 bounds.Inset(gfx::InsetsF( | 371 bounds.Inset(gfx::InsetsF( |
| 363 kInkDropVerticalInsetPx / | 372 kInkDropVerticalInsetPx / |
| 364 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), | 373 GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), |
| 365 0)); | 374 0)); |
| 366 return base::MakeUnique<views::InkDropHighlight>( | 375 return base::MakeUnique<views::InkDropHighlight>( |
| 367 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); | 376 bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); |
| 368 } | 377 } |
| 369 | 378 |
| 379 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override { |
| 380 return base::MakeUnique<views::RoundRectInkDropMask>(size(), kInkDropInsets, |
| 381 kInkDropCornerRadius); |
| 382 } |
| 383 |
| 370 SkColor GetInkDropBaseColor() const override { | 384 SkColor GetInkDropBaseColor() const override { |
| 371 return GetThemeProvider()->GetColor( | 385 return GetThemeProvider()->GetColor( |
| 372 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 386 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 373 } | 387 } |
| 374 | 388 |
| 375 private: | 389 private: |
| 376 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase); | 390 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButtonBase); |
| 377 }; | 391 }; |
| 378 | 392 |
| 379 // BookmarkFolderButton ------------------------------------------------------- | 393 // BookmarkFolderButton ------------------------------------------------------- |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 return; | 2165 return; |
| 2152 apps_page_shortcut_->SetVisible(visible); | 2166 apps_page_shortcut_->SetVisible(visible); |
| 2153 UpdateBookmarksSeparatorVisibility(); | 2167 UpdateBookmarksSeparatorVisibility(); |
| 2154 LayoutAndPaint(); | 2168 LayoutAndPaint(); |
| 2155 } | 2169 } |
| 2156 | 2170 |
| 2157 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2171 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2158 if (UpdateOtherAndManagedButtonsVisibility()) | 2172 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2159 LayoutAndPaint(); | 2173 LayoutAndPaint(); |
| 2160 } | 2174 } |
| OLD | NEW |