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

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_view.cc

Issue 1322323006: Change toolbar height for material design on Ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/toolbar/toolbar_view.cc
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
index 5f1b2a608f0a7b92ac4182509a32659576a85043..5b83aebc135ac957e7d51abd23f43da138b17201 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -102,6 +102,19 @@ bool HasAshShell() {
}
#endif // OS_CHROMEOS
+// Returns the y-position that will center an element of height
+// |child_height| inside an element of height |parent_height|. For
+// material design excess padding is placed below, for non-material
+// it is placed above.
+int CenteredChildY(int parent_height, int child_height) {
+ int child_y = (parent_height - child_height + 1) / 2;
Peter Kasting 2015/09/08 19:38:34 Nit: Why not just: int roundoff_amount = ui::Ma
tdanderson 2015/09/09 17:23:06 Changed.
+ if (!ui::MaterialDesignController::IsModeMaterial() ||
+ parent_height - child_height % 2 == 0) {
+ return child_y;
+ }
+ return child_y - 1;
+}
+
} // namespace
// static
@@ -557,7 +570,7 @@ void ToolbarView::Layout() {
// padding above the buttons.
Peter Kasting 2015/09/08 19:38:34 Nit: Delete the last sentence here
tdanderson 2015/09/09 17:23:06 Done.
int child_height =
std::min(back_->GetPreferredSize().height(), height());
- int child_y = (height() - child_height + 1) / 2;
+ int child_y = CenteredChildY(height(), child_height);
// If the window is maximized, we extend the back button to the left so that
// clicking on the left-most pixel will activate the back button.
@@ -616,7 +629,8 @@ void ToolbarView::Layout() {
location_bar_right_padding - next_element_x);
int location_height = location_bar_->GetPreferredSize().height();
- int location_y = (height() - location_height + 1) / 2;
+ int location_y = CenteredChildY(height(), location_height);
+
location_bar_->SetBounds(next_element_x, location_y,
std::max(available_width, 0), location_height);
next_element_x = location_bar_->bounds().right() + location_bar_right_padding;
@@ -769,9 +783,12 @@ gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const {
if (ui::MaterialDesignController::IsModeMaterial()) {
int content_height = std::max(back_->GetPreferredSize().height(),
location_bar_->GetPreferredSize().height());
- int padding = GetThemeProvider()->GetDisplayProperty(
- ThemeProperties::PROPERTY_TOOLBAR_VIEW_VERTICAL_PADDING);
- size.SetToMax(gfx::Size(0, content_height + (padding * 2)));
+ int top_padding = GetThemeProvider()->GetDisplayProperty(
+ ThemeProperties::PROPERTY_TOOLBAR_VIEW_TOP_VERTICAL_PADDING);
+ int bottom_padding = GetThemeProvider()->GetDisplayProperty(
+ ThemeProperties::PROPERTY_TOOLBAR_VIEW_BOTTOM_VERTICAL_PADDING);
+ size.SetToMax(
+ gfx::Size(0, content_height + (top_padding + bottom_padding)));
} else {
gfx::ImageSkia* normal_background =
GetThemeProvider()->GetImageSkiaNamed(IDR_CONTENT_TOP_CENTER);

Powered by Google App Engine
This is Rietveld 408576698