Code snippet - number of issues

Discuss GUI programming with the MUI Royale plugin here
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Code snippet - number of issues

Post by djrikki » Wed Dec 24, 2014 3:13 pm

gui.xml

Code: Select all

?xml version="1.0" encoding="iso-8859-1"?>
<application base="Listtree" id="application" singletask="true">
	<window id="MAIN" muiid="MAIN" width="screen:50" height="screen:70" notify="closerequest" open="false" title="Listtree" closegadget="true" sizegadget="true">
		<vgroup>
			<register>
				<hgroup title="\33A[21] Layout">
					<vgroup>
						<hgroup>
							<vgroup frame="group" frametitle="Layout & Structure" background="groupback">
								<listtree id="layout" notify="active;doubleclick" cyclechain="1">
									<node id="vgroup-0" name="\33P[FF0000] Default Application Window (VGROUP) \33A[100] " open="true">						
										<node id="hgroup-6" name="\33P[FF0000] HGroup 6 Window (HGROUP) \33A[72]" open="true">
											<item id="hgroup6-scale">\33A[131] Scale \33u\33P[888888](Scale)</item>
											<item id="hgroup6-checkmark1">\33A[56] Checkmark \33u\33P[888888](Checkmark)\33n : \33P[00FF00]SELECTED</item>
										</node>
									</node> 
								</listtree>
								<hgroup>
									<button id="layout-foldall" notify="pressed" hichar="e">\33A[28] Fold All</button>
									<button id="layout-unfoldall" notify="pressed" hichar="c">\33A[29] Unfold All</button>
									<button id="layout-remove-gadget" notify="pressed" hichar="r">\33A[4] Remove selected</button>
								</hgroup>
							</vgroup>
						</hgroup>
					</vgroup>
				</hgroup>
			</register>
		</vgroup>
	</window>
</application>
main.hws

Code: Select all

Const #AISSFOLDER = "tbimages:"
Const #REMOVE = 4
Const #LAYOUT = 21
Const #TREEFOLDALL = 28
Const #TREEUNFOLDALL = 29
Const #CHECKMARK = 56
Const #GAUGE = 66
Const #HGROUP = 72
Const #VGROUP = 100
Const #SCALE = 131

Global application, base
application = {}
base = {}

application.name = "Listtree"
@APPTITLE "Listree"
@APPAUTHOR "Richard Lake"
@APPCOPYRIGHT "Richard Lake"
@APPVERSION "$VER: Listtree  0.1 (24-Dec-14)"
@APPDESCRIPTION "A description"

;; base:LoadBrush(constant, folder$, alpha)
Function base:LoadBrush(constant, folder$, alpha)
    ExitOnError(False)
    If alpha = True
        LoadBrush(constant, folder$, {LoadAlpha = TRUE})
    Else
        LoadBrush(constant, folder$, {LoadAlpha = FALSE})
    EndIf

    If GetLastError() > 0 and FindStr(folder$, #AISSFOLDER) > -1
   		SystemRequest("General File/Access error","There has been a problem opening an image during run time and now " .. application.name .. " is unstable.\n\nSorry, you must restart " .. application.name .. "\n\nCannot find:\n\n" .. folder$,"Exit Application",#REQICON_WARNING)
        End()
    EndIf
    ExitOnError(True)
EndFunction

Function event_handler(msg)
    debugprint(msg.class)
    debugprint(msg.id)
    debugprint(msg.attribute)

	Switch msg.class
		;; Window
	    Case "Window"
	    	Switch msg.id
	    	    Case "MAIN"
	    	    	End()
	    	    	
	    	EndSwitch
	    
	    ;; ListTree
	    Case "Listtree"
	    	Switch msg.attribute
	    	    Case "Active"
	    	    	Switch msg.id
	    	    	    Case "layout"
	    	    	    	Local found, table = mui.DoMethod("layout", "getentry", "active", "active", "")

	    	    	    	debugprint(table.name)    			
	    	    	EndSwitch
	    	    			     	
			EndSwitch
	EndSwitch
EndFunction

base:LoadBrush(#REMOVE, #AISSFOLDER .. "remove", True)
base:LoadBrush(#CHECKMARK, #AISSFOLDER .. "gadget_checkbox", True)
base:LoadBrush(#HGROUP, #AISSFOLDER .. "gadget_layout_horizontal", True)
base:LoadBrush(#VGROUP, #AISSFOLDER .. "gadget_layout_vertical", True)
base:LoadBrush(#SCALE, #AISSFOLDER .. "resize", True)
base:LoadBrush(#LAYOUT, #AISSFOLDER .. "screen", True)
base:LoadBrush(#TREEFOLDALL, #AISSFOLDER .. "treefold", True)
base:LoadBrush(#TREEUNFOLDALL, #AISSFOLDER .. "treeunfold", True)

mui.CreateGUI( FileToString("gui.xml"))

Local object
object = {}
object.class = "Gauge"
object.icon = #GAUGE
object.id = "vgroup0-gauge1"
object.name = "Progress"
object.ckey = "p"
object.orientation = 0
object.min = "0"
object.max = "100"
object.current = 0
object.infotext = "%ld %% completed..."
object.scale = 0
object.disabled = False
object.hidden = False

InstallEventHandler({MUIRoyale = event_handler })

@DISPLAY {Width = 800, Height = 600, Borderless = False, Hidden = true, Title = "", Active = True, nomodeswitch=true, nohide=true}

mui.Set("MAIN","open",True)

ExitOnError(False)

debugprint("layout","insert","\27A[" .. object.icon .. "] " .. object.name .." \27u\27P[888888](" .. object.class .. ")\27n : \27P[00FF00] (SCALE)",object.id,"vgroup-0",mui.Get("layout","active"),"active;open")
mui.DoMethod("layout","insert","\27A[" .. object.icon .. "] " .. object.name .." \27u\27P[888888](" .. object.class .. ")\27n : \27P[00FF00] (SCALE)",object.id,"vgroup-0",mui.Get("layout","active"),"active;open")

mui.Set(object.id,"userdata",object)
Local result = mui.Get(object.id,"userdata")
debugprint( "addgauge userdata = " .. result.class )    

Repeat
    WaitEvent()
Forever
Issues:

1. Button row in HGROUP, sometimes MUI Royale misses out the loading of images into buttons. Very strange. I sometimes notice this in Jack as well.
2. Although in this example \27A[66] my listree row has an image to the left of object.name strange in my original code it does not! However, code-wise nothing changes. The brush 66 is correct.
3. mui.Set(object.id,"userdata") - Now this the line of code I am desperate to get working, but as you can see in this example it just fails returning 'Off' instead of the value sent earlier through DoMethod.

-----

http://www.lakemarketing.co.uk/jack/listree.lha - Download link

Hope you can solve this for me =) Merry christmas
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

bitRocky
Posts: 104
Joined: Fri Nov 14, 2014 6:01 pm

Re: Code snippet - number of issues

Post by bitRocky » Fri Dec 26, 2014 12:20 am

Is it intended that you insert your gauge object as a listtree node?
You should add it as a child of a group

djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Code snippet - number of issues

Post by djrikki » Sat Dec 27, 2014 3:40 pm

Its not Insertion that I am having a problem with, its being able to store Userdata and retrieve it again,
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

bitRocky
Posts: 104
Joined: Fri Nov 14, 2014 6:01 pm

Re: Code snippet - number of issues

Post by bitRocky » Sun Dec 28, 2014 3:58 pm

But MUIA_UserData is an attribute for mui objects and so can only be set/get for mui objects and a node in a listtree is not a mui object!
Or is it different in MUIRoyale?

I know its possible to embed mui objects in an entry of a list/listtree object, but then you have to create the object first.
Maybe this is done automatically in MUIRoyale... then forget what I said;)

djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Code snippet - number of issues

Post by djrikki » Sun Dec 28, 2014 5:24 pm

I wouldn't know about that. It seems I can 'Initialise' userdata, but not 'S'et it during run-time. Perhaps am wrong, waiting for Andreas to confirm either way.

If what you say is true BitRocky this will be quite a setback.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

bitRocky
Posts: 104
Joined: Fri Nov 14, 2014 6:01 pm

Re: Code snippet - number of issues

Post by bitRocky » Sun Dec 28, 2014 7:37 pm

MUIA_UserData is defined as [ISG], so it can be set at creation and during run time.

I think we misunderstood eachother at some point, to me it seemed that your gauge object with the id "vgroup0-gauge1" is inserted as an entry/node in the listtree.
But you have to create an object with mui.CreateObject() to be able to set/get MUIA_UserData.

But as I said earlier, I don't have any experience with Hollywood/MUIRoyale, I only write MUI apps in C and ecx.

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Code snippet - number of issues

Post by airsoftsoftwair » Mon Dec 29, 2014 11:46 pm

I've now had a look at this. First, you're using ExitOnError(False) before calling mui.DoMethod(). This prevents you from noticing that the call to mui.DoMethod() fails because "Off" is not a valid parameter in the penultimate argument. See here for possible values for prevnode$:
http://www.hollywood-mal.com/docs/html/ ... sert_.html

Now to the issues:
1. Button row in HGROUP, sometimes MUI Royale misses out the loading of images into buttons. Very strange. I sometimes notice this in Jack as well.
I can reproduce this behaviour but it looks like it is a MUI bug. I've verified that MUI Royale passes the string correctly to the MUI object and that the image data is correctly formatted. You should report this to the MUI developers.
2. Although in this example \27A[66] my listree row has an image to the left of object.name strange in my original code it does not! However, code-wise nothing changes. The brush 66 is correct.
Sorry, don't understand what you mean here. Please explain in more detail.
3. mui.Set(object.id,"userdata") - Now this the line of code I am desperate to get working, but as you can see in this example it just fails returning 'Off' instead of the value sent earlier through DoMethod.
Confirmed. Setting Notify.UserData doesn't currently work for items which are inserted at runtime. This needs some major changes in MUI Royale. I'll fix this for the future. This might take a little longer but you can easily work around the problem by just using a global table for storage, just do something like this as a workaround:

Code: Select all

__mui_workaround = {}

Function p_SetUserData(t$, v)
	__mui_workaround[t$] = v
EndFunction

Function p_GetUserData(t$)
	Return(__mui_workaround[t$])
EndFunction

p_SetUserData("vgroup0-gauge1", "foobar")
DebugPrint(p_GetUserData("vgroup0-gauge1"))

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Code snippet - number of issues

Post by airsoftsoftwair » Mon Dec 29, 2014 11:47 pm

bitRocky wrote:But MUIA_UserData is an attribute for mui objects and so can only be set/get for mui objects and a node in a listtree is not a mui object!
Or is it different in MUIRoyale?
Yes, it's different in MUI Royale. But as I've just pointed out, it's currently not working correctly for items inserted at runtime. But this will be fixed.

djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Code snippet - number of issues

Post by djrikki » Tue Dec 30, 2014 11:45 am

Thanks Andreas for your reply and suggestion. I guess that this current limitation also applies to ListView items. Although, this can be worked around by using hidden columns to store additional information out of view.

PS. There is a context menu right-click available on column titles is it possible to disable this behaviour in future?
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Code snippet - number of issues

Post by airsoftsoftwair » Tue Dec 30, 2014 12:19 pm

@djrikki:
Concerning the button images that are sometimes missing: I distinctly remember that there was a bug in OS4 itself that caused this but it has been fixed for OS4.1 Final Edition. Have you tried OS4.1 Final Edition and checked if it still happens with the FE? I cannot reproduce it here with OS4.1 FE on the X1000 whereas it is clearly reproducable on OS4.1 Update 5 on the Pegasos 2. So maybe it has already been fixed.... please check with OS4.1 FE if you haven't already done so and report back.

Post Reply