wxMaxima
Loading...
Searching...
No Matches
Functions | Variables
DiffScrollSync.h File Reference

The pure scroll-synchronization geometry for the diff viewer. More...

#include <vector>
Include dependency graph for DiffScrollSync.h:

Go to the source code of this file.

Functions

int ComputeSyncedScrollY (const std::vector< int > &srcCellTops, const std::vector< int > &otherCellTops, int srcViewportTop)
 Compute where the "other" worksheet must scroll to stay aligned with the scrolled ("source") worksheet.
 

Variables

constexpr int DIFFSYNC_NO_CELL = -1
 A diff-entry cell that has no counterpart in a given worksheet is marked with this top coordinate.
 

Detailed Description

The pure scroll-synchronization geometry for the diff viewer.

Kept deliberately free of any GUI/wxWidgets dependency so the alignment math (which has historically been a source of bugs) can be unit-tested in isolation. DiffFrame::SyncScrollFrom() feeds it the cell positions read from the live worksheets and applies the result with Worksheet::Scroll().

Function Documentation

◆ ComputeSyncedScrollY()

int ComputeSyncedScrollY ( const std::vector< int > &  srcCellTops,
const std::vector< int > &  otherCellTops,
int  srcViewportTop 
)

Compute where the "other" worksheet must scroll to stay aligned with the scrolled ("source") worksheet.

A single top-anchored rule is used for both scroll directions: find the first diff entry whose source cell starts at or below the source viewport top, and scroll the other worksheet so its matching cell sits at the same offset below the viewport top.

Parameters
srcCellTopsFor each diff entry, the top y-coordinate of the source worksheet's cell, or DIFFSYNC_NO_CELL if that entry has no cell in the source worksheet.
otherCellTopsThe same, for the other worksheet. Must be the same length as srcCellTops (indexed by diff entry).
srcViewportTopThe source worksheet's new viewport-top, in pixels.
Returns
The other worksheet's target viewport-top (>= 0), or DIFFSYNC_NO_CELL (-1) if there is no usable anchor (no source cell at/below the viewport top, or the anchor entry has no cell in the other worksheet) – in which case the caller should leave the other worksheet where it is.