| 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 "ui/accessibility/ax_node_data.h" |
| 8 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/color_utils.h" | 10 #include "ui/gfx/color_utils.h" |
| 10 #include "ui/gfx/scoped_canvas.h" | 11 #include "ui/gfx/scoped_canvas.h" |
| 11 #include "ui/native_theme/native_theme.h" | 12 #include "ui/native_theme/native_theme.h" |
| 12 #include "ui/views/animation/ink_drop_highlight.h" | 13 #include "ui/views/animation/ink_drop_highlight.h" |
| 13 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Compute the label bounds. The label gets whatever size is left over after | 124 // Compute the label bounds. The label gets whatever size is left over after |
| 124 // accounting for the preferred image width and padding amounts. Note that if | 125 // accounting for the preferred image width and padding amounts. Note that if |
| 125 // the label has zero size it doesn't actually matter what we compute its X | 126 // the label has zero size it doesn't actually matter what we compute its X |
| 126 // value to be, since it won't be visible. | 127 // value to be, since it won't be visible. |
| 127 const int label_x = image_x + image_width + GetInternalSpacing(); | 128 const int label_x = image_x + image_width + GetInternalSpacing(); |
| 128 const int label_width = | 129 const int label_width = |
| 129 std::max(0, width() - label_x - bubble_trailing_padding); | 130 std::max(0, width() - label_x - bubble_trailing_padding); |
| 130 label_->SetBounds(label_x, 0, label_width, height()); | 131 label_->SetBounds(label_x, 0, label_width, height()); |
| 131 } | 132 } |
| 132 | 133 |
| 134 void IconLabelBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 135 label_->GetAccessibleNodeData(node_data); |
| 136 } |
| 137 |
| 133 void IconLabelBubbleView::OnNativeThemeChanged( | 138 void IconLabelBubbleView::OnNativeThemeChanged( |
| 134 const ui::NativeTheme* native_theme) { | 139 const ui::NativeTheme* native_theme) { |
| 135 label_->SetEnabledColor(GetTextColor()); | 140 label_->SetEnabledColor(GetTextColor()); |
| 136 label_->SetBackgroundColor(GetParentBackgroundColor()); | 141 label_->SetBackgroundColor(GetParentBackgroundColor()); |
| 137 SchedulePaint(); | 142 SchedulePaint(); |
| 138 } | 143 } |
| 139 | 144 |
| 140 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 145 void IconLabelBubbleView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 141 image()->SetPaintToLayer(true); | 146 image()->SetPaintToLayer(true); |
| 142 image()->layer()->SetFillsBoundsOpaquely(false); | 147 image()->layer()->SetFillsBoundsOpaquely(false); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 242 |
| 238 // Draw the 1 px separator. | 243 // Draw the 1 px separator. |
| 239 gfx::ScopedCanvas scoped_canvas(canvas); | 244 gfx::ScopedCanvas scoped_canvas(canvas); |
| 240 const float scale = canvas->UndoDeviceScaleFactor(); | 245 const float scale = canvas->UndoDeviceScaleFactor(); |
| 241 // Keep the separator aligned on a pixel center. | 246 // Keep the separator aligned on a pixel center. |
| 242 const gfx::RectF pixel_aligned_bounds = | 247 const gfx::RectF pixel_aligned_bounds = |
| 243 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); | 248 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); |
| 244 canvas->DrawLine(pixel_aligned_bounds.top_right(), | 249 canvas->DrawLine(pixel_aligned_bounds.top_right(), |
| 245 pixel_aligned_bounds.bottom_right(), separator_color); | 250 pixel_aligned_bounds.bottom_right(), separator_color); |
| 246 } | 251 } |
| OLD | NEW |