<just:center> incompatible with "relative" sizing? [resolved]
by Tim Scheiman · in Torque Game Builder · 03/23/2010 (12:03 pm) · 7 replies
I've got a GuiMLTextCtrl... and all was well in the land before I switched to 800x600 and realized everything was shifted around.
So I set about to change my window and textctrls all to relative sizing, as recommended in the GUI tutorial by Amaranthia.
I then repositioned the GuiMLTextCtrl by hand...
Now, if I set the text to "Monkeys", it sits there at a certain point, but if I set it to "<just:center>Monkeys"... it just disappears entirely.
Anyone have any idea where it went or why?
I really need center-justified GuiMLTextCtrl objects that stay where they are supposed to be relative to the window!
Any help would be critically life-saving!
-Tim
So I set about to change my window and textctrls all to relative sizing, as recommended in the GUI tutorial by Amaranthia.
I then repositioned the GuiMLTextCtrl by hand...
Now, if I set the text to "Monkeys", it sits there at a certain point, but if I set it to "<just:center>Monkeys"... it just disappears entirely.
Anyone have any idea where it went or why?
I really need center-justified GuiMLTextCtrl objects that stay where they are supposed to be relative to the window!
Any help would be critically life-saving!
-Tim
#2
Thanks for looking into this.
Oddly enough, I discovered that the parent object, a 'handler' of type "GuiModelessDialogProfile"... (modal = false)... had an extent of "1 1".
When I changed this parent object's extent to the size of my canvas (1024 x 768), the justify issue went away...
So the new question becomes -- why was it NOT broken WITHOUT the <justify> tag? My immediate issue is resolved, but if you can shed any light on why normal text would be placed correctly but justified would not (given relative sizing on all, and a parent with a "1 1" extent), it would help me in my understanding of this madness.
-Tim
03/25/2010 (7:05 pm)
Hey William,Thanks for looking into this.
Oddly enough, I discovered that the parent object, a 'handler' of type "GuiModelessDialogProfile"... (modal = false)... had an extent of "1 1".
When I changed this parent object's extent to the size of my canvas (1024 x 768), the justify issue went away...
So the new question becomes -- why was it NOT broken WITHOUT the <justify> tag? My immediate issue is resolved, but if you can shed any light on why normal text would be placed correctly but justified would not (given relative sizing on all, and a parent with a "1 1" extent), it would help me in my understanding of this madness.
-Tim
#3
03/25/2010 (8:55 pm)
On a quick scan of the code, I can't find anything that would cause "center" to work different than no justification tag. Our of curiousity, what type of GUI control was your parent class? A generic GuiControl, a GuiScrollCtrl, or something else all-together?
#5
Glad you got past your bug anyway!
03/25/2010 (9:23 pm)
Well that just confuses me more! Unless somebody else has an idea, this might just stay a mystery.Glad you got past your bug anyway!
#6
When a GuiMLTextCtrl is created, relative sizing to the parent is taken into account. But when you call 'setposition', relative sizing of the parent is ignored.
I was calling setposition by hand.
Because of the tiny extent of the parent, sized relative to ITS parent (the canvas), when it was scaled up to 1024 x 768... the Text's extent was then set to 358400 x 30720 (rather than 350 x 40). So we've got a 1024 canvas and this giant text object.
When you call setposition by hand, it uses pixel coordinates and places the text so that the upper left hand corner of the Ctrl is where you specified (bleh!)... so when I said setposition(10,10), with LEFT justified text, there the text would be... just like I wanted it.
CENTER justify, however, placed the text right in the middle of my 358400-wide textCtrl object... which is clearly way off of my screen.
I really need to add a "setWorldPosition" function to guiMLTextCtrl that places it CENTERED like normal T2D stuff... swapping between 3 coordinate systems is a serious pain!
03/26/2010 (10:25 am)
Figured out the cause of this oddness (and a bunch of other oddness besides).When a GuiMLTextCtrl is created, relative sizing to the parent is taken into account. But when you call 'setposition', relative sizing of the parent is ignored.
I was calling setposition by hand.
Because of the tiny extent of the parent, sized relative to ITS parent (the canvas), when it was scaled up to 1024 x 768... the Text's extent was then set to 358400 x 30720 (rather than 350 x 40). So we've got a 1024 canvas and this giant text object.
When you call setposition by hand, it uses pixel coordinates and places the text so that the upper left hand corner of the Ctrl is where you specified (bleh!)... so when I said setposition(10,10), with LEFT justified text, there the text would be... just like I wanted it.
CENTER justify, however, placed the text right in the middle of my 358400-wide textCtrl object... which is clearly way off of my screen.
I really need to add a "setWorldPosition" function to guiMLTextCtrl that places it CENTERED like normal T2D stuff... swapping between 3 coordinate systems is a serious pain!
#7
03/26/2010 (1:54 pm)
That makes perfect, logical sense! I'm glad you found the answer.
Associate William Lee Sims
Machine Code Games
function GuiMLTextCtrl::onResize( %this ) { if( %this.qResizing ) return; %this.qResizing = true; %this.forceReflow(); %this.qResizing = false; }The oddness with "qResizing" is because "forceReflow" causes "resize" (and "onResize") to be called again, which causes this to get into an infinte loop. This makes it such that forceReflow is only called once per resize event.
Thanks for bringing this to my attention. My game uses GuiMLTextCtrls all over the place and I didn't even know I had a bug!
I'll see if I can get this into the 1.7.5 baseline (as a source code fix).