Radio button control: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Gamester17
No edit summary
 
(37 intermediate revisions by 15 users not shown)
Line 1: Line 1:
The radio button control is used for creating push button on/off settings in XBMC. You can choose the position, size, and look of the button. When the user clicks on the radio button, the state will change, toggling the extra textures (textureradiofocus and textureradionofocus). Used for settings controls.
<section begin="main content" />
===Example===
The radio button control is used for creating push button on/off settings in Kodi. You can choose the position, size, and look of the button. When the user clicks on the radio button, the state will change, toggling the extra textures (textureradioon and textureradiooff). Used for settings controls.
<xml>
=== Example ===
<control>
<syntaxhighlight lang="XML" enclose="div">
<control type="radiobutton" id="2">
       <description>My first radiobutton control</description>
       <description>My first radiobutton control</description>
       <type>radiobutton</type>
       <type>radiobutton</type>
       <id>1</id>
       <left>80</left>
      <posx>80</posx>
       <top>60</top>
       <posy>60</posy>
       <width>250</width>
       <width>250</width>
       <height>200</height>
       <height>200</height>
Line 14: Line 14:
       <texturefocus>myfocustexture.png</texturefocus>
       <texturefocus>myfocustexture.png</texturefocus>
       <texturenofocus>mynormaltexture.png</texturenofocus>
       <texturenofocus>mynormaltexture.png</texturenofocus>
       <textureradiofocus>myradiobutton.png</textureradiofocus>
       <textureradioonfocus colordiffuse="FFFFAAFF">myradiobutton.png</textureradioonfocus>
       <textureradionofocus>myradiobutton_nf.png</textureradionofocus>
       <textureradioonnofocus colordiffuse="FFFFAAFF">myradiobutton.png</textureradioonnofocus>
      <textureradioofffocus colordiffuse="FFFFAAFF">myradiobutton_nf.png</textureradioofffocus>
      <textureradiooffnofocus colordiffuse="FFFFAAFF">myradiobutton_nf.png</textureradiooffnofocus>
       <selected>Player.Paused</selected>
       <selected>Player.Paused</selected>
       <onclick>PlayerControls(Pause)</onclick>
       <onclick>PlayerControls(Pause)</onclick>
Line 21: Line 23:
       <font>font12</font>
       <font>font12</font>
       <textcolor>FFFFFFFF</textcolor>
       <textcolor>FFFFFFFF</textcolor>
      <focusedcolor>FFFFFFFF</focusedcolor>
       <disabledcolor>80FFFFFF</disabledcolor>
       <disabledcolor>80FFFFFF</disabledcolor>
       <align>left</align>
       <align>left</align>
Line 27: Line 30:
       <textoffsety>5</textoffsety>
       <textoffsety>5</textoffsety>
       <pulseonselect>false</pulseonselect>
       <pulseonselect>false</pulseonselect>
      <onfocus></onfocus>
      <onunfocus></onunfocus>
       <onup>2</onup>
       <onup>2</onup>
       <ondown>3</ondown>
       <ondown>3</ondown>
Line 32: Line 37:
       <onright>1</onright>
       <onright>1</onright>
</control>
</control>
</xml>
</syntaxhighlight>


===Available Tags===
=== Available tags ===
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="usertable" border="1"
{| class="prettytable"
|- class="userrow"
! Tag !! Description
| class="usercell" | '''description'''
|-  
| class="usercell" | Only used to make things clear for the skinner. Not read by XBMC at all.
| '''texturefocus'''
|- class="userrow"
|  
| class="usercell" | '''type'''
Specifies the image file which should be displayed when the button has focus. [[Texture Attributes|See here for additional information about textures.]]
| class="usercell" | Should be radiobutton for a radio button control.
|-  
|- class="userrow"
| '''texturenofocus'''
| class="usercell" | '''id'''
| Specifies the image file which should be displayed when the button does not have focus.
| class="usercell" | Specifies the control's id. The value this takes depends on the control type, and the window that you are using the control on. There are special control id's that must be present in each window. Any other controls that the skinner adds can be any id they like. Obviously they should be unique for buttons, given that they are navigatible, and you want the onup, onleft etc. to make sense.
|-  
|- class="userrow"
| '''textureradioonfocus'''
| class="usercell" | '''posx'''
| Specifies the image file which should be displayed for the radio button portion when it's the button is on and focused. This texture is positioned on the right of the button – it's positioned 24 pixels from the right edge of the button, and 8 pixels above the center vertically.
| class="usercell" | Specifies where the left edge of the button should be drawn. This is offset from the window's coordinates (normally the left edge of the screen, or 0).
|-  
|- class="userrow"
| '''textureradioonnofocus'''
| class="usercell" | '''posy'''
| Specifies the image file which should be displayed for the radio button portion when it's the button is on and unfocused. This texture is positioned on the right of the button – it's positioned 24 pixels from the right edge of the button, and 8 pixels above the center vertically.
| class="usercell" | Specifies where the top edge of the button should be drawn. This is offset from the window's coordinates (normally the top edge of the screen, or 0).
|-  
|- class="userrow"
| '''textureradioon'''
| class="usercell" | '''width'''
A shortcut to set both of the above textures to the same image file.
| class="usercell" | Specifies the width of the button. The texturefocus and texturenofocus images will be resized to fit into this width.
|-  
|- class="userrow"
| '''textureradioondisabled'''
| class="usercell" | '''height'''
| Specifies the image file which should be displayed for the radio button portion when the button is on and disabled.
| class="usercell" | Specifies the height of the button. The texturefocus and texturenofocus images will be resized to fit into this height.
|-  
|- class="userrow"
| '''textureradioofffocus'''
| class="usercell" | <strong>visible</strong>
| Specifies the image file which should be displayed for the radio button portion when the button is off and focused.
| class="usercell" | Specifies a condition as to when this control will be visible. Can be true, false, or a condition. [[Conditional Visibility|See here for&nbsp;more information.]] Defaults to true.
|-  
|- class="userrow"
| '''textureradiooffnofocus'''
| class="usercell" | <strong>animation</strong>
| Specifies the image file which should be displayed for the radio button portion when the button is off and unfocused.
| class="usercell" | Specifies the animation to be run when the control enters a particular state. [[Animating Your Skin|See here for more information]]
|-
|- class="userrow"
|  '''textureradiooff'''
| class="usercell" | '''texturefocus'''
|  A shortcut to set both of the above textures to the same image file.
| class="usercell" |
|-  
Specifies the image file which should be displayed when the button has focus. You can use animated gif's, jpgs, pngs, or bmps. This should be the path to the image file from the media/ folder of your skin directory. XBMC will first look inside the compresses Textures.xpr file, and if not found, will look inside the media/ folder for the actual skin file. Compressing textures into Textures.xpr means far faster loading times.
| '''textureradioondisabled'''
|- class="userrow"
| Specifies the image file which should be displayed for the radio button portion when the button is off and disabled.
| class="usercell" | '''texturenofocus'''
|-  
| class="usercell" | Specifies the image file which should be displayed when the button does not have focus.
| '''label'''
|- class="userrow"
| The label used on the button. It can be a link into strings.po, or an actual text label.
| class="usercell" | '''textureradiofocus'''
|-  
| class="usercell" | Specifies the image file which should be displayed for the radio button portion when it's the button is on and focused. This texture is positioned on the right of the button – it's positioned 24 pixels from the right edge of the button, and 8 pixels above the center vertically. As it's not displayed when the button is off, you may wish to have the <span class="nobr">off-state</span> look rendered into the texturefocus and texturenofocus images.
| '''label2'''
|- class="userrow"
| Optional. Will display an 'on' or 'off' label. Only available if you specify an empty radiowidth and radioheight.
| class="usercell" | '''textureradionofocus'''
|-  
| class="usercell" | Specifies the image file which should be displayed for the radio button portion when the button is on but does not have focus.
| '''font'''
|- class="userrow"
| Font used for the button label. From fonts.xml.
| class="usercell" | '''colordiffuse'''
|-  
| class="usercell" | This specifies the color to be used for the texture basis. It's in hex AARRGGBB format. If you define <colordiffuse>FFFF00FF</colordiffuse> (magenta), the image will be given a magenta tint when rendered. Defaults to FFFFFFFF (no tint).
| '''textcolor'''
|- class="userrow"
| Color used for displaying the button label. In AARRGGBB hex format, or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''label'''
|-
| class="usercell" | The label used on the button. It can be a link into strings.xml, or an actual text label.
|  '''focusedcolor'''
|- class="userrow"
|  Color used for the button label when the button has in focus. In AARRGGBB hex format or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''font'''
|-
| class="usercell" | Font used for the button label. From fonts.xml.
| '''disabledcolor'''
|- class="userrow"
| Color used for the button label if the button is disabled. In AARRGGBB hex format, or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''textcolor'''
|-  
| class="usercell" | Color used for displaying the button label. In AARRGGBB hex format.
| '''shadowcolor'''
|- class="userrow"
| Specifies the color of the drop shadow on the text, in AARRGGBB format, or a name from the [[Colour themes|colour theme.]]
| class="usercell" | '''disabledcolor'''
|-  
| class="usercell" | Color used for the button label if the button is disabled.
| '''align'''
|- class="userrow"
| Label horizontal alignment on the button. Defaults to left, can also be center or right.
| class="usercell" | '''shadowcolor'''
|-  
| class="usercell" | Specifies the color of the drop shadow on the text, in AARRGGBB format.
| '''aligny'''
|- class="userrow"
| Label vertical alignment on the button. Defaults to top, can also be center.
| class="usercell" | '''align'''
|-  
| class="usercell" | Label horizontal alignment on the button. Defaults to left, can also be center or right.
| '''textoffsetx'''
|- class="userrow"
| Amount to offset the label from the left (or right) edge of the button when using left or right alignment.
| class="usercell" | '''aligny'''
|-  
| class="usercell" | Label vertical alignment on the button. Defaults to top, can also be center.
| '''textoffsety'''
|- class="userrow"
| Amount to offset the label from the top edge of the button when using top alignment.
| class="usercell" | '''textoffsetx'''
|-
| class="usercell" | Amount to offset the label from the left (or right) edge of the button when using left or right alignment.
| '''textwidth'''
|- class="userrow"
| Will truncate any text that's too long.
| class="usercell" | '''textoffsety'''
|-  
| class="usercell" | Amount to offset the label from the top edge of the button when using top alignment.
| '''selected'''
|- class="userrow"
| The boolean condition that when met will cause the control to become selected. [[Conditional_visibility|see here for more information.]]
| class="usercell" | '''pulseonselect'''
|-  
| class="usercell" | Specifies whether the button should pulse when it's selected. Defaults to true.
| '''onclick'''
|- class="userrow"
| The function to perform when the radio button is clicked. Should be a [[Built-in_scripting|built in function.]]
| class="usercell" | '''selected'''
|-  
| class="usercell" | The boolean condition that when met will cause the control to become selected. [[Conditional Visibility|see here for more information.]]
| '''radioposx'''
|- class="userrow"
|  X offset of the ''dot'' or radio button itself
| class="usercell" | '''onclick'''
|-
| class="usercell" | The function to perform when the radio button is clicked. Should be a [[Built-in functions available to FTP, Webserver, skins, keymap and to python|built in function.]]
| '''radioposy'''
|- class="userrow"
| Y offset of the ''dot'' or radio button itself
| class="usercell" | '''onup'''
|-
| class="usercell" | Control id to move to when the user moves up off this control.
|  '''radiowidth'''
|- class="userrow"
| Width in Pixels of the ''dot'' or radio button itself
| class="usercell" | '''ondown'''
|-  
| class="usercell" | Control id to move to when the user moves down off this control.
| '''radioheight'''
|- class="userrow"
| Height in Pixels of the ''dot'' or radio button itself
| class="usercell" | '''onleft'''
|-
| class="usercell" | Control id to move to when the user moves left off this control.
| '''onfocus'''
|- class="userrow"
| Specifies the action to perform when the button is focused. Should be a built in function. The action is performed after any focus animations have completed. [[List_of_built-in_functions|See here for more information.]]
| class="usercell" | '''onright'''
|-
| class="usercell" | Control id to move to when the user moves right off this control.
|   '''onunfocus'''
| Specifies the action to perform when the button loses focus. Should be a built in function.
|}
|}


[[category:Skin Development]]
<section end="main content" />
[[category:Python]]
 
== See also ==
'''Development:'''
* [[Add-on development]]
* [[Skinning]]
 
[[Category:Skin development]]

Latest revision as of 00:52, 14 April 2022

The radio button control is used for creating push button on/off settings in Kodi. You can choose the position, size, and look of the button. When the user clicks on the radio button, the state will change, toggling the extra textures (textureradioon and textureradiooff). Used for settings controls.

Example

<control type="radiobutton" id="2">
      <description>My first radiobutton control</description>
      <type>radiobutton</type>
      <left>80</left>
      <top>60</top>
      <width>250</width>
      <height>200</height>
      <visible>true</visible>
      <colordiffuse>FFFFFFFF</colordiffuse>
      <texturefocus>myfocustexture.png</texturefocus>
      <texturenofocus>mynormaltexture.png</texturenofocus>
      <textureradioonfocus colordiffuse="FFFFAAFF">myradiobutton.png</textureradioonfocus>
      <textureradioonnofocus colordiffuse="FFFFAAFF">myradiobutton.png</textureradioonnofocus>
      <textureradioofffocus colordiffuse="FFFFAAFF">myradiobutton_nf.png</textureradioofffocus>
      <textureradiooffnofocus colordiffuse="FFFFAAFF">myradiobutton_nf.png</textureradiooffnofocus>
      <selected>Player.Paused</selected>
      <onclick>PlayerControls(Pause)</onclick>
      <label>29</label>
      <font>font12</font>
      <textcolor>FFFFFFFF</textcolor>
      <focusedcolor>FFFFFFFF</focusedcolor>
      <disabledcolor>80FFFFFF</disabledcolor>
      <align>left</align>
      <aligny>center</aligny>
      <textoffsetx>4</textoffsetx>
      <textoffsety>5</textoffsety>
      <pulseonselect>false</pulseonselect>
      <onfocus></onfocus>
      <onunfocus></onunfocus>
      <onup>2</onup>
      <ondown>3</ondown>
      <onleft>1</onleft>
      <onright>1</onright>
</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
texturefocus

Specifies the image file which should be displayed when the button has focus. See here for additional information about textures.

texturenofocus Specifies the image file which should be displayed when the button does not have focus.
textureradioonfocus Specifies the image file which should be displayed for the radio button portion when it's the button is on and focused. This texture is positioned on the right of the button – it's positioned 24 pixels from the right edge of the button, and 8 pixels above the center vertically.
textureradioonnofocus Specifies the image file which should be displayed for the radio button portion when it's the button is on and unfocused. This texture is positioned on the right of the button – it's positioned 24 pixels from the right edge of the button, and 8 pixels above the center vertically.
textureradioon A shortcut to set both of the above textures to the same image file.
textureradioondisabled Specifies the image file which should be displayed for the radio button portion when the button is on and disabled.
textureradioofffocus Specifies the image file which should be displayed for the radio button portion when the button is off and focused.
textureradiooffnofocus Specifies the image file which should be displayed for the radio button portion when the button is off and unfocused.
textureradiooff A shortcut to set both of the above textures to the same image file.
textureradioondisabled Specifies the image file which should be displayed for the radio button portion when the button is off and disabled.
label The label used on the button. It can be a link into strings.po, or an actual text label.
label2 Optional. Will display an 'on' or 'off' label. Only available if you specify an empty radiowidth and radioheight.
font Font used for the button label. From fonts.xml.
textcolor Color used for displaying the button label. In AARRGGBB hex format, or a name from the colour theme.
focusedcolor Color used for the button label when the button has in focus. In AARRGGBB hex format or a name from the colour theme.
disabledcolor Color used for the button label if the button is disabled. In AARRGGBB hex format, or a name from the colour theme.
shadowcolor Specifies the color of the drop shadow on the text, in AARRGGBB format, or a name from the colour theme.
align Label horizontal alignment on the button. Defaults to left, can also be center or right.
aligny Label vertical alignment on the button. Defaults to top, can also be center.
textoffsetx Amount to offset the label from the left (or right) edge of the button when using left or right alignment.
textoffsety Amount to offset the label from the top edge of the button when using top alignment.
textwidth Will truncate any text that's too long.
selected The boolean condition that when met will cause the control to become selected. see here for more information.
onclick The function to perform when the radio button is clicked. Should be a built in function.
radioposx X offset of the dot or radio button itself
radioposy Y offset of the dot or radio button itself
radiowidth Width in Pixels of the dot or radio button itself
radioheight Height in Pixels of the dot or radio button itself
onfocus Specifies the action to perform when the button is focused. Should be a built in function. The action is performed after any focus animations have completed. See here for more information.
onunfocus Specifies the action to perform when the button loses focus. Should be a built in function.


See also

Development: