About Store Forum Documentation Contact



Post Reply 
Positioning GUI
Author Message
Kiekos Offline
Member

Post: #1
Positioning GUI
Hey there!

Is it possible to position (with code) a GUI window created in the GUI Editor? I can't find anything in the tutorials about placing it on the screen. It says how to create window from scratch or load prepared window (but then it is in the middle of the screen).

I've created a Chat Box that I would like to have, let's say, in the bottom left corner a few pixels from the borders and I have no idea how to do that. Will it then remain the same size and in the same place despite different monitor resolutions?

Regards,
Kiekos
05-10-2013 04:25 PM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #2
RE: Positioning GUI
Something like
PHP Code:
Window.pos(Vec2(-D.w(), -D.h()+Window.size().y)) 
?
05-11-2013 09:19 AM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #3
RE: Positioning GUI
Well, I don't know... Is that how you do it?

I've created a window in the GUI Editor that I named "test.gobj". Then to check if it's working I call:

Code:
GuiObjs gui_objs;

gui_objs.load("gui/obj/test.gobj");
Gui+=gui_objs;

But then it's in the middle of the screen and I would like to position it with code... somehow.
05-11-2013 11:23 AM
Find all posts by this user Quote this message in a reply
TBJokers Offline
Member

Post: #4
RE: Positioning GUI
void thescreenChanged(Flt,Flt){
gui_objs.getWindow("").pos(D.h(),D.w()-gui_objs.getWindow("").size().y);
}


D.screen_changed = thescreenChanged;

using this method it will only reposition the object when screen resolution is changed, instead of having it in an update loop which would eventually require more from the computer
05-11-2013 01:02 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #5
RE: Positioning GUI
@TBJokers, compiler says .pos() doesn't take 2 arguments so either I'm doing something wrong or the code is incorrect.

Btw that's for repositioning GUI if screen resolution changes but what if I just want to position GUI first when I load it? The code is in my previous post. I've tried adding a positioning line after loading but nothing seems to be working.

I'm running out of ideas :x
05-12-2013 12:06 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #6
RE: Positioning GUI
.pos() has a Vector of 2 elements as argument. Middle mouse click on functions to see their declaration and understand them.

So pop those coords in a Vec2(.... , ...) inside pos and it will work. Just like Same showed you above. Personally I got all this from tutorial GUIs. They aren't loaded, they're created manually, but positioning them is exactly the same.
05-12-2013 12:35 PM
Find all posts by this user Quote this message in a reply
Kiekos Offline
Member

Post: #7
RE: Positioning GUI
Oh, I see. Now it's working perfectly. Thanks!

I'll ask a few more questions if I stumble across any problems I cannot handle.
05-12-2013 01:13 PM
Find all posts by this user Quote this message in a reply
Post Reply