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

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

Issue 2208973003: Add some extra height to bookmark bar if the font wants to be larger (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 591 }
592 592
593 private: 593 private:
594 DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView); 594 DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView);
595 }; 595 };
596 596
597 // BookmarkBarView ------------------------------------------------------------ 597 // BookmarkBarView ------------------------------------------------------------
598 598
599 // static 599 // static
600 const char BookmarkBarView::kViewClassName[] = "BookmarkBarView"; 600 const char BookmarkBarView::kViewClassName[] = "BookmarkBarView";
601 int BookmarkBarView::extra_font_padding_ = -1;
601 602
602 BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view) 603 BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view)
603 : page_navigator_(NULL), 604 : page_navigator_(NULL),
604 managed_(NULL), 605 managed_(NULL),
605 bookmark_menu_(NULL), 606 bookmark_menu_(NULL),
606 bookmark_drop_menu_(NULL), 607 bookmark_drop_menu_(NULL),
607 other_bookmarks_button_(NULL), 608 other_bookmarks_button_(NULL),
608 managed_bookmarks_button_(NULL), 609 managed_bookmarks_button_(NULL),
609 supervised_bookmarks_button_(NULL), 610 supervised_bookmarks_button_(NULL),
610 apps_page_shortcut_(NULL), 611 apps_page_shortcut_(NULL),
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 if (infobar_visible_) 837 if (infobar_visible_)
837 return detached_overlap; 838 return detached_overlap;
838 839
839 // When detached with no infobar, animate the overlap between the attached and 840 // When detached with no infobar, animate the overlap between the attached and
840 // detached states. 841 // detached states.
841 return detached_overlap + static_cast<int>( 842 return detached_overlap + static_cast<int>(
842 (attached_overlap - detached_overlap) * 843 (attached_overlap - detached_overlap) *
843 size_animation_.GetCurrentValue()); 844 size_animation_.GetCurrentValue());
844 } 845 }
845 846
847 int BookmarkBarView::GetExtraFontPadding() const {
848 if (extra_font_padding_ == -1) {
849 int height = 0;
850 for (int i = 0; i < child_count(); ++i) {
851 const views::View* view = child_at(i);
852 gfx::Size pref = view->GetPreferredSize();
853 height = std::max(pref.height(), height);
854 }
855 extra_font_padding_ = std::max(0, height - chrome::kBookmarkBarHeight);
856 }
857 return extra_font_padding_;
858 }
859
846 gfx::Size BookmarkBarView::GetPreferredSize() const { 860 gfx::Size BookmarkBarView::GetPreferredSize() const {
847 gfx::Size prefsize; 861 gfx::Size prefsize;
848 if (IsDetached()) { 862 if (IsDetached()) {
863 int padded_height = chrome::kBookmarkBarHeight + GetExtraFontPadding();
849 prefsize.set_height( 864 prefsize.set_height(
850 chrome::kBookmarkBarHeight + 865 padded_height +
851 static_cast<int>( 866 static_cast<int>((chrome::kNTPBookmarkBarHeight - padded_height) *
852 (chrome::kNTPBookmarkBarHeight - chrome::kBookmarkBarHeight) * 867 (1 - size_animation_.GetCurrentValue())));
853 (1 - size_animation_.GetCurrentValue())));
854 } else { 868 } else {
855 prefsize.set_height(static_cast<int>(chrome::kBookmarkBarHeight * 869 prefsize.set_height(
856 size_animation_.GetCurrentValue())); 870 static_cast<int>((chrome::kBookmarkBarHeight + GetExtraFontPadding()) *
Evan Stade 2016/08/04 16:05:40 this should probably just take the max of its chil
kylix_rd 2016/08/04 16:42:10 One of the issues I noticed is if the calculation
871 size_animation_.GetCurrentValue()));
857 } 872 }
858 return prefsize; 873 return prefsize;
859 } 874 }
860 875
861 bool BookmarkBarView::CanProcessEventsWithinSubtree() const { 876 bool BookmarkBarView::CanProcessEventsWithinSubtree() const {
862 // If the bookmark bar is attached and the omnibox popup is open (on top of 877 // If the bookmark bar is attached and the omnibox popup is open (on top of
863 // the bar), prevent events from targeting the bookmark bar or any of its 878 // the bar), prevent events from targeting the bookmark bar or any of its
864 // descendants. This will prevent hovers/clicks just above the omnibox popup 879 // descendants. This will prevent hovers/clicks just above the omnibox popup
865 // from activating the top few pixels of items on the bookmark bar. 880 // from activating the top few pixels of items on the bookmark bar.
866 if (!IsDetached() && browser_view_ && 881 if (!IsDetached() && browser_view_ &&
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 return; 2189 return;
2175 apps_page_shortcut_->SetVisible(visible); 2190 apps_page_shortcut_->SetVisible(visible);
2176 UpdateBookmarksSeparatorVisibility(); 2191 UpdateBookmarksSeparatorVisibility();
2177 LayoutAndPaint(); 2192 LayoutAndPaint();
2178 } 2193 }
2179 2194
2180 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { 2195 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() {
2181 if (UpdateOtherAndManagedButtonsVisibility()) 2196 if (UpdateOtherAndManagedButtonsVisibility())
2182 LayoutAndPaint(); 2197 LayoutAndPaint();
2183 } 2198 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698