Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b95ce23
add component based scaling gesture
stilnat Nov 13, 2025
4b8bc31
rename multi scale to scale
stilnat Nov 15, 2025
487e579
Delete my_tests_2 directory
stilnat Nov 15, 2025
01e81cd
Delete my_tests directory
stilnat Nov 15, 2025
8701f00
fix typo and format example
stilnat Nov 16, 2025
8b7105a
fix spelling
stilnat Nov 16, 2025
9723f97
remove TODO
stilnat Nov 16, 2025
28e24bf
format scale dispatcher
stilnat Nov 16, 2025
9c2acf6
remove automatically create multi drag dispatcher in Scale dispatcher
stilnat Nov 16, 2025
975bbdb
remove french
stilnat Nov 16, 2025
bea44fc
format scale dispatcher
stilnat Nov 16, 2025
d6f78cb
test first batch
stilnat Nov 19, 2025
987f977
add new test
stilnat Nov 21, 2025
f7b7153
format and change zoom api
stilnat Nov 21, 2025
cbc2333
fix name not recognised
stilnat Nov 21, 2025
6162fb3
format fix
stilnat Nov 21, 2025
528e665
Merge branch 'main' into scale-gesture
stilnat Nov 21, 2025
f945eea
fix melos analyse
stilnat Nov 21, 2025
8ddce28
format stuff
stilnat Nov 21, 2025
1ce9618
Merge remote-tracking branch 'upstream/main' into scale-gesture
stilnat Nov 21, 2025
c18fd0c
Merge branch 'main' into scale-gesture
spydon Nov 21, 2025
bf69b48
fix vector 2 creations
stilnat Nov 22, 2025
5369f79
add doc
stilnat Nov 22, 2025
c6e9b98
Merge branch 'main' into scale-gesture
stilnat Nov 22, 2025
0d10332
markdown fixes
stilnat Nov 22, 2025
4a8f8ad
Merge branch 'scale-gesture' of https://github.com/stilnat/flame into…
stilnat Nov 22, 2025
4441db2
fix markdown
stilnat Nov 22, 2025
47eb614
rename is scaled
stilnat Nov 22, 2025
64fe308
analyse fix
stilnat Nov 22, 2025
42f0d18
fix lint
stilnat Nov 22, 2025
d5b0086
add stuff about scale drag dispatcher
stilnat Nov 22, 2025
77df27a
add scale drag
stilnat Nov 23, 2025
bd6bd89
make gesture more than one sequence
stilnat Nov 23, 2025
d6995a8
add test
stilnat Nov 23, 2025
9a010d3
update recognizer
stilnat Nov 23, 2025
f1cd9eb
working recognizer pass all tests
stilnat Nov 24, 2025
b78a284
rewrite scale and drag callbacks without testing
stilnat Nov 24, 2025
0ff1070
make test pass without scaledrag callbacks
stilnat Nov 24, 2025
b21afe3
fix drag and scale callbacks to upgrade to scaleDragDispatcher
stilnat Nov 24, 2025
bf1398a
add a bunch of tests
stilnat Nov 24, 2025
58e986f
fix format and stuff
stilnat Nov 24, 2025
38d5e8c
make test include drag better
stilnat Nov 24, 2025
7e65ee6
factor test helper
stilnat Nov 24, 2025
2aa5be5
Merge remote-tracking branch 'upstream/main' into recognizer-v2
stilnat Nov 24, 2025
be53a17
rename scale example to scale drag
stilnat Nov 24, 2025
51b2308
remove french
stilnat Nov 25, 2025
31813e5
make consistent extension
stilnat Nov 25, 2025
5d58587
update doc
stilnat Nov 25, 2025
b34e0ca
fix small stuff
stilnat Nov 25, 2025
233d991
Update doc/flame/inputs/scale_events.md
stilnat Nov 27, 2025
b3c4b5b
Fix bugs, cleanup, and polish MultiDragScale recognizer PR
spydon Mar 2, 2026
c6a0b1c
Merge remote-tracking branch 'origin/main' into recognizer-v2
spydon Mar 2, 2026
b6e089e
test: Add dispatcher lifecycle and upgrade path tests
spydon Mar 2, 2026
7d260b3
feat: Add dynamic scale & drag example
spydon Mar 2, 2026
a77ceb0
docs: Document combining ScaleCallbacks and DragCallbacks
spydon Mar 2, 2026
9e23b3e
fix: Put control body on separate line in ScaleDispatcher
spydon Mar 2, 2026
82b4c3f
refactor: Remove unnecessary hide imports and run dart format
spydon Mar 2, 2026
77b94dc
Merge branch 'main' into recognizer-v2
spydon Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions doc/flame/inputs/drag_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,54 @@ method must be implemented manually.
If your component is a part of a larger hierarchy, then it will only receive drag events if its
ancestors have all implemented the `containsLocalPoint` correctly.


### isDragged

The `DragCallbacks` mixin provides an `isDragged` getter that returns `true` while the component is
actively being dragged. This is set to `true` at `onDragStart` and back to `false` at `onDragEnd`.
It can be used, for example, to change the component's visual appearance during a drag.


## Combining with ScaleCallbacks

A component can use both `DragCallbacks` and `ScaleCallbacks` at the same time. When both mixins are
present, single-finger gestures produce drag events and two-finger gestures produce both drag and
scale events. This is useful for components that should be draggable with one finger and
pinch-to-zoom or rotatable with two fingers.

```dart
class InteractiveRect extends RectangleComponent
with ScaleCallbacks, DragCallbacks {

@override
void onDragUpdate(DragUpdateEvent event) {
position += event.localDelta;
}

@override
void onScaleStart(ScaleStartEvent event) {
super.onScaleStart(event);
// store initial angle/scale for relative updates
}

@override
void onScaleUpdate(ScaleUpdateEvent event) {
angle = initialAngle + event.rotation;
}
}
```


### Dynamic addition

Components with different callback types can be added to the game at any time. For example, you can
start with only `DragCallbacks` components and later add a `ScaleCallbacks` component. Flame will
automatically reconfigure the gesture handling so that both types work correctly. Any gestures that
are already in progress (e.g. an ongoing drag) will continue uninterrupted during this transition.

See also [Scale Events — Combining with DragCallbacks](scale_events.md#combining-with-dragcallbacks).


```dart
class MyComponent extends PositionComponent with DragCallbacks {
MyComponent({super.size});
Expand Down
2 changes: 2 additions & 0 deletions doc/flame/inputs/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ works, but adapted for Flame's component tree.

- [Tap Events](tap_events.md)
- [Drag Events](drag_events.md)
- [Scale Events](scale_events.md)
- [Gesture Input](gesture_input.md)
- [Keyboard Input](keyboard_input.md)
- [Other Inputs and Helpers](other_inputs.md)
Expand All @@ -21,6 +22,7 @@ works, but adapted for Flame's component tree.

Tap Events <tap_events.md>
Drag Events <drag_events.md>
Scale Events <scale_events.md>
Gesture Input <gesture_input.md>
Keyboard Input <keyboard_input.md>
Other Inputs <other_inputs.md>
Expand Down
60 changes: 49 additions & 11 deletions doc/flame/inputs/scale_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,55 @@ method must be implemented manually.
If your component is a part of a larger hierarchy, then it will only receive scale events if its
ancestors have all implemented the `containsLocalPoint` correctly.


### isScaling

The `ScaleCallbacks` mixin provides an `isScaling` getter that returns `true` while the component is
actively being scaled. This is set to `true` at the start of `onScaleStart` and back to `false` at
`onScaleEnd`. It can be used, for example, to change the component's visual appearance during a scale
gesture.


## Combining with DragCallbacks

A component can use both `ScaleCallbacks` and `DragCallbacks` at the same time. When both mixins are
present, single-finger gestures produce drag events and two-finger gestures produce both scale and
drag events. This is useful for components that should be draggable with one finger and
pinch-to-zoom or rotatable with two fingers.

```dart
class InteractiveRect extends RectangleComponent
with ScaleCallbacks, DragCallbacks {

@override
void onDragUpdate(DragUpdateEvent event) {
position += event.localDelta;
}

@override
void onScaleStart(ScaleStartEvent event) {
super.onScaleStart(event);
// store initial angle/scale for relative updates
}

@override
void onScaleUpdate(ScaleUpdateEvent event) {
angle = initialAngle + event.rotation;
}
}
```


### Dynamic addition

Components with different callback types can be added to the game at any time. For example, you can
start with only `DragCallbacks` components and later add a `ScaleCallbacks` component. Flame will
automatically reconfigure the gesture handling so that both types work correctly. Any gestures that
are already in progress (e.g. an ongoing drag) will continue uninterrupted during this transition.

See also [Drag Events — Combining with ScaleCallbacks](drag_events.md#combining-with-scalecallbacks).


```dart
class ScaleOnlyRectangle extends RectangleComponent with ScaleCallbacks {
ScaleOnlyRectangle({
Expand Down Expand Up @@ -171,14 +220,3 @@ class ScaleOnlyRectangle extends RectangleComponent with ScaleCallbacks {
}

```


## Scale and drag gestures interactions

A multi drag gesture can sometimes look exactly like a scale gesture.
This is the case for instance, if you try to move two components toward each other at the same time.
If you added both a component using ScaleCallbacks and
one using DragCallbacks (or one using both), this issue will arise.
The Scale gesture will win over the drag gesture
and prevent your user to perform the multi drag gesture as they wanted. This is a limitation
with the current implementation that devs need to be aware of.
Loading