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

Allow SplitFixed to set the size of the second container #292

Open
pavel-lexyr opened this issue Feb 5, 2021 · 11 comments
Open

Allow SplitFixed to set the size of the second container #292

pavel-lexyr opened this issue Feb 5, 2021 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@pavel-lexyr
Copy link

Issue

As per the documentation,

// SplitFixed sets the size of the first container to be a fixed value
// and makes the second container take up the remaining space.
// When using SplitVertical, the provided size is applied to the new left
// container, the new right container gets the reminder of the size.
// When using SplitHorizontal, the provided size is applied to the new top
// container, the new bottom container gets the reminder of the size.

This allows for simple adaptive design if one wants to fix widgets on the left side or on top of the screen. Fixing a widget on the bottom is comparatively complex, (or entirely simple, but not documented).

It would be a helpful change to allow fixing the second container in splits.

Proposed API change:

container.SplitFixed is to allow numbers from 1-cells to -1 as its argument. Providing it with a number like this fixes the second container to the absolute value of the argument. Values of 0 and cells are preserved as is to maintain backwards compatibility.

@pavel-lexyr pavel-lexyr changed the title Allow SplitFixed to set the size of the second container. Allow SplitFixed to set the size of the second container Feb 5, 2021
@mum4k mum4k added the question Further information is requested label Feb 6, 2021
@mum4k
Copy link
Owner

mum4k commented Feb 6, 2021

Hi @Ludar-Pavel, I think you raise a very good point here.

Can you help me understand which of the following you are proposing?

a) Allow the split functions to take one or the other size as a fixed number, but continue adjusting the other size dynamically according to the available space. I.e. the user can either set the left/top side to a fixed size and the size right/bottom part gets the remaining space as its size, or vice versa.

or

b) Allow the split functions to take both sizes as a fixed number, allowing the user to set both the left/top and right/bottom parts ti a fixed size.

I think (a) is something very workable in the current architecture and we just need to discuss how to change the API. (b) would be harder due to assumptions made by the infrastructure. We can discuss these and try to find solutions if (b) is the goal.

@pavel-lexyr
Copy link
Author

(a) is definitely the goal here - it's hard to imagine how (b) would work with the current way layout is set up.

@mum4k
Copy link
Owner

mum4k commented Feb 12, 2021

Thank you for confirming that @Ludar-Pavel, (a) is definitely workable and we just need to agree on how we make the API change.

Before we do that, can you please indicate if this is something you would be interested in implementing, or if you would prefer I do the implementation?

@pavel-lexyr
Copy link
Author

I imagine you doing it would incur less overhead - not very versed in Go myself. Do wish you all the best in implementation, though!

@mum4k
Copy link
Owner

mum4k commented Feb 15, 2021

Thank you @Ludar-Pavel, I will update here once it gets implemented.

@mum4k mum4k added enhancement New feature or request and removed question Further information is requested labels Feb 15, 2021
@spacez320
Copy link
Contributor

Hey @mum4k , any updates on a potential implementation? Would you still be interested in changing the API to allow for this, or interested in possible contributions for it?

@mum4k
Copy link
Owner

mum4k commented Feb 27, 2024

Thank you for expressing interest in this @spacez320. As far as I know, this isn't currently worked on, you are more than welcome to pick it up if interested.

From the API perspective, I would recommend we implement a new option instead of giving negative numbers special meaning when SplitFixed is called. Here is one suggestion, but I am open to other ideas.

  1. Keep the meaning of the SplitFixed option as it is today for backwards compatibility.
  2. Add a new SplitOption, something like SplitFixedFromEnd that allows to specify the size of the split from right/bottom.

Please feel free to suggest a cleaner way.

@spacez320
Copy link
Contributor

@mum4k I like SplitFixedFromEnd, great suggestion. We'll go with that.

Let me know if there is a timeline I should work against, otherwise I should be able to approach this soon.

@mum4k
Copy link
Owner

mum4k commented Feb 27, 2024

Thank you for offering to help, I will assign this issue to you.

No particular timeline, please work at your convenience. I am happy to tag a new release whenever this will be available.

@spacez320
Copy link
Contributor

@mum4k I'm planning on still adding the SplitFixedFromEnd function and leaving the existing public API alone, but I am proposing an API change under private/.

See: #373

Let me know if that's not ok and we should leave the entire interface alone.

@spacez320
Copy link
Contributor

@mum4k #373 is ready to be looked at.

For anyone who might be following, the above change preserves the entire API and only augments.

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

No branches or pull requests

3 participants