Page 2 of 4

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 3:27 am
by mritter0
In your example you have a list of nodes defined

Code: Select all

struct Node *btn1 = NULL, *btn2 = NULL, *btn3 = NULL, *btn4 = NULL, *btn5 = NULL, *btn6 = NULL;
My lists are dynamic. I make my speedbar nodes in a loop.

Let's say my bar has 10 items (could be any number up to 25). How would I toggle enabled/disabled of items 3-5?
Somehow get node 3.
SetSpeedButtonNodeAttrs() for the node.
Somehow get node 4.
SetSpeedButtonNodeAttrs()
repeat....

I need something like

Code: Select all

SetSpeedButtonByIDAttrs(
    SPEEDBAR_ButtonID,    3,
        SBNA_Disabled,    FALSE,

    SPEEDBAR_ButtonID,    4,
        SBNA_Disabled,    TRUE,

    SPEEDBAR_ButtonID,    5,
        SBNA_Selected,    TRUE,
TAG_DONE);
Similar to how you AllocListBrowserNode() with multiple columns. Or like the set menu state code I came up with for the new BOOPSI menus. If only one can be modified at a time (per function call) I am fine with that.

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 3:45 am
by mritter0
This is all there is. Nothing out of the ordinary. Using window.class and layout.class

Code: Select all

	if (!(BookmarksSpeedBarList=(struct List *)IExec->AllocSysObject(ASOT_LIST,NULL)))
	{
		SAK_EasyRequest(Objects[OID_WINDOW],MainWindow,RequesterTitle,REQIMAGE_ERROR,0,SAK_LocaleString(MSG_COULD_NOT_CREATE_EXEC_LIST),SAK_LocaleString(MSG_TERMINATE));

		return(FALSE);
	}

// load bookmarks into list from prefs file

// create speedbar gadget

	struct Node						*node;		// I even put this in the while() loop, no better
	uint32							x=0;

	BookmarksNode=(struct BookmarksNode *)SAK_FirstGenericListNode(MasterBookmarksList);
	while(BookmarksNode)
	{
		if ((node=ISpeedBar->AllocSpeedButtonNode(x,
			SBNA_Text,							BookmarksNode->Name,
			SBNA_Spacing,						2,
			SBNA_UserData,						x,
		TAG_DONE)))
		{
			IExec->AddTail(BookmarksSpeedBarList,node);
		}
		else
		{
			return(FALSE);
		}
		x++;

		BookmarksNode=(struct BookmarksNode *)SAK_NextGenericListNode(MasterBookmarksList);
	}

	if (!(Objects[GAD_BOOKMARKS_SPEEDBAR]=IIntuition->NewObject(ISpeedBar->SPEEDBAR_GetClass(),NULL,
		GA_ID,								GAD_BOOKMARKS_SPEEDBAR,
		GA_RelVerify,						TRUE,
		GA_Underscore,						~0,
		SPEEDBAR_BevelStyle,				BVS_NONE,
		SPEEDBAR_HorizPadding,				0,
		SPEEDBAR_VertPadding,				0,
		SPEEDBAR_ButtonType,				SBTYPE_TEXT,
		SPEEDBAR_Buttons,					BookmarksSpeedBarList,
		ICA_TARGET,							ICTARGET_IDCMP,				// since can't get Code to work properly
	TAG_DONE)))
		return(FALSE);


// main Wait() loop

	IIntuition->GetAttrs(Objects[OID_WINDOW],
		WINDOW_SigMask,						&SignalsMask,
	TAG_DONE);
	while(!done)
	{
		Signals=IExec->Wait(SignalsMask);
		if (Signals & SignalsMask)
		{
			while((Result=IIntuition->IDoMethod(Objects[OID_WINDOW],WM_HANDLEINPUT,&Code)) != WMHI_LASTMSG)
			{
				switch(Result & WMHI_CLASSMASK)
				{
					case WMHI_GADGETUP:
						switch(Result & WMHI_GADGETMASK)
						{
							case GAD_BOOKMARKS_SPEEDBAR:
								// handled in IDCMP_IDCMPUPDATE hook
								//
								// would rather do this:
								//
								IIntuition->GetAttrs(Objects[GAD_BOOKMARKS_SPEEDBAR],
									SPEEDBAR_ButtonID,            &Offset,        (or SPEEDBAR_Selected)
								TAG_DONE);
								//
								// or
								//
								struct Node *WorkingNode;
								IIntuition->GetAttrs(Objects[GAD_BOOKMARKS_SPEEDBAR],
									SPEEDBAR_SelectedNode,            &WorkingNode,
								TAG_DONE);
								ISpeedBar->GetSpeedButtonNodeAttrs(WorkingNode,
									SBNA_UserData,                  &Offset,
								TAG_DONE);								
								break;
						}
				}
			}
		}
	}

..........

		case IDCMP_IDCMPUPDATE:
			Code=IUtility->GetTagData(GA_ID,0,imsg->IAddress);
			if (Code==GAD_BOOKMARKS_SPEEDBAR)
			{
				if ((WorkingNode=(struct Node *)IUtility->GetTagData(SPEEDBAR_SelectedNode,0,imsg->IAddress)))
				{
					ISpeedBar->GetSpeedButtonNodeAttrs(WorkingNode,
						SBNA_UserData,						&Offset,
					TAG_DONE);
					HandleBookmarks(Offset);
				}
			}


	if (BookmarksSpeedBarList)
	{
		FreeSpeedBarList(BookmarksSpeedBarList);
		IExec->FreeSysObject(ASOT_LIST,BookmarksSpeedBarList);
	}

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 2:42 pm
by broadblues
Whilst we're on to images, I'd like to see an option to specify how I want the text/image to be placed. Currently if you have both on a speedbar button, it's always image on top, text below. I'd like the option to have {image}{text} or {text}{image} or even (actually I don't want this, but it should be an option):
{text}
{image}

Any chance of this being added?
Just use a label.image ofyou want custom text and image layouts, adding abunch of flags to speedbar.gadget will always fall short of the combinations that te next dev that comes alog can think of.

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 2:45 pm
by broadblues
salass00 wrote:
mritter0 wrote:Use SBNA_ButtonID with GetAttrs() to get which button was clicked.
The SBNA_#? tags are for the AllocSpeedButtonNode(), SetSpeedButtonNodeAttrs() and GetSpeedButtonNodeAttrs() functions.

In case you're wondering SBNA is short for "SpeedButton Node Attribute".
I am still using IDCMP_UPDATE method but not a big fan of that.
The only reason to use IDCMP_IDCMPUPDATE to check for button pressed events would be if you were avoiding using window.class for some reason but still wanted to use layout.gadget for layout (AWeb does this for its browser windows for instance although I'm not sure why).
AWeb was written in an era when using window.class was much too restrictive when it came to event handling, probably with the much improved OS4 version of window.class AWeb could have used a window.class window. Even then it would likely still need an IDCMPHook

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 2:49 pm
by broadblues
What would fix my problem with the Code issue would be to make SPEEDBAR_Selected and SPEEDBAR_SelectedNode OM_GET so I can do this
That wouldn't really work, though as the buttons in a speedbar are not permanently selected, thus when you came to do the OM_GET the selection state would be "stale".

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 5:08 pm
by chris
broadblues wrote:Just use a label.image ofyou want custom text and image layouts
Oh yes, of course. Silly me. :oops:

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 7:02 pm
by mritter0
I would also REALLY REALLY like to have

Code: Select all

SBNA_BevelStyle, BVS_NONE, 
SBNA_Transparent, TRUE,
ability. Like in button.gadget.

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 7:06 pm
by mritter0
broadblues wrote:
What would fix my problem with the Code issue would be to make SPEEDBAR_Selected and SPEEDBAR_SelectedNode OM_GET so I can do this
That wouldn't really work, though as the buttons in a speedbar are not permanently selected, thus when you came to do the OM_GET the selection state would be "stale".
Why wouldn't it? It would just be what the last button clicked is. It would only be checked right after WHMI_GADGETUP. Then I could check toggle state.

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 8:56 pm
by broadblues
Why wouldn't it? It would just be what the last button clicked is. It would only be checked right after WHMI_GADGETUP. Then I could check toggle state.
Because the last button clicked is insufficient, more than one may have been clicked before you get the chnace to process your incoming messages in the IDCMP_HOOK or the main HandleInput loop.

It's unneccessary as 'code' will tell which button was pressed.

Re: SpeedBar Separator and Images and SBNA_ButtonID

Posted: Mon Nov 16, 2015 9:00 pm
by broadblues
mritter0 wrote:This is all there is. Nothing out of the ordinary. Using window.class and layout.class

snip...
Could please code that doesn't work *all of it* not the code that you would like to see with a hypothetical API change?

Or write a short example athat isn't working for you? You would either then spot your mistake or reveal a bug in the gadget if there is one.