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" | 13 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
17 #include "ui/gfx/text_utils.h" | 17 #include "ui/gfx/text_utils.h" |
18 #include "ui/strings/grit/ui_strings.h" | 18 #include "ui/strings/grit/ui_strings.h" |
19 #include "ui/views/bubble/bubble_delegate.h" | 19 #include "ui/views/bubble/bubble_delegate.h" |
20 #include "ui/views/controls/button/button.h" | 20 #include "ui/views/controls/button/button.h" |
21 #include "ui/views/controls/button/label_button.h" | 21 #include "ui/views/controls/button/label_button.h" |
22 #include "ui/views/layout/box_layout.h" | 22 #include "ui/views/layout/box_layout.h" |
| 23 #include "ui/views/style/platform_style.h" |
23 | 24 |
24 namespace views { | 25 namespace views { |
25 namespace { | 26 namespace { |
26 | 27 |
27 const int kMenuCommands[] = {IDS_APP_CUT, IDS_APP_COPY, IDS_APP_PASTE}; | 28 const int kMenuCommands[] = {IDS_APP_CUT, IDS_APP_COPY, IDS_APP_PASTE}; |
28 const int kSpacingBetweenButtons = 2; | 29 const int kSpacingBetweenButtons = 2; |
29 const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0); | 30 const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0); |
30 const int kMenuButtonMinHeight = 38; | 31 const int kMenuButtonMinHeight = 38; |
31 const int kMenuButtonMinWidth = 63; | 32 const int kMenuButtonMinWidth = 63; |
32 const int kMenuMargin = 1; | 33 const int kMenuMargin = 1; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 Layout(); | 153 Layout(); |
153 } | 154 } |
154 | 155 |
155 Button* TouchSelectionMenuRunnerViews::Menu::CreateButton( | 156 Button* TouchSelectionMenuRunnerViews::Menu::CreateButton( |
156 const base::string16& title, | 157 const base::string16& title, |
157 int tag) { | 158 int tag) { |
158 base::string16 label = | 159 base::string16 label = |
159 gfx::RemoveAcceleratorChar(title, '&', nullptr, nullptr); | 160 gfx::RemoveAcceleratorChar(title, '&', nullptr, nullptr); |
160 LabelButton* button = new LabelButton(this, label); | 161 LabelButton* button = new LabelButton(this, label); |
161 button->SetMinSize(gfx::Size(kMenuButtonMinWidth, kMenuButtonMinHeight)); | 162 button->SetMinSize(gfx::Size(kMenuButtonMinWidth, kMenuButtonMinHeight)); |
162 button->SetFocusable(true); | 163 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, button); |
163 button->set_request_focus_on_press(false); | 164 button->set_request_focus_on_press(false); |
164 const gfx::FontList& font_list = | 165 const gfx::FontList& font_list = |
165 ui::ResourceBundle::GetSharedInstance().GetFontList( | 166 ui::ResourceBundle::GetSharedInstance().GetFontList( |
166 ui::ResourceBundle::SmallFont); | 167 ui::ResourceBundle::SmallFont); |
167 button->SetFontList(font_list); | 168 button->SetFontList(font_list); |
168 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 169 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
169 button->set_tag(tag); | 170 button->set_tag(tag); |
170 return button; | 171 return button; |
171 } | 172 } |
172 | 173 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Closing the menu sets |menu_| to nullptr and eventually deletes the object. | 267 // Closing the menu sets |menu_| to nullptr and eventually deletes the object. |
267 menu_->Close(); | 268 menu_->Close(); |
268 DCHECK(!menu_); | 269 DCHECK(!menu_); |
269 } | 270 } |
270 | 271 |
271 bool TouchSelectionMenuRunnerViews::IsRunning() const { | 272 bool TouchSelectionMenuRunnerViews::IsRunning() const { |
272 return menu_ != nullptr; | 273 return menu_ != nullptr; |
273 } | 274 } |
274 | 275 |
275 } // namespace views | 276 } // namespace views |
OLD | NEW |