예제 #1
0
//只改变位置不改变大小
void CUIEditorView::moveWindow(CPoint point,CPoint step,CEGUI::Window* pWin/* = NULL*/)
{
	CEGUI::Window* pWindow =  pWin ? pWin : m_pSelectedWindow;
	if (pWindow)
	{
		//方向键操作
		if ( step.x != 0 || step.y != 0 )
		{
			CEGUI::Point pos = pWindow->getAbsolutePosition();
			pos.d_x += step.x;
			pos.d_y += step.y;
			pWindow->setPosition(CEGUI::Absolute, pos);
		}
		//鼠标操作
		else
		{
			CEGUI::Window* pParent = pWindow;
			CEGUI::Point pt = CEGUI::Point(point.x, point.y);
			if (pWindow->getParent() == CEGUI::System::getSingleton().getGUISheet())
			{
				pParent = pWindow->getParent();
				CEGUI::Point pointWindow = pWindow->getPixelRect().getPosition();
				//初始化位置
				if(m_ptMouseMovePos.x == 0 && m_ptMouseMovePos.y == 0)
				{
					m_ptMouseMovePos.x = point.x -  pointWindow.d_x;
					m_ptMouseMovePos.y = point.y -  pointWindow.d_y;
				}
				pt.d_x -= m_ptMouseMovePos.x;
				pt.d_y -= m_ptMouseMovePos.y;
			}
			else
			{
				while (pParent && pParent->getParent() != CEGUI::System::getSingleton().getGUISheet())
				{
					pParent = pParent->getParent();
				}
				CEGUI::Point pointParent = pParent->getPixelRect().getPosition();
				CEGUI::Point pointWindow = pWindow->getPixelRect().getPosition();
				//初始化位置
				if(m_ptMouseMovePos.x == 0 && m_ptMouseMovePos.y == 0)
				{
					m_ptMouseMovePos.x = point.x -  pointWindow.d_x;
					m_ptMouseMovePos.y = point.y -  pointWindow.d_y;
				}
				pt = CEGUI::Point(point.x-pointParent.d_x /*+pointWindow.d_x*/ - m_ptMouseMovePos.x, 
					point.y - pointParent.d_y/* +pointWindow.d_y*/ - m_ptMouseMovePos.y);
			}
			pWindow->setClippedByParent(true);
			pWindow->setPosition(CEGUI::Absolute, pt);
		}
	}
}
예제 #2
0
void CUIEditorView::setWindowSelected(const CEGUI::String& name,bool addEvent /*= true*/)
{
	try
	{
		if( name.length()> 0 && name != m_nSelectWindowName)
		{
			if(name == "___Shower_Window____") return;
			CEGUI::Window* pWindow = CEGUI::WindowManager::getSingleton().getWindow(name);
			CEGUI::Window* pOldSel = NULL;
			if (pWindow && !pWindow->isAutoWindow())
			{
				if(m_nSelectWindowName.length() > 0)
				{
					pOldSel = CEGUI::WindowManager::getSingleton().getWindow(m_nSelectWindowName);
					if (pOldSel)
					{
						for(;pOldSel && pOldSel != CEGUI::System::getSingleton().getGUISheet(); pOldSel = pOldSel->getParent())
						{
							pOldSel->unsubscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this));
						}
					}
				}
				//pWindow->moveToFront();
				m_nSelectWindowName = pWindow->getName();
				CEGUI::Window* pSet = pWindow;
				for (; pSet&& pSet !=CEGUI::System::getSingleton().getGUISheet(); pSet = pSet->getParent() )
				{
					pSet->subscribeEvent(CEGUI::Window::EventMoved, CEGUI::Event::Subscriber(&CUIEditorView::handleSelectedWindowMoved, this));
				}
				CEGUI::Rect rect = pWindow->getPixelRect();
				setSelectWindowPos(CRect(rect.d_left, rect.d_top, rect.getWidth(), rect.getHeight()));
				m_ptMouseMovePos = CPoint(0,0);			
			}
			m_pSelectedWindow = pWindow;
			updateCurrentWindowStatusText();
			if (addEvent)
			{
				g_DataPool.OnSelectWindowChanged(pOldSel,pWindow);
			}
		}
		else if (name.length() == 0)
		{
			if (addEvent)
			{
				g_DataPool.OnSelectWindowChanged(m_pSelectedWindow,NULL);
			}
			m_nSelectWindowName = "";
			setSelectWindowPos(CRect(), true);
			m_pSelectedWindow = NULL;
		}
	}
	catch(CEGUI::UnknownObjectException& e)
	{
		
	}
}
예제 #3
0
//只改变大小,不改变位置
void CUIEditorView::sizingWindow(CPoint point,INT type,CEGUI::Window* pWin/* = NULL*/)
{
	CEGUI::Window* pWindow =  pWin ? pWin : m_pSelectedWindow;
	if (pWindow)
	{
		CEGUI::Window* pParent = pWindow;
		CEGUI::Size pt(0,0);
		if (pWindow->getParent() == CEGUI::System::getSingleton().getGUISheet())
		{
			CEGUI::Point pos = pWindow->getPixelRect().getPosition();
			pt = CEGUI::Size(point.x - pos.d_x, point.y - pos.d_y);
		}
		else
		{
			while (pParent && pParent->getParent() != CEGUI::System::getSingleton().getGUISheet())
			{
				pParent = pParent->getParent();
			}
			CEGUI::Rect	 rectWindow = pWindow->getPixelRect();
			pt = CEGUI::Size(point.x -rectWindow.getPosition().d_x   ,point.y -rectWindow.getPosition().d_y);
		}
		pWindow->setClippedByParent(true);
		if(type == 0)
		{
			pWindow->setHeight(CEGUI::Absolute,pt.d_height);
		}
		else if (type == 1)
		{
			pWindow->setWidth(CEGUI::Absolute,pt.d_width);
		}
		else
		{
			pWindow->setSize(CEGUI::Absolute, pt);
		}
	}
}