| Index: ui/views/radial_menu/radial_menu_views.h
|
| diff --git a/ui/views/radial_menu/radial_menu_views.h b/ui/views/radial_menu/radial_menu_views.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..87b5457a85b13b94807bae42b8e76ab85811ec85
|
| --- /dev/null
|
| +++ b/ui/views/radial_menu/radial_menu_views.h
|
| @@ -0,0 +1,111 @@
|
| +// Copyright (c) 2012 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_VIEWS_RADIAL_MENU_RADIAL_MENU_VIEWS_H_
|
| +#define UI_VIEWS_RADIAL_MENU_RADIAL_MENU_VIEWS_H_
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "ui/gfx/image/image_skia.h"
|
| +#include "ui/gfx/point.h"
|
| +#include "ui/views/views_export.h"
|
| +
|
| +namespace aura {
|
| + class Window;
|
| +}
|
| +
|
| +namespace views {
|
| +
|
| +class VIEWS_EXPORT RadialMenuItem {
|
| + public:
|
| + enum RadialMenuItemType {
|
| + // This is a button style. As long as the finger / cursor is on top this,
|
| + // it will get highlighted. When the finger is released / clicked it will
|
| + // execute.
|
| + RADIAL_BUTTON = 0,
|
| + // This is a continuous style: Once activated (over or behind the element
|
| + // it will follow the cursor / finger and generate new events as further /
|
| + // closer it goes.
|
| + RADIAL_SLIDER,
|
| + // A separator which is not shown.
|
| + RADIAL_SEPARATOR,
|
| + // The item is disabled (slightly faded).
|
| + RADIAL_DISABLED,
|
| + };
|
| + virtual RadialMenuItemType Type() = 0;
|
| + virtual gfx::ImageSkia* Icon() = 0;
|
| + virtual bool DeleteIcon() = 0;
|
| +
|
| + // Creates a RadialMenuItem item. It gets a |type| which defines how the menu
|
| + // reacts on user interaction, |icon| which is used to show as a symbol on
|
| + // the wedge and the flag delete_icon if the icon should get deleted upon
|
| + // destruction or not. Multiple of these items combined in a vector get
|
| + // passed to the Radial Menu creation function.
|
| + static RadialMenuItem* CreateRadialMenuItemInstance(
|
| + RadialMenuItem::RadialMenuItemType type,
|
| + gfx::ImageSkia* icon,
|
| + bool delete_icon);
|
| +};
|
| +
|
| +// The passed parameter is a list of these items. The first item
|
| +// is the topmost item and the others are then defined clock wise.
|
| +// A NULL item indicates an empty placeholder.
|
| +typedef std::vector<RadialMenuItem*> RadialMenuItems;
|
| +
|
| +class VIEWS_EXPORT RadialMenu {
|
| + public:
|
| + // Close the menu. After this call has been issued the menu is destroyed.
|
| + // It will either do that asynchronously (fading out first ) if
|
| + // |immediate_close| is true, otherwise it will be destroyed immediately.
|
| + virtual void CloseAndDelete(bool immediate_close) = 0;
|
| +
|
| + // Get the window of the lowest segment we use.
|
| + virtual aura::Window* GetWindow() = 0;
|
| +
|
| + // Change the area sice behind a segment
|
| + virtual void set_pointer_activation_area_extension(int expansion) = 0;
|
| +
|
| + // Check if a menu item was hit by the user. If something was hit,
|
| + // |item| will be the indexed element and |count| will be the distance
|
| + // of the pointer to the item in segment width. This can be used to e.g.
|
| + // sweep through several pages. If 3 would get returned the user would be
|
| + // 3 wedge distances in.
|
| + // This method will also update the menu accordingly to show user action.
|
| + // If false get returned, neither item nor count will get changed.
|
| + virtual bool HitMenuItemTest(
|
| + const gfx::Point& location,
|
| + int* item,
|
| + int* count) = 0;
|
| +
|
| + // Create a radial menu.
|
| + // The origin of the menu is the |location|. The outer circle is defined by
|
| + // the |outer_radius| and |inner_radius| whereas the |inner_radius| might
|
| + // become 0. The |rotation| (in degrees) parameter allows the user to rotate
|
| + // the menu on the screen.
|
| + // The |items| parameter is a list of radial menu items. The elements of the
|
| + // list will be owned after this call by this menu. Note that in order to
|
| + // delete the passed images, the |delete_icon| flag should get provided upon
|
| + // menu item creation.
|
| + // Once the menu was created, the function |HitMenuItemTest| should get
|
| + // called upon user mouse / touch move.
|
| + // The default of |pointer_activation_area_extension| is one which means that
|
| + // only a pointer over the button will activate it. When a number bigger then
|
| + // one is specified, the "hot area" for the segment is this many times wider
|
| + // then the button.
|
| + // With |clip_to_screen| set to false the radial menu can grow out of the
|
| + // screen - otherwise not.
|
| + // Note: The menu belongs to the caller - until he calls "CloseAndDelete"
|
| + // which will delete the menu.
|
| + static RadialMenu* CreateRadialMenuInstance(
|
| + const gfx::Point& location,
|
| + int outer_radius,
|
| + int inner_radius,
|
| + double rotation,
|
| + const RadialMenuItems items,
|
| + int pointer_activation_area_extension,
|
| + bool clip_to_screen);
|
| +};
|
| +
|
| +} // namespace views
|
| +#endif // UI_VIEWS_RADIAL_MENU_RADIAL_MENU_VIEWS_H_
|
| +
|
|
|