From 301cb5a6ae03a3c2afe4a0e1fe1d8373c869daa1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:16:51 +0000 Subject: [PATCH 1/5] Initial plan From 9a746f5227f4ebbae507812581f9ea12c3a0e81b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:25:36 +0000 Subject: [PATCH 2/5] Fix zero-dimension rectangle issue in magicOpacityFactor call Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com> --- lib/music_view/music_system_painter.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/music_view/music_system_painter.dart b/lib/music_view/music_system_painter.dart index e620cf25..8a8a3694 100644 --- a/lib/music_view/music_system_painter.dart +++ b/lib/music_view/music_system_painter.dart @@ -263,7 +263,7 @@ class MusicSystemPainter extends CustomPainter { } // print("fontSize=$fontSize topOffset=$topOffset"); double opacityFactor = - magicOpacityFactor(Rect.fromLTRB(left, 0, left, 0)); + magicOpacityFactor(Rect.fromLTRB(left, 0, left + 1, 1)); TextSpan span = TextSpan( text: renderingSection.canonicalName, style: TextStyle( From d3128a20b42630818a69b4e8c3b0db8274cd9915 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:30:22 +0000 Subject: [PATCH 3/5] Add test for Rect.fromLTRB fix to prevent regression Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com> --- test/music_system_painter_test.dart | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/music_system_painter_test.dart diff --git a/test/music_system_painter_test.dart b/test/music_system_painter_test.dart new file mode 100644 index 00000000..f8eafc36 --- /dev/null +++ b/test/music_system_painter_test.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('Rect.fromLTRB fix', () { + test('Fixed rectangle creation should have valid dimensions', () { + // Test the specific fix for the zero-dimension rectangle issue + const double left = 50.0; + + // This is the NEW fixed way that prevents zero dimensions + final fixedRect = Rect.fromLTRB(left, 0, left + 1, 1); + + // Verify the rectangle has valid dimensions + expect(fixedRect.width, equals(1.0)); + expect(fixedRect.height, equals(1.0)); + expect(fixedRect.left, equals(left)); + expect(fixedRect.top, equals(0.0)); + expect(fixedRect.right, equals(left + 1)); + expect(fixedRect.bottom, equals(1.0)); + + // Ensure it's not empty + expect(fixedRect.isEmpty, isFalse); + }); + + test('Zero dimension rectangles should be avoided', () { + // Demonstrate the problem that was fixed + const double left = 50.0; + + // The old problematic way + final oldRect = Rect.fromLTRB(left, 0, left, 0); + expect(oldRect.width, equals(0.0)); + expect(oldRect.height, equals(0.0)); + expect(oldRect.isEmpty, isTrue); + + // The new fixed way + final newRect = Rect.fromLTRB(left, 0, left + 1, 1); + expect(newRect.width, equals(1.0)); + expect(newRect.height, equals(1.0)); + expect(newRect.isEmpty, isFalse); + }); + }); +} \ No newline at end of file From af37adcaaa3e13c4bc64a32916bc17a9c05a91cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:32:26 +0000 Subject: [PATCH 4/5] Fix another zero-width rectangle in harmony beat renderer Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com> --- lib/drawing/harmony_beat_renderer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/drawing/harmony_beat_renderer.dart b/lib/drawing/harmony_beat_renderer.dart index 5c97c704..4b04c194 100644 --- a/lib/drawing/harmony_beat_renderer.dart +++ b/lib/drawing/harmony_beat_renderer.dart @@ -163,7 +163,7 @@ class HarmonyBeatRenderer { canvas.drawRect( Rect.fromLTRB(bounds.left + leftOffset, bounds.top, - bounds.left + leftOffset, bounds.bottom), + bounds.left + leftOffset + 1, bounds.bottom), paint); canvas.drawRect( Rect.fromLTRB(bounds.right - rightOffset, bounds.top, bounds.right, From d951fb1a07fff1f3cbbb8b3407e853d18cc405ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:33:54 +0000 Subject: [PATCH 5/5] Add comprehensive test coverage for all Rect.fromLTRB fixes Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com> --- test/music_system_painter_test.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/music_system_painter_test.dart b/test/music_system_painter_test.dart index f8eafc36..26260c31 100644 --- a/test/music_system_painter_test.dart +++ b/test/music_system_painter_test.dart @@ -38,5 +38,24 @@ void main() { expect(newRect.height, equals(1.0)); expect(newRect.isEmpty, isFalse); }); + + test('Zero-width rectangles for vertical lines should have minimal width', () { + // Test the harmony beat renderer fix + final bounds = Rect.fromLTRB(0, 0, 100, 50); + const double leftOffset = 10.0; + + // This was the old problematic way (zero width) + final oldRect = Rect.fromLTRB(bounds.left + leftOffset, bounds.top, + bounds.left + leftOffset, bounds.bottom); + expect(oldRect.width, equals(0.0)); + expect(oldRect.isEmpty, isTrue); + + // This is the new fixed way (minimal 1px width) + final newRect = Rect.fromLTRB(bounds.left + leftOffset, bounds.top, + bounds.left + leftOffset + 1, bounds.bottom); + expect(newRect.width, equals(1.0)); + expect(newRect.height, equals(bounds.height)); + expect(newRect.isEmpty, isFalse); + }); }); } \ No newline at end of file