So I have my GUI far along enough to start incorporating my program, but I am hesitant to start because I want to be careful to do it in an effective and easy to manage way.
The code so far for the GUI alone is about 2100 lines, and I estimate it will be about 8000-10000 lines long when the program is complete. The code for the actual program (without GUI), is about 6000 lines long so far, and will probably get up to about 10,000 when I've added most of what I intend.
Is it a good idea to have the GUI portion, or at least some of it in a separate source file? If you were to do this, how would you? Obviously you can only have one main function. Would you have a file just for the main function, a header file with all the necessary includes and global variables, and put different portions of the rest in separate files.
Concerning the GUI; In my main function, if you click a button, a function connected to that button is called. Inside that function, I may have code to hide many other buttons while this button is selected; Also to manage effects which help you see visually which button is selected. My program so far has like 70 different GUI objects which all get modified, hidden, shown, etc in different circumstances, and multiple menus.
My question; what's the most reasonable way to do this? Right now all my buttons, and their associated objects are all global. Is this reasonable? Is there an exception to the globals are bad rule in cases like this?
Last edited by wl3; February 3rd, 2012 at 07:28 PM.
Here is an example of what I am talking about. This is just the GUI portion so far of what happens when the Go Back button is clicked. The actors are all inside a single container, the stage, which is basically your window.
You still didn't answer what platform you're using. Windows, Linux, ?
In general, global variables should be avoided as much as possible, regardless of what type of application you're developing.
Regards,
Paul McKenzie
I'm using visual studio 10, but my application is written to be portable to mac and linux.
They have a solution using a "json" script which you can somehow use to give access to all your clutter objects to all your signal handling functions.
I'm going to try and put my GUI objects all inside a struct, and then pass it with every signal handling function. Clutter seams to only let you pass one argument as user data for signal handling functions. The problem might be that such a structure will need to contain like 50 or so variables.
Is there something wrong with this? I'm having trouble passing a structure as an argument.
Yes there is "something wrong with this", thus the compiler complains!
Your declaration of void Check(...) uses struct Button Test but struct Button Test is defined some lines lower...
Try to move struct Button definition to be on top... or, at least before the void Check declaration
Yes there is "something wrong with this", thus the compiler complains!
Your declaration of void Check(...) uses struct Button Test but struct Button Test is defined some lines lower...
Try to move struct Button definition to be on top... or, at least before the void Check declaration
Ahh yeah, thanks.
Is there a maximum number of members for a struct? Is it rediculous to put say 200 members in a single struct? At this point what is the advantage over using globals?
Bookmarks