-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #3761, #2886 - Draw and Layout performance issues #3798
base: v2_develop
Are you sure you want to change the base?
Conversation
Loving the work on this. 👍 Planning to take a good look at the code later today. |
The current state is pretty good with the exception of:
I have not invested as much energy in unit tests as I've liked. |
This is how this all works (from Drawing occurs each MainLoop IterationThe @Terminal.Gui.Application MainLoop will iterate over all Views in the view hierarchy looking for views have their @Terminal.Gui.View.NeedsDraw property set. The @Terminal.Gui.View.Draw method will be called which, in turn:
Most of the steps above can be overridden by developers using the standard Terminal.Gui cancellable event pattern. For example, the base @Terminal.Gui.View always clears the viewport. To override this, a subclass can override @Terminal.Gui.View.OnClearingViewport to simply return Then, after the above steps have completed, the Mainloop will iterate through all views in the view hierarchy again, this time calling Draw on any @Terminal.Gui.View.Margin objects, using the cached Clip region mentioned above. This enables Margin to be transparent. Declaring that drawing is neededIf a View need to redraw because something changed within it's Content Area it can call @Terminal.Gui.View.SetNeedsDraw. If a View needs to be redrawn because something has changed the size of the Viewport, it can call @Terminal.Gui.View.SetNeedsLayout. ClippingClipping enables better performance by ensuring on regions of the terminal that need to be drawn actually get drawn by the @Terminal.Gui.ConsoleDriver. Terminal.Gui supports non-rectangular clip regions with @Terminal.Gui.Region. @Terminal.Gui.ConsoleDriver.Clip is the application managed clip region and is managed by @Terminal.Gui.Application. Developers cannot change this directly, but can use @Terminal.Gui.Application.ClipToScreen, @Terminal.Gui.Application.SetClip(Region), @Terminal.Gui.View.ClipToFrame, and @Terminal.Gui.ClipToViewPort. I am now working through what it would mean to have |
This is now ready for real review. Still some to do, but mostly unit tests. |
Fixes
SetNeedsLayout
-> HavePos
/Dim
use events #3485ConsoleDriver
#3622Clip
be aRegion
instead ofRectangle
#3413Related
Proposed Changes/Todos
View.LayoutSubviews
etc... to make more testable and clearer to use. IntroduceView.Layout()
as the primary API that builds onView.SetRelativeLayout
andView.LayoutSubviews
. Move from depending onIsInitialized
toNeedsLayout
as the signal that layout has been performed.View.Draw
to be more granular and use proper event patterns.View.SetAttribute
; makeDriver.SetAttribute
internalClip
be aRegion
instead ofRectangle
#3413Enabled
to enable disabled views to stay disabled even if superview changes; use an event instead of hacky logic.Driver.Move/AddStr
Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)