On 15/12/2016 at 00:55, xxxxxxxx wrote:
Cinema 4D Version: R18
Platform: Windows ;
Language(s) : C++ ;
Working on a ToolData plugin I am trying to find an example where quicktabs (as in Live Selection tool) are set up using resource files.
From the discussions found it seems it is only possible to create such by code. I have done this before in a Python plugin, and thus could find out how to do so in C++.
But was wondering if there is a way to create the QuickTabCustomGui with code and assign dialogs defined as resource files for the different tabs ?
Or should I create all my dialog gadgets via code as well?
On 16/12/2016 at 03:13, xxxxxxxx wrote:
In the meantime I have implemented the whole via code, but am struggling with another issue.
In the attribute manager there always seems to be a quicktab bar title by default, not defined via the CreateLayout.
If I look at the Live Selection tool (for example), I notice that the different quicktab items are right below the icon and toolname. When I create a tool plugin there always is this extra tool name right below the icon and above the first gadget created (via resource or code).
This happens both in Python and C++.
Below a dummy Python tool plugin, which shows the issue.
Is there a way to get rid of this "extra" line, in order to mimic the native tools?
import c4d import os from c4d import gui, plugins, bitmaps, utils PLUGIN_ID = 1031001 # dummy ID ID_MAINGROUP = 1000 ID_QUICKTAB_BAR = 1100 ID_QUICKTAB_ITEM = 1110 ID_QUICKTAB_GROUP = 1120 quicktabTitle = ['Quicktab #1', 'Quicktab #2', 'Quicktab #3'] class SettingsDialog(gui.SubDialog) : _quickTab = None; def CreateLayout(self) : self.GroupBegin(ID_MAINGROUP, c4d.BFH_SCALEFIT, 1, 1, '', 0) bc = c4d.BaseContainer() bc.SetBool(c4d.QUICKTAB_BAR, False) self._quickTab = self.AddCustomGui(ID_QUICKTAB_BAR, c4d.CUSTOMGUI_QUICKTAB, '', c4d.BFH_SCALEFIT, 0, 0, bc) for tabIdx in xrange(len(quicktabTitle)) : self._quickTab.AppendString(ID_QUICKTAB_ITEM + tabIdx, quicktabTitle[tabIdx], False) bc.FlushAll() bc.SetBool(c4d.QUICKTAB_BAR, True) bc.SetString(c4d.QUICKTAB_BARTITLE, quicktabTitle[tabIdx]) self.GroupBegin(ID_QUICKTAB_GROUP + tabIdx, c4d.BFH_SCALEFIT, 1, 1, '', 0) self.AddCustomGui(0, c4d.CUSTOMGUI_QUICKTAB, '', c4d.BFH_SCALEFIT, 0, 0, bc) # ... self.GroupEnd() self.GroupEnd() return True def InitValues(self) : if self._quickTab: for tabIdx in xrange(len(quicktabTitle)) : self._quickTab.Select(ID_QUICKTAB_ITEM + tabIdx, tabIdx == 0) self.HideElement(ID_QUICKTAB_GROUP + tabIdx, not self._quickTab.IsSelected(ID_QUICKTAB_ITEM + tabIdx)) return True def Command(self, id, msg) : if id == ID_QUICKTAB_BAR and self._quickTab: for tabIdx in xrange(len(quicktabTitle)) : self.HideElement(ID_QUICKTAB_GROUP + tabIdx, not self._quickTab.IsSelected(ID_QUICKTAB_ITEM + tabIdx)) self.LayoutChanged(ID_MAINGROUP) return True class DummyTool(plugins.ToolData) : def GetState(self, doc) : return c4d.CMD_ENABLED def GetCursorInfo(self, doc, data, bd, x, y, bc) : return True def AllocSubDialog(self, bc) : return SettingsDialog() def PluginMain() : bmp = bitmaps.BaseBitmap() dir, file = os.path.split(__file__) fn = os.path.join(dir, "res", "icon.tif") bmp.InitWith(fn) plugins.RegisterToolPlugin(id=PLUGIN_ID, str="DummyTool", info=0, icon=bmp, help="DummyTool", dat=DummyTool()) if __name__ == "__main__": PluginMain()
On 16/12/2016 at 09:37, xxxxxxxx wrote:
Most of Cinema 4D tools aren't ToolData (SubDialog for the GUI) but DescriptionToolData (description resource for the GUI).
So what you see below a ToolData's icon is the title bar of its SubDialog.
Note the Python API only allows to develop ToolData plugins.
About your initial question, the solution that works best with the QuickTabCustomGui is to use a group for each tab.
I haven't tried it but it could work loading a SubDialog for each tab (with LoadDialogResource()).
Then in the layout for the tool add a SubDialog gadget with AddSubDialog().
Finally update the tab SubDialog to show with AttachSubDialog().
On 20/12/2016 at 04:51, xxxxxxxx wrote:
So it seems I have been focusing on the wrong plugin type.
However, what I still don't understand. You mention that what is shown below the ToolData's icon is the title bar of the Subdialog. But I didn't provide any title when creating the dialog in the CreateLayout method. Additionally, when I add a self.SetTitle("Dummy title") as the first line in the CreateLayout method, the original title isn't replaced and still shows the toolname "DummyTool".
(Both in Python and C++).
As for the initial question about the quicktabs. I have indeed created different groups per tabs, but haven't found a way to load the dialog resource and attach it to a created Subdialog gadget.
I also assume that when DescriptionToolData is used, I should be loading descriptions and not subdialogs. I would assume -if time permits- that an example for both cases would be a welcome addition to the Github.