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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 2075443002: Remove IconLabelView layout constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment, fix compile Created 4 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/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/layout_constants.h" 8 #include "chrome/browser/ui/layout_constants.h"
9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" 9 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // against |parent_background_color_| using the original image grid color's 262 // against |parent_background_color_| using the original image grid color's
263 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged 263 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged
264 // even if |a| is a color with non-255 alpha. 264 // even if |a| is a color with non-255 alpha.
265 label_->SetBackgroundColor(color_utils::AlphaBlend( 265 label_->SetBackgroundColor(color_utils::AlphaBlend(
266 SkColorSetA(chip_background_color, 255), GetParentBackgroundColor(), 266 SkColorSetA(chip_background_color, 255), GetParentBackgroundColor(),
267 SkColorGetA(chip_background_color))); 267 SkColorGetA(chip_background_color)));
268 } 268 }
269 269
270 int IconLabelBubbleView::GetOuterPadding(bool leading) const { 270 int IconLabelBubbleView::GetOuterPadding(bool leading) const {
271 if (ui::MaterialDesignController::IsModeMaterial()) 271 if (ui::MaterialDesignController::IsModeMaterial())
272 return GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING); 272 return GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
273 273
274 return GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) - 274 return GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) -
275 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + 275 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
276 (leading ? 0 : GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING)); 276 (leading ? 0 : kTrailingPaddingPreMd);
277 } 277 }
278 278
279 int IconLabelBubbleView::GetInternalSpacing() const { 279 int IconLabelBubbleView::GetInternalSpacing() const {
280 return image_->GetPreferredSize().IsEmpty() 280 return image_->GetPreferredSize().IsEmpty()
281 ? 0 281 ? 0
282 : GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_SPACING); 282 : GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
283 } 283 }
284 284
285 const char* IconLabelBubbleView::GetClassName() const { 285 const char* IconLabelBubbleView::GetClassName() const {
286 return "IconLabelBubbleView"; 286 return "IconLabelBubbleView";
287 } 287 }
288 288
289 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { 289 void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) {
290 if (!ShouldShowBackground()) 290 if (!ShouldShowBackground())
291 return; 291 return;
292 if (background_painter_) { 292 if (background_painter_) {
293 views::Painter::PaintPainterAt(canvas, background_painter_.get(), 293 views::Painter::PaintPainterAt(canvas, background_painter_.get(),
294 GetContentsBounds()); 294 GetContentsBounds());
295 } 295 }
296 296
297 // In MD, draw a separator and not a background. 297 // In MD, draw a separator and not a background.
298 if (ui::MaterialDesignController::IsModeMaterial()) { 298 if (ui::MaterialDesignController::IsModeMaterial()) {
299 const SkColor plain_text_color = GetNativeTheme()->GetSystemColor( 299 const SkColor plain_text_color = GetNativeTheme()->GetSystemColor(
300 ui::NativeTheme::kColorId_TextfieldDefaultColor); 300 ui::NativeTheme::kColorId_TextfieldDefaultColor);
301 const SkColor separator_color = SkColorSetA( 301 const SkColor separator_color = SkColorSetA(
302 plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC); 302 plain_text_color, color_utils::IsDark(plain_text_color) ? 0x59 : 0xCC);
303 303
304 // Amount of padding that is built into the whatever view comes after this 304 // Amount of padding that is built into the whatever view comes after this
305 // one in the location bar (e.g. omnibox textfield). 305 // one in the location bar (e.g. omnibox textfield).
306 int post_chip_spacing = 306 int post_chip_spacing =
307 GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); 307 GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
308 // Amount of space to leave after the separator (dp). 308 // Amount of space to leave after the separator (dp).
309 const int kPostSeparatorSpacing = 309 const int kPostSeparatorSpacing =
310 (GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING) + 310 (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) +
311 kExtraTrailingPadding + post_chip_spacing) / 311 kExtraTrailingPadding + post_chip_spacing) /
312 2 - 312 2 -
313 post_chip_spacing; 313 post_chip_spacing;
314 // Height of the separator (dp). 314 // Height of the separator (dp).
315 const int kSeparatorHeight = 16; 315 const int kSeparatorHeight = 16;
316 gfx::Rect bounds(GetLocalBounds()); 316 gfx::Rect bounds(GetLocalBounds());
317 bounds.Inset(kPostSeparatorSpacing, 317 bounds.Inset(kPostSeparatorSpacing,
318 (bounds.height() - kSeparatorHeight) / 2); 318 (bounds.height() - kSeparatorHeight) / 2);
319 319
320 // 1px at all scale factors. 320 // 1px at all scale factors.
321 gfx::ScopedCanvas scoped_canvas(canvas); 321 gfx::ScopedCanvas scoped_canvas(canvas);
322 const float scale = canvas->UndoDeviceScaleFactor(); 322 const float scale = canvas->UndoDeviceScaleFactor();
323 const gfx::RectF pixel_aligned_bounds = 323 const gfx::RectF pixel_aligned_bounds =
324 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); 324 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0);
325 canvas->DrawLine(pixel_aligned_bounds.top_right(), 325 canvas->DrawLine(pixel_aligned_bounds.top_right(),
326 pixel_aligned_bounds.bottom_right(), separator_color); 326 pixel_aligned_bounds.bottom_right(), separator_color);
327 } 327 }
328 } 328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698