| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 bool animations_enabled = true; | 182 bool animations_enabled = true; |
| 183 | 183 |
| 184 gfx::ImageSkia* GetImageSkiaNamed(int id) { | 184 gfx::ImageSkia* GetImageSkiaNamed(int id) { |
| 185 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); | 185 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); |
| 186 } | 186 } |
| 187 | 187 |
| 188 int GetHorizontalMargin() { | 188 int GetHorizontalMargin() { |
| 189 return kHorizontalMargin[ui::MaterialDesignController::GetMode()]; | 189 return kHorizontalMargin[ui::MaterialDesignController::GetMode()]; |
| 190 } | 190 } |
| 191 | 191 |
| 192 gfx::Size CalculateInkDropSize(const gfx::Size& button_size) { |
| 193 gfx::Size ink_drop_size(button_size); |
| 194 ink_drop_size.Enlarge(0, -2); |
| 195 return ink_drop_size; |
| 196 } |
| 197 |
| 192 // BookmarkButtonBase ----------------------------------------------- | 198 // BookmarkButtonBase ----------------------------------------------- |
| 193 | 199 |
| 194 // Base class for non-menu hosting buttons used on the bookmark bar. | 200 // Base class for non-menu hosting buttons used on the bookmark bar. |
| 195 | 201 |
| 196 class BookmarkButtonBase : public views::LabelButton { | 202 class BookmarkButtonBase : public views::LabelButton { |
| 197 public: | 203 public: |
| 198 BookmarkButtonBase(views::ButtonListener* listener, | 204 BookmarkButtonBase(views::ButtonListener* listener, |
| 199 const base::string16& title) | 205 const base::string16& title) |
| 200 : LabelButton(listener, title), ink_drop_delegate_(this, this) { | 206 : LabelButton(listener, title), ink_drop_delegate_(this, this) { |
| 201 SetElideBehavior(kElideBehavior); | 207 SetElideBehavior(kElideBehavior); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 227 | 233 |
| 228 bool IsTriggerableEvent(const ui::Event& e) override { | 234 bool IsTriggerableEvent(const ui::Event& e) override { |
| 229 return e.type() == ui::ET_GESTURE_TAP || | 235 return e.type() == ui::ET_GESTURE_TAP || |
| 230 e.type() == ui::ET_GESTURE_TAP_DOWN || | 236 e.type() == ui::ET_GESTURE_TAP_DOWN || |
| 231 event_utils::IsPossibleDispositionEvent(e); | 237 event_utils::IsPossibleDispositionEvent(e); |
| 232 } | 238 } |
| 233 | 239 |
| 234 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() | 240 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 235 const override { | 241 const override { |
| 236 return base::WrapUnique(new views::FloodFillInkDropAnimation( | 242 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
| 237 size(), GetInkDropCenter(), GetInkDropBaseColor())); | 243 CalculateInkDropSize(size()), GetInkDropCenter(), |
| 244 GetInkDropBaseColor())); |
| 238 } | 245 } |
| 239 | 246 |
| 240 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { | 247 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { |
| 241 if (!ShouldShowInkDropHover()) | 248 if (!ShouldShowInkDropHover()) |
| 242 return nullptr; | 249 return nullptr; |
| 243 return base::WrapUnique(new views::InkDropHover( | 250 return base::WrapUnique( |
| 244 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); | 251 new views::InkDropHover(CalculateInkDropSize(size()), 0, |
| 252 GetInkDropCenter(), GetInkDropBaseColor())); |
| 245 } | 253 } |
| 246 | 254 |
| 247 SkColor GetInkDropBaseColor() const override { | 255 SkColor GetInkDropBaseColor() const override { |
| 248 return GetThemeProvider()->GetColor( | 256 return GetThemeProvider()->GetColor( |
| 249 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 257 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 250 } | 258 } |
| 251 | 259 |
| 252 private: | 260 private: |
| 253 std::unique_ptr<gfx::SlideAnimation> show_animation_; | 261 std::unique_ptr<gfx::SlideAnimation> show_animation_; |
| 254 | 262 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 views::MenuButtonListener* menu_button_listener, | 334 views::MenuButtonListener* menu_button_listener, |
| 327 bool show_menu_marker) | 335 bool show_menu_marker) |
| 328 : MenuButton(title, menu_button_listener, show_menu_marker), | 336 : MenuButton(title, menu_button_listener, show_menu_marker), |
| 329 ink_drop_delegate_(this, this) { | 337 ink_drop_delegate_(this, this) { |
| 330 set_ink_drop_delegate(&ink_drop_delegate_); | 338 set_ink_drop_delegate(&ink_drop_delegate_); |
| 331 } | 339 } |
| 332 | 340 |
| 333 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() | 341 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 334 const override { | 342 const override { |
| 335 return base::WrapUnique(new views::FloodFillInkDropAnimation( | 343 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
| 336 size(), GetInkDropCenter(), GetInkDropBaseColor())); | 344 CalculateInkDropSize(size()), GetInkDropCenter(), |
| 345 GetInkDropBaseColor())); |
| 337 } | 346 } |
| 338 | 347 |
| 339 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { | 348 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override { |
| 340 if (!ShouldShowInkDropHover()) | 349 if (!ShouldShowInkDropHover()) |
| 341 return nullptr; | 350 return nullptr; |
| 342 return base::WrapUnique(new views::InkDropHover( | 351 return base::WrapUnique( |
| 343 size(), 0, GetInkDropCenter(), GetInkDropBaseColor())); | 352 new views::InkDropHover(CalculateInkDropSize(size()), 0, |
| 353 GetInkDropCenter(), GetInkDropBaseColor())); |
| 344 } | 354 } |
| 345 | 355 |
| 346 SkColor GetInkDropBaseColor() const override { | 356 SkColor GetInkDropBaseColor() const override { |
| 347 return GetThemeProvider()->GetColor( | 357 return GetThemeProvider()->GetColor( |
| 348 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 358 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 349 } | 359 } |
| 350 | 360 |
| 351 private: | 361 private: |
| 352 // Controls the visual feedback for the button state. | 362 // Controls the visual feedback for the button state. |
| 353 views::ButtonInkDropDelegate ink_drop_delegate_; | 363 views::ButtonInkDropDelegate ink_drop_delegate_; |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 return; | 2161 return; |
| 2152 apps_page_shortcut_->SetVisible(visible); | 2162 apps_page_shortcut_->SetVisible(visible); |
| 2153 UpdateBookmarksSeparatorVisibility(); | 2163 UpdateBookmarksSeparatorVisibility(); |
| 2154 LayoutAndPaint(); | 2164 LayoutAndPaint(); |
| 2155 } | 2165 } |
| 2156 | 2166 |
| 2157 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2167 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2158 if (UpdateOtherAndManagedButtonsVisibility()) | 2168 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2159 LayoutAndPaint(); | 2169 LayoutAndPaint(); |
| 2160 } | 2170 } |
| OLD | NEW |