glimmer-dsl-libui 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 167c5bae90fe7c652d42de1f788dcb89f5cffba6288ee5bf8ef1b7b5a747a5c0
4
- data.tar.gz: 0f000ac03b6e7b368a14dad29b078745ca800a96c7df047b27ed00b450325b23
3
+ metadata.gz: 3aefaaeba868daf629c8ec07474b45a78f10c2dfb17ef5fc748b97dc3f00447c
4
+ data.tar.gz: eccf64a897d80f36e99f738c4cf528715c666ad80a86fa2c6abdb75d340edd39
5
5
  SHA512:
6
- metadata.gz: 44ea533dd57219b02924d3ae50b5591ca22b209dc677763f0b27163a685ce671bfbacc1e5b19bb2c6ae95ff25622f908d80514fc73d1e6b5dd61e6429f9a91e6
7
- data.tar.gz: c8430e69bac6b16d284bc5159bbed6892e410a4b4dd22c49d085df20ed07822c5d77caddef418abeac9b5bd6726bbe643b260e059a7213a6d2691d10cf58abb5
6
+ metadata.gz: 9bc9daeb504c2133ceadb0556ec29ff2264789c4d0c86a1958752106beed708912830692125c660579914d1cea67fe16827056add48f7d132ab67c9e814ab15e
7
+ data.tar.gz: ce7a85691919adb938b1eb3de235ca5fed5a9bfa4b484f649dff1a5a03ee7a46cabcd25cb7c54da9d86a60e215495e0e075f82c647f6e5125e491aa617491ef6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.2.12
4
+
5
+ - Upgrade to glimmer 2.4.0
6
+ - Upgrade to LibUI 0.0.12
7
+ - Support passing `string` value as an argument to attributed `string` keyword
8
+ - Support setting `string` value as a property on attributed `string` keyword (automatically redrawing)
9
+
3
10
  ## 0.2.11
4
11
 
5
12
  - Fix issue with running examples that rely on local assets from gem (they work fine from locally cloned project)
data/README.md CHANGED
@@ -1,7 +1,6 @@
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
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.12
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
- [![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
5
4
  [![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
5
 
7
6
  [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 native GUI that just works!
@@ -10,7 +9,7 @@
10
9
 
11
10
  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
11
 
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)**
12
+ **(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. Issue reporting for Windows is appreciated in the meantime.)**
14
13
 
15
14
  [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:
16
15
  - Declarative DSL syntax that visually maps to the GUI control hierarchy
@@ -134,11 +133,9 @@ window('Area Gallery', 400, 400) {
134
133
  stroke r: 0, g: 0, b: 0, thickness: 2
135
134
  }
136
135
  text(160, 40, 100) { # x, y, width
137
- string {
136
+ string('Area Gallery') {
138
137
  font family: 'Times', size: 14
139
138
  color :black
140
-
141
- 'Area Gallery'
142
139
  }
143
140
  }
144
141
 
@@ -349,7 +346,7 @@ gem install glimmer-dsl-libui
349
346
  Or install via Bundler `Gemfile`:
350
347
 
351
348
  ```ruby
352
- gem 'glimmer-dsl-libui', '~> 0.2.11'
349
+ gem 'glimmer-dsl-libui', '~> 0.2.12'
353
350
  ```
354
351
 
355
352
  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.
@@ -472,7 +469,7 @@ Control(Args) | Properties | Listeners
472
469
  `slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
473
470
  `spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
474
471
  `square(x as Numeric, y as Numeric, length as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `length` (`Numeric`) | None
475
- `string` | `font`, `color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `background` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `underline`, `underline_color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `open_type_features` | None
472
+ `string(string = '')` | `font`, `color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `background` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `underline`, `underline_color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `open_type_features`, `string` (`String`) | None
476
473
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
477
474
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
478
475
  `table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values for `text_column` cells or `Array` of `image`/`String` for `image_text_column`)), `editable` as Boolean | `on_changed {|row, type, row_data| ...}`, `on_edited {|row, row_data| ...}`
@@ -816,19 +813,23 @@ Check [Basic Transform](#basic-transform) example for use of [X11](https://en.wi
816
813
 
817
814
  Check [Histogram](#histogram) example for use of hex colors.
818
815
 
819
- To draw `text` in an `area`, you simply nest a `text(x, y, width)` control directly under `area` or inside a `on_draw` listener, and then nest attributed `string {string_value}` controls underneath it returning an actual `String` (think of them as the `<span>` element in html, which contains a string of text).
816
+ To draw `text` in an `area`, you simply nest a `text(x, y, width)` control directly under `area` or inside a `on_draw` listener, and then nest attributed `string {[attributes]; string_value}` controls underneath it returning an actual `String` (think of them as the `<span>` or `<p>` element in html, which contains a string of text). Alternatively, you can nest attributed `string(string_value) {[attributes]}` if `string_value` is a short single-line string. An attributed `string` value can be changed dynamically via its `string` property.
820
817
 
821
- `text` control can have the following properties:
818
+ `text` has the following properties:
822
819
  - `default_font`:
823
820
  - `align`: `:left` (default), `:center`, or `:right` (`align` currently seems not to work on the Mac)
821
+ - `x`: x coordinate in relation to parent `area` top-left corner
822
+ - `y`: y coordinate in relation to parent `area` top-left corner
823
+ - `width` (default: area width - x*2): width of text to display
824
824
 
825
- `string` can have the following properties:
825
+ `string` has the following properties:
826
826
  - `font`: font descriptor hash consisting of `:family`, `:size`, `:weight` (`[:minimum, :thin, :ultra_light, :light, :book, :normal, :medium, :semi_bold, :bold, :ultra_bold, :heavy, :ultra_heavy, :maximum]`), `:italic` (`[:normal, :oblique, :italic]`), and `:stretch` (`[:ultra_condensed, :extra_condensed, :condensed, :semi_condensed, :normal, :semi_expanded, :expanded, :extra_expanded, :ultra_expanded]`) key values
827
827
  - `color`: rgba, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color
828
828
  - `background`: rgba, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color
829
829
  - `underline`: one of `:none`, `:single`, `:double`, `:suggestion`, `:color_custom`, `:color_spelling`, `:color_grammar`, `:color_auxiliary`
830
830
  - `underline_color`: one of `:spelling`, `:grammar`, `:auxiliary`, rgba, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color
831
831
  - `open_type_features`: Open Type Features (https://www.microsoft.com/typography/otspec/featuretags.htm) consist of `open_type_tag`s nested in content block, which accept (`a`, `b`, `c`, `d`, `Integer`) arguments.
832
+ - `string`: string value (`String`)
832
833
 
833
834
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
834
835
 
@@ -849,12 +850,13 @@ window('area text drawing') {
849
850
  open_type_tag 'l', 'i', 'g', 'a', 1
850
851
  }
851
852
 
852
- "This is a test\n\n"
853
+ "This is a demonstration\n" \
854
+ "of a very long\n" \
855
+ "attributed string\n" \
856
+ "spanning multiple lines\n\n"
853
857
  }
854
858
 
855
- string {
856
- 'This is another test'
857
- }
859
+ string('This is a short unattributed string')
858
860
  }
859
861
  }
860
862
  }.show
@@ -891,6 +893,7 @@ window('area text drawing') {
891
893
  - `area` paths are specified declaratively with figures underneath (e.g. `rectangle`) and `area` draw listener is automatically generated
892
894
  - Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
893
895
  - Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
896
+ - Observe `text` and `string` properties for changes and automatically redraw containing area accordingly
894
897
  - All controls are protected from garbage collection until no longer needed (explicitly destroyed), so there is no need to worry about surprises.
895
898
  - All resources are freed automatically once no longer needed or left to garbage collection.
896
899
  - When nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
@@ -3906,11 +3909,9 @@ window('Area Gallery', 400, 400) {
3906
3909
  stroke r: 0, g: 0, b: 0, thickness: 2
3907
3910
  }
3908
3911
  text(160, 40, 100) { # x, y, width
3909
- string {
3912
+ string('Area Gallery') {
3910
3913
  font family: 'Times', size: 14
3911
3914
  color :black
3912
-
3913
- 'Area Gallery'
3914
3915
  }
3915
3916
  }
3916
3917
 
@@ -4214,11 +4215,9 @@ window('Area Gallery', 400, 400) {
4214
4215
  stroke r: 0, g: 0, b: 0, thickness: 2
4215
4216
  }
4216
4217
  text(160, 40, 100) { # x, y, width
4217
- string {
4218
+ string('Area Gallery') {
4218
4219
  font family: 'Times', size: 14
4219
4220
  color :black
4220
-
4221
- 'Area Gallery'
4222
4221
  }
4223
4222
  }
4224
4223
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.11
1
+ 0.2.12
@@ -55,11 +55,9 @@ window('Area Gallery', 400, 400) {
55
55
  stroke r: 0, g: 0, b: 0, thickness: 2
56
56
  }
57
57
  text(160, 40, 100) { # x, y, width
58
- string {
58
+ string('Area Gallery') {
59
59
  font family: 'Times', size: 14
60
60
  color :black
61
-
62
- 'Area Gallery'
63
61
  }
64
62
  }
65
63
 
@@ -56,11 +56,9 @@ window('Area Gallery', 400, 400) {
56
56
  stroke r: 0, g: 0, b: 0, thickness: 2
57
57
  }
58
58
  text(160, 40, 100) { # x, y, width
59
- string {
59
+ string('Area Gallery') {
60
60
  font family: 'Times', size: 14
61
61
  color :black
62
-
63
- 'Area Gallery'
64
62
  }
65
63
  }
66
64
  end
@@ -16,7 +16,6 @@ class BasicDrawText
16
16
  else
17
17
  color r: 0, g: 128, b: 0, a: 0.7
18
18
  end
19
-
20
19
  block.call + "\n\n"
21
20
  }
22
21
  end
Binary file
@@ -32,11 +32,18 @@ module Glimmer
32
32
 
33
33
  def can_interpret?(parent, keyword, *args, &block)
34
34
  super and
35
- parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy)
35
+ (
36
+ parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy) or
37
+ parent.is_a?(Glimmer::LibUI::AttributedString)
38
+ )
36
39
  end
37
40
 
38
41
  def interpret(parent, keyword, *args, &block)
39
- Glimmer::LibUI::AttributedString.new(keyword, parent, args, &block)
42
+ if parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy)
43
+ Glimmer::LibUI::AttributedString.new(keyword, parent, args, &block)
44
+ else
45
+ parent.string = args.join
46
+ end
40
47
  end
41
48
 
42
49
  def add_content(parent, keyword, *args, &block)
@@ -27,7 +27,6 @@ require 'glimmer/libui/control_proxy/transformable'
27
27
  module Glimmer
28
28
  module LibUI
29
29
  class AttributedString
30
- attr_accessor :string
31
30
  attr_reader :block, :keyword, :parent_proxy, :args
32
31
 
33
32
  def initialize(keyword, parent_proxy, args, &block)
@@ -39,6 +38,17 @@ module Glimmer
39
38
  post_add_content if @block.nil?
40
39
  end
41
40
 
41
+ def string(value = nil)
42
+ if value.nil?
43
+ @string
44
+ else
45
+ @string = value
46
+ redraw
47
+ end
48
+ end
49
+ alias string= string
50
+ alias set_string string
51
+
42
52
  def font(value = nil)
43
53
  if value.nil?
44
54
  @font
@@ -106,7 +116,7 @@ module Glimmer
106
116
  alias set_open_type_features open_type_features
107
117
 
108
118
  def post_add_content
109
- block_result = block&.call
119
+ block_result = @block&.call
110
120
  @string = block_result if block_result.is_a?(String)
111
121
  @parent_proxy&.post_initialize_child(self)
112
122
  end
@@ -104,7 +104,7 @@ module Glimmer
104
104
  end
105
105
  end
106
106
  @last_cell_rows = array_deep_clone(@cell_rows)
107
- end.observe(self, :cell_rows)
107
+ end.observe(self, :cell_rows, recursive: true)
108
108
  end
109
109
  end
110
110
  end
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.11
4
+ version: 0.2.12
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-12 00:00:00.000000000 Z
11
+ date: 2021-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 2.4.0
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.3.0
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: os
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.0.11
67
+ version: 0.0.12
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.0.11
74
+ version: 0.0.12
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: juwelier
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +192,10 @@ dependencies:
192
192
  version: 1.4.0
193
193
  description: Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development GUI
194
194
  Library (No need to pre-install any prerequisites. Just install the gem and have
195
- platform-independent native GUI that just works!)
195
+ platform-independent native GUI that just works! Glimmer DSL for LibUI aims to provide
196
+ declarative DSL syntax that visually maps to the GUI control hierarchy, convention
197
+ over configuration via smart defaults and automation of low-level details, requiring
198
+ the least amount of syntax possible to build GUI, and custom control support.)
196
199
  email: andy.am@gmail.com
197
200
  executables:
198
201
  - girb
@@ -364,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
364
367
  - !ruby/object:Gem::Version
365
368
  version: '0'
366
369
  requirements: []
367
- rubygems_version: 3.2.28
370
+ rubygems_version: 3.2.22
368
371
  signing_key:
369
372
  specification_version: 4
370
373
  summary: Glimmer DSL for LibUI