gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

xtPartName.cpp (1187B)


      1 #include "xtPartName.h"
      2 
      3 #include "xtController.h"
      4 #include "xtEditor.h"
      5 
      6 namespace xtJucePlugin
      7 {
      8 	PartName::PartName(Editor& _editor)
      9 	: jucePluginEditorLib::PartButton<juce::TextButton>(_editor)
     10 	, m_editor(_editor)
     11 	, m_onProgramChanged(_editor.getXtController().onProgramChanged)
     12 	, m_onPlayModeChanged(_editor.getXtController().onPlayModeChanged)
     13 	{
     14 		m_onPlayModeChanged = [this](const bool&)
     15 		{
     16 			updatePartName();
     17 		};
     18 
     19 		m_onProgramChanged = [this](uint8_t)
     20 		{
     21 			updatePartName();
     22 		};
     23 	}
     24 
     25 	bool PartName::isInterestedInDragSource(const SourceDetails& _dragSourceDetails)
     26 	{
     27 		if(getPart() > 0 && !m_editor.getXtController().isMultiMode())
     28 			return false;
     29 		return PartButton<TextButton>::isInterestedInDragSource(_dragSourceDetails);
     30 	}
     31 
     32 	void PartName::mouseDrag(const juce::MouseEvent& _event)
     33 	{
     34 		if(getPart() > 0 && !m_editor.getXtController().isMultiMode())
     35 			return;
     36 		PartButton<TextButton>::mouseDrag(_event);
     37 	}
     38 
     39 	void PartName::updatePartName()
     40 	{
     41 		const auto& c = m_editor.getXtController();
     42 
     43 		if(getPart() > 0 && !c.isMultiMode())
     44 		{
     45 			setButtonText("-");
     46 		}
     47 		else
     48 		{
     49 			const auto name = c.getSingleName(getPart());
     50 			setButtonText(name);
     51 		}
     52 	}
     53 }