diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 17:28:57 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-07 17:28:57 +0000 |
commit | 2fb382fd01716825e026c7833b6d170b5f412a08 (patch) | |
tree | 6d2d210583518861224a1ce40c4050e10b2675d1 /chrome/browser/chromeos/views | |
parent | 632363c0049b3c1d54b12f5b8e2a2b16de5a97b3 (diff) | |
download | chromium_src-2fb382fd01716825e026c7833b6d170b5f412a08.zip chromium_src-2fb382fd01716825e026c7833b6d170b5f412a08.tar.gz chromium_src-2fb382fd01716825e026c7833b6d170b5f412a08.tar.bz2 |
Let menu scroll when the menu content exceeds screen height.
Menu locator limits the size of window, and scrolling is handled in DOMUI.
This does not implement mouse wheel yet as the current implementation doesn't support it. I also haven't enable this yet for dropdown as I need to figure out how this should work for OOBE. I'll address it in separate CL.
Added command line parameter to specify DOMUI html page for testing.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3608006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/views')
-rw-r--r-- | chrome/browser/chromeos/views/menu_locator.cc | 36 | ||||
-rw-r--r-- | chrome/browser/chromeos/views/native_menu_domui.cc | 4 |
2 files changed, 21 insertions, 19 deletions
diff --git a/chrome/browser/chromeos/views/menu_locator.cc b/chrome/browser/chromeos/views/menu_locator.cc index bf995e7..f92a250 100644 --- a/chrome/browser/chromeos/views/menu_locator.cc +++ b/chrome/browser/chromeos/views/menu_locator.cc @@ -16,7 +16,7 @@ namespace { using views::Widget; // Menu's corner radious. -const int kMenuCornerRadius = 4; +const int kMenuCornerRadius = 3; const int kSubmenuOverlapPx = 1; gfx::Rect GetBoundsOf(const views::Widget* widget) { @@ -61,12 +61,10 @@ class DropDownMenuLocator : public chromeos::MenuLocator { gfx::Rect screen_rect = GetScreenRectAt(origin_.x(), origin_.y()); int x = origin_.x() - size.width(); int y = origin_.y(); - if (x + size.width() > screen_rect.right()) { + if (x + size.width() > screen_rect.right()) x = screen_rect.right() - size.width(); - } - if (y + size.height() > screen_rect.bottom()) { + if (y + size.height() > screen_rect.bottom()) y = screen_rect.bottom() - size.height(); - } return gfx::Rect(x, y, size.width(), size.height()); } @@ -115,15 +113,17 @@ class ContextMenuLocator : public chromeos::MenuLocator { gfx::Rect ComputeBounds(const gfx::Size& size) { gfx::Rect screen_rect = GetScreenRectAt(origin_.x(), origin_.y()); + int height = size.height(); + if (height > screen_rect.height()) + height = screen_rect.height(); + int x = origin_.x(); int y = origin_.y(); - if (x + size.width() > screen_rect.right()) { + if (x + size.width() > screen_rect.right()) x = screen_rect.right() - size.width(); - } - if (y + size.height() > screen_rect.bottom()) { - y = screen_rect.bottom() - size.height(); - } - return gfx::Rect(x, y, size.width(), size.height()); + if (y + height > screen_rect.bottom()) + y = screen_rect.bottom() - height; + return gfx::Rect(x, y, size.width(), height); } virtual const SkScalar* GetCorners() const { @@ -189,20 +189,22 @@ class SubMenuLocator : public chromeos::MenuLocator { gfx::Rect ComputeBounds(const gfx::Size& size) { gfx::Rect screen_rect = GetScreenRectAt(parent_rect_.x(), root_y_); + int height = size.height(); + if (height > screen_rect.height()) + height = screen_rect.height(); + SubmenuDirection direction = parent_direction_; - if (direction == DEFAULT) { + if (direction == DEFAULT) direction = RIGHT; // TOOD(oshima): support RTL - } // Adjust Y to fit the screen. int y = root_y_; - if (root_y_ + size.height() > screen_rect.bottom()) { - y = screen_rect.bottom() - size.height(); - } + if (root_y_ + height > screen_rect.bottom()) + y = screen_rect.bottom() - height; // Decide the attachment. int x = direction == RIGHT ? ComputeXToRight(screen_rect, size) : ComputeXToLeft(screen_rect, size); - return gfx::Rect(x, y, size.width(), size.height()); + return gfx::Rect(x, y, size.width(), height); } int ComputeXToRight(const gfx::Rect& screen_rect, const gfx::Size& size) { diff --git a/chrome/browser/chromeos/views/native_menu_domui.cc b/chrome/browser/chromeos/views/native_menu_domui.cc index 42ca581..c5b1f63 100644 --- a/chrome/browser/chromeos/views/native_menu_domui.cc +++ b/chrome/browser/chromeos/views/native_menu_domui.cc @@ -187,8 +187,8 @@ void NativeMenuDOMUI::Rebuild() { } items->Set(index, item); } - model.SetBoolean("has_icon", has_icon); - model.SetBoolean("is_root", menu_widget_->is_root()); + model.SetBoolean("hasIcon", has_icon); + model.SetBoolean("isRoot", menu_widget_->is_root()); std::string json_model; base::JSONWriter::Write(&model, false, &json_model); |