Class TCastleFloatSlider

Unit

Declaration

type TCastleFloatSlider = class(TCastleAbstractSlider)

Description

Slider to change a float value within a given range.

Hierarchy

Overview

Fields

Public nested const DefaultMin = 0.0;
Public nested const DefaultMax = 1.0;

Methods

Public constructor Create(AOwner: TComponent); overload; override;
Public constructor Create(AOwner: TComponent; const ValuePointer: PSingle; const AMin, AMax: Single; const AOnChange: TNotifyEvent); reintroduce; overload;
Public procedure Render; override;
Public function Press(const Event: TInputPressRelease): boolean; override;
Public function Motion(const Event: TInputMotion): boolean; override;
Public function ValueToStr(const AValue: Single): string; virtual;
Public function RoundAndClamp(const AValue: Single): Single;
Public function PropertySections(const PropertyName: String): TPropertySections; override;

Properties

Published property Min: Single read FMin write SetMin default DefaultMin;
Published property Max: Single read FMax write SetMax default DefaultMax;
Published property Value: Single read FValue write SetValue default DefaultMin;
Published property MultipleOf: Single read FMultipleOf write FMultipleOf;

Description

Fields

Public nested const DefaultMin = 0.0;

This item has no description.

Public nested const DefaultMax = 1.0;

This item has no description.

Methods

Public constructor Create(AOwner: TComponent); overload; override;

This item has no description.

Public constructor Create(AOwner: TComponent; const ValuePointer: PSingle; const AMin, AMax: Single; const AOnChange: TNotifyEvent); reintroduce; overload;

An easy way to construct float slider.

Public procedure Render; override;

This item has no description. Showing description inherited from TCastleUserInterface.Render.

Render a control. Called only when Exists and GLInitialized, you can depend on it in the implementation of this method.

Do not explicitly call this method. Instead, render controls by adding them to the TCastleContainer.Controls list, or render them explicitly (for off-screen rendering) by TCastleContainer.RenderControl. This is method should only be overridden in your own code.

Before calling this method we always set some OpenGL state, and you can depend on it (and you can carelessly change it, as it will be reset again before rendering other control).

OpenGL state always set:

  • Viewport is set to include whole container.

  • Depth test is off.

  • (For fixed-function pipeline:) The 2D orthographic projection is always set at the beginning. Useful for 2D controls, 3D controls can just override projection matrix, e.g. use CastleRenderContext.PerspectiveProjection.

  • (For fixed-function pipeline:) The modelview matrix is set to identity. The matrix mode is always modelview.

  • (For fixed-function pipeline:) The raster position is set to (0,0). The (deprecated) WindowPos is also set to (0,0).

  • (For fixed-function pipeline:) Texturing, lighting, fog is off.

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 of course do it already, this is only a concern if you make direct OpenGL / OpenGLES calls).

Public function Press(const Event: TInputPressRelease): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Press.

Handle press or release of a key, mouse button or mouse wheel. Return True if the event was somehow handled, which prevents from passing this event to other UI controls.

When implementing in descendants it is best to override it like this:

function TMyControl.Press(const Event: TInputPressRelease): boolean;
begin
  Result := inherited;
  if Result then Exit; // exit if ancestor already handled this event

  if Event.IsKey(keyEnter) then
  begin
    // do something in reaction to Enter key
    ...
    // let engine know that this input event was handled
    Exit(true);
  end;

  if Event.IsMouseButton(buttonLeft) then
  begin
    // do something in reaction to left mouse button press
    ...
    // let engine know that this input event was handled
    Exit(true);
  end;
end;

These events are generated for all UI controls, whether they are considered "interactive" or not. These events are generated for non-interactive controls like TCastleRectangleControl or TCastleLabel as well. For example, these events ignore the TCastleButton.Enabled state, they are generated always (see https://github.com/castle-engine/castle-engine/issues/413 ). Use instead TCastleButton.OnClick to detect clicks on a button in a way that honors the TCastleButton.Enabled state.

When a control returns True from Press, it means it starts to "capture" subsequent mouse events: subsequent mouse moves and release will be send to this control even if mouse will move outside of this control.

The events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. In partcular, overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.RenderOverChildren.

The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.Render, which is the standard place you should draw stuff. For example our TCastleButton draws there.

Note that releasing of the mouse wheel is not reported now by any backend. Only releasing of keys and mouse buttons is reported.

Public function Motion(const Event: TInputMotion): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Motion.

Motion of mouse or touch.

Public function ValueToStr(const AValue: Single): string; virtual;

This item has no description.

Public function RoundAndClamp(const AValue: Single): Single;

Round to multiple of MultipleOf, if non-zero, and clamp to Min and Max range.

Public 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

Published property Min: Single read FMin write SetMin default DefaultMin;

This item has no description.

Published property Max: Single read FMax write SetMax default DefaultMax;

This item has no description.

Published property Value: Single read FValue write SetValue default DefaultMin;

Current value. Usually within Min and Max range, although the general code should be ready for handle any value here (to work even during changes to Min and Max properties).

Published property MultipleOf: Single read FMultipleOf write FMultipleOf;

If non-zero, we force the value selected by user to be a multiple of this value (clamped to Min, Max range). For example, if you set this to 0.25, and slider is between 0..1, then when user clicks around 0.3 — we will pick 0.25. It user clicks around 0.4 — we will pick 0.5.

This only affects values selected by user interactions (clicking, dragging). This does not process the values you set by code to Value property, though you can use RoundAndClamp method on your values yourself.


Generated by PasDoc 0.16.0.