Slower gadget & canvas resizing...

BlitzMax Forums/MaxGUI Bug Reports/Slower gadget & canvas resizing...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Oh, received your e-mail today and I see your problem...

However, there is something strange going on with the way *your* gadgets are being sized... Are you manually calling SetGadgetShape() on your panels in response to EVENT_WINDOWSIZE?

I knocked up this quick benchmark program to time each module when it is resized with 48 canvases and if anything it shows that the new MaxGUI.Win32MaxGUIEx is slightly faster. Try it for yourself...

SuperStrict

'Framework MaxGUI.Win32MaxGUI
Framework MaxGUI.Win32MaxGUIEx
Import BRL.Random
Import BRL.D3D7Max2D

Const COUNT% = 5

SeedRnd MilliSecs()

Global wndMain:TGadget = CreateWindow("Test Window", 100, 100, 400, 300, Null, WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_STATUS|WINDOW_RESIZABLE)
	
	Global canvasArray:TGadget[][]
	
	For Local x% = 0 Until ClientWidth(wndMain)/50
		canvasArray = canvasArray[..x+1]
		canvasArray[x] = New TGadget[ClientHeight(wndMain)/50]
		For Local y% = 0 Until ClientHeight(wndMain)/50
			canvasArray[x][y] = CreateCanvas(x*50,y*50,50,50,wndMain);SetGadgetLayout(canvasArray[x][y],EDGE_RELATIVE,EDGE_RELATIVE,EDGE_RELATIVE,EDGE_RELATIVE)
		Next
	Next
	
	ColourizeGadgetArray( canvasArray )
	
	PollSystem()
	
AddHook EmitEventHook, eventHook

Local tmpTotal%

For Local i% = 0 Until COUNT
	Local tmpTime% = MilliSecs()
	SetGadgetShape(wndMain, 100,100,800,600)
	PollSystem();tmpTotal:+(MilliSecs()-tmpTime)
	Print (MilliSecs()-tmpTime) + "ms";PollSystem()
	tmpTime% = MilliSecs()
	SetGadgetShape(wndMain, 100,100,400,300)
	PollSystem();tmpTotal:+(MilliSecs()-tmpTime)
	Print (MilliSecs()-tmpTime) + "ms";PollSystem()
Next

If count Then Print "Resized " + (COUNT*2) + " times, taking an average of " + (tmpTotal/(COUNT*2)) + "ms."

Repeat;WaitSystem();Forever

Function ColourizeGadgetArray( pArray:TGadget[][] )
	
	For Local tmpArray:TGadget[] = EachIn pArray
		For Local tmpGadget:TGadget = EachIn tmpArray
			RepaintCanvas(tmpGadget)
		Next
	Next
	
EndFunction

Function RepaintCanvas( pCanvas:TGadget )
	
	SetGraphics CanvasGraphics(pCanvas)
	SetViewport( 0,0,ClientWidth(pCanvas), ClientHeight(pCanvas) )
	SetClsColor( Rand(0,255), Rand(0,255), Rand(0,255))
	Cls;Flip

EndFunction


Function eventHook:Object( pID%, pData:Object, pContext:Object )
	
	Local pEvent:TEvent = TEvent(pData)
	If Not pEvent Then Return pData
	
	'SetStatusText wndMain, pEvent.ToString()
	
	Select pEvent.id
		
		Case EVENT_GADGETPAINT;RepaintCanvas( TGAdget(pEvent.source) )
		Case EVENT_APPTERMINATE, EVENT_WINDOWCLOSE;End
		
	EndSelect
	
	Return Null
	
EndFunction


Also, I know this is irrelevant, but I noticed that you are using tool windows for message boxes... Is there a reason why you aren't using the standard OS message boxes (available using the Notify(), Proceed() and Confirm() commands)? It looks a bit unexpected, that's all...

Anyway, there isn't much I can do until I learn a lot more about how you are drawing your canvases, and how you are resizing your gadgets...