something like this? is older code but i still use it for the moment
SetErrorMode(2)
// set window properties
SetWindowTitle( "mine" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
setscreenresolution(1920,1080)
SetVirtualResolution( 1024,768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
setcamerarange(1,.1,1000)
SetGenerateMipmaps(1)
setAntialiasMode(4)
`SetAmbientColor(0,0,0)
setsunactive(0)
global screen_width
screen_width=GetWindowWidth()
global undopending as integer
global Mouseclicked
global clicktarget as integer
global dgray_col
dgray_col=makecolor(64,64,64,255)
global lgray_col
lgray_col=makecolor(128,128,128,255)
#constant parentnums=9
global Main as mainparenttype [ParentNums]
global fontsize as integer:fontsize=18
global HighlighterIID
global HighlighterSID
global clicked as integer//can replace with whatever u want to for clicked funtion
global backgroundSID as integer
global backgroundIID as integer
global ActiveChild as integer
global textheight as integer
global textwidth as integer
global size=1
BuildHighlighter()
BuildDropDownMenu()
do
GlobalMouse()
RunMenu()
Sync()
loop
// File: toolbar.agc
// Created: 20-02-10
Type MainParentType
x_offset as integer
localoffset as integer
parent_string as string
Parent_width as integer
parent_height as integer
Offset as integer
Child as MainParentChild[10]
SpriteID as integer
ImageID as integer
Hover as integer
ChildSpriteID as integer
ChildimageID as integer
entrys as integer
text as integer
endtype
Type MainParentChild
Data as string
Action as string
endtype
function BuildDropDownMenu()
main[1].x_offset=10
main[1].parent_string="File"
main[2].parent_string="Edit"
main[3].parent_string="Tools"
main[4].parent_string="Options"
main[5].parent_string="View"
main[6].parent_string="Entity"
main[7].parent_string="Shaders"
main[8].parent_string="Physics"
main[9].parent_string="Help"
main[1].Child[1].Data="Open Scene"
main[1].Child[2].Data="Open Recent"
main[1].Child[3].Data="New Level"
main[1].Child[4].Data="New Project"
main[1].Child[5].Data="Save Source"
main[1].Child[6].Data="Export"
main[1].Child[7].Data="Exit"
main[2].Child[1].Data="Cut"
main[2].Child[2].Data="Copy"
main[2].Child[3].Data="Paste"
main[2].Child[4].Data="Rotate Object"
main[2].Child[5].Data="Move Object"
main[3].Child[1].Data="Tool1"
main[3].Child[2].Data="Tool2"
main[3].Child[3].Data="Tool3"
main[3].Child[4].Data="Tool4"
main[4].Child[1].Data="Export Options"
main[4].Child[2].Data=""
main[4].Child[3].Data="Option3"
main[4].Child[4].Data="Option4"
main[4].Child[5].Data="Option5"
main[4].Child[6].Data="Option6"
main[4].Child[7].Data="Option7"
main[4].Child[8].Data="Option8"
main[4].Child[9].Data="Option9"
main[4].Child[10].Data="Option10"
main[9].Child[1].Data="Help Files"
main[9].Child[2].Data="Key Reference"
main[9].Child[3].Data="Contact"
main[9].Child[4].Data="About"
text=toolbar_parents()
buildChildren(text)
//fill children entrys
for i = 1 to parentnums
for b= 1 to 10
if len(main[i].child[b].data)>=1
main[i].entrys=main[i].entrys+1
endif
next
next
endfunction
function DrawToolbarBackground()
if GetSpriteExists(backgroundSID)
deletesprite(backgroundSID)
deleteimage(backgroundIID)
endif
size=27
localcolor=makecolor(255,128,40,255)
drawbox(0,0,screen_Width,size+1,localcolor,localcolor,localcolor,localcolor,1)
drawbox(0+1,0+1,screen_Width-2,size/2,Dgray_col,dgray_col,lgray_col,lgray_col,1)//splitbox top
drawbox(0+1,(size/2)+1,screen_Width-2,size-1,lgray_col,lgray_col,dgray_col,dgray_col,1)//splitbox top
image=GetImage(0,0,screen_Width,28):BackgroundIID=image
backgroundiid=image
sprite=createsprite(image):backgroundSID=sprite
setspritedepth(sprite,21)
backgroundsid=sprite
endfunction
function toolbar_parents()
clearscreen()
text=createtext("")
settextvisible(text,0)
settextsize(text,fontsize)
settextstring(text,"a")
textheight=gettexttotalheight(text)
textwidth=gettexttotalwidth(text)
settextstring(text,"")
for i = 1 to ParentNums
settextvisible(text,1)
settextstring(text,main[i].parent_string)
width=GetTextTotalWidth(text)+20
size=24//even number only
drawbox(0,0,width,size/2,Dgray_col,dgray_col,lgray_col,lgray_col,1)//splitbox top
drawbox(0,(size/2)+1,width,size-1,lgray_col,lgray_col,dgray_col,dgray_col,1)//splitbox top
settextposition(text,10,size/2-fontsize/2)
render()
drawtext(text)
settextstring(text,"")
settextvisible(text,0)
image=getimage(0,0,width,size)
sprite=createsprite(image)
main[i].spriteID=sprite
main[i].ImageID=image
setspritedepth(sprite,20)
xoffset=main[1].x_offset
setspriteposition(sprite,xoffset,2)
main[i].localoffset=xoffset
main[1].x_offset=main[1].x_offset+width+10
next
endfunction text
function buildChildren(text)
`clearscreen()
child=0
for parent=1 to ParentNums
for i=1 to 10 //get data of children determin longest lenght
if len(main[Parent].child[i].data)>=1
inc child,1
endif
settextstring(text,main[Parent].child[i].Data)
lenght1=GetTextTotalWidth(text)
if lenght <lenght1
lenght=lenght1
endif
settextstring(text,"")
next
padding=8
rows=child*textheight
localcolor=makecolor(255,128,40,255)
drawbox(0,0,lenght+60,rows+1,localcolor,localcolor,localcolor,localcolor,1)
`drawbox(0,0,lenght+60,rows+1,black_col,black_col,black_col,black_col,1)
drawbox(0+1,0+1,lenght+60-2,rows,Dgray_col,dgray_col,lgray_col,lgray_col,1)//splitbox top
drawline(20,3,20,rows-2,128,128,128)
drawline(21,3,21,rows-2,140,140,140)
for i= 1 to child
drawline(23,((i-1)*textheight)+padding-(textheight/2),lenght+50,((i-1)*textheight)+padding-(textheight/2),110,110,110)
next
render()
settextvisible(text,1)
for i= 1 to child
SetTextPosition(text,25,((i-1)*textheight)+padding-(textheight/2) )
settextstring(text,main[Parent].child[i].Data)
DrawText(text)
next
child=0
settextvisible(text,0)
image=getimage(0,0,lenght+60,rows+2)
main[Parent].ChildImageID=image
next
DeleteText(text)
endfunction
Function RunMenu()
`resolution(0)// use here or directly before in main
HitID=getspritehit(getrawmousex(),getrawmousey())
for i = 1 to Parentnums //get the number for array not id
if main[i].SpriteID=HitID
Highlightparent(i,HitID)
endif
if main[i].SpriteID<>HitID
UnHighlightParent(i,HitID)
endif
next
mouseclick()
DeleteChild()
RunChildren()
SelectSubroutine()
Endfunction
function mouseclick()
if clicked=0
if GetRawMouseLeftPressed()=1
for i = 1 to ParentNums
if main[i].hover=1
CreateChild(i)
clicked=1
endif
next
endif
endif
if clicked=1 and GetRawMouseLeftPressed()=0
clicked=0
endif
endfunction
function highlightparent(parent,HitID)
if main[parent].Hover=0
parentid=main[parent].SpriteID
setspritecolor(ParentID,355,355,355,355)
main[parent].Hover=1
endif
endfunction
function UnhighlightParent(i,HitID)
if main[i].hover=1 and main[i].SpriteID<>HitID
if HitID<>main[i].SpriteID
main[i].hover=0
setspritecolor(main[i].SpriteID,255,255,255,255)
endif
endif
endfunction
Function createChild(i)
if main[i].ChildSpriteID=0
sprite=CreateSprite(main[i].ChildimageID)
setspritedepth(sprite,0)
setspritecoloralpha(sprite,250)
setspriteposition(sprite,main[i].localoffset,27)
main[i].ChildSpriteID=sprite
activechild=i
endif
endfunction
function DeleteChild()
for b = 1 to parentnums
Target=getspritehit(getrawmousex(),getrawmousey())
if main[b].SpriteID<>target and main[b].ChildSpriteID<>target and target<>highlighterSID
if GetSpriteExists(main[b].ChildSpriteID)=1
Deletesprite(main[b].ChildSpriteID)
main[b].ChildSpriteID=0
deletesprite(highlighterSID)
highlighterSID=0
activechild=0
endif
endif
next
Endfunction
function RunChildren()
clearscreen()
if activechild>0
If highlighterSID <1
sprite=createsprite(HighlighterIID) //keep from looping
SetSpriteDepth(sprite,0)
highlighterSID=sprite
endif
if getspriteexists(main[activechild].ChildSpriteID)>0
x=getspritex(main[activechild].ChildSpriteID)
y=getspritey(main[activechild].ChildSpriteID)
mousey=ceil(getrawmousey())
size= (mousey-4-y+textheight)/(textheight)
if size> main[ActiveChild].entrys
size=main[ActiveChild].entrys
endif
if size<1 or size> main[ActiveChild].entrys-1
setspritevisible(highlightersID,0)
endif
if size>0
setspritevisible(highlightersID,1)
endif
boarderoffset=22
SetSpritePosition(highlighterSID,main[activechild].localoffset+boarderoffset+2,size*textheight+10)
text=createtext(main[ActiveChild].child[size].Data)
settextsize(text,fontsize)
width=gettexttotalwidth(text)+4
deletetext(text)
setspritesize(highlighterSID,width,textheight-3)
endif
endif
endfunction
function BuildHighlighter()
blah$="label1"
gray=makecolor(200,200,200,128)
drawbox(0,0,1,1,gray,gray,gray,gray,1)
render()
HighlighterIID=getimage(0,0,1,1)
endfunction
//below are examples for launching functions whith a click
function SelectSubroutine()
if activechild>0 and clicked=0
if getrawmouseleftpressed()=1 and len(main[activechild].child[size].Data)>1
if main[activechild].child[size].Data="Open"
File()
endif
if main[activechild].child[size].Data="Open Recent"
File()
endif
if main[activechild].child[size].Data="New"
`New()
endif
if main[activechild].child[size].Data="Save"
`File()
endif
if main[activechild].child[size].Data="Exit"
`File()
endif
//cleanup
for b= 1 to parentnums
if GetSpriteExists(main[b].ChildSpriteID)=1
Deletesprite(main[b].ChildSpriteID)
main[b].ChildSpriteID=0
deletesprite(highlighterSID)
highlighterSID=0
activechild=0
endif
next
endif
endif
endfunction
//////////////////////////FUNCTION EXAMPLE
function File()
file$=ChooseRawFile(".txt" )
endfunction
function MenuDeleteall()
for i = 1 to parentnums
if getspriteexists(main[i].SpriteID)
deletesprite(main[i].SpriteID)
deleteimage(main[i].ImageID)
endif
next
endfunction
function GlobalMouse()
spritehit=getspritehit(GetRawMouseX(),getrawmousey())
if GetRawMouseLeftState()=1 and spritehit> 0 and clicktarget=0
clicktarget=spritehit
downmousex=GetRawMouseX()
downmousey=getrawmousey()
endif
if getrawmouseleftstate()=0 and clicktarget>0 and clicktarget<>spritehit
clicktarget=0
newmousex=GetRawMouseX()
newmousey=getrawmousey()
endif
if getrawmouseleftstate()=0 and clicktarget>0 and clicktarget=spritehit
Mouseclicked=clicktarget
clicktarget=0
endif
endfunction