Class TCastleAbstractSlider
Unit
Declaration
type TCastleAbstractSlider = class(TCastleUserInterfaceFont)
Description
An abstract slider user interface. You actually want to use one of its descendants: TCastleFloatSlider or TCastleIntegerSlider.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleUserInterfaceFont
- TCastleAbstractSlider
Overview
Fields
nested const DefaultSliderWidth = 200; |
|
nested const DefaultSliderHeight = 30; |
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
Properties
property TextColor: TCastleColor read FTextColor write SetTextColor; |
|
property Width default DefaultSliderWidth; |
|
property Height default DefaultSliderHeight; |
|
property DisplayValue: boolean
read FDisplayValue write FDisplayValue default true; |
|
property Caption: String read FCaption write SetCaption; |
|
property OnChange: TNotifyEvent read FOnChange write FOnChange; |
|
property Background: TCastleImagePersistent read FBackground; |
|
property Thumb: TCastleImagePersistent read FThumb; |
|
property TextColorPersistent: TCastleColorPersistent read FTextColorPersistent ; |
Description
Fields
nested const DefaultSliderWidth = 200; |
|
This item has no description. |
nested const DefaultSliderHeight = 30; |
|
This item has no description. |
Methods
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
procedure Render; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Render. Render a control. Called only when Exists and render context is initialized. Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl. You should only override this method. See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:
Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls). |
procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Update. Control may do here anything that must be continuously repeated. E.g. camera handles here falling down due to gravity, rotating model in Examine mode, and many more.
This method may be used, among many other things, to continuously react to the fact that user pressed some key (or mouse button). For example, if holding some key should move some 3D object, you should do something like: if HandleInput then begin if Container.Pressed[keyArrowRight] then begin Transform.Position := Transform.Position + Vector3(SecondsPassed * 10, 0, 0); HandleInput := false; end; end;
Instead of directly using a key code, consider also using TInputShortcut that makes the input key nicely configurable. See engine tutorial about handling inputs. Multiplying movement by SecondsPassed makes your operation frame-rate independent. Object will move by 10 units in a second, regardless of how many FPS your game has. The code related to HandleInput is important if you write a generally-useful control that should nicely cooperate with all other controls, even when placed on top of them or under them. The correct approach is to only look at pressed keys/mouse buttons if HandleInput is Note that to handle a single press / release (like "switch light on when pressing a key") you should rather use Press and Release methods. Use this method only for continuous handling (like "holding this key makes the light brighter and brighter"). To understand why such HandleInput approach is needed, realize that the "Update" events are called differently than simple mouse and key events like "Press" and "Release". "Press" and "Release" events return whether the event was somehow "handled", and the container passes them only to the controls under the mouse (decided by TCastleUserInterface.CapturesEventsAtPosition). And as soon as some control says it "handled" the event, other controls (even if under the mouse) will not receive the event. This approach is not suitable for Update events. Some controls need to do the Update job all the time, regardless of whether the control is under the mouse and regardless of what other controls already did. So all controls (well, all controls that exist, in case of TCastleUserInterface, see TCastleUserInterface.Exists) receive Update calls. So the "handled" status is passed through HandleInput. If a control is not under the mouse, it will receive HandleInput = |
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. |
Properties
property TextColor: TCastleColor read FTextColor write SetTextColor; |
|
Color of the label. By default opaque black. |
property Width default DefaultSliderWidth; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Width. These properties determine the control size. See the EffectiveRect documentation for details how the size is calculated.
|
property Height default DefaultSliderHeight; |
|
This item has no description. |
property DisplayValue: boolean
read FDisplayValue write FDisplayValue default true; |
|
Display the current value as text on the slider, right next to the Caption. The exact method to display is defined by method TCastleFloatSlider.ValueToStr or TCastleIntegerSlider.ValueToStr (depending on descendant), so you can further customize it. |
property Caption: String read FCaption write SetCaption; |
|
Displayed on the slider. Right before value, if DisplayValue. |
property OnChange: TNotifyEvent read FOnChange write FOnChange; |
|
Called when value (like TCastleFloatSlider.Value or TCastleIntegerSlider.Value) changed because of user interaction (but not when it was changed by code setting the property). |
property Background: TCastleImagePersistent read FBackground; |
|
Background image that fills the entire slider area. |
property Thumb: TCastleImagePersistent read FThumb; |
|
|
property TextColorPersistent: TCastleColorPersistent read FTextColorPersistent ; |
|
TextColor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write TextColor directly. See also
|
Generated by PasDoc 0.16.0-snapshot.