| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_editing_menu.h" | 5 #include "ui/views/touchui/touch_editing_menu.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/font_list.h" | 11 #include "ui/gfx/font_list.h" |
| 12 #include "ui/gfx/insets.h" | 12 #include "ui/gfx/insets.h" |
| 13 #include "ui/gfx/text_utils.h" | 13 #include "ui/gfx/text_utils.h" |
| 14 #include "ui/strings/grit/ui_strings.h" | 14 #include "ui/strings/grit/ui_strings.h" |
| 15 #include "ui/views/bubble/bubble_border.h" | 15 #include "ui/views/bubble/bubble_border.h" |
| 16 #include "ui/views/bubble/bubble_frame_view.h" | 16 #include "ui/views/bubble/bubble_frame_view.h" |
| 17 #include "ui/views/controls/button/custom_button.h" | 17 #include "ui/views/controls/button/custom_button.h" |
| 18 #include "ui/views/controls/button/label_button.h" | 18 #include "ui/views/controls/button/label_button.h" |
| 19 #include "ui/views/controls/button/label_button_border.h" | |
| 20 #include "ui/views/layout/box_layout.h" | 19 #include "ui/views/layout/box_layout.h" |
| 21 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 const int kMenuCommands[] = {IDS_APP_CUT, | 24 const int kMenuCommands[] = {IDS_APP_CUT, |
| 26 IDS_APP_COPY, | 25 IDS_APP_COPY, |
| 27 IDS_APP_PASTE}; | 26 IDS_APP_PASTE}; |
| 28 const int kSpacingBetweenButtons = 2; | 27 const int kSpacingBetweenButtons = 2; |
| 29 const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0); | 28 const int kButtonSeparatorColor = SkColorSetARGB(13, 0, 0, 0); |
| 30 const int kMenuButtonHeight = 38; | 29 const int kMenuButtonMinHeight = 38; |
| 31 const int kMenuButtonWidth = 63; | 30 const int kMenuButtonMinWidth = 63; |
| 32 const int kMenuMargin = 1; | 31 const int kMenuMargin = 1; |
| 33 | 32 |
| 34 const char* kEllipsesButtonText = "..."; | 33 const char* kEllipsesButtonText = "..."; |
| 35 const int kEllipsesButtonTag = -1; | 34 const int kEllipsesButtonTag = -1; |
| 36 } // namespace | 35 } // namespace |
| 37 | 36 |
| 38 namespace views { | 37 namespace views { |
| 39 | 38 |
| 40 TouchEditingMenuView::TouchEditingMenuView( | 39 TouchEditingMenuView::TouchEditingMenuView( |
| 41 TouchEditingMenuController* controller, | 40 TouchEditingMenuController* controller, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Finally, add ellipses button. | 135 // Finally, add ellipses button. |
| 137 AddChildView(CreateButton( | 136 AddChildView(CreateButton( |
| 138 base::UTF8ToUTF16(kEllipsesButtonText), kEllipsesButtonTag)); | 137 base::UTF8ToUTF16(kEllipsesButtonText), kEllipsesButtonTag)); |
| 139 Layout(); | 138 Layout(); |
| 140 } | 139 } |
| 141 | 140 |
| 142 Button* TouchEditingMenuView::CreateButton(const base::string16& title, | 141 Button* TouchEditingMenuView::CreateButton(const base::string16& title, |
| 143 int tag) { | 142 int tag) { |
| 144 base::string16 label = gfx::RemoveAcceleratorChar(title, '&', NULL, NULL); | 143 base::string16 label = gfx::RemoveAcceleratorChar(title, '&', NULL, NULL); |
| 145 LabelButton* button = new LabelButton(this, label); | 144 LabelButton* button = new LabelButton(this, label); |
| 145 button->SetMinSize(gfx::Size(kMenuButtonMinWidth, kMenuButtonMinHeight)); |
| 146 button->SetFocusable(true); | 146 button->SetFocusable(true); |
| 147 button->set_request_focus_on_press(false); | 147 button->set_request_focus_on_press(false); |
| 148 const gfx::FontList& font_list = | 148 const gfx::FontList& font_list = |
| 149 ui::ResourceBundle::GetSharedInstance().GetFontList( | 149 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 150 ui::ResourceBundle::SmallFont); | 150 ui::ResourceBundle::SmallFont); |
| 151 scoped_ptr<LabelButtonBorder> button_border( | |
| 152 new LabelButtonBorder(button->style())); | |
| 153 int v_border = (kMenuButtonHeight - font_list.GetHeight()) / 2; | |
| 154 int h_border = (kMenuButtonWidth - gfx::GetStringWidth(label, font_list)) / 2; | |
| 155 button_border->set_insets( | |
| 156 gfx::Insets(v_border, h_border, v_border, h_border)); | |
| 157 button->SetBorder(button_border.Pass()); | |
| 158 button->SetFontList(font_list); | 151 button->SetFontList(font_list); |
| 152 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 159 button->set_tag(tag); | 153 button->set_tag(tag); |
| 160 return button; | 154 return button; |
| 161 } | 155 } |
| 162 | 156 |
| 163 } // namespace views | 157 } // namespace views |
| OLD | NEW |