Class TCastleTheme

Unit

Declaration

type TCastleTheme = class(TCastleComponent)

Description

Theme for user interface controls.

You can customize Theme singleton to change the default look.

You can also create new instances of TCastleTheme and use them for multiple controls, assigning to TCastleUserInterface.CustomTheme.

You can also use FallbackTheme to effectively disable any customizations and always use default hardcoded look.

Source: ui/castleuicontrols_theme.inc (line 71).

Hierarchy

Show Additional Members:

Overview

Fields

Public TooltipTextColor: TCastleColor;
Public TextColor: TCastleColor;
Public DisabledTextColor: TCastleColor;
Public MessageTextColor: TCastleColor;
Public MessageInputTextColor: TCastleColor;
Public BarEmptyColor: TVector3Byte;
Public BarFilledColor: TVector3Byte;
Public BackgroundColor: TCastleColor;
Public BackgroundOpaqueColor: TCastleColorRGB;
Public LoadingBackgroundColor: TCastleColor;
Public LoadingColor: TCastleColor;
Public LoadingUIScaling: TUIScaling;
Public LoadingUIReferenceWidth: Single;
Public LoadingUIReferenceHeight: Single;
Public LoadingUIExplicitScale: Single;
Public ScrollBarWidth: Single;
Public MinimumScrollbarSliderHeight: Single;
Public DefaultLabelWhite: Boolean deprecated 'if you want the labels to be white, adjust TCastleLabel.Color to White after creating every TCastleLabel';

Methods

Protected function GetInternalText: String; virtual;
Protected procedure SetInternalText(const Value: String); virtual;
Protected procedure SetName(const Value: TComponentName); override;
Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual;
Public function PropertySections(const PropertyName: String): TPropertySections; virtual;
Public procedure SetTransient;
Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);
Public procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent);
Public procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent);
Public function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer;
Public function NonVisualComponentsCount: Integer;
Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;
Public function ValueIsStreamed: Boolean; virtual;
Public procedure DesignerInfo(const SList: TStrings); virtual;
Public procedure DesignerWarnings(const SList: TStrings); virtual;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Draw(const Rect: TFloatRectangle; const ImageType: TThemeImage; const UIScale: Single = 1.0); overload;
Public procedure Draw(const Rect: TFloatRectangle; const ImageType: TThemeImage; const UIScale: Single; const Color: TCastleColor); overload;
Public procedure Draw(const Rect: TRectangle; const ImageType: TThemeImage; const UIScale: Single = 1.0); overload;
Public procedure Draw(const Rect: TRectangle; const ImageType: TThemeImage; const UIScale: Single; const Color: TCastleColor); overload;
Public procedure DialogsLight;

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;
Public property IsLoading: Boolean read FIsLoading;
Public property Images[const ImageType: TThemeImage]: TCastleImage read GetImages write SetImages; deprecated 'use ImagesPersistent[...].Image';
Public property ImagesPersistent[const ImageType: TThemeImage]: TCastleImagePersistent read GetImagePersistent;
Public property OwnsImages[const ImageType: TThemeImage]: boolean read GetOwnsImages write SetOwnsImages; deprecated 'use ImagesPersistent[...].OwnsImage';
Public property Corners[const ImageType: TThemeImage]: TVector4 read GetCorners write SetCorners; deprecated 'use ImagesPersistent[...].ProtectedSides';
Public property MessageFont: TCastleAbstractFont read FMessageFont write SetMessageFont;
Public property OwnsMessageFont: boolean read FOwnsMessageFont write FOwnsMessageFont default true;
Public property LoadingTextColor: TCastleColor read LoadingColor write LoadingColor; deprecated 'use LoadingColor';
Public property LoadingImageForWindowHeight: Single read LoadingUIReferenceHeight write LoadingUIReferenceHeight; deprecated 'use LoadingUIReferenceHeight';

Description

Fields

Public TooltipTextColor: TCastleColor;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 85).

Public TextColor: TCastleColor;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 86).

Public DisabledTextColor: TCastleColor;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 86).

Public MessageTextColor: TCastleColor;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 87).

Public MessageInputTextColor: TCastleColor;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 88).

Public BarEmptyColor: TVector3Byte;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 90).

Public BarFilledColor: TVector3Byte;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 91).

Public BackgroundColor: TCastleColor;

Color layer displayed between modal dialogs (CastleMessages, CastleDialogViews, TGLModeFrozenScreen) and their background (view underneath or a screenshot). Default is (0, 0, 0, 0.25), making things underneath darker, which helps dialog to stand out.

Source: ui/castleuicontrols_theme.inc (line 97).

Public BackgroundOpaqueColor: TCastleColorRGB;

Color used instead of BackgroundColor when InternalMessageFallbackLook is used. You can only customize the RGB values, alpha is always 1, so the resulting color is always opaque. It's a dark gray color (0.33, 0.33, 0.33) by default.

Source: ui/castleuicontrols_theme.inc (line 103).

Public LoadingBackgroundColor: TCastleColor;

Colors used when displaying the loading image (by default just with the "Loading..." text) when application is loading (before proper CGE UI can be displayed). By default, LoadingBackgroundColor is black, and LoadingColor is white.

See https://castle-engine.io/loading_image for an example how to set loading image.

Source: ui/castleuicontrols_theme.inc (line 111).

Public LoadingColor: TCastleColor;

Colors used when displaying the loading image (by default just with the "Loading..." text) when application is loading (before proper CGE UI can be displayed). By default, LoadingBackgroundColor is black, and LoadingColor is white.

See https://castle-engine.io/loading_image for an example how to set loading image.

Source: ui/castleuicontrols_theme.inc (line 111).

Public LoadingUIScaling: TUIScaling;

Adjust loading image following the UI scaling determined by these properties. They determine for what window reference size was the loading image prepared. The loading image is whatever you set at ImagesPersistent[tiLoading]. See https://castle-engine.io/loading_image for an example how to set loading image.

These properties deliberately match the behavior of TCastleContainer.UIScaling, TCastleContainer.UIReferenceWidth, TCastleContainer.UIReferenceHeight, TCastleContainer.UIExplicitScale. If these LoadingUIXxx properties are equal to the TCastleContainer.UIXxx properties, then the rendered image size will be precisely equal to how TCastleImageControl rendering of this image (with anchors set to middle) would look.

The reason why these properties exist is that when rendering ImagesPersistent[tiLoading], TCastleApplication.OnInitialize is not yet run, and so TCastleContainer.UIScaling may be not yet be initialized (because you cannot read CastleSettings.xml earlier).

By default, we set LoadingUIScaling = usEncloseReferenceSize, LoadingUIReferenceWidth = 1600, LoadingUIReferenceHeight = 900. Note that this is in contrast to TCastleContainer.UIXxx properties, that by default set no UI scaling.

Source: ui/castleuicontrols_theme.inc (line 140).

Public LoadingUIReferenceWidth: Single;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 141).

Public LoadingUIReferenceHeight: Single;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 142).

Public LoadingUIExplicitScale: Single;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 143).

Public ScrollBarWidth: Single;

Width of scrollbar for TCastleScrollView.

Source: ui/castleuicontrols_theme.inc (line 147).

Public MinimumScrollbarSliderHeight: Single;

Minumum scrollbar height, to be comfortably visible and draggable.

Source: ui/castleuicontrols_theme.inc (line 149).

Public DefaultLabelWhite: Boolean deprecated 'if you want the labels to be white, adjust TCastleLabel.Color to White after creating every TCastleLabel';

Warning: this symbol is deprecated: if you want the labels to be white, adjust TCastleLabel.Color to White after creating every TCastleLabel

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 178).

Methods

Protected function GetInternalText: String; virtual;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 575).

Protected procedure SetInternalText(const Value: String); virtual;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 576).

Protected procedure SetName(const Value: TComponentName); override;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 577).

Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;

This item is declared in ancestor TCastleComponent.

Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder.

Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate.

It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent.

You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component.

Source: base/castleclassutils.pas (line 598).

Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual;

This item is declared in ancestor TCastleComponent.

Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field.

Source: base/castleclassutils.pas (line 610).

Public function PropertySections(const PropertyName: String): TPropertySections; virtual;

This item is declared in ancestor TCastleComponent.

Section where to show property in the editor.

Source: base/castleclassutils.pas (line 631).

Public procedure SetTransient;

This item is declared in ancestor TCastleComponent.

Ignore this component when serializing parent's TCastleUserInterface.Controls list or TCastleTransform.List, and do not show this component in CGE editor. This simply sets csTransient flag in ComponentStyle.

This is useful for children that are automatically managed by the parent, and should not be modified by user code. For example, TCastleCheckbox is internally composed from TCastleImageControl and TCastleLabel children, but we don't want to serialize or even show these children to user.

Note that if you want to prevent this component from serializing as part of TCastleUserInterface.Controls list or TCastleTransform.List, but you still want it to be visible in CGE editor, then make it a "subcomponent" instead, by SetSubComponent(true).

Note that both csSubComponent and csTransient only disable the component serialization as part of parent's lists enumerated by CustomSerialization (see internal TCastleUserInterface.SerializeChildrenEnumerate , TCastleTransform.SerializeChildrenEnumerate, TCastleTransform.SerializeBehaviorsEnumerate).

If you will make the component published in its own property (which is normal for "subcomponents") then it will be serialized anyway, just as part of it's own property (like TCastleScrollView.ScrollArea). So to really avoid serializing a children component make it csSubComponent and/or csTransient, and do not publish it.

Source: base/castleclassutils.pas (line 663).

Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Add non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 672).

Public procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Insert non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 681).

Public procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Removes the component previously added by AddNonVisualComponent.

Source: base/castleclassutils.pas (line 684).

Public function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer;

This item is declared in ancestor TCastleComponent.

Index of the previously added non-visual component. Returns -1 if the component was not found.

Source: base/castleclassutils.pas (line 688).

Public function NonVisualComponentsCount: Integer;

This item is declared in ancestor TCastleComponent.

Count of components added by AddNonVisualComponent.

See also
AddNonVisualComponent
Add non-visual component to this component.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 695).

Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;

This item is declared in ancestor TCastleComponent.

You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do .... Do not call this method in other contexts, it is only useful for "for..in" construction.

See also
AddNonVisualComponent
Add non-visual component to this component.

Source: base/castleclassutils.pas (line 705).

Public function ValueIsStreamed: Boolean; virtual;

This item is declared in ancestor TCastleComponent.

Whether the current value of this object should be written to the stream. This should be True if anything inside this object should be serialized (which means it has non-default value or "stored" specifier indicates that it should be serialized).

This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization.

In simple cases, this just says whether the current value of this object equals to some default value.

The default implementation of this class returns True (so always write).

Descendants that override this to sometimes return False (so no need to write) must be very careful: any addition of a new field requires extending this method, otherwise new field may not be saved sometimes (when all other fields are default). Descentants of such classes must also be aware of it. This check must include everything that is inside this object in JSON, including subcomponents and children objects (as done e.g. by TSerializationProcess.ReadWriteList). In practice, overriding this method is only reasonable for simple classes that will not change much in the future, like TCastleVector3Persistent.

The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL.

Source: base/castleclassutils.pas (line 739).

Public procedure DesignerInfo(const SList: TStrings); virtual;

This item is declared in ancestor TCastleComponent.

Override to add information that should be visible at design-time. Call SList.Add for each new line of information.

Source: base/castleclassutils.pas (line 743).

Public procedure DesignerWarnings(const SList: TStrings); virtual;

This item is declared in ancestor TCastleComponent.

Override to add warnings that should be visible at design-time. Call SList.Add for each new warning.

Source: base/castleclassutils.pas (line 747).

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 180).

Public destructor Destroy; override;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 181).

Public procedure Draw(const Rect: TFloatRectangle; const ImageType: TThemeImage; const UIScale: Single = 1.0); overload;

Draw the selected theme image on screen.

Parameters
Color
Color tint of the image. If you do not specify a color, white will be used, so image will be displayed as-is. Specifying a color means that image will be multiplied by it, just like for TDrawableImage.Color.
UIScale
Used to properly scale corners, passed to TDrawableImage.ScaleCorners. This parameter does not scale the place where image is displayed, to do this just scale the given Rect parameter yourself.

Source: ui/castleuicontrols_theme.inc (line 236).

Public procedure Draw(const Rect: TFloatRectangle; const ImageType: TThemeImage; const UIScale: Single; const Color: TCastleColor); overload;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 238).

Public procedure Draw(const Rect: TRectangle; const ImageType: TThemeImage; const UIScale: Single = 1.0); overload;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 240).

Public procedure Draw(const Rect: TRectangle; const ImageType: TThemeImage; const UIScale: Single; const Color: TCastleColor); overload;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 242).

Public procedure DialogsLight;

Set dialogs theme to light.

Source: ui/castleuicontrols_theme.inc (line 253).

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;

This item is declared in ancestor TCastleComponent.

Components added by AddNonVisualComponent.

Source: base/castleclassutils.pas (line 698).

Public property IsLoading: Boolean read FIsLoading;

This item is declared in ancestor TCastleComponent.

Is the component during deserialization now.

Note: We can't use csLoading in ComponentState because in Delphi it is not possible to control it from CastleComponentSerialize.

Source: base/castleclassutils.pas (line 711).

Public property Images[const ImageType: TThemeImage]: TCastleImage read GetImages write SetImages; deprecated 'use ImagesPersistent[...].Image';

Warning: this symbol is deprecated: use ImagesPersistent[...].Image

Theme images, represented as TCastleImage. Although they all have sensible defaults, you can also change them at any time. Simply create TCastleImage instance (e.g. by LoadImage function) and assign it here. Be sure to adjust also OwnsImages if you want the theme to automatically free the image when it's no longer used.

The alpha channel of the image, if any, is automatically correctly used (for alpha test or alpha blending, see TDrawableImage).

Source: ui/castleuicontrols_theme.inc (line 193).

Public property ImagesPersistent[const ImageType: TThemeImage]: TCastleImagePersistent read GetImagePersistent;

Images used to draw UI controls by default.

You can adjust them e.g. to adjust how a default TCastleButton looks. Note that some controls have properties to override the "theme" look for a particular control, e.g. on a particular TCastleButton you can set TCastleButton.CustomBackground and TCastleButton.CustomBackgroundNormal.

When adjusting these images, it is simplest to assign the image URL by setting TCastleImagePersistent.URL. See https://castle-engine.io/manual_2d_user_interface.php#section_theme . Adjust also TCastleImagePersistent.ProtectedSides to use 9-slice scaling.

Source: ui/castleuicontrols_theme.inc (line 209).

Public property OwnsImages[const ImageType: TThemeImage]: boolean read GetOwnsImages write SetOwnsImages; deprecated 'use ImagesPersistent[...].OwnsImage';

Warning: this symbol is deprecated: use ImagesPersistent[...].OwnsImage

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 212).

Public property Corners[const ImageType: TThemeImage]: TVector4 read GetCorners write SetCorners; deprecated 'use ImagesPersistent[...].ProtectedSides';

Warning: this symbol is deprecated: use ImagesPersistent[...].ProtectedSides

Corners that determine how image on Images is stretched when drawing by TCastleTheme.Draw method. Together with assigning Images, adjust also this property. It is used for images rendered using TDrawableImage.Draw3x3, it determines how the image is stretched. The corners are specified as 4D vector, order like in CSS: top, right, down, left.

Source: ui/castleuicontrols_theme.inc (line 221).

Public property MessageFont: TCastleAbstractFont read FMessageFont write SetMessageFont;

Font used by dialogs. Leave Nil to use TCastleContainer.DefaultFont.

Source: ui/castleuicontrols_theme.inc (line 247).

Public property OwnsMessageFont: boolean read FOwnsMessageFont write FOwnsMessageFont default true;

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 249).

Public property LoadingTextColor: TCastleColor read LoadingColor write LoadingColor; deprecated 'use LoadingColor';

Warning: this symbol is deprecated: use LoadingColor

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 256).

Public property LoadingImageForWindowHeight: Single read LoadingUIReferenceHeight write LoadingUIReferenceHeight; deprecated 'use LoadingUIReferenceHeight';

Warning: this symbol is deprecated: use LoadingUIReferenceHeight

This item has no description.

Source: ui/castleuicontrols_theme.inc (line 259).


Generated by PasDoc 0.17.0.snapshot.