summaryrefslogtreecommitdiff
path: root/tools/toolutils/basepropertiescontainer.cpp
blob: 50891a9a2e09686b2bb16f7ac8627365803792e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

#include "toolutils/basepropertiescontainer.h"
#include "tier1/KeyValues.h"

CBasePropertiesContainer::CBasePropertiesContainer( vgui::Panel *parent, IDmNotify *pNotify, CDmeEditorTypeDictionary *pDict /*=NULL*/ )
	: BaseClass( parent, pNotify, NULL, true, pDict )
{
	SetDropEnabled( true );
}

bool CBasePropertiesContainer::IsDroppable( CUtlVector< KeyValues * >& msglist )
{
	if ( msglist.Count() != 1 )
		return false;

	KeyValues *data = msglist[ 0 ];
	CDmElement *ptr = reinterpret_cast< CDmElement * >( g_pDataModel->GetElement( DmElementHandle_t( data->GetInt( "dmeelement", DMELEMENT_HANDLE_INVALID ) ) ) );
	if ( !ptr )
		return false;

	if ( ptr == GetObject() )
		return false;

	return true;
}

void CBasePropertiesContainer::OnPanelDropped( CUtlVector< KeyValues * >& msglist )
{
	if ( msglist.Count() != 1 )
		return;

	KeyValues *data = msglist[ 0 ];
	CDmElement *ptr = reinterpret_cast< CDmElement * >( g_pDataModel->GetElement( DmElementHandle_t( data->GetInt( "dmeelement", DMELEMENT_HANDLE_INVALID ) ) ) );
	if ( !ptr )
		return;

	// Already browsing
	if ( ptr == GetObject() )
		return;

	SetObject( ptr );
}