The current GUI prepare system is a mess, as made evident by my attempt to implement drop-down boxes. The solution to this problem is to do a total of 5 passes, with new functions instead of clumping everything together in prepare.
pre_prepare which allows overlay canvases to be added to the GUIScreen system.
widget position pass: position is called on all widgets, bottom-to-top, so the positions are assigned
prepare pass: prepare is called on all widgets, top-to-bottom with execute_user_actions = false so the UI can block 3D game elements
game pass: 3D game elements handle their inputs and may block using ext_block
input pass: prepare is called on all widgets, top-to-bottom, with execute_user_actions = true so actual GUI actions are executed only if ext_block = false
Furthermore, the GUIScreen system could keep track of all canvases, so that you don't need to manually call anything else than:
gui_screen->prepare_pass(); // this calls pre_prepare, position and prepare
// 3d input stuff here which may be blocked by GUI and may at the same time block it
gui_screen->input_pass(); // this calls prepare again, but with execute user actions
This system should be straightforward to implement and should work for pretty much all GUI situations.
The current GUI prepare system is a mess, as made evident by my attempt to implement drop-down boxes. The solution to this problem is to do a total of 5 passes, with new functions instead of clumping everything together in
prepare
.GUIScreen
system.position
is called on all widgets, bottom-to-top, so the positions are assignedprepare
is called on all widgets, top-to-bottom withexecute_user_actions = false
so the UI can block 3D game elementsext_block
prepare
is called on all widgets, top-to-bottom, withexecute_user_actions = true
so actual GUI actions are executed only ifext_block = false
Furthermore, the
GUIScreen
system could keep track of all canvases, so that you don't need to manually call anything else than:This system should be straightforward to implement and should work for pretty much all GUI situations.