diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 15:36:43 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 15:36:43 +0000 |
commit | 9bbbd960f5aa7cd1399f52ab316a954a9313bd92 (patch) | |
tree | 65be421f6c06e5233b1d11794de1d74d1ff06da1 /views/controls | |
parent | 339ae77c44737793c4c0d19cfc4a3895df5302d4 (diff) | |
download | chromium_src-9bbbd960f5aa7cd1399f52ab316a954a9313bd92.zip chromium_src-9bbbd960f5aa7cd1399f52ab316a954a9313bd92.tar.gz chromium_src-9bbbd960f5aa7cd1399f52ab316a954a9313bd92.tar.bz2 |
Gets views_unittests to work when aura is defined, and adds coverage
for recent painting bug. To get views_unittests to compile I had to
convert BaseScrollBar to use MenuItemView (was still using native,
which doesn't exist on windows).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8028027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102935 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/scrollbar/base_scroll_bar.cc | 16 | ||||
-rw-r--r-- | views/controls/scrollbar/base_scroll_bar.h | 9 |
2 files changed, 18 insertions, 7 deletions
diff --git a/views/controls/scrollbar/base_scroll_bar.cc b/views/controls/scrollbar/base_scroll_bar.cc index a054ceb..f7e85fd 100644 --- a/views/controls/scrollbar/base_scroll_bar.cc +++ b/views/controls/scrollbar/base_scroll_bar.cc @@ -17,7 +17,8 @@ #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/canvas.h" -#include "views/controls/menu/menu.h" +#include "views/controls/menu/menu_item_view.h" +#include "views/controls/menu/menu_runner.h" #include "views/controls/scrollbar/base_scroll_bar_thumb.h" #include "views/controls/scroll_view.h" #include "views/widget/widget.h" @@ -79,6 +80,9 @@ void BaseScrollBar::ScrollByAmount(ScrollAmount amount) { ScrollContentsToOffset(); } +BaseScrollBar::~BaseScrollBar() { +} + void BaseScrollBar::ScrollToThumbPosition(int thumb_position, bool scroll_to_middle) { contents_scroll_offset_ = @@ -205,8 +209,9 @@ void BaseScrollBar::ShowContextMenuForView(View* source, View::ConvertPointFromWidget(this, &temp_pt); context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); - scoped_ptr<Menu> menu( - Menu::Create(this, Menu::TOPLEFT, GetWidget()->GetNativeView())); + views::MenuItemView* menu = new views::MenuItemView(this); + // MenuRunner takes ownership of |menu|. + menu_runner_.reset(new MenuRunner(menu)); menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); menu->AppendSeparator(); menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); @@ -217,7 +222,10 @@ void BaseScrollBar::ShowContextMenuForView(View* source, menu->AppendSeparator(); menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollPrev); menu->AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollNext); - menu->RunMenuAt(p.x(), p.y()); + if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(p, gfx::Size(0, 0)), + MenuItemView::TOPLEFT, MenuRunner::HAS_MNEMONICS) == + MenuRunner::MENU_DELETED) + return; } /////////////////////////////////////////////////////////////////////////////// diff --git a/views/controls/scrollbar/base_scroll_bar.h b/views/controls/scrollbar/base_scroll_bar.h index 7dc037b..cba9f73 100644 --- a/views/controls/scrollbar/base_scroll_bar.h +++ b/views/controls/scrollbar/base_scroll_bar.h @@ -8,13 +8,14 @@ #include "views/context_menu_controller.h" #include "views/controls/button/image_button.h" -#include "views/controls/menu/menu.h" +#include "views/controls/menu/menu_delegate.h" #include "views/controls/scrollbar/scroll_bar.h" #include "views/repeat_controller.h" namespace views { class BaseScrollBarThumb; +class MenuRunner; /////////////////////////////////////////////////////////////////////////////// // @@ -23,10 +24,10 @@ class BaseScrollBarThumb; /////////////////////////////////////////////////////////////////////////////// class VIEWS_EXPORT BaseScrollBar : public ScrollBar, public ContextMenuController, - public Menu::Delegate { + public MenuDelegate { public: BaseScrollBar(bool horizontal, BaseScrollBarThumb* thumb); - virtual ~BaseScrollBar() { } + virtual ~BaseScrollBar(); // Get the bounds of the "track" area that the thumb is free to slide within. virtual gfx::Rect GetTrackBounds() const = 0; @@ -148,6 +149,8 @@ class VIEWS_EXPORT BaseScrollBar : public ScrollBar, // was invoked. int context_menu_mouse_position_; + scoped_ptr<MenuRunner> menu_runner_; + DISALLOW_COPY_AND_ASSIGN(BaseScrollBar); }; |