Skip to content
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

guiSetStyle api using wrong types #131

Open
JRMurr opened this issue Aug 11, 2024 · 5 comments
Open

guiSetStyle api using wrong types #131

JRMurr opened this issue Aug 11, 2024 · 5 comments

Comments

@JRMurr
Copy link

JRMurr commented Aug 11, 2024

In #125 I think the proposed api is wrong.

The first param should be rg.GuiControl and the second param is slightly weird.

It can be rg.GuiControlProperty or rg.GuiDefaultProperty. I'm newish to zig still so not sure the best way to handle merging these two enums together, maybe we have two different wrapper funcs for this?

fn guiSetStyle(control: rg.GuiControl, property: rg.GuiControlProperty, value: i32) void
fn guiSetStyleDefualt(control: rg.GuiControl, property: rg.GuiDefaultProperty, value: i32) void
@JRMurr
Copy link
Author

JRMurr commented Aug 12, 2024

Actually i think all of the enums that end with Property are valid here. I think it depends on what control value you pass in for the first param (but not fully positive).

Maybe this func should be reverted to the old raw c_int style and we make our own wrapper api thats nested enum based?

@Not-Nik
Copy link
Owner

Not-Nik commented Aug 17, 2024

This could just be resolved with anytype and casting, but we loose type safety. I'll look into possible comptime assertions to fix this. Thanks

@elasticdog
Copy link

I believe with the changes made in #125 you can no longer set any default properties like changing the text_size, right? The control was made raygui.GuiState, but shouldn't it be raygui.GuiControl?

@everystone
Copy link

everystone commented Sep 30, 2024

I just ran into this issue trying to set default text size. There is no way of doing this now if I am not mistaken?

pub fn guiSetStyle(control: GuiState, property: GuiControlProperty, value: i32) void {
    cdef.GuiSetStyle(control, property, @as(c_int, value));
}

How can I pass GuiDefaultProperty.text_size to this function?

@Not-Nik
Copy link
Owner

Not-Nik commented Oct 2, 2024

I've reverted the API back to taking i32 for now, so any property can be passed with a single cast. I'll hopefully find some more time to investigate this, in October

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants