Just for some background, I'm creating a wrapper over GTK4 that allows the creation of widgets though a Lua config file similar to Elkowar's wacky widgets or Aylurs Gtk Widgets. Currently I've been able to pass widgets around wrapped in a struct that implements mlua::UserData and mlua::FromLua. This struct has a field that contains a gtk::Widget like the one with a gtk::Label I've implemented. Within the setup function I create and render a window that takes a child widget as a parameter to the builder. Currently I'm stuck on the implementation of a generic tsuki::Widget that can be used as the child with more specific types such as tsuki::Label being the actual widget passed. Sorry if the answer is super obvious. This is my first somewhat complicated using Rust.
#Issues implementing a trait correctly
15 messages · Page 1 of 1 (latest)
A tip for future questions, put the crate/type your working with in the title. Makes it easier to find things for people
Do you currently have any errors?
Actually no, my problem right now is within the create window function. I've hardcoded the tsuki::Label struct
I'm assuming I'd need to implement a trait or enum like tsuki::Widget but I haven't figured out how to without tons of errors
Hmm, one moment I need an actual computer to review large chunks of code
No worries, thanks for the help btw
For clarity's sake, I'm going to implement a tsuki::Button struct similar to the label one, and I'd like to be able to take either when pulling the variable
I think an enum works here
enum Widget {
Label(Label),
Button(Button),
}
I assume I'd have to write a match statement after
at some point yeah
I guess that makes sense, thanks