This commit is contained in:
visionmercer 2026-06-08 12:30:31 +02:00
commit 4a698757a3

View file

@ -64,21 +64,21 @@ state.bcolor=closestcolor(_rgb32(255,255,255),pal())
addcommand"fcolor ("+hex$(state.fcolor)+")"
addcommand"bcolor ("+hex$(state.bcolor)+")"
DIM SHARED fontHandles(1 TO 10) AS INTEGER
DIM SHARED activeFontIndex AS INTEGER: activeFontIndex = 1
DIM SHARED activeFontSize AS SINGLE: activeFontSize = 16
DIM SHARED textToolString AS STRING
dim shared fonthandles(1 to 10) as integer
dim shared activefontindex as integer:activefontindex=1
dim shared activefontsize as single:activefontsize=16
dim shared texttoolstring as string
fontHandles(1) = LoadBGIFont("./fonts/SIMP.CHR")
fontHandles(2) = LoadBGIFont("./fonts/BOLD.CHR")
fontHandles(3) = LoadBGIFont("./fonts/EURO.CHR")
fontHandles(4) = LoadBGIFont("./fonts/GOTH.CHR")
fontHandles(5) = LoadBGIFont("./fonts/LCOM.CHR")
fontHandles(6) = LoadBGIFont("./fonts/LITT.CHR")
fontHandles(7) = LoadBGIFont("./fonts/SANS.CHR")
fontHandles(8) = LoadBGIFont("./fonts/SCRI.CHR")
fontHandles(9) = LoadBGIFont("./fonts/TRIP.CHR")
fontHandles(10) = LoadBGIFont("./fonts/TSCR.CHR")
fonthandles(1)=loadbgifont("./fonts/SIMP.CHR")
fonthandles(2)=loadbgifont("./fonts/BOLD.CHR")
fonthandles(3)=loadbgifont("./fonts/EURO.CHR")
fonthandles(4)=loadbgifont("./fonts/GOTH.CHR")
fonthandles(5)=loadbgifont("./fonts/LCOM.CHR")
fonthandles(6)=loadbgifont("./fonts/LITT.CHR")
fonthandles(7)=loadbgifont("./fonts/SANS.CHR")
fonthandles(8)=loadbgifont("./fonts/SCRI.CHR")
fonthandles(9)=loadbgifont("./fonts/TRIP.CHR")
fonthandles(10)=loadbgifont("./fonts/TSCR.CHR")
dim lastmx,lastmy
dim keyin as string
@ -187,7 +187,7 @@ do
canvas
if showtoolbox then toolbox
if showcolorpicker then colorpicker
if state.tool = 12 then drawTextToolPanel
if state.tool=12 then drawtexttoolpanel
if showcommands then commandlist
_limit 30
_display
@ -238,7 +238,7 @@ sub listcontextmenu (index as long, mx as integer, my as integer)
canvas
if showtoolbox then toolbox
if showcolorpicker then colorpicker
if state.tool = 12 then drawTextToolPanel
if state.tool=12 then drawtexttoolpanel
' Manual render block for command list data under the active frame
dim lx as integer:lx=_width-250
@ -292,10 +292,10 @@ sub listcontextmenu (index as long, mx as integer, my as integer)
' Item 2: Move Up (moves toward end of array visually)
if button(bx,by,bw,bh,"Move Up") then
if index<ubound(commands)-2 then
dim tempCmd as string
tempCmd = commands(index)
dim tempcmd as string
tempcmd=commands(index)
commands(index)=commands(index+1)
commands(index + 1) = tempCmd
commands(index+1)=tempcmd
redraw
end if
done=-1
@ -305,9 +305,9 @@ sub listcontextmenu (index as long, mx as integer, my as integer)
' Item 3: Move Down (moves toward array index 0)
if button(bx,by,bw,bh,"Move Down") then
if index>0 then
tempCmd = commands(index)
tempcmd=commands(index)
commands(index)=commands(index-1)
commands(index - 1) = tempCmd
commands(index-1)=tempcmd
redraw
end if
done=-1
@ -353,15 +353,15 @@ sub listcontextmenu (index as long, mx as integer, my as integer)
rmouseclicked=0
end sub
sub drawTextToolPanel
dim panelWidth as integer: panelWidth = 160
dim x as integer: x = _width - panelWidth
static showFontList as integer ' Tracks the expanding drop-down list state
sub drawtexttoolpanel
dim panelwidth as integer:panelwidth=160
dim x as integer:x=_width-panelwidth
static showfontlist as integer ' Tracks the expanding drop-down list state
if showcommands then
x = _width - panelWidth - 250
x=_width-panelwidth-250
else
x = _width - panelWidth
x=_width-panelwidth
end if
' Draw the side panel background card block
@ -373,52 +373,52 @@ sub drawTextToolPanel
line (x+10,30)-(x+140,30),backgroundcolor2
' --- Font Size Controls ---
_printstring (x + 10, 45), "Size: " + tst(int(activeFontSize))
_printstring (x+10,45),"Size: "+tst(int(activefontsize))
if button(x+85,42,24,20,"-") then
if activeFontSize > 4 then activeFontSize = activeFontSize - 2
if activefontsize>4 then activefontsize=activefontsize-2
end if
if button(x+115,42,24,20,"+") then
if activeFontSize < 120 then activeFontSize = activeFontSize + 2
if activefontsize<120 then activefontsize=activefontsize+2
end if
' --- Expandable Font Selection Links ---
dim currentFontName as string
select case activeFontIndex
case 1: currentFontName = "SIMP.CHR"
case 2: currentFontName = "BOLD.CHR"
case 3: currentFontName = "EURO.CHR"
case 4: currentFontName = "GOTH.CHR"
case 5: currentFontName = "LCOM.CHR"
case 6: currentFontName = "LITT.CHR"
case 7: currentFontName = "SANS.CHR"
case 8: currentFontName = "SCRI.CHR"
case 9: currentFontName = "TRIP.CHR"
case 10: currentFontName = "TSCR.CHR"
dim currentfontname as string
select case activefontindex
case 1:currentfontname="SIMP.CHR"
case 2:currentfontname="BOLD.CHR"
case 3:currentfontname="EURO.CHR"
case 4:currentfontname="GOTH.CHR"
case 5:currentfontname="LCOM.CHR"
case 6:currentfontname="LITT.CHR"
case 7:currentfontname="SANS.CHR"
case 8:currentfontname="SCRI.CHR"
case 9:currentfontname="TRIP.CHR"
case 10:currentfontname="TSCR.CHR"
end select
_printstring (x+10,80),"Font: "
if link(x + 55, 80, "[" + currentFontName + " ]") then
showFontList = not showFontList ' Toggle expansion list visibility
if link(x+55,80,"["+currentfontname+" ]") then
showfontlist=not showfontlist ' Toggle expansion list visibility
end if
' Render the drop-down links when expanded
if showFontList then
dim fontNames(1 to 10) as string
fontNames(1) = "Simplex": fontNames(2) = "Bold": fontNames(3) = "Euro"
fontNames(4) = "Gothic": fontNames(5) = "Complex": fontNames(6) = "Little"
fontNames(7) = "Sans": fontNames(8) = "Script": fontNames(9) = "Triplex"
fontNames(10) = "TScript"
if showfontlist then
dim fontnames(1 to 10) as string
fontnames(1)="Simplex":fontnames(2)="Bold":fontnames(3)="Euro"
fontnames(4)="Gothic":fontnames(5)="Complex":fontnames(6)="Little"
fontnames(7)="Sans":fontnames(8)="Script":fontnames(9)="Triplex"
fontnames(10)="TScript"
dim ly as integer,idx as integer
for idx=1 to 10
ly=80+(idx*20)
' Highlight the currently active font selection with an asterisk
dim itemPrefix as string
if idx = activeFontIndex then itemPrefix = "* " else itemPrefix = " "
dim itemprefix as string
if idx=activefontindex then itemprefix="* "else itemprefix=" "
if link(x + 20, ly, itemPrefix + fontNames(idx)) then
activeFontIndex = idx
showFontList = 0 ' Auto-collapse list upon selection
if link(x+20,ly,itemprefix+fontnames(idx)) then
activefontindex=idx
showfontlist=0 ' Auto-collapse list upon selection
end if
next idx
end if
@ -494,24 +494,24 @@ sub redraw
case "text"
' Extract the string parameter from the command structure manually
' e.g., text (X, Y, FontHandleIndex, FontSize, FColor, Your String Content)
dim txtStart as integer: txtStart = instr(commands(i), ",")
dim txtstart as integer:txtstart=instr(commands(i),",")
' Advance past the first 5 commas to isolate the text string
dim commaCount as integer: commaCount = 0
dim searchPos as integer: searchPos = 1
while commaCount < 5
searchPos = instr(searchPos, commands(i), ",")
if searchPos > 0 then
commaCount = commaCount + 1
searchPos = searchPos + 1
dim commacount as integer:commacount=0
dim searchpos as integer:searchpos=1
while commacount<5
searchpos=instr(searchpos,commands(i),",")
if searchpos>0 then
commacount=commacount+1
searchpos=searchpos+1
else
exit while
end if
wend
if commaCount = 5 then
dim textMsg as string
textMsg = mid$(commands(i), searchPos, instr(searchPos, commands(i), ")") - searchPos)
if commacount=5 then
dim textmsg as string
textmsg=mid$(commands(i),searchpos,instr(searchpos,commands(i),")")-searchpos)
' Draw text to the drawing layer directly
DisplayBGIText fontHandles(numarr(2)), numarr(0), numarr(1), textMsg, numarr(3), numarr(4)
displaybgitext fonthandles(numarr(2)),numarr(0),numarr(1),textmsg,numarr(3),numarr(4)
end if
case ""
@ -659,12 +659,12 @@ sub canvas
next
_dest layers(2).ihandle:cls,0:_dest 0
' 2.5 Check if the mouse pointer is hitting the UI boundaries
dim mouseInUI as _byte
mouseInUI = 0
dim mouseinui as _byte
mouseinui=0
if showtoolbox and (_mousex>=0 and _mousex<=70) then mouseInUI = -1
if showcolorpicker and (_mousey>=_height-20) then mouseInUI = -1
if showcommands and (_mousex>=drawx2) then mouseInUI = -1
if showtoolbox and (_mousex>=0 and _mousex<=70) then mouseinui=-1
if showcolorpicker and (_mousey>=_height-20) then mouseinui=-1
if showcommands and (_mousex>=drawx2) then mouseinui=-1
' 3. Calculate Canvas Coordinates (Center-aligned to the zoom block)
dim canx as long
@ -678,7 +678,7 @@ sub canvas
if _mousebutton(2) then drawcol=state.bcolor
' ONLY initiate drawing actions if the mouse is NOT in the UI
if mouseInUI = 0 then
if mouseinui=0 then
if (mousedown or rmousedown) and state.isdrawing=0 then
state.startx=canx
state.starty=cany
@ -688,7 +688,7 @@ sub canvas
' Bypass tool execution for regular click-and-drag shapes,
' but ALWAYS allow text tool (12) to pass through so it draws the live overlay
if mouseInUI = 0 or state.tool = 12 then
if mouseinui=0 or state.tool=12 then
select case state.tool
case 1
do.pencil canx,cany,drawcol
@ -1130,7 +1130,7 @@ sub do.text (x as long, y as long, col as long)
state.startx=x
state.starty=y
state.isdrawing=-1
textToolString = "" ' Clear typing input buffer
texttoolstring="" ' Clear typing input buffer
_keyclear ' Flush background buffer lines
end if
@ -1144,13 +1144,13 @@ sub do.text (x as long, y as long, col as long)
if k=0 then exit do
' Character keys range check
if k>=32 and k<=126 then
textToolString = textToolString + chr$(k)
elseif k = 8 and len(textToolString) > 0 then ' Backspace behavior
textToolString = left$(textToolString, len(textToolString) - 1)
texttoolstring=texttoolstring+chr$(k)
elseif k=8 and len(texttoolstring)>0 then ' Backspace behavior
texttoolstring=left$(texttoolstring,len(texttoolstring)-1)
elseif k=13 then
_dest layers(1).ihandle
DisplayBGIText fontHandles(activeFontIndex), state.startx, state.starty, textToolString, activeFontSize, col
addcommand "text (" + tst(state.startx) + "," + tst(state.starty) + "," + tst(activeFontIndex) + "," + tst(int(activeFontSize)) + "," + hex$(col) + "," + textToolString + ")"
displaybgitext fonthandles(activefontindex),state.startx,state.starty,texttoolstring,activefontsize,col
addcommand"text ("+tst(state.startx)+","+tst(state.starty)+","+tst(activefontindex)+","+tst(int(activefontsize))+","+hex$(col)+","+texttoolstring+")"
state.isdrawing=0
_dest odest
_source osource
@ -1163,7 +1163,7 @@ sub do.text (x as long, y as long, col as long)
loop
' 3. Render dynamic typing string overlay to active live preview layer (layer 2)
_dest layers(2).ihandle
DisplayBGIText fontHandles(activeFontIndex), state.startx, state.starty, textToolString + "_", activeFontSize, col
displaybgitext fonthandles(activefontindex),state.startx,state.starty,texttoolstring+"_",activefontsize,col
_source osource
_dest odest
end if
@ -1249,11 +1249,11 @@ function icon (index as long)
icons(10)=_newimage(32,32,32):_dest icons(10)
ditheredgradient 6,6,26,26,highlightcolor,backgroundcolor1
icons(11) = _NEWIMAGE(32, 32, 32): _DEST icons(11)
icons(11)=_newimage(32,32,32):_dest icons(11)
line (8,8)-(24,8),c
line (16,8)-(16,24),c
line (12,24)-(20,24),c
_DEST 0
_dest 0
' Fill remaining fallback slots (10-19) with clean blank images
dim j as integer