Need help: How to center textbox in horizontal fixedlist?
#1
I'm using horizontal fixedlist for some of my menus. Width of each item is limited by layout so for some longer ones I want to use 2 lines. As far as I understand wrapmultiline doesn't work in lists so I choose textbox (it's generic so using label and label2 isn't option, i need automatic wrapping).
To make it conform to my design I need to center each item vertically and there lies my problem ... I wasn't able to make it working Smile

I tried <aligny>center</aligny>

Code:
<itemlayout width="330" height="104">
  <control type="textbox">
    <centerleft>50%</centerleft>
    <width>310</width>
    <align>center</align>
    <aligny>center</aligny>
    <font>Font_44px</font>
    <textcolor>Bright</textcolor>
    <label>$INFO[ListItem.Label]</label>
  </control>
</itemlayout>

or <height>auto</height> + <centertop>50%</centertop>

Code:
<itemlayout width="330" height="104">
  <control type="textbox">
    <centerleft>50%</centerleft>
    <centertop>50%</centertop>
    <width>310</width>
    <height>auto</height>
    <align>center</align>
    <font>Font_44px</font>
    <textcolor>Bright</textcolor>
    <label>$INFO[ListItem.Label]</label>
  </control>
</itemlayout>

and other combination, but nothing seems to work. What I'm doing wrong? Or is it known issue?

Thanks!
Reply
#2
<aligny>center</aligny> has never worked well for textboxes.

I think your second method is closer -- I'm not 100% sure, but you might need to use a max tag in the height control for the auto sizing to work properly...

e.g.
<height max="104">auto</height>

It it might be the case that this is simply not possible however. I'm not sure as I've never tried to do this specifically.
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#3
Thanks Jurial, but this doesn't work either.

Yesterday I briefly checked source codes and to me it seems there is none related to vertical alignment.
I plan to debug through and check what I can do about it.
Reply
#4
As far as I'm aware textboxes can only be left, right, or justified.
Reply
#5
@Hitcher: I hope you mean it never worked and not that it was intentionally omited by developers. I spent some time to make it working so i hope it was not waste Smile

Is any Kodi developer willing to check my code? I'm currently developing on Helix branch (won't to switch my environment to master yet) and guess I can't make pull request from branch to master. Right? Or give me advice what to do. My commit is

Code:
https://github.com/bambi73/xbmc/commit/b807633d1b195f66386d71468737f48e4201672a

I have prepared few pictures to give you better idea what's changed.

1/ Centered new textbox vs. centered original textbox. Original implemetation completelly ignore center_y and pass it to font.DrawText method, so it's vertically centered around 0 and upper half is cut.

Image

2/ Centered textbox vs. centered label with wrapmultiline. Results are same.

Image

3/ Centered textbox vs. not centered textbox, both with overflowing text. I center only fully visible lines (otherwise it'll look like not centered version), result is that starting and ending position are both centered.

Start

Image

End

Image

P.S. I'm aware that on pictures text isn't pixel perfect center, but I guess it because of resolution recalculation. Smile
Reply
#6
Just pinged mkortstiege on your pr.
Reply
#7
Cool bambi, I've got a few textboxes I'm looking forward to centering. Cheers!
Reply
#8
Excellent!
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#9
https://github.com/xbmc/xbmc/pull/6632
Reply

Logout Mark Read Team Forum Stats Members Help
Need help: How to center textbox in horizontal fixedlist?0