[DEV] set signal agnostic from other API just depend on shared_ptr<void>
This commit is contained in:
parent
00b385f433
commit
656fe783d4
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <ewol/object/Object.h>
|
#include <ewol/object/Object.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
#include <ewol/event/Time.h>
|
#include <ewol/event/Time.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class Context;
|
class Context;
|
||||||
namespace object {
|
namespace object {
|
||||||
class Manager : public ewol::object::SignalList {
|
class Manager : public ewol::signal::List {
|
||||||
private:
|
private:
|
||||||
std::vector<std::weak_ptr<ewol::Object>> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
std::vector<std::weak_ptr<ewol::Object>> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
||||||
Context& m_context;
|
Context& m_context;
|
||||||
@ -78,7 +78,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
void workerRemove(const std::shared_ptr<ewol::Object>& _worker);
|
void workerRemove(const std::shared_ptr<ewol::Object>& _worker);
|
||||||
public:
|
public:
|
||||||
ewol::object::Signal<ewol::event::Time> periodicCall;
|
ewol::Signal<ewol::event::Time> periodicCall;
|
||||||
private:
|
private:
|
||||||
int64_t m_applWakeUpTime; //!< Time of the application initialize
|
int64_t m_applWakeUpTime; //!< Time of the application initialize
|
||||||
int64_t m_lastPeriodicCallTime; //!< last call time ...
|
int64_t m_lastPeriodicCallTime; //!< last call time ...
|
||||||
|
@ -29,7 +29,7 @@ namespace ewol {
|
|||||||
#include <ewol/object/Param.h>
|
#include <ewol/object/Param.h>
|
||||||
#include <ewol/object/ParamRange.h>
|
#include <ewol/object/ParamRange.h>
|
||||||
#include <ewol/object/ParamList.h>
|
#include <ewol/object/ParamList.h>
|
||||||
#include <ewol/object/SignalList.h>
|
#include <ewol/signal/List.h>
|
||||||
|
|
||||||
#define DECLARE_FACTORY(className) \
|
#define DECLARE_FACTORY(className) \
|
||||||
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
|
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
|
||||||
@ -52,7 +52,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class Object : public std::enable_shared_from_this<Object>,
|
class Object : public std::enable_shared_from_this<Object>,
|
||||||
public ewol::object::ParameterList,
|
public ewol::object::ParameterList,
|
||||||
public ewol::object::SignalList {
|
public ewol::signal::List {
|
||||||
private:
|
private:
|
||||||
static size_t m_valUID; //!< Static used for the unique ID definition
|
static size_t m_valUID; //!< Static used for the unique ID definition
|
||||||
private:
|
private:
|
||||||
@ -222,32 +222,16 @@ namespace ewol {
|
|||||||
/**
|
/**
|
||||||
* @brief link on an signal in the subwiget with his name
|
* @brief link on an signal in the subwiget with his name
|
||||||
*/
|
*/
|
||||||
#define subBind(_type, _name, _event, _obj, _func) do {\
|
#define subBind(_type, _name, _event, _shared_ptr, _func, ...) do {\
|
||||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \
|
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \
|
||||||
if (myObject != nullptr) { \
|
if (myObject != nullptr) { \
|
||||||
myObject->_event.bind(_obj, _func); \
|
myObject->_event.bind(_shared_ptr, _func, ##__VA_ARGS__); \
|
||||||
} else { \
|
|
||||||
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
|
||||||
} \
|
|
||||||
} while (false)
|
|
||||||
#define subBind1(_type, _name, _event, _obj, _func, _param1) do {\
|
|
||||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \
|
|
||||||
if (myObject != nullptr) { \
|
|
||||||
myObject->_event.bind1(_obj, _func, _param1); \
|
|
||||||
} else { \
|
|
||||||
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
|
||||||
} \
|
|
||||||
} while (false)
|
|
||||||
#define subBind2(_type, _name, _event, _obj, _func, _param1, _param2) do {\
|
|
||||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \
|
|
||||||
if (myObject != nullptr) { \
|
|
||||||
myObject->_event.bind2(_obj, _func, _param1, _param2); \
|
|
||||||
} else { \
|
} else { \
|
||||||
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
/*
|
/*
|
||||||
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)()) {
|
template<class TYPE> void subBind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)()) {
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
||||||
if (obj2 == nullptr) {
|
if (obj2 == nullptr) {
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
EWOL_ERROR("Can not bind signal ...");
|
||||||
@ -263,10 +247,10 @@ namespace ewol {
|
|||||||
/**
|
/**
|
||||||
* @brief link on an signal in the global object list with his name
|
* @brief link on an signal in the global object list with his name
|
||||||
*/
|
*/
|
||||||
#define globalBind(_type, _name, _event, _obj, _func) do {\
|
#define globalBind(_type, _name, _event, _obj, _func, ...) do {\
|
||||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \
|
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \
|
||||||
if (myObject != nullptr) { \
|
if (myObject != nullptr) { \
|
||||||
myObject->_event.bind(_obj, _func); \
|
myObject->_event.bind(_obj, _func, ##__VA_ARGS__); \
|
||||||
} else { \
|
} else { \
|
||||||
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
} \
|
} \
|
||||||
@ -275,15 +259,15 @@ namespace ewol {
|
|||||||
/**
|
/**
|
||||||
* @brief link on an signal in the subWidget of an object with his name
|
* @brief link on an signal in the subWidget of an object with his name
|
||||||
*/
|
*/
|
||||||
#define externSubBind(_object, _type, _name, _event, _obj, _func) do {\
|
#define externSubBind(_object, _type, _name, _event, _obj, _func, ...) do {\
|
||||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_object->getObjectNamed(_name)); \
|
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_object->getObjectNamed(_name)); \
|
||||||
if (myObject != nullptr) { \
|
if (myObject != nullptr) { \
|
||||||
myObject->_event.bind(_obj, _func); \
|
myObject->_event.bind(_obj, _func, ##__VA_ARGS__); \
|
||||||
} else { \
|
} else { \
|
||||||
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
//#include <ewol/object/Signal.h>
|
//#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,400 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
|
|
||||||
#ifndef __EWOL_SIGNAL_H__
|
|
||||||
#define __EWOL_SIGNAL_H__
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <ewol/object/ParameterList.h>
|
|
||||||
#include <ewol/object/SignalBase.h>
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
namespace object {
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "object::Signal<T>"
|
|
||||||
template<typename T> class Signal : public SignalBase {
|
|
||||||
private:
|
|
||||||
std::vector<std::pair<std::weak_ptr<void>,
|
|
||||||
std::function<void(const T&)>>> m_callerList; // current list of binded element
|
|
||||||
std::vector<std::pair<std::weak_ptr<void>,
|
|
||||||
std::function<void(const T&)>>> m_callerListInCallback; // temporaty list (when add one in call process)
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Create a parameter with a specific type.
|
|
||||||
* @param[in] _objectLink reference on the parameter lister.
|
|
||||||
* @param[in] _name Static name of the parameter.
|
|
||||||
* @param[in] _defaultValue Default value of the parameter.
|
|
||||||
* @param[in] _min Minumum value.
|
|
||||||
* @param[in] _max Maximum value.
|
|
||||||
* @param[in] _description description of the parameter.
|
|
||||||
*/
|
|
||||||
Signal(ewol::object::SignalList& _objectLink,
|
|
||||||
const std::string& _name,
|
|
||||||
const std::string& _description = "") :
|
|
||||||
SignalBase(_objectLink, _name, _description) {
|
|
||||||
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~Signal() { };
|
|
||||||
/**
|
|
||||||
* @brief Bind a callback function to the current signal (generic methis (simplest))
|
|
||||||
* @param[in] _obj Shared pointer on the caller object
|
|
||||||
* @param[in] _func Link on the fuction that might be called (inside a class)
|
|
||||||
* @example signalXXXX.bind(shared_from_this(), &ClassName::onCallbackXXX);
|
|
||||||
*/
|
|
||||||
/* Maybe later :
|
|
||||||
template<class TYPE, typename... TArgs>
|
|
||||||
void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)(const T&, TArgs...), TArgs... args2) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, args2)));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
template<class TYPE_CLASS, class TYPE>
|
|
||||||
void bind(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(const T&)) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1)));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO : Rework this when I understand the use of variadic template with std::function
|
|
||||||
template<class TYPE_CLASS, class TYPE, typename TYPE2>
|
|
||||||
void bind1(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(const T&, const TYPE2&), TYPE2 _param1) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, _param1)));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, _param1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class TYPE_CLASS, class TYPE, typename TYPE2, typename TYPE3>
|
|
||||||
void bind2(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(const T&, const TYPE2&, const TYPE3&), TYPE2 _param1, TYPE3 _param2) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, _param1, _param2)));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, _param1, _param2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Advanced binding a callback function to the current signal.
|
|
||||||
* @param[in] _obj Shared pointer on the caller object
|
|
||||||
* @param[in] _func functor to call (do it yourself)
|
|
||||||
* @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1));
|
|
||||||
*/
|
|
||||||
void connect(std::shared_ptr<void> _obj, std::function<void(const T&)> _function ) {
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), _function));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), _function));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief remove link on the signal.
|
|
||||||
* @param[in] _obj shared pointer on the removing object
|
|
||||||
*/
|
|
||||||
void release(std::shared_ptr<void> _obj) {
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
// Remove from the list :
|
|
||||||
auto it(m_callerList.begin());
|
|
||||||
while(it != m_callerList.end()) {
|
|
||||||
if (it->first.lock() == _obj) {
|
|
||||||
it = m_callerList.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// just remove weak poointer
|
|
||||||
auto it(m_callerList.begin());
|
|
||||||
while(it != m_callerList.end()) {
|
|
||||||
if (it->first.lock() == _obj) {
|
|
||||||
it->first.reset();
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_someOneRemoveInCall = true;
|
|
||||||
}
|
|
||||||
// remove from add list in callback progress
|
|
||||||
auto it = m_callerListInCallback.begin();
|
|
||||||
while(it != m_callerListInCallback.end()) {
|
|
||||||
if (it->first.lock() == _obj) {
|
|
||||||
it = m_callerListInCallback.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Generate a signal on all interface listening.
|
|
||||||
* @param[in] _data data to emit
|
|
||||||
*/
|
|
||||||
void emit(const T& _data) {
|
|
||||||
m_signalCallLeval++;
|
|
||||||
m_callInProgress++;
|
|
||||||
#if 0
|
|
||||||
int32_t tmpID = m_uidSignal++;
|
|
||||||
ewol::Object* srcObject = dynamic_cast<ewol::Object*>(&m_objectLink);
|
|
||||||
if (srcObject != nullptr) {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << "emit signal{" << tmpID << "} : " << srcObject->getObjectType() << " signal='" << m_name << "' data='" << etk::to_string(_data) << "' to: " << m_callerList.size() << " element(s)");
|
|
||||||
} else {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' data='" << etk::to_string(_data) << "' to: " << m_callerList.size() << " element(s)");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (auto &it : m_callerList) {
|
|
||||||
std::shared_ptr<void> destObject = it.first.lock();
|
|
||||||
if (destObject == nullptr) {
|
|
||||||
// TODO : Remove instance ...
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << " nullptr dest");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
if (srcObject != nullptr) {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << " signal{" << tmpID << "} : [" << destObject->getId() << "]" << destObject->getObjectType());
|
|
||||||
} else {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << " signal{" << tmpID << "} : [" << destObject->getId() << "]" << destObject->getObjectType());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
it.second(_data);
|
|
||||||
}
|
|
||||||
m_callInProgress--;
|
|
||||||
m_signalCallLeval--;
|
|
||||||
// Remove element in call phase:
|
|
||||||
if (m_someOneRemoveInCall == true) {
|
|
||||||
m_someOneRemoveInCall = false;
|
|
||||||
// Remove from the list :
|
|
||||||
auto it(m_callerList.begin());
|
|
||||||
while(it != m_callerList.end()) {
|
|
||||||
if (it->first.expired() == true) {
|
|
||||||
it = m_callerList.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add element in call phase:
|
|
||||||
if (m_callerListInCallback.size() > 0) {
|
|
||||||
for (auto &it : m_callerListInCallback) {
|
|
||||||
m_callerList.push_back(it);
|
|
||||||
}
|
|
||||||
m_callerListInCallback.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
size_t getNumberConnected() {
|
|
||||||
return m_callerList.size();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "object::Signal<void>"
|
|
||||||
template<> class Signal<void> : public SignalBase {
|
|
||||||
private:
|
|
||||||
std::vector<std::pair<std::weak_ptr<void>, std::function<void()>>> m_callerList;
|
|
||||||
std::vector<std::pair<std::weak_ptr<void>, std::function<void()>>> m_callerListInCallback;
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Create a parameter with a specific type.
|
|
||||||
* @param[in] _objectLink reference on the parameter lister.
|
|
||||||
* @param[in] _name Static name of the parameter.
|
|
||||||
* @param[in] _defaultValue Default value of the parameter.
|
|
||||||
* @param[in] _min Minumum value.
|
|
||||||
* @param[in] _max Maximum value.
|
|
||||||
* @param[in] _description description of the parameter.
|
|
||||||
*/
|
|
||||||
Signal(ewol::object::SignalList& _objectLink,
|
|
||||||
const std::string& _name,
|
|
||||||
const std::string& _description = "") :
|
|
||||||
SignalBase(_objectLink, _name, _description) {
|
|
||||||
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* @brief Destructor.
|
|
||||||
*/
|
|
||||||
virtual ~Signal() { };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Bind a callback function to the current signal (generic methis (simplest))
|
|
||||||
* @param[in] _obj Shared pointer on the caller object
|
|
||||||
* @param[in] _func Link on the fuction that might be called (inside a class)
|
|
||||||
* @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX);
|
|
||||||
*/
|
|
||||||
template<class TYPE_CLASS, class TYPE>
|
|
||||||
void bind(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)()) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get())));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class TYPE_CLASS, class TYPE, class TYPE2>
|
|
||||||
void bind1(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(TYPE2), TYPE2 _param1) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), _param1)));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), _param1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<class TYPE_CLASS, class TYPE, class TYPE2, class TYPE3>
|
|
||||||
void bind2(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(TYPE2, TYPE3), TYPE2 _param1, TYPE3 _param2) {
|
|
||||||
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
|
||||||
if (obj2 == nullptr) {
|
|
||||||
EWOL_ERROR("Can not bind signal ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), _param1, _param2)));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), _param1, _param2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Advanced binding a callback function to the current signal.
|
|
||||||
* @param[in] _obj Shared pointer on the caller object
|
|
||||||
* @param[in] _func functor to call (do it yourself)
|
|
||||||
* @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1));
|
|
||||||
*/
|
|
||||||
void connect(std::shared_ptr<void> _obj, std::function<void()> _function ) {
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), _function));
|
|
||||||
} else {
|
|
||||||
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), _function));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief remove link on the signal.
|
|
||||||
* @param[in] _obj shared pointer on the removing object
|
|
||||||
*/
|
|
||||||
void release(std::shared_ptr<void> _obj) {
|
|
||||||
auto it(m_callerList.begin());
|
|
||||||
if (m_callInProgress == 0) {
|
|
||||||
// Remove from the list :
|
|
||||||
while(it != m_callerList.end()) {
|
|
||||||
if (it->first.lock() == _obj) {
|
|
||||||
//EWOL_DEBUG(" unbind : " << _obj->getObjectType() << " signal='" << m_name << "'");
|
|
||||||
it = m_callerList.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// just remove weak poointer
|
|
||||||
while(it != m_callerList.end()) {
|
|
||||||
if (it->first.lock() == _obj) {
|
|
||||||
//EWOL_DEBUG(" unbind : " << _obj->getObjectType() << " signal='" << m_name << "' (delayed)");
|
|
||||||
it->first.reset();
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_someOneRemoveInCall = true;
|
|
||||||
}
|
|
||||||
// remove from add list in callback progress
|
|
||||||
it = m_callerListInCallback.begin();
|
|
||||||
while(it != m_callerListInCallback.end()) {
|
|
||||||
if (it->first.lock() == _obj) {
|
|
||||||
//EWOL_DEBUG(" unbind : " << _obj->getObjectType() << " signal='" << m_name << "' (notActive)");
|
|
||||||
it = m_callerListInCallback.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void emit() {
|
|
||||||
m_callInProgress++;
|
|
||||||
m_signalCallLeval++;
|
|
||||||
#if 0
|
|
||||||
int32_t tmpID = m_uidSignal++;
|
|
||||||
ewol::Object* srcObject = dynamic_cast<ewol::Object*>(&m_objectLink);
|
|
||||||
if (srcObject != nullptr) {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << "emit signal{" << tmpID << "} : " << srcObject->getObjectType() << " signal='" << m_name << "' BANG!!! to: " << m_callerList.size() << " element(s)");
|
|
||||||
} else {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' to: " << m_callerList.size() << " element(s)");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (auto &it : m_callerList) {
|
|
||||||
std::shared_ptr<void> destObject = it.first.lock();
|
|
||||||
if (destObject == nullptr) {
|
|
||||||
// TODO : Remove instance ...
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << " nullptr dest");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
if (srcObject != nullptr) {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << " signal{" << tmpID << "} : [" << destObject->getId() << "]" << destObject->getObjectType());
|
|
||||||
} else {
|
|
||||||
EWOL_DEBUG(ewol::object::logIndent(m_signalCallLeval-1) << " signal{" << tmpID << "} : [" << destObject->getId() << "]" << destObject->getObjectType());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
it.second();
|
|
||||||
}
|
|
||||||
m_callInProgress--;
|
|
||||||
m_signalCallLeval--;
|
|
||||||
// Remove element in call phase:
|
|
||||||
if (m_someOneRemoveInCall == true) {
|
|
||||||
m_someOneRemoveInCall = false;
|
|
||||||
// Remove from the list :
|
|
||||||
auto it(m_callerList.begin());
|
|
||||||
while(it != m_callerList.end()) {
|
|
||||||
if (it->first.expired() == true) {
|
|
||||||
it = m_callerList.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add element in call phase:
|
|
||||||
if (m_callerListInCallback.size() > 0) {
|
|
||||||
for (auto &it : m_callerListInCallback) {
|
|
||||||
if (it.first.expired() == false) {
|
|
||||||
m_callerList.push_back(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_callerListInCallback.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
size_t getNumberConnected() {
|
|
||||||
return m_callerList.size();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ nullptr
|
|
||||||
};
|
|
||||||
};
|
|
||||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
#include <ewol/object/SignalList.h>
|
|
||||||
#include <ewol/object/SignalBase.h>
|
|
||||||
|
|
||||||
int32_t ewol::object::SignalBase::m_uidSignal = 0;
|
|
||||||
int32_t ewol::object::SignalBase::m_signalCallLeval = 0;
|
|
||||||
ewol::object::SignalBase::SignalBase(ewol::object::SignalList& _objectLink,
|
|
||||||
const std::string& _name,
|
|
||||||
const std::string& _description) :
|
|
||||||
m_objectLink(_objectLink),
|
|
||||||
m_name(_name),
|
|
||||||
m_description(_description),
|
|
||||||
m_callInProgress(0),
|
|
||||||
m_someOneRemoveInCall(false) {
|
|
||||||
// add a reference on the current signal ...
|
|
||||||
m_objectLink.signalAdd(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::SignalBase& _obj) {
|
|
||||||
_os << _obj.getName();
|
|
||||||
return _os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* ewol::object::logIndent(int32_t _iii) {
|
|
||||||
static const char g_val[] = " ";
|
|
||||||
if (_iii > 5) {
|
|
||||||
return g_val;
|
|
||||||
}
|
|
||||||
return g_val + (5-_iii)*4;
|
|
||||||
}
|
|
43
sources/ewol/signal/Base.cpp
Normal file
43
sources/ewol/signal/Base.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <ewol/debug.h>
|
||||||
|
#include <ewol/signal/List.h>
|
||||||
|
#include <ewol/signal/Base.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
int32_t ewol::signal::Base::m_uidSignal = 0;
|
||||||
|
int32_t ewol::signal::Base::m_signalCallLevel = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ewol::signal::Base::Base(ewol::signal::List& _signalLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description) :
|
||||||
|
m_signalLink(_signalLink),
|
||||||
|
m_name(_name),
|
||||||
|
m_description(_description),
|
||||||
|
m_callInProgress(0),
|
||||||
|
m_someOneRemoveInCall(false) {
|
||||||
|
// add a reference on the current signal ...
|
||||||
|
m_signalLink.signalAdd(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& ewol::signal::operator <<(std::ostream& _os, const ewol::signal::Base& _obj) {
|
||||||
|
_os << _obj.getName();
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* ewol::signal::logIndent(int32_t _iii) {
|
||||||
|
static const char g_val[] = " ";
|
||||||
|
if (_iii > 5) {
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
return g_val + (5-_iii)*4;
|
||||||
|
}
|
@ -9,18 +9,18 @@
|
|||||||
#ifndef __EWOL_SIGNAL_BASE_H__
|
#ifndef __EWOL_SIGNAL_BASE_H__
|
||||||
#define __EWOL_SIGNAL_BASE_H__
|
#define __EWOL_SIGNAL_BASE_H__
|
||||||
|
|
||||||
#include <ewol/object/SignalList.h>
|
#include <ewol/signal/List.h>
|
||||||
#include <ewol/object/SignalBase.h>
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace object {
|
namespace signal {
|
||||||
class SignalBase {
|
class Base {
|
||||||
protected:
|
protected:
|
||||||
static int32_t m_uidSignal;
|
#ifdef DEBUG
|
||||||
static int32_t m_signalCallLeval;
|
static int32_t m_uidSignal;
|
||||||
ewol::object::SignalList& m_objectLink;
|
static int32_t m_signalCallLevel;
|
||||||
|
#endif
|
||||||
|
ewol::signal::List& m_signalLink;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_description;
|
std::string m_description;
|
||||||
int32_t m_callInProgress;
|
int32_t m_callInProgress;
|
||||||
@ -28,17 +28,17 @@ namespace ewol {
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a parameter with a specific type.
|
* @brief Create a parameter with a specific type.
|
||||||
* @param[in] _objectLink reference on the parameter lister.
|
* @param[in] _signalListLink reference on the signal list.
|
||||||
* @param[in] _name Static name of the parameter.
|
* @param[in] _name Static name of the parameter.
|
||||||
* @param[in] _description description of the parameter.
|
* @param[in] _description description of the parameter.
|
||||||
*/
|
*/
|
||||||
SignalBase(ewol::object::SignalList& _objectLink,
|
Base(ewol::signal::List& _signalListLink,
|
||||||
const std::string& _name,
|
const std::string& _name,
|
||||||
const std::string& _description = "");
|
const std::string& _description = "");
|
||||||
/**
|
/**
|
||||||
* @brief Destructor.
|
* @brief Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~SignalBase() { };
|
virtual ~Base() { };
|
||||||
|
|
||||||
const std::string& getName() const {
|
const std::string& getName() const {
|
||||||
return m_name;
|
return m_name;
|
||||||
@ -48,7 +48,7 @@ namespace ewol {
|
|||||||
}
|
}
|
||||||
virtual void release(std::shared_ptr<void> _obj) = 0;
|
virtual void release(std::shared_ptr<void> _obj) = 0;
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream& _os, const SignalBase& _obj);
|
std::ostream& operator <<(std::ostream& _os, const ewol::signal::Base& _obj);
|
||||||
const char* logIndent(int32_t _iii);
|
const char* logIndent(int32_t _iii);
|
||||||
};
|
};
|
||||||
};
|
};
|
@ -8,21 +8,19 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/object/Object.h>
|
#include <ewol/signal/List.h>
|
||||||
#include <ewol/object/SignalList.h>
|
#include <ewol/signal/Base.h>
|
||||||
#include <ewol/object/SignalBase.h>
|
|
||||||
#include <ewol/context/Context.h>
|
|
||||||
|
|
||||||
ewol::object::SignalList::SignalList() {
|
ewol::signal::List::List() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::object::SignalList::~SignalList() {
|
ewol::signal::List::~List() {
|
||||||
m_list.clear();
|
m_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// note this pointer is not allocated and not free at the end of the class
|
// note this pointer is not allocated and not free at the end of the class
|
||||||
void ewol::object::SignalList::signalAdd(SignalBase* _pointerOnSignal) {
|
void ewol::signal::List::signalAdd(ewol::signal::Base* _pointerOnSignal) {
|
||||||
if (_pointerOnSignal == nullptr) {
|
if (_pointerOnSignal == nullptr) {
|
||||||
EWOL_ERROR("Try to link a nullptr parameters");
|
EWOL_ERROR("Try to link a nullptr parameters");
|
||||||
return;
|
return;
|
||||||
@ -30,7 +28,7 @@ void ewol::object::SignalList::signalAdd(SignalBase* _pointerOnSignal) {
|
|||||||
m_list.push_back(_pointerOnSignal);
|
m_list.push_back(_pointerOnSignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> ewol::object::SignalList::signalGetAll() const {
|
std::vector<std::string> ewol::signal::List::signalGetAll() const {
|
||||||
std::vector<std::string> out;
|
std::vector<std::string> out;
|
||||||
for (auto &it : m_list) {
|
for (auto &it : m_list) {
|
||||||
if(it != nullptr) {
|
if(it != nullptr) {
|
||||||
@ -40,7 +38,7 @@ std::vector<std::string> ewol::object::SignalList::signalGetAll() const {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::SignalList::unBindAll(const std::shared_ptr<void>& _object) {
|
void ewol::signal::List::signalUnBindAll(const std::shared_ptr<void>& _object) {
|
||||||
if (_object == nullptr) {
|
if (_object == nullptr) {
|
||||||
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
||||||
return;
|
return;
|
@ -14,27 +14,27 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace object {
|
namespace signal {
|
||||||
class SignalBase;
|
class Base;
|
||||||
class SignalList {
|
class List {
|
||||||
friend class ewol::object::SignalBase; // to register parameter in the list.
|
friend class ewol::signal::Base; // to register parameter in the list.
|
||||||
private:
|
private:
|
||||||
std::vector<ewol::object::SignalBase*> m_list; //!< list of availlable Parameters
|
std::vector<ewol::signal::Base*> m_list; //!< list of availlable Parameters
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor.
|
* @brief Constructor.
|
||||||
*/
|
*/
|
||||||
SignalList();
|
List();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor.
|
* @brief Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~SignalList();
|
~List();
|
||||||
/**
|
/**
|
||||||
* @brief Register a parameter class pointer in the List of parameters
|
* @brief Register a parameter class pointer in the List of parameters
|
||||||
* @note This class does not destroy the parameter pointer!!!
|
* @note This class does not destroy the parameter pointer!!!
|
||||||
* @param[in] pointerOnParameter Pointer on the parameter that might be added.
|
* @param[in] pointerOnParameter Pointer on the parameter that might be added.
|
||||||
*/
|
*/
|
||||||
void signalAdd(SignalBase* _pointerOnParameter);
|
void signalAdd(ewol::signal::Base* _pointerOnParameter);
|
||||||
/**
|
/**
|
||||||
* @brief Get All the signal list:
|
* @brief Get All the signal list:
|
||||||
* @return vector on all the signals names
|
* @return vector on all the signals names
|
||||||
@ -42,9 +42,9 @@ namespace ewol {
|
|||||||
std::vector<std::string> signalGetAll() const;
|
std::vector<std::string> signalGetAll() const;
|
||||||
/**
|
/**
|
||||||
* @brief Remove binding on all event class.
|
* @brief Remove binding on all event class.
|
||||||
* @param[in] _object Object to unlink.
|
* @param[in] _sharedPtr sharedPtr to unlink (no type needed ...).
|
||||||
*/
|
*/
|
||||||
void unBindAll(const std::shared_ptr<void>& _object);
|
void signalUnBindAll(const std::shared_ptr<void>& _sharedPtr);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
303
sources/ewol/signal/Signal.h
Normal file
303
sources/ewol/signal/Signal.h
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EWOL_SIGNAL_H__
|
||||||
|
#define __EWOL_SIGNAL_H__
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <ewol/signal/Base.h>
|
||||||
|
|
||||||
|
namespace ewol {
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Signal<T>"
|
||||||
|
template<typename T> class Signal : public signal::Base {
|
||||||
|
private:
|
||||||
|
std::vector<std::pair<std::weak_ptr<void>,
|
||||||
|
std::function<void(const T&)>>> m_callerList; // current list of binded element
|
||||||
|
std::vector<std::pair<std::weak_ptr<void>,
|
||||||
|
std::function<void(const T&)>>> m_callerListInCallback; // temporaty list (when add one in call process)
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _objectLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the parameter.
|
||||||
|
* @param[in] _defaultValue Default value of the parameter.
|
||||||
|
* @param[in] _min Minumum value.
|
||||||
|
* @param[in] _max Maximum value.
|
||||||
|
* @param[in] _description description of the parameter.
|
||||||
|
*/
|
||||||
|
Signal(ewol::signal::List& _objectLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "") :
|
||||||
|
signal::Base(_objectLink, _name, _description) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Signal() { };
|
||||||
|
/**
|
||||||
|
* @brief Bind a callback function to the current signal (generic methis (simplest))
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func Link on the fuction that might be called (inside a class)
|
||||||
|
* @example signalXXXX.bind(shared_from_this(), &ClassName::onCallbackXXX);
|
||||||
|
*/
|
||||||
|
template<class TYPE_CLASS, class TYPE, typename... TArgs>
|
||||||
|
void bind(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(const T&, TArgs...), TArgs... args2) {
|
||||||
|
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
||||||
|
if (obj2 == nullptr) {
|
||||||
|
EWOL_ERROR("Can not bind signal ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_callInProgress == 0) {
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, std::forward<TArgs>(args2)...)));
|
||||||
|
} else {
|
||||||
|
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, std::forward<TArgs>(args2)...)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Advanced binding a callback function to the current signal.
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func functor to call (do it yourself)
|
||||||
|
* @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1));
|
||||||
|
*/
|
||||||
|
void connect(std::shared_ptr<void> _obj, std::function<void(const T&)> _function ) {
|
||||||
|
if (m_callInProgress == 0) {
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), _function));
|
||||||
|
} else {
|
||||||
|
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), _function));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief remove link on the signal.
|
||||||
|
* @param[in] _obj shared pointer on the removing object
|
||||||
|
*/
|
||||||
|
void release(std::shared_ptr<void> _obj) {
|
||||||
|
if (m_callInProgress == 0) {
|
||||||
|
// Remove from the list :
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
while(it != m_callerList.end()) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
it = m_callerList.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// just remove weak poointer
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
while(it != m_callerList.end()) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
it->first.reset();
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_someOneRemoveInCall = true;
|
||||||
|
}
|
||||||
|
// remove from add list in callback progress
|
||||||
|
auto it = m_callerListInCallback.begin();
|
||||||
|
while(it != m_callerListInCallback.end()) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
it = m_callerListInCallback.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Generate a signal on all interface listening.
|
||||||
|
* @param[in] _data data to emit
|
||||||
|
*/
|
||||||
|
void emit(const T& _data) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
m_signalCallLevel++;
|
||||||
|
int32_t tmpID = m_uidSignal++;
|
||||||
|
#endif
|
||||||
|
m_callInProgress++;
|
||||||
|
EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' data='" << etk::to_string(_data) << "' to: " << m_callerList.size() << " element(s)");
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
while (it != m_callerList.end()) {
|
||||||
|
std::shared_ptr<void> destObject = it->first.lock();
|
||||||
|
if (destObject == nullptr) {
|
||||||
|
it = m_callerList.erase(it);
|
||||||
|
EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " nullptr dest");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType());
|
||||||
|
it->second(_data);
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
m_callInProgress--;
|
||||||
|
#ifdef DEBUG
|
||||||
|
m_signalCallLevel--;
|
||||||
|
#endif
|
||||||
|
// Remove element in call phase:
|
||||||
|
if (m_someOneRemoveInCall == true) {
|
||||||
|
m_someOneRemoveInCall = false;
|
||||||
|
// Remove from the list :
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
while(it != m_callerList.end()) {
|
||||||
|
if (it->first.expired() == true) {
|
||||||
|
it = m_callerList.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add element in call phase:
|
||||||
|
if (m_callerListInCallback.size() > 0) {
|
||||||
|
for (auto &it : m_callerListInCallback) {
|
||||||
|
m_callerList.push_back(it);
|
||||||
|
}
|
||||||
|
m_callerListInCallback.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size_t getNumberConnected() {
|
||||||
|
return m_callerList.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Signal<void>"
|
||||||
|
template<> class Signal<void> : public signal::Base {
|
||||||
|
private:
|
||||||
|
std::vector<std::pair<std::weak_ptr<void>, std::function<void()>>> m_callerList;
|
||||||
|
std::vector<std::pair<std::weak_ptr<void>, std::function<void()>>> m_callerListInCallback;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _objectLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the parameter.
|
||||||
|
* @param[in] _defaultValue Default value of the parameter.
|
||||||
|
* @param[in] _min Minumum value.
|
||||||
|
* @param[in] _max Maximum value.
|
||||||
|
* @param[in] _description description of the parameter.
|
||||||
|
*/
|
||||||
|
Signal(ewol::signal::List& _objectLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "") :
|
||||||
|
signal::Base(_objectLink, _name, _description) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Signal() { };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bind a callback function to the current signal (generic methis (simplest))
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func Link on the fuction that might be called (inside a class)
|
||||||
|
* @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX);
|
||||||
|
*/
|
||||||
|
template<class TYPE_CLASS, class TYPE, typename... TArgs>
|
||||||
|
void bind(std::shared_ptr<TYPE_CLASS> _obj, void (TYPE::*_func)(TArgs...), TArgs... args2) {
|
||||||
|
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
||||||
|
if (obj2 == nullptr) {
|
||||||
|
EWOL_ERROR("Can not bind signal ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_callInProgress == 0) {
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::forward<TArgs>(args2)...)));
|
||||||
|
} else {
|
||||||
|
m_callerListInCallback.push_back(std::make_pair(std::weak_ptr<void>(_obj), std::bind(_func, obj2.get(), std::forward<TArgs>(args2)...)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief remove link on the signal.
|
||||||
|
* @param[in] _obj shared pointer on the removing object
|
||||||
|
*/
|
||||||
|
void release(std::shared_ptr<void> _obj) {
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
if (m_callInProgress == 0) {
|
||||||
|
// Remove from the list :
|
||||||
|
while(it != m_callerList.end()) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
//EWOL_DEBUG(" unbind : " << _obj->getObjectType() << " signal='" << m_name << "'");
|
||||||
|
it = m_callerList.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// just remove weak poointer
|
||||||
|
while(it != m_callerList.end()) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
//EWOL_DEBUG(" unbind : " << _obj->getObjectType() << " signal='" << m_name << "' (delayed)");
|
||||||
|
it->first.reset();
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_someOneRemoveInCall = true;
|
||||||
|
}
|
||||||
|
// remove from add list in callback progress
|
||||||
|
it = m_callerListInCallback.begin();
|
||||||
|
while(it != m_callerListInCallback.end()) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
//EWOL_DEBUG(" unbind : " << _obj->getObjectType() << " signal='" << m_name << "' (notActive)");
|
||||||
|
it = m_callerListInCallback.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void emit() {
|
||||||
|
#ifdef DEBUG
|
||||||
|
m_signalCallLevel++;
|
||||||
|
int32_t tmpID = m_uidSignal++;
|
||||||
|
#endif
|
||||||
|
m_callInProgress++;
|
||||||
|
EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' to: " << m_callerList.size() << " element(s)");
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
while (it != m_callerList.end()) {
|
||||||
|
std::shared_ptr<void> destObject = it->first.lock();
|
||||||
|
if (destObject == nullptr) {
|
||||||
|
it = m_callerList.erase(it);
|
||||||
|
EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " nullptr dest");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType());
|
||||||
|
it->second();
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
m_callInProgress--;
|
||||||
|
#ifdef DEBUG
|
||||||
|
m_signalCallLevel--;
|
||||||
|
#endif
|
||||||
|
// Remove element in call phase:
|
||||||
|
if (m_someOneRemoveInCall == true) {
|
||||||
|
m_someOneRemoveInCall = false;
|
||||||
|
// Remove from the list :
|
||||||
|
auto it(m_callerList.begin());
|
||||||
|
while(it != m_callerList.end()) {
|
||||||
|
if (it->first.expired() == true) {
|
||||||
|
it = m_callerList.erase(it);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add element in call phase:
|
||||||
|
if (m_callerListInCallback.size() > 0) {
|
||||||
|
for (auto &it : m_callerListInCallback) {
|
||||||
|
if (it.first.expired() == false) {
|
||||||
|
m_callerList.push_back(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_callerListInCallback.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size_t getNumberConnected() {
|
||||||
|
return m_callerList.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ nullptr
|
||||||
|
};
|
||||||
|
#endif
|
@ -17,7 +17,7 @@
|
|||||||
#include <ewol/compositing/Shaper.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Container2.h>
|
#include <ewol/widget/Container2.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -30,12 +30,12 @@ namespace ewol {
|
|||||||
class Button : public ewol::widget::Container2 {
|
class Button : public ewol::widget::Container2 {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalPressed;
|
ewol::Signal<void> signalPressed;
|
||||||
ewol::object::Signal<void> signalDown;
|
ewol::Signal<void> signalDown;
|
||||||
ewol::object::Signal<void> signalUp;
|
ewol::Signal<void> signalUp;
|
||||||
ewol::object::Signal<void> signalEnter;
|
ewol::Signal<void> signalEnter;
|
||||||
ewol::object::Signal<void> signalLeave;
|
ewol::Signal<void> signalLeave;
|
||||||
ewol::object::Signal<bool> signalValue;
|
ewol::Signal<bool> signalValue;
|
||||||
enum buttonLock{
|
enum buttonLock{
|
||||||
lockNone, //!< normal status of the button
|
lockNone, //!< normal status of the button
|
||||||
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
||||||
|
@ -17,14 +17,14 @@
|
|||||||
#include <ewol/compositing/Shaper.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
class ButtonColor : public ewol::Widget {
|
class ButtonColor : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<etk::Color<>> signalChange;
|
ewol::Signal<etk::Color<>> signalChange;
|
||||||
private:
|
private:
|
||||||
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
|
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
|
||||||
ewol::compositing::Text m_text; //!< Compositing Test display.
|
ewol::compositing::Text m_text; //!< Compositing Test display.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <ewol/compositing/Shaper.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Container2.h>
|
#include <ewol/widget/Container2.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -22,11 +22,11 @@ namespace ewol {
|
|||||||
class CheckBox : public ewol::widget::Container2 {
|
class CheckBox : public ewol::widget::Container2 {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalPressed;
|
ewol::Signal<void> signalPressed;
|
||||||
ewol::object::Signal<void> signalDown;
|
ewol::Signal<void> signalDown;
|
||||||
ewol::object::Signal<void> signalUp;
|
ewol::Signal<void> signalUp;
|
||||||
ewol::object::Signal<void> signalEnter;
|
ewol::Signal<void> signalEnter;
|
||||||
ewol::object::Signal<bool> signalValue;
|
ewol::Signal<bool> signalValue;
|
||||||
private:
|
private:
|
||||||
ewol::object::Param<ewol::compositing::Shaper> m_shaper; //!< Compositing theme.
|
ewol::object::Param<ewol::compositing::Shaper> m_shaper; //!< Compositing theme.
|
||||||
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
|
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/compositing/Drawing.h>
|
#include <ewol/compositing/Drawing.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -22,7 +22,7 @@ namespace ewol {
|
|||||||
class ColorBar : public ewol::Widget {
|
class ColorBar : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<etk::Color<>> signalChange;
|
ewol::Signal<etk::Color<>> signalChange;
|
||||||
protected:
|
protected:
|
||||||
ColorBar();
|
ColorBar();
|
||||||
void init();
|
void init();
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -34,9 +34,9 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class Entry : public ewol::Widget {
|
class Entry : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
ewol::object::Signal<void> signalClick; //!< bang on click the entry box
|
ewol::Signal<void> signalClick; //!< bang on click the entry box
|
||||||
ewol::object::Signal<std::string> signalEnter; //!< Enter key is pressed
|
ewol::Signal<std::string> signalEnter; //!< Enter key is pressed
|
||||||
ewol::object::Signal<std::string> signalModify; //!< data change
|
ewol::Signal<std::string> signalModify; //!< data change
|
||||||
private:
|
private:
|
||||||
ewol::object::Param<ewol::compositing::Shaper> m_shaper;
|
ewol::object::Param<ewol::compositing::Shaper> m_shaper;
|
||||||
int32_t m_colorIdTextFg; //!< color property of the text foreground
|
int32_t m_colorIdTextFg; //!< color property of the text foreground
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <ewol/compositing/Image.h>
|
#include <ewol/compositing/Image.h>
|
||||||
#include <ewol/resource/ColorFile.h>
|
#include <ewol/resource/ColorFile.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -26,7 +26,7 @@ namespace ewol {
|
|||||||
class Image :public ewol::Widget {
|
class Image :public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalPressed;
|
ewol::Signal<void> signalPressed;
|
||||||
protected:
|
protected:
|
||||||
ewol::compositing::Image m_compositing; //!< compositing element of the image.
|
ewol::compositing::Image m_compositing; //!< compositing element of the image.
|
||||||
std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
|
std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <draw/Color.h>
|
#include <draw/Color.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -24,9 +24,9 @@ namespace ewol {
|
|||||||
class Joystick :public ewol::Widget {
|
class Joystick :public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalEnable;
|
ewol::Signal<void> signalEnable;
|
||||||
ewol::object::Signal<void> signalDisable;
|
ewol::Signal<void> signalDisable;
|
||||||
ewol::object::Signal<vec2> signalMove;
|
ewol::Signal<vec2> signalMove;
|
||||||
public:
|
public:
|
||||||
enum joystickMode {
|
enum joystickMode {
|
||||||
modeNormal,
|
modeNormal,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/resource/ColorFile.h>
|
#include <ewol/resource/ColorFile.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -25,7 +25,7 @@ namespace ewol {
|
|||||||
class Label : public ewol::Widget {
|
class Label : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalPressed;
|
ewol::Signal<void> signalPressed;
|
||||||
private:
|
private:
|
||||||
ewol::compositing::Text m_text; //!< Compositing text element.
|
ewol::compositing::Text m_text; //!< Compositing text element.
|
||||||
ewol::object::Param<std::u32string> m_label; //!< decorated text to display.
|
ewol::object::Param<std::u32string> m_label; //!< decorated text to display.
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <ewol/widget/List.h>
|
#include <ewol/widget/List.h>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.h>
|
||||||
#include <ewol/resource/ColorFile.h>
|
#include <ewol/resource/ColorFile.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -22,10 +22,10 @@ namespace ewol {
|
|||||||
class ListFileSystem : public ewol::widget::List {
|
class ListFileSystem : public ewol::widget::List {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<std::string> signalFileSelect; //!< @event "file-select" Generated when a file is selected.
|
ewol::Signal<std::string> signalFileSelect; //!< @event "file-select" Generated when a file is selected.
|
||||||
ewol::object::Signal<std::string> signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
ewol::Signal<std::string> signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
||||||
ewol::object::Signal<std::string> signalFolderSelect;
|
ewol::Signal<std::string> signalFolderSelect;
|
||||||
ewol::object::Signal<std::string> signalFolderValidate;
|
ewol::Signal<std::string> signalFolderValidate;
|
||||||
protected:
|
protected:
|
||||||
ListFileSystem();
|
ListFileSystem();
|
||||||
void init();
|
void init();
|
||||||
|
@ -108,7 +108,7 @@ int32_t ewol::widget::Menu::add(int32_t _parent,
|
|||||||
// add it in the widget list
|
// add it in the widget list
|
||||||
ewol::widget::Sizer::subWidgetAdd(myButton);
|
ewol::widget::Sizer::subWidgetAdd(myButton);
|
||||||
// keep the specific event ...
|
// keep the specific event ...
|
||||||
myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr<ewol::widget::Button>(myButton)));
|
myButton->signalPressed.bind(shared_from_this(), &ewol::widget::Menu::onButtonPressed, std::weak_ptr<ewol::widget::Button>(myButton));
|
||||||
tmpObject.m_widgetPointer = myButton;
|
tmpObject.m_widgetPointer = myButton;
|
||||||
}
|
}
|
||||||
m_listElement.push_back(tmpObject);
|
m_listElement.push_back(tmpObject);
|
||||||
@ -231,7 +231,7 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr<ewol::widget::Button> _bu
|
|||||||
}
|
}
|
||||||
// set the image if one is present ...
|
// set the image if one is present ...
|
||||||
//myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed);
|
//myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed);
|
||||||
myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr<ewol::widget::Button>(myButton)));
|
myButton->signalPressed.bind(shared_from_this(), &ewol::widget::Menu::onButtonPressed, std::weak_ptr<ewol::widget::Button>(myButton));
|
||||||
myButton->setExpand(bvec2(true,false));
|
myButton->setExpand(bvec2(true,false));
|
||||||
myButton->setFill(bvec2(true,false));
|
myButton->setFill(bvec2(true,false));
|
||||||
// add it in the widget list
|
// add it in the widget list
|
||||||
|
@ -34,7 +34,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class Menu :public ewol::widget::Sizer {
|
class Menu :public ewol::widget::Sizer {
|
||||||
public:
|
public:
|
||||||
ewol::object::Signal<std::string> signalSelect; // event on a menu button or ...
|
ewol::Signal<std::string> signalSelect; // event on a menu button or ...
|
||||||
protected:
|
protected:
|
||||||
Menu();
|
Menu();
|
||||||
void init();
|
void init();
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/compositing/Drawing.h>
|
#include <ewol/compositing/Drawing.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -24,7 +24,7 @@ namespace ewol {
|
|||||||
class Slider : public ewol::Widget {
|
class Slider : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<float> signalChange;
|
ewol::Signal<float> signalChange;
|
||||||
protected:
|
protected:
|
||||||
Slider();
|
Slider();
|
||||||
void init();
|
void init();
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/ContainerN.h>
|
#include <ewol/widget/ContainerN.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -23,8 +23,8 @@ namespace ewol {
|
|||||||
class WSlider :public ewol::widget::ContainerN {
|
class WSlider :public ewol::widget::ContainerN {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalStartSlide;
|
ewol::Signal<void> signalStartSlide;
|
||||||
ewol::object::Signal<void> signalStopSlide;
|
ewol::Signal<void> signalStopSlide;
|
||||||
enum sladingMode {
|
enum sladingMode {
|
||||||
sladingTransitionVert,
|
sladingTransitionVert,
|
||||||
sladingTransitionHori,
|
sladingTransitionHori,
|
||||||
|
@ -31,7 +31,7 @@ namespace ewol {
|
|||||||
#include <ewol/event/Entry.h>
|
#include <ewol/event/Entry.h>
|
||||||
#include <ewol/event/Time.h>
|
#include <ewol/event/Time.h>
|
||||||
#include <ewol/translate.h>
|
#include <ewol/translate.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
#define ULTIMATE_MAX_SIZE (99999999)
|
#define ULTIMATE_MAX_SIZE (99999999)
|
||||||
|
|
||||||
@ -558,7 +558,7 @@ namespace ewol {
|
|||||||
// -- Shortcut : management of the shortcut
|
// -- Shortcut : management of the shortcut
|
||||||
// ----------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
public:
|
public:
|
||||||
ewol::object::Signal<std::string> signalShortcut; //!< signal handle of the message
|
ewol::Signal<std::string> signalShortcut; //!< signal handle of the message
|
||||||
private:
|
private:
|
||||||
std::vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget
|
std::vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget
|
||||||
protected:
|
protected:
|
||||||
@ -684,9 +684,9 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
// event generated :
|
// event generated :
|
||||||
ewol::object::Signal<void> signalAnnimationStart; //!< event when start annimation
|
ewol::Signal<void> signalAnnimationStart; //!< event when start annimation
|
||||||
ewol::object::Signal<float> signalAnnimationRatio; //!< event when % of annimation change (integer)
|
ewol::Signal<float> signalAnnimationRatio; //!< event when % of annimation change (integer)
|
||||||
ewol::object::Signal<void> signalAnnimationStop; //!< event when stop annimation
|
ewol::Signal<void> signalAnnimationStop; //!< event when stop annimation
|
||||||
protected:
|
protected:
|
||||||
enum annimationMode {
|
enum annimationMode {
|
||||||
annimationModeEnableAdd,
|
annimationModeEnableAdd,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <ewol/widget/Sizer.h>
|
#include <ewol/widget/Sizer.h>
|
||||||
#include <ewol/widget/ColorBar.h>
|
#include <ewol/widget/ColorBar.h>
|
||||||
#include <ewol/widget/Slider.h>
|
#include <ewol/widget/Slider.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -28,7 +28,7 @@ namespace ewol {
|
|||||||
class ColorChooser : public ewol::widget::Sizer {
|
class ColorChooser : public ewol::widget::Sizer {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<etk::Color<>> signalChange;
|
ewol::Signal<etk::Color<>> signalChange;
|
||||||
protected:
|
protected:
|
||||||
ColorChooser();
|
ColorChooser();
|
||||||
void init();
|
void init();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Composer.h>
|
#include <ewol/widget/Composer.h>
|
||||||
#include <ewol/object/Signal.h>
|
#include <ewol/signal/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -67,8 +67,8 @@ namespace ewol {
|
|||||||
class FileChooser : public ewol::widget::Composer {
|
class FileChooser : public ewol::widget::Composer {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalCancel;
|
ewol::Signal<void> signalCancel;
|
||||||
ewol::object::Signal<std::string> signalValidate;
|
ewol::Signal<std::string> signalValidate;
|
||||||
protected:
|
protected:
|
||||||
FileChooser();
|
FileChooser();
|
||||||
void init();
|
void init();
|
||||||
|
@ -29,7 +29,7 @@ namespace ewol {
|
|||||||
class Parameter : public ewol::widget::PopUp {
|
class Parameter : public ewol::widget::PopUp {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<void> signalClose;
|
ewol::Signal<void> signalClose;
|
||||||
protected:
|
protected:
|
||||||
Parameter();
|
Parameter();
|
||||||
void init();
|
void init();
|
||||||
|
@ -39,7 +39,7 @@ namespace ewol {
|
|||||||
class ParameterList :public ewol::widget::WidgetScrolled {
|
class ParameterList :public ewol::widget::WidgetScrolled {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
ewol::object::Signal<int32_t> signalSelect;
|
ewol::Signal<int32_t> signalSelect;
|
||||||
private:
|
private:
|
||||||
int32_t m_idSelected;
|
int32_t m_idSelected;
|
||||||
std::vector<ewol::widget::elementPL *> m_list;
|
std::vector<ewol::widget::elementPL *> m_list;
|
||||||
|
@ -93,9 +93,12 @@ def create(target):
|
|||||||
'ewol/object/Worker.cpp',
|
'ewol/object/Worker.cpp',
|
||||||
'ewol/object/Parameter.cpp',
|
'ewol/object/Parameter.cpp',
|
||||||
'ewol/object/ParameterList.cpp',
|
'ewol/object/ParameterList.cpp',
|
||||||
'ewol/object/ParamList.cpp',
|
'ewol/object/ParamList.cpp'
|
||||||
'ewol/object/SignalList.cpp',
|
])
|
||||||
'ewol/object/SignalBase.cpp'
|
# object :
|
||||||
|
myModule.add_src_file([
|
||||||
|
'ewol/signal/List.cpp',
|
||||||
|
'ewol/signal/Base.cpp'
|
||||||
])
|
])
|
||||||
|
|
||||||
# OpenGL interface :
|
# OpenGL interface :
|
||||||
|
Loading…
Reference in New Issue
Block a user