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

Text editor shrinking to content #2221

Merged
merged 3 commits into from
Feb 7, 2024
Merged

Conversation

kyteware
Copy link
Contributor

I wanted to have a column with a mix of text-editors and other elements, but the current implementation meant I needed to create editors with fixed heights so that they wouldn't consume the entire space (not ideal). This PR resolves this issue by giving the option to shrink. Editors still default to filling the limit height.

Example usage:

let editor = TextEditor::new(content).shrink_to_content(true);

No shrinking:
https://vimeo.com/907639154?share=copy

With shrinking
https://vimeo.com/907639138?share=copy

I'm not super familiar with how general layouts tend to work in GUI development, its possible that there are some oversights in my code and I may have overcomplicated the solution (as far as I could with 20 lines of code).

@hecrj hecrj added this to the 0.12 milestone Feb 7, 2024
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I have fixed an issue with wrapped lines and renamed the TextEditor property to simply height.

The fix should have a bit of overhead, but Shrink editors should not be used without a text limit of some sort anyways!

@hecrj hecrj enabled auto-merge February 7, 2024 20:53
@hecrj hecrj merged commit 111c8bf into iced-rs:master Feb 7, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants