Possible code changes to help with alignment
#1
hi all,

as you know, scaling stuff for differing resolutions is a pain currently with python. you have to retrieve the width/height and use that info to scale where you place everything. this also has to be handled by python currently (ie in every script).

the ability to do the scaling within xbmc is ofcourse already there. i'm thinking of perhaps adding the ability for you to specify how python controls should be scaled in a single function call (ie basically specify somewhere in your script what resolution it is designed for, and then not have to worry about other resolutions at all)

the idea is you'd do something like:

xbmc.setscriptresolution(pal_4x3)

and if xbmc is running in a different resolution, it'll auto-scale the controls at render time.

please let me know what you think of this idea.

i'll probably also add xbmc.getresolution() at the same time so that if you want to, you can do custom setups for each resolution.

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
#2
that is a great idea. would be nice to see that implemented.
Reply
#3
yes it is a pain, this would be great.

would this scale just positions or could it also scale control's height and width. that would be nice, cause sometimes a controls position is based on another controls height/width.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#4
yes, it'll scale both position and width and height. i'll take a look at how xbmc handles it at the moment (been a while since i wrote it) to see how easily it can be done.
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
sounds great :thumbsup:

will it also scale according to pal / ntsc?

if i remember right the skin contains different control positions for pal and ntsc.

bernd
Reply
#6
dude that would be awesome, a lot of my favorite scripts dont have 720p support Sad
Reply
#7
ok, as promised, two new window functions have been added:

getresolution() - returns the current resolution that xbmc is running in. numbers between 0 and 9 inclusive - you can find them in guilib/graphicscontext.h, but here they are for reference anyway, including there frame sizes and pixel ratios.

hdtv_1080i = 0, (1920x1080, 16:9, pixels are 1:1)
hdtv_720p = 1, (1280x720, 16:9, pixels are 1:1)
hdtv_480p_4x3 = 2, (720x480, 4:3, pixels are 4320:4739)
hdtv_480p_16x9 = 3, (720x480, 16:9, pixels are 5760:4739)
ntsc_4x3 = 4, (720x480, 4:3, pixels are 4320:4739)
ntsc_16x9 = 5, (720x480, 16:9, pixels are 5760:4739)
pal_4x3 = 6, (720x576, 4:3, pixels are 128:117)
pal_16x9 = 7, (720x576, 16:9, pixels are 512:351)
pal60_4x3 = 8, (720x480, 4:3, pixels are 4320:4739)
pal60_16x9 = 9 (720x480, 16:9, pixels are 5760:4739)

this should help you to custom design for a particular resolution (eg a widescreen one).

setcoordinateresolution(long resolution)

this sets the coordinate resolution that you are using for the controls.

eg. you just design your script for (say) pal_4x3, thus having all coordinates designed so that it'll fit nicely onto a 720x576 drawing area (remember to allow for overscan!Wink.

then you call setcoordinateresolution(pal_4x3), and if the user running your script is using 720p, xbmc will auto-scale all the control positions and sizes at render time up so that everything fits into 1280x720.

you can call setcoordinateresolution() whenever you like - it doesn't have to be before you create the controls, though that is the logical place to do so.

i haven't tested the above functions, so please test and report back on how fantastically it works Wink

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
#8
wonderful, wonderful! nice work

i don't have time to test right now, but i hope somebody else will Smile
xbmcscripts.com administrator
Reply
#9
sweet dude, ill try it on the xmovie guide tonight when i get home from work :kickass:
Reply
#10
:thumbsup: :bowdown:
Livingroom: MacMini Mid summer 2010 4Gb RAM HDMI to Pioneer PDP-434 Plasma 1080i
Kitchen: one xbox 1.1 executer 2.3 chip 120 GB in HD 720p mode
Bedroom: Computer Intel Quad 9400, 8 GB RAM, NVIDIA GTX260, Vista Ultimate 64, Ubuntu 10.10
Reply
#11
i have a little test.py script that has some images and labels and a button. that might be a good test for the scaling.

i'm on plain ol ntsc 4:3, if someone would like to test the new features for other resolutions, i could send it to you.

sorry no ftp access, unless it could be hosted here.there are two files test.py and test.png.

i use pmiii, so the fonts may not look right in another skin and it requires panel2.png, which i think most skins have.

Image
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#12
just for fun i tried changing:

self.setcoordinateresolution(ntsc_4x3)
to:
self.setcoordinateresolution(hdtv_1080i)

and it didn't change anything. i set all the values for the above variables at the beginning of the script, so that's not the problem.

print self.getresolution() correctly returns 4

i tried for both a window and a windowdialog. i called setcoordinateresolution() before and after the controls were added.

did i miss something?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#13
thanks jonathan,

after playing around with this for a while. this is going to work out really nice. (fantastically)

going from widescreen to non-widescreen you can see it stretch, correct me if i'm wrong that wouldn't work right with just using scalex, they would have looked different on the two platforms.

great job.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#14
ok im not much good with python but i thought i would give this a try. i tried adding it to xmovie guide and it keeps telling me that the global name is not defined. i tried with self.setcoordinateresolution(ntsc_4x3) and with self.getresolution()

same thing with each. am i missing something here? would anyone be will to add in the piece for the xmovie guide and post it here or send it to me? i can usually figure it out once i have seen it done correctly :kickass:
Reply
#15
did you place it directly under:

class movieguide(xbmcgui.window):
   def ..init..(self, bkgd = ""):

and did you update your build today?

edit: also is the following at the begining of the script?

ntsc_4x3 = 4 # (720x480, 4:3, pixels are 4320:4739)
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
Possible code changes to help with alignment0