SpeedBar Separator and Images and SBNA_ButtonID

This forum is for general developer support questions.

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby mritter0 » Mon Nov 16, 2015 4:27 am

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby mritter0 » Mon Nov 16, 2015 4:45 am

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby broadblues » Mon Nov 16, 2015 3:42 pm

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby broadblues » Mon Nov 16, 2015 3:45 pm

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby broadblues » Mon Nov 16, 2015 3:49 pm

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby chris » Mon Nov 16, 2015 6:08 pm

broadblues wrote:Just use a label.image ofyou want custom text and image layouts


Oh yes, of course. Silly me. :oops:
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby mritter0 » Mon Nov 16, 2015 8:02 pm

I would also REALLY REALLY like to have
Code: Select all
SBNA_BevelStyle, BVS_NONE,
SBNA_Transparent, TRUE,

ability. Like in button.gadget.
Last edited by mritter0 on Mon Nov 16, 2015 9:49 pm, edited 1 time in total.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 207
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby mritter0 » Mon Nov 16, 2015 8:06 pm

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby broadblues » Mon Nov 16, 2015 9:56 pm

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

Re: SpeedBar Separator and Images and SBNA_ButtonID

Postby broadblues » Mon Nov 16, 2015 10:00 pm

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

PreviousNext

Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 2 guests