Many GadgetPaint Events when resize window.

BlitzMax Forums/MaxGUI Module/Many GadgetPaint Events when resize window.

Zeke(Posted 2010) [#1]
is this normal:
SuperStrict

Import MaxGui.Drivers

Local window:TGadget=CreateWindow("My Canvas",0,0,320,240,Null,WINDOW_CENTER|WINDOW_RESIZABLE|WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS)

Local canvas:TGadget=CreateCanvas(0,0,320,240,window)

While WaitEvent()
	Print CurrentEvent.tostring()
	
	Select EventID()
		Case EVENT_WINDOWCLOSE
			FreeGadget canvas
			End
		Case EVENT_APPTERMINATE
			End
	End Select
Wend


and when i resize window once, output is:


hmm.. when you change window size only 1 pixel you get only one Gadgetpaint event. 2 pixels, 2 gpaint events, 3 pixels 3 gpaint events.....


Brucey(Posted 2010) [#2]
Yes, that seems quite normal. The window is marked for a redraw because the size was changed.


Zeke(Posted 2010) [#3]
hmm.. oh, now i see this to be normal.. but problem is, when i draw a lots of things to canvas, and then if i resize window... it takes couple of seconds to do all those gadgetpaints...

like this example:

i only want ONE gadgetpaint....

OK! Now i got it. Just dont use event_gadgetpaint. Make a function render() and put all code to there. and call render function when i need to redraw canvas.

but... without eventhooks all those gadgetpaint events are pointless.. because they are are fired WHEN window resizing is done.. so only one gadgetpaint event is needed?

because if i have lots of:
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
^^ those all do same as only one gadgetpaint...

This ^^ example show what i mean.. change window size for some time.. and do LARGE SIZE CHANGES... then release button.. and watch this cool animation. :D heh


sebas76(Posted 2010) [#4]
Hello Zeke,

I have a similar problem... Redraw of canvas is a lot slower since bmax 1.26 when resizing a window. For my appn I need a realtime redrawing of the canavs during resizing (Eventhook is used)
I have tried your example and yes it is not normal that gadgetpaint event is sent many time for only one resizing !
I hope a solution will be found one day...