You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.
I was playing with the menu widget today and found a problem that I have no idea how to solve without changing part of the core ui code.
So menu widget itself is inherited from FocusManager, which listen on arrow key press and flag itself dirty for redraw.
The flag dirty mechanism is implemented as follow: a widget have to first register itself in the UIManager. Then in UIManager:run, UIManager will loop through all the registered widgets and repaint the widget if it is dirty. If a widget is not registered in UIManager, it won't be repainted even though it flags itself dirty.
Now the problem is in order to center a menu in screen, I put a menu widget inside a CenterContainer and register the CenterContainer in UIManager. When an arrow key is pressed, the menu widget will receive it, update the ui and set itself dirty. However, since it is not registered in UIManager (I only registered its parent CenterContainer), it won't get repainted on the screen.
My question is, shouldn't we loop through all the dirty widgets in UIManager:run method and repaint all the dirty widgets even though they are not registered in UIManager? Did I miss anything important?
The text was updated successfully, but these errors were encountered:
IIRC, I made this decision in order to do the repainting in the correct
order - last registered widget is painted last. So the window stack is
indeed a stack - painted from bottom to top.
Maybe the repaint logic must go into the widgets, so widgets keep track of
"dirty" child widgets and do repaint them. So top-level items are childs of
the UI manager, and below that each widget can have and do keep track of
their own childs.
If every registered widget keep track of its children, then probably we need to add a reference to its parent in every child? So children can register as dirty in their parent.
That's what I thought of. It might come handy in other places, too.
However, it probably means that we need to add childs via an "add" method,
not just as array elements.
I think I'll do a bit of testing and will report back.
we are adding child via new method now, so probably, we can add parent references in that method
if all children have parent reference, then I might not need to all parents keep track of "dirty" child. When a child called setDirty, we can set its parent as dirty instead, which will successfully trigger a redraw.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was playing with the menu widget today and found a problem that I have no idea how to solve without changing part of the core ui code.
So menu widget itself is inherited from FocusManager, which listen on arrow key press and flag itself dirty for redraw.
The flag dirty mechanism is implemented as follow: a widget have to first register itself in the UIManager. Then in
UIManager:run
, UIManager will loop through all the registered widgets and repaint the widget if it is dirty. If a widget is not registered in UIManager, it won't be repainted even though it flags itself dirty.Now the problem is in order to center a menu in screen, I put a menu widget inside a CenterContainer and register the CenterContainer in UIManager. When an arrow key is pressed, the menu widget will receive it, update the ui and set itself dirty. However, since it is not registered in UIManager (I only registered its parent CenterContainer), it won't get repainted on the screen.
My question is, shouldn't we loop through all the dirty widgets in
UIManager:run
method and repaint all the dirty widgets even though they are not registered in UIManager? Did I miss anything important?The text was updated successfully, but these errors were encountered: