Kanzi  3.9.7
Kanzi Engine API
kanzi::Slider2D Class Reference

Use the Slider 2D node as a building block for a 2D UI control that lets the application user change a numerical value using a visual indicator between a minimum and a maximum value. More...

#include <kanzi/ui/node/slider2d.hpp>

Inheritance diagram for kanzi::Slider2D:
[legend]

Public Types

typedef Slider2DConceptImplType ConceptClass
 Slider concept implementation, defining the base class (Component) and presenter (TrajectoryLayout2D). More...
 
typedef Slider2DPresenterType PresenterClass
 
- Public Types inherited from kanzi::Slider2DConceptImpl< TBaseClass, TPresenterClass, TDerivedClass >
typedef TPresenterClass PresenterClass
 
typedef shared_ptr< TPresenterClass > PresenterSharedPtr
 

Static Public Member Functions

static Slider2DSharedPtr create (Domain *domain, string_view name)
 Creates a Slider3D node. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 
- Static Public Member Functions inherited from kanzi::Slider2DConceptImpl< TBaseClass, TPresenterClass, TDerivedClass >
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 
- Static Public Member Functions inherited from kanzi::SliderConcept
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 

Protected Member Functions

 Slider2D (Domain *domain, string_view name)
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::Slider2DConceptImpl< TBaseClass, TPresenterClass, TDerivedClass >
void arrangeOverride (Vector2 actualSize) override
 Node2D::arrangeOverride() implementation. More...
 
void findLayout ()
 
Vector2 measureOverride (Vector2 availableSize) override
 Node2D::measureOverride() implementation. More...
 
void onAttached () override
 

Additional Inherited Members

- Public Member Functions inherited from kanzi::Slider2DConceptImpl< TBaseClass, TPresenterClass, TDerivedClass >
float getMaxDistanceFromCurve () const
 Gets the value of MaxDistanceFromCurveProperty. More...
 
const PresenterSharedPtrgetPresenter () const
 
void hitPointChanged ()
 
void initialize ()
 
void setMaxDistanceFromCurve (float value)
 Sets the value of MaxDistanceFromCurveProperty. More...
 
 Slider2DConceptImpl (Domain *domain, string_view name)
 
- Static Public Attributes inherited from kanzi::SliderConcept
static PropertyType< float > MaxDistanceFromCurveProperty
 MaxDistanceFromCurve property. More...
 

Detailed Description

Use the Slider 2D node as a building block for a 2D UI control that lets the application user change a numerical value using a visual indicator between a minimum and a maximum value.

To disable a Slider 2D node, set the Node::EnabledProperty to false. A disabled Slider 2D does not respond to input. To visually indicate the disabled state of a Slider 2D node, create a state manager and use the Node::EffectivelyEnabledProperty as its controller property. When Kanzi disables a Slider 2D node, it cancels current gestures and preserves the slider value.

Examples

To create a Slider 2D node with a custom appearance:

// Create a Slider 2D node named Custom 2D slider.
Slider2DSharedPtr slider = Slider2D::create(domain, "Custom 2D slider");
// Set the size of the Slider 2D node to be 400 pixels wide and 200 pixels high.
slider->setSize(400.0f, 200.0f);
// Use the Trajectory Layout 2D node to define the rail along which the knob of the slider moves.
// Create a Trajectory Layout 2D node named Slider rail.
TrajectoryLayout2DSharedPtr trajectoryLayout = TrajectoryLayout2D::create(domain, "Slider rail");
// Use the Image node to define the look of the knob that moves on the slider rail.
// Create an Image node named Slider knob.
Image2DSharedPtr knob = Image2D::create(domain, "Slider knob");
// Set the Image node to be the child of the trajectoryLayout Trajectory Layout 2D node.
trajectoryLayout->addChild(knob);
// Create an alias pointing to the Trajectory Layout 2D node that defines the slider rail.
ResourceID alias("$layout");
string path("obj:///" + trajectoryLayout->getName());
// Add the alias to the resource dictionary of the Slider 2D node.
slider->addResource(alias, path);
// Add the layout as a child node of the Slider 2D node.
// You can place the Trajectory Layout 2D node that defines the rail anywhere
// in the node tree and it does not have to be the direct child of the Slider 2D node.
slider->addChild(trajectoryLayout);
// Create the trajectory of the Trajectory Layout 2D node that is used as the rail of the Slider 2D node.
// Create a line trajectory on the x axis, that is 350 pixels long, and name it Line trajectory.
TrajectorySharedPtr trajectory = Trajectory::createLine(Vector3(), Vector3(1.0f, 0.0f, 0.0f), 350.0f, domain, "Line trajectory");
// Set the Trajectory Layout 2D node to use the line trajectory.
trajectoryLayout->setTrajectory(trajectory);
// Set the Trajectory Layout 2D node so that it sets its size
// based on the size of its parent node (in this case the Slider 2D node).
trajectoryLayout->setHorizontalAlignment(Node::HorizontalAlignmentStretch);
trajectoryLayout->setVerticalAlignment(Node::VerticalAlignmentStretch);
// The knob movement on the rail is based on modifying the TrajectoryLayout2D::StaticTrajectoryOffsetProperty
// which is set based on the Slider2D::ValueProperty.
// "../.." is the path from the knob (Image node) to the Slider 2D node.
AbstractBindingSharedPtr binding = Binding::create("../..", Slider2D::ValueProperty, PropertyFieldWhole);
// Add the Slider 2D node to the Viewport 2D node.
viewportNode->addChild(slider);
// Get the knob instance from the instance of the prefab template.
Node2DSharedPtr knobInstance = slider->getPresenter()->getLayout()->getChild(0);
// Set to the knob the binding that enables the knob to move on the rail.

Member Typedef Documentation

Slider concept implementation, defining the base class (Component) and presenter (TrajectoryLayout2D).

Constructor & Destructor Documentation

kanzi::Slider2D::Slider2D ( Domain domain,
string_view  name 
)
explicitprotected

Constructor.

Parameters
domainThe UI domain the new node belongs to.
nameThe name of the node.

Member Function Documentation

static Slider2DSharedPtr kanzi::Slider2D::create ( Domain domain,
string_view  name 
)
static

Creates a Slider3D node.

Parameters
domainThe UI domain the new node belongs to.
nameThe name of the stack layout.
static PropertyTypeEditorInfoSharedPtr kanzi::Slider2D::makeEditorInfo ( )
static

The documentation for this class was generated from the following file: