Interesting layout feature of <panels>

Moderators: Gully, peteru

Post Reply
prl
Wizard God
Posts: 32706
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Interesting layout feature of <panels>

Post by prl » Sat Jan 27, 2018 13:46

I noticed a possibly handy feature of the skin <panel/> element.

It's frequently used to position <screen/> elements as components of a displayed screen:

Code: Select all

	<panel pos="x,y" size="w,h">
		<panel name="SomeSubScreen"/>
	</panel>
But while I was having a look to see why it isn't possible to simplify that to what would seem to me to be the more logical:

Code: Select all

<panel name="SomeSubScreen" pos="x,y" size="w,h"/>
I discovered that panels can actually do some simple aligned layout. For example:

Code: Select all

		<panel position="695,570" size="240,23">
			<eLabel text="text 1" position="left" size="60,23" font="Regular;20" foregroundColor="white" transparent="1"/>
			<eLabel text="text 2" position="left" size="60,23" font="Regular;20" foregroundColor="white" transparent="1"/>
			<eLabel text="text 3" position="left" size="60,23" font="Regular;20" foregroundColor="white" transparent="1"/>
			<eLabel text="text 4" position="left" size="60,23" font="Regular;20" foregroundColor="white" transparent="1"/>
		</panel>
produces:
panelLayout.png
panelLayout.png (29.22 KiB) Viewed 1353 times
So, left adds elements from the left edge of the panel going right, right adds elements from the right edge going left, and top and bottom similarly from the top and bottom of the panel.

It looks like you can sensibly have both left and right aligned elements in the same panel, and top and bottom (though I haven't experimented with that), but the code isn't smart enough to do much that's likely to be useful if you try to use both vertical and horizontal alignment in the same panel (but putting panels within panels may allow you to do it).

There's also a fill position that allows the element to fill the panel exactly, and a layout="stack" panel attribute that lets you put the items inside the panel layered on top of each other if you give the same alignment.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: Interesting layout feature of <panels>

Post by IanSav » Sat Jan 27, 2018 13:52

Hi Prl,

Did you find a reason/solution for the need to have a panel within a panel to set the position?

Regards,
Ian.

prl
Wizard God
Posts: 32706
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Interesting layout feature of <panels>

Post by prl » Sat Jan 27, 2018 15:16

IanSav wrote:
Sat Jan 27, 2018 13:52
...
Did you find a reason/solution for the need to have a panel within a panel to set the position?
...

It's a scope thing. The screen named in the panel is processed in the context surrounding the panel, while the children of the panel element are processed in the context of the panel. I can understand the reasoning of it, but I don't necessarily agree with it.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Post Reply

Return to “Developers Community”