glimmer-dsl-libui 0.0.5 → 0.0.9

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.
@@ -30,6 +30,14 @@ module Glimmer
30
30
  def post_initialize_child(child)
31
31
  ::LibUI.group_set_child(@libui, child.libui)
32
32
  end
33
+
34
+ private
35
+
36
+ def build_control
37
+ super.tap do
38
+ self.margined = true
39
+ end
40
+ end
33
41
  end
34
42
  end
35
43
  end
@@ -0,0 +1,35 @@
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 multiline entry objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class MultilineEntryProxy < ControlProxy
30
+ def libui_api_keyword
31
+ 'multiline_entry'
32
+ end
33
+ end
34
+ end
35
+ end
@@ -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/multiline_entry_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ # Proxy for LibUI non wrapping multiline entry objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class NonWrappingMultilineEntryProxy < MultilineEntryProxy
30
+ end
31
+ end
32
+ end
@@ -33,8 +33,8 @@ module Glimmer
33
33
 
34
34
  def handle_listener(listener_name, &listener)
35
35
  if listener_name == 'on_clicked'
36
- default_behavior_listener = Proc.new do
37
- return_value = listener.call
36
+ @default_behavior_listener = Proc.new do
37
+ return_value = listener.call(self)
38
38
  if return_value.is_a?(Numeric)
39
39
  return_value
40
40
  else
@@ -43,8 +43,8 @@ module Glimmer
43
43
  0
44
44
  end
45
45
  end
46
+ ::LibUI.on_should_quit(&@default_behavior_listener)
46
47
  end
47
- ::LibUI.on_should_quit(&default_behavior_listener)
48
48
  end
49
49
 
50
50
  private
@@ -52,7 +52,7 @@ module Glimmer
52
52
  def build_control
53
53
  @libui = @parent_proxy.append_quit_item(*@args)
54
54
  handle_listener('on_clicked') do
55
- destroy
55
+ ControlProxy.main_window_proxy&.destroy
56
56
  ::LibUI.quit
57
57
  0
58
58
  end
@@ -27,8 +27,9 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class RadioButtonsProxy < ControlProxy
30
- def items(values = nil)
31
- if values.nil?
30
+ def items(*values)
31
+ values = values.first if values.first.is_a?(Array)
32
+ if values.empty?
32
33
  @values
33
34
  else
34
35
  @values = values
@@ -20,6 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/libui/control_proxy'
23
+ require 'glimmer/libui/horizontal_box_proxy'
23
24
 
24
25
  module Glimmer
25
26
  module LibUI
@@ -36,7 +37,7 @@ module Glimmer
36
37
  @block = block
37
38
  @enabled = 1
38
39
  @index = @parent_proxy.num_pages
39
- @content = @block.call
40
+ @content = @block&.call
40
41
  build_control
41
42
  end
42
43
 
@@ -53,10 +54,12 @@ module Glimmer
53
54
  end
54
55
  alias set_margined margined
55
56
  alias margined= margined
57
+ alias margined? margined
56
58
 
57
59
  private
58
60
 
59
61
  def build_control
62
+ @content = HorizontalBoxProxy.new('horizontal_box', @libui, []) if @content.nil?
60
63
  @libui = @parent_proxy.append(name, @content.libui)
61
64
  end
62
65
  end
@@ -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,6 +27,11 @@ 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
@@ -43,7 +48,7 @@ module Glimmer
43
48
  def handle_listener(listener_name, &listener)
44
49
  if listener_name == 'on_closing'
45
50
  default_behavior_listener = Proc.new do
46
- return_value = listener.call
51
+ return_value = listener.call(self)
47
52
  if return_value.is_a?(Numeric)
48
53
  return_value
49
54
  else
@@ -59,7 +64,14 @@ module Glimmer
59
64
  private
60
65
 
61
66
  def build_control
62
- super.tap do
67
+ construction_args = @args.dup
68
+ construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
69
+ construction_args[1] = DEFAULT_WIDTH if construction_args.size == 1
70
+ construction_args[2] = DEFAULT_HEIGHT if construction_args.size == 2
71
+ construction_args[3] = DEFAULT_HAS_MENUBAR if construction_args.size == 3
72
+ 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))
73
+ @libui = ::LibUI.send("new_window", *construction_args)
74
+ @libui.tap do
63
75
  handle_listener('on_closing') do
64
76
  destroy
65
77
  ::LibUI.quit
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.5
4
+ version: 0.0.9
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-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -142,9 +142,9 @@ dependencies:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
144
  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 GUI that just
147
- works!)
145
+ description: Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development GUI
146
+ Library (no need to pre-install any prerequisites. Just install the gem and have
147
+ platform-independent native GUI that just works!)
148
148
  email: andy.am@gmail.com
149
149
  executables:
150
150
  - girb
@@ -163,7 +163,9 @@ files:
163
163
  - examples/basic_button.rb
164
164
  - examples/basic_entry.rb
165
165
  - examples/basic_window.rb
166
+ - examples/basic_window2.rb
166
167
  - examples/control_gallery.rb
168
+ - examples/meta_example.rb
167
169
  - examples/midi_player.rb
168
170
  - examples/simple_notepad.rb
169
171
  - glimmer-dsl-libui.gemspec
@@ -181,15 +183,20 @@ files:
181
183
  - lib/glimmer/libui/check_menu_item_proxy.rb
182
184
  - lib/glimmer/libui/combobox_proxy.rb
183
185
  - lib/glimmer/libui/control_proxy.rb
186
+ - lib/glimmer/libui/date_picker_proxy.rb
187
+ - lib/glimmer/libui/date_time_picker_proxy.rb
184
188
  - lib/glimmer/libui/editable_combobox_proxy.rb
185
189
  - lib/glimmer/libui/group_proxy.rb
186
190
  - lib/glimmer/libui/horizontal_box_proxy.rb
187
191
  - lib/glimmer/libui/menu_item_proxy.rb
192
+ - lib/glimmer/libui/multiline_entry_proxy.rb
193
+ - lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
188
194
  - lib/glimmer/libui/preferences_menu_item_proxy.rb
189
195
  - lib/glimmer/libui/quit_menu_item_proxy.rb
190
196
  - lib/glimmer/libui/radio_buttons_proxy.rb
191
197
  - lib/glimmer/libui/separator_menu_item_proxy.rb
192
198
  - lib/glimmer/libui/tab_item_proxy.rb
199
+ - lib/glimmer/libui/time_picker_proxy.rb
193
200
  - lib/glimmer/libui/vertical_box_proxy.rb
194
201
  - lib/glimmer/libui/window_proxy.rb
195
202
  homepage: http://github.com/AndyObtiva/glimmer-dsl-libui