From bf465ce304d2a8b7f13feb872453baed981f0ced Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 2 Mar 2016 21:51:44 +0100 Subject: [PATCH] [DEV] update new property interface --- ege/Environement.cpp | 39 +++++++++++++++++++++---------------- ege/Environement.h | 46 ++++++++------------------------------------ ege/widget/Mesh.cpp | 2 +- ege/widget/Mesh.h | 2 +- ege/widget/Scene.cpp | 27 ++++++++++++-------------- ege/widget/Scene.h | 42 ++++++---------------------------------- 6 files changed, 50 insertions(+), 108 deletions(-) diff --git a/ege/Environement.cpp b/ege/Environement.cpp index cae7b5c..8da9e6b 100644 --- a/ege/Environement.cpp +++ b/ege/Environement.cpp @@ -289,15 +289,20 @@ void ege::Environement::generateInteraction(ege::ElementInteraction& _event) { } ege::Environement::Environement() : - signalPlayTimeChange(*this, "time-change"), + signalPlayTimeChange(this, "time-change", ""), + propertyStatus(this, "status", + gameStop, + "Satus of the activity of the Environement", + &ege::Environement::onChangePropertyStatus), + propertyRatio(this, "ratio", + 1.0f, + "game speed ratio"), m_listElement(), - m_status(*this, "status", gameStop, "Satus of the activity of the Environement"), - m_ratio(*this, "ratio", 1.0f, "game speed ratio"), m_particuleEngine(this) { // nothing to do ... - m_status.add(gameStart, "start", "Scene is started"); - m_status.add(gamePause, "pause", "Scene is paused"); - m_status.add(gameStop, "stop", "Scene is stopped"); + propertyStatus.add(gameStart, "start", "Scene is started"); + propertyStatus.add(gamePause, "pause", "Scene is paused"); + propertyStatus.add(gameStop, "stop", "Scene is stopped"); } void ege::Environement::init(const std::string& _name) { @@ -310,13 +315,13 @@ void ege::Environement::clear() { } -void ege::Environement::periodicCall(const ewol::event::Time& _event) { +void ege::Environement::onCallbackPeriodicCall(const ewol::event::Time& _event) { float curentDelta = _event.getDeltaCall(); EGE_VERBOSE("periodic call : " << _event); // small hack to change speed ... - curentDelta *= m_ratio; + curentDelta *= *propertyRatio; // check if the processing is availlable - if (m_status.get() == gameStop) { + if (propertyStatus.get() == gameStop) { return; } // update game time: @@ -388,12 +393,12 @@ std::shared_ptr ege::Environement::getCamera(const std::string& _na } -void ege::Environement::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { - if (_paramPointer == m_status) { - if (m_status.get() == gameStart) { - getObjectManager().periodicCall.bind(shared_from_this(), &ege::Environement::periodicCall); - } else { - getObjectManager().periodicCall.release(shared_from_this()); - } +void ege::Environement::onChangePropertyStatus() { + if (propertyStatus.get() == gameStart) { + m_periodicCallConnection = getObjectManager().periodicCall.connect(this, &ege::Environement::onCallbackPeriodicCall); + } else { + m_periodicCallConnection.disconnect(); } -} \ No newline at end of file +} + + diff --git a/ege/Environement.h b/ege/Environement.h index 4f9fb90..9e70f2e 100644 --- a/ege/Environement.h +++ b/ege/Environement.h @@ -88,8 +88,11 @@ namespace ege { class Environement : public ewol::Object { public: - // extern event - esignal::Signal signalPlayTimeChange; + // Signals + esignal::ISignal signalPlayTimeChange; + // properties: + eproperty::List propertyStatus; //!< the display is running (not in pause) + eproperty::Value propertyRatio; //!< Speed ratio private: //std::shared_ptr m_dynamicsWorld; //!< curent system world description ege::physics::Engine m_physicEngine; //!< EGE physic engine interface. @@ -101,39 +104,6 @@ namespace ege { DECLARE_FACTORY(Environement); virtual ~Environement() { }; protected: - eproperty::List m_status; //!< the display is running (not in pause) - public: - /** - * @brief Get the game status. - * @return the current status. - */ - enum gameStatus getGameStatus() { - return m_status.get(); - } - /** - * @brief Set the game status. - * @param[in] _value New game status. - */ - void setGameStatus(enum gameStatus _value) { - m_status.set(_value); - } - protected: - eproperty::Value m_ratio; //!< Speed ratio - public: - /** - * @brief Get the game speed ratio. - * @return the current ratio. - */ - float getSpeedRatio() { - return m_ratio.get(); - } - /** - * @brief Set the game ratio. - * @param[in] _value New game ratio. - */ - void setSpeedRatio(float _value) { - m_ratio.set(_value); - } protected: std::map> m_listCamera; //!< list of all camera in the world public: @@ -260,9 +230,9 @@ namespace ege { protected: int64_t m_gameTime; //!< time of the game running public: - + esignal::Connection m_periodicCallConnection; private: - void periodicCall(const ewol::event::Time& _event); + void onCallbackPeriodicCall(const ewol::event::Time& _event); protected: std::vector> m_listMeshToDrawFirst; public: @@ -272,7 +242,7 @@ namespace ege { const std::vector>& getStaticMeshToDraw() { return m_listMeshToDrawFirst; } - virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); + virtual void onChangePropertyStatus(); }; } diff --git a/ege/widget/Mesh.cpp b/ege/widget/Mesh.cpp index 2d2edd6..c626a6c 100644 --- a/ege/widget/Mesh.cpp +++ b/ege/widget/Mesh.cpp @@ -17,7 +17,7 @@ ege::widget::Mesh::Mesh(): - signalPressed(*this, "pressed"), + signalPressed(this, "pressed", ""), m_position(0,0,0), m_angle(0,0,0), m_angleSpeed(0,0,0), diff --git a/ege/widget/Mesh.h b/ege/widget/Mesh.h index 2876a68..5b54245 100644 --- a/ege/widget/Mesh.h +++ b/ege/widget/Mesh.h @@ -18,7 +18,7 @@ namespace ege { */ class Mesh :public ewol::Widget { public: - esignal::Signal signalPressed; + esignal::ISignal<> signalPressed; private: // mesh name : std::string m_meshName; diff --git a/ege/widget/Scene.cpp b/ege/widget/Scene.cpp index 17138dc..4574cf5 100644 --- a/ege/widget/Scene.cpp +++ b/ege/widget/Scene.cpp @@ -36,10 +36,14 @@ namespace etk { }; ege::widget::Scene::Scene() : - signalDisplayDebug(*this, "drawDebug", "Call to draw debug after all elements"), - m_cameraName("default"), - m_debugPhysic(*this, "debugPhysic", false, "Display debug of the physic interface"), - m_debugApplication(*this, "debugApplication", false, "Display debug of the application") { + signalDisplayDebug(this, "drawDebug", "Call to draw debug after all elements"), + propertyDebugPhysic(this, "debugPhysic", + false, + "Display debug of the physic interface"), + propertyDebugApplication(this, "debugApplication", + false, + "Display debug of the application"), + m_cameraName("default") { addObjectType("ege::widget::Scene"); } @@ -118,7 +122,7 @@ void ege::widget::Scene::onDraw() { m_displayElementOrdered[iii].element->draw(pass); } } - if (m_debugPhysic.get() == true) { + if (propertyDebugPhysic.get() == true) { // Draw debug ... (Object) for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) { m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera); @@ -131,7 +135,7 @@ void ege::widget::Scene::onDraw() { } } } - if (m_debugApplication.get() == true) { + if (propertyDebugApplication.get() == true) { // Draw debug ... (User) signalDisplayDebug.emit(m_debugDrawProperty); } @@ -185,15 +189,6 @@ void ege::widget::Scene::systemDraw(const ewol::DrawProperty& _displayProp) { #endif } -void ege::widget::Scene::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { - ewol::Widget::onPropertyChangeValue(_paramPointer); - /* - if (_paramPointer == m_isRunning) { - // nothing to do ... - } - */ -} - void ege::widget::Scene::setCamera(const std::string& _cameraName) { if (m_cameraName == _cameraName) { @@ -216,4 +211,6 @@ void ege::widget::Scene::calculateSize() { } } +#include +template class esignal::ISignal>; diff --git a/ege/widget/Scene.h b/ege/widget/Scene.h index f191d35..6a5992d 100644 --- a/ege/widget/Scene.h +++ b/ege/widget/Scene.h @@ -35,11 +35,16 @@ class btVector3; namespace ege { namespace widget { class Scene : public ewol::Widget { + public: + // signals + esignal::ISignal/*, std::shared_ptr*/> signalDisplayDebug; //!< emit a signal to the application to draw the debug (@ref setDebugPhysic) + // properties + eproperty::Value propertyDebugPhysic; //!< display Physic Debug + eproperty::Value propertyDebugApplication; //!< display Application Debug protected: std::shared_ptr m_env; std::shared_ptr m_debugDrawProperty; public: - esignal::Signal/*, std::shared_ptr*/> signalDisplayDebug; //!< emit a signal to the application to draw the debug (@ref setDebugPhysic) protected: /** * @brief Constructor of the widget classes @@ -73,46 +78,11 @@ namespace ege { std::vector m_displayElementOrdered; protected: // Derived function virtual void onDraw(); - virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); public: // Derived function virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void onRegenerateDisplay(); virtual void periodicCall(const ewol::event::Time& _event); virtual void calculateSize(); - protected: - eproperty::Value m_debugPhysic; //!< display Physic Debug - public: - /** - * @brief Set the debug display of the physic engine - * @param[in] _status new status of the debug - */ - void setDebugPhysic(bool _status) { - m_debugPhysic.set(_status); - } - /** - * @brief Get the debug display status of the physic engine - * @return The current status of the debug. - */ - bool getDebugPhysic() { - return m_debugPhysic.get(); - } - protected: - eproperty::Value m_debugApplication; //!< display Application Debug - public: - /** - * @brief Set the debug display of the application - * @param[in] _status new status of the debug - */ - void setDebugApplication(bool _status) { - m_debugApplication.set(_status); - } - /** - * @brief Get the debug display status of the application - * @return The current status of the debug. - */ - bool getDebugApplication() { - return m_debugApplication.get(); - } }; } }