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
    • Register
    • Register
    • Login

    GeDialog ColorChooser Color + Alpha

    Cinema 4D SDK
    c++
    2
    4
    688
    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.
    • E
      ECHekman
      last edited by

      I am creating my own iCumstomGUI and I want to add a colorchooser with alpha
      But there is only a function called AddColorChooser which creates a color chooser without alpha

      This one in particular:
      d50a24a0-6f91-4502-ac0f-ab8438fcbfd0-image.png

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @ECHekman
        last edited by ferdinand

        Hey @ECHekman,

        Thank you for reaching out to us. To be a little bit more verbose, you want to have color with alpha custom GUI in a dialog, and maybe are trying to use the native color field wrappers of a dialog, right?

        You have to use a custom GUI in that case, because that is what that UI is. There is sort of a trick in this case, as the custom GUI for colors and colors with an alpha is actually the same (CUSTOMGUI_COLOR), what determines the layout, is for which data type you initialize the settings container for the GUI (DTYPE_COLOR vs. DTYPE_COLORA). So, adding such field to a dialog goes like this:

        // We create a datatype settings container for DTYPE_COLORA, i.e., a color with an alpha component.
        BaseContainer settings = GetCustomDataTypeDefault(DTYPE_COLORA); 
        // ... do more settings work, check the user data editor with the data type Color with Alpha and there the details for all the settings, or the docs for `DR_COLORFIELD_...`
        
        // Now we add a #CUSTOMGUI_COLOR to the dialog with our settings.
        AddCustomGui(id, CUSTOMGUI_COLOR, String(), flags, 0, 0, settings);
        

        Reading and writing would then be done with these two little monstrosities, as the native color getters and setters of GeDialog won't work:

        Bool MyDialog::GetColorAlphaField(Int32 id, ColorA& color)
        {
        	iBaseCustomGui* colorChooser = static_cast<iBaseCustomGui*>(FindCustomGui(id, CUSTOMGUI_COLOR));
        	if (colorChooser)
        	{
        		TriState<GeData> colorData = colorChooser->GetData();
        		const ColorA* col = reinterpret_cast<const ColorA*>(colorData.GetValue().GetCustomDataTypeI(DTYPE_COLORA));
        		if (col)
        		{
        			color = *col;
        			return true;
        		}
        	}
        
        	return false;
        }
        
        Bool MyDialog::SetColorAlphaField(Int32 id, const ColorA& color)
        {
        	iBaseCustomGui* colorChooser = static_cast<iBaseCustomGui*>(FindCustomGui(id, CUSTOMGUI_COLOR));
        	if (colorChooser)
        		return colorChooser->SetData(TriState<GeData>(GeData(reinterpret_cast<const CustomDataType&>(color), DTYPE_COLORA)));
        
        	return false;
        }
        

        I hope this helps.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • E
          ECHekman
          last edited by

          Thank you for your response that did the trick.

          // ... do more settings work, check the user data editor with the data type Color with Alpha and there the details for all the settings, or the docs for DR_COLORFIELD_...

          |I am not familiar with the "user data editor". I am interested in changing the settings because this is what it looks like now:
          a5b35c99-9230-4fa2-b333-3b62d87f6976-image.png

          I would like it to look like this - including the ability to fold it
          5b066269-e1e4-489f-8f6e-61b7b1fb3fcf-image.png

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @ECHekman
            last edited by ferdinand

            Hey @ECHekman,

            well, I was talking about User Data, as they can be a nice way to inspect what data types and their custom GUIs can do.

            c72e5dab-e512-48cb-8333-95ccee722325-image.png

            For what you want to do, this will however not help, as there are only the description settings listed, which necessarily do not have to be all settings there are. To start with an expanded GUI, you must set LAYOUTMODE_MAXIMIZED. I think the little toggle arrows are not supported in dialogs, but I might be wrong. When you want to know more about the little toggle arrow, I would suggest to write us a mail, so that I can forward it to a GUI specialist, as I do not know if and how you could make the arrow work.

            This is one of the cases how we internally setup such GUI in a dialog, maybe this already helps (but there are many, and they are not all the same). The a bit odd looking SetInt32('abcd', value)` thing, where we express an Int32 ID as four chars is something we sometimes do internally. Some people find it apparently easier to read/handle than symbols. It often also means that there is no proper integer value and symbol for that ID.

            void MyDialog::AddColorAlphaChooser(Int32 id, Int32 flags, Int32 layoutFlags)
            {
            	BaseContainer colorUISettings = GetCustomDataTypeDefault(DTYPE_COLORA);
            	colorUISettings.SetInt32(CUSTOMGUI_LAYOUTMODE, LAYOUTMODE_MAXIMIZED);
            	colorUISettings.SetInt32('iccc', layoutFlags & (DR_COLORFIELD_ICC_BPTEX | DR_COLORFIELD_ICC_BASEDOC));
            	colorUISettings.SetInt32('cfld', layoutFlags);
            	AddCustomGui(id, CUSTOMGUI_COLOR, String(), flags, 0, 0, colorUISettings);
            }
            

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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