glimmer-dsl-tk 0.0.15 → 0.0.16

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: 12e68b40c6fb5c056f778d8864b88a01adb69ee4c0fe4273cc007a7d8d589cb9
4
- data.tar.gz: 16281eeb0be0b1556390c42504f82d879ae6e13f427875215454f8a5d8949706
3
+ metadata.gz: 86a726f184dac65952c4a78352e88df639707b156a3a95bf9a9e99728b78b3a1
4
+ data.tar.gz: f6caaace87672c8f636d3f97f5b223b167e48f1f23620b82c0b19286cdfd6f35
5
5
  SHA512:
6
- metadata.gz: 07ec8746537d220b0b768715f29f5796543f497c1054c55796b8a23ae0ac83c4007d545d378b3ac7896893f68a1a2f2d0b11a0bbd002254cddb5369d7d6a5653
7
- data.tar.gz: aae794b82923901cd227d899fa914978e168fb8c35ff8433ccda048d7845e346aa9b74b001d91cc7779dcbe588cad46817fac48aa7c3ec3be1332ebf9ce80852
6
+ metadata.gz: e64dc523caf04755e3380846ef1ac9b9abec8bfdb3cd8b1e251dd98ef4a70470e73e744310cf2e9ce943a0085ac9c730b655dc5945c29409d6e09cc6f1095dd4
7
+ data.tar.gz: 23f99d7734e49d93f702c8987840e6ac043c247c83457be9f6cd1b028624aedb733e68b98c7922a2ec5a17afe05134da90664ab5dcf464350f31dc1afb45dd18
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.16
4
+
5
+ - Support common themed widget state attributes: `active`, `disabled`, `focus`, `pressed`, `selected`, `background`, `readonly`, `alternate`, `invalid`, and `hover`
6
+ - Update Hello, Button! to utilize `focus true` in first button.
7
+
3
8
  ## 0.0.15
4
9
 
5
10
  - Update Hello, Button! to demo all button attributes
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.15
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.16
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)
@@ -87,7 +87,7 @@ gem install glimmer-dsl-tk
87
87
 
88
88
  Add the following to `Gemfile`:
89
89
  ```
90
- gem 'glimmer-dsl-tk', '~> 0.0.15'
90
+ gem 'glimmer-dsl-tk', '~> 0.0.16'
91
91
  ```
92
92
 
93
93
  And, then run:
@@ -175,9 +175,9 @@ root {
175
175
 
176
176
  ### Supported Widgets
177
177
 
178
- keyword(args) | attributes | listeners / events / bindings / callbacks
178
+ keyword(args) | attributes | event bindings & callbacks
179
179
  ------------- | ---------- | ---------
180
- `button` | `text`, `image`, `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
180
+ `button` | `text`, `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `default` (`'active', 'normal'`) | `command`
181
181
  `entry` | `width`, `text` | None
182
182
  `frame(text: )` | None | None
183
183
  `label` | `text` | None
@@ -188,7 +188,20 @@ keyword(args) | attributes | listeners / events / bindings / callbacks
188
188
 
189
189
  #### Common Attributes
190
190
 
191
- - `grid`
191
+ - `grid`: `Hash` of `:row`, `:column`, `:padx`, `:pady`, `:sticky` (`'e', 'w', 'n', 's'` or any combination of direction letters)
192
+
193
+ #### Common Themed Widget States
194
+
195
+ - `active?`
196
+ - `disabled?`
197
+ - `focus?`
198
+ - `pressed?`
199
+ - `selected?`
200
+ - `background?`
201
+ - `readonly?`
202
+ - `alternate?`
203
+ - `invalid?`
204
+ - `hover?`
192
205
 
193
206
  ### Smart Defaults and Convensions
194
207
 
@@ -429,6 +442,7 @@ class HelloButton
429
442
  button {
430
443
  text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
431
444
  default 'active'
445
+ focus true
432
446
 
433
447
  command {
434
448
  self.count += 1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
Binary file
@@ -120,10 +120,25 @@ module Glimmer
120
120
  @tk.respond_to?(attribute)
121
121
  end
122
122
 
123
+ def has_state?(attribute)
124
+ attribute = attribute.sub(/\?$/, '').sub(/=$/, '')
125
+ if @tk.respond_to?(:tile_state)
126
+ begin
127
+ @tk.tile_instate(attribute)
128
+ true
129
+ rescue
130
+ false
131
+ end
132
+ else
133
+ false
134
+ end
135
+ end
136
+
123
137
  def has_attribute?(attribute, *args)
124
138
  (widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][attribute.to_s]) ||
125
139
  tk_widget_has_attribute_setter?(attribute) ||
126
140
  tk_widget_has_attribute_getter_setter?(attribute) ||
141
+ has_state?(attribute) ||
127
142
  respond_to?(attribute_setter(attribute), args)
128
143
  end
129
144
 
@@ -135,6 +150,13 @@ module Glimmer
135
150
  @tk.send(attribute_setter(attribute), *args) unless @tk.send(attribute) == args.first
136
151
  elsif tk_widget_has_attribute_getter_setter?(attribute)
137
152
  @tk.send(attribute, *args)
153
+ elsif has_state?(attribute)
154
+ attribute = attribute.sub(/=$/, '')
155
+ if !!args.first
156
+ @tk.tile_state(attribute)
157
+ else
158
+ @tk.tile_state("!#{attribute}")
159
+ end
138
160
  else
139
161
  send(attribute_setter(attribute), args)
140
162
  end
@@ -146,6 +168,8 @@ module Glimmer
146
168
  widget_custom_attribute[:getter][:invoker].call(@tk, args)
147
169
  elsif tk_widget_has_attribute_getter_setter?(attribute)
148
170
  @tk.send(attribute)
171
+ elsif has_state?(attribute)
172
+ @tk.tile_instate(attribute.sub(/\?$/, ''))
149
173
  else
150
174
  send(attribute)
151
175
  end
@@ -244,9 +268,9 @@ module Glimmer
244
268
 
245
269
  def method_missing(method, *args, &block)
246
270
  method = method.to_s
247
- if args.empty? && block.nil? && widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method]
271
+ if args.empty? && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method]) || has_state?(method))
248
272
  get_attribute(method)
249
- elsif widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method.sub(/=$/, '')] && method.end_with?('=') && block.nil?
273
+ elsif method.end_with?('=') && block.nil? && ((widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][method.sub(/=$/, '')]) || has_state?(method))
250
274
  set_attribute(method.sub(/=$/, ''), *args)
251
275
  else
252
276
  tk.send(method, *args, &block)
@@ -42,9 +42,10 @@ class HelloButton
42
42
  text 'Text Button'
43
43
  }
44
44
 
45
- button {
45
+ button { |b|
46
46
  text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
47
47
  default 'active'
48
+ focus true
48
49
 
49
50
  command {
50
51
  self.count += 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-09 00:00:00.000000000 Z
11
+ date: 2021-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer