# Unity In need of data layout advice [SDL Gui System]

This topic is 4876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

As posted here, I am working on my own little SDL gui library as part of a bigger SDL library I am currently developing piece by piece. Anyways the main goal is to make a simple/easy to use, practical, and effective GUI system for SDL users. Right now though, before I go on, I need some feedback and opinions on what would be a 'well rounded' approach to the config files and see what's generally accepted and what's advised against. Right now the config file for those screenshots on that last post is as follows:
background
{
r = 212;
g = 208;
b = 200;
}

title
{
x = 3;
y = 3;
w = width - 6;
h = 18;
r = 10;
g = 36;
b = 106;
r = 166;
g = 202;
b = 240;
}

style
{
x  =  width - 3;
y  =  3;
w  =  1;
h  =  height;
r  =  212;
g  =  208;
b  =  200;
}

style
{
x = 1;
y = 1;
w = 1;
h = height - 1;
r = 255;
g = 255;
b = 255;
}

style
{
x = 1;
y = 1;
w = width - 1;
h = 1;
r = 255;
g = 255;
b = 255;
}

style
{
x = 1;
y = height - 2;
w = width - 1;
h = 1;
r = 128;
g = 128;
b = 128;
}

style
{
x = width - 2;
y = 1;
w = 1;
h = height - 2;
r = 128;
g = 128;
b = 128;
}

style
{
x = width - 1;
y = 0;
w = 1;
h = height;
r = 64;
g = 64;
b = 64;
}

style
{
x = 0;
y = height - 1;
w = width;
h = 1;
r = 64;
g = 64;
b = 64;
}



##### Share on other sites
Drew, that is a very nice idea, congratulations!

I think it would be best if you have a config file that is initially blank. When the program is first run, you may have a preview pane where you render the colors like you would for a real window, and ask the user for input on what colors they want. Ideally, sliders for rgb values would be best, but then, have you already thought about sliders and input boxes? Didn't look like that from the screen shots.

And, may I venture to suggest, instead of making windows like the way microsoft do, you could use more of the translucency (to the point of it being usable [wink]), and bright images and stuff for buttons?

Great work!

##### Share on other sites
I'd recommend against .ini files as they would look out of place on Linux or Mac.

XML seems popular but the files would be large.

I personally would probably go with some sort of binary-coded version but make sure to use the endian-correction features of SDL to make sure that they work well on big-endian systems otherwise the resultant source codes won't work on the current Macs or PPC Linux.

Question: Are you coding your GUI in C or C++?

If you were planning on using C++ we could just as well use ParaGUI. I'm involved with a compiler project that currently generates code in ANSI C and uses SDL for the graphics engine. It would be nice to render windows in a cross-platform development environment in such a way that we wouldn't need a separate code generator for each platform. That is why your project interests me.

##### Share on other sites
Quote:
 Original post by deavikAnd, may I venture to suggest, instead of making windows like the way microsoft do, you could use more of the translucency (to the point of it being usable [wink]), and bright images and stuff for buttons?

Thanks! Starting off, the window is entirely data driven (well almost). I just used the microsoft colors just to show what could be emulated. And as of right now, the only thing that is implemented is that dialog form. The alpha is just set as is right now in the code, but I will be adding that to the data driven design as well. It's just before I do all that I need to figure out what's a good way to go about setting up the data format. I do plan on adding more 'widgets' so I will have to see how that goes. If possible, down the line it'd be nice if the user could make their own widgets and use them dynamically as well.

Quote:
 I think it would be best if you have a config file that is initially blank. When the program is first run, you may have a preview pane where you render the colors like you would for a real window, and ask the user for input on what colors they want. Ideally, sliders for rgb values would be best, but then, have you already thought about sliders and input boxes? Didn't look like that from the screen shots.

Thanks for the input, I will make a note of that approach and then do comparing when I get more method together. Thanks for the response!

Quote:
 Original post by samuraicrowI'd recommend against .ini files as they would look out of place on Linux or Mac.XML seems popular but the files would be large.

Good points, while I say to ues .INI styled files, they would probabally just be text files not to alienate too much [wink]. I could make XML files a lot smaller, but by the time I strip it all down, I just might as have used a plain text formatted file.

Quote:
 I personally would probably go with some sort of binary-coded version but make sure to use the endian-correction features of SDL to make sure that they work well on big-endian systems otherwise the resultant source codes won't work on the current Macs or PPC Linux.

That would fefinitly be a future feature that would be great to add in for the most efficiency and speed. I'm glad you mentioned that though, I will definitly have to make sure to test well on other systems for the sake of the endianess.

Quote:
 Question: Are you coding your GUI in C or C++?

C++ [smile] I can look into using C, but things might get bulky with that style of programming. So I'll see what can be done about that. However, my input class is C++ right now, so I'd need to do a rewrite of that for C - so right now, C would be a secondary porting project after I get the main one done and fully tested.

Quote:
 If you were planning on using C++ we could just as well use ParaGUI. I'm involved with a compiler project that currently generates code in ANSI C and uses SDL for the graphics engine.

Ah yes, ParaGUI looks very nice and has all those bells and whistles of a great library [smile]. Shoot, they have some nice looking gradient functionality from looking at the docs. Looking at the examples though, I'd hope to make something a little more simple and probabally nowhere as complex as it is. I'm not sure yet, main reason I'm doing this is for the learning process as well as the challenge - and to have something to use that I know how it works. I know this library is just in the beginning stages, but hopefully I can get it to the point where it's a viable option for getting GUI's done.

Quote:
 It would be nice to render windows in a cross-platform development environment in such a way that we wouldn't need a separate code generator for each platform. That is why your project interests me.

Well, I'll definitly take a look into seeing what can be done for a C-style, but since I don't have 'that much' done on this library yet, I'm not sure how much of help it can be for your project, unless you have a decently long time schedule. Thanks for your input as well.

I guess for now I will keep working on just this simple format and change it later on when I can get a better idea of what to use. Changing that part of the code isn't that much of a problem. I will though, look into the graphic idea. I think what I'll do is just make a demo of it and let people test it out to see if they like how it works. If anyone else has suggestions/comments don't hesitate!

##### Share on other sites
Quote:
 XML is quite easy to use and understand for manual file editing. The only problem is that it can get quite verbose and possibly a hassle if you are making your own style-sheets for a GUI dialog.

I've been using XML in my own GUI system and can say that it was quite nice, elegant and good solution, and I've seen that other people also use XML a lot in GUIs - so I suggest to use it.

As for that problem of verbose style you mention, maybe you could use sth like "typedef" in C++: there would be special tag called <Typedef Type="xxx" Name="zzz"> yyy </Typedef> where xxx would be the type of typefedef style, zzz the name of typefedef style and yyy would be it's body. There could be many of those typedefs, and each could have been referenced in control (widget etc.) definitions.

I think that example will tell more than my lame explanations :-)

<Typedef Type="Appearance" Name="TitleTextTypedef"> <Background>  <Color>   <R> 255 </R>   <G> 255 </G>   <B> 255 </B>  </Color> </Background> <Font>  <Size> 12 </Size>  <Name> Courier New </Name>  <Format Bold="true" Italic="false" Underline="false"/>  <Color>   <R> 255 </R>   <G> 128 </G>   <B> 0 </B>  </Color> </Font>  <!-- and other properties, none of them is obligatory --></Typedef>

That typedef could be used like this:

<Control Type="Button" Name="TitleScreen"> <Position>  <x> 5 </x>  <y> 25 </y> </Position> <Appearance UseTypedef="TitleTextTypedef"> <!-- nothing here, everything is taken from TitleTextTypedef,   but if user wants, he can override here those elements of that typedef   with sth else, just like virtual member functions in classess --> </Appearance></Control>

For comparison, that's how would you achieve exactly the same without typedefs:

<Control Type="Button" Name="TitleScreen"> <Position>  <x> 5 </x>  <y> 25 </y> </Position> <Appearance> <Background>  <Color>   <R> 255 </R>   <G> 255 </G>   <B> 255 </B>  </Color> </Background> <Font>  <Size> 12 </Size>  <Name> Courier New </Name>  <Format Bold="true" Italic="false" Underline="false"/>  <Color>   <R> 255 </R>   <G> 128 </G>   <B> 0 </B>  </Color> </Font> </Appearance></Control>

Using those typedefs, you could reuse the most commonly used styles without duplication, copy n' paste, memory waste etc.

##### Share on other sites
Quote:
 Original post by Drew_BentonWell, I'll definitly take a look into seeing what can be done for a C-style, but since I don't have 'that much' done on this library yet, I'm not sure how much of help it can be for your project, unless you have a decently long time schedule. Thanks for your input as well.

It's a non-commercial project with no deadlines. I'd give you a link to our webpage but it is down at the moment. :-D

##### Share on other sites
Quote:
 Original post by KoshmaarAs for that problem of verbose style you mention, maybe you could use sth like "typedef" in C++

Ahh, thanks for that suggestion. I've used that before in OgreOde, but had no idea what that was called. I'll take a look into doing that and see if it helps out. I'll probabally just make one config file, then do it in all the various formats, XML, text, etc.. then see which looks the most usable. That or I'll just make the system so you can use whatever floats your boat [smile] That way then it's up to the end user to choose how they want to store the data.

Quote:
 Original post by samuraicrowIt's a non-commercial project with no deadlines. I'd give you a link to our webpage but it is down at the moment. :-D

Well then, since that's the case, I'll have a look into the possibility of making it C-style then. I should have time this weekend to work on it some, unfortunatly, not that much though because of school work. If I can come up with anything, I'll send you a PM.

Quote:
 Original post by KylotanConsider YAML instead of XML.

I was taking a look at that and was going to give it a spin, but I could not find a proper version for C++ on the download page. I did a little seaching and found a mention that there is no one for C++, so would I need to do some workaround for it, or am I just SOL?

Thanks guys for the responses!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015743
×