[enigma2] New TemplatedMultiContentEx converter#1268
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TemplatedMultiContentEx adds two things to the eval context:
e — the actual pixel width of the listbox widget, resolved at runtime from self.master.instance.size().width()
c — horizontal center shorthand (e // 2)
i = int — a short alias for explicit integer casting in expressions
Deferred template evaluation:
TemplatedMultiContent evaluates the template string once in init with a fixed set of skin/font locals and never revisits it. TemplatedMultiContentEx stores the raw args string and re-evaluates it in setTemplate() the first time a valid widget size is available (width > 0). This is what makes e meaningful — by setTemplate() time, applySkin has already resolved the widget's pixel dimensions.
_size_resolved flag:
The re-evaluation only happens once (first call with width > 0), so there's no repeated re-parsing on every list update.
In practice:
TemplatedMultiContent templates must use only constants and skin-time values. TemplatedMultiContentEx templates can express positions and sizes proportionally to the widget's actual width, making the layout automatically adapt to different screen resolutions without any hardcoded pixel values.
Here is an example of a skin:
(The "var" key was already supported in the original TemplatedMultiContent converter.)
... and the result:
