[DEV] update new signal system
This commit is contained in:
parent
e3f71e5201
commit
7edbc3a0cf
2
external/ege
vendored
2
external/ege
vendored
@ -1 +1 @@
|
||||
Subproject commit 87b68c408e3bceff1923e84d2e08fcee9d868561
|
||||
Subproject commit cddef97574c4066bc778b529791bd168ecf731cf
|
@ -18,23 +18,10 @@
|
||||
|
||||
namespace ewol {
|
||||
namespace object {
|
||||
class SignalCallerIdentifier {
|
||||
public:
|
||||
std::weak_ptr<ewol::Object> m_object;
|
||||
const char* m_enevntId;
|
||||
std::string m_data;
|
||||
SignalCallerIdentifier(std::shared_ptr<ewol::Object> _object, const char* _enevntId, const std::string& _data) :
|
||||
m_object(_object),
|
||||
m_enevntId(_enevntId),
|
||||
m_data(_data) {
|
||||
// nothing to do ...
|
||||
}
|
||||
};
|
||||
template<typename T> class Signal : public SignalBase {
|
||||
private:
|
||||
std::vector<std::pair<std::weak_ptr<ewol::Object>,
|
||||
std::function<void(const T&)>>> m_callerList;
|
||||
std::vector<SignalCallerIdentifier> m_serializedCallerList;
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
@ -61,13 +48,13 @@ namespace ewol {
|
||||
* @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, typename... Args> void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)(const T&), Args... args) {
|
||||
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _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;
|
||||
}
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1, args...)));
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1)));
|
||||
}
|
||||
/**
|
||||
* @brief Advanced binding a callback function to the current signal.
|
||||
@ -78,23 +65,11 @@ namespace ewol {
|
||||
void connect(std::shared_ptr<ewol::Object> _obj, std::function<void(const T&)> _function ) {
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), _function));
|
||||
}
|
||||
/**
|
||||
* @brief DEPRECATED: old connect signal between Objects
|
||||
*/
|
||||
void connect(std::shared_ptr<ewol::Object> _obj, const char* _destId=nullptr, const std::string& _data="" ) __attribute__ ((deprecated)) {
|
||||
m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data));
|
||||
}
|
||||
/**
|
||||
* @brief remove link on the signal.
|
||||
* @param[in] _obj shared pointer on the removing object
|
||||
*/
|
||||
void release(std::shared_ptr<ewol::Object> _obj) {
|
||||
for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) {
|
||||
if (it->m_object.lock() == _obj) {
|
||||
m_serializedCallerList.erase(it);
|
||||
it = m_serializedCallerList.begin();
|
||||
}
|
||||
}
|
||||
for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) {
|
||||
if (it->first.lock() == _obj) {
|
||||
m_callerList.erase(it);
|
||||
@ -106,36 +81,7 @@ namespace ewol {
|
||||
* @brief Generate a signal on all interface listening.
|
||||
* @param[in] _data data to emit
|
||||
*/
|
||||
void emit(const std::shared_ptr<ewol::Object>& _source, const T& _data) __attribute__ ((deprecated)) {
|
||||
emit(_data);
|
||||
}
|
||||
void emit(const T& _data) {
|
||||
// note : this can not emit on function ....
|
||||
if (m_serializedCallerList.size()>0 ) {
|
||||
std::string stringData = etk::to_string(_data);
|
||||
for (auto &it : m_serializedCallerList) {
|
||||
std::shared_ptr<ewol::Object> destObject = it.m_object.lock();
|
||||
if (destObject == nullptr) {
|
||||
// TODO : Remove instance ...
|
||||
EWOL_VERBOSE(" nullptr dest");
|
||||
continue;
|
||||
}
|
||||
const char* eventId = m_name.c_str();
|
||||
if (it.m_enevntId != nullptr) {
|
||||
eventId = it.m_enevntId;
|
||||
}
|
||||
if (it.m_data.size() <= 0){
|
||||
ewol::object::Message tmpMsg(eventId, stringData);
|
||||
EWOL_VERBOSE("send message " << tmpMsg);
|
||||
destObject->onReceiveMessage(tmpMsg);
|
||||
} else {
|
||||
// set the user requested data ...
|
||||
ewol::object::Message tmpMsg(eventId, it.m_data);
|
||||
EWOL_VERBOSE("send message " << tmpMsg);
|
||||
destObject->onReceiveMessage(tmpMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto &it : m_callerList) {
|
||||
std::shared_ptr<ewol::Object> destObject = it.first.lock();
|
||||
if (destObject == nullptr) {
|
||||
@ -150,9 +96,7 @@ namespace ewol {
|
||||
|
||||
template<> class Signal<void> : public SignalBase {
|
||||
private:
|
||||
std::vector<std::pair<std::weak_ptr<ewol::Object>,
|
||||
std::function<void()>>> m_callerList;
|
||||
std::vector<SignalCallerIdentifier> m_serializedCallerList;
|
||||
std::vector<std::pair<std::weak_ptr<ewol::Object>, std::function<void()>>> m_callerList;
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
@ -180,13 +124,13 @@ namespace ewol {
|
||||
* @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, typename... Args> void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)(), Args... args) {
|
||||
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _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;
|
||||
}
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get(), args...)));
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get())));
|
||||
}
|
||||
/**
|
||||
* @brief Advanced binding a callback function to the current signal.
|
||||
@ -197,23 +141,11 @@ namespace ewol {
|
||||
void connect(std::shared_ptr<ewol::Object> _obj, std::function<void()> _function ) {
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), _function));
|
||||
}
|
||||
/**
|
||||
* @brief DEPRECATED: old connect signal between Objects
|
||||
*/
|
||||
void connect(std::shared_ptr<ewol::Object> _obj, const char* _destId=nullptr, const std::string& _data="" ) __attribute__ ((deprecated)) {
|
||||
m_serializedCallerList.push_back(SignalCallerIdentifier(_obj, _destId, _data));
|
||||
}
|
||||
/**
|
||||
* @brief remove link on the signal.
|
||||
* @param[in] _obj shared pointer on the removing object
|
||||
*/
|
||||
void release(std::shared_ptr<ewol::Object> _obj) {
|
||||
for (auto it(m_serializedCallerList.begin()) ; it != m_serializedCallerList.end(); ++it) {
|
||||
if (it->m_object.lock() == _obj) {
|
||||
m_serializedCallerList.erase(it);
|
||||
it = m_serializedCallerList.begin();
|
||||
}
|
||||
}
|
||||
for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) {
|
||||
if (it->first.lock() == _obj) {
|
||||
m_callerList.erase(it);
|
||||
@ -221,34 +153,7 @@ namespace ewol {
|
||||
}
|
||||
}
|
||||
}
|
||||
void emit(const std::shared_ptr<ewol::Object>& _source) __attribute__ ((deprecated)) {
|
||||
emit();
|
||||
}
|
||||
void emit() {
|
||||
// note : this can not emit on function ....
|
||||
std::string stringData;
|
||||
for (auto &it : m_serializedCallerList) {
|
||||
std::shared_ptr<ewol::Object> destObject = it.m_object.lock();
|
||||
if (destObject == nullptr) {
|
||||
// TODO : Remove instance ...
|
||||
EWOL_VERBOSE(" nullptr dest");
|
||||
continue;
|
||||
}
|
||||
const char* eventId = m_name.c_str();
|
||||
if (it.m_enevntId != nullptr) {
|
||||
eventId = it.m_enevntId;
|
||||
}
|
||||
if (it.m_data.size() <= 0){
|
||||
ewol::object::Message tmpMsg(eventId, stringData);
|
||||
EWOL_VERBOSE("send message " << tmpMsg);
|
||||
destObject->onReceiveMessage(tmpMsg);
|
||||
} else {
|
||||
// set the user requested data ...
|
||||
ewol::object::Message tmpMsg(eventId, it.m_data);
|
||||
EWOL_VERBOSE("send message " << tmpMsg);
|
||||
destObject->onReceiveMessage(tmpMsg);
|
||||
}
|
||||
}
|
||||
for (auto &it : m_callerList) {
|
||||
std::shared_ptr<ewol::Object> destObject = it.first.lock();
|
||||
if (destObject == nullptr) {
|
||||
|
@ -42,7 +42,6 @@ namespace ewol {
|
||||
const std::string& getDescription() const {
|
||||
return m_description;
|
||||
}
|
||||
virtual void connect(std::shared_ptr<ewol::Object> _obj, const char* _destId=nullptr, const std::string& _data="" ) = 0;
|
||||
virtual void release(std::shared_ptr<ewol::Object> _obj) = 0;
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const SignalBase& _obj);
|
||||
|
@ -45,7 +45,8 @@ void ewol::object::SignalList::registerOnObjectEvent(const std::shared_ptr<ewol:
|
||||
const char * _eventId,
|
||||
const char * _eventIdgenerated,
|
||||
const std::string& _overloadData) {
|
||||
ewol::object::Manager& tmp = ewol::getContext().getEObjectManager();
|
||||
EWOL_TODO("RegisterOnEvent ... + name");
|
||||
/*ewol::object::Manager& tmp = ewol::getContext().getEObjectManager();
|
||||
std::shared_ptr<ewol::Object> tmpObject = tmp.getObjectNamed(_objectName);
|
||||
if (nullptr != tmpObject) {
|
||||
EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'");
|
||||
@ -53,12 +54,15 @@ void ewol::object::SignalList::registerOnObjectEvent(const std::shared_ptr<ewol:
|
||||
} else {
|
||||
EWOL_WARNING(" Can not register event : '" << _eventId << "' the object named='" << _objectName << "' does not exist");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ewol::object::SignalList::registerOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
||||
const char * _eventId,
|
||||
const char * _eventIdgenerated,
|
||||
const std::string& _overloadData) {
|
||||
EWOL_TODO("RegisterOnEvent ...");
|
||||
/*
|
||||
if (_destinationObject == nullptr) {
|
||||
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
||||
return;
|
||||
@ -93,10 +97,13 @@ void ewol::object::SignalList::registerOnEvent(const std::shared_ptr<ewol::Objec
|
||||
EWOL_ERROR("Can not register event on this event=\"" << _eventId << "\" == > unknow event");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
||||
const char * _eventId) {
|
||||
EWOL_TODO("unRegisterOnEvent ...");
|
||||
/*
|
||||
if (_destinationObject == nullptr) {
|
||||
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
||||
return;
|
||||
@ -111,4 +118,5 @@ void ewol::object::SignalList::unRegisterOnEvent(const std::shared_ptr<ewol::Obj
|
||||
it->release(_destinationObject);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -67,14 +67,14 @@ namespace ewol {
|
||||
void registerOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
||||
const char * _eventId,
|
||||
const char * _eventIdgenerated = nullptr,
|
||||
const std::string& _overloadData = "");
|
||||
const std::string& _overloadData = "") __attribute__ ((deprecated));
|
||||
/**
|
||||
* @brief Un-Register an Object over an other.
|
||||
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
|
||||
* @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object)
|
||||
*/
|
||||
void unRegisterOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
||||
const char * _eventId = nullptr);
|
||||
const char * _eventId = nullptr) __attribute__ ((deprecated));
|
||||
/**
|
||||
* @brief Receive a message from an other Object with a specific eventId and data
|
||||
* @param[in] _msg Message handle
|
||||
|
@ -182,7 +182,7 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
|
||||
myColorChooser->setColor(m_textColorFg);
|
||||
// set it in the pop-up-system :
|
||||
m_widgetContextMenu->setSubWidget(myColorChooser);
|
||||
myColorChooser->registerOnEvent(shared_from_this(), "change", eventColorHasChange);
|
||||
myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange);
|
||||
std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows();
|
||||
if (currentWindows == nullptr) {
|
||||
EWOL_ERROR("Can not get the curent Windows...");
|
||||
@ -209,8 +209,11 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
|
||||
return m_mouseHover;
|
||||
}
|
||||
|
||||
void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color) {
|
||||
setValue(_color);
|
||||
}
|
||||
|
||||
void ewol::widget::ButtonColor::setValue(etk::Color<> _color) {
|
||||
void ewol::widget::ButtonColor::setValue(const etk::Color<>& _color) {
|
||||
m_textColorFg = _color;
|
||||
markToRedraw();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace ewol {
|
||||
* @brief Specify the current color.
|
||||
* @param[in] _color The new display color.
|
||||
*/
|
||||
void setValue(etk::Color<> _color);
|
||||
void setValue(const etk::Color<>& _color);
|
||||
protected: // Derived function
|
||||
virtual void onDraw();
|
||||
public: // Derived function
|
||||
@ -79,6 +79,8 @@ namespace ewol {
|
||||
void changeStatusIn(int32_t _newStatusId);
|
||||
// Derived function
|
||||
virtual void periodicCall(const ewol::event::Time& _event);
|
||||
// Callback function:
|
||||
void onCallbackColorChange(const etk::Color<>& _color);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -58,6 +58,23 @@ namespace ewol {
|
||||
*/
|
||||
bool loadFromString(const std::string& _composerXmlString);
|
||||
protected:
|
||||
// TODO : Create a template ...
|
||||
#define composerBind(_type, _name, _event, _obj, _func) do {\
|
||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getObjectNamed(_name)); \
|
||||
if (myObject != nullptr) { \
|
||||
myObject->_event.bind(_obj, _func); \
|
||||
} \
|
||||
} while (false)
|
||||
/*
|
||||
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _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;
|
||||
}
|
||||
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get())));
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* @brief Register an Event an named widget. @see registerOnEvent
|
||||
* @param[in] _subWidgetName Name of the subWidget.
|
||||
@ -69,8 +86,14 @@ namespace ewol {
|
||||
void registerOnEventNameWidget(const std::string& _subWidgetName,
|
||||
const char * _eventId,
|
||||
const char * _eventIdgenerated = nullptr,
|
||||
const std::string& _overloadData="");
|
||||
const std::string& _overloadData="") __attribute__ ((deprecated));
|
||||
public:
|
||||
#define composerExternBind(_composer, _type, _name, _event, _obj, _func) do {\
|
||||
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_composer->getObjectNamed(_name)); \
|
||||
if (myObject != nullptr) { \
|
||||
myObject->_event.bind(_obj, _func); \
|
||||
} \
|
||||
} while (false)
|
||||
/**
|
||||
* @brief Register an Event an named widget. @see registerOnEvent
|
||||
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
|
||||
@ -84,7 +107,7 @@ namespace ewol {
|
||||
const std::string& _subWidgetName,
|
||||
const char * _eventId,
|
||||
const char * _eventIdgenerated = nullptr,
|
||||
const std::string& _overloadData="");
|
||||
const std::string& _overloadData="") __attribute__ ((deprecated));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -97,9 +97,6 @@ int32_t ewol::widget::Menu::add(int32_t _parent,
|
||||
// add it in the widget list
|
||||
ewol::widget::Sizer::subWidgetAdd(myButton);
|
||||
// keep the specific event ...
|
||||
//myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed);
|
||||
std::weak_ptr<ewol::widget::Button> myButtonWeak(myButton);
|
||||
//myButton->signalPressed.bind(shared_from_this(), &ewol::widget::Menu::onButtonPressed, myButtonWeak);
|
||||
myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr<ewol::widget::Button>(myButton)));
|
||||
tmpObject.m_widgetPointer = myButton;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void ewol::widget::ColorChooser::init() {
|
||||
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
|
||||
lockExpand(bvec2(true,true));
|
||||
m_widgetColorBar = ewol::widget::ColorBar::create();
|
||||
m_widgetColorBar->registerOnEvent(shared_from_this(), "change", eventColorBarHasChange);
|
||||
m_widgetColorBar->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChange);
|
||||
m_widgetColorBar->setFill(bvec2(true,true));
|
||||
subWidgetAdd(m_widgetColorBar);
|
||||
|
||||
@ -164,3 +164,10 @@ void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const int32_t& _newC
|
||||
}
|
||||
signalChange.emit(m_currentColor);
|
||||
}
|
||||
void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) {
|
||||
m_currentColor = _newColor;
|
||||
if (nullptr != m_widgetColorBar) {
|
||||
m_widgetColorBar->setCurrentColor(m_currentColor);
|
||||
}
|
||||
signalChange.emit(m_currentColor);
|
||||
}
|
@ -51,6 +51,7 @@ namespace ewol {
|
||||
void onCallbackColorChangeGreen(const int32_t& _newColor);
|
||||
void onCallbackColorChangeBlue(const int32_t& _newColor);
|
||||
void onCallbackColorChangeAlpha(const int32_t& _newColor);
|
||||
void onCallbackColorChange(const etk::Color<>& _newColor);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -10,6 +10,10 @@
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <ewol/widget/Sizer.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/ListFileSystem.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Image.h>
|
||||
#include <ewol/widget/Composer.h>
|
||||
@ -29,20 +33,6 @@ extern "C" {
|
||||
#undef __class__
|
||||
#define __class__ "FileChooser"
|
||||
|
||||
|
||||
static const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel";
|
||||
static const char * const ewolEventFileChooserValidate = "ewol-event-file-chooser-validate";
|
||||
static const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files";
|
||||
static const char * const ewolEventFileChooserEntryFolder = "ewol-event-file-chooser-modify-entry-folder";
|
||||
static const char * const ewolEventFileChooserEntryFolderEnter = "ewol-event-file-chooser-modify-entry-folder-enter";
|
||||
static const char * const ewolEventFileChooserEntryFile = "ewol-event-file-chooser-modify-entry-file";
|
||||
static const char * const ewolEventFileChooserEntryFileEnter = "ewol-event-file-chooser-modify-entry-file-enter";
|
||||
static const char * const ewolEventFileChooserListFolder = "ewol-event-file-chooser-modify-list-folder";
|
||||
static const char * const ewolEventFileChooserListFile = "ewol-event-file-chooser-modify-list-file";
|
||||
static const char * const ewolEventFileChooserListFileValidate = "ewol-event-file-chooser-modify-list-file-validate";
|
||||
static const char * const ewolEventFileChooserHome = "ewol-event-file-chooser-home";
|
||||
|
||||
|
||||
ewol::widget::FileChooser::FileChooser() :
|
||||
signalCancel(*this, "cancel"),
|
||||
signalValidate(*this, "validate") {
|
||||
@ -105,17 +95,17 @@ void ewol::widget::FileChooser::init() {
|
||||
+ " </sizer>\n"
|
||||
+ "</popup>";
|
||||
loadFromString(myDescription);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", "value", ewolEventFileChooserHidenFileChange);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-validate", "pressed", ewolEventFileChooserValidate);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-cancel", "pressed", ewolEventFileChooserCancel);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "folder-validate", ewolEventFileChooserListFolder);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-select", ewolEventFileChooserListFile);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-validate", ewolEventFileChooserListFileValidate);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "modify", ewolEventFileChooserEntryFile);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "enter", ewolEventFileChooserEntryFileEnter);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "modify", ewolEventFileChooserEntryFolder);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "enter", ewolEventFileChooserEntryFolderEnter);
|
||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:img-home", "pressed", ewolEventFileChooserHome);
|
||||
composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", signalValue, shared_from_this(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue);
|
||||
composerBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-validate", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackListValidate);
|
||||
composerBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-cancel", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed);
|
||||
composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-folder", signalFolderValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFolderSelectChange);
|
||||
composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileSelect, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileSelectChange);
|
||||
composerBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate);
|
||||
composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValue);
|
||||
composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalEnter, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate);
|
||||
composerBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFolderChangeValue);
|
||||
//composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalEnter, shared_from_this(), &ewol::widget::FileChooser::);
|
||||
composerBind(ewol::widget::Image, "[" + etk::to_string(getId()) + "]file-shooser:img-home", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackHomePressed);
|
||||
// set the default Folder properties:
|
||||
updateCurrentFolder();
|
||||
setCanHaveFocus(true);
|
||||
@ -152,62 +142,78 @@ void ewol::widget::FileChooser::setFileName(const std::string& _filename) {
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "value", _filename);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
EWOL_INFO("Receive Event from the LIST ... : " << _msg);
|
||||
if (_msg.getMessage() == ewolEventFileChooserEntryFolder) {
|
||||
// == > change the folder name
|
||||
// TODO : change the folder, if it exit ...
|
||||
} else if (_msg.getMessage() == ewolEventFileChooserEntryFile) {
|
||||
// == > change the file name
|
||||
m_file = _msg.getData();
|
||||
// update the selected file in the list :
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file);
|
||||
} else if (ewolEventFileChooserCancel == _msg.getMessage()) {
|
||||
// == > Auto remove ...
|
||||
signalCancel.emit();
|
||||
autoDestroy();
|
||||
} else if (_msg.getMessage() == ewolEventFileChooserHidenFileChange) {
|
||||
if (_msg.getData() == "true") {
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "true");
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "true");
|
||||
} else {
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "false");
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "false");
|
||||
}
|
||||
} else if (_msg.getMessage() == ewolEventFileChooserListFolder) {
|
||||
// == > this is an internal event ...
|
||||
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _msg.getData() << "\"");
|
||||
m_folder = m_folder + _msg.getData();
|
||||
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
|
||||
m_folder = etk::simplifyPath(m_folder);
|
||||
setFileName("");
|
||||
updateCurrentFolder();
|
||||
} else if (_msg.getMessage() == ewolEventFileChooserListFile) {
|
||||
setFileName(_msg.getData());
|
||||
std::string tmpFileCompleatName = m_folder;
|
||||
tmpFileCompleatName += m_file;
|
||||
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
|
||||
} else if( _msg.getMessage() == ewolEventFileChooserListFileValidate
|
||||
|| (_msg.getMessage() == ewolEventFileChooserValidate && m_file != "" )
|
||||
|| (_msg.getMessage() == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) {
|
||||
// select the file == > generate a validate
|
||||
if (_msg.getData() != "") {
|
||||
setFileName(_msg.getData());
|
||||
}
|
||||
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\"");
|
||||
signalValidate.emit(getCompleateFileName());
|
||||
autoDestroy();
|
||||
} else if(_msg.getMessage() == ewolEventFileChooserHome) {
|
||||
std::string tmpUserFolder = etk::getUserHomeFolder();
|
||||
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");
|
||||
|
||||
m_folder = etk::simplifyPath(tmpUserFolder);
|
||||
|
||||
setFileName("");
|
||||
updateCurrentFolder();
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue(const std::string& _value) {
|
||||
// == > change the folder name
|
||||
// TODO : change the folder, if it exit ...
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackEntryFileChangeValue(const std::string& _value) {
|
||||
// == > change the file name
|
||||
m_file = _value;
|
||||
// update the selected file in the list :
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackButtonCancelPressed() {
|
||||
// == > Auto remove ...
|
||||
signalCancel.emit();
|
||||
autoDestroy();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue(const bool& _value) {
|
||||
if (_value == true) {
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "true");
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "true");
|
||||
} else {
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "false");
|
||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "false");
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const std::string& _value) {
|
||||
// == > this is an internal event ...
|
||||
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _value << "\"");
|
||||
m_folder = m_folder + _value;
|
||||
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
|
||||
m_folder = etk::simplifyPath(m_folder);
|
||||
setFileName("");
|
||||
updateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) {
|
||||
setFileName(_value);
|
||||
std::string tmpFileCompleatName = m_folder;
|
||||
tmpFileCompleatName += m_file;
|
||||
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) {
|
||||
// select the file == > generate a validate
|
||||
setFileName(_value);
|
||||
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\"");
|
||||
signalValidate.emit(getCompleateFileName());
|
||||
autoDestroy();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListValidate() {
|
||||
if (m_file != "" ) {
|
||||
return;
|
||||
}
|
||||
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\"");
|
||||
signalValidate.emit(getCompleateFileName());
|
||||
autoDestroy();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackHomePressed() {
|
||||
std::string tmpUserFolder = etk::getUserHomeFolder();
|
||||
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");
|
||||
|
||||
m_folder = etk::simplifyPath(tmpUserFolder);
|
||||
|
||||
setFileName("");
|
||||
updateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::updateCurrentFolder() {
|
||||
if (m_folder != "" ) {
|
||||
|
@ -95,8 +95,18 @@ namespace ewol {
|
||||
std::string getCompleateFileName();
|
||||
void updateCurrentFolder();
|
||||
public: // Derived function
|
||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
||||
virtual void onGetFocus();
|
||||
private:
|
||||
// callback functions:
|
||||
void onCallbackEntryFolderChangeValue(const std::string& _value);
|
||||
void onCallbackEntryFileChangeValue(const std::string& _value);
|
||||
void onCallbackButtonCancelPressed();
|
||||
void onCallbackHidenFileChangeChangeValue(const bool& _value);
|
||||
void onCallbackListFolderSelectChange(const std::string& _value);
|
||||
void onCallbackListFileSelectChange(const std::string& _value);
|
||||
void onCallbackListFileValidate(const std::string& _value);
|
||||
void onCallbackListValidate();
|
||||
void onCallbackHomePressed();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -20,10 +20,6 @@
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Parameter"
|
||||
static const char * const ewolEventParameterValidate = "ewol-event-parameter-validate";
|
||||
static const char * const ewolEventParameterSave = "ewol-event-parameter-save";
|
||||
static const char * const l_eventMenuSelected = "local-event-menu-selected";
|
||||
static const char * const ewolEventMenuclosed = "local-event-menu-closed";
|
||||
|
||||
ewol::widget::Parameter::Parameter() :
|
||||
signalClose(*this, "close"),
|
||||
@ -80,7 +76,7 @@ void ewol::widget::Parameter::init() {
|
||||
" <label>Save</label>\n"
|
||||
" </sizer>\n"
|
||||
"</composer>\n"));
|
||||
tmpButton->registerOnEvent(shared_from_this(), "pressed", ewolEventParameterSave);
|
||||
tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackParameterSave);
|
||||
mySizerHori->subWidgetAdd(tmpButton);
|
||||
}
|
||||
|
||||
@ -104,7 +100,7 @@ void ewol::widget::Parameter::init() {
|
||||
" <label>Close</label>\n"
|
||||
" </sizer>\n"
|
||||
"</composer>\n"));
|
||||
tmpButton->registerOnEvent(shared_from_this(), "pressed", ewolEventMenuclosed);
|
||||
tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuclosed);
|
||||
mySizerHori->subWidgetAdd(tmpButton);
|
||||
}
|
||||
}
|
||||
@ -120,7 +116,7 @@ void ewol::widget::Parameter::init() {
|
||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
|
||||
m_paramList->registerOnEvent(shared_from_this(), "select", l_eventMenuSelected);
|
||||
m_paramList->signalSelect.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuSelected);
|
||||
m_paramList->setFill(bvec2(false,true));
|
||||
m_paramList->setExpand(bvec2(false,true));
|
||||
mySizerHori->subWidgetAdd(m_paramList);
|
||||
@ -195,26 +191,21 @@ void ewol::widget::Parameter::setTitle(std::string _label) {
|
||||
m_widgetTitle->setLabel(_label);
|
||||
}
|
||||
|
||||
void ewol::widget::Parameter::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
ewol::widget::PopUp::onReceiveMessage(_msg);
|
||||
EWOL_DEBUG("event on the parameter : " << _msg);
|
||||
if (_msg.getMessage() == ewolEventMenuclosed) {
|
||||
// inform that the parameter windows is closed
|
||||
signalClose.emit();
|
||||
// close this widget ...
|
||||
autoDestroy();
|
||||
} else if (_msg.getMessage() == ewolEventParameterSave) {
|
||||
//ewol::userConfig::Save();
|
||||
EWOL_TODO("Save Parameter !!! ");
|
||||
} else if (_msg.getMessage() == l_eventMenuSelected) {
|
||||
if (nullptr != m_wSlider) {
|
||||
int32_t value = 0;
|
||||
sscanf(_msg.getData().c_str(), "%d", &value);
|
||||
EWOL_DEBUG("event on the parameter : " << _msg.getMessage() << " select ID=" << value << "");
|
||||
m_wSlider->subWidgetSelectSet(value);
|
||||
}
|
||||
void ewol::widget::Parameter::onCallbackMenuclosed() {
|
||||
// inform that the parameter windows is closed
|
||||
signalClose.emit();
|
||||
// close this widget ...
|
||||
autoDestroy();
|
||||
}
|
||||
void ewol::widget::Parameter::onCallbackParameterSave() {
|
||||
//ewol::userConfig::Save();
|
||||
EWOL_TODO("Save Parameter !!! ");
|
||||
}
|
||||
void ewol::widget::Parameter::onCallbackMenuSelected(const int32_t& _value) {
|
||||
if (m_wSlider != nullptr) {
|
||||
EWOL_DEBUG("event on the parameter : Menu-select select ID=" << _value << "");
|
||||
m_wSlider->subWidgetSelectSet(_value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget) {
|
||||
|
@ -36,8 +36,6 @@ namespace ewol {
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Parameter, "Parameter");
|
||||
virtual ~Parameter();
|
||||
public: // Derived function
|
||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
||||
public:
|
||||
void setTitle(std::string _label);
|
||||
void menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget);
|
||||
@ -49,6 +47,10 @@ namespace ewol {
|
||||
std::shared_ptr<ewol::widget::Label> m_widgetTitle;
|
||||
std::shared_ptr<ewol::widget::ParameterList> m_paramList;
|
||||
std::shared_ptr<ewol::widget::WSlider> m_wSlider;
|
||||
private: //callback functions:
|
||||
void onCallbackMenuclosed();
|
||||
void onCallbackParameterSave();
|
||||
void onCallbackMenuSelected(const int32_t& _value);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -16,8 +16,6 @@
|
||||
#undef __class__
|
||||
#define __class__ "ewol::StdPopUp"
|
||||
|
||||
static const char * const eventButtonExit = "ewol-event-pop-up-exit-button";
|
||||
|
||||
ewol::widget::StdPopUp::StdPopUp() :
|
||||
m_title(nullptr),
|
||||
m_comment(nullptr),
|
||||
@ -107,17 +105,13 @@ std::shared_ptr<ewol::widget::Button> ewol::widget::StdPopUp::addButton(const st
|
||||
}
|
||||
myButton->setSubWidget(ewol::widget::Label::create(_text));
|
||||
if(_autoExit == true) {
|
||||
myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonExit);
|
||||
myButton->signalPressed.bind(shared_from_this(), &ewol::widget::StdPopUp::onCallBackButtonExit);
|
||||
}
|
||||
m_subBar->subWidgetAdd(myButton);
|
||||
markToRedraw();
|
||||
return myButton;
|
||||
}
|
||||
|
||||
void ewol::widget::StdPopUp::onReceiveMessage(const ewol::object::Message& _msg) {
|
||||
// call parent:
|
||||
ewol::widget::PopUp::onReceiveMessage(_msg);
|
||||
if (_msg.getMessage() == eventButtonExit) {
|
||||
autoDestroy();
|
||||
}
|
||||
void ewol::widget::StdPopUp::onCallBackButtonExit() {
|
||||
autoDestroy();
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ namespace ewol {
|
||||
* @param[in] _text Decorated text to diplay in button.
|
||||
*/
|
||||
std::shared_ptr<ewol::widget::Button> addButton(const std::string& _text, bool _autoExit=false);
|
||||
public: // Derived function
|
||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
||||
public: // callback function
|
||||
void onCallBackButtonExit();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user