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

[gui] include now supports nested element processing #11850

Merged
merged 1 commit into from Jan 13, 2018

Conversation

@xhaggi
Copy link
Member

commented Mar 13, 2017

Extends our GUI lib and adds support to use a nested element to include a XML fragment which is defined between the start-tag and end-tag of an include element. The nested part can contain anything what is valid in our skin language. Using parameters for the nested XML fragment is also supported.

This is really handy if you want to re-use XML fragments before and after some variable XML nested fragment e.g. a menu with variable items. Currently you need to specify a menu_top and menu_bottom include definition and include it before and after your variable XML fragment.

<!-- define a nested include -->
<include name="nested_include">
  <control type="group">
    <include>OtherInclude</include>
    <!-- nested element, used to indicate where to place the nested elements of include body -->
    <nested />
  </control>
</include>

<!-- use the nested include -->
<include content="nested_include">
  <param name="x" value="v1" />
  <param name="y" value="v2" />
  <!-- nested elements -->
  <control type="label">..</control> 
  <control type="group">
    <control type="label">..</control> 
  </control> 
</include>
@xhaggi

This comment has been minimized.

Copy link
Member Author

commented Mar 21, 2017

@xbmc/team-skinners ping you all

@phil65

This comment has been minimized.

Copy link
Member

commented Mar 28, 2017

Didnt test, but idea makes sense, I can also imagine some places where this could be useful.

@MartijnKaijser

This comment has been minimized.

Copy link
Member

commented Apr 15, 2017

Ping @ronie for testing

@MartijnKaijser

This comment has been minimized.

Copy link
Member

commented May 12, 2017

jenkins build this please

@MartijnKaijser

This comment has been minimized.

Copy link
Member

commented May 20, 2017

Ping to skinners

@HitcherUK

This comment has been minimized.

Copy link
Contributor

commented May 20, 2017

I'm not sure I fully understand how to use it.

@gade01

This comment has been minimized.

Copy link

commented May 20, 2017

I'm not sure I fully understand how to use it.

Phew, then I'm not the only one. ;)

I'm sure this will be very useful once I understand how to implement it.

@xhaggi

This comment has been minimized.

Copy link
Member Author

commented May 21, 2017

Imagine you need a frame/container where you only want to change the inner controls for various scenarios. In Xperience1080 we have a menu with a header and footer which is always the same, but the items within this menu should differ in various windows. ATM the only way to achieve this is using two includes (header and footer) and place the menu item controls between. With this changes you only need one include which surrounds the nested XML fragment, the menu items.

Before:

<include content="OptionMenuHeader" />
<!-- put your menu item controls here -->
<include content="OptionMenuFooter" />

After:

<include content="OptionMenu">
  <!-- put your menu item controls here -->
</include>

In case you want to use variable header and footer labels the old way would become more and more hard to read and use.

Before:

<include content="OptionMenuHeader">
  <param name="Label" value="Header" />
</include>
<!-- put your menu item controls here -->
<include content="OptionMenuFooter">
  <param name="Label" value="Footer" />
</include>

After:

<include content="OptionMenu">
  <param name="LabelHeader" value="Header" />
  <param name="LabelFooter" value="Footer" />
  <!-- put your menu item controls here -->
</include>

Another advantage if you use modern editors like Sublime you can use block level code folding to collapse the whole include.

@HitcherUK

This comment has been minimized.

Copy link
Contributor

commented May 21, 2017

Is this correct?

Before -

Define include

<include name="OptionMenuHeader">
	...
</include>
<include name="OptionMenuFooter">
	...
</include>

Use include

<include content="OptionMenuHeader">
	...
</include>
	<!-- Other controls -->
<include content="OptionMenuFooter">
	...
</include>

After -

Define include

<include content="OptionMenu">
	<include name="OptionMenuHeader">
		<!-- Header controls -->
	</include>
		<nested/>
	<include name="OptionMenuFooter">
		<!-- Footer controls -->
	</include>
</include>

or

<include content="OptionMenu">
	<!-- Header controls -->
		<nested/>
	<!-- Footer controls -->
</include>

Use include

<include content="OptionMenu">
	<!-- Other controls -->
</include>
@xhaggi

This comment has been minimized.

Copy link
Member Author

commented May 21, 2017

You define the controls nested into the specified include within the body of the include element.
Everything else is correct.

Use include

<include content="OptionMenu">
	<!-- Other controls -->
</include>
@xhaggi

This comment has been minimized.

Copy link
Member Author

commented May 21, 2017

Here is a real world example.

Include definition:
https://pastebin.com/8QTSRiEY

Use of include:
https://pastebin.com/UuqDFnxp

@HitcherUK

This comment has been minimized.

Copy link
Contributor

commented May 21, 2017

You define the controls nested into the specified include within the body of the include element.
Everything else is correct.

That's actually what I meant to post.

Thanks for adding this.

@MartijnKaijser

This comment has been minimized.

Copy link
Member

commented Jun 10, 2017

@xhaggi this needs a rebase

@phil65
phil65 approved these changes Nov 19, 2017
nested = node;
target = controls;
}
else {

This comment has been minimized.

Copy link
@phil65

phil65 Nov 19, 2017

Member

bracket to next line

@xhaggi xhaggi force-pushed the xhaggi:gui-include-nested branch 2 times, most recently from 31f27b8 to 6e18ec6 Nov 20, 2017
@xhaggi xhaggi force-pushed the xhaggi:gui-include-nested branch from 6e18ec6 to 01c328d Nov 20, 2017
@xhaggi xhaggi merged commit d2ef378 into xbmc:master Jan 13, 2018
1 check passed
1 check passed
default You're awesome. Have a cookie
Details
@xhaggi xhaggi deleted the xhaggi:gui-include-nested branch Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.