Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 2899133004: Reduce overdraw on bookmark bar (Closed)
Patch Set: revert change in browserview Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
609 608
610 size_animation_.Reset(1); 609 size_animation_.Reset(1);
611 } 610 }
612 611
613 BookmarkBarView::~BookmarkBarView() { 612 BookmarkBarView::~BookmarkBarView() {
614 if (model_) 613 if (model_)
615 model_->RemoveObserver(this); 614 model_->RemoveObserver(this);
616 615
617 // It's possible for the menu to outlive us, reset the observer to make sure 616 // It's possible for the menu to outlive us, reset the observer to make sure
618 // it doesn't have a reference to us. 617 // it doesn't have a reference to us.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 } 791 }
793 return result; 792 return result;
794 } 793 }
795 794
796 bool BookmarkBarView::IsDetached() const { 795 bool BookmarkBarView::IsDetached() const {
797 return (bookmark_bar_state_ == BookmarkBar::DETACHED) || 796 return (bookmark_bar_state_ == BookmarkBar::DETACHED) ||
798 (animating_detached_ && size_animation_.is_animating()); 797 (animating_detached_ && size_animation_.is_animating());
799 } 798 }
800 799
801 int BookmarkBarView::GetToolbarOverlap() const { 800 int BookmarkBarView::GetToolbarOverlap() const {
802 int attached_overlap = kToolbarAttachedBookmarkBarOverlap + 801 int attached_overlap = kToolbarAttachedBookmarkBarOverlap;
803 views::NonClientFrameView::kClientEdgeThickness; 802
804 if (!IsDetached()) 803 if (!IsDetached())
805 return attached_overlap; 804 return attached_overlap;
806 805
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 806 // 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. 807 // detached), since drawing over the infobar looks weird.
811 if (infobar_visible_) 808 if (infobar_visible_)
812 return detached_overlap; 809 return 0;
813 810
814 // When detached with no infobar, animate the overlap between the attached and 811 // When detached with no infobar, animate the overlap between the attached and
815 // detached states. 812 // detached states.
816 return detached_overlap + static_cast<int>( 813 return static_cast<int>(attached_overlap * size_animation_.GetCurrentValue());
817 (attached_overlap - detached_overlap) *
818 size_animation_.GetCurrentValue());
819 } 814 }
820 815
821 int BookmarkBarView::GetPreferredHeight() const { 816 int BookmarkBarView::GetPreferredHeight() const {
822 int height = chrome::kMinimumBookmarkBarHeight; 817 int height = chrome::kMinimumBookmarkBarHeight;
823 for (int i = 0; i < child_count(); ++i) { 818 for (int i = 0; i < child_count(); ++i) {
824 const views::View* view = child_at(i); 819 const views::View* view = child_at(i);
825 if (view->visible()) 820 if (view->visible())
826 height = std::max(view->GetPreferredSize().height(), height); 821 height = std::max(view->GetPreferredSize().height(), height);
827 } 822 }
828 return height; 823 return height;
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 return; 2160 return;
2166 apps_page_shortcut_->SetVisible(visible); 2161 apps_page_shortcut_->SetVisible(visible);
2167 UpdateBookmarksSeparatorVisibility(); 2162 UpdateBookmarksSeparatorVisibility();
2168 LayoutAndPaint(); 2163 LayoutAndPaint();
2169 } 2164 }
2170 2165
2171 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2166 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2172 if (UpdateOtherAndManagedButtonsVisibility()) 2167 if (UpdateOtherAndManagedButtonsVisibility())
2173 LayoutAndPaint(); 2168 LayoutAndPaint();
2174 } 2169 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698