Toolbox design
From Emergent
Contents |
ToolBoxes
A ToolBox is a dock widget that provides a collection of clip/drag/droppable icon buttons to facilitate design of structures in the program. There is one toolbox definition for the entire application, divided into sections. The number of sections and icon buttons in each section are both extensible, to enable application extensions or plug-ins to extend it.
Each projectviewer window gets a visible toolbox. Each browser window gets a hidden toolbox which can be set visible in the View menu.
Sections
Each toolbox is divided into named sections; the user can open one section at a time and view and use its contents.
Tool Icons
Each tool comprises a toolbutton icon. The normal class is iBaseClipToolWidget, which wraps a template instance of a taBase object.
QToolButton
iClipToolWidget
iBaseClipToolWidget
Template Instances
TAI_xxx instances are normally not suitable as template instances for toolwidgets, since they have no ownership and are not part of the pathing. A special root.templates collection is provided as a home for tool template instances. These instances are created by the startup code in emergent/temt. For plugins, the instances should be created in the plugin's second initialization routine.
ToolBox Procedures
The toolbox is extended via a callback procedure of the following signature:
void MyToolBoxProc(iToolBoxDockViewer* tb);
This procedure is registered by creating a static instance (in the .cpp file) of the following object:
ToolBoxRegistrar(ToolBoxProc proc);
An example implementation should be something like this:
void MyToolBoxProc(iToolBoxDockViewer* tb) {
taBase* inst = NULL; // pointer for instances
int sect = tb->AssertSection("My Section Name");
// lookup inst from templates
iClipToolWidget* ctw = new iBaseClipToolWidget(inst);
tb->AddClipToolWidget(sect, ctw);
// keep adding additional tools
}
// register it
ToolBoxRegistrar mtb(MyToolBoxProc);
