Module: LibUI
- Defined in:
- lib/libui.rb,
lib/libui/ffi.rb,
lib/libui/error.rb,
lib/libui/utils.rb,
lib/libui/version.rb,
lib/libui/libui_base.rb,
lib/libui/fiddle_patch.rb
Defined Under Namespace
Modules: FFI, Utils Classes: Error, LibraryLoadError, LibraryNotFoundError
Constant Summary collapse
- ForEachContinue =
ForEach
0- ForEachStop =
1- WindowResizeEdgeLeft =
WindowResizeEdge
0- WindowResizeEdgeTop =
1- WindowResizeEdgeRight =
2- WindowResizeEdgeBottom =
3- WindowResizeEdgeTopLeft =
4- WindowResizeEdgeTopRight =
5- WindowResizeEdgeBottomLeft =
6- WindowResizeEdgeBottomRight =
7- DrawBrushTypeSolid =
DrawBrushType
0- DrawBrushTypeLinearGradient =
1- DrawBrushTypeRadialGradient =
2- DrawBrushTypeImage =
3- DrawLineCapFlat =
DrawLineCap
0- DrawLineCapRound =
1- DrawLineCapSquare =
2- DrawLineJoinMiter =
DrawLineJoin
0- DrawLineJoinRound =
1- DrawLineJoinBevel =
2- DrawDefaultMiterLimit =
10.0- DrawFillModeWinding =
DrawFillMode
0- DrawFillModeAlternate =
1- AttributeTypeFamily =
AttributeType
0- AttributeTypeSize =
1- AttributeTypeWeight =
2- AttributeTypeItalic =
3- AttributeTypeStretch =
4- AttributeTypeColor =
5- AttributeTypeBackground =
6- AttributeTypeUnderline =
7- AttributeTypeUnderlineColor =
8- AttributeTypeFeatures =
9- TextWeightMinimum =
TextWeight
0- TextWeightThin =
100- TextWeightUltraLight =
200- TextWeightLight =
300- TextWeightBook =
350- TextWeightNormal =
400- TextWeightMedium =
500- TextWeightSemiBold =
600- TextWeightBold =
700- TextWeightUltraBold =
800- TextWeightHeavy =
900- TextWeightUltraHeavy =
950- TextWeightMaximum =
1000- TextItalicNormal =
TextItalic
0- TextItalicOblique =
1- TextItalicItalic =
2- TextStretchUltraCondensed =
TextStretch
0- TextStretchExtraCondensed =
1- TextStretchCondensed =
2- TextStretchSemiCondensed =
3- TextStretchNormal =
4- TextStretchSemiExpanded =
5- TextStretchExpanded =
6- TextStretchExtraExpanded =
7- TextStretchUltraExpanded =
8- UnderlineNone =
Underline
0- UnderlineSingle =
1- UnderlineDouble =
2- UnderlineSuggestion =
3- UnderlineColorCustom =
UnderlineColor
0- UnderlineColorSpelling =
1- UnderlineColorGrammar =
2- UnderlineColorAuxiliary =
3- DrawTextAlignLeft =
DrawTextAlign
0- DrawTextAlignCenter =
1- DrawTextAlignRight =
2- ModifierCtrl =
Modifiers
(1 << 0)
- ModifierAlt =
(1 << 1)
- ModifierShift =
(1 << 2)
- ModifierSuper =
(1 << 3)
- ExtKeyEscape =
ExtKey
1- ExtKeyInsert =
2- ExtKeyDelete =
3- ExtKeyHome =
4- ExtKeyEnd =
5- ExtKeyPageUp =
6- ExtKeyPageDown =
7- ExtKeyUp =
8- ExtKeyDown =
9- ExtKeyLeft =
10- ExtKeyRight =
11- ExtKeyF1 =
12- ExtKeyF2 =
13- ExtKeyF3 =
14- ExtKeyF4 =
15- ExtKeyF5 =
16- ExtKeyF6 =
17- ExtKeyF7 =
18- ExtKeyF8 =
19- ExtKeyF9 =
20- ExtKeyF10 =
21- ExtKeyF11 =
22- ExtKeyF12 =
23- ExtKeyN0 =
24- ExtKeyN1 =
25- ExtKeyN2 =
26- ExtKeyN3 =
27- ExtKeyN4 =
28- ExtKeyN5 =
29- ExtKeyN6 =
30- ExtKeyN7 =
31- ExtKeyN8 =
32- ExtKeyN9 =
33- ExtKeyNDot =
34- ExtKeyNEnter =
35- ExtKeyNAdd =
36- ExtKeyNSubtract =
37- ExtKeyNMultiply =
38- ExtKeyNDivide =
39- AlignFill =
Align
0- AlignStart =
1- AlignCenter =
2- AlignEnd =
3- AtLeading =
At
0- AtTop =
1- AtTrailing =
2- AtBottom =
3- TableValueTypeString =
TableValueType
0- TableValueTypeImage =
1- TableValueTypeInt =
2- TableValueTypeColor =
3- SortIndicatorNone =
SortIndicator
0- SortIndicatorAscending =
1- SortIndicatorDescending =
2- TableModelColumnNeverEditable =
editable
-1
- TableModelColumnAlwaysEditable =
-2
- TableSelectionModeNone =
TableSelectionMode
0- TableSelectionModeZeroOrOne =
1- TableSelectionModeOne =
2- TableSelectionModeZeroOrMany =
3- VERSION =
'0.2.0'
Class Attribute Summary collapse
-
.ffi_lib ⇒ Object
Returns the value of attribute ffi_lib.
Class Method Summary collapse
- .init(opt = nil) ⇒ Object
-
.open_type_features_add(otf, a, b, c, d, value) ⇒ Object
FIXME: This is a workaround for a old version of Fiddle.
- .open_type_features_get(otf, a, b, c, d, value) ⇒ Object
- .open_type_features_remove(otf, a, b, c, d) ⇒ Object
-
.window_position(w) ⇒ Array
Gets the window position.
Class Attribute Details
.ffi_lib ⇒ Object
Returns the value of attribute ffi_lib.
8 9 10 |
# File 'lib/libui.rb', line 8 def ffi_lib @ffi_lib end |
Class Method Details
.init(opt = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/libui.rb', line 44 def init(opt = nil) # Allocate uiInitOptions if not provided unless opt opt = FFI::InitOptions.malloc opt.to_ptr.free = Fiddle::RUBY_FREE opt.Size = FFI::InitOptions.size end err_ptr = super(opt) # uiInit returns const char* error or NULL on success return nil if err_ptr.null? # Convert C string to Ruby string and free the error string per API contract err_msg = err_ptr.to_s free_init_error(err_ptr) warn err_msg nil end |
.open_type_features_add(otf, a, b, c, d, value) ⇒ Object
FIXME: This is a workaround for a old version of Fiddle. Fiddle 1.1.2 and above should be able to handle one character string. See github.com/ruby/fiddle/issues/96
81 82 83 84 |
# File 'lib/libui.rb', line 81 def open_type_features_add(otf, a, b, c, d, value) a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s } super(otf, a, b, c, d, value) end |
.open_type_features_get(otf, a, b, c, d, value) ⇒ Object
91 92 93 94 |
# File 'lib/libui.rb', line 91 def open_type_features_get(otf, a, b, c, d, value) a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s } super(otf, a, b, c, d, value) end |
.open_type_features_remove(otf, a, b, c, d) ⇒ Object
86 87 88 89 |
# File 'lib/libui.rb', line 86 def open_type_features_remove(otf, a, b, c, d) a, b, c, d = [a, b, c, d].map { |s| s.is_a?(String) ? s.ord : s } super(otf, a, b, c, d) end |
.window_position(w) ⇒ Array
This method may return inaccurate or dummy values on Unix platforms.
Gets the window position. Coordinates are measured from the top left corner of the screen.
68 69 70 71 72 73 74 75 |
# File 'lib/libui.rb', line 68 def window_position(w) x_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE) y_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE) super(w, x_ptr, y_ptr) x = x_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*') y = y_ptr[0, Fiddle::SIZEOF_INT].unpack1('i*') [x, y] end |