2011-02-14, 15:20
Currently skinners need to do complex and not always obvious workarounds to achieve some goals and this add unnecessary complexity to skin's xml and therefore slowing down GUI. Those are just ideas and I'd like to start discussion what could be done to ease process of skinning and extend skins potential.
Improving GUI handling
1. Loading XML files:
2. Extending controls functionality:
4. Builtin functions:
Other ideas (outside of GUI scope)
5. Python modules:
Of course I would offer contribution in form of patches if people would be excited about any of this features.
What do You think?
Improving GUI handling
1. Loading XML files:
- CGUIWindow::Load could save copy of loaded window to (let's call it) CachedWindows, next time it would just create copy of cached window instead of reading and parsing same .xml again.
ReloadSkin would clear CachedWindows. Feature could be toggled in AdvancedSettings.
pros: less I/O operations -> faster UI processing -> better user experience
cons: memory consumption (don't think would be a problem)
posible issues: handling conditional includes
2. Extending controls functionality:
- Add <onaction action="action" [override="false"]>DoSmth</action> to focusable controls
Example: on some button control: <onaction action="ACTION_SHOW_INFO">ActivateWindow(movieinformation,ListItem.Property(path_to_file))</onaction> - this could bring info window for movies listed in RecentlyAdded block on home window.
Override parameter would specify if we call core's handling of action or not
- Making static content item to act like focusable control - add onfocus/onunfocus and onaction mentioned above (just idea - didn't think about it too much yet)
- Adding Expressions to skin:
There are situations when skinner create two identical ontrols that differs only by <onfocus>/<onclick>/<label> and <visible> attribute
Expressions could be something like:
Code:<expressions>
<expression name="RunRecentlyAdded">
<value condition="Skin.HasSetting(homepageShowRecentlyAdded)">XBMC.RunScript(script.recentlyadded,limit=4)</value>
<value>-</value>
</expression>
</expressions>
[...]
<control type="button">
<onfocus>$VAR[RunRecentlyAdded]</onfocus>
</control>
And for labels:
Code:<expressions>
<expression name="TodayTemp">
<value condition="IsEmpty(Window.Property(Day0.HighTemp)) | IsEmpty(Window.Property(Day0.LowTemp))">$INFO[Window.Property(Day1.LowTemp)]$INFO[System.TemperatureUnits] - $INFO[Window.Property(Day1.HighTemp)]$INFO[System.TemperatureUnits]</value>
<value>$INFO[Window.Property(Current.Temperature)]$INFO[System.TemperatureUnits]</value>
</expression>
</expressions>
[...]
<control type="label">
<label>$VAR[TodayTemp]</label>
</control>
- xbmcgui - containers:
- Allow scripts to retrieve, insert, remove, modify items that aren't created by python script
Possible usage:- filtering items on the fly (not only by labels - also genres, years etc)
- Having letter seperated lists - example:where [A], could have special layout prepared to stand out from rest of list itemsCode:
[A] [American Psycho] [Apocalypse Now] [b] [Batman] [Black Hawk Down] ...
- Allow scripts to retrieve, insert, remove, modify items that aren't created by python script
- Add ContextMenu class to xbmcgui to allow easy way of showing it filled with items defined in python script
4. Builtin functions:
- Adding 'Container(id).Select([b]n[,type,behaviour])' builtin function - type could be: filtered, all, id
- filtered - select nth item from that left after filtering list
- all - select nth item from all items (if item is filtered out it it would select item based on behaviour parameter (no_action, prev, next, select_0):
- no_action - no action
- prev / next - it would select previous / next available item
- select_0 - would select first item in list
- no_action - no action
- id - would select item with id equal to n
I found basic workaround for this: I used this python script placed in skin's extras dir:Code:import xbmcgui
try:
wnd = xbmcgui.Window(xbmcgui.getCurrentWindowId())
c = len(sys.argv)
id = -1
item = -1
if ile == 2:
id = wnd.getFocusId()
elif ile == 3:
id = int(sys.argv[1])
if ile > 1:
item = int(sys.argv[ile - 1])
if id > 0 and item > 0:
wnd.getControl(id).selectItem(item)
except:
pass - filtered - select nth item from that left after filtering list
Other ideas (outside of GUI scope)
5. Python modules:
- playlist:
- allow callbacks for onNextItem, onPrevItem and allow overriding GetNextItem, etc
would make posible to create playlist script for advanced playlist operations: such as "play after current", smart shuffle/random - random could be based on inner rating if user skips song it decrease inner rating of the song - again this could be used just by 5% of users
alternative idea is to move playlist outside of xbmc core to chose from different playlist engines as addons
- allow callbacks for onNextItem, onPrevItem and allow overriding GetNextItem, etc
Of course I would offer contribution in form of patches if people would be excited about any of this features.
What do You think?