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

Fixes #3691. Adds Popover #3749

wants to merge 53 commits into from

Conversation

tig
Copy link
Collaborator

@tig tig commented Sep 19, 2024

Fixes

fykztjo 1

fImBrr3 1

Proposed Changes/Todos

Future PRs

  • Replace Menu and MenuBar using Bar (aka finish Menuv2

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@tig tig changed the title V2 3691 popover Fixes #3691. Adds Popover Sep 19, 2024
@tig
Copy link
Collaborator Author

tig commented Sep 19, 2024

FWIW, here's the API in action (the prototype for the File menubar item in Bars):

var fileMenuBarItem = new Shortcut
{
    Title = "_File",
    HelpText = "File Menu",
    Key = Key.D0.WithAlt,
};

fileMenuBarItem.Accept += (sender, args) =>
                          {
                              var fileMenu = new Menuv2
                              {
                                  Id = "fileMenu",
                              };
                              ConfigureMenu (fileMenu);
                              fileMenu.VisibleChanged += (sender, args) =>
                                                         {
                                                             if (Application.Popover == _popoverMenu && Application.Popover is { Visible: false })
                                                             {
                                                                 Application.Popover?.Dispose ();
                                                                 Application.Popover = null;
                                                             }
                                                         };
                              Application.Popover = fileMenu;
                              Rectangle screen = fileMenuBarItem.FrameToScreen ();
                              fileMenu.X = screen.X;
                              fileMenu.Y = screen.Y + screen.Height;
                              fileMenu.Visible = true;

                          };

Here's the entirety of the new API (on Application):

    /// <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

@tig
Copy link
Collaborator Author

tig commented Sep 23, 2024

ZtNvfaH 1

@tig
Copy link
Collaborator Author

tig commented Sep 23, 2024

Kinda cool. Mouse wheel will now be able to nav within a Bar (or Menu).

AKE5pyM 1

@tig
Copy link
Collaborator Author

tig commented Sep 26, 2024

n4wBc8q 1

A new ContextMenuv2 implementation.

TextField now uses it instead of the old one.

@tig
Copy link
Collaborator Author

tig commented Sep 27, 2024

The TextField has no sense to start his position at cursor position, TextView has. TextField must start his position at (0,1), but never over it unless it doesn't fit.

I don't understand.

TextView does know the cursor pos. I've used it to position the CM in this PR. I'm travelling today so can't send a video. Try it and let me know what you think.

@BDisp
Copy link
Collaborator

BDisp commented Sep 27, 2024

Nothing of this is working in your PR. You put a zig zag menus for what? To show that this will stopping working? UseSubMenusSingleFrame will also not working in the new Popover? To me a ContextMenu must work like a Menu but without a visible MenuBar. Popover should be used for floated view that will show content on front of others views. But that only my opinion.

image

@BDisp
Copy link
Collaborator

BDisp commented Sep 27, 2024

In this PR:

WindowsTerminal_sfT355oQXG

In v2_develop the MenuBar is not showing.

WindowsTerminal_TFdFrY5i9k

@tig
Copy link
Collaborator Author

tig commented Sep 27, 2024

Nothing of this is working in your PR. You put a zig zag menus for what? To show that this will stopping working? UseSubMenusSingleFrame will also not working in the new Popover? To me a ContextMenu must work like a Menu but without a visible MenuBar. Popover should be used for floated view that will show content on front of others views. But that only my opinion.

image

This is a WIP. I will add the more advanced features as I progress.

@tig
Copy link
Collaborator Author

tig commented Sep 27, 2024

In this PR:

WindowsTerminal_sfT355oQXG

In v2_develop the MenuBar is not showing.

WindowsTerminal_TFdFrY5i9k

This is because Window is set for Overlapped/Movable/Sizable.

Please file a bug for me to make it so arrange mode is disabled if Top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants