glimmer-dsl-libui 0.0.7 → 0.0.11

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.
@@ -0,0 +1,68 @@
1
+ # Copyright (c) 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/libui/control_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ # Proxy for LibUI font button objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class FontButtonProxy < ControlProxy
30
+ def font
31
+ @font_descriptor ||= ::LibUI::FFI::FontDescriptor.malloc
32
+ ::LibUI.font_button_font(@libui, @font_descriptor)
33
+ {
34
+ family: @font_descriptor.Family.to_s,
35
+ size: @font_descriptor.Size,
36
+ weight: @font_descriptor.Weight,
37
+ italic: @font_descriptor.Italic,
38
+ stretch: @font_descriptor.Stretch
39
+ }
40
+ end
41
+
42
+ def family
43
+ font[:family]
44
+ end
45
+
46
+ def size
47
+ font[:size]
48
+ end
49
+
50
+ def weight
51
+ font[:weight]
52
+ end
53
+
54
+ def italic
55
+ font[:italic]
56
+ end
57
+
58
+ def stretch
59
+ font[:stretch]
60
+ end
61
+
62
+ def destroy
63
+ ::LibUI.free_font_button_font(@font_descriptor) unless @font_descriptor.nil?
64
+ super
65
+ end
66
+ end
67
+ end
68
+ end
@@ -31,11 +31,16 @@ module Glimmer
31
31
  ::LibUI.group_set_child(@libui, child.libui)
32
32
  end
33
33
 
34
+ def destroy_child(child)
35
+ ::LibUI.send("group_set_child", @libui, nil)
36
+ super
37
+ end
38
+
34
39
  private
35
40
 
36
41
  def build_control
37
42
  super.tap do
38
- self.margined = 1
43
+ self.margined = true
39
44
  end
40
45
  end
41
46
  end
@@ -54,6 +54,7 @@ module Glimmer
54
54
  end
55
55
  alias set_margined margined
56
56
  alias margined= margined
57
+ alias margined? margined
57
58
 
58
59
  private
59
60
 
@@ -0,0 +1,32 @@
1
+ # Copyright (c) 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/libui/date_time_picker_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ # Proxy for LibUI time picker objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class TimePickerProxy < DateTimePickerProxy
30
+ end
31
+ end
32
+ end
@@ -27,12 +27,22 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class WindowProxy < ControlProxy
30
+ DEFAULT_TITLE = 'Glimmer'
31
+ DEFAULT_WIDTH = 150
32
+ DEFAULT_HEIGHT = 150
33
+ DEFAULT_HAS_MENUBAR = 1
34
+
30
35
  def post_initialize_child(child)
31
36
  ::LibUI.window_set_child(@libui, child.libui)
32
37
  end
38
+
39
+ def destroy_child(child)
40
+ ::LibUI.send("window_set_child", @libui, nil)
41
+ super
42
+ end
33
43
 
34
44
  def show
35
- send_to_libui('show')
45
+ super
36
46
  unless @shown_at_least_once
37
47
  @shown_at_least_once = true
38
48
  ::LibUI.main
@@ -59,7 +69,18 @@ module Glimmer
59
69
  private
60
70
 
61
71
  def build_control
62
- super.tap do
72
+ if OS.mac? && ControlProxy.menu_proxies.empty?
73
+ menu_proxy = ControlProxy.create('menu', nil, [''])
74
+ quit_menu_item_proxy = ControlProxy.create('quit_menu_item', menu_proxy, [])
75
+ end
76
+ construction_args = @args.dup
77
+ construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
78
+ construction_args[1] = DEFAULT_WIDTH if construction_args.size == 1
79
+ construction_args[2] = DEFAULT_HEIGHT if construction_args.size == 2
80
+ construction_args[3] = DEFAULT_HAS_MENUBAR if construction_args.size == 3
81
+ construction_args[3] = ControlProxy.boolean_to_integer(construction_args[3]) if construction_args.size == 4 && (construction_args[3].is_a?(TrueClass) || construction_args[3].is_a?(FalseClass))
82
+ @libui = ::LibUI.send("new_window", *construction_args)
83
+ @libui.tap do
63
84
  handle_listener('on_closing') do
64
85
  destroy
65
86
  ::LibUI.quit
@@ -26,6 +26,7 @@ require 'glimmer'
26
26
  # require 'logging'
27
27
  # require 'puts_debuggerer' if ENV['pd'].to_s.downcase == 'true'
28
28
  # require 'super_module'
29
+ require 'os'
29
30
  require 'libui'
30
31
 
31
32
  # Internal requires
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-18 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: os
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 2.0.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.0
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: libui
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -142,9 +162,9 @@ dependencies:
142
162
  - - "~>"
143
163
  - !ruby/object:Gem::Version
144
164
  version: 0.7.0
145
- description: Prerequisite-Free Ruby Desktop Development GUI Library (no need to pre-install
146
- any prerequisites. Just install the gem and have platform-independent native GUI
147
- that just works!)
165
+ description: Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development GUI
166
+ Library (no need to pre-install any prerequisites. Just install the gem and have
167
+ platform-independent native GUI that just works!)
148
168
  email: andy.am@gmail.com
149
169
  executables:
150
170
  - girb
@@ -163,7 +183,11 @@ files:
163
183
  - examples/basic_button.rb
164
184
  - examples/basic_entry.rb
165
185
  - examples/basic_window.rb
186
+ - examples/basic_window2.rb
187
+ - examples/color_button.rb
166
188
  - examples/control_gallery.rb
189
+ - examples/font_button.rb
190
+ - examples/meta_example.rb
167
191
  - examples/midi_player.rb
168
192
  - examples/simple_notepad.rb
169
193
  - glimmer-dsl-libui.gemspec
@@ -179,9 +203,13 @@ files:
179
203
  - lib/glimmer/libui/about_menu_item_proxy.rb
180
204
  - lib/glimmer/libui/box.rb
181
205
  - lib/glimmer/libui/check_menu_item_proxy.rb
206
+ - lib/glimmer/libui/color_button_proxy.rb
182
207
  - lib/glimmer/libui/combobox_proxy.rb
183
208
  - lib/glimmer/libui/control_proxy.rb
209
+ - lib/glimmer/libui/date_picker_proxy.rb
210
+ - lib/glimmer/libui/date_time_picker_proxy.rb
184
211
  - lib/glimmer/libui/editable_combobox_proxy.rb
212
+ - lib/glimmer/libui/font_button_proxy.rb
185
213
  - lib/glimmer/libui/group_proxy.rb
186
214
  - lib/glimmer/libui/horizontal_box_proxy.rb
187
215
  - lib/glimmer/libui/menu_item_proxy.rb
@@ -192,6 +220,7 @@ files:
192
220
  - lib/glimmer/libui/radio_buttons_proxy.rb
193
221
  - lib/glimmer/libui/separator_menu_item_proxy.rb
194
222
  - lib/glimmer/libui/tab_item_proxy.rb
223
+ - lib/glimmer/libui/time_picker_proxy.rb
195
224
  - lib/glimmer/libui/vertical_box_proxy.rb
196
225
  - lib/glimmer/libui/window_proxy.rb
197
226
  homepage: http://github.com/AndyObtiva/glimmer-dsl-libui