vpaeder / lvglpp

A C++ wrapper for LVGL
MIT License
34 stars 12 forks source link

get_width/height/content_width.. returning 0 #4

Open KimBP opened 3 days ago

KimBP commented 3 days ago

I make a class, say ContDer derived from Container supposed to contain some subobjects.

In my code I first create a 'screen' based on root which is my scr_act();

auto root = src_act(); screen = std::make_unique(root); screen->set_size(root.get_width(), root.get_height()); I then set it up for grid layout I can print out root dimensions which are correct. but printing out screen dimension (screen->get_width() ) just returns 0

Inside screen I create an ContDer object which due to my column descriptor becomes half the size of screen (With borders enabled I can see it works correct)

contDer = std::make_unique(*screen);

In my constructor of condDer I want to add yet a container supposed to 'host' a label. I call it nameContainer

Container nameContainer(*this); nameContainer.set_size(this->get_content_width(), someHeight);

By some reason get_content_width() as well as get_width() and corresponding height functions return 0.

Except from putting it into my class I don't find it different from what you show in the last example in the README.

Any suggestion on that problem?

vpaeder commented 2 days ago

The get_width function calls lv_area_get_width. Why this returns 0 is not clear to me. The object exists and is valid, otherwise it'd crash. Have you tried setting a constant width? If yes, do you also get 0 when you request the size?

KimBP commented 1 day ago

Yeah - I guess this relates to my 'outer' container (screen) having a grid layout somehow even though I can't see why this container, which is of a 'const size' does also it self return 0. Looking more into your code I see it is just the 'raw' pointer being referred, so it must occur from something in the LVGL somehow.

Nice work by the way. I have integrated your module with a Zephyr project. A few issues corrected. My only issue right now is a single warning in the font module I think.