Unit CastleUIControls

Description

User interface basic classes: TCastleUserInterface, TCastleContainer.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TTouch Tracking of a touch by a single finger, used by TTouchList.
Class TTouchList Tracking of multi-touch, a position of each finger on the screen.
Class TInputInspector How to invoke the inspector, see TCastleContainer.InputInspector.
Class TCastleContainer Abstract user interface container.
Class TCastleUserInterface Basic user-interface class.
Class TCastleUserInterfaceList List of TCastleUserInterface instances.
Class TInternalChildrenControls List of UI controls, with a parent control and container.
Class TCastleTheme Theme for user interface controls.

Functions and Procedures

function Theme: TCastleTheme;
function FallbackTheme: TCastleTheme;
procedure UserInterfaceSave(const C: TCastleUserInterface; const Url: String);
function UserInterfaceLoad(const Url: String; const Owner: TComponent): TCastleUserInterface;
function OnGLContextOpen: TGLContextEventList; deprecated 'use ApplicationProperties.OnGLContextOpen';
function OnGLContextClose: TGLContextEventList; deprecated 'use ApplicationProperties.OnGLContextClose';
function IsGLContextOpen: boolean; deprecated 'use ApplicationProperties.IsGLContextOpen';
function RenderControlToImage(const Container: TCastleContainer; const Control: TCastleUserInterface; const ViewportRect: TRectangle; const BackgroundColor: TCastleColor): TRGBAlphaImage; overload;

Types

TBorder = CastleVectors.TBorder;
TContainerEvent = procedure (Container: TCastleContainer);
TContainerObjectEvent = procedure (Container: TCastleContainer) of object;
TInputPressReleaseEvent = procedure (Container: TCastleContainer; const Event: TInputPressRelease);
TInputMotionEvent = procedure (Container: TCastleContainer; const Event: TInputMotion);
TUiNotifyEvent = procedure (const Sender: TCastleUserInterface) of object;
TUiUpdateEvent = procedure (const Sender: TCastleUserInterface; const SecondsPassed: Single; var HandleInput: Boolean) of object;
TUiPressReleaseEvent = procedure (const Sender: TCastleUserInterface; const Event: TInputPressRelease; var Handled: Boolean) of object;
TUiMotionEvent = procedure (const Sender: TCastleUserInterface; const Event: TInputMotion; var Handled: Boolean) of object;
TUIScaling = (...);
TCastleUserInterfaceChange = (...);
TCastleUserInterfaceChanges = set of TCastleUserInterfaceChange;
TCastleUserInterfaceChangeEvent = procedure(const Sender: TCastleUserInterface; const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean) of object;
TPositionRelative = (...) deprecated;
PTouch = ˆTTouch;
TCastleUserInterfaceClass = class of TCastleUserInterface;
TUIControlPos = TCastleUserInterface deprecated 'use TCastleUserInterface';
TUIRectangularControl = TCastleUserInterface deprecated 'use TCastleUserInterface';
TUIControl = TCastleUserInterface deprecated 'use TCastleUserInterface';
TUIControlSizeable = TCastleUserInterface deprecated 'use TCastleUserInterface';
TCastleUserInterfaceRect = TCastleUserInterface deprecated 'use TCastleUserInterface';
TInputListener = TCastleUserInterface deprecated 'use TCastleUserInterface';
TUIControlChange = TCastleUserInterfaceChange deprecated 'use TCastleUserInterfaceChange';
TUIControlChanges = TCastleUserInterfaceChanges deprecated 'use TCastleUserInterfaceChanges';
TUIControlList = TCastleUserInterfaceList deprecated 'use TCastleUserInterfaceList';
TUIControlChangeEvent = TCastleUserInterfaceChangeEvent deprecated 'use TCastleUserInterfaceChangeEvent';
TUIContainer = TCastleContainer deprecated 'use TCastleContainer';
TThemeImage = (...);

Constants

DefaultDpi = 96.0;
DefaultTooltipDelay = 1.0;
DefaultTooltipDistance = 10;
prLeft = prLow deprecated;
prRight = prHigh deprecated;
prBottom = prLow deprecated;
prTop = prHigh deprecated;
hpLeft = CastleRectangles.hpLeft ;
hpMiddle = CastleRectangles.hpMiddle;
hpRight = CastleRectangles.hpRight ;
vpBottom = CastleRectangles.vpBottom;
vpMiddle = CastleRectangles.vpMiddle;
vpTop = CastleRectangles.vpTop ;

Description

Functions and Procedures

function Theme: TCastleTheme;

Theme that you can customize, used by default by all UI controls.

function FallbackTheme: TCastleTheme;

Fallback (do not change this, ever) theme. Default state of Theme.

procedure UserInterfaceSave(const C: TCastleUserInterface; const Url: String);

Save / load TCastleUserInterface (or descendant) to a .castle-user-interface file.

function UserInterfaceLoad(const Url: String; const Owner: TComponent): TCastleUserInterface;
 
function OnGLContextOpen: TGLContextEventList; deprecated 'use ApplicationProperties.OnGLContextOpen';

Warning: this symbol is deprecated: use ApplicationProperties.OnGLContextOpen

Copyright 2010-2021 Michalis Kamburelis.

This file is part of "Castle Game Engine".

"Castle Game Engine" is free software; see the file COPYING.txt, included in this distribution, for details about the copyright.

"Castle Game Engine" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

—————————————————————————-

function OnGLContextClose: TGLContextEventList; deprecated 'use ApplicationProperties.OnGLContextClose';

Warning: this symbol is deprecated: use ApplicationProperties.OnGLContextClose

 
function IsGLContextOpen: boolean; deprecated 'use ApplicationProperties.IsGLContextOpen';

Warning: this symbol is deprecated: use ApplicationProperties.IsGLContextOpen

 
function RenderControlToImage(const Container: TCastleContainer; const Control: TCastleUserInterface; const ViewportRect: TRectangle; const BackgroundColor: TCastleColor): TRGBAlphaImage; overload;

Render control contents to an RGBA image, using off-screen rendering. The background behind the control is filled with BackgroundColor (which may be transparent, e.g. with alpha = 0).

The rendering is done using off-screen FBO. Which means that you can request any size, you are not limited to your current window / control size.

Make sure that the control is nicely positioned to fill the ViewportRect. Usually you want to adjust control size and position, and disable UI scaling (set TCastleUserInterface.EnableUIScaling = False if you use TCastleContainer.UIScaling).

This is the easiest way to make off-screen rendering, i.e. to render 3D things (like TCastleScene in TCastleViewport) into an image. This is not the fastest way, as it creates new TGLRenderToTexture instance each time, and it grabs the image contents to CPU. If you want a faster approach, use TCastleContainer.RenderControl and render into TDrawableImage using TDrawableImage.RenderToImageBegin and TDrawableImage.RenderToImageEnd.

Types

TBorder = CastleVectors.TBorder;

type

TContainerEvent = procedure (Container: TCastleContainer);
 
TContainerObjectEvent = procedure (Container: TCastleContainer) of object;
 
TInputPressReleaseEvent = procedure (Container: TCastleContainer; const Event: TInputPressRelease);
 
TInputMotionEvent = procedure (Container: TCastleContainer; const Event: TInputMotion);
 
TUiNotifyEvent = procedure (const Sender: TCastleUserInterface) of object;
 
TUiUpdateEvent = procedure (const Sender: TCastleUserInterface; const SecondsPassed: Single; var HandleInput: Boolean) of object;
 
TUiPressReleaseEvent = procedure (const Sender: TCastleUserInterface; const Event: TInputPressRelease; var Handled: Boolean) of object;
 
TUiMotionEvent = procedure (const Sender: TCastleUserInterface; const Event: TInputMotion; var Handled: Boolean) of object;
 
TUIScaling = (...);

Possible values for TCastleContainer.UIScaling.

Values
TCastleUserInterfaceChange = (...);

Things that can cause TCastleUserInterface.VisibleChange notification.

Values
  • chRender: The look of this control changed. This concerns all the things that affect what TCastleUserInterface.Render does.

    Note that changing chRectangle implies that the look changed too. So when chRectangle is in Changes, you should always behave like chRender is also in Changes, regardless if it's there or not.

  • chRectangle: The rectangle (size or position) of the control changed. This concerns all the things that affect size or our position inside parent (anchors).

    Note that this is not (necessarily) called when the screen position changed just because the parent screen position changed. We only notify when the size or position changed with respect to the parent.

    Note that changing chRectangle implies that the look changed too. So when chRectangle is in Changes, you should always behave like chRender is also in Changes, regardless if it's there or not.

  • chCursor
  • chExists
  • chChildren: A (direct) child control was added or removed.
  • chChildrenExists: A (direct) child control TCastleUserInterface.Exists value changed.
TCastleUserInterfaceChanges = set of TCastleUserInterfaceChange;
 
TCastleUserInterfaceChangeEvent = procedure(const Sender: TCastleUserInterface; const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean) of object;
 
TPositionRelative = (...) deprecated;

Warning: this symbol is deprecated.

Position for relative layout of one control in respect to another. Deprecated, rather use cleaner THorizontalPosition and TVerticalPosition.

Values
  • prLow
  • prMiddle
  • prHigh
PTouch = ˆTTouch;
 
TCastleUserInterfaceClass = class of TCastleUserInterface;
 
TUIControlPos = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

 
TUIRectangularControl = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

 
TUIControl = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

 
TUIControlSizeable = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

 
TCastleUserInterfaceRect = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

 
TInputListener = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

 
TUIControlChange = TCastleUserInterfaceChange deprecated 'use TCastleUserInterfaceChange';

Warning: this symbol is deprecated: use TCastleUserInterfaceChange

 
TUIControlChanges = TCastleUserInterfaceChanges deprecated 'use TCastleUserInterfaceChanges';

Warning: this symbol is deprecated: use TCastleUserInterfaceChanges

 
TUIControlList = TCastleUserInterfaceList deprecated 'use TCastleUserInterfaceList';

Warning: this symbol is deprecated: use TCastleUserInterfaceList

 
TUIControlChangeEvent = TCastleUserInterfaceChangeEvent deprecated 'use TCastleUserInterfaceChangeEvent';

Warning: this symbol is deprecated: use TCastleUserInterfaceChangeEvent

 
TUIContainer = TCastleContainer deprecated 'use TCastleContainer';

Warning: this symbol is deprecated: use TCastleContainer

 
TThemeImage = (...);

Type of theme image, use of TCastleTheme.ImagesPersistent.

Values
  • tiPanel
  • tiPanelSeparator
  • tiProgressBar
  • tiProgressFill
  • tiButtonPressed
  • tiButtonDisabled
  • tiButtonFocused
  • tiButtonNormal
  • tiWindow
  • tiScrollbarFrame
  • tiScrollbarSlider
  • tiSlider
  • tiSliderPosition
  • tiLabel
  • tiGroup
  • tiActiveFrame
  • tiTooltip
  • tiTouchCtlInner
  • tiTouchCtlOuter
  • tiTouchCtlFlyInner
  • tiTouchCtlFlyOuter
  • tiCrosshair1
  • tiCrosshair2
  • tiCheckmark
  • tiSquareEmpty
  • tiSquareChecked
  • tiSquarePressedBackground
  • tiDisclosure
  • tiSwitchControl
  • tiSwitchControlFill
  • tiLoading: Image displayed when the application is initializing, during Application.OnInitialize and Window.OnOpen. And TCastleUserInterface.GLContextOpen for all initially present UI controls. This "loading image" is loaded and displayed first, so that user does not see a black screen while the resources are prepared.

    It is especially useful on Android, where we can lose the OpenGL context at any moment, as user may switch applications in the middle of the game. When getting back to the application, we need to initiailize some resources, and during this process we also show this image. So this serves as a universal "please wait, we're loading" screen.

    You can customize this image, by setting Theme.ImagesPersistent[tiLoading].Image, LoadingBackgroundColor, LoadingTextColor. See https://castle-engine.io/manual_2d_user_interface.php#section_theme for a sample code that sets a theme image.

    Note that the customization of this image should be done before Application.OnInitialize has started, so it has to be usually done from the "initialization" section of some unit. And in the "initialization" section of a unit, you cannot load files (doing LoadImage at this point may fail on some Android devices, as we cannot load assets before activity is started). So you can only assign images already available in code — use image-to-pascal tool to convert any image to a Pascal code for this purpose.

  • tiEdit: TCastleEdit frame.

Constants

DefaultDpi = 96.0;

Default value for container's Dpi, as is usually set on desktops.

DefaultTooltipDelay = 1.0;
 
DefaultTooltipDistance = 10;
 
prLeft = prLow deprecated;

Warning: this symbol is deprecated.

 
prRight = prHigh deprecated;

Warning: this symbol is deprecated.

 
prBottom = prLow deprecated;

Warning: this symbol is deprecated.

 
prTop = prHigh deprecated;

Warning: this symbol is deprecated.

 
hpLeft = CastleRectangles.hpLeft ;
 
hpMiddle = CastleRectangles.hpMiddle;
 
hpRight = CastleRectangles.hpRight ;
 
vpBottom = CastleRectangles.vpBottom;
 
vpMiddle = CastleRectangles.vpMiddle;
 
vpTop = CastleRectangles.vpTop ;
 

Generated by PasDoc 0.16.0.