Fix the Eyedropper tool on web with Vello and on desktop with SVG#3886
Fix the Eyedropper tool on web with Vello and on desktop with SVG#3886
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refines the Eyedropper tool's functionality, ensuring consistent and accurate behavior across both web (Wasm) and desktop environments, particularly when interacting with different rendering modes like Vello and SVG. It streamlines backend message handling, introduces render mode-aware preview updates, and intelligently adjusts how eyedropper previews are generated based on the platform and chosen rendering technology. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes the Eyedropper tool for Vello on web and for SVG mode on desktop. The changes involve unifying the eyedropper message handling across platforms and adding logic to switch between frontend and backend rendering based on the current render mode. On desktop, it adds a fallback from SVG Preview to Normal mode for the eyedropper. The changes look solid and address the issue described. I have one minor suggestion for code conciseness, which remains valid as it does not conflict with any existing rules.
| // TODO: On desktop, SVG Preview mode cannot work with the Eyedropper tool until <https://github.com/GraphiteEditor/Graphite/issues/3796> is implemented. | ||
| // TODO: So for now, we fall back to the Eyedropper using Normal mode (Vello) rendering, which looks similar enough to SVG Preview. | ||
| #[cfg(not(target_family = "wasm"))] | ||
| let render_mode = match document.render_mode { | ||
| graphene_std::vector::style::RenderMode::SvgPreview => graphene_std::vector::style::RenderMode::Normal, | ||
| other => other, | ||
| }; | ||
| // On web, SVG Preview is handled by the frontend's SVG rasterization path instead, producing the correct result, so we keep it enabled. | ||
| #[cfg(target_family = "wasm")] | ||
| let render_mode = document.render_mode; |
There was a problem hiding this comment.
This logic for determining the render_mode can be made more concise by using an if expression with cfg!. This avoids separate #[cfg] attributes and repeated let bindings.
| // TODO: On desktop, SVG Preview mode cannot work with the Eyedropper tool until <https://github.com/GraphiteEditor/Graphite/issues/3796> is implemented. | |
| // TODO: So for now, we fall back to the Eyedropper using Normal mode (Vello) rendering, which looks similar enough to SVG Preview. | |
| #[cfg(not(target_family = "wasm"))] | |
| let render_mode = match document.render_mode { | |
| graphene_std::vector::style::RenderMode::SvgPreview => graphene_std::vector::style::RenderMode::Normal, | |
| other => other, | |
| }; | |
| // On web, SVG Preview is handled by the frontend's SVG rasterization path instead, producing the correct result, so we keep it enabled. | |
| #[cfg(target_family = "wasm")] | |
| let render_mode = document.render_mode; | |
| // TODO: On desktop, SVG Preview mode cannot work with the Eyedropper tool until <https://github.com/GraphiteEditor/Graphite/issues/3796> is implemented. | |
| // TODO: So for now, we fall back to the Eyedropper using Normal mode (Vello) rendering, which looks similar enough to SVG Preview. | |
| // On web, SVG Preview is handled by the frontend's SVG rasterization path instead, producing the correct result, so we keep it enabled. | |
| let render_mode = if cfg!(not(target_family = "wasm")) && document.render_mode == graphene_std::vector::style::RenderMode::SvgPreview { | |
| graphene_std::vector::style::RenderMode::Normal | |
| } else { | |
| document.render_mode | |
| }; |
Closes #2340.