Does widgets 2.0 themes has support for 'styles'?

I just got back to Corona and want to get my old project up and running. Since I haven’t worked on it for well over a year there’s a lot of things I have to update, one of them is widgets.

In my project (pre widgets 2.0) I have a theme file that includes several styles of buttons, I’ve looked into and found that themes still exists in widgets 2.0 but it seems that each theme can only have one way of displaying a button.

So what I’m wondering is if there’s still support for ‘styles’ only that it’s not documented or if I have to add support for it my self since widgets are now open source.

I’m not sure what you have pre widgets 2.0.   But in the current version of widgets, there are themes which are based on the operating system you are targeting.  We have an iOS6 and earlier theme (widget_theme_ios), an iOS7 theme (widget_theme_ios7), and two variants for Android (widget_theme_android_holo_light, widget_theme_android_holo_dark).  The expectation is that  you would not want to make widgets look like iOS 7 on an Android device and so on.

Each widget can have it’s own custom “skin” where you an style each widget as you see fit.  You can also create your own theme file, and theme.lua file for it if you wanted to have all of your widgets use a common theme file.

Rob

Thanks for the reply.

In my game I’m declaring a button like this
 

local widget = require "widget" widget.setTheme( "myWidgetThemes" ) local button = widget.newButton{ style = "mainMenuSmall1", label = "Water and Lava", onRelease = highLightSelected }

and in myWidgetThemes.lua the theme.button table can contain several ‘styles’ of buttons.

themeTable.button = { -- if no style is specified, will use default: -- default = assetDir .. "button/default.png", -- over = assetDir .. "button/over.png", -- width = 278, height = 46, -- font = "Helvetica-Bold", -- fontSize = 20, -- labelColor = { default={0}, over={255} }, -- emboss = true, -- button styles mainMenuBig = { font = "Dwarf\_font", fontSize = 48, yOffset = -2, labelColor = { default={ 255 } , over={ 255, 204, 70, 255} }, defaultColor = { 255, 204, 70, 255 }, overColor = { 0 }, emboss = true, cornerRadius = 4, width = 240, }, mainMenuSmall = { font = "Dwarf\_font", fontSize = 24, yOffset = -2, labelColor = { default={ 255 } , over={ 255, 204, 70, 255} }, defaultColor = { 255, 204, 70, 255 }, overColor = { 0 }, emboss = true, cornerRadius = 2, width =160, height = 36, }, }

Basically it allowed the user to have a theme containing more than one button which made a lot of sense.

With widgets 2.0 it seems like you’re either forced to only have one type of button or styling each widget manually, leading to a lot of copy pasting and lethargic code.

Feel free to download the widget library from our github repository and make it do what you want.

Rob

While it’s really great that I’m able to do that I’m still confused as to why this feature didn’t make it to 2.0. I have a hard time seeing an app or game only using one button throughout the whole application. This considering I haven’t even been able to find a native app (android) that does that.

Anyway it shouldn’t be any problems implementing it myself, thanks for the help Rob!

I didn’t fork Corona’s GitHub repository. I didn’t want to end up with difficult to maintain code, so I ended up implementing my own “theme library wrapper” around the live version of Widget 2.0. 

For those interested, I followed ingemar’s recommendation and made a really simple wrapper, only 40 lines of code. This also made it really easy to implement in my project I ended up to only having to change require “widget” to require my wrapper instead.

I’m not sure what you have pre widgets 2.0.   But in the current version of widgets, there are themes which are based on the operating system you are targeting.  We have an iOS6 and earlier theme (widget_theme_ios), an iOS7 theme (widget_theme_ios7), and two variants for Android (widget_theme_android_holo_light, widget_theme_android_holo_dark).  The expectation is that  you would not want to make widgets look like iOS 7 on an Android device and so on.

Each widget can have it’s own custom “skin” where you an style each widget as you see fit.  You can also create your own theme file, and theme.lua file for it if you wanted to have all of your widgets use a common theme file.

Rob

Thanks for the reply.

In my game I’m declaring a button like this
 

local widget = require "widget" widget.setTheme( "myWidgetThemes" ) local button = widget.newButton{ style = "mainMenuSmall1", label = "Water and Lava", onRelease = highLightSelected }

and in myWidgetThemes.lua the theme.button table can contain several ‘styles’ of buttons.

themeTable.button = { -- if no style is specified, will use default: -- default = assetDir .. "button/default.png", -- over = assetDir .. "button/over.png", -- width = 278, height = 46, -- font = "Helvetica-Bold", -- fontSize = 20, -- labelColor = { default={0}, over={255} }, -- emboss = true, -- button styles mainMenuBig = { font = "Dwarf\_font", fontSize = 48, yOffset = -2, labelColor = { default={ 255 } , over={ 255, 204, 70, 255} }, defaultColor = { 255, 204, 70, 255 }, overColor = { 0 }, emboss = true, cornerRadius = 4, width = 240, }, mainMenuSmall = { font = "Dwarf\_font", fontSize = 24, yOffset = -2, labelColor = { default={ 255 } , over={ 255, 204, 70, 255} }, defaultColor = { 255, 204, 70, 255 }, overColor = { 0 }, emboss = true, cornerRadius = 2, width =160, height = 36, }, }

Basically it allowed the user to have a theme containing more than one button which made a lot of sense.

With widgets 2.0 it seems like you’re either forced to only have one type of button or styling each widget manually, leading to a lot of copy pasting and lethargic code.

Feel free to download the widget library from our github repository and make it do what you want.

Rob

While it’s really great that I’m able to do that I’m still confused as to why this feature didn’t make it to 2.0. I have a hard time seeing an app or game only using one button throughout the whole application. This considering I haven’t even been able to find a native app (android) that does that.

Anyway it shouldn’t be any problems implementing it myself, thanks for the help Rob!

I didn’t fork Corona’s GitHub repository. I didn’t want to end up with difficult to maintain code, so I ended up implementing my own “theme library wrapper” around the live version of Widget 2.0. 

For those interested, I followed ingemar’s recommendation and made a really simple wrapper, only 40 lines of code. This also made it really easy to implement in my project I ended up to only having to change require “widget” to require my wrapper instead.