Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: chrome/browser/chromeos/login/keyboard_switch_menu.cc

Issue 6962012: Convert ChromiumOS input method menu to views::MenuItemView implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/input_method_menu.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/login/keyboard_switch_menu.h" 5 #include "chrome/browser/chromeos/login/keyboard_switch_menu.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "chrome/browser/chromeos/input_method/input_method_util.h" 10 #include "chrome/browser/chromeos/input_method/input_method_util.h"
(...skipping 22 matching lines...) Expand all
33 views::Widget::NotifyLocaleChanged(); 33 views::Widget::NotifyLocaleChanged();
34 } 34 }
35 35
36 bool KeyboardSwitchMenu::ShouldSupportConfigUI() { 36 bool KeyboardSwitchMenu::ShouldSupportConfigUI() {
37 return false; 37 return false;
38 } 38 }
39 39
40 //////////////////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////////////////
41 // views::ViewMenuDelegate implementation. 41 // views::ViewMenuDelegate implementation.
42 void KeyboardSwitchMenu::RunMenu(views::View* source, const gfx::Point& pt) { 42 void KeyboardSwitchMenu::RunMenu(views::View* source, const gfx::Point& pt) {
43 PrepareForMenuOpen();
44 gfx::Point new_pt(pt); 43 gfx::Point new_pt(pt);
45 views::MenuButton* button = static_cast<views::MenuButton*>(source); 44 views::MenuButton* button = static_cast<views::MenuButton*>(source);
46 // Keyboard switch menu is aligned on left by default. 45 // Keyboard switch menu is aligned on left by default. MenuButton passes
46 // in pt the lower left corner for RTL and the lower right corner for
47 // non-RTL (with menu_offset applied).
47 int reverse_offset = button->width() + button->menu_offset().x() * 2; 48 int reverse_offset = button->width() + button->menu_offset().x() * 2;
48 if (base::i18n::IsRTL()) { 49 if (base::i18n::IsRTL()) {
49 new_pt.set_x(pt.x() + reverse_offset); 50 new_pt.set_x(pt.x() + reverse_offset);
50 } else { 51 } else {
51 new_pt.set_x(pt.x() - reverse_offset); 52 new_pt.set_x(pt.x() - reverse_offset);
52 } 53 }
53 input_method_menu().RunMenuAt(new_pt, views::Menu2::ALIGN_TOPLEFT); 54
55 set_menu_alignment(views::MenuItemView::TOPLEFT);
56 InputMethodMenu::RunMenu(source, new_pt);
54 } 57 }
55 58
56 string16 KeyboardSwitchMenu::GetCurrentKeyboardName() const { 59 string16 KeyboardSwitchMenu::GetCurrentKeyboardName() const {
57 const int count = GetItemCount(); 60 const int count = GetItemCount();
58 for (int i = 0; i < count; ++i) { 61 for (int i = 0; i < count; ++i) {
59 if (IsItemCheckedAt(i)) 62 if (IsItemCheckedAt(i))
60 return GetLabelAt(i); 63 return GetLabelAt(i);
61 } 64 }
62 VLOG(1) << "The input method menu is not ready yet. Show the display " 65 VLOG(1) << "The input method menu is not ready yet. Show the display "
63 << "name of the current input method"; 66 << "name of the current input method";
64 InputMethodLibrary* library = CrosLibrary::Get()->GetInputMethodLibrary(); 67 InputMethodLibrary* library = CrosLibrary::Get()->GetInputMethodLibrary();
65 return UTF8ToUTF16(input_method::GetInputMethodDisplayNameFromId( 68 return UTF8ToUTF16(input_method::GetInputMethodDisplayNameFromId(
66 library->current_input_method().id)); 69 library->current_input_method().id));
67 } 70 }
68 71
69 } // namespace chromeos 72 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/input_method_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698