glimmer-dsl-libui 0.2.2 → 0.2.6

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,65 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ # Michael Ende (1929-1995)
4
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5
+ # The English version, translated by Ralph Manheim, was published in 1983.
6
+ class BasicDrawText
7
+ include Glimmer
8
+
9
+ def alternating_color_string(initial: false, &block)
10
+ @index = 0 if initial
11
+ @index += 1
12
+ string {
13
+ if @index.odd?
14
+ color r: 128, g: 0, b: 64, a: 0.7
15
+ else
16
+ color r: 0, g: 128, b: 0, a: 0.7
17
+ end
18
+
19
+ block.call + "\n\n"
20
+ }
21
+ end
22
+
23
+ def launch
24
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 400) {
25
+ margined true
26
+
27
+ area {
28
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
29
+ # align :left # default alignment
30
+ default_font family: 'Georgia', size: 13, weight: :medium, italic: :normal, stretch: :normal
31
+
32
+ alternating_color_string(initial: true) {
33
+ ' At last Ygramul sensed that something was coming toward ' \
34
+ 'her. With the speed of lightning, she turned about, confronting ' \
35
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
36
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
37
+ }
38
+ alternating_color_string {
39
+ ' A cry of fear escaped Bastian. '
40
+ }
41
+ alternating_color_string {
42
+ ' A cry of terror passed through the ravine and echoed from ' \
43
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
44
+ 'someone else had arrived, for that sound could not have been ' \
45
+ 'made by the boy who stood there as though paralyzed with ' \
46
+ 'horror. '
47
+ }
48
+ alternating_color_string {
49
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
50
+ "But that's not possible. "
51
+ }
52
+ alternating_color_string {
53
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
54
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
55
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
56
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
57
+ 'words. '
58
+ }
59
+ }
60
+ }
61
+ }.show
62
+ end
63
+ end
64
+
65
+ BasicDrawText.new.launch
@@ -0,0 +1,68 @@
1
+
2
+ require 'glimmer-dsl-libui'
3
+
4
+ # Michael Ende (1929-1995)
5
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
6
+ # The English version, translated by Ralph Manheim, was published in 1983.
7
+ class BasicDrawText
8
+ include Glimmer
9
+
10
+ def alternating_color_string(initial: false, &block)
11
+ @index = 0 if initial
12
+ @index += 1
13
+ string {
14
+ if @index.odd?
15
+ color r: 128, g: 0, b: 64, a: 0.7
16
+ else
17
+ color r: 0, g: 128, b: 0, a: 0.7
18
+ end
19
+
20
+ block.call + "\n\n"
21
+ }
22
+ end
23
+
24
+ def launch
25
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 400) {
26
+ margined true
27
+
28
+ area {
29
+ on_draw do |area_draw_params|
30
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
31
+ # align :left # default alignment
32
+ default_font family: 'Georgia', size: 13, weight: :medium, italic: :normal, stretch: :normal
33
+
34
+ alternating_color_string(initial: true) {
35
+ ' At last Ygramul sensed that something was coming toward ' \
36
+ 'her. With the speed of lightning, she turned about, confronting ' \
37
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
38
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
39
+ }
40
+ alternating_color_string {
41
+ ' A cry of fear escaped Bastian. '
42
+ }
43
+ alternating_color_string {
44
+ ' A cry of terror passed through the ravine and echoed from ' \
45
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
46
+ 'someone else had arrived, for that sound could not have been ' \
47
+ 'made by the boy who stood there as though paralyzed with ' \
48
+ 'horror. '
49
+ }
50
+ alternating_color_string {
51
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
52
+ "But that's not possible. "
53
+ }
54
+ alternating_color_string {
55
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
56
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
57
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
58
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
59
+ 'words. '
60
+ }
61
+ }
62
+ end
63
+ }
64
+ }.show
65
+ end
66
+ end
67
+
68
+ BasicDrawText.new.launch
@@ -0,0 +1,106 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ # Michael Ende (1929-1995)
4
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5
+ # The English version, translated by Ralph Manheim, was published in 1983.
6
+ class CustomDrawText
7
+ include Glimmer
8
+
9
+ def launch
10
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
11
+ margined true
12
+
13
+ vertical_box {
14
+ form {
15
+ stretchy false
16
+
17
+ font_button { |fb|
18
+ label 'Font'
19
+
20
+ on_changed do
21
+ @string.font = fb.font
22
+ end
23
+ }
24
+ color_button { |cb|
25
+ label 'Color'
26
+
27
+ on_changed do
28
+ @string.color = cb.color
29
+ end
30
+ }
31
+ color_button { |cb|
32
+ label 'Background'
33
+
34
+ on_changed do
35
+ @string.background = cb.color
36
+ end
37
+ }
38
+ combobox { |c|
39
+ label 'Underline'
40
+ items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
41
+ selected 'None'
42
+
43
+ on_selected do
44
+ @string.underline = c.selected_item.underscore
45
+ end
46
+ }
47
+ combobox { |c|
48
+ label 'Underline Built-In Color'
49
+ items Glimmer::LibUI.enum_symbols(:underline_color).map(&:to_s).map(&:capitalize)
50
+ selected 'Custom'
51
+
52
+ on_selected do
53
+ @underline_custom_color_button.enabled = c.selected_item == 'Custom'
54
+ if c.selected_item == 'Custom'
55
+ @string.underline_color = @underline_custom_color_button.color
56
+ else
57
+ @string.underline_color = c.selected_item.underscore
58
+ @underline_custom_color_button.color = :black
59
+ end
60
+ end
61
+ }
62
+ @underline_custom_color_button = color_button {
63
+ label 'Underline Custom Color'
64
+
65
+ on_changed do
66
+ @string.underline_color = @underline_custom_color_button.color
67
+ end
68
+ }
69
+ }
70
+
71
+ area {
72
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
73
+ # align :left # default alignment
74
+
75
+ @string = string {
76
+ ' At last Ygramul sensed that something was coming toward ' \
77
+ 'her. With the speed of lightning, she turned about, confronting ' \
78
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
79
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. ' \
80
+ "\n\n" \
81
+ ' A cry of fear escaped Bastian. ' \
82
+ "\n\n" \
83
+ ' A cry of terror passed through the ravine and echoed from ' \
84
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
85
+ 'someone else had arrived, for that sound could not have been ' \
86
+ 'made by the boy who stood there as though paralyzed with ' \
87
+ 'horror. ' \
88
+ "\n\n" \
89
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
90
+ "But that's not possible. " \
91
+ "\n\n" \
92
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
93
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
94
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
95
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
96
+ 'words. ' \
97
+ "\n\n"
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }.show
103
+ end
104
+ end
105
+
106
+ CustomDrawText.new.launch
@@ -0,0 +1,120 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ # Michael Ende (1929-1995)
4
+ # The Neverending Story is a fantasy novel by German writer Michael Ende,
5
+ # The English version, translated by Ralph Manheim, was published in 1983.
6
+ class CustomDrawText
7
+ include Glimmer
8
+
9
+ def launch
10
+ window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
11
+ margined true
12
+
13
+ vertical_box {
14
+ form {
15
+ stretchy false
16
+
17
+ font_button { |fb|
18
+ label 'Font'
19
+
20
+ on_changed do
21
+ @font = fb.font
22
+ @area.queue_redraw_all
23
+ end
24
+ }
25
+ color_button { |cb|
26
+ label 'Color'
27
+
28
+ on_changed do
29
+ @color = cb.color
30
+ @area.queue_redraw_all
31
+ end
32
+ }
33
+ color_button { |cb|
34
+ label 'Background'
35
+
36
+ on_changed do
37
+ @background = cb.color
38
+ @area.queue_redraw_all
39
+ end
40
+ }
41
+ combobox { |c|
42
+ label 'Underline'
43
+ items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
44
+ selected 'None'
45
+
46
+ on_selected do
47
+ @underline = c.selected_item.underscore
48
+ @area.queue_redraw_all
49
+ end
50
+ }
51
+ combobox { |c|
52
+ label 'Underline Built-In Color'
53
+ items Glimmer::LibUI.enum_symbols(:underline_color).map(&:to_s).map(&:capitalize)
54
+ selected 'Custom'
55
+
56
+ on_selected do
57
+ @underline_custom_color_button.enabled = c.selected_item == 'Custom'
58
+ if c.selected_item == 'Custom'
59
+ @underline_color = @underline_custom_color_button.color
60
+ else
61
+ @underline_color = c.selected_item.underscore
62
+ @underline_custom_color_button.color = :black
63
+ end
64
+ @area.queue_redraw_all
65
+ end
66
+ }
67
+ @underline_custom_color_button = color_button {
68
+ label 'Underline Custom Color'
69
+
70
+ on_changed do
71
+ @underline_color = @underline_custom_color_button.color
72
+ @area.queue_redraw_all
73
+ end
74
+ }
75
+ }
76
+
77
+ @area = area {
78
+ on_draw do |area_draw_params|
79
+ text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
80
+ # align :left # default alignment
81
+
82
+ string {
83
+ font @font
84
+ color @color
85
+ background @background
86
+ underline @underline
87
+ underline_color @underline_color
88
+
89
+ ' At last Ygramul sensed that something was coming toward ' \
90
+ 'her. With the speed of lightning, she turned about, confronting ' \
91
+ 'Atreyu with an enormous steel-blue face. Her single eye had a ' \
92
+ 'vertical pupil, which stared at Atreyu with inconceivable malignancy. ' \
93
+ "\n\n" \
94
+ ' A cry of fear escaped Bastian. ' \
95
+ "\n\n" \
96
+ ' A cry of terror passed through the ravine and echoed from ' \
97
+ 'side to side. Ygramul turned her eye to left and right, to see if ' \
98
+ 'someone else had arrived, for that sound could not have been ' \
99
+ 'made by the boy who stood there as though paralyzed with ' \
100
+ 'horror. ' \
101
+ "\n\n" \
102
+ ' Could she have heard my cry? Bastion wondered in alarm. ' \
103
+ "But that's not possible. " \
104
+ "\n\n" \
105
+ ' And then Atreyu heard Ygramuls voice. It was very high ' \
106
+ 'and slightly hoarse, not at all the right kind of voice for that ' \
107
+ 'enormous face. Her lips did not move as she spoke. It was the ' \
108
+ 'buzzing of a great swarm of hornets that shaped itself into ' \
109
+ 'words. ' \
110
+ "\n\n"
111
+ }
112
+ }
113
+ end
114
+ }
115
+ }
116
+ }.show
117
+ end
118
+ end
119
+
120
+ CustomDrawText.new.launch
@@ -9,7 +9,7 @@ class TinyMidiPlayer
9
9
 
10
10
  def initialize
11
11
  @pid = nil
12
- @music_directory = File.expand_path(ARGV[0] || '~/Music/')
12
+ @music_directory = File.expand_path('../sounds', __dir__)
13
13
  @midi_files = Dir.glob(File.join(@music_directory, '**/*.mid'))
14
14
  .sort_by { |path| File.basename(path) }
15
15
  at_exit { stop_midi }
Binary file
@@ -40,7 +40,6 @@ module Glimmer
40
40
  super
41
41
  parent.post_add_content
42
42
  end
43
-
44
43
  end
45
44
  end
46
45
  end
@@ -22,6 +22,7 @@
22
22
  require 'glimmer/dsl/expression'
23
23
  require 'glimmer/libui/control_proxy'
24
24
  require 'glimmer/libui/shape'
25
+ require 'glimmer/libui/attributed_string'
25
26
 
26
27
  module Glimmer
27
28
  module DSL
@@ -30,7 +31,8 @@ module Glimmer
30
31
  def can_interpret?(parent, keyword, *args, &block)
31
32
  (
32
33
  parent.is_a?(Glimmer::LibUI::ControlProxy) or
33
- parent.is_a?(Glimmer::LibUI::Shape)
34
+ parent.is_a?(Glimmer::LibUI::Shape) or
35
+ parent.is_a?(Glimmer::LibUI::AttributedString)
34
36
  ) and
35
37
  block.nil? and
36
38
  parent.respond_to?(keyword, *args)
@@ -0,0 +1,48 @@
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/dsl/static_expression'
23
+ require 'glimmer/dsl/parent_expression'
24
+ require 'glimmer/libui/control_proxy/text_proxy'
25
+ require 'glimmer/libui/attributed_string'
26
+
27
+ module Glimmer
28
+ module DSL
29
+ module Libui
30
+ class StringExpression < StaticExpression
31
+ include ParentExpression
32
+
33
+ def can_interpret?(parent, keyword, *args, &block)
34
+ super and
35
+ parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy)
36
+ end
37
+
38
+ def interpret(parent, keyword, *args, &block)
39
+ Glimmer::LibUI::AttributedString.new(keyword, parent, args, &block)
40
+ end
41
+
42
+ def add_content(parent, keyword, *args, &block)
43
+ parent.post_add_content
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,176 @@
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
+ require 'glimmer/libui/control_proxy/transformable'
26
+
27
+ module Glimmer
28
+ module LibUI
29
+ class AttributedString
30
+ attr_accessor :string
31
+ attr_reader :block, :keyword, :parent_proxy, :args
32
+
33
+ def initialize(keyword, parent_proxy, args, &block)
34
+ @keyword = keyword
35
+ @parent_proxy = parent_proxy
36
+ @args = args
37
+ @string = @args.first || ''
38
+ @block = block
39
+ post_add_content if @block.nil?
40
+ end
41
+
42
+ def font(value = nil)
43
+ if value.nil?
44
+ @font
45
+ else
46
+ @font = value
47
+ redraw
48
+ end
49
+ end
50
+ alias font= font
51
+ alias set_font font
52
+
53
+ def color(value = nil)
54
+ if value.nil?
55
+ @color
56
+ else
57
+ @color = Glimmer::LibUI.interpret_color(value)
58
+ redraw
59
+ end
60
+ end
61
+ alias color= color
62
+ alias set_color color
63
+
64
+ def background(value = nil)
65
+ if value.nil?
66
+ @background
67
+ else
68
+ @background = Glimmer::LibUI.interpret_color(value)
69
+ redraw
70
+ end
71
+ end
72
+ alias background= background
73
+ alias set_background background
74
+
75
+ def underline(value = nil)
76
+ if value.nil?
77
+ @underline
78
+ else
79
+ @underline = value
80
+ redraw
81
+ end
82
+ end
83
+ alias underline= underline
84
+ alias set_underline underline
85
+
86
+ def underline_color(value = nil)
87
+ if value.nil?
88
+ @underline_color
89
+ else
90
+ @underline_color = value
91
+ redraw
92
+ end
93
+ end
94
+ alias underline_color= underline_color
95
+ alias set_underline_color underline_color
96
+
97
+ def open_type_features(value = nil)
98
+ if value.nil?
99
+ @open_type_features
100
+ else
101
+ @open_type_features = value
102
+ redraw
103
+ end
104
+ end
105
+ alias open_type_features= open_type_features
106
+ alias set_open_type_features open_type_features
107
+
108
+ def post_add_content
109
+ block_result = block&.call
110
+ @string = block_result if block_result.is_a?(String)
111
+ @parent_proxy&.post_initialize_child(self)
112
+ end
113
+
114
+ def post_initialize_child(child)
115
+ self.open_type_features = child if child.is_a?(Glimmer::LibUI::ControlProxy::OpenTypeFeaturesProxy)
116
+ end
117
+
118
+ def draw(area_draw_params)
119
+ @start = ::LibUI.attributed_string_len(@parent_proxy.attributed_string)
120
+ ::LibUI.attributed_string_append_unattributed(@parent_proxy.attributed_string, @string)
121
+ unless color.nil?
122
+ color_attribute = ::LibUI.new_color_attribute(@color[:r].to_f / 255.0, @color[:g].to_f / 255.0, @color[:b].to_f / 255.0, @color[:a] || 1.0)
123
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, @start, @start + @string.size)
124
+ end
125
+ unless background.nil?
126
+ background_attribute = ::LibUI.new_background_attribute(@background[:r].to_f / 255.0, @background[:g].to_f / 255.0, @background[:b].to_f / 255.0, @background[:a] || 1.0)
127
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, background_attribute, @start, @start + @string.size)
128
+ end
129
+ unless underline.nil?
130
+ underline_attribute = ::LibUI.new_underline_attribute(Glimmer::LibUI.enum_symbol_to_value(:underline, @underline))
131
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, underline_attribute, @start, @start + @string.size)
132
+ end
133
+ unless underline_color.nil?
134
+ if Glimmer::LibUI.enum_symbols(:underline_color).include?(underline_color.to_s.to_sym) && underline_color.to_s.to_sym != :custom
135
+ underline_color_attribute = ::LibUI.new_underline_color_attribute(Glimmer::LibUI.enum_symbol_to_value(:underline_color, @underline_color), 0, 0, 0, 0)
136
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, underline_color_attribute, @start, @start + @string.size)
137
+ else
138
+ the_color = Glimmer::LibUI.interpret_color(@underline_color)
139
+ underline_color_attribute = ::LibUI.new_underline_color_attribute(0, the_color[:r].to_f / 255.0, the_color[:g].to_f / 255.0, the_color[:b].to_f / 255.0, the_color[:a] || 1.0)
140
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, underline_color_attribute, @start, @start + @string.size)
141
+ end
142
+ end
143
+ unless font.nil?
144
+ family_attribute = ::LibUI.new_family_attribute(font[:family])
145
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, family_attribute, @start, @start + @string.size)
146
+ size_attribute = ::LibUI.new_size_attribute(font[:size])
147
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, size_attribute, @start, @start + @string.size)
148
+ weight_attribute = ::LibUI.new_weight_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_weight, font[:weight]))
149
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, weight_attribute, @start, @start + @string.size)
150
+ italic_attribute = ::LibUI.new_italic_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_italic, font[:italic]))
151
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, italic_attribute, @start, @start + @string.size)
152
+ stretch_attribute = ::LibUI.new_stretch_attribute(Glimmer::LibUI.enum_symbol_to_value(:text_stretch, font[:stretch]))
153
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, stretch_attribute, @start, @start + @string.size)
154
+ end
155
+ unless open_type_features.nil?
156
+ open_type_features_attribute = ::LibUI.new_features_attribute(open_type_features.libui)
157
+ ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, open_type_features_attribute, @start, @start + @string.size)
158
+ end
159
+ destroy if area_proxy.nil?
160
+ end
161
+
162
+ def destroy
163
+ open_type_features.destroy unless open_type_features.nil?
164
+ @parent_proxy&.children&.delete(self)
165
+ end
166
+
167
+ def redraw
168
+ area_proxy&.queue_redraw_all
169
+ end
170
+
171
+ def area_proxy
172
+ @parent_proxy.parent_proxy
173
+ end
174
+ end
175
+ end
176
+ end
@@ -180,7 +180,7 @@ module Glimmer
180
180
  end
181
181
 
182
182
  def ext_key_to_symbol(ext_key_value)
183
- Glimmer::LibUI.enum_symbols(:ext_key)[ext_key_value - 1].to_s.to_sym if ext_key_value > 0
183
+ Glimmer::LibUI.enum_value_to_symbol(:ext_key, ext_key_value)
184
184
  end
185
185
 
186
186
  def modifiers_to_symbols(modifiers_value)
@@ -29,7 +29,6 @@ module Glimmer
29
29
  # Follows the Proxy Design Pattern
30
30
  class ColorButtonProxy < ControlProxy
31
31
  def color(value = nil)
32
- # TODO support hex color value
33
32
  if value.nil?
34
33
  @red ||= Fiddle::Pointer.malloc(8) # double
35
34
  @green ||= Fiddle::Pointer.malloc(8) # double
@@ -52,6 +51,8 @@ module Glimmer
52
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])
53
52
  end
54
53
  end
54
+ alias color= color
55
+ alias set_color color
55
56
 
56
57
  def red(value = nil)
57
58
  if value.nil?
@@ -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