Exemplo n.º 1
0
Arquivo: Color.cpp Projeto: wolqws/sws
void ItemGradient(COMMAND_T* = NULL)
{
	int iCurPos = 0;
	int iNumSel = 0;
	// First, must count the number of selected items 
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
			if (*(bool*)GetSetMediaItemInfo(GetTrackMediaItem(tr, j), "B_UISEL", NULL))
				iNumSel++;
	}
	// Now, set the colors
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
			{
				COLORREF cr = CalcGradient(g_crGradStart, g_crGradEnd, (double)iCurPos++ / (iNumSel-1)) | 0x1000000;
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
			}
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set selected item(s) to color gradient","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 2
0
void SelULItem(COMMAND_T* = NULL)
{
	UnselOnTracks();
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		int iNumItems = GetTrackNumMediaItems(tr);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL) && iNumItems)
		{
			MediaItem* pUL = GetTrackMediaItem(tr, 0);
			double dFirstPos = *(double*)GetSetMediaItemInfo(pUL, "D_POSITION", NULL);
			float fFIPMy = *(float*)GetSetMediaItemInfo(pUL, "F_FREEMODE_Y", NULL);
			for (int j = 1; j < iNumItems; j++)
			{
				if (dFirstPos != *(double*)GetSetMediaItemInfo(GetTrackMediaItem(tr, j), "D_POSITION", NULL))
					break;
				if (fFIPMy > *(float*)GetSetMediaItemInfo(GetTrackMediaItem(tr, j), "F_FREEMODE_Y", NULL))
				{
					pUL = GetTrackMediaItem(tr, j);
					fFIPMy = *(float*)GetSetMediaItemInfo(pUL, "F_FREEMODE_Y", NULL);
				}
			}
			GetSetMediaItemInfo(pUL, "B_UISEL", &g_bTrue);
		}
	}
	UpdateTimeline();
}
Exemplo n.º 3
0
MediaItem* FindWnd::FindPrevNextItem(int _dir, MediaItem* _item)
{
	if (!_dir)
		return NULL;

	MediaItem* previous = NULL;
	int startTrIdx = (_dir == -1 ? CountTracks(NULL) : 1);
	if (_item)
		if (MediaTrack* trItem = GetMediaItem_Track(_item))
			startTrIdx = CSurf_TrackToID(trItem, false);

	if (startTrIdx>=0)
	{
		bool found = (_item == NULL);
		for (int i = startTrIdx; !previous && i <= CountTracks(NULL) && i >= 1; i+=_dir)
		{
			MediaTrack* tr = CSurf_TrackFromID(i, false); 
			int nbItems = GetTrackNumMediaItems(tr);
			for (int j = (_dir > 0 ? 0 : (nbItems-1)); j < nbItems && j >= 0; j+=_dir)
			{
				MediaItem* item = GetTrackMediaItem(tr,j);
				if (found && item) {
					previous = item;
					break;
				}
				if (_item && item == _item)
					found = true;
			}
		}
	}
	return previous;
}
Exemplo n.º 4
0
void NameTrackLikeItem(COMMAND_T* ct)
{
	WDL_TypedBuf<MediaTrack*> tracks;
	SWS_GetSelectedTracks(&tracks);
	bool bUndo = false;
	for (int i = 0; i < tracks.GetSize(); i++)
	{
		for (int j = 0; j < GetTrackNumMediaItems(tracks.Get()[i]); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tracks.Get()[i], j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL) && GetMediaItemNumTakes(mi))
			{
				MediaItem_Take* take = GetMediaItemTake(mi, -1);
				if (take)
				{
					const char* pName = (const char*)GetSetMediaItemTakeInfo(take, "P_NAME", NULL);
					if (pName && strlen(pName))
					{
						char* pNameNoExt = new char[strlen(pName)+1];
						strcpy(pNameNoExt, pName);
						char* pDot = strrchr(pNameNoExt, '.');
						if (pDot && IsMediaExtension(pDot+1, false))
							*pDot = 0;
						GetSetMediaTrackInfo(tracks.Get()[i], "P_NAME", (void*)pNameNoExt);
						bUndo = true;
						delete [] pNameNoExt;
					}
					break;
				}
			}
		}
	}
	if (bUndo)
		Undo_OnStateChangeEx(SWS_CMD_SHORTNAME(ct), UNDO_STATE_TRACKCFG, -1);
}
Exemplo n.º 5
0
void ActiveTakeTrack::Restore(MediaTrack* tr)
{
	// TODO : if no matched items, return false and delete from level above???
	if (m_items.GetSize() == 0 || !GetTrackNumMediaItems(tr))
		return;

	bool* bUsed = new bool[m_items.GetSize()];
	memset(bUsed, 0, sizeof(bool) * m_items.GetSize());

	for (int i = 0; i < GetTrackNumMediaItems(tr); i++)
	{
		MediaItem* mi = GetTrackMediaItem(tr, i);
		GUID* g = (GUID*)GetSetMediaItemInfo(mi, "GUID", NULL);
		for (int j = 0; j < m_items.GetSize(); j++)
		{
			if (!bUsed[j] && GuidsEqual(g, &m_items.Get(j)->m_item))
			{
				// TODO check this logic under a bunch of situs
				if (!m_items.Get(j)->Restore(mi))
					m_items.Delete(j--, true);
				else
					bUsed[j] = true;
				break;
			}
		}
	}

	delete[] bUsed;
}
Exemplo n.º 6
0
void RecSrcOut(COMMAND_T* = NULL)
{
	// Set the rec source to output
	// Set to mono or stereo based on first item
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		int iMode = 1; // 5 = mono, 1 = stereo
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
		{
			if (GetTrackNumMediaItems(tr))
			{
				MediaItem* mi = GetTrackMediaItem(tr, 0);
				if (GetMediaItemNumTakes(mi))
				{
					MediaItem_Take* mit = GetMediaItemTake(mi, 0);
					PCM_source* p = (PCM_source*)GetSetMediaItemTakeInfo(mit, "P_SOURCE", NULL);
					if (p && p->GetNumChannels() == 1)
						iMode = 5;

				}
			}
			GetSetMediaTrackInfo(tr, "I_RECMODE", &iMode);
		}
	}
}
Exemplo n.º 7
0
void SelPrevItem(COMMAND_T* ctx)
{
	// Find the last selected
	MediaItem* prevMi = NULL;
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (GetTrackVis(tr) & 2)
		{
			for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
			{
				MediaItem* mi = GetTrackMediaItem(tr, j);
				if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
				{
					if (prevMi)
					{
						if (ctx->user == 0)
							Main_OnCommand(40289, 0); // Unselect all items
						GetSetMediaItemInfo(prevMi, "B_UISEL", &g_bTrue);
						UpdateTimeline();
						return;
					}
				}
				prevMi = mi;
			}
		}
	}
}
Exemplo n.º 8
0
double SNM_GetProjectLength(bool _items, bool _inclRgnsMkrs)
{
	double prjlen = 0.0, pos, end;
	if (_inclRgnsMkrs)
	{
		int x=0; bool isRgn;
		while (x = EnumProjectMarkers2(NULL, x, &isRgn, &pos, &end, NULL, NULL)) {
			if (isRgn) { if (end > prjlen) prjlen = end; }
			else { if (pos > prjlen) prjlen = pos; }
		}
	}
	if (_items)
	{
		double len;
		for (int i=1; i <= GetNumTracks(); i++) // skip master
			if (MediaTrack* tr = CSurf_TrackFromID(i, false))
				for (int j=0; j < GetTrackNumMediaItems(tr); j++)
					if (MediaItem* item = GetTrackMediaItem(tr,j))
					{
						pos = *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL);
						len = *(double*)GetSetMediaItemInfo(item, "D_LENGTH", NULL);
						if ((pos+len)>prjlen)
							prjlen = pos+len;
					}
	}
	return prjlen;
}
Exemplo n.º 9
0
Arquivo: Color.cpp Projeto: wolqws/sws
void CustomColorAll(COMMAND_T*)
{	
	// Get the first selected track
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
		{
			Undo_BeginBlock();
			Main_OnCommand(40357, 0); // Set track(s) to one custom color
			// Assume the user clicked 'OK' in the color picker!
			COLORREF cr = *(COLORREF*)GetSetMediaTrackInfo(tr, "I_CUSTOMCOLOR", NULL);
			for (int i = 1; i <= GetNumTracks(); i++)
			{
				tr = CSurf_TrackFromID(i, false);
				for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
				{
					MediaItem* mi = GetTrackMediaItem(tr, j);
					if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
						GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
				}
			}
			UpdateTimeline();
			Undo_EndBlock(__LOCALIZE("Set selected track(s)/item(s) to custom color","sws_undo"), UNDO_STATE_ALL);
			return;
		}
	}
	// No tracks selected so just run the item action
	Main_OnCommand(40704, 0); // Set item(s) to one custom color
}
Exemplo n.º 10
0
Arquivo: Color.cpp Projeto: wolqws/sws
void TakeRandomCols(COMMAND_T* = NULL)
{
	COLORREF cr;
	// All black check
	if (AllBlack())
		return;
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
			{
				for (int h = 0; h < CountTakes(mi); h++)
				{
					while (!(cr = g_custColors[rand() % 16]));
					cr |= 0x1000000;
					GetSetMediaItemTakeInfo(GetTake(mi, h), "I_CUSTOMCOLOR", &cr);
				}
			}
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set takes in selected item(s) to random custom color(s)","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 11
0
ActiveTakeTrack::ActiveTakeTrack(MediaTrack* tr)
{
	m_guid = *(GUID*)GetSetMediaTrackInfo(tr, "GUID", NULL);
	for (int i = 0; i < GetTrackNumMediaItems(tr); i++)
	{
		MediaItem* mi = GetTrackMediaItem(tr, i);
		if (GetMediaItemNumTakes(mi))
			m_items.Add(new ActiveTake(mi));
	}
}
Exemplo n.º 12
0
void UnselOnTracks(COMMAND_T* = NULL)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
			for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
				GetSetMediaItemInfo(GetTrackMediaItem(tr, j), "B_UISEL", &g_bFalse);
	}
	UpdateTimeline();
}
Exemplo n.º 13
0
void SelItems::Add(MediaTrack* tr)
{
	for (int i = 0; i < GetTrackNumMediaItems(tr); i++)
	{
		MediaItem* mi = GetTrackMediaItem(tr, i);
		if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
		{
			GUID* g = new GUID;
			*g = *(GUID*)GetSetMediaItemInfo(mi, "GUID", NULL);
			m_selItems.Add(g);
		}
	}
}
Exemplo n.º 14
0
void AddLeftItem(COMMAND_T* = NULL)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		WDL_PtrList<void> selItems;
		// First find selected items
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* selItem = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(selItem, "B_UISEL", NULL))
				selItems.Add(selItem);
		}

		for (int j = 0; j < selItems.GetSize(); j++)
		{
			double dLeft    = *(double*)GetSetMediaItemInfo((MediaItem*)selItems.Get(j), "D_POSITION", NULL);
			double dRight   = *(double*)GetSetMediaItemInfo((MediaItem*)selItems.Get(j), "D_LENGTH", NULL) + dLeft;
			double dMaxLeft = -DBL_MAX;
			MediaItem* leftItem = NULL;
			for (int k = 0; k < GetTrackNumMediaItems(tr); k++)
			{
				MediaItem* mi;
				mi = GetTrackMediaItem(tr, k);
				double dLeft2  = *(double*)GetSetMediaItemInfo(mi, "D_POSITION", NULL);
				double dRight2 = *(double*)GetSetMediaItemInfo(mi, "D_LENGTH", NULL) + dLeft2;
				if (dLeft2 < dLeft && dRight2 < dRight && dLeft2 > dMaxLeft)
				{
					dMaxLeft = dLeft2;
					leftItem = mi;
				}
			}
			if (leftItem)
				GetSetMediaItemInfo(leftItem, "B_UISEL", &g_i1);
		}
	}
	UpdateTimeline();
}
Exemplo n.º 15
0
void SelMutedItems(COMMAND_T* ct)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			bool sel = *(bool*)GetSetMediaItemInfo(mi, "B_MUTE", NULL);
			if ((int)ct->user == 0) sel = !sel;
			GetSetMediaItemInfo(mi, "B_UISEL", &sel);
		}
	}
	UpdateTimeline();
}
Exemplo n.º 16
0
Arquivo: Color.cpp Projeto: wolqws/sws
void BlackItem(COMMAND_T* = NULL)
{
	int iBlack = 0x1000000 | RGB(0, 0, 0);
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &iBlack);
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set item(s) color black","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 17
0
void SelLockedItems(COMMAND_T* = NULL)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(char*)GetSetMediaItemInfo(mi, "C_LOCK", NULL))
				GetSetMediaItemInfo(mi, "B_UISEL", &g_i1);
			else
				GetSetMediaItemInfo(mi, "B_UISEL", &g_i0);
		}
	}
	UpdateTimeline();
}
Exemplo n.º 18
0
void SWS_GetSelectedMediaItemsOnTrack(WDL_TypedBuf<MediaItem*>* buf, MediaTrack* tr)
{
	buf->Resize(0);
	if (CSurf_TrackToID(tr, false) <= 0)
		return;
	for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
	{
		MediaItem* item = GetTrackMediaItem(tr, j);
		if (*(bool*)GetSetMediaItemInfo(item, "B_UISEL", NULL))
		{
			int pos = buf->GetSize();
			buf->Resize(pos + 1);
			buf->Get()[pos] = item;
		}
	}
}
Exemplo n.º 19
0
// appends _tr's state to _chunkOut
//JFB TODO: save envs with beat position info (like it is done for items)
void SaveSingleTrackTemplateChunk(MediaTrack* _tr, WDL_FastString* _chunkOut, bool _delItems, bool _delEnvs)
{
	if (_tr && _chunkOut)
	{
		SNM_TrackEnvParserPatcher p(_tr, false); // no auto-commit!
		if (_delEnvs)
			p.RemoveEnvelopes();

		// systematically remove items whatever is _delItems, then
		// replace them with items + optional beat pos info, if !_delItems (i.e. mimic native templates)
		p.RemoveSubChunk("ITEM", 2, -1);

		_chunkOut->Append(p.GetChunk()->Get());

		if (!_delItems)
		{
			double d;
			WDL_FastString beatInfo;
			for (int i=0; i<GetTrackNumMediaItems(_tr); i++)
			{
				if (MediaItem* item = GetTrackMediaItem(_tr, i))
				{
					SNM_ChunkParserPatcher pitem(item, false); // no auto-commit!
					int posChunk = pitem.GetLinePos(1, "ITEM", "POSITION", 1, 0); // look for the *next* line
					if (--posChunk>=0) { // --posChunk to zap "\n"
						TimeMap2_timeToBeats(NULL, *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL), NULL, NULL, &d, NULL);
						beatInfo.SetFormatted(32, " %.14f", d);
						pitem.GetChunk()->Insert(beatInfo.Get(), posChunk);
					}
					posChunk = pitem.GetLinePos(1, "ITEM", "SNAPOFFS", 1, 0);
					if (--posChunk>=0) {
						TimeMap2_timeToBeats(NULL, *(double*)GetSetMediaItemInfo(item, "D_SNAPOFFSET", NULL), NULL, NULL, &d, NULL);
						beatInfo.SetFormatted(32, " %.14f", d);
						pitem.GetChunk()->Insert(beatInfo.Get(), posChunk);
					}
					posChunk = pitem.GetLinePos(1, "ITEM", "LENGTH", 1, 0);
					if (--posChunk>=0) {
						TimeMap2_timeToBeats(NULL, *(double*)GetSetMediaItemInfo(item, "D_LENGTH", NULL), NULL, NULL, &d, NULL);
						beatInfo.SetFormatted(32, " %.14f", d);
						pitem.GetChunk()->Insert(beatInfo.Get(), posChunk);
					}
					_chunkOut->Insert(pitem.GetChunk(), _chunkOut->GetLength()-2); // -2: before ">\n"
				}
			}
		}
	}
}
Exemplo n.º 20
0
// flags&1=incl. items, &2=incl. markers/regions, &4=incl. envelopes
double SNM_GetProjectLength(int _flags)
{
	double prjlen = 0.0, pos, end;
	if (_flags&2)
	{
		int x=0; bool isRgn;
		while ((x = EnumProjectMarkers2(NULL, x, &isRgn, &pos, &end, NULL, NULL))) {
			if (isRgn) { if (end > prjlen) prjlen = end; }
			else { if (pos > prjlen) prjlen = pos; }
		}
	}
	if ((_flags&1) || (_flags&4))
	{
		double len;
		for (int i=0; i <= GetNumTracks(); i++)
		{
			if (MediaTrack* tr = CSurf_TrackFromID(i, false))
			{
				int cnt= i>0 ? GetTrackNumMediaItems(tr) : 0; // skip master
				if (_flags&1) for (int j=0; j<cnt; j++)
				{
					if (MediaItem* item = GetTrackMediaItem(tr,j))
					{
						pos = *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL);
						len = *(double*)GetSetMediaItemInfo(item, "D_LENGTH", NULL);
						if ((pos+len)>prjlen) prjlen = pos+len;
					}
				}

				cnt=CountTrackEnvelopes(tr);
				if (_flags&4) for (int j=0; j<cnt; j++)
				{
					if (TrackEnvelope* env = GetTrackEnvelope(tr,j))
					{
						if (int ptcnt=CountEnvelopePoints(env))
						{
							pos=prjlen;
							GetEnvelopePoint(env, ptcnt-1, &pos, NULL, NULL, NULL, NULL);
							if (pos>prjlen) prjlen = pos;
						}
					}
				}
			}
		}
	}
	return prjlen;
}
Exemplo n.º 21
0
Arquivo: Color.cpp Projeto: wolqws/sws
void ItemToTrackCol(COMMAND_T* = NULL)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		COLORREF cr = *(COLORREF*)GetSetMediaTrackInfo(tr, "I_CUSTOMCOLOR", NULL);

		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set selected item(s) to respective track color","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 22
0
void UnselNotRender(COMMAND_T* = NULL)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (GetMediaItemNumTakes(mi))
			{
				PCM_source* src = (PCM_source*)GetSetMediaItemTakeInfo(GetMediaItemTake(mi, -1), "P_SOURCE", NULL);
				if (src && src->GetFileName() && !strstr(src->GetFileName(), "render"))
					GetSetMediaItemInfo(mi, "B_UISEL", &g_bFalse);
			}
		}
	}
	UpdateTimeline();
}
Exemplo n.º 23
0
void TogItemSel(COMMAND_T* = NULL)
{	// Toggle item's selection states on selected tracks
	bool bSel;
	MediaTrack* tr;
	MediaItem* mi;
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
			for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
			{
				mi = GetTrackMediaItem(tr, j);
				bSel = !*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL);
				GetSetMediaItemInfo(mi, "B_UISEL", &bSel);
			}
	}
	UpdateTimeline();
}
Exemplo n.º 24
0
void SWS_GetSelectedMediaItems(WDL_TypedBuf<MediaItem*>* buf)
{
	buf->Resize(0);
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* item = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(item, "B_UISEL", NULL))
			{
				int pos = buf->GetSize();
				buf->Resize(pos + 1);
				buf->Get()[pos] = item;
			}
		}
	}
}
Exemplo n.º 25
0
// bUsed is an array of bools with size == m_selItems.GetSize(), used to "check off" when an item from that list is used
// caller initializes bUsed
void SelItems::Match(MediaTrack* tr, bool* bUsed)
{
	PreventUIRefresh(1);
	int nbitems=GetTrackNumMediaItems(tr);
	for (int i = 0; i < nbitems; i++)
	{
		MediaItem* mi = GetTrackMediaItem(tr, i);
		GetSetMediaItemInfo(mi, "B_UISEL", &g_bFalse);
		GUID* g = (GUID*)GetSetMediaItemInfo(mi, "GUID", NULL);
		for (int j = 0; j < m_selItems.GetSize(); j++)
			if (!bUsed[j] && GuidsEqual(m_selItems.Get(j), g))
			{
				bUsed[j] = true;
				GetSetMediaItemInfo(mi, "B_UISEL", &g_bTrue);
				break;
			}
	}
	PreventUIRefresh(-1);
}
Exemplo n.º 26
0
Arquivo: Color.cpp Projeto: wolqws/sws
void ItemCustomColor(int iCustColor)
{
	COLORREF cr;
	UpdateCustomColors();
	cr = g_custColors[iCustColor] | 0x1000000;
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
		}
	}
	char cUndoText[100];
	sprintf(cUndoText, __LOCALIZE_VERFMT("Set item(s) to custom color %d","sws_undo"), iCustColor+1);
	Undo_OnStateChange(cUndoText);
	UpdateTimeline();
}
Exemplo n.º 27
0
Arquivo: Color.cpp Projeto: wolqws/sws
void ItemOrderedCol(COMMAND_T* = NULL)
{
	int iCurPos = 0;
	UpdateCustomColors();
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
			{
				COLORREF cr = g_custColors[iCurPos++ % 16] | 0x1000000;
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
			}
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set selected item(s) to ordered custom colors","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 28
0
Arquivo: Color.cpp Projeto: wolqws/sws
void ItemRandomCol(COMMAND_T* = NULL)
{
	COLORREF cr;
	// All black check
	if (AllBlack())
		return;
	while (!(cr = g_custColors[rand() % 16]));
	cr |= 0x1000000;
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set item(s) to one random custom color","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 29
0
Arquivo: Color.cpp Projeto: wolqws/sws
void ColorItemNextCust(COMMAND_T* = NULL)
{
	if (AllBlack())
		return;

	for (int j = 1; j <= GetNumTracks(); j++)
	{
		MediaTrack* tr = CSurf_TrackFromID(j, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
			{
				COLORREF cr = *(int*)GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", NULL) & 0xFFFFFF;
				cr = GetNextCustColor(cr) | 0x1000000;
				GetSetMediaItemInfo(mi, "I_CUSTOMCOLOR", &cr);
			}
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set item(s) to next custom color","sws_undo"));
	UpdateTimeline();
}
Exemplo n.º 30
0
Arquivo: Color.cpp Projeto: wolqws/sws
void TakeGradient(COMMAND_T* = NULL)
{
	int tCurPos = 0;
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		for (int j = 0; j < GetTrackNumMediaItems(tr); j++)
		{
			MediaItem* mi = GetTrackMediaItem(tr, j);
			if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL))
			{
				for (int h = 0; h < CountTakes(mi); h++)
				{
					COLORREF cr = CalcGradient(g_crGradStart, g_crGradEnd, (double)tCurPos++ / (CountTakes(mi)-1)) | 0x1000000;
					GetSetMediaItemTakeInfo(GetTake(mi, h), "I_CUSTOMCOLOR", &cr);
				}
				tCurPos = 0;
			}
		}
	}
	Undo_OnStateChange(__LOCALIZE("Set takes in selected item(s) to color gradient","sws_undo"));
	UpdateTimeline();
}