Added beginnings of new osgUI library, a replacement for osgWidget that works fully in 3D/stereo and is scriptable.

This commit is contained in:
Robert Osfield
2014-05-12 11:27:54 +00:00
parent 490b351330
commit ead92353fe
27 changed files with 1438 additions and 9 deletions

View File

@@ -50,3 +50,4 @@ ADD_SUBDIRECTORY(osgText)
ADD_SUBDIRECTORY(osgVolume)
ADD_SUBDIRECTORY(osgPresentation)
ADD_SUBDIRECTORY(osgViewer)
ADD_SUBDIRECTORY(osgUI)

View File

@@ -0,0 +1,31 @@
#include <osgUI/AlignmentSettings>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( AlignmentSettings,
new osgUI::AlignmentSettings,
osgUI::AlignmentSettings,
"osg::Object osgUI::AlignmentSettings" )
{
BEGIN_ENUM_SERIALIZER2( Alignment, osgUI::AlignmentSettings::Alignment, LEFT_BOTTOM );
ADD_ENUM_VALUE( LEFT_TOP );
ADD_ENUM_VALUE( LEFT_CENTER );
ADD_ENUM_VALUE( LEFT_BOTTOM );
ADD_ENUM_VALUE( CENTER_TOP );
ADD_ENUM_VALUE( CENTER_CENTER );
ADD_ENUM_VALUE( CENTER_BOTTOM );
ADD_ENUM_VALUE( RIGHT_TOP );
ADD_ENUM_VALUE( RIGHT_CENTER );
ADD_ENUM_VALUE( RIGHT_BOTTOM );
ADD_ENUM_VALUE( LEFT_BASE_LINE );
ADD_ENUM_VALUE( CENTER_BASE_LINE );
ADD_ENUM_VALUE( RIGHT_BASE_LINE );
ADD_ENUM_VALUE( LEFT_BOTTOM_BASE_LINE );
ADD_ENUM_VALUE( CENTER_BOTTOM_BASE_LINE );
ADD_ENUM_VALUE( RIGHT_BOTTOM_BASE_LINE );
END_ENUM_SERIALIZER(); // _alignment
}

View File

@@ -0,0 +1,7 @@
FILE(GLOB TARGET_SRC *.cpp)
FILE(GLOB TARGET_H *.h)
SET(TARGET_ADDED_LIBRARIES osgUI )
#### end var setup ###
SETUP_PLUGIN(osgui)

View File

@@ -0,0 +1,27 @@
#include <osgUI/FrameSettings>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( FrameSettings,
new osgUI::FrameSettings,
osgUI::FrameSettings,
"osg::Object osgUI::FrameSettings" )
{
BEGIN_ENUM_SERIALIZER2( Shape, osgUI::FrameSettings::Shape, NO_FRAME );
ADD_ENUM_VALUE( NO_FRAME );
ADD_ENUM_VALUE( BOX );
ADD_ENUM_VALUE( PANEL );
END_ENUM_SERIALIZER();
BEGIN_ENUM_SERIALIZER2( Shadow, osgUI::FrameSettings::Shadow, PLAIN );
ADD_ENUM_VALUE( PLAIN );
ADD_ENUM_VALUE( SUNKEN );
ADD_ENUM_VALUE( RAISED );
END_ENUM_SERIALIZER();
ADD_FLOAT_SERIALIZER( LineWidth, 0.01);
}

View File

@@ -0,0 +1,15 @@
#include <osgUI/Label>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( Label,
new osgUI::Label,
osgUI::Label,
"osg::Object osg::Node osg::Group osgUI::Widget osgUI::Label" )
{
ADD_STRING_SERIALIZER( Text, std::string());
}

View File

@@ -0,0 +1,14 @@
#include <osgUI/LineEdit>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( LineEdit,
new osgUI::LineEdit,
osgUI::LineEdit,
"osg::Object osg::Node osg::Group osgUI::Widget osgUI::LineEdit" )
{
ADD_STRING_SERIALIZER( Text, std::string());
}

View File

@@ -0,0 +1,16 @@
#include <osgUI/TextSettings>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( TextSettings,
new osgUI::TextSettings,
osgUI::TextSettings,
"osg::Object osgUI::TextSettings" )
{
ADD_STRING_SERIALIZER( Font, std::string());
ADD_FLOAT_SERIALIZER( CharacterSize, 0.0f);
}

View File

@@ -0,0 +1,155 @@
#include <osgUI/Widget>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#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
{
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
osg::NodeVisitor* nv = (inputParameters.size()>=1) ? dynamic_cast<osg::NodeVisitor*>(inputParameters[0].get()) : 0;
if (!nv) return false;
widget->traverse(*nv);
return true;
}
};
struct TraverseImplementation : public osgDB::MethodObject
{
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters&) const
{
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
osg::NodeVisitor* nv = (inputParameters.size()>=1) ? dynamic_cast<osg::NodeVisitor*>(inputParameters[0].get()) : 0;
if (!nv) return false;
widget->traverseImplementation(*nv);
return true;
}
};
struct Handle : public osgDB::MethodObject
{
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters&) const
{
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
osgGA::EventVisitor* ev = (inputParameters.size()>=1) ? dynamic_cast<osgGA::EventVisitor*>(inputParameters[0].get()) : 0;
osgGA::Event* event = (inputParameters.size()>=2) ? dynamic_cast<osgGA::Event*>(inputParameters[1].get()) : 0;
if (!widget || !ev || !event) return false;
widget->handle(ev, event);
return true;
}
};
struct HandleImplementation : public osgDB::MethodObject
{
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters&) const
{
osgUI::Widget* widget = reinterpret_cast<osgUI::Widget*>(objectPtr);
osgGA::EventVisitor* ev = (inputParameters.size()>=1) ? dynamic_cast<osgGA::EventVisitor*>(inputParameters[0].get()) : 0;
osgGA::Event* event = (inputParameters.size()>=2) ? dynamic_cast<osgGA::Event*>(inputParameters[1].get()) : 0;
if (!widget || !ev || !event) return false;
widget->handleImplementation(ev, event);
return true;
}
};
REGISTER_OBJECT_WRAPPER( Widget,
new osgUI::Widget,
osgUI::Widget,
"osg::Object osg::Node osg::Group osgUI::Widget" )
{
BEGIN_ENUM_SERIALIZER( FocusBehaviour, FOCUS_FOLLOWS_POINTER );
ADD_ENUM_VALUE( CLICK_TO_FOCUS );
ADD_ENUM_VALUE( FOCUS_FOLLOWS_POINTER );
ADD_ENUM_VALUE( EVENT_DRIVEN_FOCUS_DISABLED );
END_ENUM_SERIALIZER();
ADD_BOOL_SERIALIZER(HasEventFocus, false);
ADD_BOUNDINGBOXF_SERIALIZER(Extents, osg::BoundingBoxf());
ADD_OBJECT_SERIALIZER( FrameSettings, osgUI::FrameSettings, NULL );
ADD_OBJECT_SERIALIZER( AlignmentSettings, osgUI::AlignmentSettings, NULL );
ADD_OBJECT_SERIALIZER( TextSettings, osgUI::TextSettings, NULL );
ADD_METHOD_OBJECT( "createGraphics", CreateGraphics );
ADD_METHOD_OBJECT( "createGraphicsImplementation", CreateGraphicsImplementation );
ADD_METHOD_OBJECT( "enter", Enter );
ADD_METHOD_OBJECT( "enterImplementation", EnterImplementation );
ADD_METHOD_OBJECT( "leave", Leave );
ADD_METHOD_OBJECT( "leaveImplementation", LeaveImplementation );
ADD_METHOD_OBJECT( "traverse", Traverse );
ADD_METHOD_OBJECT( "traverseImplementation", TraverseImplementation );
ADD_METHOD_OBJECT( "handle", Handle );
ADD_METHOD_OBJECT( "handleImplementation", HandleImplementation );
}