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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 | 112 |
113 double IconLabelBubbleView::WidthMultiplier() const { | 113 double IconLabelBubbleView::WidthMultiplier() const { |
114 return 1.0; | 114 return 1.0; |
115 } | 115 } |
116 | 116 |
117 bool IconLabelBubbleView::IsShrinking() const { | 117 bool IconLabelBubbleView::IsShrinking() const { |
118 return false; | 118 return false; |
119 } | 119 } |
120 | 120 |
121 bool IconLabelBubbleView::OnActivate() { | 121 bool IconLabelBubbleView::OnActivate(const ui::Event& event) { |
122 return false; | 122 return false; |
123 } | 123 } |
124 | 124 |
125 gfx::Size IconLabelBubbleView::GetPreferredSize() const { | 125 gfx::Size IconLabelBubbleView::GetPreferredSize() const { |
126 // Height will be ignored by the LocationBarView. | 126 // Height will be ignored by the LocationBarView. |
127 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); | 127 return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
128 } | 128 } |
129 | 129 |
130 bool IconLabelBubbleView::OnKeyPressed(const ui::KeyEvent& event) { | 130 bool IconLabelBubbleView::OnKeyPressed(const ui::KeyEvent& event) { |
131 if (event.key_code() == ui::VKEY_RETURN) | 131 if (event.key_code() == ui::VKEY_RETURN) |
132 return OnActivate(); | 132 return OnActivate(event); |
133 return false; | 133 return false; |
134 } | 134 } |
135 | 135 |
136 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) { | 136 bool IconLabelBubbleView::OnKeyReleased(const ui::KeyEvent& event) { |
137 if (event.key_code() == ui::VKEY_SPACE) | 137 if (event.key_code() == ui::VKEY_SPACE) |
138 return OnActivate(); | 138 return OnActivate(event); |
139 return false; | 139 return false; |
140 } | 140 } |
141 | 141 |
142 void IconLabelBubbleView::Layout() { | 142 void IconLabelBubbleView::Layout() { |
143 // Compute the image bounds. In non-MD, the leading padding depends on | 143 // Compute the image bounds. In non-MD, the leading padding depends on |
144 // whether this is an extension icon, since extension icons and | 144 // whether this is an extension icon, since extension icons and |
145 // Chrome-provided icons are different sizes. In MD, these sizes are the | 145 // Chrome-provided icons are different sizes. In MD, these sizes are the |
146 // same, so it's not necessary to handle the two types differently. | 146 // same, so it's not necessary to handle the two types differently. |
147 const bool icon_has_enough_padding = | 147 const bool icon_has_enough_padding = |
148 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); | 148 !is_extension_icon_ || ui::MaterialDesignController::IsModeMaterial(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // Draw the 1 px separator. | 328 // Draw the 1 px separator. |
329 gfx::ScopedCanvas scoped_canvas(canvas); | 329 gfx::ScopedCanvas scoped_canvas(canvas); |
330 const float scale = canvas->UndoDeviceScaleFactor(); | 330 const float scale = canvas->UndoDeviceScaleFactor(); |
331 // Keep the separator aligned on a pixel center. | 331 // Keep the separator aligned on a pixel center. |
332 const gfx::RectF pixel_aligned_bounds = | 332 const gfx::RectF pixel_aligned_bounds = |
333 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); | 333 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); |
334 canvas->DrawLine(pixel_aligned_bounds.top_right(), | 334 canvas->DrawLine(pixel_aligned_bounds.top_right(), |
335 pixel_aligned_bounds.bottom_right(), separator_color); | 335 pixel_aligned_bounds.bottom_right(), separator_color); |
336 } | 336 } |
337 } | 337 } |
OLD | NEW |