Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TUIContainer
Unit
CastleUIControls
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
Overview
Methods
Properties
Description
Methods
 |
procedure Notification(AComponent: TComponent; Operation: TOperation); override; |
|
 |
procedure SetCursor(const Value: TMouseCursor); virtual; abstract; |
|
 |
procedure SetMousePosition(const Value: TVector2Single); virtual; abstract; |
|
 |
function GetTouches(const Index: Integer): TTouch; virtual; abstract; |
|
 |
constructor Create(AOwner: TComponent); override; |
|
 |
destructor Destroy; override; |
|
 |
procedure EventOpen(const OpenWindowsCount: Cardinal); virtual; |
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.
|
 |
procedure EventClose(const OpenWindowsCount: Cardinal); virtual; |
|
 |
procedure EventUpdate; virtual; |
|
 |
function AllowSuspendForInput: boolean; |
|
 |
procedure EventBeforeRender; virtual; |
|
 |
procedure EventRender; virtual; abstract; |
|
 |
procedure EventResize; virtual; |
|
 |
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).
|
 |
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.
|
 |
function GLInitialized: boolean; virtual; abstract; |
Is the OpenGL context initialized.
|
 |
function Width: Integer; virtual; abstract; |
|
 |
function Height: Integer; virtual; abstract; |
|
 |
function Dpi: Integer; virtual; abstract; |
|
 |
function MousePressed: TMouseButtons; virtual; abstract; |
Mouse buttons currently pressed.
|
 |
function Focused: boolean; virtual; abstract; |
Is the window focused now, which means that keys/mouse events are directed to this window.
|
 |
function Pressed: TKeysPressed; virtual; abstract; |
Keys currently pressed.
|
 |
function TouchesCount: Integer; virtual; abstract; |
|
 |
procedure UpdateFocusAndMouseCursor; |
Called by controls within this container when something could change the container focused control (or it's cursor) or Focused or MouseLook. 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).
|
 |
function IsMousePositionForMouseLook: boolean; |
Internal for implementing mouse look in cameras.
|
 |
procedure MakeMousePositionForMouseLook; |
Internal for implementing mouse look in cameras.
|
Properties
 |
property OnBeforeRender: TContainerEvent read FOnBeforeRender write FOnBeforeRender; |
|
 |
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.
|
 |
property ForceCaptureInput: TUIControl
read FForceCaptureInput write FForceCaptureInput; |
Force passing events to given control first, regardless if this control is under mouse cursor. This control also always has focus.
An example when this is useful is when you use camera MouseLook, and the associated viewport does not fill the full window (TCastleAbstractViewport.FullSize is False , and actual sizes are smaller than window, and may not include window center). In this case you want to make sure that motion events get passed to this control, and that this control has focus (to keep mouse cursor hidden).
This is used only if it is also present on our Controls list, as it doesn't make sense otherwise. We also cannot reliably track it's existence when it's outside our Controls list (and we don't want to eagerly Nil this property automatically).
|
 |
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.
rs3D means that OnRender is called after all other Controls with rs3D draw style, but before any 2D controls.
This is suitable if you want to draw something 3D, that may be later covered by 2D controls.
|
 |
property TooltipDistance: Cardinal read FTooltipDistance write FTooltipDistance
default DefaultTooltipDistance; |
|
Generated by PasDoc 0.14.0.
|