Skip to content

[enigma2] New TemplatedMultiContentEx converter#1268

Merged
Huevos merged 1 commit into
OpenViX:Developerfrom
xcentaurix:tmcx
Jun 11, 2026
Merged

[enigma2] New TemplatedMultiContentEx converter#1268
Huevos merged 1 commit into
OpenViX:Developerfrom
xcentaurix:tmcx

Conversation

@xcentaurix

Copy link
Copy Markdown
Contributor

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.)

	<widget enableWrapAround="1" position="20,65" render="Listbox" scrollbarMode="showNever" size="e-40,e-140" source="list" transparent="1">
		<convert type="TemplatedMultiContentEx">
			{
			"var": (
				ih := 70,
				hspace := 10,
				thumb_w := ih * 2 - 10,
				thumb_h := ih - 10,
				x1 := hspace // 2 + thumb_w + hspace,
				col3_w := ih * 3,
				col2_w := (e - x1) // 4,
				x3 := e - col3_w - hspace // 2,
				x2 := x3 - col2_w - hspace,
				col1_w := x2 - x1 - hspace
			),
			"template": [
				MultiContentEntryPixmapAlphaTest(pos=(hspace//2, (ih-thumb_h)//2), size=(thumb_w, thumb_h), png=0, backcolor=None, flags=BT_SCALE|BT_KEEP_ASPECT_RATIO),
				MultiContentEntryText(pos=(x1, 0), size=(col1_w, ih), flags=RT_VALIGN_CENTER, text=1),
				MultiContentEntryText(pos=(x2, 0), size=(col2_w, ih), flags=RT_VALIGN_CENTER, text=2),
				MultiContentEntryText(pos=(x3, 0), size=(col3_w, ih), flags=RT_VALIGN_CENTER|RT_HALIGN_RIGHT, text=3)
			],
			"fonts": [gFont("Regular", 26)],
			"itemHeight": ih
			}
		</convert>
	</widget>

... and the result:
tso

@Huevos Huevos merged commit 7c1f4ac into OpenViX:Developer Jun 11, 2026
1 check passed
@xcentaurix xcentaurix deleted the tmcx branch June 11, 2026 10:58
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