I’m trying to implement redraw efficient way of doing the following:
A simple ShapeButton with couple of LED style graphics right next to it, which update when the button is pressed.
Only the button area should react to mouse clicks. Clicking on the LEDs should not do anything.
I’m implementing it like this at the moment:
LED colors (or rather their state) are set in ShapeButton.onClick() callback function. Can’t draw in the callback function since there’s no access to Graphics class.
The LED graphics are drawn in Paint() method with Graphics.fillEllipse() so they aren’t child objects of the button itself. To get the Paint() method to be called each time a button is being pressed, I call repaint() in the ShapeButton.onClick() callback, which seems to be not so good idea: the whole GUI seems to flicker now and then if I press the button repeatedly. I.e. there’s tons of redrawing happening, I believe.
What’s the best way to implement this kind of button/LED combo feature?
Should I just create a more complicated system which itself keeps track of the clicked buttons and GUI components and redraws only those? Is there a more convenient way of doing this?