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

LVGL allow access to lv.LAYOUT_GRID and lv.LAYOUT_FLEX #17948

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

s-hadinger
Copy link
Collaborator

Description:

LVGL allow access to lv.LAYOUT_GRID and lv.LAYOUT_FLEX. The mapping requires a helper accessor function since they are not constants.

Example of script:

lv.start()

hres = lv.get_hor_res()       # should be 320
vres = lv.get_ver_res()       # should be 240

var col_dsc = lv.coord_arr([70, 70, 70, lv.GRID_TEMPLATE_LAST])
var row_dsc = lv.coord_arr([50, 50, 50, lv.GRID_TEMPLATE_LAST])

# Create a container with grid
var cont = lv.obj(lv.scr_act())
cont.set_style_grid_column_dsc_array(col_dsc, 0)
cont.set_style_grid_row_dsc_array(row_dsc, 0)
# cont.set_size(300, 220)

cont.set_size(hres - 10,vres - 10)
cont.set_pos(10,30)

cont.center()
cont.set_layout(lv.LAYOUT_GRID) # issue

for i:0..9
    var col = i % 3
    var row = i / 3

    var obj = lv.btn(cont)
    # Stretch the cell horizontally and vertically too
    # Set span to 1 to make the cell 1 column/row sized
    obj.set_grid_cell(lv.GRID_ALIGN_STRETCH, col, 1,
                      lv.GRID_ALIGN_STRETCH, row, 1) # issue

    var label = lv.label(obj)
    label.set_text("c" +str(col) +  "r" +str(row))
    label.center()
end

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works with Tasmota core ESP32 V.2.0.6
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@s-hadinger s-hadinger merged commit fcec5a5 into arendst:development Feb 14, 2023
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