forked from neo/neo-layout
neovars: ini-input sanitization + some cleanup
This commit is contained in:
parent
3a3b07886a
commit
14104c0e6b
|
@ -13,6 +13,8 @@ UniFontLocalFilePath := ApplicationFolder
|
|||
UniFontLocalFile := UniFontLocalFilePath . "\" . UniFontFilename
|
||||
UniFontZipFontPath := "dejavu-fonts-ttf-" . UniFontVersion . "\ttf\" . UniFontFilename
|
||||
|
||||
BSTguiTitle := "Neo-Bildschirmtastatur"
|
||||
|
||||
BSTnumLayouts := 4
|
||||
|
||||
; default layout
|
||||
|
@ -264,28 +266,52 @@ BSTOnSize() {
|
|||
global
|
||||
if (BSThidden or (BSTxSize == A_guiWidth) and (BSTySize == A_GuiHeight)) ; quick return
|
||||
return
|
||||
local xSize := BSTlayout_%bstLayout%_width
|
||||
local ySize := BSTlayout_%bstLayout%_height
|
||||
local guiWidth := A_GuiWidth
|
||||
local guiHeight := Round(guiWidth*ySize/xSize,0)
|
||||
local yPosition := WorkAreaBottom - Round(guiWidth*ySize/xSize,0) - 1
|
||||
local layoutVariant := (Mod3RAufAe and BSTlayout_%bstLayout%_hasVar1 ? 1 : 0)
|
||||
Gui, Show, % "Y" . yPosition . " W" . guiWidth . " H" . Round(guiWidth*ySize/xSize,0) . " NoActivate", Neo-Bildschirmtastatur
|
||||
Gui, Font, % "s" . Round(guiWidth*12/xSize,0) . " bold", % UniFontName
|
||||
|
||||
local scale := A_guiWidth/BSTlayout_%bstLayout%_width
|
||||
BSTResize(scale, A_guiWidth)
|
||||
}
|
||||
|
||||
; Resize and reposition the GUI window
|
||||
; By default, the window is resized to given scale and moved to the bottom of the screen.
|
||||
; Use centerX=1 to centered horizontally; use xSize to fix the width.
|
||||
BSTResize(scale:="", xSize="", centerX=0) {
|
||||
global
|
||||
if (scale == "")
|
||||
scale := bstScale
|
||||
local xSize_, ySize, xPos, yPos, fontSize
|
||||
BSTmakeDimensions(xSize_, ySize, xPos, yPos, fontSize, scale)
|
||||
xSize := (xSize ? xSize : xSize_) ; fix width if provided
|
||||
Gui, Show, % (centerX ? "x" . xPos : "") . " y" . yPos . " w" . xSize . " h" . ySize . " NoActivate", %BSTguiTitle%
|
||||
|
||||
Gui, Font, % "s" . fontSize . " bold", % UniFontName
|
||||
Loop, Parse, GuiKeyList, `,
|
||||
{
|
||||
GuiPhysKey := A_LoopField
|
||||
GuiControl, -Redraw, GuiKey%GuiPhysKey%
|
||||
GuiControl, Font,GuiKey%GuiPhysKey%
|
||||
GuiControl, Move,GuiKey%GuiPhysKey%, % "x" . Round(GuiPosx%GuiPhysKey%*guiWidth/xSize,0) . " y" . Round(GuiPosy%GuiPhysKey%*guiWidth/xSize,0) . " w" . Round(38*guiWidth/xSize,0) . " h" . Round(38*guiWidth/xSize,0)
|
||||
GuiControl, Move,GuiKey%GuiPhysKey%, % "x" . Round(GuiPosx%GuiPhysKey%*scale) . " y" . Round(GuiPosy%GuiPhysKey%*scale) . " w" . Round(38*scale) . " h" . Round(38*scale)
|
||||
GuiControl, +Redraw, GuiKey%GuiPhysKey%
|
||||
}
|
||||
local layoutVariant := (Mod3RAufAe and BSTlayout_%bstLayout%_hasVar1 ? 1 : 0)
|
||||
Loop, Parse, BSTlayout_%bstLayout%_var_%layoutVariant%_levelImgs, `,
|
||||
{
|
||||
GuiControl, , BSTlevelPicture%A_Index%, % "*w" . guiWidth * 1.0 . " *h-1 " . ResourceFolder . "\" . A_LoopField
|
||||
GuiControl, , BSTlevelPicture%A_Index%, % "*w" . xSize * 1.0 . " *h-1 " . ResourceFolder . "\" . A_LoopField
|
||||
}
|
||||
BSTxSize := guiWidth ; update cached dimensions
|
||||
BSTySize := guiHeight
|
||||
|
||||
; update cached dimensions
|
||||
BSTxSize := xSize
|
||||
BSTySize := ySize
|
||||
}
|
||||
|
||||
; Define various dimensions for the GUI window
|
||||
; Requires globals WorkAreaBottom, bstLayout
|
||||
BSTmakeDimensions(byRef xSize, byRef ySize, byRef xPos, byRef yPos, byRef fontSize, scale) {
|
||||
global
|
||||
xSize := Round(BSTlayout_%bstLayout%_width * scale)
|
||||
ySize := Round(BSTlayout_%bstLayout%_height * scale)
|
||||
xPos := Floor((WorkAreaRight - xSize)/2.) ; centered (floor ~ autocentering in Gui Show)
|
||||
yPos := WorkAreaBottom - ySize - 1 ; lift by 1 pixel (e.g. to bring up hidden taskbar with mouse)
|
||||
fontSize := Round(12*scale)
|
||||
}
|
||||
|
||||
; Prepare for suspension
|
||||
|
@ -295,7 +321,7 @@ BSTStartSuspend() {
|
|||
if (!GuiCurrent)
|
||||
return
|
||||
; display translucent
|
||||
WinSet, TransColor, White 185, Neo-Bildschirmtastatur
|
||||
WinSet, TransColor, White 185, %BSTguiTitle%
|
||||
}
|
||||
|
||||
; Prepare for end of suspension
|
||||
|
@ -306,9 +332,9 @@ BSTEndSuspend() {
|
|||
if (!GuiCurrent)
|
||||
return
|
||||
; display opaque
|
||||
WinSet, Transparent, 255, Neo-Bildschirmtastatur
|
||||
WinSet, Transparent, Off, Neo-Bildschirmtastatur
|
||||
WinSet, TransColor, White, Neo-Bildschirmtastatur
|
||||
WinSet, Transparent, 255, %BSTguiTitle%
|
||||
WinSet, Transparent, Off, %BSTguiTitle%
|
||||
WinSet, TransColor, White, %BSTguiTitle%
|
||||
}
|
||||
|
||||
CharProc__BST0() {
|
||||
|
@ -482,7 +508,7 @@ BSTergodoxLayout() {
|
|||
GuiAddKey("enter",440,240) ; moved
|
||||
}
|
||||
|
||||
BSTisoLayout(hasNumpad = 1) {
|
||||
BSTisoLayout(hasNumpad:=1) {
|
||||
global
|
||||
|
||||
; key spacing 1u = 20px * 2 (scale of export) = 40px
|
||||
|
@ -595,7 +621,7 @@ BSTisoLayout(hasNumpad = 1) {
|
|||
}
|
||||
|
||||
BSTisoTKLLayout() {
|
||||
BSTisoLayout(hasNumpad=0)
|
||||
BSTisoLayout(0)
|
||||
}
|
||||
|
||||
CharProc__BST1() {
|
||||
|
@ -678,15 +704,13 @@ CharProc__BST1() {
|
|||
|
||||
DllCall( "GDI32.DLL\AddFontResourceEx", Str, UniFontLocalFile ,UInt,(FR_PRIVATE:=0x10), Int,0)
|
||||
SysGet, WorkArea, MonitorWorkArea
|
||||
|
||||
local xSize := Round(BSTlayout_%bstLayout%_width * bstScale)
|
||||
local ySize := Round(BSTlayout_%bstLayout%_height * bstScale)
|
||||
local yPosition := WorkAreaBottom - ySize - 1 ; lift by 1 pixel (e.g. to bring up hidden taskbar with mouse)
|
||||
local layoutVariant := (Mod3RAufAe and BSTlayout_%bstLayout%_hasVar1 ? 1 : 0)
|
||||
local xSize, ySize, xPos, yPos, fontSize
|
||||
BSTmakeDimensions(xSize, ySize, xPos, yPos, fontSize, bstScale)
|
||||
|
||||
Gui, Color, FFFFFF
|
||||
Gui, Font, % "s" . Round(bstScale*12,0) . " bold", % UniFontName
|
||||
Gui, Font, % "s" . fontSize . " bold", % UniFontName
|
||||
|
||||
local layoutVariant := (Mod3RAufAe and BSTlayout_%bstLayout%_hasVar1 ? 1 : 0)
|
||||
local level := 0
|
||||
Loop, Parse, BSTlayout_%bstLayout%_var_%layoutVariant%_levelImgs, `,
|
||||
{
|
||||
|
@ -712,9 +736,9 @@ CharProc__BST1() {
|
|||
|
||||
; create hidden GUI window (avoid flicker between now and update)
|
||||
Gui, +AlwaysOnTop +LastFound +Resize +ToolWindow -0x40000 -DPIScale -Caption -MaximizeBox
|
||||
Gui, Show, % "y" . yPosition . " w" . xSize . " h" . ySize . " NoActivate Hide", Neo-Bildschirmtastatur
|
||||
Gui, Show, % "x" . xPos . " y" . yPos . " w" . xSize . " h" . ySize . " NoActivate Hide", %BSTguiTitle%
|
||||
DetectHiddenWindows, On
|
||||
WinSet, TransColor, White, Neo-Bildschirmtastatur
|
||||
WinSet, TransColor, White, %BSTguiTitle%
|
||||
DetectHiddenWindows, Off
|
||||
GuiCurrent := "BST"
|
||||
|
||||
|
@ -725,12 +749,15 @@ CharProc__BST1() {
|
|||
BSTxSize := xSize
|
||||
BSTySize := ySize
|
||||
Check_BSTUpdate()
|
||||
if (A_IsSuspended)
|
||||
BSTStartSuspend()
|
||||
|
||||
; register mouse events
|
||||
OnMessage(0x201, "WM_LBUTTONDOWN")
|
||||
}
|
||||
|
||||
WM_LBUTTONDOWN()
|
||||
{
|
||||
WM_LBUTTONDOWN() {
|
||||
; start dragging with WM_NCLBUTTONDOWN
|
||||
PostMessage, 0xA1, 2
|
||||
}
|
||||
|
||||
|
@ -738,11 +765,11 @@ BSTToggleAlwaysOnTop() {
|
|||
global
|
||||
if (BSTalwaysOnTop) {
|
||||
Gui, -AlwaysOnTop
|
||||
WinSet, Style, +0x40000, Neo-Bildschirmtastatur
|
||||
WinSet, Style, +0x40000, %BSTguiTitle%
|
||||
BSTalwaysOnTop := 0
|
||||
} else {
|
||||
Gui, +AlwaysOnTop
|
||||
WinSet, Style, -0x40000, Neo-Bildschirmtastatur
|
||||
WinSet, Style, -0x40000, %BSTguiTitle%
|
||||
BSTalwaysOnTop := 1
|
||||
}
|
||||
}
|
||||
|
@ -882,12 +909,18 @@ BSTRegister() {
|
|||
|
||||
BSTSymbols()
|
||||
|
||||
IniRead,bstLayout,%ini%,Global,bstLayout,0
|
||||
IniRead,useBST,%ini%,Global,useBST,0
|
||||
IniRead,useDBST,%ini%,Global,useDBST,0
|
||||
IniRead,bstAnimate,%ini%,Global,bstAnimate,1
|
||||
IniRead,bstLayout,%ini%,Global,bstLayout,0
|
||||
if bstLayout is not integer
|
||||
bstLayout := 1
|
||||
else
|
||||
bstLayout := Mod(bstLayout, BSTnumLayouts)
|
||||
IniRead,bstScale,%ini%,Global,bstScale,1
|
||||
if (bstScale <= 0) ; invalid scale
|
||||
if bstScale is not number
|
||||
bstScale := 1
|
||||
else if (bstScale <= 0) ; invalid scale
|
||||
bstScale := 1
|
||||
|
||||
if (useBST or useDBST)
|
||||
|
|
Loading…
Reference in New Issue