OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/touchui/touch_selection_menu_runner_views.h" | 5 #include "ui/views/touchui/touch_selection_menu_runner_views.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/resource/resource_bundle.h" | |
14 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
17 #include "ui/gfx/text_utils.h" | 16 #include "ui/gfx/text_utils.h" |
18 #include "ui/strings/grit/ui_strings.h" | 17 #include "ui/strings/grit/ui_strings.h" |
19 #include "ui/views/bubble/bubble_dialog_delegate.h" | 18 #include "ui/views/bubble/bubble_dialog_delegate.h" |
20 #include "ui/views/controls/button/button.h" | 19 #include "ui/views/controls/button/button.h" |
21 #include "ui/views/controls/button/label_button.h" | 20 #include "ui/views/controls/button/label_button.h" |
22 #include "ui/views/layout/box_layout.h" | 21 #include "ui/views/layout/box_layout.h" |
| 22 #include "ui/views/style/typography.h" |
23 | 23 |
24 namespace views { | 24 namespace views { |
25 namespace { | 25 namespace { |
26 | 26 |
27 const int kMenuCommands[] = {IDS_APP_CUT, IDS_APP_COPY, IDS_APP_PASTE}; | 27 const int kMenuCommands[] = {IDS_APP_CUT, IDS_APP_COPY, IDS_APP_PASTE}; |
28 const int kSpacingBetweenButtons = 2; | 28 const int kSpacingBetweenButtons = 2; |
29 const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0); | 29 const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0); |
30 const int kMenuButtonMinHeight = 38; | 30 const int kMenuButtonMinHeight = 38; |
31 const int kMenuButtonMinWidth = 63; | 31 const int kMenuButtonMinWidth = 63; |
32 const int kMenuMargin = 1; | 32 const int kMenuMargin = 1; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 AddChildView( | 151 AddChildView( |
152 CreateButton(base::UTF8ToUTF16(kEllipsesButtonText), kEllipsesButtonTag)); | 152 CreateButton(base::UTF8ToUTF16(kEllipsesButtonText), kEllipsesButtonTag)); |
153 Layout(); | 153 Layout(); |
154 } | 154 } |
155 | 155 |
156 Button* TouchSelectionMenuRunnerViews::Menu::CreateButton( | 156 Button* TouchSelectionMenuRunnerViews::Menu::CreateButton( |
157 const base::string16& title, | 157 const base::string16& title, |
158 int tag) { | 158 int tag) { |
159 base::string16 label = | 159 base::string16 label = |
160 gfx::RemoveAcceleratorChar(title, '&', nullptr, nullptr); | 160 gfx::RemoveAcceleratorChar(title, '&', nullptr, nullptr); |
161 LabelButton* button = new LabelButton(this, label); | 161 LabelButton* button = new LabelButton(this, label, style::CONTEXT_TOUCH_MENU); |
162 button->SetMinSize(gfx::Size(kMenuButtonMinWidth, kMenuButtonMinHeight)); | 162 button->SetMinSize(gfx::Size(kMenuButtonMinWidth, kMenuButtonMinHeight)); |
163 button->SetFocusForPlatform(); | 163 button->SetFocusForPlatform(); |
164 button->AdjustFontSize(ui::ResourceBundle::kSmallFontDelta); | |
165 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 164 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
166 button->set_tag(tag); | 165 button->set_tag(tag); |
167 return button; | 166 return button; |
168 } | 167 } |
169 | 168 |
170 void TouchSelectionMenuRunnerViews::Menu::CloseMenu() { | 169 void TouchSelectionMenuRunnerViews::Menu::CloseMenu() { |
171 DisconnectOwner(); | 170 DisconnectOwner(); |
172 // Closing the widget will self-destroy this object. | 171 // Closing the widget will self-destroy this object. |
173 Widget* widget = GetWidget(); | 172 Widget* widget = GetWidget(); |
174 if (widget && !widget->IsClosed()) | 173 if (widget && !widget->IsClosed()) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Closing the menu sets |menu_| to nullptr and eventually deletes the object. | 266 // Closing the menu sets |menu_| to nullptr and eventually deletes the object. |
268 menu_->CloseMenu(); | 267 menu_->CloseMenu(); |
269 DCHECK(!menu_); | 268 DCHECK(!menu_); |
270 } | 269 } |
271 | 270 |
272 bool TouchSelectionMenuRunnerViews::IsRunning() const { | 271 bool TouchSelectionMenuRunnerViews::IsRunning() const { |
273 return menu_ != nullptr; | 272 return menu_ != nullptr; |
274 } | 273 } |
275 | 274 |
276 } // namespace views | 275 } // namespace views |
OLD | NEW |