[TheBar] TheBar fix

  • From: "Gianfranco \"ShInKurO\" Gignina" <sh1nkur0@xxxxxxxxx>
  • To: thebar@xxxxxxxxxxxxx
  • Date: Mon, 25 May 2009 10:13:03 +0200

Hi all!
Here my fix :-)


-- 
Ciao da ShInKurO!

http://shinkuro.amiga.it
When TheButton is subclassed and pointer to this subclass is added to struct MUIS_TheBar_Button like documentation said, this subclass is not used for spaces. More precisely, If it's used as space MUIV_TheBar_ImageSpacer, you should obtain setting MUIA_TheBar_SpacerIndex to a right image number a TheButton object which has same features of your TheButton subclass, and this didn't happen. This fix solve this problem without damage normal behaviour of TheBar. This fix permit to have a d&d space in case of MUIV_TheBar_ImageSpacer and MUIA_TheBar_SpacerIndex right setted. Now it's possible to sort, remove and add an (image) space button. --This line, and those below, will be ignored-- M trunk/mcc/class.c
Index: trunk/mcc/class.c
===================================================================
--- trunk/mcc/class.c   (revision 309)
+++ trunk/mcc/class.c   (working copy)
@@ -72,7 +72,7 @@
     }
     else if(button->img==MUIV_TheBar_ImageSpacer)
     {
-      if(isFlagClear(data->flags, FLG_TextOnly) && data->brushes 
&&((LONG)data->spacer>=0) && (data->viewMode!=MUIV_TheBar_ViewMode_Text) &&
+      if(data->brushes &&((LONG)data->spacer>=0) && (!button->class) &&
          (o = (Object *)TheButtonObject,
                MUIA_TheButton_MinVer,                                       16,
                MUIA_Group_Horiz,                                            
isFlagSet(flags, FLG_Horiz),
@@ -87,12 +87,35 @@
                MUIA_TheButton_Sunny,                                        
isFlagSet(flags, FLG_Sunny),
                MUIA_TheButton_Scaled,                                       
isFlagSet(flags, FLG_Scaled),
                MUIA_TheButton_Spacer,                                       
MUIV_TheButton_Spacer_Image,
+               MUIA_TheButton_ID,                                           
button->ID,
                isFlagSet(flags, FLG_FreeStrip) ? MUIA_TheButton_Strip : 
TAG_IGNORE, (IPTR)&data->strip,
           End))
       {
         RETURN(o);
         return o;
       }
+      else if(data->brushes &&((LONG)data->spacer>=0) && (button->class) &&
+         (o =  NewObject(button->class,NULL,
+               MUIA_TheButton_MinVer,                                       16,
+               MUIA_Group_Horiz,                                            
isFlagSet(flags, FLG_Horiz),
+               MUIA_TheButton_TheBar,                                       
(IPTR)obj,
+               MUIA_TheButton_NoClick,                                      
TRUE,
+               MUIA_TheButton_Image,                                        
(IPTR)data->brushes[data->spacer],
+               data->sbrushes ? MUIA_TheButton_SelImage : TAG_IGNORE,       
(IPTR)(data->sbrushes ? data->sbrushes[data->spacer] : NULL),
+               data->dbrushes ? MUIA_TheButton_DisImage : TAG_IGNORE,       
(IPTR)(data->dbrushes ? data->dbrushes[data->spacer] : NULL),
+               MUIA_TheButton_ViewMode,                                     
MUIV_TheButton_ViewMode_Gfx,
+               MUIA_TheButton_Borderless,                                   
TRUE,
+               MUIA_TheButton_Raised,                                       
FALSE,
+               MUIA_TheButton_Sunny,                                        
isFlagSet(flags, FLG_Sunny),
+               MUIA_TheButton_Scaled,                                       
isFlagSet(flags, FLG_Scaled),
+               MUIA_TheButton_Spacer,                                       
MUIV_TheButton_Spacer_Image,
+               MUIA_TheButton_ID,                                           
button->ID,
+               isFlagSet(flags, FLG_FreeStrip) ? MUIA_TheButton_Strip : 
TAG_IGNORE, (IPTR)&data->strip,
+          TAG_DONE)))
+      {
+        RETURN(o);
+        return o;
+      }
       else
       {
         Object *spacer;
@@ -2268,9 +2291,9 @@
     }
     else
     {
-       #if defined(__amigaos4__)
-       FreeSysObject(ASOT_MEMPOOL, pool);
-       #else
+      #if defined(__amigaos4__)
+      FreeSysObject(ASOT_MEMPOOL, pool);
+      #else
         DeletePool(pool);
         #endif
     }

Other related posts: