本文整理汇总了C++中CtrlrModulator::setComponentType方法的典型用法代码示例。如果您正苦于以下问题:C++ CtrlrModulator::setComponentType方法的具体用法?C++ CtrlrModulator::setComponentType怎么用?C++ CtrlrModulator::setComponentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CtrlrModulator
的用法示例。
在下文中一共展示了CtrlrModulator::setComponentType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replaceComponent
void CtrlrPanelCanvas::replaceComponent (CtrlrModulator &modulator, const String &targetComponentType)
{
CtrlrComponent *oldComponent = modulator.getComponent();
CtrlrComponent *newComponent = nullptr;
/* detach the existing component so it doesn't get notified about anything, the pointer will be invalid */
if (getOwner().getSelection())
{
getOwner().getSelection()->deselectAll();
getOwner().getSelection()->dispatchPendingMessages();
getOwner().getSelection()->removeChangeListener(oldComponent);
}
if (oldComponent)
{
/* keep a copy of the old properties, we need to find out if the component is in a group */
ValueTree oldComponentProperties = oldComponent->getObjectTree().createCopy();
modulator.setComponentType(targetComponentType, false);
/* get the new component pointer and attach it */
newComponent = modulator.getComponent();
if (getOwner().getSelection())
getOwner().getSelection()->addChangeListener (newComponent);
addAndMakeVisibleNg (modulator.getComponent(), nullptr, true);
/* attach the new component to any group components the old component was int */
if (oldComponentProperties.hasProperty(Ids::componentGroupName))
{
CtrlrGroup *group = dynamic_cast<CtrlrGroup*>(owner.getOwner().getComponent(oldComponentProperties.getProperty(Ids::componentGroupName)));
if (group)
{
group->setOwned (newComponent, true);
}
}
if (oldComponentProperties.hasProperty(Ids::componentTabName))
{
CtrlrTabsComponent *tabs = dynamic_cast<CtrlrTabsComponent*>(owner.getOwner().getComponent(oldComponentProperties.getProperty(Ids::componentTabName)));
if (tabs)
{
tabs->setOwned (newComponent, oldComponentProperties.getProperty(Ids::componentTabId), true);
}
}
/* copy any old properties to the new component */
for (int i=0; i<oldComponentProperties.getNumProperties(); i++)
{
const Identifier propName = oldComponentProperties.getPropertyName(i);
const var propValue = oldComponentProperties.getProperty(propName);
if (propName != Ids::uiType)
{
if (newComponent->getObjectTree().hasProperty(propName))
newComponent->setProperty (propName, propValue);
}
}
}
}