Rotate TCastleFloatSlider/TCastleIntegerSlider

Hello,

Is there a way to rotate the TCastleFloatSlider/TCastleIntegerSlider from withing the editor so that it is vertical instead of horizontal ?

Thanks

Hmmm… Interesting! I don’t see any way to make it vertical (but I was sure there was)… But it shouldn’t be too hard to as far as I see. If you need it ping me, I’ll try to implement it.

Hi,

If your up for it that would be great !

Also, is it possible to use pictures for the sliders track and thumb ? It does not look like I can from the editor ( which would be great ) but would I be able to from the code ?

Thanks

Yes, but indeed it requires to use code. All sliders use the same “theme images” (see https://castle-engine.io/apidoc-unstable/html/CastleControls.TCastleTheme.html#ImagesPersistent), namely these two images are tiSlider and tiSliderPosition (see Castle Game Engine: CastleControls).

You should do something like:

Theme.ImagesPersistent[tiSlider].Url := 'castle-data:/slider-image.png';
Theme.ImagesPersistent[tiSliderPosition].Url := 'castle-data:/slider-position-image.png';

EDIT: Fixed the code, sorry I’m tired and sleepy :smiley:

@michalis WDYT about vertical sliders and assignable images for them in Castle Editor? I think I can do that, not sure how quickly though.

Thank you very much, I don’t mind using the code. Its just nice doing it in the editor well brainstorming the ui.

I will read thru all the documentation and go from there.

Thanks !

I’m cool with it, go for it. Similar to how one can adjust now images for TCastleButton.

So I would add to TCastleAbstractSlider properties like

SliderImage: TCastleImagePersistent
SliderPositionImage: TCastleImagePersistent

, make them subcomponents (that is create in constructor, but they will not have any content loaded initially so SliderImage.Empty will be true), and use instead of theme images when they are not empty, like

if SliderImage.Empty then
  Theme.Draw(RenderRect, tiSlider, UIScale)
else
begin
    // Temporarily disable OnChange, since below we change image
    SliderImage.OnChange := nil;
    SliderImage.ScaleCorners := UIScale;
    SliderImage.Draw(RenderRect);
    SliderImage.OnChange := @SliderImageChanged;
end;

See how TCastleButton and TCastleImageControl use their TCastleImagePersistent instances.

Note: In the future I would also like to have Theme images visually adjustable in the editor. But I’m still thinking how to do it in the easiest way possible (new approach to CastleSettings.castle-component may open the door to this). But, regardless of it, it will remain valid idea to adjust images per-component, so a properties like above SliderImage in each slider instance will also make sense.