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 TCastleView "View" represents the current state of your application user interface.
Class TCastleViewList  
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;
TContainerObjectEvent = procedure (Container: TCastleContainer) of object;
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;
tiSlider = tiSliderBackground deprecated 'use tiSliderBackground';
tiSliderPosition = tiSliderThumb deprecated 'use tiSliderThumb';
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;

This item has no description.

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

Warning: this symbol is deprecated: use ApplicationProperties.OnGLContextOpen

Called when first OpenGL context opens.

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

Warning: this symbol is deprecated: use ApplicationProperties.OnGLContextClose

Called when last OpenGL context closes.

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

Warning: this symbol is deprecated: use ApplicationProperties.IsGLContextOpen

Is any OpenGL context open.

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

TContainerObjectEvent = procedure (Container: TCastleContainer) of object;

This item has no description.

TUiNotifyEvent = procedure (const Sender: TCastleUserInterface) of object;

This item has no description.

TUiUpdateEvent = procedure (const Sender: TCastleUserInterface; const SecondsPassed: Single; var HandleInput: Boolean) of object;

This item has no description.

TUiPressReleaseEvent = procedure (const Sender: TCastleUserInterface; const Event: TInputPressRelease; var Handled: Boolean) of object;

This item has no description.

TUiMotionEvent = procedure (const Sender: TCastleUserInterface; const Event: TInputMotion; var Handled: Boolean) of object;

This item has no description.

TUIScaling = (...);

Possible values for TCastleContainer.UIScaling.

Values
  • usNone: Do not scale UI.
  • usEncloseReferenceSize: Scale to fake that the container sizes enclose TCastleContainer.UIReferenceWidth and TCastleContainer.UIReferenceHeight. So one size will be equal to reference size, and the other will be equal or larger to reference.

    Controls that look at TCastleUserInterface.UIScale will be affected by this. Together with anchors (see TCastleUserInterface.Anchor), this allows to easily design a scalable UI.

  • usEncloseReferenceSizeAutoOrientation: Similar to usEncloseReferenceSize, but automatically flips the reference width and height to adjust to what is currently bigger (width or height), to adjust to mobile orientation changes (portrait vs landscape).

    For example, when UIReferenceWidth = 1600 and UIReferenceHeight = 900, then it will adjust to 1600x900 when device is in landscape mode (width > height), and to 900x1600 when device is in portrait mode (width < height).

    In effect, in contrast to usEncloseReferenceSize:

    • Advantage: On mobile devices, if you allow user to switch between portrait and landscape, the UI will have the same physical size in both portrait and landscape modes. So it looks better on mobile.

    • Disadvantage: Designing for this is a bit harder than for usEncloseReferenceSize, as you need to test both portrait (width smaller than height) and landscape (width bigger than height), as they result in different calculations.

    This is different from usEncloseReferenceSize only when both TCastleContainer.UIReferenceWidth and TCastleContainer.UIReferenceHeight are set to non-zero values. When one of them is zero, then both usEncloseReferenceSize and usEncloseReferenceSizeAutoOrientation behave the same, they just adjust scaling based on this one non-zero reference size.

  • usFitReferenceSize: Scale to fake that the container sizes fit inside TCastleContainer.UIReferenceWidth and TCastleContainer.UIReferenceHeight. So one size will be equal to reference size, and the other will be equal or smaller to reference.

    Controls that look at TCastleUserInterface.UIScale will be affected by this. Together with anchors (see TCastleUserInterface.Anchor), this allows to easily design a scalable UI.

  • usExplicitScale: Scale to fake that the container sizes are smaller/larger by an explicit factor TCastleContainer.UIExplicitScale. Controls that look at TCastleUserInterface.UIScale will be affected by this.

    Like usEncloseReferenceSize or usFitReferenceSize, this allows to design a scalable UI. In this case, the scale factor has to be calculated by your code (by default TCastleContainer.UIExplicitScale is 1.0 and the engine will not modify it automatically in any way), which allows customizing the scale to your requirements.

  • usDpiScale: Scale to pretend that the container size is smaller/larger by a factor derived from TCastleContainer.Dpi.

    This allows to adjust controls to:

    • The physical size. TCastleContainer.Dpi on iOS and Android really reflects physical size.

    • Or at least to follow user preferred UI scaling. TCastleContainer.Dpi on desktops is often more like "configurable way to scale UI" than derived from actual monitor physical size.

    This is the same scaling done by normal desktop applications, e.g. using Lazarus LCL. Using this scaling is best if your user interface using CGE should match (the size of) the user interface done by Lazarus LCL or native applications.

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;

This item has no description.

TCastleUserInterfaceChangeEvent = procedure(const Sender: TCastleUserInterface; const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean) of object;

This item has no description.

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;

This item has no description.

TCastleUserInterfaceClass = class of TCastleUserInterface;

This item has no description.

TUIControlPos = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

This item has no description.

TUIRectangularControl = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

This item has no description.

TUIControl = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

This item has no description.

TUIControlSizeable = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

This item has no description.

TCastleUserInterfaceRect = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

This item has no description.

TInputListener = TCastleUserInterface deprecated 'use TCastleUserInterface';

Warning: this symbol is deprecated: use TCastleUserInterface

This item has no description.

TUIControlChange = TCastleUserInterfaceChange deprecated 'use TCastleUserInterfaceChange';

Warning: this symbol is deprecated: use TCastleUserInterfaceChange

This item has no description.

TUIControlChanges = TCastleUserInterfaceChanges deprecated 'use TCastleUserInterfaceChanges';

Warning: this symbol is deprecated: use TCastleUserInterfaceChanges

This item has no description.

TUIControlList = TCastleUserInterfaceList deprecated 'use TCastleUserInterfaceList';

Warning: this symbol is deprecated: use TCastleUserInterfaceList

This item has no description.

TUIControlChangeEvent = TCastleUserInterfaceChangeEvent deprecated 'use TCastleUserInterfaceChangeEvent';

Warning: this symbol is deprecated: use TCastleUserInterfaceChangeEvent

This item has no description.

TUIContainer = TCastleContainer deprecated 'use TCastleContainer';

Warning: this symbol is deprecated: use TCastleContainer

This item has no description.

TThemeImage = (...);

Type of theme image, use of TCastleTheme.ImagesPersistent.

Values
  • tiPanel
  • tiPanelSeparator
  • tiButtonPressed
  • tiButtonDisabled
  • tiButtonFocused
  • tiButtonNormal
  • tiWindow
  • tiScrollbarFrame
  • tiScrollbarSlider
  • tiSliderBackground
  • tiSliderThumb
  • tiLabel
  • tiGroup
  • tiActiveFrame
  • tiTooltip
  • tiTouchCtlInner
  • tiTouchCtlOuter
  • tiTouchCtlFlyInner
  • tiTouchCtlFlyOuter
  • tiCrosshair1
  • tiCrosshair2
  • tiSquareEmpty
  • tiSquareChecked
  • tiSquarePressedBackground
  • tiLoading: Image displayed when the application is initializing, during Application.OnInitialize. 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;

This item has no description.

DefaultTooltipDistance = 10;

This item has no description.

tiSlider = tiSliderBackground deprecated 'use tiSliderBackground';

Warning: this symbol is deprecated: use tiSliderBackground

This item has no description.

tiSliderPosition = tiSliderThumb deprecated 'use tiSliderThumb';

Warning: this symbol is deprecated: use tiSliderThumb

This item has no description.

prLeft = prLow deprecated;

Warning: this symbol is deprecated.

This item has no description.

prRight = prHigh deprecated;

Warning: this symbol is deprecated.

This item has no description.

prBottom = prLow deprecated;

Warning: this symbol is deprecated.

This item has no description.

prTop = prHigh deprecated;

Warning: this symbol is deprecated.

This item has no description.

hpLeft = CastleRectangles.hpLeft ;

This item has no description.

hpMiddle = CastleRectangles.hpMiddle;

This item has no description.

hpRight = CastleRectangles.hpRight ;

This item has no description.

vpBottom = CastleRectangles.vpBottom;

This item has no description.

vpMiddle = CastleRectangles.vpMiddle;

This item has no description.

vpTop = CastleRectangles.vpTop ;

This item has no description.


Generated by PasDoc 0.16.0-snapshot.