Added shell of Popup class

This commit is contained in:
Robert Osfield 2014-05-20 08:35:19 +00:00
parent e4004118db
commit d917987938
4 changed files with 157 additions and 0 deletions

50
include/osgUI/Popup Normal file
View File

@ -0,0 +1,50 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGUI_POPUP
#define OSGUI_POPUP
#include <osgUI/Widget>
#include <osgText/Text>
#include <osg/PositionAttitudeTransform>
namespace osgUI
{
class OSGUI_EXPORT Popup : public osgUI::Widget
{
public:
Popup();
Popup(const Popup& dialog, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Node(osgUI, Popup);
void close();
void open();
virtual void leaveImplementation();
bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event);
virtual void createGraphicsImplementation();
protected:
virtual ~Popup() {}
std::string _title;
osg::ref_ptr<osg::PositionAttitudeTransform> _transform;
};
}
#endif

View File

@ -13,6 +13,7 @@ SET(TARGET_H
${HEADER_PATH}/Label
${HEADER_PATH}/LineEdit
${HEADER_PATH}/Dialog
${HEADER_PATH}/Popup
${HEADER_PATH}/PushButton
${HEADER_PATH}/ComboBox
${HEADER_PATH}/Style
@ -26,6 +27,7 @@ SET(TARGET_SRC
Label.cpp
LineEdit.cpp
Dialog.cpp
Popup.cpp
PushButton.cpp
ComboBox.cpp
Style.cpp

92
src/osgUI/Popup.cpp Normal file
View File

@ -0,0 +1,92 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgUI/Popup>
#include <osgText/String>
#include <osgText/Font>
#include <osgText/Text>
#include <osg/Notify>
using namespace osgUI;
Popup::Popup()
{
}
Popup::Popup(const osgUI::Popup& dialog, const osg::CopyOp& copyop):
Widget(dialog, copyop),
_title(dialog._title)
{
}
bool Popup::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event)
{
OSG_NOTICE<<"Popup::handleImplementation"<<std::endl;
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
if (!ea) return false;
switch(ea->getEventType())
{
//case(osgGA::GUIEventAdapter::KEYDOWN):
case(osgGA::GUIEventAdapter::KEYUP):
OSG_NOTICE<<"Key pressed : "<<(char)ea->getKey()<<std::endl;
if (ea->getKey()=='c')
{
close();
ea->setHandled(true);
return true;
}
break;
default:
break;
}
return false;
}
void Popup::close()
{
if (_transform.valid()) _transform->setNodeMask(0x0);
}
void Popup::open()
{
if (_transform.valid()) _transform->setNodeMask(0xffffffff);
}
void Popup::leaveImplementation()
{
close();
}
void Popup::createGraphicsImplementation()
{
OSG_NOTICE<<"Popup::createGraphicsImplementation()"<<std::endl;
Widget::createGraphicsImplementation();
_transform = new osg::PositionAttitudeTransform;
addChild(_transform.get());
Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get();
osg::Vec4 dialogBackgroundColor(0.8,0.8,0.8,1.0);
_transform->addChild( style->createPanel(_extents, dialogBackgroundColor) );
}

View File

@ -0,0 +1,13 @@
#include <osgUI/Popup>
#include <osg/ValueObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
REGISTER_OBJECT_WRAPPER( Popup,
new osgUI::Popup,
osgUI::Popup,
"osg::Object osg::Node osg::Group osgUI::Widget osgUI::Popup" )
{
}