-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose node position in C API #293
Conversation
node: *const Node, | ||
node_data: *mut CTextNode, | ||
) { | ||
pub unsafe extern "C" fn gosub_render_tree_get_node_data(node: *const Node, c_node: *mut CNode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new struct CNode
introduced to more properly wrap the node_t
struct from the C API. This is more generic than the previous CTextNode
when we add more types
// TODO: it'll be good at some point in the future to have the | ||
// margins to compute the expected_y position instead of manually | ||
// doing math. This will make the tests more robust if we change | ||
// margins/etc. in the engine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converting this to issue
pub fn new_root() -> Self { | ||
Self::default() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really needed or used, but leaving it here "for completion" (typically the root node is always skipped in the iterator because it's not really useful)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although now that I think about it, for the purpose of the RenderTree
, the root node is technically not a visible node so should probably be skipped in the iterator itself anyways
double render_tree_node_get_x(const struct node_t *node); | ||
double render_tree_node_get_y(const struct node_t *node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to attach these functions to the node_t structs. The only problem I'd see with attaching them to the node_t is, that it could make it harder to call them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean exactly? These already take a node_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, what i meant is a c++ only feature thought, i did this once in C. Also, i thought i had seen this once in a c library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yea c++ allows methods in structs since they’re a special case of a class in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some people put function pointers in structs but I only do that if it’s really necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I thought this was possible because C had no classes. But probably when c had this, there would be no c++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some people put function pointers in structs, but I only do that if it’s really necessary
Ah, probably I was a bit confused with this then.
This is a small extension to the C API to expose the node position. After this is merged the user agent can be changed to use positions instead of the default vertical-stack layout