Solved Conditional <include> Based on Screen Aspect Ratio
#1
A few days ago I started modding the Re-Touched Skin by Jezz_X and Ronie. For anybody who might not be familiar with it, the skin is specifically for touch screens.
In order to accommodate for the different screen resolutions of tablets (which, for the most part, are 16x9 and 4x3), the skin's includes.xml has various includes with conditionals based on the aspect ratio of the screen. The code in the following link is a copy of these conditionals directly from the Re-Touched Skin.

Conditional Includes based on Aspect Ratio

The addon.xml consists of the following code, specifying which files to use when. I believe that Jezz_X actually had two different folders, one named 16x9 and the other 4x3. And I think when Ronie took over, he was able to condense everything to the 16x9 folder. This is why these two lines might seem weird maybe?

Addon.xml
PHP Code:
<extension point="xbmc.gui.skin" debugging="false">
        <
res width="1280" height="960" aspect="4:3" folder="16x9"/>
        <
res width="1706" height="960" aspect="16:9" default="true" folder="16x9"/>
    </
extension

When I finished with the 16x9 aspect of my modded skin, I started working on the 4x3 views. I began by editing the ViewsAddonBrowser-4x3.xml file, and I tried testing it on an iPad Mini (which is 4:3). But none of the changes I made to this file were showing up in the Addon Browser Window on the iPad. (I made sure to make dramatic changes to make sure I wasn't overlooking anything). I guessed that it was still using the ViewsAddonBrowser.xml (the 16x9 version), ignoring the conditions in includes.xml.

So I tried removing the ViewsAddonBrowser.xml from the includes.xml, so that only ViewsAddonBrowser-4x3.xml was present. Now, the changes I had made were appearing as they should. But I still didn't understand why it wouldn't work with the 16x9 ViewsAddonBrowser.xml included. It seemed the conditional wasn't working for me one reason or another. But it's the same ones that are used in the Re-Touched skin??

Deciding to experiment with one last thing, with regards to the pastebin code above, I edited the code so that any <include> conditional statements regarding 4:3 were placed above the 16:9 conditional statements (opposite of how they are originally). Surprisingly, this actually worked too. The Addon Browser Window on the iPad appeared as it should. BUT then I ran the skin on my computer, where I'd expect the 16:9 views to be used. This was not the case. The 4x3 views were being shown no matter what.

In short, I guess I'm wondering what I'm doing wrong? The conditionals are the same as those used in the Re-Touched skin. And I have all the same windows (except PVR, not really sure what that is yet lol).



Thank you in advance for the taking the time to help out and post back.

Apologies for the username mixup. Didn't have my password from before so had to make a new account. But I was able to recover the old one (vs604), so I'll stick to that for now on.
Reply
#2
Add a Skin.AspectRatio label to any window to display the actual aspect ratio and see if they're correct.
Reply
#3
Thank you Hitcher for replying. I actually just created folders 4x3 and 16x9 and changed addon.xml accordingly to point to the appropriate folder to use. This solution worked. But I am still going to try your suggestion and report back. (I'm guessing it's better and easier to have anything in one folder)



Sidenote: I went ahead and edited the original Re-Touched skin to test if I get the same behavior with it. In includes.xml I switched the conditional includes so that the 4x3 conditional includes are written above the 16x9 conditional includes. I did this on my computer, where the 16x9 views should be appearing. But I actually got the same behavior that I got with my modded skin. After the switch, the 4x3 views were showing instead of the expected 16x9 views. So idk, maybe it's just a problem with my setup?
Reply
#4
Hitcher, here are my results after trying your suggestion. (It took me a sec to figure out how lol, sorry)

The skin has a ViewsAddonBrowser.xml (the 16:9 view) and a ViewsAddonBrowser-4x3.xml. I added a Skin.AspectRatio label to AddonBrowser.xml.

Testing on a Macbook (16:9).

I tested it under two different conditions, which I'll describe in a sec. But both times, the label returned "16:9", so that part is correct.

Test 1: In Includes.xml, I left the conditional statement as they originally were i.e. the 16:9 includes were stated first, followed by the 4x3 includes.
Result: The window appeared as expected i.e. the skin used the correct view (from ViewsAddonBrowser.xml).

Test 2: In includes.xml, I swapped the includes around again. The 4:3 includes were stated above the 16:9 includes.
Result: The window did NOT appear as expected i.e. the skin used the 4x3 view (from ViewsAddonBrowser-4x3.xml).
(The Skin.AspectRatio label still returned 16:9)

Testing on the iPad yielded the same results. It seemed that the actual aspect ratio did not matter. The only thing that had any affect was switching the order of the includes in includes.xml.
Reply
#5
More Info: (sorry for all the posts; this is the last thing I have to add, I swear)

Before I noticed all this, I was modifying Settings.xml to fit the new theme. Realizing I was going to have to need a different view for different aspect ratios for the Settings window, I decided to make 2 different panels, each with it it's own <visible> tag, all in one window Settings.xml.

The first panel uses the this visible tag:
PHP Code:
<control type="panel" id="9000">
        <
visible>StringCompare(Skin.AspectRatio,16:9)</visible

The second panel uses this visible tag:
PHP Code:
<control type="panel" id="9000">
        <
visible>StringCompare(Skin.AspectRatio,4:3)</visible


And, to my noob surprise, this works just fine!
On the computer, the panel that shows is the one with the <visible>StringCompare(Skin.AspectRatio,16:9)</visible>
On the iPad, the panel that shows is the one with the <visible>StringCompare(Skin.AspectRatio,4:3)</visible>

I feel like I'm being dumb about something.
Reply
#6
you're modding the jarvis version of re-touched, but you're probably not using a nightly build of kodi.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#7
Wow. That's like 5 hours of my life I'm not getting back lol. Completely looked over conditional includes is new to Jarvis in the Skinning Engine update thread. Sorry about that guys. And thank you for your help.
Reply

Logout Mark Read Team Forum Stats Members Help
Conditional <include> Based on Screen Aspect Ratio1