forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To use the touch selection quick menu in the upcoming unified touch selection, a new interface is added to ui/touch_selection with an implementation for Views. The implementation mostly copied code from the old implementation. COLLABORATOR=mfomitchev BUG=399721 Review URL: https://codereview.chromium.org/1019353003 Cr-Commit-Position: refs/heads/master@{#331924}
- Loading branch information
mohsen
authored and
Commit bot
committed
May 29, 2015
1 parent
7a6acf6
commit 1d0063d
Showing
20 changed files
with
624 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2015 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 "ui/touch_selection/touch_selection_menu_runner.h" | ||
|
||
namespace ui { | ||
namespace { | ||
|
||
TouchSelectionMenuRunner* g_touch_selection_menu_runner = nullptr; | ||
|
||
} // namespace | ||
|
||
TouchSelectionMenuRunner::~TouchSelectionMenuRunner() { | ||
g_touch_selection_menu_runner = nullptr; | ||
} | ||
|
||
TouchSelectionMenuRunner* TouchSelectionMenuRunner::GetInstance() { | ||
return g_touch_selection_menu_runner; | ||
} | ||
|
||
TouchSelectionMenuRunner::TouchSelectionMenuRunner() { | ||
// TODO(mohsen): Ideally we should DCHECK that |g_touch_selection_menu_runner| | ||
// is not set here, in order to make sure we don't create multiple menu | ||
// runners accidentally. Currently, this is not possible because we can have | ||
// multiple ViewsDelegate's at the same time which should not happen. See | ||
// crbug.com/492991. | ||
g_touch_selection_menu_runner = this; | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2015 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 UI_TOUCH_SELECTION_TOUCH_SELECTION_MENU_RUNNER_H_ | ||
#define UI_TOUCH_SELECTION_TOUCH_SELECTION_MENU_RUNNER_H_ | ||
|
||
#include "base/macros.h" | ||
#include "ui/touch_selection/ui_touch_selection_export.h" | ||
|
||
namespace aura { | ||
class Window; | ||
} | ||
|
||
namespace gfx { | ||
class Rect; | ||
class Size; | ||
} | ||
|
||
namespace ui { | ||
|
||
// Client interface for TouchSelectionMenuRunner. | ||
class UI_TOUCH_SELECTION_EXPORT TouchSelectionMenuClient { | ||
public: | ||
virtual ~TouchSelectionMenuClient() {} | ||
|
||
virtual bool IsCommandIdEnabled(int command_id) const = 0; | ||
virtual void ExecuteCommand(int command_id, int event_flags) = 0; | ||
|
||
// Called when the quick menu needs to run a context menu. Depending on the | ||
// implementation, this may run the context menu synchronously, or request the | ||
// menu to show up in which case the menu will run asynchronously at a later | ||
// time. | ||
virtual void RunContextMenu() = 0; | ||
}; | ||
|
||
// An interface for the singleton object responsible for running touch selection | ||
// quick menu. | ||
class UI_TOUCH_SELECTION_EXPORT TouchSelectionMenuRunner { | ||
public: | ||
virtual ~TouchSelectionMenuRunner(); | ||
|
||
static TouchSelectionMenuRunner* GetInstance(); | ||
|
||
// Creates and displays the quick menu, if there is any command available. | ||
// |anchor_rect| is in screen coordinates. | ||
virtual void OpenMenu(TouchSelectionMenuClient* client, | ||
const gfx::Rect& anchor_rect, | ||
const gfx::Size& handle_image_size, | ||
aura::Window* context) = 0; | ||
|
||
virtual void CloseMenu() = 0; | ||
|
||
virtual bool IsRunning() const = 0; | ||
|
||
protected: | ||
TouchSelectionMenuRunner(); | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(TouchSelectionMenuRunner); | ||
}; | ||
|
||
} // namespace ui | ||
|
||
#endif // UI_TOUCH_SELECTION_TOUCH_SELECTION_MENU_RUNNER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.