Graphics.UI.GLUT.Menu

GLUT-2.7.0.3: A binding for the OpenGL Utility Toolkit

Copyright | (c) Sven Panne 2002-2013
License | BSD3
Maintainer | Sven Panne <svenpanne@gmail.com>
Stability | stable
Portability | portable
Safe Haskell | None
Language | Haskell2010

Graphics.UI.GLUT.Menu

Description

GLUT supports simple cascading pop-up menus. They are designed to let a user select various modes within a program. The functionality is simple and minimalistic and is meant to be that way. Do not mistake GLUT's pop-up menu facility with an attempt to create a full-featured user interface.

Synopsis

- data Menu
  - = Menu [MenuItem]
  - | MenuWithFont BitmapFont [MenuItem]
- data MenuItem
  - = MenuEntry String MenuCallback
  - | SubMenu String Menu
- type MenuCallback = IO ()
- attachMenu :: MonadIO m => MouseButton -> Menu -> m ()
- numMenuItems :: GettableStateVar Int

# Documentation

data Menu

A menu is simply a list of menu items, possibly with an associated font.

Constructors

Menu [MenuItem] |
MenuWithFont BitmapFont [MenuItem] |

data MenuItem

A single item within a menu can either be a plain menu entry or a sub-menu entry, allowing for arbitrarily deep nested menus.

Constructors

MenuEntry String MenuCallback | A plain menu entry with an associated callback, which is triggered when the user selects the entry
SubMenu String Menu | A sub-menu, which is cascaded when the user selects the entry, allowing sub-menu entries to be selected

type MenuCallback = IO ()

attachMenu :: MonadIO m => MouseButton -> Menu -> m ()

Create a new pop-up menu for the current window, attaching it to the given mouse button. A previously attached menu (if any), is detached before and won't receive callbacks anymore.

It is illegal to call `attachMenu` while any (sub-)menu is in use, i.e. popped up.

X Implementation Notes: If available, GLUT for X will take advantage of overlay planes for implementing pop-up menus. The use of overlay planes can eliminate display callbacks when pop-up menus are deactivated. The `SERVER_OVERLAY_VISUALS` convention is used to determine if overlay visuals are available.

numMenuItems :: GettableStateVar Int

Contains the number of menu items in the current menu.