glimmer-dsl-libui 0.0.2 → 0.0.3

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: 686f778cb2f5ec48ff536ba285ea078eaca725dbc9f244630c277de89698909c
4
- data.tar.gz: 232094e072370a3d9aa10902659a78ceb61195ad20c897894fc22dc9bdbbcb0b
3
+ metadata.gz: 6d8ea366932ccab5730b36184d7577cf09c23532809c153aaaa5b22a79780bde
4
+ data.tar.gz: 044c9ad6ff2b80030b70b497b4cea87efd9720c0ba167c8a96c5b5fdc60a2f03
5
5
  SHA512:
6
- metadata.gz: cb9a14df6b910961466bcc4ee970f186e13113991534853d7fdcad8bc4524d61cd0166016ff91f00a9e02d0bcd18708af719f6e3621db9c46d7a55e8867bda6d
7
- data.tar.gz: 9d38221eb5e1fe6446febb706b07fb3800e739fc4cf28f6580cb90163256710d78d235669d24c71551f5dc21cf2fa23a6eab556dbbcb11d75bc52cab48f9adab
6
+ metadata.gz: 4abd11ef0a3f79e46e20eca75bc7e0deb2555567837bdcb90d4b84022417dbb419aef1ee0a8dd1ef48ee3a52b330e63eedd1876a86ab89a4da46ffd936043b7a
7
+ data.tar.gz: 6e372ea2b1fa6263f5c1a601e583a44a52a9f619c9141af7f30cb238c2d91ae125de09078cbf384c3482fcb5fc06e4e32e0c2a61a30a2a025f6677af8b998ebf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.3
4
+
5
+ - Support examples/simple_notepad.rb
6
+
3
7
  ## 0.0.2
4
8
 
5
9
  - Support `vertical_box` and `horizontal_box`
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.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.3
2
2
  ## Dependency-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)
@@ -51,8 +51,8 @@ The Glimmer GUI DSL provides a declarative syntax for [LibUI](https://github.com
51
51
  The Glimmer GUI DSL follows these simple concepts in mapping from [LibUI](https://github.com/kojix2/LibUI) syntax:
52
52
  - **Control**: [LibUI](https://github.com/kojix2/LibUI) controls may be declared by lower-case underscored name (aka keyword) (e.g. `window` or `button`). Behind the scenes, they are represented by keyword methods that map to corresponding `LibUI.new_keyword` methods receiving args (e.g. `window('hello world', 300, 200, 1)`).
53
53
  - **Content/Properties/Listeners Block**: Any keyword may be optionally followed by a Ruby curly-brace multi-line-block containing nested controls (content) and/or properties (attributes) (e.g. `window('hello world', 300, 200, 1) {button('greet')}`). It optionally recives one arg representing the control (e.g. `button('greet') {|b| on_clicked { puts b.text}}`)
54
- - **Property**: Control properties may be declared inside keyword blocks with lower-case underscored name followed by property value args (e.g. `title "hello world"` inside `group`). Behind the scenes, they properties correspond to `control_set_property` methods.
55
- - **Listener**: Control listeners may be declared inside keyword blocks with listener lower-case underscored name beginning with `on_` and receiving required block handler (e.g. `on_clicked {puts 'clicked'}` inside `button`). Behind the scenes, they listeners correspond to `control_on_event` methods.
54
+ - **Property**: Control properties may be declared inside keyword blocks with lower-case underscored name followed by property value args (e.g. `title "hello world"` inside `group`). Behind the scenes, properties correspond to `control_set_property` methods.
55
+ - **Listener**: Control listeners may be declared inside keyword blocks with listener lower-case underscored name beginning with `on_` and receiving required block handler (e.g. `on_clicked {puts 'clicked'}` inside `button`). Behind the scenes, listeners correspond to `control_on_event` methods.
56
56
 
57
57
  Example of an app written in [LibUI](https://github.com/kojix2/LibUI)'s procedural imperative syntax:
58
58
 
@@ -65,7 +65,11 @@ UI.init
65
65
 
66
66
  main_window = UI.new_window('hello world', 300, 200, 1)
67
67
 
68
- UI.control_show(main_window)
68
+ button = UI.new_button('Button')
69
+
70
+ UI.button_on_clicked(button) do
71
+ UI.msg_box(main_window, 'Information', 'You clicked the button')
72
+ end
69
73
 
70
74
  UI.window_on_closing(main_window) do
71
75
  puts 'Bye Bye'
@@ -74,6 +78,9 @@ UI.window_on_closing(main_window) do
74
78
  0
75
79
  end
76
80
 
81
+ UI.window_set_child(main_window, button)
82
+ UI.control_show(main_window)
83
+
77
84
  UI.main
78
85
  UI.quit
79
86
  ```
@@ -85,7 +92,13 @@ require 'glimmer-dsl-libui'
85
92
 
86
93
  include Glimmer
87
94
 
88
- window('hello world', 300, 200, 1) {
95
+ window('hello world', 300, 200, 1) { |w|
96
+ button('Button') {
97
+ on_clicked do
98
+ msg_box(w, 'Information', 'You clicked the button')
99
+ end
100
+ }
101
+
89
102
  on_closing do
90
103
  puts 'Bye Bye'
91
104
  end
@@ -103,7 +116,7 @@ gem install glimmer-dsl-libui
103
116
  Or install via Bundler `Gemfile`:
104
117
 
105
118
  ```ruby
106
- gem 'glimmer-dsl-libui', '~> 0.0.2'
119
+ gem 'glimmer-dsl-libui', '~> 0.0.3'
107
120
  ```
108
121
 
109
122
  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.
@@ -377,7 +390,7 @@ include Glimmer
377
390
  window('Basic Entry', 300, 50, 1) { |w|
378
391
  horizontal_box {
379
392
  e = entry {
380
- stretchy 1
393
+ # stretchy 1 # Smart default option for appending to horizontal_box
381
394
 
382
395
  on_changed do
383
396
  puts e.text
@@ -401,6 +414,76 @@ window('Basic Entry', 300, 50, 1) { |w|
401
414
  }.show
402
415
  ```
403
416
 
417
+ ### Simple Notepad
418
+
419
+ [examples/simple_notepad.rb](examples/simple_notepad.rb)
420
+
421
+ Run with this command from the root of the project if you cloned the project:
422
+
423
+ ```
424
+ ruby -r './lib/glimmer-dsl-libui' examples/simple_notepad.rb
425
+ ```
426
+
427
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
428
+
429
+ ```
430
+ ruby -r glimmer-dsl-libui -e "require 'examples/simple_notepad'"
431
+ ```
432
+
433
+ Mac
434
+
435
+ ![glimmer-dsl-libui-simple-notepad-mac.png](images/glimmer-dsl-libui-simple-notepad-mac.png)
436
+
437
+ Linux
438
+
439
+ ![glimmer-dsl-libui-simple-notepad-linux.png](images/glimmer-dsl-libui-simple-notepad-linux.png)
440
+
441
+ [LibUI](https://github.com/kojix2/LibUI) Original Version:
442
+
443
+ ```ruby
444
+ require 'libui'
445
+
446
+ UI = LibUI
447
+
448
+ UI.init
449
+
450
+ main_window = UI.new_window('Notepad', 500, 300, 1)
451
+ UI.window_on_closing(main_window) do
452
+ puts 'Bye Bye'
453
+ UI.control_destroy(main_window)
454
+ UI.quit
455
+ 0
456
+ end
457
+
458
+ vbox = UI.new_vertical_box
459
+ UI.window_set_child(main_window, vbox)
460
+
461
+ entry = UI.new_non_wrapping_multiline_entry
462
+ UI.box_append(vbox, entry, 1)
463
+
464
+ UI.control_show(main_window)
465
+ UI.main
466
+ UI.quit
467
+ ```
468
+
469
+ [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
470
+
471
+ ```ruby
472
+ require 'glimmer-dsl-libui'
473
+
474
+ include Glimmer
475
+
476
+ window('Notepad', 500, 300, 1) {
477
+ on_closing do
478
+ puts 'Bye Bye'
479
+ end
480
+
481
+ vertical_box {
482
+ non_wrapping_multiline_entry
483
+ }
484
+ }.show
485
+ ```
486
+
404
487
  ## Contributing to glimmer-dsl-libui
405
488
 
406
489
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -7,7 +7,7 @@ include Glimmer
7
7
  window('Basic Entry', 300, 50, 1) { |w|
8
8
  horizontal_box {
9
9
  e = entry {
10
- stretchy 1
10
+ # stretchy 1 # Smart default option for appending to horizontal_box
11
11
 
12
12
  on_changed do
13
13
  puts e.text
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ window('Notepad', 500, 300, 1) {
8
+ on_closing do
9
+ puts 'Bye Bye'
10
+ end
11
+
12
+ vertical_box {
13
+ non_wrapping_multiline_entry
14
+ }
15
+ }.show
Binary file
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.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -163,6 +163,7 @@ files:
163
163
  - examples/basic_button.rb
164
164
  - examples/basic_entry.rb
165
165
  - examples/basic_window.rb
166
+ - examples/simple_notepad.rb
166
167
  - glimmer-dsl-libui.gemspec
167
168
  - lib/glimmer-dsl-libui.rb
168
169
  - lib/glimmer/dsl/libui/control_expression.rb