added colors
This commit is contained in:
parent
ecfaf41f91
commit
d156b060a8
Notes:
visionmercer
2026-04-29 12:39:55 +02:00
This also adds right button mouse click to imagebutton function, and resize functionality.
2 changed files with 71 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ function imagebutton (x as integer,y as integer,w as integer,h as integer,iconha
|
||||||
if _mousex>x and _mousey>y and _mousex<x+w and _mousey<y+h then
|
if _mousex>x and _mousey>y and _mousex<x+w and _mousey<y+h then
|
||||||
drawimagebutton x,y,w,h,iconhandle,1
|
drawimagebutton x,y,w,h,iconhandle,1
|
||||||
if mouseclicked then imagebutton=-1
|
if mouseclicked then imagebutton=-1
|
||||||
|
if rmouseclicked then imagebutton=-2
|
||||||
else
|
else
|
||||||
drawimagebutton x,y,w,h,iconhandle,0
|
drawimagebutton x,y,w,h,iconhandle,0
|
||||||
end if
|
end if
|
||||||
|
|
|
||||||
74
pixler.bas
74
pixler.bas
|
|
@ -8,6 +8,7 @@ type layertype
|
||||||
ihandle as long
|
ihandle as long
|
||||||
blendmode as long
|
blendmode as long
|
||||||
filter as long
|
filter as long
|
||||||
|
kind as long
|
||||||
end type
|
end type
|
||||||
|
|
||||||
dim shared layers(0) as layertype
|
dim shared layers(0) as layertype
|
||||||
|
|
@ -17,21 +18,32 @@ dim shared state as statetype
|
||||||
|
|
||||||
dim shared mouseclicked as integer
|
dim shared mouseclicked as integer
|
||||||
dim shared mousedown as integer
|
dim shared mousedown as integer
|
||||||
|
dim shared rmouseclicked as integer
|
||||||
|
dim shared rmousedown as integer
|
||||||
|
$resize:on
|
||||||
screen _newimage(640,480,32)
|
screen _newimage(640,480,32)
|
||||||
redim pal(0) as _unsigned long
|
_delay 0.1
|
||||||
|
temp&=_resize
|
||||||
|
redim shared pal(0) as _unsigned long
|
||||||
dim as integer ch1,ch2,ch3,bt
|
dim as integer ch1,ch2,ch3,bt
|
||||||
loadpalette "slso8",pal()
|
loadpalette "endesga16",pal()
|
||||||
|
|
||||||
do
|
do
|
||||||
line (0,0)-(_width-1,_height-1),backgroundcolor1,bf
|
line (0,0)-(_width-1,_height-1),backgroundcolor1,bf
|
||||||
|
IF CheckResize(_SOURCE) = -1 then rem 'whatever, maybe some day somthing needs changing if the window is resized'
|
||||||
while _mouseinput:wend
|
while _mouseinput:wend
|
||||||
mouseclicked=0
|
mouseclicked=0
|
||||||
|
rmouseclicked=0
|
||||||
if mousedown=-1 and _mousebutton(1)=0 then mouseclicked=-1
|
if mousedown=-1 and _mousebutton(1)=0 then mouseclicked=-1
|
||||||
|
if rmousedown=-1 and _mousebutton(1)=0 then rmouseclicked=-1
|
||||||
mousedown=_mousebutton(1)
|
mousedown=_mousebutton(1)
|
||||||
|
rmousedown=_mousebutton(2)
|
||||||
toolbox
|
toolbox
|
||||||
colorpicker
|
colorpicker
|
||||||
canvas
|
canvas
|
||||||
locate 10,10: print state.tool
|
locate 10,10: print state.tool
|
||||||
|
locate 11,10: color state.fcolor: print state.fcolor
|
||||||
|
locate 12,10: color state.bcolor: print state.bcolor
|
||||||
_limit 30
|
_limit 30
|
||||||
_display
|
_display
|
||||||
loop
|
loop
|
||||||
|
|
@ -43,7 +55,21 @@ sub toolbox
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
sub colorpicker
|
sub colorpicker
|
||||||
|
dim img as long
|
||||||
|
img=_newimage(16,16,32)
|
||||||
|
for i=0 to ubound(pal)
|
||||||
|
_dest img
|
||||||
|
cls ,pal(i)
|
||||||
|
line (0,0)-(_width-1,height-1),pal(i),bf
|
||||||
|
_dest 0
|
||||||
|
select case imagebutton(i*16,_height-17,16,16,img)
|
||||||
|
case -1
|
||||||
|
state.fcolor=pal(i)
|
||||||
|
case -2
|
||||||
|
state.bcolor=pal(i)
|
||||||
|
end select
|
||||||
|
next i
|
||||||
|
_freeimage img
|
||||||
end sub
|
end sub
|
||||||
|
|
||||||
sub canvas
|
sub canvas
|
||||||
|
|
@ -73,7 +99,6 @@ function icon(index as long)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
'$include: 'include/ui.bm'
|
'$include: 'include/ui.bm'
|
||||||
|
|
||||||
'$include: 'include/imgout.bm'
|
'$include: 'include/imgout.bm'
|
||||||
'$include: 'include/palette.bm'
|
'$include: 'include/palette.bm'
|
||||||
|
|
||||||
|
|
@ -133,3 +158,44 @@ function __internaluiicon&(index as long,imagehandle as long,mode as integer)
|
||||||
__internaluiicon=icons(index)
|
__internaluiicon=icons(index)
|
||||||
end select
|
end select
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|
||||||
|
FUNCTION CheckResize (CurrentScreen AS _UNSIGNED LONG)
|
||||||
|
|
||||||
|
' *** Define local variable for temporary screen
|
||||||
|
DIM TempScreen AS _UNSIGNED LONG
|
||||||
|
|
||||||
|
CheckResize = 0
|
||||||
|
|
||||||
|
' *** Check to see if the user resized the window. If so, change the SCREEN image to the correct size.
|
||||||
|
IF _RESIZE THEN
|
||||||
|
|
||||||
|
' *** First, create a copy of the current SCREEN image.
|
||||||
|
TempScreen = _COPYIMAGE(CurrentScreen, 32)
|
||||||
|
|
||||||
|
' *** Set the SCREEN to the copied image, releasing the current SCREEN image.
|
||||||
|
SCREEN TempScreen
|
||||||
|
|
||||||
|
' *** Remove (FREE) the original SCREEN image.
|
||||||
|
_FREEIMAGE CurrentScreen
|
||||||
|
|
||||||
|
' *** Create a new "original" SCREEN image.
|
||||||
|
CurrentScreen = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32)
|
||||||
|
|
||||||
|
' *** Set the SCREEN to the new "original" image, releasing the copied SCREEN image.
|
||||||
|
SCREEN CurrentScreen
|
||||||
|
|
||||||
|
' DRAW PREVIOUS SCREEN ON THE NEW ONE
|
||||||
|
_PUTIMAGE (0, 0), TempScreen, CurrentScreen
|
||||||
|
|
||||||
|
_DISPLAY
|
||||||
|
|
||||||
|
' *** Remove (FREE) the copied SCREEN image.
|
||||||
|
_FREEIMAGE TempScreen
|
||||||
|
|
||||||
|
' *** Tell the caller there was a resize
|
||||||
|
CheckResize = -1
|
||||||
|
|
||||||
|
END IF
|
||||||
|
|
||||||
|
END FUNCTION
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue