Combine two Drawables


I have two Drawables (DrawableComposites) that contain the "on" and "off" LED-chains for metering.

Preferably the Drawables are added to the parent component.

How can I cut one or both Drawables so that partly the "off" and partly the "on" LED-chain are shown?




If you drew them with Drawable::draw rather than adding them as components, then you could clip them with Graphics::reduceClipRect

thanks, Jules,

Befor applying reduceClipRect I was making sure the "ON" LED-chain can be drawn over "OFF":


I am using a DrawableComposite filled with the OFF state drawables (as background), I override its

void paintOverChildren (juce::Graphics & g) override {
  on->draw (g, 1.);

to draw my foreground (on = DrawableComposite with the ON state drawable).

I would now assume that ON is painted. - But only the background OFF is seen.


(I have verified that my ON drawable works, if I add it to the "OFF"-parent as Component its displayed correctly)

Another test I did 

void paintOverChildren (juce::Graphics & g) override {
  on->draw (g, 1.);
  g.drawRect (on->getX(), on->getY(), on->getWidth(), on->getHeight());

which draws the rectangle, so the coordinates should be OK. I even

on->setVisible (true)


And now I am clueless,

what else could I check...?





the Drawables itself are extracted from a sub Component created from an svg.

Could it be that there are different undelaying coordinate systems for the Components - so "ON" is outside the Drawable region of the background "OFF" Component?

How could I verify/correct that?




There is a Drawable::drawWithin that should fit it within the space you want. That'll at least show whether it's drawing off-screen.