Commit 1e0ab401 authored by Danil Boldyrev's avatar Danil Boldyrev

Added the ability to swap the zoom hotkeys and resize the brush

parent d306d25e
...@@ -73,9 +73,10 @@ onUiLoaded(async() => { ...@@ -73,9 +73,10 @@ onUiLoaded(async() => {
canvas_hotkey_fullscreen: "KeyS", canvas_hotkey_fullscreen: "KeyS",
canvas_hotkey_move: "KeyF", canvas_hotkey_move: "KeyF",
canvas_hotkey_overlap: "KeyO", canvas_hotkey_overlap: "KeyO",
canvas_show_tooltip: true canvas_show_tooltip: true,
canvas_swap_controls: false
}; };
// swap the actions for ctr + wheel and shift + wheel
const hotkeysConfig = createHotkeyConfig( const hotkeysConfig = createHotkeyConfig(
defaultHotkeysConfig, defaultHotkeysConfig,
hotkeysConfigOpts hotkeysConfigOpts
...@@ -124,9 +125,12 @@ onUiLoaded(async() => { ...@@ -124,9 +125,12 @@ onUiLoaded(async() => {
tooltipContent.className = "tooltip-content"; tooltipContent.className = "tooltip-content";
// Add info about hotkets // Add info about hotkets
const zoomKey = hotkeysConfig.canvas_swap_controls ? "Ctrl" : "Shift";
const adjustKey = hotkeysConfig.canvas_swap_controls ? "Shift" : "Ctrl";
const hotkeys = [ const hotkeys = [
{key: "Shift + wheel", action: "Zoom canvas"}, {key: `${zoomKey} + wheel`, action: "Zoom canvas"},
{key: "Ctr+wheel", action: "Adjust brush size"}, {key: `${adjustKey} + wheel`, action: "Adjust brush size"},
{ {
key: hotkeysConfig.canvas_hotkey_reset.charAt( key: hotkeysConfig.canvas_hotkey_reset.charAt(
hotkeysConfig.canvas_hotkey_reset.length - 1 hotkeysConfig.canvas_hotkey_reset.length - 1
...@@ -277,7 +281,10 @@ onUiLoaded(async() => { ...@@ -277,7 +281,10 @@ onUiLoaded(async() => {
// Change the zoom level based on user interaction // Change the zoom level based on user interaction
function changeZoomLevel(operation, e) { function changeZoomLevel(operation, e) {
if (e.shiftKey) { if (
(!hotkeysConfig.canvas_swap_controls && e.shiftKey) ||
(hotkeysConfig.canvas_swap_controls && e.ctrlKey)
) {
e.preventDefault(); e.preventDefault();
let zoomPosX, zoomPosY; let zoomPosX, zoomPosY;
...@@ -487,7 +494,11 @@ onUiLoaded(async() => { ...@@ -487,7 +494,11 @@ onUiLoaded(async() => {
changeZoomLevel(operation, e); changeZoomLevel(operation, e);
// Handle brush size adjustment with ctrl key pressed // Handle brush size adjustment with ctrl key pressed
if (e.ctrlKey || e.metaKey) { if (
(hotkeysConfig.canvas_swap_controls && e.shiftKey) ||
(!hotkeysConfig.canvas_swap_controls &&
(e.ctrlKey || e.metaKey))
) {
e.preventDefault(); e.preventDefault();
// Increase or decrease brush size based on scroll direction // Increase or decrease brush size based on scroll direction
......
from modules import shared from modules import shared
shared.options_templates.update(shared.options_section(('canvas_hotkey', "Canvas hotkeys"), { shared.options_templates.update(shared.options_section(('canvas_hotkey', "Canvas Hotkeys"), {
"canvas_hotkey_move": shared.OptionInfo("F", "Moving the canvas"), "canvas_hotkey_move": shared.OptionInfo("F", "Moving the canvas"),
"canvas_hotkey_fullscreen": shared.OptionInfo("S", "Fullscreen Mode, maximizes the picture so that it fits into the screen and stretches it to its full width "), "canvas_hotkey_fullscreen": shared.OptionInfo("S", "Fullscreen Mode, maximizes the picture so that it fits into the screen and stretches it to its full width "),
"canvas_hotkey_reset": shared.OptionInfo("R", "Reset zoom and canvas positon"), "canvas_hotkey_reset": shared.OptionInfo("R", "Reset zoom and canvas positon"),
"canvas_hotkey_overlap": shared.OptionInfo("O", "Toggle overlap ( Technical button, neededs for testing )"), "canvas_hotkey_overlap": shared.OptionInfo("O", "Toggle overlap ( Technical button, neededs for testing )"),
"canvas_show_tooltip": shared.OptionInfo(True, "Enable tooltip on the canvas"), "canvas_show_tooltip": shared.OptionInfo(True, "Enable tooltip on the canvas"),
"canvas_swap_controls": shared.OptionInfo(False, "Swap hotkey combinations for Zoom and Adjust brush resize"),
})) }))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment