Пример #1
0
void RestoreActiveTakes(COMMAND_T*)
{
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
			// Find the saved track
			for (int j = 0; j < g_activeTakeTracks.Get()->GetSize(); j++)
				if (TrackMatchesGuid(tr, &g_activeTakeTracks.Get()->Get(j)->m_guid))
					g_activeTakeTracks.Get()->Get(j)->Restore(tr);
	}
	UpdateArrange();
}
Пример #2
0
void RestoreLastSelItemTrack(COMMAND_T* ct)
{
	PreventUIRefresh(1);
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
		{
			GUID* g = (GUID*)GetSetMediaTrackInfo(tr, "GUID", NULL);
			for (int j = 0; j < g_selItemsTrack.Get()->GetSize(); j++)
				if (GuidsEqual(g, &g_selItemsTrack.Get()->Get(j)->m_guid))
				{
					g_selItemsTrack.Get()->Get(j)->PreviousSelection(tr);
					break;
				}
		}
	}
	PreventUIRefresh(-1);
	Undo_OnStateChangeEx(SWS_CMD_SHORTNAME(ct), UNDO_STATE_ITEMS, -1);
	UpdateArrange();
}
Пример #3
0
void generate_items_sequence(std::shared_ptr<breakpoint_envelope> env, const char* fn)
{
	SetCursorContext(1, NULL);
	Main_OnCommand(40182, 0); // select all items
	Main_OnCommand(40006, 0); // remove selected items
	MediaTrack* dest_track = GetTrack(nullptr, 0);
	double timepos = 0.0;
	double seqlen = 30.0;
	int sanity = 0;
	while (timepos < seqlen)
	{
		create_item_result r = create_item_with_take_and_source(dest_track, fn);
		SetMediaItemPosition(r.item, timepos, false);
		double srclen = GetMediaSourceLength(r.src, nullptr);
		double normtime = 1.0 / seqlen * timepos;
		double directionfactor = skip_near_zero(-1.0 + 2.0*env->interpolate(normtime), 0.02);
		if (directionfactor < 0.0)
		{
			//readbg() << "item " << sanity << " should be reversed\n";
			SetMediaItemSelected(r.item, true);
			Main_OnCommand(41051, 0); // toggle reverse
			SetMediaItemSelected(r.item, false);
		}


		double absfactor = fabs(directionfactor);
		double itemlen = bound_value(0.02, srclen*absfactor, srclen);
		SetMediaItemLength(r.item, itemlen, false);
		SetMediaItemTakeInfo_Value(r.take, "D_PLAYRATE", 1.0 / absfactor);
		timepos += srclen*absfactor;
		++sanity;
		if (sanity > 1000)
		{
			readbg() << "too many items created!\n";
			break;
		}
	}
	UpdateArrange();
}
Пример #4
0
void RestoreSelTrackSelItems(int iSlot)
{
	PreventUIRefresh(1);
	for (int i = 1; i <= GetNumTracks(); i++)
	{
		MediaTrack* tr = CSurf_TrackFromID(i, false);
		if (*(int*)GetSetMediaTrackInfo(tr, "I_SELECTED", NULL))
		{
			GUID* g = (GUID*)GetSetMediaTrackInfo(tr, "GUID", NULL);
			for (int j = 0; j < g_selItemsTrack.Get()->GetSize(); j++)
				if (GuidsEqual(g, &g_selItemsTrack.Get()->Get(j)->m_guid))
				{
					g_selItemsTrack.Get()->Get(j)->Restore(tr, iSlot);
					break;
				}
		}
	}
	PreventUIRefresh(-1);

	char cUndoText[256];
	sprintf(cUndoText, __LOCALIZE_VERFMT("Restore selected track(s) selected item(s), slot %d","sws_undo"), iSlot+1);
	Undo_OnStateChangeEx(cUndoText, UNDO_STATE_ITEMS, -1);
	UpdateArrange();
}
Пример #5
0
SimpleExampleWindow::SimpleExampleWindow(HWND parent, std::string title) : MRPWindow(parent,title)
{
	m_last_project_change_count = GetProjectStateChangeCount(nullptr);
	m_but1 = std::make_shared<WinButton>(this, "Get take name");
	m_but1->GenericNotifyCallback = [this](GenericNotifications)
	{
		if (CountSelectedMediaItems(nullptr) > 0)
		{
			MediaItem* item = GetSelectedMediaItem(nullptr, 0);
			MediaItem_Take* take = GetActiveTake(item);
			if (take != nullptr)
			{
				char buf[2048];
				GetSetMediaItemTakeInfo_String(take, "P_NAME", buf, false);
				m_edit1->setText(buf);
			}
		}
	};
	add_control(m_but1);
	m_but2 = std::make_shared<WinButton>(this, "Set take name");
	m_but2->GenericNotifyCallback = [this](GenericNotifications)
	{
		if (CountSelectedMediaItems(nullptr) > 0)
		{
			MediaItem* item = GetSelectedMediaItem(nullptr, 0);
			MediaItem_Take* take = GetActiveTake(item);
			if (take != nullptr)
			{
				GetSetMediaItemTakeInfo_String(take, "P_NAME", (char*)m_edit1->getText().c_str(), true);
				UpdateArrange();
			}
		}
	};
	add_control(m_but2);
	
	m_but3 = std::make_shared<WinButton>(this, "Refresh item list");
	m_but3->GenericNotifyCallback = [this](GenericNotifications)
	{
		populate_listbox();
	};
	add_control(m_but3);
	
	m_but4 = std::make_shared<WinButton>(this, "Remove selected listbox item foffoffooo");
	m_but4->GenericNotifyCallback = [this](GenericNotifications)
	{
		int selindex = m_listbox1->getSelectedIndex();
		if (selindex >= 0)
		{
			m_listbox1->removeItem(selindex);
			m_itemmap.erase(m_listbox1->userIDfromIndex(selindex));
		}
	};
	add_control(m_but4);
	
	m_edit1 = std::make_shared<WinLineEdit>(this, "No take name yet");
	add_control(m_edit1);
	m_listbox1 = std::make_shared<WinListBox>(this);
	
	m_listbox1->SelectedChangedCallback = [this](int index) mutable
	{
		if (index >= 0)
		{
			std::string temp = m_listbox1->getItemText(index);
			readbg() << "you chose " << temp << " from the listbox\n";
			int user_id = m_listbox1->userIDfromIndex(index);
			MediaItem* itemfromlist = m_itemmap[user_id];
			if (ValidatePtr((void*)itemfromlist, "MediaItem*") == true)
			{
				m_edit1->setText(std::string("You chose item with mem address " +
					std::to_string((uint64_t)itemfromlist) + " from the listbox"));
			}
			else m_edit1->setText(("You chose an item from listbox that's no longer valid!"));
		}
		else readbg() << "you managed to choose no item from the listbox\n";
	};
	add_control(m_listbox1);
	add_control(m_listbox1);
	
	m_checkbox1 = std::make_shared<WinCheckBox>(this,"The check box");
	add_control(m_checkbox1);
	m_checkbox1->GenericNotifyCallback = [this](GenericNotifications reason)
	{
		if (reason == GenericNotifications::Checked)
			readbg() << "check box was checked\n";
		else readbg() << "check box was unchecked\n";
	};
	
	m_label1 = std::make_shared<WinLabel>(this, "Ok, will all this text be shown by default...? I wonder...");
	add_control(m_label1);
	m_label1->setTopLeftPosition(150, 60);

	m_rectcontrol1 = std::make_shared<RectangleTestControl>(this);
	add_control(m_rectcontrol1);

	setSize(900, 650);
}
Пример #6
0
void TogGridOverUnder(COMMAND_T*) { int* p = (int*)GetConfigVar("gridinbg"); if (p) *p = *p == 2 ? 0 : 2; UpdateArrange(); }