summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authoravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 20:56:48 +0000
committeravayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 20:56:48 +0000
commitc32f04146677ab69289f661de3236fda5791c953 (patch)
tree5e2bd8a649cf69696ea236bed422898e0e1e8957 /views
parent2c58e65c67d21074424eeeb2673a995d42a6614e (diff)
downloadchromium_src-c32f04146677ab69289f661de3236fda5791c953.zip
chromium_src-c32f04146677ab69289f661de3236fda5791c953.tar.gz
chromium_src-c32f04146677ab69289f661de3236fda5791c953.tar.bz2
Fixed alignment of button dropdowns for RTL languages.
BUG=none TEST=Run chrome with LANGUAGE=ar or with --lang=ar. Verify that all status area menus as well as main menu are aligned properly (go to the right, not to the left). Review URL: http://codereview.chromium.org/601032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/button_dropdown.cc5
-rw-r--r--views/controls/menu/menu_2.cc20
-rw-r--r--views/controls/menu/menu_2.h11
3 files changed, 26 insertions, 10 deletions
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc
index a2740ca..a851c84 100644
--- a/views/controls/button/button_dropdown.cc
+++ b/views/controls/button/button_dropdown.cc
@@ -148,10 +148,7 @@ void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) {
menu_position.set_x(left_bound);
menu_.reset(new Menu2(model_));
- Menu2::Alignment align = Menu2::ALIGN_TOPLEFT;
- if (UILayoutIsRightToLeft())
- align = Menu2::ALIGN_TOPLEFT;
- menu_->RunMenuAt(menu_position, align);
+ menu_->RunMenuAt(menu_position, Menu2::ALIGN_TOPLEFT);
// Need to explicitly clear mouse handler so that events get sent
// properly after the menu finishes running. If we don't do this, then
diff --git a/views/controls/menu/menu_2.cc b/views/controls/menu/menu_2.cc
index 8c9cddc..4b7829e 100644
--- a/views/controls/menu/menu_2.cc
+++ b/views/controls/menu/menu_2.cc
@@ -1,10 +1,12 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
#include "views/controls/menu/menu_2.h"
+#include "app/l10n_util.h"
#include "base/compiler_specific.h"
+#include "base/logging.h"
#include "views/controls/menu/menu_wrapper.h"
namespace views {
@@ -21,11 +23,25 @@ gfx::NativeMenu Menu2::GetNativeMenu() const {
}
void Menu2::RunMenuAt(const gfx::Point& point, Alignment alignment) {
+ // On RTL systems menu alignment must be reversed.
+ if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
+ switch (alignment) {
+ case ALIGN_TOPRIGHT:
+ alignment = ALIGN_TOPLEFT;
+ break;
+ case ALIGN_TOPLEFT:
+ alignment = ALIGN_TOPRIGHT;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
wrapper_->RunMenuAt(point, alignment);
}
void Menu2::RunContextMenuAt(const gfx::Point& point) {
- wrapper_->RunMenuAt(point, ALIGN_TOPLEFT);
+ RunMenuAt(point, ALIGN_TOPLEFT);
}
void Menu2::CancelMenu() {
diff --git a/views/controls/menu/menu_2.h b/views/controls/menu/menu_2.h
index 1000d86..77ff3d0 100644
--- a/views/controls/menu/menu_2.h
+++ b/views/controls/menu/menu_2.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
-#ifndef CONTROLS_MENU_VIEWS_MENU_2_H_
-#define CONTROLS_MENU_VIEWS_MENU_2_H_
+#ifndef VIEWS_CONTROLS_MENU_MENU_2_H_
+#define VIEWS_CONTROLS_MENU_MENU_2_H_
#include "app/menus/menu_model.h"
#include "base/scoped_ptr.h"
@@ -16,6 +16,7 @@ class Point;
namespace views {
class NativeMenuGtk;
+class View;
// A menu. Populated from a model, and relies on a delegate to execute commands.
//
@@ -34,6 +35,7 @@ class Menu2 {
virtual ~Menu2() {}
// How the menu is aligned relative to the point it is shown at.
+ // The alignment is reversed by menu if text direction is right to left.
enum Alignment {
ALIGN_TOPLEFT,
ALIGN_TOPRIGHT
@@ -75,4 +77,5 @@ class Menu2 {
} // namespace views
-#endif // CONTROLS_MENU_VIEWS_MENU_2_H_
+#endif // VIEWS_CONTROLS_MENU_MENU_2_H_
+