glimmer-dsl-tk 0.0.18 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +36 -2
- data/VERSION +1 -1
- data/glimmer-dsl-tk.gemspec +0 -0
- data/lib/glimmer/tk/root_proxy.rb +102 -2
- data/lib/glimmer/tk/widget_proxy.rb +7 -1
- data/samples/hello/hello_root.rb +35 -0
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b35ad7e7ce829ab16c8ded93da64a71120483982e1799afddf538ff0726d686
|
4
|
+
data.tar.gz: 6a5eec2b8c52f7df03d1f324780cc3b209b2969fe04ab64dc33efc8a1b3d05e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b462e07684dc68a0c15096ea80cd5a516ac9332a1ba21f2235e85b5343b174561446d62633aa2dfc280557ff01531872fd3a033aafc1bf0eec6386b8b4d9901
|
7
|
+
data.tar.gz: 79dba86d404165e841ad94d034799bf3ba10e52fc286bdaa2af3d85b80d0ada8a075396f229e2de498fcea61274722cb8dacd762e68fb7243a9754b57e6221fe
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.20
|
4
|
+
|
5
|
+
- Hello, Root! sample
|
6
|
+
- Support `root` `width`, `height`, `x`, `y` attributes
|
7
|
+
- Support `root` attribute: `resizable`
|
8
|
+
- Support `root` attribute: `minsize`
|
9
|
+
- Support `root` attribute: `maxsize`
|
10
|
+
- Set minimum width/height on `root` (190 pixels)
|
11
|
+
|
3
12
|
## 0.0.18
|
4
13
|
|
5
14
|
- Hello, Frame! sample
|
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.
|
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.20
|
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)
|
@@ -94,6 +94,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
94
94
|
- [Hello, World!](#hello-world)
|
95
95
|
- [Hello, Button!](#hello-button)
|
96
96
|
- [Hello, Frame!](#hello-frame)
|
97
|
+
- [Hello, Root!](#hello-root)
|
97
98
|
- [Hello, Notebook!](#hello-notebook)
|
98
99
|
- [Hello, Label!](#hello-label)
|
99
100
|
- [Hello, Message Box!](#hello-message-box)
|
@@ -137,7 +138,7 @@ gem install glimmer-dsl-tk
|
|
137
138
|
|
138
139
|
Add the following to `Gemfile`:
|
139
140
|
```
|
140
|
-
gem 'glimmer-dsl-tk', '~> 0.0.
|
141
|
+
gem 'glimmer-dsl-tk', '~> 0.0.20'
|
141
142
|
```
|
142
143
|
|
143
144
|
And, then run:
|
@@ -645,6 +646,39 @@ Glimmer app:
|
|
645
646
|
|
646
647
|
![glimmer dsl tk screenshot sample hello frame](images/glimmer-dsl-tk-screenshot-sample-hello-frame.png)
|
647
648
|
|
649
|
+
### Hello, Root!
|
650
|
+
|
651
|
+
Glimmer code (from [samples/hello/hello_frame.rb](samples/hello/hello_frame.rb)):
|
652
|
+
|
653
|
+
```ruby
|
654
|
+
require 'glimmer-dsl-tk'
|
655
|
+
|
656
|
+
include Glimmer
|
657
|
+
|
658
|
+
root {
|
659
|
+
title 'Hello, Root!'
|
660
|
+
width 400
|
661
|
+
height 200
|
662
|
+
x 150
|
663
|
+
y 300
|
664
|
+
resizable true # same as `resizable true, true`, meaning cannot resize horizontally and vertically
|
665
|
+
minsize 200, 100
|
666
|
+
maxsize 600, 400
|
667
|
+
}.open
|
668
|
+
```
|
669
|
+
|
670
|
+
Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
671
|
+
|
672
|
+
```
|
673
|
+
ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_root'"
|
674
|
+
```
|
675
|
+
|
676
|
+
Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
|
677
|
+
|
678
|
+
```
|
679
|
+
ruby -r ./lib/glimmer-dsl-tk.rb ./samples/hello/hello_root.rb
|
680
|
+
```
|
681
|
+
|
648
682
|
### Hello, Notebook!
|
649
683
|
|
650
684
|
Glimmer code (from [samples/hello/hello_notebook.rb](samples/hello/hello_notebook.rb)):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.20
|
data/glimmer-dsl-tk.gemspec
CHANGED
Binary file
|
@@ -27,8 +27,13 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class RootProxy < WidgetProxy
|
30
|
+
REGEX_GEOMETRY = /[x+-]/
|
31
|
+
DEFAULT_WIDTH = 190
|
32
|
+
DEFAULT_HEIGHT = 95
|
33
|
+
|
30
34
|
def initialize(*args)
|
31
35
|
@tk = ::TkRoot.new
|
36
|
+
@tk.minsize = DEFAULT_WIDTH, DEFAULT_HEIGHT
|
32
37
|
end
|
33
38
|
|
34
39
|
def post_add_content
|
@@ -43,19 +48,114 @@ module Glimmer
|
|
43
48
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, keyword, *args, &block)
|
44
49
|
end
|
45
50
|
|
51
|
+
def has_attribute?(attribute, *args)
|
52
|
+
%w[width height x y].include?(attribute.to_s) || super
|
53
|
+
end
|
54
|
+
|
46
55
|
def set_attribute(attribute, *args)
|
47
|
-
|
56
|
+
case attribute.to_s
|
57
|
+
when 'iconphoto'
|
48
58
|
args[0..-1] = [image_argument(args)]
|
49
59
|
super
|
60
|
+
when 'width'
|
61
|
+
@width = args.first.to_i
|
62
|
+
self.geometry = "#{args.first.to_i}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{y_sign}#{abs_y}"
|
63
|
+
when 'height'
|
64
|
+
@height = args.first.to_i
|
65
|
+
self.geometry = "#{@width || DEFAULT_WIDTH}x#{args.first.to_i}#{x_sign}#{abs_x}#{y_sign}#{abs_y}"
|
66
|
+
when 'x'
|
67
|
+
self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{args.first.to_i > 0 ? '+' : '-'}#{args.first.to_i.abs}#{y_sign}#{abs_y}"
|
68
|
+
when 'y'
|
69
|
+
self.geometry = "#{@width || DEFAULT_WIDTH}x#{@height || DEFAULT_HEIGHT}#{x_sign}#{abs_x}#{args.first.to_i > 0 ? '+' : '-'}#{args.first.to_i.abs}"
|
70
|
+
when 'resizable'
|
71
|
+
if args.size == 1 && !args.first.is_a?(Array)
|
72
|
+
self.resizable = [args.first]*2
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
50
76
|
else
|
51
77
|
super
|
52
78
|
end
|
53
79
|
end
|
54
|
-
|
80
|
+
|
81
|
+
def get_attribute(attribute)
|
82
|
+
attribute = attribute.to_s
|
83
|
+
case attribute
|
84
|
+
when 'width'
|
85
|
+
geometry.split(REGEX_GEOMETRY)[0].to_i
|
86
|
+
when 'height'
|
87
|
+
geometry.split(REGEX_GEOMETRY)[1].to_i
|
88
|
+
when 'x'
|
89
|
+
sign_number(x_sign, geometry.split(REGEX_GEOMETRY)[2].to_i)
|
90
|
+
when 'y'
|
91
|
+
sign_number(y_sign, geometry.split(REGEX_GEOMETRY)[3].to_i)
|
92
|
+
else
|
93
|
+
super
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def width
|
98
|
+
get_attribute(:width)
|
99
|
+
end
|
100
|
+
|
101
|
+
def height
|
102
|
+
get_attribute(:height)
|
103
|
+
end
|
104
|
+
|
105
|
+
def x
|
106
|
+
get_attribute(:x)
|
107
|
+
end
|
108
|
+
|
109
|
+
def y
|
110
|
+
get_attribute(:y)
|
111
|
+
end
|
112
|
+
|
113
|
+
def width=(value)
|
114
|
+
set_attribute(:width, value)
|
115
|
+
end
|
116
|
+
|
117
|
+
def height=(value)
|
118
|
+
set_attribute(:height, value)
|
119
|
+
end
|
120
|
+
|
121
|
+
def x=(value)
|
122
|
+
set_attribute(:x, value)
|
123
|
+
end
|
124
|
+
|
125
|
+
def y=(value)
|
126
|
+
set_attribute(:y, value)
|
127
|
+
end
|
128
|
+
|
55
129
|
# Starts Tk mainloop
|
56
130
|
def start_event_loop
|
57
131
|
::Tk.mainloop
|
58
132
|
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def sign_number(sign, number)
|
137
|
+
"#{sign}1".to_i * number
|
138
|
+
end
|
139
|
+
|
140
|
+
def abs_x
|
141
|
+
geometry.split(REGEX_GEOMETRY)[2].to_i
|
142
|
+
end
|
143
|
+
|
144
|
+
def abs_y
|
145
|
+
geometry.split(REGEX_GEOMETRY)[3].to_i
|
146
|
+
end
|
147
|
+
|
148
|
+
def x_sign
|
149
|
+
geometry_signs[0]
|
150
|
+
end
|
151
|
+
|
152
|
+
def y_sign
|
153
|
+
geometry_signs[1]
|
154
|
+
end
|
155
|
+
|
156
|
+
def geometry_signs
|
157
|
+
geometry.chars.select {|char| char.match(/[+-]/)}
|
158
|
+
end
|
59
159
|
end
|
60
160
|
end
|
61
161
|
end
|
@@ -153,7 +153,13 @@ module Glimmer
|
|
153
153
|
if widget_custom_attribute
|
154
154
|
widget_custom_attribute[:setter][:invoker].call(@tk, args)
|
155
155
|
elsif tk_widget_has_attribute_setter?(attribute)
|
156
|
-
|
156
|
+
unless args.size == 1 && @tk.send(attribute) == args.first
|
157
|
+
if args.size == 1
|
158
|
+
@tk.send(attribute_setter(attribute), *args)
|
159
|
+
else
|
160
|
+
@tk.send(attribute_setter(attribute), args)
|
161
|
+
end
|
162
|
+
end
|
157
163
|
elsif tk_widget_has_attribute_getter_setter?(attribute)
|
158
164
|
@tk.send(attribute, *args)
|
159
165
|
elsif has_state?(attribute)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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
|
+
include Glimmer
|
25
|
+
|
26
|
+
root {
|
27
|
+
title 'Hello, Root!'
|
28
|
+
width 400
|
29
|
+
height 200
|
30
|
+
x 150
|
31
|
+
y 300
|
32
|
+
resizable true # same as `resizable true, true`, meaning cannot resize horizontally and vertically
|
33
|
+
minsize 200, 100
|
34
|
+
maxsize 600, 400
|
35
|
+
}.open
|
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.
|
4
|
+
version: 0.0.20
|
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-
|
11
|
+
date: 2021-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.5.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rdoc
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.12'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.12'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: bundler
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +128,20 @@ dependencies:
|
|
142
128
|
- - '='
|
143
129
|
- !ruby/object:Gem::Version
|
144
130
|
version: 0.8.23
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: json
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.5.1
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 2.5.1
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: simplecov
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- samples/hello/hello_list_single_selection.rb
|
221
221
|
- samples/hello/hello_message_box.rb
|
222
222
|
- samples/hello/hello_notebook.rb
|
223
|
+
- samples/hello/hello_root.rb
|
223
224
|
- samples/hello/hello_world.rb
|
224
225
|
- samples/hello/images/denmark.png
|
225
226
|
- samples/hello/images/finland.png
|