glimmer-dsl-libui 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +446 -15
- data/VERSION +1 -1
- data/examples/control_gallery.rb +184 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/dsl.rb +1 -1
- data/lib/glimmer/dsl/libui/file_expression.rb +33 -0
- data/lib/glimmer/dsl/libui/open_file_expression.rb +33 -0
- data/lib/glimmer/dsl/libui/save_file_expression.rb +33 -0
- data/lib/glimmer/dsl/libui/tab_item_expression.rb +35 -0
- data/lib/glimmer/libui/about_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/box.rb +4 -0
- data/lib/glimmer/libui/check_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/combobox_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy.rb +54 -18
- data/lib/glimmer/libui/editable_combobox_proxy.rb +42 -0
- data/lib/glimmer/libui/group_proxy.rb +35 -0
- data/lib/glimmer/libui/menu_item_proxy.rb +4 -1
- data/lib/glimmer/libui/preferences_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/quit_menu_item_proxy.rb +62 -0
- data/lib/glimmer/libui/radio_buttons_proxy.rb +42 -0
- data/lib/glimmer/libui/separator_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/tab_item_proxy.rb +64 -0
- data/lib/glimmer/libui/window_proxy.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3d949c7e8a83eaa3d09b07e3117158885f1c34d13737420d3a1cf7499d2250c
|
4
|
+
data.tar.gz: db7447e66369398e9c1b48ab194f27c710cab11e60998bc8eaae1bb2c64145b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f9c8af1645a02379f6a1693bffc20bc6c1c70a349603810a7f292b886c1652f60426459063641a676ee50e5f6b035a25effe21b4f39acca5bb43c394ef89e58
|
7
|
+
data.tar.gz: f41584f6026750c4c30e18475ceabac1a8382b11cfccd62f536fafbed0225a4a21cd651ec477baae93b596090154f7a1692ac3a3ae6fca8a7625fe774a618fcd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.5
|
4
|
+
|
5
|
+
- Support examples/control_gallery.rb
|
6
|
+
- Support `open_file` and `save_file`
|
7
|
+
- Support `quit_menu_item` with `on_clicked` listener
|
8
|
+
- Support `preferences_menu_item` and `about_menu_item`
|
9
|
+
- Support `check_menu_item` and `separator_menu_item`
|
10
|
+
- Support `enabled=` & `set_enabled` on all controls (making `enabled` property read/write by relying on `enable`/`disable` operations)
|
11
|
+
- Support `visible=` & `set_visible` on all controls (making `visible` property read/write by relying on `show`/`hide` operations)
|
12
|
+
- Support `horizontal_box` and `vertical_box` propeties (`padded`) & operations (`append`, `delete`) via `LibUI.box_*` methods
|
13
|
+
- Support `editable_combobox`, `radio_buttons`, and `group`
|
14
|
+
- Support `tab` and `tab_item`
|
15
|
+
- Fix issue with always setting menu item text to 'Version' (correctly set to passed argument instead)
|
16
|
+
|
3
17
|
## 0.0.4
|
4
18
|
|
5
19
|
- Support examples/midi_player.rb
|
data/README.md
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.0.
|
2
|
-
##
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.0.5
|
2
|
+
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
5
5
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
6
6
|
|
7
|
-
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a
|
8
|
-
ll any pre-requisites. Just install the gem and have platform-independent GUI that just works!
|
7
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a prerequisite-free Ruby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent GUI that just works!
|
9
8
|
|
10
|
-
|
9
|
+
[LibUI](https://github.com/kojix2/LibUI) is a thin [Ruby](https://www.ruby-lang.org/en/) wrapper around [libui](https://github.com/andlabs/libui), a relatively new C GUI library that renders native widgets on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
|
11
10
|
|
12
|
-
[Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
|
11
|
+
The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) as opposed to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) or [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) is the fact that [SWT](https://www.eclipse.org/swt/) and [Tk](https://www.tcl.tk/) are more mature than mid-alpha [libui](https://github.com/andlabs/libui) as GUI toolkits. Still, if there is only a need to build a small simple application, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) could be a good convenient choice due to having zero prerequisites beyond the dependencies included in the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui). Also, just like [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk), its apps start instantly and have a small memory footprint. [LibUI](https://github.com/kojix2/LibUI) is a promising new GUI toolkit that might prove quite worthy in the future.
|
12
|
+
|
13
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
|
13
14
|
- Declarative DSL syntax that visually maps to the GUI widget hierarchy
|
14
15
|
- Convention over configuration via smart defaults and automation of low-level details
|
15
16
|
- Requiring the least amount of syntax possible to build GUI
|
@@ -42,7 +43,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
42
43
|
|
43
44
|
## Glimmer GUI DSL Concepts
|
44
45
|
|
45
|
-
The Glimmer GUI DSL provides
|
46
|
+
The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for [LibUI](https://github.com/kojix2/LibUI) that:
|
46
47
|
- Supports smart defaults (e.g. automatic `on_closing` listener that quits `window`)
|
47
48
|
- Automates wiring of widgets (e.g. `button` is automatically set as child of `window`)
|
48
49
|
- Hides lower-level details (e.g. `LibUI.main` loop is started automatically when triggering `show` on `window`)
|
@@ -117,7 +118,7 @@ gem install glimmer-dsl-libui
|
|
117
118
|
Or install via Bundler `Gemfile`:
|
118
119
|
|
119
120
|
```ruby
|
120
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
121
|
+
gem 'glimmer-dsl-libui', '~> 0.0.5'
|
121
122
|
```
|
122
123
|
|
123
124
|
Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
|
@@ -146,7 +147,7 @@ Application.new.launch
|
|
146
147
|
|
147
148
|
## API
|
148
149
|
|
149
|
-
Any control returned by a Glimmer GUI DSL keyword declaration can be introspected for its properties and updated via object-oriented attributes (standard Ruby `attr`/`attr=` or `set_attr`).
|
150
|
+
Any control returned by a [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) keyword declaration can be introspected for its properties and updated via object-oriented attributes (standard Ruby `attr`/`attr=` or `set_attr`).
|
150
151
|
|
151
152
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
152
153
|
|
@@ -170,18 +171,40 @@ w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0
|
|
170
171
|
|
171
172
|
Supported Controls and their Properties / Listeners:
|
172
173
|
- `button`: `text` (`String`) / `on_clicked`
|
174
|
+
- `combobox`: `items` (`Array` of `String`), `selected` (`1` or `0`) / `on_selected`
|
175
|
+
- `color_button`: `color` (r `Numeric`, g `Numeric`, b `Numeric`, a `Numeric`), `selected` (`1` or `0`) / `on_selected`
|
176
|
+
- `date_picker`: None / None
|
177
|
+
- `date_time_picker`: `time` (`UI::FFI::TM`) / `on_changed`
|
178
|
+
- `editable_combobox`: `items` (`Array` of `String`), `text` (`String`) / `on_changed`
|
173
179
|
- `entry`: `read_only` (`1` or `0`), `text` (`String`) / `on_changed`
|
180
|
+
- `font_button`: `font` (`UI::FFI::FontDescriptor`) / `on_changed`
|
181
|
+
- `group`: `margined` (`1` or `0`), `title` (`String`) / None
|
182
|
+
- `horizontal_box`: `padded` (`1` or `0`) / None
|
183
|
+
- `horizontal_separator`: None / None
|
184
|
+
- `label`: `text` (`String`) / None
|
174
185
|
- `menu`: None / None
|
175
186
|
- `menu_item`: `checked` (`1` or `0`) / `on_clicked`
|
187
|
+
- `multiline_entry`: `read_only` (`1` or `0`), `text` (`String`) / None
|
176
188
|
- `msg_box`: None / None
|
177
189
|
- `non_wrapping_multiline_entry`: None / None
|
190
|
+
- `progress_bar`: `value` (`Numeric`) / None
|
191
|
+
- `radio_buttons`: `selected` (`1` or `0`) / `on_selected`
|
192
|
+
- `slider`: `value` (`Numeric`) / `on_changed`
|
193
|
+
- `spinbox`: `value` (`Numeric`) / `on_changed`
|
194
|
+
- `tab`: `margined` (`1` or `0`), `num_pages` (`Integer`) / None
|
195
|
+
- `tab_item`: `index` [read-only] (`Integer`), `margined` (`1` or `0`), `name` [read-only] (`String`) / None
|
196
|
+
- `time_picker`: None / None
|
197
|
+
- `vertical_box`: `padded` (`1` or `0`) / None
|
178
198
|
- `window`: `borderless` (`1` or `0`), `content_size` (width `Numeric`, height `Numeric`), `fullscreen` (`1` or `0`), `margined` (`1` or `0`), `title` (`String`) / `on_closing`, `on_content_size_changed`
|
179
199
|
|
180
200
|
Common Control Properties:
|
181
|
-
- `enabled`
|
182
|
-
- `
|
183
|
-
- `
|
184
|
-
- `
|
201
|
+
- `enabled` (`1` or `0`)
|
202
|
+
- `libui` (`Fiddle::Pointer`): returns wrapped [LibUI](https://github.com/kojix2/LibUI) object
|
203
|
+
- `parent_proxy` (`Glimmer::LibUI::ControlProxy` or subclass)
|
204
|
+
- `parent` (`Fiddle::Pointer`)
|
205
|
+
- `toplevel` [read-only] (`1` or `0`)
|
206
|
+
- `visible` (`1` or `0`)
|
207
|
+
- `stretchy` [dsl-only] (`1` or `0`): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
|
185
208
|
|
186
209
|
Common Control Operations:
|
187
210
|
- `destroy`
|
@@ -190,6 +213,8 @@ Common Control Operations:
|
|
190
213
|
- `hide`
|
191
214
|
- `show`
|
192
215
|
|
216
|
+
To learn more about the [LibUI](https://github.com/kojix2/LibUI) API exposed through [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui), check out the [libui C headers](https://github.com/andlabs/libui/blob/master/ui.h)
|
217
|
+
|
193
218
|
## Girb (Glimmer IRB)
|
194
219
|
|
195
220
|
You can run the `girb` command (`bin/girb` if you cloned the project locally):
|
@@ -204,7 +229,7 @@ Gotcha: On the Mac, when you close a window opened in `girb`, it remains open un
|
|
204
229
|
|
205
230
|
## Examples
|
206
231
|
|
207
|
-
These examples reimplement the ones in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the Glimmer GUI DSL.
|
232
|
+
These examples reimplement the ones in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the [Glimmer GUI DSL](#glimmer-gui-dsl-concepts).
|
208
233
|
|
209
234
|
### Basic Window
|
210
235
|
|
@@ -518,7 +543,7 @@ window('Notepad', 500, 300, 1) {
|
|
518
543
|
|
519
544
|
### Midi Player
|
520
545
|
|
521
|
-
This example has
|
546
|
+
This example has prerequisites:
|
522
547
|
- Install [TiMidity](http://timidity.sourceforge.net) and ensure `timidity` command is in `PATH` (can be installed via [Homebrew](https://brew.sh) on Mac or [apt-get](https://help.ubuntu.com/community/AptGet/Howto) on Linux).
|
523
548
|
- Add `*.mid` files to `~/Music` directory (you may copy the ones included in [sounds](sounds) directory)
|
524
549
|
|
@@ -740,6 +765,412 @@ end
|
|
740
765
|
TinyMidiPlayer.new
|
741
766
|
```
|
742
767
|
|
768
|
+
### Control Gallery
|
769
|
+
|
770
|
+
[examples/control_gallery.rb](examples/control_gallery.rb)
|
771
|
+
|
772
|
+
Run with this command from the root of the project if you cloned the project:
|
773
|
+
|
774
|
+
```
|
775
|
+
ruby -r './lib/glimmer-dsl-libui' examples/control_gallery.rb
|
776
|
+
```
|
777
|
+
|
778
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
779
|
+
|
780
|
+
```
|
781
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/control_gallery'"
|
782
|
+
```
|
783
|
+
|
784
|
+
Mac
|
785
|
+
|
786
|
+
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png)
|
787
|
+
|
788
|
+
Linux
|
789
|
+
|
790
|
+
![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
791
|
+
|
792
|
+
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
793
|
+
|
794
|
+
```ruby
|
795
|
+
require 'libui'
|
796
|
+
UI = LibUI
|
797
|
+
|
798
|
+
UI.init
|
799
|
+
|
800
|
+
should_quit = proc do
|
801
|
+
puts 'Bye Bye'
|
802
|
+
UI.control_destroy(MAIN_WINDOW)
|
803
|
+
UI.quit
|
804
|
+
0
|
805
|
+
end
|
806
|
+
|
807
|
+
# File menu
|
808
|
+
menu = UI.new_menu('File')
|
809
|
+
open_menu_item = UI.menu_append_item(menu, 'Open')
|
810
|
+
UI.menu_item_on_clicked(open_menu_item) do
|
811
|
+
pt = UI.open_file(MAIN_WINDOW)
|
812
|
+
puts pt unless pt.null?
|
813
|
+
end
|
814
|
+
save_menu_item = UI.menu_append_item(menu, 'Save')
|
815
|
+
UI.menu_item_on_clicked(save_menu_item) do
|
816
|
+
pt = UI.save_file(MAIN_WINDOW)
|
817
|
+
puts pt unless pt.null?
|
818
|
+
end
|
819
|
+
|
820
|
+
UI.menu_append_quit_item(menu)
|
821
|
+
UI.on_should_quit(should_quit)
|
822
|
+
|
823
|
+
# Edit menu
|
824
|
+
edit_menu = UI.new_menu('Edit')
|
825
|
+
UI.menu_append_check_item(edit_menu, 'Checkable Item_')
|
826
|
+
UI.menu_append_separator(edit_menu)
|
827
|
+
disabled_item = UI.menu_append_item(edit_menu, 'Disabled Item_')
|
828
|
+
UI.menu_item_disable(disabled_item)
|
829
|
+
|
830
|
+
preferences = UI.menu_append_preferences_item(menu)
|
831
|
+
|
832
|
+
# Help menu
|
833
|
+
help_menu = UI.new_menu('Help')
|
834
|
+
UI.menu_append_item(help_menu, 'Help')
|
835
|
+
UI.menu_append_about_item(help_menu)
|
836
|
+
|
837
|
+
# Main Window
|
838
|
+
MAIN_WINDOW = UI.new_window('Control Gallery', 600, 500, 1)
|
839
|
+
UI.window_set_margined(MAIN_WINDOW, 1)
|
840
|
+
UI.window_on_closing(MAIN_WINDOW, should_quit)
|
841
|
+
|
842
|
+
vbox = UI.new_vertical_box
|
843
|
+
UI.window_set_child(MAIN_WINDOW, vbox)
|
844
|
+
hbox = UI.new_horizontal_box
|
845
|
+
UI.box_set_padded(vbox, 1)
|
846
|
+
UI.box_set_padded(hbox, 1)
|
847
|
+
|
848
|
+
UI.box_append(vbox, hbox, 1)
|
849
|
+
|
850
|
+
# Group - Basic Controls
|
851
|
+
group = UI.new_group('Basic Controls')
|
852
|
+
UI.group_set_margined(group, 1)
|
853
|
+
UI.box_append(hbox, group, 1) # OSX bug?
|
854
|
+
|
855
|
+
inner = UI.new_vertical_box
|
856
|
+
UI.box_set_padded(inner, 1)
|
857
|
+
UI.group_set_child(group, inner)
|
858
|
+
|
859
|
+
# Button
|
860
|
+
button = UI.new_button('Button')
|
861
|
+
UI.button_on_clicked(button) do
|
862
|
+
UI.msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
863
|
+
end
|
864
|
+
UI.box_append(inner, button, 0)
|
865
|
+
|
866
|
+
# Checkbox
|
867
|
+
checkbox = UI.new_checkbox('Checkbox')
|
868
|
+
UI.checkbox_on_toggled(checkbox) do |ptr|
|
869
|
+
checked = UI.checkbox_checked(ptr) == 1
|
870
|
+
UI.window_set_title(MAIN_WINDOW, "Checkbox is #{checked}")
|
871
|
+
UI.checkbox_set_text(ptr, "I am the checkbox (#{checked})")
|
872
|
+
end
|
873
|
+
UI.box_append(inner, checkbox, 0)
|
874
|
+
|
875
|
+
# Label
|
876
|
+
UI.box_append(inner, UI.new_label('Label'), 0)
|
877
|
+
|
878
|
+
# Separator
|
879
|
+
UI.box_append(inner, UI.new_horizontal_separator, 0)
|
880
|
+
|
881
|
+
# Date Picker
|
882
|
+
UI.box_append(inner, UI.new_date_picker, 0)
|
883
|
+
|
884
|
+
# Time Picker
|
885
|
+
UI.box_append(inner, UI.new_time_picker, 0)
|
886
|
+
|
887
|
+
# Date Time Picker
|
888
|
+
UI.box_append(inner, UI.new_date_time_picker, 0)
|
889
|
+
|
890
|
+
# Font Button
|
891
|
+
UI.box_append(inner, UI.new_font_button, 0)
|
892
|
+
|
893
|
+
# Color Button
|
894
|
+
UI.box_append(inner, UI.new_color_button, 0)
|
895
|
+
|
896
|
+
inner2 = UI.new_vertical_box
|
897
|
+
UI.box_set_padded(inner2, 1)
|
898
|
+
UI.box_append(hbox, inner2, 1)
|
899
|
+
|
900
|
+
# Group - Numbers
|
901
|
+
group = UI.new_group('Numbers')
|
902
|
+
UI.group_set_margined(group, 1)
|
903
|
+
UI.box_append(inner2, group, 0)
|
904
|
+
|
905
|
+
inner = UI.new_vertical_box
|
906
|
+
UI.box_set_padded(inner, 1)
|
907
|
+
UI.group_set_child(group, inner)
|
908
|
+
|
909
|
+
# Spinbox
|
910
|
+
spinbox = UI.new_spinbox(0, 100)
|
911
|
+
UI.spinbox_set_value(spinbox, 42)
|
912
|
+
UI.spinbox_on_changed(spinbox) do |ptr|
|
913
|
+
puts "New Spinbox value: #{UI.spinbox_value(ptr)}"
|
914
|
+
end
|
915
|
+
UI.box_append(inner, spinbox, 0)
|
916
|
+
|
917
|
+
# Slider
|
918
|
+
slider = UI.new_slider(0, 100)
|
919
|
+
UI.box_append(inner, slider, 0)
|
920
|
+
|
921
|
+
# Progressbar
|
922
|
+
progressbar = UI.new_progress_bar
|
923
|
+
UI.box_append(inner, progressbar, 0)
|
924
|
+
|
925
|
+
UI.slider_on_changed(slider) do |ptr|
|
926
|
+
v = UI.slider_value(ptr)
|
927
|
+
puts "New Slider value: #{v}"
|
928
|
+
UI.progress_bar_set_value(progressbar, v)
|
929
|
+
end
|
930
|
+
|
931
|
+
# Group - Lists
|
932
|
+
group = UI.new_group('Lists')
|
933
|
+
UI.group_set_margined(group, 1)
|
934
|
+
UI.box_append(inner2, group, 0)
|
935
|
+
|
936
|
+
inner = UI.new_vertical_box
|
937
|
+
UI.box_set_padded(inner, 1)
|
938
|
+
UI.group_set_child(group, inner)
|
939
|
+
|
940
|
+
# Combobox
|
941
|
+
cbox = UI.new_combobox
|
942
|
+
UI.combobox_append(cbox, 'combobox Item 1')
|
943
|
+
UI.combobox_append(cbox, 'combobox Item 2')
|
944
|
+
UI.combobox_append(cbox, 'combobox Item 3')
|
945
|
+
UI.box_append(inner, cbox, 0)
|
946
|
+
UI.combobox_on_selected(cbox) do |ptr|
|
947
|
+
puts "New combobox selection: #{UI.combobox_selected(ptr)}"
|
948
|
+
end
|
949
|
+
|
950
|
+
# Editable Combobox
|
951
|
+
ebox = UI.new_editable_combobox
|
952
|
+
UI.editable_combobox_append(ebox, 'Editable Item 1')
|
953
|
+
UI.editable_combobox_append(ebox, 'Editable Item 2')
|
954
|
+
UI.editable_combobox_append(ebox, 'Editable Item 3')
|
955
|
+
UI.box_append(inner, ebox, 0)
|
956
|
+
|
957
|
+
# Radio Buttons
|
958
|
+
rb = UI.new_radio_buttons
|
959
|
+
UI.radio_buttons_append(rb, 'Radio Button 1')
|
960
|
+
UI.radio_buttons_append(rb, 'Radio Button 2')
|
961
|
+
UI.radio_buttons_append(rb, 'Radio Button 3')
|
962
|
+
UI.box_append(inner, rb, 1)
|
963
|
+
|
964
|
+
# Tab
|
965
|
+
tab = UI.new_tab
|
966
|
+
hbox1 = UI.new_horizontal_box
|
967
|
+
hbox2 = UI.new_horizontal_box
|
968
|
+
UI.tab_append(tab, 'Page 1', hbox1)
|
969
|
+
UI.tab_append(tab, 'Page 2', hbox2)
|
970
|
+
UI.tab_append(tab, 'Page 3', UI.new_horizontal_box)
|
971
|
+
UI.box_append(inner2, tab, 1)
|
972
|
+
|
973
|
+
# Text Entry
|
974
|
+
text_entry = UI.new_entry
|
975
|
+
UI.entry_set_text text_entry, 'Please enter your feelings'
|
976
|
+
UI.entry_on_changed(text_entry) do |ptr|
|
977
|
+
puts "Current textbox data: '#{UI.entry_text(ptr)}'"
|
978
|
+
end
|
979
|
+
UI.box_append(hbox1, text_entry, 1)
|
980
|
+
|
981
|
+
UI.control_show(MAIN_WINDOW)
|
982
|
+
|
983
|
+
UI.main
|
984
|
+
UI.quit
|
985
|
+
```
|
986
|
+
|
987
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
988
|
+
|
989
|
+
```ruby
|
990
|
+
require 'glimmer-dsl-libui'
|
991
|
+
|
992
|
+
include Glimmer
|
993
|
+
|
994
|
+
menu('File') {
|
995
|
+
menu_item('Open') {
|
996
|
+
on_clicked do
|
997
|
+
file = open_file(MAIN_WINDOW)
|
998
|
+
puts file unless file.nil?
|
999
|
+
end
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
menu_item('Save') {
|
1003
|
+
on_clicked do
|
1004
|
+
file = save_file(MAIN_WINDOW)
|
1005
|
+
puts file unless file.nil?
|
1006
|
+
end
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
quit_menu_item {
|
1010
|
+
on_clicked do
|
1011
|
+
puts 'Bye Bye'
|
1012
|
+
end
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
preferences_menu_item # Can optionally contain an on_clicked listener
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
menu('Edit') {
|
1019
|
+
check_menu_item('Checkable Item_')
|
1020
|
+
separator_menu_item
|
1021
|
+
menu_item('Disabled Item_') { |mi|
|
1022
|
+
enabled 0
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
menu('Help') {
|
1027
|
+
menu_item('Help')
|
1028
|
+
|
1029
|
+
about_menu_item # Can optionally contain an on_clicked listener
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
1033
|
+
margined 1
|
1034
|
+
|
1035
|
+
on_closing do
|
1036
|
+
puts 'Bye Bye'
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
vertical_box { |vb|
|
1040
|
+
padded 1
|
1041
|
+
|
1042
|
+
horizontal_box {
|
1043
|
+
padded 1
|
1044
|
+
|
1045
|
+
group('Basic Controls') {
|
1046
|
+
margined 1
|
1047
|
+
|
1048
|
+
vertical_box {
|
1049
|
+
padded 1
|
1050
|
+
|
1051
|
+
button('Button') {
|
1052
|
+
stretchy 0
|
1053
|
+
|
1054
|
+
on_clicked do
|
1055
|
+
msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
1056
|
+
end
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
checkbox('Checkbox') { |c|
|
1060
|
+
stretchy 0
|
1061
|
+
|
1062
|
+
on_toggled do
|
1063
|
+
checked = c.checked == 1
|
1064
|
+
MAIN_WINDOW.title = "Checkbox is #{checked}"
|
1065
|
+
c.text = "I am the checkbox (#{checked})"
|
1066
|
+
end
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
label('Label') { stretchy 0 }
|
1070
|
+
|
1071
|
+
horizontal_separator { stretchy 0 }
|
1072
|
+
|
1073
|
+
date_picker { stretchy 0 }
|
1074
|
+
|
1075
|
+
time_picker { stretchy 0 }
|
1076
|
+
|
1077
|
+
date_time_picker { stretchy 0 }
|
1078
|
+
|
1079
|
+
font_button { stretchy 0 }
|
1080
|
+
|
1081
|
+
color_button { stretchy 0 }
|
1082
|
+
}
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
vertical_box {
|
1086
|
+
padded 1
|
1087
|
+
|
1088
|
+
group('Numbers') {
|
1089
|
+
stretchy 0
|
1090
|
+
margined 1
|
1091
|
+
|
1092
|
+
vertical_box {
|
1093
|
+
padded 1
|
1094
|
+
|
1095
|
+
spinbox(0, 100) { |s|
|
1096
|
+
stretchy 0
|
1097
|
+
value 42
|
1098
|
+
|
1099
|
+
on_changed do
|
1100
|
+
puts "New Spinbox value: #{s.value}"
|
1101
|
+
end
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
slider(0, 100) { |s|
|
1105
|
+
stretchy 0
|
1106
|
+
|
1107
|
+
on_changed do
|
1108
|
+
v = s.value
|
1109
|
+
puts "New Slider value: #{v}"
|
1110
|
+
@progress_bar.value = v
|
1111
|
+
end
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
@progress_bar = progress_bar { stretchy 0 }
|
1115
|
+
}
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
group('Lists') {
|
1119
|
+
stretchy 0
|
1120
|
+
margined 1
|
1121
|
+
|
1122
|
+
vertical_box {
|
1123
|
+
padded 1
|
1124
|
+
|
1125
|
+
combobox { |c|
|
1126
|
+
stretchy 0
|
1127
|
+
items ['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
|
1128
|
+
|
1129
|
+
on_selected do
|
1130
|
+
puts "New combobox selection: #{c.selected}"
|
1131
|
+
end
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
editable_combobox {
|
1135
|
+
stretchy 0
|
1136
|
+
items ['Editable Item 1', 'Editable Item 2', 'Editable Item 3']
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
radio_buttons {
|
1140
|
+
items ['Radio Button 1', 'Radio Button 2', 'Radio Button 3']
|
1141
|
+
}
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
tab {
|
1146
|
+
tab_item('Page 1') {
|
1147
|
+
horizontal_box {
|
1148
|
+
entry { |e|
|
1149
|
+
text 'Please enter your feelings'
|
1150
|
+
|
1151
|
+
on_changed do
|
1152
|
+
puts "Current textbox data: '#{e.text}'"
|
1153
|
+
end
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
tab_item('Page 2') {
|
1159
|
+
horizontal_box
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
tab_item('Page 3') {
|
1163
|
+
horizontal_box
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
}
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
MAIN_WINDOW.show
|
1172
|
+
```
|
1173
|
+
|
743
1174
|
## Contributing to glimmer-dsl-libui
|
744
1175
|
|
745
1176
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|