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
Absolute Position Layout #459
Comments
Hi, and thanks for the report! Forking/taking inspiration from LinearLayout is indeed the current way to add view groups that aren't available as built-ins yet. If the layout itself is already taken care of, then a lot of code from there will be unnecessary. Do you have more details regarding this absolute layout you'd like? What kind of API would you expect? |
Thanks for responding and maintaining this great project. I just need something to set the position relative to its parent view. Modified from the hello world example:
I think everything else I can achieve by composing the existing views. |
I see. What size would each child receive? The maximum size possible without causing overlap? Say I add 3 children, all asking to be as big as possible:
And assuming the view is given a size of (2, 2) to work with. Something like:
Here. Or would you handle this internally with |
I'm not very familiar with layout algorithms. I imagined that was some kind of default behavior and that I could add a wrapping fixed_width/fixed_height wrapper view around each element to specify what I need. Perhaps that should just be a width/height argument? For me your question is all handled with Here's a neat playground: https://yogalayout.com/playground/ . Once |
Thanks for the details! I started working on such a layout; the main complexity is now just in handling focus change (for example find out which view is "to the left" of the current view). The other question is how the view dimensions/positions will be updated, either if views are added or if the terminal is resized.
|
Thanks so much for looking into this! For my use case what I'd prefer is actually an API like I think for my use case I'll be wrapping the event loop and single step Cursive and interleave my event: But I haven't gotten that far yet. I think I already have everything I need as far as that's concerned. I can work with anything you provide. |
Do you have a branch or a draft I can take a look? I’m going to look into this some more. |
A bit busy these days. Will come back to this soon. |
The EDIT: The branch also brings |
Thank you for doing this! Looking great so far. I think FixedLayout::required_size should use I'm still implementing I'll have more concrete feedback shortly. |
Whoops you're very right, should be fixed now |
It appears that view names are not updated for children added during call_on_name. I'm struggling to update the views at runtime.
|
Arf yesh I forgot some method implementations from the |
Initial render, and wrapping the event loop is all working fine. I'm facing an issue with updating the position of views and removing views. FixedLayout is accessed via position. This requires my code to track position in-sync out of band. I could either iterate over all the children myself and check if they're a named view, but AFAIK I can't query the name of a Suggestion: Have a variant of |
Ah right - added Also added |
Perfect. Thank you! |
Glad it solves your problem (for now)! |
First: Suggestion / Help
Problem description
Context: I've got a toy re-implementation of React in Rust generating a Virtual DOM. It's already handling layout via Stretch. I'm trying to use Cursive as one 'DOM' backend to show a new novel use case of implementation.
I'm trying to find the best method to absolute position the views according to my position/size information. Looks like it's not supported? Is my best bet to fork LinearLayout into an absolute view?
Environment
locale
in a terminal). en_US.UTF-8The text was updated successfully, but these errors were encountered: