Пример #1
0
void MarkerView::markerSelectionChanged()
{
    MarkerItem* item = (MarkerItem*) table->currentItem();
    if (item == 0)
    { // never triggered
        editTick->setValue(0);
        editName->setText(QString(""));
        lock->setChecked(false);
        editTick->setEnabled(false);
        lock->setEnabled(false);
        editName->setEnabled(false);
    }
    else
    {
        editTick->setValue(item->tick());
        editName->setText(item->name());
        editName->setEnabled(true);
        lock->setChecked(item->lock());
        lock->setEnabled(true);

        //printf("MarkerView::markerSelectionChanged item->lock:%d\n", item->lock());

        editTick->setEnabled(!item->lock());
    }
}
Пример #2
0
void MarkerView::lockChanged(bool lck)
{
    MarkerItem* item = (MarkerItem*) table->currentItem();
    if (item)
    {
        item->setLock(lck);
        editTick->setEnabled(!item->lock());
    }
}
Пример #3
0
void MarkerView::tickChanged(const Pos& pos)
{
	MarkerItem* item = (MarkerItem*) table->currentItem();
	if (item)
	{
		item->setTick(pos.tick());
		Pos p(pos.tick(), true);
		song->setPos(0, p, true, true, false);
		table->sortByColumn(COL_TICK, Qt::AscendingOrder);
	}
}
Пример #4
0
void MarkerView::clicked(QTreeWidgetItem* i)
{
	MarkerItem* item = (MarkerItem*) i;
	if (item == 0)
	{
		table->clearSelection();
		return;
	}
	Pos p(item->tick(), true);
	song->setPos(0, p, true, true, false);
}
Пример #5
0
void MarkerView::deleteMarker()
{
	MarkerItem* item = (MarkerItem*) table->currentItem();
	if (item)
	{
		table->blockSignals(true);
		song->removeMarker(item->marker());
		table->blockSignals(false);
		// Removed p3.3.43 Let Song::removeMarker emit markerChanged(MARKER_REMOVE)
		//  and handle it in MarkerView::markerChanged(int)
		//delete item;
	}
}
Пример #6
0
void RenumberRegions(COMMAND_T* ct)
{
	MarkerList ml(NULL, true);
	DeleteAllRegions();
	int iID = 1;
	for (int i = 0; i < ml.m_items.GetSize(); i++)
	{
		MarkerItem* mi = ml.m_items.Get(i);
		if (mi->IsRegion())
		{
			mi->SetNum(iID++);
			mi->AddToProject();
		}
	}
	g_pMarkerList->Update();
	UpdateTimeline();
	Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(ct), UNDO_STATE_MISCCFG, -1);
}
Пример #7
0
void CanvasPicker::move( const QPoint &pos )
{
	if( !m_dragAndDropInProgress )
		return;

	PlotWidget* plotWidget = dynamic_cast<PlotWidget*>( plot() );

	switch( m_typeOfItemsToDrag )
	{
	case Globals::Rtti_PlotMarker:
		{
			const double dX = plot()->invTransform( QwtPlot::xBottom, pos.x() ) - plot()->invTransform( QwtPlot::xBottom, m_previousPoint.x() );
			const double dY = plot()->invTransform( QwtPlot::yLeft, pos.y() ) - plot()->invTransform( QwtPlot::yLeft, m_previousPoint.y() );

			QList<QwtPlotItem*>& listOfSelectedMarkers = plotWidget->listOfSelectedItems( Globals::Rtti_PlotMarker );

			foreach( QwtPlotItem* item, listOfSelectedMarkers )
			{
				MarkerItem* markerItem = dynamic_cast<MarkerItem*>( item );
				markerItem->setValue(  markerItem->xValue() + dX, markerItem->yValue() + dY );
				emit dataChanged( markerItem );
			}

			break;
		}
	case Globals::Rtti_PlotKnot:
		{
			const double dX = plot()->invTransform( QwtPlot::xBottom, pos.x() ) - plot()->invTransform( QwtPlot::xBottom, m_previousPoint.x() );

			QList<QwtPlotItem*>& listOfSelectedKnots = plotWidget->listOfSelectedItems( Globals::Rtti_PlotKnot );

			foreach( QwtPlotItem* item, listOfSelectedKnots )
			{
				KnotItem* knotItem = dynamic_cast<KnotItem*>( item );
				if( knotItem->isEditAllowed() )
				{
					knotItem->setCoordinate( knotItem->coordinate() + dX );
					emit dataChanged( knotItem );
				}
			}

			break;
		}
Пример #8
0
void MarkerView::markerChanged(int val)
{
	//if (val != Song::MARKER_CUR)
	//      return;
	// p3.3.43
	switch (val)
	{
			// MARKER_CUR, MARKER_ADD, MARKER_REMOVE, MARKER_NAME,
			// MARKER_TICK, MARKER_LOCK
		case Song::MARKER_ADD:
		case Song::MARKER_REMOVE:
			updateList();
			break; // Try falling through and let it try to select something. No, let updateList() do it...

		case Song::MARKER_CUR:
		{

			MarkerList* marker = song->marker();
			for (iMarker i = marker->begin(); i != marker->end(); ++i)
			{
				if (i->second.current())
				{
					MarkerItem* item = (MarkerItem*) table->topLevelItem(0);
					while (item)
					{
						if (item->marker() == &i->second)
						{
							table->setCurrentItem(item);
							return;
						}
						item = (MarkerItem*) table->itemBelow(item);
					}
				}
			}
		}
			break;

		default:
			break;
	}
}
Пример #9
0
void MarkersToRegions(COMMAND_T* ct)
{
	MarkerList ml(NULL, true);

	WDL_PtrList<MarkerItem> &markers = ml.m_items;

	if(markers.GetSize() == 0) return; // Bail if there are no markers/regions

	double projEnd = SNM_GetProjectLength();

	Undo_BeginBlock2(NULL);

	// Insert dummy marker at project start if necessary
	if(markers.Get(0)->GetPos() > 0)
	{
		markers.Insert(0, new MarkerItem(false, 0, 0, "", 0, 0));
	}

	// Convert markers to regions
	for(int i = 0, c = markers.GetSize(); i < c; i++)
	{
		MarkerItem *pm = markers.Get(i);
		if(!pm->IsRegion())
		{
			// Find next marker
			MarkerItem *pNext = NULL;
			int n = i + 1;
			do
			{
				pNext = markers.Get(n++);
			}
			while(pNext && pNext->IsRegion());

			double pos = pm->GetPos();
			double end = pNext ? pNext->GetPos() : projEnd;

			if(pos != end)
			{
				pm->SetReg(true);
				pm->SetRegEnd(end);
			}
		}
	}

	ml.UpdateReaper();

	Undo_EndBlock2(NULL, __LOCALIZE("Convert markers to regions","sws_undo"), UNDO_STATE_MISCCFG);
}
Пример #10
0
void RegionsToMarkers(COMMAND_T*)
{
	MarkerList ml(NULL, true);

	WDL_PtrList<MarkerItem> &markers = ml.m_items;

	if(markers.GetSize() == 0) return; // Bail if there are no markers/regions

	Undo_BeginBlock2(NULL);

	for(int i = 0, c = markers.GetSize(); i < c; i++)
	{
		MarkerItem *pm = markers.Get(i);

		if(pm->IsRegion())
		{
			pm->SetReg(false);
		}
	}

	ml.UpdateReaper();

	Undo_EndBlock2(NULL, __LOCALIZE("Convert regions to markers","sws_undo"), UNDO_STATE_MISCCFG);
}
Пример #11
0
void SelPrevMarkerOrRegion(COMMAND_T*)
{
	// Save the current marker list so we can traverse the list bacwards
	MarkerList ml(NULL, true);

	double dCurPos = GetCursorPosition();
	double dCurStart, dCurEnd;
	GetSet_LoopTimeRange(false, false, &dCurStart, &dCurEnd, false);
	bool bCurSel = dCurStart != dCurEnd;
	for (int i = ml.m_items.GetSize()-1; i >= 0; i--)
	{
		MarkerItem* mi = ml.m_items.Get(i);
		if (mi->GetPos() < dCurPos || (!mi->IsRegion() && mi->GetPos() <= dCurPos && bCurSel))
		{
			double dNewStart = mi->GetPos(), dNewEnd = mi->GetRegEnd();
			GetSet_LoopTimeRange(true, false, &dNewStart, mi->IsRegion() ? &dNewEnd : &dNewStart, false);
			SetEditCurPos(mi->GetPos(), true, true);
			return;
		}
	}
}
Пример #12
0
void MarkerView::nameChanged(const QString& s)
{
	MarkerItem* item = (MarkerItem*) table->currentItem();
	if (item)
		item->setName(s);
}
Пример #13
0
void MarkerView::updateList()
{
	// Added p3.3.43 Manage selected item, due to clearing of table...
	MarkerList* marker = song->marker();
	MarkerItem* selitem = (MarkerItem*) table->currentItem();
	Marker* selm = selitem ? selitem->marker() : 0;
	// p3.3.44 Look for removed markers before added markers...
	if (selitem)
	{
		MarkerItem* mitem = (MarkerItem*) table->topLevelItem(0);
		while (mitem)
		{
			bool found = false;
			for (iMarker i = marker->begin(); i != marker->end(); ++i)
			{
				Marker* m = &i->second;
				if (m == mitem->marker())
				{
					found = true;
					break;
				}
			}
			// Anything removed from the marker list?
			if (!found)
			{
				// If it is the current selected item, it no longer exists. Make the next item be selected.
				if (mitem == selitem)
				{
					MarkerItem* mi = (MarkerItem*) table->itemBelow(selitem);
					if (mi)
					{
						selitem = mi;
						selm = selitem->marker();
					}
				}
			}
			mitem = (MarkerItem*) table->itemBelow(mitem);
		}
	}
	// Look for added markers...
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		Marker* m = &i->second;
		bool found = false;
		MarkerItem* item = (MarkerItem*) table->topLevelItem(0);
		while (item)
		{
			if (item->marker() == m)
			{
				found = true;
				break;
			}
			item = (MarkerItem*) table->itemBelow(item);
		}
		// Anything new found in the marker list?
		if (!found)
			selm = m;
	}

	// Block signals added. Triggers itemSelectionChanged() causing crash. Tim.
	table->blockSignals(true);
	table->clear();
	table->blockSignals(false);

	//MarkerList* marker = song->marker();
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		Marker* m = &i->second;

		// Changed p3.3.43
		//QString tick;
		//tick.setNum(i->first);
		//new MarkerItem(table, m);
		MarkerItem* item = new MarkerItem(table, m);
		if (m == selm)
		{
			m->setCurrent(true);
			table->setCurrentItem(item);
		}
		else
		{
			m->setCurrent(false);
		}
	}
}
Пример #14
0
void CanvasPicker::select( const QPoint &pos, Qt::KeyboardModifiers modifiers )
{
	m_selectionPoint = pos;
	m_previousPoint = pos;

    double minDistanceMarkers = 10e10;
	double minDistanceKnots = 10e10;

	MarkerItem* markerWithMinDistance = 0;
	KnotItem* knotWithMinDistance = 0;

	int selectionType = -1;

	PlotWidget* plotWidget = dynamic_cast<PlotWidget*>( plot() );

	const QwtScaleMap xMap = plot()->canvasMap( QwtPlot::xBottom );
    const QwtScaleMap yMap = plot()->canvasMap( QwtPlot::yLeft );

    const QwtPlotItemList& itemList = plot()->itemList();
    for ( QwtPlotItemIterator it = itemList.begin(); it != itemList.end(); ++it )
    {
        if ( ( *it )->rtti() == Globals::Rtti_PlotMarker )
        {
            MarkerItem* marker = static_cast<MarkerItem*>( *it );

			const double deltaX = xMap.transform( marker->xValue() ) - pos.x();
			const double deltaY = yMap.transform( marker->yValue() ) - pos.y();
			const double distance = qSqrt( qwtSqr( deltaX ) + qwtSqr( deltaY ) );
            if ( distance < minDistanceMarkers )
			{
				minDistanceMarkers = distance;
				markerWithMinDistance = marker;
			}
		}
		else if ( ( *it )->rtti() == Globals::Rtti_PlotKnot )
		{
			KnotItem* knot = static_cast<KnotItem*>( *it );

			const double distance = qAbs( xMap.transform( knot->coordinate() ) - pos.x() );

			if( distance < minDistanceKnots )
			{
				minDistanceKnots = distance;
				knotWithMinDistance = knot;
			}
		}
    }

	// Give a priority to the markers
	if( minDistanceMarkers < Globals::SELECTION_PIXEL_TOLERANCE && markerWithMinDistance != 0 )
	{
		m_itemToPick = markerWithMinDistance;
		selectionType = Globals::Rtti_PlotMarker;
	}
	else if(  minDistanceKnots < Globals::SELECTION_PIXEL_TOLERANCE && knotWithMinDistance != 0 )
	{
		m_itemToPick = knotWithMinDistance;
		selectionType = Globals::Rtti_PlotKnot;
	}

	if( selectionType == -1 )
	{
		emit picked( modifiers, 0 );
		return;
	}

	QList<QwtPlotItem*>& listOfSelectedItems = plotWidget->listOfSelectedItems( selectionType );

	if( listOfSelectedItems.count() == 0 )
	{
		// Select and allow the user to drag and drop.
		emit picked( modifiers, m_itemToPick );

		m_typeOfItemsToDrag = selectionType;
		m_dragAndDropInProgress = true;
		m_itemToPick = 0;
	}
	else
	{
		if( listOfSelectedItems.contains( m_itemToPick ) )
		{
			// We don't know yet whether the user wants to do a selection or a drag and drop operation.
			// The picking operation will be detected in CanvasPicker::release().

			m_typeOfItemsToDrag = selectionType;
			m_dragAndDropInProgress = true;
		}
		else
		{
			emit picked( modifiers, m_itemToPick );
			m_itemToPick = 0;

			if( listOfSelectedItems.count() == 1 )
			{
				m_typeOfItemsToDrag = selectionType;
				m_dragAndDropInProgress = true;
			}
		}
	}
}
Пример #15
0
void MarkerList::CropToTimeSel(bool bOffset)
{
	double dStart, dEnd;
	GetSet_LoopTimeRange(false, false, &dStart, &dEnd, false);
	// If no time sel just return
	if (dStart == dEnd)
		return;

	// Don't crop the end of regions
	for (int i = 0; i < m_items.GetSize(); i++)
	{
		MarkerItem* item = m_items.Get(i);
		if (item->GetPos() > dEnd ||
			(!item->IsRegion() && item->GetPos() < dStart) ||
			(item->IsRegion()  && item->GetRegEnd() < dStart))
		{ // delete the item
			m_items.Delete(i, true);
			i--;
		}
		else
		{
			if (item->IsRegion() && item->GetPos() < dStart && item->GetRegEnd() >= dStart)
				item->SetPos(dStart);
			
			if (bOffset)
			{
				item->SetPos(item->GetPos() - dStart);
				if (item->IsRegion())
					item->SetRegEnd(item->GetRegEnd() - dStart);
			}
		}
	}
}