glimmer-dsl-libui 0.1.9 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6159cc2323ab4b53114187df37e888c3f070102ce1b8a98dbaad724912b999b9
4
- data.tar.gz: b0368395d3175a5528732c665f43902f84187a4f62ab23e4f47ebb8d729ac304
3
+ metadata.gz: 748bd2b706f088ec5e69da3567dac4b59085b374507f9e3dd5e4a2b0432895a0
4
+ data.tar.gz: 8ff551d013d3d7524698c3ceaf7c5176e190e5ff6ca3bb8189de56a90fc2b3a1
5
5
  SHA512:
6
- metadata.gz: ede14899e28cc5030f2d49653c51b931e1438934b26f7486843ed518d74fbe33107fa6db7c53a46991895835d9989e275a41474fbf4d2d692ae33d0c6cbf2bfd
7
- data.tar.gz: e0964cfde750af8ebe2f14ab326eb477ebf0ed7cea56b7145828af909615a534acd67ec0169ceb41ed3d876bb229fb552dd62cc79ed4f9a552d7e72750d8a108
6
+ metadata.gz: d2cff96b2dfe600c675feb491e9f396fb436b67430fa72dafd2ae88b69f06027a5cef250d18aa9872ed4329782e6ce7da14d78506e9786b8fc62426c9f985455
7
+ data.tar.gz: c6b565cf1aba0f603c1233a8411a4ad25f78821f832f0576cf97cad7ebf9b06a0b8f1b3d83200a79da5d998fa5849d10e47b2e9257069dc0fdfe6a1cfdb6b57f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.1.10
4
+
5
+ - Upgrade to glimmer 2.2.1
6
+ - Add a 3rd tab to examples/grid.rb showcasing the halign and valign properties
7
+ - Support `grid` `halign`/`valign` symbol values of `:fill` (default), `:start`, `:center`, `:end`
8
+ - Add `key_value` to `area_key_event` `Hash`
9
+ - Add `ext_key_value` to `area_key_event` `Hash`
10
+
3
11
  ## 0.1.9
4
12
 
5
13
  - Support `area` listener: `on_key_event`
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.1.9
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.1.10
2
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)
@@ -191,7 +191,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
191
191
 
192
192
  ## Table of Contents
193
193
 
194
- - [Glimmer DSL for LibUI 0.1.9](#-glimmer-dsl-for-libui-019)
194
+ - [Glimmer DSL for LibUI 0.1.10](#-glimmer-dsl-for-libui-0110)
195
195
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
196
196
  - [Usage](#usage)
197
197
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
@@ -321,7 +321,7 @@ gem install glimmer-dsl-libui
321
321
  Or install via Bundler `Gemfile`:
322
322
 
323
323
  ```ruby
324
- gem 'glimmer-dsl-libui', '~> 0.1.9'
324
+ gem 'glimmer-dsl-libui', '~> 0.1.10'
325
325
  ```
326
326
 
327
327
  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.
@@ -460,9 +460,9 @@ Control(Args) | Properties | Listeners
460
460
  - `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
461
461
  - `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
462
462
  - `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
463
- - `halign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
463
+ - `halign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
464
464
  - `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
465
- - `valign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
465
+ - `valign` [dsl-only] (`:fill`, `:start`, `:center`, or `:end`) [default=`:fill`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
466
466
 
467
467
  ### Common Control Operations
468
468
  - `destroy`
@@ -684,7 +684,9 @@ The `area_mouse_event` `Hash` argument for mouse events that receive it (e.g. `o
684
684
 
685
685
  The `area_key_event` `Hash` argument for keyboard events that receive it (e.g. `on_key_up`, `on_key_down`) consist of the following hash keys:
686
686
  - `:key`: key character (`String`)
687
- - `:ext_key`: non-character extra key (`Symbol`) such as `:left`, `:right`, `:escape`, `:insert`
687
+ - `:key_value`: key value (`Integer`). Useful in rare cases for numeric processing of keys instead of dealing with as `:key` character `String`
688
+ - `:ext_key`: non-character extra key (`Symbol`) from `Glimmer::LibUI.enum_symbols(:ext_key)` such as `:left`, `:right`, `:escape`, `:insert`
689
+ - `:ext_key_value`: non-character extra key value (`Integer`). Useful in rare cases for numeric processing of extra keys instead of dealing with as `:ext_key` `Symbol`
688
690
  - `:modifier`: modifier key pressed alone (e.g. `:shift` or `:control`)
689
691
  - `:modifiers`: modifier keys pressed simultaneously with `:key`, `:ext_key`, or `:modifier`
690
692
  - `:up`: indicates if key has been released or not (Boolean)
@@ -786,7 +788,7 @@ Check [Histogram](#histogram) example for use of hex colors.
786
788
  - When destroying a control nested under a `form`, it is automatically deleted from the form's children
787
789
  - When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
788
790
  - For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
789
- - Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
791
+ - Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`:fill`), `vexpand` (`false`), and `valign` (`:fill`)
790
792
  - The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
791
793
  - Table model instances are automatically freed from memory after `window` is destroyed.
792
794
  - Table `cell_rows` data has implicit data-binding to table cell values for deletion, insertion, and change (done by diffing `cell_rows` value before and after change and auto-informing `table` of deletions [`LibUI.table_model_row_deleted`], insertions [`LibUI.table_model_row_deleted`], and changes [`LibUI.table_model_row_changed`]). When deleting data rows from `cell_rows` array, then actual rows from the `table` are automatically deleted. When inserting data rows into `cell_rows` array, then actual `table` rows are automatically inserted. When updating data rows in `cell_rows` array, then actual `table` rows are automatically updated.
@@ -2097,13 +2099,15 @@ ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
2097
2099
 
2098
2100
  Mac
2099
2101
 
2100
- ![glimmer-dsl-libui-mac-grid-spanning.png](images/glimmer-dsl-libui-mac-grid-spanning.png)
2101
- ![glimmer-dsl-libui-mac-grid-expanding.png](images/glimmer-dsl-libui-mac-grid-expanding.png)
2102
+ ![glimmer-dsl-libui-mac-grid-span.png](images/glimmer-dsl-libui-mac-grid-span.png)
2103
+ ![glimmer-dsl-libui-mac-grid-expand.png](images/glimmer-dsl-libui-mac-grid-expand.png)
2104
+ ![glimmer-dsl-libui-mac-grid-align.png](images/glimmer-dsl-libui-mac-grid-align.png)
2102
2105
 
2103
2106
  Linux
2104
2107
 
2105
- ![glimmer-dsl-libui-linux-grid-spanning.png](images/glimmer-dsl-libui-linux-grid-spanning.png)
2106
- ![glimmer-dsl-libui-linux-grid-expanding.png](images/glimmer-dsl-libui-linux-grid-expanding.png)
2108
+ ![glimmer-dsl-libui-linux-grid-span.png](images/glimmer-dsl-libui-linux-grid-span.png)
2109
+ ![glimmer-dsl-libui-linux-grid-expand.png](images/glimmer-dsl-libui-linux-grid-expand.png)
2110
+ ![glimmer-dsl-libui-linux-grid-align.png](images/glimmer-dsl-libui-linux-grid-align.png)
2107
2111
 
2108
2112
  New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2109
2113
 
@@ -2114,7 +2118,7 @@ include Glimmer
2114
2118
 
2115
2119
  window('Grid') {
2116
2120
  tab {
2117
- tab_item('Spanning') {
2121
+ tab_item('Span') {
2118
2122
  grid {
2119
2123
  4.times { |top_value|
2120
2124
  4.times { |left_value|
@@ -2154,7 +2158,7 @@ window('Grid') {
2154
2158
  }
2155
2159
  }
2156
2160
  }
2157
- tab_item('Expanding') {
2161
+ tab_item('Expand') {
2158
2162
  grid {
2159
2163
  label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
2160
2164
  left 0
@@ -2176,6 +2180,42 @@ window('Grid') {
2176
2180
  }
2177
2181
  }
2178
2182
  }
2183
+ tab_item('Align') {
2184
+ grid {
2185
+ label("(0, 0) halign/valign fill\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
2186
+ left 0
2187
+ top 0
2188
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2189
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2190
+ halign :fill
2191
+ valign :fill
2192
+ }
2193
+ label("(1, 0) halign/valign start") {
2194
+ left 1
2195
+ top 0
2196
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2197
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2198
+ halign :start
2199
+ valign :start
2200
+ }
2201
+ label("(0, 1) halign/valign center") {
2202
+ left 0
2203
+ top 1
2204
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2205
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2206
+ halign :center
2207
+ valign :center
2208
+ }
2209
+ label("(1, 1) halign/valign end") {
2210
+ left 1
2211
+ top 1
2212
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2213
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
2214
+ halign :end
2215
+ valign :end
2216
+ }
2217
+ }
2218
+ }
2179
2219
  }
2180
2220
  }.show
2181
2221
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
data/examples/grid.rb CHANGED
@@ -6,7 +6,7 @@ include Glimmer
6
6
 
7
7
  window('Grid') {
8
8
  tab {
9
- tab_item('Spanning') {
9
+ tab_item('Span') {
10
10
  grid {
11
11
  4.times { |top_value|
12
12
  4.times { |left_value|
@@ -46,7 +46,7 @@ window('Grid') {
46
46
  }
47
47
  }
48
48
  }
49
- tab_item('Expanding') {
49
+ tab_item('Expand') {
50
50
  grid {
51
51
  label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
52
52
  left 0
@@ -68,5 +68,41 @@ window('Grid') {
68
68
  }
69
69
  }
70
70
  }
71
+ tab_item('Align') {
72
+ grid {
73
+ label("(0, 0) halign/valign fill\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
74
+ left 0
75
+ top 0
76
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
77
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
78
+ halign :fill
79
+ valign :fill
80
+ }
81
+ label("(1, 0) halign/valign start") {
82
+ left 1
83
+ top 0
84
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
85
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
86
+ halign :start
87
+ valign :start
88
+ }
89
+ label("(0, 1) halign/valign center") {
90
+ left 0
91
+ top 1
92
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
93
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
94
+ halign :center
95
+ valign :center
96
+ }
97
+ label("(1, 1) halign/valign end") {
98
+ left 1
99
+ top 1
100
+ hexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
101
+ vexpand true unless OS.mac? # on Mac, only the first label is given all space, so avoid expanding
102
+ halign :end
103
+ valign :end
104
+ }
105
+ }
106
+ }
71
107
  }
72
108
  }.show
Binary file
@@ -34,10 +34,6 @@ module Glimmer
34
34
  class << self
35
35
  # this attribute is only populated during on_draw call
36
36
  attr_accessor :current_area_draw_params
37
-
38
- def ext_key_symbols
39
- @ext_key_symbols ||= ::LibUI.constants.select { |c| c.to_s.start_with?('ExtKey') }.map { |c| c.to_s.underscore.sub('ext_key_', '') }
40
- end
41
37
  end
42
38
 
43
39
  LISTENERS = ['on_draw', 'on_mouse_event', 'on_mouse_move', 'on_mouse_down', 'on_mouse_up', 'on_mouse_drag_start', 'on_mouse_drag', 'on_mouse_drop', 'on_mouse_crossed', 'on_mouse_enter', 'on_mouse_exit', 'on_drag_broken', 'on_key_event', 'on_key_down', 'on_key_up']
@@ -155,7 +151,9 @@ module Glimmer
155
151
  def area_key_event_hash(area_key_event)
156
152
  {
157
153
  key: key_to_char(area_key_event.Key),
154
+ key_value: area_key_event.Key,
158
155
  ext_key: ext_key_to_symbol(area_key_event.ExtKey),
156
+ ext_key_value: area_key_event.ExtKey,
159
157
  modifier: modifiers_to_symbols(area_key_event.Modifier).first,
160
158
  modifiers: modifiers_to_symbols(area_key_event.Modifiers),
161
159
  up: Glimmer::LibUI.integer_to_boolean(area_key_event.Up),
@@ -167,7 +165,7 @@ module Glimmer
167
165
  end
168
166
 
169
167
  def ext_key_to_symbol(ext_key_value)
170
- AreaProxy.ext_key_symbols[ext_key_value - 1].to_s.to_sym if ext_key_value > 0
168
+ Glimmer::LibUI.enum_symbols(:ext_key)[ext_key_value - 1].to_s.to_sym if ext_key_value > 0
171
169
  end
172
170
 
173
171
  def modifiers_to_symbols(modifiers_value)
@@ -36,7 +36,18 @@ module Glimmer
36
36
  child.halign = 0 if child.halign.nil?
37
37
  child.vexpand = false if child.vexpand.nil?
38
38
  child.valign = 0 if child.valign.nil?
39
- ::LibUI.grid_append(@libui, child.libui, child.left, child.top, child.xspan, child.yspan, Glimmer::LibUI.boolean_to_integer(child.hexpand), child.halign, Glimmer::LibUI.boolean_to_integer(child.vexpand), child.valign)
39
+ ::LibUI.grid_append(
40
+ @libui,
41
+ child.libui,
42
+ child.left,
43
+ child.top,
44
+ child.xspan,
45
+ child.yspan,
46
+ Glimmer::LibUI.boolean_to_integer(child.hexpand),
47
+ Glimmer::LibUI.enum_symbol_to_value(:align, child.halign),
48
+ Glimmer::LibUI.boolean_to_integer(child.vexpand),
49
+ Glimmer::LibUI.enum_symbol_to_value(:align, child.valign)
50
+ )
40
51
  children << child
41
52
  end
42
53
 
@@ -128,25 +128,11 @@ module Glimmer
128
128
  end
129
129
 
130
130
  def draw_line_cap
131
- case @stroke && @stroke[:cap].to_s
132
- when 'round'
133
- 1
134
- when 'square'
135
- 2
136
- else # 'flat'
137
- 0
138
- end
131
+ Glimmer::LibUI.enum_symbol_to_value(:draw_line_cap, @stroke && @stroke[:cap])
139
132
  end
140
133
 
141
134
  def draw_line_join
142
- case @stroke && @stroke[:join].to_s
143
- when 'round'
144
- 1
145
- when 'bevel'
146
- 2
147
- else # 'miter'
148
- 0
149
- end
135
+ Glimmer::LibUI.enum_symbol_to_value(:draw_line_join, @stroke && @stroke[:join])
150
136
  end
151
137
 
152
138
  def destroy
@@ -165,20 +151,7 @@ module Glimmer
165
151
  end
166
152
 
167
153
  def init_draw_brush(draw_brush, draw_brush_args)
168
- case draw_brush_args[:type]
169
- when Integer
170
- draw_brush.Type = draw_brush_args[:type]
171
- when :solid, 'solid'
172
- draw_brush.Type = 0
173
- when :linear_gradient, 'linear_gradient'
174
- draw_brush.Type = 1
175
- when :radial_gradient, 'radial_gradient'
176
- draw_brush.Type = 2
177
- when :image, 'image'
178
- draw_brush.Type = 3
179
- else
180
- draw_brush.Type = 0
181
- end
154
+ draw_brush.Type = Glimmer::LibUI.enum_symbol_to_value(:draw_brush_type, draw_brush_args[:type])
182
155
  draw_brush.R = (draw_brush_args[:r] || draw_brush_args[:red]).to_f / 255.0
183
156
  draw_brush.G = (draw_brush_args[:g] || draw_brush_args[:green]).to_f / 255.0
184
157
  draw_brush.B = (draw_brush_args[:b] || draw_brush_args[:blue]).to_f / 255.0
data/lib/glimmer/libui.rb CHANGED
@@ -87,6 +87,23 @@ module Glimmer
87
87
  end
88
88
  value
89
89
  end
90
+
91
+ # Returns ruby underscored symbols for enum values starting with enum name (camelcase, e.g. 'ext_key')
92
+ def enum_symbols(enum_name)
93
+ enum_name = enum_name.to_s.underscore.to_sym
94
+ @enum_symbols ||= {}
95
+ @enum_symbols[enum_name] ||= ::LibUI.constants.select { |c| c.to_s.start_with?(enum_name.to_s.camelcase(:upper)) }.map { |c| c.to_s.underscore.sub("#{enum_name}_", '').to_sym }
96
+ end
97
+
98
+ def enum_symbol_to_value(enum_name, enum_symbol, default_index: 0)
99
+ if enum_symbol.is_a?(Integer)
100
+ enum_symbol
101
+ elsif enum_symbols(enum_name).include?(enum_symbol.to_s.to_sym)
102
+ ::LibUI.const_get("#{enum_name}_#{enum_symbol}".camelcase(:upper))
103
+ else
104
+ enum_symbol_to_value(enum_name, enum_symbols(enum_name)[default_index])
105
+ end
106
+ end
90
107
  end
91
108
  end
92
109
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.0
19
+ version: 2.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.0
26
+ version: 2.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: os
29
29
  requirement: !ruby/object:Gem::Requirement