[CODE] Slider+Value (or Edit) and Check, custom classes

Crystal Hammer

21-08-2014 20:48:24

So this is probably the final evolution of my custom code.
(For reference, the older float value slider class is there: viewtopic.php?f=17&t=29445)

What is it allows you to do:

  1. Shorten the Gui initialization code (a lot) when you have plenty of:
    1. sliders with value text (bound to some float, by pointer)[/*]
    2. sliders with editbox (both change the value and update itself)[/*]
    3. checkboxes (bound to some bool)[/*][/list:u][/*]
    4. Add an event when the value changed, and run your code after[/*]
    5. Easily change the pointer later[/*]
    6. Update slider (value and edit too) if you changed the value yourself (just 1 call)[/*]
    7. Simply change the TextBox to EditBox (just in .layout) if you want to also be able to edit the value, not only show it[/*]
    8. Use power exponent for slider value (default is 1)[/*]
    9. RMB on slider resets to default value, set earlier by a method (or default 0.5)[/*]
    10. Plenty formatting options for value
      1. Specify how many digits after dot and how many in total (for float)[/*]
      2. You can add suffix after value, and use scale for the value displayed[/*]
      3. Use string map if you want to show strings not integer values[/*]

        For more info see the comments in example use code in _Options.cpp (with _Options.layout) and in SliderValue.h.
        Probably only <Resource type="ResourceLayout" name="Slider" version="3.2.0"> is needed in templates but I inluded the whole skin.

        Example screenshot from editor using those.
        Scale has both editbox and slider rest are just sliders and value text.
        This also shows the use for pointer change. We have max 6 layers, and on changing layer (click on tab or key press) the slider's pointer change to those float values from other layer, and they get updated on Gui.

        Here, a bit covered but the bottom sliders also have edits.