Kodi Community Forum

Full Version: Params in includes - Width / Heigh
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Simple question : is it possible to use $PARAM[] with Width and Heigh attributes ?

I tried and have no success with a test on image control.

I also tried to set a default value to params.
The image is displayed, but not with the expected widht and/or Height

PHP Code:
<include name="MyControl">
    <
param name="W"/>
    <
param name="P" />
    <
definition>
        <
control type="image">
            <
left>0</left>
            <
top>0</top>
            <
width>$PARAM[W]</width>
            <
height>$PARAM[H]</height>
            <
texture>$INFO[ListItem.Art(clearlogo)]</texture>
        </
control>
    </
definition>
</include> 
it works, you have to pass constants via the PARAM though. passing infolabels wont work, <width> and <height> dont support them.
(2016-02-04, 17:31)gates Wrote: [ -> ]Hi,

Simple question : is it possible to use $PARAM[] with Width and Heigh attributes ?

I tried and have no success with a test on image control.

I also tried to set a default value to params.
The image is displayed, but not with the expected widht and/or Height

PHP Code:
<include name="MyControl">
    <
param name="W"/>
    <
param name="P" />
    <
definition>
        <
control type="image">
            <
left>0</left>
            <
top>0</top>
            <
width>$PARAM[W]</width>
            <
height>$PARAM[H]</height>
            <
texture>$INFO[ListItem.Art(clearlogo)]</texture>
        </
control>
    </
definition>
</include> 

Yes, it works. But you have to set a value <param name="myparamname" value="myvalue" />.
Only restiction is you can't use infolabels or variables where it doesn't work also without param.
That means for width / height, you have to set a param value as a real value :

<param name="Height" value="$VAR[MyValue]" />. --> DOESN'T WORK
<param name="Height" value="500" />. --> WORKS
(2016-02-04, 18:10)Jayz2K Wrote: [ -> ]
(2016-02-04, 17:31)gates Wrote: [ -> ]Hi,

Simple question : is it possible to use $PARAM[] with Width and Heigh attributes ?

I tried and have no success with a test on image control.

I also tried to set a default value to params.
The image is displayed, but not with the expected widht and/or Height

PHP Code:
<include name="MyControl">
    <
param name="W"/>
    <
param name="P" />
    <
definition>
        <
control type="image">
            <
left>0</left>
            <
top>0</top>
            <
width>$PARAM[W]</width>
            <
height>$PARAM[H]</height>
            <
texture>$INFO[ListItem.Art(clearlogo)]</texture>
        </
control>
    </
definition>
</include> 

Yes, it works. But you have to set a value <param name="myparamname" value="myvalue" />.
Only restiction is you can't use infolabels or variables where it doesn't work also without param.
That means for width / height, you have to set a param value as a real value :

<param name="Height" value="$VAR[MyValue]" />. --> DOESN'T WORK
<param name="Height" value="500" />. --> WORKS

EDIT : Hehe, Phil was faster Wink
If you need to use variable dimensions use conditional includes for the complete tag.

eg

Code:
<include condition="Window.IsVisible(progressdialog)">Height295</include>

Code:
<include name="Height295">
    <height>295</height>
</include>
Depending on the complexity of the include I would probably prefer this:

Code:
        <include name="MyControl" condition="Window.IsVisible(progressdialog)">
            <param name="W" value="295" />
            <param name="H" value="33" />
        </include>
        <include name="MyControl" condition="!Window.IsVisible(progressdialog)">
            <param name="W" value="500" />
            <param name="H" value="33" />
        </include>
That way you dont need that many includes. Feels cleaner imo.
Will that work inside another parameter?
(2016-02-04, 19:28)Hitcher Wrote: [ -> ]Will that work inside another parameter?

not 100% sure if i understand correctly, but yes, it should work.
This is my DialogConfirm include parameter -

PHP Code:
<include name="DialogConfirm">
    <!-- 
Background -->
    <include>
DialogBackgroundImage</include>
    <!-- 
Main group -->
    <
control type="group">
        <include>
DialogAnimation</include>
        <
centerleft>50%</centerleft>
        <
centertop>50%</centertop>
        <
width>716</width>
        <include 
condition="Window.IsVisible(progressdialog)">Height295</include>
        <include 
condition="Window.IsVisible(okdialog)">Height253</include>
        <include 
condition="!Window.IsVisible(progressdialog) + !Window.IsVisible(okdialog)">Height289</include>
        <!-- 
Background -->
        <
control type="image">
            <
centerleft>50%</centerleft>
            <
centertop>50%</centertop>
            <
width>100%</width>
            <
height>100%</height>
            <include>
MessageBackground</include>
        </
control>
        <!-- 
Heading -->
        <
control id="1" type="label">
            <
centerleft>50%</centerleft>
            <
top>-16</top>
            <
width>100%</width>
            <
height>38</height>
            <
font>Bold38</font>
            <
textcolor>ffdadada</textcolor>
        </
control>
        <!-- 
Details -->
        <
control id="9" type="textbox">
            <
centerleft>50%</centerleft>
            <
top>55</top>
            <
width>100%</width>
            <
height>110</height>
            <
font>Light28</font>
            <
textcolor>ff9d9d9d</textcolor>
        </
control>
        <!--  
Progress -->
        <
control id="20" type="progress">
            <
centerleft>50%</centerleft>
            <
top>186</top>
            <
width>100%</width>
            <
height>9</height>
            <
reveal>true</reveal>
            <
info>System.Progressbar</info>
            <
texturebg border="4">dialogs/progress_back.png</texturebg>
            <
lefttexture>-</lefttexture>
            <
midtexture border="4">dialogs/progress_bar.png</midtexture>
            <
righttexture>-</righttexture>
            <
overlaytexture>-</overlaytexture>
        </
control>
        <!-- 
Button grouplist -->
        <
control type="grouplist">
            <
centerleft>50%</centerleft>
            <
bottom>0</bottom>
            <
width>100%</width>
            <
height>76</height>
            <
itemgap>0</itemgap>
            <
align>center</align>
            <
orientation>horizontal</orientation>
            <!-- 
Cancel -->
            <
control id="10" type="button">
                <include 
condition="Control.IsVisible(12)">Width242</include>
                <include 
condition="!Control.IsVisible(12)">Width358</include>
                <
height>76</height>
                <
align>center</align>
                <
aligny>top</aligny>
                <
onleft>10</onleft>
                <
onright>noop</onright>
                <
font>MedUpper24</font>
                <
textoffsety>27</textoffsety>
            </
control>
            <!-- 
Yes -->
            <
control id="11" type="button">
                <include 
condition="Control.IsVisible(12)">Width242</include>
                <include 
condition="!Control.IsVisible(12)">Width358</include>
                <
height>76</height>
                <
align>center</align>
                <
aligny>top</aligny>
                <
onleft>10</onleft>
                <
onright>noop</onright>
                <
font>MedUpper24</font>
                <
textoffsety>27</textoffsety>
            </
control>
            <!-- 
Custom -->
            <
control id="12" type="button">
                <include 
condition="Control.IsVisible(12)">Width242</include>
                <include 
condition="!Control.IsVisible(12)">Width358</include>
                <
height>76</height>
                <
align>center</align>
                <
aligny>top</aligny>
                <
onleft>10</onleft>
                <
onright>noop</onright>
                <
font>MedUpper24</font>
                <
textoffsety>27</textoffsety>
            </
control>
        </
control>
    </
control>
</include> 

And the corresponding includes for the dimensions -

PHP Code:
<!-- Dialog Heights -->
<include 
name="Height295">
    <
height>295</height>
</include>
<include 
name="Height289">
    <
height>289</height>
</include>
<include 
name="Height253">
    <
height>253</height>
</include>
<!-- 
Button Widths -->
<include 
name="Width242">
    <
width>242</width>
</include>
<include 
name="Width358">
    <
width>358</width>
</include> 
Not sure you're going to save a lot of code here. No need to use it for height since you have only one instance per condition. Also including the 3 last buttons might share the same code using $PARAM[ID] = 10 or 11 or 12 + $PARAM[Width] but since it's depending on visibility condition I'm pretty sure it will fail because include will be stuck at call state ... worth to give it a try ...
Thx Phil, Hitcher and Jayz

I think i've found "my" problem
It occurs when i use <left>500r</left> or <right>500<right>
it's all good, when i use <left>500</left>
(2016-02-04, 20:42)Jayz2K Wrote: [ -> ]Not sure you're going to save a lot of code here. No need to use it for height since you have only one instance per condition. Also including the 3 last buttons might share the same code using $PARAM[ID] = 10 or 11 or 12 + $PARAM[Width] but since it's depending on visibility condition I'm pretty sure it will fail because include will be stuck at call state ... worth to give it a try ...
I'll only find out if that extra button ever gets used. Wink
Hi,

as you all say : it works Smile

my problem came from exluded lines with <!-- ... --->

the same as Sualfred :
http://forum.kodi.tv/showthread.php?tid=259305