refactor: improve interval display - #180
Conversation
There was a problem hiding this comment.
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
rulerTickSpacingfrom 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.
|
OK, this is really good when using when using the scroll wheel, but when using touchpad zoom, it gives the ruler a seizure. |
|
OK, I modified the viewport code, so that ruler number basis can be modified - 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. |
|
Ok I'll check it later -- maybe tomorrow or later |
|
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. |
Update ruler number spacing and ruler tick spacing algorithm for better display.
Before (timescale is 1s):




After:
This may help for #175 .