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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 #include "ui/base/material_design/material_design_controller.h" | 81 #include "ui/base/material_design/material_design_controller.h" |
| 82 #include "ui/base/page_transition_types.h" | 82 #include "ui/base/page_transition_types.h" |
| 83 #include "ui/base/resource/resource_bundle.h" | 83 #include "ui/base/resource/resource_bundle.h" |
| 84 #include "ui/base/theme_provider.h" | 84 #include "ui/base/theme_provider.h" |
| 85 #include "ui/base/window_open_disposition.h" | 85 #include "ui/base/window_open_disposition.h" |
| 86 #include "ui/compositor/paint_recorder.h" | 86 #include "ui/compositor/paint_recorder.h" |
| 87 #include "ui/gfx/animation/slide_animation.h" | 87 #include "ui/gfx/animation/slide_animation.h" |
| 88 #include "ui/gfx/canvas.h" | 88 #include "ui/gfx/canvas.h" |
| 89 #include "ui/gfx/color_utils.h" | 89 #include "ui/gfx/color_utils.h" |
| 90 #include "ui/gfx/favicon_size.h" | 90 #include "ui/gfx/favicon_size.h" |
| 91 #include "ui/gfx/geometry/rect.h" | |
| 91 #include "ui/gfx/paint_vector_icon.h" | 92 #include "ui/gfx/paint_vector_icon.h" |
| 92 #include "ui/gfx/scoped_canvas.h" | 93 #include "ui/gfx/scoped_canvas.h" |
| 93 #include "ui/gfx/text_constants.h" | 94 #include "ui/gfx/text_constants.h" |
| 94 #include "ui/gfx/text_elider.h" | 95 #include "ui/gfx/text_elider.h" |
| 95 #include "ui/gfx/vector_icons_public.h" | 96 #include "ui/gfx/vector_icons_public.h" |
| 96 #include "ui/resources/grit/ui_resources.h" | 97 #include "ui/resources/grit/ui_resources.h" |
| 97 #include "ui/views/animation/button_ink_drop_delegate.h" | 98 #include "ui/views/animation/button_ink_drop_delegate.h" |
| 98 #include "ui/views/animation/flood_fill_ink_drop_animation.h" | 99 #include "ui/views/animation/flood_fill_ink_drop_animation.h" |
| 99 #include "ui/views/animation/ink_drop_hover.h" | 100 #include "ui/views/animation/ink_drop_hover.h" |
| 100 #include "ui/views/button_drag_utils.h" | 101 #include "ui/views/button_drag_utils.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 bool animations_enabled = true; | 183 bool animations_enabled = true; |
| 183 | 184 |
| 184 gfx::ImageSkia* GetImageSkiaNamed(int id) { | 185 gfx::ImageSkia* GetImageSkiaNamed(int id) { |
| 185 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); | 186 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); |
| 186 } | 187 } |
| 187 | 188 |
| 188 int GetHorizontalMargin() { | 189 int GetHorizontalMargin() { |
| 189 return kHorizontalMargin[ui::MaterialDesignController::GetMode()]; | 190 return kHorizontalMargin[ui::MaterialDesignController::GetMode()]; |
| 190 } | 191 } |
| 191 | 192 |
| 192 gfx::Size CalculateInkDropSize(const gfx::Size& button_size) { | 193 gfx::Rect CalculateInkDropBounds(const gfx::Size& size) { |
| 193 gfx::Size ink_drop_size(button_size); | 194 gfx::Rect ink_drop_bounds(size); |
| 194 ink_drop_size.Enlarge(0, -2); | 195 ink_drop_bounds.Inset(0, 1); |
| 195 return ink_drop_size; | 196 return ink_drop_bounds; |
| 196 } | 197 } |
| 197 | 198 |
| 198 // BookmarkButtonBase ----------------------------------------------- | 199 // BookmarkButtonBase ----------------------------------------------- |
| 199 | 200 |
| 200 // 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. |
| 201 | 202 |
| 202 class BookmarkButtonBase : public views::LabelButton { | 203 class BookmarkButtonBase : public views::LabelButton { |
| 203 public: | 204 public: |
| 204 BookmarkButtonBase(views::ButtonListener* listener, | 205 BookmarkButtonBase(views::ButtonListener* listener, |
| 205 const base::string16& title) | 206 const base::string16& title) |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 233 | 234 |
| 234 bool IsTriggerableEvent(const ui::Event& e) override { | 235 bool IsTriggerableEvent(const ui::Event& e) override { |
| 235 return e.type() == ui::ET_GESTURE_TAP || | 236 return e.type() == ui::ET_GESTURE_TAP || |
| 236 e.type() == ui::ET_GESTURE_TAP_DOWN || | 237 e.type() == ui::ET_GESTURE_TAP_DOWN || |
| 237 event_utils::IsPossibleDispositionEvent(e); | 238 event_utils::IsPossibleDispositionEvent(e); |
| 238 } | 239 } |
| 239 | 240 |
| 240 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() | 241 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 241 const override { | 242 const override { |
| 242 return base::WrapUnique(new views::FloodFillInkDropAnimation( | 243 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
| 243 CalculateInkDropSize(size()), GetInkDropCenter(), | 244 CalculateInkDropBounds(size()), GetInkDropCenter(), |
| 244 GetInkDropBaseColor())); | 245 GetInkDropBaseColor())); |
| 245 } | 246 } |
| 246 | 247 |
| 247 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { | 248 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { |
| 248 if (!ShouldShowInkDropHover()) | 249 if (!ShouldShowInkDropHover()) |
| 249 return nullptr; | 250 return nullptr; |
| 250 return base::WrapUnique( | 251 return base::WrapUnique(new views::InkDropHover( |
| 251 new views::InkDropHover(CalculateInkDropSize(size()), 0, | 252 CalculateInkDropBounds(size()), 0, GetInkDropBaseColor())); |
|
Evan Stade
2016/04/27 23:10:44
Do we need the new InkDropHover ctor? Why not
new
bruthig
2016/04/27 23:36:28
Done.
| |
| 252 GetInkDropCenter(), GetInkDropBaseColor())); | |
| 253 } | 253 } |
| 254 | 254 |
| 255 SkColor GetInkDropBaseColor() const override { | 255 SkColor GetInkDropBaseColor() const override { |
| 256 return GetThemeProvider()->GetColor( | 256 return GetThemeProvider()->GetColor( |
| 257 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 257 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 258 } | 258 } |
| 259 | 259 |
| 260 private: | 260 private: |
| 261 std::unique_ptr<gfx::SlideAnimation> show_animation_; | 261 std::unique_ptr<gfx::SlideAnimation> show_animation_; |
| 262 | 262 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 views::MenuButtonListener* menu_button_listener, | 334 views::MenuButtonListener* menu_button_listener, |
| 335 bool show_menu_marker) | 335 bool show_menu_marker) |
| 336 : MenuButton(title, menu_button_listener, show_menu_marker), | 336 : MenuButton(title, menu_button_listener, show_menu_marker), |
| 337 ink_drop_delegate_(this, this) { | 337 ink_drop_delegate_(this, this) { |
| 338 set_ink_drop_delegate(&ink_drop_delegate_); | 338 set_ink_drop_delegate(&ink_drop_delegate_); |
| 339 } | 339 } |
| 340 | 340 |
| 341 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() | 341 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 342 const override { | 342 const override { |
| 343 return base::WrapUnique(new views::FloodFillInkDropAnimation( | 343 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
| 344 CalculateInkDropSize(size()), GetInkDropCenter(), | 344 CalculateInkDropBounds(size()), GetInkDropCenter(), |
| 345 GetInkDropBaseColor())); | 345 GetInkDropBaseColor())); |
| 346 } | 346 } |
| 347 | 347 |
| 348 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { | 348 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { |
| 349 if (!ShouldShowInkDropHover()) | 349 if (!ShouldShowInkDropHover()) |
| 350 return nullptr; | 350 return nullptr; |
| 351 return base::WrapUnique( | 351 return base::WrapUnique(new views::InkDropHover( |
| 352 new views::InkDropHover(CalculateInkDropSize(size()), 0, | 352 CalculateInkDropBounds(size()), 0, GetInkDropBaseColor())); |
| 353 GetInkDropCenter(), GetInkDropBaseColor())); | |
| 354 } | 353 } |
| 355 | 354 |
| 356 SkColor GetInkDropBaseColor() const override { | 355 SkColor GetInkDropBaseColor() const override { |
| 357 return GetThemeProvider()->GetColor( | 356 return GetThemeProvider()->GetColor( |
| 358 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 357 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 359 } | 358 } |
| 360 | 359 |
| 361 private: | 360 private: |
| 362 // Controls the visual feedback for the button state. | 361 // Controls the visual feedback for the button state. |
| 363 views::ButtonInkDropDelegate ink_drop_delegate_; | 362 views::ButtonInkDropDelegate ink_drop_delegate_; |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2161 return; | 2160 return; |
| 2162 apps_page_shortcut_->SetVisible(visible); | 2161 apps_page_shortcut_->SetVisible(visible); |
| 2163 UpdateBookmarksSeparatorVisibility(); | 2162 UpdateBookmarksSeparatorVisibility(); |
| 2164 LayoutAndPaint(); | 2163 LayoutAndPaint(); |
| 2165 } | 2164 } |
| 2166 | 2165 |
| 2167 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2166 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2168 if (UpdateOtherAndManagedButtonsVisibility()) | 2167 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2169 LayoutAndPaint(); | 2168 LayoutAndPaint(); |
| 2170 } | 2169 } |
| OLD | NEW |