On 29/07/2016 at 10:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R17
Platform:
Language(s) : C++ ;
---------
Hi! I'm implementing a CustomGuiData plugin and it works very good so far. It's a lot of work due to
the many classes that are necessary, especially in combination with a new CustomDataType. Anyway,
the custom GUI creates one of the new nifty Color Chooser widgets, the only problem is that everytime
I change the value of my CustomDataType via the iCustomGui Dialog (in the Attributes Manager), the
iCustomGui is re-allocated by Cinema 4D and thus CreateLayout() is called again, which ultimately
causes the Color Chooser to reset to its initial state.
Is there any way to save the state of the Color Chooser? Or maybe prevent Cinema from re-allocating
the iCustomGui dialog when the value changed?
Just in case I'm doing something wrong to notify C4D about the changed value, here's some code.
The Command() function is the one inside my iCustomGui subclass.
Bool Command(Int32 param, BaseContainer const& bc) override
{
ColorPaletteData* data = nullptr;
switch (param) {
case GADGET_USERAREA:
nr::c4d::send_value_changed(this, bc);
// TODO: this->Update(); ?
break;
case GADGET_NEWFOLDER:
data = this->data.Get(true);
if (data && data->AskNewFolder() != nullptr) {
nr::c4d::send_value_changed(this, bc);
this->Update();
}
return true;
case GADGET_SHOWCOLORCHOOSER:
data = this->data.Get(true);
if (data) {
data->show_chooser = !data->show_chooser;
nr::c4d::send_value_changed(this, bc);
this->Update();
}
return true;
}
return false;
}
And this is my send_value_changed() function (this notifies the holder of the iCustomGui about
the changed value and will ultimately update the parameter that holds the CustomDataType in
the BaseList2D node).
/*!
* This function takes over the process of informing the dialog that contains
* the custom GUI that the value has been changed, ultimately updating the
* parameter value via SetDParameter().
*
* Note that this function uses #iCustomGui::GetData() to read the new value.
* This method is apparently unused in C4D SDK (as far as I can tell), but this
* function makes use of it. :-)
*/
inline Bool send_value_changed(iCustomGui* gui, BaseContainer msg = {})
{
msg.SetInt32(BFM_ACTION_ID, gui->GetId());
msg.RemoveData(BFM_ACTION_VALUE);
msg.SetData(BFM_ACTION_VALUE, gui->GetData().GetValue());
return gui->SendParentMessage(msg);
}
Thanks in advance,
Niklas