Skip to content
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

Improve keybindings #245

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies/nanogui
Submodule nanogui updated 1 files
+3 −1 src/textbox.cpp
26 changes: 13 additions & 13 deletions src/HelpWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC

addRow(imageSelection, "Left Click", "Select hovered image");
addRow(imageSelection, "1…9", "Select N-th image");
addRow(imageSelection, "Down or S or Ctrl+Tab / Up or W or Ctrl+Shift+Tab", "Select next / previous image");
addRow(imageSelection, "Home / End", "Select first / last image");
addRow(imageSelection, "Down/Up or S/W or J/K or Ctrl+Tab/Ctrl+Shift+Tab", "Select next/previous image");
addRow(imageSelection, "Home/End", "Select first/last image");
addRow(imageSelection, "Space", "Toggle playback of images as video");

addRow(imageSelection, "Click & Drag (+Shift/" + COMMAND + ")", "Translate image");
addRow(imageSelection, "Click & Drag+C (hold)", "Crop image");
addRow(imageSelection, "+ / - / Scroll (+Shift/" + COMMAND + ")", "Zoom in / out of image");
addRow(imageSelection, "+/- or Scroll (+Shift/" + COMMAND + ")", "Zoom in/out of image");

addRow(imageSelection, COMMAND + "+0", "Zoom to actual size");
addRow(imageSelection, COMMAND + "+9 / F", "Zoom to fit");
addRow(imageSelection, COMMAND + "+9/F", "Zoom to fit");
addRow(imageSelection, "N", "Normalize image to [0, 1]");
addRow(imageSelection, "R", "Reset image parameters");
if (supportsHdr) {
addRow(imageSelection, "L", "Display the image as if on an LDR screen");
}

addRow(imageSelection, "Shift+Right or Shift+D / Shift+Left or Shift+A", "Select next / previous tonemap");
addRow(imageSelection, "Shift+Right/Left or Shift+D/A or Shift+L/H", "Select next/previous tonemap");

addRow(imageSelection, "E / Shift+E", "Increase / decrease exposure by 0.5");
addRow(imageSelection, "O / Shift+O", "Increase / decrease offset by 0.1");
addRow(imageSelection, "E/Shift+E", "Increase/decrease exposure by 0.5");
addRow(imageSelection, "O/Shift+O", "Increase/decrease offset by 0.1");

addRow(imageSelection, "B (hold)", "Draw a border around the image");
addRow(imageSelection, "Shift+Ctrl (hold)", "Display raw bytes on pixels when zoomed-in");
Expand All @@ -114,18 +114,18 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC
addRow(referenceSelection, "Shift (hold)", "View currently selected reference");
addRow(referenceSelection, "Shift+Left Click or Right Click", "Select hovered image as reference");
addRow(referenceSelection, "Shift+1…9", "Select N-th image as reference");
addRow(referenceSelection, "Shift+Down or Shift+S / Shift+Up or Shift+W", "Select next / previous image as reference");
addRow(referenceSelection, "Shift+Down/Up or Shift+S/W or Shift+J/K", "Select next/previous image as reference");

addRow(referenceSelection, "Ctrl (hold)", "View selected image if reference is selected");
addRow(referenceSelection, "Ctrl+Right or Ctrl+D / Ctrl+Left or Ctrl+A", "Select next / previous error metric");
addRow(referenceSelection, "Ctrl (hold)", "View selected image if reference is selected");
addRow(referenceSelection, "Ctrl+Right/Left or Ctrl+D/A or Ctrl+L/H", "Select next/previous error metric");

new Label{shortcuts, "Channel group options", "sans-bold", 18};
auto groupSelection = new Widget{shortcuts};
groupSelection->set_layout(new BoxLayout{Orientation::Vertical, Alignment::Fill, 0, 0});

addRow(groupSelection, "Left Click", "Select hovered channel group");
addRow(groupSelection, "Ctrl+1…9", "Select N-th channel group");
addRow(groupSelection, "Right or D or ] / Left or A or [", "Select next / previous channel group");
addRow(groupSelection, "Right/Left or D/A or L/H or ]/[", "Select next/previous channel group");
addRow(groupSelection, "X", "Explode current channel group");

new Label{shortcuts, "Interface", "sans-bold", 18};
Expand All @@ -134,8 +134,8 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC

addRow(ui, ALT + "+Enter", "Maximize");
addRow(ui, COMMAND + "+B", "Toggle GUI");
addRow(ui, "H or ?", "Show help (this window)");
addRow(ui, COMMAND + "+P", "Find image or channel group");
addRow(ui, "H or ?", "Show help (this window)");
addRow(ui, COMMAND + "+F", "Find image or channel group");
addRow(ui, "Escape", "Reset find string");
addRow(ui, COMMAND + "+Q", "Quit");

Expand Down
23 changes: 9 additions & 14 deletions src/ImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
if (key == GLFW_KEY_0 && (modifiers & SYSTEM_COMMAND_MOD)) {
mImageCanvas->resetTransform();
return true;
} else if (key == GLFW_KEY_F && (modifiers & SYSTEM_COMMAND_MOD)) {
mFilter->request_focus();
return true;
} else if (key == GLFW_KEY_F || (key == GLFW_KEY_9 && (modifiers & SYSTEM_COMMAND_MOD))) {
if (mCurrentImage) {
mImageCanvas->fitImageToScreen(*mCurrentImage);
Expand Down Expand Up @@ -795,13 +798,9 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
} else if (key == GLFW_KEY_S && (modifiers & SYSTEM_COMMAND_MOD)) {
saveImageDialog();
return true;
} else if (key == GLFW_KEY_P && (modifiers & SYSTEM_COMMAND_MOD)) {
mFilter->request_focus();
return true;
} else if (
key == GLFW_KEY_H || /* question mark on US layout */ (
key == GLFW_KEY_SLASH && (modifiers & GLFW_MOD_SHIFT)
)
// question mark on US layout
key == GLFW_KEY_SLASH && (modifiers & GLFW_MOD_SHIFT)
) {
toggleHelpWindow();
return true;
Expand All @@ -822,10 +821,6 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
} else if (key == GLFW_KEY_SPACE) {
setPlayingBack(!playingBack());
return true;
} else if (key == GLFW_KEY_L && mSupportsHdr) {
mClipToLdrButton->set_pushed(!mClipToLdrButton->pushed());
mImageCanvas->setClipToLdr(mClipToLdrButton->pushed());
return true;
} else if (key == GLFW_KEY_ESCAPE) {
setFilter("");
return true;
Expand Down Expand Up @@ -966,7 +961,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
removeImage(mCurrentImage);
}
} else if (
key == GLFW_KEY_UP || key == GLFW_KEY_W || key == GLFW_KEY_PAGE_UP || (
key == GLFW_KEY_UP || key == GLFW_KEY_W || key == GLFW_KEY_K || key == GLFW_KEY_PAGE_UP || (
key == GLFW_KEY_TAB && (modifiers & GLFW_MOD_CONTROL) && (modifiers & GLFW_MOD_SHIFT)
)
) {
Expand All @@ -976,7 +971,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
selectImage(nextImage(mCurrentImage, Backward));
}
} else if (
key == GLFW_KEY_DOWN || key == GLFW_KEY_S || key == GLFW_KEY_PAGE_DOWN || (
key == GLFW_KEY_DOWN || key == GLFW_KEY_S || key == GLFW_KEY_J || key == GLFW_KEY_PAGE_DOWN || (
key == GLFW_KEY_TAB && (modifiers & GLFW_MOD_CONTROL) && !(modifiers & GLFW_MOD_SHIFT)
)
) {
Expand All @@ -987,7 +982,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
}
}

if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D || key == GLFW_KEY_RIGHT_BRACKET) {
if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D || key == GLFW_KEY_L || key == GLFW_KEY_RIGHT_BRACKET) {
if (modifiers & GLFW_MOD_SHIFT) {
setTonemap(static_cast<ETonemap>((tonemap() + 1) % NumTonemaps));
} else if (modifiers & GLFW_MOD_CONTROL) {
Expand All @@ -997,7 +992,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
} else {
selectGroup(nextGroup(mCurrentGroup, Forward));
}
} else if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A || key == GLFW_KEY_LEFT_BRACKET) {
} else if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A || key == GLFW_KEY_H || key == GLFW_KEY_LEFT_BRACKET) {
if (modifiers & GLFW_MOD_SHIFT) {
setTonemap(static_cast<ETonemap>((tonemap() - 1 + NumTonemaps) % NumTonemaps));
} else if (modifiers & GLFW_MOD_CONTROL) {
Expand Down