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/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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 (widget && widget->GetCompositor()->device_scale_factor() >= 2) ? 0 : 1; | 242 (widget && widget->GetCompositor()->device_scale_factor() >= 2) ? 0 : 1; |
243 const int post_label_width = ui::MaterialDesignController::IsModeMaterial() | 243 const int post_label_width = ui::MaterialDesignController::IsModeMaterial() |
244 ? (kSpaceBesideSeparator + separator_width + GetPostSeparatorPadding()) | 244 ? (kSpaceBesideSeparator + separator_width + GetPostSeparatorPadding()) |
245 : GetOuterPadding(false); | 245 : GetOuterPadding(false); |
246 | 246 |
247 // |multiplier| grows from zero to one, stays equal to one and then shrinks | 247 // |multiplier| grows from zero to one, stays equal to one and then shrinks |
248 // to zero again. The view width should correspondingly grow from zero to | 248 // to zero again. The view width should correspondingly grow from zero to |
249 // fully showing both label and icon, stay there, then shrink to just large | 249 // fully showing both label and icon, stay there, then shrink to just large |
250 // enough to show the icon. We don't want to shrink all the way back to | 250 // enough to show the icon. We don't want to shrink all the way back to |
251 // zero, since this would mean the view would completely disappear and then | 251 // zero, since this would mean the view would completely disappear and then |
252 // pop back to an icon after the animation finishes. | 252 // pop back to an icon after the animation finishes. Thus, while shrinking, |
253 const int max_width = GetImageTrailingEdge() + GetInternalSpacing() + | 253 // |multiplier| only refers to the label, separator and padding - the only |
254 label_width + post_label_width; | 254 // parts which, in fact, shrink. |
255 const int current_width = WidthMultiplier() * max_width; | 255 int current_width; |
256 size.set_width(shrinking ? std::max(current_width, size.width()) | 256 if (shrinking) { |
257 : current_width); | 257 current_width = GetImageTrailingEdge() + GetInternalSpacing() + |
258 (label_width + post_label_width) * WidthMultiplier(); | |
259 } else { | |
260 const int max_width = GetImageTrailingEdge() + GetInternalSpacing() + | |
261 label_width + post_label_width; | |
262 current_width = WidthMultiplier() * max_width; | |
263 } | |
264 size.set_width(current_width); | |
Peter Kasting
2016/08/15 23:29:49
It seems like there are two effects this change ha
Kevin Bailey
2016/08/16 16:39:36
Done, but see comment in location_icon_view.cc.
| |
258 } | 265 } |
259 return size; | 266 return size; |
260 } | 267 } |
261 | 268 |
262 int IconLabelBubbleView::MinimumWidthForImageWithBackgroundShown() const { | 269 int IconLabelBubbleView::MinimumWidthForImageWithBackgroundShown() const { |
263 return GetImageTrailingEdge() + GetOuterPadding(false); | 270 return GetImageTrailingEdge() + GetOuterPadding(false); |
264 } | 271 } |
265 | 272 |
266 void IconLabelBubbleView::SetLabelBackgroundColor( | 273 void IconLabelBubbleView::SetLabelBackgroundColor( |
267 SkColor chip_background_color) { | 274 SkColor chip_background_color) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 // Draw the 1 px separator. | 336 // Draw the 1 px separator. |
330 gfx::ScopedCanvas scoped_canvas(canvas); | 337 gfx::ScopedCanvas scoped_canvas(canvas); |
331 const float scale = canvas->UndoDeviceScaleFactor(); | 338 const float scale = canvas->UndoDeviceScaleFactor(); |
332 // Keep the separator aligned on a pixel center. | 339 // Keep the separator aligned on a pixel center. |
333 const gfx::RectF pixel_aligned_bounds = | 340 const gfx::RectF pixel_aligned_bounds = |
334 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); | 341 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); |
335 canvas->DrawLine(pixel_aligned_bounds.top_right(), | 342 canvas->DrawLine(pixel_aligned_bounds.top_right(), |
336 pixel_aligned_bounds.bottom_right(), separator_color); | 343 pixel_aligned_bounds.bottom_right(), separator_color); |
337 } | 344 } |
338 } | 345 } |
OLD | NEW |