gui.guimousecontrollable - ICE 0.1 API documentation

ICE 0.1 API documentation

# gui.guimousecontrollable

Mouse zooming/panning support for GUI elements.

class GUIMouseControllable: gui.guielement.GUIElement;

  Provides logic for recognizing mouse input used for zooming and panning, using signals for actual implementations of zooming/panning, so user only needs to implement what is needed.

  Mouse wheel is used for zooming, movement with a mouse key pressed (dragging) for panning. Also supports a mouse key used to return to default view when clicked.
  This is not a class to derive other GUI elements from. Rather, this should be used as a child of GUI elements that need mouse zooming/panning logic.
  Also, the name is ugly. Need a better one.

  Signal:
  public mixin Signal!(float) zoom
  Emitted when zooming. Float passed specifies zoom level change (-1 : zoom out 1 level, +1 : zoom in 1 level)

  Signal:
  public mixin Signal!(Vector2f) pan
  Emitted when panning. Vector2f passed specifies relative change of panning.

  Signal:
  public mixin Signal!() resetView
  Emitted user presses a button to return to default view.

  this(const(MouseKey) panKey = cast(MouseKey)0, const(MouseKey) resetViewKey = cast(MouseKey)2);

    Construct a GUIMouseControllable.

    Parameters:

    const(MouseKey) panKey | Mouse key to use for panning when dragged.
    const(MouseKey) resetViewKey | Mouse key to reset view when clicked.

template MouseControl(real zoomMultiplier)

  Basic GUIMouseControllable based mouse control code, good default for simple mouse control.

  Vector2f offset_;

    Current view offset.

  real zoom_;

    Current zoom.

  void init();

    Initialize mouse control.

  void zoom(float relative);

    Zoom by specified number of levels.

    Parameters:

    float relative | Number of zoom levels (doesn't have to be an integer).

  void pan(Vector2f relative);

    Pan view with specified offset.

    Parameters:

    Vector2f relative | Offset to pan the view by.

  void resetView();

    Restore default view.

Copyright © Ferdinand Majerech 2011. | Page generated by AutoDDoc and Ddoc.