From d9179879384de960012c4aec7202788428c05d87 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 20 May 2014 08:35:19 +0000 Subject: [PATCH] Added shell of Popup class --- include/osgUI/Popup | 50 +++++++++++ src/osgUI/CMakeLists.txt | 2 + src/osgUI/Popup.cpp | 92 +++++++++++++++++++++ src/osgWrappers/serializers/osgUI/Popup.cpp | 13 +++ 4 files changed, 157 insertions(+) create mode 100644 include/osgUI/Popup create mode 100644 src/osgUI/Popup.cpp create mode 100644 src/osgWrappers/serializers/osgUI/Popup.cpp diff --git a/include/osgUI/Popup b/include/osgUI/Popup new file mode 100644 index 000000000..70e9f38c9 --- /dev/null +++ b/include/osgUI/Popup @@ -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 +#include +#include + +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 _transform; +}; + +} + +#endif diff --git a/src/osgUI/CMakeLists.txt b/src/osgUI/CMakeLists.txt index 84c77fcb5..53af1eed3 100644 --- a/src/osgUI/CMakeLists.txt +++ b/src/osgUI/CMakeLists.txt @@ -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 diff --git a/src/osgUI/Popup.cpp b/src/osgUI/Popup.cpp new file mode 100644 index 000000000..3f84aa2a0 --- /dev/null +++ b/src/osgUI/Popup.cpp @@ -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 +#include +#include +#include +#include + +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"<asGUIEventAdapter(); + if (!ea) return false; + + switch(ea->getEventType()) + { + //case(osgGA::GUIEventAdapter::KEYDOWN): + case(osgGA::GUIEventAdapter::KEYUP): + OSG_NOTICE<<"Key pressed : "<<(char)ea->getKey()<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()"<addChild( style->createPanel(_extents, dialogBackgroundColor) ); +} diff --git a/src/osgWrappers/serializers/osgUI/Popup.cpp b/src/osgWrappers/serializers/osgUI/Popup.cpp new file mode 100644 index 000000000..423d08d40 --- /dev/null +++ b/src/osgWrappers/serializers/osgUI/Popup.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include +#include + + +REGISTER_OBJECT_WRAPPER( Popup, + new osgUI::Popup, + osgUI::Popup, + "osg::Object osg::Node osg::Group osgUI::Widget osgUI::Popup" ) +{ +}