Skip to content

Commit 1494b27

Browse files
committed
Fix bindings after rebase
1 parent dfcb3b5 commit 1494b27

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

ctaffy/include/taffy.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ typedef enum TaffyGridAutoFlow {
166166
TAFFY_GRID_AUTO_FLOW_COLUMN_DENSE,
167167
} TaffyGridAutoFlow;
168168

169+
typedef enum TaffyMeasureMode {
170+
// A none value (used to unset optional fields)
171+
TAFFY_MEASURE_MODE_EXACT,
172+
// Fixed Length (pixel) value
173+
TAFFY_MEASURE_MODE_FIT_CONTENT,
174+
// Percentage value
175+
TAFFY_MEASURE_MODE_MIN_CONTENT,
176+
// Min-content size
177+
TAFFY_MEASURE_MODE_MAX_CONTENT,
178+
} TaffyMeasureMode;
179+
169180
// How children overflowing their container should affect layout
170181
//
171182
// In CSS the primary effect of this property is to control whether contents of a parent container that overflow that container should
@@ -317,8 +328,6 @@ typedef struct TaffyNodeId {
317328
uint64_t _0;
318329
} TaffyNodeId;
319330

320-
typedef const struct TaffyTree *TaffyTreeConstRef;
321-
322331
typedef struct TaffyNodeIdResult {
323332
enum TaffyReturnCode return_code;
324333
struct TaffyNodeId value;
@@ -329,6 +338,13 @@ typedef struct TaffyStyleMutRefResult {
329338
TaffyStyleMutRef value;
330339
} TaffyStyleMutRefResult;
331340

341+
typedef struct TaffySize {
342+
float width;
343+
float height;
344+
} TaffySize;
345+
346+
typedef struct TaffySize (*TaffyMeasureFunction)(enum TaffyMeasureMode width_measure_mode, float width, enum TaffyMeasureMode height_measure_mode, float height, void *context);
347+
332348
typedef struct TaffyLayout {
333349
float x;
334350
float y;
@@ -341,6 +357,8 @@ typedef struct TaffyResult_TaffyLayout {
341357
struct TaffyLayout value;
342358
} TaffyResult_TaffyLayout;
343359

360+
typedef const struct TaffyTree *TaffyTreeConstRef;
361+
344362
#ifdef __cplusplus
345363
extern "C" {
346364
#endif // __cplusplus
@@ -541,7 +559,7 @@ enum TaffyReturnCode TaffyTree_ComputeLayout(TaffyTreeMutRef raw_tree,
541559
float available_height);
542560

543561
// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
544-
enum TaffyReturnCode TaffyTree_PrintTree(TaffyTreeConstRef raw_tree, struct TaffyNodeId node_id);
562+
enum TaffyReturnCode TaffyTree_PrintTree(TaffyTreeMutRef raw_tree, struct TaffyNodeId node_id);
545563

546564
// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
547565
struct TaffyNodeIdResult TaffyTree_NewNode(TaffyTreeMutRef raw_tree);
@@ -557,6 +575,12 @@ enum TaffyReturnCode TaffyTree_AppendChild(TaffyTreeMutRef raw_tree,
557575
// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
558576
struct TaffyStyleMutRefResult TaffyTree_GetStyleMut(TaffyTreeMutRef raw_tree, struct TaffyNodeId node_id);
559577

578+
// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
579+
enum TaffyReturnCode TaffyTree_SetNodeContext(TaffyTreeMutRef raw_tree,
580+
struct TaffyNodeId node_id,
581+
TaffyMeasureFunction measure_function,
582+
void *context);
583+
560584
// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
561585
struct TaffyResult_TaffyLayout TaffyTree_GetLayout(TaffyTreeConstRef raw_tree, struct TaffyNodeId node_id);
562586

ctaffy/src/tree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ pub unsafe extern "C" fn TaffyTree_ComputeLayout(
102102
/// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
103103
#[no_mangle]
104104
#[allow(clippy::missing_safety_doc)]
105-
pub unsafe extern "C" fn TaffyTree_PrintTree(raw_tree: TaffyTreeConstRef, node_id: TaffyNodeId) -> TaffyReturnCode {
106-
with_tree!(raw_tree, tree, {
107-
taffy::util::print_tree(&tree.inner, node_id.into());
105+
pub unsafe extern "C" fn TaffyTree_PrintTree(raw_tree: TaffyTreeMutRef, node_id: TaffyNodeId) -> TaffyReturnCode {
106+
with_tree_mut!(raw_tree, tree, {
107+
tree.inner.print_tree(node_id.into());
108108
TaffyReturnCode::Ok
109109
})
110110
}

0 commit comments

Comments
 (0)