Specify the exact position of a window in a screen

This forum is for general developer support questions.
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Specify the exact position of a window in a screen

Post by AmiHyperion »

Hello,

as the topic title say, how can i specify the exact window position?

I know there are some constants defined (TOPLEFT, CENTERSCREEN, etc), but there's a way to specify the exact position?

Thank you
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 534
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland
Contact:

Re: Specify the exact position of a window in a screen

Post by salass00 »

WA_Left and WA_Top tags.
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Specify the exact position of a window in a screen

Post by AmiHyperion »

Assuming that i want to set the window position to the TopRight.

I know there is the WINDOW_Position, WPOS_TOPLEFT tag that move the window at topleft. But what if i want to move to the top only? I mean, just below the WorkBench title bar or custom screen title bar?

If i set manually the top position (WA_Top,30), for example, would this be a relative position, wouldn't it? Probably based on the height of the AmigaOS titlebar or customscreen title bar, subject to change with different theme.
User avatar
gazelle
Posts: 102
Joined: Sun Mar 04, 2012 12:49 pm
Location: Frohnleiten, Austria

Re: Specify the exact position of a window in a screen

Post by gazelle »

I think WA_Left and WA_Top are absolute screen coordinates of the window not relative.

If you want to position your window right below the titlebar of the screen you need to get the screenpointer and use the BarHeight value for that.

Code: Select all

...
struct Screen *screen;
int32 posX;

/* the default public screen */
screen = IIntuition->LockPubScreen(NULL);
if (screen)
{
	/* plus one, see <intuition/screens.h> */
	posX = screen->BarHeight + 1;
	...
	IIntuition->UnlockPubScreen(NULL, screen);
}
...
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 534
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland
Contact:

Re: Specify the exact position of a window in a screen

Post by salass00 »

As gazelle says the WA_Left and WA_Top values are the absolute x and y coordinates for the top left corner of your window. It is how you position your window if none of the predefined WINDOW_Position modes is suitable.

To place the window just below the title bar just set WA_Top to "screen->BarHeight + 1".
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Specify the exact position of a window in a screen

Post by AmiHyperion »

Thank you for the info. I solved in a different way. I'll post the code as soon as i get back to my Amiga.

@Salass00
I sent you a PM on os4coding.
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Specify the exact position of a window in a screen

Post by AmiHyperion »

What about positioning gadgets?

It is possible to specify the exact position?

Edit: found this in the wiki:

"The position and dimensions of the gadget's select box are defined in the Gadget structure. The LeftEdge, TopEdge, Width and Height values can be absolute numbers or values relative to the size of the window."

Still valid?
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Specify the exact position of a window in a screen

Post by AmiHyperion »

What should i change to specify the exact position of this image button?

Code: Select all

LAYOUT_AddChild, gadgets[OBJ_BUT1] = /*ButtonObject,*/
                        					IIntuition->NewObject(NULL, "button.gadget",
                            					GA_ID, OBJ_BUT1,
												BUTTON_BevelStyle, BVS_NONE,
												BUTTON_Transparent, TRUE,
												BUTTON_RenderImage, gadgets[OBJ_BUT1_UNSEL] = /*BitMapObject,*/
                        					IIntuition->NewObject(NULL, "bitmap.image",
												BITMAP_SourceFile, "images/AUP.png",
												BITMAP_DisabledSourceFile, "images/Object1.png",
												BITMAP_Screen, scr,
												BITMAP_Masking, TRUE,
											TAG_END),
												/*BitMapEnd,*/
												BUTTON_SelectImage, gadgets[OBJ_BUT1_SEL] = /*BitMapObject,*/
                        					IIntuition->NewObject(NULL, "bitmap.image",
												BITMAP_SourceFile, "images/Object1.png",
												BITMAP_Screen, scr,
												BITMAP_Masking, TRUE,	
											TAG_END),
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Specify the exact position of a window in a screen

Post by AmiHyperion »

i tried to add GA_Left and GA_Top to specify the exact position, but the gadget appears always in the middle of the screen

LAYOUT_AddChild, gadgets[OBJ_BUT1] = /*ButtonObject,*/
IIntuition->NewObject(NULL, "button.gadget",
GA_ID, OBJ_BUT1,
GA_Left, 10,
GA_Top, 10,
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 534
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland
Contact:

Re: Specify the exact position of a window in a screen

Post by salass00 »

@AmiHyperion

You should be able to use LAYOUT_NoLayout tag if you want to manually position all gadgets/images added to a layout. Not that I see why you want to do this. If you let layout.gadget handle the positioning it will care of all the boring stuff like font sensitivity and such while if you do it yourself you will have to do this stuff manually.
Post Reply