Dominaezzz / kgl

Thin multiplatform wrappers for graphics.
Apache License 2.0
106 stars 14 forks source link

GLFW KeyboardKey `value` and `from` are internal preventing easy conversion from GLFW to custom class #14

Closed nlbuescher closed 4 years ago

nlbuescher commented 4 years ago

This also applies to MouseButton. Having the value be inaccessible makes it very difficult to convert the library-specific KeyboardKey into a library-agnostic custom class. Making value and from public would solve the issue.

Dominaezzz commented 4 years ago

Although I don't have any real issue with making them public, why is this preventing easy conversion? You can still use the enum in when expressions and in Maps. You also have the ordinal of the enum if you just want an integer.

nlbuescher commented 4 years ago

I have an inline class Key(val value: Int) that has its values defined in the companion (so pseudo enum). These values are already defined as the GLFW keycodes. If I had access to KeyboardKey.value, I would be able to convert with a simple fun Key.Companion.fromGlfw(key: KeyboardKey) = Key(key.value). As it stands I'd have to build a map as you say.

It's more of a convenience thing, but since the internal pointer variables of most wrapper classes are also public (cf Window), having just these values be internal seemed odd.

EDIT: I'm testing moving over from using GLFW cinterop to using KGL

Dominaezzz commented 4 years ago

Okay, for the sake of consistency I'll remove the internal modifier.