-
Notifications
You must be signed in to change notification settings - Fork 250
Left/right document isolated view with hotkeys #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,14 @@ | |
| #include <wx/progdlg.h> | ||
| #include <wx/filesys.h> | ||
|
|
||
|
|
||
| enum DisplayMode | ||
| { | ||
| SHOW_DIFF_DOCUMENT, | ||
| SHOW_LEFT_DOCUMENT, | ||
| SHOW_RIGHT_DOCUMENT | ||
| }; | ||
|
|
||
| // ------------------------------------------------------------------------ | ||
| // PDF rendering functions | ||
| // ------------------------------------------------------------------------ | ||
|
|
@@ -537,6 +545,9 @@ const int ID_OFFSET_RIGHT = wxNewId(); | |
| const int ID_OFFSET_UP = wxNewId(); | ||
| const int ID_OFFSET_DOWN = wxNewId(); | ||
| const int ID_GUTTER = wxNewId(); | ||
| const int ID_LEFT_DOC = wxNewId(); | ||
| const int ID_RIGHT_DOC = wxNewId(); | ||
| const int ID_DIFF_DOC = wxNewId(); | ||
|
|
||
| #define BMP_ARTPROV(id) wxArtProvider::GetBitmap(id, wxART_TOOLBAR) | ||
|
|
||
|
|
@@ -597,11 +608,17 @@ class DiffFrame : public wxFrame | |
| "Offset one of the pages up (Ctrl up)"); | ||
| toolbar->AddTool(ID_OFFSET_DOWN, "", BMP_OFFSET_DOWN, | ||
| "Offset one of the pages down (Ctrl down)"); | ||
| 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 >)"); | ||
|
||
|
|
||
| toolbar->Realize(); | ||
| SetToolBar(toolbar); | ||
|
|
||
| wxAcceleratorEntry accels[8]; | ||
| wxAcceleratorEntry accels[11]; | ||
| accels[0].Set(wxACCEL_NORMAL, WXK_PAGEUP, ID_PREV_PAGE); | ||
| accels[1].Set(wxACCEL_NORMAL, WXK_PAGEDOWN, ID_NEXT_PAGE); | ||
| accels[2].Set(wxACCEL_CTRL, (int)'=', ID_ZOOM_IN); | ||
|
|
@@ -610,8 +627,11 @@ class DiffFrame : public wxFrame | |
| accels[5].Set(wxACCEL_CTRL, WXK_RIGHT, ID_OFFSET_RIGHT); | ||
| accels[6].Set(wxACCEL_CTRL, WXK_UP, ID_OFFSET_UP); | ||
| accels[7].Set(wxACCEL_CTRL, WXK_DOWN, ID_OFFSET_DOWN); | ||
| accels[8].Set(wxACCEL_CTRL, (int)',', ID_LEFT_DOC); | ||
| accels[9].Set(wxACCEL_CTRL, (int)'.', ID_RIGHT_DOC); | ||
| accels[10].Set(wxACCEL_CTRL, (int)'d', ID_DIFF_DOC); | ||
|
|
||
| wxAcceleratorTable accel_table(8, accels); | ||
| wxAcceleratorTable accel_table(11, accels); | ||
| SetAcceleratorTable(accel_table); | ||
|
|
||
| m_gutter = new Gutter(this, ID_GUTTER); | ||
|
|
@@ -695,8 +715,32 @@ class DiffFrame : public wxFrame | |
| m_offset.x, m_offset.y, | ||
| &thumbnail, Gutter::WIDTH | ||
| ); | ||
| // Render page according to the current display mode | ||
| switch ( m_display_mode ) | ||
| { | ||
| case SHOW_LEFT_DOCUMENT: | ||
| // | ||
|
||
| 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; | ||
|
Comment on lines
727
to
743
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| m_viewer->Set(diff ? diff : img1); | ||
| case SHOW_DIFF_DOCUMENT: | ||
| default: | ||
| m_viewer->Set(diff ? diff : img1); | ||
| } | ||
|
|
||
| // Always update the diff map. It will be all-white if there were | ||
| // no differences. | ||
|
|
@@ -788,6 +832,27 @@ class DiffFrame : public wxFrame | |
| DoUpdatePage(); | ||
| } | ||
|
|
||
| void OnShowLeftDocument(wxCommandEvent&) | ||
| { | ||
| m_display_mode = SHOW_LEFT_DOCUMENT; | ||
| m_offset = wxPoint(0, 0); | ||
| DoUpdatePage(); | ||
|
||
| } | ||
|
|
||
| void OnShowDiffDocument(wxCommandEvent&) | ||
| { | ||
| m_display_mode = SHOW_DIFF_DOCUMENT; | ||
| m_offset = wxPoint(0, 0); | ||
| DoUpdatePage(); | ||
| } | ||
|
|
||
| void OnShowRightDocument(wxCommandEvent&) | ||
| { | ||
| m_display_mode = SHOW_RIGHT_DOCUMENT; | ||
| m_offset = wxPoint(0, 0); | ||
| DoUpdatePage(); | ||
| } | ||
|
|
||
| void OnOffsetLeft(wxCommandEvent&) { DoOffset(-1, 0); } | ||
| void OnOffsetRight(wxCommandEvent&) { DoOffset(1, 0); } | ||
| void OnOffsetUp(wxCommandEvent&) { DoOffset(0, -1); } | ||
|
|
@@ -803,6 +868,7 @@ class DiffFrame : public wxFrame | |
| int m_diff_count; | ||
| int m_cur_page; | ||
| wxPoint m_offset; | ||
| DisplayMode m_display_mode; | ||
| }; | ||
|
|
||
| BEGIN_EVENT_TABLE(DiffFrame, wxFrame) | ||
|
|
@@ -817,6 +883,9 @@ BEGIN_EVENT_TABLE(DiffFrame, wxFrame) | |
| EVT_TOOL (ID_OFFSET_RIGHT, DiffFrame::OnOffsetRight) | ||
| EVT_TOOL (ID_OFFSET_UP, DiffFrame::OnOffsetUp) | ||
| EVT_TOOL (ID_OFFSET_DOWN, DiffFrame::OnOffsetDown) | ||
| EVT_TOOL (ID_LEFT_DOC, DiffFrame::OnShowLeftDocument) | ||
| EVT_TOOL (ID_DIFF_DOC, DiffFrame::OnShowDiffDocument) | ||
| EVT_TOOL (ID_RIGHT_DOC, DiffFrame::OnShowRightDocument) | ||
|
||
| END_EVENT_TABLE() | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: