Intuition/GadTools image menus (IM_ITEM/IM_SUB)

This forum is for general developer support questions.

Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby chris » Sat Jun 18, 2011 11:10 pm

I asked about this on UtilityBase and the Amigans.net temporary site but have yet to receive a conclusive answer.

If I try to create a menu with IM_ITEM, passing a struct Image * created with image.class subclasses in nm_Label, the menu fails to create. Thomas (on UtilityBase) helpfully informed me:

In V40.4 (OS 3.1 / 3.9) LayoutMenus() simply crashes if a BOOPSI image is used.


The include file for gadtools states:

* NOTE: At present, you may only use conventional images.
* Custom images created from Intuition image-classes do not work.


However, in the AutoDoc for CreateMenu, it reads as follows:

Prior to V39, if you put images into menus using IM_ITEM or IM_SUB for a NewMenu->nm_Type, the image supplied had to be an ordinary struct Image. Starting with V39, you can use boopsi images.


and in image.class it says this:

These images are backwards compatible with the conventional Intuition Images.
Every BOOPSI image has an Intuition Image structure embedded in it so Intuition can access the BOOPSI image as a conventional Image structure when necessary.


The documentation is at least contradictary, and maybe slightly misleading. Even if I'm doing something wrong, there's definitely a problem here.

Please can somebody confirm:
* Which bits of the documentation quoted above are actually correct?
I don't see how image.class can be backwards-compatible with standard Images yet not be useable for IM_ITEM labels.

* Whether IM_ITEM is supposed to work with BOOPSI images, but due to a long-standing bug it has never worked? (or if it does work I'd be interested to hear that too!)

* Is there a workaround? Is it possible to convert a BOOPSI Image into a standard Image? (even though this shouldn't be necessary)

I have also tried a standard Intuition Image (the one from the RKRM "simple image" example) in my menu, with not much more success. The menu strip does get attached, but the entire menu under which my IM_ITEM item occured does not get constructed.

I'm being to suspect that image menus (IM_ITEM/IM_SUB) don't work at all through GadTools.

However, even poking the Intuition Menu's FirstItem->ItemFill with a BOOPSI or standard struct Image *, before or after LayoutMenus, doesn't work. It must work at this level with standard Images, or even things like checkmarks wouldn't display. So, what am I doing wrong? Some example code would be really helpful!
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby chris » Mon Jun 20, 2011 6:52 pm

*sigh* Obviously nobody has a clue about this, even people with access to the OS4 source code.

If it helps I've hacked together (and it really is a hack of an old Reaction menu example, my additions have no error checking, but it performs as expected - ie. not at all) an example here. I've essentially replaced the ARexx menu item with one which should display a crown from AISS.

Changing the Image creation method to non-BOOPSI, changing the menu creation to manual LayoutMenus etc, makes very little difference.
Last edited by chris on Wed Jun 22, 2011 6:47 pm, edited 1 time in total.
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby broadblues » Wed Jun 22, 2011 6:29 pm

Your link above us broken. Not that I want to raise your hope by replying to your thread as I haven't a clue either....
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 591
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby chris » Wed Jun 22, 2011 6:51 pm

broadblues wrote:Your link above us broken.


Oops, fixed.

Not that I want to raise your hope by replying to your thread as I haven't a clue either....


Somebody probably needs to dig around in the source code to see how checkmarks work, and then compare that to what GadTools is doing...

The annoying thing is I thought I'd seen an image menu example somewhere (ages ago) but I can't find it, it showed the menus in Sapphire or one of those old bitmap fonts. There is a listview example like that so it may be that I'm getting confused. Other than that I've never seen this being used so I'm kind of curious to get it working.
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby chris » Mon Jul 23, 2012 8:57 am

*bump*

Any chance of an example added to the wiki?
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby samo79 » Thu Aug 02, 2012 6:50 am

When i saw this thread i automatically though about Timberwolf, once a native menu will be integrated (hopefully soon) into the browser this feature would be exactly what the project need in order to handle all that favicons, images and so on ... still we might need also some support for nested menus .. but images would be enough atleast ;)

@chris

I found a couple of links that maybe can help you, one is italian but i think easy translable

http://www.amiworld.it/corsi/amigaos/amigaos12.html
http://www.ummon.eu/En/Amiga/API/AmigaO ... enusA.html
User avatar
samo79
 
Posts: 540
Joined: Sat Jun 18, 2011 12:13 am
Location: Italy

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby chris » Sun Oct 07, 2012 2:37 pm

Finally, a non-working standalone example (it crashes in LayoutMenus). Perhaps somebody can tell me what I'm doing wrong now?

Code: Select all
#define __USE_INLINE__

#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/label.h>
#include <proto/bitmap.h>
#include <intuition/imageclass.h>
#include <images/label.h>
#include <images/bitmap.h>
#include <stdio.h>
#include <reaction/reaction_macros.h>

#ifdef __amigaos4__
struct Library *IntuitionBase = NULL;
struct IntuitionIFace *IIntuition = NULL;
struct Library *GadToolsBase = NULL;
struct GadToolsIFace *IGadTools = NULL;
#else
struct IntuitionBase *IntuitionBase = NULL;
APTR IIntuition = NULL;
struct LabelBase *LabelBase = NULL;
#endif

void cleanup(struct Window *window);

struct Menu *initmenu(struct Window *window, struct Screen *scrn, struct DrawInfo *dri)
{
   struct VisualInfo *vi;
   struct Menu *menu;

   struct NewMenu newmenu[] = {
      { NM_TITLE, "Title", 0, 0, 0, 0, },
      { IM_ITEM, NULL, 0, 0, 0, 0, },
      { NM_END, NULL, 0, 0, 0, 0, },
   };

   newmenu[1].nm_Label = LabelObject,
      LABEL_DrawInfo, dri,
/*
      LABEL_Image, BitMapObject,
         BITMAP_Screen, scrn,
         BITMAP_SourceFile, "TBimages:list_objects",
      BitMapEnd,
*/
      LABEL_Text, "test",
   LabelEnd;

   printf("%lx\n", newmenu[1].nm_Label);

   vi = GetVisualInfoA(scrn, NULL);

   if(menu = CreateMenusA(newmenu, NULL)) {
      if(LayoutMenus(menu, vi, GTMN_NewLookMenus, TRUE, TAG_DONE)) {
         SetMenuStrip(window, menu);
         printf("menus attached\n");
      }
   }
   return menu;
}

int main(int argv, char **argc)
{
    ULONG signalmask, winsignal, signals;
    BOOL done = FALSE;
    struct IntuiMessage *message = NULL;
    ULONG class;
    struct Window *window = NULL;
   struct Screen *scr;
   struct DrawInfo *dri;
   struct Menu *menu;

    IntuitionBase = OpenLibrary("intuition.library",0);
#ifdef __amigaos4__
   IIntuition = (struct IntuitionIFace *)GetInterface(IntuitionBase, "main", 1, NULL);
#endif

    GadToolsBase = OpenLibrary("gadtools.library",0);
#ifdef __amigaos4__
   IGadTools = (struct GadToolsIFace *)GetInterface(GadToolsBase, "main", 1, NULL);
#endif

    LabelBase = OpenLibrary("CLASSES:Images/label.image",0);
#ifdef __amigaos4__
   ILabel = (struct LabelIFace *)GetInterface(LabelBase, "main", 1, NULL);
#endif
scr = LockPubScreen(NULL);
 dri = GetScreenDrawInfo(scr);

    window = OpenWindowTags(NULL,
                     WA_CloseGadget,  TRUE,
                     WA_DragBar,      TRUE,
                     WA_DepthGadget,  TRUE,
                     WA_SizeGadget, TRUE,
                     WA_MinWidth,        50,
                     WA_MinHeight,       50,
                     WA_MaxWidth,        1000,
                     WA_MaxHeight,       700,
                     WA_Width,        600,
                     WA_Height,       200,
                     WA_IDCMP,        IDCMP_CLOSEWINDOW,
                     WA_Title,        "test",
                     WA_NewLookMenus, TRUE,
                     TAG_DONE);

    if (window == NULL) {
        cleanup(window);
      return;
   }

   menu = initmenu(window, scr, dri);

   UnlockPubScreen(NULL, scr);

    winsignal = 1L << window->UserPort->mp_SigBit;
    signalmask = winsignal;

    while(!done)
    {
        signals = Wait(signalmask);

        if(signals & winsignal)
      {
          while(message = (struct IntuiMessage *)GetMsg(window->UserPort))
          {
              class = message->Class;

              switch(class)
              {
                  case IDCMP_SIZEVERIFY:
                   break;

                  case IDCMP_CLOSEWINDOW:
                      done=TRUE;
                   break;

                  default:
                   break;
            }
              ReplyMsg((struct Message *)message);
           }
       }
    }
    cleanup(window);
   return 0;
}

void cleanup(struct Window *window)
{
    if(window) {
      ClearMenuStrip(window);
      CloseWindow(window);
   }

#ifdef __amigaos4__
   if(IIntuition)
      DropInterface((struct Interface *)IIntuition);
#endif

    if(IntuitionBase)
      CloseLibrary(IntuitionBase);

    return;
}





edit: Just noticed I'd already posted an example a year ago. At least I've proved it still doesn't work. *sigh*
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby salass00 » Tue May 14, 2013 1:29 pm

This bug should be fixed in gadtools.library 53.5.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 516
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby chris » Thu May 16, 2013 6:50 pm

salass00 wrote:This bug should be fixed in gadtools.library 53.5.


Woo-hoo! Thanks Fredrik!

Do you fancy looking into my long-running popupmenu.class bug too? (viewtopic.php?f=26&t=121)
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition/GadTools image menus (IM_ITEM/IM_SUB)

Postby salass00 » Thu May 16, 2013 7:21 pm

chris wrote:Do you fancy looking into my long-running popupmenu.class bug too? (viewtopic.php?f=26&t=121)


This bug is already assigned. FWIW I tried running your test case using the latest SVN version of popupmenu.class on my beta system and I couldn't get it to crash here. After allocating signal 17 the popup menu stopped opening but it didn't crash or cause the OS to freeze.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 516
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Next

Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron