Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Guide-1#3825

Open
jsjgdh wants to merge 3 commits intoGraphiteEditor:masterfrom
jsjgdh:Guide-1
Open

Guide-1#3825
jsjgdh wants to merge 3 commits intoGraphiteEditor:masterfrom
jsjgdh:Guide-1

Conversation

@jsjgdh
Copy link
Contributor

@jsjgdh jsjgdh commented Feb 24, 2026

PR-1 out of 3.
contains: Core guide infrastructure + overlays + frontend ruler drag

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jsjgdh, 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 lays the groundwork for a comprehensive guide system within the editor. It establishes the necessary backend infrastructure for handling guide data and messages, integrates these capabilities into the editor's core message dispatching, and provides the initial frontend components for user interaction, such as dragging guides from rulers and toggling their visibility. This is the first of three planned PRs to fully implement guides.

Highlights

  • Guide System Core Logic: Introduced new GuideMessage and GuideMessageHandler to manage the lifecycle of guides, including creation, movement, deletion, and visibility toggling within the editor's backend.
  • Frontend Guide Interaction: Implemented frontend logic in Svelte components (Document.svelte, RulerInput.svelte) to allow users to drag guides directly from the rulers, initiating their creation and enabling subsequent manipulation.
  • WASM API for Guides: Extended the WASM API with new functions (generateGuideId, createGuide, moveGuide, deleteGuide) to expose guide management functionality to the JavaScript frontend.
  • Menu Bar Integration: Added a 'Guides' toggle to the editor's menu bar, allowing users to easily control the visibility of all guides on the canvas.
Changelog
  • editor/src/dispatcher.rs
    • Updated menu_bar_message_handler to include the guides_visible state from the document's guide handler.
  • editor/src/messages/menu_bar/menu_bar_message_handler.rs
    • Imported GuideMessage for guide-related actions.
    • Added a guides_visible boolean field to track guide visibility.
    • Integrated a 'Guides' menu list entry with a checkbox icon to toggle guide visibility via GuideMessage::ToggleGuidesVisibility.
  • editor/src/messages/portfolio/document/document_message.rs
    • Imported GuideMessage.
    • Added Guide(GuideMessage) as a child message variant to DocumentMessage.
  • editor/src/messages/portfolio/document/document_message_handler.rs
    • Imported GuideMessageHandler and GuideMessageContext.
    • Added a guide_handler field to DocumentMessageHandler and initialized it with a default GuideMessageHandler.
    • Implemented message processing for DocumentMessage::Guide to delegate to the guide_handler.
    • Extended common actions with those from the guide_handler.
  • editor/src/messages/portfolio/document/guide_message.rs
    • Added a new file defining the GuideMessage enum, which includes variants for creating, moving, deleting, rendering overlays, toggling visibility, and setting hovered guides.
  • editor/src/messages/portfolio/document/guide_message_handler.rs
    • Added a new file defining GuideMessageHandler, responsible for managing a collection of Guide objects, their visibility, and processing GuideMessages to update guide states and trigger UI updates.
  • editor/src/messages/portfolio/document/mod.rs
    • Exported the new guide_message and guide_message_handler modules.
  • editor/src/messages/portfolio/document/overlays/guide_overlays.rs
    • Added a new file containing guide_overlay function to draw guide lines on the canvas, extending them to the viewport edges and highlighting hovered guides.
  • editor/src/messages/portfolio/document/overlays/mod.rs
    • Exported the new guide_overlays module.
  • editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs
    • Imported GuideMessage.
    • Dispatched GuideMessage::GuideOverlays to render guide overlays during canvas drawing.
  • editor/src/messages/portfolio/document/utility_types/guide.rs
    • Added a new file defining GuideId (a unique identifier), GuideDirection (Horizontal/Vertical), and Guide (containing ID, direction, and position) structs.
  • editor/src/messages/portfolio/document/utility_types/mod.rs
    • Exported the new guide utility type module.
  • frontend/src/components/panels/Document.svelte
    • Imported generateGuideId from the WASM package.
    • Added draggingGuideId and draggingGuideDirection state variables for guide drag operations.
    • Implemented getViewportElement, getGuideMousePosition, and isInRulerArea helper functions.
    • Created createGuideDragHandlers and startGuideDrag to manage pointer and keyboard events during guide dragging.
    • Implemented handleGuideDragStart to create a new guide and initiate dragging when triggered from a ruler.
    • Updated RulerInput components to listen for the guideDragStart event.
  • frontend/src/components/widgets/inputs/RulerInput.svelte
    • Imported createEventDispatcher to emit custom events.
    • Added isDragging state to track active drag operations.
    • Implemented handlePointerDown to dispatch a guideDragStart event with guide direction and mouse coordinates, and capture the pointer.
    • Implemented handlePointerUp to release the pointer capture.
    • Applied pointerdown and pointerup event listeners to the ruler element, along with a dynamic cursor style.
  • frontend/wasm/src/editor_api.rs
    • Imported GuideMessage, GuideDirection, and GuideId.
    • Added set_random_seed for UUID generation.
    • Added generate_guide_id to create unique identifiers for guides.
    • Added create_guide WASM function to send GuideMessage::CreateGuide to the editor.
    • Added move_guide WASM function to send GuideMessage::MoveGuide to the editor.
    • Added delete_guide WASM function to send GuideMessage::DeleteGuide to the editor.
Activity
  • The pull request is titled "Guide-1" and is explicitly marked as "PR-1 out of 3", indicating it's the initial installment of a multi-part feature implementation by jsjgdh.
  • No specific comments or reviews have been recorded in the provided context.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the backend and frontend infrastructure for guides, including creating, moving, deleting, and displaying them. The changes are well-structured and the implementation is solid. I've provided a few suggestions to improve code quality by reducing duplication and decoupling components.

@jsjgdh jsjgdh marked this pull request as ready for review February 25, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants