51EditController::EditController ()
66 componentHandler.reset ();
67 componentHandler2.reset ();
75 return kNotImplemented;
81 return kNotImplemented;
87 return kNotImplemented;
101 info = parameter->getInfo ();
113 parameter->toString (valueNormalized,
string);
125 if (parameter->fromString (
string, valueNormalized))
139 return parameter->toPlain (valueNormalized);
141 return valueNormalized;
149 return parameter->toNormalized (plainValue);
159 return parameter->getNormalized ();
169 parameter->setNormalized (value);
178 if (componentHandler == newHandler)
183 componentHandler = newHandler;
184 componentHandler2.reset ();
189 newHandler->
queryInterface (IComponentHandler2::iid, (
void**)&componentHandler2);
197 if (componentHandler)
199 return componentHandler->beginEdit (tag);
207 if (componentHandler)
209 return componentHandler->performEdit (tag, valueNormalized);
217 if (componentHandler)
219 return componentHandler->endEdit (tag);
227 if (componentHandler2)
229 return componentHandler2->startGroupEdit ();
231 return kNotImplemented;
237 if (componentHandler2)
239 return componentHandler2->finishGroupEdit ();
241 return kNotImplemented;
249 info = parameter->getInfo ();
258 if (componentHandler2)
260 return componentHandler2->setDirty (state);
262 return kNotImplemented;
268 if (componentHandler2)
270 return componentHandler2->requestOpenEditor (name);
272 return kNotImplemented;
285EditorView::~EditorView ()
289 controller->editorDestroyed (
this);
290 controller =
nullptr;
299 controller->editorAttached (
this);
308 controller->editorRemoved (
this);
316EditControllerEx1::EditControllerEx1 ()
318 UpdateHandler::instance ();
322EditControllerEx1::~EditControllerEx1 ()
331 for (
const auto& programList : programLists)
334 programList->removeDependent (
this);
336 programLists.
clear ();
337 programIndexMap.
clear ();
352 if (unitIndex < 0 || unitIndex >=
static_cast<int32
> (units.
size ()))
354 if (
Unit* unit = units.
at (unitIndex))
356 info = unit->getInfo ();
365 tresult result = kResultFalse;
368 result = unitHandler->notifyUnitSelection (selectedUnit);
375 programIndexMap[list->getID ()] = programLists.
size ();
377 list->addDependent (
this);
384 auto it = programIndexMap.
find (listId);
385 return it == programIndexMap.
end () ? nullptr : programLists[it->second];
391 tresult result = kResultFalse;
394 result = unitHandler->notifyProgramListChange (listId, programIndex);
401 return static_cast<int32
> (programLists.
size ());
408 if (listIndex < 0 || listIndex >=
static_cast<int32
> (programLists.
size ()))
410 info = programLists[listIndex]->getInfo ();
418 ProgramIndexMap::const_iterator it = programIndexMap.
find (listId);
419 if (it != programIndexMap.
end ())
421 return programLists[it->second]->getProgramName (programIndex, name);
427tresult EditControllerEx1::setProgramName (
ProgramListID listId, int32 programIndex,
430 ProgramIndexMap::const_iterator it = programIndexMap.
find (listId);
431 if (it != programIndexMap.
end ())
433 return programLists[it->second]->setProgramName (programIndex, name);
443 ProgramIndexMap::const_iterator it = programIndexMap.
find (listId);
444 if (it != programIndexMap.
end ())
446 return programLists[it->second]->getProgramInfo (programIndex, attributeId, attributeValue);
455 ProgramIndexMap::const_iterator it = programIndexMap.
find (listId);
456 if (it != programIndexMap.
end ())
458 return programLists[it->second]->hasPitchNames (programIndex);
467 ProgramIndexMap::const_iterator it = programIndexMap.
find (listId);
468 if (it != programIndexMap.
end ())
470 return programLists[it->second]->getPitchName (programIndex, midiPitch, name);
478 auto* programList = FCast<ProgramList> (changedUnknown);
483 unitHandler->notifyProgramListChange (programList->getID (), kAllProgramInvalid);
505Unit::Unit (
const UnitInfo& info) : info (info)
519: unitId (unitId), parameter (nullptr)
523 info.programCount = 0;
527ProgramList::ProgramList (
const ProgramList& programList)
528: info (programList.info)
529, unitId (programList.unitId)
530, programNames (programList.programNames)
541 return static_cast<int32
> (programNames.
size ()) - 1;
547 if (programIndex >= 0 && programIndex <
static_cast<int32
> (programNames.
size ()))
549 programInfos.
at (programIndex).insert (
std::make_pair (attributeId, value));
556tresult ProgramList::getProgramInfo (int32 programIndex,
CString attributeId,
559 if (programIndex >= 0 && programIndex <
static_cast<int32
> (programNames.
size ()))
561 StringMap::const_iterator it = programInfos[programIndex].find (attributeId);
562 if (it != programInfos[programIndex].end ())
564 if (!it->second.empty ())
567 it->second.copy (value, 128);
576tresult ProgramList::getProgramName (int32 programIndex,
String128 name )
578 if (programIndex >= 0 && programIndex <
static_cast<int32
> (programNames.
size ()))
581 programNames.
at (programIndex).copy (name, 128);
588tresult ProgramList::setProgramName (int32 programIndex,
const String128 name )
590 if (programIndex >= 0 && programIndex <
static_cast<int32
> (programNames.
size ()))
592 programNames.
at (programIndex) = name;
595 static_cast<StringListParameter*
> (parameter)->replaceString (programIndex, name);
605 if (parameter ==
nullptr)
608 info.
name, info.
id,
nullptr,
611 for (
const auto& programName : programNames)
613 listParameter->appendString (programName.data ());
615 parameter = listParameter;
642 if (programIndex < 0 || programIndex >= getCount ())
645 bool nameChanged =
true;
650 if (res.
first->second == pitchName)
653 res.
first->second = pitchName;
665 if (programIndex >= 0 && programIndex < getCount ())
667 result = pitchNames.
at (programIndex).erase (pitch) != 0;
675tresult ProgramListWithPitchNames::hasPitchNames (int32 programIndex)
677 if (programIndex >= 0 && programIndex < getCount ())
678 return (pitchNames.
at (programIndex).empty () ==
true) ? kResultFalse : kResultTrue;
683tresult ProgramListWithPitchNames::getPitchName (int32 programIndex, int16 midiPitch,
686 if (programIndex >= 0 && programIndex < getCount ())
688 PitchNameMap::const_iterator it = pitchNames[programIndex].find (midiPitch);
689 if (it != pitchNames[programIndex].end ())
692 it->second.copy (name, 128);
Plug-In view default implementation.
virtual void changed(int32 msg=kChanged)
Inform all dependents, that the object has changed.
FUnknownPtr - automatic interface conversion and smart pointer in one.
The basic interface of all interfaces.
virtual tresult PLUGIN_API queryInterface(const TUID _iid, void **obj)=0
Query for a pointer to the specified interface.
UTF-16 string with fixed buffer size.
const UString & copyTo(char16 *dst, int32 dstSize) const
Copy to UTF-16 buffer (dstSize is in code unit (count of char16)).
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
The host passes a number of interfaces as context to initialize the plug-in class.
tresult PLUGIN_API terminate() SMTG_OVERRIDE
This function is called before the plug-in is unloaded and can be used for cleanups.
tresult PLUGIN_API getProgramInfo(ProgramListID listId, int32 programIndex, CString attributeId, String128 attributeValue) SMTG_OVERRIDE
Gets for a given program list ID, program index and attributeId the associated attribute value.
tresult PLUGIN_API getProgramListInfo(int32 listIndex, ProgramListInfo &info) SMTG_OVERRIDE
Gets for a given index the Program List Info.
tresult PLUGIN_API getUnitInfo(int32 unitIndex, UnitInfo &info) SMTG_OVERRIDE
Gets UnitInfo for a given index in the flat list of unit.
tresult PLUGIN_API getProgramName(ProgramListID listId, int32 programIndex, String128 name) SMTG_OVERRIDE
Gets for a given program list ID and program index its program name.
ProgramList * getProgramList(ProgramListID listId) const
Returns the ProgramList associated to a given listId.
virtual tresult notifyUnitSelection()
Notifies the host about the selected Unit.
tresult PLUGIN_API getProgramPitchName(ProgramListID listId, int32 programIndex, int16 midiPitch, String128 name) SMTG_OVERRIDE
Gets the PitchName for a given program list ID, program index and pitch.
tresult notifyProgramListChange(ProgramListID listId, int32 programIndex=kAllProgramInvalid)
Notifies the host about program list changes.
int32 PLUGIN_API getProgramListCount() SMTG_OVERRIDE
Component intern program structure.
tresult PLUGIN_API terminate() SMTG_OVERRIDE
This function is called before the plug-in is unloaded and can be used for cleanups.
bool addProgramList(ProgramList *list)
Adds a given program list.
tresult PLUGIN_API hasProgramPitchNames(ProgramListID listId, int32 programIndex) SMTG_OVERRIDE
Returns kResultTrue if the given program index of a given program list ID supports PitchNames.
void PLUGIN_API update(FUnknown *changedUnknown, int32 message) SMTG_OVERRIDE
Inform the dependent, that the passed FUnknown has changed.
bool addUnit(Unit *unit)
Adds a given unit.
Default implementation for a VST 3 edit controller.
virtual Parameter * getParameterObject(ParamID tag)
Gets for a given tag the parameter object.
virtual tresult getParameterInfoByTag(ParamID tag, ParameterInfo &info)
Gets for a given tag the parameter information.
int32 PLUGIN_API getParameterCount() SMTG_OVERRIDE
Returns the number of parameters exported.
tresult PLUGIN_API setComponentHandler(IComponentHandler *handler) SMTG_OVERRIDE
Gets from host a handler which allows the Plugin-in to communicate with the host.
virtual tresult performEdit(ParamID tag, ParamValue valueNormalized)
will inform the host about the value change
virtual tresult finishGroupEdit()
calls IComponentHandler2::finishGroupEdit() if host supports it
tresult PLUGIN_API initialize(FUnknown *context) SMTG_OVERRIDE
The host passes a number of interfaces as context to initialize the plug-in class.
virtual tresult startGroupEdit()
calls IComponentHandler2::startGroupEdit() if host supports it
ParamValue PLUGIN_API plainParamToNormalized(ParamID tag, ParamValue plainValue) SMTG_OVERRIDE
Returns for a given paramID and a plain value its normalized value.
tresult PLUGIN_API setParamNormalized(ParamID tag, ParamValue value) SMTG_OVERRIDE
Sets the normalized value to the parameter associated to the paramID.
ParamValue PLUGIN_API normalizedParamToPlain(ParamID tag, ParamValue valueNormalized) SMTG_OVERRIDE
Returns for a given paramID and a normalized value its plain representation (for example -6 for -6dB ...
virtual tresult requestOpenEditor(FIDString name=ViewType::kEditor)
Calls IComponentHandler2::requestOpenEditor (name) if host supports it.
tresult PLUGIN_API getState(IBStream *state) SMTG_OVERRIDE
Gets the controller state.
virtual tresult setDirty(TBool state)
Calls IComponentHandler2::setDirty (state) if host supports it.
tresult PLUGIN_API getParamValueByString(ParamID tag, TChar *string, ParamValue &valueNormalized) SMTG_OVERRIDE
Gets for a given paramID and string its normalized value.
tresult PLUGIN_API getParameterInfo(int32 paramIndex, ParameterInfo &info) SMTG_OVERRIDE
Gets for a given index the parameter information.
virtual tresult beginEdit(ParamID tag)
to be called before a serie of performEdit
tresult PLUGIN_API getParamStringByValue(ParamID tag, ParamValue valueNormalized, String128 string) SMTG_OVERRIDE
Gets for a given paramID and normalized value its associated string representation.
ParamValue PLUGIN_API getParamNormalized(ParamID tag) SMTG_OVERRIDE
Returns the normalized value of the parameter associated to the paramID.
tresult PLUGIN_API terminate() SMTG_OVERRIDE
This function is called before the plug-in is unloaded and can be used for cleanups.
virtual tresult endEdit(ParamID tag)
to be called after a serie of performEdit
tresult PLUGIN_API setComponentState(IBStream *state) SMTG_OVERRIDE
Receives the component state.
tresult PLUGIN_API setState(IBStream *state) SMTG_OVERRIDE
Sets the controller state.
void attachedToParent() SMTG_OVERRIDE
Calls when this view will be attached to its parent view.
void removedFromParent() SMTG_OVERRIDE
Calls when this view will be removed from its parent view.
Host callback interface for an edit controller: Vst::IComponentHandler.
int32 getParameterCount() const
Returns the count of parameters.
void removeAll()
Removes all parameters.
Parameter * getParameterByIndex(int32 index) const
Gets parameter by index.
Description of a Parameter.
int32 addProgram(const String128 name) SMTG_OVERRIDE
Adds a program to the end of the list.
bool setPitchName(int32 programIndex, int16 pitch, const String128 pitchName)
Sets a name for the given program index and a given pitch.
bool removePitchName(int32 programIndex, int16 pitch)
Removes the PitchName entry for the given program index and a given pitch.
virtual int32 addProgram(const String128 name)
Adds a program to the end of the list.
virtual bool setProgramInfo(int32 programIndex, CString attributeId, const String128 value)
Sets a program attribute value.
virtual Parameter * getParameter()
Creates and returns the program parameter.
Description of a StringListParameter.
void setName(const String128 newName)
Sets a new Unit Name.
T emplace_back(T... args)
int32 KnobMode
Knob Mode Type.
ProgramListID programListId
id of program list used in unit (kNoProgramListId = no programs used in this unit)
String128 name
name of program list
uint32 ParamID
parameter identifier
TChar String128[128]
128 character UTF-16 string
char16 TChar
UTF-16 character.
double ParamValue
parameter value type
UnitID parentUnitId
identifier of parent unit (kNoParentUnitId: does not apply, this unit is the root)
int32 programCount
number of programs in this list
String128 name
name, optional for the root component, required otherwise
int32 ProgramListID
program list identifier
int32 UnitID
unit identifier
const char8 * CString
C-String.
ProgramListID id
program list identifier
@ kCircularMode
Circular with jump to clicked position.
Basic Program List Description.
Graphical rectangle structure.
Controller Parameter Info.
@ kIsList
parameter should be displayed as list in generic editor or automation editing [SDK 3....
@ kCanAutomate
parameter can be automated
@ kIsProgramChange
parameter is a program change (unitId gives info about associated unit