OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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_RADIAL_MENU_RADIAL_MENU_VIEWS_H_ |
| 6 #define UI_VIEWS_RADIAL_MENU_RADIAL_MENU_VIEWS_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "ui/gfx/image/image_skia.h" |
| 10 #include "ui/gfx/point.h" |
| 11 #include "ui/views/views_export.h" |
| 12 |
| 13 namespace aura { |
| 14 class Window; |
| 15 } |
| 16 |
| 17 namespace views { |
| 18 |
| 19 class VIEWS_EXPORT RadialMenuItem { |
| 20 public: |
| 21 enum RadialMenuItemType { |
| 22 // This is a button style. As long as the finger / cursor is on top this, |
| 23 // it will get highlighted. When the finger is released / clicked it will |
| 24 // execute. |
| 25 RADIAL_BUTTON = 0, |
| 26 // This is a continuous style: Once activated (over or behind the element |
| 27 // it will follow the cursor / finger and generate new events as further / |
| 28 // closer it goes. |
| 29 RADIAL_SLIDER, |
| 30 // A separator which is not shown. |
| 31 RADIAL_SEPARATOR, |
| 32 // The item is disabled (slightly faded). |
| 33 RADIAL_DISABLED, |
| 34 }; |
| 35 virtual RadialMenuItemType Type() = 0; |
| 36 virtual gfx::ImageSkia* Icon() = 0; |
| 37 virtual bool DeleteIcon() = 0; |
| 38 |
| 39 // Creates a RadialMenuItem item. It gets a |type| which defines how the menu |
| 40 // reacts on user interaction, |icon| which is used to show as a symbol on |
| 41 // the wedge and the flag delete_icon if the icon should get deleted upon |
| 42 // destruction or not. Multiple of these items combined in a vector get |
| 43 // passed to the Radial Menu creation function. |
| 44 static RadialMenuItem* CreateRadialMenuItemInstance( |
| 45 RadialMenuItem::RadialMenuItemType type, |
| 46 gfx::ImageSkia* icon, |
| 47 bool delete_icon); |
| 48 }; |
| 49 |
| 50 // The passed parameter is a list of these items. The first item |
| 51 // is the topmost item and the others are then defined clock wise. |
| 52 // A NULL item indicates an empty placeholder. |
| 53 typedef std::vector<RadialMenuItem*> RadialMenuItems; |
| 54 |
| 55 class VIEWS_EXPORT RadialMenu { |
| 56 public: |
| 57 // Close the menu. After this call has been issued the menu is destroyed. |
| 58 // It will either do that asynchronously (fading out first ) if |
| 59 // |immediate_close| is true, otherwise it will be destroyed immediately. |
| 60 virtual void CloseAndDelete(bool immediate_close) = 0; |
| 61 |
| 62 // Get the window of the lowest segment we use. |
| 63 virtual aura::Window* GetWindow() = 0; |
| 64 |
| 65 // Change the area sice behind a segment |
| 66 virtual void set_pointer_activation_area_extension(int expansion) = 0; |
| 67 |
| 68 // Check if a menu item was hit by the user. If something was hit, |
| 69 // |item| will be the indexed element and |count| will be the distance |
| 70 // of the pointer to the item in segment width. This can be used to e.g. |
| 71 // sweep through several pages. If 3 would get returned the user would be |
| 72 // 3 wedge distances in. |
| 73 // This method will also update the menu accordingly to show user action. |
| 74 // If false get returned, neither item nor count will get changed. |
| 75 virtual bool HitMenuItemTest( |
| 76 const gfx::Point& location, |
| 77 int* item, |
| 78 int* count) = 0; |
| 79 |
| 80 // Create a radial menu. |
| 81 // The origin of the menu is the |location|. The outer circle is defined by |
| 82 // the |outer_radius| and |inner_radius| whereas the |inner_radius| might |
| 83 // become 0. The |rotation| (in degrees) parameter allows the user to rotate |
| 84 // the menu on the screen. |
| 85 // The |items| parameter is a list of radial menu items. The elements of the |
| 86 // list will be owned after this call by this menu. Note that in order to |
| 87 // delete the passed images, the |delete_icon| flag should get provided upon |
| 88 // menu item creation. |
| 89 // Once the menu was created, the function |HitMenuItemTest| should get |
| 90 // called upon user mouse / touch move. |
| 91 // The default of |pointer_activation_area_extension| is one which means that |
| 92 // only a pointer over the button will activate it. When a number bigger then |
| 93 // one is specified, the "hot area" for the segment is this many times wider |
| 94 // then the button. |
| 95 // With |clip_to_screen| set to false the radial menu can grow out of the |
| 96 // screen - otherwise not. |
| 97 // Note: The menu belongs to the caller - until he calls "CloseAndDelete" |
| 98 // which will delete the menu. |
| 99 static RadialMenu* CreateRadialMenuInstance( |
| 100 const gfx::Point& location, |
| 101 int outer_radius, |
| 102 int inner_radius, |
| 103 double rotation, |
| 104 const RadialMenuItems items, |
| 105 int pointer_activation_area_extension, |
| 106 bool clip_to_screen); |
| 107 }; |
| 108 |
| 109 } // namespace views |
| 110 #endif // UI_VIEWS_RADIAL_MENU_RADIAL_MENU_VIEWS_H_ |
| 111 |
OLD | NEW |