ListTree looking for a solution

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

Re: ListTree looking for a solution

Post by djrikki »

I can't follow your code in C, doesn't help that a lot of your variables are just two letters and I am meant to guess what they mean. Are you able to comment it or better still write it in psuedocode?
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListTree looking for a solution

Post by airsoftsoftwair »

@djrikki:
This is really simple. You know you've arrived at the end of a branch when Listtree.GetEntry() returns FALSE. As soon as Listtree.GetEntry() returns FALSE, you just have to look at the last element you've successfully obtained from it and then you know that this must be the last element in this branch.

@bitRocky:
Do I spy another GUI designer for MUI Royale here? :)
bitRocky
Posts: 120
Joined: Fri Nov 14, 2014 6:01 pm

Re: ListTree looking for a solution

Post by bitRocky »

Because I don't know how to edit my post, I quoted it and appended some comments.
bitRocky wrote:Hi,

here is a C source code, I hope you can make some use of it:

Code: Select all

// this function prints the name of a class, if "end" is true, it preceeds with a "/" to mark the end of a class
printCID(long i, enum CLASSID cid, BOOL end) {
	long j;

	for(j=1; j <= i; j++) {bug("  "); }
	bug("%s%s\n", end ? "/" : "", CLASSIDStr[cid]);
}
...
	DEC_QUICK(MM_WinMain_Test)
	{
		GETDATA;
		//struct MP_ *m = (APTR)msg;
		Object			*lt = data->ltMenu; // the listtree object
		structTN			*tn = NULL; // the current treenode
                structTN                    *hd = NULL; // the head/first node of a listnode
                structTN                    *tnP = NULL; // the parent treenode
                structTN                    *ln = NULL; // the listnode
                structTN                    *pn = NULL; // another parent node
		struct MenuEntry	*entry; // my user data of a treenode
		long				i=0; // the indent level

		Bug("DumpTree\n");
		tn = LT_Head(lt, NULL); // get the head of the listtree
		while (tn)
		{
			entry = tn->tn_User; // get my userdata
			if (entry) {
				printCID(i, entry->cid, FALSE); // print the class name
				if (LT_IsListNode(tn)){ // if its a listnode, increment the indentation level
					i++;
				}
			}
			tnP = tn; hd = 1; // remember parent node, and set "head" to some value not NULL
			if (LT_IsListNode(tn) && (hd = LT_Head(lt, tn))){ // if current node is a listnode, get the head of it
				tn = hd; // set the current node "tn" to the head
			}else{ // current treenode is an empty listnode or a treenode
				if (!hd){ // if it was an empty listnode, print the end marker of the class
					i--;
					printCID(i, entry->cid, TRUE);
				}
				tn = LT_NextSame(lt, tn); // get the next treenode with the same level!
				while (!tn) {// while there is no treenode with the same level, find the next treenode of its parent node
					i--;
					pn = LT_Parent(lt, tnP);
					if (pn){
						entry = pn->tn_User;
						printCID(i, entry->cid, TRUE); // print the classname with an end marker
						tn = LT_NextSame(lt, pn); tnP = pn;
					}else{
						break;
					}
				}
			}
/* This part is obsolete, the while loop above does the job
			if (!tn) { 
				while( (pn = LT_Parent(lt, tnP)) && !(tn = LT_NextSame(lt, pn)) )
					{ tnP = pn; };
			}
*/
		}// while	
		return 0;
	}
And this is the output:

Code: Select all

 Application
   Window
     Button
     Checkmark
     Gauge
     HGroup
       HGroup
         Cycle
         HGroup
           HGroup
             Listtree
               Image
             /Listtree
           /HGroup
         /HGroup
       /HGroup
       Coloradjust
     /HGroup
   /Window
   Window
   /Window
 /Application
And this is the tree:
Image
airsoftsoftwair wrote:@bitRocky:
Do I spy another GUI designer for MUI Royale here? :)
My designer was the first;)
I created the thread where I asked if there will be a MUIDesigner for Hollywood, but then djrikki came up with its colorfull and more advanced version and I lost a bit of motivation...
Also he seems to create a full blown AppDesigner for Hollywood!

But I think I will continue and maybe create a universal MUIDesigner not only for Hollywood...
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListTree looking for a solution

Post by djrikki »

