7 Commits

Author SHA1 Message Date
12841d6471 docs: Update RawKeyEvent references to KeyEvent (#3052) (#3053)
This PR fixes #3052 and updates deprecated type references in docs from
`RawKeyEvent` to `KeyEvent`.

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-03-06 14:40:54 +01:00
9c1e1c3098 chore: Remove deprecations for v1.9.0 (#2749)
Removes everything that was marked as deprecated and that should be
removed for v1.9.0.
2023-09-19 16:47:41 +02:00
4b420b7952 refactor!: Rename (Text) Elements, Nodes and Styles for clarity, add docs (#2700)
This occurred to me after a discussion on the [new FCS component
PR](https://github.com/flame-engine/flame/pull/2694#discussion_r1312450113).
As per usual, @spydon has opened my eyes to the ultimate truth:

We should rename loads of files, and it shall affect almost no one.

The idea is to (1) add a "Text" prefix to all text-rendering-related
classes and (2) rename the existing `Text*` to `InlineText*` (which is
what they are).

This PR is a bit big, but the changes should hopefully be simple to
review, and can be broken down into:

* Add a proper base class for the node inheritance chain, call it
TextNode (while working on Flame Markdown I realized the value this will
have to me)
* Rename the old TextNode to InlineTextNode
* Rename DocumentNode to DocumentRoot because it is not a node
* Rename Element to TextElement
* Rename the old TextElement to InlineTextElement
* Rename Style to FlameTextStyle (note: we could consider dropping the
Flame here)
* Rename the old FlameTextStyle to InlineTextStyle
* Update the docs accordingly
* Add some more diagrams and explanations to the docs, following the new
nomenclature
* I also updated our "internal" imports to use the text module to make
life so much easier (this could arguably be done in a separate PR, but I
honestly think it's easier to review together, please lmk if you prefer
me to split).

These are all breaking changes but likely won't actually affect most
users (see below).

While this is breaking, it should hopefully not affect most users,
because these are all infrastructure classes that most people aren't
using directly. If you are using the FCS components, or the renderers
`TextPaint` or `SpriteFontRenderer` directly, this should have zero
effect to you.

If you are using the Nodes, Stlyes or Elements directly, or have a
custom TextRenderer, see below.

Migrating should be a simple matter of renaming your type references:

* from TextNode to InlineTextNode
* from TextElement to InlineTextElement
* from Element to TextElement
* from FlameTextStyle to InlineTextStyle
* from Style to FlameTextStyle

Make sure to do it in the appropriate order not to cause any
double-replace issues.

If you are importing via the module `package:flame/text.dart`, which we
highly encourage, you should not have to change any import statements
whatsoever.
2023-09-02 12:59:59 -04:00
a1cb9a06ad refactor!: Kill TextRenderer, Long Live TextRenderer (#2683)
This will:

    kill the TextRenderer inheritance chain
    incorporate the functionality of the base TextRenderer in the base TextFormatter
    rename TextFormatter to TextRenderer and appropriate references

That is because both essentially do the same job; encompass the style (or "how") information about how to render text, but using two slightly different interfaces. While that could allow for more flexibility, it is a faux choice that needlessly complicates the pipeline. By having a single interface to comply with, we still allow for custom renders while at the same time making all the code downstream simpler to use and understand.
2023-08-27 21:47:01 +02:00
1a64443cca refactor!: Make TextElement more usable on its own (#2679)
This is part of my ongoing effort to simplify the text rendering
pipeline.
My ultimate goal is to:
* get rid of renders
* rename formatters to renderers
* make the interface complies to both
All details are specified here:
https://github.com/flame-engine/flame/pull/2663

As a first step to break down that huge PR, this makes a small change to
TextElements to make them more useful

This PR will:
### rename render -> draw

draw becomes the "internal", underlying impl, raw method, that just
draws the element w/ any custom options

### add a new render method that takes in more options

this does not need to be extended by every impl.
this is for end users and accepts parameters like position and anchor to
be more in line with the renderer interface

This is technically a breaking change but should have no effect for
users, unless you are creating your own custom `TextElement`s. In that
case, to migrate:

* rename your `render` method to `draw`
2023-08-26 12:10:03 -04:00
10e4109c81 refactor: Fix lint issues across the codebase - Part 2 (#2677)
Fix a handful of lint issues across the codebase, identified using DCM.
Nothing controversial, I expect; slowly getting these out of the way so
we can focus on discussing bigger things.
2023-08-25 18:15:17 +00:00
95b1fc0fbc feat: Added HardwareKeyboardDetector (#2257)
This creates a new component HardwareKeyboardDetector, which is a more advanced version of the KeyboardEvents mixin:

    HardwareKeyboardDetector is a component instead of a mixin, which means it can be added/removed by the user at any point;
    multiple such detectors can be attached to a game - for example, in a 2-player game one component may be paying attention to arrow keys, while another to WASD keys;
    the new component uses Flutter's HardwareKeyboard interface, bypassing the need for a Focus widget;
    the component keeps the ordered list of keys that are currently being pressed, which is helpful for games where this order is important;
    there is the ability to temporarily pause the reception of key events using keyEventsPaused property.
2023-01-27 21:57:42 +00:00