Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Custom Gui - How to hide the label?

    SDK Help
    0
    33
    18.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 15/01/2015 at 10:45, xxxxxxxx wrote:

      Hello Andreas,

      Are you sure these properties are not part of the datatype instead of the Custom GUI? I think MINSLIDER and MAXSLIDER sare part of the **  LONG** datatype, implemented in CustomDataTypeClass::GetProperties(). When creating user-data, you can specify these values not in the "Details" Tab (where the properties are listed) but in the "Properties" Tab (where you change the datatype of the parameter, etc. [Yes, confusing]).

      I think, the problem in your case is, that you expect such properties to propagate through. You'd like to set the properties of a BITMAPBUTTON CustomGUI, which is embedded in your own CustomGUI BANNER. And this won't work.

      Actually, no. I only have a GeUserArea in my CustomGui dialog and I define the properties in the CustomGuiData subclass.

      class BannerGuiCustomGuiData : public CustomGuiData
      {
        typedef CustomGuiData super;
      public:
        
        // CustomGuiData Overrides
        
        virtual Int32 GetId() override
        {
          return CUSTOMGUI_BANNER;
        }
        virtual CDialog* Alloc(const BaseContainer& settings) override
        {
          BannerGui* dlg = NewObj(BannerGui, settings, this->GetPlugin());
          if (dlg) {
            return dlg->Get();
          }
          return nullptr;
        }
        virtual void Free(CDialog* dlg, void* userdata) override
        {
          if (userdata) {
            BannerGui* gui = static_cast<BannerGui*>(userdata);
            DeleteObj(gui);
          }
        }
        virtual const Char* GetResourceSym() override
        {
          return "BANNER";
        }
        virtual CustomProperty* GetProperties() override
        {
          static CustomProperty props[] = {
            { CUSTOMTYPE_LONG,   BANNERGUI_ICONID,         "ICON_ID" },
            { CUSTOMTYPE_LONG,   BANNERGUI_BGCOLOR_ID,     "BGCOLOR_ID" },
            { CUSTOMTYPE_VECTOR, BANNERGUI_BGCOLOR_VECTOR, "BGCOLOR_VECTOR" },
            { CUSTOMTYPE_FLAG,   BANNERGUI_TRANSPARENT,    "TRANSPARENT" },
            { CUSTOMTYPE_STRING, BANNERGUI_HALIGN,         "ALIGN_H" },
            { CUSTOMTYPE_LONG,   BANNERGUI_WIDTH,          "WIDTH" },
            { CUSTOMTYPE_LONG,   BANNERGUI_HEIGHT,         "HEIGHT" },
            { CUSTOMTYPE_FLAG,   BANNERGUI_LOCKSCALE,      "LOCKSCALE" },
            { CUSTOMTYPE_END, 0, "" },
          };
          return props;
        }
        virtual Int32 GetResourceDataType(Int32*& table) override
        {
          static Int32 _table[] = { DA_LONG, DA_LLONG, DA_STRING, DA_FILENAME };
          table = _table;
          return 4;
        }
      };
      

      Best,
      Niklas

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 15/01/2015 at 13:02, xxxxxxxx wrote:

        To be honest, I'm not sure at all. 😉

        This entire CustomGUI/CustomDataType/resource description/dialog description/dynamic description stuff confused and is still confusing me. No promises made, but sometime I will write an article for the SDK docs, to get this sorted.

        On the other hand I tried it here in one of my private plugins.
        I just double checked (the plugin contains indeed a CustomDataType as well).
        Here's my code:

        Int32 ColorHarmonyCustomGuiData::GetId() { return CUSTOMGUI_HARMONY; }
          
        CDialog* ColorHarmonyCustomGuiData::Alloc(const BaseContainer& settings)
        {
          m_pDlg = NewObj(ColorHarmonyCustomGuiWheel, settings, GetPlugin());
          if (!m_pDlg) {
            return nullptr;
          }
          return m_pDlg->Get();
        }
          
        void ColorHarmonyCustomGuiData::Free(CDialog* dlg, void* ud)
        {
          if (dlg) {
            DeleteObj((GeDialog*&)dlg);
          }
        }
          
        const Char* ColorHarmonyCustomGuiData::GetResourceSym()
        {
          return "HARMONY";
        }
          
        CustomProperty g_cpHarmonyWheelProps[] =
        {
          { CUSTOMTYPE_LONG, HARMONY_RGB_FIRST, "NUM_HARMONIES" }, // SDK Support Test
          { CUSTOMTYPE_END, 0, nullptr }
        };
          
        CustomProperty* ColorHarmonyCustomGuiData::GetProperties()
        {
          return g_cpHarmonyWheelProps;
        }
          
        Int32 ColorHarmonyCustomGuiData::GetResourceDataType(Int32*& table)
        {
          static Int32 l_table[] = { DTYPE_COLOR, CUSTOMDATATYPE_GRADIENT, CUSTOMDATATYPE_HARMONY };
          table = l_table;
          return sizeof(l_table);
        }
        

        And in a test resource file, I used:

        COLOR ID_TESTOBJECT_HARMONY { FIT_H; SCALE_H; ANIM OFF; CUSTOMGUI HARMONY; NUM_HARMONIES 5; }
        

        I'll double check the LONG datatype tomorrow.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 15/01/2015 at 18:19, xxxxxxxx wrote:

          Thanks Andreas! Not only to you is it confusing. I don't even want't to tell how much time I had
          to invest to get around the CustomGui and CustomDataType stuff. It's poorly documented/explained.

          One idea came up while I read your reply: Maybe it doesn't work because the ID of my property
          conflicts with an existing ID? BANNERGUI_ICONID for instance has the ID 1000. I'm gonna check
          this tomorrow. 🙂

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 23/01/2015 at 07:02, xxxxxxxx wrote:

            That wasn't it. The obvious solution was to make a CustomDataTypeClass plugin that exposes the
            same custom properties. The settings will be merged in the same BaseContainer that is passed to the
            iCustomGui.

            I have only one problem left, unfortunately. I want one of the custom properties to be a String.

            static CustomProperty BannerGuiProperties[] = {
              { CUSTOMTYPE_LONG,   BANNERGUI_ICONID,         "ICON_ID" },
              { CUSTOMTYPE_LONG,   BANNERGUI_BGCOLOR_ID,     "BGCOLOR_ID" },
              { CUSTOMTYPE_VECTOR, BANNERGUI_BGCOLOR_VECTOR, "BGCOLOR_VECTOR" },
              { CUSTOMTYPE_FLAG,   BANNERGUI_TRANSPARENT,    "TRANSPARENT" },
              **{ CUSTOMTYPE_STRING, BANNERGUI_HALIGN,         "ALIGN_H" },**
              { CUSTOMTYPE_LONG,   BANNERGUI_WIDTH,          "WIDTH" },
              { CUSTOMTYPE_LONG,   BANNERGUI_HEIGHT,         "HEIGHT" },
              { CUSTOMTYPE_FLAG,   BANNERGUI_LOCKSCALE,      "LOCKSCALE" },
              { CUSTOMTYPE_END, 0, "" },
            };
            

            But when the property is specified in the Description resource, the entry in the settings container I
            get in the iCustomGui is empty (DA_NIL). If the property is left out, I get the default value that I
            initialized in CustomDataTypeClass::GetDefaultProperties() (which is fine).

                    GROUP {
                        BANNER TEST { ICON_ID 5159; WIDTH 16; ALIGN_H "center"; LOCKSCALE; TRANSPARENT; }
                    }
            
            class BannerGuiDataType : public CustomDataTypeClass {
              typedef CustomDataTypeClass super;
            public:
              
              // CustomDataTypeClass
              
              virtual Int32 GetId() override
              {
                return CUSTOMDATATYPE_BANNER;
              }
              
              virtual CustomDataType* AllocData() override
              {
                return NewObjClear(CustomDataType);
              }
              
              virtual void FreeData(CustomDataType* data) override
              {
                DeleteObj(data);
              }
              
              virtual Bool CopyData(
                const CustomDataType* src, CustomDataType* dest, AliasTrans* at)
                override
              {
                return true;
              }
              
              virtual Int32 Compare(const CustomDataType* d1, const CustomDataType* d2)
                override
              {
                return -1;
              }
              
              virtual Bool WriteData(const CustomDataType* data, HyperFile* hf) override
              {
                return true;
              }
              
              virtual Bool ReadData(CustomDataType* data, HyperFile* hf, Int32 level)
                override
              {
                return true;
              }
              
              virtual const Char* GetResourceSym() override
              {
                return "BANNER";
              }
              
              virtual CustomProperty* GetProperties() override
              {
                return ::BannerGuiProperties;
              }
              
              virtual void GetDefaultProperties(BaseContainer& data) override
              {
                data.SetInt32(BANNERGUI_ICONID, 0);
                data.SetInt32(BANNERGUI_BGCOLOR_ID, -1);
                data.SetVector(BANNERGUI_BGCOLOR_VECTOR, Vector(0, 0, 0));
                data.SetBool(BANNERGUI_TRANSPARENT, false);
                data.SetString(BANNERGUI_HALIGN, "LEFT");
                data.SetInt32(BANNERGUI_WIDTH, -1);
                data.SetInt32(BANNERGUI_HEIGHT, -1);
                data.SetBool(BANNERGUI_LOCKSCALE, false);
                data.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF);
                data.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BANNER);
              }
            };
              
            // -------------------------------------------------------------------------
              
            BannerGui::BannerGui(
              const BaseContainer& bc, CUSTOMGUIPLUGIN* plugin)
              : super(bc, plugin), iconData(), ownsBitmap(false)
            {
              this->ua = NewObjClear(BannerGuiUserArea, this);
              this->iconId = bc.GetInt32(BANNERGUI_ICONID, 0);
              this->transparent = bc.GetBool(BANNERGUI_TRANSPARENT);
              
              if (bc.GetInt32(BANNERGUI_BGCOLOR_ID, -1) < 0) {
                this->bgColor = bc.GetVector(BANNERGUI_BGCOLOR_VECTOR);
              }
              else {
                this->bgColor = bc.GetInt32(BANNERGUI_BGCOLOR_ID);
              }
              
              const String alignMode = bc.GetString(BANNERGUI_HALIGN).ToLower();
              if (alignMode == "right") {
                this->alignH = BANNERGUI_HALIGN_RIGHT;
              }
              else if (alignMode == "center") {
                this->alignH = BANNERGUI_HALIGN_CENTER;
              }
              else if (alignMode == "left" || true) {
                this->alignH = BANNERGUI_HALIGN_LEFT;
              }
              
              this->width = bc.GetInt32(BANNERGUI_WIDTH, -1);
              this->height = bc.GetInt32(BANNERGUI_HEIGHT, -1);
              this->lockScale = bc.GetBool(BANNERGUI_LOCKSCALE, false);
              
              GePrint("HALIGN Dtype: " + String::IntToString(bc.GetType(BANNERGUI_HALIGN)));
              GePrint("Icon ID: " + String::IntToString(this->iconId));
              GePrint("alignMode: " + alignMode);
              GePrint("Width: " + String::IntToString(this->width));
              GePrint("Height: " + String::IntToString(this->height));
              GePrint("LockScale: " + String::IntToString(this->lockScale));
            }
            

            An idea where the problem could be? Thanks!

            Niklas

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 26/01/2015 at 10:55, xxxxxxxx wrote:

              ">I'm not sure where the problem could be!! "I usually get problems with .res files "I like C++ functions more""

              what I did in my custom data type class and it worked

                
              virtual Bool _GetDescription(const CustomDataType* data, Description& desc, DESCFLAGS_DESC& flags, const BaseContainer& parentdescription, DescID* singledescid)
              {
              	//won't read res file!!  
              	//edited the code
              	DescID cid = DescLevel( **/* your ID here, same as the ID used in GetParameter() */ YOURID** , DTYPE_STRING, 0);
              	if (!singleid || cid.IsPartOf(*singledescid, nullptr)) // important to check for speedup c4d!
              	{
              		BaseContainer mstring = GetCustomDataTypeDefault(DTYPE_STRING);
              		mstring .SetString(BANNERGUI_HALIGN, "left");
              		if (!desc.SetParameter(cid, mstring, DescLevel(0)))
              			return true;
              	}
              	
              	flags |= DESCFLAGS_DESC_LOADED;
              	return SUPER::_GetDescription(data, desc, flags, parentdescription, singledescid);
              }
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 29/01/2015 at 10:13, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                I have only one problem left, unfortunately. I want one of the custom properties to be a String.

                        GROUP {
                            BANNER TEST { ICON_ID 5159; WIDTH 16; ALIGN_H "center"; LOCKSCALE; TRANSPARENT; }
                        }
                

                Hmm, not sure if that's the problem but get rid of the "":

                          
                            BANNER TEST { ICON_ID 5159; WIDTH 16; ALIGN_H center; LOCKSCALE; TRANSPARENT; }
                

                Also, you shouldn't require a custom datatype to get the settings. At least it works here with a custom gui finely.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 11/03/2015 at 12:04, xxxxxxxx wrote:

                  Niklas,
                  have you been able to get it working?

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 22/05/2015 at 06:00, xxxxxxxx wrote:

                    No unfortunately not. But I had an idea: Could it be that String  custom property can not be a hardcoded
                    string inside the description resource, but must instead be a resource symbol that will be loaded from the
                    stringtable? I'll try it out as soon as I can.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 22/05/2015 at 06:14, xxxxxxxx wrote:

                      Hmm, I don't think so. The above way does not work for you?
                      In my custom gui I get the string in the constructor with

                      m_unit = settings.GetString(MY_UNIT);
                      

                      and in my description resource it looks like this
                      REAL ELEMENT_ID { MIN 0; MAX 100; CUSTOMGUI FXUNIT; MY_UNIT SQR_METER; }

                      then I get a string from the stringtable with

                      if(m_unit.Compare("SQR_METER")==0)
                      unit_str = GeLoadString(DPIT_SQR);
                      

                      works all fine here.

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 22/05/2015 at 06:23, xxxxxxxx wrote:

                        Katachi, that is actually what I meant in my previous post. 🙂 And right now I see in the SDK, the
                        documentation of CUSTOMTYPE_STRING says: "String data. (An ID from the string table.)".
                        So, to use it, it must be set up like this?

                        mydescription.res

                        CONTAINER mydescription {
                            GROUP {
                                BANNER MY_BANNER { TITLE MY_BANNER_TITLE; }
                            }
                        }
                        

                        mydescription.str

                        STRINGTABLE mydescription {
                            MY_BANNER_TITLE "The string to be passed to the TITLE property here";
                        }
                        

                        I thought I could use it to write in-line strings into the description. I wanted to use it to specify the
                        alignment of the banner image using the words "left", "center" and "right" instead of using integers
                        like -1, 0 and 1 respectively.

                        Solved [x]

                        😄

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          On 22/05/2015 at 06:38, xxxxxxxx wrote:

                          yes, exactly like that. 🙂 Yeah, directly inline won't work but well you can still use LEFT, RIGHT and CENTER instead of MY_BANNER_TITLE right? You would just add each of them to your .str file like:

                          LEFT "Left";
                          CENTER "Center";
                          RIGHT "Right";

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            On 22/05/2015 at 07:49, xxxxxxxx wrote:

                            But my plugin is a Custom Gui plugin, and the other plugin that makes use of the Custom Gui should
                            not need to add LEFT CENTER and RIGHT to its Stringtable when it wants to use the Custom Gui. 😉

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              On 22/05/2015 at 12:32, xxxxxxxx wrote:

                              It doesn't have to. The other plugin can simply use LEFT, RIGHT and CENTER as well (of course the custom gui must be installed). It doesn't have to redefine them in its stringtable. Or what do you mean?

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                On 22/05/2015 at 23:30, xxxxxxxx wrote:

                                Oh really? In what Stringtable need LEFT,CENTER and RIGHT be defined then?

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  On 23/05/2015 at 01:05, xxxxxxxx wrote:

                                  They should be defined in the stringtable of the customgui of yours.
                                  Then once that customgui is installed, the description (and its resources) are registered too so any parsing of your customgui by c4d (no matter where in c4d) shall allow to use these flags.

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

                                    On 23/05/2015 at 03:55, xxxxxxxx wrote:

                                    I kind of feel like I don't get it. I don't see a way to register a stringtable or description resource with a
                                    Custom GUI plugin. And I tried adding it to c4d_strings.str and c4d_symbols.h but I get a message when
                                    the description that uses the Custom GUI is loaded "Symbol 'RIGHT' could not be found".

                                    Tried both ways, in the plugin that uses the Custom GUI and in the Custom GUI plugin itself.

                                    #ifndef C4D_SYMBOLS_H__
                                    #define C4D_SYMBOLS_H__
                                      
                                    enum
                                    {
                                      LEFT,
                                      RIGHT,
                                      CENTER
                                    };
                                      
                                    #endif // C4D_SYMBOLS_H__
                                    
                                    STRINGTABLE
                                    {
                                      LEFT "left";
                                      RIGHT "right";
                                      CENTER "center";
                                    }
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Helper
                                      last edited by

                                      On 23/05/2015 at 04:16, xxxxxxxx wrote:

                                      You need to use RegisterDescription (I do it in PluginMessage with C4DPL_INIT_SYS) to have it registered along with your customgui. Then it should work.

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Helper
                                        last edited by

                                        On 23/05/2015 at 04:47, xxxxxxxx wrote:

                                        Thanks Katachi, that makes sense to me. 🙂

                                        Edit: Oh well, I fail at doing good test cases. 😂 Actually no, it doesn't really work  with a LONG prop.
                                        It just uses zero as the value when it can't convert the value to a number, and I didn't notice that my
                                        banner image was centered instead of right aligned in my test case (you might ask yourself how you
                                        can not see that immediately..)

                                        Seems like I can't get this to work atm. When I have time next week I'll make a stripped down custom
                                        datatype plugin and test it again. Thanks for your help Katachi!

                                        -Niklas

                                        ~~
                                        Unfortunately, it still doesn't work with a CUSTOMTYPE_STRING propety. But it works with a LONG prop!~~
                                        ~~
                                        ~~
                                        ** nrbannergui.h**
                                        ~~
                                        ~~
                                        ~~

                                        #if 0~~
                                         ~~enum~~
                                         ~~{~~
                                         ~~  LEFT = -1,~~
                                         ~~  RIGHT = 1,~~
                                         ~~  CENTER = 0,~~
                                         ~~};~~
                                         ~~#endif 
                                        

                                        ~~
                                        ~~
                                        ~~
                                        The CustomProperty is
                                        ~~
                                        ~~
                                        ~~

                                         { CUSTOMTYPE_LONG,   BANNERGUI_HALIGN,         "HALIGN" }
                                        

                                        ~~
                                        ~~
                                        ~~
                                        And handled in the iCustomGui constructor as
                                        ~~
                                        ~~
                                        ~~

                                           Int32 align = bc.GetInt32(BANNERGUI_HALIGN);~~
                                         ~~  if (align  < 0)       this->alignH = BANNERGUI_HALIGN_LEFT;~~
                                         ~~  else if (align == 0) this- >alignH = BANNERGUI_HALIGN_CENTER;~~
                                         ~~  else if (align  > 0)  this->alignH = BANNERGUI_HALIGN_RIGHT;
                                        

                                        ~~
                                        ~~
                                        ~~
                                        And since I use the custom property on both the custom GUI and custom datatype, I registered the
                                        description for both.
                                        ~~
                                        ~~
                                        ~~

                                           if (!RegisterDescription(CUSTOMGUI_BANNER, "nrbannergui")) return false;~~
                                         ~~  if (!RegisterDescription(CUSTOMDATATYPE_BANNER, "nrbannergui")) return false;
                                        

                                        ~~
                                        ~~
                                        ~~
                                        Now I can use it in my plugin description as
                                        ~~
                                        ~~
                                        ~~

                                           GROUP {~~
                                         ~~    NR_BANNER  MY_BANNER { ICON_ID 1035231; ICON_ID_HOVER 1035232; BUTTON; BGCOLOR_VECTOR 0.157 0.353 0.663; HALIGN RIGHT; }~~
                                         ~~  }
                                        

                                        ~~
                                        ~~
                                        ~~
                                        Thanks again!
                                        ~~
                                        ~~
                                        -Niklas

                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post