示例#1
0
bool
Action::ValueDescConnect::is_candidate(const ParamList &x)
{
	if(candidate_check(get_param_vocab(),x))
	{
	    ValueDesc value_desc(x.find("dest")->second.get_value_desc());
	    ValueNode::Handle value_node(x.find("src")->second.get_value_node());

	    //! forbid recursive linking (fix #48)
	    if (value_desc.parent_is_value_node())
	    {
	        ValueNode* vn = dynamic_cast<ValueNode*>(value_node.get());
	        if (vn && vn->is_descendant(value_desc.get_parent_value_node()))
	            return false;
	    }


		// don't show the option of connecting to an existing Index parameter of the Duplicate layer
		if(x.count("dest"))
		{
			if (value_desc.parent_is_layer() &&
				value_desc.get_layer()->get_name() == "duplicate" &&
				value_desc.get_param_name() == "index")
				return false;
		}

		if(x.count("src"))
		{
			if(value_desc.get_value_type()==value_node->get_type())
				return true;
		}
		return true;
	}
	return false;
}
示例#2
0
bool
Action::ValueDescConnect::is_candidate(const ParamList &x)
{
    if(candidate_check(get_param_vocab(),x))
    {
        // don't show the option of connecting to an existing Index parameter of the Duplicate layer
        if(x.count("dest"))
        {
            ValueDesc value_desc=x.find("dest")->second.get_value_desc();

            if (value_desc.parent_is_layer() &&
                    value_desc.get_layer()->get_name() == "duplicate" &&
                    value_desc.get_param_name() == "index")
                return false;
        }

        if(x.count("src"))
        {
            ValueDesc value_desc=x.find("dest")->second.get_value_desc();
            ValueNode::Handle value_node=x.find("src")->second.get_value_node();
            if(value_desc.get_value_type()==value_node->get_type())
                return true;
        }
        return true;
    }
    return false;
}
bool
Action::ValueNodeConstUnSetStatic::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueNode::Handle value_node;
	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

	if(value_desc.parent_is_value_node_const() || value_desc.parent_is_linkable_value_node())
		value_node = value_desc.get_value_node();
	else
		value_node = x.find("value_node")->second.get_value_node();
	// Don't allow to unset static to lower and upper boundaries of the WidhtPoint
	if(value_desc.parent_is_linkable_value_node()
		&& value_desc.get_parent_value_node()->get_name()=="composite"
		&& value_desc.get_parent_value_node()->get_type()==ValueBase::TYPE_WIDTHPOINT
		&& (value_desc.get_index()==4 || value_desc.get_index()==5))
		return false;
	// We need a constant value node or a constant layer param.
	return (
			(ValueNode_Const::Handle::cast_dynamic(value_node) &&
			// We need the constant value node to be static.
			ValueNode_Const::Handle::cast_dynamic(value_node)->get_static())
			);
}
示例#4
0
//--------------------------------------------------------------------------------//
void LinuxInputManager::_parseConfigSettings( ParamList &paramList )
{
	ParamList::iterator i = paramList.find("WINDOW");
	if( i == paramList.end() ) 
		OIS_EXCEPT( E_InvalidParam, "LinuxInputManager >> No WINDOW!" );

	//TODO 64 bit proof this little conversion xxx wip
	window  = strtoul(i->second.c_str(), 0, 10);

	//--------- Keyboard Settings ------------//
	i = paramList.find("XAutoRepeatOn");
	if( i != paramList.end() )
		if( i->second == "true" )
			useXRepeat = true;

	i = paramList.find("x11_keyboard_grab");
	if( i != paramList.end() )
		if( i->second == "false" )
			grabKeyboard = false;

	//--------- Mouse Settings ------------//
	i = paramList.find("x11_mouse_grab");
	if( i != paramList.end() )
		if( i->second == "false" )
			grabMouse = false;

	i = paramList.find("x11_mouse_hide");
	if( i != paramList.end() )
		if( i->second == "false" )
			hideMouse = false;
}
bool
Action::TimepointsMove::is_candidate(const ParamList &x)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;

	if(	x.find("addlayer") == x.end() &&
		x.find("addcanvas") == x.end() &&
		x.find("addvaluedesc") == x.end())
		return false;
	return true;
}
//----------------------------------------------------------------------------
void Win32InputManager::Initialize (ParamList &paramList)
{
	HINSTANCE hInst = 0;
	HRESULT hr;

	ParamList::iterator i = paramList.find("Window");
	if (i == paramList.end()) 
	{
		assertion(false, 
			"Win32InputManager::Win32InputManager >> No HWND found!");
	}

	unsigned __int64 handle = _strtoui64(i->second.c_str(), 0, 10);
	mhWnd = (HWND)handle;

	if (IsWindow(mhWnd) == 0)
	{
		assertion(false, "The sent HWND is not valid!");
	}

	hInst = GetModuleHandle(0);

	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, 
		(VOID**)&mDirectInput, 0 );
	if (FAILED(hr))
	{
		assertion(false, "Not able to init DirectX8 Input!");
	}

	ParseConfigSettings(paramList);
	EnumerateDevices();
}
//--------------------------------------------------------------------------------//
void Win32InputManager::_initialize( ParamList &paramList )
{
    HINSTANCE hInst = 0;
    HRESULT hr;

    //TODO 64 bit proof this little conversion xxx wip
    //First of all, get the Windows Handle and Instance
    ParamList::iterator i = paramList.find("WINDOW");
    if( i == paramList.end() )
        OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );

#ifdef _MSC_VER
#pragma warning(disable:4312)
#endif
    hWnd  = (HWND)strtoul(i->second.c_str(), 0, 10);
#ifdef _MSC_VER
#pragma warning(default:4312)
#endif

    hInst = GetModuleHandle(0);

    //Create the device
    hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
    if (FAILED(hr))
        OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input");

    //Ok, now we have DirectInput, parse whatever extra settings were sent to us
    _parseConfigSettings( paramList );
    _enumerateDevices();
}
bool
Action::ValueNodeDynamicListRemoveSmart::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
	bool parent_is_dynamic_list(
			value_desc.parent_is_value_node() &&
			ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())
			);
	if(!parent_is_dynamic_list)
	{
		// Let's check if we are selecting a composite child
		if(value_desc.parent_is_value_node())
		{
			ValueNode::Handle compo(ValueNode_Composite::Handle::cast_dynamic(value_desc.get_parent_value_node()));
			if(compo)
			{
				ValueNode_DynamicList::Handle parent_list=NULL;
				std::set<Node*>::iterator iter;
				// now check if the composite parent is a dynamic list type
				for(iter=compo->parent_set.begin();iter!=compo->parent_set.end();++iter)
					{
						parent_list=ValueNode_DynamicList::Handle::cast_dynamic(*iter);
						if(parent_list)
							break;
					}
				if(parent_list)
					parent_is_dynamic_list=true;
			}
		}
	}
	return (parent_is_dynamic_list);
}
bool
Action::candidate_check(const ParamVocab& param_vocab, const ParamList& param_list)
{
	ParamVocab::const_iterator iter;

	for(iter=param_vocab.begin();iter!=param_vocab.end();++iter)
	{
		int n(param_list.count(iter->get_name()));

//		if(n && !iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
//			return false;

		if(!n && !iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
			continue;

		if(iter->get_user_supplied() || iter->get_optional())
			continue;

		if(n==0)
			return false;
		if(n==1 && iter->get_requires_multiple())
			return false;
		if(n>1 && !iter->get_supports_multiple())
			return false;

		if(iter->get_type()!=param_list.find(iter->get_name())->second.get_type())
			return false;
	}
	return true;
}
示例#10
0
bool
Action::LayerEmbed::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x)) return false;

	Layer::Handle layer=x.find("layer")->second.get_layer();
	if(!layer) return false;

	etl::handle<synfig::Layer_PasteCanvas> layer_pastecanvas
		= etl::handle<synfig::Layer_PasteCanvas>::cast_dynamic(layer);
	if (layer_pastecanvas)
	{
		Canvas::Handle canvas = layer_pastecanvas->get_sub_canvas();;
		if (canvas && canvas->is_root())
			return true;
	}

	Layer::Handle layer_import = layer;
	if (layer_import->get_param_list().count("filename") != 0)
	{
		String filename = layer_import->get_param("filename").get(String());
		// TODO: literal "container:"
		if (!filename.empty()
		  && filename.substr(0, String("#").size()) != "#"
	      && layer_import->dynamic_param_list().count("filename") == 0)
			return true;
	}

	return false;
}
示例#11
0
//--------------------------------------------------------------------------------//
void Win32InputManager::_initialize( ParamList &paramList )
{
	HINSTANCE hInst = 0;
	HRESULT hr;


	//First of all, get the Windows Handle and Instance
	ParamList::iterator i = paramList.find("WINDOW");
	if( i == paramList.end() )
		OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );

	// Get number as 64 bit and then convert. Handles the case of 32 or 64 bit HWND
	unsigned __int64 handle = _strtoui64(i->second.c_str(), 0, 10);
	hWnd  = (HWND)handle;

	if( IsWindow(hWnd) == 0 )
		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> The sent HWND is not valid!");

	hInst = GetModuleHandle(0);

	//Create the device
	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
    if (FAILED(hr))
		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");

	//Ok, now we have DirectInput, parse whatever extra settings were sent to us
	_parseConfigSettings( paramList );

	// Enumerate devices ...
	_enumerateDevices();
}
示例#12
0
bool
Action::LayerEmbed::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x)) return false;

	Layer::Handle layer=x.find("layer")->second.get_layer();
	if(!layer) return false;

	etl::handle<synfig::Layer_PasteCanvas> layer_pastecanvas
		= etl::handle<synfig::Layer_PasteCanvas>::cast_dynamic(layer);
	if (layer_pastecanvas)
	{
		Canvas::Handle canvas = layer_pastecanvas->get_sub_canvas();;
		if (canvas && canvas->is_root())
			return true;
	}

	Layer::Handle layer_import = layer;
	if (layer_import->get_param_list().count("filename") != 0)
	{
		String filename = layer_import->get_param("filename").get(String());
		if ( !CanvasFileNaming::is_embeded(filename)
	      && !layer_import->dynamic_param_list().count("filename") )
			return true;
	}

	return false;
}
示例#13
0
bool
Action::ValueDescDisconnect::is_candidate(const ParamList &x)
{
    if (!candidate_check(get_param_vocab(),x))
        return false;

    ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

    // don't allow Bone ValueNodes to be disconnected
    if(getenv("SYNFIG_DISALLOW_BONE_DISCONNECT") &&
            value_desc.is_value_node() &&
            ValueNode_Bone::Handle::cast_dynamic(value_desc.get_value_node()))
        return false;
    // don't allow the Index parameter of the Duplicate layer to be disconnected
    if(value_desc.parent_is_layer() && value_desc.get_layer()->get_name() == "duplicate" && value_desc.get_param_name() == "index")
        return false;
    if(!value_desc.parent_is_canvas() && value_desc.is_value_node() && value_desc.get_value_node()->rcount()>1)
        return true;
    if(value_desc.is_const())
        return false;
    if(value_desc.is_value_node() && ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node()))
        return false;
    // don't allow Duplicate ValueNodes in the Children dialog to be disconnected
    if(value_desc.is_value_node() &&
            ValueNode_Duplicate::Handle::cast_dynamic(value_desc.get_value_node()) &&
            !value_desc.parent_is_layer() &&
            !value_desc.parent_is_value_node())
        return false;
    return true;
}
示例#14
0
//--------------------------------------------------------------------------------//
void MacInputManager::_parseConfigSettings( ParamList &paramList )
{
    // Some carbon apps are running in a window, however full screen apps
	// do not have a window, so we need to account for that too.
	ParamList::iterator i = paramList.find("WINDOW");
	if(i != paramList.end())
	{
		mWindow = (WindowRef)strtoul(i->second.c_str(), 0, 10);
		if(mWindow == 0)
		{
			mWindow = NULL;
			mEventTargetRef = GetApplicationEventTarget();
		}
		else
		{
			//mEventTargetRef = GetWindowEventTarget(mWindow);
			mEventTargetRef = GetApplicationEventTarget();
		}
    }
	else
	{
		// else get the main active window.. user might not have access to it through some
		// graphics libraries, if that fails then try at the application level.
		mWindow = ActiveNonFloatingWindow();
		if(mWindow == NULL)
		{
			mEventTargetRef = GetApplicationEventTarget();
		}
		else
		{
			//mEventTargetRef = GetWindowEventTarget(mWindow);
			mEventTargetRef = GetApplicationEventTarget();
		}
	}
	
	if(mEventTargetRef == NULL)
		OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" );
    
    // Keyboard
    if(paramList.find("MacAutoRepeatOn") != paramList.end())
	{
        if(paramList.find("MacAutoRepeatOn")->second == "true")
		{
            mUseRepeat = true;
        }
    }
}
示例#15
0
bool
Action::WaypointAdd::is_candidate(const ParamList &x)
{
	return (candidate_check(get_param_vocab(),x) &&
			// We need an animated valuenode.
			ValueNode_Animated::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()) &&
			// We need either a waypoint or a time.
			(x.count("waypoint") || x.count("time")));
}
示例#16
0
bool
Action::LayerRaise::is_candidate(const ParamList &x)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;
	if(x.find("layer")->second.get_layer()->get_depth()==0)
		return false;
	return true;
}
示例#17
0
bool
Action::ValueNodeRename::is_candidate(const ParamList &x)
{
	if(candidate_check(get_param_vocab(),x))
	{
		if(x.find("value_node")->second.get_value_node()->is_exported())
			return true;
	}
	return false;
}
void AndroidInputManager::_initialize( ParamList &paramList )
{
        ParamList::iterator i = paramList.find("WINDOW");
        if(i != paramList.end())
        {
                size_t whandle = strtoul(i->second.c_str(), 0, 10);            
    }

        //TODO: setup window
}
bool
Action::ValueNodeConstSet::is_candidate(const ParamList &x)
{
	if(candidate_check(get_param_vocab(),x))
	{
		if(ValueNode_Const::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()))
			return true;
	}
	return false;
}
bool
Action::BLinePointTangentSplit::is_candidate(const ParamList &x)
{
    if(candidate_check(get_param_vocab(),x))
    {
        ValueNode_Composite::Handle value_node;
        value_node=ValueNode_Composite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node());
        if(!value_node || value_node->get_type()!=ValueBase::TYPE_BLINEPOINT)
        {
            // Before return false, let's check whether the value_node
            // is radial composite and vector type
            ValueNode_RadialComposite::Handle radial_value_node;
            radial_value_node=ValueNode_RadialComposite::Handle::cast_dynamic(x.find("value_node")->second.get_value_node());
            if(radial_value_node && radial_value_node->get_type()==ValueBase::TYPE_VECTOR)
                // value_node is radial composite and vector (user rigth click on a tangent)
            {
                ValueNode_Composite::Handle blinepoint=NULL;
                std::set<Node*>::iterator iter;
                // now check if the parent of radial_value_node is a blinepoint type
                for(iter=radial_value_node->parent_set.begin(); iter!=radial_value_node->parent_set.end(); ++iter)
                {
                    blinepoint=ValueNode_Composite::Handle::cast_dynamic(*iter);
                    if(blinepoint && blinepoint->get_type()==ValueBase::TYPE_BLINEPOINT)
                        break;
                }
                if(blinepoint)
                    value_node=blinepoint;
            }
        }
        // at this point we should have a value node and it should be blinepoint
        // if we haven't, then return false
        if(!value_node || value_node->get_type()!=ValueBase::TYPE_BLINEPOINT)
            return false;
        synfig::Time time(x.find("time")->second.get_time());
        bool split_radius=(*value_node->get_link("split_radius"))(time).get(bool());
        bool split_angle=(*value_node->get_link("split_angle"))(time).get(bool());
        if(split_radius==true || split_angle==true)
            return false;
        return true;
    }
    return false;
}
bool
Action::ValueDescBLineLink::is_candidate(const ParamList &x)
{
	ParamList::const_iterator i;

	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
	ValueDesc selected_value_desc(x.find("selected_value_desc")->second.get_value_desc());

	//! if the valuedesc belong to the spline, can't link.
	if(value_desc.parent_is_value_node() && selected_value_desc.parent_is_value_node() &&
	        value_desc.get_parent_value_node() == selected_value_desc.get_parent_value_node())
	    return false;

	return (value_desc.parent_is_value_node() &&
			// We need a dynamic list.
			ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()));
}
示例#22
0
bool
Action::ActivepointSetOff::is_candidate(const ParamList &x)
{
    if (!candidate_check(get_param_vocab(),x))
        return false;

    ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

    if (!(value_desc.parent_is_value_node() &&
            // We need a dynamic list.
            ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node())))
        return false;

    Canvas::Handle canvas(x.find("canvas")->second.get_canvas());

    // We are only a candidate if this canvas is animated.
    return (canvas->rend_desc().get_time_start() != canvas->rend_desc().get_time_end() &&
            // We need either an activepoint or a time.
            (x.count("activepoint") || x.count("time")));
}
示例#23
0
bool
Action::LayerAddFrame::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x)) return false;

	Layer::Handle layer=x.find("layer")->second.get_layer();
	if(!layer) return false;

	if (!etl::handle<Layer_Switch>::cast_dynamic(layer)) return false;

	return true;
}
bool
Action::ValueNodeConstSetStatic::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueNode::Handle value_node;
	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

	if(value_desc.parent_is_value_node_const() || value_desc.parent_is_linkable_value_node())
		value_node = value_desc.get_value_node();
	else
		value_node = x.find("value_node")->second.get_value_node();

	// We need a constant value node or a constant layer param.
	return (
			(ValueNode_Const::Handle::cast_dynamic(value_node) &&
			// We need the constant value node to be not static.
			!ValueNode_Const::Handle::cast_dynamic(value_node)->get_static())
			);
}
示例#25
0
bool
Action::LayerLower::is_candidate(const ParamList &x)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;

	Layer::Handle layer(x.find("layer")->second.get_layer());
	//synfig::info("layer->get_depth()= %d ; layer->get_canvas()->size()=%d ;",layer->get_depth(),layer->get_canvas()->size());
	if(layer->get_depth()+1>=layer->get_canvas()->size())
		return false;
	return true;
}
bool
Action::ValueNodeDynamicListRemove::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

	return (value_desc.parent_is_value_node() &&
			// We need a dynamic list.
			ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()));
}
示例#27
0
bool
Action::ValueNodeStaticListLoop::is_candidate(const ParamList &x)
{
	if (!candidate_check(get_param_vocab(),x))
		return false;

	ValueNode::Handle value_node;
	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

	if(value_desc.parent_is_value_node())
		value_node = value_desc.get_parent_value_node();
	else
		value_node = x.find("value_node")->second.get_value_node();

	ValueNode_StaticList::Handle static_list;
	// We need a static list
	return ((static_list = ValueNode_StaticList::Handle::cast_dynamic(value_node)) &&
			// We need the list not to be a list of bones
			static_list->get_contained_type() != type_bone_object &&
			// We need the list not to be looped
			!static_list->get_loop());
}
示例#28
0
bool
Action::ActivepointSimpleAdd::is_candidate(const ParamList &x)
{
	if(candidate_check(get_param_vocab(),x))
	{
		ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
		if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
			return false;

		return true;
	}
	return candidate_check(get_param_vocab(),x);
}
示例#29
0
bool
Action::ValueDescSkeletonLink::is_candidate(const ParamList &x)
{
	ParamList::const_iterator i;

	ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());

	if (!candidate_check(get_param_vocab(),x))
		return false;

	return value_desc.parent_is_value_node()
		&& ValueNode_Bone::Handle::cast_dynamic(value_desc.get_parent_value_node());
}
示例#30
0
bool
Action::LayerResetPose::is_candidate(const ParamList &x)
{
	if(!candidate_check(get_param_vocab(),x))
		return false;

	for(ParamList::const_iterator i = x.find("layer"); i != x.end() && i->first == "layer"; ++i)
		if (i->second.get_type()==Param::TYPE_LAYER
		 && i->second.get_layer()->get_name() == "skeleton_deformation")
			return true;

	return false;
}