list context menu
This commit is contained in:
parent
4126beddc2
commit
d6bdadb75f
2 changed files with 145 additions and 5 deletions
|
|
@ -164,6 +164,7 @@ function link(x,y,label as string)
|
|||
if _mousex>x and _mousey>y and _mousex<x+w and _mousey<y+16 then
|
||||
drawlink x,y,label,1
|
||||
if mouseclicked then link=-1
|
||||
if rmouseclicked then link=-2
|
||||
else
|
||||
drawlink x,y,label,0
|
||||
end if
|
||||
|
|
|
|||
147
pixler.bas
147
pixler.bas
|
|
@ -10,7 +10,7 @@ type statetype
|
|||
starty as long
|
||||
isdrawing as integer
|
||||
end type
|
||||
|
||||
''
|
||||
type layertype
|
||||
ihandle as long
|
||||
blendmode as long
|
||||
|
|
@ -207,15 +207,154 @@ sub commandlist
|
|||
for i=ubound(commands)-1 to 0 step -1
|
||||
y=(ubound(commands)-i)*16
|
||||
if y<_height-20 then
|
||||
'_printstring (x + 5, y + 5), left$(commands(i), 31)
|
||||
if link(x+5,y+5,left$(commands(i),31)) then
|
||||
select case link(x+5,y+5,left$(commands(i),31))
|
||||
case -1 ' Left-Click triggers the inline text rename input box
|
||||
commands(i)=textinput(x+5,y+5,248,23,commands(i))
|
||||
end if
|
||||
case -2 ' Right-Click opens the context menu layout overlay
|
||||
listcontextmenu i, _mousex, _mousey
|
||||
exit sub
|
||||
end select
|
||||
end if
|
||||
next i
|
||||
if button(x,_height-25,60,23,"redraw") then redraw
|
||||
end sub
|
||||
|
||||
sub listcontextmenu (index as long, mx as integer, my as integer)
|
||||
if index < 0 or index >= ubound(commands) then exit sub
|
||||
|
||||
dim done as integer: done = 0
|
||||
dim menuw as integer: menuw = 120
|
||||
dim menuh as integer: menuh = 6 * 24 + 4 ' 6 items at 24px layout spacing
|
||||
|
||||
' Position correction so context panels don't clip outside screens
|
||||
dim x as integer: x = mx
|
||||
if x + menuw > _width then x = _width - menuw
|
||||
dim y as integer: y = my
|
||||
if y + menuh > _height then y = _height - menuh
|
||||
|
||||
do
|
||||
' UI Backdrop reconstruction stack to prevent flickering frames
|
||||
cls, backgroundcolor1
|
||||
canvas
|
||||
if showtoolbox then toolbox
|
||||
if showcolorpicker then colorpicker
|
||||
if state.tool = 12 then drawTextToolPanel
|
||||
|
||||
' Manual render block for command list data under the active frame
|
||||
dim lx as integer: lx = _width - 250
|
||||
line (lx, 0)-(_width - 1, _height - 1), backgroundcolor1, bf
|
||||
line (lx, 0)-(lx, _height - 1), backgroundcolor2
|
||||
_printmode _keepbackground
|
||||
dim ly as integer, i as long
|
||||
for i = ubound(commands) - 1 to 0 step -1
|
||||
ly = (ubound(commands) - i) * 16
|
||||
if ly < _height - 20 then
|
||||
_printstring (lx + 5, ly + 5), left$(commands(i), 31)
|
||||
end if
|
||||
next i
|
||||
if button(lx, _height - 25, 60, 23, "redraw") then redraw
|
||||
|
||||
' Render Context Container Box
|
||||
line (x, y)-(x + menuw, y + menuh), backgroundcolor1, bf
|
||||
line (x, y)-(x + menuw, y + menuh), highlightcolor, b
|
||||
|
||||
' Standard poll for incoming click state loops
|
||||
while _mouseinput: wend
|
||||
mouseclicked = 0: rmouseclicked = 0
|
||||
if mousedown = -1 and _mousebutton(1) = 0 then mouseclicked = -1
|
||||
if rmousedown = -1 and _mousebutton(2) = 0 then rmouseclicked = -1
|
||||
mousedown = _mousebutton(1)
|
||||
rmousedown = _mousebutton(2)
|
||||
|
||||
' Clicking completely outside the menu closes the context window
|
||||
if mouseclicked or rmouseclicked then
|
||||
if not (_mousex > x and _mousex < x + menuw and _mousey > y and _mousey < y + menuh) then
|
||||
done = -1
|
||||
end if
|
||||
end if
|
||||
|
||||
' --- RENDER ENTRIES VIA UI BUTTONS ---
|
||||
dim bx as integer: bx = x + 2
|
||||
dim by as integer: by = y + 2
|
||||
dim bw as integer: bw = menuw - 4
|
||||
dim bh as integer: bh = 22
|
||||
|
||||
' Item 1: Delete
|
||||
if button(bx, by, bw, bh, "Delete") then
|
||||
dim k as long
|
||||
for k = index to ubound(commands) - 1
|
||||
commands(k) = commands(k + 1)
|
||||
next k
|
||||
redim _preserve commands(ubound(commands) - 1) as string
|
||||
redraw
|
||||
done = -1
|
||||
end if
|
||||
by = by + 24
|
||||
|
||||
' 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)
|
||||
commands(index) = commands(index + 1)
|
||||
commands(index + 1) = tempCmd
|
||||
redraw
|
||||
end if
|
||||
done = -1
|
||||
end if
|
||||
by = by + 24
|
||||
|
||||
' 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)
|
||||
commands(index) = commands(index - 1)
|
||||
commands(index - 1) = tempCmd
|
||||
redraw
|
||||
end if
|
||||
done = -1
|
||||
end if
|
||||
by = by + 24
|
||||
|
||||
' Item 4: Insert Above
|
||||
if button(bx, by, bw, bh, "Insert Above") then
|
||||
redim _preserve commands(ubound(commands) + 1) as string
|
||||
for k = ubound(commands) - 1 to index + 2 step -1
|
||||
commands(k) = commands(k - 1)
|
||||
next k
|
||||
commands(index + 1) = ""
|
||||
redraw
|
||||
done = -1
|
||||
end if
|
||||
by = by + 24
|
||||
|
||||
' Item 5: Insert Below
|
||||
if button(bx, by, bw, bh, "Insert Below") then
|
||||
redim _preserve commands(ubound(commands) + 1) as string
|
||||
for k = ubound(commands) - 1 to index + 1 step -1
|
||||
commands(k) = commands(k - 1)
|
||||
next k
|
||||
commands(index) = ""
|
||||
redraw
|
||||
done = -1
|
||||
end if
|
||||
by = by + 24
|
||||
|
||||
' Item 6: Copy to OS Clipboard
|
||||
if button(bx, by, bw, bh, "Copy") then
|
||||
_clipboard$ = commands(index)
|
||||
done = -1
|
||||
end if
|
||||
|
||||
_limit 30
|
||||
_display
|
||||
loop until done or _keydown(27)
|
||||
|
||||
' Flush trailing triggers so the next loop cycle doesn't draw accidental strokes
|
||||
mouseclicked = 0
|
||||
rmouseclicked = 0
|
||||
end sub
|
||||
|
||||
sub drawTextToolPanel
|
||||
dim panelWidth as integer: panelWidth = 160
|
||||
dim x as integer: x = _width - panelWidth
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue