Skip to content

Conversation

@mandulaj
Copy link

Sometimes the red/blue diff view is a bit confusing and its easier to just check the left/right documents individually. This PR adds buttons to toggle between 3 modes:

  • Left Document
  • Diff
  • Right Document

You can also use Ctrl < and Ctrl > to hot switch between the Left/Right view.

Ctrl d returns to the default Diff view.

Futher more, the Ctrl d sets the offsets to 0, 0 (acts as a clear in case you want to quickly reset the offset)

Futher Improvements

[ ] Show the names of the current document view (Left: file.pdf/ Right other.pdf / Diff)
[ ] Handle Missing pages (currently the diff doesn't handle missing pages and just shows changes for all subsequent pages)

diff-pdf.cpp Outdated
Comment on lines 611 to 616
toolbar->AddTool(ID_LEFT_DOC, "Left document", BMP_ARTPROV(wxART_GO_BACK),
"Show left document (Ctrl <)");
toolbar->AddTool(ID_DIFF_DOC, "Diff document", BMP_ARTPROV(wxART_REDO),
"Show diff document (Ctrl d)");
toolbar->AddTool(ID_RIGHT_DOC, "Right document", BMP_ARTPROV(wxART_GO_FORWARD),
"Show right document (Ctrl >)");
Copy link
Owner

Choose a reason for hiding this comment

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

These icons seem arbitrary — and semantically incorrect.

Copy link
Author

Choose a reason for hiding this comment

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

I am open to suggestions regarding the icons. I wanted something to indicate the left document (left arrow) right document (right arrow) and diff (I am using the redo arrow as its sort of returning to the default comparison mode)

I am not familiar with wx icons so if you have better suggestions I am open to change this :)

diff-pdf.cpp Outdated
switch ( m_display_mode )
{
case SHOW_LEFT_DOCUMENT:
//
Copy link
Owner

Choose a reason for hiding this comment

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

Huh?

Comment on lines 723 to 738
if ( img1 )
m_viewer->Set(img1);
else if ( img2 )
m_viewer->Set(img2);
else
m_viewer->Set(NULL);
break;

case SHOW_RIGHT_DOCUMENT:
if ( img2 )
m_viewer->Set(img2);
else if ( img1 )
m_viewer->Set(img1);
else
m_viewer->Set(NULL);
break;
Copy link
Owner

Choose a reason for hiding this comment

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

I don’t understand why this code shows left-side image on the right side and vice versa?

Copy link
Author

Choose a reason for hiding this comment

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

In my head img1 is the Left document and img2 is the right document.

The idea is if we are in the SHOW_RIGHT_DOCUMENT mode, we try showing the right document, however if the image doesn't exist (if the documents aren't the same length, we just show the left document. Seemed to make most sense in my usecase scenario, however I could change this to just display some kind of default image (like Page, not available....)

diff-pdf.cpp Outdated
Comment on lines 838 to 839
m_offset = wxPoint(0, 0);
DoUpdatePage();
Copy link
Owner

Choose a reason for hiding this comment

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

Why do these reset the offset — seems unrelated?

Please also don’t duplicate code like this, use a helper function.

Copy link
Author

Choose a reason for hiding this comment

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

I agree, there should be a dedicated button (shortcut for this)

In my use case scenario I found it usefult to use the the Ctrl+D shortcut to not only return to the the diff mode but also the reset the offset. I removed it in the update

diff-pdf.cpp Outdated
Comment on lines 886 to 888
EVT_TOOL (ID_LEFT_DOC, DiffFrame::OnShowLeftDocument)
EVT_TOOL (ID_DIFF_DOC, DiffFrame::OnShowDiffDocument)
EVT_TOOL (ID_RIGHT_DOC, DiffFrame::OnShowRightDocument)
Copy link
Owner

Choose a reason for hiding this comment

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

Wrong indentation, D is not aligned.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed the indent.... would you like me to set up a clang-format to keep the style consistent?

README.md Outdated
It is also possible to shift the two pages relatively to each other using
Ctrl-arrows (Cmd-arrows on MacOS). This is useful for identifying translation-only differences.

You can also use Ctrl < and Ctrl > (Cmd < and Cmd > on MacOS) show the left and right documents respecively. Ctrl d to return back to the diff view.
Copy link
Owner

Choose a reason for hiding this comment

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

Please use the standard way of referring to combined keypresses, which is Ctrl+D etc.

Copy link
Author

Choose a reason for hiding this comment

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

Made the update. I tried staying consistent with the existing convention in the code. Perhaps this should be fixed also for the other combined key-presses for the zoom and offset:

        toolbar->AddTool(ID_ZOOM_IN, "Zoom in", BMP_ZOOM_IN,
                         "Make the page larger (Ctrl +)");
        toolbar->AddTool(ID_ZOOM_OUT, "Zoom out", BMP_ZOOM_OUT,
                         "Make the page smaller (Ctrl -)");
        toolbar->AddTool(ID_OFFSET_LEFT, "", BMP_OFFSET_LEFT,
                         "Offset one of the pages to the left (Ctrl left)");
        toolbar->AddTool(ID_OFFSET_RIGHT, "", BMP_OFFSET_RIGHT,
                         "Offset one of the pages to the right (Ctrl right)");
        toolbar->AddTool(ID_OFFSET_UP, "", BMP_OFFSET_UP,
                         "Offset one of the pages up (Ctrl up)");
        toolbar->AddTool(ID_OFFSET_DOWN, "", BMP_OFFSET_DOWN,
                         "Offset one of the pages down (Ctrl down)");

@mandulaj
Copy link
Author

mandulaj commented Jan 8, 2026

Hi @vslavik thanks for the review. I will try addressing some of the points you raise directly in the comments, and will push an update.

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