Not-Nik / raylib-zig

Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib
MIT License
691 stars 122 forks source link

guiSetStyle api using wrong types #131

Open JRMurr opened 3 months ago

JRMurr commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

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 commented 1 month ago

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 commented 1 month ago

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