Label and button width
#1
is there a way of getting the width in pixels of a label or button control ?

at the moment all i can think of doing is calculating the width based on each individual characters width. (also mention here: http://www.xboxmediaplayer.de/cgi-bin....t=2731)

getwidth() and getheight() for controlbutton , controllabel etc would ideal.

any ideas?

thanks
Reply
#2
im pretty sure the width and height must be specified in the constructor and any text you put in it will be either truncated or won't fill up the area.
Reply
#3
yes. what i meant was that i'm trying to calculate the button width according to the text length about to be used for the label.

i've now used the fontattr class (from this forum) which works.

would be nice if we had a built in func to calc string length based on font used.

cheers anyway.
Reply
#4
ohh ok... well the xbmc python api is very limited right now and there are lots of things needing adding..

like changing the color of text to a label after you create it...
or interfacing with the picture slideshow...

i really need to get a copy of vc++ 2003 so i can get into this code...
Reply
#5
xbmc patch 1166891 may help with what is being discussed here. i exposed the remaining parameters to the cguilabelcontrol class (amongst other things). this means that you can pass the left, right, center y, center x, and truncate alignment flags. if truncate is passed, it will only render the label within the defined label width. if the label text is too large, xbmc renders as much as it can minus room for "...".

when i first started doing python scripting for xbmc, i went down the road of calculating character pixel widths but as soon as you start supporting skins, it gets messy. fonts come with different character widths... also, skinners may change fonts depending on resolution. it is just better to let xbmc calculate what it can and cannot display.

the patch also exposes those parameters for button controls... but the guilib doesn't support truncation of button labels yet. i may add in support later - for now the work around is to use a button control (if you need a button) and then slap a label control on top with the truncate option. of course you'll need to wait until my patch is accepted into cvs...
Reply
#6
thanks for the putting the time into helping out, exposing more parameters is very welcome.

it would be good if we could actually specify a font on buttons and other controls ie. controllist etc

i have a grip with controllist navigation, don't know if someone can help out, but;

there doesn't seem to be a way to navigate right off onto another control (button label whatever) as focus moves to the page up/down and stops there.

would it not be better to either a) have the ability to move right from the paging controls onto your specified control or b) have the option to not display the paging info at all.

i raise this as, if you put several controllists next to each other horizontally on the screen, it doesn't make sense to the user to have to press left to get to the next list on it right.

did i make sense there?
Reply
#7
you can specify a font on controlbuttons (11th parameter) and controllists (5th parameter)... you might need patch 1166891 to get the functionality for the controlbutton but the list font parameter has been there for a while.

there is a parameter to the c++ version of the list to not display the paging control. it is not yet exposed to python. however, you might be able to call getspincontrol() to get the spinner from the list and then set the right navigation control for that control. i haven't tried that but it seems logical. if that works then it would result in:

list -> page up/down control (spinner) -> list 2 -> page up/down...
Reply
#8
it appears that the default right action from the spin control is not mapped, so it basically just returns to the list control in this case.

i'll see what i can fix up on the list control side (because it should go to the <onright> control of the listcontrol).

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
#9
(madtw @ april 04 2005,19:24 Wrote:left, right, center y, center x, and truncate alignment flags.
alignment on labels! sweet.. once this gets out i would be time to update my stock script i think (i really wanted some of the tables right aligned).

can you change the color of a label after it has been created?
this would simplify some of my code as well (right now i am toggling visibility of three labels of different colors as a work-around).
Reply
#10
11th and 7th parameters !? my xbmcgui html doc (dated cvs build 19.mars) must be well out of date?
i have nowhere near as many parameters exposed in that doc.

cheers anyway.
nav on lists: thanks, that definitly would improve the user experience. personnaly i'd prefer it to have the option to skip over the page controls too ... ?
Retired from Add-on dev
Reply
#11
thor918's more recent docs.
xbmc.html
xbmcgui.html
Reply
#12
updated the docs now.more parameteres in there.
Reply
#13
am i being thick, but the link to xbmcgui.html on thor918 still show these prototypes;

controlbutton(int x, int y, int width, int height[, label, focus, nofocus])

and

controllist(int x, int y, int width, int height[, buttontexture, buttonfocustexture])

so i see no 11th and 7th parameters, relating to font?

please explain if i've completly misunderstood about the documentation.

thanks
Reply
#14
cvs was only updated yesterday with madtw's patches (thanks!!Wink

so perhaps things haven't filtered down yet?

edit: i see them in the above links.



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
#15
really sorry. my fault. it was a browser refresh cache thing.

cheers for looking
Reply

Logout Mark Read Team Forum Stats Members Help
Label and button width0