Skip to content

Commit

Permalink
Fix bindings after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Oct 22, 2023
1 parent dfcb3b5 commit 1494b27
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
30 changes: 27 additions & 3 deletions ctaffy/include/taffy.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ typedef enum TaffyGridAutoFlow {
TAFFY_GRID_AUTO_FLOW_COLUMN_DENSE,
} TaffyGridAutoFlow;

typedef enum TaffyMeasureMode {
// A none value (used to unset optional fields)
TAFFY_MEASURE_MODE_EXACT,
// Fixed Length (pixel) value
TAFFY_MEASURE_MODE_FIT_CONTENT,
// Percentage value
TAFFY_MEASURE_MODE_MIN_CONTENT,
// Min-content size
TAFFY_MEASURE_MODE_MAX_CONTENT,
} TaffyMeasureMode;

// How children overflowing their container should affect layout
//
// In CSS the primary effect of this property is to control whether contents of a parent container that overflow that container should
Expand Down Expand Up @@ -317,8 +328,6 @@ typedef struct TaffyNodeId {
uint64_t _0;
} TaffyNodeId;

typedef const struct TaffyTree *TaffyTreeConstRef;

typedef struct TaffyNodeIdResult {
enum TaffyReturnCode return_code;
struct TaffyNodeId value;
Expand All @@ -329,6 +338,13 @@ typedef struct TaffyStyleMutRefResult {
TaffyStyleMutRef value;
} TaffyStyleMutRefResult;

typedef struct TaffySize {
float width;
float height;
} TaffySize;

typedef struct TaffySize (*TaffyMeasureFunction)(enum TaffyMeasureMode width_measure_mode, float width, enum TaffyMeasureMode height_measure_mode, float height, void *context);

typedef struct TaffyLayout {
float x;
float y;
Expand All @@ -341,6 +357,8 @@ typedef struct TaffyResult_TaffyLayout {
struct TaffyLayout value;
} TaffyResult_TaffyLayout;

typedef const struct TaffyTree *TaffyTreeConstRef;

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
Expand Down Expand Up @@ -541,7 +559,7 @@ enum TaffyReturnCode TaffyTree_ComputeLayout(TaffyTreeMutRef raw_tree,
float available_height);

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

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

// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
enum TaffyReturnCode TaffyTree_SetNodeContext(TaffyTreeMutRef raw_tree,
struct TaffyNodeId node_id,
TaffyMeasureFunction measure_function,
void *context);

// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
struct TaffyResult_TaffyLayout TaffyTree_GetLayout(TaffyTreeConstRef raw_tree, struct TaffyNodeId node_id);

Expand Down
6 changes: 3 additions & 3 deletions ctaffy/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ pub unsafe extern "C" fn TaffyTree_ComputeLayout(
/// Create a new Node in the TaffyTree. Returns a NodeId handle to the node.
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn TaffyTree_PrintTree(raw_tree: TaffyTreeConstRef, node_id: TaffyNodeId) -> TaffyReturnCode {
with_tree!(raw_tree, tree, {
taffy::util::print_tree(&tree.inner, node_id.into());
pub unsafe extern "C" fn TaffyTree_PrintTree(raw_tree: TaffyTreeMutRef, node_id: TaffyNodeId) -> TaffyReturnCode {
with_tree_mut!(raw_tree, tree, {
tree.inner.print_tree(node_id.into());
TaffyReturnCode::Ok
})
}
Expand Down

0 comments on commit 1494b27

Please sign in to comment.