Configura canale migliorato per schermi touch

This commit is contained in:
Alhaziel01
2020-05-12 19:23:08 +02:00
parent 2ee25b0a21
commit c4f62feb03
2 changed files with 149 additions and 129 deletions

View File

@@ -366,8 +366,7 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
return ok
def add_control_label(self, c):
control = xbmcgui.ControlLabel(0, -100, self.controls_width, 40, "", alignment=4, font=self.font,
textColor=c["color"])
control = xbmcgui.ControlLabel(0, -100, self.controls_width + 20, 40, "", alignment=4, font=self.font, textColor=c["color"])
self.addControl(control)
@@ -378,20 +377,20 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
c["control"] = control
def add_control_list(self, c):
control = xbmcgui.ControlButton(0, -100, self.controls_width + 20, self.height_control,
control = xbmcgui.ControlButton(0, -100, self.controls_width + 10, self.height_control,
c["label"], os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'),
os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'),
10, textColor=c["color"],
font=self.font)
label = xbmcgui.ControlLabel(0, -100, self.controls_width - 80, self.height_control,
label = xbmcgui.ControlLabel(0, -100, self.controls_width - 100, self.height_control,
"", font=self.font, textColor=c["color"], alignment= 1 | 4)
upBtn = xbmcgui.ControlButton(0, -100, 15, 7, "",
upBtn = xbmcgui.ControlButton(100, -100, 30, 15, "",
focusTexture=os.path.join(self.mediapath, 'Controls', 'spinUp-Focus.png'),
noFocusTexture=os.path.join(self.mediapath, 'Controls', 'spinUp-noFocus.png'))
downBtn = xbmcgui.ControlButton(0, -100 + 15, 15, 7, "",
downBtn = xbmcgui.ControlButton(0, -100, 30, 15, "",
focusTexture=os.path.join(self.mediapath, 'Controls', 'spinDown-Focus.png'),
noFocusTexture=os.path.join(self.mediapath, 'Controls', 'spinDown-noFocus.png'))
@@ -445,31 +444,23 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
if xbmcgui.__version__ in ["1.2", "2.0"]:
control = xbmcgui.ControlRadioButton(0, -100, self.controls_width + 20, self.height_control,
label=c["label"], font=self.font, textColor=c["color"],
focusTexture=os.path.join(self.mediapath, 'Controls',
'MenuItemFO.png'),
noFocusTexture=os.path.join(self.mediapath, 'Controls',
'MenuItemNF.png'))
focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'),
noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'))
else:
control = xbmcgui.ControlRadioButton(0, -100, self.controls_width + 20,
self.height_control, label=c["label"], font=self.font,
textColor=c["color"],
focusTexture=os.path.join(self.mediapath, 'Controls',
'MenuItemFO.png'),
noFocusTexture=os.path.join(self.mediapath, 'Controls',
'MenuItemNF.png'),
focusOnTexture=os.path.join(self.mediapath, 'Controls',
'radiobutton-focus.png'),
noFocusOnTexture=os.path.join(self.mediapath, 'Controls',
'radiobutton-focus.png'),
focusOffTexture=os.path.join(self.mediapath, 'Controls',
'radiobutton-nofocus.png'),
noFocusOffTexture=os.path.join(self.mediapath, 'Controls',
'radiobutton-nofocus.png'))
focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'),
noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'),
focusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'),
noFocusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'),
focusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png'),
noFocusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png'))
self.addControl(control)
control.setVisible(False)
control.setRadioDimension(x=self.controls_width + 10 - (self.height_control - 5), y=0,
control.setRadioDimension(x=self.controls_width - (self.height_control - 5), y=0,
width=self.height_control - 5, height=self.height_control - 5)
control.setSelected(self.values[c["id"]])
@@ -497,18 +488,16 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
self.getControl(10006).setLabel(self.custom_button['label'])
else:
self.getControl(10006).setVisible(False)
self.getControl(10004).setPosition(self.getControl(10004).getPosition()[0] + 80,
self.getControl(10004).getPosition()[1])
self.getControl(10005).setPosition(self.getControl(10005).getPosition()[0] + 80,
self.getControl(10005).getPosition()[1])
self.getControl(10004).setPosition(self.getControl(10004).getPosition()[0] + 80, self.getControl(10004).getPosition()[1])
self.getControl(10005).setPosition(self.getControl(10005).getPosition()[0] + 80, self.getControl(10005).getPosition()[1])
# Obtenemos las dimensiones del area de controles
self.controls_width = self.getControl(10007).getWidth() - 30
self.controls_height = self.getControl(10007).getHeight() -100
self.controls_pos_x = self.getControl(10007).getPosition()[0] + self.getControl(10001).getPosition()[0] + 10
self.controls_pos_y = self.getControl(10007).getPosition()[1] + self.getControl(10001).getPosition()[1]
self.height_control = 40
self.font = "font12"
self.height_control = 60
self.font = "font16"
# En versiones antiguas: creamos 5 controles, de lo conrtario al hacer click al segundo control,
# automaticamente cambia el label del tercero a "Short By: Name" no se porque...
@@ -616,9 +605,10 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
new_index = self.index
else:
if index + show_controls >= len(self.visible_controls): index = len(
self.visible_controls) - show_controls - 1
if index < 0: index = 0
if index + show_controls >= len(self.visible_controls):
index = len(self.visible_controls) - show_controls - 1
if index < 0:
index = 0
new_index = index
if self.index != new_index or force:
@@ -641,8 +631,8 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
c["label"].setPosition(self.controls_pos_x + self.controls_width - 30, c["y"])
else:
c["label"].setPosition(self.controls_pos_x, c["y"])
c["upBtn"].setPosition(self.controls_pos_x + c["control"].getWidth() - 40, c["y"] + 15)
c["downBtn"].setPosition(self.controls_pos_x + c["control"].getWidth() - 25, c["y"] + 15)
c["upBtn"].setPosition(self.controls_pos_x + c["control"].getWidth() - 90, c["y"] + 23)
c["downBtn"].setPosition(self.controls_pos_x + c["control"].getWidth() - 50, c["y"] + 23)
self.set_visible(c, True)
@@ -821,40 +811,50 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
pass
def onAction(self, raw_action):
# Obtenemos el foco
# Get Focus
focus = self.getFocusId()
action = raw_action.getId()
# Accion 1: Flecha izquierda
# On Left
if action == 1:
# Si el foco no está en ninguno de los tres botones inferiores, y esta en un "list" cambiamos el valor
if focus not in [10004, 10005, 10006]:
# if focus is on List
if focus not in [10003, 10004, 10005, 10006]:
isList = False
control = self.getFocus().getId()
# if Focus is on control list
for cont in self.list_controls:
if cont["type"] == "list" and cont["control"].getId() == control:
index = cont["lvalues"].index(cont["label"].getLabel())
if index > 0:
cont["label"].setLabel(cont["lvalues"][index - 1])
# Guardamos el nuevo valor en el listado de controles
# the new value is saved in the list of controls
self.values[cont["id"]] = cont["lvalues"].index(cont["label"].getLabel())
isList = True
self.evaluate_conditions()
self.dispose_controls(self.index, force=True)
self.check_default()
self.check_ok()
# else focus on first active Button
if not isList:
if self.ok_enabled:
self.setFocusId(10004)
else:
self.setFocusId(10005)
# Si el foco está en alguno de los tres botones inferiores, movemos al siguiente
else:
if focus == 10006:
self.setFocusId(10005)
if focus == 10005 and self.ok_enabled:
self.setFocusId(10004)
else:
self.evaluate_conditions()
self.dispose_controls(self.index, force=True)
self.check_default()
self.check_ok()
# Accion 1: Flecha derecha
# if Focus is on close button
elif focus == 10003:
self.setFocusId(3001)
# On Right
elif action == 2:
# Si el foco no está en ninguno de los tres botones inferiores, y esta en un "list" cambiamos el valor
if focus not in [10004, 10005, 10006]:
# if focus is on List
if focus not in [10003, 10004, 10005, 10006]:
isList = False
control = self.getFocus().getId()
for cont in self.list_controls:
if cont["type"] == "list" and cont["control"].getId() == control:
@@ -862,24 +862,27 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
if index < len(cont["lvalues"]) - 1:
cont["label"].setLabel(cont["lvalues"][index + 1])
# Guardamos el nuevo valor en el listado de controles
# the new value is saved in the list of controls
self.values[cont["id"]] = cont["lvalues"].index(cont["label"].getLabel())
isList = True
self.evaluate_conditions()
self.dispose_controls(self.index, force=True)
self.check_default()
self.check_ok()
# else focus on close Button
if not isList:
self.setFocusId(10003)
# Si el foco está en alguno de los tres botones inferiores, movemos al siguiente
else:
self.evaluate_conditions()
self.dispose_controls(self.index, force=True)
self.check_default()
self.check_ok()
# if Focus is on button
else:
if focus == 10004:
self.setFocusId(10005)
if focus == 10005 and self.default_enabled:
self.setFocusId(10006)
self.setFocusId(3001)
# Accion 4: Flecha abajo
# On Down
elif action == 4:
# Si el foco no está en ninguno de los tres botones inferiores, bajamos el foco en los controles de ajustes
# if focus is on List
if focus not in [10004, 10005, 10006]:
try:
focus_control = [self.visible_controls.index(c) for c in self.visible_controls if c["control"].getId() == self.getFocus().getId()][0]
@@ -888,20 +891,29 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
except:
focus_control = 0
while not focus_control == len(self.visible_controls) and (
self.visible_controls[focus_control]["type"] == "label" or not
self.visible_controls[focus_control]["active"]):
while not focus_control == len(self.visible_controls) and (self.visible_controls[focus_control]["type"] == "label" or not self.visible_controls[focus_control]["active"]):
focus_control += 1
if focus_control >= len(self.visible_controls):
self.setFocusId(10005)
focus_control = 0
self.setFocusId(3001)
return
self.dispose_controls(focus_control, True)
# Accion 4: Flecha arriba
# Else navigate on main buttons
elif focus in [10004]:
self.setFocusId(10005)
elif focus in [10005]:
if self.default_enabled: self.setFocusId(10006)
elif self.ok_enabled: self.setFocusId(10004)
elif focus in [10006]:
if self.ok_enabled: self.setFocusId(10004)
else: self.setFocusId(10005)
# On Up
elif action == 3:
# Si el foco no está en ninguno de los tres botones inferiores, subimos el foco en los controles de ajustes
# if focus is on List
if focus not in [10003, 10004, 10005, 10006]:
try:
focus_control = \
@@ -912,27 +924,31 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
self.visible_controls[focus_control]["active"]):
focus_control -= 1
if focus_control < 0: focus_control = 0
if focus_control < 0:
focus_control = len(self.visible_controls) - 1
except:
focus_control = 0
self.dispose_controls(focus_control, True)
# Si el foco está en alguno de los tres botones inferiores, ponemos el foco en el ultimo ajuste.
else:
focus_control = len(self.visible_controls) - 1
while not focus_control == -1 and (self.visible_controls[focus_control]["type"] == "label" or not
self.visible_controls[focus_control]["active"]):
focus_control -= 1
if focus_control < 0: focus_control = 0
# Else navigate on main buttons
elif focus in [10004]:
if self.default_enabled: self.setFocusId(10006)
else: self.setFocusId(10005)
elif focus in [10005]:
if self.ok_enabled: self.setFocusId(10004)
elif self.default_enabled: self.setFocusId(10006)
elif focus in [10006]:
self.setFocusId(10005)
self.setFocus(self.visible_controls[focus_control]["control"])
# Accion 104: Scroll arriba
# Accion 104: Scroll Down
elif action == 104:
self.dispose_controls(self.index - 1)
# Accion 105: Scroll abajo
# Accion 105: Scroll Up
elif action == 105:
self.dispose_controls(self.index + 1)
@@ -941,6 +957,9 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
elif action in [10, 92]:
self.close()
elif action == 501:
self.xx = int(raw_action.getAmount2())
elif action == 504:
if self.xx > raw_action.getAmount2():
@@ -953,8 +972,6 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
self.dispose_controls(self.index - 1)
return
elif action == 501:
self.xx = int(raw_action.getAmount2())
class ControlEdit(xbmcgui.ControlButton):

View File

@@ -2,48 +2,50 @@
<window>
<allowoverlays>false</allowoverlays>
<animation type="WindowOpen" reversible="false">
<effect type="zoom" start="80" end="100" center="640,225" delay="160" tween="back" time="240" />
<effect type="slide" start="0,-100" end="0,0" center="640,225" delay="160" tween="back" time="240" />
<effect type="fade" delay="160" end="100" time="240" />
</animation>
<animation type="WindowClose" reversible="false">
<effect type="zoom" start="100" end="80" center="640,225" easing="in" tween="back" time="240" />
<effect type="slide" start="0,0" end="0,-100" center="640,225" easing="in" tween="back" time="240" />
<effect type="fade" start="100" end="0" time="240" />
</animation>
<controls>
<control type="group" id="10001">
<posx>240</posx>
<posy>110</posy>
<width>800</width>
<height>500</height>
<left>0</left>
<top>0</top>
<width>100%</width>
<height>100%</height>
<control type="image">
<width>800</width>
<height>500</height>
<texture>Shortcut/dialog-bg-solid.png</texture>
<width>100%</width>
<height>100%</height>
<texture border="2" colordiffuse="EE232323">Shortcut/white.png</texture>
</control>
<control type="label" id="10002">
<posy>15</posy>
<posx>50</posx>
<height>34</height>
<width>725</width>
<font>font12_title</font>
<top>20</top>
<left>10%</left>
<height>40</height>
<width>80%</width>
<font>font30_title</font>
<textcolor>FFFFFFFF</textcolor>
<align>center</align>
<align>left</align>
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70000]</label>
</control>
<!-- CLOSE BUTTON -->
<control type="button" id="10003">
<posx>745</posx>
<posy>25</posy>
<width>20</width>
<height>20</height>
<right>30</right>
<top>30</top>
<width>30</width>
<height>30</height>
<texturefocus>Controls/DialogCloseButton-focus.png</texturefocus>
<texturenofocus>Controls/DialogCloseButton.png</texturenofocus>
</control>
<!-- OK -->
<control type="button" id="10004">
<posx>40</posx>
<posy>410</posy>
<left>60</left>
<top>100</top>
<width>200</width>
<height>50</height>
<height>60</height>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<texturefocus>Controls/KeyboardKey.png</texturefocus>
@@ -52,11 +54,12 @@
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70001]</label>
</control>
<!-- CANCEL -->
<control type="button" id="10005">
<posx>300</posx>
<posy>410</posy>
<left>60</left>
<top>170</top>
<width>200</width>
<height>50</height>
<height>60</height>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<texturefocus>Controls/KeyboardKey.png</texturefocus>
@@ -65,11 +68,12 @@
<aligny>center</aligny>
<label>$ADDON[plugin.video.kod 70002]</label>
</control>
<!-- DEFAULT -->
<control type="button" id="10006">
<posx>560</posx>
<posy>410</posy>
<left>60</left>
<top>240</top>
<width>200</width>
<height>50</height>
<height>60</height>
<textwidth>110</textwidth>
<textcolor>FFFFFFFF</textcolor>
<texturefocus>Controls/KeyboardKey.png</texturefocus>
@@ -79,16 +83,16 @@
<label>$ADDON[plugin.video.kod 70003]</label>
</control>
<control type="group" id="10007">
<posy>80</posy>
<posx>20</posx>
<width>745</width>
<height>387</height>
<top>100</top>
<left>300</left>
<width>900</width>
<height>680</height>
<control type="label" id="100010">
<posy>30</posy>
<posx>0</posx>
<width>745</width>
<height>300</height>
<font>font16</font>
<top>0</top>
<left>0</left>
<width>900</width>
<height>680</height>
<font>font20</font>
<textcolor>FFFFFFFF</textcolor>
<align>center</align>
<aligny>center</aligny>
@@ -96,19 +100,18 @@
</control>
</control>
<control type="image" id="10008">
<posy>80</posy>
<posx>780</posx>
<top>100</top>
<right>0</right>
<width>10</width>
<height>300</height>
<textcolor>FFFFFFFF</textcolor>
<texture>Controls/ScrollBack.png</texture>
<height>560</height>
<texture border="2" colordiffuse="FF232323">Shortcut/white.png</texture>
</control>
<control type="image" id="10009">
<posy>80</posy>
<posx>780</posx>
<top>100</top>
<right>0</right>
<width>10</width>
<height>300</height>
<texture>Controls/ScrollBar.png</texture>
<height>560</height>
<texture border="2" colordiffuse="33FFFFFF">Shortcut/white.png</texture>
</control>
</control>
</controls>