Terminal.Gui
Terminal.Gui copied to clipboard
Master Issue: `LineView` -> `Line`
This is a sub-issue of:
- #2994
Todo
- [ ] Enable line-ends like
LineViewhas, soLinecan replace it. - [ ] Enable mouse/keyboard movement of a
Line(ifCanFocus == true). - [ ] Build a
Line Demoscenario. - [ ] Use
LinewithinBorderto support https://github.com/gui-cs/Terminal.Gui/issues/2537
Background
Sometime back I implemented Line. It is extremely simple right now:
/// <summary>
/// Draws a single line using the <see cref="LineStyle"/> specified by <see cref="View.BorderStyle"/>.
/// </summary>
public class Line : View {
private Orientation _orientation;
/// <summary>
/// The direction of the line. If you change this you will need to manually update the Width/Height
/// of the control to cover a relevant area based on the new direction.
/// </summary>
public Orientation Orientation { get => _orientation; set => _orientation = value; }
/// <summary>
/// Constructs a Line object.
/// </summary>
public Line ()
{
}
/// <inheritdoc/>
public override bool OnDrawFrames ()
{
var screenBounds = BoundsToScreen (Bounds);
LineCanvas lc;
lc = SuperView?.LineCanvas;
lc.AddLine (screenBounds.Location, Orientation == Orientation.Horizontal ? Frame.Width : Frame.Height, Orientation, BorderStyle);
return true;
}
//public override void OnDrawContentComplete (Rect contentArea)
//{
// var screenBounds = ViewToScreen (Frame);
//}
/// <inheritdoc/>
public override void OnDrawContent (Rect contentArea)
{
OnDrawFrames ();
}
}
Note the comments in the code are wrong and it's buggy (assumes Bounds == Frame).
My dream is that it gets enhanced to take the code that's in TileView for dragging an edge with keyboard/mouse (showing a diamond) so that I can be used as the basis for any "view edge drag operation".
If we do this, and then use Line objects for the top, right, bottom, and left of a view's Border frame, all mouse/keyboard dragging logic for View resizing (see https://github.com/gui-cs/Terminal.Gui/issues/2537) will be nicely encapsulated.
TileView then can be removed and replaced with a tiled-layout mode. See https://github.com/gui-cs/Terminal.Gui/issues/2491.