gui.guielement - ICE 0.1 API documentation

ICE 0.1 API documentation

# gui.guielement

Base class for all widgets.

class GUIElement;

  Base class for all GUI elements. Can be used directly to draw empty elements.

  protected GUIElement parent_;

    Parent element of this element.

  protected GUIElement[] children_;

    Children elements of this element.

  protected Color borderColor_;

    Color of the element's border.

  protected Recti bounds_;

    Bounds of this element in screen space.

  protected bool visible_;

    Is this element visible?

  protected bool drawBorder_;

    Draw border of this element?

  protected bool aligned_;

    Are the contents of this element aligned based on its current properties?

  protected string xString_;

    Math expression used to calculate X position of the element.

  protected string yString_;

    Math expression used to calculate Y position of the element.

  protected string widthString_;

    Math expression used to calculate width of the element.

  protected string heightString_;

    Math expression used to calculate height of the element.

  final void die();

    Destroy this element and all its children.

  final const @property Vector2i positionGlobal();

    Get position in screen space.

  final const @property Vector2i positionLocal();

    Get position relative to parent element.

  final const @property Vector2u size();

    Get size of this element in screen space.

  final const @property Recti boundsGlobal();

    Get bounding rectangle of this GUI element in screen space.

  final void addChild(GUIElement child);

    Add a child element.

    A single child can't be added twice to the same element or to two different GUI elements at the same time.

    Parameters:

    GUIElement child | Child to add.

  final void removeChild(GUIElement child);

    Remove a child element. The specified element must be a child of this element.

  final const @property bool visible();

    Is this element visible?

  final @property void hide();

    Hide this element and its children.

  final @property void show();

    Make this element and its children visible.

  protected this(const(GUIElementParams) params);

    Construct a GUIElement with specified parameters.

    Parameters:

    const(GUIElementParams) params | Parameters for construction of the GUIElement.

  protected void draw(VideoDriver driver);

    Draw this GUIElement and its children, if visible.

    Parameters:

    VideoDriver driver | Driver to draw with.

  protected void update();

    Update this GUIElement and its children.

  protected void key(KeyState state, Key key, dchar unicode);

    Process keyboard input.

    Parameters:

    KeyState state | State of the key.
    Key key | Keyboard key.
    dchar unicode | Unicode value of the key.

  protected void mouseKey(KeyState state, MouseKey key, Vector2u position);

    Process mouse key input.

    Parameters:

    KeyState state | State of the key.
    MouseKey key | Mouse key.
    Vector2u position | Position of the mouse.

  protected void mouseMove(Vector2u position, Vector2i relative);

    Process mouse movement.

    Parameters:

    Vector2u position | Position of the mouse in screen coordinates.
    Vector2i relative | Relative movement of the mouse.

  protected void realign(VideoDriver driver);

    Realign contents of this element according to its dimensions.

class GUIRoot;

  GUI root container. Contains drawing and input handling methods.

  this(Platform platform);

    Construct the GUI root.

    Size of the root GUI element will be identical to window size.

    Parameters:

    Platform platform | Platform to use for input.

  void draw(VideoDriver driver);

    Draw the GUI.

    Parameters:

    VideoDriver driver | VideoDriver to draw with.

  @property GUIElement root();

    Get the root element of the GUI.

  void update();

    Update the GUI.

  void addChild(GUIElement child);

    Add a child element.

  void removeChild(GUIElement child);

    Remove a child element.

  void realign(VideoDriver driver);

    Realign the GUI.

class GUIElementFactory: gui.guielement.GUIElementFactoryBase!(GUIElement).GUIElementFactoryBase;

  Factory used for GUI element construction.

  See Also:
  GUIElementFactoryBase
class GUIElementFactoryBase(T);

  Template base class for all GUI element factories, template type T specifies type of GUI element constructed by the factory.

  Position and size of GUI elements are specified with strings containing simple math expressions which are evaluated to determine the actual coordinates.
  Supported operators are +,-,*,/ as well as parentheses.
  Furthermore, there are builtin macros representing window and parent coordinates. These are:
  w_right : Window right end (left end is always 0, so this is window width)
  w_bottom : Window bottom end (top end is always 0, so this is window height)
  p_left : Parent left end
  p_right : Parent right end
  p_top : Parent top end
  p_bottom : Parent bottom end

  Parameters:

  x | X position math expression. Default; "p_left"
  y | Y position math expression. Default; "p_top"
  width | Width math expression. Default; "64"
  height | Height math expression. Default; "64"
  drawBorder | Draw border of the element? Default; true

  Examples:
  Example of usage of GUIElementFactory, which is used to construct instances of GUIElement, but the principle is the same for every GUI element class factory.

       //Assuming other is some GUI element we already have or root GUI element

       //construction of a GUI element:

       GUIElement element;

       with(new GUIElementFactory)
       {
           x = "p_left + 96";
           y = "p_top + 16";
           width = "p_right - 192";
           height = "p_bottom - 32";
           element = produce();
           other.addChild(element);
       }

       //destruction:
       other.removeChild(element);
       element.die();
       //(alternatively, we could just destroy other, which would also destroy element)

  const GUIElementParams guiElementParams();

    Return a struct containing factory parameters packaged for GUIElement ctor.

  void margin(in int top, in int right, in int bottom, in int left);

    Set dimensions of the element relative to the parent.

    Can be used instead of manually specifying x, y, width and height. Works similarly to HTML margin, but only takes the parent to account, NOT the siblings.

    Parameters:

    int top | Width of top y margin relative to parent top y.
    int right | Width of right x margin relative to parent right y.
    int bottom | Width of bottom y margin relative to parent bottom y.
    int left | Width of left y margin relative to parent left y.

  T produce();

    Return a new instance of the class produced by the factory with parameters of the factory.

struct GUIElementParams;

  GUI element constructor parameters

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