MoAlyousef / zfltk

Zig bindings for the FLTK gui library
MIT License
58 stars 7 forks source link

Color enums #4

Closed mgord9518 closed 1 year ago

mgord9518 commented 2 years ago

Zig does not appear to offer implicit conversion from enums to their underlying types. I've run into this issue as converting a u32 into an enum explicitly doesn't allow for values that aren't defined as values set in the enum, which becomes a problem when setting custom RGB colors.

Do you think a good solution would just be to change all color functions to use u32 as well (or offer enum-specific functions)? I've noticed as it is currently, it's a mixture of both

MoAlyousef commented 2 years ago

Hi At some point Color was defind as:

pub const Color = enum(u32) 

This was changed to a struct. I had planned to add methods to it which would accept RGB values. These could then be used with widget methods taking Color. I didn't get yet to refactoring the rest of the code.

As to my preference, I would prefer to stick with a Color struct, since the FLTK color representation (RGBI) is a bit unintuitive.

MoAlyousef commented 2 years ago

I've pushed a proof of concept. The changes might be a lot, but it's to make zfltk build with latest zig.