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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 throbbing_view_(nullptr), | 598 throbbing_view_(nullptr), |
| 599 bookmark_bar_state_(BookmarkBar::SHOW), | 599 bookmark_bar_state_(BookmarkBar::SHOW), |
| 600 animating_detached_(false), | 600 animating_detached_(false), |
| 601 show_folder_method_factory_(this) { | 601 show_folder_method_factory_(this) { |
| 602 set_id(VIEW_ID_BOOKMARK_BAR); | 602 set_id(VIEW_ID_BOOKMARK_BAR); |
| 603 Init(); | 603 Init(); |
| 604 | 604 |
| 605 // Don't let the bookmarks show on top of the location bar while animating. | 605 // Don't let the bookmarks show on top of the location bar while animating. |
| 606 SetPaintToLayer(); | 606 SetPaintToLayer(); |
| 607 layer()->SetMasksToBounds(true); | 607 layer()->SetMasksToBounds(true); |
| 608 layer()->SetFillsBoundsOpaquely(false); | 608 layer()->SetFillsBoundsOpaquely(true); |
|
Evan Stade
2017/05/30 21:39:33
you can just remove this line as opacity is the de
yiyix
2017/05/30 22:20:50
Done.
| |
| 609 | 609 |
| 610 size_animation_.Reset(1); | 610 size_animation_.Reset(1); |
| 611 } | 611 } |
| 612 | 612 |
| 613 BookmarkBarView::~BookmarkBarView() { | 613 BookmarkBarView::~BookmarkBarView() { |
| 614 if (model_) | 614 if (model_) |
| 615 model_->RemoveObserver(this); | 615 model_->RemoveObserver(this); |
| 616 | 616 |
| 617 // It's possible for the menu to outlive us, reset the observer to make sure | 617 // It's possible for the menu to outlive us, reset the observer to make sure |
| 618 // it doesn't have a reference to us. | 618 // it doesn't have a reference to us. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 } | 792 } |
| 793 return result; | 793 return result; |
| 794 } | 794 } |
| 795 | 795 |
| 796 bool BookmarkBarView::IsDetached() const { | 796 bool BookmarkBarView::IsDetached() const { |
| 797 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || | 797 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || |
| 798 (animating_detached_ && size_animation_.is_animating()); | 798 (animating_detached_ && size_animation_.is_animating()); |
| 799 } | 799 } |
| 800 | 800 |
| 801 int BookmarkBarView::GetToolbarOverlap() const { | 801 int BookmarkBarView::GetToolbarOverlap() const { |
| 802 int attached_overlap = kToolbarAttachedBookmarkBarOverlap + | 802 int attached_overlap = kToolbarAttachedBookmarkBarOverlap; |
| 803 views::NonClientFrameView::kClientEdgeThickness; | 803 |
| 804 if (!IsDetached()) | 804 if (!IsDetached()) |
| 805 return attached_overlap; | 805 return attached_overlap; |
| 806 | 806 |
| 807 int detached_overlap = views::NonClientFrameView::kClientEdgeThickness; | |
| 808 | |
| 809 // Do not animate the overlap when the infobar is above us (i.e. when we're | 807 // Do not animate the overlap when the infobar is above us (i.e. when we're |
| 810 // detached), since drawing over the infobar looks weird. | 808 // detached), since drawing over the infobar looks weird. |
| 811 if (infobar_visible_) | 809 if (infobar_visible_) |
| 812 return detached_overlap; | 810 return 0; |
| 813 | 811 |
| 814 // When detached with no infobar, animate the overlap between the attached and | 812 // When detached with no infobar, animate the overlap between the attached and |
| 815 // detached states. | 813 // detached states. |
| 816 return detached_overlap + static_cast<int>( | 814 return static_cast<int>(attached_overlap * size_animation_.GetCurrentValue()); |
| 817 (attached_overlap - detached_overlap) * | |
| 818 size_animation_.GetCurrentValue()); | |
| 819 } | 815 } |
| 820 | 816 |
| 821 int BookmarkBarView::GetPreferredHeight() const { | 817 int BookmarkBarView::GetPreferredHeight() const { |
| 822 int height = chrome::kMinimumBookmarkBarHeight; | 818 int height = chrome::kMinimumBookmarkBarHeight; |
| 823 for (int i = 0; i < child_count(); ++i) { | 819 for (int i = 0; i < child_count(); ++i) { |
| 824 const views::View* view = child_at(i); | 820 const views::View* view = child_at(i); |
| 825 if (view->visible()) | 821 if (view->visible()) |
| 826 height = std::max(view->GetPreferredSize().height(), height); | 822 height = std::max(view->GetPreferredSize().height(), height); |
| 827 } | 823 } |
| 828 return height; | 824 return height; |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2165 return; | 2161 return; |
| 2166 apps_page_shortcut_->SetVisible(visible); | 2162 apps_page_shortcut_->SetVisible(visible); |
| 2167 UpdateBookmarksSeparatorVisibility(); | 2163 UpdateBookmarksSeparatorVisibility(); |
| 2168 LayoutAndPaint(); | 2164 LayoutAndPaint(); |
| 2169 } | 2165 } |
| 2170 | 2166 |
| 2171 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2167 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2172 if (UpdateOtherAndManagedButtonsVisibility()) | 2168 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2173 LayoutAndPaint(); | 2169 LayoutAndPaint(); |
| 2174 } | 2170 } |
| OLD | NEW |