Group Control: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Jmarshall
(New page: The group control is one of the most important controls. It allows you to group controls together, applying attributes to all of them at once. It also remembers the last navigated button i...)
 
No edit summary
 
(15 intermediate revisions by 6 users not shown)
Line 1: Line 1:
The group control is one of the most important controls. It allows you to group controls together, applying attributes to all of them at once. It also remembers the last navigated button in the group, so you can set the <onup> of a control to a group of controls to have it always go back to the one you were at before. It also allows you to position controls more accurately relative to each other, as any controls within a group take their coordinates from the group's top left corner (or from elsewhere if you use the "r" attribute). You can have as many groups as you like within the skin, and groups within groups are handled with no issues.
<section begin="main content" />
===Example===
The group control is one of the most important controls. It allows you to group controls together, applying attributes to all of them at once. It also remembers the last navigated button in the group, so you can set the <onup> of a control to a group of controls to have it always go back to the one you were at before. It also allows you to position controls more accurately relative to each other, as any controls within a group take their coordinates from the group's top left corner (or from elsewhere if you use the "r" attribute). You can have as many groups as you like within the skin, and groups within groups are handled with no issues.
<xml>
=== Example ===
<syntaxhighlight lang="xml" enclose="div">
<control type="group" id="17">
<control type="group" id="17">
       <description>My first group control</description>
       <description>My first group control</description>
       <posx>80</posx>
       <left>80</left>
       <posy>60</posy>
       <top>60</top>
       <width>250</width>
       <width>250</width>
       <height>30</height>
       <height>30</height>
Line 16: Line 17:
       ... more controls go here ...
       ... more controls go here ...
</control>
</control>
</xml>
</syntaxhighlight>
===Available Tags===
=== Available tags ===
In addition to the [[Default Control Tags]] the following tags are available. Note that each tag is '''lower case''' only. This is important, as xml tags are case-sensitive.
In addition to the [[Default Control Tags]] the following tags are available. Note that each tag is '''lower case''' only. This is important, as xml tags are case-sensitive.
{| class="dtable"
{| class="prettytable"
|- class="userrow"
! Tag !! Description
| class="usercell" | '''defaultcontrol'''
|-  
| class="usercell" | Specifies the default control that will be focused within the group when the group receives focus.  Note that the group remembers it's previously focused item and will return to it.
| '''defaultcontrol'''
| Specifies the default control that will be focused within the group when the group receives focus.  Note that the group remembers it's previously focused item and will return to it.
|}
|}
===Notes on positioning of controls within groups===
 
All controls within a group take their positions relative to the group's placement. Thus, the group always requires its <posx>, <posy>, <width>, and <height> attributes to be defined. As this can be a pain to remember, anything that you don't specify will be inherited from it's parent group (or the main window).
=== Notes on positioning of controls within groups ===
All controls within a group take their positions relative to the group's placement. Thus, the group always requires its <left>, <top>, <width>, and <height> attributes to be defined. As this can be a pain to remember, anything that you don't specify will be inherited from it's parent group (or the main window).


By way of example, consider the first group within a PAL full screen window (720x576), and suppose we have
By way of example, consider the first group within a PAL full screen window (720x576), and suppose we have
<xml>
<syntaxhighlight lang="xml" enclose="div">
<control type="group" id="15">
<control type="group" id="15">
   <posx>30</posx>
   <left>30</left>
   <posy>70</posy>
   <top>70</top>
   <width>400</width>
   <width>400</width>
   ... more controls go here ...
   ... more controls go here ...
</control>
</control>
</xml>
</syntaxhighlight>
so that the <height> hasn't been defined. Then XBMC will automatically set the <height> equal to 506 by inheriting this from the window's height of 576, less the <posy> amount.
so that the <height> hasn't been defined. Then Kodi will automatically set the <height> equal to 506 by inheriting this from the window's height of 576, less the <top> amount.


You can align controls within a group to the right edge of the group, by using the "r" modifier to the <posx> and <posy> fields
You can align controls within a group to the right edge of the group, by using the "r" modifier to the <left> and <top> fields
<xml>
<syntaxhighlight lang="xml" enclose="div">
<control type="group" id="20">
<control type="group" id="20">
   <control type="button" id=2>
   <control type="button" id=2>
     <posx>180r</posx>
     <left>180r</left>
     <width>180</width>
     <width>180</width>
   </control>
   </control>
   <control type="button" id=3>
   <control type="button" id=3>
     <posx>180r</posx>
     <left>180r</left>
     <width>180</width>
     <width>180</width>
   </control>
   </control>
   <control type="button" id=4>
   <control type="button" id=4>
     <posx>180r</posx>
     <left>180r</left>
     <width>180</width>
     <width>180</width>
   </control>
   </control>
</control>
</control>
</xml>
</syntaxhighlight>
All the buttons have width 180, and are aligned 180 pixels from the right edge of the group they're within.
All the buttons have width 180, and are aligned 180 pixels from the right edge of the group they're within.
[[category:Skin Development]]
<section end="main content" />
 
== See also ==
'''Development:'''
* [[Add-on development]]
* [[Skinning]]
 
[[Category:Skin development]]

Latest revision as of 12:33, 9 April 2016

The group control is one of the most important controls. It allows you to group controls together, applying attributes to all of them at once. It also remembers the last navigated button in the group, so you can set the <onup> of a control to a group of controls to have it always go back to the one you were at before. It also allows you to position controls more accurately relative to each other, as any controls within a group take their coordinates from the group's top left corner (or from elsewhere if you use the "r" attribute). You can have as many groups as you like within the skin, and groups within groups are handled with no issues.

Example

<control type="group" id="17">
      <description>My first group control</description>
      <left>80</left>
      <top>60</top>
      <width>250</width>
      <height>30</height>
      <defaultcontrol>2</defaultcontrol>
      <visible>true</visible>
      <onup>2</onup>
      <ondown>3</ondown>
      <onleft>1</onleft>
      <onright>1</onright>
      ... more controls go here ...
</control>

Available tags

In addition to the Default Control Tags the following tags are available. Note that each tag is lower case only. This is important, as xml tags are case-sensitive.

Tag Description
defaultcontrol Specifies the default control that will be focused within the group when the group receives focus. Note that the group remembers it's previously focused item and will return to it.

Notes on positioning of controls within groups

All controls within a group take their positions relative to the group's placement. Thus, the group always requires its <left>, <top>, <width>, and <height> attributes to be defined. As this can be a pain to remember, anything that you don't specify will be inherited from it's parent group (or the main window).

By way of example, consider the first group within a PAL full screen window (720x576), and suppose we have

<control type="group" id="15">
  <left>30</left>
  <top>70</top>
  <width>400</width>
  ... more controls go here ...
</control>

so that the <height> hasn't been defined. Then Kodi will automatically set the <height> equal to 506 by inheriting this from the window's height of 576, less the <top> amount.

You can align controls within a group to the right edge of the group, by using the "r" modifier to the <left> and <top> fields

<control type="group" id="20">
  <control type="button" id=2>
    <left>180r</left>
    <width>180</width>
  </control>
  <control type="button" id=3>
    <left>180r</left>
    <width>180</width>
  </control>
  <control type="button" id=4>
    <left>180r</left>
    <width>180</width>
  </control>
</control>

All the buttons have width 180, and are aligned 180 pixels from the right edge of the group they're within.


See also

Development: