Commit Graph

1282 Commits

Author SHA1 Message Date
Nathan Adams 10b8f4abaf avm1: Handle stack poping in avm 2020-06-29 08:55:50 +02:00
Nathan Adams 84a5fae43f avm1: Only perform stack-frame adjustments in one place, not scattered throughout actions 2020-06-29 08:51:34 +02:00
Nathan Adams 9109d89daa avm1: Allow for frame control in StackFrame from any action 2020-06-29 08:51:34 +02:00
Nathan Adams 329716bfe7 avm1: Don't refetch activation.data every action 2020-06-29 08:51:33 +02:00
Nathan Adams af72f68f0f avm1: Run entire stack frames at once 2020-06-29 08:51:33 +02:00
Nathan Adams c6b9de883f avm1: Add Activation to StackFrame, removing lots of get-and-unwraps 2020-06-29 08:51:33 +02:00
Nathan Adams 4d76e8b24d avm1: Move all actions from Avm1 to a new StackFrame 2020-06-29 08:51:33 +02:00
Mike Welsh 3bc3d4acb2 text: Fix bindings being incorrectly cleared in StageObject
Call to `Vec::retain` was backwards, causing bindings to be
incorrectly cleared/not cleared when a text field was removed.
2020-06-28 23:38:58 -07:00
Mike Welsh 93cf7a1386 text: Use retire_stack_frame after firing text bindings 2020-06-28 23:37:50 -07:00
Mike Welsh ed82d984d2 text: Properly set text field position when created dynamically 2020-06-28 18:36:10 -07:00
Mike Welsh 7eeda7d93e chore: clippy 2020-06-28 18:36:10 -07:00
Mike Welsh ef31a6bea4 text: Don't override TextField::set_matrix and other layout changes
Don't override set_matrix and set_x for TextFields, and leave the
bounds intact.

TODO: There are still some wrapping issues in the tests, but
this allows the simple case of single-line texts to render
correctly.
2020-06-28 18:36:10 -07:00
Mike Welsh b40f9d4c1a avm1: Implement TextField.html 2020-06-28 18:36:10 -07:00
Mike Welsh d97a515330 tests: Add text field variable test 2020-06-28 18:36:10 -07:00
Mike Welsh 618fa11acb avm1: Implement text field variable binding 2020-06-28 18:36:10 -07:00
Mike Welsh 51d66c53f0 core: Edit text sets variables on instantiation 2020-06-28 18:36:10 -07:00
Mike Welsh 12fca71b21 avm1: Move StageObjectData behind a GC pointer 2020-06-28 18:36:10 -07:00
Mike Welsh a922fd559f avm1: Add EditText variable property
Add `EditText::variable` as well as `TextField.variable` property.
This commit only adds the getter/setter and does not yet add the
binding functionality.
2020-06-28 18:36:10 -07:00
Mike Welsh dd50071240 core: Move frame and goto methods from MovieClipData to MovieClip 2020-06-28 18:36:10 -07:00
Mike Welsh 8da0f43412 tests: Add test for DefineLocal and issue #760 2020-06-28 15:15:45 -07:00
Mike Welsh 52fbb77e99 avm1: DefineLocal respects virtual properties and prototype chain (fix #760)
DefineLocal will call a virtual setter if the property already exists
on the local object, including the local object's prototype chain.

DefineLocal2 will also not overwrite a property if it already exists
on the local object, including the local object's prototype chain.
2020-06-28 15:15:45 -07:00
Mike Welsh 905f9d7ac6 core: Clear mouse down flag even if there is no hovered object 2020-06-27 23:34:19 -07:00
Mike Welsh a846d92d8c core: Don't fire rollOut events if clip is removed
Allows the inventory to work in The Room Tribute.
2020-06-27 21:24:49 -07:00
Mike Welsh 0833c15e25 tests: Add test for enumerating array indices 2020-06-27 20:25:45 -07:00
Mike Welsh 478d88b22d tests: Test hasOwnProperty for array indices in array_properties 2020-06-27 20:25:45 -07:00
Mike Welsh 8e3b96f1b1 tests: Add tests for non-string params in hasOwnProperty: 2020-06-27 20:25:45 -07:00
Mike Welsh ccf33eedf6 avm1: Array indices are enumerable 2020-06-27 20:25:45 -07:00
Mike Welsh ecc54d01f7 avm1: Disallow setting "" property
object[""] has no effect.
2020-06-27 20:25:45 -07:00
Mike Welsh ef82fc472e avm1: Object.hasOwnProperty should coerce_to_string 2020-06-27 20:25:45 -07:00
Mike Welsh b37b74e0b6 tests: Add test for __constructor__ being DontEnum 2020-06-27 18:54:01 -07:00
Mike Welsh 054194026e avm1: Mark __constructor__ and constructor as DontEnum 2020-06-27 18:54:01 -07:00
dependabot-preview[bot] 63beea22a2 build(deps): bump weak-table from 0.2.3 to 0.3.0
Bumps [weak-table](https://github.com/tov/weak-table-rs) from 0.2.3 to 0.3.0.
- [Release notes](https://github.com/tov/weak-table-rs/releases)
- [Changelog](https://github.com/tov/weak-table-rs/blob/master/release.toml)
- [Commits](https://github.com/tov/weak-table-rs/compare/0.2.3...0.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-27 16:08:52 -07:00
dependabot-preview[bot] 82a86d6139 build(deps): bump png from 0.16.5 to 0.16.6
Bumps [png](https://github.com/image-rs/image-png) from 0.16.5 to 0.16.6.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-27 16:08:11 -07:00
Nathan Adams 463b79f063 avm1: Implement Action::Throw 2020-06-25 02:03:15 -07:00
Nathan Adams 70e4a40f01 avm1: Allow for user errors inside avm1::error::Error 2020-06-25 02:03:15 -07:00
Mike Welsh 81d75c6256
text: Text formatting for EditText fields (merge #615)
First implementation of HTML parsing and formatting for text fields.
2020-06-24 23:06:11 -07:00
Mike Welsh 5d9701313e text: Fix TextField.embedFonts setter 2020-06-24 22:46:59 -07:00
Mike Welsh b2c96336fd text: Cull text field if offscreen 2020-06-24 22:46:54 -07:00
David Wendt 74af7b345c Adjust `BoxBounds` to use `Copy` instead of `Clone`. 2020-06-24 23:40:27 -04:00
David Wendt d7a257f93f Adjust `LayoutContext` and `LayoutBox` to construct a `Vec` of boxes rather than an intrusive, garbage-collected linked list. 2020-06-24 23:34:38 -04:00
David Wendt d281452fe1 Expose the device font flag to AVM1 code. 2020-06-24 22:55:50 -04:00
David Wendt 453cf6c0f1 Remove *extremely* out of date documentation on `BoxBounds`. 2020-06-24 22:36:36 -04:00
David Wendt 2723c3f6d9 Rename `Collec` to `CollectWrapper` 2020-06-24 22:34:04 -04:00
David Wendt 5b36522258 Remove out-of-date doccomment on `LayoutBox`. 2020-06-24 22:19:16 -04:00
David Wendt 0b8d0e8c85 Move the internal padding to a separate constant. 2020-06-24 21:53:58 -04:00
David Wendt e4d4d996f9 Don't push each line of text down with the leading adjustment.
We already adjust the cursor with the same adjustment, so we don't need to move the text down.
2020-06-24 21:32:59 -04:00
David Wendt bfb150ec05 Remove hardcoded 3px margin.
This was originally intended to correctly position text within the border, but it appears borders are weird and this doesn't jive with what unbordered text does.
2020-06-24 21:32:59 -04:00
Mike Welsh 0f794489a4 text: Don't create underline drawing if no underline exists 2020-06-24 12:53:51 -07:00
Mike Welsh 3558e42c34 text: Always fallback to Noto Sans if text field is set to use device fonts 2020-06-24 12:19:06 -07:00
Mike Welsh f591e1dafc text: process_html_entity returns a Cow 2020-06-24 11:56:20 -07:00
Mike Welsh 5a7012923b avm1: Move TextField methods into functions 2020-06-24 11:11:00 -07:00
Mike Welsh d2702464a5 avm1: TextField properties are emumerable and deletable 2020-06-24 11:02:21 -07:00
Mike Welsh b47e84b131 text: Derive Default for TextFormat 2020-06-24 10:44:34 -07:00
CUB3D a5b0a196cc core: Update to use updated value conversion functions 2020-06-24 01:57:15 +01:00
CUB3D f03093528c core: Add shared object cache and saving on exit
On the desktop player, shared objects will now be flushed on quit.
Attempting to retrieve an existing shared object will now return a
reference to the existing one.
2020-06-24 01:46:42 +01:00
CUB3D 166cb60d89 chore: Clean up useage of unwrap 2020-06-24 01:46:07 +01:00
CUB3D 62834fd690 chore: Remove unnecessary comment 2020-06-24 01:46:07 +01:00
CUB3D fce8e8b7de chore: Fix build 2020-06-24 01:46:07 +01:00
CUB3D 8a65ac764b chore: Clean up comments 2020-06-24 01:46:07 +01:00
CUB3D 8e28bab159 chore: Fix clippy lints, refactor storage to use data_local_dir 2020-06-24 01:46:07 +01:00
CUB3D 0122d65a09 core: Refactor SharedObject 2020-06-24 01:46:07 +01:00
CUB3D 1b130ccd47 chore: Refactor storage access 2020-06-24 01:46:06 +01:00
CUB3D 4e286b43ae chore: Format 2020-06-24 01:46:06 +01:00
CUB3D 0c6a7b3b4c core: Add SharedObject object type 2020-06-24 01:46:05 +01:00
CUB3D 752ffc5cca chore: Fix clippy lints and tests 2020-06-24 01:44:07 +01:00
CUB3D eff06d3d4d core: Add stub listener methods for SharedObject 2020-06-24 01:43:25 +01:00
CUB3D d3ae6a3a40 core: Fix data property of SharedObject 2020-06-24 01:43:25 +01:00
CUB3D 48693e4a7a core: Add inital storage backend implementation
Currently SharedObjects are encoded and decoded from JSON via the
StorageBackend, also provided is a basic in-memory implementation
2020-06-24 01:43:23 +01:00
CUB3D 539b4b0f63 core: Add stub for SharedObject 2020-06-24 01:42:19 +01:00
David Wendt 12495de91e Generate `LI`s when newlines are encountered with bullets on. 2020-06-22 19:45:39 -04:00
David Wendt ed5f3cdd0e Don't attempt to use non-embedded fonts. Instead, replace all of them with Noto (like EditText used to do). 2020-06-22 19:02:32 -04:00
David Wendt 40ea58c1c0 Since we cannot parse `<br>` properly yet, replace them and `<sbr>` with newlines before parsing so that we don't get spurious parse errors. 2020-06-22 18:00:51 -04:00
dependabot-preview[bot] 0a166af8ac build(deps): bump syn from 1.0.32 to 1.0.33
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.32 to 1.0.33.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.32...1.0.33)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-22 10:15:50 -07:00
Nathan Adams cea2c9520d chore: Ignore new 'unnested_or_patterns' clippy lint as we the suggested behaviour doesn't exist outside of nightly 2020-06-21 04:18:44 -07:00
David Wendt 7a9796a2f9 Restore BR parsing.
Note that this won't actually work since we're behind an XML parser that chokes on implicitly self-closing HTML tags.
2020-06-20 20:15:00 -04:00
David Wendt c1ad37a0f6 Implement text span raising, sans list items.
During the raising process, we maintain a list of pointers to the lowest-most `textformat`, `p`, `font`, `a`, `b`, `i`, and `u` in the document that we are appending to. When we get a new one of any of those elements, we clear the rest off the stack. This forces us to add HTML in the same order Flash does.

LIs are not yet supported because they require us to process text line-by-line which doesn't mesh with this model.

There's also a test but the XML DOM generates HTML strings with the wrong attribute order, so the test fails spuriously.
2020-06-20 20:14:57 -04:00
David Wendt e036d6594b Add some entity support to HTML parsing. 2020-06-20 20:08:22 -04:00
David Wendt 88fcb98913 Allow disabling entity processing when parsing XML.
This necessitated a change to edittext_bullet, which turns out is accidentally an entity test, too. It now no longer uses entities so that it won't spuriously fail due to an entity related problem.
2020-06-20 20:06:21 -04:00
David Wendt 65f4d2cf1e Add regression tests for `underline`.
We're within 4px in every case.
2020-06-20 19:56:01 -04:00
David Wendt f097a6584e Implement underlines. 2020-06-20 19:56:01 -04:00
David Wendt d63b3f23e9 Add support for inserting arbitrary drawings into the layout. 2020-06-20 19:56:00 -04:00
David Wendt a2d69a69a3 Add a test for bullets.
As usual with most newline related things, we're 3px off no matter how many or how few lines we have.
2020-06-20 19:56:00 -04:00
David Wendt 1c371c3a95 Render bullets.
Bullets are implemented by rendering U+2022 as if it were normal text, but always placed 18px from the left of the line. This appears to be sort of what Flash does.
2020-06-20 19:55:59 -04:00
David Wendt a3dfa8c21f Bulleted lists get 35px of additional left-margin and do not respect alignment at all. 2020-06-20 19:55:59 -04:00
David Wendt fa2da492a7 Allow ActionScript to control text field borders. 2020-06-20 19:55:58 -04:00
David Wendt 2aa7d9770f Draw a border around text if requested. 2020-06-20 19:55:58 -04:00
David Wendt 8628261dc8 Add a bunch of necessary fixes to default text formatting and HTML format extraction.
This also replaces the `edittext_html_defaults` test with a more robust test that checks the default format and global format of SWF-based, text, and HTML test vectors.
2020-06-20 19:55:57 -04:00
David Wendt 4f3d4c82fb For some reason, Flash does not respect `<br>` at all, so we won't, either.
It *does*, however, respect `<sbr>` (which does the exact same thing), as well as `\n` (which makes absolutely no sense in HTML, normally that would get stripped out).
2020-06-20 19:55:57 -04:00
David Wendt efc6236cb5 Treat the end of each paragraph as a newline. 2020-06-20 19:55:56 -04:00
David Wendt d5fc2709fc Don't use a slice to hold an index.
Fixes clippy on beta and nightly Rust.
2020-06-20 19:55:56 -04:00
David Wendt 58a039a6aa Nulls in font names are ignored. 2020-06-20 19:55:56 -04:00
David Wendt d8a38d06bb Collect font height, letter spacing and the kerning flag into a single `EvalParameters` structure. 2020-06-20 19:55:55 -04:00
David Wendt 1f6d6018dc Use a char pattern here for clippy's sake 2020-06-20 19:55:55 -04:00
David Wendt 1966ec5cb1 Implement `sbr` tags.
No, I don't know what they are either, but at least one movie exists which treats them like `br`, so we'll treat them like that, too.
2020-06-20 19:55:54 -04:00
David Wendt 9e56f10fd0 Approx the align and margins text by up to 3 pixels.
These tests currently have visual bugs in all cases, and measurement bugs in the justification case that require me to approx them.
2020-06-20 19:55:54 -04:00
David Wendt f746ac5539 Implement `justify`, mostly.
This implementation has a few bugs which appear to have something to do with alignment. It's not only justify, but justify is the only test that's flagged as failing.

If you look at the margins test, you'll see what I mean: right-aligned and justified text doesn't quite make it to the right edge of the box even though it should. I'm not sure why.

This also restricts text rounding further: `measure` now only rounds when wrapping text, since Flash Player appears to account for fractional pixels in all other cases.
2020-06-20 19:55:54 -04:00
David Wendt 670c4723e3 Add support for the `kerning` flag, which turns on and off the kerning information on fonts. 2020-06-20 19:55:53 -04:00
David Wendt 3c9a43ea72 Add a regression test for newlines.
This test includes tests for HTML newlines, which causes the XML parser in Ruffle to throw errors. Hence why it's currently ignored.
2020-06-20 19:55:53 -04:00
David Wendt 180ef3b423 Recognize `<br>` as a line break.
This code is currently unreachable as `<br>` will actually trigger an AVM1 error due to our overly-strict XML parser.
2020-06-20 19:55:52 -04:00
David Wendt 045a81e79e Implement `html` and `htmlText`... sort of.
There are several problems, first off:

1. I'm not entirely sure what I'm supposed to be changing on the text field when someone writes `html`.
2. We're using the XML parser for HTML (both `htmlText` and SWF tag parsing) which causes problems. Notably, `<br>` issues an AVM1 error (!!!) because the XML parser doesn't like unclosed tags.
3. Reading `htmlText` should not return the same HTML tree (at least, not until we implement stylesheets). It should instead regenerate an HTML tree from text spans.
2020-06-20 19:55:52 -04:00
David Wendt 2452124631 Break individual words at the start of lines that are too big to fit on the line. 2020-06-20 19:55:51 -04:00
David Wendt 6c44418b10 Add a test for tab_stops.
This test is currently inaccurate by up to 5 pixels, this is due to some behavior with really, really wide tabstops and word breaks that I don't entirely get yet.
2020-06-20 19:55:51 -04:00
David Wendt 2ad216cab4 Don't continue comparing tab stops after we find one that fits. 2020-06-20 19:55:50 -04:00
David Wendt b6c12b1e23 Use current font height times 2.7 as the natural tab stop, as that seems to match Flash... for now. 2020-06-20 19:55:50 -04:00
David Wendt 0e45dc12e9 Recompile the letter spacing test 'cause I spotted an errant `s` in the FLA 2020-06-20 19:55:49 -04:00
David Wendt 2caaa6875d Add support for explicit tabs and newlines. 2020-06-20 19:55:49 -04:00
David Wendt 153ab675e9 When aligning a line, actually consider all the boxes within the line. 2020-06-20 19:55:49 -04:00
David Wendt 3d094ed689 Add margins test.
This test is also approx'd to 1px due to the same issue where heights are off by one.
2020-06-20 19:55:48 -04:00
David Wendt db0398d2ee Left and right margins and indents should not be included in `textWidth`. 2020-06-20 19:55:48 -04:00
David Wendt 74d4c25133 Add a test for letter spacing.
This test is approximate because the 0.5px test is off by 1px in terms of height.
2020-06-20 19:55:47 -04:00
David Wendt 6ce7ecee78 Implement `letterSpacing`. 2020-06-20 19:55:47 -04:00
David Wendt 171954d5e4 Add `edittext_leading` test.
This test constructs a handful of text fields and measures them. Each field has 0, 5, or 15px of `leading` applied to it's text format.
2020-06-20 19:55:47 -04:00
David Wendt bbc73f1477 The `edittext_align` test now passes perfectly. 2020-06-20 19:55:46 -04:00
David Wendt 16da6d827c Line-leading is always applied at least once, even if there are no line breaks in the text field. 2020-06-20 19:55:46 -04:00
David Wendt 410fb3ab86 Don't round each line's leading. Instead, round at the end of the operation.
This was verified by visual comparison with Flash Player; lines of text appear to be shifted by half-pixels, while the script output is always still rounded down.
2020-06-20 19:55:45 -04:00
David Wendt 2858c09b6e Only apply leading adjustment on newlines.
This results in ALL height adjustments being off by 2px, regardless of leading or font size. Tantalizing!
2020-06-20 19:55:45 -04:00
David Wendt 2ab85c32e2 When wrapping text, measure the text including the trailing space (if present).
This matches Flash behavior, but breaks an existing test, which I've adjusted appropriately.
2020-06-20 19:55:44 -04:00
David Wendt c67bf0b6b7 Add approximate test of text field metrics during alignment.
This is an approximate text with a 1-pixel tolerance because our height is currently off by one and I cannot explain why. Previous attempts to fix the bug have resulted in cascading errors that resulted in off-by-one errors in the opposite direction. This is still better than nothing and I need to check other tests in.
2020-06-20 19:55:44 -04:00
David Wendt a1e52ab556 Add a test for formatting defaults on HTML text. 2020-06-20 19:55:44 -04:00
David Wendt 09c91d191a Round-trip tab stops between `EditText` and AVM1 2020-06-20 19:55:43 -04:00
David Wendt 00217072e6 After the previous set of fixes our tests are now consistent with a layout engine that always rounds down to the nearest pixel and never up. Adjust code to match. 2020-06-20 19:55:43 -04:00
David Wendt 06c66533c7 Don't apply leading twice. 2020-06-20 19:55:42 -04:00
David Wendt 82c6269cf6 Ensure that presentational markup styles cascade from parent tag to child, and from the default format to the first tag. 2020-06-20 19:55:42 -04:00
David Wendt 88d07f5d17 We don't need to relayout when the new-text text format gets changed. 2020-06-20 19:55:42 -04:00
David Wendt 9981148482 Add a test for `BoxBounds.with_size`, since we're using it now 2020-06-20 19:55:41 -04:00
David Wendt aae1f0ba7a Skip fixups on empty lines. 2020-06-20 19:55:41 -04:00
David Wendt bd40295076 Ensure that the font-provided leading is accounted for when moving the cursor for a newline. 2020-06-20 19:55:41 -04:00
David Wendt 0e0b2fb85d All layout boxes on the line should have trailing whitespace trimmed off of their measurements.
Flash has a weird bug where it will NOT trim trailing spaces off of the metrics reported to users if the text is left-aligned. We replicate this here so that tests pass.
2020-06-20 19:55:40 -04:00
David Wendt 50a05df998 Generated lines should *always* include their end spaces, there should be no gaps. 2020-06-20 19:55:40 -04:00
David Wendt ab2b9cc733 Change all of the `BoxBounds` in the layout machinery to not use `Default`.
The `Default` bounds are NOT safe to union against if they were uninitialized. Doing so will force any resulting layout box to enclose `(0,0)`, which can throw off certain layout calculations. Instead, we use `None` to signal an uninitialized box.
2020-06-20 19:55:40 -04:00
David Wendt 806a741bf4 EditText appears to have internal padding between it's borders equivalent to a CSS padding of `3px 4px 3px 0`.
Verified by experimentation with Flash Player, appears to be necessary for tests to pass.
2020-06-20 19:55:39 -04:00
David Wendt 96c43654d0 Retain the bounds returned when constructing layout boxes and use them as the `textWidth` and `textHeight` of a given text field. 2020-06-20 19:55:39 -04:00
David Wendt 318f09d241 Include the font-provided leading in the exterior bounds sent off for `autoSize` calculation. 2020-06-20 19:55:39 -04:00
David Wendt 06dc2f5fe0 Implement the `leading` attribute as defined by fonts.
`EditText` supports two different forms of leading:

1. Font-provided leading, specified relative to the EM square and scaled with font size
2. User-specificed leading, specified in pixels

Notably, the former appears to apply to the first line in the text and pushes it down. This showed up in the `edittext_font_size` test, and according to that test result the leading is rounded *up* to the nearest pixel, plus one.

That last bit seems possibly wrong and is subject to further change, but it matches the tests at multiple scales.
2020-06-20 19:55:29 -04:00
David Wendt 6e81f30a70 Round down to the nearest pixel when measuring text.
Certain text routines calculate text on the pixel grid, despite the fact that Flash ordinarily works in twips. There is probably a reason for this - my guess is to keep text wrapping stable across multiple pixel densities (e.g. low-res screens plus high-res print).
2020-06-20 19:53:42 -04:00
David Wendt 7a62a8e9ce Programmatically created text fields get a biased depth. 2020-06-20 19:53:34 -04:00
David Wendt 75aaa49169 Y coordinates should always be adjusted by Y coordinates. 2020-06-20 19:48:14 -04:00
David Wendt 245cea784f Running an `autoSize` on any text field should always synchronize the X coordinate between the bounding box and the base transform.
I don't know why, but this is necessary for the "NEW STUFF" box on homestarrunner.com's toons menu to position correctly. SOMEWHERE, we are performing some kind of operation that adjusts one of the two, but not the other, and I can't find out what.
2020-06-20 19:48:13 -04:00
David Wendt 5a2b74c5fc Setting a new matrix should also transform the bounds as well. 2020-06-20 19:48:13 -04:00
David Wendt e7e944ad76 Account for the width of glyphs when measuring text.
This fixes spaces at the start of text spans not being rendered, but also breaks center-align.

I also broke the font tests, so I had to rewrite them, which makes me question their value.
2020-06-20 19:48:13 -04:00
David Wendt 8a5a2bf7c7 When `Font.wrap_text` indicates that none of the line can fit, we should also refresh our width and offset and check if there's even more text to measure or not. 2020-06-20 19:48:12 -04:00
David Wendt efc50da367 `Font.wrap_text` should return `0` if no part of the string can fit within the requested bounds. 2020-06-20 19:48:12 -04:00
David Wendt 38d679ef29 `wrap_line` should take spaces into account when sizing lines. 2020-06-20 19:48:12 -04:00
David Wendt 85a3a845d9 Dynamic `EditText` bounds should go from `x` to `x+width`, not `x` to `x+height` (etc) 2020-06-20 19:48:12 -04:00
David Wendt bacbf06614 Setting the matrix of an `EditText` should scale it's bounds. 2020-06-20 19:48:12 -04:00
David Wendt 9564cbeda4 Use the new dynamic bounding box to calculate a width for word-wrapping, and update the new bounding box directly in autosize rather than hitting `DisplayObject` methods.
This also adjusts `DisplayObject` methods to use the bounds.
2020-06-20 19:48:11 -04:00
David Wendt a0477e7525 Adjust the layout code to properly align content with right margins, trailing spaces on lines, and lines wider than the bounds.
Right margins: Simple enough, we just need to subtract the right margin from the bounds when we calculate our alignment adjustment.

Trailing spaces: This is very tricky as we effectively have to remeasure the last box in the line when fixing it up. This also means LayoutContext has to hold the text itself so we can remeasure again...

Lines wider than bounds: If word wrap is disabled it is possible for a line to exceed the bounds of the box. In this case it will be left-aligned. Effectively, the align adjustment is clamped to positive values and we do that here too.
2020-06-20 19:48:11 -04:00
David Wendt 4eb2113a77 Setting positions and widths on the `EditText` should adjust intrinsic bounds rather than stretching or transforming the field. 2020-06-20 19:48:11 -04:00
David Wendt 7cf2cce3ef Add functions to set positions and widths on bounding boxes. 2020-06-20 19:48:10 -04:00
David Wendt dc46885021 Implement `autoSize`.
This doesn't work right yet because the resulting width doesn't apply correctly to the field. This is because `EditText`'s `_width` and `_height` change it's intrinsic bounds rather than it's X and Y scale (like it would with a button or a movie clip).
2020-06-20 19:48:00 -04:00