[DEV] correct layer getWidgetAtPos and remove temporary debug to fing string error, and add functotion to remove sub element in delayed

This commit is contained in:
Edouard DUPIN 2013-05-20 22:09:16 +02:00
parent 0c36f880db
commit 81458d0523
11 changed files with 90 additions and 24 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 8acac8918b8899a4ededb35e99469ac7227465fe
Subproject commit b433625df8188ca5d27d5adb1eedbf42c4590744

View File

@ -315,7 +315,9 @@ bool ewol::EObject::StoreXML(TiXmlNode* _node) const
bool ewol::EObject::OnSetConfig(const ewol::EConfig& _conf)
{
EWOL_DEBUG("[" << GetId() << "] {" << GetObjectType() << "} set config : " << _conf);
if (_conf.GetConfig() == ewol::EObject::configName) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Set config name : \"" << _conf.GetData() << "\"");
SetName(_conf.GetData());
return true;
}

View File

@ -192,7 +192,7 @@ ewol::TexturedFont::TexturedFont(etk::UString fontName) :
}
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
if (m_fileName[iiiFontId].IsEmpty()==false) {
if (m_fileName[iiiFontId].IsEmpty()==true) {
EWOL_DEBUG("can not load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" ==> size=" << m_size );
m_font[iiiFontId] = NULL;
continue;

View File

@ -105,7 +105,7 @@ void widget::Button::SetSubWidget(ewol::Widget* _subWidget)
m_subWidget[idWidget]=NULL;
}
}
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
@ -123,7 +123,7 @@ void widget::Button::SetSubWidgetToggle(ewol::Widget* _subWidget)
m_subWidget[idWidget]=NULL;
}
}
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
@ -407,8 +407,9 @@ void widget::Button::PeriodicCall(int64_t _localTime)
ewol::Widget* widget::Button::GetWidgetNamed(const etk::UString& _widgetName)
{
if (GetName()==_widgetName) {
return this;
ewol::Widget* tmpUpperWidget = ewol::Widget::GetWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) {
return tmpUpperWidget;
}
if (m_subWidget[0]!= NULL) {
ewol::Widget* tmpWidget = m_subWidget[0]->GetWidgetNamed(_widgetName);

View File

@ -54,17 +54,29 @@ void widget::Container::SubWidgetRemove(void)
delete(m_subWidget);
// might have been destroy first here :
if (m_subWidget!=NULL) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} An error Occured when removing main node");
EWOL_ERROR("Composer : An error Occured when removing main node");
}
MarkToRedraw();
ewol::RequestUpdateSize();
}
}
void widget::Container::SubWidgetRemoveDelayed(void)
{
if (NULL != m_subWidget) {
m_subWidget->RemoveUpperWidget();
m_subWidget->RemoveObject();
m_subWidget=NULL;
MarkToRedraw();
ewol::RequestUpdateSize();
}
}
ewol::Widget* widget::Container::GetWidgetNamed(const etk::UString& _widgetName)
{
if (GetName()==_widgetName) {
return this;
ewol::Widget* tmpUpperWidget = ewol::Widget::GetWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) {
return tmpUpperWidget;
}
if (NULL != m_subWidget) {
return m_subWidget->GetWidgetNamed(_widgetName);
@ -133,7 +145,7 @@ void widget::Container::CalculateMinMaxSize(void)
vec2 min = m_subWidget->GetCalculateMinSize();
m_minSize.setMax(min);
}
//EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Result min size : " << m_minSize);
//EWOL_ERROR("[" << GetId() << "] Result min size : " << m_minSize);
}
void widget::Container::OnRegenerateDisplay(void)
@ -162,7 +174,7 @@ bool widget::Container::LoadXML(TiXmlNode* _node)
// parse generic properties :
ewol::Widget::LoadXML(_node);
// remove previous element :
SubWidgetRemove();
SubWidgetRemoveDelayed();
// parse all the elements :
for(TiXmlNode * pNode = _node->FirstChild() ;
@ -174,23 +186,23 @@ bool widget::Container::LoadXML(TiXmlNode* _node)
}
etk::UString widgetName = pNode->Value();
if (ewol::widgetManager::Exist(widgetName) == false) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
EWOL_ERROR("(l "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
continue;
}
if (NULL != GetSubWidget()) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
EWOL_ERROR("(l "<<pNode->Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
continue;
}
EWOL_DEBUG("[" << GetId() << "] {" << GetObjectType() << "} try to create subwidget : '" << widgetName << "'");
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName);
if (tmpWidget == NULL) {
EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
EWOL_ERROR ("(l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}
// add widget :
SetSubWidget(tmpWidget);
if (false == tmpWidget->LoadXML(pNode)) {
EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
EWOL_ERROR ("(l "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
return false;
}
}

View File

@ -46,6 +46,10 @@ namespace widget
* @brief Remove the subWidget node.
*/
void SubWidgetRemove(void);
/**
* @brief Remove the subWidget node (delayed to prevent remove in the callbback).
*/
virtual void SubWidgetRemoveDelayed(void);
public: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);

View File

@ -144,11 +144,27 @@ void widget::ContainerN::SubWidgetRemoveAll(void)
}
m_subWidget.Clear();
}
void widget::ContainerN::SubWidgetRemoveAllDelayed(void)
{
// the size automaticly decrement with the auto call of the OnObjectRemove function
for(int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->RemoveUpperWidget();
m_subWidget[iii]->RemoveObject();
m_subWidget[iii] = NULL;
} else {
EWOL_WARNING("[" << GetId() << "] {" << GetObjectType() << "} Must not have null pointer on the subWidget list ...");
}
}
m_subWidget.Clear();
}
ewol::Widget* widget::ContainerN::GetWidgetNamed(const etk::UString& _widgetName)
{
if (GetName()==_widgetName) {
return this;
ewol::Widget* tmpUpperWidget = ewol::Widget::GetWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) {
return tmpUpperWidget;
}
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
@ -299,6 +315,7 @@ bool widget::ContainerN::LoadXML(TiXmlNode* _node)
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
continue;
}
EWOL_DEBUG("[" << GetId() << "] {" << GetObjectType() << "} load new element : \"" << widgetName << "\"");
ewol::Widget *subWidget = ewol::widgetManager::Create(widgetName);
if (subWidget == NULL) {
EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");

View File

@ -47,6 +47,10 @@ namespace widget
* @brief Remove all sub element from the widget.
*/
virtual void SubWidgetRemoveAll(void);
/**
* @brief Remove all sub element from the widget (delayed to prevent remove in the callbback).
*/
virtual void SubWidgetRemoveAllDelayed(void);
/**
* @brief Add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @param[in] _newWidget the element pointer

View File

@ -39,3 +39,27 @@ widget::Layer::~Layer(void)
EWOL_DEBUG("[" << GetId() << "] Layer : destroy");
}
ewol::Widget* widget::Layer::GetWidgetAtPos(const vec2& _pos)
{
if (true == IsHide()) {
return NULL;
}
// for all element in the sizer ...
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->GetSize();
vec2 tmpOrigin = m_subWidget[iii]->GetOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[iii]->GetWidgetAtPos(_pos);
if (NULL != tmpWidget) {
return tmpWidget;
}
// parse the next layer ...
}
}
}
return NULL;
};

View File

@ -36,6 +36,7 @@ namespace widget {
virtual ~Layer(void);
public:
virtual const char * const GetObjectType(void) { return "Ewol::Layer"; };
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
};
};

View File

@ -396,7 +396,7 @@ void ewol::Widget::SetOrigin(const vec2& _pos)
#if DEBUG_LEVEL > 2
if( m_origin.x() < -5000
|| m_origin.y() < -5000) {
EWOL_WARNING("[" << GetId() << "] {" << GetObjectType() << "} Set origin < 5000 : " << m_origin);
EWOL_WARNING("[" << GetId() << "] Set origin < 5000 : " << m_origin);
}
#endif
m_origin = _pos;
@ -415,9 +415,9 @@ vec2 ewol::Widget::RelativePosition(const vec2& _pos)
void ewol::Widget::CalculateMinMaxSize(void)
{
m_minSize = m_userMinSize.GetPixel();
//EWOL_ERROR("[" << GetId() << "] convert in min size : " << m_userMinSize << " out=" << m_minSize);
m_maxSize = m_userMaxSize.GetPixel();
MarkToRedraw();
//EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} convert in min size : " << m_userMinSize << " out=" << m_minSize);
}
vec2 ewol::Widget::GetCalculateMinSize(void)
@ -449,7 +449,7 @@ void ewol::Widget::SetMinSize(const ewol::Dimension& _size)
error=true;
}
if (error==true) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Can not set a 'min Size' > 'max size' set nothing ...");
EWOL_ERROR("Can not set a 'min Size' > 'max size' set nothing ...");
return;
}
m_userMinSize = _size;
@ -481,7 +481,7 @@ void ewol::Widget::SetMaxSize(const ewol::Dimension& _size)
error=true;
}
if (error==true) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Can not set a 'min Size' > 'max size' set nothing ...");
EWOL_ERROR("Can not set a 'min Size' > 'max size' set nothing ...");
return;
}
m_userMaxSize = _size;
@ -551,13 +551,13 @@ void ewol::Widget::ShortCutAdd(const char * _descriptiveString, const char * _ge
if( NULL==_descriptiveString
|| 0==strlen(_descriptiveString))
{
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} try to add shortcut with no descriptive string ...");
EWOL_ERROR("try to add shortcut with no descriptive string ...");
return;
}
EventShortCut* tmpElement = new EventShortCut();
if (NULL == tmpElement) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} allocation error ... Memory error ...");
EWOL_ERROR("allocation error ... Memory error ...");
return;
}
tmpElement->broadcastEvent = _broadcast;
@ -736,6 +736,7 @@ bool ewol::Widget::LoadXML(TiXmlNode* _node)
ewol::Widget* ewol::Widget::GetWidgetNamed(const etk::UString& _widgetName)
{
EWOL_DEBUG("[" << GetId() << "] {" << GetObjectType() << "} compare : " << GetName() << "==" << _widgetName );
if (GetName()==_widgetName) {
return this;
}