コード例 #1
0
ファイル: Animator Bar.cpp プロジェクト: aolko/construct
////////////////////////////////////////////////////////////////////////////
// Film strip
////////////////////////////////////////////////////////////////////////////
void AnimatorBar::OnKeyDownFilmStrip(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
	
	// Check modifier
	bool bControlDown = GetKeyState(VK_CONTROL) >> 4;

	LV_KEYDOWN* pKeyDown = (LV_KEYDOWN*)pNMHDR;
	WORD Test = pKeyDown->wVKey;

	// delete, delete
	if (Test == VK_DELETE)
		RemoveFrame();

	// C, copy
	if (Test == 0x43)
	{
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);
	}

	// X, cut
	if (Test == 0x78 && film_strip.GetItemCount() != 1)
	{
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);

		RemoveFrame();
	}

	// V, paste
	if (Test == 0x56)
	{
		if (m_pDDMgr.OkToPaste())
		{
			CAnimEdFrame pFrames;
			pFrames.m_anim_ed = this;
			m_pDDMgr.DoDrop(&pFrames,
							  NULL,
							  "Construct Frames");
		}
	}

	*pResult = 0;
}
コード例 #2
0
ファイル: nsFrameList.cpp プロジェクト: at13/mozilla-central
void
nsFrameList::DestroyFrame(nsIFrame* aFrame)
{
  NS_PRECONDITION(aFrame, "null ptr");
  RemoveFrame(aFrame);
  aFrame->Destroy();
}
コード例 #3
0
cv::Mat LucasKanade::AddFrame(Frame* frame) {
	frames.push_back(frame);
	int total_frames = kGradientEnd - kGradientBegin + 1;
	if (total_frames < frames.size()) RemoveFrame();
	SmoothFrame(frames.size() - 1);
	return frames.back()->GetMatrix();
}
コード例 #4
0
ファイル: CCodeChainCtx.cpp プロジェクト: bmer/Mammoth
ICCItem *CCodeChainCtx::RunLambda (ICCItem *pCode)

//	RunLambda
//
//	Runs a piece of code or a lambda expression
//	and returns a result (which must be discarded by the caller)

	{
	DEBUG_TRY

	AddFrame();

	//	If this is a lambda expression, then eval as if
	//	it were an expression with no arguments

	ICCItem *pResult;
	if (pCode->IsFunction())
		pResult = m_CC.Apply(pCode, m_CC.CreateNil(), this);
	else
		pResult = m_CC.TopLevel(pCode, this);

	//	Done

	RemoveFrame();

	return pResult;

	DEBUG_CATCH
	}
コード例 #5
0
ファイル: DockWindow.cpp プロジェクト: dreamsxin/ultimatepp
void DockWindow::DockLayout()
{
	if (hideframe[0].GetParent())
		for (int i = 0; i < 4; i++) {
			RemoveFrame(hideframe[i]);
			RemoveFrame(dockframe[i]);
		}
	// Top, Bottom, Left, Right
	AddFrame(hideframe[1]);
	AddFrame(hideframe[3]);
	AddFrame(hideframe[0]);
	AddFrame(hideframe[2]);
	AddFrame(dockframe[1]);
	AddFrame(dockframe[3]);
	AddFrame(dockframe[0]);
	AddFrame(dockframe[2]);
}
コード例 #6
0
ファイル: NURBSSurface.cpp プロジェクト: subprotocol/xflr5
/**
 * Removes all the Frame objects from the array
 */
void NURBSSurface::ClearFrames()
{
	if(!FrameSize()) return;
	for(int ifr=FrameSize()-1; ifr>=0; ifr--)
	{
		RemoveFrame(ifr);
	}
}
コード例 #7
0
ファイル: nsFrameList.cpp プロジェクト: at13/mozilla-central
nsIFrame*
nsFrameList::RemoveFirstChild()
{
  if (mFirstChild) {
    nsIFrame* firstChild = mFirstChild;
    RemoveFrame(firstChild);
    return firstChild;
  }
  return nullptr;
}
コード例 #8
0
NS_IMETHODIMP
nsTableColGroupFrame::RemoveFrame(ChildListID     aListID,
                                  nsIFrame*       aOldFrame)
{
  NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");

  if (!aOldFrame) return NS_OK;
  bool contentRemoval = false;
  
  if (nsGkAtoms::tableColFrame == aOldFrame->GetType()) {
    nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
    if (colFrame->GetColType() == eColContent) {
      contentRemoval = true;
      // Remove any anonymous column frames this <col> produced via a colspan
      nsTableColFrame* col = colFrame->GetNextCol();
      nsTableColFrame* nextCol;
      while (col && col->GetColType() == eColAnonymousCol) {
#ifdef DEBUG
        nsIFrame* providerFrame = colFrame->GetParentStyleContextFrame();
        if (colFrame->GetStyleContext()->GetParent() ==
            providerFrame->GetStyleContext()) {
          NS_ASSERTION(col->GetStyleContext() == colFrame->GetStyleContext() &&
                       col->GetContent() == colFrame->GetContent(),
                       "How did that happen??");
        }
        // else colFrame is being removed because of a frame
        // reconstruct on it, and its style context is still the old
        // one, so we can't assert anything about how it compares to
        // col's style context.
#endif
        nextCol = col->GetNextCol();
        RemoveFrame(kPrincipalList, col);
        col = nextCol;
      }
    }
    
    PRInt32 colIndex = colFrame->GetColIndex();
    // The RemoveChild call handles calling FrameNeedsReflow on us.
    RemoveChild(*colFrame, true);
    
    nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
    tableFrame->RemoveCol(this, colIndex, true, true);
    if (mFrames.IsEmpty() && contentRemoval && 
        GetColType() == eColGroupContent) {
      tableFrame->AppendAnonymousColFrames(this, GetSpan(),
                                           eColAnonymousColGroup, true);
    }
  }
  else {
    mFrames.DestroyFrame(aOldFrame);
  }

  return NS_OK;
}
コード例 #9
0
PRBool
nsFrameList::RemoveFrameIfPresent(nsIFrame* aFrame)
{
  NS_PRECONDITION(aFrame, "null ptr");

  for (Enumerator e(*this); !e.AtEnd(); e.Next()) {
    if (e.get() == aFrame) {
      RemoveFrame(aFrame);
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}
コード例 #10
0
ファイル: CCodeChainCtx.cpp プロジェクト: bmer/Mammoth
ICCItem *CCodeChainCtx::Run (ICCItem *pCode)

//	Run
//
//	Runs the given piece of code and returns a result
//	(which must be discarded by the caller)

	{
	DEBUG_TRY

	AddFrame();
	ICCItem *pResult = m_CC.TopLevel(pCode, this);
	RemoveFrame();

	return pResult;

	DEBUG_CATCH
	}
コード例 #11
0
NS_IMETHODIMP
nsTableColGroupFrame::InsertFrames(ChildListID     aListID,
                                   nsIFrame*       aPrevFrame,
                                   nsFrameList&    aFrameList)
{
  NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
  NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
               "inserting after sibling frame with different parent");

  nsTableColFrame* col = GetFirstColumn();
  nsTableColFrame* nextCol;
  while (col && col->GetColType() == eColAnonymousColGroup) {
    // this colgroup spans one or more columns but now that there is a
    // real column below, spanned anonymous columns should be removed,
    // since the HTML spec says to ignore the span of a colgroup if it
    // has content columns in it.
    nextCol = col->GetNextCol();
    if (col == aPrevFrame) {
      // This can happen when we're being appended to
      NS_ASSERTION(!nextCol || nextCol->GetColType() != eColAnonymousColGroup,
                   "Inserting in the middle of our anonymous cols?");
      // We'll want to insert at the beginning
      aPrevFrame = nsnull;
    }
    RemoveFrame(kPrincipalList, col);
    col = nextCol;
  }

  NS_ASSERTION(!aPrevFrame || aPrevFrame == aPrevFrame->GetLastContinuation(),
               "Prev frame should be last in continuation chain");
  NS_ASSERTION(!aPrevFrame || !GetNextColumn(aPrevFrame) ||
               GetNextColumn(aPrevFrame)->GetColType() != eColAnonymousCol,
               "Shouldn't be inserting before a spanned colframe");

  const nsFrameList::Slice& newFrames =
    mFrames.InsertFrames(this, aPrevFrame, aFrameList);
  nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,
                                                         nsGkAtoms::tableColFrame);

  PRInt32 colIndex = (prevFrame) ? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1 : GetStartColumnIndex();
  InsertColsReflow(colIndex, newFrames);

  return NS_OK;
}
コード例 #12
0
ファイル: RecordingBuffer.cpp プロジェクト: AiYong/CryGame
void CRecordingBuffer::EnsureFreeSpace(size_t size)
{
	CRY_ASSERT_MESSAGE(size <= m_actualBufferSize, "Unable to clear enough space");
	while (true)
	{
		uint8* pEnd = GetEnd();
		size_t freeSpaceLeft = 0;
		if (m_pStart > pEnd)
		{
			freeSpaceLeft = m_pStart - pEnd;
		}
		else if (m_pStart == pEnd)
		{
			if (m_usedSize == 0)
			{
				// We have cleared the entire buffer by this point
				break;
			}
			else
			{
				// No free space at all, the buffer is entirely full
			}
		}
		else
		{
			// We need a continuous block of memory, so take the greatest of either
			// the end bit or the start bit
			size_t endSpace = m_pBuffer + m_actualBufferSize - pEnd;
			size_t startSpace = m_pStart - m_pBuffer;
			freeSpaceLeft = max(endSpace, startSpace);
		}
		if (freeSpaceLeft >= size)
		{
			// That's enough space, don't need to clear any more
			break;
		}
		RemoveFrame();
	};
}
コード例 #13
0
NS_IMETHODIMP
nsTableColGroupFrame::AppendFrames(ChildListID     aListID,
                                   nsFrameList&    aFrameList)
{
  NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");

  nsTableColFrame* col = GetFirstColumn();
  nsTableColFrame* nextCol;
  while (col && col->GetColType() == eColAnonymousColGroup) {
    // this colgroup spans one or more columns but now that there is a
    // real column below, spanned anonymous columns should be removed,
    // since the HTML spec says to ignore the span of a colgroup if it
    // has content columns in it.
    nextCol = col->GetNextCol();
    RemoveFrame(kPrincipalList, col);
    col = nextCol;
  }

  const nsFrameList::Slice& newFrames =
    mFrames.AppendFrames(this, aFrameList);
  InsertColsReflow(GetStartColumnIndex() + mColCount, newFrames);
  return NS_OK;
}
コード例 #14
0
ファイル: Animator Bar.cpp プロジェクト: aolko/construct
void AnimatorBar::OnRClickFilmStrip(NMHDR *pNMHDR, LRESULT *pResult)
{
	if (m_pCurrentAnimation == NULL)
		return;

	POINT MousePosition;
	GetCursorPos(&MousePosition);

	CExtPopupMenuWnd * popup = new CExtPopupMenuWnd;
	popup->LoadMenu(m_hWnd, IDR_BLANK, true, false);
	popup->ItemRemove(0);

	UINT ChosenItem = 0;

	// Add frame
	popup->ItemInsertCommand(1, -1, "Add frame", NULL, NULL);

	bool bIsSel = false;

	POSITION Pos = film_strip.GetFirstSelectedItemPosition();

	if(!m_pCurrentAnimation)
		return;

	if(!m_pCurrentAnimation->supportsFrames())
		return;

	while(Pos)
	{
		int Item = film_strip.GetNextSelectedItem(Pos);
		if (Item != -1)
			bIsSel = true;
	}

	// Import
	popup->ItemInsertCommand(3, -1, AB_IMPORTFRAME, NULL, NULL);
	popup->ItemBoldGet(0);

	// Copy/paste
	popup->ItemInsertCommand();

	// Remove frame(s)
	if (bIsSel)
		popup->ItemInsertCommand(2, -1, AB_REMOVEFRAME, NULL, NULL);

	if (film_strip.GetItemCount() != 1)
		popup->ItemInsertCommand(7, -1, AB_CUTFRAMES, NULL, NULL);

	popup->ItemInsertCommand(4, -1, AB_COPYFRAMES, NULL, NULL);
	popup->ItemInsertCommand(5, -1, AB_PASTEFRAMES, NULL, NULL);
	popup->ItemInsertCommand(10, -1, AB_DUPLICATEFRAMES, NULL, NULL);

	popup->ItemInsertCommand();

	// flip vertical/horizontal
	popup->ItemInsertCommand(8, -1, AB_MIRRORFRAMES, NULL, NULL);
	popup->ItemInsertCommand(9, -1, AB_FLIPFRAMES, NULL, NULL);

	// Explore
	popup->ItemInsertCommand();
	popup->ItemInsertCommand(6, -1, AB_LAUNCHEXPLORER, NULL, NULL);

	// Explore
	popup->ItemInsertCommand();
	popup->ItemInsertCommand(11, -1, AB_COPYCOLLISIONMASKTOEACHFRAME, NULL, NULL);


	// Show menu
	popup->TrackPopupMenu(TPMX_DO_MESSAGE_LOOP | TPMX_NO_WM_COMMAND | TPMX_NO_CMD_UI, MousePosition.x, MousePosition.y, NULL, NULL, NULL, &ChosenItem);
		
	if (ChosenItem == 1)
		AddFrame();

	else if (ChosenItem == 2)
		RemoveFrame();

	else if (ChosenItem == 3)
	{
		CImportImagesDlg ImportDlg;
		if (ImportDlg.DoModal() == IDOK)
		{			
			for(list<CImageResource>::iterator i = ImportDlg.m_Images.begin(); i!= ImportDlg.m_Images.end(); i++)
			{
				int id = layout->AddImage(i->bitmap.GetWidth(), i->bitmap.GetHeight());

				m_pCurrentAnimation->m_Images.push_back(id);
				m_pCurrentAnimation->m_FrameTimes.push_back(1.0);

				CImageResource* image = application->resources.FindImageResourceFromNumber(id);
				image->bitmap.Copy(i->bitmap);

				image->m_Action = i->m_Action;
				image->m_Hotspot = i->m_Hotspot;
				image->m_Collision = i->m_Collision;
				
			}
			
			UpdateFilmStrip();
		}
	}

	// copy
	else if (ChosenItem == 4)
	{	
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);
	}

	// cut
	else if (ChosenItem == 7)
	{
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);

		RemoveFrame();
	}

	// paste
	else if (ChosenItem == 5)
	{
		if (m_pDDMgr.OkToPaste())
		{
			CAnimEdFrame pFrames;
			pFrames.m_anim_ed = this;
			m_pDDMgr.DoDrop(&pFrames,
							  NULL,
							  "Construct Frames");
		}
	}

	// duplicate
	else if (ChosenItem == 10)
	{	
		CAnimEdFrame* pFrames = new CAnimEdFrame;
		pFrames->m_anim_ed = this;
		DROPEFFECT de = DROPEFFECT_NONE;
		m_pDDMgr.PrepareDrop(DO_CLIPBOARD, "Construct Frames", pFrames, &de);

		if (m_pDDMgr.OkToPaste())
		{
			CAnimEdFrame pFrames;
			pFrames.m_anim_ed = this;
			m_pDDMgr.DoDrop(&pFrames,
							  NULL,
							  "Construct Frames");
		}
	}
	// Copy collision mask to every other frame
	else if (ChosenItem == 11)
	{
		// Get the frame we right clicked on
		POSITION pos = film_strip.GetFirstSelectedItemPosition();
		if(pos)
		{
			int nItem = film_strip.GetNextSelectedItem(pos);
			int handle = m_pCurrentAnimation->m_Images.at(nItem);
		
			int result = MessageBox("Click 'OK' to confirm you want to copy the collision mask of this selected frame to every other frame in the animation package", "Construct", MB_OKCANCEL);

			if(result == IDOK){
				CImageResource* res = application->resources.FindImageResourceFromNumber(handle);
				if(!res)
					MessageBox("Error. Image resource could not be found for this animation frame");
				else
				{
					if(!res->m_Collision.IsValid())
						res->m_Collision = res->bitmap; // copy
					
					application->resources.CopyCollisionMaskToEveryFrameInAnimation(m_pAnimation, res); 

				}
			
				
		}
		}

	}

	// Launch explorer
	else if (ChosenItem == 6)
	{
		CPath Path;
		Path.SetToCurrentDirectory();
		
		CString InfoPath;
		InfoPath.Format("%sImages\\", Path.GetFullPath());

		// make sure directory exists
		::CreateDirectory(InfoPath, NULL);

		// now open file
		InfoPath += "frames.txt";
		CFile File(InfoPath, CFile::modeWrite | CFile::modeCreate);
	

		int index = 0;
		for(vector<int>::iterator i = m_pCurrentAnimation->m_Images.begin(); i!= m_pCurrentAnimation->m_Images.end(); i++)
		{
			CImageResource* img = application->resources.FindImageResourceFromNumber(*i);
			if(img)
			{
				CString nl;
				nl.Format("%c%c", 13,10);
				index ++;
				CString SavePath;
				SavePath.Format("%sImages\\Frame %d.png", Path.GetFullPath(), index);
				CxImage backup = img->bitmap;
				img->Predivide();
				img->bitmap.Save(SavePath,CXIMAGE_FORMAT_PNG);
				img->bitmap = backup;

				if(img->m_Collision.IsValid())
				{
					SavePath.Format("%sImages\\Mask %d.png", Path.GetFullPath(), index);
					img->m_Collision.Save(SavePath,CXIMAGE_FORMAT_PNG);
				}
				else
				{
					SavePath.Format("%sImages\\Mask %d.png", Path.GetFullPath(), index);
					img->bitmap.Save(SavePath,CXIMAGE_FORMAT_PNG);
				}


				CString Info;
				Info.Format("Frame %d%sPivotX%s%d%sPivotY%s%d%s", index, nl,nl, img->m_Hotspot.x, nl,nl, img->m_Hotspot.y, nl);
				for(map<CString, CPoint>::iterator a = img->m_Action.begin(); a!= img->m_Action.end(); a++)
				{
					Info.Format("%s%s%s%d%s%d%s", Info, a->first, nl, a->second.x, nl, a->second.y, nl);
				}
				Info += nl;
				File.Write((const char*)Info, Info.GetLength() * sizeof(char));


			}
		}
		File.Close();

		CString LaunchPath;
		LaunchPath.Format("%sImages\\", Path.GetFullPath());

		ShellExecute(NULL,  "open", LaunchPath, NULL, NULL, SW_SHOW);

		int result = MessageBox("Click 'OK' to reimport the images that have been exported to Explorer.", "Construct", MB_OKCANCEL);

		if(result == IDOK)
		{
			int result2 = MessageBox("Import collision mask?", "Construct", MB_YESNOCANCEL);
			int index = 0;
			for(vector<int>::iterator i = m_pCurrentAnimation->m_Images.begin(); i!= m_pCurrentAnimation->m_Images.end(); i++)
			{
				index ++;
				CImageResource* img = application->resources.FindImageResourceFromNumber(*i);
			
				CString SavePath;
				SavePath.Format("%sImages\\Frame %d.png", Path.GetFullPath(), index);			
				
				img->bitmap.Load(SavePath,CXIMAGE_FORMAT_PNG);
				img->Premultiply();

				if(result2 == IDYES)
				{
				SavePath.Format("%sImages\\Mask %d.png", Path.GetFullPath(), index);			
				img->m_Collision.Load(SavePath,CXIMAGE_FORMAT_PNG);
				}
				if(result2 == IDNO)
				{
					if(img->m_Collision.IsValid())
						img->m_Collision.Destroy();
				}

				application->m_image_to_texture.erase(img->m_FixedID);

				img->small_thumbnail.Destroy();
				img->large_thumbnail.Destroy();
			}

			application->resources.images_changed = true;

			AnimationHasChanged();
			UpdateFilmStrip();
		}
	}

	else if (ChosenItem == 8)
	{
		// mirror
		POSITION position = film_strip.GetFirstSelectedItemPosition();

		if(!m_pCurrentAnimation)
			return;

		vector<int>& images = m_pCurrentAnimation->m_Images;

		while(position)
		{
			int item = film_strip.GetNextSelectedItem(position);

			if (item == -1) break;

			CImageResource* image = application->resources.FindImageResourceFromNumber(images[item]);
			image->Mirror();

			application->resources.images_changed = true;
		}

		AnimationHasChanged();
		UpdateFilmStrip();
	}

	else if (ChosenItem == 9)
	{
		// mirror
		POSITION position = film_strip.GetFirstSelectedItemPosition();

		if(!m_pCurrentAnimation)
			return;

		vector<int>& images = m_pCurrentAnimation->m_Images;

		while(position)
		{
			int item = film_strip.GetNextSelectedItem(position);

			if (item == -1) break;

			CImageResource* image = application->resources.FindImageResourceFromNumber(images[item]);
			image->Flip();

			application->resources.images_changed = true;
		}

		AnimationHasChanged();
		UpdateFilmStrip();
	}
}