glimmer-dsl-libui 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +65 -23
- data/VERSION +1 -1
- data/examples/basic_table_button.rb +1 -0
- data/examples/editable_table.rb +2 -0
- data/examples/meta_example.rb +8 -3
- data/examples/method_based_custom_keyword.rb +16 -6
- data/glimmer-dsl-libui.gemspec +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 167c5bae90fe7c652d42de1f788dcb89f5cffba6288ee5bf8ef1b7b5a747a5c0
|
4
|
+
data.tar.gz: 0f000ac03b6e7b368a14dad29b078745ca800a96c7df047b27ed00b450325b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44ea533dd57219b02924d3ae50b5591ca22b209dc677763f0b27163a685ce671bfbacc1e5b19bb2c6ae95ff25622f908d80514fc73d1e6b5dd61e6429f9a91e6
|
7
|
+
data.tar.gz: c8430e69bac6b16d284bc5159bbed6892e410a4b4dd22c49d085df20ed07822c5d77caddef418abeac9b5bd6726bbe643b260e059a7213a6d2691d10cf58abb5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.11
|
4
|
+
|
5
|
+
- Fix issue with running examples that rely on local assets from gem (they work fine from locally cloned project)
|
6
|
+
- Fix issue with not showing puts output in Basic Table Button and Editable Table examples when run from Meta Example
|
7
|
+
|
3
8
|
## 0.2.10
|
4
9
|
|
5
10
|
- New examples/method_based_custom_keyword.rb
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
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.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.2.11
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
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
12
|
|
13
|
+
**(Note: although LibUI works on Windows, this project has not been tested on Windows yet. It has only been verified on Mac x64 and Linux x64)**
|
14
|
+
|
13
15
|
[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:
|
14
16
|
- Declarative DSL syntax that visually maps to the GUI control hierarchy
|
15
17
|
- Convention over configuration via smart defaults and automation of low-level details
|
@@ -207,7 +209,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
207
209
|
|
208
210
|
## Table of Contents
|
209
211
|
|
210
|
-
- [Glimmer DSL for LibUI
|
212
|
+
- [Glimmer DSL for LibUI](#)
|
211
213
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
212
214
|
- [Usage](#usage)
|
213
215
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
@@ -347,7 +349,7 @@ gem install glimmer-dsl-libui
|
|
347
349
|
Or install via Bundler `Gemfile`:
|
348
350
|
|
349
351
|
```ruby
|
350
|
-
gem 'glimmer-dsl-libui', '~> 0.2.
|
352
|
+
gem 'glimmer-dsl-libui', '~> 0.2.11'
|
351
353
|
```
|
352
354
|
|
353
355
|
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.
|
@@ -899,7 +901,7 @@ window('area text drawing') {
|
|
899
901
|
|
900
902
|
To define custom keywords, simply define a method representing the custom control you want. To make reusable, you can define in modules and simply include the modules in the view classes that need them.
|
901
903
|
|
902
|
-
Example that defines `
|
904
|
+
Example that defines `form_field`, `address_form`, `label_pair`, and `address` keywords (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
903
905
|
|
904
906
|
```ruby
|
905
907
|
require 'glimmer-dsl-libui'
|
@@ -909,7 +911,7 @@ include Glimmer
|
|
909
911
|
|
910
912
|
Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code)
|
911
913
|
|
912
|
-
def
|
914
|
+
def form_field(model, property)
|
913
915
|
property = property.to_s
|
914
916
|
entry { |e|
|
915
917
|
label property.underscore.split('_').map(&:capitalize).join(' ')
|
@@ -923,11 +925,11 @@ end
|
|
923
925
|
|
924
926
|
def address_form(address)
|
925
927
|
form {
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
928
|
+
form_field(address, :street)
|
929
|
+
form_field(address, :p_o_box)
|
930
|
+
form_field(address, :city)
|
931
|
+
form_field(address, :state)
|
932
|
+
form_field(address, :zip_code)
|
931
933
|
}
|
932
934
|
end
|
933
935
|
|
@@ -962,29 +964,39 @@ window('Method-Based Custom Keyword') {
|
|
962
964
|
label('Address 1') {
|
963
965
|
stretchy false
|
964
966
|
}
|
967
|
+
|
965
968
|
address_form(address1)
|
969
|
+
|
966
970
|
horizontal_separator {
|
967
971
|
stretchy false
|
968
972
|
}
|
973
|
+
|
969
974
|
label('Address 1 (Saved)') {
|
970
975
|
stretchy false
|
971
976
|
}
|
977
|
+
|
972
978
|
address(address1)
|
973
979
|
}
|
980
|
+
|
974
981
|
vertical_separator {
|
975
982
|
stretchy false
|
976
983
|
}
|
984
|
+
|
977
985
|
vertical_box {
|
978
986
|
label('Address 2') {
|
979
987
|
stretchy false
|
980
988
|
}
|
989
|
+
|
981
990
|
address_form(address2)
|
991
|
+
|
982
992
|
horizontal_separator {
|
983
993
|
stretchy false
|
984
994
|
}
|
995
|
+
|
985
996
|
label('Address 2 (Saved)') {
|
986
997
|
stretchy false
|
987
998
|
}
|
999
|
+
|
988
1000
|
address(address2)
|
989
1001
|
}
|
990
1002
|
}
|
@@ -1056,8 +1068,6 @@ Linux
|
|
1056
1068
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1057
1069
|
|
1058
1070
|
```ruby
|
1059
|
-
# frozen_string_literal: true
|
1060
|
-
|
1061
1071
|
require 'glimmer-dsl-libui'
|
1062
1072
|
require 'facets'
|
1063
1073
|
|
@@ -1100,6 +1110,18 @@ class MetaExample
|
|
1100
1110
|
examples[@selected_example_index]
|
1101
1111
|
end
|
1102
1112
|
|
1113
|
+
def run_example(example)
|
1114
|
+
command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
|
1115
|
+
result = ''
|
1116
|
+
IO.popen(command) do |f|
|
1117
|
+
f.each_line do |line|
|
1118
|
+
result << line
|
1119
|
+
puts line
|
1120
|
+
end
|
1121
|
+
end
|
1122
|
+
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
1123
|
+
end
|
1124
|
+
|
1103
1125
|
def launch
|
1104
1126
|
window('Meta-Example', 700, 500) {
|
1105
1127
|
margined true
|
@@ -1150,11 +1172,11 @@ class MetaExample
|
|
1150
1172
|
begin
|
1151
1173
|
meta_example_file = File.join(Dir.home, '.meta_example.rb')
|
1152
1174
|
File.write(meta_example_file, @code_entry.text)
|
1153
|
-
|
1154
|
-
msg_box('Error Running Example', result) if result.include?('error')
|
1175
|
+
run_example(meta_example_file)
|
1155
1176
|
rescue => e
|
1177
|
+
puts e.full_message
|
1156
1178
|
puts 'Unable to write code changes! Running original example...'
|
1157
|
-
|
1179
|
+
run_example(file_path_for(selected_example))
|
1158
1180
|
end
|
1159
1181
|
end
|
1160
1182
|
}
|
@@ -2518,11 +2540,21 @@ window('Form') {
|
|
2518
2540
|
@last_name_entry = entry {
|
2519
2541
|
label 'Last Name' # label property is available when control is nested under form
|
2520
2542
|
}
|
2543
|
+
|
2544
|
+
@phone_entry = entry {
|
2545
|
+
label 'Phone' # label property is available when control is nested under form
|
2546
|
+
}
|
2547
|
+
|
2548
|
+
@email_entry = entry {
|
2549
|
+
label 'Email' # label property is available when control is nested under form
|
2550
|
+
}
|
2521
2551
|
}
|
2522
2552
|
|
2523
|
-
button('Display
|
2553
|
+
button('Display Info') {
|
2554
|
+
stretchy false
|
2555
|
+
|
2524
2556
|
on_clicked do
|
2525
|
-
msg_box('
|
2557
|
+
msg_box('Info', "#{@first_name_entry.text} #{@last_name_entry.text} has phone #{@phone_entry.text} and email #{@email_entry.text}")
|
2526
2558
|
end
|
2527
2559
|
}
|
2528
2560
|
}
|
@@ -5838,7 +5870,7 @@ include Glimmer
|
|
5838
5870
|
|
5839
5871
|
Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code)
|
5840
5872
|
|
5841
|
-
def
|
5873
|
+
def form_field(model, property)
|
5842
5874
|
property = property.to_s
|
5843
5875
|
entry { |e|
|
5844
5876
|
label property.underscore.split('_').map(&:capitalize).join(' ')
|
@@ -5852,11 +5884,11 @@ end
|
|
5852
5884
|
|
5853
5885
|
def address_form(address)
|
5854
5886
|
form {
|
5855
|
-
|
5856
|
-
|
5857
|
-
|
5858
|
-
|
5859
|
-
|
5887
|
+
form_field(address, :street)
|
5888
|
+
form_field(address, :p_o_box)
|
5889
|
+
form_field(address, :city)
|
5890
|
+
form_field(address, :state)
|
5891
|
+
form_field(address, :zip_code)
|
5860
5892
|
}
|
5861
5893
|
end
|
5862
5894
|
|
@@ -5891,29 +5923,39 @@ window('Method-Based Custom Keyword') {
|
|
5891
5923
|
label('Address 1') {
|
5892
5924
|
stretchy false
|
5893
5925
|
}
|
5926
|
+
|
5894
5927
|
address_form(address1)
|
5928
|
+
|
5895
5929
|
horizontal_separator {
|
5896
5930
|
stretchy false
|
5897
5931
|
}
|
5932
|
+
|
5898
5933
|
label('Address 1 (Saved)') {
|
5899
5934
|
stretchy false
|
5900
5935
|
}
|
5936
|
+
|
5901
5937
|
address(address1)
|
5902
5938
|
}
|
5939
|
+
|
5903
5940
|
vertical_separator {
|
5904
5941
|
stretchy false
|
5905
5942
|
}
|
5943
|
+
|
5906
5944
|
vertical_box {
|
5907
5945
|
label('Address 2') {
|
5908
5946
|
stretchy false
|
5909
5947
|
}
|
5948
|
+
|
5910
5949
|
address_form(address2)
|
5950
|
+
|
5911
5951
|
horizontal_separator {
|
5912
5952
|
stretchy false
|
5913
5953
|
}
|
5954
|
+
|
5914
5955
|
label('Address 2 (Saved)') {
|
5915
5956
|
stretchy false
|
5916
5957
|
}
|
5958
|
+
|
5917
5959
|
address(address2)
|
5918
5960
|
}
|
5919
5961
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.11
|
data/examples/editable_table.rb
CHANGED
@@ -23,10 +23,12 @@ window('Editable animal sounds', 300, 200) {
|
|
23
23
|
|
24
24
|
on_changed do |row, type, row_data| # fires on all changes (even ones happening through data array)
|
25
25
|
puts "Row #{row} #{type}: #{row_data}"
|
26
|
+
$stdout.flush
|
26
27
|
end
|
27
28
|
|
28
29
|
on_edited do |row, row_data| # only fires on direct table editing
|
29
30
|
puts "Row #{row} edited: #{row_data}"
|
31
|
+
$stdout.flush
|
30
32
|
end
|
31
33
|
}
|
32
34
|
}
|
data/examples/meta_example.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'facets'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
class MetaExample
|
5
6
|
include Glimmer
|
@@ -100,9 +101,13 @@ class MetaExample
|
|
100
101
|
button('Launch') {
|
101
102
|
on_clicked do
|
102
103
|
begin
|
103
|
-
|
104
|
-
|
105
|
-
|
104
|
+
parent_dir = File.join(Dir.home, '.glimmer-dsl-libui', 'examples')
|
105
|
+
FileUtils.mkdir_p(parent_dir)
|
106
|
+
example_file = File.join(parent_dir, "#{selected_example.underscore}.rb")
|
107
|
+
File.write(example_file, @code_entry.text)
|
108
|
+
FileUtils.cp_r(File.expand_path('../icons', __dir__), File.dirname(parent_dir))
|
109
|
+
FileUtils.cp_r(File.expand_path('../sounds', __dir__), File.dirname(parent_dir))
|
110
|
+
run_example(example_file)
|
106
111
|
rescue => e
|
107
112
|
puts e.full_message
|
108
113
|
puts 'Unable to write code changes! Running original example...'
|
@@ -5,7 +5,7 @@ include Glimmer
|
|
5
5
|
|
6
6
|
Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code)
|
7
7
|
|
8
|
-
def
|
8
|
+
def form_field(model, property)
|
9
9
|
property = property.to_s
|
10
10
|
entry { |e|
|
11
11
|
label property.underscore.split('_').map(&:capitalize).join(' ')
|
@@ -19,11 +19,11 @@ end
|
|
19
19
|
|
20
20
|
def address_form(address)
|
21
21
|
form {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
form_field(address, :street)
|
23
|
+
form_field(address, :p_o_box)
|
24
|
+
form_field(address, :city)
|
25
|
+
form_field(address, :state)
|
26
|
+
form_field(address, :zip_code)
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
@@ -58,29 +58,39 @@ window('Method-Based Custom Keyword') {
|
|
58
58
|
label('Address 1') {
|
59
59
|
stretchy false
|
60
60
|
}
|
61
|
+
|
61
62
|
address_form(address1)
|
63
|
+
|
62
64
|
horizontal_separator {
|
63
65
|
stretchy false
|
64
66
|
}
|
67
|
+
|
65
68
|
label('Address 1 (Saved)') {
|
66
69
|
stretchy false
|
67
70
|
}
|
71
|
+
|
68
72
|
address(address1)
|
69
73
|
}
|
74
|
+
|
70
75
|
vertical_separator {
|
71
76
|
stretchy false
|
72
77
|
}
|
78
|
+
|
73
79
|
vertical_box {
|
74
80
|
label('Address 2') {
|
75
81
|
stretchy false
|
76
82
|
}
|
83
|
+
|
77
84
|
address_form(address2)
|
85
|
+
|
78
86
|
horizontal_separator {
|
79
87
|
stretchy false
|
80
88
|
}
|
89
|
+
|
81
90
|
label('Address 2 (Saved)') {
|
82
91
|
stretchy false
|
83
92
|
}
|
93
|
+
|
84
94
|
address(address2)
|
85
95
|
}
|
86
96
|
}
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|