yoga_layout 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,131 @@
1
+ # This file is auto-generated by //enums.py
2
+ # Do not edit by hand!
3
+ module YogaLayout
4
+ module Bindings
5
+
6
+ Align = enum(
7
+ :auto,
8
+ :flex_start,
9
+ :center,
10
+ :flex_end,
11
+ :stretch,
12
+ :baseline,
13
+ :space_between,
14
+ :space_around,
15
+ )
16
+ typedef Align, :YGAlign
17
+
18
+ Dimension = enum(
19
+ :width,
20
+ :height,
21
+ )
22
+ typedef Dimension, :YGDimension
23
+
24
+ Direction = enum(
25
+ :inherit,
26
+ :ltr,
27
+ :rtl,
28
+ )
29
+ typedef Direction, :YGDirection
30
+
31
+ Display = enum(
32
+ :flex,
33
+ :none,
34
+ )
35
+ typedef Display, :YGDisplay
36
+
37
+ Edge = enum(
38
+ :left,
39
+ :top,
40
+ :right,
41
+ :bottom,
42
+ :start,
43
+ :end,
44
+ :horizontal,
45
+ :vertical,
46
+ :all,
47
+ )
48
+ typedef Edge, :YGEdge
49
+
50
+ ExperimentalFeature = enum(
51
+ :web_flex_basis,
52
+ )
53
+ typedef ExperimentalFeature, :YGExperimentalFeature
54
+
55
+ FlexDirection = enum(
56
+ :column,
57
+ :column_reverse,
58
+ :row,
59
+ :row_reverse,
60
+ )
61
+ typedef FlexDirection, :YGFlexDirection
62
+
63
+ Justify = enum(
64
+ :flex_start,
65
+ :center,
66
+ :flex_end,
67
+ :space_between,
68
+ :space_around,
69
+ )
70
+ typedef Justify, :YGJustify
71
+
72
+ LogLevel = enum(
73
+ :error,
74
+ :warn,
75
+ :info,
76
+ :debug,
77
+ :verbose,
78
+ :fatal,
79
+ )
80
+ typedef LogLevel, :YGLogLevel
81
+
82
+ MeasureMode = enum(
83
+ :undefined,
84
+ :exactly,
85
+ :at_most,
86
+ )
87
+ typedef MeasureMode, :YGMeasureMode
88
+
89
+ NodeType = enum(
90
+ :default,
91
+ :text,
92
+ )
93
+ typedef NodeType, :YGNodeType
94
+
95
+ Overflow = enum(
96
+ :visible,
97
+ :hidden,
98
+ :scroll,
99
+ )
100
+ typedef Overflow, :YGOverflow
101
+
102
+ PositionType = enum(
103
+ :relative,
104
+ :absolute,
105
+ )
106
+ typedef PositionType, :YGPositionType
107
+
108
+ PrintOptions = enum(
109
+ :layout, 1,
110
+ :style, 2,
111
+ :children, 4,
112
+ )
113
+ typedef PrintOptions, :YGPrintOptions
114
+
115
+ Unit = enum(
116
+ :undefined,
117
+ :point,
118
+ :percent,
119
+ :auto,
120
+ )
121
+ typedef Unit, :YGUnit
122
+
123
+ Wrap = enum(
124
+ :no_wrap,
125
+ :wrap,
126
+ :wrap_reverse,
127
+ )
128
+ typedef Wrap, :YGWrap
129
+
130
+ end
131
+ end
@@ -0,0 +1,23 @@
1
+ module YogaLayout
2
+ module Bindings
3
+ # Disabled, because YGLogger type is unsupported by Ruby's FFI
4
+ # remember_function :YCConfigSetLogger, [:YGConfigRef, :YGLogger], :void
5
+ remember_function :YGLog, [:YGNodeRef, :YGLogLevel, :string, :varargs], :void
6
+ remember_function :YGLogWithConfig, [:YGConfigRef, :YGLogLevel, :string, :varargs], :void
7
+ remember_function :YGAssert, [:bool, :string], :void
8
+ remember_function :YGAssertWithNode, [:YGNodeRef, :bool, :string], :void
9
+ remember_function :YGAssertWithConfig, [:YGConfigRef, :bool, :string], :void
10
+
11
+ # Disabled, because YGLogger type is unsupported by Ruby's FFI
12
+ # rememebr_function :YGConfigSetLogger, [:YGConfigRef, :YGLogger], :void
13
+ remember_function :YGLog, [:YGNodeRef, :YGLogLevel, :string, :varargs], :void
14
+ remember_function :YGLogWithConfig, [:YGConfigRef, :YGLogLevel, :string, :varargs], :void
15
+ remember_function :YGAssert, [:bool, :string], :void
16
+ remember_function :YGAssertWithNode, [:YGNodeRef, :bool, :string], :void
17
+ remember_function :YGAssertWithConfig, [:YGConfigRef, :bool, :string], :void
18
+
19
+ remember_function :YGSetMemoryFuncs, [:YGMalloc, :YGCalloc, :YGRealloc, :YGFree], :void
20
+
21
+ remember_function :YGFloatIsUndefined, [:float], :bool
22
+ end
23
+ end
@@ -0,0 +1,51 @@
1
+ module YogaLayout
2
+ module Bindings
3
+ typedef :pointer, :YGNodeRef
4
+ typedef :pointer, :YGConfigRef
5
+
6
+ class Size < FFI::Struct
7
+ layout :width, :float,
8
+ :height, :float
9
+ end
10
+ typedef Size.by_value, :YGSize
11
+
12
+ class Value < FFI::Struct
13
+ layout :value, :float,
14
+ :unit, :YGUnit
15
+ end
16
+ typedef Value.by_value, :YGValue
17
+
18
+ callback :YGMeasureFunc, [
19
+ :YGNodeRef,
20
+ :float, # width
21
+ :YGMeasureMode, # widthMode
22
+ :float, # height
23
+ :YGMeasureMode, # heightMode
24
+ ], :YGSize
25
+
26
+ callback :YGPrintFunc, [:YGNodeRef], :void
27
+
28
+ callback :YGBaselineFunc, [
29
+ :YGNodeRef,
30
+ :float, # width
31
+ :float, # height
32
+ ], :float
33
+
34
+ # Can't support YGLogger type because Ruby's FFI bindings don't support
35
+ # va_args types on major platforms.
36
+ #
37
+ # callback :YGLogger, [
38
+ # :YGConfigRef,
39
+ # :YGNodeRef,
40
+ # :YGLogLevel,
41
+ # :string, # format
42
+ # :va_list, # args
43
+ # ], :int
44
+
45
+ # it would be crazy to actually use ruby to implement these...
46
+ callback :YGMalloc, [:size_t], :pointer
47
+ callback :YGCalloc, [:size_t, :size_t], :pointer
48
+ callback :YGRealloc, [:pointer, :size_t], :pointer
49
+ callback :YGFree, [:pointer], :void
50
+ end
51
+ end
@@ -0,0 +1,37 @@
1
+ module YogaLayout
2
+ module Bindings
3
+ # This file contains the Yoga functions that operate primarily on YGConfigRef
4
+
5
+ # Set this to number of pixels in 1 point to round calculation results. If
6
+ # you want to avoid rounding - set PointScaleFactor to 0
7
+ remember_function :YGConfigSetPointScaleFactor, [:YGConfigRef, :float], :void
8
+
9
+ # Yoga previously had an error where containers would take the maximum
10
+ # space possible instead of the minimum like they are supposed to. In
11
+ # practice this resulted in implicit behaviour similar to align-self:
12
+ # stretch; Because this was such a long-standing bug we must allow legacy
13
+ # users to switch back to this behaviour.
14
+ remember_function :YGConfigSetUseLegacyStretchBehaviour, [:YGConfigRef, :bool], :void
15
+
16
+ remember_function :YGConfigNew, [], :YGConfigRef
17
+ remember_function :YGConfigFree, [:YGConfigRef], :void
18
+ remember_function :YGConfigCopy, [
19
+ :YGConfigRef, # dest
20
+ :YGConfigRef, # source
21
+ ], :void
22
+ remember_function :YGConfigGetInstanceCount, [], :int32_t
23
+
24
+ remember_function :YGConfigSetExperimentalFeatureEnabled, [:YGConfigRef, :YGExperimentalFeature, :bool], :void
25
+ remember_function :YGConfigIsExperimentalFeatureEnabled, [:YGConfigRef, :YGExperimentalFeature], :bool
26
+
27
+ remember_function :YGConfigSetUseWebDefaults, [:YGConfigRef, :bool], :void
28
+ remember_function :YGConfigGetUseWebDefaults, [:YGConfigRef], :bool
29
+
30
+ # "Exported only for C#"
31
+ # TODO: should we wrap this in the Ruby library, or not?
32
+ remember_function :YGConfigGetDefault, [], :YGConfigRef
33
+
34
+ remember_function :YGConfigSetContext, [:YGConfigRef, :pointer], :void
35
+ remember_function :YGConfigGetContext, [:YGConfigRef], :pointer
36
+ end
37
+ end
@@ -0,0 +1,59 @@
1
+ module YogaLayout
2
+ module Bindings
3
+ # This file defines non-propety methods of YGNodde
4
+
5
+ # Lifecycle
6
+ remember_function :YGNodeNew, [], :YGNodeRef
7
+ remember_function :YGNodeNewWithConfig, [:YGConfigRef], :YGNodeRef
8
+ remember_function :YGNodeFree, [:YGNodeRef], :void
9
+ remember_function :YGNodeFreeRecursive, [:YGNodeRef], :void
10
+ remember_function :YGNodeReset, [:YGNodeRef], :void
11
+ remember_function :YGNodeGetInstanceCount, [], :int32_t
12
+
13
+ # Children
14
+ remember_function :YGNodeInsertChild, [:YGNodeRef, :YGNodeRef, :uint32_t], :void
15
+ remember_function :YGNodeRemoveChild, [:YGNodeRef, :YGNodeRef], :void
16
+ remember_function :YGNodeGetChild, [:YGNodeRef, :uint32_t], :YGNodeRef
17
+ remember_function :YGNodeGetParent, [:YGNodeRef], :YGNodeRef
18
+ remember_function :YGNodeGetChildCount, [:YGNodeRef], :uint32_t
19
+
20
+ # Layout
21
+ remember_function :YGNodeCalculateLayout, [
22
+ :YGNodeRef,
23
+ :float, # availableWidth
24
+ :float, # availibleHeight
25
+ :YGDirection, # parentDirection
26
+ ], :void
27
+ # Mark a node as dirty. Only valid for nodes with a custom measure
28
+ # function set. YG knows when to mark all other nodes as dirty but because
29
+ # nodes with measure functions depends on information not known to YG they
30
+ # must perform this dirty marking manually.
31
+ remember_function :YGNodeMarkDirty, [:YGNodeRef], :void
32
+ remember_function :YGNodeIsDirty, [:YGNodeRef], :bool
33
+
34
+ # Printing (for debug???)
35
+ remember_function :YGNodePrint, [:YGNodeRef, PrintOptions], :void
36
+
37
+ # No idea what this is used for
38
+ remember_function :YGNodeCanUseCachedMeasurement, [
39
+ :YGMeasureMode, # widthMode
40
+ :float, # width
41
+ :YGMeasureMode, # heightMode
42
+ :float, # height
43
+ :YGMeasureMode, # lastWidthMode
44
+ :float, # lastWidth
45
+ :YGMeasureMode, # lastHeightMode
46
+ :float, # lastHeight
47
+ :float, # lastComputedWidth
48
+ :float, # lastComputedHeight
49
+ :float, # marginRow
50
+ :float, # marginColumn
51
+ :YGConfigRef, # config
52
+ ], :bool
53
+
54
+ remember_function :YGNodeCopyStyle, [
55
+ :YGNodeRef, # destination
56
+ :YGNodeRef, # source
57
+ ], :void
58
+ end
59
+ end
@@ -0,0 +1,93 @@
1
+ # Auto-generated by Rake from Yoga.h
2
+ # Do not edit by hand
3
+ module YogaLayout
4
+ module Bindings
5
+ remember_function :YGNodeSetContext, [:YGNodeRef, :pointer], :void
6
+ remember_function :YGNodeGetContext, [:YGNodeRef], :pointer
7
+ remember_function :YGNodeSetMeasureFunc, [:YGNodeRef, :YGMeasureFunc], :void
8
+ remember_function :YGNodeGetMeasureFunc, [:YGNodeRef], :YGMeasureFunc
9
+ remember_function :YGNodeSetBaselineFunc, [:YGNodeRef, :YGBaselineFunc], :void
10
+ remember_function :YGNodeGetBaselineFunc, [:YGNodeRef], :YGBaselineFunc
11
+ remember_function :YGNodeSetPrintFunc, [:YGNodeRef, :YGPrintFunc], :void
12
+ remember_function :YGNodeGetPrintFunc, [:YGNodeRef], :YGPrintFunc
13
+ remember_function :YGNodeSetHasNewLayout, [:YGNodeRef, :bool], :void
14
+ remember_function :YGNodeGetHasNewLayout, [:YGNodeRef], :bool
15
+ remember_function :YGNodeSetNodeType, [:YGNodeRef, :YGNodeType], :void
16
+ remember_function :YGNodeGetNodeType, [:YGNodeRef], :YGNodeType
17
+ remember_function :YGNodeStyleSetDirection, [:YGNodeRef, :YGDirection], :void
18
+ remember_function :YGNodeStyleGetDirection, [:YGNodeRef], :YGDirection
19
+ remember_function :YGNodeStyleSetFlexDirection, [:YGNodeRef, :YGFlexDirection], :void
20
+ remember_function :YGNodeStyleGetFlexDirection, [:YGNodeRef], :YGFlexDirection
21
+ remember_function :YGNodeStyleSetJustifyContent, [:YGNodeRef, :YGJustify], :void
22
+ remember_function :YGNodeStyleGetJustifyContent, [:YGNodeRef], :YGJustify
23
+ remember_function :YGNodeStyleSetAlignContent, [:YGNodeRef, :YGAlign], :void
24
+ remember_function :YGNodeStyleGetAlignContent, [:YGNodeRef], :YGAlign
25
+ remember_function :YGNodeStyleSetAlignItems, [:YGNodeRef, :YGAlign], :void
26
+ remember_function :YGNodeStyleGetAlignItems, [:YGNodeRef], :YGAlign
27
+ remember_function :YGNodeStyleSetAlignSelf, [:YGNodeRef, :YGAlign], :void
28
+ remember_function :YGNodeStyleGetAlignSelf, [:YGNodeRef], :YGAlign
29
+ remember_function :YGNodeStyleSetPositionType, [:YGNodeRef, :YGPositionType], :void
30
+ remember_function :YGNodeStyleGetPositionType, [:YGNodeRef], :YGPositionType
31
+ remember_function :YGNodeStyleSetFlexWrap, [:YGNodeRef, :YGWrap], :void
32
+ remember_function :YGNodeStyleGetFlexWrap, [:YGNodeRef], :YGWrap
33
+ remember_function :YGNodeStyleSetOverflow, [:YGNodeRef, :YGOverflow], :void
34
+ remember_function :YGNodeStyleGetOverflow, [:YGNodeRef], :YGOverflow
35
+ remember_function :YGNodeStyleSetDisplay, [:YGNodeRef, :YGDisplay], :void
36
+ remember_function :YGNodeStyleGetDisplay, [:YGNodeRef], :YGDisplay
37
+ remember_function :YGNodeStyleSetFlex, [:YGNodeRef, :float], :void
38
+ remember_function :YGNodeStyleGetFlex, [:YGNodeRef], :float
39
+ remember_function :YGNodeStyleSetFlexGrow, [:YGNodeRef, :float], :void
40
+ remember_function :YGNodeStyleGetFlexGrow, [:YGNodeRef], :float
41
+ remember_function :YGNodeStyleSetFlexShrink, [:YGNodeRef, :float], :void
42
+ remember_function :YGNodeStyleGetFlexShrink, [:YGNodeRef], :float
43
+ remember_function :YGNodeStyleSetFlexBasis, [:YGNodeRef, :float], :void
44
+ remember_function :YGNodeStyleSetFlexBasisPercent, [:YGNodeRef, :float], :void
45
+ remember_function :YGNodeStyleGetFlexBasis, [:YGNodeRef], :YGValue
46
+ remember_function :YGNodeStyleSetFlexBasisAuto, [:YGNodeRef], :void
47
+ remember_function :YGNodeStyleSetPosition, [:YGNodeRef, :YGEdge, :float], :void
48
+ remember_function :YGNodeStyleSetPositionPercent, [:YGNodeRef, :YGEdge, :float], :void
49
+ remember_function :YGNodeStyleGetPosition, [:YGNodeRef, :YGEdge], :YGValue
50
+ remember_function :YGNodeStyleSetMargin, [:YGNodeRef, :YGEdge, :float], :void
51
+ remember_function :YGNodeStyleSetMarginPercent, [:YGNodeRef, :YGEdge, :float], :void
52
+ remember_function :YGNodeStyleGetMargin, [:YGNodeRef, :YGEdge], :YGValue
53
+ remember_function :YGNodeStyleSetMarginAuto, [:YGNodeRef, :YGEdge], :void
54
+ remember_function :YGNodeStyleSetPadding, [:YGNodeRef, :YGEdge, :float], :void
55
+ remember_function :YGNodeStyleSetPaddingPercent, [:YGNodeRef, :YGEdge, :float], :void
56
+ remember_function :YGNodeStyleGetPadding, [:YGNodeRef, :YGEdge], :YGValue
57
+ remember_function :YGNodeStyleSetBorder, [:YGNodeRef, :YGEdge, :float], :void
58
+ remember_function :YGNodeStyleGetBorder, [:YGNodeRef, :YGEdge], :float
59
+ remember_function :YGNodeStyleSetWidth, [:YGNodeRef, :float], :void
60
+ remember_function :YGNodeStyleSetWidthPercent, [:YGNodeRef, :float], :void
61
+ remember_function :YGNodeStyleGetWidth, [:YGNodeRef], :YGValue
62
+ remember_function :YGNodeStyleSetWidthAuto, [:YGNodeRef], :void
63
+ remember_function :YGNodeStyleSetHeight, [:YGNodeRef, :float], :void
64
+ remember_function :YGNodeStyleSetHeightPercent, [:YGNodeRef, :float], :void
65
+ remember_function :YGNodeStyleGetHeight, [:YGNodeRef], :YGValue
66
+ remember_function :YGNodeStyleSetHeightAuto, [:YGNodeRef], :void
67
+ remember_function :YGNodeStyleSetMinWidth, [:YGNodeRef, :float], :void
68
+ remember_function :YGNodeStyleSetMinWidthPercent, [:YGNodeRef, :float], :void
69
+ remember_function :YGNodeStyleGetMinWidth, [:YGNodeRef], :YGValue
70
+ remember_function :YGNodeStyleSetMinHeight, [:YGNodeRef, :float], :void
71
+ remember_function :YGNodeStyleSetMinHeightPercent, [:YGNodeRef, :float], :void
72
+ remember_function :YGNodeStyleGetMinHeight, [:YGNodeRef], :YGValue
73
+ remember_function :YGNodeStyleSetMaxWidth, [:YGNodeRef, :float], :void
74
+ remember_function :YGNodeStyleSetMaxWidthPercent, [:YGNodeRef, :float], :void
75
+ remember_function :YGNodeStyleGetMaxWidth, [:YGNodeRef], :YGValue
76
+ remember_function :YGNodeStyleSetMaxHeight, [:YGNodeRef, :float], :void
77
+ remember_function :YGNodeStyleSetMaxHeightPercent, [:YGNodeRef, :float], :void
78
+ remember_function :YGNodeStyleGetMaxHeight, [:YGNodeRef], :YGValue
79
+ remember_function :YGNodeStyleSetAspectRatio, [:YGNodeRef, :float], :void
80
+ remember_function :YGNodeStyleGetAspectRatio, [:YGNodeRef], :float
81
+ remember_function :YGNodeLayoutGetLeft, [:YGNodeRef], :float
82
+ remember_function :YGNodeLayoutGetTop, [:YGNodeRef], :float
83
+ remember_function :YGNodeLayoutGetRight, [:YGNodeRef], :float
84
+ remember_function :YGNodeLayoutGetBottom, [:YGNodeRef], :float
85
+ remember_function :YGNodeLayoutGetWidth, [:YGNodeRef], :float
86
+ remember_function :YGNodeLayoutGetHeight, [:YGNodeRef], :float
87
+ remember_function :YGNodeLayoutGetDirection, [:YGNodeRef], :YGDirection
88
+ remember_function :YGNodeLayoutGetHadOverflow, [:YGNodeRef], :bool
89
+ remember_function :YGNodeLayoutGetMargin, [:YGNodeRef, :YGEdge], :float
90
+ remember_function :YGNodeLayoutGetBorder, [:YGNodeRef, :YGEdge], :float
91
+ remember_function :YGNodeLayoutGetPadding, [:YGNodeRef, :YGEdge], :float
92
+ end
93
+ end
@@ -0,0 +1,56 @@
1
+ require 'yoga_layout/wrapper'
2
+
3
+ module YogaLayout
4
+ # Config changes the way the Yoga layout system works.
5
+ #
6
+ # Yoga has the concept of experiments. An experiment is a feature which is
7
+ # not yet stable. To enable a feature use the
8
+ # {#set_experimental_feature_enabled} method. Once a feature has been tested
9
+ # and is ready to be released as a stable API we will remove its feature
10
+ # flag.
11
+ #
12
+ # @example Use web defaults by default
13
+ # YogaLayout::Config.default.set_use_web_defaults(true)
14
+ #
15
+ # @example Create a node tree with a custom config
16
+ # config = YogaLayout::Config.new
17
+ # node = YogaLayout::Node.new_with_config(config)
18
+ # node.insert_child(config.new_node, 0)
19
+ class Config < YogaLayout::Wrapper
20
+ # @override
21
+ # @api private
22
+ def self.unsafe_new_pointer
23
+ YogaLayout::Bindings.YGConfigNew
24
+ end
25
+
26
+ # @override
27
+ # @api private
28
+ def self.unsafe_free_pointer(pointer)
29
+ YogaLayout::Bindings.YGConfigFree(pointer)
30
+ end
31
+
32
+ # Use this to adjust the default settings.
33
+ def self.default
34
+ # Not using auto_ptr, because you can't deallocate the default config
35
+ @default ||= new(YogaLayout::Bindings.YGConfigGetDefault)
36
+ end
37
+
38
+ # Convinience method to create new nodes with this config.
39
+ #
40
+ # @return [YogaLayout::Node]
41
+ def new_node
42
+ YogaLayout::Node.new_with_config(self)
43
+ end
44
+
45
+ map_method(:copy_from, :YGConfigCopy)
46
+
47
+ map_method(:set_point_scaling_factor, :YGConfigSetPointScaleFactor)
48
+ map_method(:set_use_legacy_stretch_behavior, :YGConfigSetUseLegacyStretchBehaviour)
49
+
50
+ map_method(:set_experimental_feature_enabled, :YGConfigSetExperimentalFeatureEnabled)
51
+ map_method(:experimental_feature_enabled?, :YGConfigIsExperimentalFeatureEnabled)
52
+
53
+ map_method(:set_use_web_defaults, :YGConfigSetUseWebDefaults)
54
+ map_method(:use_web_defaults?, :YGConfigGetUseWebDefaults)
55
+ end
56
+ end