Page 1 of 1

LAYOUT_BackFill

Posted: Sat Jul 01, 2017 3:36 am
by mritter0
LAYOUT_BackFill (struct Hook *)
A layer backfill hook to use in the group to provide a more
complex background pattern. This is not propagated to the
group's children; use LAYOUT_LayoutBackFill for that.
Pass ~0L to have the group use the window.class backfill.

Defaults to use the window.class backfill if any exists; else
to "clear" for the main layout, and "no backfill" for sublayouts.

Applicability is (OM_NEW, OM_SET)
I would like to make a group, not the entire window, set to a black background color (no pattern). The window is resizeable, thus changing the group size, so would have to refresh automatically. I am looking for the hook source code to do this.

Code: Select all

			LAYOUT_AddChild,					IIntuition->NewObject(LayoutClass,NULL,LAYOUT_Orientation,LAYOUT_ORIENT_VERT,

// make this group with a black background
LAYOUT_BackFill, hook,

				LAYOUT_AddChild,					IIntuition->NewObject(LayoutClass,NULL,LAYOUT_Orientation,LAYOUT_ORIENT_HORIZ,
					LAYOUT_SpaceInner,					TRUE,
					LAYOUT_SpaceOuter,					TRUE,
					LAYOUT_EvenSize,					TRUE,
					LAYOUT_AddChild,					ChildObjects[GAD_OK]=IIntuition->NewObject(ButtonClass,NULL,
						GA_ID,								GAD_OK,
						GA_Underscore,						~0,
						GA_RelVerify,						TRUE,
						GA_Text,							SAK_LocaleString(MSG_OK),
						BUTTON_SoftStyle,					FSF_BOLD,
					TAG_DONE),
						CHILD_WeightedWidth,				0,
					LAYOUT_AddChild,					ChildObjects[GAD_CANCEL]=IIntuition->NewObject(ButtonClass,NULL,
						GA_ID,								GAD_CANCEL,
						GA_Underscore,						~0,
						GA_RelVerify,						TRUE,
						GA_Text,							SAK_LocaleString(MSG_CANCEL),
					TAG_DONE),
						CHILD_WeightedWidth,				0,
				TAG_DONE),
			TAG_DONE),

Re: LAYOUT_BackFill

Posted: Sat Jul 01, 2017 11:52 am
by gazelle
What about LAYOUT_LayoutBackFill which should be propagated to all childrens, which is right there in the description you posted?

Re: LAYOUT_BackFill

Posted: Sat Jul 01, 2017 3:41 pm
by mritter0
I don't want all the groups to use the backfill, just 1. I am looking for the hook source code on how to fill it with a solid color.

Re: LAYOUT_BackFill

Posted: Sun Jul 02, 2017 2:17 am
by broadblues
Try this:

Code: Select all


VARARGS68K ULONG backfillhookfunc(struct Hook *hook, struct RastPort *rp, struct BackFillMessage *msg)
{
   struct RastPort myrp = *rp;
   myrp.Layer = NULL;

   IGraphics->SetAPen(&myrp,myBackFillPen);
   IGraphics->RectFill(&myrp,msg->Bounds.MinX,msg->Bounds.MinY,msg->Bounds.MaxX,msg->Bounds.MaxY);
   return 0L;
}

The pen there is passed through using a global, you could use the hook data ptr (better TBH) you could use ARGB colur values and SetRPortAttrs() I used a pen in this case (AOrgnanisers main window) as I need to pass the pen colour to the button gadgets as the unslected colour so they blend into the background.



Note you need to set the hook *after* the layout has been added to window.object , otherwise window.class will overwrite the hook settings with it's own.

You *may* need to rethink the window after that. I read thread to that effect a short while ago, AO rethinks it's window anyway so I never tested it without that.

Re: LAYOUT_BackFill

Posted: Sun Jul 02, 2017 6:23 pm
by mritter0
That worked. Thanks.

But seeing your code gave me an idea that made things easier for what I am trying to do.

BTW, why are you using VARARGS68K for your hook?

Re: LAYOUT_BackFill

Posted: Sun Jul 02, 2017 7:41 pm
by broadblues
mritter0 wrote: BTW, why are you using VARARGS68K for your hook?
Because it's a hook, probably called by DoHookPacket() at some level and so *must* be declared with VARARGS68K. It's so that the args are on the stack 68k style and not in System V ABI PPC style

From the migration guide.pdf in the SDK , see last line in particular.

5.1 General Hook Functions
Hook functions used to be called with a specific mapping of 68k registers. Quite naturally, there are no 68k
registers on a PowerPC machine, so the programmer needs to be a bit careful when writing a hook function.
CallHookPkt, or its vararg version CallHook, will always adhere to the PowerPC SysV ABI, and therefore the
order of the parameters in the called function is important (it was always to be considered bad style to rearrange
the parameters of a hook function, but possible through the explicit declaration of register mappings).
A hook function should always look like this:
uint32 HookFunction(struct Hook *hook, APTR object, APTR message);
The first argument, hook, points to the hook with which this function was invoked. The second paramter, objec, is
a generic 'target' for the oeration, and depends on the context that this hook is being called in. The final argument,
message, is a pointer to a message package whose layout also depends on the hook context.
Hook functions need to have the VARARGS68K tag. The next chapter will describe what that means.