Class TUIContainer

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TUIContainer = class abstract(TComponent)

Description

Abstract user interface container. Connects OpenGL context management code with Castle Game Engine controls (TUIControl, that is the basis for all our 2D and 3D rendering). When you use TCastleWindowCustom (a window) or TCastleControlCustom (Lazarus component), they provide you a non-abstact implementation of TUIContainer.

Basically, this class manages a Controls list.

We pass our inputs (mouse / key events) to these controls. Input goes to the top-most (that is, first on the Controls list) control under the current mouse position (we check control's PositionInside method for this). As long as the event is not handled, we look for next controls under the mouse position.

We also call other methods on every control, like TUIControl.Update, TUIControl.Render.

Hierarchy

  • TComponent
  • TUIContainer

Overview

Methods

Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Protected procedure SetCursor(const Value: TMouseCursor); virtual; abstract;
Protected function GetMousePosition: TVector2Single; virtual; abstract;
Protected procedure SetMousePosition(const Value: TVector2Single); virtual; abstract;
Protected function GetTouches(const Index: Integer): TTouch; virtual; abstract;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure EventOpen(const OpenWindowsCount: Cardinal);
Public procedure EventClose(const OpenWindowsCount: Cardinal);
Public function EventPress(const Event: TInputPressRelease): boolean;
Public function EventRelease(const Event: TInputPressRelease): boolean;
Public procedure EventUpdate;
Public procedure EventMotion(const Event: TInputMotion);
Public function AllowSuspendForInput: boolean;
Public procedure EventBeforeRender;
Public procedure EventRender; virtual; abstract;
Public procedure EventResize;
Public function Controls: TUIControlList;
Public procedure Invalidate; virtual; abstract;
Public function GLInitialized: boolean; virtual; abstract;
Public function Width: Integer; virtual; abstract;
Public function Height: Integer; virtual; abstract;
Public function Rect: TRectangle; virtual; abstract;
Public function Dpi: Integer; virtual; abstract;
Public function MousePressed: TMouseButtons; virtual; abstract;
Public function Pressed: TKeysPressed; virtual; abstract;
Public function Fps: TFramesPerSecond; virtual; abstract;
Public function TouchesCount: Integer; virtual; abstract;
Public procedure UpdateFocusAndMouseCursor;
Public function IsMousePositionForMouseLook: boolean;
Public procedure MakeMousePositionForMouseLook;

Properties

Protected property OnOpen: TContainerEvent read FOnOpen write FOnOpen;
Protected property OnOpenObject: TContainerObjectEvent read FOnOpenObject write FOnOpenObject;
Protected property OnBeforeRender: TContainerEvent read FOnBeforeRender write FOnBeforeRender;
Protected property OnRender: TContainerEvent read FOnRender write FOnRender;
Protected property OnResize: TContainerEvent read FOnResize write FOnResize;
Protected property OnClose: TContainerEvent read FOnClose write FOnClose;
Protected property OnCloseObject: TContainerObjectEvent read FOnCloseObject write FOnCloseObject;
Protected property OnPress: TInputPressReleaseEvent read FOnPress write FOnPress;
Protected property OnRelease: TInputPressReleaseEvent read FOnRelease write FOnRelease;
Protected property OnMotion: TInputMotionEvent read FOnMotion write FOnMotion;
Protected property OnUpdate: TContainerEvent read FOnUpdate write FOnUpdate;
Protected property Cursor: TMouseCursor write SetCursor;
Public property Focus: TUIControl read FFocus;
Public property TooltipVisible: boolean read FTooltipVisible;
Public property TooltipPosition: TVector2Single read FTooltipPosition;
Public property MousePosition: TVector2Single read GetMousePosition write SetMousePosition;
Public property Touches[Index:Integer]: TTouch read GetTouches;
Published property RenderStyle: TRenderStyle read FRenderStyle write FRenderStyle default rs2D;
Published property TooltipDelay: TMilisecTime read FTooltipDelay write FTooltipDelay default DefaultTooltipDelay;
Published property TooltipDistance: Cardinal read FTooltipDistance write FTooltipDistance default DefaultTooltipDistance;

Description

Methods

Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;
 
Protected procedure SetCursor(const Value: TMouseCursor); virtual; abstract;
 
Protected function GetMousePosition: TVector2Single; virtual; abstract;
 
Protected procedure SetMousePosition(const Value: TVector2Single); virtual; abstract;
 
Protected function GetTouches(const Index: Integer): TTouch; virtual; abstract;
 
Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure EventOpen(const OpenWindowsCount: Cardinal);

Propagate the event to all the Controls and to our own OnXxx callbacks. Usually these are called by a container provider, like TCastleWindow or TCastleControl. But it is also allowed to call them manually to fake given event.

Public procedure EventClose(const OpenWindowsCount: Cardinal);
 
Public function EventPress(const Event: TInputPressRelease): boolean;
 
Public function EventRelease(const Event: TInputPressRelease): boolean;
 
Public procedure EventUpdate;
 
Public procedure EventMotion(const Event: TInputMotion);
 
Public function AllowSuspendForInput: boolean;
 
Public procedure EventBeforeRender;
 
Public procedure EventRender; virtual; abstract;
 
Public procedure EventResize;
 
Public function Controls: TUIControlList;

Controls listening for events (user input, resize, and such) of this container.

Usually you explicitly add / delete controls to this list. Also, freeing the control that is on this list automatically removes it from this list (using the TComponent.Notification mechanism).

Controls on the list should be specified in front-to-back order. That is, controls at the beginning of this list are first to catch some events, and are rendered as the last ones (to cover controls beneath them).

Public procedure Invalidate; virtual; abstract;

Redraw the contents of of this window, at the nearest good time. The redraw will not happen immediately, we will only "make a note" that we should do it soon. Redraw means that we call EventBeforeRender (OnBeforeRender), EventRender (OnRender), then we flush OpenGL commands, swap buffers etc.

Calling this on a closed container (with GLInitialized = False) is allowed and ignored.

Public function GLInitialized: boolean; virtual; abstract;

Is the OpenGL context initialized.

Public function Width: Integer; virtual; abstract;
 
Public function Height: Integer; virtual; abstract;
 
Public function Rect: TRectangle; virtual; abstract;
 
Public function Dpi: Integer; virtual; abstract;
 
Public function MousePressed: TMouseButtons; virtual; abstract;

Mouse buttons currently pressed.

Public function Pressed: TKeysPressed; virtual; abstract;

Keys currently pressed.

Public function Fps: TFramesPerSecond; virtual; abstract;
 
Public function TouchesCount: Integer; virtual; abstract;
 
Public procedure UpdateFocusAndMouseCursor;

Called by controls within this container when something could change the container focused control (or it's cursor). In practice, called when TUIControl.Cursor or TUIControl.PositionInside results change.

This recalculates the focused control and the final cursor of the container, looking at Container's Controls, testing PositionInside with current mouse position, and looking at Cursor property of the focused control.

When you add / remove some control from the Controls list, or when you move mouse (focused changes) this will also be automatically called (since focused control or final container cursor may also change then).

Public function IsMousePositionForMouseLook: boolean;

Internal for implmenting mouse look in cameras.

Public procedure MakeMousePositionForMouseLook;

Internal for implmenting mouse look in cameras.

Properties

Protected property OnOpen: TContainerEvent read FOnOpen write FOnOpen;

These should only be get/set by a container provider, like TCastleWindow or TCastleControl.

Protected property OnOpenObject: TContainerObjectEvent read FOnOpenObject write FOnOpenObject;
 
Protected property OnBeforeRender: TContainerEvent read FOnBeforeRender write FOnBeforeRender;
 
Protected property OnRender: TContainerEvent read FOnRender write FOnRender;
 
Protected property OnResize: TContainerEvent read FOnResize write FOnResize;
 
Protected property OnClose: TContainerEvent read FOnClose write FOnClose;
 
Protected property OnCloseObject: TContainerObjectEvent read FOnCloseObject write FOnCloseObject;
 
Protected property OnPress: TInputPressReleaseEvent read FOnPress write FOnPress;
 
Protected property OnRelease: TInputPressReleaseEvent read FOnRelease write FOnRelease;
 
Protected property OnMotion: TInputMotionEvent read FOnMotion write FOnMotion;
 
Protected property OnUpdate: TContainerEvent read FOnUpdate write FOnUpdate;
 
Protected property Cursor: TMouseCursor write SetCursor;
 
Public property Focus: TUIControl read FFocus;

Returns the control that should receive input events first, or Nil if none. More precisely, this is the first on Controls list that is enabled and under the mouse cursor. Nil is returned when there's no enabled control under the mouse cursor.

Public property TooltipVisible: boolean read FTooltipVisible;

When the tooltip should be shown (mouse hovers over a control with a tooltip) then the TooltipVisible is set to True, and TooltipPosition indicate left-bottom suggested position of the tooltip.

The tooltip is only detected when TUIControl.TooltipExists. See TUIControl.TooltipExists and TUIControl.TooltipStyle and TUIControl.TooltipRender. For simple purposes just set TUIControlFont.Tooltip to something non-empty.

Public property TooltipPosition: TVector2Single read FTooltipPosition;
 
Public property MousePosition: TVector2Single read GetMousePosition write SetMousePosition;
 
Public property Touches[Index:Integer]: TTouch read GetTouches;
 
Published property RenderStyle: TRenderStyle read FRenderStyle write FRenderStyle default rs2D;

How OnRender callback fits within various Render methods of our Controls.

  • rs2D means that OnRender is called at the end, after all our Controls (3D and 2D) are drawn. The 2D orthographic projection is set, along with other parameters suitable for 2D rendering, see the documentation for TUIControl.RenderStyle = rs2D.

  • rs3D means that OnRender is called after all other Controls with rs3D draw style, but before any 2D controls.

    OpenGL projection matrix is not modified (so projection is whatever you set yourself, by EventResize, OnResize, or whatever TCastleSceneManager set for you). You should set your own projection matrix at the beginning of this (e.g. use PerspectiveProjection), otherwise rendering results are undefined.

    This is suitable if you want to draw something 3D, that may be later covered by 2D controls.

Published property TooltipDelay: TMilisecTime read FTooltipDelay write FTooltipDelay default DefaultTooltipDelay;
 
Published property TooltipDistance: Cardinal read FTooltipDistance write FTooltipDistance default DefaultTooltipDistance;
 

Generated by PasDoc 0.13.0 on 2014-10-26 05:15:15