views: Remove PopupAtPoint
This commit is contained in:
parent
5f195a789a
commit
0e3a3d0748
2 changed files with 11 additions and 8 deletions
|
@ -17,7 +17,7 @@ MenuViews::MenuViews() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuViews::Popup(Window* window) {
|
void MenuViews::Popup(Window* window) {
|
||||||
PopupAtPoint(window, gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
|
PopupAt(window, -1, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||||
|
@ -31,18 +31,23 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
|
||||||
if (!view)
|
if (!view)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gfx::Point origin = view->GetViewBounds().origin();
|
// (-1, -1) means showing on mouse location.
|
||||||
PopupAtPoint(window, gfx::Point(origin.x() + x, origin.y() + y));
|
gfx::Point location;
|
||||||
}
|
if (x == -1 || y == -1) {
|
||||||
|
location = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
||||||
|
} else {
|
||||||
|
gfx::Point origin = view->GetViewBounds().origin();
|
||||||
|
location = gfx::Point(origin.x() + x, origin.y() + y);
|
||||||
|
}
|
||||||
|
|
||||||
void MenuViews::PopupAtPoint(Window* window, const gfx::Point& point) {
|
// Show the menu.
|
||||||
views::MenuRunner menu_runner(
|
views::MenuRunner menu_runner(
|
||||||
model(),
|
model(),
|
||||||
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
||||||
ignore_result(menu_runner.RunMenuAt(
|
ignore_result(menu_runner.RunMenuAt(
|
||||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
static_cast<NativeWindowViews*>(window->window())->widget(),
|
||||||
NULL,
|
NULL,
|
||||||
gfx::Rect(point, gfx::Size()),
|
gfx::Rect(location, gfx::Size()),
|
||||||
views::MENU_ANCHOR_TOPLEFT,
|
views::MENU_ANCHOR_TOPLEFT,
|
||||||
ui::MENU_SOURCE_MOUSE));
|
ui::MENU_SOURCE_MOUSE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ class MenuViews : public Menu {
|
||||||
void PopupAt(Window* window, int x, int y, int positioning_item = 0) override;
|
void PopupAt(Window* window, int x, int y, int positioning_item = 0) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PopupAtPoint(Window* window, const gfx::Point& point);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue