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

Fixes #3691. Adds Popover #3749

Open
wants to merge 53 commits into
base: v2_develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f314848
Added Applicaton.Popover.
tig Sep 19, 2024
4073e23
Popover prototype
tig Sep 19, 2024
fd632e3
Merge branch 'v2_develop' into v2_3691-Popover
tig Sep 19, 2024
4da7f48
Merged v2_3750
tig Sep 22, 2024
9f84b3a
Testing highlight
tig Sep 22, 2024
aa5cf82
Merged latest
tig Sep 22, 2024
9222972
Merge branch 'v2_3750-MouseEnter' into v2_3691-Popover
tig Sep 23, 2024
f589416
Fixed click outside issue
tig Sep 23, 2024
5d1d6cb
Fixed DialogTests
tig Sep 23, 2024
c623206
Fixed click outside issue (agbain)
tig Sep 23, 2024
e2a4620
Enabled mouse wheel in Bar
tig Sep 23, 2024
7b7649a
Enabled mouse wheel in Bar
tig Sep 23, 2024
bfefabc
Progress. Broke arrangement
tig Sep 23, 2024
7346afb
Merge branch 'v2_develop' into v2_3691-Popover
tig Sep 24, 2024
ec847a3
Rebased onto v2_3750-MouseEnter
tig Sep 24, 2024
850c308
Merge branch 'v2_develop' into v2_3691-Popover
tig Sep 26, 2024
3e8ed7a
Added popover tests.
tig Sep 26, 2024
1369bb2
Can't set ForceDriver to empty in Resources/config.json.
tig Sep 26, 2024
3aa3598
added BUGBUG
tig Sep 26, 2024
ae4b172
Made Position/ScreenPosition clear
tig Sep 26, 2024
4e6bf04
Added View.IsInHierarchy tests
tig Sep 26, 2024
a5044df
Added Contextmenuv2 scenario.
tig Sep 26, 2024
06bcefe
Implemented CM2 in TextView
tig Sep 26, 2024
a708648
Removed unneeded CM stuff from testhelpers
tig Sep 26, 2024
d888de8
Shortcut API docs
tig Sep 26, 2024
8954fec
Fixed keybinding unit tests
tig Sep 27, 2024
47a9ef7
Fixed mouse handling
tig Sep 27, 2024
23c3ec8
Fighting with CM related unit test failures
tig Sep 27, 2024
493ece7
Unit tests pass. I think.
tig Sep 27, 2024
16e7689
Shortcut code cleanup
tig Sep 27, 2024
5d9e0d1
TextView uses new CM2
tig Sep 27, 2024
fb85d44
Starting on OnSelect etc...
tig Sep 28, 2024
bdc947e
Starting on OnSelect etc...
tig Sep 28, 2024
8b54152
Merge branch 'v2_develop' into v2_3691-Popover
tig Oct 2, 2024
6800168
Merged and debugged and mostly fixed stuff.
tig Oct 3, 2024
5d67850
Merge branch 'v2_develop' into v2_3691-Popover
tig Oct 7, 2024
be46664
Merged - builds
tig Oct 7, 2024
a68dec2
Fixed ContextMenuv2
tig Oct 7, 2024
040f73a
Merge branch 'v2_3691-Popover' of tig:tig/Terminal.Gui into v2_3691-P…
tig Oct 7, 2024
8346348
ContextMenu is working again.
tig Oct 8, 2024
22dc075
Ugh. ANd fixed button api docs
tig Oct 8, 2024
125bc4e
merged
tig Oct 11, 2024
ed0b179
Fixed DrawHorizontalShadowTransparent (vertical was already fixed).
tig Oct 11, 2024
4fef1c2
Merge branch 'v2_3691-Popover' of tig:tig/Terminal.Gui into v2_3691-P…
tig Oct 11, 2024
f5ab50f
Made Scenarios compatible with #nullable enable
tig Oct 11, 2024
90fb7cc
Merge branch 'v2_develop' into v2_3691-Popover
tig Oct 11, 2024
e81ab44
Undid some keybinding stuff
tig Oct 11, 2024
3d5d101
Fixed stuff
tig Oct 11, 2024
a243cc8
Sped up unit tests
tig Oct 11, 2024
e63fb7c
Sped up unit tests 2
tig Oct 11, 2024
2f3dbe7
Sped up unit tests 3
tig Oct 11, 2024
883ab67
Messing with menus
tig Oct 13, 2024
4547d1b
Merged v2_develop
tig Nov 5, 2024
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
2 changes: 2 additions & 0 deletions Terminal.Gui/Application/Application.Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static partial class Application // Driver abstractions
/// <summary>Gets the <see cref="ConsoleDriver"/> that has been selected. See also <see cref="ForceDriver"/>.</summary>
public static ConsoleDriver? Driver { get; internal set; }

// BUGBUG: Force16Colors should be nullable.
/// <summary>
/// Gets or sets whether <see cref="Application.Driver"/> will be forced to output only the 16 colors defined in
/// <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
Expand All @@ -16,6 +17,7 @@ public static partial class Application // Driver abstractions
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
public static bool Force16Colors { get; set; }

// BUGBUG: ForceDriver should be nullable.
/// <summary>
/// Forces the use of the specified driver (one of "fake", "ansi", "curses", "net", or "windows"). If not
/// specified, the driver is selected based on the platform.
Expand Down
20 changes: 19 additions & 1 deletion Terminal.Gui/Application/Application.Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
return true;
}

if (Top is null)
View? top = Top;

if (Popover is { Visible: true })
{
top = Popover;
}

if (top is null)
{
foreach (Toplevel topLevel in TopLevels.ToList ())
{
Expand All @@ -37,7 +44,7 @@
}
else
{
if (Top.NewKeyDownEvent (key))

Check warning on line 47 in Terminal.Gui/Application/Application.Keyboard.cs

View workflow job for this annotation

GitHub Actions / build_release

Dereference of a possibly null reference.

Check warning on line 47 in Terminal.Gui/Application/Application.Keyboard.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 47 in Terminal.Gui/Application/Application.Keyboard.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (macos-latest)

Dereference of a possibly null reference.
{
return true;
}
Expand All @@ -49,6 +56,11 @@
{
if (binding.Value.BoundView is { })
{
if (!binding.Value.BoundView.Enabled)
{
return false;
}

bool? handled = binding.Value.BoundView?.InvokeCommands (binding.Value.Commands, binding.Key, binding.Value);

if (handled != null && (bool)handled)
Expand Down Expand Up @@ -164,6 +176,12 @@
Command.Quit,
static () =>
{
if (Popover is {Visible: true})
{
Popover.Visible = false;

return true;
}
RequestStop ();

return true;
Expand Down
25 changes: 21 additions & 4 deletions Terminal.Gui/Application/Application.Mouse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable
using System.ComponentModel;
using System.Diagnostics;

namespace Terminal.Gui;

Expand Down Expand Up @@ -165,16 +166,31 @@ internal static void RaiseMouseEvent (MouseEventArgs mouseEvent)
return;
}

if (Popover is { Visible: true }
&& View.IsInHierarchy (Popover, deepestViewUnderMouse, includeAdornments: true) is false
&& (mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed)
|| mouseEvent.Flags.HasFlag (MouseFlags.Button2Pressed)
|| mouseEvent.Flags.HasFlag (MouseFlags.Button3Pressed)))
{

Popover.Visible = false;

// Recurse once
RaiseMouseEvent (mouseEvent);

return;
}

if (HandleMouseGrab (deepestViewUnderMouse, mouseEvent))
{
return;
}

WantContinuousButtonPressedView = deepestViewUnderMouse switch
{
{ WantContinuousButtonPressed: true } => deepestViewUnderMouse,
_ => null
};
{
{ WantContinuousButtonPressed: true } => deepestViewUnderMouse,
_ => null
};

// May be null before the prior condition or the condition may set it as null.
// So, the checking must be outside the prior condition.
Expand Down Expand Up @@ -213,6 +229,7 @@ internal static void RaiseMouseEvent (MouseEventArgs mouseEvent)
else
{
// The mouse was outside any View's Viewport.
Debug.Fail ("this should not happen.");

// Debug.Fail ("This should never happen. If it does please file an Issue!!");

Expand Down
87 changes: 87 additions & 0 deletions Terminal.Gui/Application/Application.Popover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#nullable enable
namespace Terminal.Gui;

public static partial class Application // Popover handling
{
private static View? _popover;

/// <summary>Gets or sets the Application Popover View.</summary>
/// <remarks>
/// <para>
/// To show or hide the Popover, set it's <see cref="View.Visible"/> property.
/// </para>
/// </remarks>
public static View? Popover
{
get => _popover;
set
{
if (_popover == value)
{
return;
}

if (_popover is { })
{
_popover.Visible = false;
_popover.VisibleChanging -= PopoverVisibleChanging;
}

_popover = value;

if (_popover is { })
{
if (!_popover.IsInitialized)
{
_popover.BeginInit ();
_popover.EndInit ();
}

_popover.Arrangement |= ViewArrangement.Overlapped;

if (_popover.ColorScheme is null)
{
_popover.ColorScheme = Top?.ColorScheme;
}

_popover.SetRelativeLayout (Screen.Size);

_popover.VisibleChanging += PopoverVisibleChanging;
}
}
}

private static void PopoverVisibleChanging (object? sender, CancelEventArgs<bool> e)
{
if (Popover is null)
{
return;
}

if (e.NewValue)
{
Popover.Arrangement |= ViewArrangement.Overlapped;

Popover.ColorScheme ??= Top?.ColorScheme;

View.GetLocationEnsuringFullVisibility (
Popover,
Popover.Frame.X,
Popover.Frame.Y,
out int nx,
out int ny);

Popover.X = nx;
Popover.Y = ny;

Popover.SetRelativeLayout (Screen.Size);

if (Top is { })
{
Top.HasFocus = false;
}

Popover?.SetFocus ();
}
}
}
12 changes: 12 additions & 0 deletions Terminal.Gui/Application/Application.Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,13 @@ public static void Refresh ()
tl.Draw ();
}

if (Popover is { LayoutNeeded: true })
{
Popover.LayoutSubviews ();
}

Popover?.Draw ();

Driver!.Refresh ();
}

Expand Down Expand Up @@ -667,6 +674,11 @@ public static void End (RunState runState)

_cachedRunStateToplevel = runState.Toplevel;

if (Popover is { })
{
Popover = null;
}

runState.Toplevel = null;
runState.Dispose ();

Expand Down
2 changes: 2 additions & 0 deletions Terminal.Gui/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ internal static void ResetState (bool ignoreDisposed = false)
Top = null;
_cachedRunStateToplevel = null;

Popover = null;

// MainLoop stuff
MainLoop?.Dispose ();
MainLoop = null;
Expand Down
8 changes: 8 additions & 0 deletions Terminal.Gui/Application/ApplicationNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
return _focused;

if (_focused is { CanFocus: true, HasFocus: true })

Check warning on line 34 in Terminal.Gui/Application/ApplicationNavigation.cs

View workflow job for this annotation

GitHub Actions / build_release

Unreachable code detected

Check warning on line 34 in Terminal.Gui/Application/ApplicationNavigation.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Unreachable code detected

Check warning on line 34 in Terminal.Gui/Application/ApplicationNavigation.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (macos-latest)

Unreachable code detected
{
return _focused;
}
Expand Down Expand Up @@ -85,6 +85,10 @@
/// </remarks>
internal void SetFocused (View? value)
{
if (value is null)
{

}
if (_focused == value)
{
return;
Expand Down Expand Up @@ -113,6 +117,10 @@
/// </returns>
public bool AdvanceFocus (NavigationDirection direction, TabBehavior? behavior)
{
if (Application.Popover is { Visible: true })
{
return Application.Popover.AdvanceFocus (direction, behavior);
}
return Application.Top is { } && Application.Top.AdvanceFocus (direction, behavior);
}
}
5 changes: 5 additions & 0 deletions Terminal.Gui/Drawing/Glyphs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
/// </remarks>
public class GlyphDefinitions
{
// IMPORTANT: If you change these, make sure to update the ./Resources/config.json file as
// IMPORTANT: it is the source of truth for the default glyphs at runtime.
// IMPORTANT: Configuration Manager test SaveDefaults uses this class to generate the default config file
// IMPORTANT: in ./UnitTests/bin/Debug/netX.0/config.json

/// <summary>File icon. Defaults to ☰ (Trigram For Heaven)</summary>
public Rune File { get; set; } = (Rune)'☰';

Expand Down
Loading
Loading