-
Notifications
You must be signed in to change notification settings - Fork 16
/
custom_draw_text.rb
113 lines (95 loc) · 3.75 KB
/
custom_draw_text.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
require 'glimmer-dsl-libui'
# Michael Ende (1929-1995)
# The Neverending Story is a fantasy novel by German writer Michael Ende,
# The English version, translated by Ralph Manheim, was published in 1983.
class CustomDrawText
include Glimmer
def launch
window('Michael Ende (1929-1995) The Neverending Story', 600, 500) {
margined true
vertical_box {
form {
stretchy false
font_button { |fb|
label 'Font'
on_changed do
@string.font = fb.font
end
}
color_button { |cb|
label 'Color'
on_changed do
@string.color = cb.color
end
}
unless OS.windows?
color_button { |cb|
label 'Background'
on_changed do
@string.background = cb.color
end
}
end
combobox { |c|
label 'Underline'
items Glimmer::LibUI.enum_symbols(:underline).map(&:to_s).map {|word| word.split('_').map(&:capitalize).join(' ')}
selected 'None'
on_selected do
@string.underline = c.selected_item.underscore
end
}
combobox { |c|
label 'Underline Built-In Color'
items Glimmer::LibUI.enum_symbols(:underline_color).map(&:to_s).map(&:capitalize)
selected 'Custom'
on_selected do
@underline_custom_color_button.enabled = c.selected_item == 'Custom'
if c.selected_item == 'Custom'
@string.underline_color = @underline_custom_color_button.color
else
@string.underline_color = c.selected_item.underscore
@underline_custom_color_button.color = :black
end
end
}
@underline_custom_color_button = color_button {
label 'Underline Custom Color'
on_changed do
@string.underline_color = @underline_custom_color_button.color
end
}
}
area {
text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
# align :left # default alignment
@string = string {
' At last Ygramul sensed that something was coming toward ' \
'her. With the speed of lightning, she turned about, confronting ' \
'Atreyu with an enormous steel-blue face. Her single eye had a ' \
'vertical pupil, which stared at Atreyu with inconceivable malignancy. ' \
"\n\n" \
' A cry of fear escaped Bastian. ' \
"\n\n" \
' A cry of terror passed through the ravine and echoed from ' \
'side to side. Ygramul turned her eye to left and right, to see if ' \
'someone else had arrived, for that sound could not have been ' \
'made by the boy who stood there as though paralyzed with ' \
'horror. ' \
"\n\n" \
' Could she have heard my cry? Bastion wondered in alarm. ' \
"But that's not possible. " \
"\n\n" \
' And then Atreyu heard Ygramuls voice. It was very high ' \
'and slightly hoarse, not at all the right kind of voice for that ' \
'enormous face. Her lips did not move as she spoke. It was the ' \
'buzzing of a great swarm of hornets that shaped itself into ' \
'words. ' \
"\n\n"
}
}
}
}
}.show
end
end
CustomDrawText.new.launch