Glimmer DSL for SWT 4.17.7.0 ships with the checkbox_group and radio_group Built-In Custom Widgets enabling the spawning of checkboxes and radios automatically with data-binding.
Changes:
- checkbox_group built-in custom widget
- Hello, Checkbox Group! Sample
- Refactor radio_group to render labels instead of relying on radio button text since they are better stylable
- Refactor Glimmer Meta-Sample to use radio_group instead of radio
- Fix issue with ExpandBar fill_layout with the extra element at the end (remove it)
Samples:
Hello, Checkbox Group!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloCheckboxGroup | |
class Person | |
attr_accessor :activities | |
def initialize | |
reset_activities | |
end | |
def activities_options | |
['Skiing', 'Snowboarding', 'Snowmobiling', 'Snowshoeing'] | |
end | |
def reset_activities | |
self.activities = ['Snowboarding'] | |
end | |
end | |
include Glimmer | |
def launch | |
person = Person.new | |
shell { | |
text 'Hello, Checkbox Group!' | |
row_layout :vertical | |
label { | |
text 'Check all snow activities you are interested in:' | |
font style: :bold | |
} | |
checkbox_group { | |
selection bind(person, :activities) | |
} | |
button { | |
text 'Reset Activities' | |
on_widget_selected do | |
person.reset_activities | |
end | |
} | |
}.open | |
end | |
end | |
HelloCheckboxGroup.new.launch |
Hello, Radio Group!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloRadioGroup | |
class Person | |
attr_accessor :gender, :age_group | |
def initialize | |
reset | |
end | |
def gender_options | |
['Male', 'Female'] | |
end | |
def age_group_options | |
['Child', 'Teen', 'Adult', 'Senior'] | |
end | |
def reset | |
self.gender = nil | |
self.age_group = 'Adult' | |
end | |
end | |
include Glimmer | |
def launch | |
person = Person.new | |
shell { | |
text 'Hello, Radio Group!' | |
row_layout :vertical | |
label { | |
text 'Gender:' | |
font style: :bold | |
} | |
radio_group { | |
row_layout :horizontal | |
selection bind(person, :gender) | |
} | |
label { | |
text 'Age Group:' | |
font style: :bold | |
} | |
radio_group { | |
row_layout :horizontal | |
selection bind(person, :age_group) | |
} | |
button { | |
text 'Reset' | |
on_widget_selected do | |
person.reset | |
end | |
} | |
}.open | |
end | |
end | |
HelloRadioGroup.new.launch |

Happy Glimmering!
No comments:
Post a Comment