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

Skip to content

Adjust ruler tick alignment when document is tilted#3844

Draft
jsjgdh wants to merge 3 commits intoGraphiteEditor:masterfrom
jsjgdh:Ruler
Draft

Adjust ruler tick alignment when document is tilted#3844
jsjgdh wants to merge 3 commits intoGraphiteEditor:masterfrom
jsjgdh:Ruler

Conversation

@jsjgdh
Copy link
Contributor

@jsjgdh jsjgdh commented Mar 1, 2026

closes #1482 .
Not meant to be merged .

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the document ruler functionality by enabling them to dynamically adapt to a tilted document view. It introduces a tilt parameter that is propagated from the backend to the frontend, allowing the ruler components to intelligently adjust their visual representation, including tick marks, spacing, and text orientation, to maintain accuracy and readability when the canvas is rotated.

Highlights

  • Ruler Tilt Parameter: A new tilt parameter has been introduced in the UpdateDocumentRulers message, allowing the backend to communicate the document's tilt angle to the frontend ruler components.
  • Ruler Input Component Refactor: The RulerInput.svelte component has been significantly refactored to incorporate the tilt parameter, enabling dynamic adjustment of ruler tick alignment, spacing, and numbering based on the document's rotation.
  • Coordinate System Transformation: New mathematical functions (computeAxes, computeEffectiveOrigin) were added to handle complex coordinate system transformations, calculating stretched spacing and effective origins for rulers in a tilted view.
  • Adaptive Tick Rendering and Text Rotation: The ruler rendering logic now adapts tick density based on the stretchFactor caused by tilt, and ruler text is rotated and aligned correctly to remain readable when the document is tilted.
Changelog
  • editor/src/messages/frontend/frontend_message.rs
    • Added a tilt field of type f64 to the UpdateDocumentRulers enum variant.
  • editor/src/messages/portfolio/document/document_message_handler.rs
    • Included the tilt value from current_ptz.tilt() in the UpdateDocumentRulers message sent to the frontend, defaulting to 0. if the graph view overlay is open.
  • frontend/src/components/panels/Document.svelte
    • Introduced a new rulerTilt state variable initialized to 0.
    • Updated the updateDocumentRulers function signature to accept a tilt parameter and assigned it to rulerTilt.
    • Modified the subscription to UpdateDocumentRulers to destructure and pass the new tilt data to updateDocumentRulers.
    • Changed the RulerInput component instantiation to pass originX, originY, and tilt props instead of a single origin prop.
  • frontend/src/components/widgets/inputs/RulerInput.svelte
    • Replaced the origin export with originX and originY exports, and added a tilt export initialized to 0.
    • Introduced an Axis interface and new reactive variables (axes, isHorizontal, trackedAxis, otherAxis, stretchFactor, stretchedSpacing, effectiveOrigin) to handle tilt calculations.
    • Added computeAxes and computeEffectiveOrigin functions to determine axis vectors and adjusted origins based on tilt.
    • Refactored computeSvgPath to use effectiveOrigin, stretchedSpacing, and otherAxis for tick rendering, including adaptive minor/micro divisions and tick direction based on tilt.
    • Refactored computeSvgTexts to use effectiveOrigin, stretchedSpacing, and trackedAxis for text rendering, incorporating rotation based on tilt and adaptive label steps.
    • Updated the resize function to use stretchedSpacing for calculating rulerLength.
    • Simplified the mod function by changing remainder to r.
    • Added dominant-baseline attribute to SVG text elements, setting it to central for vertical rulers.
  • frontend/src/messages.ts
    • Added a readonly tilt!: number; property to the UpdateDocumentRulers class.
Activity
  • The pull request description explicitly states "Not meant to be merged", indicating it is likely a work-in-progress or an experimental branch.
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 a sophisticated solution for aligning ruler ticks with a tilted document, which is a great enhancement. The changes span both the backend and frontend to pass the tilt information and perform the necessary calculations. The trigonometric logic in RulerInput.svelte is comprehensive. However, I've found a significant issue in the mod utility function which will lead to incorrect ruler rendering. Please see my comment for details.

@Keavon
Copy link
Member

Keavon commented Mar 3, 2026

!build (Run ID 22610169902)

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

📦 Build Complete for c75b29e
https://ed0ff2dd.graphite.pages.dev

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.

Stretch and tilt ruler increments when canvas is tilted

2 participants