PAINTROID-790: Create cursor_tool object and provider.#117
PAINTROID-790: Create cursor_tool object and provider.#117haske6155 wants to merge 10 commits intoCatrobat:developfrom
Conversation
…for cursor and add unit/integration tests
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new CursorTool, its provider, integrates it into the toolbox state and painter, and adds corresponding unit & integration tests, plus minor UI painter and iOS project config updates.
- Added
CursorToolimplementation and provider, and wired it intoToolBoxStateProvider&CommandPainter - Added comprehensive unit tests (
cursor_tool_test.dart) and integration tests (cursor_tool_test.dart) - Updated
CanvasPainterto render the cursor icon and adjusted iOS scheme/project for GPU validation and pod resource copying
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/unit/tools/cursor_tool_test.dart | Added unit tests covering cursor positioning and drawing behavior |
| test/integration/cursor_tool_test.dart | Added integration tests for cursor tool interactions |
| lib/ui/pages/workspace_page/components/drawing_surface/canvas_painter.dart | Render cursor icon instead of const Stack |
| lib/core/tools/tool.dart | Changed Tool constructor from const to non-const |
| lib/core/tools/implementation/cursor_tool.dart | New CursorTool implementation |
| lib/core/providers/state/toolbox_state_provider.dart | Integrated ToolType.CURSOR into toolbox state |
| lib/core/providers/object/tools/cursor_tool_provider.dart | Added Riverpod provider for CursorTool |
| lib/core/commands/command_painter.dart | Draw cursor icon in the painter switch |
| ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | Enabled GPU validation |
| ios/Runner.xcodeproj/project.pbxproj | Added pod resource copy build phase |
Comments suppressed due to low confidence (4)
test/integration/cursor_tool_test.dart:50
- The test block for testID 1 and the test block for testID 2 are identical. Consider removing one of the duplicate tests to reduce redundancy and speed up CI.
if (testID == -1 || testID == 1) {
lib/ui/pages/workspace_page/components/drawing_surface/canvas_painter.dart:24
- [nitpick] Removing the
constqualifier from theStackprevents compile-time optimizations. If the children are immutable, consider restoringconst Stackto improve rendering performance.
child: Stack(
lib/core/tools/tool.dart:15
- [nitpick] The constructor was changed from
const Toolto non-const; since all fields arefinal, you could reintroduceconsthere to allow compile-time instantiation and improve code clarity.
Tool({
ios/Runner.xcodeproj/project.pbxproj:272
- This appears to add a duplicate '[CP] Copy Pods Resources' build phase, which can lead to duplicated resource copies or build confusion. Consider removing or merging with the existing phase.
CE347BAC542BC77A1AF7E630 /* [CP] Copy Pods Resources */ = {
| ref.read(paintProvider.notifier).updateStrokeWidth(SPRAY_TOOL_RADIUS); | ||
| break; | ||
| case ToolType.CURSOR: | ||
| state = state.copyWith(currentTool: ref.read(cursorToolProvider)); |
There was a problem hiding this comment.
When selecting the cursor tool, the paint stroke width isn’t updated. You may need to call ref.read(paintProvider.notifier).updateStrokeWidth(...) with the cursor’s stroke width to ensure drawing uses the correct thickness.
| state = state.copyWith(currentTool: ref.read(cursorToolProvider)); | |
| state = state.copyWith(currentTool: ref.read(cursorToolProvider)); | |
| ref.read(paintProvider.notifier).updateStrokeWidth(1.0); // Default stroke width for cursor |
Lenkomotive
left a comment
There was a problem hiding this comment.
Overall good work:
- pls check out the redo/undo function and how it works in other tools. I noticed some inconsistency and also redoing to a line which was drawn by a cursor should also switch back to cursor tool. Might need to look at the PathCommand.
- pls use the Catrobat PR-template and check if you have ticked all the boxes.
lib/ui/pages/workspace_page/components/drawing_surface/canvas_painter.dart
Outdated
Show resolved
Hide resolved
|
Please solve the conflicts, otherwise verything looks good 👍🏻 |
|
When zooming the cursor icon changes position or just vanishes completely. Undoing until you hit a cursor tool stroke it still changes back to cursor tool like Mario mentioned, that should not happen. |
PAINTROID-790
New Features and Enhancements
Added new Cursor Tool functionality allowing users to control a cursor for precise drawing
Code Structure Improvements
Checklist
Your checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.