Skip to content

refactor: improve interval display - #180

Open
DGGua wants to merge 1 commit into
Lramseyer:mainfrom
DGGua:ruler
Open

refactor: improve interval display#180
DGGua wants to merge 1 commit into
Lramseyer:mainfrom
DGGua:ruler

Conversation

@DGGua

@DGGua DGGua commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Update ruler number spacing and ruler tick spacing algorithm for better display.

Before (timescale is 1s):
image
image
After:
image
image

This may help for #175 .

Copilot AI review requested due to automatic review settings April 16, 2026 08:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the ruler interval calculation in the webview viewport to produce “nicer” tick/label spacing across zoom levels, improving readability and aligning ruler lines more predictably (related to #175).

Changes:

  • Replaces continuous spacing ratio scaling with a snapped “nice interval” algorithm for rulerNumberIncrement/rulerNumberSpacing.
  • Derives rulerTickSpacing from the chosen label increment (subdivide by 2 or 5 when possible).
  • Adds a snapToTimescale() helper to pick a closest “nice” interval.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/webview/viewport.ts Outdated
Comment thread src/webview/viewport.ts Outdated
Comment thread src/webview/viewport.ts Outdated
@Lramseyer

Copy link
Copy Markdown
Owner

OK, this is really good when using when using the scroll wheel, but when using touchpad zoom, it gives the ruler a seizure.

@Lramseyer

Copy link
Copy Markdown
Owner

OK, I modified the viewport code, so that ruler number basis can be modified - updateRulerNumberBasis() if you want to play around with it. With this, it keeps the ruler numbers zoom as a factor of 2, but the function allows you to set the baseline.

Let's say that by default a waveform has a baseline of 1,000,000 ps, and a clock speed of 1 GHz (1000 ps peroid) If you zoom in, you will see a ruler basis of 976.5625. You should be able to change it to 1000 to match your clock rate. This function allows you to do that. As far as how to auto detect that, I didn't have time tonight to implement that part.

@DGGua

DGGua commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

Ok I'll check it later -- maybe tomorrow or later

@Lramseyer

Copy link
Copy Markdown
Owner

OK, I pushed some changes. Take a look, and let me know what you think. If you don't like the behavior, I'm happy to change it up.

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.

3 participants