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

Enable Text widget #143

Merged
merged 2 commits into from
Nov 9, 2023
Merged

Enable Text widget #143

merged 2 commits into from
Nov 9, 2023

Conversation

nicoburns
Copy link
Contributor

@nicoburns nicoburns commented Nov 8, 2023

There was already a text widget in the repository. This PR:

  • Enables the text view and widget modules
  • Fixes them up so they compile with latest Xilem
  • Implements compute_max_intrinsic for text

I'm not sure that having String for the view makes sense because:

  • Strings are not string literals, so the DX isn't that great anyway as you have to wrap in String::from, which is longer than some hypothetical text function for a custom text type.
  • We're almost certainly going to want modifiers on text like font size, color, etc. And we'll need to store those somewhere.

But I've left it as String for now.

@nicoburns nicoburns added the enhancement New feature or request label Nov 8, 2023
@Philipp-M
Copy link
Contributor

Strings are not string literals, so the DX isn't that great anyway as you have to wrap in String::from, which is longer than some hypothetical text function for a custom text type.

We'll likely need all kinds View impls for string based views (&str, Cow<str> etc.), and I think they may share all the same widget, and maybe even wrap the same text view.

We're almost certainly going to want modifiers on text like font size, color, etc. And we'll need to store those somewhere.

I think a few composing style views probably make sense for such views (and maybe in general). Something like StyledText<String> or StyledText<&'static str>.

I'll try to review this later (or in the following few days).

Copy link
Contributor

@Philipp-M Philipp-M left a comment

Choose a reason for hiding this comment

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

Apart from the one comment, this looks good to me, thanks, finally support for strings :)

src/widget/text.rs Outdated Show resolved Hide resolved
src/view/text.rs Outdated Show resolved Hide resolved
@nicoburns nicoburns force-pushed the text-widget branch 2 times, most recently from ee8ed98 to f993d43 Compare November 9, 2023 23:34
@nicoburns nicoburns added this pull request to the merge queue Nov 9, 2023
Merged via the queue into main with commit 1656532 Nov 9, 2023
7 checks passed
@DJMcNab DJMcNab deleted the text-widget branch April 28, 2024 16:29
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

Successfully merging this pull request may close these issues.

2 participants