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

feat(obj): allow to create child obj inside property table #47

Merged
merged 1 commit into from
May 26, 2024

Conversation

XuNeo
Copy link
Owner

@XuNeo XuNeo commented May 26, 2024

This patch allows to create child obj directly in the property table. To make it looks like children are created recursively.

In fact, with this coding style, the children is created firstly and it's stored to property table with integer key. Simply find them out and set parent for them.

local lvgl = require("lvgl")

local root = lvgl.Object(nil, {
    flex = {
        flex_direction = "row",
        flex_wrap = "wrap",
        justify_content = "center",
        align_items = "center",
        align_content = "center",
    },
    w = 300,
    h = 75,
    align = lvgl.ALIGN.CENTER,
    lvgl.Object(nil, {
        w = 100,
        h = lvgl.PCT(100),
        lvgl.Label(nil, {
            text = string.format("label %d", 1)
        }):center()
    }):clear_flag(lvgl.FLAG.SCROLLABLE),

    lvgl.Object(nil, {
        w = 100,
        h = lvgl.PCT(100),
        lvgl.Label(nil, {
            text = string.format("label %d", 1)
        }):center()
    }):clear_flag(lvgl.FLAG.SCROLLABLE)
})

@XuNeo XuNeo merged commit f4b5c9c into master May 26, 2024
1 check passed
@XuNeo XuNeo deleted the child-obj-in-property-table branch May 26, 2024 17:29
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.

1 participant