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: Use bitflags for edit text flags #7853

Merged
merged 4 commits into from
Sep 7, 2022

Conversation

Herschel
Copy link
Member

@Herschel Herschel commented Sep 3, 2022

Clean up the massive set of bools used by swf::EditText and core::edit_text::EditText.

  • Add swf::EditTextFlag for the bits used by the DefineEditText SWF tag.
  • Add builder-like methods to swf::EditText to allow setting these flags and values.
  • Add core::edit_text::EditTextFlag that extends this with additional flags used by core/ActionScript.
  • Simplify EditTextStatic as it was mostly unused fields.
  • Fix a bug where height should be read in DefineEditText when the HAS_FONT_CLASS flag is set.

Shaves off 8 bytes or so from EditText. This is a small step to make #7749 nicer.

@Herschel Herschel marked this pull request as draft September 3, 2022 05:47
@Herschel Herschel force-pushed the swf-edit-text-flags branch 2 times, most recently from 570108b to 7997c7c Compare September 3, 2022 06:30
swf/src/types.rs Outdated Show resolved Hide resolved
@Herschel Herschel force-pushed the swf-edit-text-flags branch 3 times, most recently from cd702a2 to 3913b51 Compare September 5, 2022 03:09
@Herschel Herschel marked this pull request as ready for review September 5, 2022 03:12
@Herschel Herschel force-pushed the swf-edit-text-flags branch from 3913b51 to 2f32023 Compare September 5, 2022 03:21
@Herschel Herschel requested a review from relrelb September 5, 2022 03:21
@Herschel Herschel force-pushed the swf-edit-text-flags branch from 2f32023 to cf3905a Compare September 5, 2022 04:00

/// If the text field should have a background. Only applied when has_border.
has_background: bool,

/// The color of the background fill. Only applied when has_border and has_background.
background_color: u32,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think background_color and border_color should be swf::Color, but that's for a future PR.

The SWF19 specs incorrectly state DefineEditText tag only contains
font height if the HasFont flag is set. The tag also contains
the height if the HasFontClass flag is set. This indicates that a
font is used via runtime sharing.
@Herschel Herschel force-pushed the swf-edit-text-flags branch from cf3905a to f9bd2ea Compare September 7, 2022 02:45
@Herschel Herschel merged commit de114f0 into ruffle-rs:master Sep 7, 2022
@Herschel Herschel deleted the swf-edit-text-flags branch September 7, 2022 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants