[DEV] change the keyboard and mouse event function

This commit is contained in:
Edouard DUPIN 2013-05-08 12:20:47 +02:00
parent 5d7152f572
commit 66924458eb
57 changed files with 1483 additions and 907 deletions

2
build

@ -1 +1 @@
Subproject commit a51dda48794d739e98595c54f83a4fbc6f14b84d Subproject commit d6995577112942253beab5e122bb9c9795001c42

2
external/etk vendored

@ -1 +1 @@
Subproject commit 2c649d3741503c66386de4f38f319a97fcbe6a4e Subproject commit 249870fc130e93ee3bec51701f1fb595a02f8671

View File

@ -224,7 +224,7 @@ void ewol::Shaper::UpdateVectex(void)
m_propertyOrigin.y()+m_propertySize.y()); m_propertyOrigin.y()+m_propertySize.y());
} }
void ewol::Shaper::SetOrigin(vec2 newOri) void ewol::Shaper::SetOrigin(const vec2& newOri)
{ {
if (m_propertyOrigin != newOri) { if (m_propertyOrigin != newOri) {
m_propertyOrigin = newOri; m_propertyOrigin = newOri;
@ -233,7 +233,7 @@ void ewol::Shaper::SetOrigin(vec2 newOri)
} }
void ewol::Shaper::SetSize(vec2 newSize) void ewol::Shaper::SetSize(const vec2& newSize)
{ {
if (m_propertySize != newSize) { if (m_propertySize != newSize) {
m_propertySize = newSize; m_propertySize = newSize;
@ -241,12 +241,12 @@ void ewol::Shaper::SetSize(vec2 newSize)
} }
} }
void ewol::Shaper::SetInsideSize(vec2 newInsideSize) void ewol::Shaper::SetInsideSize(const vec2& newInsideSize)
{ {
m_propertyInsideSize = newInsideSize; m_propertyInsideSize = newInsideSize;
} }
void ewol::Shaper::SetInsidePos(vec2 newInsidePos) void ewol::Shaper::SetInsidePos(const vec2& newInsidePos)
{ {
m_propertyInsidePosition = newInsidePos; m_propertyInsidePosition = newInsidePos;
} }

View File

@ -112,22 +112,22 @@ namespace ewol
* @brief Set the widget origin (needed fot the display) * @brief Set the widget origin (needed fot the display)
* @param[in] newOri : the new widget origin * @param[in] newOri : the new widget origin
*/ */
void SetOrigin(vec2 newOri); void SetOrigin(const vec2& newOri);
/** /**
* @brief Set the widget size (needed fot the display) * @brief Set the widget size (needed fot the display)
* @param[in] newSize : the new widget size * @param[in] newSize : the new widget size
*/ */
void SetSize(vec2 newSize); void SetSize(const vec2& newSize);
/** /**
* @brief Set the internal widget size * @brief Set the internal widget size
* @param[in] newInsidePos : the subelement size. * @param[in] newInsidePos : the subelement size.
*/ */
void SetInsideSize(vec2 newInsideSize); void SetInsideSize(const vec2& newInsideSize);
/** /**
* @brief Set the internal widget position * @brief Set the internal widget position
* @param[in] newInsidePos : the subelement position * @param[in] newInsidePos : the subelement position
*/ */
void SetInsidePos(vec2 newInsidePos); void SetInsidePos(const vec2& newInsidePos);
/** /**
* @brief Get the padding declared by the user in the config file * @brief Get the padding declared by the user in the config file
* @return the padding property * @return the padding property

View File

@ -244,7 +244,7 @@ vec3 ewol::Text::GetPos(void)
} }
void ewol::Text::SetPos(vec3 pos) void ewol::Text::SetPos(const vec3& pos)
{ {
// check min max for display area // check min max for display area
if (m_nbCharDisplayed != 0) { if (m_nbCharDisplayed != 0) {
@ -276,7 +276,7 @@ void ewol::Text::SetPos(vec3 pos)
} }
void ewol::Text::SetRelPos(vec3 pos) void ewol::Text::SetRelPos(const vec3& pos)
{ {
m_position += pos; m_position += pos;
m_previousCharcode = 0; m_previousCharcode = 0;
@ -284,25 +284,35 @@ void ewol::Text::SetRelPos(vec3 pos)
} }
void ewol::Text::SetColor(draw::Color color) void ewol::Text::SetColor(const draw::Color& color)
{ {
m_color = color; m_color = color;
} }
void ewol::Text::SetColorBg(draw::Color color) void ewol::Text::SetColorBg(const draw::Color& color)
{ {
m_colorBg = color; m_colorBg = color;
m_vectorialDraw.SetColor(color); m_vectorialDraw.SetColor(color);
} }
void ewol::Text::SetClippingWidth(vec3 pos, vec3 width) void ewol::Text::SetClippingWidth(const vec2& pos, const vec2& width)
{ {
SetClipping(pos, pos+width); SetClipping(pos, pos+width);
} }
void ewol::Text::SetClipping(vec3 pos, vec3 posEnd) void ewol::Text::SetClippingWidth(const vec3& pos, const vec3& width)
{
SetClipping(pos, pos+width);
}
void ewol::Text::SetClipping(const vec2& pos, const vec2& posEnd)
{
SetClipping(vec3(pos.x(),pos.y(),-1), vec3(posEnd.x(),posEnd.y(),1) );
}
void ewol::Text::SetClipping(const vec3& pos, const vec3& posEnd)
{ {
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (pos.x() <= posEnd.x()) { if (pos.x() <= posEnd.x()) {
@ -349,7 +359,7 @@ void ewol::Text::SetFontSize(int32_t fontSize)
} }
void ewol::Text::SetFontName(etk::UString fontName) void ewol::Text::SetFontName(const etk::UString& fontName)
{ {
// get old size // get old size
int32_t fontSize = -1; int32_t fontSize = -1;

View File

@ -137,34 +137,38 @@ namespace ewol
* @brief Set position for the next text writen * @brief Set position for the next text writen
* @param[in] pos Position of the text (in 3D) * @param[in] pos Position of the text (in 3D)
*/ */
void SetPos(vec3 pos); void SetPos(const vec3& pos);
inline void SetPos(const vec2& pos) { SetPos(vec3(pos.x(),pos.y(),0)); };
/** /**
* @brief Set relative position for the next text writen * @brief Set relative position for the next text writen
* @param[in] pos ofset apply of the text (in 3D) * @param[in] pos ofset apply of the text (in 3D)
*/ */
void SetRelPos(vec3 pos); void SetRelPos(const vec3& pos);
inline void SetRelPos(const vec2& pos) { SetRelPos(vec3(pos.x(),pos.y(),0)); };
/** /**
* @brief Set the Color of the current foreground font * @brief Set the Color of the current foreground font
* @param[in] color Color to set on foreground (for next print) * @param[in] color Color to set on foreground (for next print)
*/ */
void SetColor(draw::Color color); void SetColor(const draw::Color& color);
/** /**
* @brief Set the background color of the font (for selected Text (not the global BG)) * @brief Set the background color of the font (for selected Text (not the global BG))
* @param[in] color Color to set on background (for next print) * @param[in] color Color to set on background (for next print)
*/ */
void SetColorBg(draw::Color color); void SetColorBg(const draw::Color& color);
/** /**
* @brief Request a clipping area for the text (next draw only) * @brief Request a clipping area for the text (next draw only)
* @param[in] pos Start position of the clipping * @param[in] pos Start position of the clipping
* @param[in] width Width size of the clipping * @param[in] width Width size of the clipping
*/ */
void SetClippingWidth(vec3 pos, vec3 width); void SetClippingWidth(const vec3& pos, const vec3& width);
void SetClippingWidth(const vec2& pos, const vec2& width);
/** /**
* @brief Request a clipping area for the text (next draw only) * @brief Request a clipping area for the text (next draw only)
* @param[in] pos Start position of the clipping * @param[in] pos Start position of the clipping
* @param[in] posEnd End position of the clipping * @param[in] posEnd End position of the clipping
*/ */
void SetClipping(vec3 pos, vec3 posEnd); void SetClipping(const vec3& pos, const vec3& posEnd);
void SetClipping(const vec2& pos, const vec2& posEnd);
/** /**
* @brief Enable/Disable the clipping (without lose the current clipping position) * @brief Enable/Disable the clipping (without lose the current clipping position)
* @brief newMode The new status of the clipping * @brief newMode The new status of the clipping
@ -180,7 +184,7 @@ namespace ewol
* @brief Specify the font name (this reset the internal element of the current text (system requirement) * @brief Specify the font name (this reset the internal element of the current text (system requirement)
* @param[in] fontName Current name of the selected font * @param[in] fontName Current name of the selected font
*/ */
void SetFontName(etk::UString fontName); void SetFontName(const etk::UString& fontName);
/** /**
* @brief Specify the font property (this reset the internal element of the current text (system requirement) * @brief Specify the font property (this reset the internal element of the current text (system requirement)
* @param[in] fontName Current name of the selected font * @param[in] fontName Current name of the selected font

View File

@ -39,34 +39,34 @@ void ewol::EObjectMessageMultiCast::UnInit(void)
} }
static void MultiCastAdd(ewol::EObject* object, const char* const message) static void MultiCastAdd(ewol::EObject* _object, const char* const _message)
{ {
if (NULL == object) { if (NULL == _object) {
EWOL_ERROR("Add with NULL object"); EWOL_ERROR("Add with NULL object");
return; return;
} }
if (NULL == message) { if (NULL == _message) {
EWOL_ERROR("Add with NULL Message"); EWOL_ERROR("Add with NULL Message");
return; return;
} }
messageList_ts tmpMessage; messageList_ts tmpMessage;
tmpMessage.object = object; tmpMessage.object = _object;
tmpMessage.message = message; tmpMessage.message = _message;
m_messageList.PushBack(tmpMessage); m_messageList.PushBack(tmpMessage);
EWOL_DEBUG("SendMulticast ADD listener :" << object->GetId() << " on \"" << message << "\"" ); EWOL_DEBUG("SendMulticast ADD listener :" << _object->GetId() << " on \"" << _message << "\"" );
} }
static void MultiCastRm(ewol::EObject* object) static void MultiCastRm(ewol::EObject* _object)
{ {
if (NULL == object) { if (NULL == _object) {
EWOL_ERROR("Rm with NULL object"); EWOL_ERROR("Rm with NULL object");
return; return;
} }
// send the message at all registered widget ... // send the message at all registered widget ...
for (int32_t iii=m_messageList.Size()-1; iii>=0; iii--) { for (int32_t iii=m_messageList.Size()-1; iii>=0; iii--) {
if(m_messageList[iii].object == object) { if(m_messageList[iii].object == _object) {
EWOL_DEBUG("SendMulticast RM listener :" << object->GetId()); EWOL_DEBUG("SendMulticast RM listener :" << _object->GetId());
m_messageList[iii].message = NULL; m_messageList[iii].message = NULL;
m_messageList[iii].object = NULL; m_messageList[iii].object = NULL;
m_messageList.Erase(iii); m_messageList.Erase(iii);
@ -74,27 +74,27 @@ static void MultiCastRm(ewol::EObject* object)
} }
} }
static void MultiCastSend(ewol::EObject* object, const char* const message, const etk::UString& data) static void MultiCastSend(ewol::EObject* _object, const char* const _message, const etk::UString& _data)
{ {
EWOL_VERBOSE("SendMulticast message \"" << message << "\" data=\"" << data << "\" to :"); EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to :");
// send the message at all registered widget ... // send the message at all registered widget ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) { for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if( m_messageList[iii].message == message if( m_messageList[iii].message == _message
&& m_messageList[iii].object != object) && m_messageList[iii].object != _object)
{ {
if (NULL != m_messageList[iii].object) { if (NULL != m_messageList[iii].object) {
EWOL_VERBOSE(" id = " << m_messageList[iii].object->GetId() << " type=" << m_messageList[iii].object->GetObjectType()); EWOL_VERBOSE(" id = " << m_messageList[iii].object->GetId() << " type=" << m_messageList[iii].object->GetObjectType());
// generate event ... // generate event ...
m_messageList[iii].object->OnReceiveMessage(object, m_messageList[iii].message, data); m_messageList[iii].object->OnReceiveMessage(_object, m_messageList[iii].message, _data);
} }
} }
} }
} }
void ewol::EObjectMessageMultiCast::AnonymousSend(const char* const messageId, const etk::UString& data) void ewol::EObjectMessageMultiCast::AnonymousSend(const char* const _messageId, const etk::UString& _data)
{ {
MultiCastSend(NULL, messageId, data); MultiCastSend(NULL, _messageId, _data);
} }
#undef __class__ #undef __class__
@ -137,24 +137,24 @@ void ewol::EObject::RemoveObject(void)
ewol::EObjectManager::AutoRemove(this); ewol::EObjectManager::AutoRemove(this);
} }
void ewol::EObject::AddEventId(const char * generateEventId) void ewol::EObject::AddEventId(const char * _generateEventId)
{ {
if (NULL != generateEventId) { if (NULL != _generateEventId) {
m_availlableEventId.PushBack(generateEventId); m_availlableEventId.PushBack(_generateEventId);
} }
} }
void ewol::EObject::GenerateEventId(const char * generateEventId, const etk::UString& data) void ewol::EObject::GenerateEventId(const char * _generateEventId, const etk::UString& _data)
{ {
int32_t nbObject = ewol::EObjectManager::GetNumberObject(); int32_t nbObject = ewol::EObjectManager::GetNumberObject();
// for every element registered ... // for every element registered ...
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) { for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) { if (NULL!=m_externEvent[iii]) {
// if we find the event ... // if we find the event ...
if (m_externEvent[iii]->localEventId == generateEventId) { if (m_externEvent[iii]->localEventId == _generateEventId) {
if (NULL != m_externEvent[iii]->destEObject) { if (NULL != m_externEvent[iii]->destEObject) {
if (m_externEvent[iii]->overloadData.Size()<=0){ if (m_externEvent[iii]->overloadData.Size()<=0){
m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, data); m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, _data);
} else { } else {
// set the user requested data ... // set the user requested data ...
m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData); m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData);
@ -168,34 +168,37 @@ void ewol::EObject::GenerateEventId(const char * generateEventId, const etk::USt
} }
} }
void ewol::EObject::SendMultiCast(const char* const messageId, const etk::UString& data) void ewol::EObject::SendMultiCast(const char* const _messageId, const etk::UString& _data)
{ {
int32_t nbObject = ewol::EObjectManager::GetNumberObject(); int32_t nbObject = ewol::EObjectManager::GetNumberObject();
MultiCastSend(this, messageId, data); MultiCastSend(this, _messageId, _data);
if (nbObject > ewol::EObjectManager::GetNumberObject()) { if (nbObject > ewol::EObjectManager::GetNumberObject()) {
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->RemoveObject() which is asynchronous"); EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->RemoveObject() which is asynchronous");
} }
} }
void ewol::EObject::RegisterMultiCast(const char* const messageId) void ewol::EObject::RegisterMultiCast(const char* const _messageId)
{ {
MultiCastAdd(this, messageId); MultiCastAdd(this, _messageId);
} }
void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const char * eventId, const char * eventIdgenerated, const etk::UString& overloadData) void ewol::EObject::RegisterOnEvent(ewol::EObject * _destinationObject,
const char * _eventId,
const char * _eventIdgenerated,
const etk::UString& _overloadData)
{ {
if (NULL == destinationObject) { if (NULL == _destinationObject) {
EWOL_ERROR("Input ERROR NULL pointer EObject ..."); EWOL_ERROR("Input ERROR NULL pointer EObject ...");
return; return;
} }
if (NULL == eventId) { if (NULL == _eventId) {
EWOL_ERROR("Input ERROR NULL pointer Event Id..."); EWOL_ERROR("Input ERROR NULL pointer Event Id...");
return; return;
} }
// check if event existed : // check if event existed :
bool findIt = false; bool findIt = false;
for(int32_t iii=0; iii<m_availlableEventId.Size(); iii++) { for(int32_t iii=0; iii<m_availlableEventId.Size(); iii++) {
if (m_availlableEventId[iii] == eventId) { if (m_availlableEventId[iii] == _eventId) {
findIt = true; findIt = true;
break; break;
} }
@ -203,15 +206,15 @@ void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const cha
if (false == findIt) { if (false == findIt) {
EWOL_DEBUG("Try to register with a NON direct string name"); EWOL_DEBUG("Try to register with a NON direct string name");
for(int32_t iii=0; iii<m_availlableEventId.Size(); iii++) { for(int32_t iii=0; iii<m_availlableEventId.Size(); iii++) {
if (0 == strncmp(m_availlableEventId[iii], eventId, 1024)) { if (0 == strncmp(m_availlableEventId[iii], _eventId, 1024)) {
findIt = true; findIt = true;
eventIdgenerated = m_availlableEventId[iii]; _eventIdgenerated = m_availlableEventId[iii];
break; break;
} }
} }
} }
if (false == findIt) { if (false == findIt) {
EWOL_ERROR("Can not register event on this WidgetType=" << GetObjectType() << " event=\"" << eventId << "\" ==> unknow event"); EWOL_ERROR("Can not register event on this WidgetType=" << GetObjectType() << " event=\"" << _eventId << "\" ==> unknow event");
return; return;
} }
ewol::EventExtGen * tmpEvent = new ewol::EventExtGen(); ewol::EventExtGen * tmpEvent = new ewol::EventExtGen();
@ -219,24 +222,24 @@ void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const cha
EWOL_ERROR("Allocation error in Register Event..."); EWOL_ERROR("Allocation error in Register Event...");
return; return;
} }
tmpEvent->localEventId = eventId; tmpEvent->localEventId = _eventId;
tmpEvent->destEObject = destinationObject; tmpEvent->destEObject = _destinationObject;
tmpEvent->overloadData = overloadData; tmpEvent->overloadData = _overloadData;
if (NULL != eventIdgenerated) { if (NULL != _eventIdgenerated) {
tmpEvent->destEventId = eventIdgenerated; tmpEvent->destEventId = _eventIdgenerated;
} else { } else {
tmpEvent->destEventId = eventId; tmpEvent->destEventId = _eventId;
} }
m_externEvent.PushBack(tmpEvent); m_externEvent.PushBack(tmpEvent);
} }
void ewol::EObject::OnObjectRemove(ewol::EObject * removeObject) void ewol::EObject::OnObjectRemove(ewol::EObject * _removeObject)
{ {
for(int32_t iii=m_externEvent.Size()-1; iii>=0; iii--) { for(int32_t iii=m_externEvent.Size()-1; iii>=0; iii--) {
if (NULL==m_externEvent[iii]) { if (NULL==m_externEvent[iii]) {
m_externEvent.Erase(iii); m_externEvent.Erase(iii);
} else if (m_externEvent[iii]->destEObject == removeObject) { } else if (m_externEvent[iii]->destEObject == _removeObject) {
m_externEvent.Erase(iii); m_externEvent.Erase(iii);
} }
} }

View File

@ -17,7 +17,7 @@ namespace ewol {
namespace EObjectMessageMultiCast { namespace EObjectMessageMultiCast {
void Init(void); void Init(void);
void UnInit(void); void UnInit(void);
void AnonymousSend(const char* const messageId, const etk::UString& data); void AnonymousSend(const char* const _messageId, const etk::UString& _data);
}; };
class EObject; class EObject;
@ -72,60 +72,60 @@ namespace ewol {
/** /**
* @brief Get the current Object type of the EObject * @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description * @param[in] _objectType type description
* @return true if the object is compatible, otherwise false * @return true if the object is compatible, otherwise false
*/ */
virtual const char * const GetObjectType(void) { return "EObject"; }; virtual const char * const GetObjectType(void) { return "EObject"; };
protected: protected:
/** /**
* @brief Add a specific event Id in the list to prevent wrong link on a EObject * @brief Add a specific event Id in the list to prevent wrong link on a EObject
* @param[in] generateEventId event Id to add * @param[in] _generateEventId event Id to add
*/ */
void AddEventId(const char * generateEventId); void AddEventId(const char * _generateEventId);
/** /**
* @brief Generate event on all registered EObject * @brief Generate event on all registered EObject
* @param[in] generateEventId event Id that is curetly generated * @param[in] _generateEventId event Id that is curetly generated
* @param[in] data data associated with the event * @param[in] _data data associated with the event
*/ */
void GenerateEventId(const char * generateEventId, const etk::UString& data = ""); void GenerateEventId(const char * _generateEventId, const etk::UString& _data = "");
/** /**
* @brief Generate Multicast event on all EObject requested the event * @brief Generate Multicast event on all EObject requested the event
* @param[in] messageId Event Id that is generated * @param[in] _messageId Event Id that is generated
* @param[in] data String that is send at all the destinations * @param[in] _data String that is send at all the destinations
*/ */
void SendMultiCast(const char* const messageId, const etk::UString& data = ""); void SendMultiCast(const char* const _messageId, const etk::UString& _data = "");
/** /**
* @brief Register of the arrival of a Multicast message * @brief Register of the arrival of a Multicast message
* @param[in] messageId Event Id waiting for... * @param[in] _messageId Event Id waiting for...
*/ */
void RegisterMultiCast(const char* const messageId); void RegisterMultiCast(const char* const _messageId);
public: public:
/** /**
* @brief Register an EObject over an other to get event on the second... * @brief Register an EObject over an other to get event on the second...
* @param[in] destinationObject pointer on the object that might be call when an event is generated * @param[in] _destinationObject pointer on the object that might be call when an event is generated
* @param[in] eventId Event generate inside the object * @param[in] _eventId Event generate inside the object
* @param[in] eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...) * @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 ... * @param[in] _overloadData When the user prever to receive a data specificly for this event ...
*/ */
void RegisterOnEvent(ewol::EObject * destinationObject, const char * eventId, const char * eventIdgenerated = NULL, const etk::UString& overloadData=""); void RegisterOnEvent(ewol::EObject * _destinationObject, const char * _eventId, const char * _eventIdgenerated = NULL, const etk::UString& _overloadData="");
/** /**
* @brief Inform object that an other object is removed ... * @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject * @param[in] _removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class * @note : Sub classes must call this class
*/ */
virtual void OnObjectRemove(ewol::EObject * removeObject); virtual void OnObjectRemove(ewol::EObject * _removeObject);
/** /**
* @brief Receive a message from an other EObject with a specific eventId and data * @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from * @param[in] _CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class * @param[in] _eventId Message registered by this class
* @param[in] data Data registered by this class * @param[in] _data Data registered by this class
*/ */
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data) { }; virtual void OnReceiveMessage(ewol::EObject * _CallerObject, const char * _eventId, const etk::UString& _data) { };
protected: protected:
etk::UString m_name; //!< name of the element ... etk::UString m_name; //!< name of the element ...
@ -137,9 +137,9 @@ namespace ewol {
const etk::UString& GetName(void) { return m_name; }; const etk::UString& GetName(void) { return m_name; };
/** /**
* @brief Get the Widget name * @brief Get the Widget name
* @param[in] name The new name * @param[in] _name The new name
*/ */
void SetName(const etk::UString& name) { m_name=name; }; void SetName(const etk::UString& _name) { m_name=_name; };
}; };
}; };

View File

@ -38,6 +38,7 @@ etk::CCout& ewol::keyEvent::operator <<(etk::CCout &os, const ewol::keyEvent::st
static const char* keyboardDescriptionString[ewol::keyEvent::keyboardCount+1] = { static const char* keyboardDescriptionString[ewol::keyEvent::keyboardCount+1] = {
"keyboardUnknow", "keyboardUnknow",
"keyboardChar",
"keyboardLeft", "keyboardLeft",
"keyboardRight", "keyboardRight",
"keyboardUp", "keyboardUp",

View File

@ -58,6 +58,7 @@ namespace ewol
*/ */
typedef enum { typedef enum {
keyboardUnknow = 0, //!< Unknown keyboard key keyboardUnknow = 0, //!< Unknown keyboard key
keyboardChar, //!< Char input is arrived ...
keyboardLeft, //!< Left key <-- keyboardLeft, //!< Left key <--
keyboardRight, //!< Right key --> keyboardRight, //!< Right key -->
keyboardUp, //!< Up key ^ keyboardUp, //!< Up key ^

View File

View File

@ -0,0 +1,48 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_EVENT_ENTRY_H__
#define __EWOL_EVENT_ENTRY_H__
#include <etk/types.h>
namespace ewol {
class EventEntry {
private:
ewol::keyEvent::keyboard_te m_type; //!< type of hardware event
ewol::keyEvent::status_te m_status; //!< status of hardware event
uniChar_t m_unicodeData; //!< Unicode data (in some case)
public:
EventEntry(ewol::keyEvent::keyboard_te _type,
ewol::keyEvent::status_te _status,
uniChar_t _char) :
m_type(_type),
m_status(_status),
m_unicodeData(_char)
{ };
void SetType(ewol::keyEvent::keyboard_te _type) { m_type = _type; };
inline const ewol::keyEvent::keyboard_te& GetType(void) const { return m_type; };
void SetStatus(ewol::keyEvent::status_te _status) { m_status = _status; };
inline const ewol::keyEvent::status_te& GetStatus(void) const { return m_status; };
void SetChar(uniChar_t _char) { m_unicodeData = _char; };
inline const uniChar_t& GetChar(void) const { return m_unicodeData; };
};
class EventEntrySystem {
public:
EventEntrySystem(ewol::keyEvent::keyboard_te _type,
ewol::keyEvent::status_te _status,
uniChar_t _char) :
m_event(_type, _status, _char)
{ };
ewol::EventEntry m_event;
};
};
#endif

View File

View File

@ -0,0 +1,67 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_EVENT_INPUT_H__
#define __EWOL_EVENT_INPUT_H__
#include <etk/types.h>
namespace ewol {
class EventInput {
private:
ewol::keyEvent::type_te m_type;
ewol::keyEvent::status_te m_status;
uint8_t m_inputId;
vec2 m_pos;
public:
EventInput(ewol::keyEvent::type_te _type,
ewol::keyEvent::status_te _status,
uint8_t _id,
const vec2& _pos):
m_type(_type),
m_status(_status),
m_inputId(_id),
m_pos(_pos)
{ };
void SetType(ewol::keyEvent::type_te _type) { m_type = _type; };
inline const ewol::keyEvent::type_te& GetType(void) const { return m_type; };
void SetStatus(ewol::keyEvent::status_te _status) { m_status = _status; };
inline const ewol::keyEvent::status_te& GetStatus(void) const { return m_status; };
void SetId(uint8_t _id) { m_inputId = _id; };
inline const uint8_t& GetId(void) const { return m_inputId; };
void SetPos(const vec2& _pos) { m_pos = _pos; };
inline const vec2& GetPos(void) const { return m_pos; };
};
class EventInputSystem {
public:
EventInputSystem(ewol::keyEvent::type_te _type,
ewol::keyEvent::status_te _status,
uint8_t _id,
const vec2& _pos) :
m_event(_type, _status, _id, _pos)
{ };
ewol::EventInput m_event;
/*
private:
int64_t m_lastTime;
uint8_t m_systemId;
uint8_t m_id;
uint8_t m_numberClick;
bool m_isUsed;
bool m_isDown;
bool m_isInside;
ewol::Widget* m_widget;
vec2 m_downStart;
vec2 m_pos;
*/
};
};
#endif

View File

@ -174,18 +174,18 @@ void ewolProcessEvents(void)
data.stateIsDown) ) { data.stateIsDown) ) {
// generate the direct event ... // generate the direct event ...
if (data.TypeMessage == THREAD_KEYBORAD_KEY) { if (data.TypeMessage == THREAD_KEYBORAD_KEY) {
ewol::EventEntrySystem tmpEntryEvent(ewol::keyEvent::keyboardChar, ewol::keyEvent::statusUp, data.keyboardChar);
if(true == data.stateIsDown) { if(true == data.stateIsDown) {
tmpWidget->OnEventKb(ewol::keyEvent::statusDown, data.keyboardChar); tmpEntryEvent.m_event.SetStatus(ewol::keyEvent::statusDown);
} else {
tmpWidget->OnEventKb(ewol::keyEvent::statusUp, data.keyboardChar);
} }
tmpWidget->SystemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE } else { // THREAD_KEYBORAD_MOVE
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown); EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown);
ewol::EventEntrySystem tmpEntryEvent(data.keyboardMove, ewol::keyEvent::statusUp, 0);
if(true == data.stateIsDown) { if(true == data.stateIsDown) {
tmpWidget->OnEventKbMove(ewol::keyEvent::statusDown, data.keyboardMove); tmpEntryEvent.m_event.SetStatus(ewol::keyEvent::statusDown);
} else {
tmpWidget->OnEventKbMove(ewol::keyEvent::statusUp, data.keyboardMove);
} }
tmpWidget->SystemEventEntry(tmpEntryEvent);
} }
} else { } else {
EWOL_DEBUG("remove Repeate key ..."); EWOL_DEBUG("remove Repeate key ...");

View File

@ -65,15 +65,18 @@ void ewol::eSystemInput::CleanElement(InputPoperty_ts *eventTable, int32_t idInp
} }
bool ewol::eSystemInput::localEventInput(ewol::keyEvent::type_te type, bool ewol::eSystemInput::localEventInput(ewol::keyEvent::type_te _type,
ewol::Widget* destWidget, ewol::Widget* _destWidget,
int32_t IdInput, int32_t _IdInput,
ewol::keyEvent::status_te typeEvent, ewol::keyEvent::status_te _status,
vec2 pos) vec2 _pos)
{ {
if (NULL != destWidget) { if (NULL != _destWidget) {
if (type == ewol::keyEvent::typeMouse || type == ewol::keyEvent::typeFinger) { if (_type == ewol::keyEvent::typeMouse || _type == ewol::keyEvent::typeFinger) {
return destWidget->OnEventInput(type, IdInput, typeEvent, pos); // create the system Event :
ewol::EventInputSystem tmpEventSystem(_type, _status, _IdInput, _pos);
// generate the event :
return _destWidget->SystemEventInput(tmpEventSystem);
} else { } else {
return false; return false;
} }

View File

@ -46,8 +46,8 @@ void widget::Button::UnInit(void)
widget::Button::Button(const etk::UString& shaperName) : widget::Button::Button(const etk::UString& _shaperName) :
m_shaper(shaperName), m_shaper(_shaperName),
m_toggleMode(false), m_toggleMode(false),
m_value(false), m_value(false),
m_mouseHover(false), m_mouseHover(false),
@ -80,12 +80,12 @@ widget::Button::~Button(void)
} }
void widget::Button::SetShaperName(const etk::UString& shaperName) void widget::Button::SetShaperName(const etk::UString& _shaperName)
{ {
m_shaper.SetSource(shaperName); m_shaper.SetSource(_shaperName);
} }
void widget::Button::SetSubWidget(ewol::Widget* subWidget) void widget::Button::SetSubWidget(ewol::Widget* _subWidget)
{ {
int32_t idWidget=0; int32_t idWidget=0;
if (NULL!=m_subWidget[idWidget]) { if (NULL!=m_subWidget[idWidget]) {
@ -96,14 +96,14 @@ void widget::Button::SetSubWidget(ewol::Widget* subWidget)
m_subWidget[idWidget]=NULL; m_subWidget[idWidget]=NULL;
} }
} }
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget); EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = subWidget; m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments : // element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
MarkToRedraw(); MarkToRedraw();
} }
void widget::Button::SetSubWidgetToggle(ewol::Widget* subWidget) void widget::Button::SetSubWidgetToggle(ewol::Widget* _subWidget)
{ {
int32_t idWidget=1; int32_t idWidget=1;
if (NULL!=m_subWidget[idWidget]) { if (NULL!=m_subWidget[idWidget]) {
@ -114,8 +114,8 @@ void widget::Button::SetSubWidgetToggle(ewol::Widget* subWidget)
m_subWidget[idWidget]=NULL; m_subWidget[idWidget]=NULL;
} }
} }
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget); EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = subWidget; m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments : // element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
@ -131,7 +131,7 @@ ewol::Widget* widget::Button::GetSubWidgetToggle(void)
} }
void widget::Button::CalculateSize(const vec2& availlable) void widget::Button::CalculateSize(const vec2& _availlable)
{ {
vec2 padding = m_shaper.GetPadding(); vec2 padding = m_shaper.GetPadding();
// set minimal size // set minimal size
@ -141,10 +141,10 @@ void widget::Button::CalculateSize(const vec2& availlable)
vec2 minimumSizeToggle(0,0); vec2 minimumSizeToggle(0,0);
// Checking the expand properties : // Checking the expand properties :
if (m_userExpand.x() == true) { if (m_userExpand.x() == true) {
m_size.setX(availlable.x()); m_size.setX(_availlable.x());
} }
if (m_userExpand.y() == true) { if (m_userExpand.y() == true) {
m_size.setY(availlable.y()); m_size.setY(_availlable.y());
} }
// Checkin the filling properties ==> for the subElements: // Checkin the filling properties ==> for the subElements:
vec2 subElementSize = m_minSize; vec2 subElementSize = m_minSize;
@ -195,7 +195,7 @@ void widget::Button::CalculateMinMaxSize(void)
MarkToRedraw(); MarkToRedraw();
} }
void widget::Button::OnDraw(ewol::DrawProperty& displayProp) void widget::Button::OnDraw(ewol::DrawProperty& _displayProp)
{ {
// draw the shaaper (if needed indeed) // draw the shaaper (if needed indeed)
m_shaper.Draw(); m_shaper.Draw();
@ -203,11 +203,11 @@ void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
if( false == m_toggleMode if( false == m_toggleMode
|| false == m_value) { || false == m_value) {
if (NULL!=m_subWidget[0]) { if (NULL!=m_subWidget[0]) {
m_subWidget[0]->GenDraw(displayProp); m_subWidget[0]->GenDraw(_displayProp);
} }
} else { } else {
if (NULL!=m_subWidget[1]) { if (NULL!=m_subWidget[1]) {
m_subWidget[1]->GenDraw(displayProp); m_subWidget[1]->GenDraw(_displayProp);
} }
} }
} }
@ -234,10 +234,10 @@ void widget::Button::OnRegenerateDisplay(void)
} }
} }
void widget::Button::SetValue(bool val) void widget::Button::SetValue(bool _val)
{ {
if (m_value != val) { if (m_value != _val) {
m_value = val; m_value = _val;
MarkToRedraw(); MarkToRedraw();
} }
} }
@ -247,10 +247,10 @@ bool widget::Button::GetValue(void)
return m_value; return m_value;
} }
void widget::Button::SetToggleMode(bool togg) void widget::Button::SetToggleMode(bool _togg)
{ {
if (m_toggleMode != togg) { if (m_toggleMode != _togg) {
m_toggleMode = togg; m_toggleMode = _togg;
if (m_value == true) { if (m_value == true) {
m_value = false; m_value = false;
// TODO : Change display and send event ... // TODO : Change display and send event ...
@ -260,15 +260,15 @@ void widget::Button::SetToggleMode(bool togg)
} }
} }
bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Button::OnEventInput(const ewol::EventInput& _event)
{ {
bool previousHoverState = m_mouseHover; bool previousHoverState = m_mouseHover;
if( ewol::keyEvent::statusLeave == typeEvent if( ewol::keyEvent::statusLeave == _event.GetStatus()
|| ewol::keyEvent::statusAbort == typeEvent) { || ewol::keyEvent::statusAbort == _event.GetStatus()) {
m_mouseHover = false; m_mouseHover = false;
m_buttonPressed = false; m_buttonPressed = false;
} else { } else {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
// prevent error from ouside the button // prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x() if( relativePos.x() < m_selectableAreaPos.x()
|| relativePos.y() < m_selectableAreaPos.y() || relativePos.y() < m_selectableAreaPos.y()
@ -283,20 +283,20 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
bool previousPressed = m_buttonPressed; bool previousPressed = m_buttonPressed;
//EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover); //EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover);
if (true == m_mouseHover) { if (true == m_mouseHover) {
if (1 == IdInput) { if (1 == _event.GetId()) {
if(ewol::keyEvent::statusDown == typeEvent) { if(ewol::keyEvent::statusDown == _event.GetStatus()) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonDown); //EWOL_DEBUG("Generate event : " << ewolEventButtonDown);
GenerateEventId(ewolEventButtonDown); GenerateEventId(ewolEventButtonDown);
m_buttonPressed = true; m_buttonPressed = true;
MarkToRedraw(); MarkToRedraw();
} }
if(ewol::keyEvent::statusUp == typeEvent) { if(ewol::keyEvent::statusUp == _event.GetStatus()) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonUp); //EWOL_DEBUG("Generate event : " << ewolEventButtonUp);
GenerateEventId(ewolEventButtonUp); GenerateEventId(ewolEventButtonUp);
m_buttonPressed = false; m_buttonPressed = false;
MarkToRedraw(); MarkToRedraw();
} }
if(ewol::keyEvent::statusSingle == typeEvent) { if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
// inverse value : // inverse value :
m_value = (m_value)?false:true; m_value = (m_value)?false:true;
//EWOL_DEBUG("Generate event : " << ewolEventButtonPressed); //EWOL_DEBUG("Generate event : " << ewolEventButtonPressed);
@ -321,12 +321,14 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
} }
bool widget::Button::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData) bool widget::Button::OnEventEntry(const ewol::EventEntry& _event)
{ {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( typeEvent == ewol::keyEvent::statusDown if( _event.GetType() == ewol::keyEvent::keyboardChar
&& unicodeData == '\r') { && _event.GetStatus() == ewol::keyEvent::statusDown
&& _event.GetChar() == '\r') {
GenerateEventId(ewolEventButtonEnter); GenerateEventId(ewolEventButtonEnter);
return true;
} }
return false; return false;
} }
@ -348,21 +350,74 @@ void widget::Button::CheckStatus(void)
} }
} }
void widget::Button::ChangeStatusIn(int32_t newStatusId) void widget::Button::ChangeStatusIn(int32_t _newStatusId)
{ {
if (true == m_shaper.ChangeStatusIn(newStatusId) ) { if (true == m_shaper.ChangeStatusIn(_newStatusId) ) {
PeriodicCallSet(true); PeriodicCallSet(true);
MarkToRedraw(); MarkToRedraw();
} }
} }
void widget::Button::PeriodicCall(int64_t localTime) void widget::Button::PeriodicCall(int64_t _localTime)
{ {
if (false == m_shaper.PeriodicCall(localTime) ) { if (false == m_shaper.PeriodicCall(_localTime) ) {
PeriodicCallSet(false); PeriodicCallSet(false);
} }
MarkToRedraw(); MarkToRedraw();
} }
bool widget::Button::LoadXML(TiXmlNode* _node)
{
if (NULL==_node) {
return false;
}
// parse generic properties :
ewol::Widget::LoadXML(_node);
// remove previous element :
SetSubWidget(NULL);
SetSubWidgetToggle(NULL);
// parse all the elements :
for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ;
pNode = pNode->NextSibling() ) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
continue;
}
etk::UString widgetName = pNode->Value();
if (ewol::widgetManager::Exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
continue;
}
bool toogleMode=false;
if (NULL != GetSubWidget()) {
toogleMode=true;
if (NULL != GetSubWidgetToggle()) {
EWOL_ERROR("(l "<<pNode->Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
continue;
}
}
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName);
if (tmpWidget == NULL) {
EWOL_ERROR ("(l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}
// add widget :
if (toogleMode==false) {
SetSubWidget(tmpWidget);
} else {
SetToggleMode(true);
SetSubWidgetToggle(tmpWidget);
}
if (false == tmpWidget->LoadXML(pNode)) {
EWOL_ERROR ("(l "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
return false;
}
}
return true;
}

View File

@ -48,28 +48,28 @@ namespace widget {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* @param[in] newLabel Button Label to display * @param[in] _newLabel Button Label to display
*/ */
Button(const etk::UString& shaperName="THEME:GUI:widgetButton.conf"); Button(const etk::UString& _shaperName="THEME:GUI:widgetButton.conf");
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~Button(void); virtual ~Button(void);
/** /**
* @brief Set the shaper name (use the contructer one this permit to not noad unused shaper) * @brief Set the shaper name (use the contructer one this permit to not noad unused shaper)
* @param[in] shaperName The new shaper filename * @param[in] _shaperName The new shaper filename
*/ */
void SetShaperName(const etk::UString& shaperName); void SetShaperName(const etk::UString& _shaperName);
/** /**
* @brief Specify the current widget * @brief Specify the current widget
* @param[in] subWidget Widget to add normal * @param[in] _subWidget Widget to add normal
*/ */
void SetSubWidget(ewol::Widget* subWidget); void SetSubWidget(ewol::Widget* _subWidget);
/** /**
* @brief Specify the current widget * @brief Specify the current widget
* @param[in] subWidget Widget to add Toggle * @param[in] _subWidget Widget to add Toggle
*/ */
void SetSubWidgetToggle(ewol::Widget* subWidget); void SetSubWidgetToggle(ewol::Widget* _subWidget);
/** /**
* @brief Get the current displayed composition * @brief Get the current displayed composition
* @return The base widget * @return The base widget
@ -83,9 +83,9 @@ namespace widget {
/** /**
* @brief Set the currentValue of the Button (pressed or not) * @brief Set the currentValue of the Button (pressed or not)
* @note Work only in toggle mode * @note Work only in toggle mode
* @param[in] val New value of the button * @param[in] _val New value of the button
*/ */
void SetValue(bool val); void SetValue(bool _val);
/** /**
* @brief Get the current button value. * @brief Get the current button value.
* @return True : The button is pressed. * @return True : The button is pressed.
@ -94,15 +94,15 @@ namespace widget {
bool GetValue(void); bool GetValue(void);
/** /**
* @brief Change the Toggle mode. * @brief Change the Toggle mode.
* @param[in] togg New toggle mode * @param[in] _togg New toggle mode
*/ */
void SetToggleMode(bool togg); void SetToggleMode(bool _togg);
private: private:
/** /**
* @brief Internal system to Change the property of the current status * @brief Internal system to Change the property of the current status
* @param[in] new state * @param[in] _newStatusId new state
*/ */
void ChangeStatusIn(int32_t newStatusId); void ChangeStatusIn(int32_t _newStatusId);
/** /**
* @brief update the status with the internal satte of the button ... * @brief update the status with the internal satte of the button ...
*/ */
@ -111,14 +111,15 @@ namespace widget {
// Derived function // Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; }; virtual const char * const GetObjectType(void) { return "widget::Button"; };
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual void CalculateSize(const vec2& availlable); virtual void CalculateSize(const vec2& _availlable);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData); virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual bool LoadXML(TiXmlNode* _node);
private: private:
// derived function // derived function
virtual void PeriodicCall(int64_t localTime); virtual void PeriodicCall(int64_t _localTime);
}; };
}; };

View File

@ -154,14 +154,14 @@ void widget::ButtonColor::OnRegenerateDisplay(void)
} }
bool widget::ButtonColor::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::ButtonColor::OnEventInput(const ewol::EventInput& _event)
{ {
bool previousHoverState = m_mouseHover; bool previousHoverState = m_mouseHover;
if(ewol::keyEvent::statusLeave == typeEvent) { if(ewol::keyEvent::statusLeave == _event.GetStatus()) {
m_mouseHover = false; m_mouseHover = false;
m_buttonPressed = false; m_buttonPressed = false;
} else { } else {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
// prevent error from ouside the button // prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x() if( relativePos.x() < m_selectableAreaPos.x()
|| relativePos.y() < m_selectableAreaPos.y() || relativePos.y() < m_selectableAreaPos.y()
@ -176,16 +176,16 @@ bool widget::ButtonColor::OnEventInput(ewol::keyEvent::type_te type, int32_t IdI
bool previousPressed = m_buttonPressed; bool previousPressed = m_buttonPressed;
//EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover); //EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover);
if (true == m_mouseHover) { if (true == m_mouseHover) {
if (1 == IdInput) { if (1 == _event.GetId()) {
if(ewol::keyEvent::statusDown == typeEvent) { if(ewol::keyEvent::statusDown == _event.GetStatus()) {
m_buttonPressed = true; m_buttonPressed = true;
MarkToRedraw(); MarkToRedraw();
} }
if(ewol::keyEvent::statusUp == typeEvent) { if(ewol::keyEvent::statusUp == _event.GetStatus()) {
m_buttonPressed = false; m_buttonPressed = false;
MarkToRedraw(); MarkToRedraw();
} }
if(ewol::keyEvent::statusSingle == typeEvent) { if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
m_buttonPressed = false; m_buttonPressed = false;
m_mouseHover = false; m_mouseHover = false;
// create a context menu : // create a context menu :

View File

@ -67,7 +67,7 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "widget::ButtonColor"; }; virtual const char * const GetObjectType(void) { return "widget::ButtonColor"; };
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data); virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
private: private:
/** /**

View File

@ -115,11 +115,11 @@ void widget::CheckBox::OnRegenerateDisplay(void)
} }
} }
bool widget::CheckBox::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::CheckBox::OnEventInput(const ewol::EventInput& _event)
{ {
//EWOL_DEBUG("Event on checkbox ..."); //EWOL_DEBUG("Event on checkbox ...");
if (1 == IdInput) { if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == typeEvent) { if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
if(true == m_value) { if(true == m_value) {
m_value = false; m_value = false;
GenerateEventId(ewolEventCheckBoxClicked, "false"); GenerateEventId(ewolEventCheckBoxClicked, "false");
@ -135,13 +135,13 @@ bool widget::CheckBox::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInpu
return false; return false;
} }
bool widget::CheckBox::OnEventEntry(const ewol::EventEntry& _event)
bool widget::CheckBox::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData)
{ {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( typeEvent == ewol::keyEvent::statusDown if( _event.GetType() == ewol::keyEvent::keyboardChar
&& ( unicodeData == '\r' && _event.GetStatus() == ewol::keyEvent::statusDown
|| unicodeData == ' ') && ( _event.GetChar() == '\r'
|| _event.GetChar() == ' ')
) { ) {
if(true == m_value) { if(true == m_value) {
m_value = false; m_value = false;

View File

@ -42,8 +42,8 @@ namespace widget {
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData); virtual bool OnEventEntry(const ewol::EventEntry& _event);
}; };
}; };

View File

@ -170,15 +170,15 @@ void widget::ColorBar::OnRegenerateDisplay(void)
} }
bool widget::ColorBar::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::ColorBar::OnEventInput(const ewol::EventInput& _event)
{ {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == IdInput) { if (1 == _event.GetId()) {
relativePos.setValue( etk_max(etk_min(relativePos.x(), m_size.x()),0), relativePos.setValue( etk_max(etk_min(relativePos.x(), m_size.x()),0),
etk_max(etk_min(relativePos.y(), m_size.y()),0)); etk_max(etk_min(relativePos.y(), m_size.y()),0));
if( ewol::keyEvent::statusSingle == typeEvent if( ewol::keyEvent::statusSingle == _event.GetStatus()
|| ewol::keyEvent::statusMove == typeEvent) { || ewol::keyEvent::statusMove == _event.GetStatus()) {
// nothing to do ... // nothing to do ...
m_currentUserPos.setValue( relativePos.x()/m_size.x(), m_currentUserPos.setValue( relativePos.x()/m_size.x(),
relativePos.y()/m_size.y() ); relativePos.y()/m_size.y() );

View File

@ -35,7 +35,7 @@ namespace widget {
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
}; };
}; };

View File

@ -16,8 +16,8 @@
#define __class__ "Container" #define __class__ "Container"
widget::Container::Container(ewol::Widget* subElement) : widget::Container::Container(ewol::Widget* _subElement) :
m_subWidget(subElement) m_subWidget(_subElement)
{ {
// nothing to do ... // nothing to do ...
} }
@ -32,13 +32,13 @@ ewol::Widget* widget::Container::GetSubWidget(void)
return m_subWidget; return m_subWidget;
} }
void widget::Container::SetSubWidget(ewol::Widget* newWidget) void widget::Container::SetSubWidget(ewol::Widget* _newWidget)
{ {
if (NULL==newWidget) { if (NULL==_newWidget) {
return; return;
} }
SubWidgetRemove(); SubWidgetRemove();
m_subWidget = newWidget; m_subWidget = _newWidget;
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
@ -57,45 +57,45 @@ void widget::Container::SubWidgetRemove(void)
} }
} }
ewol::Widget* widget::Container::GetWidgetNamed(const etk::UString& widgetName) ewol::Widget* widget::Container::GetWidgetNamed(const etk::UString& _widgetName)
{ {
if (GetName()==widgetName) { if (GetName()==_widgetName) {
return this; return this;
} }
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
return m_subWidget->GetWidgetNamed(widgetName); return m_subWidget->GetWidgetNamed(_widgetName);
} }
return NULL; return NULL;
} }
void widget::Container::OnObjectRemove(ewol::EObject* removeObject) void widget::Container::OnObjectRemove(ewol::EObject* _removeObject)
{ {
if (m_subWidget==removeObject) { if (m_subWidget==_removeObject) {
m_subWidget=NULL; m_subWidget=NULL;
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
} }
void widget::Container::OnDraw(ewol::DrawProperty& displayProp) void widget::Container::OnDraw(ewol::DrawProperty& _displayProp)
{ {
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
m_subWidget->GenDraw(displayProp); m_subWidget->GenDraw(_displayProp);
} }
} }
void widget::Container::CalculateSize(const vec2& availlable) void widget::Container::CalculateSize(const vec2& _availlable)
{ {
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
m_subWidget->SetOrigin(m_origin); m_subWidget->SetOrigin(m_origin);
m_subWidget->CalculateSize(availlable); m_subWidget->CalculateSize(_availlable);
} }
ewol::Widget::CalculateSize(availlable); ewol::Widget::CalculateSize(_availlable);
} }
void widget::Container::CalculateMinMaxSize(void) void widget::Container::CalculateMinMaxSize(void)
{ {
// callmain class // call main class
ewol::Widget::CalculateMinMaxSize(); ewol::Widget::CalculateMinMaxSize();
// call sub classes // call sub classes
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
@ -112,29 +112,29 @@ void widget::Container::OnRegenerateDisplay(void)
} }
} }
ewol::Widget* widget::Container::GetWidgetAtPos(const vec2& pos) ewol::Widget* widget::Container::GetWidgetAtPos(const vec2& _pos)
{ {
if (false==IsHide()) { if (false==IsHide()) {
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
return m_subWidget->GetWidgetAtPos(pos); return m_subWidget->GetWidgetAtPos(_pos);
} }
} }
return NULL; return NULL;
}; };
bool widget::Container::LoadXML(TiXmlNode* node) bool widget::Container::LoadXML(TiXmlNode* _node)
{ {
if (NULL==node) { if (NULL==_node) {
return false; return false;
} }
// parse generic properties : // parse generic properties :
ewol::Widget::LoadXML(node); ewol::Widget::LoadXML(_node);
// remove previous element : // remove previous element :
SubWidgetRemove(); SubWidgetRemove();
// parse all the elements : // parse all the elements :
for(TiXmlNode * pNode = node->FirstChild() ; for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ; NULL != pNode ;
pNode = pNode->NextSibling() ) { pNode = pNode->NextSibling() ) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
@ -150,6 +150,7 @@ bool widget::Container::LoadXML(TiXmlNode* node)
EWOL_ERROR("(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; continue;
} }
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName); ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName);
if (tmpWidget == NULL) { if (tmpWidget == NULL) {
EWOL_ERROR ("(l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\""); EWOL_ERROR ("(l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");

View File

@ -26,7 +26,7 @@ namespace widget
/** /**
* @brief Constructor * @brief Constructor
*/ */
Container(ewol::Widget* subElement=NULL); Container(ewol::Widget* _subElement=NULL);
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -39,25 +39,25 @@ namespace widget
ewol::Widget* GetSubWidget(void); ewol::Widget* GetSubWidget(void);
/** /**
* @brief Set the subWidget node widget. * @brief Set the subWidget node widget.
* @param[in] newWidget The widget to Add. * @param[in] _newWidget The widget to Add.
*/ */
void SetSubWidget(ewol::Widget* newWidget); void SetSubWidget(ewol::Widget* _newWidget);
/** /**
* @brief Remove the subWidget node. * @brief Remove the subWidget node.
*/ */
void SubWidgetRemove(void); void SubWidgetRemove(void);
protected: // Derived function protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& _displayProp);
public:// Derived function public:// Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnObjectRemove(ewol::EObject* removeObject); virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual void CalculateSize(const vec2& availlable); virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos); virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* GetWidgetNamed(const etk::UString& widgetName); virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
virtual const char * const GetObjectType(void) { return "Ewol::Container"; }; virtual const char * const GetObjectType(void) { return "ewol::widget::Container"; };
virtual bool LoadXML(TiXmlNode* node); virtual bool LoadXML(TiXmlNode* _node);
}; };
}; };

View File

@ -45,46 +45,46 @@ bvec2 widget::ContainerN::CanExpand(void)
return res; return res;
} }
void widget::ContainerN::LockExpand(const bvec2& lockExpand) void widget::ContainerN::LockExpand(const bvec2& _lockExpand)
{ {
if (lockExpand != m_lockExpand) { if (_lockExpand != m_lockExpand) {
m_lockExpand = lockExpand; m_lockExpand = _lockExpand;
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
} }
void widget::ContainerN::SubWidgetAdd(ewol::Widget* newWidget) void widget::ContainerN::SubWidgetAdd(ewol::Widget* _newWidget)
{ {
if (NULL == newWidget) { if (NULL == _newWidget) {
EWOL_ERROR("[" << GetId() << "] Try to add An empty Widget ... "); EWOL_ERROR("[" << GetId() << "] Try to add An empty Widget ... ");
return; return;
} }
m_subWidget.PushBack(newWidget); m_subWidget.PushBack(_newWidget);
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
void widget::ContainerN::SubWidgetAddStart(ewol::Widget* newWidget) void widget::ContainerN::SubWidgetAddStart(ewol::Widget* _newWidget)
{ {
if (NULL == newWidget) { if (NULL == _newWidget) {
EWOL_ERROR("[" << GetId() << "] Try to add start An empty Widget ... "); EWOL_ERROR("[" << GetId() << "] Try to add start An empty Widget ... ");
return; return;
} }
m_subWidget.PushFront(newWidget); m_subWidget.PushFront(_newWidget);
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
void widget::ContainerN::SubWidgetRemove(ewol::Widget* newWidget) void widget::ContainerN::SubWidgetRemove(ewol::Widget* _newWidget)
{ {
if (NULL == newWidget) { if (NULL == _newWidget) {
return; return;
} }
int32_t errorControl = m_subWidget.Size(); int32_t errorControl = m_subWidget.Size();
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) { for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) { if (_newWidget == m_subWidget[iii]) {
delete(m_subWidget[iii]); delete(m_subWidget[iii]);
// no remove, this element is removed with the function OnObjectRemove ==> it does not exist anymore ... // no remove, this element is removed with the function OnObjectRemove ==> it does not exist anymore ...
if (errorControl == m_subWidget.Size()) { if (errorControl == m_subWidget.Size()) {
@ -99,13 +99,13 @@ void widget::ContainerN::SubWidgetRemove(ewol::Widget* newWidget)
} }
} }
void widget::ContainerN::SubWidgetUnLink(ewol::Widget* newWidget) void widget::ContainerN::SubWidgetUnLink(ewol::Widget* _newWidget)
{ {
if (NULL == newWidget) { if (NULL == _newWidget) {
return; return;
} }
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) { for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) { if (_newWidget == m_subWidget[iii]) {
m_subWidget[iii] = NULL; m_subWidget[iii] = NULL;
m_subWidget.Erase(iii); m_subWidget.Erase(iii);
MarkToRedraw(); MarkToRedraw();
@ -136,14 +136,14 @@ void widget::ContainerN::SubWidgetRemoveAll(void)
m_subWidget.Clear(); m_subWidget.Clear();
} }
ewol::Widget* widget::ContainerN::GetWidgetNamed(const etk::UString& widgetName) ewol::Widget* widget::ContainerN::GetWidgetNamed(const etk::UString& _widgetName)
{ {
if (GetName()==widgetName) { if (GetName()==_widgetName) {
return this; return this;
} }
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) { for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
ewol::Widget* tmpWidget = m_subWidget[iii]->GetWidgetNamed(widgetName); ewol::Widget* tmpWidget = m_subWidget[iii]->GetWidgetNamed(_widgetName);
if (NULL != tmpWidget) { if (NULL != tmpWidget) {
return tmpWidget; return tmpWidget;
} }
@ -152,13 +152,13 @@ ewol::Widget* widget::ContainerN::GetWidgetNamed(const etk::UString& widgetName)
return NULL; return NULL;
} }
void widget::ContainerN::OnObjectRemove(ewol::EObject* removeObject) void widget::ContainerN::OnObjectRemove(ewol::EObject* _removeObject)
{ {
// First step call parrent : // First step call parrent :
ewol::Widget::OnObjectRemove(removeObject); ewol::Widget::OnObjectRemove(_removeObject);
// second step find if in all the elements ... // second step find if in all the elements ...
for(int32_t iii=m_subWidget.Size()-1; iii>=0; iii--) { for(int32_t iii=m_subWidget.Size()-1; iii>=0; iii--) {
if(m_subWidget[iii] == removeObject) { if(m_subWidget[iii] == _removeObject) {
EWOL_VERBOSE("[" << GetId() << "]={" << GetObjectType() << "} Remove sizer sub Element [" << iii << "/" << m_subWidget.Size()-1 << "] ==> destroyed object"); EWOL_VERBOSE("[" << GetId() << "]={" << GetObjectType() << "} Remove sizer sub Element [" << iii << "/" << m_subWidget.Size()-1 << "] ==> destroyed object");
m_subWidget[iii] = NULL; m_subWidget[iii] = NULL;
m_subWidget.Erase(iii); m_subWidget.Erase(iii);
@ -166,19 +166,19 @@ void widget::ContainerN::OnObjectRemove(ewol::EObject* removeObject)
} }
} }
void widget::ContainerN::OnDraw(ewol::DrawProperty& displayProp) void widget::ContainerN::OnDraw(ewol::DrawProperty& _displayProp)
{ {
for (int32_t iii=m_subWidget.Size()-1; iii>=0; iii--) { for (int32_t iii=m_subWidget.Size()-1; iii>=0; iii--) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->GenDraw(displayProp); m_subWidget[iii]->GenDraw(_displayProp);
} }
} }
} }
void widget::ContainerN::CalculateSize(const vec2& availlable) void widget::ContainerN::CalculateSize(const vec2& _availlable)
{ {
EWOL_DEBUG("Update Size ???"); EWOL_DEBUG("Update Size ???");
m_size = availlable; m_size = _availlable;
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) { for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->SetOrigin(m_origin); m_subWidget[iii]->SetOrigin(m_origin);
@ -219,7 +219,7 @@ void widget::ContainerN::OnRegenerateDisplay(void)
} }
} }
ewol::Widget* widget::ContainerN::GetWidgetAtPos(const vec2& pos) ewol::Widget* widget::ContainerN::GetWidgetAtPos(const vec2& _pos)
{ {
if (true == IsHide()) { if (true == IsHide()) {
return NULL; return NULL;
@ -229,10 +229,10 @@ ewol::Widget* widget::ContainerN::GetWidgetAtPos(const vec2& pos)
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->GetSize(); vec2 tmpSize = m_subWidget[iii]->GetSize();
vec2 tmpOrigin = m_subWidget[iii]->GetOrigin(); vec2 tmpOrigin = m_subWidget[iii]->GetOrigin();
if( (tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x()) if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y()) ) && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{ {
ewol::Widget * tmpWidget = m_subWidget[iii]->GetWidgetAtPos(pos); ewol::Widget * tmpWidget = m_subWidget[iii]->GetWidgetAtPos(_pos);
if (NULL != tmpWidget) { if (NULL != tmpWidget) {
return tmpWidget; return tmpWidget;
} }
@ -245,22 +245,22 @@ ewol::Widget* widget::ContainerN::GetWidgetAtPos(const vec2& pos)
}; };
bool widget::ContainerN::LoadXML(TiXmlNode* node) bool widget::ContainerN::LoadXML(TiXmlNode* _node)
{ {
if (NULL==node) { if (NULL==_node) {
return false; return false;
} }
// parse generic properties : // parse generic properties :
ewol::Widget::LoadXML(node); ewol::Widget::LoadXML(_node);
// remove previous element : // remove previous element :
SubWidgetRemoveAll(); SubWidgetRemoveAll();
const char *tmpAttributeValue = node->ToElement()->Attribute("lock"); const char *tmpAttributeValue = _node->ToElement()->Attribute("lock");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
m_lockExpand = tmpAttributeValue; m_lockExpand = tmpAttributeValue;
} }
bool invertAdding=false; bool invertAdding=false;
tmpAttributeValue = node->ToElement()->Attribute("addmode"); tmpAttributeValue = _node->ToElement()->Attribute("addmode");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
etk::UString val(tmpAttributeValue); etk::UString val(tmpAttributeValue);
if(val.CompareNoCase("invert")) { if(val.CompareNoCase("invert")) {
@ -268,7 +268,7 @@ bool widget::ContainerN::LoadXML(TiXmlNode* node)
} }
} }
// parse all the elements : // parse all the elements :
for(TiXmlNode * pNode = node->FirstChild() ; for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ; NULL != pNode ;
pNode = pNode->NextSibling() ) { pNode = pNode->NextSibling() ) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {

View File

@ -37,9 +37,9 @@ namespace widget
public: public:
/** /**
* @brief Limit the expend properties to the current widget (no contamination) * @brief Limit the expend properties to the current widget (no contamination)
* @param[in] lockExpend Lock mode of the expend properties * @param[in] _lockExpend Lock mode of the expend properties
*/ */
void LockExpand(const bvec2& lockExpand); void LockExpand(const bvec2& _lockExpand);
// herited function // herited function
virtual bvec2 CanExpand(void); virtual bvec2 CanExpand(void);
public: public:
@ -49,38 +49,38 @@ namespace widget
virtual void SubWidgetRemoveAll(void); virtual void SubWidgetRemoveAll(void);
/** /**
* @brief Add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @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 * @param[in] _newWidget the element pointer
*/ */
virtual void SubWidgetAdd(ewol::Widget* newWidget); virtual void SubWidgetAdd(ewol::Widget* _newWidget);
inline void SubWidgetAddBack(ewol::Widget* newWidget) { SubWidgetAdd(newWidget); }; inline void SubWidgetAddBack(ewol::Widget* _newWidget) { SubWidgetAdd(_newWidget); };
inline void SubWidgetAddEnd(ewol::Widget* newWidget) { SubWidgetAdd(newWidget); }; inline void SubWidgetAddEnd(ewol::Widget* _newWidget) { SubWidgetAdd(_newWidget); };
/** /**
* @brief Add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @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 * @param[in] _newWidget the element pointer
*/ */
virtual void SubWidgetAddStart(ewol::Widget* newWidget); virtual void SubWidgetAddStart(ewol::Widget* _newWidget);
inline void SubWidgetAddFront(ewol::Widget* newWidget) { SubWidgetAddStart(newWidget); }; inline void SubWidgetAddFront(ewol::Widget* _newWidget) { SubWidgetAddStart(_newWidget); };
/** /**
* @brief Remove definitly a widget from the system and this layer. * @brief Remove definitly a widget from the system and this layer.
* @param[in] newWidget the element pointer. * @param[in] _newWidget the element pointer.
*/ */
virtual void SubWidgetRemove(ewol::Widget* newWidget); virtual void SubWidgetRemove(ewol::Widget* _newWidget);
/** /**
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...) * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...)
* @param[in] newWidget the element pointer. * @param[in] _newWidget the element pointer.
*/ */
virtual void SubWidgetUnLink(ewol::Widget* newWidget); virtual void SubWidgetUnLink(ewol::Widget* _newWidget);
protected: // Derived function protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& _displayProp);
public:// Derived function public:// Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnObjectRemove(ewol::EObject* removeObject); virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual void CalculateSize(const vec2& availlable); virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos); virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* GetWidgetNamed(const etk::UString& widgetName); virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
virtual const char * const GetObjectType(void) { return "Ewol::ContainerN"; }; virtual const char * const GetObjectType(void) { return "Ewol::ContainerN"; };
virtual bool LoadXML(TiXmlNode* node); virtual bool LoadXML(TiXmlNode* _node);
}; };
}; };

View File

@ -192,17 +192,16 @@ void widget::ContextMenu::OnRegenerateDisplay(void)
m_subWidget->OnRegenerateDisplay(); m_subWidget->OnRegenerateDisplay();
} }
} }
bool widget::ContextMenu::OnEventInput(const ewol::EventInput& _event)
bool widget::ContextMenu::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos)
{ {
//EWOL_INFO("Event ouside the context menu"); //EWOL_INFO("Event ouside the context menu");
if (IdInput > 0) { if (_event.GetId() > 0) {
if( typeEvent == ewol::keyEvent::statusDown if( _event.GetStatus() == ewol::keyEvent::statusDown
|| typeEvent == ewol::keyEvent::statusMove || _event.GetStatus() == ewol::keyEvent::statusMove
|| typeEvent == ewol::keyEvent::statusSingle || _event.GetStatus() == ewol::keyEvent::statusSingle
|| typeEvent == ewol::keyEvent::statusUp || _event.GetStatus() == ewol::keyEvent::statusUp
|| typeEvent == ewol::keyEvent::statusEnter || _event.GetStatus() == ewol::keyEvent::statusEnter
|| typeEvent == ewol::keyEvent::statusLeave ) { || _event.GetStatus() == ewol::keyEvent::statusLeave ) {
// Auto-remove ... // Auto-remove ...
AutoDestroy(); AutoDestroy();
return true; return true;

View File

@ -42,7 +42,7 @@ namespace widget {
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
public: // Derived function public: // Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void CalculateSize(const vec2& availlable); virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "ewol::ContextMenu"; }; virtual const char * const GetObjectType(void) { return "ewol::ContextMenu"; };

View File

@ -47,16 +47,19 @@ void widget::Entry::UnInit(void)
} }
widget::Entry::Entry(etk::UString newData) : widget::Entry::Entry(etk::UString _newData) :
m_shaper("THEME:GUI:widgetEntry.conf"), m_shaper("THEME:GUI:widgetEntry.conf"),
m_data(""), m_data(""),
m_textColorFg(draw::color::black), m_maxCharacter(0x7FFFFFFF),
m_textColorBg(draw::color::white), m_regExp(".*"),
m_userSize(50), m_needUpdateTextPos(true),
m_displayStartPosition(0), m_displayStartPosition(0),
m_displayCursor(false), m_displayCursor(false),
m_displayCursorPos(0), m_displayCursorPos(0),
m_displayCursorPosSelection(0) m_displayCursorPosSelection(0),
m_textColorFg(draw::color::black),
m_textColorBg(draw::color::white),
m_textWhenNothing("")
{ {
m_textColorBg.a = 0xAF; m_textColorBg.a = 0xAF;
SetCanHaveFocus(true); SetCanHaveFocus(true);
@ -69,8 +72,7 @@ widget::Entry::Entry(etk::UString newData) :
ShortCutAdd("ctrl+v", ewolEventEntryPaste); ShortCutAdd("ctrl+v", ewolEventEntryPaste);
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL"); ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE"); ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
SetValue(newData); SetValue(_newData);
UpdateTextPosition();
MarkToRedraw(); MarkToRedraw();
} }
@ -81,24 +83,51 @@ widget::Entry::~Entry(void)
} }
void widget::Entry::CalculateMinMaxSize(void) void widget::Entry::SetMaxChar(int32_t _nbMax)
{ {
vec2 padding = m_shaper.GetPadding(); if (_nbMax<=0) {
m_maxCharacter = 0x7FFFFFFF;
} else {
m_maxCharacter = _nbMax;
}
}
int32_t minHeight = m_oObjectText.CalculateSize('A').y(); int32_t widget::Entry::SetMaxChar(void)
m_minSize.setValue(m_userSize + 2*padding.x(), {
minHeight + 2*padding.y()); return m_maxCharacter;
UpdateTextPosition();
MarkToRedraw();
} }
void widget::Entry::SetValue(etk::UString newData) void widget::Entry::CalculateMinMaxSize(void)
{ {
m_data = newData; // call main class
ewol::Widget::CalculateMinMaxSize();
// get generic padding
vec2 padding = m_shaper.GetPadding();
int32_t minHeight = m_oObjectText.CalculateSize('A').y();
vec2 minimumSizeBase(20, minHeight);
// add padding :
minimumSizeBase += padding*2.0f;
m_minSize.setMax(minimumSizeBase);
// verify the min max of the min size ...
CheckMinSize();
}
void widget::Entry::SetValue(const etk::UString& _newData)
{
etk::UString newData = _newData;
if (newData.Size()>m_maxCharacter) {
newData = _newData.Extract(0, m_maxCharacter);
EWOL_DEBUG("Limit entry set of data... " << _newData.Extract(m_maxCharacter));
}
// set the value with the check of the RegExp ...
SetInternalValue(newData);
if (m_data==newData) {
m_displayCursorPos = m_data.Size(); m_displayCursorPos = m_data.Size();
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
EWOL_DEBUG("Set ... " << newData); EWOL_DEBUG("Set ... " << newData);
}
MarkToRedraw(); MarkToRedraw();
} }
@ -108,7 +137,7 @@ etk::UString widget::Entry::GetValue(void)
} }
void widget::Entry::OnDraw(ewol::DrawProperty& displayProp) void widget::Entry::OnDraw(ewol::DrawProperty& _displayProp)
{ {
m_shaper.Draw(); m_shaper.Draw();
m_oObjectText.Draw(); m_oObjectText.Draw();
@ -123,56 +152,55 @@ void widget::Entry::OnRegenerateDisplay(void)
UpdateTextPosition(); UpdateTextPosition();
vec2 padding = m_shaper.GetPadding(); vec2 padding = m_shaper.GetPadding();
int32_t tmpSizeX = m_minSize.x(); vec2 tmpSizeShaper = m_minSize;
int32_t tmpSizeY = m_minSize.y();
int32_t tmpOriginX = 0;
int32_t tmpOriginY = (m_size.y() - tmpSizeY) / 2;
// no change for the text orogin :
int32_t tmpTextOriginX = padding.x();
int32_t tmpTextOriginY = tmpOriginY + padding.y();
if (true==m_userFill.x()) { if (true==m_userFill.x()) {
tmpSizeX = m_size.x(); tmpSizeShaper.setX(m_size.x());
} }
if (true==m_userFill.y()) { if (true==m_userFill.y()) {
//tmpSizeY = m_size.y; tmpSizeShaper.setY(m_size.y());
tmpOriginY = 0;
tmpTextOriginY = tmpOriginY + padding.y();
} }
tmpOriginX += padding.x();
tmpOriginY += padding.y();
tmpSizeX -= 2*padding.x();
tmpSizeY -= 2*padding.y();
vec2 tmpOriginShaper = (m_size - tmpSizeShaper) / 2.0f;
vec2 tmpSizeText = tmpSizeShaper - padding * 2.0f;
vec2 tmpOriginText = (m_size - tmpSizeText) / 2.0f;
// sometimes, the user define an height bigger than the real size needed ==> in this case we need to center the text in the shaper ...
int32_t minHeight = m_oObjectText.CalculateSize('A').y();
if (tmpSizeText.y()>minHeight) {
tmpOriginText += vec2(0,(tmpSizeText.y()-minHeight)/2.0f);
}
// fix all the position in the int32_t class:
tmpSizeShaper = vec2ClipInt32(tmpSizeShaper);
tmpOriginShaper = vec2ClipInt32(tmpOriginShaper);
tmpSizeText = vec2ClipInt32(tmpSizeText);
tmpOriginText = vec2ClipInt32(tmpOriginText);
vec3 textPos( tmpTextOriginX + m_displayStartPosition, m_oObjectText.SetClippingWidth(tmpOriginText, tmpSizeText);
tmpTextOriginY, m_oObjectText.SetPos(tmpOriginText+vec2(m_displayStartPosition,0));
0 );
vec3 drawClippingPos( padding.x(),
padding.y(),
-1 );
vec3 drawClippingSize( m_size.x() - 2*drawClippingPos.x(),
m_size.y() - 2*drawClippingPos.y(),
1 );
m_oObjectText.SetClippingWidth(drawClippingPos, drawClippingSize);
m_oObjectText.SetPos(textPos);
if (m_displayCursorPosSelection != m_displayCursorPos) { if (m_displayCursorPosSelection != m_displayCursorPos) {
m_oObjectText.SetCursorSelection(m_displayCursorPos, m_displayCursorPosSelection); m_oObjectText.SetCursorSelection(m_displayCursorPos, m_displayCursorPosSelection);
} else { } else {
m_oObjectText.SetCursorPos(m_displayCursorPos); m_oObjectText.SetCursorPos(m_displayCursorPos);
} }
if (0!=m_data.Size()) {
m_oObjectText.Print(m_data); m_oObjectText.Print(m_data);
} else {
if (0!=m_textWhenNothing.Size()) {
m_oObjectText.PrintDecorated(m_textWhenNothing);
}
}
m_oObjectText.SetClippingMode(false); m_oObjectText.SetClippingMode(false);
m_shaper.SetSize(m_size);
m_shaper.SetOrigin(tmpOriginShaper);
m_shaper.SetSize(tmpSizeShaper);
} }
} }
void widget::Entry::UpdateCursorPosition(const vec2& pos, bool selection) void widget::Entry::UpdateCursorPosition(const vec2& _pos, bool _selection)
{ {
vec2 padding = m_shaper.GetPadding(); vec2 padding = m_shaper.GetPadding();
vec2 relPos = RelativePosition(pos); vec2 relPos = RelativePosition(_pos);
relPos.setX(relPos.x()-m_displayStartPosition - padding.x()); relPos.setX(relPos.x()-m_displayStartPosition - padding.x());
// try to find the new cursor position : // try to find the new cursor position :
etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition); etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition);
@ -191,7 +219,7 @@ void widget::Entry::UpdateCursorPosition(const vec2& pos, bool selection)
if (newCursorPosition == -1) { if (newCursorPosition == -1) {
newCursorPosition = m_data.Size(); newCursorPosition = m_data.Size();
} }
if (false == selection) { if (false == _selection) {
m_displayCursorPos = newCursorPosition; m_displayCursorPos = newCursorPosition;
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw(); MarkToRedraw();
@ -202,7 +230,7 @@ void widget::Entry::UpdateCursorPosition(const vec2& pos, bool selection)
m_displayCursorPos = newCursorPosition; m_displayCursorPos = newCursorPosition;
MarkToRedraw(); MarkToRedraw();
} }
UpdateTextPosition(); MarkToUpdateTextPosition();
} }
@ -226,7 +254,7 @@ void widget::Entry::RemoveSelected(void)
} }
void widget::Entry::CopySelectionToClipBoard(ewol::clipBoard::clipboardListe_te clipboardID) void widget::Entry::CopySelectionToClipBoard(ewol::clipBoard::clipboardListe_te _clipboardID)
{ {
if (m_displayCursorPosSelection==m_displayCursorPos) { if (m_displayCursorPosSelection==m_displayCursorPos) {
// nothing to cut ... // nothing to cut ...
@ -240,20 +268,20 @@ void widget::Entry::CopySelectionToClipBoard(ewol::clipBoard::clipboardListe_te
} }
// Copy // Copy
etk::UString tmpData = m_data.Extract(pos1, pos2); etk::UString tmpData = m_data.Extract(pos1, pos2);
ewol::clipBoard::Set(clipboardID, tmpData); ewol::clipBoard::Set(_clipboardID, tmpData);
} }
bool widget::Entry::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Entry::OnEventInput(const ewol::EventInput& _event)
{ {
//EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput); //EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput);
if (1 == IdInput) { if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == typeEvent) { if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
KeepFocus(); KeepFocus();
GenerateEventId(ewolEventEntryClick); GenerateEventId(ewolEventEntryClick);
//nothing to do ... //nothing to do ...
return true; return true;
} else if (ewol::keyEvent::statusDouble == typeEvent) { } else if (ewol::keyEvent::statusDouble == _event.GetStatus()) {
KeepFocus(); KeepFocus();
// select word // select word
m_displayCursorPosSelection = m_displayCursorPos-1; m_displayCursorPosSelection = m_displayCursorPos-1;
@ -298,37 +326,37 @@ bool widget::Entry::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
// Copy to clipboard Middle ... // Copy to clipboard Middle ...
CopySelectionToClipBoard(ewol::clipBoard::clipboardSelection); CopySelectionToClipBoard(ewol::clipBoard::clipboardSelection);
MarkToRedraw(); MarkToRedraw();
} else if (ewol::keyEvent::statusTriple == typeEvent) { } else if (ewol::keyEvent::statusTriple == _event.GetStatus()) {
KeepFocus(); KeepFocus();
m_displayCursorPosSelection = 0; m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data.Size(); m_displayCursorPos = m_data.Size();
} else if (ewol::keyEvent::statusDown == typeEvent) { } else if (ewol::keyEvent::statusDown == _event.GetStatus()) {
KeepFocus(); KeepFocus();
UpdateCursorPosition(pos); UpdateCursorPosition(_event.GetPos());
MarkToRedraw(); MarkToRedraw();
} else if (ewol::keyEvent::statusMove == typeEvent) { } else if (ewol::keyEvent::statusMove == _event.GetStatus()) {
KeepFocus(); KeepFocus();
UpdateCursorPosition(pos, true); UpdateCursorPosition(_event.GetPos(), true);
MarkToRedraw(); MarkToRedraw();
} else if (ewol::keyEvent::statusUp == typeEvent) { } else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
KeepFocus(); KeepFocus();
UpdateCursorPosition(pos, true); UpdateCursorPosition(_event.GetPos(), true);
// Copy to clipboard Middle ... // Copy to clipboard Middle ...
CopySelectionToClipBoard(ewol::clipBoard::clipboardSelection); CopySelectionToClipBoard(ewol::clipBoard::clipboardSelection);
MarkToRedraw(); MarkToRedraw();
} }
} }
else if( ewol::keyEvent::typeMouse == type else if( ewol::keyEvent::typeMouse == _event.GetType()
&& 2 == IdInput) { && 2 == _event.GetId()) {
if( typeEvent == ewol::keyEvent::statusDown if( _event.GetStatus() == ewol::keyEvent::statusDown
|| typeEvent == ewol::keyEvent::statusMove || _event.GetStatus() == ewol::keyEvent::statusMove
|| typeEvent == ewol::keyEvent::statusUp) { || _event.GetStatus() == ewol::keyEvent::statusUp) {
KeepFocus(); KeepFocus();
// updatethe cursor position : // updatethe cursor position :
UpdateCursorPosition(pos); UpdateCursorPosition(_event.GetPos());
} }
// Paste current selection only when up button // Paste current selection only when up button
if (typeEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
KeepFocus(); KeepFocus();
// middle button => past data... // middle button => past data...
ewol::clipBoard::Request(ewol::clipBoard::clipboardSelection); ewol::clipBoard::Request(ewol::clipBoard::clipboardSelection);
@ -338,25 +366,26 @@ bool widget::Entry::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
} }
bool widget::Entry::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData) bool widget::Entry::OnEventEntry(const ewol::EventEntry& _event)
{ {
if( typeEvent == ewol::keyEvent::statusDown) { if (_event.GetType() == ewol::keyEvent::keyboardChar) {
if(_event.GetStatus() == ewol::keyEvent::statusDown) {
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " ); //EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
//return GenEventInputExternal(ewolEventEntryEnter, -1, -1); //return GenEventInputExternal(ewolEventEntryEnter, -1, -1);
// remove curent selected data ... // remove curent selected data ...
RemoveSelected(); RemoveSelected();
if( '\n' == unicodeData if( '\n' == _event.GetChar()
|| '\r' == unicodeData) { || '\r' == _event.GetChar()) {
GenerateEventId(ewolEventEntryEnter, m_data); GenerateEventId(ewolEventEntryEnter, m_data);
return true; return true;
} else if (0x7F == unicodeData) { } else if (0x7F == _event.GetChar()) {
// SUPPR : // SUPPR :
if (m_data.Size() > 0 && m_displayCursorPos<m_data.Size()) { if (m_data.Size() > 0 && m_displayCursorPos<m_data.Size()) {
m_data.Remove(m_displayCursorPos, 1); m_data.Remove(m_displayCursorPos, 1);
m_displayCursorPos = etk_max(m_displayCursorPos, 0); m_displayCursorPos = etk_max(m_displayCursorPos, 0);
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
} }
} else if (0x08 == unicodeData) { } else if (0x08 == _event.GetChar()) {
// DEL : // DEL :
if (m_data.Size() > 0 && m_displayCursorPos != 0) { if (m_data.Size() > 0 && m_displayCursorPos != 0) {
m_data.Remove(m_displayCursorPos-1, 1); m_data.Remove(m_displayCursorPos-1, 1);
@ -364,23 +393,27 @@ bool widget::Entry::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t uni
m_displayCursorPos = etk_max(m_displayCursorPos, 0); m_displayCursorPos = etk_max(m_displayCursorPos, 0);
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
} }
} else if(unicodeData >= 20) { } else if(_event.GetChar() >= 20) {
m_data.Add(m_displayCursorPos, unicodeData); if (m_data.Size() > m_maxCharacter) {
EWOL_INFO("Reject data for entry : '" << _event.GetChar() << "'");
} else {
etk::UString newData = m_data;
newData.Add(m_displayCursorPos, _event.GetChar());
SetInternalValue(newData);
if (m_data==newData) {
m_displayCursorPos++; m_displayCursorPos++;
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
} }
}
}
GenerateEventId(ewolEventEntryModify, m_data); GenerateEventId(ewolEventEntryModify, m_data);
MarkToRedraw(); MarkToRedraw();
return true; return true;
} }
return false; return false;
} } else {
if(_event.GetStatus() == ewol::keyEvent::statusDown) {
switch (_event.GetType())
bool widget::Entry::OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent)
{
if(typeEvent == ewol::keyEvent::statusDown) {
switch (moveTypeEvent)
{ {
case ewol::keyEvent::keyboardLeft: case ewol::keyEvent::keyboardLeft:
m_displayCursorPos--; m_displayCursorPos--;
@ -402,19 +435,41 @@ bool widget::Entry::OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::key
MarkToRedraw(); MarkToRedraw();
return true; return true;
} }
}
return false; return false;
} }
void widget::Entry::SetInternalValue(const etk::UString& _newData)
{
etk::UString previous = m_data;
// check the RegExp :
if (_newData.Size()>0) {
if (false==m_regExp.ProcessOneElement(_newData,0,_newData.Size()) ) {
EWOL_INFO("the input data does not match with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp.GetRegExp() << "\" start=" << m_regExp.Start() << " stop=" << m_regExp.Stop() );
return;
}
//EWOL_INFO("find regExp : \"" << m_data << "\" start=" << m_regExp.Start() << " stop=" << m_regExp.Stop() );
if( 0 != m_regExp.Start()
|| _newData.Size() != m_regExp.Stop() ) {
EWOL_INFO("The input data match not entirely with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp.GetRegExp() << "\" start=" << m_regExp.Start() << " stop=" << m_regExp.Stop() );
return;
}
}
m_data = _newData;
}
void widget::Entry::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID) void widget::Entry::OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID)
{ {
// remove curent selected data ... // remove curent selected data ...
RemoveSelected(); RemoveSelected();
// get current selection / Copy : // get current selection / Copy :
etk::UString tmpData = Get(clipboardID); etk::UString tmpData = Get(_clipboardID);
// add it on the current display : // add it on the current display :
if (tmpData.Size() >= 0) { if (tmpData.Size() >= 0) {
m_data.Add(m_displayCursorPos, &tmpData[0]); etk::UString newData = m_data;
newData.Add(m_displayCursorPos, &tmpData[0]);
SetInternalValue(newData);
if (m_data == newData) {
if (m_data.Size() == tmpData.Size()) { if (m_data.Size() == tmpData.Size()) {
m_displayCursorPos = tmpData.Size(); m_displayCursorPos = tmpData.Size();
} else { } else {
@ -423,29 +478,30 @@ void widget::Entry::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboar
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw(); MarkToRedraw();
} }
}
GenerateEventId(ewolEventEntryModify, m_data); GenerateEventId(ewolEventEntryModify, m_data);
} }
void widget::Entry::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data) void widget::Entry::OnReceiveMessage(ewol::EObject * _CallerObject, const char * _eventId, const etk::UString& _data)
{ {
ewol::Widget::OnReceiveMessage(CallerObject, eventId, data); ewol::Widget::OnReceiveMessage(_CallerObject, _eventId, _data);
if(eventId == ewolEventEntryClean) { if(_eventId == ewolEventEntryClean) {
m_data = ""; m_data = "";
m_displayStartPosition = 0; m_displayStartPosition = 0;
m_displayCursorPos = 0; m_displayCursorPos = 0;
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw(); MarkToRedraw();
} else if(eventId == ewolEventEntryCut) { } else if(_eventId == ewolEventEntryCut) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd); CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
RemoveSelected(); RemoveSelected();
GenerateEventId(ewolEventEntryModify, m_data); GenerateEventId(ewolEventEntryModify, m_data);
} else if(eventId == ewolEventEntryCopy) { } else if(_eventId == ewolEventEntryCopy) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd); CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
} else if(eventId == ewolEventEntryPaste) { } else if(_eventId == ewolEventEntryPaste) {
ewol::clipBoard::Request(ewol::clipBoard::clipboardStd); ewol::clipBoard::Request(ewol::clipBoard::clipboardStd);
} else if(eventId == ewolEventEntrySelect) { } else if(_eventId == ewolEventEntrySelect) {
if(data == "ALL") { if(_data == "ALL") {
m_displayCursorPosSelection = 0; m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data.Size(); m_displayCursorPos = m_data.Size();
} else { } else {
@ -455,9 +511,16 @@ void widget::Entry::OnReceiveMessage(ewol::EObject * CallerObject, const char *
} }
} }
void widget::Entry::MarkToUpdateTextPosition(void)
{
m_needUpdateTextPos=true;
}
void widget::Entry::UpdateTextPosition(void) void widget::Entry::UpdateTextPosition(void)
{ {
if (false==m_needUpdateTextPos) {
return;
}
vec2 padding = m_shaper.GetPadding(); vec2 padding = m_shaper.GetPadding();
int32_t tmpSizeX = m_minSize.x(); int32_t tmpSizeX = m_minSize.x();
@ -508,19 +571,89 @@ void widget::Entry::OnLostFocus(void)
} }
void widget::Entry::ChangeStatusIn(int32_t newStatusId) void widget::Entry::ChangeStatusIn(int32_t _newStatusId)
{ {
if (true == m_shaper.ChangeStatusIn(newStatusId) ) { if (true == m_shaper.ChangeStatusIn(_newStatusId) ) {
PeriodicCallSet(true); PeriodicCallSet(true);
MarkToRedraw(); MarkToRedraw();
} }
} }
void widget::Entry::PeriodicCall(int64_t localTime) void widget::Entry::PeriodicCall(int64_t _localTime)
{ {
if (false == m_shaper.PeriodicCall(localTime) ) { if (false == m_shaper.PeriodicCall(_localTime) ) {
PeriodicCallSet(false); PeriodicCallSet(false);
} }
MarkToRedraw(); MarkToRedraw();
} }
void widget::Entry::SetRegExp(const etk::UString& _expression)
{
etk::UString previousRegExp = m_regExp.GetRegExp();
EWOL_DEBUG("change input regExp \"" << previousRegExp << "\" ==> \"" << _expression << "\"");
m_regExp.SetRegExp(_expression);
if (m_regExp.GetStatus()==false) {
EWOL_ERROR("error when adding regExp ... ==> set the previous back ...");
m_regExp.SetRegExp(previousRegExp);
}
}
void widget::Entry::SetColorText(const draw::Color& _color)
{
m_textColorFg = _color;
MarkToRedraw();
}
void widget::Entry::SetColorTextSelected(const draw::Color& _color)
{
m_textColorBg = _color;
MarkToRedraw();
}
void widget::Entry::SetEmptyText(const etk::UString& _text)
{
m_textWhenNothing = _text;
MarkToRedraw();
}
bool widget::Entry::LoadXML(TiXmlNode* _node)
{
if (NULL==_node) {
return false;
}
ewol::Widget::LoadXML(_node);
// get internal data :
const char *xmlData = _node->ToElement()->Attribute("color");
if (NULL != xmlData) {
m_textColorFg = xmlData;
}
xmlData = _node->ToElement()->Attribute("background");
if (NULL != xmlData) {
m_textColorBg = xmlData;
}
xmlData = _node->ToElement()->Attribute("regExp");
if (NULL != xmlData) {
SetRegExp(xmlData);
}
xmlData = _node->ToElement()->Attribute("max");
if (NULL != xmlData) {
int32_t tmpVal=0;
sscanf(xmlData, "%d", &tmpVal);
m_maxCharacter = tmpVal;
}
xmlData = _node->ToElement()->Attribute("emptytext");
if (NULL != xmlData) {
m_textWhenNothing = xmlData;
}
MarkToRedraw();
return true;
}

View File

@ -10,6 +10,7 @@
#define __EWOL_ENTRY_H__ #define __EWOL_ENTRY_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/RegExp.h>
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/compositing/Text.h> #include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h> #include <ewol/compositing/Drawing.h>
@ -38,78 +39,157 @@ namespace widget {
static void UnInit(void); static void UnInit(void);
private: private:
ewol::Shaper m_shaper; ewol::Shaper m_shaper;
ewol::Text m_oObjectText; //!< text display ewol::Text m_oObjectText; //!< text display m_text
etk::UString m_data; //!< sting that must be displayed
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
int32_t m_userSize; //!< Display size requested by the user
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
bool m_displayCursor; //!< Cursor mus be display only when the widget has the focus
int32_t m_displayCursorPos; //!< Cursor position in number of Char
int32_t m_displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == m_displayCursorPos chan no selection availlable
public: public:
/** /**
* @brief Contuctor * @brief Contuctor
* @param[in] newData The USting that might be set in the Entry box (no event generation!!) * @param[in] _newData The USting that might be set in the Entry box (no event generation!!)
*/ */
Entry(etk::UString newData = ""); Entry(etk::UString _newData = "");
/** /**
* @brief Destuctor * @brief Destuctor
*/ */
virtual ~Entry(void); virtual ~Entry(void);
void SetValue(etk::UString newData);
etk::UString GetValue(void); private:
void SetWidth(int32_t width) etk::UString m_data; //!< sting that must be displayed
{
m_userSize = width;
}
public:
// Derived function
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos);
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
virtual bool OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent);
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
virtual const char * const GetObjectType(void) { return "EwolEntry"; };
virtual void CalculateMinMaxSize(void);
protected: protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
/** /**
* @brief Change the cursor position with the curent position requested on the display * @brief internal check the value with RegExp checking
* @param[in] pos Absolute position of the event * @param[in] _newData The new string to display
* @note The display is automaticly requested when change apear.
* @return ---
*/ */
virtual void UpdateCursorPosition(const vec2& pos, bool Selection=false); void SetInternalValue(const etk::UString& _newData);
public:
/**
* @brief set a new value on the entry.
* @param[in] _newData the new string to display.
*/
void SetValue(const etk::UString& _newData);
/**
* @brief Get the current value in the entry
* @return The current display value
*/
etk::UString GetValue(void);
private:
int32_t m_maxCharacter; //!< number max of xharacter in the list
public:
/**
* @brief Limit the number of Unicode character in the entry
* @param[in] _nbMax Number of max character set in the List (0x7FFFFFFF for no limit)
*/
void SetMaxChar(int32_t _nbMax);
/**
* @brief Limit the number of Unicode character in the entry
* @return Number of max character set in the List.
*/
int32_t SetMaxChar(void);
private:
etk::RegExp<etk::UString> m_regExp; //!< regular expression to limit the input of an entry
public:
/**
* @brief Limit the input entry at a regular expression... (by default it is "*")
* @param _expression New regular expression
*/
void SetRegExp(const etk::UString& _expression);
/**
* @brief Get the regualar expression limitation
* @param The regExp string
*/
etk::UString SetRegExp(void) { return m_regExp.GetRegExp(); };
private:
bool m_needUpdateTextPos; //!< text position can have change
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
bool m_displayCursor; //!< Cursor must be display only when the widget has the focus
int32_t m_displayCursorPos; //!< Cursor position in number of Char
int32_t m_displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == m_displayCursorPos chan no selection availlable
protected:
/**
* @brief informe the system thet the text change and the start position change
*/
virtual void MarkToUpdateTextPosition(void);
/** /**
* @brief Update the display position start ==> depending of the position of the Cursor and the size of the Data inside * @brief Update the display position start ==> depending of the position of the Cursor and the size of the Data inside
* @param ---
* @return ---
* @change m_displayStartPosition <== updated * @change m_displayStartPosition <== updated
*/ */
virtual void UpdateTextPosition(void); virtual void UpdateTextPosition(void);
/** /**
* @brief Copy the selected data on the specify clipboard * @brief Change the cursor position with the curent position requested on the display
* @param[in] clipboardID Selected clipboard * @param[in] _pos Absolute position of the event
* @return --- * @note The display is automaticly requested when change apear.
*/ */
virtual void CopySelectionToClipBoard(ewol::clipBoard::clipboardListe_te clipboardID); virtual void UpdateCursorPosition(const vec2& _pos, bool _Selection=false);
public:
/**
* @brief Copy the selected data on the specify clipboard
* @param[in] _clipboardID Selected clipboard
*/
virtual void CopySelectionToClipBoard(ewol::clipBoard::clipboardListe_te _clipboardID);
/** /**
* @brief Remove the selected area * @brief Remove the selected area
* @note This request a regeneration of the display * @note This request a regeneration of the display
* @return ---
*/ */
virtual void RemoveSelected(void); virtual void RemoveSelected(void);
// Derived function
private:
draw::Color m_textColorFg; //!< Text color.
public:
/**
* @brief Set text color.
* @param _color Color that is selected.
*/
void SetColorText(const draw::Color& _color);
/**
* @brief Get the color for the text.
* @return The color requested.
*/
draw::Color GetColorText(void) { return m_textColorFg; };
private:
draw::Color m_textColorBg; //!< Background color.
public:
/**
* @brief Set text backgroung color when selected.
* @param _color Color that is selected.
*/
void SetColorTextSelected(const draw::Color& _color);
/**
* @brief Get the selected color for the text in selection mode.
* @return The color requested.
*/
draw::Color GetColorTextSelected(void) { return m_textColorBg; };
private:
etk::UString m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...)
public:
/**
* @brief Set The text displayed when nothing is in the entry.
* @param _text Text to display when the entry box is empty (this text can be decorated).
*/
void SetEmptyText(const etk::UString& _text);
/**
* @brief Get The text displayed when nothing is in the entry.
* @return Text display when nothing
*/
etk::UString GetEmptyText(void) { return m_textWhenNothing; };
public: // Derived function
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual void OnReceiveMessage(ewol::EObject * _CallerObject, const char * _eventId, const etk::UString& _data);
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID);
virtual const char * const GetObjectType(void) { return "EwolEntry"; };
virtual void CalculateMinMaxSize(void);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual void OnGetFocus(void); virtual void OnGetFocus(void);
// Derived function
virtual void OnLostFocus(void); virtual void OnLostFocus(void);
// change the current shaper display : virtual void ChangeStatusIn(int32_t _newStatusId);
void ChangeStatusIn(int32_t newStatusId); virtual void PeriodicCall(int64_t _localTime);
// Derived function virtual bool LoadXML(TiXmlNode* _node);
virtual void PeriodicCall(int64_t localTime);
}; };
}; };

View File

@ -34,59 +34,59 @@ void widget::Image::UnInit(void)
} }
widget::Image::Image(const etk::UString& file, const ewol::Dimension& border) : widget::Image::Image(const etk::UString& _file, const ewol::Dimension& _border) :
m_imageSize(vec2(0,0)), m_imageSize(vec2(0,0)),
m_keepRatio(true) m_keepRatio(true)
{ {
AddEventId(ewolEventImagePressed); AddEventId(ewolEventImagePressed);
Set(file, border); Set(_file, _border);
} }
void widget::Image::SetFile(const etk::UString& file) void widget::Image::SetFile(const etk::UString& _file)
{ {
// copy data : // copy data :
m_fileName = file; m_fileName = _file;
// Force redraw all : // Force redraw all :
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
m_compositing.SetSource(m_fileName, vec2(64,64)); m_compositing.SetSource(m_fileName, vec2(64,64));
} }
void widget::Image::SetBorder(const ewol::Dimension& border) void widget::Image::SetBorder(const ewol::Dimension& _border)
{ {
// copy data : // copy data :
m_border = border; m_border = _border;
// Force redraw all : // Force redraw all :
MarkToRedraw(); MarkToRedraw();
// TODO : Change the size with no size requested ... // TODO : Change the size with no size requested ...
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
void widget::Image::SetKeepRatio(bool keep) void widget::Image::SetKeepRatio(bool _keep)
{ {
if (m_keepRatio != keep) { if (m_keepRatio != _keep) {
// copy data : // copy data :
m_keepRatio = keep; m_keepRatio = _keep;
// Force redraw all : // Force redraw all :
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
} }
void widget::Image::SetImageSize(const ewol::Dimension& size) void widget::Image::SetImageSize(const ewol::Dimension& _size)
{ {
m_imageSize = size; m_imageSize = _size;
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
m_compositing.SetSource(m_fileName, m_imageSize.GetPixel()); m_compositing.SetSource(m_fileName, m_imageSize.GetPixel());
} }
void widget::Image::Set(const etk::UString& file, const ewol::Dimension& border) void widget::Image::Set(const etk::UString& _file, const ewol::Dimension& _border)
{ {
// copy data : // copy data :
m_border = border; m_border = _border;
m_fileName = file; m_fileName = _file;
// Force redraw all : // Force redraw all :
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
@ -94,7 +94,7 @@ void widget::Image::Set(const etk::UString& file, const ewol::Dimension& border)
} }
void widget::Image::OnDraw(ewol::DrawProperty& displayProp) void widget::Image::OnDraw(ewol::DrawProperty& _displayProp)
{ {
m_compositing.Draw(); m_compositing.Draw();
} }
@ -153,11 +153,11 @@ void widget::Image::CalculateMinMaxSize(void)
} }
bool widget::Image::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Image::OnEventInput(const ewol::EventInput& _event)
{ {
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == IdInput) { if (1 == _event.GetId()) {
if( ewol::keyEvent::statusSingle == typeEvent) { if( ewol::keyEvent::statusSingle == _event.GetStatus()) {
GenerateEventId(ewolEventImagePressed); GenerateEventId(ewolEventImagePressed);
return true; return true;
} }
@ -165,15 +165,15 @@ bool widget::Image::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
return false; return false;
} }
bool widget::Image::LoadXML(TiXmlNode* node) bool widget::Image::LoadXML(TiXmlNode* _node)
{ {
if (NULL==node) { if (NULL==_node) {
return false; return false;
} }
ewol::Widget::LoadXML(node); ewol::Widget::LoadXML(_node);
// get internal data : // get internal data :
const char *tmpAttributeValue = node->ToElement()->Attribute("ratio"); const char *tmpAttributeValue = _node->ToElement()->Attribute("ratio");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
if (strcmp(tmpAttributeValue,"true")==0) { if (strcmp(tmpAttributeValue,"true")==0) {
m_keepRatio = true; m_keepRatio = true;
@ -183,21 +183,21 @@ bool widget::Image::LoadXML(TiXmlNode* node)
m_keepRatio = false; m_keepRatio = false;
} }
} }
tmpAttributeValue = node->ToElement()->Attribute("size"); tmpAttributeValue = _node->ToElement()->Attribute("size");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
//EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue); //EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue);
m_imageSize = tmpAttributeValue; m_imageSize = tmpAttributeValue;
//EWOL_CRITICAL(" ==> " << m_imageSize); //EWOL_CRITICAL(" ==> " << m_imageSize);
} }
tmpAttributeValue = node->ToElement()->Attribute("border"); tmpAttributeValue = _node->ToElement()->Attribute("border");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
m_border = tmpAttributeValue; m_border = tmpAttributeValue;
} }
//EWOL_DEBUG("Load label:" << node->ToElement()->GetText()); //EWOL_DEBUG("Load label:" << node->ToElement()->GetText());
if (node->ToElement()->GetText() != NULL) { if (_node->ToElement()->GetText() != NULL) {
SetFile(node->ToElement()->GetText()); SetFile(_node->ToElement()->GetText());
} else { } else {
tmpAttributeValue = node->ToElement()->Attribute("src"); tmpAttributeValue = _node->ToElement()->Attribute("src");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
SetFile(tmpAttributeValue); SetFile(tmpAttributeValue);
} }

View File

@ -35,66 +35,65 @@ namespace widget {
/** /**
* @brief * @brief
*/ */
Image(const etk::UString& file="", Image(const etk::UString& _file="",
const ewol::Dimension& border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter)); const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
/** /**
* @brief * @brief
*/ */
virtual ~Image(void) { }; virtual ~Image(void) { };
/** /**
* @brief Set All the configuration of the current image * @brief Set All the configuration of the current image
* @param[in] file Filaneme of the new image * @param[in] _file Filaneme of the new image
* @param[in] border New border size to set * @param[in] _border New border size to set
* @param[in] size new size of the display
*/ */
void Set(const etk::UString& file, const ewol::Dimension& border); void Set(const etk::UString& _file, const ewol::Dimension& _border);
protected: protected:
etk::UString m_fileName; //!< File name of the image. etk::UString m_fileName; //!< File name of the image.
public: public:
/** /**
* @brief Set the new filename * @brief Set the new filename
* @param[in] file Filaneme of the new image * @param[in] _file Filaneme of the new image
*/ */
void SetFile(const etk::UString& file); void SetFile(const etk::UString& _file);
/** /**
* @brief Get the file displayed * @brief Get the file displayed
* @return the filename of the image * @return the filename of the image
*/ */
const etk::UString& GetFile() { return m_fileName; }; const etk::UString& GetFile(void) { return m_fileName; };
protected: protected:
ewol::Dimension m_border; //!< border to add at the image. ewol::Dimension m_border; //!< border to add at the image.
public: public:
/** /**
* @brief Set tge Border size around the image * @brief Set tge Border size around the image
* @param[in] border New border size to set * @param[in] _border New border size to set
*/ */
void SetBorder(const ewol::Dimension& border); void SetBorder(const ewol::Dimension& _border);
/** /**
* @brief Get the current border request at the image * @brief Get the current border request at the image
* @return the border size * @return the border size
*/ */
const ewol::Dimension& GetBorder() { return m_border; }; const ewol::Dimension& GetBorder(void) { return m_border; };
protected: protected:
ewol::Dimension m_imageSize; //!< border to add at the image. ewol::Dimension m_imageSize; //!< border to add at the image.
public: public:
/** /**
* @brief Set tge Border size around the image * @brief Set tge Border size around the image
* @param[in] border New border size to set * @param[in] _size New border size to set
*/ */
void SetImageSize(const ewol::Dimension& size); void SetImageSize(const ewol::Dimension& _size);
/** /**
* @brief Get the current border request at the image * @brief Get the current border request at the image
* @return the border size * @return the border size
*/ */
const ewol::Dimension& GetImageSize() { return m_imageSize; }; const ewol::Dimension& GetImageSize(void) { return m_imageSize; };
protected: protected:
bool m_keepRatio; //!< Keep the image ratio between width and hight bool m_keepRatio; //!< Keep the image ratio between width and hight
public: public:
/** /**
* @brief Set the current status of keeping ratio. * @brief Set the current status of keeping ratio.
* @param[in] The new status of keeping the ratio of this image. * @param[in] _keep The new status of keeping the ratio of this image.
*/ */
void SetKeepRatio(bool keep); void SetKeepRatio(bool _keep);
/** /**
* @brief Get the current status of keeping ratio. * @brief Get the current status of keeping ratio.
* @return The status of keeping the ratio of this image. * @return The status of keeping the ratio of this image.
@ -105,9 +104,9 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "Ewol::Image"; }; virtual const char * const GetObjectType(void) { return "Ewol::Image"; };
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool LoadXML(TiXmlNode* node); virtual bool LoadXML(TiXmlNode* _node);
}; };
}; };

View File

@ -118,7 +118,7 @@ Sine Function: sin(teta) = Opposite / Hypotenuse
Cosine Function: cos(teta) = Adjacent / Hypotenuse Cosine Function: cos(teta) = Adjacent / Hypotenuse
Tangent Function: tan(teta) = Opposite / Adjacent Tangent Function: tan(teta) = Opposite / Adjacent
*/ */
bool widget::Joystick::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Joystick::OnEventInput(const ewol::EventInput& _event)
{ {
/* /*
if (1 == IdInput) { if (1 == IdInput) {

View File

@ -46,7 +46,7 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "Ewol::Joystick"; }; virtual const char * const GetObjectType(void) { return "Ewol::Joystick"; };
virtual void CalculateSize(const vec2& availlable); virtual void CalculateSize(const vec2& availlable);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
void SetLockMode(bool lockWhenOut) { m_lock = lockWhenOut; }; void SetLockMode(bool lockWhenOut) { m_lock = lockWhenOut; };
void SetDisplayMode(joystickMode_te newMode) { m_displayMode = newMode; }; void SetDisplayMode(joystickMode_te newMode) { m_displayMode = newMode; };

View File

@ -32,9 +32,9 @@ void widget::Label::UnInit(void)
ewol::widgetManager::AddWidgetCreator(__class__,NULL); ewol::widgetManager::AddWidgetCreator(__class__,NULL);
} }
widget::Label::Label(etk::UString newLabel) widget::Label::Label(etk::UString _newLabel)
{ {
m_label = newLabel; m_label = _newLabel;
AddEventId(ewolEventLabelPressed); AddEventId(ewolEventLabelPressed);
SetCanHaveFocus(false); SetCanHaveFocus(false);
} }
@ -51,9 +51,9 @@ void widget::Label::CalculateMinMaxSize(void)
m_minSize.setY(etk_min(4 + minSize.y(), tmpMax.y())); m_minSize.setY(etk_min(4 + minSize.y(), tmpMax.y()));
} }
void widget::Label::SetLabel(const etk::UString& newLabel) void widget::Label::SetLabel(const etk::UString& _newLabel)
{ {
m_label = newLabel; m_label = _newLabel;
MarkToRedraw(); MarkToRedraw();
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
@ -63,7 +63,7 @@ etk::UString widget::Label::GetLabel(void)
return m_label; return m_label;
} }
void widget::Label::OnDraw(ewol::DrawProperty& displayProp) void widget::Label::OnDraw(ewol::DrawProperty& _displayProp)
{ {
m_text.Draw(); m_text.Draw();
} }
@ -118,11 +118,11 @@ void widget::Label::OnRegenerateDisplay(void)
} }
} }
bool widget::Label::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Label::OnEventInput(const ewol::EventInput& _event)
{ {
//EWOL_DEBUG("Event on Label ..."); //EWOL_DEBUG("Event on Label ...");
if (1 == IdInput) { if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == typeEvent) { if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
// nothing to do ... // nothing to do ...
GenerateEventId(ewolEventLabelPressed); GenerateEventId(ewolEventLabelPressed);
return true; return true;
@ -131,15 +131,15 @@ bool widget::Label::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
return false; return false;
} }
bool widget::Label::LoadXML(TiXmlNode* node) bool widget::Label::LoadXML(TiXmlNode* _node)
{ {
if (NULL==node) { if (NULL==_node) {
return false; return false;
} }
ewol::Widget::LoadXML(node); ewol::Widget::LoadXML(_node);
// get internal data : // get internal data :
// TODO : Unparse data type XML ... // TODO : Unparse data type XML ...
EWOL_DEBUG("Load label:" << node->ToElement()->GetText()); EWOL_DEBUG("Load label:" << _node->ToElement()->GetText());
SetLabel(node->ToElement()->GetText()); SetLabel(_node->ToElement()->GetText());
return true; return true;
} }

View File

@ -34,18 +34,18 @@ namespace widget {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* @param[in] newLabel The displayed decorated text. * @param[in] _newLabel The displayed decorated text.
*/ */
Label(etk::UString newLabel="---"); Label(etk::UString _newLabel="---");
/** /**
* @brief destructor * @brief destructor
*/ */
virtual ~Label(void) { }; virtual ~Label(void) { };
/** /**
* @brief Change the label displayed * @brief Change the label displayed
* @param[in] newLabel The displayed decorated text. * @param[in] _newLabel The displayed decorated text.
*/ */
void SetLabel(const etk::UString& newLabel); void SetLabel(const etk::UString& _newLabel);
/** /**
* @brief Get the current displayed label * @brief Get the current displayed label
* @return The displayed decorated text. * @return The displayed decorated text.
@ -56,9 +56,9 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "Ewol::Label"; }; virtual const char * const GetObjectType(void) { return "Ewol::Label"; };
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool LoadXML(TiXmlNode* node); virtual bool LoadXML(TiXmlNode* _node);
}; };
}; };

View File

@ -200,11 +200,11 @@ void widget::List::OnRegenerateDisplay(void)
} }
} }
bool widget::List::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::List::OnEventInput(const ewol::EventInput& _event)
{ {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) { if (true == WidgetScrooled::OnEventInput(_event)) {
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widet ... // nothing to do ... done on upper widet ...
return true; return true;
@ -221,7 +221,7 @@ bool widget::List::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, e
} }
//EWOL_DEBUG("List event : idInput=" << IdInput << " typeEvent=" << typeEvent << " raw=" << rawID << " pos=" << pos << ""); //EWOL_DEBUG("List event : idInput=" << IdInput << " typeEvent=" << typeEvent << " raw=" << rawID << " pos=" << pos << "");
bool isUsed = OnItemEvent(IdInput, typeEvent, 0, rawID, pos.x(), pos.y()); bool isUsed = OnItemEvent(_event.GetId(), _event.GetStatus(), 0, rawID, _event.GetPos().x(), _event.GetPos().y());
if (true == isUsed) { if (true == isUsed) {
// TODO : this generate bugs ... I did not understand why .. // TODO : this generate bugs ... I did not understand why ..
//ewol::widgetManager::FocusKeep(this); //ewol::widgetManager::FocusKeep(this);

View File

@ -46,7 +46,7 @@ namespace widget {
// Derived function // Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
// Derived function // Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
protected: protected:
// function call to display the list : // function call to display the list :
virtual draw::Color GetBasicBG(void) { virtual draw::Color GetBasicBG(void) {

View File

@ -102,11 +102,11 @@ void widget::Mesh::PeriodicCall(int64_t localTime)
m_lastTime = localTime; m_lastTime = localTime;
} }
bool widget::Mesh::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Mesh::OnEventInput(const ewol::EventInput& _event)
{ {
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == IdInput) { if (1 == _event.GetId()) {
if( ewol::keyEvent::statusSingle == typeEvent) { if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
GenerateEventId(ewolEventMeshPressed); GenerateEventId(ewolEventMeshPressed);
return true; return true;
} }

View File

@ -37,7 +37,7 @@ namespace widget {
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual void GenDraw(ewol::DrawProperty displayProp); virtual void GenDraw(ewol::DrawProperty displayProp);
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void PeriodicCall(int64_t localTime); virtual void PeriodicCall(int64_t localTime);
public: public:
/** /**

View File

@ -1131,26 +1131,27 @@ vec2 widget::Scene::RelativePosition(vec2 pos)
}; };
bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te statusEvent, const vec2& pos) bool widget::Scene::OnEventInput(const ewol::EventInput& _event)
OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te statusEvent, const vec2& pos)
{ {
//EWOL_DEBUG("type : " << type << " IdInput=" << IdInput << " " << "status=" << statusEvent << " RelPos=" << relativePos); //EWOL_DEBUG("type : " << type << " IdInput=" << IdInput << " " << "status=" << statusEvent << " RelPos=" << relativePos);
if (type == ewol::keyEvent::typeMouse) { if (_event.GetType() == ewol::keyEvent::typeMouse) {
if (0 != IdInput) { if (0 != _event.GetId()) {
KeepFocus(); KeepFocus();
GrabCursor(); GrabCursor();
SetCursor(ewol::cursorNone); SetCursor(ewol::cursorNone);
} }
if (true == GetGrabStatus() ) { if (true == GetGrabStatus() ) {
if (ewol::keyEvent::statusMove == statusEvent) { if (ewol::keyEvent::statusMove == statusEvent) {
vec2 tmpPos = pos * M_PI/(360.0f*6); vec2 tmpPos = _event.GetPos() * M_PI/(360.0f*6);
vec3 oldAngles = m_camera.GetAngle(); vec3 oldAngles = m_camera.GetAngle();
oldAngles.setZ(oldAngles.z() + tmpPos.x()); oldAngles.setZ(oldAngles.z() + tmpPos.x());
oldAngles.setY(oldAngles.y() + tmpPos.y()); oldAngles.setY(oldAngles.y() + tmpPos.y());
m_camera.SetAngle(oldAngles); m_camera.SetAngle(oldAngles);
} }
} }
} else if (type == ewol::keyEvent::typeFinger) { } else if (_event.GetType() == ewol::keyEvent::typeFinger) {
KeepFocus(); KeepFocus();
} }
// note : we did not parse the oether media ... // note : we did not parse the oether media ...
@ -1159,14 +1160,15 @@ bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
} }
bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData) bool widget::Scene::OnEventEntry(const ewol::EventEntry& _event)
OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData)
{ {
if (_event.GetType() == ewol:::keyEvent:keyboardChar) {
EWOL_DEBUG("KB EVENT : \"" << unicodeData << "\"" << "type=" << statusEvent); EWOL_DEBUG("KB EVENT : \"" << _event.GetChar() << "\"" << "type=" << _event.GetStatus());
// escape case : // escape case :
if(unicodeData == 27) { if(_event.GetChar() == 27) {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
UnGrabCursor(); UnGrabCursor();
SetCursor(ewol::cursorArrow); SetCursor(ewol::cursorArrow);
} }
@ -1176,45 +1178,45 @@ bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t u
GrabCursor(); GrabCursor();
SetCursor(ewol::cursorNone); SetCursor(ewol::cursorNone);
} }
if( unicodeData == 'z' if( _event.GetChar() == 'z'
|| unicodeData == 'Z') { || _event.GetChar() == 'Z') {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD; m_walk |= WALK_FLAG_FORWARD;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) { if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD; m_walk -= WALK_FLAG_FORWARD;
} }
} }
} }
if( unicodeData == 's' if( _event.GetChar() == 's'
|| unicodeData == 'S') { || _event.GetChar() == 'S') {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK; m_walk |= WALK_FLAG_BACK;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) { if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK; m_walk -= WALK_FLAG_BACK;
} }
} }
} }
if( unicodeData == 'q' if( _event.GetChar() == 'q'
|| unicodeData == 'Q') { || _event.GetChar() == 'Q') {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT; m_walk |= WALK_FLAG_LEFT;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) { if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT; m_walk -= WALK_FLAG_LEFT;
} }
} }
} }
if( unicodeData == 'd' if( _event.GetChar() == 'd'
|| unicodeData == 'D') { || _event.GetChar() == 'D') {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT; m_walk |= WALK_FLAG_RIGHT;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) { if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT; m_walk -= WALK_FLAG_RIGHT;
} }
@ -1222,54 +1224,53 @@ bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t u
} }
EWOL_DEBUG("m_walk=" << m_walk); EWOL_DEBUG("m_walk=" << m_walk);
return false; return false;
} }
// --------------------
// -- move mode :
bool widget::Scene::OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey) // --------------------
{ if (_event.GetType() == ewol::keyEvent::keyboardUp) {
if (specialKey == ewol::keyEvent::keyboardUp) {
EWOL_DEBUG("test ..." << specialKey << " " << statusEvent); EWOL_DEBUG("test ..." << specialKey << " " << statusEvent);
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD; m_walk |= WALK_FLAG_FORWARD;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) { if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD; m_walk -= WALK_FLAG_FORWARD;
} }
} }
} }
if (specialKey == ewol::keyEvent::keyboardDown) { if (_event.GetType() == ewol::keyEvent::keyboardDown) {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK; m_walk |= WALK_FLAG_BACK;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) { if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK; m_walk -= WALK_FLAG_BACK;
} }
} }
} }
if (specialKey == ewol::keyEvent::keyboardLeft) { if (_event.GetType() == ewol::keyEvent::keyboardLeft) {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT; m_walk |= WALK_FLAG_LEFT;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) { if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT; m_walk -= WALK_FLAG_LEFT;
} }
} }
} }
if (specialKey == ewol::keyEvent::keyboardRight) { if (_event.GetType() == ewol::keyEvent::keyboardRight) {
if (statusEvent == ewol::keyEvent::statusDown) { if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT; m_walk |= WALK_FLAG_RIGHT;
} }
if (statusEvent == ewol::keyEvent::statusUp) { if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) { if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT; m_walk -= WALK_FLAG_RIGHT;
} }
} }
} }
EWOL_DEBUG("m_walk=" << m_walk); EWOL_DEBUG("m_walk=" << m_walk);
return false; return true;
} }

View File

@ -97,25 +97,14 @@ namespace widget {
* @return the relative position * @return the relative position
*/ */
virtual vec2 RelativePosition(vec2 pos); virtual vec2 RelativePosition(vec2 pos);
public: // dericed function:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Scene"; }; virtual const char * const GetObjectType(void) { return "Ewol::Scene"; };
// Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
// Derived function
virtual void PeriodicCall(int64_t localTime); virtual void PeriodicCall(int64_t localTime);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
// Derived function virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te statusEvent, const vec2& pos);
// Derived function
virtual bool OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData);
// Derived function
virtual bool OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey);
// Derived function
virtual void OnGetFocus(void); virtual void OnGetFocus(void);
// Derived function
virtual void OnLostFocus(void); virtual void OnLostFocus(void);
void renderscene(int pass); void renderscene(int pass);
void DrawOpenGL(btScalar* m, void DrawOpenGL(btScalar* m,

View File

@ -0,0 +1,59 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/widget/Scroll.h>
#include <ewol/ewol.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/debug.h>
#undef __class__
#define __class__ "Scroll"
static ewol::Widget* Create(void)
{
return new widget::Scroll();
}
void widget::Scroll::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Scroll::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Scroll::Scroll(void) :
m_scrollOrigin(0,0),
m_scrollSize(0,0)
{
}
widget::Scroll::~Scroll(void)
{
}
ewol::Widget* widget::Scroll::GetWidgetAtPos(const vec2& _pos)
{
if (false==IsHide()) {
return this;
}
return NULL;
}
bool widget::Scroll::OnEventInput(const ewol::EventInput& _event)
{
EWOL_DEBUG("event from the scroll ... " << _event.GetType() << " idinput=" << _event.GetId() << " status=" << _event.GetStatus());
return false;
}

View File

@ -0,0 +1,45 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_WIDGET_SCROLL_H__
#define __EWOL_WIDGET_SCROLL_H__
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/Container.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Drawing.h>
namespace widget {
class Scroll : public widget::Container
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Drawing m_draw;
protected:
vec2 m_scrollOrigin;
vec2 m_scrollSize;
//float m_limitScrolling;
public:
Scroll(void);
virtual ~Scroll(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "ewol::widget::Scroll"; };
//virtual void OnRegenerateDisplay(void);
//virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
virtual bool OnEventInput(const ewol::EventInput& _event);
//virtual void GenDraw(ewol::DrawProperty _displayProp);
protected:
};
};
#endif

View File

@ -127,13 +127,13 @@ void widget::Slider::OnRegenerateDisplay(void)
} }
bool widget::Slider::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::Slider::OnEventInput(const ewol::EventInput& _event)
{ {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
//EWOL_DEBUG("Event on Slider ..."); //EWOL_DEBUG("Event on Slider ...");
if (1 == IdInput) { if (1 == _event.GetId()) {
if( ewol::keyEvent::statusSingle == typeEvent if( ewol::keyEvent::statusSingle == _event.GetStatus()
|| ewol::keyEvent::statusMove == typeEvent) { || ewol::keyEvent::statusMove == _event.GetStatus()) {
// get the new position : // get the new position :
EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")"); EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")");
int32_t oldValue = m_value; int32_t oldValue = m_value;

View File

@ -41,7 +41,7 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "Ewol::Slider"; } ; virtual const char * const GetObjectType(void) { return "Ewol::Slider"; } ;
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
}; };
}; };

View File

@ -19,6 +19,7 @@
#define __class__ "Widget" #define __class__ "Widget"
ewol::Widget::Widget(void) : ewol::Widget::Widget(void) :
m_up(NULL),
m_size(10,10), m_size(10,10),
m_minSize(0,0), m_minSize(0,0),
m_maxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)), m_maxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)),
@ -49,6 +50,26 @@ ewol::Widget::~Widget(void)
ShortCutClean(); ShortCutClean();
} }
void ewol::Widget::SetUpperWidget(ewol::Widget* _upper)
{
if (NULL == _upper) {
//just remove father :
m_up = NULL;
return;
}
if (NULL != m_up) {
EWOL_WARNING("[" << GetId() << "] Replace upper widget of this one ...");
}
m_up = _upper;
}
void ewol::Widget::OnObjectRemove(ewol::EObject* _removeObject)
{
if (_removeObject == m_up) {
EWOL_WARNING("[" << GetId() << "] Remove upper widget befor removing this widget ...");
m_up = NULL;
}
}
void ewol::Widget::Hide(void) void ewol::Widget::Hide(void)
{ {
@ -66,9 +87,9 @@ void ewol::Widget::Show(void)
} }
void ewol::Widget::CalculateSize(const vec2& availlable) void ewol::Widget::CalculateSize(const vec2& _availlable)
{ {
m_size = availlable; m_size = _availlable;
MarkToRedraw(); MarkToRedraw();
} }
@ -95,9 +116,9 @@ bool ewol::Widget::RmFocus(void)
} }
void ewol::Widget::SetCanHaveFocus(bool canFocusState) void ewol::Widget::SetCanHaveFocus(bool _canFocusState)
{ {
m_canFocus = canFocusState; m_canFocus = _canFocusState;
if (true == m_hasFocus) { if (true == m_hasFocus) {
(void)RmFocus(); (void)RmFocus();
} }
@ -110,29 +131,29 @@ void ewol::Widget::KeepFocus(void)
} }
void ewol::Widget::GenDraw(DrawProperty displayProp) void ewol::Widget::GenDraw(DrawProperty _displayProp)
{ {
if (true==m_hide){ if (true==m_hide){
// widget is hidden ... // widget is hidden ...
return; return;
} }
// check if the element is displayable in the windows : // check if the element is displayable in the windows :
if( displayProp.m_windowsSize.x() < m_origin.x() if( _displayProp.m_windowsSize.x() < m_origin.x()
|| displayProp.m_windowsSize.y() < m_origin.y() ) { || _displayProp.m_windowsSize.y() < m_origin.y() ) {
// out of the windows ==> nothing to display ... // out of the windows ==> nothing to display ...
return; return;
} }
ewol::openGL::Push(); ewol::openGL::Push();
if( (displayProp.m_origin.x() > m_origin.x()) if( (_displayProp.m_origin.x() > m_origin.x())
|| (displayProp.m_origin.x() + displayProp.m_size.x() < m_size.x() + m_origin.x()) ) { || (_displayProp.m_origin.x() + _displayProp.m_size.x() < m_size.x() + m_origin.x()) ) {
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
int32_t tmpOriginX = etk_max(displayProp.m_origin.x(), m_origin.x()); int32_t tmpOriginX = etk_max(_displayProp.m_origin.x(), m_origin.x());
int32_t tmppp1 = displayProp.m_origin.x() + displayProp.m_size.x(); int32_t tmppp1 = _displayProp.m_origin.x() + _displayProp.m_size.x();
int32_t tmppp2 = m_origin.x() + m_size.x(); int32_t tmppp2 = m_origin.x() + m_size.x();
int32_t tmpclipX = etk_min(tmppp1, tmppp2) - tmpOriginX; int32_t tmpclipX = etk_min(tmppp1, tmppp2) - tmpOriginX;
int32_t tmpOriginY = etk_max(displayProp.m_origin.y(), m_origin.y()); int32_t tmpOriginY = etk_max(_displayProp.m_origin.y(), m_origin.y());
tmppp1 = displayProp.m_origin.y() + displayProp.m_size.y(); tmppp1 = _displayProp.m_origin.y() + _displayProp.m_size.y();
tmppp2 = m_origin.y() + m_size.y(); tmppp2 = m_origin.y() + m_size.y();
//int32_t tmpclipY = etk_min(tmppp1, tmppp2) - tmpOriginX; //int32_t tmpclipY = etk_min(tmppp1, tmppp2) - tmpOriginX;
@ -147,10 +168,10 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);
// Call the widget drawing methode // Call the widget drawing methode
displayProp.m_origin.setValue(tmpOriginX, tmpOriginY); _displayProp.m_origin.setValue(tmpOriginX, tmpOriginY);
displayProp.m_size.setValue(tmpclipX, m_size.y()); _displayProp.m_size.setValue(tmpclipX, m_size.y());
//int64_t ___startTime = ewol::GetTime(); //int64_t ___startTime = ewol::GetTime();
OnDraw(displayProp); OnDraw(_displayProp);
//float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f; //float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget1 : " << ___localTime << "ms "); //EWOL_DEBUG(" Widget1 : " << ___localTime << "ms ");
} else { } else {
@ -165,10 +186,10 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
// set internal matrix system : // set internal matrix system :
ewol::openGL::SetMatrix(tmpMat); ewol::openGL::SetMatrix(tmpMat);
// Call the widget drawing methode // Call the widget drawing methode
displayProp.m_origin = m_origin; _displayProp.m_origin = m_origin;
displayProp.m_size = m_size; _displayProp.m_size = m_size;
//int64_t ___startTime = ewol::GetTime(); //int64_t ___startTime = ewol::GetTime();
OnDraw(displayProp); OnDraw(_displayProp);
//float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f; //float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget2 : " << ___localTime << "ms "); //EWOL_DEBUG(" Widget2 : " << ___localTime << "ms ");
} }
@ -177,9 +198,9 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
} }
void ewol::Widget::PeriodicCallSet(bool statusToSet) void ewol::Widget::PeriodicCallSet(bool _statusToSet)
{ {
if (true == statusToSet) { if (true == _statusToSet) {
ewol::widgetManager::PeriodicCallAdd(this); ewol::widgetManager::PeriodicCallAdd(this);
} else { } else {
ewol::widgetManager::PeriodicCallRm(this); ewol::widgetManager::PeriodicCallRm(this);
@ -194,9 +215,9 @@ void ewol::Widget::MarkToRedraw(void)
} }
void ewol::Widget::SetZoom(float newVal) void ewol::Widget::SetZoom(float _newVal)
{ {
m_zoom = etk_avg(0.0000001,newVal,1000000.0); m_zoom = etk_avg(0.0000001,_newVal,1000000.0);
MarkToRedraw(); MarkToRedraw();
} }
@ -205,9 +226,9 @@ float ewol::Widget::GetZoom(void)
return m_zoom; return m_zoom;
} }
void ewol::Widget::SetOrigin(const vec2& pos) void ewol::Widget::SetOrigin(const vec2& _pos)
{ {
m_origin = pos; m_origin = _pos;
} }
vec2 ewol::Widget::GetOrigin(void) vec2 ewol::Widget::GetOrigin(void)
@ -215,9 +236,9 @@ vec2 ewol::Widget::GetOrigin(void)
return m_origin; return m_origin;
} }
vec2 ewol::Widget::RelativePosition(const vec2& pos) vec2 ewol::Widget::RelativePosition(const vec2& _pos)
{ {
return pos - m_origin; return _pos - m_origin;
} }
void ewol::Widget::CalculateMinMaxSize(void) void ewol::Widget::CalculateMinMaxSize(void)
@ -243,9 +264,9 @@ vec2 ewol::Widget::GetCalculateMaxSize(void)
return vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE); return vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE);
} }
void ewol::Widget::SetMinSize(const ewol::Dimension& size) void ewol::Widget::SetMinSize(const ewol::Dimension& _size)
{ {
vec2 pixelMin = size.GetPixel(); vec2 pixelMin = _size.GetPixel();
vec2 pixelMax = m_userMaxSize.GetPixel(); vec2 pixelMax = m_userMaxSize.GetPixel();
// check minimum & maximum compatibility : // check minimum & maximum compatibility :
bool error=false; bool error=false;
@ -259,7 +280,7 @@ void ewol::Widget::SetMinSize(const ewol::Dimension& size)
EWOL_ERROR("Can not set a 'min Size' > 'max size' set nothing ..."); EWOL_ERROR("Can not set a 'min Size' > 'max size' set nothing ...");
return; return;
} }
m_userMinSize = size; m_userMinSize = _size;
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
@ -275,10 +296,10 @@ void ewol::Widget::CheckMinSize(void)
m_minSize.setY(etk_max(m_minSize.y(), pixelSize.y())); m_minSize.setY(etk_max(m_minSize.y(), pixelSize.y()));
} }
void ewol::Widget::SetMaxSize(const ewol::Dimension& size) void ewol::Widget::SetMaxSize(const ewol::Dimension& _size)
{ {
vec2 pixelMin = m_userMinSize.GetPixel(); vec2 pixelMin = m_userMinSize.GetPixel();
vec2 pixelMax = size.GetPixel(); vec2 pixelMax = _size.GetPixel();
// check minimum & maximum compatibility : // check minimum & maximum compatibility :
bool error=false; bool error=false;
if (pixelMin.x()>pixelMax.x()) { if (pixelMin.x()>pixelMax.x()) {
@ -291,7 +312,7 @@ void ewol::Widget::SetMaxSize(const ewol::Dimension& size)
EWOL_ERROR("Can not set a 'min Size' > 'max size' set nothing ..."); EWOL_ERROR("Can not set a 'min Size' > 'max size' set nothing ...");
return; return;
} }
m_userMaxSize = size; m_userMaxSize = _size;
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
} }
@ -315,11 +336,11 @@ vec2 ewol::Widget::GetSize(void)
return vec2(0,0); return vec2(0,0);
} }
void ewol::Widget::SetExpand(const bvec2& newExpand) void ewol::Widget::SetExpand(const bvec2& _newExpand)
{ {
if( m_userExpand.x() != newExpand.x() if( m_userExpand.x() != _newExpand.x()
|| m_userExpand.y() != newExpand.y()) { || m_userExpand.y() != _newExpand.y()) {
m_userExpand = newExpand; m_userExpand = _newExpand;
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
MarkToRedraw(); MarkToRedraw();
} }
@ -334,11 +355,11 @@ bvec2 ewol::Widget::CanExpand(void)
} }
void ewol::Widget::SetFill(const bvec2& newFill) void ewol::Widget::SetFill(const bvec2& _newFill)
{ {
if( m_userFill.x() != newFill.x() if( m_userFill.x() != _newFill.x()
|| m_userFill.y() != newFill.y()) { || m_userFill.y() != _newFill.y()) {
m_userFill = newFill; m_userFill = _newFill;
ewol::RequestUpdateSize(); ewol::RequestUpdateSize();
MarkToRedraw(); MarkToRedraw();
} }
@ -353,10 +374,10 @@ const bvec2& ewol::Widget::CanFill(void)
// -- Shortcut : management of the shortcut // -- Shortcut : management of the shortcut
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
void ewol::Widget::ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data, bool broadcast) void ewol::Widget::ShortCutAdd(const char * _descriptiveString, const char * _generateEventId, etk::UString _data, bool _broadcast)
{ {
if( NULL==descriptiveString if( NULL==_descriptiveString
|| 0==strlen(descriptiveString)) || 0==strlen(_descriptiveString))
{ {
EWOL_ERROR("try to add shortcut with no descriptive string ..."); EWOL_ERROR("try to add shortcut with no descriptive string ...");
return; return;
@ -367,83 +388,83 @@ void ewol::Widget::ShortCutAdd(const char * descriptiveString, const char * gene
EWOL_ERROR("allocation error ... Memory error ..."); EWOL_ERROR("allocation error ... Memory error ...");
return; return;
} }
tmpElement->broadcastEvent = broadcast; tmpElement->broadcastEvent = _broadcast;
tmpElement->generateEventId = generateEventId; tmpElement->generateEventId = _generateEventId;
tmpElement->eventData = data; tmpElement->eventData = _data;
// parsing of the string : // parsing of the string :
//"ctrl+shift+alt+meta+s" //"ctrl+shift+alt+meta+s"
const char * tmp = strstr(descriptiveString, "ctrl"); const char * tmp = strstr(_descriptiveString, "ctrl");
if(NULL != tmp) { if(NULL != tmp) {
tmpElement->specialKey.ctrl = true; tmpElement->specialKey.ctrl = true;
} }
tmp = strstr(descriptiveString, "shift"); tmp = strstr(_descriptiveString, "shift");
if(NULL != tmp) { if(NULL != tmp) {
tmpElement->specialKey.shift = true; tmpElement->specialKey.shift = true;
} }
tmp = strstr(descriptiveString, "alt"); tmp = strstr(_descriptiveString, "alt");
if(NULL != tmp) { if(NULL != tmp) {
tmpElement->specialKey.alt = true; tmpElement->specialKey.alt = true;
} }
tmp = strstr(descriptiveString, "meta"); tmp = strstr(_descriptiveString, "meta");
if(NULL != tmp) { if(NULL != tmp) {
tmpElement->specialKey.meta = true; tmpElement->specialKey.meta = true;
} }
if(NULL != strstr(descriptiveString, "F12") ) { if(NULL != strstr(_descriptiveString, "F12") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF12; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF12;
} else if(NULL != strstr(descriptiveString, "F11") ) { } else if(NULL != strstr(_descriptiveString, "F11") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF11; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF11;
} else if(NULL != strstr(descriptiveString, "F10") ) { } else if(NULL != strstr(_descriptiveString, "F10") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF10; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF10;
} else if(NULL != strstr(descriptiveString, "F9") ) { } else if(NULL != strstr(_descriptiveString, "F9") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF9; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF9;
} else if(NULL != strstr(descriptiveString, "F8") ) { } else if(NULL != strstr(_descriptiveString, "F8") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF8; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF8;
} else if(NULL != strstr(descriptiveString, "F7") ) { } else if(NULL != strstr(_descriptiveString, "F7") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF7; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF7;
} else if(NULL != strstr(descriptiveString, "F6") ) { } else if(NULL != strstr(_descriptiveString, "F6") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF6; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF6;
} else if(NULL != strstr(descriptiveString, "F5") ) { } else if(NULL != strstr(_descriptiveString, "F5") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF5; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF5;
} else if(NULL != strstr(descriptiveString, "F4") ) { } else if(NULL != strstr(_descriptiveString, "F4") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF4; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF4;
} else if(NULL != strstr(descriptiveString, "F3") ) { } else if(NULL != strstr(_descriptiveString, "F3") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF3; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF3;
} else if(NULL != strstr(descriptiveString, "F2") ) { } else if(NULL != strstr(_descriptiveString, "F2") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF2; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF2;
} else if(NULL != strstr(descriptiveString, "F1") ) { } else if(NULL != strstr(_descriptiveString, "F1") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF1; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF1;
} else if(NULL != strstr(descriptiveString, "LEFT") ) { } else if(NULL != strstr(_descriptiveString, "LEFT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardLeft; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardLeft;
} else if(NULL != strstr(descriptiveString, "RIGHT") ) { } else if(NULL != strstr(_descriptiveString, "RIGHT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardRight; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardRight;
} else if(NULL != strstr(descriptiveString, "UP") ) { } else if(NULL != strstr(_descriptiveString, "UP") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardUp; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardUp;
} else if(NULL != strstr(descriptiveString, "DOWN") ) { } else if(NULL != strstr(_descriptiveString, "DOWN") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardDown; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardDown;
} else if(NULL != strstr(descriptiveString, "PAGE_UP") ) { } else if(NULL != strstr(_descriptiveString, "PAGE_UP") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPageUp; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPageUp;
} else if(NULL != strstr(descriptiveString, "PAGE_DOWN") ) { } else if(NULL != strstr(_descriptiveString, "PAGE_DOWN") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPageDown; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPageDown;
} else if(NULL != strstr(descriptiveString, "START") ) { } else if(NULL != strstr(_descriptiveString, "START") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardStart; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardStart;
} else if(NULL != strstr(descriptiveString, "END") ) { } else if(NULL != strstr(_descriptiveString, "END") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardEnd; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardEnd;
} else if(NULL != strstr(descriptiveString, "PRINT") ) { } else if(NULL != strstr(_descriptiveString, "PRINT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPrint; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPrint;
} else if(NULL != strstr(descriptiveString, "ARRET_DEFIL") ) { } else if(NULL != strstr(_descriptiveString, "ARRET_DEFIL") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardStopDefil; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardStopDefil;
} else if(NULL != strstr(descriptiveString, "WAIT") ) { } else if(NULL != strstr(_descriptiveString, "WAIT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardWait; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardWait;
} else if(NULL != strstr(descriptiveString, "INSERT") ) { } else if(NULL != strstr(_descriptiveString, "INSERT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardInsert; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardInsert;
} else if(NULL != strstr(descriptiveString, "CAPLOCK") ) { } else if(NULL != strstr(_descriptiveString, "CAPLOCK") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardCapLock; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardCapLock;
} else if(NULL != strstr(descriptiveString, "CONTEXT_MENU") ) { } else if(NULL != strstr(_descriptiveString, "CONTEXT_MENU") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardContextMenu; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardContextMenu;
} else if(NULL != strstr(descriptiveString, "NUM_LOCK") ) { } else if(NULL != strstr(_descriptiveString, "NUM_LOCK") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardNumLock; tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardNumLock;
} else { } else {
tmpElement->unicodeValue = descriptiveString[strlen(descriptiveString) -1]; tmpElement->unicodeValue = _descriptiveString[strlen(_descriptiveString) -1];
} }
// add it on the List ... // add it on the List ...
m_localShortcut.PushBack(tmpElement); m_localShortcut.PushBack(tmpElement);
@ -462,25 +483,25 @@ void ewol::Widget::ShortCutClean(void)
} }
bool ewol::Widget::OnEventShortCut(ewol::SpecialKey& special, uniChar_t unicodeValue, ewol::keyEvent::keyboard_te kbMove, bool isDown) bool ewol::Widget::OnEventShortCut(ewol::SpecialKey& _special, uniChar_t _unicodeValue, ewol::keyEvent::keyboard_te _kbMove, bool _isDown)
{ {
if (unicodeValue >= 'A' && unicodeValue <='Z') { if (_unicodeValue >= 'A' && _unicodeValue <='Z') {
unicodeValue += 'a' - 'A'; _unicodeValue += 'a' - 'A';
} }
//EWOL_INFO("Try to find generic shortcut ..."); //EWOL_INFO("Try to find generic shortcut ...");
for(int32_t iii=m_localShortcut.Size()-1; iii>=0; iii--) { for(int32_t iii=m_localShortcut.Size()-1; iii>=0; iii--) {
if(NULL != m_localShortcut[iii]) { if(NULL != m_localShortcut[iii]) {
if( m_localShortcut[iii]->specialKey.shift == special.shift if( m_localShortcut[iii]->specialKey.shift == _special.shift
&& m_localShortcut[iii]->specialKey.ctrl == special.ctrl && m_localShortcut[iii]->specialKey.ctrl == _special.ctrl
&& m_localShortcut[iii]->specialKey.alt == special.alt && m_localShortcut[iii]->specialKey.alt == _special.alt
&& m_localShortcut[iii]->specialKey.meta == special.meta && m_localShortcut[iii]->specialKey.meta == _special.meta
&& ( ( m_localShortcut[iii]->keyboardMoveValue == ewol::keyEvent::keyboardUnknow && ( ( m_localShortcut[iii]->keyboardMoveValue == ewol::keyEvent::keyboardUnknow
&& m_localShortcut[iii]->unicodeValue == unicodeValue) && m_localShortcut[iii]->unicodeValue == _unicodeValue)
|| ( m_localShortcut[iii]->keyboardMoveValue == kbMove || ( m_localShortcut[iii]->keyboardMoveValue == _kbMove
&& m_localShortcut[iii]->unicodeValue == 0) && m_localShortcut[iii]->unicodeValue == 0)
) ) ) )
{ {
if (isDown) { if (_isDown) {
if (true == m_localShortcut[iii]->broadcastEvent) { if (true == m_localShortcut[iii]->broadcastEvent) {
// send message at all the widget (exepted this one) // send message at all the widget (exepted this one)
SendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData); SendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
@ -520,10 +541,10 @@ bool ewol::Widget::GetGrabStatus(void)
void ewol::Widget::SetCursor(ewol::cursorDisplay_te newCursor) void ewol::Widget::SetCursor(ewol::cursorDisplay_te _newCursor)
{ {
EWOL_DEBUG("Change Cursor in " << newCursor); EWOL_DEBUG("Change Cursor in " << _newCursor);
m_cursorDisplay = newCursor; m_cursorDisplay = _newCursor;
guiInterface::SetCursor(m_cursorDisplay); guiInterface::SetCursor(m_cursorDisplay);
} }
@ -532,17 +553,17 @@ ewol::cursorDisplay_te ewol::Widget::GetCursor(void)
return m_cursorDisplay; return m_cursorDisplay;
} }
bool ewol::Widget::LoadXML(TiXmlNode* node) bool ewol::Widget::LoadXML(TiXmlNode* _node)
{ {
if (NULL==node) { if (NULL==_node) {
return false; return false;
} }
bool ret = true; bool ret = true;
const char *tmpAttributeValue = node->ToElement()->Attribute("name"); const char *tmpAttributeValue = _node->ToElement()->Attribute("name");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
SetName(tmpAttributeValue); SetName(tmpAttributeValue);
} }
tmpAttributeValue = node->ToElement()->Attribute("fill"); tmpAttributeValue = _node->ToElement()->Attribute("fill");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) { if (strcmp("false,false", tmpAttributeValue)==0) {
SetFill(bvec2(false,false)); SetFill(bvec2(false,false));
@ -556,7 +577,7 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
SetFill(bvec2(true,true)); SetFill(bvec2(true,true));
} }
} }
tmpAttributeValue = node->ToElement()->Attribute("expand"); tmpAttributeValue = _node->ToElement()->Attribute("expand");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) { if (strcmp("false,false", tmpAttributeValue)==0) {
SetExpand(bvec2(false,false)); SetExpand(bvec2(false,false));
@ -570,7 +591,7 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
SetExpand(bvec2(true,true)); SetExpand(bvec2(true,true));
} }
} }
tmpAttributeValue = node->ToElement()->Attribute("hide"); tmpAttributeValue = _node->ToElement()->Attribute("hide");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) { if (strcmp("true", tmpAttributeValue)==0) {
Hide(); Hide();
@ -578,17 +599,17 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
Show(); Show();
} }
} }
tmpAttributeValue = node->ToElement()->Attribute("focus"); tmpAttributeValue = _node->ToElement()->Attribute("focus");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) { if (strcmp("true", tmpAttributeValue)==0) {
KeepFocus(); KeepFocus();
} }
} }
tmpAttributeValue = node->ToElement()->Attribute("min-size"); tmpAttributeValue = _node->ToElement()->Attribute("min-size");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
m_userMinSize.SetString(tmpAttributeValue); m_userMinSize.SetString(tmpAttributeValue);
} }
tmpAttributeValue = node->ToElement()->Attribute("max-size"); tmpAttributeValue = _node->ToElement()->Attribute("max-size");
if (NULL != tmpAttributeValue) { if (NULL != tmpAttributeValue) {
m_userMaxSize.SetString(tmpAttributeValue); m_userMaxSize.SetString(tmpAttributeValue);
} }
@ -597,9 +618,9 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
return ret; return ret;
} }
bool ewol::Widget::StoreXML(TiXmlNode* node) bool ewol::Widget::StoreXML(TiXmlNode* _node)
{ {
if (NULL==node) { if (NULL==_node) {
return false; return false;
} }
/* /*
@ -608,39 +629,59 @@ bool ewol::Widget::StoreXML(TiXmlNode* node)
EWOL_ERROR("TinyXML node allocation error"); EWOL_ERROR("TinyXML node allocation error");
return false; return false;
} }
node->LinkEndChild(element); _node->LinkEndChild(element);
*/ */
if (GetName().Size()!=0) { if (GetName().Size()!=0) {
node->ToElement()->SetAttribute("name", GetName().c_str() ); _node->ToElement()->SetAttribute("name", GetName().c_str() );
} }
if (m_userMinSize.GetPixel() != vec2(0,0)) { if (m_userMinSize.GetPixel() != vec2(0,0)) {
node->ToElement()->SetAttribute("min-size", m_userMinSize.GetString().c_str() ); _node->ToElement()->SetAttribute("min-size", m_userMinSize.GetString().c_str() );
} }
if (m_userMaxSize.GetPixel() != vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)) { if (m_userMaxSize.GetPixel() != vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)) {
node->ToElement()->SetAttribute("max-size", m_userMaxSize.GetString().c_str() ); _node->ToElement()->SetAttribute("max-size", m_userMaxSize.GetString().c_str() );
} }
if (m_userExpand != bvec2(false,false)) { if (m_userExpand != bvec2(false,false)) {
etk::UString tmpVal = etk::UString(m_userExpand.x()) + "," + etk::UString(m_userExpand.y()); etk::UString tmpVal = etk::UString(m_userExpand.x()) + "," + etk::UString(m_userExpand.y());
node->ToElement()->SetAttribute("expand", tmpVal.c_str() ); _node->ToElement()->SetAttribute("expand", tmpVal.c_str() );
} }
if (m_userFill != bvec2(false,false)) { if (m_userFill != bvec2(false,false)) {
etk::UString tmpVal = etk::UString(m_userFill.x()) + "," + etk::UString(m_userFill.y()); etk::UString tmpVal = etk::UString(m_userFill.x()) + "," + etk::UString(m_userFill.y());
node->ToElement()->SetAttribute("fill", tmpVal.c_str() ); _node->ToElement()->SetAttribute("fill", tmpVal.c_str() );
} }
if (IsHide() != false) { if (IsHide() != false) {
node->ToElement()->SetAttribute("hide", "true" ); _node->ToElement()->SetAttribute("hide", "true" );
} }
return true; return true;
} }
ewol::Widget* ewol::Widget::GetWidgetNamed(const etk::UString& widgetName) ewol::Widget* ewol::Widget::GetWidgetNamed(const etk::UString& _widgetName)
{ {
if (GetName()==widgetName) { if (GetName()==_widgetName) {
return this; return this;
} }
return NULL; return NULL;
} }
bool ewol::Widget::SystemEventEntry(ewol::EventEntrySystem& _event)
{
if (NULL != m_up) {
if (true==m_up->SystemEventEntry(_event)) {
return true;
}
}
return OnEventEntry(_event.m_event);
}
bool ewol::Widget::SystemEventInput(ewol::EventInputSystem& _event)
{
if (NULL != m_up) {
if (true==m_up->SystemEventInput(_event)) {
return true;
}
}
return OnEventInput(_event.m_event);
}

View File

@ -23,6 +23,8 @@ namespace ewol {
#include <ewol/clipBoard.h> #include <ewol/clipBoard.h>
#include <ewol/key.h> #include <ewol/key.h>
#include <ewol/cursor.h> #include <ewol/cursor.h>
#include <ewol/renderer/EventInput.h>
#include <ewol/renderer/EventEntry.h>
#define ULTIMATE_MAX_SIZE (99999999) #define ULTIMATE_MAX_SIZE (99999999)
@ -34,16 +36,14 @@ namespace ewol {
ivec2 m_origin; ivec2 m_origin;
ivec2 m_size; ivec2 m_size;
}; };
class EventShortCut { class EventShortCut {
public: public:
bool broadcastEvent; // if it is true, then the message is sent to all the system bool broadcastEvent; //!< if it is true, then the message is sent to all the system
const char * generateEventId; // Local generated event const char* generateEventId; //!< Local generated event
etk::UString eventData; // data link with the event etk::UString eventData; //!< data link with the event
ewol::SpecialKey specialKey; // special board key ewol::SpecialKey specialKey; //!< special board key
uniChar_t unicodeValue; // 0 if not used uniChar_t unicodeValue; //!< 0 if not used
ewol::keyEvent::keyboard_te keyboardMoveValue; // ewol::EVENT_KB_MOVE_TYPE_NONE if not used ewol::keyEvent::keyboard_te keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used
EventShortCut(void) { EventShortCut(void) {
broadcastEvent = false; broadcastEvent = false;
generateEventId = NULL; generateEventId = NULL;
@ -71,6 +71,26 @@ namespace ewol {
*/ */
virtual const char * const GetObjectType(void) { return "Ewol::Widget"; }; virtual const char * const GetObjectType(void) { return "Ewol::Widget"; };
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- Hierarchy management:
// ----------------------------------------------------------------------------------------------------------------
protected:
ewol::Widget* m_up; //!< uppper widget in the tree of widget
public:
/**
* @brief Set the upper widget of this widget.
* @param[in] _upper Father widget (only keep the last and write error if a previous was set) ==> disable with NULL.
*/
void SetUpperWidget(ewol::Widget* _upper);
/**
* @brief Remove the upper widget of this widget.
*/
void RemoveUpperWidget(void) { SetUpperWidget(NULL); };
/**
* @brief Get the upper widget (father).
* @ return the requested widget (if NULL , 2 case : root widget or error implementation).
*/
ewol::Widget* GetUpperWidget(void) { return m_up; };
// ----------------------------------------------------------------------------------------------------------------
// -- Widget Size: // -- Widget Size:
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
protected: protected:
@ -80,17 +100,17 @@ namespace ewol {
public: public:
/** /**
* @brief Convert the absolute position in the local Position (Relative) * @brief Convert the absolute position in the local Position (Relative)
* @param[in] pos Absolute position that you request convertion * @param[in] _pos Absolute position that you request convertion
* @return the relative position * @return the relative position
*/ */
virtual vec2 RelativePosition(const vec2& pos); virtual vec2 RelativePosition(const vec2& _pos);
/** /**
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities * @brief Parrent set the possible diplay size of the current widget whith his own possibilities
* By default this save the widget availlable size in the widget size * By default this save the widget availlable size in the widget size
* @param[in] availlable Availlable x&y pixel size * @param[in] _availlable Availlable x&y pixel size
* @note : INTERNAL EWOL SYSTEM * @note : INTERNAL EWOL SYSTEM
*/ */
virtual void CalculateSize(const vec2& availlable); virtual void CalculateSize(const vec2& _availlable);
/** /**
* @brief Get the widget size * @brief Get the widget size
* @return Requested size * @return Requested size
@ -120,9 +140,9 @@ namespace ewol {
public: public:
/** /**
* @brief Set the zoom property of the widget * @brief Set the zoom property of the widget
* @param[in] newVal newZoom value * @param[in] _newVal newZoom value
*/ */
virtual void SetZoom(float newVal); virtual void SetZoom(float _newVal);
/** /**
* @brief Get the zoom property of the widget * @brief Get the zoom property of the widget
* @return the current zoom value * @return the current zoom value
@ -134,10 +154,10 @@ namespace ewol {
/** /**
* @brief Set origin at the widget (must be an parrent widget that set this parameter). * @brief Set origin at the widget (must be an parrent widget that set this parameter).
* This represent the absolute origin in the program windows * This represent the absolute origin in the program windows
* @param[in] pos Position of the origin * @param[in] _pos Position of the origin
* @note : INTERNAL EWOL SYSTEM * @note : INTERNAL EWOL SYSTEM
*/ */
virtual void SetOrigin(const vec2& pos); virtual void SetOrigin(const vec2& _pos);
/** /**
* @brief Get the origin (obsolute position in the windows) * @brief Get the origin (obsolute position in the windows)
* @return coordonate of the origin requested * @return coordonate of the origin requested
@ -148,9 +168,9 @@ namespace ewol {
public: public:
/** /**
* @brief User set the minimum size he want to set the display * @brief User set the minimum size he want to set the display
* @param[in] size Set minimum size (none : 0) * @param[in] _size Set minimum size (none : 0)
*/ */
void SetMinSize(const ewol::Dimension& size); void SetMinSize(const ewol::Dimension& _size);
/** /**
* @brief User set No minimum size. * @brief User set No minimum size.
*/ */
@ -171,9 +191,9 @@ namespace ewol {
public: public:
/** /**
* @brief User set the maximum size he want to set the display * @brief User set the maximum size he want to set the display
* @param[in] size The new maximum size requested (vec2(0,0) to unset) * @param[in] _size The new maximum size requested (vec2(0,0) to unset)
*/ */
void SetMaxSize(const ewol::Dimension& size); void SetMaxSize(const ewol::Dimension& _size);
/** /**
* @brief User set No maximum size. * @brief User set No maximum size.
*/ */
@ -194,9 +214,9 @@ namespace ewol {
public: public:
/** /**
* @brief Set the expend capabilities (x&y) * @brief Set the expend capabilities (x&y)
* @param[in] newExpend 2D boolean repensent the capacity to expend * @param[in] _newExpend 2D boolean repensent the capacity to expend
*/ */
virtual void SetExpand(const bvec2& newExpand); virtual void SetExpand(const bvec2& _newExpand);
/** /**
* @brief Get the expend capabilities (x&y) (set by the user) * @brief Get the expend capabilities (x&y) (set by the user)
* @return 2D boolean repensent the capacity to expend * @return 2D boolean repensent the capacity to expend
@ -213,9 +233,9 @@ namespace ewol {
public: public:
/** /**
* @brief Set the x&y filling capacity * @brief Set the x&y filling capacity
* @param[in] newFill new x&y fill state * @param[in] _newFill new x&y fill state
*/ */
virtual void SetFill(const bvec2& newFill); virtual void SetFill(const bvec2& _newFill);
/** /**
* @brief Set the x&y filling capacity set by the user * @brief Set the x&y filling capacity set by the user
* @return bvec2 repensent the capacity to x&y filling (set by the user) * @return bvec2 repensent the capacity to x&y filling (set by the user)
@ -272,9 +292,9 @@ namespace ewol {
virtual bool RmFocus(void); virtual bool RmFocus(void);
/** /**
* @brief Set the capability to have the focus * @brief Set the capability to have the focus
* @param[in] canFocusState new focus capability * @param[in] _canFocusState new focus capability
*/ */
virtual void SetCanHaveFocus(bool canFocusState); virtual void SetCanHaveFocus(bool _canFocusState);
/** /**
* @brief Keep the focus on this widget ==> this remove the previous focus on all other widget * @brief Keep the focus on this widget ==> this remove the previous focus on all other widget
*/ */
@ -302,9 +322,9 @@ namespace ewol {
virtual int32_t GetMouseLimit(void) { return m_limitMouseEvent; }; virtual int32_t GetMouseLimit(void) { return m_limitMouseEvent; };
/** /**
* @brief Get the number of mouse event supported * @brief Get the number of mouse event supported
* @param[in] numberState The number of event that the mouse supported [0..3] * @param[in] _numberState The number of event that the mouse supported [0..3]
*/ */
virtual void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; }; virtual void SetMouseLimit(int32_t _numberState) { m_limitMouseEvent = _numberState; };
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- keyboard event properties Area // -- keyboard event properties Area
@ -320,9 +340,9 @@ namespace ewol {
virtual bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; }; virtual bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; };
/** /**
* @brief Set the keyboard repeating event supporting. * @brief Set the keyboard repeating event supporting.
* @param[in] state The repeating status (true: enable, false disable). * @param[in] _state The repeating status (true: enable, false disable).
*/ */
virtual void SetKeyboardRepeate(bool state) { m_allowRepeateKeyboardEvent = state; }; virtual void SetKeyboardRepeate(bool _state) { m_allowRepeateKeyboardEvent = _state; };
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- Periodic call Area // -- Periodic call Area
@ -336,69 +356,84 @@ namespace ewol {
public: public:
/** /**
* @brief Periodic call of this widget * @brief Periodic call of this widget
* @param localTime curent system time * @param _localTime curent system time
*/ */
virtual void PeriodicCall(int64_t localTime) { }; virtual void PeriodicCall(int64_t _localTime) { };
public: public:
/** /**
* @brief Get the widget at the specific windows absolute position * @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge * @param[in] _pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found * @return NULL No widget found
* @return pointer on the widget found * @return pointer on the widget found
* @note : INTERNAL EWOL SYSTEM * @note : INTERNAL EWOL SYSTEM
*/ */
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos) { if (false==IsHide()) { return this; } return NULL; }; virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos) { if (false==IsHide()) { return this; } return NULL; };
/** /**
* @brief Get the widget if it have this name or one of the subwidget with the same name * @brief Get the widget if it have this name or one of the subwidget with the same name
* @param[in] widgetName name of the widget * @param[in] _widgetName name of the widget
* @return the requested pointer on the node (or NULL pointer) * @return the requested pointer on the node (or NULL pointer)
*/ */
virtual ewol::Widget* GetWidgetNamed(const etk::UString& widgetName); virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
// event section:
public:
/** /**
* @brief Event on an input of this Widget * @brief system event input (only meta widget might overwrite this function).
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...) * @param[in] _event Event properties
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Absolute position of the event
* @return true the event is used * @return true the event is used
* @return false the event is not used * @return false the event is not used
*/ */
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) { return false; }; virtual bool SystemEventInput(ewol::EventInputSystem& _event);
protected:
/** /**
* @brief Event on the keybord (if no shortcut has been detected before). * @brief Event on an input of this Widget (finger, mouse, stilet)
* @param[in] type of the event (ewol::EVENT_KB_TYPE_DOWN or ewol::EVENT_KB_TYPE_UP) * @param[in] _event Event properties
* @param[in] unicodeValue key pressed by the user * @return true the event is used
* @return false the event is not used
*/
virtual bool OnEventInput(const ewol::EventInput& _event) { return false; };
public:
/**
* @brief Entry event (only meta widget might overwrite this function).
* @param[in] _event Event properties
* @return true if the event has been used * @return true if the event has been used
* @return false if the event has not been used * @return false if the event has not been used
*/ */
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData) { return false; }; virtual bool SystemEventEntry(ewol::EventEntrySystem& _event);
protected:
/** /**
* @brief Event on the keyboard that is not a printable key (if no shortcut has been detected before). * @brief Entry event.
* represent the physical event :
* - Keyboard (key event and move event)
* - Accelerometer
* - Joystick
* @param[in] _event Event properties
* @return true if the event has been used * @return true if the event has been used
* @return false if the event has not been used * @return false if the event has not been used
*/ */
virtual bool OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent) { return false; }; virtual bool OnEventEntry(const ewol::EventEntry& _event) { return false; };
public:
/** /**
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas * @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
* @note : need to have focus ... * @note : need to have focus ...
* @param[in] mode Mode of data requested * @param[in] mode Mode of data requested
*/ */
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID) { }; virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID) { };
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- Shortcut : management of the shortcut // -- Shortcut : management of the shortcut
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
private: private:
etk::Vector<EventShortCut*> m_localShortcut; etk::Vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget
protected: protected:
/** /**
* @brief Add a specific shortcut with his description * @brief Add a specific shortcut with his description
* @param[in] descriptiveString Description string of the shortcut * @param[in] _descriptiveString Description string of the shortcut
* @param[in] generateEventId Event generic of the element * @param[in] _generateEventId Event generic of the element
* @param[in] data Associate data wit the event * @param[in] _data Associate data wit the event
*/ */
virtual void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false); virtual void ShortCutAdd(const char * _descriptiveString, const char * _generateEventId, etk::UString _data="", bool _broadcast=false);
/** /**
* @brief Remove all curent shortCut * @brief Remove all curent shortCut
*/ */
@ -406,14 +441,14 @@ namespace ewol {
public: public:
/** /**
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb) * @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb)
* @param[in] special all the special kay pressed at this time * @param[in] _special all the special kay pressed at this time
* @param[in] unicodeValue key pressed by the user not used if the kbMove!=ewol::EVENT_KB_MOVE_TYPE_NONE * @param[in] _unicodeValue key pressed by the user not used if the kbMove!=ewol::EVENT_KB_MOVE_TYPE_NONE
* @param[in] kbMove special key of the keyboard * @param[in] _kbMove special key of the keyboard
* @return true if the event has been used * @return true if the event has been used
* @return false if the event has not been used * @return false if the event has not been used
* @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some ununderstanding error * @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some ununderstanding error
*/ */
virtual bool OnEventShortCut(ewol::SpecialKey& special, uniChar_t unicodeValue, ewol::keyEvent::keyboard_te kbMove, bool isDown); virtual bool OnEventShortCut(ewol::SpecialKey& _special, uniChar_t _unicodeValue, ewol::keyEvent::keyboard_te _kbMove, bool _isDown);
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- Drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working... // -- Drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working...
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
@ -434,16 +469,17 @@ namespace ewol {
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...]) * @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget * This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
* @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget * @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget
* @param[in] displayProp properties of the current display * @param[in] _displayProp properties of the current display
* @note : INTERNAL EWOL SYSTEM * @note : INTERNAL EWOL SYSTEM
*/ */
virtual void GenDraw(DrawProperty displayProp); // TODO : Rename SystemDraw()
virtual void GenDraw(DrawProperty _displayProp);
protected: protected:
/** /**
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...]) * @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
* @param[in] displayProp properties of the current display * @param[in] _displayProp properties of the current display
*/ */
virtual void OnDraw(DrawProperty& displayProp) { }; virtual void OnDraw(DrawProperty& _displayProp) { };
public: public:
/** /**
* @brief Event generated when a redraw is needed * @brief Event generated when a redraw is needed
@ -473,9 +509,9 @@ namespace ewol {
public: public:
/** /**
* @brief Set the cursor display type. * @brief Set the cursor display type.
* @param[in] newCursor selected new cursor. * @param[in] _newCursor selected new cursor.
*/ */
virtual void SetCursor(ewol::cursorDisplay_te newCursor); virtual void SetCursor(ewol::cursorDisplay_te _newCursor);
/** /**
* @brief Get the currrent cursor. * @brief Get the currrent cursor.
* @return the type of the cursor. * @return the type of the cursor.
@ -484,18 +520,20 @@ namespace ewol {
public: public:
/** /**
* @brief Load properties with an XML node. * @brief Load properties with an XML node.
* @param[in] node Pointer on the tinyXML node. * @param[in] _node Pointer on the tinyXML node.
* @return true : All has been done corectly. * @return true : All has been done corectly.
* @return false : An error occured. * @return false : An error occured.
*/ */
virtual bool LoadXML(TiXmlNode* node); virtual bool LoadXML(TiXmlNode* _node);
/** /**
* @brief Store properties in this XML node. * @brief Store properties in this XML node.
* @param[in,out] node Pointer on the tinyXML node. * @param[in,out] _node Pointer on the tinyXML node.
* @return true : All has been done corectly. * @return true : All has been done corectly.
* @return false : An error occured. * @return false : An error occured.
*/ */
virtual bool StoreXML(TiXmlNode* node); virtual bool StoreXML(TiXmlNode* _node);
public: // herited function
virtual void OnObjectRemove(ewol::EObject* _removeObject);
}; // end of the class Widget declaration }; // end of the class Widget declaration
};// end of namespace };// end of namespace

View File

@ -20,6 +20,7 @@
#include <ewol/widget/Gird.h> #include <ewol/widget/Gird.h>
#include <ewol/widget/Entry.h> #include <ewol/widget/Entry.h>
#include <ewol/widget/CheckBox.h> #include <ewol/widget/CheckBox.h>
#include <ewol/widget/Scroll.h>
#include <etk/Vector.h> #include <etk/Vector.h>
#undef __class__ #undef __class__
@ -70,6 +71,7 @@ void ewol::widgetManager::Init(void)
widget::Gird::Init(); widget::Gird::Init();
widget::Entry::Init(); widget::Entry::Init();
widget::CheckBox::Init(); widget::CheckBox::Init();
widget::Scroll::Init();
IsInit = true; IsInit = true;
} }
@ -80,7 +82,7 @@ void ewol::widgetManager::UnInit(void)
ewol::widgetManager::FocusSetDefault(NULL); ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease(); ewol::widgetManager::FocusRelease();
widget::Scroll::UnInit();
widget::CheckBox::UnInit(); widget::CheckBox::UnInit();
widget::Entry::UnInit(); widget::Entry::UnInit();
widget::Gird::UnInit(); widget::Gird::UnInit();

View File

@ -78,14 +78,16 @@ void widget::WidgetScrooled::OnRegenerateDisplay(void)
} }
bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::WidgetScrooled::OnEventInput(const ewol::EventInput& _event)
{ {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
// corection due to the open Gl invertion ... // corection due to the open Gl invertion ...
relativePos.setY(m_size.y() - relativePos.y()); relativePos.setY(m_size.y() - relativePos.y());
if (SCROLL_MODE_NORMAL == m_scroollingMode) { if (SCROLL_MODE_NORMAL == m_scroollingMode) {
if (ewol::keyEvent::typeMouse==type && ( ewol::keyEvent::typeUnknow==m_highSpeedType || ewol::keyEvent::typeMouse==m_highSpeedType )) { if( ewol::keyEvent::typeMouse==_event.GetType()
if (1 == IdInput && ewol::keyEvent::statusDown == typeEvent) { && ( ewol::keyEvent::typeUnknow==m_highSpeedType
|| ewol::keyEvent::typeMouse==m_highSpeedType ) ) {
if (1 == _event.GetId() && ewol::keyEvent::statusDown == _event.GetStatus()) {
// check if selected the scrolling position whth the scrolling bar ... // check if selected the scrolling position whth the scrolling bar ...
if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) { if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) {
if( m_size.y() < m_maxSize.y() if( m_size.y() < m_maxSize.y()
@ -117,7 +119,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
} }
} }
return false; return false;
} else if (4 == IdInput && ewol::keyEvent::statusUp == typeEvent) { } else if (4 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
/* /*
if (true == ewol::IsSetCtrl()) { if (true == ewol::IsSetCtrl()) {
float zoom = GetZoom()*1.1; float zoom = GetZoom()*1.1;
@ -131,7 +133,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true; return true;
} }
} }
} else if (5 == IdInput && ewol::keyEvent::statusUp == typeEvent) { } else if (5 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
/* /*
if (true == ewol::IsSetCtrl()) { if (true == ewol::IsSetCtrl()) {
float zoom = GetZoom()*0.9; float zoom = GetZoom()*0.9;
@ -145,7 +147,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true; return true;
} }
} }
}else if (2 == IdInput) { }else if (2 == _event.GetId()) {
/* /*
if (true == ewol::IsSetCtrl()) { if (true == ewol::IsSetCtrl()) {
if (ewol::keyEvent::statusDown == typeEvent) { if (ewol::keyEvent::statusDown == typeEvent) {
@ -153,7 +155,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
SetZoom(zoom); SetZoom(zoom);
} }
} else */{ } else */{
if (ewol::keyEvent::statusDown == typeEvent) { if (ewol::keyEvent::statusDown == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_INIT; m_highSpeedMode = widget::SCROLL_INIT;
m_highSpeedType = ewol::keyEvent::typeMouse; m_highSpeedType = ewol::keyEvent::typeMouse;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
@ -161,14 +163,14 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true; return true;
} }
} }
} else if (widget::SCROLL_DISABLE!=m_highSpeedMode && ewol::keyEvent::statusLeave == typeEvent) { } else if (widget::SCROLL_DISABLE!=m_highSpeedMode && ewol::keyEvent::statusLeave == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE; m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow; m_highSpeedType = ewol::keyEvent::typeUnknow;
MarkToRedraw(); MarkToRedraw();
return true; return true;
} }
if (IdInput==m_highSpeedButton && widget::SCROLL_DISABLE!=m_highSpeedMode) { if (_event.GetId()==m_highSpeedButton && widget::SCROLL_DISABLE!=m_highSpeedMode) {
if (ewol::keyEvent::statusUp == typeEvent) { if (ewol::keyEvent::statusUp == _event.GetStatus()) {
if (widget::SCROLL_INIT==m_highSpeedMode) { if (widget::SCROLL_INIT==m_highSpeedMode) {
// TODO : Generate back the down event ... // TODO : Generate back the down event ...
m_highSpeedMode = widget::SCROLL_DISABLE; m_highSpeedMode = widget::SCROLL_DISABLE;
@ -180,14 +182,14 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true; return true;
} }
} else if (widget::SCROLL_GREP_END_EVENT == m_highSpeedMode) { } else if (widget::SCROLL_GREP_END_EVENT == m_highSpeedMode) {
if (ewol::keyEvent::statusSingle == typeEvent) { if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE; m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow; m_highSpeedType = ewol::keyEvent::typeUnknow;
m_highSpeedButton = -1; m_highSpeedButton = -1;
MarkToRedraw(); MarkToRedraw();
} }
return true; return true;
} else if (widget::SCROLL_INIT==m_highSpeedMode && ewol::keyEvent::statusMove == typeEvent) { } else if (widget::SCROLL_INIT==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
// wait that the cursor move more than 10 px to enable it : // wait that the cursor move more than 10 px to enable it :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
@ -214,34 +216,36 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
} }
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling))); m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
return true; return true;
} if (widget::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::keyEvent::statusMove == typeEvent) { } if (widget::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2))); m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2)));
m_originScrooled.setX(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling))); m_originScrooled.setX(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
MarkToRedraw(); MarkToRedraw();
return true; return true;
} if (widget::SCROLL_ENABLE_VERTICAL==m_highSpeedMode && ewol::keyEvent::statusMove == typeEvent) { } if (widget::SCROLL_ENABLE_VERTICAL==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2))); m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2)));
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling))); m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
MarkToRedraw(); MarkToRedraw();
return true; return true;
} }
} }
} else if (ewol::keyEvent::typeFinger==type && ( ewol::keyEvent::typeUnknow==m_highSpeedType || ewol::keyEvent::typeFinger==m_highSpeedType )) { } else if( ewol::keyEvent::typeFinger==_event.GetType()
if (1 == IdInput) { && ( ewol::keyEvent::typeUnknow==m_highSpeedType
|| ewol::keyEvent::typeFinger==m_highSpeedType ) ) {
if (1 == _event.GetId()) {
//EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")"); //EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
if (ewol::keyEvent::statusDown == typeEvent) { if (ewol::keyEvent::statusDown == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_INIT; m_highSpeedMode = widget::SCROLL_INIT;
m_highSpeedType = ewol::keyEvent::typeFinger; m_highSpeedType = ewol::keyEvent::typeFinger;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
EWOL_VERBOSE("SCROOL ==> INIT"); EWOL_VERBOSE("SCROOL ==> INIT");
return true; return true;
} else if (ewol::keyEvent::statusUp == typeEvent) { } else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE; m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow; m_highSpeedType = ewol::keyEvent::typeUnknow;
EWOL_VERBOSE("SCROOL ==> DISABLE"); EWOL_VERBOSE("SCROOL ==> DISABLE");
MarkToRedraw(); MarkToRedraw();
return true; return true;
} else if (widget::SCROLL_INIT==m_highSpeedMode && ewol::keyEvent::statusMove == typeEvent) { } else if (widget::SCROLL_INIT==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
// wait that the cursor move more than 10 px to enable it : // wait that the cursor move more than 10 px to enable it :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
@ -252,7 +256,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
MarkToRedraw(); MarkToRedraw();
} }
return true; return true;
} if (widget::SCROLL_ENABLE_FINGER==m_highSpeedMode && ewol::keyEvent::statusMove == typeEvent) { } if (widget::SCROLL_ENABLE_FINGER==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
//m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x); //m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x);
m_originScrooled.setX(m_originScrooled.x() - relativePos.x() - m_highSpeedStartPos.x()); m_originScrooled.setX(m_originScrooled.x() - relativePos.x() - m_highSpeedStartPos.x());
m_originScrooled.setY(m_originScrooled.y() - relativePos.y() - m_highSpeedStartPos.y()); m_originScrooled.setY(m_originScrooled.y() - relativePos.y() - m_highSpeedStartPos.y());
@ -263,7 +267,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
MarkToRedraw(); MarkToRedraw();
return true; return true;
} }
} else if (widget::SCROLL_DISABLE!=m_highSpeedMode && ewol::keyEvent::statusLeave == typeEvent) { } else if (widget::SCROLL_DISABLE!=m_highSpeedMode && ewol::keyEvent::statusLeave == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE; m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow; m_highSpeedType = ewol::keyEvent::typeUnknow;
EWOL_VERBOSE("SCROOL ==> DISABLE"); EWOL_VERBOSE("SCROOL ==> DISABLE");
@ -272,12 +276,12 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
} }
} }
} else if (SCROLL_MODE_CENTER == m_scroollingMode) { } else if (SCROLL_MODE_CENTER == m_scroollingMode) {
if (ewol::keyEvent::typeMouse==type) { if (ewol::keyEvent::typeMouse==_event.GetType()) {
float tmp1=m_size.x() / m_maxSize.y(); float tmp1=m_size.x() / m_maxSize.y();
float tmp2=m_size.y() / m_maxSize.x(); float tmp2=m_size.y() / m_maxSize.x();
//EWOL_INFO(" elements Zoom : " << tmp1 << " " << tmp2); //EWOL_INFO(" elements Zoom : " << tmp1 << " " << tmp2);
tmp1 = etk_min(tmp1, tmp2); tmp1 = etk_min(tmp1, tmp2);
if (4 == IdInput && ewol::keyEvent::statusUp == typeEvent) { if (4 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
m_zoom -= 0.1; m_zoom -= 0.1;
if (tmp1 < 1.0) { if (tmp1 < 1.0) {
m_zoom = etk_max(tmp1, m_zoom); m_zoom = etk_max(tmp1, m_zoom);
@ -286,7 +290,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
} }
MarkToRedraw(); MarkToRedraw();
return true; return true;
} else if (5 == IdInput && ewol::keyEvent::statusUp == typeEvent) { } else if (5 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
m_zoom += 0.1; m_zoom += 0.1;
if (tmp1 > 1.0) { if (tmp1 > 1.0) {
m_zoom = etk_min(tmp1, m_zoom); m_zoom = etk_min(tmp1, m_zoom);
@ -305,16 +309,16 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return false; return false;
} }
void widget::WidgetScrooled::AddOObject(ewol::Compositing* newObject, int32_t pos) void widget::WidgetScrooled::AddOObject(ewol::Compositing* _newObject, int32_t _pos)
{ {
if (NULL == newObject) { if (NULL == _newObject) {
EWOL_ERROR("Try to add an empty object in the Widget generic display system"); EWOL_ERROR("Try to add an empty object in the Widget generic display system");
return; return;
} }
if (pos < 0 || pos >= m_listOObject.Size() ) { if (_pos < 0 || _pos >= m_listOObject.Size() ) {
m_listOObject.PushBack(newObject); m_listOObject.PushBack(_newObject);
} else { } else {
m_listOObject.Insert(pos, newObject); m_listOObject.Insert(_pos, _newObject);
} }
} }

View File

@ -33,7 +33,7 @@ namespace widget {
{ {
private: private:
etk::Vector<ewol::Compositing*> m_listOObject; //!< generic element to display... etk::Vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
void AddOObject(ewol::Compositing* newObject, int32_t pos=-1); void AddOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
void ClearOObjectList(void); void ClearOObjectList(void);
protected: protected:
vec2 m_originScrooled; vec2 m_originScrooled;
@ -49,33 +49,26 @@ namespace widget {
public: public:
WidgetScrooled(void); WidgetScrooled(void);
virtual ~WidgetScrooled(void); virtual ~WidgetScrooled(void);
// Derived function public: // Derived function
virtual const char * const GetObjectType(void) { return "EwolWidgetScrooled"; }; virtual const char * const GetObjectType(void) { return "EwolWidgetScrooled"; };
// Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp); virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos);
// Derived function
virtual void GenDraw(ewol::DrawProperty displayProp); virtual void GenDraw(ewol::DrawProperty displayProp);
protected: protected:
/** /**
* @brief For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled * @brief For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
* @param[in] nbPixel number of pixel scrolling * @param[in] nbPixel number of pixel scrolling
* @return ---
*/ */
void SetScrollingSize(float nbPixel) { m_pixelScrolling = nbPixel; }; void SetScrollingSize(float nbPixel) { m_pixelScrolling = nbPixel; };
/** /**
* @brief Specify the mode of scrolling for this windows * @brief Specify the mode of scrolling for this windows
* @param[in] newMode the selected mode for the scrolling... * @param[in] newMode the selected mode for the scrolling...
* @return ---
*/ */
void ScroolingMode(scrollingMode_te newMode); void ScroolingMode(scrollingMode_te newMode);
/** /**
* @brief Set the specific mawimum size of the widget * @brief Set the specific mawimum size of the widget
* @param[in] localSize new Maximum size * @param[in] localSize new Maximum size
* @return ---
*/ */
void SetMaxSize(vec2 localSize) { m_maxSize = localSize; }; void SetMaxSize(vec2 localSize) { m_maxSize = localSize; };
/** /**
@ -83,13 +76,11 @@ namespace widget {
* @param[in] borderWidth Size of the border that requested the element might not to be * @param[in] borderWidth Size of the border that requested the element might not to be
* @param[in] currentPosition Position that is requested to view * @param[in] currentPosition Position that is requested to view
* @param[in] center True if the position might be at the center of the widget * @param[in] center True if the position might be at the center of the widget
* @return ---
*/ */
void SetScrollingPositionDynamic(vec2 borderWidth, vec2 currentPosition, bool center = false); void SetScrollingPositionDynamic(vec2 borderWidth, vec2 currentPosition, bool center = false);
/** /**
* @brief Set the scrolling limit when arriving at he end of the widget * @brief Set the scrolling limit when arriving at he end of the widget
* @param[in] poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ... * @param[in] poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
* @return ---
*/ */
void SetLimitScrolling(float poucentageLimit) { m_limitScrolling = etk_avg(0.1, poucentageLimit,0.9); }; void SetLimitScrolling(float poucentageLimit) { m_limitScrolling = etk_avg(0.1, poucentageLimit,0.9); };
}; };

View File

@ -247,7 +247,7 @@ widget::FileChooser::FileChooser(void)
m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFileEnter); m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFileEnter);
m_widgetCurrentFileName->SetExpand(bvec2(true,false)); m_widgetCurrentFileName->SetExpand(bvec2(true,false));
m_widgetCurrentFileName->SetFill(bvec2(true,false)); m_widgetCurrentFileName->SetFill(bvec2(true,false));
m_widgetCurrentFileName->SetWidth(200); //m_widgetCurrentFileName->SetWidth(200);
mySizerHori->SubWidgetAdd(m_widgetCurrentFileName); mySizerHori->SubWidgetAdd(m_widgetCurrentFileName);
} }
} }
@ -273,7 +273,7 @@ widget::FileChooser::FileChooser(void)
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFolderEnter); m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFolderEnter);
m_widgetCurrentFolder->SetExpand(bvec2(true,false)); m_widgetCurrentFolder->SetExpand(bvec2(true,false));
m_widgetCurrentFolder->SetFill(bvec2(true,false)); m_widgetCurrentFolder->SetFill(bvec2(true,false));
m_widgetCurrentFolder->SetWidth(200); //m_widgetCurrentFolder->SetWidth(200);
mySizerHori->SubWidgetAdd(m_widgetCurrentFolder); mySizerHori->SubWidgetAdd(m_widgetCurrentFolder);
} }
myImage = new widget::Image("THEME:GUI:Home.svg"); myImage = new widget::Image("THEME:GUI:Home.svg");

View File

@ -184,15 +184,15 @@ void widget::ParameterList::OnRegenerateDisplay(void)
} }
bool widget::ParameterList::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos) bool widget::ParameterList::OnEventInput(const ewol::EventInput& _event)
{ {
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) { if (true == WidgetScrooled::OnEventInput(_event)) {
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widet ... // nothing to do ... done on upper widet ...
return true; return true;
} }
if (IdInput == 1 && typeEvent == ewol::keyEvent::statusSingle) { if (_event.GetId() == 1 && _event.GetStatus() == ewol::keyEvent::statusSingle) {
vec2 relativePos = RelativePosition(pos); vec2 relativePos = RelativePosition(_event.GetPos());
// corection for the openGl abstraction // corection for the openGl abstraction
relativePos.setY(m_size.y() - relativePos.y()); relativePos.setY(m_size.y() - relativePos.y());
// TODO : Rework this ... // TODO : Rework this ...

View File

@ -67,7 +67,7 @@ namespace widget {
// Derived function // Derived function
void OnRegenerateDisplay(void); void OnRegenerateDisplay(void);
// Derived function // Derived function
bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos); virtual bool OnEventInput(const ewol::EventInput& _event);
protected: protected:
// Derived function // Derived function
void OnGetFocus(void); void OnGetFocus(void);

View File

@ -96,6 +96,7 @@ def Create(target):
'ewol/widget/Mesh.cpp', 'ewol/widget/Mesh.cpp',
'ewol/widget/PopUp.cpp', 'ewol/widget/PopUp.cpp',
'ewol/widget/ProgressBar.cpp', 'ewol/widget/ProgressBar.cpp',
'ewol/widget/Scroll.cpp',
'ewol/widget/Sizer.cpp', 'ewol/widget/Sizer.cpp',
'ewol/widget/Slider.cpp', 'ewol/widget/Slider.cpp',
'ewol/widget/WSlider.cpp', 'ewol/widget/WSlider.cpp',