void AutomationEvent::mouseUp (const MouseEvent& e)
{
    if (owner)
    {
        SelectedItemSet<MidiGridItem*> selection = owner->getLassoSelection ();

        if (e.mods.isLeftButtonDown())
        {
			for (int i = 0; i < selection.getNumSelected (); i++)
			{
				MidiGridItem* component = selection.getSelectedItem (i);
				component->endDragging (e);
				owner->repaint();
			}

            repaint ();
        }
		else if (e.mods.isRightButtonDown())
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
				AutomationEvent* component = dynamic_cast<AutomationEvent*>(selection.getSelectedItem (i));
                if (component && component != this)
                    owner->removeNote (component, true);
            }

            owner->removeNote (this, false);
            delete (this);
        }
    }
}
Exemplo n.º 2
0
void ModulatorSamplerSound::selectSoundsBasedOnRegex(const String &regexWildcard, ModulatorSampler *sampler, SelectedItemSet<ModulatorSamplerSound::Ptr> &set)
{
	bool subtractMode = false;

	bool addMode = false;

	String wildcard = regexWildcard;

	if (wildcard.startsWith("sub:"))
	{
		subtractMode = true;
		wildcard = wildcard.fromFirstOccurrenceOf("sub:", false, true);
	}
	else if (wildcard.startsWith("add:"))
	{
		addMode = true;
		wildcard = wildcard.fromFirstOccurrenceOf("add:", false, true);
	}
	else
	{
		set.deselectAll();
	}


    try
    {
		std::regex reg(wildcard.toStdString());

		ModulatorSampler::SoundIterator iter(sampler, false);

		while (auto sound = iter.getNextSound())
		{
			const String name = sound->getPropertyAsString(Property::FileName);

			if (std::regex_search(name.toStdString(), reg))
			{
				if (subtractMode)
				{
					set.deselect(sound.get());
				}
				else
				{
					set.addToSelection(sound.get());
				}
			}
		}
	}
	catch (std::regex_error e)
	{
		debugError(sampler, e.what());
	}
}
void PianoGridNote::mouseUp (const MouseEvent& e)
{
    if (owner)
    {
        SelectedItemSet<MidiGridItem*> selection = owner->getLassoSelection ();

        if (e.mods.isLeftButtonDown())
        {
            if (isResizing)
            {
                for (int i = 0; i < selection.getNumSelected (); i++)
                {
					PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
					if (component)
						component->endResizing (e);
                }
            }
            else if (isDragging)
            {
                for (int i = 0; i < selection.getNumSelected (); i++)
                {
                    MidiGridItem* component = selection.getSelectedItem (i);
                    component->endDragging (e);
                }
            }

            repaint ();
        }
        else if (e.mods.isMiddleButtonDown())
        {
            if (isEditingVelocity)
            {
                for (int i = 0; i < selection.getNumSelected (); i++)
                {
					PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
					if (component)
						component->endVelocity (component == this ? e : e.getEventRelativeTo (component));
                }
            }
        }
        else if (e.mods.isRightButtonDown())
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
				PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
                if (component && component != this)
                    owner->removeNote (component, true);
            }

            owner->removeNote (this, false);
            delete (this);
        }
    }
}
void AutomationEvent::mouseDown (const MouseEvent& e)
{
    if (! owner) return;

    SelectedItemSet<MidiGridItem*> selection = owner->getLassoSelection ();
    if (! selection.isSelected (this))
        owner->selectNote (this, true);

    if (e.mods.isLeftButtonDown())
    {
		for (int i = 0; i < selection.getNumSelected (); i++)
		{
			MidiGridItem* component = selection.getSelectedItem (i);
			component->startDragging (component == this ? e : e.getEventRelativeTo (component));
			owner->repaint();
		}
    }
}
void PianoGridNote::mouseDown (const MouseEvent& e)
{
   if (! owner) return;

   SelectedItemSet<MidiGridItem*> selection = owner->getLassoSelection ();
   if (! selection.isSelected (this))
   {
      owner->selectNote (this, !e.mods.isShiftDown());
      selection = owner->getLassoSelection();
   }

    if (e.mods.isLeftButtonDown())
    {
        if (e.x >= getWidth() - 2)
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
                PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
				if (component)
					component->startResizing (e);
            }
        }
        else
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
                MidiGridItem* component = selection.getSelectedItem (i);
                component->startDragging (component == this ? e : e.getEventRelativeTo (component));
            }
        }

        DBG ("Note: " + String (note) + " " + String (beat) + " " + String (length));
    }
    else if (e.mods.isMiddleButtonDown())
    {
        for (int i = 0; i < selection.getNumSelected (); i++)
        {
            PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
			if (component)
				component->startVelocity (e);
        }
    }
}
void PianoGridNote::mouseDrag (const MouseEvent& e)
{
    if (! owner) return;

    SelectedItemSet<MidiGridItem*> selection = owner->getLassoSelection ();

    if (e.mods.isLeftButtonDown())
    {
        if (isResizing)
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
            PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
			if (component)
                component->continueResizing (e);
            }
        }
        else if (isDragging)
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
                MidiGridItem* component = selection.getSelectedItem (i);
                component->continueDragging (component == this ? e : e.getEventRelativeTo (component));
            }
        }
    }
    else if (e.mods.isMiddleButtonDown())
    {
        if (isEditingVelocity)
        {
            for (int i = 0; i < selection.getNumSelected (); i++)
            {
				PianoGridNote* component = dynamic_cast<PianoGridNote*>(selection.getSelectedItem (i));
				if (component)
					component->continueVelocity (e);
            }
        }
    }
}
void ObjController::removeSelectedObjects(ObjectsHolder& holder)
{
    SelectedItemSet <SelectableObject*> temp;
    temp = sObjects;

    if (temp.getNumSelected() > 0)
    {
        sObjects.deselectAll();
        sObjects.changed(true);
        // first remove all selected links
        for (int i = temp.getNumSelected(); --i >= 0;)
        {
            if(LinkComponent* lc = dynamic_cast<LinkComponent*>(temp.getSelectedItem(i)))
            {
                temp.deselect(lc);
                removeLink(lc, true, &holder);
            }
        }
        // then objects and remaining links connected to the objects
        for (int i = temp.getNumSelected(); --i >= 0;)
        {
            if(AudioOutConnector* aoc = dynamic_cast<AudioOutConnector*>(temp.getSelectedItem(i)))
            {
                temp.deselect(aoc);
                removeAudioConnection(aoc, true, &holder);
                continue;
            }
        }
        for (int i = temp.getNumSelected(); --i >= 0;)
        {
            if(ObjectComponent* oc = dynamic_cast<ObjectComponent*>(temp.getSelectedItem(i)))
            {
                removeObject(oc, true, &holder);
            }
            else if(CommentComponent* cc = dynamic_cast<CommentComponent*>(temp.getSelectedItem(i)))
            {
                removeComment(cc, true, &holder);
            }
//            LinkComponent* lc = ObjectsHelper::getLink(temp.getSelectedItem(i));
//            if(lc != nullptr)
//            {
//                removeLink(lc, true, holder);
//                continue;
//            }

        }
    }
}