Page 3 of 3

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

Posted: Fri Feb 21, 2014 6:39 pm
by salass00
AmiHyperion wrote:Tried both, same result.
You did add "LAYOUT_SpaceInner, FALSE," to all your layouts?

If you did then it's not inter-gadget spacing but spacing between the button text and the 0 pixel wide, BVS_NONE bevel. You can reduce this to it's minimum f.e. by adding "CHILD_WeightedWidth, 0, CHILD_WeightedHeight, 0," after your parent layout like so:

Code: Select all

LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* vertical layout */
    LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
    LAYOUT_SpaceInner, FALSE,
    LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 1 */
        LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        LAYOUT_SpaceInner, FALSE,
        /* buttons here */
    TAG_END),
    LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 2 */
        LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        LAYOUT_SpaceInner, FALSE,
        /* buttons here */
    TAG_END),
    LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 3 */
        LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        LAYOUT_SpaceInner, FALSE,
        /* buttons here */
    TAG_END),
TAG_END),
CHILD_WeightedWidth, 0,
CHILD_WeightedHeight, 0,

Re: Reaction Layout Tutorial

Posted: Fri Feb 21, 2014 7:52 pm
by gazelle
AmiHyperion wrote:It's a long piece of code for 9 buttons.
If all your buttons are looking the same way you can make a macro or function out of it, you know.

edit:

Code: Select all

Object *buildButton(uint32 objID, CONST_STRPTR fileUNSEL, CONST_STRPTR fileSEL)
{
	return IIntuition->NewObject(NULL, "button.gadget",
		GA_ID, objID,
		BUTTON_BevelStyle, BVS_NONE,
		BUTTON_Transparent, TRUE,
		BUTTON_RenderImage, IIntuition->NewObject(NULL, "bitmap.image",
			BITMAP_SourceFile, fileUNSEL,
			BITMAP_DisabledSourceFile, fileSEL,
			BITMAP_Screen, scr,
			BITMAP_Masking, TRUE,
		TAG_END),
		BUTTON_SelectImage, IIntuition->NewObject(NULL, "bitmap.image",
			BITMAP_SourceFile, fileSEL,
			BITMAP_Screen, scr,
			BITMAP_Masking, TRUE,
		TAG_END),
	TAG_END);
}

[...]

LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* vertical layout */
	LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
	LAYOUT_SpaceInner, FALSE,
	LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 1 */
		LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
		LAYOUT_SpaceInner, FALSE,
        /* buttons here */
		LAYOUT_AddChild, gadgets[OBJ_BUT1] = buildButton(OBJ_BUT1, "images/AUP.png", "images/Object1.png"),
		LAYOUT_AddChild, gadgets[OBJ_BUT2] = buildButton(OBJ_BUT2, "images/AUP.png", "images/Object1.png"),
		LAYOUT_AddChild, gadgets[OBJ_BUT3] = buildButton(OBJ_BUT3, "images/AUP.png", "images/Object1.png"),
    TAG_END),
    LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 2 */
        LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        LAYOUT_SpaceInner, FALSE,
        /* buttons here */
		LAYOUT_AddChild, gadgets[OBJ_BUT4] = buildButton(OBJ_BUT4, "images/AUP.png", "images/Object1.png"),
		LAYOUT_AddChild, gadgets[OBJ_BUT5] = buildButton(OBJ_BUT5, "images/AUP.png", "images/Object1.png"),
		LAYOUT_AddChild, gadgets[OBJ_BUT6] = buildButton(OBJ_BUT6, "images/AUP.png", "images/Object1.png"),
    TAG_END),
    LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 3 */
        LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        LAYOUT_SpaceInner, FALSE,
        /* buttons here */
		LAYOUT_AddChild, gadgets[OBJ_BUT7] = buildButton(OBJ_BUT7, "images/AUP.png", "images/Object1.png"),
		LAYOUT_AddChild, gadgets[OBJ_BUT8] = buildButton(OBJ_BUT8, "images/AUP.png", "images/Object1.png"),
		LAYOUT_AddChild, gadgets[OBJ_BUT9] = buildButton(OBJ_BUT9, "images/AUP.png", "images/Object1.png"),
    TAG_END),
TAG_END),
CHILD_WeightedWidth, 0,
CHILD_WeightedHeight, 0,

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

Posted: Fri Feb 21, 2014 10:01 pm
by salass00
AmiHyperion wrote: It's a long piece of code for 9 buttons.
Not sure what you are wanting to do exactly but in PlayCDDA GUI I have numbered buttons to select which CD track to play. These are 32 numbered buttons in 4 rows with 8 buttons in each. Creating this many buttons one by one manually would have been a huge amount of code and I wanted to be able to easily change the amount of columns and rows if necessary so I created some helper functions using for loops to do the job called CreateTable() and CreateColumn(). You can find them in src/playcdda_gui.c in the archive on OS4Depot.

http://os4depot.net/share/audio/play/playcdda_gui.lha

In PlayCDDA I have the buttons labeled using increasing numbers but if you want to use images you could simply specify the image filenames for each button using an array like so:

Code: Select all

CONST_STRPTR button_images[9 * 2] = {
    "normal_image1", "selected_image1",
    "normal_image2", "selected_image2",
    "normal_image3", "selected_image3",
    /* ... */
     "normal_image9", "selected_image9",
};

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

Posted: Fri Feb 21, 2014 11:12 pm
by AmiHyperion
@salass00
AmiHyperion wrote:If you did then it's not inter-gadget spacing but spacing between the button text and the 0 pixel wide, BVS_NONE bevel. You can reduce this to it's minimum f.e. by adding "CHILD_WeightedWidth, 0, CHILD_WeightedHeight, 0," after your parent layout like so:
I did as you told here, adding CHILD_WeightedWidth, 0, CHILD_WeightedHeight, 0. The result is the same as using "LAYOUT_FixedHoriz, FALSE," to each layout.

The spaces beetween buttons are removed, but the layout (and the buttons) are aligned to the left border of the window, not at the middle.

@gazelle
As for the macro, thank you. Could be usefull in the future, but at the moment i uses 9 different buttons

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

Posted: Sat Feb 22, 2014 9:20 am
by salass00
AmiHyperion wrote: The spaces beetween buttons are removed, but the layout (and the buttons) are aligned to the left border of the window, not at the middle.
So change the alignment. That's what the LAYOUT_HorizAlignment and LAYOUT_VertAlignment tags are for. The default for LAYOUT_HorizAlignment is LALIGN_LEFT, if you want centered set it to LALIGN_CENTER.

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

Posted: Sat Feb 22, 2014 7:03 pm
by AmiHyperion
I had already tried this, but instead of inserting after the vertical layout, I had inserted after the horizontal layout. Now i moved the tag to the right place and it works!

Code: Select all


LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL,
							LAYOUT_BevelStyle,  BVS_GROUP,
							LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, //Here's the righ place
							LAYOUT_Label,       " N A V I G A T I O N ",
								LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* vertical layout */
    								LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
    								LAYOUT_HorizAlignment, LALIGN_CENTER,
    								LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, /* row 1 */
        							LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        							LAYOUT_FixedHoriz, FALSE,
        							/* Add buttons here */
    								LAYOUT_AddChild, gadgets[OBJ_BUT1] = /*ButtonObject,*/
                        					IIntuition->NewObject(NULL, "button.gadget",

One note: the click area button is a rectangular area around the pixel itself, it's not pixel precise. It's normal?