Addd method implementation in serializers
This commit is contained in:
parent
d8adc80c2c
commit
0b5b3213fe
@ -249,8 +249,6 @@ protected:
|
||||
typedef CLASS MyClass; \
|
||||
void wrapper_propfunc_##NAME(const char* domain, osgDB::ObjectWrapper* wrapper)
|
||||
|
||||
#define ADD_METHOD_OBJECT( METHODNAME, METHODOBJECTCLASS ) wrapper->addMethodObject(METHODNAME, new METHODOBJECTCLASS());
|
||||
|
||||
class OSGDB_EXPORT RegisterCompressorProxy
|
||||
{
|
||||
public:
|
||||
|
@ -1703,6 +1703,22 @@ public:
|
||||
#define REMOVE_SERIALIZER(PROP) \
|
||||
wrapper->markSerializerAsRemoved( #PROP );
|
||||
|
||||
#define ADD_METHOD_OBJECT( METHODNAME, METHODOBJECTCLASS ) wrapper->addMethodObject(METHODNAME, new METHODOBJECTCLASS());
|
||||
|
||||
#define ADD_METHOD(METHODNAME) \
|
||||
{ \
|
||||
struct MethodCaller : public osgDB::MethodObject \
|
||||
{ \
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const \
|
||||
{ \
|
||||
MyClass* obj = reinterpret_cast<MyClass*>(objectPtr); \
|
||||
obj->METHODNAME(); \
|
||||
return true; \
|
||||
} \
|
||||
}; \
|
||||
wrapper->addMethodObject(#METHODNAME, new MethodCaller()); \
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -37,6 +37,13 @@ public:
|
||||
virtual void enterImplementation();
|
||||
virtual void leaveImplementation();
|
||||
|
||||
virtual void pressed() { if (!runCallbacks("pressed")) pressedImplementation(); }
|
||||
virtual void pressedImplementation();
|
||||
|
||||
virtual void released() { if (!runCallbacks("released")) releasedImplementation(); }
|
||||
virtual void releasedImplementation();
|
||||
|
||||
|
||||
protected:
|
||||
virtual ~PushButton() {}
|
||||
|
||||
|
@ -40,15 +40,13 @@ bool PushButton::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* eve
|
||||
case(osgGA::GUIEventAdapter::PUSH):
|
||||
if (_buttonSwitch.valid())
|
||||
{
|
||||
_buttonSwitch->setSingleChildOn(2);
|
||||
runCallbacks("pressed");
|
||||
pressed();
|
||||
}
|
||||
break;
|
||||
case(osgGA::GUIEventAdapter::RELEASE):
|
||||
if (_buttonSwitch.valid())
|
||||
{
|
||||
_buttonSwitch->setSingleChildOn(1);
|
||||
runCallbacks("released");
|
||||
released();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -107,3 +105,13 @@ void PushButton::createGraphicsImplementation()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void PushButton::pressedImplementation()
|
||||
{
|
||||
_buttonSwitch->setSingleChildOn(2);
|
||||
}
|
||||
|
||||
void PushButton::releasedImplementation()
|
||||
{
|
||||
_buttonSwitch->setSingleChildOn(1);
|
||||
}
|
||||
|
@ -11,4 +11,8 @@ REGISTER_OBJECT_WRAPPER( PushButton,
|
||||
"osg::Object osg::Node osg::Group osgUI::Widget osgUI::PushButton" )
|
||||
{
|
||||
ADD_STRING_SERIALIZER( Text, std::string());
|
||||
ADD_METHOD( pressed );
|
||||
ADD_METHOD( pressedImplementation );
|
||||
ADD_METHOD( released );
|
||||
ADD_METHOD( releasedImplementation );
|
||||
}
|
||||
|
@ -5,67 +5,6 @@
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
|
||||
struct CreateGraphics : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
|
||||
widget->createGraphics();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct CreateGraphicsImplementation : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
|
||||
widget->createGraphicsImplementation();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct Enter : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
|
||||
widget->enter();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct EnterImplementation : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
|
||||
widget->enterImplementation();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct Leave : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
|
||||
widget->leave();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct LeaveImplementation : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
|
||||
widget->leaveImplementation();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Traverse : public osgDB::MethodObject
|
||||
{
|
||||
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters&) const
|
||||
@ -137,14 +76,14 @@ REGISTER_OBJECT_WRAPPER( Widget,
|
||||
ADD_OBJECT_SERIALIZER( TextSettings, osgUI::TextSettings, NULL );
|
||||
|
||||
|
||||
ADD_METHOD_OBJECT( "createGraphics", CreateGraphics );
|
||||
ADD_METHOD_OBJECT( "createGraphicsImplementation", CreateGraphicsImplementation );
|
||||
ADD_METHOD( createGraphics );
|
||||
ADD_METHOD( createGraphicsImplementation );
|
||||
|
||||
ADD_METHOD_OBJECT( "enter", Enter );
|
||||
ADD_METHOD_OBJECT( "enterImplementation", EnterImplementation );
|
||||
ADD_METHOD( enter );
|
||||
ADD_METHOD( enterImplementation );
|
||||
|
||||
ADD_METHOD_OBJECT( "leave", Leave );
|
||||
ADD_METHOD_OBJECT( "leaveImplementation", LeaveImplementation );
|
||||
ADD_METHOD( leave );
|
||||
ADD_METHOD( leaveImplementation );
|
||||
|
||||
ADD_METHOD_OBJECT( "traverse", Traverse );
|
||||
ADD_METHOD_OBJECT( "traverseImplementation", TraverseImplementation );
|
||||
|
Loading…
Reference in New Issue
Block a user