LAYOUT_BackFill

This forum is for general developer support questions.

LAYOUT_BackFill

Postby mritter0 » Sat Jul 01, 2017 4:36 am

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),
Last edited by mritter0 on Sat Jul 01, 2017 7:49 pm, edited 1 time in total.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 184
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: LAYOUT_BackFill

Postby gazelle » Sat Jul 01, 2017 12:52 pm

What about LAYOUT_LayoutBackFill which should be propagated to all childrens, which is right there in the description you posted?
User avatar
gazelle
 
Posts: 101
Joined: Sun Mar 04, 2012 1:49 pm
Location: Frohnleiten, Austria

Re: LAYOUT_BackFill

Postby mritter0 » Sat Jul 01, 2017 4:41 pm

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.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 184
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: LAYOUT_BackFill

Postby broadblues » Sun Jul 02, 2017 3:17 am

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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 461
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: LAYOUT_BackFill

Postby mritter0 » Sun Jul 02, 2017 7:23 pm

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?
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 184
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: LAYOUT_BackFill

Postby broadblues » Sun Jul 02, 2017 8:41 pm

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.

User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 461
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 1 guest