Skip to content
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

Significant MessageBox and Dialog Improvements #590

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ packages
# User-specific files
*.user

docfx/api
docfx/api

#git merge files
*.orig
6 changes: 3 additions & 3 deletions Example/demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void SetCursorPosition (Point pos)
throw new NotImplementedException ();
}

public override void Redraw (Rect region)
public override void Redraw (Rect bounds)
{
//Point pos = new Point (region.X, region.Y);
Driver.SetAttribute (ColorScheme.Focus);
Expand All @@ -53,7 +53,7 @@ public Filler (Rect rect) : base (rect)
{
}

public override void Redraw (Rect region)
public override void Redraw (Rect bounds)
{
Driver.SetAttribute (ColorScheme.Focus);
var f = Frame;
Expand Down Expand Up @@ -509,7 +509,7 @@ static void Main ()

//Application.UseSystemConsole = true;

Application.Init ();
Application.Init();

var top = Application.Top;

Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public static RunState Begin (Toplevel toplevel)
Current = toplevel;
Driver.PrepareToRun (MainLoop, ProcessKeyEvent, ProcessKeyDownEvent, ProcessKeyUpEvent, ProcessMouseEvent);
if (toplevel.LayoutStyle == LayoutStyle.Computed)
toplevel.RelativeLayout (new Rect (0, 0, Driver.Cols, Driver.Rows));
toplevel.SetRelativeLayout (new Rect (0, 0, Driver.Cols, Driver.Rows));
toplevel.LayoutSubviews ();
Loaded?.Invoke (null, new ResizedEventArgs () { Rows = Driver.Rows, Cols = Driver.Cols });
toplevel.WillPresent ();
Expand Down Expand Up @@ -670,7 +670,7 @@ static void TerminalResized ()
Driver.Clip = full;
foreach (var t in toplevels) {
t.PositionToplevels ();
t.RelativeLayout (full);
t.SetRelativeLayout (full);
t.LayoutSubviews ();
}
Refresh ();
Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Core/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public virtual void DrawWindowTitle (Rect region, ustring title, int paddingLeft
const char bottomChar = clearChar;
#endif
/// <summary>
/// Draws a frame for a window with padding aand n optional visible border inside the padding.
/// Draws a frame for a window with padding and an optional visible border inside the padding.
/// </summary>
/// <param name="region">Screen relative region where the frame will be drawn.</param>
/// <param name="paddingLeft">Number of columns to pad on the left (if 0 the border will not appear on the left).</param>
Expand Down Expand Up @@ -724,7 +724,7 @@ public virtual void DrawFrame (Rect region, int padding, bool fill)
// DrawFrame assumes the border is always at least one row/col thick
// DrawWindowFrame assumes a padding of 0 means NO padding and no frame
DrawWindowFrame (new Rect (region.X, region.Y, region.Width, region.Height),
padding + 1, padding + 1, padding + 1, padding + 1, fill: fill);
padding + 1, padding + 1, padding + 1, padding + 1, border: false, fill: fill);
}


Expand Down
45 changes: 23 additions & 22 deletions Terminal.Gui/Core/Toplevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,48 @@ namespace Terminal.Gui {
/// </summary>
/// <remarks>
/// <para>
/// Toplevels can be modally executing views, and they return control
/// to the caller when the "Running" property is set to false, or
/// by calling <see cref="M:Terminal.Gui.Application.RequestStop()"/>
/// Toplevels can be modally executing views, started by calling <see cref="Application.Run(Toplevel, bool)"/>.
/// They return control to the caller when <see cref="Application.RequestStop()"/> has
/// been called (which sets the <see cref="Toplevel.Running"/> property to false).
/// </para>
/// <para>
/// There will be a toplevel created for you on the first time use
/// and can be accessed from the property <see cref="P:Terminal.Gui.Application.Top"/>,
/// but new toplevels can be created and ran on top of it. To run, create the
/// toplevel and then invoke <see cref="M:Terminal.Gui.Application.Run"/> with the
/// new toplevel.
/// A Toplevel is created when an application initialzies Terminal.Gui by callling <see cref="Application.Init()"/>.
/// The application Toplevel can be accessed via <see cref="Application.Top"/>. Additional Toplevels can be created
/// and run (e.g. <see cref="Dialog"/>s. To run a Toplevel, create the <see cref="Toplevel"/> and
/// call <see cref="Application.Run(Toplevel, bool)"/>.
/// </para>
/// <para>
/// TopLevels can also opt-in to more sophisticated initialization
/// Toplevels can also opt-in to more sophisticated initialization
/// by implementing <see cref="ISupportInitialize"/>. When they do
/// so, the <see cref="ISupportInitialize.BeginInit"/> and
/// <see cref="ISupportInitialize.EndInit"/> methods will be called
/// before running the view.
/// If first-run-only initialization is preferred, the <see cref="ISupportInitializeNotification"/>
/// can be implemented too, in which case the <see cref="ISupportInitialize"/>
/// methods will only be called if <see cref="ISupportInitializeNotification.IsInitialized"/>
/// is <see langword="false"/>. This allows proper View inheritance hierarchies
/// is <see langword="false"/>. This allows proper <see cref="View"/> inheritance hierarchies
/// to override base class layout code optimally by doing so only on first run,
/// instead of on every run.
/// </para>
/// </remarks>
public class Toplevel : View {
/// <summary>
/// Gets or sets whether the Mainloop for this <see cref="Toplevel"/> is running or not. Setting
/// this property to false will cause the MainLoop to exit.
/// Gets or sets whether the <see cref="MainLoop"/> for this <see cref="Toplevel"/> is running or not.
/// </summary>
/// <remarks>
/// Setting this property directly is discouraged. Use <see cref="Application.RequestStop"/> instead.
/// </remarks>
public bool Running { get; set; }

/// <summary>
/// Fired once the Toplevel's MainLoop has started it's first iteration.
/// Fired once the Toplevel's <see cref="MainLoop"/> has started it's first iteration.
/// Subscribe to this event to perform tasks when the <see cref="Toplevel"/> has been laid out and focus has been set.
/// changes. A Ready event handler is a good place to finalize initialization after calling `<see cref="Application.Run()"/>(topLevel)`.
/// </summary>
public event EventHandler Ready;

/// <summary>
/// Called from Application.RunLoop after the <see cref="Toplevel"/> has entered it's first iteration of the loop.
/// Called from <see cref="Application.RunLoop"/> after the <see cref="Toplevel"/> has entered it's first iteration of the loop.
/// </summary>
internal virtual void OnReady ()
{
Expand All @@ -70,7 +71,7 @@ public Toplevel (Rect frame) : base (frame)
}

/// <summary>
/// Initializes a new instance of the <see cref="Toplevel"/> class with Computed layout, defaulting to <see langword="async"/> full screen.
/// Initializes a new instance of the <see cref="Toplevel"/> class with <see cref="LayoutStyle.Computed"/> layout, defaulting to full screen.
/// </summary>
public Toplevel () : base ()
{
Expand All @@ -85,7 +86,7 @@ void Initialize ()
}

/// <summary>
/// Convenience factory method that creates a new toplevel with the current terminal dimensions.
/// Convenience factory method that creates a new Toplevel with the current terminal dimensions.
/// </summary>
/// <returns>The create.</returns>
public static Toplevel Create ()
Expand All @@ -109,12 +110,12 @@ public override bool CanFocus {
public bool Modal { get; set; }

/// <summary>
/// Check id current toplevel has menu bar
/// Gets or sets the menu for this Toplevel
/// </summary>
public MenuBar MenuBar { get; set; }

/// <summary>
/// Check id current toplevel has status bar
/// Gets or sets the status bar for this Toplevel
/// </summary>
public StatusBar StatusBar { get; set; }

Expand Down Expand Up @@ -256,18 +257,18 @@ internal void PositionToplevels ()
}

///<inheritdoc cref="Redraw"/>
public override void Redraw (Rect region)
public override void Redraw (Rect bounds)
{
Application.CurrentView = this;

if (IsCurrentTop || this == Application.Top) {
if (NeedDisplay != null && !NeedDisplay.IsEmpty) {
Driver.SetAttribute (Colors.TopLevel.Normal);
Clear (region);
Clear (bounds);
Driver.SetAttribute (Colors.Base.Normal);
}
foreach (var view in Subviews) {
if (view.Frame.IntersectsWith (region)) {
if (view.Frame.IntersectsWith (bounds)) {
view.SetNeedsLayout ();
view.SetNeedsDisplay (view.Bounds);
}
Expand All @@ -280,7 +281,7 @@ public override void Redraw (Rect region)
}

/// <summary>
/// This method is invoked by Application.Begin as part of the Application.Run after
/// Invoked by <see cref="Application.Begin"/> as part of the <see cref="Application.Run(Toplevel, bool)"/> after
/// the views have been laid out, and before the views are drawn for the first time.
/// </summary>
public virtual void WillPresent ()
Expand Down
Loading