glimmer-dsl-libui 0.2.3 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
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/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/triple_column'
25
+ require 'glimmer/libui/control_proxy/editable_column'
26
+
27
+ module Glimmer
28
+ module LibUI
29
+ class ControlProxy
30
+ module Column
31
+ # Proxy for LibUI checkbox text color column objects
32
+ #
33
+ # Follows the Proxy Design Pattern
34
+ class CheckboxTextColorColumnProxy < ControlProxy
35
+ include Column
36
+ include TripleColumn
37
+ include EditableColumn
38
+
39
+ def editable_checkbox(value = nil)
40
+ if value.nil?
41
+ @editable_checkbox = false if @editable_checkbox.nil?
42
+ @editable_checkbox
43
+ else
44
+ @editable_checkbox = !!value
45
+ end
46
+ end
47
+ alias editable_checkbox= editable_checkbox
48
+ alias set_editable_checkbox editable_checkbox
49
+ alias editable_checkbox? editable_checkbox
50
+
51
+ def editable_text(value = nil)
52
+ if value.nil?
53
+ @editable_text = false if @editable_text.nil?
54
+ @editable_text
55
+ else
56
+ @editable_text = !!value
57
+ end
58
+ end
59
+ alias editable_text= editable_text
60
+ alias set_editable_text editable_text
61
+ alias editable_text? editable_text
62
+
63
+ private
64
+
65
+ def build_control
66
+ table_text_column_optional_params = ::LibUI::FFI::TableTextColumnOptionalParams.malloc
67
+ table_text_column_optional_params.ColorModelColumn = third_column_index
68
+ @parent_proxy.append_checkbox_text_column(name, column_index, editable_checkbox_value, second_column_index, editable_text_value, table_text_column_optional_params)
69
+ end
70
+
71
+ def editable_checkbox_value
72
+ (@parent_proxy.editable? || editable? || editable_checkbox?) ? -2 : -1
73
+ end
74
+
75
+ def editable_text_value
76
+ (@parent_proxy.editable? || editable? || editable_text?) ? -2 : -1
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,50 @@
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/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/triple_column'
25
+ require 'glimmer/libui/control_proxy/editable_column'
26
+
27
+ module Glimmer
28
+ module LibUI
29
+ class ControlProxy
30
+ module Column
31
+ # Proxy for LibUI image text color column objects
32
+ #
33
+ # Follows the Proxy Design Pattern
34
+ class ImageTextColorColumnProxy < ControlProxy
35
+ include Column
36
+ include TripleColumn
37
+ include EditableColumn
38
+
39
+ private
40
+
41
+ def build_control
42
+ table_text_column_optional_params = ::LibUI::FFI::TableTextColumnOptionalParams.malloc
43
+ table_text_column_optional_params.ColorModelColumn = third_column_index
44
+ @parent_proxy.append_image_text_column(name, column_index, second_column_index, editable_value, table_text_column_optional_params)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,50 @@
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/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/dual_column'
25
+ require 'glimmer/libui/control_proxy/editable_column'
26
+
27
+ module Glimmer
28
+ module LibUI
29
+ class ControlProxy
30
+ module Column
31
+ # Proxy for LibUI text color column objects
32
+ #
33
+ # Follows the Proxy Design Pattern
34
+ class TextColorColumnProxy < ControlProxy
35
+ include Column
36
+ include DualColumn
37
+ include EditableColumn
38
+
39
+ private
40
+
41
+ def build_control
42
+ table_text_column_optional_params = ::LibUI::FFI::TableTextColumnOptionalParams.malloc
43
+ table_text_column_optional_params.ColorModelColumn = second_column_index
44
+ @parent_proxy.append_text_column(name, column_index, editable_value, table_text_column_optional_params)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -28,6 +28,20 @@ module Glimmer
28
28
  #
29
29
  # Follows the Proxy Design Pattern
30
30
  class ComboboxProxy < ControlProxy
31
+ def selected(value = nil)
32
+ if value.nil?
33
+ super()
34
+ else
35
+ if value.is_a?(String)
36
+ super(items.index(value).to_i)
37
+ else
38
+ super
39
+ end
40
+ end
41
+ end
42
+ alias selected= selected
43
+ alias set_selected selected
44
+
31
45
  def items(*values)
32
46
  values = values.first if values.first.is_a?(Array)
33
47
  if values.empty?
@@ -39,6 +53,10 @@ module Glimmer
39
53
  end
40
54
  alias set_items items
41
55
  alias items= items
56
+
57
+ def selected_item
58
+ items[selected]
59
+ end
42
60
  end
43
61
  end
44
62
  end
@@ -38,6 +38,7 @@ module Glimmer
38
38
  private
39
39
 
40
40
  def editable_value
41
+ # TODO consider relying on enum symbol :table_model_column
41
42
  (@parent_proxy.editable? || editable?) ? -2 : -1
42
43
  end
43
44
  end
@@ -0,0 +1,53 @@
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/control_proxy/area_proxy'
24
+ require 'glimmer/libui/parent'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ class ControlProxy
29
+ # Proxy for LibUI open type features objects
30
+ #
31
+ # Follows the Proxy Design Pattern
32
+ class OpenTypeFeaturesProxy < ControlProxy
33
+ include Parent
34
+
35
+ def destroy
36
+ ::LibUI.free_open_type_features(@libui)
37
+ @parent_proxy&.children&.delete(self)
38
+ ControlProxy.control_proxies.delete(self)
39
+ end
40
+
41
+ def redraw
42
+ @parent_proxy.redraw
43
+ end
44
+
45
+ private
46
+
47
+ def build_control
48
+ @libui = ::LibUI.new_open_type_features
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,59 @@
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/control_proxy/area_proxy'
24
+ require 'glimmer/libui/parent'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ class ControlProxy
29
+ # Proxy for LibUI open type tag objects
30
+ #
31
+ # Follows the Proxy Design Pattern
32
+ class OpenTypeTagProxy < ControlProxy
33
+ def destroy
34
+ @parent_proxy&.children&.delete(self)
35
+ ControlProxy.control_proxies.delete(self)
36
+ end
37
+
38
+ def redraw
39
+ @parent_proxy.redraw
40
+ end
41
+
42
+ private
43
+
44
+ def build_control
45
+ tag_args = @args.dup
46
+ tag_args[0] = ordinalize(tag_args[0])
47
+ tag_args[1] = ordinalize(tag_args[1])
48
+ tag_args[2] = ordinalize(tag_args[2])
49
+ tag_args[3] = ordinalize(tag_args[3])
50
+ ::LibUI.open_type_features_add(@parent_proxy.libui, *tag_args)
51
+ end
52
+
53
+ def ordinalize(arg)
54
+ arg.is_a?(String) ? arg.ord : arg
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -58,8 +58,16 @@ module Glimmer
58
58
 
59
59
  def post_initialize_child(child)
60
60
  @columns << child
61
- # add an extra complementary nil column if it is a dual column (i.e. ImageTextColumnProxy or CheckboxTextColumnProxy
62
- @columns << nil if child.is_a?(DualColumn)
61
+ # add extra complementary columns (:text, :color) if it is a dual/triple column (i.e. ImageTextColumnProxy or CheckboxTextColumnProxy
62
+ case child
63
+ when Column::ImageTextColumnProxy, Column::CheckboxTextColumnProxy
64
+ @columns << :text
65
+ when Column::TextColorColumnProxy
66
+ @columns << :color
67
+ when Column::CheckboxTextColorColumnProxy, Column::ImageTextColorColumnProxy
68
+ @columns << :text
69
+ @columns << :color
70
+ end
63
71
  end
64
72
 
65
73
  def destroy
@@ -119,27 +127,36 @@ module Glimmer
119
127
  @model_handler = ::LibUI::FFI::TableModelHandler.malloc
120
128
  @model_handler.NumColumns = fiddle_closure_block_caller(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : 1}.sum }
121
129
  @model_handler.ColumnType = fiddle_closure_block_caller(4, [1, 1, 4]) do |_, _, column|
130
+ # TODO consider refactoring to use Glimmer::LibUI.enum_symbols(:table_value_type)
122
131
  case @columns[column]
123
- when Column::TextColumnProxy, Column::ButtonColumnProxy, NilClass
132
+ when Column::TextColumnProxy, Column::ButtonColumnProxy, Column::TextColorColumnProxy, :text
124
133
  0
125
- when Column::ImageColumnProxy, Column::ImageTextColumnProxy
134
+ when Column::ImageColumnProxy, Column::ImageTextColumnProxy, Column::ImageTextColorColumnProxy
126
135
  1
127
- when Column::CheckboxColumnProxy, Column::CheckboxTextColumnProxy, Column::ProgressBarColumnProxy
136
+ when Column::CheckboxColumnProxy, Column::CheckboxTextColumnProxy, Column::CheckboxTextColorColumnProxy, Column::ProgressBarColumnProxy
128
137
  2
138
+ when Column::BackgroundColorColumnProxy, :color
139
+ 3
129
140
  end
130
141
  end
131
142
  @model_handler.NumRows = fiddle_closure_block_caller(4) { cell_rows.count }
132
143
  @model_handler.CellValue = fiddle_closure_block_caller(1, [1, 1, 4, 4]) do |_, _, row, column|
133
144
  the_cell_rows = expanded_cell_rows
134
145
  case @columns[column]
135
- when Column::TextColumnProxy, Column::ButtonColumnProxy, NilClass
146
+ when Column::TextColumnProxy, Column::ButtonColumnProxy, Column::TextColorColumnProxy, :text
136
147
  ::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
137
- when Column::ImageColumnProxy, Column::ImageTextColumnProxy
148
+ when Column::ImageColumnProxy, Column::ImageTextColumnProxy, Column::ImageTextColorColumnProxy
138
149
  ::LibUI.new_table_value_image((expanded_cell_rows[row] && (expanded_cell_rows[row][column].respond_to?(:libui) ? expanded_cell_rows[row][column].libui : expanded_cell_rows[row][column])))
139
- when Column::CheckboxColumnProxy, Column::CheckboxTextColumnProxy
150
+ when Column::CheckboxColumnProxy, Column::CheckboxTextColumnProxy, Column::CheckboxTextColorColumnProxy
140
151
  ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column] == 1 || expanded_cell_rows[row][column].to_s.strip.downcase == 'true' ? 1 : 0)))
141
152
  when Column::ProgressBarColumnProxy
142
153
  ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column].to_i)))
154
+ when Column::BackgroundColorColumnProxy
155
+ background_color = Glimmer::LibUI.interpret_color(expanded_cell_rows[row] && expanded_cell_rows[row][column])
156
+ ::LibUI.new_table_value_color(background_color[:r] / 255.0, background_color[:g] / 255.0, background_color[:b] / 255.0, background_color[:a] || 1.0)
157
+ when :color
158
+ color = Glimmer::LibUI.interpret_color(expanded_cell_rows[row] && expanded_cell_rows[row][column])
159
+ ::LibUI.new_table_value_color(color[:r] / 255.0, color[:g] / 255.0, color[:b] / 255.0, color[:a] || 1.0)
143
160
  end
144
161
  end
145
162
  @model_handler.SetCellValue = fiddle_closure_block_caller(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
@@ -148,7 +165,7 @@ module Glimmer
148
165
  column = @columns[column].index
149
166
  @cell_rows[row] ||= []
150
167
  @cell_rows[row][column] = ::LibUI.table_value_string(val).to_s
151
- when NilClass
168
+ when :text
152
169
  column = @columns[column - 1].index
153
170
  @cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
154
171
  when Column::ButtonColumnProxy
@@ -162,13 +179,16 @@ module Glimmer
162
179
 
163
180
  @model = ::LibUI.new_table_model(@model_handler)
164
181
 
182
+ # figure out and reserve column indices for columns
183
+ @columns.each { |column| column.respond_to?(:column_index) && column.column_index }
184
+
165
185
  @table_params = ::LibUI::FFI::TableParams.malloc
166
186
  @table_params.Model = @model
167
- @table_params.RowBackgroundColorModelColumn = -1
187
+ @table_params.RowBackgroundColorModelColumn = @columns.find {|column| column.is_a?(Column::BackgroundColorColumnProxy)}&.column_index || -1
168
188
 
169
189
  @libui = ControlProxy.new_control(@keyword, [@table_params])
170
190
  @libui.tap do
171
- @columns.each {|column| column&.send(:build_control) }
191
+ @columns.each {|column| column.respond_to?(:build_control, true) && column.send(:build_control) }
172
192
  end
173
193
  end
174
194
 
@@ -51,10 +51,12 @@ module Glimmer
51
51
  end
52
52
 
53
53
  def draw(area_draw_params)
54
+ reset_attributed_string
54
55
  children.dup.each {|child| child.draw(area_draw_params)}
55
56
  build_control
56
57
  ::LibUI.draw_text(area_draw_params[:context], @libui, x, y)
57
58
  ::LibUI.draw_free_text_layout(@libui)
59
+ ::LibUI.free_attributed_string(@attributed_string)
58
60
  end
59
61
 
60
62
  def destroy
@@ -88,23 +90,35 @@ module Glimmer
88
90
 
89
91
  def width(value = nil)
90
92
  if value.nil?
91
- @width ||= args[2] || (AreaProxy.current_area_draw_params && AreaProxy.current_area_draw_params[:width])
93
+ @width ||= args[2] || (AreaProxy.current_area_draw_params && AreaProxy.current_area_draw_params[:area_width])
92
94
  else
93
95
  @width = value
96
+ redraw
94
97
  end
95
98
  end
96
99
  alias width= width
97
100
  alias set_width width
98
101
 
99
102
  def attributed_string
100
- @attributed_string ||= ::LibUI.new_attributed_string('')
103
+ @attributed_string ||= reset_attributed_string
104
+ end
105
+
106
+ def reset_attributed_string
107
+ @attributed_string = ::LibUI.new_attributed_string('')
101
108
  end
102
109
 
103
110
  def default_font(value = nil)
104
111
  if value.nil?
105
- @default_font ||= {}
112
+ @default_font ||= {
113
+ family: 'Helvetica',
114
+ size: 12.0,
115
+ weight: :normal,
116
+ italic: :normal,
117
+ stretch: :normal,
118
+ }
106
119
  else
107
120
  @default_font = value
121
+ redraw
108
122
  end
109
123
  end
110
124
  alias default_font= default_font
@@ -122,9 +136,10 @@ module Glimmer
122
136
 
123
137
  def align(value = nil)
124
138
  if value.nil?
125
- @align ||= {}
139
+ @align
126
140
  else
127
141
  @align = value
142
+ redraw
128
143
  end
129
144
  end
130
145
  alias align= align
@@ -135,7 +150,7 @@ module Glimmer
135
150
  @draw_text_layout_params.String = attributed_string
136
151
  @draw_text_layout_params.DefaultFont = default_font_descriptor
137
152
  @draw_text_layout_params.Width = width
138
- @draw_text_layout_params.Align = Glimmer::LibUI.enum_symbol_to_value(:draw_text_align, align, default_symbol: :center)
153
+ @draw_text_layout_params.Align = Glimmer::LibUI.enum_symbol_to_value(:draw_text_align, align, default_symbol: :left)
139
154
  @draw_text_layout_params
140
155
  end
141
156
 
@@ -0,0 +1,45 @@
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
+ class ControlProxy
25
+ # A dual column is one that represents two values (e.g. image and text or checkbox and text)
26
+ # It is meant to be included in a column proxy class that already includes Column
27
+ module TripleColumn
28
+ def second_column_index
29
+ column_index + 1
30
+ end
31
+
32
+ def third_column_index
33
+ column_index + 2
34
+ end
35
+
36
+ def column_index
37
+ @column_index ||= @parent_proxy.send(:next_column_index).tap do
38
+ @parent_proxy.send(:next_column_index)
39
+ @parent_proxy.send(:next_column_index)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/glimmer/libui.rb CHANGED
@@ -115,7 +115,7 @@ module Glimmer
115
115
  if enum_symbol.is_a?(Integer)
116
116
  enum_symbol
117
117
  elsif enum_symbols(enum_name).include?(enum_symbol.to_s.to_sym)
118
- enum_symbol_values(enum_name)[enum_symbol]
118
+ enum_symbol_values(enum_name)[enum_symbol.to_s.to_sym]
119
119
  elsif default_symbol
120
120
  enum_symbol_to_value(enum_name, default_symbol)
121
121
  else
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.2.3
4
+ version: 0.2.7
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-10-06 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -216,11 +216,13 @@ files:
216
216
  - examples/basic_area2.rb
217
217
  - examples/basic_button.rb
218
218
  - examples/basic_draw_text.rb
219
+ - examples/basic_draw_text2.rb
219
220
  - examples/basic_entry.rb
220
221
  - examples/basic_table.rb
221
222
  - examples/basic_table_button.rb
222
223
  - examples/basic_table_checkbox.rb
223
224
  - examples/basic_table_checkbox_text.rb
225
+ - examples/basic_table_color.rb
224
226
  - examples/basic_table_image.rb
225
227
  - examples/basic_table_image_text.rb
226
228
  - examples/basic_table_progress_bar.rb
@@ -230,6 +232,8 @@ files:
230
232
  - examples/color_button.rb
231
233
  - examples/color_the_circles.rb
232
234
  - examples/control_gallery.rb
235
+ - examples/custom_draw_text.rb
236
+ - examples/custom_draw_text2.rb
233
237
  - examples/date_time_picker.rb
234
238
  - examples/dynamic_area.rb
235
239
  - examples/dynamic_area2.rb
@@ -246,6 +250,7 @@ files:
246
250
  - examples/simple_notepad.rb
247
251
  - examples/timer.rb
248
252
  - glimmer-dsl-libui.gemspec
253
+ - icons/glimmer.png
249
254
  - lib/glimmer-dsl-libui.rb
250
255
  - lib/glimmer/dsl/libui/control_expression.rb
251
256
  - lib/glimmer/dsl/libui/dsl.rb
@@ -270,12 +275,16 @@ files:
270
275
  - lib/glimmer/libui/control_proxy/checkbox_proxy.rb
271
276
  - lib/glimmer/libui/control_proxy/color_button_proxy.rb
272
277
  - lib/glimmer/libui/control_proxy/column.rb
278
+ - lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb
273
279
  - lib/glimmer/libui/control_proxy/column/button_column_proxy.rb
274
280
  - lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb
281
+ - lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb
275
282
  - lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb
276
283
  - lib/glimmer/libui/control_proxy/column/image_column_proxy.rb
284
+ - lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb
277
285
  - lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb
278
286
  - lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb
287
+ - lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb
279
288
  - lib/glimmer/libui/control_proxy/column/text_column_proxy.rb
280
289
  - lib/glimmer/libui/control_proxy/combobox_proxy.rb
281
290
  - lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb
@@ -309,12 +318,15 @@ files:
309
318
  - lib/glimmer/libui/control_proxy/message_box/msg_box_proxy.rb
310
319
  - lib/glimmer/libui/control_proxy/multiline_entry_proxy.rb
311
320
  - lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb
321
+ - lib/glimmer/libui/control_proxy/open_type_features_proxy.rb
322
+ - lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb
312
323
  - lib/glimmer/libui/control_proxy/path_proxy.rb
313
324
  - lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb
314
325
  - lib/glimmer/libui/control_proxy/tab_item_proxy.rb
315
326
  - lib/glimmer/libui/control_proxy/table_proxy.rb
316
327
  - lib/glimmer/libui/control_proxy/text_proxy.rb
317
328
  - lib/glimmer/libui/control_proxy/transformable.rb
329
+ - lib/glimmer/libui/control_proxy/triple_column.rb
318
330
  - lib/glimmer/libui/control_proxy/window_proxy.rb
319
331
  - lib/glimmer/libui/parent.rb
320
332
  - lib/glimmer/libui/shape.rb