Hmm ... allow me to use one post as a documentation-to-self for a feature of the GuiEngine that I haven't used a lot, yet: the ability to dynamically control widgets showing up on screen.
- one static widgets list per window
- nbWidgets may tune how far you can go in that list
- wstart indicates where you start reading from.
- add(x,y,Widget) populate the list, normally in the Window's CTOR.
- setmark() inserts a terminator in the list.
- setmark(HOP_TO_ZERO) inserts a "goto" item that forces the list to be read from the start. This is allowed only when wstart>nbWidgets, which implies that you must reset nbWidget to the position returned by the earlier setmark(). I'm not happy with this constraint.
Note that visibility of the 'pop-up' widget needs to be manually adjusted with render()/hide() and that we need to force the Gui Engine to lose widget focus to make it work. In setup, the current location of the optional widget (here box) needs to be captured (in nbox):if (wstart==nbox) { wstart=0; box->hide(); ge.release(); } else { wstart=nbox; box->render(); ge.focus(box); }
If you want the 'pop-up widget' to be hidden when you'll enter that window again, you'll have to complete your Window::release() method with a conditional test:add(64,0,(box=new BoxWidget(...))->attach(...)); setmark(HOP_TO_ZERO); nbox=nbWidgets--;
if (wstart==nbox) { box->hide(); wstart=0; }
No comments:
Post a Comment