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

Line canvas exclude method #3004

Merged
merged 20 commits into from
Nov 26, 2023
Merged

Line canvas exclude method #3004

merged 20 commits into from
Nov 26, 2023

Conversation

tznind
Copy link
Collaborator

@tznind tznind commented Nov 21, 2023

Fixes #_____ - Include a terse summary of the change or which issue is fixed.

This is a WIP. Current implementation only works for parallel exclusion, perpendicular exclusion and more tests will be added before I mark this ready. There may be 'off by 1' type bugs.

It is an alternative to the proposed DrawIncompleteFrame.

Use Case:
Ability to draw rectangles (or other shapes) with parts of the boundary line snipped out e.g. for TabView. Also in general, to apply an 'eraser' effect to a LineCanvas.

Approach:
Adds extension method Exclude to collections of StraightLine (this decouples the method from LineCanvas).

exclude

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
Copy link
Collaborator

tig commented Nov 21, 2023

Wow. Just wow. 🤩

@tznind
Copy link
Collaborator Author

tznind commented Nov 21, 2023

Now works for perpendicular intersection too (cutting at most 1 cell out - i.e. splitting a line into 2).

@tznind
Copy link
Collaborator Author

tznind commented Nov 21, 2023

One corner case bug currently is that the resulting lines are always of positive length.

Now a horizontal line x=1 with length 5 is the same as one with x=5 with length -5

But not so for the special case of length = 1 vs length = -1 when joined to another line. In this case a UL or LL is created depending on positivity of the length.

So I think I will need to ensure returned lines keep their +/- length.

See here when cutting horizontally just above the bottom line the bottom corners flip to pointing downwards (+1 length is down on y axis)

flip-down

@BDisp
Copy link
Collaborator

BDisp commented Nov 21, 2023

One corner case bug currently is that the resulting lines are always of positive length.

No it can't, otherwise you can't control the flow.

Now a horizontal line x=1 with length 5 is the same as one with x=5 with length -5

That the right behavior.

But not so for the special case of length = 1 vs length = -1 when joined to another line. In this case a UL or LL is created depending on positivity of the length.

That was the problem I was facing before and I made confusion that corner could have more than one way to achieve them, but thankfully to you I learned that they must have unique values and the only exception is that no matter if vertical or horizontal are used first.

So I think I will need to ensure returned lines keep their +/- length.

Make sure it always return the signal value.

See here when cutting horizontally just above the bottom line the bottom corners flip to pointing downwards (+1 length is down on y axis)

Yes I see, but I think you can manipulate that by getting the Y position where you cutting and the corner case you are manipulating. If the desired effect is the opposite return the right ones.

@tznind tznind marked this pull request as ready for review November 25, 2023 15:22
@tznind tznind requested a review from tig as a code owner November 25, 2023 15:22
@tznind
Copy link
Collaborator Author

tznind commented Nov 25, 2023

Error is tree view colors unit test. Should be good to go though.

@tig tig merged commit 8ed1b16 into gui-cs:v2_develop Nov 26, 2023
1 check failed
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.

3 participants