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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, | 52 SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, |
53 kSpacingBetweenButtons)); | 53 kSpacingBetweenButtons)); |
54 CreateButtons(); | 54 CreateButtons(); |
55 | 55 |
56 // After buttons are created, check if there is enough room between handles to | 56 // After buttons are created, check if there is enough room between handles to |
57 // show the menu and adjust anchor rect properly if needed, just in case the | 57 // show the menu and adjust anchor rect properly if needed, just in case the |
58 // menu is needed to be shown under the selection. | 58 // menu is needed to be shown under the selection. |
59 gfx::Rect adjusted_anchor_rect(anchor_rect); | 59 gfx::Rect adjusted_anchor_rect(anchor_rect); |
60 int menu_width = GetPreferredSize().width(); | 60 int menu_width = GetPreferredSize().width(); |
| 61 // TODO(mfomitchev): This assumes that the handles are center-aligned to the |
| 62 // achor_rect edges, which is not true. We should fix this, perhaps by passing |
| 63 // down the cumulative width occupied by the handles within anchor_rect plus |
| 64 // the handle image height instead of |handle_image_size|. Perhaps we should |
| 65 // also allow for some minimum padding. |
61 if (menu_width > anchor_rect.width() - handle_image_size.width()) | 66 if (menu_width > anchor_rect.width() - handle_image_size.width()) |
62 adjusted_anchor_rect.Inset(0, 0, 0, -handle_image_size.height()); | 67 adjusted_anchor_rect.Inset(0, 0, 0, -handle_image_size.height()); |
63 SetAnchorRect(adjusted_anchor_rect); | 68 SetAnchorRect(adjusted_anchor_rect); |
64 | 69 |
65 views::BubbleDelegateView::CreateBubble(this); | 70 views::BubbleDelegateView::CreateBubble(this); |
66 GetWidget()->Show(); | 71 GetWidget()->Show(); |
67 } | 72 } |
68 | 73 |
69 TouchEditingMenuView::~TouchEditingMenuView() { | 74 TouchEditingMenuView::~TouchEditingMenuView() { |
70 } | 75 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 const gfx::FontList& font_list = | 153 const gfx::FontList& font_list = |
149 ui::ResourceBundle::GetSharedInstance().GetFontList( | 154 ui::ResourceBundle::GetSharedInstance().GetFontList( |
150 ui::ResourceBundle::SmallFont); | 155 ui::ResourceBundle::SmallFont); |
151 button->SetFontList(font_list); | 156 button->SetFontList(font_list); |
152 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 157 button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
153 button->set_tag(tag); | 158 button->set_tag(tag); |
154 return button; | 159 return button; |
155 } | 160 } |
156 | 161 |
157 } // namespace views | 162 } // namespace views |
OLD | NEW |