Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add declarative example #63

Merged
merged 3 commits into from
Aug 18, 2024
Merged

Add declarative example #63

merged 3 commits into from
Aug 18, 2024

Conversation

XuNeo
Copy link
Owner

@XuNeo XuNeo commented Aug 18, 2024

Add declarative example:

Object {
    flex = {
        flex_direction = "row",
        flex_wrap = "wrap",
        justify_content = "center",
        align_items = "center",
        align_content = "center",
    },
    w = 400,
    h = 100,
    align = lvgl.ALIGN.CENTER,

    -- Button with label, inside a container
    Object {
        w = 150,
        h = lvgl.PCT(80),
        bg_color = "#aa0",

        Button {
            Label {
                text = string.format("BUTTON %d", 1),
                align = lvgl.ALIGN.CENTER
            }
        }:center()
    }:clear_flag(lvgl.FLAG.SCROLLABLE),

    -- Label inside a container
    Object({
        w = 150,
        h = lvgl.PCT(80),
        Label {
            text = string.format("label %d", 2)
        }:center()
    }):clear_flag(lvgl.FLAG.SCROLLABLE)
}

@XuNeo XuNeo merged commit 9413c48 into master Aug 18, 2024
1 check passed
@XuNeo XuNeo deleted the t5 branch August 18, 2024 13:20
@kisvegabor
Copy link

Really impressive! Just one thing which bothers me: how does the user know that flex_direction is inside a flex? It makes sense, but as it doesn't mimic LVGL's C API basically everything needs to be documented.

Or am I missing something?

@XuNeo
Copy link
Owner Author

XuNeo commented Aug 31, 2024

flex_direction is inside a flex?

It doesn't need to be.
It's one of the several optimizations made in luavgl to group the parameters related together, like the align we mentioned before. Use the LVGL's C API style will also work.

It certainly does need documentation https://github.com/XuNeo/luavgl/blob/master/src/lvgl.lua
image

@kisvegabor
Copy link

I see, very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants