I would like to be sorry before anything, since this question is probably solved but I can't get to a concise answer since I'm not sure what exactly to search and English is not my first language.
I'm building an app in C++ which works reasonablly well, however since the beginning I knew that I would like to add a GUI to it so I started developing both "front-end" and "back-end" at the same time. (The GUI I have chosen actually is a command-line GUI named FTXUI) Although the GUI was not mandatory I did add it to get my feet wet since this is my first GUI ever developed.
I quickly realized that all problems scalated quickly like a snowball, mostly related to parse the app data to the GUI and vice-versa, and keeping control of program flow jumping from one page to another. That is why I was wondering how this is normally designed. I do not mean exactly program or code, but approaches and design methods to propper communication between them efficiently.
Just as an example, I've made a page meant to be a "Login" page. The whole page is executed as a function with two pointers as parameters. Those pointers are where I dump the user's inputs as std::string once the user clicks a "Login" labeled button, the program returns to the main program, processes those strigns and calls for the next page (Which is also a whole function...) This is working as intended, but something is yelling and I'm not sure what. If I need to access a lot of bytes of data (Which I actually need in another page) I ended up building a class to hold that data and parse that instance (as reference) to the page to later format needed data on screen.
I've read in another post about a concept like "Server-Client", where the GUI is executed on the client and exchanges data with the server where the actual program is running. I found it interesting, and that's what I am asking for I guess. Design patterns for GUI's.
-
When starting a project like this, should GUI and main program developed independently? How Can I "connect" them afterwards? How can a GUI page access to the main program data in C++ without parsing everything?
-
Which side of the application should be developed with preference, the main program or the GUI?
-
Can I add a GUI to an already working project?
-
Should a program like this work either with a GUI or exclusively command line at the same time? I mean, should it be designed to work without a GUI (Despite knowing that this GUI will eventually exist)?
-
At the moment my GUI and its pages are held in a class called
MyGUI
. This class has an attribute called_currentPage
which holds anenum
type calledpages
. All GUI pages return the next page to be shown and store it in_currentPage
(f.e.,LOGIN_PAGE
,MAIN_MENU
...) Another method of this class calledshow
just have a switch-case statment with said variable calling the corresponding page function. As I said, I can see the problem here but I'm not sure how this "page management" is normally handled. -
Talking about pages, a GUI is supposed to have a unique page for every possible case? I mean, show "Login Page", then show "Main Menu Page", where you can go to (for example) "Settings page"... each one of them as a different entity with its own implementation.
Thanks in advance and again, sorry for the long question.
I'm expecting to have not a fancy and nice-looking GUI (That's a different topic) but a nice, clean, scalable and maintainable code to newbie-GUI's. I'm guess that the language here is not that critical since is not a problem about code, but design.
Aucun commentaire:
Enregistrer un commentaire