Sunday, November 8, 2015

Sliding Drawer Menu

Sliding Drawer Menu

အရင္ တေခါက္က menu button ႏွိပ္လိုက္ရင္ menu panel ေလး တခု ထြက္လာေအာင္ timer သံုးၿပီး ေရးျပခဲ့ပါတယ္။ အခုတခါေတာ့ menu panel ကို လက္နဲ႔ drag ဆြဲထုတ္ရတဲ့ Sliding Drawer Menu တခု ေရးျပပါမယ္။

# Views Panel
# #########

in=-50%x+50
Visible=50
pwidth=50%x

# ###########

AddPanel("pnlMain",0,0,100%x,100%y,"")

AddPanel("pnlPage1",50,0,100%x-50,100%y,"pnlMain")
SetColor("pnlPage1",0,cgreen)

AddPanel("pnlPage2",50,0,100%x-50,100%y,"pnlMain")
SetColor("pnlPage2",0,cyellow)

AddPanel("pnlPage3",50,0,100%x-50,100%y,"pnlMain")
SetColor("pnlPage3",0,cred)

SetVisible("pnlPage2",false)
SetVisible("pnlPage3",false)

# ##########

AddPanel("pnlDrawer",in,0,pwidth,100%y,"")
SetColor("pnlDrawer",0,cblue)
AddLabel("lbl1",10,100,300,100,"pnlDrawer")
SetText("lbl1","Select page")
AddButton("btn1",10,200,300,100,"pnlDrawer")
SetText("btn1","Page1")

AddButton("btn2",10,300,300,100,"pnlDrawer")
SetText("btn2","Page2")

AddButton("btn3",10,400,300,100,"pnlDrawer")
SetText("btn3","Page3")

# ##########

dx=0
dy=0
x=0
y=0
draggable=false
oldl=in
newl=0
currentpage="pnlPage1"

# Events Panel
# ###########
Sub Activity_Pause(UserClosed)
End Sub

Sub Activity_Resume
End Sub

sub activity_touch(action,tx,ty)

select action

case 0
if tx< Visible then
draggable=true
dx=tx
end if

case 1
draggable=false

case 2
if draggable=true then
oldl=getleft("pnlDrawer")
newl=oldl+tx-dx
if newl>0 then
newl=0
end if
if newl<in then
newl=in
end if
Visible=pwidth-newl
Setleft("pnlDrawer",newl)

end if

end select

end sub

Sub Button_Click(Who)
select who

case "btn1"
SetVisible( currentpage,false)
SetVisible( "pnlPage1",true)
currentpage="pnlPage1"

case "btn2"

SetVisible( currentpage,false)
SetVisible( "pnlPage2",true)
currentpage="pnlPage2"

case "btn3"

SetVisible( currentpage,false)
SetVisible( "pnlPage3",true)
currentpage="pnlPage3"

end select
End Sub
# #########

No comments:

Post a Comment