Class TCastleControlContainer

Unit

Declaration

type TCastleControlContainer = class(TCastleContainer)

Description

This item has no description. Showing description inherited from TCastleContainer.

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

Basically, this class manages a Controls list.

We pass our inputs (mouse / key / touch events) to the controls on this list. Input goes to the front-most (that is, last on the Controls list) control under the event position (or mouse position, or the appropriate touch position). We use TCastleUserInterface.CapturesEventsAtPosition to decide this (by default it simply checks control's TCastleUserInterface.RenderRect vs the given position). As long as the event is not handled, we search for the next control that can handle this event and returns TCastleUserInterface.CapturesEventsAtPosition = True.

We also call various methods to every control. These include TCastleUserInterface.Update, TCastleUserInterface.Render, TCastleUserInterface.Resize.

Source: delphi/castlecontrolcontainer.pas (line 54).

Hierarchy

Overview

Fields

Protected class var UpdatingEnabled: Boolean;

Methods

Protected procedure AdjustContext(const PlatformContext: TGLContext); virtual;
Protected procedure InitializeContext;
Protected procedure FinalizeContext;
Protected procedure DoRender;
Protected class procedure DoUpdateEverything;
Protected class procedure UpdatingEnable; virtual; abstract;
Protected class procedure UpdatingDisable; virtual; abstract;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function SaveScreen(const SaveRect: TRectangle): TRGBImage; overload; override;
Public function GLInitialized: boolean; override;
Public procedure MakeContextCurrent;
Public function DesignedComponent(const ComponentName: String; const Required: Boolean = true): TComponent;

Properties

Published property AutoRedisplay: Boolean read FAutoRedisplay write SetAutoRedisplay default true;
Published property Requirements: TGLContextRequirements read FRequirements;
Published property DesignUrl: String read FDesignUrl write SetDesignUrl;

Description

Fields

Protected class var UpdatingEnabled: Boolean;

"Updating" means that the mechanism to call DoUpdateEverything continuosly is set up.

Source: delphi/castlecontrolcontainer.pas (line 87).

Methods

Protected procedure AdjustContext(const PlatformContext: TGLContext); virtual;

Adjust context parameters right before usage.

Source: delphi/castlecontrolcontainer.pas (line 76).

Protected procedure InitializeContext;

Call these methods from final components that wrap TCastleControlContainer, like TCastleControl, TCastleWindow.

Source: delphi/castlecontrolcontainer.pas (line 80).

Protected procedure FinalizeContext;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 81).

Protected procedure DoRender;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 82).

Protected class procedure DoUpdateEverything;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 89).

Protected class procedure UpdatingEnable; virtual; abstract;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 90).

Protected class procedure UpdatingDisable; virtual; abstract;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 91).

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 93).

Public destructor Destroy; override;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 94).

Public function SaveScreen(const SaveRect: TRectangle): TRGBImage; overload; override;

This item has no description.

Source: delphi/castlecontrolcontainer.pas (line 95).

Public function GLInitialized: boolean; override;

Is OpenGL(ES) context initialized for this container.

Source: delphi/castlecontrolcontainer.pas (line 98).

Public procedure MakeContextCurrent;

Make given OpenGL(ES) context current. Can only be used if GLInitialized.

Source: delphi/castlecontrolcontainer.pas (line 102).

Public function DesignedComponent(const ComponentName: String; const Required: Boolean = true): TComponent;

When the DesignUrl is set you can use this method to find loaded components. Like this:

MyButton := MyCastleControl.Container.DesignedComponent('MyButton') as TCastleButton;

When the name is not found, raises exception (unless Required is False, then it returns Nil).

See also
DesignUrl
Load and show the design (.castle-user-interface file).

Source: delphi/castlecontrolcontainer.pas (line 115).

Properties

Published property AutoRedisplay: Boolean read FAutoRedisplay write SetAutoRedisplay default true;

Should we automatically redraw the window all the time, without the need for an Invalidate call. If True (the default), rendering and other processing will be called constantly.

If your game may have a still screen (nothing animates), then this approach is a little unoptimal, as we use CPU and GPU for drawing, when it's not needed. In such case, you can set this property to False, and make sure that you call Invalidate always when you need to redraw the screen. Note that the engine components always call Invalidate when necessary, so usually you should only call it yourself if you do custom rendering in overridden TCastleUserInterface.Render implementation.

Source: delphi/castlecontrolcontainer.pas (line 131).

Published property Requirements: TGLContextRequirements read FRequirements;

Context required parameters.

Source: delphi/castlecontrolcontainer.pas (line 135).

Published property DesignUrl: String read FDesignUrl write SetDesignUrl;

Load and show the design (.castle-user-interface file). You can reference the loaded components by name using DesignedComponent.

If you have more complicated control flow, we recommend to leave this property empty, and split your management into a number of states (TCastleView) instead. In this case, load design using TCastleView.DesignUrl. This property makes it however easy to use .castle-user-interface in simple cases, e.g. when TCastleControl just shows one UI.

The design loaded here is visible also at design-time, when editing the form in Lazarus/Delphi. Though we have to way to edit it now in Lazarus/Delphi (you have to use CGE editor to edit the design), so it is just a preview in this case.

See https://castle-engine.io/control_on_form for documentation how to use TCastleControl.

Source: delphi/castlecontrolcontainer.pas (line 153).


Generated by PasDoc 0.17.0.snapshot.