In python (see below) ident (x direction) for pixmap is set to 5, and pixmap y position is set to 0. If you downsize pixmap (icon) to less than text size the pixmap will stick to position y0. There is no centering neither in x or y direction. And we dont need that either.
From standard code: res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 5, 0, pxw, pxh, png)) # x=5 y=0
Standard code is:
def ChoiceEntryComponent(key = "", text = ["--"]):
res = [ text ]
"""
<component type="ChoiceList" itemHeight="30" textWidth="800" textHeight="25" textX="45" textY="0" pixmapWidth="35" pixmapHeight="25" fillerCount="200" />
"""
sizes = componentSizes[componentSizes.CHOICELIST]
tx = sizes.get("textX", 45)
ty = sizes.get("textY", 0)
tw = sizes.get("textWidth", 800)
th = sizes.get("textHeight", 25)
pxw = sizes.get("pixmapWidth", 35)
pxh = sizes.get("pixmapHeight", 25)
fillers = sizes.get("fillerCount", 200)
if text[0] == "--":
res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, tw, th, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, "-" * fillers))
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, tx, ty, tw, th, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, text[0]))
png = (key != "False") and LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/key_" + key + ".png")) or None
if png is not None:
res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 5, 0, pxw, pxh, png))
return res
Alles anzeigen
...and it could be this, what solves the problem properly:
def ChoiceEntryComponent(key = "", text = ["--"]):
res = [ text ]
"""
<component type="ChoiceList" itemHeight="30" textWidth="800" textHeight="25" textX="45" textY="0" pixmapX="5" pixmapY="0" pixmapWidth="35" pixmapHeight="25" fillerCount="200" />
"""
sizes = componentSizes[componentSizes.CHOICELIST]
px = sizes.get("pixmapX", 5)
py = sizes.get("pixmapY", 0)
tx = sizes.get("textX", 45)
ty = sizes.get("textY", 0)
tw = sizes.get("textWidth", 800)
th = sizes.get("textHeight", 25)
pxw = sizes.get("pixmapWidth", 35)
pxh = sizes.get("pixmapHeight", 25)
fillers = sizes.get("fillerCount", 200)
if text[0] == "--":
res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, tw, th, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, "-" * fillers))
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, tx, ty, tw, th, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, text[0]))
png = (key != "False") and LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/key_" + key + ".png")) or None
if png is not None:
res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, px, py, pxw, pxh, png))
return res
Alles anzeigen
You could even go further and auto calculate a textMargin from pixmapWidth to where text starts, but the code above will be good enough for a skin maker to solve every issue.