Custom slider clipping issue



My problem is somehow similar to another posted here:

I Need to do custom slider which is supposed to look like this one:[attachment=0]whatiwanttoget.png[/attachment]

I’m trying to do that by nesting slider inside a component, because in normal slider entire horizontal space is taken as “work area”

That pointer is drawn using this code:

  Path p;
  p.addTriangle (1.f, 0.5f, triangleSide - 1, 0.5f, triangleSide / 2.f, triangleSide);
  AffineTransform tr;
  tr = tr.translated ( 0., cntrdY + 0);
  p.applyTransform (tr);
  g.setColour (Colours::white);
  g.fillPath (p);

  g.setColour (Colours::black);
  g.strokePath (p, 1.f);

however when I change

side of the pointer is clipped on min and max position.

what else might be relevant…

  class MySlider : public Slider
    MySlider() : Slider (LinearHorizontal, NoTextBox) 
      setRange (-1.f, 1.f);

    ~MySlider() {}

    virtual void paint (Graphics& g) 
       g.fillAll (Colour (0x40000088));

my question is … should I do that by LookAndFeel somehow or my attempt is good but there is an issue I’m not aware.
I’ve tried to use stuff like toBack, setPaintingIsUnclipped etc, changing from paint to paintOverChildren but nothing worked as I expected.
Maybe there is just some way to limit slider’s “working area” ?


You should be doing this with a custom lookandfeel - that’s exactly the kind of thing it’s designed for. I’m sure it’d be possible to bodge something together in the way you’re doing it, but it’s not ideal.


thanks for suggestion.

but… how to actually set up these margins on left and right?
Especially asking because programmer who ordered me this task didn’t find way to do that by just altering look’n’feel…


Sorry, I don’t understand what you mean about margins? You can draw whatever you like in the slider, so can leave whatever margins you want.


Thank you for int, I finally managed to do everything using LaF.