| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_VIEWS_TOUCHUI_TOUCH_EDITING_MENU_H_ | |
| 6 #define UI_VIEWS_TOUCHUI_TOUCH_EDITING_MENU_H_ | |
| 7 | |
| 8 #include "ui/gfx/point.h" | |
| 9 #include "ui/views/bubble/bubble_delegate.h" | |
| 10 #include "ui/views/controls/button/button.h" | |
| 11 #include "ui/views/views_export.h" | |
| 12 | |
| 13 namespace gfx { | |
| 14 class Canvas; | |
| 15 } | |
| 16 | |
| 17 namespace views { | |
| 18 class TouchEditingMenuView; | |
| 19 class Widget; | |
| 20 | |
| 21 class VIEWS_EXPORT TouchEditingMenuController { | |
| 22 public: | |
| 23 // Checks if the specified menu command is supported. | |
| 24 virtual bool IsCommandIdEnabled(int command_id) const = 0; | |
| 25 | |
| 26 // Send a context menu command to the controller. | |
| 27 virtual void ExecuteCommand(int command_id, int event_flags) = 0; | |
| 28 | |
| 29 // Tell the controller that user has selected the context menu button. | |
| 30 virtual void OpenContextMenu() = 0; | |
| 31 | |
| 32 // Called when the menu is closed. | |
| 33 virtual void OnMenuClosed(TouchEditingMenuView* menu) = 0; | |
| 34 | |
| 35 protected: | |
| 36 virtual ~TouchEditingMenuController() {} | |
| 37 }; | |
| 38 | |
| 39 // A View that displays the touch context menu. | |
| 40 class VIEWS_EXPORT TouchEditingMenuView : public BubbleDelegateView, | |
| 41 public ButtonListener { | |
| 42 public: | |
| 43 virtual ~TouchEditingMenuView(); | |
| 44 | |
| 45 // If there are no actions available for the menu, returns NULL. Otherwise, | |
| 46 // returns a new instance of TouchEditingMenuView. | |
| 47 static TouchEditingMenuView* Create(TouchEditingMenuController* controller, | |
| 48 const gfx::Rect& anchor_rect, | |
| 49 const gfx::Size& handle_image_size, | |
| 50 gfx::NativeView context); | |
| 51 | |
| 52 void Close(); | |
| 53 | |
| 54 private: | |
| 55 TouchEditingMenuView(TouchEditingMenuController* controller, | |
| 56 const gfx::Rect& anchor_rect, | |
| 57 const gfx::Size& handle_image_size, | |
| 58 gfx::NativeView context); | |
| 59 | |
| 60 // views::WidgetDelegate overrides: | |
| 61 virtual void WindowClosing() override; | |
| 62 | |
| 63 // Overridden from ButtonListener. | |
| 64 virtual void ButtonPressed(Button* sender, const ui::Event& event) override; | |
| 65 | |
| 66 // Overridden from BubbleDelegateView. | |
| 67 virtual void OnPaint(gfx::Canvas* canvas) override; | |
| 68 | |
| 69 // Queries the |controller_| for what elements to show in the menu and sizes | |
| 70 // the menu appropriately. | |
| 71 void CreateButtons(); | |
| 72 | |
| 73 // Helper method to create a single button. | |
| 74 Button* CreateButton(const base::string16& title, int tag); | |
| 75 | |
| 76 TouchEditingMenuController* controller_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(TouchEditingMenuView); | |
| 79 }; | |
| 80 | |
| 81 } // namespace views | |
| 82 | |
| 83 #endif // UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ | |
| OLD | NEW |