libui 0.1.3.pre-x64-mingw32 → 0.2.0.pre-x64-mingw32
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +275 -251
- data/lib/libui/error.rb +10 -0
- data/lib/libui/ffi.rb +658 -647
- data/lib/libui/fiddle_patch.rb +87 -87
- data/lib/libui/libui_base.rb +52 -52
- data/lib/libui/utils.rb +19 -19
- data/lib/libui/version.rb +3 -3
- data/lib/libui.rb +268 -258
- data/vendor/LICENSE.md +10 -10
- data/vendor/README.md +157 -157
- data/vendor/libui.x64.dll +0 -0
- metadata +19 -4
data/lib/libui.rb
CHANGED
@@ -1,258 +1,268 @@
|
|
1
|
-
require_relative 'libui/version'
|
2
|
-
require_relative 'libui/utils'
|
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
|
-
def
|
76
|
-
a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
|
77
|
-
super(otf, a, b, c, d, value)
|
78
|
-
end
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
1
|
+
require_relative 'libui/version'
|
2
|
+
require_relative 'libui/utils'
|
3
|
+
require_relative 'libui/error'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
module LibUI
|
7
|
+
class << self
|
8
|
+
attr_accessor :ffi_lib
|
9
|
+
end
|
10
|
+
|
11
|
+
host_cpu = case RbConfig::CONFIG['host_cpu']
|
12
|
+
when /i\d86/
|
13
|
+
'x86'
|
14
|
+
else
|
15
|
+
RbConfig::CONFIG['host_cpu']
|
16
|
+
end
|
17
|
+
|
18
|
+
lib_name = [
|
19
|
+
# For libui-ng shared libraries compiled with (rake vendor:build)
|
20
|
+
"libui.#{RbConfig::CONFIG['host_cpu']}.#{RbConfig::CONFIG['SOEXT']}",
|
21
|
+
# For libui-ng shared library downloaded from RubyGems.org
|
22
|
+
"libui.#{host_cpu}.#{RbConfig::CONFIG['SOEXT']}",
|
23
|
+
# For backward compatibility or manual compilation of libui-ng
|
24
|
+
"libui.#{RbConfig::CONFIG['SOEXT']}"
|
25
|
+
]
|
26
|
+
|
27
|
+
self.ffi_lib = \
|
28
|
+
if ENV['LIBUIDIR'] && !ENV['LIBUIDIR'].empty?
|
29
|
+
lib_name.lazy
|
30
|
+
.map { |name| File.expand_path(name, ENV['LIBUIDIR']) }
|
31
|
+
.find { |path| File.exist?(path) }
|
32
|
+
else
|
33
|
+
lib_name.lazy
|
34
|
+
.map { |name| File.expand_path("../vendor/#{name}", __dir__) }
|
35
|
+
.find { |path| File.exist?(path) }
|
36
|
+
end
|
37
|
+
|
38
|
+
require_relative 'libui/ffi'
|
39
|
+
require_relative 'libui/libui_base'
|
40
|
+
|
41
|
+
extend LibUIBase
|
42
|
+
|
43
|
+
class << self
|
44
|
+
def init(opt = nil)
|
45
|
+
unless opt
|
46
|
+
opt = FFI::InitOptions.malloc
|
47
|
+
opt.to_ptr.free = Fiddle::RUBY_FREE
|
48
|
+
end
|
49
|
+
i = super(opt)
|
50
|
+
return if i.size.zero?
|
51
|
+
|
52
|
+
warn 'error'
|
53
|
+
warn UI.free_init_error(init)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Gets the window position.
|
57
|
+
# Coordinates are measured from the top left corner of the screen.
|
58
|
+
# @param w [Fiddle::Pointer] Pointer of uiWindow instance.
|
59
|
+
# @return [Array] position of the window. [x, y]
|
60
|
+
# @note This method may return inaccurate or dummy values on Unix platforms.
|
61
|
+
|
62
|
+
def window_position(w)
|
63
|
+
x_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
|
64
|
+
y_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
|
65
|
+
super(w, x_ptr, y_ptr)
|
66
|
+
x = x_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*')
|
67
|
+
y = y_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*')
|
68
|
+
[x, y]
|
69
|
+
end
|
70
|
+
|
71
|
+
# FIXME: This is a workaround for a old version of Fiddle.
|
72
|
+
# Fiddle 1.1.2 and above should be able to handle one character string.
|
73
|
+
# See https://github.com/ruby/fiddle/issues/96
|
74
|
+
|
75
|
+
def open_type_features_add(otf, a, b, c, d, value)
|
76
|
+
a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
|
77
|
+
super(otf, a, b, c, d, value)
|
78
|
+
end
|
79
|
+
|
80
|
+
def open_type_features_remove(otf, a, b, c, d)
|
81
|
+
a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
|
82
|
+
super(otf, a, b, c, d)
|
83
|
+
end
|
84
|
+
|
85
|
+
def open_type_features_get(otf, a, b, c, d, value)
|
86
|
+
a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
|
87
|
+
super(otf, a, b, c, d, value)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
## UI_ENUM https://github.com/libui-ng/libui-ng/blob/master/ui.h
|
92
|
+
|
93
|
+
# ForEach
|
94
|
+
ForEachContinue = 0
|
95
|
+
ForEachStop = 1
|
96
|
+
|
97
|
+
# WindowResizeEdge
|
98
|
+
WindowResizeEdgeLeft = 0
|
99
|
+
WindowResizeEdgeTop = 1
|
100
|
+
WindowResizeEdgeRight = 2
|
101
|
+
WindowResizeEdgeBottom = 3
|
102
|
+
WindowResizeEdgeTopLeft = 4
|
103
|
+
WindowResizeEdgeTopRight = 5
|
104
|
+
WindowResizeEdgeBottomLeft = 6
|
105
|
+
WindowResizeEdgeBottomRight = 7
|
106
|
+
|
107
|
+
# DrawBrushType
|
108
|
+
DrawBrushTypeSolid = 0
|
109
|
+
DrawBrushTypeLinearGradient = 1
|
110
|
+
DrawBrushTypeRadialGradient = 2
|
111
|
+
DrawBrushTypeImage = 3
|
112
|
+
|
113
|
+
# DrawLineCap
|
114
|
+
DrawLineCapFlat = 0
|
115
|
+
DrawLineCapRound = 1
|
116
|
+
DrawLineCapSquare = 2
|
117
|
+
|
118
|
+
# DrawLineJoin
|
119
|
+
DrawLineJoinMiter = 0
|
120
|
+
DrawLineJoinRound = 1
|
121
|
+
DrawLineJoinBevel = 2
|
122
|
+
|
123
|
+
DrawDefaultMiterLimit = 10.0
|
124
|
+
|
125
|
+
# DrawFillMode
|
126
|
+
DrawFillModeWinding = 0
|
127
|
+
DrawFillModeAlternate = 1
|
128
|
+
|
129
|
+
# AttributeType
|
130
|
+
AttributeTypeFamily = 0
|
131
|
+
AttributeTypeSize = 1
|
132
|
+
AttributeTypeWeight = 2
|
133
|
+
AttributeTypeItalic = 3
|
134
|
+
AttributeTypeStretch = 4
|
135
|
+
AttributeTypeColor = 5
|
136
|
+
AttributeTypeBackground = 6
|
137
|
+
AttributeTypeUnderline = 7
|
138
|
+
AttributeTypeUnderlineColor = 8
|
139
|
+
AttributeTypeFeatures = 9
|
140
|
+
|
141
|
+
# TextWeight
|
142
|
+
TextWeightMinimum = 0
|
143
|
+
TextWeightThin = 100
|
144
|
+
TextWeightUltraLight = 200
|
145
|
+
TextWeightLight = 300
|
146
|
+
TextWeightBook = 350
|
147
|
+
TextWeightNormal = 400
|
148
|
+
TextWeightMedium = 500
|
149
|
+
TextWeightSemiBold = 600
|
150
|
+
TextWeightBold = 700
|
151
|
+
TextWeightUltraBold = 800
|
152
|
+
TextWeightHeavy = 900
|
153
|
+
TextWeightUltraHeavy = 950
|
154
|
+
TextWeightMaximum = 1000
|
155
|
+
|
156
|
+
# TextItalic
|
157
|
+
TextItalicNormal = 0
|
158
|
+
TextItalicOblique = 1
|
159
|
+
TextItalicItalic = 2
|
160
|
+
|
161
|
+
# TextStretch
|
162
|
+
TextStretchUltraCondensed = 0
|
163
|
+
TextStretchExtraCondensed = 1
|
164
|
+
TextStretchCondensed = 2
|
165
|
+
TextStretchSemiCondensed = 3
|
166
|
+
TextStretchNormal = 4
|
167
|
+
TextStretchSemiExpanded = 5
|
168
|
+
TextStretchExpanded = 6
|
169
|
+
TextStretchExtraExpanded = 7
|
170
|
+
TextStretchUltraExpanded = 8
|
171
|
+
|
172
|
+
# Underline
|
173
|
+
UnderlineNone = 0
|
174
|
+
UnderlineSingle = 1
|
175
|
+
UnderlineDouble = 2
|
176
|
+
UnderlineSuggestion = 3
|
177
|
+
|
178
|
+
# UnderlineColor
|
179
|
+
UnderlineColorCustom = 0
|
180
|
+
UnderlineColorSpelling = 1
|
181
|
+
UnderlineColorGrammar = 2
|
182
|
+
UnderlineColorAuxiliary = 3
|
183
|
+
|
184
|
+
# DrawTextAlign
|
185
|
+
DrawTextAlignLeft = 0
|
186
|
+
DrawTextAlignCenter = 1
|
187
|
+
DrawTextAlignRight = 2
|
188
|
+
|
189
|
+
# Modifiers
|
190
|
+
ModifierCtrl = (1 << 0)
|
191
|
+
ModifierAlt = (1 << 1)
|
192
|
+
ModifierShift = (1 << 2)
|
193
|
+
ModifierSuper = (1 << 3)
|
194
|
+
|
195
|
+
# ExtKey
|
196
|
+
ExtKeyEscape = 1
|
197
|
+
ExtKeyInsert = 2
|
198
|
+
ExtKeyDelete = 3
|
199
|
+
ExtKeyHome = 4
|
200
|
+
ExtKeyEnd = 5
|
201
|
+
ExtKeyPageUp = 6
|
202
|
+
ExtKeyPageDown = 7
|
203
|
+
ExtKeyUp = 8
|
204
|
+
ExtKeyDown = 9
|
205
|
+
ExtKeyLeft = 10
|
206
|
+
ExtKeyRight = 11
|
207
|
+
ExtKeyF1 = 12
|
208
|
+
ExtKeyF2 = 13
|
209
|
+
ExtKeyF3 = 14
|
210
|
+
ExtKeyF4 = 15
|
211
|
+
ExtKeyF5 = 16
|
212
|
+
ExtKeyF6 = 17
|
213
|
+
ExtKeyF7 = 18
|
214
|
+
ExtKeyF8 = 19
|
215
|
+
ExtKeyF9 = 20
|
216
|
+
ExtKeyF10 = 21
|
217
|
+
ExtKeyF11 = 22
|
218
|
+
ExtKeyF12 = 23
|
219
|
+
ExtKeyN0 = 24
|
220
|
+
ExtKeyN1 = 25
|
221
|
+
ExtKeyN2 = 26
|
222
|
+
ExtKeyN3 = 27
|
223
|
+
ExtKeyN4 = 28
|
224
|
+
ExtKeyN5 = 29
|
225
|
+
ExtKeyN6 = 30
|
226
|
+
ExtKeyN7 = 31
|
227
|
+
ExtKeyN8 = 32
|
228
|
+
ExtKeyN9 = 33
|
229
|
+
ExtKeyNDot = 34
|
230
|
+
ExtKeyNEnter = 35
|
231
|
+
ExtKeyNAdd = 36
|
232
|
+
ExtKeyNSubtract = 37
|
233
|
+
ExtKeyNMultiply = 38
|
234
|
+
ExtKeyNDivide = 39
|
235
|
+
|
236
|
+
# Align
|
237
|
+
AlignFill = 0
|
238
|
+
AlignStart = 1
|
239
|
+
AlignCenter = 2
|
240
|
+
AlignEnd = 3
|
241
|
+
|
242
|
+
# At
|
243
|
+
AtLeading = 0
|
244
|
+
AtTop = 1
|
245
|
+
AtTrailing = 2
|
246
|
+
AtBottom = 3
|
247
|
+
|
248
|
+
# TableValueType
|
249
|
+
TableValueTypeString = 0
|
250
|
+
TableValueTypeImage = 1
|
251
|
+
TableValueTypeInt = 2
|
252
|
+
TableValueTypeColor = 3
|
253
|
+
|
254
|
+
# SortIndicator
|
255
|
+
SortIndicatorNone = 0
|
256
|
+
SortIndicatorAscending = 1
|
257
|
+
SortIndicatorDescending = 2
|
258
|
+
|
259
|
+
# editable
|
260
|
+
TableModelColumnNeverEditable = -1
|
261
|
+
TableModelColumnAlwaysEditable = -2
|
262
|
+
|
263
|
+
# TableSelectionMode
|
264
|
+
TableSelectionModeNone = 0
|
265
|
+
TableSelectionModeZeroOrOne = 1
|
266
|
+
TableSelectionModeOne = 2
|
267
|
+
TableSelectionModeZeroOrMany = 3
|
268
|
+
end
|
data/vendor/LICENSE.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
Copyright (c) 2022 libui-ng authors
|
2
|
-
|
3
|
-
Copyright (c) 2014 Pietro Gagliardi
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
-
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
-
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
10
|
-
|
1
|
+
Copyright (c) 2022 libui-ng authors
|
2
|
+
|
3
|
+
Copyright (c) 2014 Pietro Gagliardi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
10
|
+
|