Kodi ——4 Windows窗口

原文 http://kodi.wiki/view/XBMC_Skinning_Manual


4.1窗口构造

4.2 关于Window窗口XML文件

       在kodi的皮肤系统中,每个窗口是用一个单独的xml文件表示的。

       要记住的重要一点是,每个窗口都有一个唯一的标识名称。这是kodi如何从源代码内识别窗口。窗口的名字都列在附录I:Windows列表。

      每个xml文件具有相同的基本结构——它以一些头信息开始,这些头信息作为一个整体隶属于窗口,在用于描述被定义的所有的控制模块中,包含<controls>标签模块。在每个窗口的多个控制模块都应该有唯一的id。否则他们只能用作导航页不重要的图片或者标签,kodi没有必要对他们唯一识别。

4.3 Window Header

<?xml version="1.0" encoding="UTF-8"?>
<window>
  <onload>RunScript(script.foobar)</onload>
  <onunload>SetProperty(foo,bar)</onunload>
  <defaultcontrol always="false">2</defaultcontrol>
  <menucontrol>9000</menucontrol>
  <backgroundcolor>0xff00ff00</backgroundcolor>
  <views>50,51,509,510</views>
  <visible>Window.IsActive(Home)</visible>
  <animation effect="fade" time="100">WindowOpen</animation>
  <animation effect="slide" end="0,576" time="100">WindowClose</animation>
  <zorder>1</zorder>
  <coordinates>
    <left>40</left>
    <top>50</top>
    <origin x="100" y="50">Window.IsActive(Home)</origin>
  </coordinates>
  <previouswindow>MyVideos</previouswindow>
  <controls>
    <control>
    </control>
    ....
  </controls>
</window>

       有一点需要注意的是,所有的标签名称是小写。XML标记名称是区分大小写的!
       头包含以下标签:
onload:
     
内置函数窗口打开时执行
unonload:
    
内置函数窗口关闭时执行
defaultcontrol:
     
用于指定窗口的默认的控件,这是控件的id,窗口第一次被打开的时候,将会接受焦点。请注意,大多数的Kodi窗户在你离开窗口的时候,会保存当前的焦点,当你返回窗口的时候,将会返回到最后的焦点所在项。这种行为可以通过指定属性always="true"停止
menucontrol
      当用户按下'menu' / 'm'按钮的时候,用于指定获取焦点的控件。
backgroundcolor:
      指定窗口是否需要清空渲染,如果需要,将要用到哪种颜色。默认清楚为空白。设置 0 (or 0x00000000) 不需要清除。如果你的皮肤总是在整个界面上渲染不透明的文字(比如用一个或者多个背景图片)绝大多数选择是设置背景色为0,可在慢的GPU显著提高性能
visible:
      指定对话框可见条件,kodi将会在渲染是进行计算,计算改标签进行显示或者隐藏对话框。仅适用于type="dialog"的窗口。
animation:
     指定动画作用于打开或者关闭窗口。
zorder:
    窗口绘制时,用于指定“深度”,zorder比较高的窗口绘制在zorder比较低的窗口之上。所有的对话框默认zorder为1,如果你想让对话框位于所有的对话框下面,指定zorder的值为0.
coordinates:
    此模块用于指定Kodi如何计算所有控件的坐标。
left:
    设置窗口的水平“原点”位置。如果不设置,默认为0。
top:
    设置窗口的垂直“原点”位置。如果不设置,默认为0。
origin:
    设置窗口原点当原点条件满足,该窗口将显示在(X,Y)。只要你喜欢,你可以有很多原点标签 - 他们存在于文件中的顺序,以及该条件满足第一个进行评估。如果没有原点条件满足,我们退回到<left>和<top>标记。
previouswindow:

This can be used to specify a window to force Kodi to go to on press of the Back button. Normally Kodi keeps a “window stack” of previous windows to handle this. This tag allows you to override this behaviour. The value is the name of the window.
views
This tag lets you use view id's beyond 50 to 59 it also lets you set the order in which they cycle with the change view button in the skin. Only useful in My<Foo>.xml windows.
controls
This is the block the defines all controls that will appear on this window.

4.3.1 The Different Types of Controls

Kodi supports many different types of controls.

Click here for the control types and what they all do.

Some of these controls are required on specific windows, as they're necessary for that window to perform it's duty, or, the contents of the control are only valid on a particular window. The mandatory controls for each window are listedhere. While the controls are mandatory, you can ofcourse move them about and change their appearance within the windows to your hearts content!

4.3.2 Adding Extra Windows

All of the windows in the window list are defined within the executable of Kodi itself, as most of them have a specific purpose. However, the skinner may add extra windows as and when they are needed or wanted. The only restriction to this is that only controls that do not require specific source code to operate can be used. This is not too much of a restriction though, as many skinners have found out.

To add an extra window, all you need to do is design up the window's .xml file in the usual way, assign it an <id> outside of the ones defined in the window list, and then name the file customN.xml, where N is a number or name. You can have as many as you like, as long as they have unique <id>'s, and are named differently. Then just define the type of window you want, the coordinate system and so on, add the controls and setup the navigation. To activate your window, you can do it by adding a button control elsewhere in the skin, or you can get it to popup on a press of the controller or remote via keymap.xml and so on. Basically you just need to run ActivateWindow(id) from a suitable place
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值