View Single Post
Old 08 July 2021, 15:26   #6
Warty
Registered User
 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 301
I will do a little audit of what I'm doing to this window. It's been a year or so since I really worked on it, I don't remember everything I'm doing.

I did make a lot of progress on the reaction conversion. Most things are working again.

A couple of things I'm stuck with though:
1. how do I get the scrollbars back into the window borders? I have taken out all the old code I had that positioned the scrollbars in the borders using GA_RelBottom, etc. My assumption is that when I make them part of the reaction layout, I shouldn't be doing that sort of thing.

2. I can't pick up events for the scrollbars. I have an IDCMP hook set up:

the scroller objects:
Code:
	// create the scrollbar objects and the string object used for renaming files
	the_surface->gadgets_[MAIN_GID_H_SCROLL] = ScrollerObject,
			GA_ID,					MAIN_GID_H_SCROLL,
			SCROLLER_Orientation,	SORIENT_HORIZ,
			GA_Immediate,			TRUE,
			GA_RelVerify,			TRUE,
			ICA_TARGET, 			ICTARGET_IDCMP,
		ScrollerEnd;
	
	the_surface->gadgets_[MAIN_GID_V_SCROLL] = ScrollerObject,
			GA_ID,					MAIN_GID_V_SCROLL,
			SCROLLER_Orientation,	SORIENT_VERT,
			GA_Immediate,			TRUE,
			GA_RelVerify,			TRUE,
			ICA_TARGET, 			ICTARGET_IDCMP,
		ScrollerEnd;
relevant part of the object creation for the window:
Code:
		WA_IDCMP,			IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW | IDCMP_CHANGEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_MENUPICK | IDCMP_EXTENDEDMOUSE,
		WINDOW_IDCMPHook,		&the_surface->scroller_hook_,
		WINDOW_IDCMPHookBits,	IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
		WINDOW_AppPort,		global_app->launched_app_reply_port_,
		WINDOW_SharedPort,	the_user_port,
Code:
		// set up an IDCMP hook that will let us examine IDCMP messages to see if scrollers have been moved
		the_surface->scroller_hook_.h_Entry = (void *)Window_ScrollerHook;
		the_surface->scroller_hook_.h_SubEntry = NULL;
		the_surface->scroller_hook_.h_Data = (APTR)the_surface;
Code:
// hook function to receive IDCMP events, and check them for scrollbar movement
// based on code found here: https://github.com/pcwalton/NetSurf/blob/master/netsurf/amiga/tree.c\ami_tree_scroller_hook
void Window_ScrollerHook(struct Hook* hook, Object* object, struct IntuiMessage* msg) 
{
	ULONG					activated_gadget_id;
	ULONG					x;
	ULONG					y;
	WB2KWindow*				the_surface = (WB2KWindow*)hook->h_Data;
	struct IntuiWheelData*	wheel;

	DEBUG_OUT(("Window_ScrollerHook %d: msg->Class = %lu, code=%u, qualifier=%u, addr=%p", __LINE__, msg->Class, msg->Code, msg->Qualifier, msg->IAddress));
	
	switch(msg->Class)
	{
		case IDCMP_IDCMPUPDATE:
			activated_gadget_id = GetTagData( GA_ID, 0, msg->IAddress ); 
			DEBUG_OUT(("Window_ScrollerHook %d: activated_gadget_id = %lu", __LINE__, activated_gadget_id));

			if (activated_gadget_id == MAIN_GID_H_SCROLL || activated_gadget_id == MAIN_GID_V_SCROLL)
			{
				signed long		new_pos;
				
				new_pos = Gadget_GetTop(the_surface->gadgets_[activated_gadget_id]);
				DEBUG_OUT(("Window_ScrollerHook %d: scrollbar gadget %lu = %li", __LINE__, activated_gadget_id, new_pos));

				if (activated_gadget_id == MAIN_GID_H_SCROLL)
				{
					the_surface->content_left_ = new_pos;
				}
				
				// draw content without recalculating icon positions
				Panel_RegenerateDisplay(the_surface->active_panel_);
			}
			

			break;

		case IDCMP_EXTENDEDMOUSE:
			// TODO: mousewheel support! 
// 			if(msg->Code == IMSGCODE_INTUIWHEELDATA)
// 			{
// 				wheel = (struct IntuiWheelData *)msg->IAddress;
// 
// 				ami_tree_scroll(twin, (wheel->WheelX * 20), (wheel->WheelY * 20));
// 			}
			break;
	}
}
The hook function is getting called, but the msg code is basically always 0 on mouse down and scrollbar movement. I think on mouse up it is sending the other result you see in the screenshot. I say "I think" because once I click on a scrollbar, the amiga gets very slow and unresponsive for a few seconds. Definitely something not right.
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2021-07-08 wb2k reaction IDCMP hook.png
Views:	99
Size:	69.1 KB
ID:	72492  
Warty is offline  
 
Page generated in 0.08190 seconds with 12 queries