[DEV] correct the id of the WSlider ==> unique even if whe change the order of the widget (remove...

This commit is contained in:
Edouard DUPIN 2013-06-07 21:50:24 +02:00
parent d2d8b6fca1
commit 0b3fe6d74a
5 changed files with 111 additions and 10 deletions

View File

@ -68,14 +68,14 @@ int32_t widget::ContainerN::SubWidgetAdd(ewol::Widget* _newWidget)
MarkToRedraw();
ewol::RequestUpdateSize();
// added at the last eelement :
return m_subWidget.Size()-1;
return _newWidget->GetId();
}
void widget::ContainerN::SubWidgetAddStart(ewol::Widget* _newWidget)
int32_t widget::ContainerN::SubWidgetAddStart(ewol::Widget* _newWidget)
{
if (NULL == _newWidget) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Try to add start An empty Widget ... ");
return;
return -1;
}
if (_newWidget!=NULL) {
_newWidget->SetUpperWidget(this);
@ -83,6 +83,7 @@ void widget::ContainerN::SubWidgetAddStart(ewol::Widget* _newWidget)
m_subWidget.PushFront(_newWidget);
MarkToRedraw();
ewol::RequestUpdateSize();
return _newWidget->GetId();
}
void widget::ContainerN::SubWidgetRemove(ewol::Widget* _newWidget)

View File

@ -54,6 +54,7 @@ namespace widget
/**
* @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
* @return the ID of the set element
*/
virtual int32_t SubWidgetAdd(ewol::Widget* _newWidget);
inline int32_t SubWidgetAddBack(ewol::Widget* _newWidget) { return SubWidgetAdd(_newWidget); };
@ -61,9 +62,10 @@ namespace widget
/**
* @brief Add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @param[in] _newWidget the element pointer
* @return the ID of the set element
*/
virtual void SubWidgetAddStart(ewol::Widget* _newWidget);
inline void SubWidgetAddFront(ewol::Widget* _newWidget) { SubWidgetAddStart(_newWidget); };
virtual int32_t SubWidgetAddStart(ewol::Widget* _newWidget);
inline int32_t SubWidgetAddFront(ewol::Widget* _newWidget) { return SubWidgetAddStart(_newWidget); };
/**
* @brief Remove definitly a widget from the system and this layer.
* @param[in] _newWidget the element pointer.

View File

@ -32,13 +32,18 @@ void widget::Sizer::UnInit(void)
widget::Sizer::Sizer(widget::Sizer::displayMode_te _mode):
m_mode(_mode),
m_borderSize()
m_borderSize(),
m_animation(animationNone),
m_animationTime(0)
{
}
widget::Sizer::~Sizer(void)
{
// disable annimation to remore "remove" error
m_animation = animationNone;
m_animationTime = 0;
//EWOL_DEBUG("[" << GetId() << "]={" << GetObjectType() << "} Sizer : destroy (mode=" << (m_mode==widget::Sizer::modeVert?"Vert":"Hori") << ")");
}
@ -199,3 +204,44 @@ bool widget::Sizer::LoadXML(TiXmlNode* _node)
}
int32_t widget::Sizer::SubWidgetAdd(ewol::Widget* _newWidget)
{
if (m_animation == animationNone) {
return widget::ContainerN::SubWidgetAdd(_newWidget);
}
// TODO : ...
return widget::ContainerN::SubWidgetAdd(_newWidget);
}
int32_t widget::Sizer::SubWidgetAddStart(ewol::Widget* _newWidget)
{
if (m_animation == animationNone) {
return widget::ContainerN::SubWidgetAddStart(_newWidget);
}
// TODO : ...
return widget::ContainerN::SubWidgetAddStart(_newWidget);
}
void widget::Sizer::SubWidgetRemove(ewol::Widget* _newWidget)
{
if (m_animation == animationNone) {
widget::ContainerN::SubWidgetRemove(_newWidget);
return;
}
// TODO : ...
widget::ContainerN::SubWidgetRemove(_newWidget);
}
void widget::Sizer::SubWidgetUnLink(ewol::Widget* _newWidget)
{
if (m_animation == animationNone) {
widget::ContainerN::SubWidgetUnLink(_newWidget);
return;
}
// TODO : ...
widget::ContainerN::SubWidgetUnLink(_newWidget);
}

View File

@ -65,11 +65,51 @@ namespace widget {
* @return the border size (0 if not used)
*/
const ewol::Dimension& GetBorderSize(void) { return m_borderSize; };
public:
typedef enum {
animationNone, //!< No annimation
animationTop, //!< element came from the top
animationbuttom, //!< element came from the buttom
animationLeft, //!< element came from the Left
animationRight //!< element came from the right
//animationZoom //!< element came from zooming
} animation_te;
private:
animation_te m_animation; //!< Methode add and remove element (animation)
public:
/**
* @brief Set an animation mode for the new element set in the Widget container.
* @param[in] _animation The new animation mode.
*/
void SetAnimationMode(animation_te _animation) { m_animation = _animation; };
/**
* @brief Get the current animation mode.
* @return The animation mode.
*/
animation_te GetAnimationMode(void) { return m_animation;};
private:
float m_animationTime; //!< Time in second to generate animation
public:
/**
* @brief Set the time to produce animation.
* @param[in] _time The new animation time.
*/
void SetAnimationTime(float _time) { m_animationTime = _time; };
/**
* @brief Get the current animation time.
* @return The time to produce the animation.
*/
float GetAnimationTime(void) { return m_animationTime;};
public: // Derived function
virtual const char * const GetObjectType(void) { return "ewol::widget::sizer"; };
virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateMinMaxSize(void);
virtual bool LoadXML(TiXmlNode* _node);
// overwrite the set fuction to start annimations ...
virtual int32_t SubWidgetAdd(ewol::Widget* _newWidget);
virtual int32_t SubWidgetAddStart(ewol::Widget* _newWidget);
virtual void SubWidgetRemove(ewol::Widget* _newWidget);
virtual void SubWidgetUnLink(ewol::Widget* _newWidget);
};
};

View File

@ -123,11 +123,23 @@ void widget::WSlider::CalculateSize(const vec2& _availlable)
void widget::WSlider::SubWidgetSelectSet(int32_t _id)
{
if (_id<0 || _id >= m_subWidget.Size()) {
EWOL_ERROR("Can not change to a widget not present");
int32_t elementID = -1;
// search element in the list :
for( int32_t iii=0 ; iii<m_subWidget.Size() ; iii++) {
if (m_subWidget[iii] != NULL) {
if (m_subWidget[iii]->GetId()==_id) {
elementID = iii;
break;
}
}
}
if (_id != m_windowsDestination) {
m_windowsRequested = _id;
if (elementID<0) {
EWOL_ERROR("Can not change to a widget not present : uid="<<_id);
return;
}
if (elementID != m_windowsDestination) {
m_windowsRequested = elementID;
GenerateEventId(eventStartSlide);
PeriodicCallEnable();
MarkToRedraw();