HI,
I've recreated the function of the tabs example with customizable tabs.
It should be easy to edit the code for more than 3 tabs.
You can use buttons instead of text (use ontouch instead of ontouchdown).
For landscape you can have the tabs on the left
(change lay to be horizontal, horiz1 to be vertical)
and/or switch layout when the user rotates the screen
(I tried to write it more like a plugin, but Layouts don't seem to allow .data)
Regards, ah
const qact = "#999999" // bg for active tab
const qina = "#000000" // bg for inactive tab
function OnStart() {
lay = app.CreateLayout( "Linear", "Vertical,FillXY" )
horiz1 = app.AddLayout( lay,"Linear","Horizontal" )
but1 = qaddbut(horiz1,"Tab 1",1)
but2 = qaddbut(horiz1,"Tab 2",2)
but3 = qaddbut(horiz1,"Tab 3",3)
tab1 = qaddlay(lay)
tab2 = qaddlay(lay)
tab3 = qaddlay(lay)
tab1.SetBackGradient( "red", "green", "", "left-right" )
t1 = app.AddText( tab1,"text1" )
tab2.SetBackGradient( "green", "blue", "", "left-right" )
t2 = app.AddText( tab2,"text2" )
tab3.SetBackGradient( "blue", "red", "", "left-right" )
t3 = app.AddText( tab3,"text3" )
app.SimulateTouch(but1,0.5,0.5,"down") // make first tab active
app.AddLayout( lay )
}
function qaddbut(qlay,qtxt,qidx) {
var q = app.AddText( qlay,qtxt )
q.SetPadding(10,10,10,10,"px")
q.SetOnTouchDown( q_OnTouch )
q.data.qidx = qidx
return q
}
function qaddlay(qlay,qidx) {
var q = app.AddLayout(lay,"Linear", "FillXY")
// q.data.qidx = qidx
q.Gone()
return q
}
function q_OnTouch() {
but1.SetBackColor(qina)
but2.SetBackColor(qina)
but3.SetBackColor(qina)
this.SetBackColor(qact)
var qidx = this.data.qidx
if (qidx == 1) {tab1.Show();} else {tab1.Gone();}
if (qidx == 2) {tab2.Show();} else {tab2.Gone();}
if (qidx == 3) {tab3.Show();} else {tab3.Gone();}
}