[DEBUG] add some object functionnality and remove some button error

This commit is contained in:
Edouard DUPIN 2014-06-21 20:46:41 +02:00
parent d51301924a
commit beaf2179c6
10 changed files with 195 additions and 45 deletions

2
build

@ -1 +1 @@
Subproject commit 0ae540881a3ddaf8fe2fd3cfbb5131f3d22fe0fc Subproject commit ec60375c9fdf6ae46db9ee5574ec8837e531e5fa

View File

@ -178,3 +178,13 @@ void ewol::object::Manager::rm(ewol::object::RemoveEvent* _class) {
} }
} }
ewol::object::Shared<ewol::Object> ewol::object::Manager::getObjectNamed(const std::string& _name) {
for (auto &it : m_eObjectList) {
if ( it != nullptr
&& _name == it->getName()) {
return it;
}
}
return nullptr;
}

View File

@ -69,6 +69,14 @@ namespace ewol {
void add(ewol::object::RemoveEvent* _class); void add(ewol::object::RemoveEvent* _class);
void rm(ewol::object::RemoveEvent* _class); void rm(ewol::object::RemoveEvent* _class);
public:
/**
* @brief retrive an object with his name
* @param[in] _name Name of the object
* @return the requested object or nullptr
*/
ewol::object::Shared<ewol::Object> getObjectNamed(const std::string& _name);
}; };
}; };
}; };

View File

@ -472,14 +472,32 @@ bool ewol::Object::setConfigNamed(const std::string& _objectName, const std::str
return object->setConfig(_config, _value); return object->setConfig(_config, _value);
} }
ewol::object::Manager& ewol::Object::getObjectManager() { ewol::object::Manager& ewol::Object::getObjectManager() const {
return ewol::getContext().getEObjectManager(); return ewol::getContext().getEObjectManager();
} }
ewol::object::MultiCast& ewol::Object::getMultiCast() { ewol::object::MultiCast& ewol::Object::getMultiCast() const {
return ewol::getContext().getEObjectManager().multiCast(); return ewol::getContext().getEObjectManager().multiCast();
} }
ewol::Context& ewol::Object::getContext() { ewol::Context& ewol::Object::getContext() const {
return ewol::getContext(); return ewol::getContext();
} }
void ewol::Object::registerOnObjectEvent(const ewol::object::Shared<ewol::Object>& _destinationObject,
const std::string& _objectName,
const char * _eventId,
const char * _eventIdgenerated,
const std::string& _overloadData) {
ewol::object::Shared<ewol::Object> tmpObject = getObjectManager().getObjectNamed(_objectName);
if (nullptr != tmpObject) {
EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'");
tmpObject->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData);
} else {
EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Can not register event : \"" << _eventId << "\" the object named=\"" << _objectName << "\" does not exist");
}
}
ewol::object::Shared<ewol::Object> ewol::Object::getObjectNamed(const std::string& _objectName) const {
return getObjectManager().getObjectNamed(_objectName);
}

View File

@ -312,17 +312,17 @@ namespace ewol {
* @breif get the current Object manager. * @breif get the current Object manager.
* @return the requested object manager. * @return the requested object manager.
*/ */
ewol::object::Manager& getObjectManager(); ewol::object::Manager& getObjectManager() const;
/** /**
* @breif get the current Object Message Multicast manager. * @breif get the current Object Message Multicast manager.
* @return the requested object manager. * @return the requested object manager.
*/ */
ewol::object::MultiCast& getMultiCast(); ewol::object::MultiCast& getMultiCast() const;
/** /**
* @brief get the curent the system inteface. * @brief get the curent the system inteface.
* @return current reference on the instance. * @return current reference on the instance.
*/ */
ewol::Context& getContext(); ewol::Context& getContext() const;
private: private:
bool m_isResource; //!< enable this when you want to declare this element is auto-remove bool m_isResource; //!< enable this when you want to declare this element is auto-remove
public: public:
@ -338,9 +338,29 @@ namespace ewol {
* @brief Get the resource status of the element. * @brief Get the resource status of the element.
* @return the resource status. * @return the resource status.
*/ */
bool getStatusResource() { bool getStatusResource() const {
return m_isResource; return m_isResource;
} }
/**
* @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
* @param[in] _objectName Name of the object.
* @param[in] _eventId Event generate inside the object.
* @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...)
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
* @note : To used when NOT herited from this object.
*/
void registerOnObjectEvent(const ewol::object::Shared<ewol::Object>& _destinationObject,
const std::string& _objectName,
const char * _eventId,
const char * _eventIdgenerated = nullptr,
const std::string& _overloadData="");
/**
* @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object
* @return the requested object or nullptr
*/
ewol::object::Shared<ewol::Object> getObjectNamed(const std::string& _objectName) const;
}; };
}; };

View File

@ -23,6 +23,7 @@ const char* const ewol::widget::Button::eventValue = "value";
const char* const ewol::widget::Button::configToggle = "toggle"; const char* const ewol::widget::Button::configToggle = "toggle";
const char* const ewol::widget::Button::configLock = "lock"; const char* const ewol::widget::Button::configLock = "lock";
const char* const ewol::widget::Button::configEnableSingle = "enable-single";
const char* const ewol::widget::Button::configValue = "value"; const char* const ewol::widget::Button::configValue = "value";
const char* const ewol::widget::Button::configShaper = "shaper"; const char* const ewol::widget::Button::configShaper = "shaper";
@ -47,6 +48,7 @@ ewol::widget::Button::Button(const std::string& _shaperName) :
m_value(false), m_value(false),
m_lock(ewol::widget::Button::lockNone), m_lock(ewol::widget::Button::lockNone),
m_toggleMode(false), m_toggleMode(false),
m_enableSingle(false),
m_mouseHover(false), m_mouseHover(false),
m_buttonPressed(false), m_buttonPressed(false),
m_selectableAreaPos(0,0), m_selectableAreaPos(0,0),
@ -62,6 +64,7 @@ ewol::widget::Button::Button(const std::string& _shaperName) :
// add configuration // add configuration
registerConfig(configToggle, "bool", nullptr, "The Button can toogle"); registerConfig(configToggle, "bool", nullptr, "The Button can toogle");
registerConfig(configValue, "bool", nullptr, "Basic value of the widget"); registerConfig(configValue, "bool", nullptr, "Basic value of the widget");
registerConfig(configEnableSingle, "bool", nullptr, "If one element set in the Button ==> display only set");
registerConfig(configLock, "list", "none;true;released;pressed", "Lock the button in a special state to permit changing state only by the coder"); registerConfig(configLock, "list", "none;true;released;pressed", "Lock the button in a special state to permit changing state only by the coder");
registerConfig(configShaper, "string", nullptr, "the display name for config file"); registerConfig(configShaper, "string", nullptr, "the display name for config file");
@ -117,7 +120,9 @@ void ewol::widget::Button::onRegenerateDisplay() {
} }
void ewol::widget::Button::setLock(enum buttonLock _lock) { void ewol::widget::Button::setLock(enum buttonLock _lock) {
if (m_lock != _lock) { if (m_lock == _lock) {
return;
}
m_lock = _lock; m_lock = _lock;
if(ewol::widget::Button::lockAccess == _lock) { if(ewol::widget::Button::lockAccess == _lock) {
m_buttonPressed = false; m_buttonPressed = false;
@ -125,11 +130,29 @@ void ewol::widget::Button::setLock(enum buttonLock _lock) {
} }
CheckStatus(); CheckStatus();
markToRedraw(); markToRedraw();
}
void ewol::widget::Button::setEnableSingle(bool _single){
if (m_enableSingle == _single) {
return;
}
m_enableSingle = _single;
if (m_enableSingle == true) {
if ( m_idWidgetDisplayed == 0
&& m_subWidget[0] == nullptr
&& m_subWidget[1] != nullptr) {
m_idWidgetDisplayed = 1;
} else if ( m_idWidgetDisplayed == 1
&& m_subWidget[1] == nullptr
&& m_subWidget[0] != nullptr) {
m_idWidgetDisplayed = 0;
}
} }
} }
void ewol::widget::Button::setValue(bool _val) { void ewol::widget::Button::setValue(bool _val) {
if (m_value != _val) { if (m_value == _val) {
return;
}
m_value = _val; m_value = _val;
if (m_toggleMode == true) { if (m_toggleMode == true) {
if (m_value == false) { if (m_value == false) {
@ -138,13 +161,25 @@ void ewol::widget::Button::setValue(bool _val) {
m_idWidgetDisplayed = 1; m_idWidgetDisplayed = 1;
} }
} }
if (m_enableSingle == true) {
if ( m_idWidgetDisplayed == 0
&& m_subWidget[0] == nullptr
&& m_subWidget[1] != nullptr) {
m_idWidgetDisplayed = 1;
} else if ( m_idWidgetDisplayed == 1
&& m_subWidget[1] == nullptr
&& m_subWidget[0] != nullptr) {
m_idWidgetDisplayed = 0;
}
}
CheckStatus(); CheckStatus();
markToRedraw(); markToRedraw();
}
} }
void ewol::widget::Button::setToggleMode(bool _togg) { void ewol::widget::Button::setToggleMode(bool _togg) {
if (m_toggleMode != _togg) { if (m_toggleMode == _togg) {
return;
}
m_toggleMode = _togg; m_toggleMode = _togg;
if (m_value == true) { if (m_value == true) {
m_value = false; m_value = false;
@ -159,9 +194,19 @@ void ewol::widget::Button::setToggleMode(bool _togg) {
m_idWidgetDisplayed = 1; m_idWidgetDisplayed = 1;
} }
} }
if (m_enableSingle == true) {
if ( m_idWidgetDisplayed == 0
&& m_subWidget[0] == nullptr
&& m_subWidget[1] != nullptr) {
m_idWidgetDisplayed = 1;
} else if ( m_idWidgetDisplayed == 1
&& m_subWidget[1] == nullptr
&& m_subWidget[0] != nullptr) {
m_idWidgetDisplayed = 0;
}
}
CheckStatus(); CheckStatus();
markToRedraw(); markToRedraw();
}
} }
bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
@ -312,6 +357,10 @@ bool ewol::widget::Button::onSetConfig(const ewol::object::Config& _conf) {
setShaperName(_conf.getData()); setShaperName(_conf.getData());
return true; return true;
} }
if (_conf.getConfig() == configEnableSingle) {
setEnableSingle(std::stob(_conf.getData()));
return true;
}
return false; return false;
} }
@ -349,6 +398,11 @@ bool ewol::widget::Button::onGetConfig(const char* _config, std::string& _result
_result = m_shaper.getSource(); _result = m_shaper.getSource();
return true; return true;
} }
if (_config == configEnableSingle) {
_result = getEnableSingle();
return true;
}
return false; return false;
} }

View File

@ -39,6 +39,7 @@ namespace ewol {
// Config list of properties // Config list of properties
static const char* const configToggle; static const char* const configToggle;
static const char* const configLock; static const char* const configLock;
static const char* const configEnableSingle;
static const char* const configValue; static const char* const configValue;
static const char* const configShaper; static const char* const configShaper;
enum buttonLock{ enum buttonLock{
@ -111,6 +112,21 @@ namespace ewol {
bool getToggleMode() const { bool getToggleMode() const {
return m_toggleMode; return m_toggleMode;
}; };
protected:
bool m_enableSingle; //!< When a single subwidget is set display all time it.
public:
/**
* @brief Chane the display single widget mode availlable.
* @param[in] _single single mode widget set
*/
void setEnableSingle(bool _single);
/**
* @brief get the current single mode enableling.
* @return the current value.
*/
bool getEnableSingle() const {
return m_enableSingle;
};
private: private:
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)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed. bool m_buttonPressed; //!< Flag to know if the button is curently pressed.

View File

@ -86,13 +86,17 @@ void ewol::widget::ContainerN::subWidgetRemove(ewol::object::Shared<ewol::Widget
return; return;
} }
size_t errorControl = m_subWidget.size(); size_t errorControl = m_subWidget.size();
for (auto it(m_subWidget.begin()) ; it != m_subWidget.end() ; ++it) {
auto it(m_subWidget.begin());
while (it != m_subWidget.end()) {
if (_newWidget == *it) { if (_newWidget == *it) {
(*it)->removeUpperWidget(); (*it)->removeUpperWidget();
m_subWidget.erase(it); m_subWidget.erase(it);
it = m_subWidget.begin();
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
return; } else {
++it;
} }
} }
} }
@ -101,23 +105,27 @@ void ewol::widget::ContainerN::subWidgetUnLink(ewol::object::Shared<ewol::Widget
if (nullptr == _newWidget) { if (nullptr == _newWidget) {
return; return;
} }
for (auto it(m_subWidget.begin()) ; it != m_subWidget.end() ; ++it) { auto it(m_subWidget.begin());
while (it != m_subWidget.end()) {
if (_newWidget == *it) { if (_newWidget == *it) {
(*it)->removeUpperWidget(); (*it)->removeUpperWidget();
(*it).resetShared(); (*it).resetShared();
m_subWidget.erase(it); m_subWidget.erase(it);
it = m_subWidget.begin();
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
return; } else {
++it;
} }
} }
} }
void ewol::widget::ContainerN::subWidgetRemoveAll() { void ewol::widget::ContainerN::subWidgetRemoveAll() {
for (auto &it : m_subWidget) { for(auto &it : m_subWidget) {
if (it != nullptr) { if (it != nullptr) {
it->removeUpperWidget(); it->removeUpperWidget();
} }
it.reset();
} }
m_subWidget.clear(); m_subWidget.clear();
} }

View File

@ -29,6 +29,7 @@ const char* const ewol::widget::WSlider::eventStopSlide = "ewol-widget-wslider-e
// Config list of properties // Config list of properties
const char* const ewol::widget::WSlider::configMode = "mode"; const char* const ewol::widget::WSlider::configMode = "mode";
const char* const ewol::widget::WSlider::configSpeed = "speed"; const char* const ewol::widget::WSlider::configSpeed = "speed";
const char* const ewol::widget::WSlider::configSelect = "select";
static ewol::Widget* create() { static ewol::Widget* create() {
return new ewol::widget::WSlider(); return new ewol::widget::WSlider();
@ -51,6 +52,7 @@ ewol::widget::WSlider::WSlider() :
// add configuration // add configuration
registerConfig(configMode, "list", "vert;hori", "Transition mode of the slider"); registerConfig(configMode, "list", "vert;hori", "Transition mode of the slider");
registerConfig(configSpeed, "float", nullptr, "Transition speed of the slider"); registerConfig(configSpeed, "float", nullptr, "Transition speed of the slider");
registerConfig(configSelect, "strin", nullptr, "Select the requested widget to display");
} }
ewol::widget::WSlider::~WSlider() { ewol::widget::WSlider::~WSlider() {
@ -295,6 +297,10 @@ bool ewol::widget::WSlider::onSetConfig(const ewol::object::Config& _conf) {
setTransitionSpeed(std::stof(_conf.getData())); setTransitionSpeed(std::stof(_conf.getData()));
return true; return true;
} }
if (_conf.getConfig() == configSelect) {
subWidgetSelectSet(_conf.getData());
return true;
}
return false; return false;
} }
@ -318,6 +324,15 @@ bool ewol::widget::WSlider::onGetConfig(const char* _config, std::string& _resul
_result = std::to_string(getTransitionSpeed()); _result = std::to_string(getTransitionSpeed());
return true; return true;
} }
if (_config == configSelect) {
auto it = m_subWidget.begin();
std::advance(it, m_windowsRequested);
if ( it != m_subWidget.end()
&& *it != nullptr) {
_result = (*it)->getName();
}
return true;
}
return false; return false;
} }

View File

@ -29,6 +29,7 @@ namespace ewol {
// TODO : remove the dynamic transition and set this in annimation ... // TODO : remove the dynamic transition and set this in annimation ...
static const char* const configMode; static const char* const configMode;
static const char* const configSpeed; static const char* const configSpeed;
static const char* const configSelect;
enum sladingMode { enum sladingMode {
sladingTransitionVert, sladingTransitionVert,
sladingTransitionHori, sladingTransitionHori,