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

fix(lua) - Store and update the 'zone' rectangle for Lua widgets. #3060

Merged
merged 2 commits into from
Feb 20, 2023

Conversation

philmoz
Copy link
Collaborator

@philmoz philmoz commented Jan 19, 2023

Fixes #2598

Summary of changes:

Implements solution from @jfrickmann in issue 2598:

  • Store the widget zone rectangle data in the Lua registry.
  • Updates the zone data when the layout changes.

Also calls the widget 'update' function if the zone has been altered.

@pfeerick pfeerick added color Related generally to color LCD radios lua labels Jan 25, 2023
@pfeerick pfeerick self-assigned this Jan 26, 2023
@philmoz philmoz force-pushed the lua-widget-zone branch 2 times, most recently from 567eeba to 067437e Compare February 1, 2023 21:48
Phil Mitchell added 2 commits February 19, 2023 16:22
…een layout changes or full screen mode changes. Allows Lua widgets to adjust to layout changes.
@pfeerick
Copy link
Member

pfeerick commented Feb 20, 2023

This is working beautifully with the sample widget code which was provided in #2598 ... i.e. w and h update automatically as changes are made that affect them.

local defaultOptions = {}

local function create(zone, options)
  return {zone=zone, options=options}
end

local function update(wgt, newOptions)
end

local function background(wgt)
end

local function refresh(wgt, event, touchstate)

  local st = string.format ("w=%s, h=%s, event=%s", wgt.zone.w, wgt.zone.h, event)
  lcd.drawText (wgt.zone.x, wgt.zone.y, st, SMLSIZE)
  lcd.drawRectangle (wgt.zone.x, wgt.zone.y, wgt.zone.w, wgt.zone.h)
end

return { name="paneinfo", options=defaultOptions, create=create, update=update, refresh=refresh, background=background }

@pfeerick pfeerick added this to the 2.9 milestone Feb 20, 2023
@pfeerick pfeerick added the documentation Improvements or additions to documentation label Feb 20, 2023
@pfeerick pfeerick merged commit 1df8fe8 into EdgeTX:main Feb 20, 2023
@philmoz philmoz deleted the lua-widget-zone branch September 20, 2023 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
color Related generally to color LCD radios documentation Improvements or additions to documentation lua
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lua widgets: zone width/height not updated after screen options are changed
2 participants