Menu
class represents a displayable, interactive menu. It is abstract, so it can never be instantiated on its own. Instead, users should call the constructor of one of its subclasses, such as Toolbar
or Dock
. The main purpose for the Menu
class is to hold a large amount of generic structure and logic for managing and displaying a menu-type object within Processing. This includes: dealing with mouse events, keeping track of which menu item is currently hovered, selected, and open, and creating and drawing to an off-screen buffer when necessary (to allow us to use Java2D functions within a P3D or OpenGL PApplet).
The Menu
class is the base class for all other menu objects within this package. It inherits from the MenuItem
class, because a Menu should act like a well-behaved MenuItem as well (this way, we can cascade menus within other menus). It also helped keep down the amount of code repetition.
The side effect of this completely inherited organization is, of course, some complexity in thinking about the recursive method calls. You need to keep in mind that when the Menu
class calls super.someMethod()
, it's calling the method defined in the MenuItem
class.
There is also a slight issue with the fact that a Menu
should not be strictly considered a MenuItem
, because more often than not, the Menu
object itself does not "act" like a menu. Rather, its sub-items are what is shown to the screen and what interacts with the user. See the classes that extend the Menu
class for examples of how to deal with this code organization.
Important information for developers: if you plan to create a new type of menu using the Menu
class as a base class, you should keep in mind the following:
Dock
, Toolbar
, and VerticalMenu
. Examining how these classes interact with the Menu
structure will be very helpful when designing a novel Menu type.setOptions()
within your new class as a place to define your new menu's behavioral and display options. Particularly important are useCameraCoordinates
and usesJava2D
. See each option's javadoc for more information.
@author Greg
@see org.andrewberman.ui.menu.MenuItem
@see org.andrewberman.ui.menu.Dock
@see org.andrewberman.ui.menu.Toolbar
|
|
|
|
|
|