glimmer-dsl-tk 0.0.14 → 0.0.15

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: 497468a4ac3cef00c77957d6cb216ba1aed9916214e54561e8bff752c5117261
4
- data.tar.gz: 3da1ce8af59ea3e03f45b1ab7c218c375fd86a145959657e8251d431bc6d0d90
3
+ metadata.gz: 12e68b40c6fb5c056f778d8864b88a01adb69ee4c0fe4273cc007a7d8d589cb9
4
+ data.tar.gz: 16281eeb0be0b1556390c42504f82d879ae6e13f427875215454f8a5d8949706
5
5
  SHA512:
6
- metadata.gz: f8def1bfc6f2263a3557a0fd6ccdf48b53180a259a63972463341e9afa235610634b4070b3b5b425c7a0205b73d2b22f3f9562cdebb53b3792232723f7a3a0bb
7
- data.tar.gz: 7bd54e692f828e9134876bf9b00f3f3d2413235c919673ffe44be294c6890fcf1c2655ab5928a92a3e814049a37bd458e82f5870c0d051c91f0f60f14eebcd6b
6
+ metadata.gz: 07ec8746537d220b0b768715f29f5796543f497c1054c55796b8a23ae0ac83c4007d545d378b3ac7896893f68a1a2f2d0b11a0bbd002254cddb5369d7d6a5653
7
+ data.tar.gz: aae794b82923901cd227d899fa914978e168fb8c35ff8433ccda048d7845e346aa9b74b001d91cc7779dcbe588cad46817fac48aa7c3ec3be1332ebf9ce80852
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.15
4
+
5
+ - Update Hello, Button! to demo all button attributes
6
+ - Support `button` `image` attribute (accepting image arguments: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule` to automatically process image)
7
+ - Update `root` `iconphoto` support to accept image arguments: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule` to automatically process image
8
+ - Support `button` `compound` attribute (`'center', 'top', 'bottom', 'left', 'right'`)
9
+ - Support `button` `default` attribute (`'active'` or `'normal'`)
10
+
11
+ ## 0.0.14
12
+
13
+ - Hello, Button!
14
+
15
+ ## 0.0.13
16
+
17
+ - Hello, Message Box!
18
+ - Support `message_box`
19
+
3
20
  ## 0.0.12
4
21
 
5
22
  - Upgrade to glimmer 2.3.0
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 Tk 0.0.14
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 Tk 0.0.15
2
2
  ## MRI Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-tk/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-tk?branch=master)
@@ -29,7 +29,13 @@ The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a pleth
29
29
  Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
30
30
 
31
31
  ```ruby
32
+ require 'glimmer-dsl-tk'
33
+
34
+ include Glimmer
35
+
32
36
  root {
37
+ title 'Hello, World!'
38
+
33
39
  label {
34
40
  text 'Hello, World!'
35
41
  }
@@ -81,7 +87,7 @@ gem install glimmer-dsl-tk
81
87
 
82
88
  Add the following to `Gemfile`:
83
89
  ```
84
- gem 'glimmer-dsl-tk', '~> 0.0.14'
90
+ gem 'glimmer-dsl-tk', '~> 0.0.15'
85
91
  ```
86
92
 
87
93
  And, then run:
@@ -169,9 +175,9 @@ root {
169
175
 
170
176
  ### Supported Widgets
171
177
 
172
- keyword(args) | attributes | listeners/events
178
+ keyword(args) | attributes | listeners / events / bindings / callbacks
173
179
  ------------- | ---------- | ---------
174
- `button` | `text` | `command`
180
+ `button` | `text`, `image`, `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
175
181
  `entry` | `width`, `text` | None
176
182
  `frame(text: )` | None | None
177
183
  `label` | `text` | None
@@ -363,9 +369,13 @@ More details can be found in the [Hello, Combobox!](#hello-combobox) sample belo
363
369
  Glimmer code (from [samples/hello/hello_world.rb](samples/hello/hello_world.rb)):
364
370
 
365
371
  ```ruby
372
+ require 'glimmer-dsl-tk'
373
+
366
374
  include Glimmer
367
375
 
368
376
  root {
377
+ title 'Hello, World!'
378
+
369
379
  label {
370
380
  text 'Hello, World!'
371
381
  }
@@ -381,7 +391,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_world'"
381
391
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
382
392
 
383
393
  ```
384
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_world'"
394
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_world.rb
385
395
  ```
386
396
 
387
397
  Glimmer app:
@@ -408,12 +418,60 @@ class HelloButton
408
418
  root {
409
419
  title 'Hello, Button!'
410
420
 
411
- button {
412
- text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
421
+ frame {
422
+ grid row: 0, column: 0
413
423
 
414
- command {
415
- self.count += 1
424
+ label {
425
+ grid pady: 15
426
+ text 'Text Button'
416
427
  }
428
+
429
+ button {
430
+ text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
431
+ default 'active'
432
+
433
+ command {
434
+ self.count += 1
435
+ }
436
+ }
437
+ }
438
+
439
+ frame {
440
+ grid row: 0, column: 1
441
+
442
+ label {
443
+ grid pady: 15
444
+ text 'Image Button'
445
+ }
446
+
447
+ button {
448
+ image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
449
+
450
+ command {
451
+ message_box(title: 'Image Button', message: 'Image Button Clicked!')
452
+ }
453
+ }
454
+ }
455
+
456
+ frame {
457
+ grid row: 0, column: 2
458
+
459
+ label {
460
+ grid pady: 15
461
+ text 'Text Image Buttons'
462
+ }
463
+
464
+ ['center', 'top', 'bottom', 'left', 'right'].each do |compound_option|
465
+ button {
466
+ image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
467
+ text 'Text Image Button'
468
+ compound compound_option
469
+
470
+ command {
471
+ message_box(title: 'Text Image Button', message: 'Text Image Button Clicked!', detail: "(#{compound_option})")
472
+ }
473
+ }
474
+ end
417
475
  }
418
476
  }.open
419
477
  end
@@ -431,7 +489,7 @@ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_button'"
431
489
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
432
490
 
433
491
  ```
434
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_button'"
492
+ ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_button.rb
435
493
  ```
436
494
 
437
495
  Glimmer app:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.15
Binary file
@@ -45,9 +45,7 @@ module Glimmer
45
45
 
46
46
  def set_attribute(attribute, *args)
47
47
  if attribute.to_s == 'iconphoto'
48
- if args.size == 1 && args.first.is_a?(String)
49
- args[0] = ::TkPhotoImage.new(file: args.first)
50
- end
48
+ args[0..-1] = [image_argument(args)]
51
49
  super
52
50
  else
53
51
  super
@@ -157,6 +157,12 @@ module Glimmer
157
157
 
158
158
  def widget_custom_attribute_mapping
159
159
  @widget_custom_attribute_mapping ||= {
160
+ ::Tk::Tile::TButton => {
161
+ 'image' => {
162
+ getter: {name: 'image', invoker: lambda { |widget, args| @tk.textvariable&.value }},
163
+ setter: {name: 'image=', invoker: lambda { |widget, args| @tk['image'] = image_argument(args) }},
164
+ },
165
+ },
160
166
  ::Tk::Tile::TCombobox => {
161
167
  'text' => {
162
168
  getter: {name: 'text', invoker: lambda { |widget, args| @tk.textvariable&.value }},
@@ -210,6 +216,22 @@ module Glimmer
210
216
  }
211
217
  end
212
218
 
219
+ def image_argument(args)
220
+ if args.first.is_a?(::TkPhotoImage)
221
+ args.first
222
+ else
223
+ image_args = {}
224
+ image_args.merge!(file: args.first.to_s) if args.first.is_a?(String)
225
+ the_image = ::TkPhotoImage.new(image_args)
226
+ if args.last.is_a?(Hash)
227
+ processed_image = ::TkPhotoImage.new
228
+ processed_image.copy(the_image, args.last)
229
+ the_image = processed_image
230
+ end
231
+ the_image
232
+ end
233
+ end
234
+
213
235
  def add_observer(observer, attribute)
214
236
  attribute_listener_installers = @tk.class.ancestors.map {|ancestor| widget_attribute_listener_installers[ancestor]}.compact
215
237
  widget_listener_installers = attribute_listener_installers.map{|installer| installer[attribute.to_s]}.compact if !attribute_listener_installers.empty?
@@ -34,12 +34,60 @@ class HelloButton
34
34
  root {
35
35
  title 'Hello, Button!'
36
36
 
37
- button {
38
- text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
37
+ frame {
38
+ grid row: 0, column: 0
39
39
 
40
- command {
41
- self.count += 1
40
+ label {
41
+ grid pady: 15
42
+ text 'Text Button'
42
43
  }
44
+
45
+ button {
46
+ text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
47
+ default 'active'
48
+
49
+ command {
50
+ self.count += 1
51
+ }
52
+ }
53
+ }
54
+
55
+ frame {
56
+ grid row: 0, column: 1
57
+
58
+ label {
59
+ grid pady: 15
60
+ text 'Image Button'
61
+ }
62
+
63
+ button {
64
+ image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
65
+
66
+ command {
67
+ message_box(title: 'Image Button', message: 'Image Button Clicked!')
68
+ }
69
+ }
70
+ }
71
+
72
+ frame {
73
+ grid row: 0, column: 2
74
+
75
+ label {
76
+ grid pady: 15
77
+ text 'Text Image Buttons'
78
+ }
79
+
80
+ ['center', 'top', 'bottom', 'left', 'right'].each do |compound_option|
81
+ button {
82
+ image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
83
+ text 'Text Image Button'
84
+ compound compound_option
85
+
86
+ command {
87
+ message_box(title: 'Text Image Button', message: 'Text Image Button Clicked!', detail: "(#{compound_option})")
88
+ }
89
+ }
90
+ end
43
91
  }
44
92
  }.open
45
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh