Sliding Tabs (Custom Control) - Using Gideros

A while ago, I had a custom control for a lua based framework, now it is time to test the last article. The best proof would be to create a custom control that one could use. As I mentioned in that article, this can present a wonderful opportunity to distribute apps as a Demo version rather than the release version. If you like it, you can purchase the mobile version for use. So, here goes

Here is a sliding tab control that you can use to have multiple tabs in your app, a video of the same can be viewed here



This has been now made for Gideros and you can download the attached zip file which contains the project. The graphics are contained and were made specifically for the 320x480 version, so if you run this on a larger screen, you might need to resize the graphics for larger screen sizes. The control is rather simple to use. Most of the settings can be changed by code.

here's a sampler of the main.lua that allows you to use the control

require("slider")

local l

local function onTabs(event)
   if event.name=="button" then 
      local theTab = l:getTab(event.tab)
         if theTab.showing==true then 
            print(event.name, event.tab, event.button)
         end
   else 
      print(event.name, event.tab, event.lastTab)
   end 
end

 l = createSlider()     --create the tab control
 l:setHandler(onTabs)   --set the function that shall handle the touches
 l:setButtonWidth(32)   --set the width of the tab header button
 l:setItemWidth(64)     --set the width of the items on the TabBar
 l:setMaxTabs(5)        --set the max number of bars that you want to have
 l:setFileType(".png")  --set the default file type (this shall load images accordingly)
 
 --Create a couple of tabs
 l:createTab()
 l:createTab()
 l:createTab()
 l:createTab()
 l:createTab()
  
--Add a button to the tab #1
 l:addButton(1)
 
--Add buttons to tab #2, but note that the buttons are added as specific images
 l:addButton(2,"006.png")
 l:addButton(2,"005.png")
 l:addButton(2,"004.png")
 l:addButton(2,"003.png")
 l:addButton(2,"002.png")
 
--adding buttons to tab#3 and again specific images
 l:addButton(3,"002.png")
 l:addButton(3,"004.png")
 
--Position the tabbar to the lower bottom of the screen
 l:position(0,256)
 

This will definitely run on a Mac running GiderosStudio, I am not sure about this running on Windows, I hope that it will, but no guarantees.

you can download the project with the zipped file from http://files.oz-apps.com/controls/slidingTab.zip You may not distribute or sell the Graphics or the code which is provided to you in this package for testing only. You may not use it in your projects without purchasing a license to the same.

If you like it and would like to use it in your projects, you may purchase it for $15 AUD, and you can receive the project ready to be incorporated into your own deployment project.

NOTE: This will not work for any other lua framework other than Gideros.

Comments

Popular Posts