示例#1
0
void ObjectBarDialog::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	*pResult = 0;

	POSITION Pos = objects.GetFirstSelectedItemPosition();
	int Item = objects.GetNextSelectedItem(Pos);

	if (Item == -1) return; // Safety first

	// Select in layout editor, if it's open
	if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
	{
		// Find a CObj for the CObjType
		CObjType* pType;
		long ID = objects.GetItemData(Item);

		if (ID == -1)
			return; //folder

		application->object_types.Lookup(ID, pType);

		// Find out if this is a nonframe object
		CPlugin plugin = GetPlugin(pType->DLLIndex);

		if (plugin.m_Flags & OF_NODRAW)
			return;

		CLayout* pLayout = parent.layout_editor[0][0]->layout;

		// We're creating a duplicate
		g_bDuplicate = TRUE;

		parent.layout_editor[0][0]->m_sel.RemoveAll();

		// Iterate each instance
		POSITION InstancePos = pLayout->objects.GetStartPosition();
		long unused = 0;
		CObj* pObj;

		while (InstancePos)
		{
			pLayout->objects.GetNextAssoc(InstancePos, unused, pObj);

			// Add 
			if (pObj->editObject->ObjectIdentifier == pType->ObjectIdentifier)
				break;
		}

		long OID = pObj->GetInstanceID();

		parent.layout_editor[0][0]->m_sel.AddTail(OID);
		CPoint pt = pObj->GetObjectRect(parent.layout_editor[0][0]).GetBoundingRect().CenterPoint();

		parent.layout_editor[0][0]->m_oldPt = pt;
		pt.Offset(3,3);

		parent.layout_editor[0][0]->InitializeMove(pt);
	}
}
示例#2
0
void ObjectBarDialog::OnClickObject(NMHDR *pNMHDR, LRESULT *pResult)
{
	POSITION Pos = objects.GetFirstSelectedItemPosition();
	int Item = objects.GetNextSelectedItem(Pos);

	if (!layout) return;

	if (layout->m_ObjectFrameIsLockedTo != 0) // InputLocked()
		return;

	// Select in layout editor, if it's open
	if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
	{
		parent.layout_editor[0][0]->m_sel.RemoveAll();

		// This is intentionally here; clear selection if clicked on whitespace
		if(Item == -1)
		{
			parent.layout_editor[0][0]->Invalidate();
			g_PropertyBar->Update(parent.layout_editor[0][0], TYPE_LAYOUT, NULL, layout, NULL, application); 

			return;
		}

		// Now we have to wangle in the selected object
		int ObjectIdentifier = objects.GetItemData(Item);

		if (ObjectIdentifier==-1)
			return; //folder

		CObj*			pObject = 0;
		CObjType*		pObjectType = 0;

		POSITION LayerPos = layout->layers.GetHeadPosition();

		// So we have to find all the CObj's with this CObjType in the layout, and add them
		// For each layer
		while(LayerPos)
		{
			CLayer* pLayer = layout->layers.GetNext(LayerPos);

			// Loop all objects
			CObjList Objects;
			pLayer->GetEveryObject(Objects, layout);

			POSITION ObjectPos = Objects.GetHeadPosition();

			for (int i = 0; i < Objects.GetCount(); i++) 
			{
				CObj* pTestObject;
				long ID = Objects.GetNext(ObjectPos);
				layout->objects.Lookup(ID, pTestObject);

				if (pTestObject->GetGlobalID() != -1) 
				{
					CObjType* pTestType = pTestObject->GetObjectType(application);

					if (pTestType->ObjectIdentifier == ObjectIdentifier)
					{
						pObjectType = pTestType;
						pObject = pTestObject;

						long nKey = pObject->GetInstanceID();
						parent.layout_editor[0][0]->m_sel.AddTail(nKey);
					}
				}
			}
		}

		g_PropertyBar->Update(parent.layout_editor[0][0], TYPE_OBJECT, &parent.layout_editor[0][0]->m_sel, layout, &layout->objects, application); // Show object properties

		parent.layout_editor[0][0]->Invalidate();

		// While we're here, show animations for object
		// Future note: .. to be continued

		if(!pObjectType)
			return;

		int iRoot = -1;
		OINFO* oInfo = GetOINFO(pObjectType->DLLIndex);
		if (oInfo->ETGetAnimationHandle)
		{
			oInfo->ETGetAnimationHandle(pObject->editObject, iRoot);
			pMainWnd->animator.UpdateAnimations(application, layout, pObjectType, iRoot);
		}
	}
}