Skip to content

Commit

Permalink
Fix pointer list on window exit, closes #521
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 8, 2023
1 parent 5768136 commit baea766
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/lib/cubits/current_index.dart
Expand Up @@ -106,6 +106,7 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {

Handler? changeTool(DocumentBloc bloc, int index,
[Handler? handler, bool justAdded = false, bool runSelected = true]) {
resetInput(bloc);
final blocState = bloc.state;
if (blocState is! DocumentLoadSuccess) return null;
final document = blocState.data;
Expand Down Expand Up @@ -286,7 +287,8 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
}

void addPointer(int pointer) {
emit(state.copyWith(pointers: state.pointers.toList()..add(pointer)));
emit(state.copyWith(
pointers: (state.pointers.toSet()..add(pointer)).toList()));
}

void removePointer(int pointer) {
Expand Down
12 changes: 8 additions & 4 deletions app/lib/renderers/renderer.dart
Expand Up @@ -182,14 +182,18 @@ abstract class Renderer<T> {
position ??= relative ? Offset.zero : rect.topLeft;
final nextPosition = relative ? position + rect.topLeft : position;

final scale = Offset(scaleX, scaleY);
// .rotate(const Offset(1, 1), useRotation / 180 * pi);
final radians = rotation * (pi / 180);
final cosRotation = cos(radians);
final sinRotation = sin(radians);

scaleX = scaleX * cosRotation - scaleY * sinRotation;
scaleY = scaleX * sinRotation + scaleY * cosRotation;

return _transform(
position: nextPosition,
rotation: nextRotation,
scaleX: scale.dx,
scaleY: scale.dy,
scaleX: scaleX,
scaleY: scaleY,
);
}

Expand Down
4 changes: 4 additions & 0 deletions app/lib/views/view.dart
Expand Up @@ -350,6 +350,10 @@ class _MainViewViewportState extends State<MainViewViewport>
child: BlocBuilder<TransformCubit, CameraTransform>(
builder: (context, transform) => MouseRegion(
cursor: currentIndex.currentCursor,
onExit: (event) {
cubit.removePointer(event.pointer);
cubit.removeButtons();
},
child: ClipRRect(
child: Stack(children: [
Container(color: Colors.white),
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/79.txt
@@ -1,4 +1,5 @@
* Add templates to data settings
* Fix icon button if no display icon available
* Fix pointer list on window exit ([#521](https://github.com/LinwoodDev/Butterfly/issues/521))

View all changes in the blog: https://linwood.dev/butterfly/2.0.0-beta.15

0 comments on commit baea766

Please sign in to comment.