From d1099ea4e984b0045a04eaf97915543cd1ba339c Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Wed, 1 Jan 2025 19:43:34 +0100 Subject: [PATCH] Change aspect ratio to use 3 fraction digits for area --- app/android/Gemfile.lock | 2 +- app/lib/handlers/stamp.dart | 18 ++++-------------- app/lib/selections/tools/area.dart | 21 +++++++++++---------- metadata/en-US/changelogs/127.txt | 1 + 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/app/android/Gemfile.lock b/app/android/Gemfile.lock index 9de345f10c70..e6665534c7de 100644 --- a/app/android/Gemfile.lock +++ b/app/android/Gemfile.lock @@ -11,7 +11,7 @@ GEM atomos (0.1.3) aws-eventstream (1.3.0) aws-partitions (1.1029.0) - aws-sdk-core (3.214.0) + aws-sdk-core (3.214.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) aws-sigv4 (~> 1.9) diff --git a/app/lib/handlers/stamp.dart b/app/lib/handlers/stamp.dart index 9c919300281d..413084aad2eb 100644 --- a/app/lib/handlers/stamp.dart +++ b/app/lib/handlers/stamp.dart @@ -47,25 +47,15 @@ class StampHandler extends PastingHandler { _position = Offset.zero; _component = getComponent(document); if ((!force && _elements != null) || _component == null) return; - _elements = await Future.wait( + final elements = _elements = await Future.wait( _component?.elements.map(Renderer.fromInstance).map((e) async { await e.setup(document, assetService, page); return e; }) ?? []); - Rect? rect; - for (final e in _elements!) { - final r = e.rect; - if (r == null) continue; - if (rect == null) { - rect = r; - } else { - rect = rect.expandToInclude(r); - } - } - if (rect != null) { - this.rect = rect; - } + rect = elements.map((e) => e.rect).nonNulls.fold(null, + (value, element) => value?.expandToInclude(element) ?? element) ?? + Rect.zero; } @override diff --git a/app/lib/selections/tools/area.dart b/app/lib/selections/tools/area.dart index b956868bd2c1..4551e20bce08 100644 --- a/app/lib/selections/tools/area.dart +++ b/app/lib/selections/tools/area.dart @@ -8,6 +8,16 @@ class AreaToolSelection extends ToolSelection { final tool = selected.first; return [ ...super.buildProperties(context), + CheckboxListTile( + title: Text(AppLocalizations.of(context).askForName), + value: tool.askForName, + onChanged: (value) => update( + context, + selected + .map((e) => e.copyWith(askForName: value ?? false)) + .toList()), + ), + const SizedBox(height: 4), ExactSlider( header: Text(AppLocalizations.of(context).width), value: tool.constrainedWidth, @@ -62,21 +72,12 @@ class AreaToolSelection extends ToolSelection { min: 0, max: 10, defaultValue: 0, + fractionDigits: 3, onChangeEnd: (value) => update( context, selected .map((e) => e.copyWith(constrainedAspectRatio: value)) .toList())), - const SizedBox(height: 4), - CheckboxListTile( - title: Text(AppLocalizations.of(context).askForName), - value: tool.askForName, - onChanged: (value) => update( - context, - selected - .map((e) => e.copyWith(askForName: value ?? false)) - .toList()), - ), ]; } diff --git a/metadata/en-US/changelogs/127.txt b/metadata/en-US/changelogs/127.txt index cd2543e419d2..b3ffbc6451d7 100644 --- a/metadata/en-US/changelogs/127.txt +++ b/metadata/en-US/changelogs/127.txt @@ -13,6 +13,7 @@ * Add password protected notes ([#771](https://github.com/LinwoodDev/Butterfly/issues/771)) * Add option to import svg as text ([#596](https://github.com/LinwoodDev/Butterfly/issues/596)) * Improve grid files view +* Change aspect ratio to use 3 fraction digits for area * Fix undo/redo tools not showing status correctly * Fix grid not working correctly * Fix capture thumbnail uses wrong position