Prior to seeking a solution to this I was using the recursive function to store elements of the layout in an array for later saving to disc then had another section of code that would traverse this array to produce the layout. After many seemingly wasted hours over the weekend I came to the conclusion that I would have to re-write this section of code entirely.
So now I have one recursive function that does both operations at the same time prepares an array for later saving to disc and produces a layout, thankfully with your help I now have what I come to call Container Groups successively ending with a '</' throughout the layout, thank you.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListTree looking for a solution

Post by airsoftsoftwair »

I created the thread where I asked if there will be a MUIDesigner for Hollywood, but then djrikki came up with its colorfull and more advanced version and I lost a bit of motivation...
Also he seems to create a full blown AppDesigner for Hollywood!

But I think I will continue and maybe create a universal MUIDesigner not only for Hollywood...
Yeah, don't let yourself be discouraged. Just release it and let the users decide which one they prefer....
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListTree looking for a solution

Post by djrikki »

@bitrocky

Besides I am some time away from a release date, waiting on Andreas to add <item> userdata functionality during runtime. I would be interested to know in broad terms how much longer this may be.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListTree looking for a solution

Post by djrikki »

Look... nearly working... Just need to work out why a bunch of close tags are missing from the end, then and only then will the ; comments be removed

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<APPLICATION Base="ApplicationName" ID="application" SingleTask="true"  icon="SYS:Prefs/Env-Archive/Sys/def_mui">
	<MENUSTRIP ID="application-menu">
		<MENU Title="Application Name">
			<Item ID="application-about" Shortcut="J" Notify="selected">About Application Name...</Item>
			<Item/>
			<Item ID="application-aboutmui" Shortcut="M" Notify="selected">About MUI...</item>
			<Item ID="application-aboutmuiroyale" Shortcut="R" Notify="selected">About MUI Royale...</Item>
			<Item/>
			<Item ID="application-mui" Notify="selected">MUI Settings...</Item>
			<item/>
			<MENU Title="Application Name">
				<Item id="application-www" Notify="selected" Userdata="http://">Application Name website</Item>
				<Item id="application-bugreport" Notify="selected" Userdata="http://bugs.os4depot.net/">Send Bug Report</Item>
				<Item id="application-email" Notify="selected" Userdata="info@example.com">Get in Touch</Item>
				<Item id="application-facebook" Notify="selected" Userdata="https://www.facebook.com/yourpage">Like us on Facebook</Item>
				<Item id="application-twitter" Notify="selected" Userdata="http://www.twitter.com/youraccount">Follow on Twitter</Item>
			</MENU>
			<Item id="application-quit" notify="selected">Quit...</Item>
		</MENU>
	</MENUSTRIP>
	<MENUSTRIP id="application-ccp">
		<MENU Title="Text Options">
			<Item ID="text-cut" Shortcut="X" Notify="selected">[997] Cut</Item>
			<Item ID="text-copy" Shortcut="C" Notify="selected">[998] Copy</Item>
			<Item ID="text-paste" Shortcut="V" Notify="selected">[999] Paste</Item>
		</MENU>
	</MENUSTRIP>
	<WINDOW ID="MAIN" MENUSTRIP="" MuiID="MAIN" Width="Screen:100" Height=":100" Notify="Activate;CloseRequest;MouseObject" open="true" Title="Default Application Window" Borderless="false" CloseGadget="true" DepthGadget="true"  SizeGadget="true"  AppWindow="false" NeedsMouseObject="True" >
		<VGROUP ID="win0-vgroup0" Frame="group" FrameTitle="frame-title" Background="Groupback">
			<REGISTER ID=" win0-register0"  Notify="ActivePage" >
				<VGROUP ID="win0-vgroup1" Frame="group" FrameTitle="frame-title" Background="Groupback">
					<LISTVIEW ID="win0-vgroup1-listview-0" Weight="100"  Hidden="true"  Notify="ClickColumn;DoubleClick;"  AdjustWidth="true"  AdjustHeight="true"  AutoVisible="true"  MultiSelect="default"  MinLineHeight="20"  ScrollerPos="right" />
						<Column Title="Name">
 							<Item>Richard Lake</Item>
							<Item>Laura Campbell</Item>
						</Column>
						<Column Title="Age">
 							<Item>38</Item>
							<Item>29</Item>
						</Column>
					</LISTVIEW>
					<HGROUP ID="win0-hgroup0" Frame="group" FrameTitle="frame-title" Background="Groupback">
						<LABEL ID="win0-colour-0" ControlChar="l"  Hidden="true"  Centered="true"  DoubleFrame="true"  LeftAligned="true"  Font="Normal" >Select a Label</LABEL>
						<COLORADJUST ID="win0-colour-1" ShortHelp="shorthelp-coloradjust"  HelpNode="coloradjust-node"  Weight="100"  Disabled="true"  Hidden="true"  Notify="Rgb" Rgb="$FF00FF" />
					</HGROUP> ; win0-hgroup0
					<VGROUP ID="win0-vgroup2" Frame="group" FrameTitle="frame-title" Background="Groupback">
						<RADIO ID="win0-othertab-0" ShortHelp="shorthelp-text"  HelpNode="radio-node"  Weight="100"  ControlChar="r"  Disabled="true"  Hidden="true"  Notify="Active" Active="2" />
							<Item>Red</Item>
							<Item>Green</Item>
							<Item>Blue</Item>
						</RADIO>
						<HOLLYWOOD ID="win0-othertab-1" Weight="100"  MinWidth="100"  MaxWidth="1000"  MinHeight="100"  MaxHeight="1000" />
					</VGROUP> ; win0-vgroup2
					<HGROUP ID="win0-hgroup1" Frame="group" FrameTitle="frame-title" Background="Groupback">
						<BUTTON ID="win0-hgroup1-button1" ShortHelp="shorthelp-text"  HelpNode="button-node"  Weight="100"  ControlChar="b"  Disabled="true"  Hidden="true"  Label="Action"  HiChar="b"  Notify="Pressed;Selected" Toggle="true" />
						<TEXT ID="win0-hgroup1-text4" Hidden="true"  HiChar="t"  Preparse="preparse-text" >This is some text</TEXT>
						<HGROUP ID="win0-hgroup2" Frame="group" FrameTitle="frame-title" Background="Groupback">
							<STRING ID="win0-hgroup2-string1" ShortHelp="shorthelp-string"  HelpNode="string-node"  Weight="100"  ControlChar="s"  Disabled="true"  Hidden="true"  Notify="Acknowledge;Contents;ContextMenuTrigger" Contents="this is a string"  Maxlen="80"  Accept="accept"  Reject="reject"  Secret="true"  AdvanceOnCR="true" />
							<POPLIST ID="win0-hgroup2-poplist1" ShortHelp="shorthelp-poplist"  HelpNode="poplist-node"  Weight="100"  ControlChar="l"  Disabled="true"  Hidden="true"  Notify="Acknowledge;Contents;ContextMenuTrigger" Contents="Apple" />
								<Item>Apple</Item>
							</POPLIST>
							<POPDRAWER ID="win0-hgroup2-popdrawer1" ShortHelp="shorthelp-popdrawer"  HelpNode="popdrawer-node"  Weight="100"  ControlChar="d"  Disabled="true"  Hidden="true"  Notify="Acknowledge;Contents;ContextMenuTrigger" Title="PopDrawer"  Contents="PROGDIR:"  SaveMode="true" />
							<POPFILE ID="win0-hgroup2-popfile1" ShortHelp="shorthelp-popfile"  HelpNode="popfile-node"  Weight="100"  ControlChar="f"  Disabled="true"  Hidden="true"  Notify="Acknowledge;Contents;ContextMenuTrigger" Contents="defaultvalue"  RejectPattern="#?.accepted"  RejectPattern="#?.test"  SaveMode="true"  RejectIcons="true"  ShowPattern="true" />
							<HGROUP ID="win0-hgroup3" Frame="group" FrameTitle="frame-title" Background="Groupback">
								<TEXTEDITOR ID="win0-hgroup3-texteditor1" ShortHelp="shorthelp-texteditor"  HelpNode="texteditor-node"  Weight="100"  ControlChar="t"  Disabled="true"  Hidden="true"  Notify="AreaMarked;ContextMenuTrigger;CursorX;CursorY;HasChanged;Pen;RedoAvailable;StyleBold;StyleItalic;StyleUnderline;UndoAvailable" Contents="This is some text"  Columns="80"  Rows="40"  FixedFont="true"  ReadOnly="true"  ScrollBars="true"  FixedFont="hardwrap"  WrapWords="true"  ConvertTabs="true" />
								<POPPEN ID="win0-hgroup3-poppen1" ShortHelp="shorthelp-poppen"  HelpNode="poppen-node"  Weight="100"  Disabled="true"  Hidden="true"  Notify="Rgb" Title="Select a Pen"  Rgb="$FF00FF" />
								<HGROUP ID="win0-hgroup4" Frame="group" FrameTitle="frame-title" Background="Groupback">
									<VGROUP ID="win0-vgroup3" Frame="group" FrameTitle="frame-title" Background="Groupback">
										<SLIDER ID="win0-vgroup3-slider1" ShortHelp="shorthelp-slider"  HelpNode="slider-node"  Weight="100"  ControlChar="s"  Disabled="true"  Hidden="true"  Horiz="true"  Level="65"  Min="50"  Max="75"  Format="%ld"  Quiet="true"  Reverse="true"  Notify="Stringify" Stringify="MyFunction" />
										<IMAGE ID="win0-vgroup3-image1" ShortHelp="shorthelp-image"  HelpNode="image-node"  Weight="100"  Source="brush:100" />
										<HGROUP ID="win0-hgroup5" Frame="group" FrameTitle="frame-title" Background="Groupback">
											<CYCLE ID="win0-hgroup5-cycle1" ShortHelp="shorthelp-text"  HelpNode="cycle-node"  Weight="100"  ControlChar="c"  Disabled="true"  Hidden="true"  Notify="Active" Active="0" />
												<Item>Red</Item>
												<Item>Yellow</Item>
												<Item>Pink</Item>
												<Item>Green</Item>
											</CYCLE>
										</HGROUP> ; win0-hgroup5
									</VGROUP> ; win0-vgroup3
									<HGROUP ID="win0-hgroup6" Frame="group" FrameTitle="frame-title" Background="Groupback">
										<FLOATTEXT ID="win0-hgroup6-floattext1" Hidden="true"  Justify="true"  Font="Normal" >This is some floattext</FLOATTEXT>
										<POPFONT ID="win0-hgroup6-popfont1" Weight="100"  ControlChar="f"  Disabled="true"  Hidden="true"  Notify="Acknowledge;Contents;ContextMenuTrigger" Title="Select a Font..."  Contents="topaz/8"  MinHeight="5"  MaxHeight="32"  FixedWidthOnly="true" />
										<RECTANGLE ID="win0-hgroup6-rectangle" BarTitle="rectangle-test"  Hbar="true" />
										<GAUGE ID="win0-hgroup6-gauge" Weight="100"  Hidden="true"  Notify="Current" Horiz="false"  Current="75"  Min="50"  Max="100"  InfoText="%ld %% completed..." />
										<SCALE/>
										<CHECKMARK ID="win0-hgroup6-checkmark1" ShortHelp="shorthelp-text"  HelpNode="checkmark-node"  Weight="100"  Disabled="true"  Hidden="true"  Notify="Selected" Toggle="true" />
										<TOOLBAR ID=" win0-toolbar0"  Weight="100"  Notify="Active;MouseOver"  BarPos="left"  Horiz="true"  EnableKeys="true"  LabelPos="bottom"  ViewMode="textgfx"  IgnoreAppearance="true"  CycleChain="true">
											<TOOLBARBUTTON ID="win0-toolbar0-button1" ShortHelp="shorthelp-toolbarbutton"  HelpNode="toolbarbutton-node"  Disabled="true"  Hidden="true"  Notify="Pressed;Selected" />
										</TOOLBAR>
										<HGROUP ID="win0-hgroup7" Frame="group" FrameTitle="frame-title" Background="Groupback">
											<SCROLLGROUP ID=" win0-scrollgroup0" >
												<VIRTGROUP ID=" win0-virtgroup0" >
													<LISTTREE ID="win0-virtgroup0-listtree" Weight="100"  Disabled="false"  Notify="Active;DoubleClick" />
													</LISTTREE>
												</VIRTGROUP> ; win0-virtgroup0
											</SCROLLGROUP> ; win0-scrollgroup0
										</HGROUP> ; win0-hgroup7
									</VGROUP> ; win0-vgroup0
	</WINDOW>
</APPLICATION>
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListTree looking for a solution

Post by djrikki »

Was worthwhile pasting it in here, spotted and fixed a couple of Class Properties in the output.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ListTree looking for a solution

Post by airsoftsoftwair »

djrikki wrote:Besides I am some time away from a release date, waiting on Andreas to add <item> userdata functionality during runtime. I would be interested to know in broad terms how much longer this may be.
Don't expect it too soon.... but you can just use the workaround I posted a few weeks ago. This really shouldn't stop you from finishing MUI Builder :)
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: ListTree looking for a solution

Post by djrikki »

Yes I did it see it posted (somewhere), to be honest I have plenty still to do so probably 6-8 weeks away. I don't know how that fits with your timescales.

Once I've got the layout.xml sorted, the next complicated step will be building the event hander which ideally should fit within the same recursive function.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
Post Reply