| 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 "chrome/browser/ui/layout_constants.h" | 7 #include "chrome/browser/ui/layout_constants.h" |
| 8 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 8 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/color_utils.h" | 12 #include "ui/gfx/color_utils.h" |
| 13 #include "ui/gfx/scoped_canvas.h" | 13 #include "ui/gfx/scoped_canvas.h" |
| 14 #include "ui/native_theme/native_theme.h" | 14 #include "ui/native_theme/native_theme.h" |
| 15 #include "ui/views/animation/ink_drop_highlight.h" | 15 #include "ui/views/animation/ink_drop_highlight.h" |
| 16 #include "ui/views/border.h" | 16 #include "ui/views/border.h" |
| 17 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Amount of space on either side of the separator that appears after the label. | 22 // Amount of space on either side of the separator that appears after the label. |
| 23 constexpr int kSpaceBesideSeparator = 8; | 23 constexpr int kSpaceBesideSeparator = 8; |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 IconLabelBubbleView::IconLabelBubbleView(const gfx::FontList& font_list, | 27 IconLabelBubbleView::IconLabelBubbleView(const gfx::FontList& font_list, |
| 28 bool elide_in_middle) | 28 bool elide_in_middle) |
| 29 : image_(new views::ImageView()), | 29 : image_(new views::ImageView()), |
| 30 label_(new views::Label(base::string16(), font_list)) { | 30 label_(new views::Label(base::string16(), |
| 31 views::Label::CustomFont{font_list})) { |
| 31 // Disable separate hit testing for |image_|. This prevents views treating | 32 // Disable separate hit testing for |image_|. This prevents views treating |
| 32 // |image_| as a separate mouse hover region from |this|. | 33 // |image_| as a separate mouse hover region from |this|. |
| 33 image_->set_can_process_events_within_subtree(false); | 34 image_->set_can_process_events_within_subtree(false); |
| 34 image_->SetBorder(views::CreateEmptyBorder( | 35 image_->SetBorder(views::CreateEmptyBorder( |
| 35 gfx::Insets(LocationBarView::kIconInteriorPadding))); | 36 gfx::Insets(LocationBarView::kIconInteriorPadding))); |
| 36 AddChildView(image_); | 37 AddChildView(image_); |
| 37 | 38 |
| 38 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 39 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 39 | 40 |
| 40 if (elide_in_middle) | 41 if (elide_in_middle) |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 233 |
| 233 // Draw the 1 px separator. | 234 // Draw the 1 px separator. |
| 234 gfx::ScopedCanvas scoped_canvas(canvas); | 235 gfx::ScopedCanvas scoped_canvas(canvas); |
| 235 const float scale = canvas->UndoDeviceScaleFactor(); | 236 const float scale = canvas->UndoDeviceScaleFactor(); |
| 236 // Keep the separator aligned on a pixel center. | 237 // Keep the separator aligned on a pixel center. |
| 237 const gfx::RectF pixel_aligned_bounds = | 238 const gfx::RectF pixel_aligned_bounds = |
| 238 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); | 239 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); |
| 239 canvas->DrawLine(pixel_aligned_bounds.top_right(), | 240 canvas->DrawLine(pixel_aligned_bounds.top_right(), |
| 240 pixel_aligned_bounds.bottom_right(), separator_color); | 241 pixel_aligned_bounds.bottom_right(), separator_color); |
| 241 } | 242 } |
| OLD | NEW |