// If the property does not pass the test or has already been used, we keep the default value
console.error(
`Hotkey: ${hotkeysConfigOpts[key]} for ${key} is repeated and conflicts with another hotkey or is not 1 letter. The default hotkey is used: ${defaultHotkeysConfig[key][3]}`
);
result[key]=defaultHotkeysConfig[key];
}
}
returnresult;
}
// Main
onUiLoaded(async()=>{
consthotkeysConfig={
resetZoom:"KeyR",
fitToScreen:"KeyS",
moveKey:"KeyF",
overlap:"KeyO"
consthotkeysConfigOpts=awaitwaitForOpts();
// Default config
constdefaultHotkeysConfig={
canvas_hotkey_reset:"KeyR",
canvas_hotkey_fullscreen:"KeyS",
canvas_hotkey_move:"KeyF",
canvas_hotkey_overlap:"KeyO",
canvas_show_tooltip:true,
canvas_swap_controls:false
};
// swap the actions for ctr + wheel and shift + wheel
consthotkeysConfig=createHotkeyConfig(
defaultHotkeysConfig,
hotkeysConfigOpts
);
letisMoving=false;
letmouseX,mouseY;
...
...
@@ -48,6 +108,68 @@ onUiLoaded(async() => {
let[zoomLevel,panX,panY]=[1,0,0];
letfullScreenMode=false;
// Create tooltip
functioncreateTooltip(){
consttoolTipElemnt=
targetElement.querySelector(".image-container");
consttooltip=document.createElement("div");
tooltip.className="tooltip";
// Creating an item of information
constinfo=document.createElement("i");
info.className="tooltip-info";
info.textContent="";
// Create a container for the contents of the tooltip
// Add information and content elements to the tooltip element
tooltip.appendChild(info);
tooltip.appendChild(tooltipContent);
// Add a hint element to the target element
toolTipElemnt.appendChild(tooltip);
}
//Show tool tip if setting enable
if(hotkeysConfig.canvas_show_tooltip){
createTooltip();
}
// In the course of research, it was found that the tag img is very harmful when zooming and creates white canvases. This hack allows you to almost never think about this problem, it has no effect on webui.
"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_reset":shared.OptionInfo("R","Reset zoom and canvas positon"),
"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_swap_controls":shared.OptionInfo(False,"Swap hotkey combinations for Zoom and Adjust brush resize"),