glimmer-dsl-libui 0.2.1 → 0.2.5

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: 276e4ac15791c16e7f6b8816bba43b7a402484800bc1a11e84037e5511ec9b39
4
- data.tar.gz: b6fcc1cb1e2707452ab8e88140d40446e7e740e6b0d5d2241aa204ec59ee8a11
3
+ metadata.gz: b691a0eeec6e7d571ac6815c272e0dd5ae48c0f0302fc11876ae373cb92cba1e
4
+ data.tar.gz: 576d6840f47182d0dc0bd3ccccdb301b5a9efb2f7b7038efa3e5fa8d8ea30537
5
5
  SHA512:
6
- metadata.gz: 07a11c38a4d2e2a9ea043bab960c20b84cb148ba837d4293157b452a0851d51246373f1b031aa3c79680a28e56c2e95b33c0661c6949aa865a6182151b719872
7
- data.tar.gz: 53c5d5be2ca21d765d81e75d1b6924965536a7c34d5ba63899b7e37f7e2785c19eabf271fbbb801b899cb703ffa7d2ad4357c38dd6bce63673adcc3899b1e00a
6
+ metadata.gz: d00b9ecc527e56e144d1baead2910e62a29f9f429af9fc57a1da05a4d590d9286f47c2fe8d840062c1a989f42183f9dfc717a0800db2ec6467acc434201d3707
7
+ data.tar.gz: 53dbe182b9b9607111915412af9d418571511af560dc5af83d792214139c62f91358aa5555147d962a040802852d74f581413b99d287827454ea2ca865ec110b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.2.5
4
+
5
+ - Support attributed `string` `underline_color` property (built-in enum symbols and custom color)
6
+
7
+ ## 0.2.4
8
+
9
+ - Support examples/custom_draw_text.rb
10
+ - Support stable `text` control nestable under `area`
11
+ - Support `string` control property `background`
12
+ - Support `string` control property `font`
13
+ - Support `string` control property `underline`
14
+ - Enhance `combobox` to accept `String` value for `selected` item instead of just `Integer` index
15
+ - Add `selected_item` read-only property to `combobox` to return selected item `String` value
16
+ - Fix `color` property support for `string` to accept 255-based rgb values
17
+ - Fix issue with alternating string colors in examples/basic_draw_text.rb
18
+
19
+ ## 0.2.3
20
+
21
+ - Update examples/midi_player.rb to read sounds locally from gem
22
+ - Support examples/basic_draw_text.rb
23
+ - Support dynamic `text` control to be called in `area` `on_draw` listener
24
+ - Support `text` control `default_font` property
25
+ - Support `string` control nestable under `text` to represent an attributed/unattributed string (depending on nestable properties)
26
+ - Support `string` control property `color`
27
+ - Support enum symbols for `align` property of `text` control
28
+ - Support enum symbols for `:italic` font descriptor key (in addition to numbers)
29
+ - Support enum symbols for `:stretch` font descriptor key (in addition to numbers)
30
+ - Support enum symbols for `:weight` font descriptor key (in addition to numbers)
31
+
32
+ ## 0.2.2
33
+
34
+ - Automatically add `vertical_box` parent to `area` if it did not have a box parent (otherwise, it seems not to show up on Linux, even when directly under `grid`)
35
+
3
36
  ## 0.2.1
4
37
 
5
38
  - Have examples/timer.rb show `msg_box` on finish
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
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.5
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)
@@ -197,7 +197,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
197
197
 
198
198
  ## Table of Contents
199
199
 
200
- - [Glimmer DSL for LibUI 0.2.1](#-glimmer-dsl-for-libui-021)
200
+ - [Glimmer DSL for LibUI 0.2.5](#-glimmer-dsl-for-libui-025)
201
201
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
202
202
  - [Usage](#usage)
203
203
  - [Girb (Glimmer IRB)](#girb-glimmer-irb)
@@ -244,6 +244,8 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
244
244
  - [Login](#login)
245
245
  - [Timer](#timer)
246
246
  - [Color The Circles](#color-the-circles)
247
+ - [Basic Draw Text](#basic-draw-text)
248
+ - [Custom Draw Text](#custom-draw-text)
247
249
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
248
250
  - [Help](#help)
249
251
  - [Issues](#issues)
@@ -331,7 +333,7 @@ gem install glimmer-dsl-libui
331
333
  Or install via Bundler `Gemfile`:
332
334
 
333
335
  ```ruby
334
- gem 'glimmer-dsl-libui', '~> 0.2.1'
336
+ gem 'glimmer-dsl-libui', '~> 0.2.5'
335
337
  ```
336
338
 
337
339
  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.
@@ -1276,9 +1278,7 @@ window('Notepad', 500, 300) {
1276
1278
 
1277
1279
  ### Midi Player
1278
1280
 
1279
- This example has prerequisites:
1280
- - 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).
1281
- - Add `*.mid` files to `~/Music` directory (you may copy the ones included in [sounds](sounds) directory)
1281
+ To run this example, 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).
1282
1282
 
1283
1283
  [examples/midi_player.rb](examples/midi_player.rb)
1284
1284
 
@@ -1417,7 +1417,7 @@ class TinyMidiPlayer
1417
1417
 
1418
1418
  def initialize
1419
1419
  @pid = nil
1420
- @music_directory = File.expand_path(ARGV[0] || '~/Music/')
1420
+ @music_directory = File.expand_path('../sounds', __dir__)
1421
1421
  @midi_files = Dir.glob(File.join(@music_directory, '**/*.mid'))
1422
1422
  .sort_by { |path| File.basename(path) }
1423
1423
  at_exit { stop_midi }
@@ -4538,6 +4538,8 @@ window('Login') {
4538
4538
 
4539
4539
  ### Timer
4540
4540
 
4541
+ To run this example, 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).
4542
+
4541
4543
  [examples/timer.rb](examples/timer.rb)
4542
4544
 
4543
4545
  Run with this command from the root of the project if you cloned the project:
@@ -4565,8 +4567,6 @@ Linux
4565
4567
  New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
4566
4568
 
4567
4569
  ```ruby
4568
- # frozen_string_literal: true
4569
-
4570
4570
  require 'glimmer-dsl-libui'
4571
4571
 
4572
4572
  class Timer
@@ -4578,13 +4578,13 @@ class Timer
4578
4578
 
4579
4579
  def initialize
4580
4580
  @pid = nil
4581
- @midi_file = File.expand_path('../sounds/AlanWalker-Faded.mid', __dir__)
4582
- at_exit { stop_midi }
4581
+ @alarm_file = File.expand_path('../sounds/AlanWalker-Faded.mid', __dir__)
4582
+ at_exit { stop_alarm }
4583
4583
  setup_timer
4584
4584
  create_gui
4585
4585
  end
4586
4586
 
4587
- def stop_midi
4587
+ def stop_alarm
4588
4588
  if @pid
4589
4589
  if @th.alive?
4590
4590
  Process.kill(:SIGKILL, @pid)
@@ -4595,11 +4595,11 @@ class Timer
4595
4595
  end
4596
4596
  end
4597
4597
 
4598
- def play_midi
4599
- stop_midi
4598
+ def play_alarm
4599
+ stop_alarm
4600
4600
  if @pid.nil?
4601
4601
  begin
4602
- @pid = spawn "timidity -G 0.0-10.0 #{@midi_file}"
4602
+ @pid = spawn "timidity -G 0.0-10.0 #{@alarm_file}"
4603
4603
  @th = Process.detach @pid
4604
4604
  rescue Errno::ENOENT
4605
4605
  warn 'Timidty++ not found. Please install Timidity++.'
@@ -4634,7 +4634,8 @@ class Timer
4634
4634
  @stop_button.enabled = false
4635
4635
  @started = false
4636
4636
  unless @played
4637
- play_midi
4637
+ play_alarm
4638
+ msg_box('Alarm', 'Countdown Is Finished!')
4638
4639
  @played = true
4639
4640
  end
4640
4641
  end
@@ -4939,6 +4940,504 @@ end
4939
4940
  ColorTheCircles.new.launch
4940
4941
  ```
4941
4942
 
4943
+ ### Basic Draw Text
4944
+
4945
+ [examples/basic_draw_text.rb](examples/basic_draw_text.rb)
4946
+
4947
+ Run with this command from the root of the project if you cloned the project:
4948
+
4949
+ ```
4950
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_draw_text.rb
4951
+ ```
4952
+
4953
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
4954
+
4955
+ ```
4956
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_draw_text'"
4957
+ ```
4958
+
4959
+ Mac
4960
+
4961
+ ![glimmer-dsl-libui-mac-basic-draw-text.png](images/glimmer-dsl-libui-mac-basic-draw-text.png)
4962
+
4963
+ Linux
4964
+
4965
+ ![glimmer-dsl-libui-linux-basic-draw-text.png](images/glimmer-dsl-libui-linux-basic-draw-text.png)
4966
+
4967
+ [LibUI](https://github.com/kojix2/LibUI) Original Version:
4968
+
4969
+ ```ruby
4970
+ require 'libui'
4971
+
4972
+ UI = LibUI
4973
+
4974
+ UI.init
4975
+
4976
+ handler = UI::FFI::AreaHandler.malloc
4977
+ area = UI.new_area(handler)
4978
+
4979
+ # Michael Ende (1929-1995)
4980
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
4981
+ # The English version, translated by Ralph Manheim, was published in 1983.
4982
+
4983
+ TITLE = 'Michael Ende (1929-1995) The Neverending Story'
4984
+
4985
+ str1 = \
4986
+ ' At last Ygramul sensed that something was coming toward ' \
4987
+ 'her. With the speed of lightning, she turned about, confronting ' \
4988
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
4989
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
4990
+
4991
+ str2 = \
4992
+ ' A cry of fear escaped Bastian. '
4993
+
4994
+ str3 = \
4995
+ ' A cry of terror passed through the ravine and echoed from ' \
4996
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
4997
+ 'someone else had arrived, for that sound could not have been ' \
4998
+ 'made by the boy who stood there as though paralyzed with ' \
4999
+ 'horror. '
5000
+
5001
+ str4 = \
5002
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
5003
+ "But that's not possible. "
5004
+
5005
+ str5 = \
5006
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
5007
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
5008
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
5009
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
5010
+ 'words. '
5011
+
5012
+ str = ''
5013
+ attr_str = UI.new_attributed_string(str)
5014
+
5015
+ def attr_str.append(what, color)
5016
+ case color
5017
+ when :red
5018
+ color_attribute = UI.new_color_attribute(0.0, 0.5, 0.0, 0.7)
5019
+ when :green
5020
+ color_attribute = UI.new_color_attribute(0.5, 0.0, 0.25, 0.7)
5021
+ end
5022
+ start = UI.attributed_string_len(self)
5023
+ UI.attributed_string_append_unattributed(self, what)
5024
+ UI.attributed_string_set_attribute(self, color_attribute, start, start + what.size)
5025
+ UI.attributed_string_append_unattributed(self, "\n\n")
5026
+ end
5027
+
5028
+ attr_str.append(str1, :green)
5029
+ attr_str.append(str2, :red)
5030
+ attr_str.append(str3, :green)
5031
+ attr_str.append(str4, :red)
5032
+ attr_str.append(str5, :green)
5033
+
5034
+ Georgia = 'Georgia'
5035
+
5036
+ handler_draw_event = Fiddle::Closure::BlockCaller.new(0, [1, 1, 1]) do |_, _, adp|
5037
+ area_draw_params = UI::FFI::AreaDrawParams.new(adp)
5038
+ default_font = UI::FFI::FontDescriptor.malloc
5039
+ default_font.Family = Georgia
5040
+ default_font.Size = 13
5041
+ default_font.Weight = 500
5042
+ default_font.Italic = 0
5043
+ default_font.Stretch = 4
5044
+ params = UI::FFI::DrawTextLayoutParams.malloc
5045
+
5046
+ # UI.font_button_font(font_button, default_font)
5047
+ params.String = attr_str
5048
+ params.DefaultFont = default_font
5049
+ params.Width = area_draw_params.AreaWidth
5050
+ params.Align = 0
5051
+ text_layout = UI.draw_new_text_layout(params)
5052
+ UI.draw_text(area_draw_params.Context, text_layout, 0, 0)
5053
+ UI.draw_free_text_layout(text_layout)
5054
+ end
5055
+
5056
+ handler.Draw = handler_draw_event
5057
+ # Assigning to local variables
5058
+ # This is intended to protect Fiddle::Closure from garbage collection.
5059
+ handler.MouseEvent = (c1 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
5060
+ handler.MouseCrossed = (c2 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
5061
+ handler.DragBroken = (c3 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
5062
+ handler.KeyEvent = (c4 = Fiddle::Closure::BlockCaller.new(0, [0]) {})
5063
+
5064
+ box = UI.new_vertical_box
5065
+ UI.box_set_padded(box, 1)
5066
+ UI.box_append(box, area, 1)
5067
+
5068
+ main_window = UI.new_window(TITLE, 600, 400, 1)
5069
+ UI.window_set_margined(main_window, 1)
5070
+ UI.window_set_child(main_window, box)
5071
+
5072
+ UI.window_on_closing(main_window) do
5073
+ UI.control_destroy(main_window)
5074
+ UI.quit
5075
+ 0
5076
+ end
5077
+ UI.control_show(main_window)
5078
+
5079
+ UI.main
5080
+ UI.quit
5081
+ ```
5082
+
5083
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
5084
+
5085
+ ```ruby
5086
+ require 'glimmer-dsl-libui'
5087
+
5088
+ # Michael Ende (1929-1995)
5089
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5090
+ # The English version, translated by Ralph Manheim, was published in 1983.
5091
+ class BasicDrawText
5092
+ include Glimmer
5093
+
5094
+ def alternating_color_string(initial: false, &block)
5095
+ @index = 0 if initial
5096
+ @index += 1
5097
+ string {
5098
+ if @index.odd?
5099
+ color r: 0.5, g: 0, b: 0.25, a: 0.7
5100
+ else
5101
+ color r: 0, g: 0.5, b: 0, a: 0.7
5102
+ end
5103
+
5104
+ block.call + "\n\n"
5105
+ }
5106
+ end
5107
+
5108
+ def launch
5109
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 400) {
5110
+ margined true
5111
+
5112
+ area {
5113
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
5114
+ # align :left # default alignment
5115
+ default_font family: 'Georgia', size: 13, weight: :medium, italic: :normal, stretch: :normal
5116
+
5117
+ alternating_color_string(initial: true) {
5118
+ ' At last Ygramul sensed that something was coming toward ' \
5119
+ 'her. With the speed of lightning, she turned about, confronting ' \
5120
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
5121
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
5122
+ }
5123
+ alternating_color_string {
5124
+ ' A cry of fear escaped Bastian. '
5125
+ }
5126
+ alternating_color_string {
5127
+ ' A cry of terror passed through the ravine and echoed from ' \
5128
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
5129
+ 'someone else had arrived, for that sound could not have been ' \
5130
+ 'made by the boy who stood there as though paralyzed with ' \
5131
+ 'horror. '
5132
+ }
5133
+ alternating_color_string {
5134
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
5135
+ "But that's not possible. "
5136
+ }
5137
+ alternating_color_string {
5138
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
5139
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
5140
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
5141
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
5142
+ 'words. '
5143
+ }
5144
+ }
5145
+ }
5146
+ }.show
5147
+ end
5148
+ end
5149
+
5150
+ BasicDrawText.new.launch
5151
+ ```
5152
+
5153
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2:
5154
+
5155
+ ```ruby
5156
+ require 'glimmer-dsl-libui'
5157
+
5158
+ # Michael Ende (1929-1995)
5159
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5160
+ # The English version, translated by Ralph Manheim, was published in 1983.
5161
+ class BasicDrawText
5162
+ include Glimmer
5163
+
5164
+ def alternating_color_string(initial: false, &block)
5165
+ @index = 0 if initial
5166
+ @index += 1
5167
+ string {
5168
+ if @index.odd?
5169
+ color r: 0.5, g: 0, b: 0.25, a: 0.7
5170
+ else
5171
+ color r: 0, g: 0.5, b: 0, a: 0.7
5172
+ end
5173
+
5174
+ block.call + "\n\n"
5175
+ }
5176
+ end
5177
+
5178
+ def launch
5179
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 400) {
5180
+ margined true
5181
+
5182
+ area {
5183
+ on_draw do |area_draw_params|
5184
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
5185
+ # align :left # default alignment
5186
+ default_font family: 'Georgia', size: 13, weight: :medium, italic: :normal, stretch: :normal
5187
+
5188
+ alternating_color_string(initial: true) {
5189
+ ' At last Ygramul sensed that something was coming toward ' \
5190
+ 'her. With the speed of lightning, she turned about, confronting ' \
5191
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
5192
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
5193
+ }
5194
+ alternating_color_string {
5195
+ ' A cry of fear escaped Bastian. '
5196
+ }
5197
+ alternating_color_string {
5198
+ ' A cry of terror passed through the ravine and echoed from ' \
5199
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
5200
+ 'someone else had arrived, for that sound could not have been ' \
5201
+ 'made by the boy who stood there as though paralyzed with ' \
5202
+ 'horror. '
5203
+ }
5204
+ alternating_color_string {
5205
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
5206
+ "But that's not possible. "
5207
+ }
5208
+ alternating_color_string {
5209
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
5210
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
5211
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
5212
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
5213
+ 'words. '
5214
+ }
5215
+ }
5216
+ end
5217
+ }
5218
+ }.show
5219
+ end
5220
+ end
5221
+
5222
+ BasicDrawText.new.launch
5223
+ ```
5224
+
5225
+ ### Custom Draw Text
5226
+
5227
+ [examples/custom_draw_text.rb](examples/custom_draw_text.rb)
5228
+
5229
+ Run with this command from the root of the project if you cloned the project:
5230
+
5231
+ ```
5232
+ ruby -r './lib/glimmer-dsl-libui' examples/custom_draw_text.rb
5233
+ ```
5234
+
5235
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
5236
+
5237
+ ```
5238
+ ruby -r glimmer-dsl-libui -e "require 'examples/custom_draw_text'"
5239
+ ```
5240
+
5241
+ Mac
5242
+
5243
+ ![glimmer-dsl-libui-mac-custom-draw-text.png](images/glimmer-dsl-libui-mac-custom-draw-text.png)
5244
+ ![glimmer-dsl-libui-mac-custom-draw-text-changed.png](images/glimmer-dsl-libui-mac-custom-draw-text-changed.png)
5245
+
5246
+ Linux
5247
+
5248
+ ![glimmer-dsl-libui-linux-custom-draw-text.png](images/glimmer-dsl-libui-linux-custom-draw-text.png)
5249
+ ![glimmer-dsl-libui-linux-custom-draw-text-changed.png](images/glimmer-dsl-libui-linux-custom-draw-text-changed.png)
5250
+
5251
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
5252
+
5253
+ ```ruby
5254
+ require 'glimmer-dsl-libui'
5255
+
5256
+ # Michael Ende (1929-1995)
5257
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5258
+ # The English version, translated by Ralph Manheim, was published in 1983.
5259
+ class CustomDrawText
5260
+ include Glimmer
5261
+
5262
+ def launch
5263
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
5264
+ margined true
5265
+
5266
+ vertical_box {
5267
+ form {
5268
+ stretchy false
5269
+
5270
+ font_button { |fb|
5271
+ label 'Font'
5272
+
5273
+ on_changed do
5274
+ @string.font = fb.font
5275
+ end
5276
+ }
5277
+ color_button { |cb|
5278
+ label 'Color'
5279
+
5280
+ on_changed do
5281
+ @string.color = cb.color
5282
+ end
5283
+ }
5284
+ color_button { |cb|
5285
+ label 'Background'
5286
+
5287
+ on_changed do
5288
+ @string.background = cb.color
5289
+ end
5290
+ }
5291
+ combobox { |c|
5292
+ label 'Underline'
5293
+ items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
5294
+ selected 'None'
5295
+
5296
+ on_selected do
5297
+ @string.underline = c.selected_item.underscore
5298
+ end
5299
+ }
5300
+ }
5301
+
5302
+ area {
5303
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
5304
+ # align :left # default alignment
5305
+
5306
+ @string = string {
5307
+ ' At last Ygramul sensed that something was coming toward ' \
5308
+ 'her. With the speed of lightning, she turned about, confronting ' \
5309
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
5310
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. ' \
5311
+ "\n\n" \
5312
+ ' A cry of fear escaped Bastian. ' \
5313
+ "\n\n" \
5314
+ ' A cry of terror passed through the ravine and echoed from ' \
5315
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
5316
+ 'someone else had arrived, for that sound could not have been ' \
5317
+ 'made by the boy who stood there as though paralyzed with ' \
5318
+ 'horror. ' \
5319
+ "\n\n" \
5320
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
5321
+ "But that's not possible. " \
5322
+ "\n\n" \
5323
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
5324
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
5325
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
5326
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
5327
+ 'words. ' \
5328
+ "\n\n"
5329
+ }
5330
+ }
5331
+ }
5332
+ }
5333
+ }.show
5334
+ end
5335
+ end
5336
+
5337
+ CustomDrawText.new.launch
5338
+ ```
5339
+
5340
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2:
5341
+
5342
+ ```ruby
5343
+ require 'glimmer-dsl-libui'
5344
+
5345
+ # Michael Ende (1929-1995)
5346
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5347
+ # The English version, translated by Ralph Manheim, was published in 1983.
5348
+ class CustomDrawText
5349
+ include Glimmer
5350
+
5351
+ def launch
5352
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
5353
+ margined true
5354
+
5355
+ vertical_box {
5356
+ form {
5357
+ stretchy false
5358
+
5359
+ font_button { |fb|
5360
+ label 'Font'
5361
+
5362
+ on_changed do
5363
+ @font = fb.font
5364
+ @area.queue_redraw_all
5365
+ end
5366
+ }
5367
+ color_button { |cb|
5368
+ label 'Color'
5369
+
5370
+ on_changed do
5371
+ @color = cb.color
5372
+ @area.queue_redraw_all
5373
+ end
5374
+ }
5375
+ color_button { |cb|
5376
+ label 'Background'
5377
+
5378
+ on_changed do
5379
+ @background = cb.color
5380
+ @area.queue_redraw_all
5381
+ end
5382
+ }
5383
+ combobox { |c|
5384
+ label 'Underline'
5385
+ items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
5386
+ selected 'None'
5387
+
5388
+ on_selected do
5389
+ @underline = c.selected_item.underscore
5390
+ @area.queue_redraw_all
5391
+ end
5392
+ }
5393
+ }
5394
+
5395
+ @area = area {
5396
+ on_draw do |area_draw_params|
5397
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
5398
+ # align :left # default alignment
5399
+
5400
+ @string = string {
5401
+ font @font unless @font.nil?
5402
+ color @color unless @color.nil?
5403
+ background @background unless @background.nil?
5404
+ underline @underline unless @underline.nil?
5405
+
5406
+ ' At last Ygramul sensed that something was coming toward ' \
5407
+ 'her. With the speed of lightning, she turned about, confronting ' \
5408
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
5409
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. ' \
5410
+ "\n\n" \
5411
+ ' A cry of fear escaped Bastian. ' \
5412
+ "\n\n" \
5413
+ ' A cry of terror passed through the ravine and echoed from ' \
5414
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
5415
+ 'someone else had arrived, for that sound could not have been ' \
5416
+ 'made by the boy who stood there as though paralyzed with ' \
5417
+ 'horror. ' \
5418
+ "\n\n" \
5419
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
5420
+ "But that's not possible. " \
5421
+ "\n\n" \
5422
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
5423
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
5424
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
5425
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
5426
+ 'words. ' \
5427
+ "\n\n"
5428
+ }
5429
+ }
5430
+ end
5431
+ }
5432
+ }
5433
+ }.show
5434
+ end
5435
+ end
5436
+
5437
+ CustomDrawText.new.launch
5438
+
5439
+ ```
5440
+
4942
5441
  ## Contributing to glimmer-dsl-libui
4943
5442
 
4944
5443
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.5