-
Notifications
You must be signed in to change notification settings - Fork 696
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
Discuss - There should only be one (Application.Top
)
#2502
Comments
The only advantage from having multi toplevels in the |
I'm not understanding this. Can you explain further as it sounds interesting! |
I'm only be vague :-) ProcessStartInfo startInfo = new ProcessStartInfo("myApp.exe") {
Arguments = "myToplevelSerialized",
UseShellExecute = true,
CreateNoWindow = false
}
Process.Start(startInfo); When the console is loaded with a argument the attribute will de-serialize the argument and run it by call The Mdi can be achieved by adding other toplevels to the @tig what do you mean by |
@tig but thinking better we can maintain the |
This is all debatable, but here's my thinking:
TopLevel
is currently built around several concepts that are muddled and have led to overly complex code:Toplevel
is a view that can host a Menu and StatusBar. Other views cannot.Toplevel
can run modally, and have its ownRunstate
(viaApplication.Run()
. It is unclear why ANY VIEW can't be run this way, but it seems to be a limitation of the current implementation.Toplevel
can be moved by the user (actually only theToplevel
subclass,Window
). It should be possible to enable the moving of any View (e.g.View.CanMove = true
or similar).Application
is the place where all of the aboveTopLevel
gunk happens in addition to other "application" stuff.The
MdiContainer stuff
is complex, perhaps overly so, and is not actually used by anyone outside of the project. It's also misnamed because Terminal.Gui doesn't actually support "documents" nor does it have a full "MDI" system like Windows (did). It seems to represent features useful in overlapping Views, but it is super confusing on how this works, and the naming doesn't help.Application
is full of code likeif (MdiTop != null && top != MdiTop && top != Current && Current?.Running == false && !top.Running)
which just screams poor-OO design and fragility. This all can be refactored to support specific scenarios and thus be simplified.My proposal:
Application.Top
should be set when an app starts, and should not be changeable. Changing it afterApplication.Begin
has been called should result in an exception.The
Application
class should do the following (and nothing else; other things should be moved elsewhere as appropriate):Runstate
and managing theMainloop
Top
view or a developer-provided oneTop
Stuff that will be moved out of (or deleted) from
Application
:Mdi
stuffCurrent
andtoplevels
. This stuff will just be part ofView
.All
Views
should support overlapping within a superview and have a menubar and statusbar.All
Views
should support having subviews be overlappingAll the insane logic in
Application.cs
for dealing withCurrent
, the stack oftoplevels
, etc, should be moved into theView
hierarchy (either as part ofView
directly or a helper class)... and radically simplified. This includes getting rid of all of theMdi
stuff.Any
View
can be run modally (as a popup that captures all user input) can be executed with a new API:view.Run(popupView)
as is today, except they don't have to be of typeToplevel
. When such a view is run,view.Modal
is set totrue
letting the view know it's modal. We'll retainApplication.Run()
for backward compatibility, but it will simply doApplication.Top.Run(popupView)
.Making this happen requires the following to be done first:
Toplevel
- IntroduceRunnable
andOverlapped
instead #2491Frame
to host subviews (adornments) #2487MenuBar
andStatusBar
to be adornments #2488But it seems doable, and will significantly simplify the programming model (and codebase).
What do folks think?
The text was updated successfully, but these errors were encountered: