XuNeo / luavgl

lua + lvgl = luavgl An optimized lvgl Lua binding
MIT License
68 stars 15 forks source link

Property won't work in complex inherency situation #61

Closed XuNeo closed 2 months ago

XuNeo commented 3 months ago

Introduce the problem

E.g. Image's base class is obj. The latter has align property. luavgl makes align property easier to use by accepting two kinds of align parameter:

obj.align = lvgl.ALIGN.CENTER
obj.align = {
  type = lvgl.ALIGN.CENTER,
  x_ofs = 10,
  y_ofs = 10,
}

Now in order to set image obj's property, luavgl will firstly search luavgl's custom property, and find out image does't override align(because obj does), then luavgl try lvgl's property API and find the correct one.

The issue is that lvgl's property API doesn't support two kinds of align parameter, because it's a simple int value.

Proposal

  1. Follow strickly property value definition with lvgl.
  2. Try to search property class by class, firstly luavgl then lvgl.
  3. Add property type of _TYPE_ALIGN to accept a struct of parameters.