glimmer-dsl-tk 0.0.54 → 0.0.55

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: 556b89d33cee530135e72cd6f31a79a355db86cf45bbacfd65dbf14b8184b4c3
4
- data.tar.gz: 7c5c0750b19380e8561a16e7789273bd742d33e50294d8100cd5759b6fa2d329
3
+ metadata.gz: c60d4ed3e0d36df11f12decc435cc03357dfb96ec95720e7bb830b527a473f9f
4
+ data.tar.gz: 1d33536b8b2e2c5700c8d3c320b28afc7b4c6d9eb976ce8d210cae94d7b731d5
5
5
  SHA512:
6
- metadata.gz: 2c25d0b5f8a677a82adf158fa7685a4dfb1e4ea006d4fc6a134d1046c3468e3af1261f37aa66678f802a0f4b0d6b2951ea49bf89cab76db89bcedd92d8eb78cd
7
- data.tar.gz: 4bc9c4b2dd59849206e95f85118b230735d72bfb06810fa38fb39a71d4fc3419dc4415b1d5261a465dbf07a0b4d183a673f75f24872a8f4b2ece0f362bde1ad3
6
+ metadata.gz: fc9fffd9cfdc6f75b57bcec0bb2851efe21fbfc6b46376db9350f552e29930c0f452c84654aa74a2fe4cd06e757a5470be265f533479e0a37feb8795ce473d52
7
+ data.tar.gz: 8425516afcb5698463cd23ee20b34570772bf084b29f393a8cc12302f3c3cde95c9d90671d06d4e9be7f5ae953a8d582d8c6d183d2ae55f3d1d09ea5470d320e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.55
4
+
5
+ - Hello, Scale!
6
+ - `scale` `variable` data-binding
7
+
3
8
  ## 0.0.54
4
9
 
5
10
  - Hello, Labelframe!
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.54
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.55
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
  [![Ruby](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml/badge.svg)](https://github.com/AndyObtiva/glimmer-dsl-tk/actions/workflows/ruby.yml)
@@ -100,6 +100,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
100
100
  - [List Multi Selection Data-Binding](#list-multi-selection-data-binding)
101
101
  - [Entry Data-Binding](#entry-data-binding)
102
102
  - [Text Data-Binding](#text-data-binding)
103
+ - [Scale Data-Binding](#scale-data-binding)
103
104
  - [Spinbox Data-Binding](#spinbox-data-binding)
104
105
  - [Checkbutton Data-Binding](#checkbutton-data-binding)
105
106
  - [Radiobutton Data-Binding](#radiobutton-data-binding)
@@ -132,6 +133,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
132
133
  - [Hello, Menu Bar!](#hello-menu-bar)
133
134
  - [Hello, Contextual Menu!](#hello-contextual-menu)
134
135
  - [Hello, Labelframe!](#hello-labelframe)
136
+ - [Hello, Scale!](#hello-scale)
135
137
  - [Applications](#applications)
136
138
  - [Glimmer Tk Calculator](#glimmer-tk-calculator)
137
139
  - [Y3network Ruby UI](#y3network-ruby-ui)
@@ -191,7 +193,7 @@ gem install glimmer-dsl-tk
191
193
 
192
194
  Add the following to `Gemfile`:
193
195
  ```
194
- gem 'glimmer-dsl-tk', '0.0.54'
196
+ gem 'glimmer-dsl-tk', '0.0.55'
195
197
  ```
196
198
 
197
199
  And, then run:
@@ -768,6 +770,28 @@ It automatically handles all the Tk plumbing behind the scenes.
768
770
 
769
771
  More details can be found in [Hello, Text!](#hello-text) sample below.
770
772
 
773
+ ### Scale Data-Binding
774
+
775
+ Example:
776
+
777
+ This assumes a `Person` model with an `age` attribute.
778
+
779
+ ```ruby
780
+ spinbox {
781
+ orient 'horizontal' # can be 'vertical' too
782
+ length 200
783
+ from 0.0
784
+ to 100.0
785
+ variable <=> [person, :age, on_write: ->(val) {val.to_i}]
786
+ }
787
+ ```
788
+
789
+ That code binds the `variable` value of the `scale` to the `age` attribute on the `person` model.
790
+
791
+ It automatically handles all the Tk plumbing behind the scenes.
792
+
793
+ More details can be found in [Hello, Scale!](#hello-scale) sample below.
794
+
771
795
  ### Spinbox Data-Binding
772
796
 
773
797
  Example:
@@ -3894,6 +3918,61 @@ Glimmer app:
3894
3918
 
3895
3919
  ![glimmer dsl tk screenshot sample hello label-frame](images/glimmer-dsl-tk-screenshot-sample-hello-labelframe.png)
3896
3920
 
3921
+ ### Hello, Scale!
3922
+
3923
+ Glimmer code (from [samples/hello/hello_scale.rb](samples/hello/hello_scale.rb)):
3924
+
3925
+ ```ruby
3926
+ require 'glimmer-dsl-tk'
3927
+
3928
+ class HelloScale
3929
+ include Glimmer
3930
+
3931
+ attr_accessor :scale_value
3932
+
3933
+ def initialize
3934
+ self.scale_value = 50
3935
+ end
3936
+
3937
+ def launch
3938
+ root {
3939
+ text 'Hello, Scale!'
3940
+
3941
+ label {
3942
+ anchor 'center'
3943
+ text <= [self, :scale_value]
3944
+ }
3945
+
3946
+ scale {
3947
+ orient 'horizontal'
3948
+ length 200
3949
+ from 0.0
3950
+ to 100.0
3951
+ variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}]
3952
+ }
3953
+ }.open
3954
+ end
3955
+ end
3956
+
3957
+ HelloScale.new.launch
3958
+ ```
3959
+
3960
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
3961
+
3962
+ ```
3963
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_scale'"
3964
+ ```
3965
+
3966
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
3967
+
3968
+ ```
3969
+ ruby -r ./lib/glimmer-dsl-tk.rb samples/hello/hello_scale.rb
3970
+ ```
3971
+
3972
+ Glimmer app:
3973
+
3974
+ ![glimmer dsl tk screenshot sample hello scale](images/glimmer-dsl-tk-screenshot-sample-hello-scale.png)
3975
+
3897
3976
  ## Applications
3898
3977
 
3899
3978
  ### Glimmer Tk Calculator
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.54
1
+ 0.0.55
Binary file
@@ -0,0 +1,48 @@
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/tk/widget_proxy'
23
+ require 'glimmer/tk/variable_owner'
24
+
25
+ module Glimmer
26
+ module Tk
27
+ # Proxy for Tk::Tile::TScale
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class ScaleProxy < WidgetProxy
31
+ include VariableOwner
32
+
33
+ def command_block=(proc)
34
+ tk.command(proc)
35
+ end
36
+
37
+ def handle_listener(listener_name, &listener)
38
+ case listener_name.to_s.downcase
39
+ when 'command', 'change'
40
+ command(&listener)
41
+ else
42
+ super
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -369,6 +369,12 @@ module Glimmer
369
369
  setter: {name: 'text=', invoker: lambda { |widget, args| @tk.textvariable&.value = args.first }},
370
370
  },
371
371
  },
372
+ ::Tk::Tile::TScale => {
373
+ 'variable' => {
374
+ getter: {name: 'variable', invoker: lambda { |widget, args| @tk.variable&.value }},
375
+ setter: {name: 'variable=', invoker: lambda { |widget, args| @tk.variable&.value = args.first }},
376
+ },
377
+ },
372
378
  ::Tk::Root => {
373
379
  'text' => {
374
380
  getter: {name: 'text', invoker: lambda { |widget, args| @tk.title }},
@@ -428,6 +434,13 @@ module Glimmer
428
434
  }
429
435
  end,
430
436
  },
437
+ ::Tk::Tile::TScale => {
438
+ 'variable' => lambda do |observer|
439
+ @tk.command {
440
+ observer.call(@tk.variable&.value)
441
+ }
442
+ end,
443
+ },
431
444
  ::Tk::Text => {
432
445
  'value' => lambda do |observer|
433
446
  handle_listener('modified') do
@@ -0,0 +1,53 @@
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer-dsl-tk'
23
+
24
+ class HelloScale
25
+ include Glimmer
26
+
27
+ attr_accessor :scale_value
28
+
29
+ def initialize
30
+ self.scale_value = 50
31
+ end
32
+
33
+ def launch
34
+ root {
35
+ text 'Hello, Scale!'
36
+
37
+ label {
38
+ anchor 'center'
39
+ text <= [self, :scale_value]
40
+ }
41
+
42
+ scale {
43
+ orient 'horizontal' # can be 'vertical' too
44
+ length 200
45
+ from 0.0
46
+ to 100.0
47
+ variable <=> [self, :scale_value, on_write: ->(val) {val.to_i}]
48
+ }
49
+ }.open
50
+ end
51
+ end
52
+
53
+ HelloScale.new.launch
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.54
4
+ version: 0.0.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
@@ -222,6 +222,7 @@ files:
222
222
  - lib/glimmer/tk/os.rb
223
223
  - lib/glimmer/tk/radiobutton_proxy.rb
224
224
  - lib/glimmer/tk/root_proxy.rb
225
+ - lib/glimmer/tk/scale_proxy.rb
225
226
  - lib/glimmer/tk/scrollbar_frame_proxy.rb
226
227
  - lib/glimmer/tk/spinbox_proxy.rb
227
228
  - lib/glimmer/tk/text_proxy.rb
@@ -251,6 +252,7 @@ files:
251
252
  - samples/hello/hello_notebook.rb
252
253
  - samples/hello/hello_radiobutton.rb
253
254
  - samples/hello/hello_root.rb
255
+ - samples/hello/hello_scale.rb
254
256
  - samples/hello/hello_scrollbar.rb
255
257
  - samples/hello/hello_scrollbar_frame.rb
256
258
  - samples/hello/hello_separator.rb