eez-open / studio

Cross-platform low-code GUI and automation
https://www.envox.eu/studio/studio-introduction/
GNU General Public License v3.0
609 stars 101 forks source link

[LVGL] Tables #613

Closed ajayre closed 3 weeks ago

ajayre commented 3 weeks ago

LVGL 9.1

How can I populate and style tables in the editor? Is there a place to enter custom LVGL API code and have it execute with the Run button?

mvladic commented 3 weeks ago

Not possible right now from the Studio. In Studio, you can only create Table widget, the rest must be done from the code.

ajayre commented 3 weeks ago

I edited ui.c and added to the end of ui_init() the following:

    lv_table_set_row_count(TimingTable, 3);
    lv_table_set_column_count(TimingTable, 3);
    lv_table_set_cell_value(TimingTable, 1, 1, "Content");

It checks and builds OK but when I Run it in EEZ Studio these lines have no effect. Am I adding them in the wrong place? Or is simulating the table in EEZ Studio not possible at all?

Thanks!

mvladic commented 3 weeks ago

What is TimingTable, how this variable is initialized?

ajayre commented 3 weeks ago

It is the name of the table widget.

I now tried this:

Created a native user action called ScreenLoaded Went to the screen properties Added a SCREEN_LOADED event handler, type action, action ScreenLoaded Created action.cpp with the following contents:

#include <lvgl/lvgl.h>

#include "actions.h"
#include "screens.h"
#include "ui.h"

void action_ScreenLoaded(lv_event_t *e)
{
    lv_table_set_row_count(TimingTable, 3);
    lv_table_set_column_count(TimingTable, 3);
    lv_table_set_cell_value(TimingTable, 1, 1, "Content");
}

Checks and builds OK but doesn't seem to affect the table. I must be missing a step?

Thanks.

mvladic commented 3 weeks ago

Usually, widget objects are accessed with objects.my_widget_name where my_widget_name is entered in the Name property of the widget. So, that is the reason why I asking how TimingTable is initialized, as it doesn't have objects. prefix.

ajayre commented 3 weeks ago

Thanks! I changed it to:

objects.injector_timing_table

and it still doesn't work. I then added some junk to the action.cpp file and it still checks, builds and runs without error. So it seems this file is not being used at all?

I then added some junk to ui_init() and same thing - checks, builds and runs. I am confused.

void ui_init() {
    create_screens();
    loadScreen(SCREEN_ID_MAIN);
    fffff
}
mvladic commented 3 weeks ago

If you are using CMake then maybe you should run cmake command to include newly added source files.

ajayre commented 3 weeks ago

I am just clicking on the Build button in EEZ Studio. Does that not compile the files each time?

The build output shows that actions.cpp is being built, but I can add junk to ui.c which was already added when the project was created.

mvladic commented 3 weeks ago

Studio build just builds/generates source files to be included in your C/C++ project. You need to make sure these source file are included in your Makefile, but this depends how exactly you are building your C/C++ project.

ajayre commented 3 weeks ago

So right now I don't have a target. I am only creating the UI and simulating it in EEZ Studio. It seems I can't do anything with the table widget because EEZ Studio doesn't use the source files at all, right?

mvladic commented 3 weeks ago

Yes. These changes in actions.cpp you can only test on your device or you can build your project using Emscripten and test it inside web browser - check this repository how to do that https://github.com/lvgl/lv_web_emscripten.

ajayre commented 3 weeks ago

Oh, ok, thanks, Would be nice if full graphical support of creating tables was included because my application really needs them.