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

ComboBox. Support parameterless constructor. Update scenario demo #607

Merged
merged 24 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ce30a83
Ensures that only the current top to execute keys.
BDisp Jun 2, 2020
f4fba42
Improvements the mouse and keys of the MenuBar.
BDisp Jun 2, 2020
ae126b4
Reverting this because it interfere with the Alt+Tab when switching t…
BDisp Jun 3, 2020
4a1f5a9
Merge branch 'mouse-tasks' into menu-improvements
BDisp Jun 3, 2020
eaf254b
Merge branch 'master' of tig:migueldeicaza/gui.cs
tig Jun 3, 2020
cfb76b1
Merge branch 'master' of tig:migueldeicaza/gui.cs
tig Jun 3, 2020
767eeec
Fixes #604 Toplevel repaint.
BDisp Jun 3, 2020
f1af54d
ComboBox. Support parameterless constructor. Update scenario demo
fergusonr Jun 3, 2020
ca03645
Added some features to TextView like mouse welling and Ctrl+End/Home …
BDisp Jun 3, 2020
cb04a81
Merge pull request #606 from BDisp/textview-features
tig Jun 3, 2020
46cde0c
Merge branch 'master' of tig:migueldeicaza/gui.cs
tig Jun 3, 2020
020d43f
Added a comment as suggested.
BDisp Jun 3, 2020
6631a0f
Merge pull request #605 from BDisp/toplevel-repaint
tig Jun 3, 2020
05a8171
Merge branch 'master' of tig:migueldeicaza/gui.cs
tig Jun 3, 2020
afae8b8
Requested changes made.
BDisp Jun 3, 2020
e87b56c
updated api docs; implemented inheritdoc; may break deploy
tig Jun 4, 2020
0756917
Merge pull request #596 from BDisp/menu-improvements
tig Jun 4, 2020
1d91b0d
Merge branch 'master' of tig:migueldeicaza/gui.cs
tig Jun 4, 2020
d980d70
Merge branch 'master' into bounds_comments
tig Jun 4, 2020
7fdc7e6
Merge pull request #608 from tig/bounds_comments
tig Jun 4, 2020
1c6223e
regen docs
tig Jun 4, 2020
d6205e4
Merge pull request #611 from tig/bounds_comments
tig Jun 4, 2020
4d2ddcf
ComboBox. Support parameterless constructor. Update scenario demo
fergusonr Jun 3, 2020
b71d72f
Merge branch 'combobox_fixes' of https://github.com/fergusonr/gui.cs …
fergusonr Jun 4, 2020
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
9 changes: 5 additions & 4 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,9 @@ void IMainLoopDriver.MainIteration ()
keyUpHandler (new KeyEvent (map, keyModifiers));
}
}
if (!inputEvent.KeyEvent.bKeyDown)
if (!inputEvent.KeyEvent.bKeyDown) {
keyModifiers = null;
}
break;

case WindowsConsole.EventType.Mouse:
Expand Down Expand Up @@ -879,7 +880,7 @@ MouseEvent ToDriverMouse (WindowsConsole.MouseEventRecord mouseEvent)
};
}

private async Task ProcessButtonDoubleClickedAsync ()
async Task ProcessButtonDoubleClickedAsync ()
{
await Task.Delay (200);
IsButtonDoubleClicked = false;
Expand All @@ -896,11 +897,11 @@ async Task ProcessContinuousButtonPressedAsync (WindowsConsole.MouseEventRecord
};

var view = Application.wantContinuousButtonPressedView;
if (view == null)
if (view == null) {
break;
}
if (IsButtonPressed && (mouseFlag & MouseFlags.ReportMousePosition) == 0) {
mouseHandler (me);
//mainLoop.Driver.Wakeup ();
}
}
}
Expand Down
28 changes: 22 additions & 6 deletions Terminal.Gui/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,33 @@
namespace Terminal.Gui {

/// <summary>
/// The application driver for Terminal.Gui.
/// A static, singelton class provding the main application driver for Terminal.Gui apps.
/// </summary>
/// <example>
/// <code>
/// // A simple Terminal.Gui app that creates a window with a frame and title with
/// // 5 rows/columns of padding.
/// Application.Init();
/// var win = new Window ("Hello World - CTRL-Q to quit") {
/// X = 5,
/// Y = 5,
/// Width = Dim.Fill (5),
/// Height = Dim.Fill (5)
/// };
/// Application.Top.Add(win);
/// Application.Run();
/// </code>
/// </example>
/// <remarks>
/// <para>
/// You can hook up to the <see cref="Iteration"/> event to have your method
/// invoked on each iteration of the <see cref="Terminal.Gui.MainLoop"/>.
/// </para>
/// <para>
/// Creates a instance of <see cref="Terminal.Gui.MainLoop"/> to process input events, handle timers and
/// other sources of data. It is accessible via the <see cref="MainLoop"/> property.
/// </para>
/// <para>
/// You can hook up to the <see cref="Iteration"/> event to have your method
/// invoked on each iteration of the <see cref="Terminal.Gui.MainLoop"/>.
/// </para>
/// <para>
/// When invoked sets the SynchronizationContext to one that is tied
/// to the mainloop, allowing user code to use async/await.
/// </para>
Expand Down Expand Up @@ -351,8 +366,9 @@ static void ProcessMouseEvent (MouseEvent me)
OfY = me.Y - newxy.Y,
View = view
};
if (OutsideFrame (new Point (nme.X, nme.Y), mouseGrabView.Frame))
if (OutsideFrame (new Point (nme.X, nme.Y), mouseGrabView.Frame)) {
lastMouseOwnerView?.OnMouseLeave (me);
}
if (mouseGrabView != null) {
mouseGrabView.OnMouseEvent (nme);
return;
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Core/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Terminal.Gui {

/// <summary>
/// Basic colors that can be used to set the foreground and background colors in console applications. These can only be
/// Basic colors that can be used to set the foreground and background colors in console applications.
/// </summary>
public enum Color {
/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion Terminal.Gui/Core/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ public KeyEvent (Key k, KeyModifiers km)
keyModifiers = km;
}

///<inheritdoc cref="ToString"/>
/// <summary>
/// Pretty prints the KeyEvent
/// </summary>
/// <returns></returns>
public override string ToString ()
{
string msg = "";
Expand Down
17 changes: 10 additions & 7 deletions Terminal.Gui/Core/Toplevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal virtual void OnReady ()
/// <summary>
/// Initializes a new instance of the <see cref="Toplevel"/> class with the specified absolute layout.
/// </summary>
/// <param name="frame">Frame.</param>
/// <param name="frame">A superview-relative rectangle specifying the location and size for the new Toplevel</param>
public Toplevel (Rect frame) : base (frame)
{
Initialize ();
Expand Down Expand Up @@ -119,7 +119,7 @@ public override bool CanFocus {
/// </summary>
public StatusBar StatusBar { get; set; }

///<inheritdoc cref="ProcessKey"/>
///<inheritdoc/>
public override bool ProcessKey (KeyEvent keyEvent)
{
if (base.ProcessKey (keyEvent))
Expand Down Expand Up @@ -171,7 +171,7 @@ public override bool ProcessKey (KeyEvent keyEvent)
return false;
}

///<inheritdoc cref="Add"/>
///<inheritdoc/>
public override void Add (View view)
{
if (this == Application.Top) {
Expand All @@ -183,7 +183,7 @@ public override void Add (View view)
base.Add (view);
}

///<inheritdoc cref="Remove"/>
///<inheritdoc/>
public override void Remove (View view)
{
if (this == Application.Top) {
Expand All @@ -195,7 +195,7 @@ public override void Remove (View view)
base.Remove (view);
}

///<inheritdoc cref="RemoveAll"/>
///<inheritdoc/>
public override void RemoveAll ()
{
if (this == Application.Top) {
Expand Down Expand Up @@ -256,15 +256,18 @@ internal void PositionToplevels ()
}
}

///<inheritdoc cref="Redraw"/>
///<inheritdoc/>
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 (Frame);

// This is the Application.Top. Clear just the region we're being asked to redraw
// (the bounds passed to us).
Clear (bounds);
Driver.SetAttribute (Colors.Base.Normal);
}
foreach (var view in Subviews) {
Expand Down
52 changes: 34 additions & 18 deletions Terminal.Gui/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public enum LayoutStyle {
/// The container of a View can be accessed with the <see cref="SuperView"/> property.
/// </para>
/// <para>
/// The <see cref="SetNeedsDisplay(Rect)"/> method flags a region or the entire view
/// as requiring to be redrawn.
/// To flag a region of the View's <see cref="Bounds"/> to be redrawn call <see cref="SetNeedsDisplay(Rect)"/>. To flag the entire view
/// for redraw call <see cref="SetNeedsDisplay()"/>.
/// </para>
/// <para>
/// Views have a <see cref="ColorScheme"/> property that defines the default colors that subviews
Expand Down Expand Up @@ -210,7 +210,7 @@ public bool IsCurrentTop {
public virtual bool WantContinuousButtonPressed { get; set; } = false;

/// <summary>
/// Gets or sets the frame for the view. The frame is relative to the <see cref="SuperView"/>.
/// Gets or sets the frame for the view. The frame is relative to the view's container (<see cref="SuperView"/>).
/// </summary>
/// <value>The frame.</value>
/// <remarks>
Expand All @@ -219,7 +219,7 @@ public bool IsCurrentTop {
/// </para>
/// <para>
/// Altering the Frame of a view will trigger the redrawing of the
/// view as well as the redrawing of the affected regions in the <see cref="SuperView"/>.
/// view as well as the redrawing of the affected regions of the <see cref="SuperView"/>.
/// </para>
/// </remarks>
public virtual Rect Frame {
Expand Down Expand Up @@ -263,9 +263,21 @@ public LayoutStyle LayoutStyle {
}

/// <summary>
/// The bounds represent the View-relative rectangle used for this view. Updates to the Bounds update the <see cref="Frame"/>, and has the same side effects as updating the <see cref="Frame"/>.
/// The bounds represent the View-relative rectangle used for this view; the area inside of the view.
/// </summary>
/// <value>The bounds.</value>
/// <remarks>
/// <para>
/// Updates to the Bounds update the <see cref="Frame"/>,
/// and has the same side effects as updating the <see cref="Frame"/>.
/// </para>
/// <para>
/// Because <see cref="Bounds"/> coordinates are relative to the upper-left corner of the <see cref="View"/>,
/// the coordinates of the upper-left corner of the rectangle returned by this property are (0,0).
/// Use this property to obtain the size and coordinates of the client area of the
/// control for tasks such as drawing on the surface of the control.
/// </para>
/// </remarks>
public Rect Bounds {
get => new Rect (Point.Empty, Frame.Size);
set {
Expand Down Expand Up @@ -781,7 +793,7 @@ public virtual void PositionCursor ()
Move (frame.X, frame.Y);
}

/// <inheritdoc cref="HasFocus"/>
/// <inheritdoc/>
public override bool HasFocus {
get {
return base.HasFocus;
Expand Down Expand Up @@ -819,7 +831,7 @@ public FocusEventArgs () { }
public bool Handled { get; set; }
}

/// <inheritdoc cref="OnEnter"/>
/// <inheritdoc/>
public override bool OnEnter ()
{
FocusEventArgs args = new FocusEventArgs ();
Expand All @@ -832,7 +844,7 @@ public override bool OnEnter ()
return false;
}

/// <inheritdoc cref="OnLeave"/>
/// <inheritdoc/>
public override bool OnLeave ()
{
FocusEventArgs args = new FocusEventArgs ();
Expand Down Expand Up @@ -946,6 +958,7 @@ public virtual void Redraw (Rect bounds)
var savedClip = ClipToBounds ();

// Draw the subview
// Use the view's bounds (view-relative; Location will always be (0,0) because
view.Redraw (view.Bounds);

// Undo the clip
Expand Down Expand Up @@ -1042,7 +1055,7 @@ public class KeyEventEventArgs : EventArgs {
/// </summary>
public event EventHandler<KeyEventEventArgs> KeyPress;

/// <inheritdoc cref="ProcessKey"/>
/// <inheritdoc/>
public override bool ProcessKey (KeyEvent keyEvent)
{

Expand All @@ -1056,7 +1069,7 @@ public override bool ProcessKey (KeyEvent keyEvent)
return false;
}

/// <inheritdoc cref="ProcessHotKey"/>
/// <inheritdoc/>
public override bool ProcessHotKey (KeyEvent keyEvent)
{
KeyEventEventArgs args = new KeyEventEventArgs (keyEvent);
Expand All @@ -1066,12 +1079,12 @@ public override bool ProcessHotKey (KeyEvent keyEvent)
if (subviews == null || subviews.Count == 0)
return false;
foreach (var view in subviews)
if (view.ProcessHotKey (keyEvent))
if (view.SuperView.IsCurrentTop && view.ProcessHotKey (keyEvent))
return true;
return false;
}

/// <inheritdoc cref="ProcessColdKey"/>
/// <inheritdoc/>
public override bool ProcessColdKey (KeyEvent keyEvent)
{
KeyEventEventArgs args = new KeyEventEventArgs (keyEvent);
Expand All @@ -1081,7 +1094,7 @@ public override bool ProcessColdKey (KeyEvent keyEvent)
if (subviews == null || subviews.Count == 0)
return false;
foreach (var view in subviews)
if (view.ProcessColdKey (keyEvent))
if (view.SuperView.IsCurrentTop && view.ProcessColdKey (keyEvent))
return true;
return false;
}
Expand All @@ -1101,7 +1114,7 @@ public override bool OnKeyDown (KeyEvent keyEvent)
if (subviews == null || subviews.Count == 0)
return false;
foreach (var view in subviews)
if (view.OnKeyDown (keyEvent))
if (view.SuperView.IsCurrentTop && view.OnKeyDown (keyEvent))
return true;

return false;
Expand All @@ -1122,7 +1135,7 @@ public override bool OnKeyUp (KeyEvent keyEvent)
if (subviews == null || subviews.Count == 0)
return false;
foreach (var view in subviews)
if (view.OnKeyUp (keyEvent))
if (view.SuperView.IsCurrentTop && view.OnKeyUp (keyEvent))
return true;

return false;
Expand Down Expand Up @@ -1432,7 +1445,10 @@ public virtual void LayoutSubviews ()
OnLayoutComplete (new LayoutEventArgs () { OldBounds = oldBounds });
}

/// <inheritdoc cref="ToString"/>
/// <summary>
/// Pretty prints the View
/// </summary>
/// <returns></returns>
public override string ToString ()
{
return $"{GetType ().Name}({Id})({Frame})";
Expand All @@ -1458,7 +1474,7 @@ public class MouseEventEventArgs : EventArgs {
public bool Handled { get; set; }
}

/// <inheritdoc cref="OnMouseEnter(Gui.MouseEvent)"/>
/// <inheritdoc/>
public override bool OnMouseEnter (MouseEvent mouseEvent)
{
MouseEventEventArgs args = new MouseEventEventArgs (mouseEvent);
Expand All @@ -1471,7 +1487,7 @@ public override bool OnMouseEnter (MouseEvent mouseEvent)
return false;
}

/// <inheritdoc cref="OnMouseLeave(Gui.MouseEvent)"/>
/// <inheritdoc/>
public override bool OnMouseLeave (MouseEvent mouseEvent)
{
MouseEventEventArgs args = new MouseEventEventArgs (mouseEvent);
Expand Down
Loading