glimmer-dsl-tk 0.0.38 → 0.0.39

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: 5c6969620ced6ade48e45e36bd48909bfe282a412e2f57d8a201f398082c6836
4
- data.tar.gz: d8d4bc858b5fdf7399b10d71922a2e12aaf1cbf0b4c8c0db4bf78416e025a5d0
3
+ metadata.gz: 40c011bf31bc0b5d5691abc8930f93b7fe33c77b8cb77f1f0bf439cd3344d9d7
4
+ data.tar.gz: 65af004b131e750be35b4bab6b11316c012e49dbbcc3509171c40abcdc4b809f
5
5
  SHA512:
6
- metadata.gz: 35a7d92e7f5b9098a9dcd50a5045447237bd66b89dfdd9f5ea10d45201b050a66b7b272266f275645552980a043cda9b59b6b96f591521a7da326fce4ff60524
7
- data.tar.gz: c866f8e9a51d4dd291900ebb0c3b506f5a8d0975d1df779474ebf0997114d4384f5a9d2610e868a3196c1ba1b93cfeb98311d41f4e2b35b1582c64cee2b9dc71
6
+ metadata.gz: b53ed25b7f36d71a8db9dfde148589b95efd88b5ba881b9da1ce011024f13eb90d6b7b4c536fe0302774fe5bf71645e457eb694adceba7f94238d7cc24e3a26c
7
+ data.tar.gz: 11b7ada873371764ec7e255e2ab070863eaad8deec1f54da0246fa7e5e7ed3af3b53ef1fb11954a2d572502353b9b1ed43e6cf557d43cf9517f6fb0047da60b0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.39
4
+
5
+ - Add Language and Language Name menus to Hello, Menu Bar! sample
6
+ - Update Hello, Button! sample to indicate compound option value on image text buttons
7
+ - Support Mac `menu_item(:about, label: ) { on('command') {} }`
8
+ - Support Mac `menu_item(:preferences) { on('command') {} }`
9
+ - Support Mac `menu_item(:help) { on('command') {} }`
10
+ - Support Mac `menu_item(:quit) { on('command') {} }`
11
+ - Support Mac/X11 `'Help'` menu
12
+ - Support Mac `'Window'` menu
13
+ - Support Windows `'System'` menu
14
+
15
+
3
16
  ## 0.0.38
4
17
 
5
18
  - Hello, Menu Bar! 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.38
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.39
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)
@@ -171,7 +171,7 @@ gem install glimmer-dsl-tk
171
171
 
172
172
  Add the following to `Gemfile`:
173
173
  ```
174
- gem 'glimmer-dsl-tk', '~> 0.0.38'
174
+ gem 'glimmer-dsl-tk', '~> 0.0.39'
175
175
  ```
176
176
 
177
177
  And, then run:
@@ -296,7 +296,7 @@ keyword(args) | attributes | event bindings & callbacks
296
296
  `list` | `selectmode`, `selection` | None
297
297
  `message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
298
298
  `menu(label: nil) (label is nil if nested under root/toplevel for menu bar)` | None | None
299
- `menu_item(style = :command, label: , underline: )` (style also can be `:radiobutton`, `:checkbutton`, or `:separator`) | `state`, `accelerator`, `selection` & `variable` (if `:radiobutton` or `:checkbutton`) | `command`
299
+ `menu_item(style = :command, label: , underline: )` (style also can be `:radiobutton`, `:checkbutton`, `:separator`, `:about`, `:preferences`, `:quit`, `:help`) | `state`, `accelerator`, `selection` & `variable` (if `:radiobutton` or `:checkbutton`), `image`, `compound` | `command`
300
300
  `notebook` | None | None
301
301
  `radiobutton` | `text`, `variable` (Boolean), `image` (optional keyword args: `subsample`, `zoom`, `from`, `to`, `shrink`, `compositingrule`), `compound` (`'center', 'top', 'bottom', 'left', 'right'`), `value` (default: `text`) | `command {}`
302
302
  `root` | `title`, `iconphoto`, `background`, `alpha`, `escapable`, `fullscreen?`, `topmost?`, `transparent?`, `stackorder`, `winfo_screendepth`, `winfo_screenvisual`, `winfo_screenwidth`, `winfo_screenheight`, `winfo_pixels('li')`, `winfo_screen`, `wm_maxsize`, `state` (`'normal', 'iconic', 'withdrawn', 'icon', 'zoomed'`) | `'DELETE_WINDOW'`, `'OPEN_WINDOW'`
@@ -3122,12 +3122,20 @@ Glimmer app:
3122
3122
 
3123
3123
  ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar.png)
3124
3124
 
3125
+ ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-application.png)
3126
+
3125
3127
  ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-file.png)
3126
3128
 
3127
3129
  ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-edit.png)
3128
3130
 
3129
3131
  ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-options.png)
3130
3132
 
3133
+ ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-language.png)
3134
+
3135
+ ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-language-name.png)
3136
+
3137
+ ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-window.png)
3138
+
3131
3139
  ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-format.png)
3132
3140
 
3133
3141
  ![glimmer dsl tk screenshot sample hello menu-bar](images/glimmer-dsl-tk-screenshot-sample-hello-menu-bar-view.png)
@@ -3152,9 +3160,9 @@ https://github.com/ancorgs/y3network-ruby-ui
3152
3160
 
3153
3161
  This is a Graphical User Interface for the famous [cryptopunks Ruby gem](https://github.com/cryptopunksnotdead/cryptopunks/tree/master/cryptopunks).
3154
3162
 
3155
- https://github.com/AndyObtiva/cryptopunks-gui
3163
+ https://github.com/cryptopunksnotdead/cryptopunks-gui
3156
3164
 
3157
- ![CryptoPunks GUI Screenshot](https://raw.githubusercontent.com/AndyObtiva/cryptopunks-gui/master/screenshots/cryptopunks-gui-screenshot.png)
3165
+ ![CryptoPunks GUI Screenshot](https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks-gui/master/screenshots/cryptopunks-gui-screenshot.png)
3158
3166
 
3159
3167
  ### Circule
3160
3168
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.38
1
+ 0.0.39
Binary file
@@ -45,7 +45,7 @@ module Glimmer
45
45
 
46
46
  def accelerator=(value)
47
47
  @accelerator = value
48
- @parent_proxy.tk.entryconfigure @options[:label], accelerator: value
48
+ configure_menu_item_attribute(accelerator: value)
49
49
  root_parent_proxy.bind(accelerator_event) do |event|
50
50
  @command_block&.call(event)
51
51
  end
@@ -64,16 +64,38 @@ module Glimmer
64
64
 
65
65
  def state=(value)
66
66
  @state = value
67
- @parent_proxy.tk.entryconfigure @options[:label], :state => value
67
+ configure_menu_item_attribute(state: value)
68
68
  end
69
69
 
70
70
  def state
71
71
  @state
72
72
  end
73
73
 
74
+ def label
75
+ @options[:label]
76
+ end
77
+
78
+ def image=(*args)
79
+ @image = image_argument(args)
80
+ configure_menu_item_attribute(image: @image)
81
+ end
82
+
83
+ def image
84
+ @image
85
+ end
86
+
87
+ def compound=(value)
88
+ @compound = value
89
+ configure_menu_item_attribute(compound: @compound)
90
+ end
91
+
92
+ def compound
93
+ @compound
94
+ end
95
+
74
96
  def command_block=(proc)
75
97
  @command_block = proc
76
- @parent_proxy.tk.entryconfigure @options[:label], command: @command_block
98
+ configure_menu_item_attribute(command: @command_block)
77
99
  end
78
100
 
79
101
  def handle_listener(listener_name, &listener)
@@ -101,6 +123,22 @@ module Glimmer
101
123
  @args.first == :separator
102
124
  end
103
125
 
126
+ def about?
127
+ @args.first == :about
128
+ end
129
+
130
+ def preferences?
131
+ @args.first == :preferences
132
+ end
133
+
134
+ def help?
135
+ @args.first == :help
136
+ end
137
+
138
+ def quit?
139
+ @args.first == :quit
140
+ end
141
+
104
142
  def variable(auto_create: true)
105
143
  if @variable.nil? && auto_create
106
144
  sibling_variable = sibling_radio_menu_items.map {|mi| mi.variable(auto_create: false)}.compact.first
@@ -113,15 +151,27 @@ module Glimmer
113
151
 
114
152
  def selection=(value)
115
153
  if value
116
- variable.value = @options[:label]
117
- # TODO handle image case where there is no label
154
+ variable.value = label
118
155
  elsif checkbutton?
119
- variable.value = '__unchecked__'
156
+ variable.value = ''
120
157
  end
121
158
  end
122
159
 
123
160
  def selection
124
- variable.value == @options[:label]
161
+ variable.value == label
162
+ end
163
+
164
+ # configures menu item attribute through parent menu
165
+ def configure_menu_item_attribute(attribute_value_hash)
166
+ if preferences? && attribute_value_hash[:command]
167
+ ::Tk.ip_eval("proc ::tk::mac::ShowPreferences {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}")
168
+ elsif help? && attribute_value_hash[:command]
169
+ ::Tk.ip_eval("proc ::tk::mac::ShowHelp {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}")
170
+ elsif quit? && attribute_value_hash[:command]
171
+ ::Tk.ip_eval("proc ::tk::mac::Quit {} {#{::Tk.install_cmd(attribute_value_hash[:command])}}")
172
+ else
173
+ @parent_proxy.tk.entryconfigure label, attribute_value_hash
174
+ end
125
175
  end
126
176
 
127
177
  private
@@ -133,10 +183,18 @@ module Glimmer
133
183
  def build_widget
134
184
  @args.prepend(:command) if @args.first.is_a?(Hash)
135
185
  @args.append({}) if !@args.last.is_a?(Hash)
136
- @args.last.merge!(variable: variable, value: @options[:label]) if radiobutton? || checkbutton?
186
+ @args.last.merge!(variable: variable, value: label) if radiobutton? || checkbutton?
137
187
  case @parent_proxy
138
188
  when MenuProxy
139
- @parent_proxy.tk.add(*@args)
189
+ if @parent_proxy.application?
190
+ if OS.mac?
191
+ if about?
192
+ @parent_proxy.tk.add :command, :label => label
193
+ end
194
+ end
195
+ else
196
+ @parent_proxy.tk.add(*@args) unless help?
197
+ end
140
198
  end
141
199
  end
142
200
  end
@@ -31,16 +31,56 @@ module Glimmer
31
31
  super
32
32
  end
33
33
 
34
- private
35
-
36
- def build_widget
37
- tk_widget_class = self.class.tk_widget_class_for(@keyword)
38
- @tk = tk_widget_class.new(@parent_proxy.tk)
34
+ def post_add_content
39
35
  case @parent_proxy
40
36
  when ToplevelProxy
41
37
  @parent_proxy.tk['menu'] = @tk
42
- when MenuProxy
43
- @parent_proxy.tk.add(:cascade, {menu: @tk}.merge(@options))
38
+ end
39
+ end
40
+
41
+ def label
42
+ @options[:label]
43
+ end
44
+
45
+ def help?
46
+ label == 'Help'
47
+ end
48
+
49
+ def window?
50
+ label == 'Window'
51
+ end
52
+
53
+ def system?
54
+ label == 'System'
55
+ end
56
+
57
+ def application?
58
+ @args.first == :application
59
+ end
60
+
61
+ private
62
+
63
+ def build_widget
64
+ if application?
65
+ if OS.mac?
66
+ @tk = ::TkSysMenu_Apple.new(@parent_proxy.tk)
67
+ @parent_proxy.tk.add :cascade, :menu => @tk
68
+ end
69
+ else
70
+ if @parent_proxy.parent_proxy.is_a?(ToplevelProxy) && (OS.mac? || OS.linux?) && help?
71
+ @tk = ::TkSysMenu_Help.new(@parent_proxy.tk)
72
+ elsif @parent_proxy.parent_proxy.is_a?(ToplevelProxy) && OS.mac? && window?
73
+ @tk = ::Tk::TkSysMenu_Window.new(@parent_proxy.tk)
74
+ elsif @parent_proxy.parent_proxy.is_a?(ToplevelProxy) && OS.windows? && system?
75
+ @tk = ::TkSysMenu_System.new(@parent_proxy.tk)
76
+ else
77
+ tk_widget_class = self.class.tk_widget_class_for(@keyword)
78
+ @tk = tk_widget_class.new(@parent_proxy.tk)
79
+ end
80
+ case @parent_proxy
81
+ when MenuProxy
82
+ @parent_proxy.tk.add(:cascade, {menu: @tk}.merge(@options))
83
+ end
44
84
  end
45
85
  end
46
86
  end
@@ -37,10 +37,18 @@ require 'delegate'
37
37
  # require 'ext/glimmer/config'
38
38
  # require 'ext/glimmer'
39
39
  require 'glimmer/dsl/tk/dsl'
40
+
40
41
  Glimmer::Config.loop_max_count = -1
42
+
41
43
  Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
42
44
  method = method_symbol.to_s
43
45
  result = false
44
46
  result ||= method == 'load_iseq'
45
47
  end
48
+
46
49
  ::TkOption.add '*tearOff', 0
50
+
51
+ class ::Tk::TkSysMenu_Window < Tk::Menu
52
+ include Tk::SystemMenu
53
+ SYSMENU_NAME = 'window'
54
+ end
@@ -81,7 +81,7 @@ class HelloButton
81
81
  ['center', 'top', 'bottom', 'left', 'right'].each do |compound_option|
82
82
  button {
83
83
  image File.expand_path('../../icons/glimmer.png', __dir__), subsample: 5
84
- text 'Text Image Button'
84
+ text "#{compound_option.capitalize} Image"
85
85
  compound compound_option
86
86
 
87
87
  command {
@@ -38,6 +38,36 @@ root { |r|
38
38
  }
39
39
 
40
40
  menu {
41
+ if OS.mac?
42
+ menu(:application) {
43
+ menu_item(:about, label: 'About My Application') {
44
+ accelerator 'Command+A'
45
+
46
+ on('command') do
47
+ message_box(parent: r, title: 'About', message: 'About my application.')
48
+ end
49
+ }
50
+
51
+ menu_item(:preferences) {
52
+ on('command') do
53
+ message_box(parent: r, title: 'Preferences', message: 'Preferences of my application.')
54
+ end
55
+ }
56
+
57
+ # If not defined, application simply quits upon selecting Quit menu item
58
+ menu_item(:quit) {
59
+ on('command') do
60
+ message_box(parent: r, title: 'Quit', message: 'Quitting my application...')
61
+ exit(0)
62
+ end
63
+ }
64
+ }
65
+ end
66
+
67
+ if OS.windows?
68
+ menu(label: 'System')
69
+ end
70
+
41
71
  menu(label: 'File', underline: 0) {
42
72
  menu_item(label: 'New', underline: 0) {
43
73
  accelerator 'Command+N'
@@ -46,6 +76,7 @@ root { |r|
46
76
  message_box(parent: r, title: 'New', message: 'New file created.')
47
77
  end
48
78
  }
79
+
49
80
  menu_item(label: 'Open...', underline: 0) {
50
81
  accelerator 'Command+O'
51
82
 
@@ -53,36 +84,44 @@ root { |r|
53
84
  message_box(parent: r, title: 'Open', message: 'Opening File...')
54
85
  end
55
86
  }
87
+
56
88
  menu(label: 'Open Recent', underline: 5) {
57
89
  menu_item(label: 'File 1') {
58
90
  on('command') do
59
91
  message_box(parent: r, title: 'File 1', message: 'File 1 Contents')
60
92
  end
61
93
  }
94
+
62
95
  menu_item(label: 'File 2') {
63
96
  on('command') do
64
97
  message_box(parent: r, title: 'File 2', message: 'File 2 Contents')
65
98
  end
66
99
  }
67
100
  }
101
+
68
102
  menu_item(:separator)
103
+
69
104
  menu_item(label: 'Exit', underline: 1) {
70
105
  on('command') do
71
106
  exit(0)
72
107
  end
73
108
  }
74
109
  }
110
+
75
111
  menu(label: 'Edit', underline: 0) {
76
112
  menu_item(label: 'Cut', underline: 2) {
77
113
  accelerator 'Command+X'
78
114
  }
115
+
79
116
  menu_item(label: 'Copy', underline: 0) {
80
117
  accelerator 'Command+C'
81
118
  }
119
+
82
120
  menu_item(label: 'Paste', underline: 0) {
83
121
  accelerator 'Command+V'
84
122
  }
85
123
  }
124
+
86
125
  menu(label: 'Options', underline: 0) {
87
126
  menu_item(:checkbutton, label: 'Enabled', underline: 0) {
88
127
  on('command') do
@@ -90,6 +129,7 @@ root { |r|
90
129
  @select_multiple_menu.children.each { |menu_item| menu_item.state = menu_item.state == 'disabled' ? 'normal' : 'disabled' }
91
130
  end
92
131
  }
132
+
93
133
  @select_one_menu = menu(label: 'Select One', underline: 0) {
94
134
  menu_item(:radiobutton, label: 'Option 1') {
95
135
  state 'disabled'
@@ -101,6 +141,7 @@ root { |r|
101
141
  state 'disabled'
102
142
  }
103
143
  }
144
+
104
145
  @select_multiple_menu = menu(label: 'Select Multiple', underline: 0) {
105
146
  menu_item(:checkbutton, label: 'Option 4') {
106
147
  state 'disabled'
@@ -113,6 +154,26 @@ root { |r|
113
154
  }
114
155
  }
115
156
  }
157
+
158
+ menu(label: 'Language', underline: 3) {
159
+ ['denmark', 'finland', 'france', 'germany', 'italy', 'mexico', 'netherlands', 'norway', 'usa'].each do |image_name|
160
+ menu_item(:radiobutton, label: image_name.capitalize) {
161
+ selection image_name == 'usa'
162
+ image File.expand_path("images/#{image_name}.png", __dir__)
163
+ }
164
+ end
165
+ }
166
+
167
+ menu(label: 'Language Name', underline: 3) {
168
+ ['denmark', 'finland', 'france', 'germany', 'italy', 'mexico', 'netherlands', 'norway', 'usa'].each do |image_name|
169
+ menu_item(:radiobutton, label: image_name.capitalize) {
170
+ selection image_name == 'usa'
171
+ image File.expand_path("images/#{image_name}.png", __dir__)
172
+ compound 'left'
173
+ }
174
+ end
175
+ }
176
+
116
177
  menu(label: 'Format', underline: 0) {
117
178
  menu(label: 'Background Color', underline: 0) {
118
179
  COLORS.each { |color_style|
@@ -123,6 +184,7 @@ root { |r|
123
184
  }
124
185
  }
125
186
  }
187
+
126
188
  menu(label: 'Foreground Color', underline: 11) {
127
189
  COLORS.each { |color_style|
128
190
  menu_item(:radiobutton, label: color_style.to_s.split('_').map(&:capitalize).join(' ')) {
@@ -133,6 +195,7 @@ root { |r|
133
195
  }
134
196
  }
135
197
  }
198
+
136
199
  menu(label: 'View', underline: 0) {
137
200
  menu_item(:radiobutton, label: 'Small', underline: 0) {
138
201
  accelerator 'Command+S'
@@ -141,6 +204,7 @@ root { |r|
141
204
  @label.font = {size: 25}
142
205
  end
143
206
  }
207
+
144
208
  menu_item(:radiobutton, label: 'Medium', underline: 0) {
145
209
  accelerator 'Command+M'
146
210
  selection true
@@ -149,6 +213,7 @@ root { |r|
149
213
  @label.font = {size: 50}
150
214
  end
151
215
  }
216
+
152
217
  menu_item(:radiobutton, label: 'Large', underline: 0) {
153
218
  accelerator 'Command+L'
154
219
 
@@ -157,7 +222,16 @@ root { |r|
157
222
  end
158
223
  }
159
224
  }
225
+
226
+ menu(label: 'Window', underline: 0)
227
+
160
228
  menu(label: 'Help', underline: 0) {
229
+ menu_item(:help) {
230
+ on('command') do
231
+ message_box(parent: r, title: 'Help', message: 'Help for my application.')
232
+ end
233
+ }
234
+
161
235
  menu_item(label: 'Manual', underline: 0) {
162
236
  accelerator 'Command+Shift+M'
163
237
 
@@ -165,6 +239,7 @@ root { |r|
165
239
  message_box(parent: r, title: 'Manual', message: 'Manual Contents')
166
240
  end
167
241
  }
242
+
168
243
  menu_item(label: 'Tutorial', underline: 0) {
169
244
  accelerator 'Command+Shift+T'
170
245
 
@@ -172,7 +247,9 @@ root { |r|
172
247
  message_box(parent: r, title: 'Tutorial', message: 'Tutorial Contents')
173
248
  end
174
249
  }
250
+
175
251
  menu_item(:separator)
252
+
176
253
  menu_item(label: 'Report an Issue...', underline: 0) {
177
254
  on('command') do
178
255
  message_box(parent: r, title: 'Report an Issue', message: 'Reporting an issue...')
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.38
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer