Skip to content

Text editor shrinking to content#2221

Merged
hecrj merged 3 commits into
iced-rs:masterfrom
ryanwarfield:text-shrink
Feb 7, 2024
Merged

Text editor shrinking to content#2221
hecrj merged 3 commits into
iced-rs:masterfrom
ryanwarfield:text-shrink

Conversation

@ryanwarfield

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

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

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
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