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.
data/lib/libui.rb CHANGED
@@ -1,258 +1,268 @@
1
- require_relative 'libui/version'
2
- require_relative 'libui/utils'
3
- require 'rbconfig'
4
-
5
- module LibUI
6
- class Error < StandardError; end
7
-
8
- class << self
9
- attr_accessor :ffi_lib
10
- end
11
-
12
- lib_name = [
13
- "libui.#{RbConfig::CONFIG['host_cpu']}.#{RbConfig::CONFIG['SOEXT']}",
14
- "libui.#{RbConfig::CONFIG['SOEXT']}"
15
- ]
16
-
17
- self.ffi_lib = \
18
- if ENV['LIBUIDIR'] && !ENV['LIBUIDIR'].empty?
19
- lib_name.lazy
20
- .map { |name| File.expand_path(name, ENV['LIBUIDIR']) }
21
- .find { |path| File.exist?(path) }
22
- else
23
- lib_name.lazy
24
- .map { |name| File.expand_path("../vendor/#{name}", __dir__) }
25
- .find { |path| File.exist?(path) }
26
- end
27
-
28
- require_relative 'libui/ffi'
29
- require_relative 'libui/libui_base'
30
-
31
- extend LibUIBase
32
-
33
- class << self
34
- def init(opt = nil)
35
- unless opt
36
- opt = FFI::InitOptions.malloc
37
- opt.to_ptr.free = Fiddle::RUBY_FREE
38
- end
39
- i = super(opt)
40
- return if i.size.zero?
41
-
42
- warn 'error'
43
- warn UI.free_init_error(init)
44
- end
45
-
46
- # Gets the window position.
47
- # Coordinates are measured from the top left corner of the screen.
48
- # @param w [Fiddle::Pointer] Pointer of uiWindow instance.
49
- # @return [Array] position of the window. [x, y]
50
- # @note This method may return inaccurate or dummy values on Unix platforms.
51
-
52
- def window_position(w)
53
- x_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
54
- y_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
55
- super(w, x_ptr, y_ptr)
56
- x = x_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*')
57
- y = y_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*')
58
- [x, y]
59
- end
60
-
61
- # FIXME: This is a workaround for a old version of Fiddle.
62
- # Fiddle 1.1.2 and above should be able to handle one character string.
63
- # See https://github.com/ruby/fiddle/issues/96
64
-
65
- def open_type_features_add(otf, a, b, c, d, value)
66
- a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
67
- super(otf, a, b, c, d, value)
68
- end
69
-
70
- def open_type_features_remove(otf, a, b, c, d)
71
- a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s }
72
- super(otf, a, b, c, d)
73
- end
74
-
75
- def open_type_features_get(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
- end
80
-
81
- ## UI_ENUM https://github.com/libui-ng/libui-ng/blob/master/ui.h
82
-
83
- # ForEach
84
- ForEachContinue = 0
85
- ForEachStop = 1
86
-
87
- # WindowResizeEdge
88
- WindowResizeEdgeLeft = 0
89
- WindowResizeEdgeTop = 1
90
- WindowResizeEdgeRight = 2
91
- WindowResizeEdgeBottom = 3
92
- WindowResizeEdgeTopLeft = 4
93
- WindowResizeEdgeTopRight = 5
94
- WindowResizeEdgeBottomLeft = 6
95
- WindowResizeEdgeBottomRight = 7
96
-
97
- # DrawBrushType
98
- DrawBrushTypeSolid = 0
99
- DrawBrushTypeLinearGradient = 1
100
- DrawBrushTypeRadialGradient = 2
101
- DrawBrushTypeImage = 3
102
-
103
- # DrawLineCap
104
- DrawLineCapFlat = 0
105
- DrawLineCapRound = 1
106
- DrawLineCapSquare = 2
107
-
108
- # DrawLineJoin
109
- DrawLineJoinMiter = 0
110
- DrawLineJoinRound = 1
111
- DrawLineJoinBevel = 2
112
-
113
- DrawDefaultMiterLimit = 10.0
114
-
115
- # DrawFillMode
116
- DrawFillModeWinding = 0
117
- DrawFillModeAlternate = 1
118
-
119
- # AttributeType
120
- AttributeTypeFamily = 0
121
- AttributeTypeSize = 1
122
- AttributeTypeWeight = 2
123
- AttributeTypeItalic = 3
124
- AttributeTypeStretch = 4
125
- AttributeTypeColor = 5
126
- AttributeTypeBackground = 6
127
- AttributeTypeUnderline = 7
128
- AttributeTypeUnderlineColor = 8
129
- AttributeTypeFeatures = 9
130
-
131
- # TextWeight
132
- TextWeightMinimum = 0
133
- TextWeightThin = 100
134
- TextWeightUltraLight = 200
135
- TextWeightLight = 300
136
- TextWeightBook = 350
137
- TextWeightNormal = 400
138
- TextWeightMedium = 500
139
- TextWeightSemiBold = 600
140
- TextWeightBold = 700
141
- TextWeightUltraBold = 800
142
- TextWeightHeavy = 900
143
- TextWeightUltraHeavy = 950
144
- TextWeightMaximum = 1000
145
-
146
- # TextItalic
147
- TextItalicNormal = 0
148
- TextItalicOblique = 1
149
- TextItalicItalic = 2
150
-
151
- # TextStretch
152
- TextStretchUltraCondensed = 0
153
- TextStretchExtraCondensed = 1
154
- TextStretchCondensed = 2
155
- TextStretchSemiCondensed = 3
156
- TextStretchNormal = 4
157
- TextStretchSemiExpanded = 5
158
- TextStretchExpanded = 6
159
- TextStretchExtraExpanded = 7
160
- TextStretchUltraExpanded = 8
161
-
162
- # Underline
163
- UnderlineNone = 0
164
- UnderlineSingle = 1
165
- UnderlineDouble = 2
166
- UnderlineSuggestion = 3
167
-
168
- # UnderlineColor
169
- UnderlineColorCustom = 0
170
- UnderlineColorSpelling = 1
171
- UnderlineColorGrammar = 2
172
- UnderlineColorAuxiliary = 3
173
-
174
- # DrawTextAlign
175
- DrawTextAlignLeft = 0
176
- DrawTextAlignCenter = 1
177
- DrawTextAlignRight = 2
178
-
179
- # Modifiers
180
- ModifierCtrl = (1 << 0)
181
- ModifierAlt = (1 << 1)
182
- ModifierShift = (1 << 2)
183
- ModifierSuper = (1 << 3)
184
-
185
- # ExtKey
186
- ExtKeyEscape = 1
187
- ExtKeyInsert = 2
188
- ExtKeyDelete = 3
189
- ExtKeyHome = 4
190
- ExtKeyEnd = 5
191
- ExtKeyPageUp = 6
192
- ExtKeyPageDown = 7
193
- ExtKeyUp = 8
194
- ExtKeyDown = 9
195
- ExtKeyLeft = 10
196
- ExtKeyRight = 11
197
- ExtKeyF1 = 12
198
- ExtKeyF2 = 13
199
- ExtKeyF3 = 14
200
- ExtKeyF4 = 15
201
- ExtKeyF5 = 16
202
- ExtKeyF6 = 17
203
- ExtKeyF7 = 18
204
- ExtKeyF8 = 19
205
- ExtKeyF9 = 20
206
- ExtKeyF10 = 21
207
- ExtKeyF11 = 22
208
- ExtKeyF12 = 23
209
- ExtKeyN0 = 24
210
- ExtKeyN1 = 25
211
- ExtKeyN2 = 26
212
- ExtKeyN3 = 27
213
- ExtKeyN4 = 28
214
- ExtKeyN5 = 29
215
- ExtKeyN6 = 30
216
- ExtKeyN7 = 31
217
- ExtKeyN8 = 32
218
- ExtKeyN9 = 33
219
- ExtKeyNDot = 34
220
- ExtKeyNEnter = 35
221
- ExtKeyNAdd = 36
222
- ExtKeyNSubtract = 37
223
- ExtKeyNMultiply = 38
224
- ExtKeyNDivide = 39
225
-
226
- # Align
227
- AlignFill = 0
228
- AlignStart = 1
229
- AlignCenter = 2
230
- AlignEnd = 3
231
-
232
- # At
233
- AtLeading = 0
234
- AtTop = 1
235
- AtTrailing = 2
236
- AtBottom = 3
237
-
238
- # TableValueType
239
- TableValueTypeString = 0
240
- TableValueTypeImage = 1
241
- TableValueTypeInt = 2
242
- TableValueTypeColor = 3
243
-
244
- # SortIndicator
245
- SortIndicatorNone = 0
246
- SortIndicatorAscending = 1
247
- SortIndicatorDescending = 2
248
-
249
- # editable
250
- TableModelColumnNeverEditable = -1
251
- TableModelColumnAlwaysEditable = -2
252
-
253
- # TableSelectionMode
254
- TableSelectionModeNone = 0
255
- TableSelectionModeZeroOrOne = 1
256
- TableSelectionModeOne = 2
257
- TableSelectionModeZeroOrMany = 3
258
- end
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
+