glimmer-dsl-libui 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +63 -55
  4. data/VERSION +1 -1
  5. data/examples/basic_button.rb +2 -2
  6. data/examples/basic_entry.rb +2 -2
  7. data/examples/basic_transform.rb +1 -1
  8. data/examples/control_gallery.rb +3 -3
  9. data/examples/form.rb +2 -2
  10. data/examples/histogram.rb +18 -19
  11. data/examples/meta_example.rb +71 -20
  12. data/examples/midi_player.rb +8 -10
  13. data/glimmer-dsl-libui.gemspec +0 -0
  14. data/lib/glimmer/dsl/libui/control_expression.rb +0 -2
  15. data/lib/glimmer/dsl/libui/file_expression.rb +5 -1
  16. data/lib/glimmer/dsl/libui/shape_expression.rb +2 -4
  17. data/lib/glimmer/dsl/libui/tab_item_expression.rb +2 -2
  18. data/lib/glimmer/libui/control_proxy/area_proxy.rb +117 -0
  19. data/lib/glimmer/libui/{menu_item_proxy.rb → control_proxy/box/horizontal_box_proxy.rb} +9 -12
  20. data/lib/glimmer/libui/{horizontal_box_proxy.rb → control_proxy/box/vertical_box_proxy.rb} +10 -6
  21. data/lib/glimmer/libui/{box.rb → control_proxy/box.rb} +31 -27
  22. data/lib/glimmer/libui/{button_proxy.rb → control_proxy/button_proxy.rb} +14 -12
  23. data/lib/glimmer/libui/{checkbox_proxy.rb → control_proxy/checkbox_proxy.rb} +14 -12
  24. data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +118 -0
  25. data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +76 -0
  26. data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +46 -0
  27. data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +80 -0
  28. data/lib/glimmer/libui/{radio_buttons_proxy.rb → control_proxy/column/image_column_proxy.rb} +14 -13
  29. data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +48 -0
  30. data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +44 -0
  31. data/lib/glimmer/libui/{checkbox_column_proxy.rb → control_proxy/column/text_column_proxy.rb} +17 -13
  32. data/lib/glimmer/libui/control_proxy/column.rb +55 -0
  33. data/lib/glimmer/libui/control_proxy/combobox_proxy.rb +45 -0
  34. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +43 -0
  35. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +43 -0
  36. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +72 -0
  37. data/lib/glimmer/libui/control_proxy/dual_column.rb +40 -0
  38. data/lib/glimmer/libui/control_proxy/editable_column.rb +46 -0
  39. data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +45 -0
  40. data/lib/glimmer/libui/{dual_column.rb → control_proxy/enableable_column.rb} +18 -10
  41. data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +70 -0
  42. data/lib/glimmer/libui/{form_proxy.rb → control_proxy/form_proxy.rb} +26 -24
  43. data/lib/glimmer/libui/{grid_proxy.rb → control_proxy/grid_proxy.rb} +29 -27
  44. data/lib/glimmer/libui/{group_proxy.rb → control_proxy/group_proxy.rb} +24 -22
  45. data/lib/glimmer/libui/{image_part_proxy.rb → control_proxy/image_part_proxy.rb} +20 -18
  46. data/lib/glimmer/libui/{image_proxy.rb → control_proxy/image_proxy.rb} +32 -30
  47. data/lib/glimmer/libui/{combobox_proxy.rb → control_proxy/label_proxy.rb} +13 -13
  48. data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +147 -0
  49. data/lib/glimmer/libui/{editable_column.rb → control_proxy/menu_item_proxy/about_menu_item_proxy.rb} +13 -16
  50. data/lib/glimmer/libui/{enableable_column.rb → control_proxy/menu_item_proxy/check_menu_item_proxy.rb} +13 -16
  51. data/lib/glimmer/libui/{date_picker_proxy.rb → control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb} +10 -10
  52. data/lib/glimmer/libui/{quit_menu_item_proxy.rb → control_proxy/menu_item_proxy/quit_menu_item_proxy.rb} +33 -29
  53. data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +41 -0
  54. data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +45 -0
  55. data/lib/glimmer/libui/{editable_combobox_proxy.rb → control_proxy/menu_proxy.rb} +13 -13
  56. data/lib/glimmer/libui/{vertical_box_proxy.rb → control_proxy/message_box/msg_box_error_proxy.rb} +9 -6
  57. data/lib/glimmer/libui/{multiline_entry_proxy.rb → control_proxy/message_box/msg_box_proxy.rb} +8 -6
  58. data/lib/glimmer/libui/{time_picker_proxy.rb → control_proxy/message_box.rb} +9 -10
  59. data/lib/glimmer/libui/{rectangle.rb → control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb} +6 -8
  60. data/lib/glimmer/libui/{progress_bar_column_proxy.rb → control_proxy/multiline_entry_proxy.rb} +10 -11
  61. data/lib/glimmer/libui/control_proxy/path_proxy.rb +169 -0
  62. data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +45 -0
  63. data/lib/glimmer/libui/{button_column_proxy.rb → control_proxy/tab_item_proxy.rb} +37 -40
  64. data/lib/glimmer/libui/control_proxy/table_proxy.rb +182 -0
  65. data/lib/glimmer/libui/{transformable.rb → control_proxy/transformable.rb} +3 -1
  66. data/lib/glimmer/libui/control_proxy/window_proxy.rb +128 -0
  67. data/lib/glimmer/libui/control_proxy.rb +35 -8
  68. data/lib/glimmer/libui/{arc.rb → shape/arc.rb} +13 -11
  69. data/lib/glimmer/libui/shape/bezier.rb +38 -0
  70. data/lib/glimmer/libui/{figure.rb → shape/figure.rb} +23 -21
  71. data/lib/glimmer/libui/{line.rb → shape/line.rb} +9 -7
  72. data/lib/glimmer/libui/{bezier.rb → shape/rectangle.rb} +9 -7
  73. data/lib/glimmer/libui/{square.rb → shape/square.rb} +9 -7
  74. data/lib/glimmer/libui/shape.rb +8 -6
  75. data/lib/glimmer/libui.rb +43 -1
  76. data/lib/glimmer-dsl-libui.rb +1 -0
  77. metadata +72 -55
  78. data/lib/glimmer/libui/about_menu_item_proxy.rb +0 -37
  79. data/lib/glimmer/libui/area_proxy.rb +0 -115
  80. data/lib/glimmer/libui/check_menu_item_proxy.rb +0 -37
  81. data/lib/glimmer/libui/checkbox_text_column_proxy.rb +0 -76
  82. data/lib/glimmer/libui/color_button_proxy.rb +0 -116
  83. data/lib/glimmer/libui/column.rb +0 -51
  84. data/lib/glimmer/libui/date_time_picker_proxy.rb +0 -68
  85. data/lib/glimmer/libui/font_button_proxy.rb +0 -68
  86. data/lib/glimmer/libui/image_column_proxy.rb +0 -40
  87. data/lib/glimmer/libui/image_text_column_proxy.rb +0 -44
  88. data/lib/glimmer/libui/label_proxy.rb +0 -41
  89. data/lib/glimmer/libui/matrix_proxy.rb +0 -145
  90. data/lib/glimmer/libui/menu_proxy.rb +0 -41
  91. data/lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb +0 -32
  92. data/lib/glimmer/libui/path_proxy.rb +0 -166
  93. data/lib/glimmer/libui/preferences_menu_item_proxy.rb +0 -37
  94. data/lib/glimmer/libui/separator_menu_item_proxy.rb +0 -37
  95. data/lib/glimmer/libui/tab_item_proxy.rb +0 -67
  96. data/lib/glimmer/libui/table_proxy.rb +0 -180
  97. data/lib/glimmer/libui/text_column_proxy.rb +0 -42
  98. data/lib/glimmer/libui/window_proxy.rb +0 -126
@@ -1,116 +0,0 @@
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 color button objects
27
- #
28
- # Follows the Proxy Design Pattern
29
- class ColorButtonProxy < ControlProxy
30
- def color(value = nil)
31
- # TODO support hex color value
32
- if value.nil?
33
- @red ||= Fiddle::Pointer.malloc(8) # double
34
- @green ||= Fiddle::Pointer.malloc(8) # double
35
- @blue ||= Fiddle::Pointer.malloc(8) # double
36
- @alpha ||= Fiddle::Pointer.malloc(8) # double
37
- ::LibUI.color_button_color(@libui, @red, @green, @blue, @alpha)
38
- {
39
- r: @red[0, 8].unpack1('d') * 255.0,
40
- g: @green[0, 8].unpack1('d') * 255.0,
41
- b: @blue[0, 8].unpack1('d') * 255.0,
42
- a: @alpha[0, 8].unpack1('d')
43
- }
44
- else
45
- current_color = color
46
- value = Glimmer::LibUI.hex_to_rgb(value)
47
- value[:r] ||= current_color[:r]
48
- value[:g] ||= current_color[:g]
49
- value[:b] ||= current_color[:b]
50
- value[:a] ||= current_color[:a]
51
- ::LibUI.color_button_set_color(@libui, value[:r].to_f / 255.0, value[:g].to_f / 255.0, value[:b].to_f / 255.0, value[:a])
52
- end
53
- end
54
-
55
- def red(value = nil)
56
- if value.nil?
57
- color[:r]
58
- else
59
- self.color = {r: value}
60
- end
61
- end
62
- alias red= red
63
- alias set_red red
64
- alias r red
65
- alias r= red
66
- alias set_r red
67
-
68
- def green(value = nil)
69
- if value.nil?
70
- color[:g]
71
- else
72
- self.color = {g: value}
73
- end
74
- end
75
- alias green= green
76
- alias set_green green
77
- alias g green
78
- alias g= green
79
- alias set_g green
80
-
81
- def blue(value = nil)
82
- if value.nil?
83
- color[:b]
84
- else
85
- self.color = {b: value}
86
- end
87
- end
88
- alias blue= blue
89
- alias set_blue blue
90
- alias b blue
91
- alias b= blue
92
- alias set_b blue
93
-
94
- def alpha(value = nil)
95
- if value.nil?
96
- color[:a]
97
- else
98
- self.color = {a: value}
99
- end
100
- end
101
- alias alpha= alpha
102
- alias set_alpha alpha
103
- alias a alpha
104
- alias a= alpha
105
- alias set_a alpha
106
-
107
- def destroy
108
- Fiddle.free @red unless @red.nil?
109
- Fiddle.free @green unless @green.nil?
110
- Fiddle.free @blue unless @blue.nil?
111
- Fiddle.free @alpha unless @alpha.nil?
112
- super
113
- end
114
- end
115
- end
116
- end
@@ -1,51 +0,0 @@
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
- module Glimmer
23
- module LibUI
24
- # Common logic for all column proxy objects
25
- module Column
26
- def initialize(keyword, parent, args, &block)
27
- @keyword = keyword
28
- @parent_proxy = parent
29
- @args = args
30
- @block = block
31
- @enabled = true
32
- post_add_content if @block.nil?
33
- end
34
-
35
- def name
36
- @args.first
37
- end
38
-
39
- # column index used in table append column API call
40
- # expanded to ensure DualColumn index accounts for two columns acting as one
41
- def column_index
42
- @column_index ||= @parent_proxy.send(:next_column_index)
43
- end
44
-
45
- # actual index within table columns (disregarding nil fillings that account for DualColumn instances)
46
- def index
47
- @parent_proxy.columns.compact.index(self)
48
- end
49
- end
50
- end
51
- end
@@ -1,68 +0,0 @@
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 date time picker objects
27
- #
28
- # Follows the Proxy Design Pattern
29
- class DateTimePickerProxy < ControlProxy
30
- def libui_api_keyword
31
- 'date_time_picker'
32
- end
33
-
34
- def time(value = nil)
35
- @time ||= ::LibUI::FFI::TM.malloc
36
- ::LibUI.date_time_picker_time(@libui, @time)
37
- if value.nil?
38
- {
39
- sec: @time.tm_sec,
40
- min: @time.tm_min,
41
- hour: @time.tm_hour,
42
- mday: @time.tm_mday,
43
- mon: @time.tm_mon + 1,
44
- year: @time.tm_year + 1900,
45
- wday: @time.tm_wday + 1,
46
- yday: @time.tm_yday + 1,
47
- dst: @time.tm_isdst == 1
48
- }
49
- else
50
- @time.tm_sec = value[:sec] unless value[:sec].nil?
51
- @time.tm_min = value[:min] unless value[:min].nil?
52
- @time.tm_hour = value[:hour] unless value[:hour].nil?
53
- @time.tm_mday = value[:mday] unless value[:mday].nil?
54
- @time.tm_mon = value[:mon] - 1 unless value[:mon].nil?
55
- @time.tm_year = value[:year] - 1900 unless value[:year].nil?
56
- ::LibUI.date_time_picker_set_time(@libui, @time)
57
- end
58
- end
59
- alias set_time time
60
- alias time= time
61
-
62
- def destroy
63
- Fiddle.free @time unless @time.nil?
64
- super
65
- end
66
- end
67
- end
68
- end
@@ -1,68 +0,0 @@
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
@@ -1,40 +0,0 @@
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
- require 'glimmer/libui/column'
24
-
25
- module Glimmer
26
- module LibUI
27
- # Proxy for LibUI image column objects
28
- #
29
- # Follows the Proxy Design Pattern
30
- class ImageColumnProxy < ControlProxy
31
- include Column
32
-
33
- private
34
-
35
- def build_control
36
- @parent_proxy.append_image_column(name, column_index)
37
- end
38
- end
39
- end
40
- end
@@ -1,44 +0,0 @@
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
- require 'glimmer/libui/column'
24
- require 'glimmer/libui/dual_column'
25
- require 'glimmer/libui/editable_column'
26
-
27
- module Glimmer
28
- module LibUI
29
- # Proxy for LibUI image text column objects
30
- #
31
- # Follows the Proxy Design Pattern
32
- class ImageTextColumnProxy < ControlProxy
33
- include Column
34
- include DualColumn
35
- include EditableColumn
36
-
37
- private
38
-
39
- def build_control
40
- @parent_proxy.append_image_text_column(name, column_index, second_column_index, editable_value)
41
- end
42
- end
43
- end
44
- end
@@ -1,41 +0,0 @@
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 label objects
27
- #
28
- # Follows the Proxy Design Pattern
29
- class LabelProxy < ControlProxy
30
- DEFAULT_TEXT = ''
31
-
32
- private
33
-
34
- def build_control
35
- construction_args = @args.dup
36
- construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
37
- @libui = ControlProxy.new_control(@keyword, construction_args)
38
- end
39
- end
40
- end
41
- end
@@ -1,145 +0,0 @@
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 matrix objects
27
- #
28
- # Follows the Proxy Design Pattern
29
- class MatrixProxy < ControlProxy
30
- def libui_api_keyword
31
- 'draw_matrix'
32
- end
33
-
34
- def clone
35
- MatrixProxy.new('matrix', nil, [@libui.M11, @libui.M12, @libui.M21, @libui.M22, @libui.M31, @libui.M32])
36
- end
37
-
38
- def dup
39
- clone
40
- end
41
-
42
- def m11(value = nil)
43
- if value.nil?
44
- @libui.M11
45
- else
46
- @libui.M11 = value.to_f
47
- end
48
- end
49
- alias m11= m11
50
- alias set_m11 m11
51
-
52
- def m12(value = nil)
53
- if value.nil?
54
- @libui.M12
55
- else
56
- @libui.M12 = value.to_f
57
- end
58
- end
59
- alias m12= m12
60
- alias set_m12 m12
61
-
62
- def m21(value = nil)
63
- if value.nil?
64
- @libui.M21
65
- else
66
- @libui.M21 = value.to_f
67
- end
68
- end
69
- alias m21= m21
70
- alias set_m21 m21
71
-
72
- def m22(value = nil)
73
- if value.nil?
74
- @libui.M22
75
- else
76
- @libui.M22 = value.to_f
77
- end
78
- end
79
- alias m22= m22
80
- alias set_m22 m22
81
-
82
- def m31(value = nil)
83
- if value.nil?
84
- @libui.M31
85
- else
86
- @libui.M31 = value.to_f
87
- end
88
- end
89
- alias m31= m31
90
- alias set_m31 m31
91
-
92
- def m32(value = nil)
93
- if value.nil?
94
- @libui.M32
95
- else
96
- @libui.M32 = value.to_f
97
- end
98
- end
99
- alias m32= m32
100
- alias set_m32 m32
101
-
102
- def identity
103
- set_identity
104
- end
105
-
106
- def rotate(x = 0, y = 0, degrees)
107
- super(x, y, (Math::PI*2.0/360.0)*degrees)
108
- end
109
-
110
- def scale(x_center = 0, y_center = 0, x, y)
111
- super
112
- end
113
-
114
- def skew(x = 0, y = 0, x_amount, y_amount)
115
- super
116
- end
117
-
118
- def multiply(matrix)
119
- super(matrix.respond_to?(:libui) ? matrix.libui : matrix)
120
- end
121
-
122
- def invertible
123
- Glimmer::LibUI.integer_to_boolean(super, allow_nil: false)
124
- end
125
- alias invertible? invertible
126
-
127
- private
128
-
129
- def build_control
130
- @libui = ::LibUI::FFI::DrawMatrix.malloc
131
- if @args.empty?
132
- set_identity
133
- else
134
- @libui.M11 = @args[0].to_f
135
- @libui.M12 = @args[1].to_f
136
- @libui.M21 = @args[2].to_f
137
- @libui.M22 = @args[3].to_f
138
- @libui.M31 = @args[4].to_f
139
- @libui.M32 = @args[5].to_f
140
- end
141
- end
142
- end
143
- TransformProxy = MatrixProxy # alias
144
- end
145
- end
@@ -1,41 +0,0 @@
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 menu objects
27
- #
28
- # Follows the Proxy Design Pattern
29
- class MenuProxy < ControlProxy
30
- DEFAULT_TEXT = ''
31
-
32
- private
33
-
34
- def build_control
35
- construction_args = @args.dup
36
- construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
37
- @libui = ControlProxy.new_control(@keyword, construction_args)
38
- end
39
- end
40
- end
41
- end
@@ -1,32 +0,0 @@
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