[QUESTION] label positioning based on prior labels - possible?
#1
hi there,

i wonder if i can get a workaround for this situation:

lets's say we have a button for ejecting a disc. in english this would be called

EJECT DISC. now there is the german user for whom the label would be
DISC AUSWERFEN <- note the longer words.

if that label is positioned alongside other horizontal arranged labels, it will be displayed just fine for the english strings, but on german that label would overlap the next label. (note: i don't want to scroll here.)

is there a possibility to position the next label (posx that is) depending on it's prior label so they never overlap in any situation? would "spacebetweenitems" already do the job?
and, if yes, how do i use that? normally, i tend to create a group of labels where each entry gets it's own posx/posy alignment..

thanks for enlighting me here..
cheers,azido :;):
Reply
#2
Not currently possible. A patch would be welcome. What would be needed is an alteration to the label control so that it could report it's width as the text width rather than the actual width.

That way you could throw them in a grouplist and you'd be done.

It's potentially a fairly quick modification, should you be that way inclined.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
jmarshall Wrote:Not currently possible. A patch would be welcome. What would be needed is an alteration to the label control so that it could report it's width as the text width rather than the actual width.

That way you could throw them in a grouplist and you'd be done.

It's potentially a fairly quick modification, should you be that way inclined.

Cheers,
Jonathan

i wish i would be. i might have a clue how to do this using ajax in dynamic web page generation, but not here, although i think it could be solved quite similar. if the creation of pages and labels in xbmc would be as dynamic on user's demand as it is on such web content, it would be fairly easy to get them well-formed. but xbmc's way of displaying content is more like the good old html: reading pre-defined and pre-formatted contents that get displayed on trigger in a fixed way.

so for the time being the only solution to bypass that overlapping is to apply scrolling to the labels in question unless someone finds a better trick.
cheers,azido :;):
Reply
#4
There's been some discussion about this before. Indeed, some legend even made a trac ticket on it (that same legend then forgot all about it :p ):

http://trac.xbmc.org/ticket/6510#comment:1

On considering it some more, I think it'd be better to leave GetWidth() as-is, as there are some functions in XBMC that expect this to be the actual control width. Instead, the use of another function or two to grab the dynamic width would be preferable.

Jezz_X suggested this format, from the skinner's perspective.

<width min="20" max="200">auto</width>

The most obvious controls that could use this are the label and button controls.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
jmarshall Wrote:There's been some discussion about this before. Indeed, some legend even made a trac ticket on it (that same legend then forgot all about it :p ):

haha Wink ok, i see you're on the same boat here. any ongoing discussion on forum (beside this one) regarding that subject i can participate?

that grabbing from a defined maxwidth with the current text length returned is an interesting way of getting it done, indeed.
cheers,azido :;):
Reply
#6
There was certainly some discussion earlier on the forums - I'm sure you can dredge it up just as fast as I can (hint: try google search rather than the forum search)

I might take a (very) quick look at getting the label control working this evening. In fact, the keen svn follower would have noticed some commits by me today - these are all aimed at making this possible (one can't space stuff out correctly within a group unless one has first updated the label).

I'll update the thread and the trac ticket if I get anywhere.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
jmarshall Wrote:There was certainly some discussion earlier on the forums - I'm sure you can dredge it up just as fast as I can (hint: try google search rather than the forum search)

I might take a (very) quick look at getting the label control working this evening. In fact, the keen svn follower would have noticed some commits by me today - these are all aimed at making this possible (one can't space stuff out correctly within a group unless one has first updated the label).

I'll update the thread and the trac ticket if I get anywhere.

Cheers,
Jonathan

i've just woke up so my following on trac will.. ahm.. follow Wink so now it's time for reading&searching.

thanks for your time.

edit: i see something on the horizon now.. called m_textWidth and m_textHeight.. Big Grin

Quote:(one can't space stuff out correctly within a group unless one has first updated the label).
yes. so before it even tries to count, it has to get the words to display from the strings.xml of users desired language. note that this will not work on labels where the string to use is already there, so our routine has to consider

a) <label>This Text is already to be displayed</label>
b) <label>31254</label> (i am a string id to be replaced by strings.xml either in english or another desired language
c) <label>23</label> (i am a number to be displayed)

even before it measures text widths. or am i wrong and all those defined string ids are already readed in on startup/reload of xbmc (loading user's strings.xml) so for our convenience any label will already be seen as being the final text to display?

edit: another thing that comes in my mind: it should not even try to count if there is a <scroll>true</scroll> command involved, so for such labels it should just read the defined <width> or take maxWidth as it's given limit.
cheers,azido :;):
Reply
#8
if you have enough empty space to the left of the label as a short term fix you could just align right the label and align left the value.
Reply
#9
andyblac Wrote:if you have enough empty space to the left of the label as a short term fix you could just align right the label and align left the value.

you mean like the hebrew labelling fix for episode air date on your mod, don't you?

true. another workaround also would be to increase the size of the label spacing so that it would fit the longest possible content it can have. but that would not produce a smart layout for a group of labels as their content (and so the length) varies on given languages.

we need something that in the end will create the same amount of space between those labels in every possible variation.
cheers,azido :;):
Reply
#10
here's a visual example as what happens regulary on rows of labels and should be avoided..

see 1st the english movie info screen. note the row "cast watch.. and so on"
(don't mind for the 3rd word, it's just greyed out but is still there)

Image

and now the same one with german strings.xml applied

Image

in an ideal, peaceful and happy world the position of those labels would just expand to the right so we have the same spaces between those labels as on the english example, the group itself just became wider on demand.
cheers,azido :;):
Reply
#11
Note that the above is likely buttons not just labels, so the current patch (see the trac ticket) won't work currently. (In fact, given that the patch attached to the ticket hasn't been tested, it may not work for labels either :p )

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#12
jmarshall Wrote:Note that the above is likely buttons not just labels, so the current patch (see the trac ticket) won't work currently. (In fact, given that the patch attached to the ticket hasn't been tested, it may not work for labels either :p )

Cheers,
Jonathan

yeah, of course those are buttons, sorry. but as i understand it the labels are their visual and usable appearances, aren't they? at least when it comes to a horizontal line up for those. surely we wouldn't have to discuss about given label lengths when they are vertically aligned. i'd extend the button with and give those labels an additional center tag and me and my eyes would be fine..

but for the horizontal alignment - i mean, if there has been drawn an underlying texture to make it visually appear more as a button, i would still request to extend/shrink the underlying texture to fit the current label length plus some padding left+right (lets say a given button.png is 2px wide so use repeat-x until it fits currentlabelwidth +x), then have a defined space, then do the same for the next button based on it's label and so on.

but as we don't need to deal with graphics here, it comes down to just the label to be the measured (and displayed) thing anyway.

that given, once you can define where a label gets positioned based on the given length of the previous label, it might be pretty easy to adopt this for the width and height of a button plus have a general rule for the group how much space should be between the items - or am i completely messing up different things here?

as i said, i'm no developer/coder and my only sight here is from the web-programmers point of view, so forgive me if my output is technical nonsense for you Smile
cheers,azido :;):
Reply
#13
Ofcourse the same trick will work for buttons - it's just a matter of time.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#14
jmarshall Wrote:Ofcourse the same trick will work for buttons - it's just a matter of time.

that's what i wanted to hear from you. minus that time thing, though.. Rolleyes
the better part would have been

"ahm, if you need to move buttons, why don't you &!%/%"/ read the manual and use command "movethatbuttonbylabellength" for your convenience?"Laugh
cheers,azido :;):
Reply
#15
I've been working on the Contrete skin with Feanor, and I had this problem with some sub menus.
As a workaround, I made this python script that gets loaded with the window (like the RecentlyAdded script). You pass it all the ids of the buttons, and it adjusts their width based on the number of characters.
It's not an ideal solution, since a label with a lot of 'i' or 'l' will be larger than necessary, but it works.
You can download it here: http://pastebin.com/f29466fa1.
Save it as 'FixLabelWidth.py' in your skin scripts folder.
I'm using this code to load it at startup:
Code:
<control type="button" id="8998">
    <description>Run adjust width script</description>
    <posx>-20</posx>
    <posy>-20</posy>
    <width>1</width>
    <height>1</height>
    <label>-</label>
    <font>-</font>
    <onfocus>RunScript(special://skin/scripts/FixLabelWidth.py,90161,90162,90163,90164)</onfocus>
    <onfocus>SetFocus(9000)</onfocus>
    <texturenofocus>-</texturenofocus>
    <texturefocus>-</texturefocus>
</control>
I have set '8998' as the window defaultcontrol, and '9000' is the control I actually want to start with focus. Also, '90161,90162,90163,90164' are the ids of the buttons I want the script to affect.

This is the first script I've made for XBMC, so please let me know what you think.
Reply

Logout Mark Read Team Forum Stats Members Help
[QUESTION] label positioning based on prior labels - possible?0