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 #1785. Adds Pos.Align - Align sets of views horizontally or vertically #3415

Open
wants to merge 172 commits into
base: v2_develop
Choose a base branch
from

Conversation

tig
Copy link
Collaborator

@tig tig commented Apr 17, 2024

Fixes

Proposed Changes/Todos

  • Prototype & experiment
  • Build generic/flexible justification engine that will work for both text and view layout
  • Implement prototype Pos.Justify that automatically justifies views on the same X or Y axis with the same Justification setting
    • This works. See Generic scenario.
    • Note Dialog/Message box is broken.
    • It won't work for real because the automatic behavior is too limiting.
    • Add GroupID - Default is zero and zero gets auto behavior
  • Refactor Justification class to be an instance class that can hold all the settings, calling Justification.Justify(...) static method
  • Add PosJustification Scenario
  • Justifier -> Add events
  • Pos.Justify -> Cache location
  • Update Dialog (and MessageBox)
  • Remove old TextAlignment and `VerticalTextAlignment``enums.
  • Rename "Justify" back to "Align"
  • Other Pos/Dim -> Cache location/size?
  • Unit Tests

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 mentioned this pull request Apr 21, 2024
@tig
Copy link
Collaborator Author

tig commented May 9, 2024

9TY52CS 1

@tig tig marked this pull request as ready for review May 9, 2024 20:05
@tig
Copy link
Collaborator Author

tig commented May 9, 2024

While this does not yet have sufficient unit tests, it is ready for review.

I'm specifically looking for feedback on the API.

The typical use-case where someone has a set of horizontal subviews they want justified (e.g. Dialog's buttons) is:

Button button1 = new () { Title = "Button 1", X = Pos.Justify(Justification.Center), Y = Pos.Bottom() };
Button button2 = new () { Title = "Button 2", X = Pos.Justify(Justification.Center), Y = Pos.Bottom() };
Button button3 = new () { Title = "Button 3", X = Pos.Justify(Justification.Center), Y = Pos.Bottom() };
Add (button1, button2, button3);

If there are multiple groups:

const int CHECKBOXGROUP = 1;
Checkbox cb1 = new () { Title = "Check 1", X = Pos.Justify(Justification.Justified, CHECKBOXGROUP), Y = 0};
Checkbox cb2 = new () { Title = "Check 2", X = Pos.Justify(Justification.Justified, CHECKBOXGROUP), Y = 0};
Checkbox cb3 = new () { Title = "Check 3", X = Pos.Justify(Justification.Justified, CHECKBOXGROUP), Y = 0};
Add (cb1, cb2, cb3);

const int BUTTONGROUP = 2;
Button button1 = new () { Title = "Button 1", X = Pos.Justify(Justification.Center, BUTTONGROUP), Y = Pos.Bottom() };
Button button2 = new () { Title = "Button 2", X = Pos.Justify(Justification.Center, BUTTONGROUP), Y = Pos.Bottom() };
Button button3 = new () { Title = "Button 3", X = Pos.Justify(Justification.Center, BUTTONGROUP), Y = Pos.Bottom() };
Add (button1, button2, button3);

I'm open for suggestions for other ways to let devs have multiple sets of views that are independently justified other than the somewhat clunky "GroupID" concept. I've tried multiple things, including trying to make it automatic based on the opposite dimension, but what I have now seems to be the cleanest.

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

Successfully merging this pull request may close these issues.

None yet

3 participants