c++ - How can I go to my previous Fl::window? -


ok, i'm making game using fltk. , have function prints splash screen subclass of fl::window made buttons "play" , "rules". when user clicks "rules", prints fl::window subclass "back" button , rules (obviously). problem first figure out how display original splash screen when user presses back. know can create second identical splash screen pops when button pressed, means user can go "rules" , "back" 1 time. prefer loop, user can press "rules"-->"back"-->"rules"-->"back" many times he/she like. make sense? ideas?

normally each gui can represented nested state machine. if go screen ( state ) destroy actual displayed widget or window , create new one. if there button, brings "back" first state, same: destroy actual widget or screen , create first 1 again. simple or not :-)

if go deeper hierarchy of sm, create new widget on existing 1 of higher state. leaving substates delete widgets level. changing level of substates destroy widgets of substates , create new ones in same level.

in c++ easy represent state machine classes. entering state creates instance of class , leaving destroys instance represents it.

with c++11 can use "new at" operator on union, "contains" states have in level of application. union guarantees, have reserved enough memory , not need use new/delete @ can problem on small systems without mmu. expect if using fltk, have small system :-)

with c++03 can not use non trivial classes inside union, c++11 real simplification here!

have fun!


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -