Exemplo n.º 1
0
bool TabStrip::DragAndDrop_HandleDrop(Gwen::DragAndDrop::Package* /*pPackage*/, int x, int y)
{
	Gwen::Point LocalPos = CanvasPosToLocal(Gwen::Point(x, y));

	Base* el = DragAndDrop::SourceControl;

	TabButton* pButton = el ? el->DynamicCastTabButton() : 0;
	TabControl* pTabControl = GetParent() ? GetParent()->DynamicCastTabControl() : 0;
	if (pTabControl && pButton)
	{
		if (pButton->GetTabControl() != pTabControl)
		{
			// We've moved tab controls!
			pTabControl->AddPage(pButton);
		}
	}

	Base* DroppedOn = GetControlAt(LocalPos.x, LocalPos.y);
	if (DroppedOn)
	{
		Gwen::Point DropPos = DroppedOn->CanvasPosToLocal(Gwen::Point(x, y));
		DragAndDrop::SourceControl->BringNextToControl(DroppedOn, DropPos.x > DroppedOn->Width() / 2);
	}
	else
	{
		DragAndDrop::SourceControl->BringToFront();
	}
	return true;
}
Exemplo n.º 2
0
void TabStrip::DragAndDrop_Hover( gwen::DragAndDrop::Package* /*pPackage*/, int x, int y )
{
	gwen::Point LocalPos = CanvasPosToLocal( gwen::Point( x, y ) );
	Base* DroppedOn = GetControlAt( LocalPos.x, LocalPos.y );

	if ( DroppedOn && DroppedOn != this )
	{
		gwen::Point DropPos = DroppedOn->CanvasPosToLocal( gwen::Point( x, y ) );
		m_TabDragControl->SetBounds( gwen::Rect( 0, 0, 3, Height() ) );
		m_TabDragControl->BringToFront();
		m_TabDragControl->SetPos( DroppedOn->X() - 1, 0 );

		if ( DropPos.x > DroppedOn->Width() / 2 )
		{
			m_TabDragControl->MoveBy( DroppedOn->Width() - 1, 0 );
		}

		m_TabDragControl->Dock( Pos::None );
	}
	else
	{
		m_TabDragControl->Dock( Pos::Left );
		m_TabDragControl->BringToFront();
	}
}