Need someone who knows a lot about BlitzMax

BlitzMax Forums/MaxGUI Module/Need someone who knows a lot about BlitzMax

Chapman7(Posted 2011) [#1]
I need to determine which is the best method to use. Two things I need determined for the methods are 1. Which is faster 2. Which is better MemAllocation wise.

(Using MaxGUI) I created a standard Window and a Tabber with 6-7 Tabs. I was trying to determine which is the best way to manage gadgets drawn on each tab so I dont have to use HideGadget/ShowGadget for each gadget. The first method I can think of is parenting Gadgets to a panel and hiding/showing the panels when a new tab is selected. The second method is keeping track of gadgets by using TLists (Tab1List, Tab2List, etc.)

The reason I wanted to start using Lists was because when I tried panels, going back and forth made a slightly beige(almost) flash that was irritating (not only to me but to the ocd-perfectionist side of me). So I tried the lists but I was surfing around and saw some threads about code optimization and how it can significantly increase programs performance.

So I ask anyone, which would be better to use speed wise or memory wise. Using Panels as parents or TLists as parents.


JoshK(Posted 2011) [#2]
When switching panels, show the new panel first before you hide the old one.


Chapman7(Posted 2011) [#3]
Thanks Josh! Does that imply that using Panels is better than using TLists?

EDIT: (Better as in faster and better mem allocation than using TLists)

Last edited 2011


H&K(Posted 2011) [#4]
I think he might just be going on the , "If you dont show the new panel first, what ARE you going to be showing when you have already hidden the old panel"

Unless you are writing this for a 286 why not have Tlist of panels as well?


ima747(Posted 2011) [#5]
The things are going to exist regardless of how you store them, a tlist and a panel are both going to have trivial overhead from a memory perspective. Not sure processing time wise, but I would be shocked if there was a marked difference in the real world either way...

I'd say use whatever makes the most sense to you organizationally.

Last edited 2011


jsp(Posted 2011) [#6]
I would use panels if possible, it's easier to switch and easier to maintain if you want to change later some things on top.
Hiding and showing a lot of gadgets one after the other is sometimes visible by the user on slow machines while switching one panel works almost immediately.
As ima747 already wrote the overhead is trivial.


Chapman7(Posted 2011) [#7]
Well the whole reason I thought about the TLists was because of that weird flash but if as you say JSP, hiding and showing a lot of gadgets is visible by the user, I think Ill take your word on that. Having a TList of Panels aint such a bad idea either. AND showing before hiding does make more sense.

I think I can make a solid mixture from all your inputs. Thanks for the replys!


jsp(Posted 2011) [#8]
When you see a flash then may one more thing is important, don't create and show your gadgets in one go. First create them on a hidden panel (or hiddden window) and then later show that panel when needed. The creation can take again that little more time that the flash is visible.


Chapman7(Posted 2011) [#9]
I believe I am doing the same thing your saying (Heres a small example):

SuperStrict

Import MaxGUI.MaxGUI
Import MaxGUI.Drivers

Global Window:TGadget = CreateWindow("Window", 0, 0, 800, 600)
Global Tabber:TGadget = CreateTabber(0, 0, ClientWidth(Window), ClientHeight(Window), Window)
SetGadgetLayout(Tabber, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)

Global Panel1:TGadget = CreatePanel(0, 0, ClientWidth(Tabber), ClientHeight(Tabber), Tabber)
SetGadgetLayout(Panel1, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)
Global Panel2:TGadget = CreatePanel(0, 0, ClientWidth(Tabber), ClientHeight(Tabber), Tabber)
SetGadgetLayout(Panel2, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)

Global Label1:TGadget = CreateLabel("This is on Panel1", 50, 20, 200, 40, Panel1)
Global Label2:TGadget = CreateLabel("This is on Panel2", 50, 20, 200, 40, Panel2)

AddGadgetItem Tabber, "Tab1"
AddGadgetItem Tabber, "Tab2"

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_GADGETACTION
			If EventSource() = Tabber
				Select EventData()
					Case 0
						ShowGadget Panel1
						HideGadget Panel2
					Case 1
						ShowGadget Panel2
						HideGadget Panel1
				EndSelect
			EndIf
	EndSelect
Forever
End


I have a 1920x1080 monitor hooked up to my laptop so perhaps its just a result from that. When I use my regular laptop screen, it still occurs but just Barely and only noticeable if your looking for it.

Is it just something I shouldnt worry about?


jsp(Posted 2011) [#10]
Create your window hidden:
CreateWindow("Window", 0, 0, 800, 600,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE |WINDOW_STATUS |WINDOW_CLIENTCOORDS |WINDOW_HIDDEN )

and then show the window before you enter the repeat loop, thus all the creation steps are not visible.


Chapman7(Posted 2011) [#11]
Its not a flash from when everything is being created, its a flash from when I flip back and forth between the Tabs (showgadget panel#, hidegadget panel#)

Its probably not something I should be worried about but it is annoying


jsp(Posted 2011) [#12]
Ah ok. Your code runs just fine here, so it may is your monitor connection. So don't worry.


Chapman7(Posted 2011) [#13]
Very cool, thanks for all the help man!