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

Refactor Border to use subviews for title, lines, and close button #3407

Open
Tracked by #2994
tig opened this issue Apr 15, 2024 · 1 comment · May be fixed by #3862
Open
Tracked by #2994

Refactor Border to use subviews for title, lines, and close button #3407

tig opened this issue Apr 15, 2024 · 1 comment · May be fixed by #3862
Assignees
Milestone

Comments

@tig
Copy link
Collaborator

tig commented Apr 15, 2024

Related:

Requires

Will enable

Design

Subviews

public Label TitleLabel { get; set; };
public Button CloseButton { get ; set; }
public Line Top { get; set; }
public Line Left { get; set; }
public Line Right{ get; set; }
public Line Bottom{ get; set; }

Layout

This also indicates the order the views should be added; The label & button must be added after the lines so that they occlude them.

Top.X = Pos.Function (Thickness.Left/ 2);
Top.Y = Pos.Function (Thickness.Top / 2);
Top.Width = Dim.Fill () - Dim.Function (Thickness.Right / 2);

Left.X = Pos.Left (Top);
Left.Y = Pos.Top (Top);
Left.Height = Dim.Fill () - Dim.Function (Thickness.Bottom / 2);

Right.X = Pos.Right (Top);
Right.Y = Pos.Top (Top);
Right.Height = Dim.Fill () - Dim.Function (Thickness.Bottom / 2);

Bottom.X = Pos.Left (Top);
Bottom.Y= Pos.Bottom (Left);
Bottom.Width = Dim.Fill () - Dim.Function (Thickness.Right / 2);

TitleLabel.X = Pos.Right (Left) + 1;
TitleLabelY = Pos.Top (Top);

CloseButton .X = Pos.Left (Right) - 1;
CloseButton .Y = Pos.Top (Top);

Example usage:

view.Border.TitleLabel.X = Pos.Center (); // centers title (default is X = 1)
view.Border.TitleLabel.Visible = false; // Turn off the Title.
@tig
Copy link
Collaborator Author

tig commented Aug 13, 2024

From #2814 which I just closed:

Mini-Spec

Three scenarios so far:

  • User clicks on a button in the Border (top/right) that causes a Modal to quit.
  • User clicks on a button in the Border (top/right) that causes an Overlapped to close/hide.
  • User clicks on a button in the Border (top/right) that causes the view to collapse/expand.

We will create 3 new View subclasses, one for each of these:

  • ApplicationQuitter - Glyph is an X. MouseClick, and KeyBinding (Space) invoke Command.QuitToplevel (to be renamed to Command.Close). The command handler simply calls Application.RequestStop().
  • ViewHider -  Glyph is an X. MouseClick, and KeyBinding (Space) invoke Command.Close. The command handler simply calls SuperView.Parent.Visible = false. (or perhaps we add Close() as a verb on View?).
  • ViewExpander - Glyph is a up/down arrow. MouseClick, and KeyBinding (Space) invoke Command.ToggleExpandCollapse. Command hander
    • Disables/Hides/Enables/Shows SuperView.Parent's subviews
    • Sets the Height of the SuperView.Parent to 3 or Dim.Auto

Devs will add these views via view.Border.Add.

This is what ViewExpander will look like/do:

9rGXIUs 1

I've built a POC of ViewExpander in #3376

Background

This is a sub-issue of:

Will be fixed in this PR as a proof:

Background

Is your feature request related to a problem? Please describe.
I want user to be able to close button by [X] button near dialog title from top right side. And I want them to be shown in Query dialogs by default. Because when you pass no button its not clear, that you need Escape button to be pressed to close it.

Describe the solution you'd like
For dialogs and querries to have [x] button: Dialog Title [x]

Describe alternatives you've considered
Have close button as now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗 Approved - In progress
1 participant