Drop-down list in tag for C++ plugin
-
Hi, guys.
While writing C++ plugin for C4D I ran into the following problem: can't find any info about how to create a drop-down list for tag parameter.
Manual states, that it's possible to use CUSTOMGUI flag and I see implementation CUSTOMGUI_LISTVIEW in framework, but no any other info how to use it.
At the same time 'CUSTOMGUI MULTISTRING' works fine.Any help or suggestions please !
Thanks in advance,
...
YB -
Hello @yesbird,
welcome to the forum and thank you for reaching out to us.
In case you are really developing for R19, I must warn you that R19 is well out of scope of support. You are of course welcome to ask questions here, and we will answer them. But when it comes to writing code examples for a specific SDK, we will not be able to match R19. The official support range is one major version back, i.e.,
S26.0
to2023.1
. We provide support beyond that up toR21
but might not match the target SDK in our code examples and instead write forR25
,S26
, or2023
.With that being said, it is a bit unclear to me what you mean by 'a drop-down list for tag parameter'.
- What is commonly known as a drop-down list gadget is realized a bit oddly in Cinema 4D: As a
LONG
parameter. The parameter then has theCycle
markup to describe its items. This also means that other than for example in the Microsoft GUI world, you cannot have a dropdown-list that returns a string. They always return their integer value for the selected item as defined in their description. The result looks then like this:
Read more about the LONG parameter type. Note thatLONG
can have multiple custom GUIs, determining how the value selection looks like. The same description with the radio buttons custom GUI:
CUSTOMGUI_LISTVIEW
is not a description GUI because it has no data type associated with it. It is meant for dialogs and everything that inherits fromGeDialog
. It is also not a drop-down list but a list view as its name implies. There is customgui_itemtree.h which is used by the character tools do display trees of nodes inside descriptions, but it is semi-public and therefore not documented.
Cheers,
Ferdinand - What is commonly known as a drop-down list gadget is realized a bit oddly in Cinema 4D: As a
-
Hello, @ferdinand.
Thank you very much for the rapid and detailed response, after reading the section about LONG parameter type more carefully, I was able to complete this part of the UI and now the list works fine.
Although I am satisfied with the present result, if you will give me a little more details about the radio buttons' custom GUI, I will be absolutely happy :).
Unfortunately, I didn't find any info about radio buttons in manual.All the best,
YB. -
Hello @yesbird,
That is indeed one of the pitfalls of our GUI system, the custom GUI resource symbols, they are not very well documented. I will update the GUI documentation with the upcoming cycle, but currently writing GUI resources often means greping the
{Cinema 4D RXX}\resource
directory, particularly the*.res
files to be found in there. E.g., you could grep forLONG.*CUSTOMGUI.*CYCLE
, i.e., all things that areLONG
, have aCUSTOMGUI
and are aCYCLE
, it will for example spit out this from the viewport resources and show you how we define the GUI:LONG BASEDRAW_DATA_PICTURE_USEALPHA { ANIM OFF; CUSTOMGUI QUICKTABRADIO; CYCLE { BASEDRAW_ALPHA_NONE; BASEDRAW_ALPHA_NORMAL; BASEDRAW_ALPHA_INVERTED; } }
The crucial bit of information is here that "fundamentally different looks and feels" are expressed by changing the
CUSTOMGUI
of a parameter type, hereLONG
.The greping workflow is laborious, requires the knowledge of how these things are structured, and relies on the assumption that all custom GUIs are always in use in the Cinema 4D description resources (which does not hold true). Currently some of the more specialized
LONG
GUIs do not seem to be in use (in descriptions) anymore for example; at least I did not find them all. Another technique which I also sometimes use it the user data editor, as it is fantastic way to find out which custom GUIs and flags are supported by a data type and its GUIs.As shown here, a long cycle can have four GUIs: The default, button style, tabs, and radio. Sometimes parameter type GUIs also have custom flags which can be set in the resource, but these are then more fine-tuning options. The radio GUI does that for example and allows you to define the layout of the radio gadgets, among other things. These GUI flags are currently largely undocumented except from what you find in the C++ docs. As a rule of thumb: One can usually infer them from the user data editor details tab:
The actual resource properties definition for the radio tab GUI:
static CustomProperty longtabsprops[] = { { CUSTOMTYPE::FLAG, LONGTABS_OPENCLOSED, "OPEN" }, { CUSTOMTYPE::LONG, LONGTABS_ROWS, "COLUMNS" }, { CUSTOMTYPE::LONG, LONGTABS_COLUMNS, "ROWS" }, { CUSTOMTYPE::FLAG, LONGTABS_BUTTONS, "BUTTONS" }, { CUSTOMTYPE::END, 0, nullptr } };
I.e., the following code block would be valid markup for a radio button GUI that uses a two-column layout. As a warning, not all flags make sense for public usage.
OPEN
andBUTTONS
do not seem to be too useful for public users in this case (at least to me their purpose is unclear).LONG ID_CYCLE_RADIO { CUSTOMGUI RADIOBUTTONS; OPEN; BUTTONS; COLUMNS 2; CYCLE { ID_ITEM_0; ID_ITEM_1; ID_ITEM_2; } }
Find below how to define the four
LONG
cycle GUIs in a resource.Cheers,
FerdinandResult:
Resource:
*.res
// The description defintion of the tag Tmmover. CONTAINER Tmmover { NAME Tmmover; INCLUDE Texpression; // I resued here a tag plugin resource GROUP ID_TAGPROPERTIES { // ... // Plain cycle long with no special GUI. LONG ID_CYCLE { CYCLE { ID_ITEM_0; ID_ITEM_1; ID_ITEM_2; } } // The three custom GUIs which can be used with LONG cycle elements as of 2023. They were // probably all present in R19, as most of the GUI stuff is quite old, but I did not check. // Reusing cycle value symbols as I do here is technically fine but not usually something one // does in pratice. LONG ID_CYCLE_BUTTON { CUSTOMGUI CYCLEBUTTON; CYCLE { ID_ITEM_0; ID_ITEM_1; ID_ITEM_2; } } LONG ID_CYCLE_TAB { CUSTOMGUI QUICKTABRADIO; CYCLE { ID_ITEM_0; ID_ITEM_1; ID_ITEM_2; } } LONG ID_CYCLE_RADIO { CUSTOMGUI RADIOBUTTONS; CYCLE { ID_ITEM_0; ID_ITEM_1; ID_ITEM_2; } } } }
*.h
#ifndef _TMMOVER_H_ #define _TMMOVER_H_ enum { // ... ID_CYCLE = 2000, ID_CYCLE_BUTTON, ID_CYCLE_TAB, ID_CYCLE_RADIO, ID_ITEM_0 = 0, ID_ITEM_1 = 1, ID_ITEM_2 = 2, } #endif // _TMMOVER_H_
*str
STRINGTABLE Tmmover { Tmmover "mMover"; // ... ID_CYCLE "Cycle"; ID_CYCLE_BUTTON "Cycle Button"; ID_CYCLE_TAB "Cycle Tabs"; ID_CYCLE_RADIO "Cycle Radio"; ID_ITEM_0 "Item 0"; ID_ITEM_1 "Item 1"; ID_ITEM_2 "Item 2"; }
-
Hello, @ferdinand.
Many, many thanks for your detailed description of UI background, grepping-based workflow is not new to me, so "sapienti sat"
I used the User Data Editor before, but now I discovered a new side. If I understand well, there is a possibility to create a UI sketch, save it and then find the appropriate
*.res
in{Cinema 4D RXX}\resource
directory. This technique should be very useful, I definitely will try it.All your code examples are exactly what I was looking for, now I can implement all my ideas in the best way.
Besides that, I would like to say that after more than 30 years of working in IT, I've never seen such attentive and mindful support - with not only code samples, but even with animated screenshots.
Writing plugins for C4D is pure fun now.
Thanks again,
...
YB -
Hello @yesbird,
@yesbird said in Drop-down list in tag for C++ plugin:
I used the User Data Editor before, but now I discovered a new side. If I understand well, there is a possibility to create a UI sketch, save it and then find the appropriate *.res in {Cinema 4D RXX}\resource directory.
No, that is unfortunately not possible. You can only explore what is possible with description resources, but not save the result as a collection of resource files. There are also some things which are not possible with user data descriptions (without getting hacky) which are possible with description resources, e.g., having multiple tab groups.
Cheers,
Ferdinand -