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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/README.md +550 -21
- data/VERSION +1 -1
- data/examples/basic_draw_text.rb +35 -37
- data/examples/basic_draw_text2.rb +68 -0
- data/examples/basic_table_color.rb +39 -0
- data/examples/custom_draw_text.rb +106 -0
- data/examples/custom_draw_text2.rb +120 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/icons/glimmer.png +0 -0
- data/lib/glimmer/libui/attributed_string.rb +90 -4
- data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +2 -1
- data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +38 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +82 -0
- data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +50 -0
- data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +50 -0
- data/lib/glimmer/libui/control_proxy/combobox_proxy.rb +18 -0
- data/lib/glimmer/libui/control_proxy/editable_column.rb +1 -0
- data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +53 -0
- data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +59 -0
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +31 -11
- data/lib/glimmer/libui/control_proxy/text_proxy.rb +20 -5
- data/lib/glimmer/libui/control_proxy/triple_column.rb +45 -0
- data/lib/glimmer/libui.rb +1 -1
- metadata +14 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/examples/basic_draw_text.rb
CHANGED
@@ -6,14 +6,14 @@ require 'glimmer-dsl-libui'
|
|
6
6
|
class BasicDrawText
|
7
7
|
include Glimmer
|
8
8
|
|
9
|
-
def alternating_color_string(&block)
|
10
|
-
@index
|
9
|
+
def alternating_color_string(initial: false, &block)
|
10
|
+
@index = 0 if initial
|
11
11
|
@index += 1
|
12
12
|
string {
|
13
13
|
if @index.odd?
|
14
|
-
color r:
|
14
|
+
color r: 128, g: 0, b: 64, a: 0.7
|
15
15
|
else
|
16
|
-
color r: 0, g:
|
16
|
+
color r: 0, g: 128, b: 0, a: 0.7
|
17
17
|
end
|
18
18
|
|
19
19
|
block.call + "\n\n"
|
@@ -25,40 +25,38 @@ class BasicDrawText
|
|
25
25
|
margined true
|
26
26
|
|
27
27
|
area {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
'vertical pupil, which stared at Atreyu with inconceivable malignancy. '
|
38
|
-
}
|
39
|
-
alternating_color_string {
|
40
|
-
' A cry of fear escaped Bastian. '
|
41
|
-
}
|
42
|
-
alternating_color_string {
|
43
|
-
' A cry of terror passed through the ravine and echoed from ' \
|
44
|
-
'side to side. Ygramul turned her eye to left and right, to see if ' \
|
45
|
-
'someone else had arrived, for that sound could not have been ' \
|
46
|
-
'made by the boy who stood there as though paralyzed with ' \
|
47
|
-
'horror. '
|
48
|
-
}
|
49
|
-
alternating_color_string {
|
50
|
-
' Could she have heard my cry? Bastion wondered in alarm. ' \
|
51
|
-
"But that's not possible. "
|
52
|
-
}
|
53
|
-
alternating_color_string {
|
54
|
-
' And then Atreyu heard Ygramuls voice. It was very high ' \
|
55
|
-
'and slightly hoarse, not at all the right kind of voice for that ' \
|
56
|
-
'enormous face. Her lips did not move as she spoke. It was the ' \
|
57
|
-
'buzzing of a great swarm of hornets that shaped itself into ' \
|
58
|
-
'words. '
|
59
|
-
}
|
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. '
|
60
37
|
}
|
61
|
-
|
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
|
+
}
|
62
60
|
}
|
63
61
|
}.show
|
64
62
|
end
|
@@ -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,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
require 'chunky_png'
|
5
|
+
|
6
|
+
include Glimmer
|
7
|
+
|
8
|
+
f = File.open(File.expand_path('../icons/glimmer.png', __dir__))
|
9
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
10
|
+
f.close
|
11
|
+
canvas.resample_nearest_neighbor!(24, 24)
|
12
|
+
data = canvas.to_rgba_stream
|
13
|
+
width = canvas.width
|
14
|
+
height = canvas.height
|
15
|
+
img = image {
|
16
|
+
image_part(data, width, height, width * 4)
|
17
|
+
}
|
18
|
+
|
19
|
+
data = [
|
20
|
+
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
21
|
+
[['dog', :yellow] , ['woof', {r: 240, g: 32, b: 32}] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], :skyblue],
|
22
|
+
[['chicken', :beige], ['cock-a-doodle-doo', :blue] , [false, 'mammal', :red] , [img, 'Glimmer', :beige], {r: 5, g: 120, b: 110}],
|
23
|
+
[['horse', :purple] , ['neigh', {r: 240, g: 32, b: 32}], [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], '13a1fb'],
|
24
|
+
[['cow', :gray] , ['moo', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :brown], 0x12ff02]
|
25
|
+
]
|
26
|
+
|
27
|
+
window('Animals', 500, 200) {
|
28
|
+
horizontal_box {
|
29
|
+
table {
|
30
|
+
text_color_column('Animal')
|
31
|
+
text_color_column('Sound')
|
32
|
+
checkbox_text_color_column('Description')
|
33
|
+
image_text_color_column('GUI')
|
34
|
+
background_color_column('Mammal')
|
35
|
+
|
36
|
+
cell_rows data
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}.show
|
@@ -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
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/icons/glimmer.png
ADDED
Binary file
|
@@ -40,24 +40,70 @@ module Glimmer
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def font(value = nil)
|
43
|
-
|
43
|
+
if value.nil?
|
44
|
+
@font
|
45
|
+
else
|
46
|
+
@font = value
|
47
|
+
redraw
|
48
|
+
end
|
44
49
|
end
|
50
|
+
alias font= font
|
51
|
+
alias set_font font
|
45
52
|
|
46
53
|
def color(value = nil)
|
47
54
|
if value.nil?
|
48
55
|
@color
|
49
56
|
else
|
50
57
|
@color = Glimmer::LibUI.interpret_color(value)
|
58
|
+
redraw
|
51
59
|
end
|
52
60
|
end
|
61
|
+
alias color= color
|
62
|
+
alias set_color color
|
53
63
|
|
54
64
|
def background(value = nil)
|
55
|
-
|
65
|
+
if value.nil?
|
66
|
+
@background
|
67
|
+
else
|
68
|
+
@background = Glimmer::LibUI.interpret_color(value)
|
69
|
+
redraw
|
70
|
+
end
|
56
71
|
end
|
72
|
+
alias background= background
|
73
|
+
alias set_background background
|
57
74
|
|
58
75
|
def underline(value = nil)
|
59
|
-
|
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
|
60
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
|
61
107
|
|
62
108
|
def post_add_content
|
63
109
|
block_result = block&.call
|
@@ -65,16 +111,56 @@ module Glimmer
|
|
65
111
|
@parent_proxy&.post_initialize_child(self)
|
66
112
|
end
|
67
113
|
|
114
|
+
def post_initialize_child(child)
|
115
|
+
self.open_type_features = child if child.is_a?(Glimmer::LibUI::ControlProxy::OpenTypeFeaturesProxy)
|
116
|
+
end
|
117
|
+
|
68
118
|
def draw(area_draw_params)
|
69
119
|
@start = ::LibUI.attributed_string_len(@parent_proxy.attributed_string)
|
70
120
|
::LibUI.attributed_string_append_unattributed(@parent_proxy.attributed_string, @string)
|
71
121
|
unless color.nil?
|
72
|
-
color_attribute = ::LibUI.new_color_attribute(@color[:r], @color[:g], @color[:b], @color[:a] || 1.0)
|
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)
|
73
123
|
::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, @start, @start + @string.size)
|
74
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?
|
75
160
|
end
|
76
161
|
|
77
162
|
def destroy
|
163
|
+
open_type_features.destroy unless open_type_features.nil?
|
78
164
|
@parent_proxy&.children&.delete(self)
|
79
165
|
end
|
80
166
|
|
@@ -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?
|
@@ -0,0 +1,38 @@
|
|
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
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
class ControlProxy
|
28
|
+
module Column
|
29
|
+
# Proxy for LibUI background color column objects
|
30
|
+
#
|
31
|
+
# Follows the Proxy Design Pattern
|
32
|
+
class BackgroundColorColumnProxy < ControlProxy
|
33
|
+
include Column
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|