[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());
}
void ewol::Shaper::SetOrigin(vec2 newOri)
void ewol::Shaper::SetOrigin(const vec2& newOri)
{
if (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) {
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;
}
void ewol::Shaper::SetInsidePos(vec2 newInsidePos)
void ewol::Shaper::SetInsidePos(const vec2& newInsidePos)
{
m_propertyInsidePosition = newInsidePos;
}

View File

@ -112,22 +112,22 @@ namespace ewol
* @brief Set the widget origin (needed fot the display)
* @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)
* @param[in] newSize : the new widget size
*/
void SetSize(vec2 newSize);
void SetSize(const vec2& newSize);
/**
* @brief Set the internal widget size
* @param[in] newInsidePos : the subelement size.
*/
void SetInsideSize(vec2 newInsideSize);
void SetInsideSize(const vec2& newInsideSize);
/**
* @brief Set the internal widget 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
* @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
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_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;
}
void ewol::Text::SetColorBg(draw::Color color)
void ewol::Text::SetColorBg(const draw::Color& color)
{
m_colorBg = 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);
}
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
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
int32_t fontSize = -1;

View File

@ -137,34 +137,38 @@ namespace ewol
* @brief Set position for the next text writen
* @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
* @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
* @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))
* @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)
* @param[in] pos Start position 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)
* @param[in] pos Start 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 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)
* @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)
* @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");
return;
}
if (NULL == message) {
if (NULL == _message) {
EWOL_ERROR("Add with NULL Message");
return;
}
messageList_ts tmpMessage;
tmpMessage.object = object;
tmpMessage.message = message;
tmpMessage.object = _object;
tmpMessage.message = _message;
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");
return;
}
// send the message at all registered widget ...
for (int32_t iii=m_messageList.Size()-1; iii>=0; iii--) {
if(m_messageList[iii].object == object) {
EWOL_DEBUG("SendMulticast RM listener :" << object->GetId());
if(m_messageList[iii].object == _object) {
EWOL_DEBUG("SendMulticast RM listener :" << _object->GetId());
m_messageList[iii].message = NULL;
m_messageList[iii].object = NULL;
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 ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if( m_messageList[iii].message == message
&& m_messageList[iii].object != object)
if( m_messageList[iii].message == _message
&& m_messageList[iii].object != _object)
{
if (NULL != m_messageList[iii].object) {
EWOL_VERBOSE(" id = " << m_messageList[iii].object->GetId() << " type=" << m_messageList[iii].object->GetObjectType());
// 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__
@ -137,24 +137,24 @@ void ewol::EObject::RemoveObject(void)
ewol::EObjectManager::AutoRemove(this);
}
void ewol::EObject::AddEventId(const char * generateEventId)
void ewol::EObject::AddEventId(const char * _generateEventId)
{
if (NULL != generateEventId) {
m_availlableEventId.PushBack(generateEventId);
if (NULL != _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();
// for every element registered ...
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
// if we find the event ...
if (m_externEvent[iii]->localEventId == generateEventId) {
if (m_externEvent[iii]->localEventId == _generateEventId) {
if (NULL != m_externEvent[iii]->destEObject) {
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 {
// set the user requested data ...
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();
MultiCastSend(this, messageId, data);
MultiCastSend(this, _messageId, _data);
if (nbObject > ewol::EObjectManager::GetNumberObject()) {
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 ...");
return;
}
if (NULL == eventId) {
if (NULL == _eventId) {
EWOL_ERROR("Input ERROR NULL pointer Event Id...");
return;
}
// check if event existed :
bool findIt = false;
for(int32_t iii=0; iii<m_availlableEventId.Size(); iii++) {
if (m_availlableEventId[iii] == eventId) {
if (m_availlableEventId[iii] == _eventId) {
findIt = true;
break;
}
@ -203,15 +206,15 @@ void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const cha
if (false == findIt) {
EWOL_DEBUG("Try to register with a NON direct string name");
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;
eventIdgenerated = m_availlableEventId[iii];
_eventIdgenerated = m_availlableEventId[iii];
break;
}
}
}
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;
}
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...");
return;
}
tmpEvent->localEventId = eventId;
tmpEvent->destEObject = destinationObject;
tmpEvent->overloadData = overloadData;
if (NULL != eventIdgenerated) {
tmpEvent->destEventId = eventIdgenerated;
tmpEvent->localEventId = _eventId;
tmpEvent->destEObject = _destinationObject;
tmpEvent->overloadData = _overloadData;
if (NULL != _eventIdgenerated) {
tmpEvent->destEventId = _eventIdgenerated;
} else {
tmpEvent->destEventId = eventId;
tmpEvent->destEventId = _eventId;
}
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--) {
if (NULL==m_externEvent[iii]) {
m_externEvent.Erase(iii);
} else if (m_externEvent[iii]->destEObject == removeObject) {
} else if (m_externEvent[iii]->destEObject == _removeObject) {
m_externEvent.Erase(iii);
}
}

View File

@ -17,7 +17,7 @@ namespace ewol {
namespace EObjectMessageMultiCast {
void Init(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;
@ -72,60 +72,60 @@ namespace ewol {
/**
* @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
* @param[in] objectType type description
* @param[in] _objectType type description
* @return true if the object is compatible, otherwise false
*/
virtual const char * const GetObjectType(void) { return "EObject"; };
protected:
/**
* @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
* @param[in] generateEventId event Id that is curetly generated
* @param[in] data data associated with the event
* @param[in] _generateEventId event Id that is curetly generated
* @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
* @param[in] messageId Event Id that is generated
* @param[in] data String that is send at all the destinations
* @param[in] _messageId Event Id that is generated
* @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
* @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:
/**
* @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] eventId Event generate inside the object
* @param[in] eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...)
* @param[in] overloadData When the user prever to receive a data specificly for this event ...
* @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] _eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...)
* @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 ...
* @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
*/
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
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @param[in] _CallerObject Pointer on the EObject that information came from
* @param[in] _eventId Message 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:
etk::UString m_name; //!< name of the element ...
@ -137,9 +137,9 @@ namespace ewol {
const etk::UString& GetName(void) { return m_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] = {
"keyboardUnknow",
"keyboardChar",
"keyboardLeft",
"keyboardRight",
"keyboardUp",

View File

@ -58,6 +58,7 @@ namespace ewol
*/
typedef enum {
keyboardUnknow = 0, //!< Unknown keyboard key
keyboardChar, //!< Char input is arrived ...
keyboardLeft, //!< Left key <--
keyboardRight, //!< Right 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) ) {
// generate the direct event ...
if (data.TypeMessage == THREAD_KEYBORAD_KEY) {
ewol::EventEntrySystem tmpEntryEvent(ewol::keyEvent::keyboardChar, ewol::keyEvent::statusUp, data.keyboardChar);
if(true == data.stateIsDown) {
tmpWidget->OnEventKb(ewol::keyEvent::statusDown, data.keyboardChar);
} else {
tmpWidget->OnEventKb(ewol::keyEvent::statusUp, data.keyboardChar);
tmpEntryEvent.m_event.SetStatus(ewol::keyEvent::statusDown);
}
tmpWidget->SystemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown);
ewol::EventEntrySystem tmpEntryEvent(data.keyboardMove, ewol::keyEvent::statusUp, 0);
if(true == data.stateIsDown) {
tmpWidget->OnEventKbMove(ewol::keyEvent::statusDown, data.keyboardMove);
} else {
tmpWidget->OnEventKbMove(ewol::keyEvent::statusUp, data.keyboardMove);
tmpEntryEvent.m_event.SetStatus(ewol::keyEvent::statusDown);
}
tmpWidget->SystemEventEntry(tmpEntryEvent);
}
} else {
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,
ewol::Widget* destWidget,
int32_t IdInput,
ewol::keyEvent::status_te typeEvent,
vec2 pos)
bool ewol::eSystemInput::localEventInput(ewol::keyEvent::type_te _type,
ewol::Widget* _destWidget,
int32_t _IdInput,
ewol::keyEvent::status_te _status,
vec2 _pos)
{
if (NULL != destWidget) {
if (type == ewol::keyEvent::typeMouse || type == ewol::keyEvent::typeFinger) {
return destWidget->OnEventInput(type, IdInput, typeEvent, pos);
if (NULL != _destWidget) {
if (_type == ewol::keyEvent::typeMouse || _type == ewol::keyEvent::typeFinger) {
// create the system Event :
ewol::EventInputSystem tmpEventSystem(_type, _status, _IdInput, _pos);
// generate the event :
return _destWidget->SystemEventInput(tmpEventSystem);
} else {
return false;
}

View File

@ -46,8 +46,8 @@ void widget::Button::UnInit(void)
widget::Button::Button(const etk::UString& shaperName) :
m_shaper(shaperName),
widget::Button::Button(const etk::UString& _shaperName) :
m_shaper(_shaperName),
m_toggleMode(false),
m_value(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;
if (NULL!=m_subWidget[idWidget]) {
@ -96,14 +96,14 @@ void widget::Button::SetSubWidget(ewol::Widget* subWidget)
m_subWidget[idWidget]=NULL;
}
}
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget);
m_subWidget[idWidget] = subWidget;
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
MarkToRedraw();
}
void widget::Button::SetSubWidgetToggle(ewol::Widget* subWidget)
void widget::Button::SetSubWidgetToggle(ewol::Widget* _subWidget)
{
int32_t idWidget=1;
if (NULL!=m_subWidget[idWidget]) {
@ -114,8 +114,8 @@ void widget::Button::SetSubWidgetToggle(ewol::Widget* subWidget)
m_subWidget[idWidget]=NULL;
}
}
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget);
m_subWidget[idWidget] = subWidget;
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget;
// element change ... We need to recalculate all the subElments :
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();
// set minimal size
@ -141,10 +141,10 @@ void widget::Button::CalculateSize(const vec2& availlable)
vec2 minimumSizeToggle(0,0);
// Checking the expand properties :
if (m_userExpand.x() == true) {
m_size.setX(availlable.x());
m_size.setX(_availlable.x());
}
if (m_userExpand.y() == true) {
m_size.setY(availlable.y());
m_size.setY(_availlable.y());
}
// Checkin the filling properties ==> for the subElements:
vec2 subElementSize = m_minSize;
@ -195,7 +195,7 @@ void widget::Button::CalculateMinMaxSize(void)
MarkToRedraw();
}
void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
void widget::Button::OnDraw(ewol::DrawProperty& _displayProp)
{
// draw the shaaper (if needed indeed)
m_shaper.Draw();
@ -203,11 +203,11 @@ void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
if( false == m_toggleMode
|| false == m_value) {
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->GenDraw(displayProp);
m_subWidget[0]->GenDraw(_displayProp);
}
} else {
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) {
m_value = val;
if (m_value != _val) {
m_value = _val;
MarkToRedraw();
}
}
@ -247,10 +247,10 @@ bool widget::Button::GetValue(void)
return m_value;
}
void widget::Button::SetToggleMode(bool togg)
void widget::Button::SetToggleMode(bool _togg)
{
if (m_toggleMode != togg) {
m_toggleMode = togg;
if (m_toggleMode != _togg) {
m_toggleMode = _togg;
if (m_value == true) {
m_value = false;
// 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;
if( ewol::keyEvent::statusLeave == typeEvent
|| ewol::keyEvent::statusAbort == typeEvent) {
if( ewol::keyEvent::statusLeave == _event.GetStatus()
|| ewol::keyEvent::statusAbort == _event.GetStatus()) {
m_mouseHover = false;
m_buttonPressed = false;
} else {
vec2 relativePos = RelativePosition(pos);
vec2 relativePos = RelativePosition(_event.GetPos());
// prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x()
|| 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;
//EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover);
if (true == m_mouseHover) {
if (1 == IdInput) {
if(ewol::keyEvent::statusDown == typeEvent) {
if (1 == _event.GetId()) {
if(ewol::keyEvent::statusDown == _event.GetStatus()) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonDown);
GenerateEventId(ewolEventButtonDown);
m_buttonPressed = true;
MarkToRedraw();
}
if(ewol::keyEvent::statusUp == typeEvent) {
if(ewol::keyEvent::statusUp == _event.GetStatus()) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonUp);
GenerateEventId(ewolEventButtonUp);
m_buttonPressed = false;
MarkToRedraw();
}
if(ewol::keyEvent::statusSingle == typeEvent) {
if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
// inverse value :
m_value = (m_value)?false:true;
//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));
if( typeEvent == ewol::keyEvent::statusDown
&& unicodeData == '\r') {
if( _event.GetType() == ewol::keyEvent::keyboardChar
&& _event.GetStatus() == ewol::keyEvent::statusDown
&& _event.GetChar() == '\r') {
GenerateEventId(ewolEventButtonEnter);
return true;
}
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);
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);
}
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:
/**
* @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
*/
virtual ~Button(void);
/**
* @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
* @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
* @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
* @return The base widget
@ -83,9 +83,9 @@ namespace widget {
/**
* @brief Set the currentValue of the Button (pressed or not)
* @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.
* @return True : The button is pressed.
@ -94,15 +94,15 @@ namespace widget {
bool GetValue(void);
/**
* @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:
/**
* @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 ...
*/
@ -111,14 +111,15 @@ namespace widget {
// Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; };
virtual void CalculateMinMaxSize(void);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateSize(const vec2& _availlable);
virtual void OnRegenerateDisplay(void);
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 OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual bool LoadXML(TiXmlNode* _node);
private:
// 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;
if(ewol::keyEvent::statusLeave == typeEvent) {
if(ewol::keyEvent::statusLeave == _event.GetStatus()) {
m_mouseHover = false;
m_buttonPressed = false;
} else {
vec2 relativePos = RelativePosition(pos);
vec2 relativePos = RelativePosition(_event.GetPos());
// prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x()
|| 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;
//EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover);
if (true == m_mouseHover) {
if (1 == IdInput) {
if(ewol::keyEvent::statusDown == typeEvent) {
if (1 == _event.GetId()) {
if(ewol::keyEvent::statusDown == _event.GetStatus()) {
m_buttonPressed = true;
MarkToRedraw();
}
if(ewol::keyEvent::statusUp == typeEvent) {
if(ewol::keyEvent::statusUp == _event.GetStatus()) {
m_buttonPressed = false;
MarkToRedraw();
}
if(ewol::keyEvent::statusSingle == typeEvent) {
if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
m_buttonPressed = false;
m_mouseHover = false;
// create a context menu :

View File

@ -67,7 +67,7 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "widget::ButtonColor"; };
virtual void OnRegenerateDisplay(void);
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);
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 ...");
if (1 == IdInput) {
if (ewol::keyEvent::statusSingle == typeEvent) {
if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
if(true == m_value) {
m_value = false;
GenerateEventId(ewolEventCheckBoxClicked, "false");
@ -135,13 +135,13 @@ bool widget::CheckBox::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInpu
return false;
}
bool widget::CheckBox::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData)
bool widget::CheckBox::OnEventEntry(const ewol::EventEntry& _event)
{
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( typeEvent == ewol::keyEvent::statusDown
&& ( unicodeData == '\r'
|| unicodeData == ' ')
if( _event.GetType() == ewol::keyEvent::keyboardChar
&& _event.GetStatus() == ewol::keyEvent::statusDown
&& ( _event.GetChar() == '\r'
|| _event.GetChar() == ' ')
) {
if(true == m_value) {
m_value = false;

View File

@ -42,8 +42,8 @@ namespace widget {
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
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 OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
virtual bool OnEventInput(const ewol::EventInput& _event);
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 ...");
if (1 == IdInput) {
if (1 == _event.GetId()) {
relativePos.setValue( etk_max(etk_min(relativePos.x(), m_size.x()),0),
etk_max(etk_min(relativePos.y(), m_size.y()),0));
if( ewol::keyEvent::statusSingle == typeEvent
|| ewol::keyEvent::statusMove == typeEvent) {
if( ewol::keyEvent::statusSingle == _event.GetStatus()
|| ewol::keyEvent::statusMove == _event.GetStatus()) {
// nothing to do ...
m_currentUserPos.setValue( relativePos.x()/m_size.x(),
relativePos.y()/m_size.y() );

View File

@ -35,7 +35,7 @@ namespace widget {
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
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"
widget::Container::Container(ewol::Widget* subElement) :
m_subWidget(subElement)
widget::Container::Container(ewol::Widget* _subElement) :
m_subWidget(_subElement)
{
// nothing to do ...
}
@ -32,13 +32,13 @@ ewol::Widget* widget::Container::GetSubWidget(void)
return m_subWidget;
}
void widget::Container::SetSubWidget(ewol::Widget* newWidget)
void widget::Container::SetSubWidget(ewol::Widget* _newWidget)
{
if (NULL==newWidget) {
if (NULL==_newWidget) {
return;
}
SubWidgetRemove();
m_subWidget = newWidget;
m_subWidget = _newWidget;
MarkToRedraw();
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;
}
if (NULL != m_subWidget) {
return m_subWidget->GetWidgetNamed(widgetName);
return m_subWidget->GetWidgetNamed(_widgetName);
}
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;
MarkToRedraw();
ewol::RequestUpdateSize();
}
}
void widget::Container::OnDraw(ewol::DrawProperty& displayProp)
void widget::Container::OnDraw(ewol::DrawProperty& _displayProp)
{
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) {
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)
{
// callmain class
// call main class
ewol::Widget::CalculateMinMaxSize();
// call sub classes
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 (NULL!=m_subWidget) {
return m_subWidget->GetWidgetAtPos(pos);
return m_subWidget->GetWidgetAtPos(_pos);
}
}
return NULL;
};
bool widget::Container::LoadXML(TiXmlNode* node)
bool widget::Container::LoadXML(TiXmlNode* _node)
{
if (NULL==node) {
if (NULL==_node) {
return false;
}
// parse generic properties :
ewol::Widget::LoadXML(node);
ewol::Widget::LoadXML(_node);
// remove previous element :
SubWidgetRemove();
// parse all the elements :
for(TiXmlNode * pNode = node->FirstChild() ;
for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ;
pNode = pNode->NextSibling() ) {
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 << "\"" );
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 << "\"");

View File

@ -26,7 +26,7 @@ namespace widget
/**
* @brief Constructor
*/
Container(ewol::Widget* subElement=NULL);
Container(ewol::Widget* _subElement=NULL);
/**
* @brief Destructor
*/
@ -39,25 +39,25 @@ namespace widget
ewol::Widget* GetSubWidget(void);
/**
* @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.
*/
void SubWidgetRemove(void);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
public:// Derived function
virtual void OnRegenerateDisplay(void);
virtual void OnObjectRemove(ewol::EObject* removeObject);
virtual void CalculateSize(const vec2& availlable);
virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateMinMaxSize(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);
virtual ewol::Widget* GetWidgetNamed(const etk::UString& widgetName);
virtual const char * const GetObjectType(void) { return "Ewol::Container"; };
virtual bool LoadXML(TiXmlNode* node);
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
virtual const char * const GetObjectType(void) { return "ewol::widget::Container"; };
virtual bool LoadXML(TiXmlNode* _node);
};
};

View File

@ -45,46 +45,46 @@ bvec2 widget::ContainerN::CanExpand(void)
return res;
}
void widget::ContainerN::LockExpand(const bvec2& lockExpand)
void widget::ContainerN::LockExpand(const bvec2& _lockExpand)
{
if (lockExpand != m_lockExpand) {
m_lockExpand = lockExpand;
if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand;
MarkToRedraw();
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 ... ");
return;
}
m_subWidget.PushBack(newWidget);
m_subWidget.PushBack(_newWidget);
MarkToRedraw();
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 ... ");
return;
}
m_subWidget.PushFront(newWidget);
m_subWidget.PushFront(_newWidget);
MarkToRedraw();
ewol::RequestUpdateSize();
}
void widget::ContainerN::SubWidgetRemove(ewol::Widget* newWidget)
void widget::ContainerN::SubWidgetRemove(ewol::Widget* _newWidget)
{
if (NULL == newWidget) {
if (NULL == _newWidget) {
return;
}
int32_t errorControl = m_subWidget.Size();
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) {
if (_newWidget == m_subWidget[iii]) {
delete(m_subWidget[iii]);
// no remove, this element is removed with the function OnObjectRemove ==> it does not exist anymore ...
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;
}
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.Erase(iii);
MarkToRedraw();
@ -136,14 +136,14 @@ void widget::ContainerN::SubWidgetRemoveAll(void)
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;
}
for (int32_t iii=0; iii<m_subWidget.Size(); 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) {
return tmpWidget;
}
@ -152,13 +152,13 @@ ewol::Widget* widget::ContainerN::GetWidgetNamed(const etk::UString& widgetName)
return NULL;
}
void widget::ContainerN::OnObjectRemove(ewol::EObject* removeObject)
void widget::ContainerN::OnObjectRemove(ewol::EObject* _removeObject)
{
// First step call parrent :
ewol::Widget::OnObjectRemove(removeObject);
ewol::Widget::OnObjectRemove(_removeObject);
// second step find if in all the elements ...
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");
m_subWidget[iii] = NULL;
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--) {
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 ???");
m_size = availlable;
m_size = _availlable;
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
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()) {
return NULL;
@ -229,10 +229,10 @@ ewol::Widget* widget::ContainerN::GetWidgetAtPos(const vec2& pos)
if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->GetSize();
vec2 tmpOrigin = m_subWidget[iii]->GetOrigin();
if( (tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x())
&& (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y()) )
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[iii]->GetWidgetAtPos(pos);
ewol::Widget * tmpWidget = m_subWidget[iii]->GetWidgetAtPos(_pos);
if (NULL != 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;
}
// parse generic properties :
ewol::Widget::LoadXML(node);
ewol::Widget::LoadXML(_node);
// remove previous element :
SubWidgetRemoveAll();
const char *tmpAttributeValue = node->ToElement()->Attribute("lock");
const char *tmpAttributeValue = _node->ToElement()->Attribute("lock");
if (NULL != tmpAttributeValue) {
m_lockExpand = tmpAttributeValue;
}
bool invertAdding=false;
tmpAttributeValue = node->ToElement()->Attribute("addmode");
tmpAttributeValue = _node->ToElement()->Attribute("addmode");
if (NULL != tmpAttributeValue) {
etk::UString val(tmpAttributeValue);
if(val.CompareNoCase("invert")) {
@ -268,7 +268,7 @@ bool widget::ContainerN::LoadXML(TiXmlNode* node)
}
}
// parse all the elements :
for(TiXmlNode * pNode = node->FirstChild() ;
for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ;
pNode = pNode->NextSibling() ) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {

View File

@ -37,9 +37,9 @@ namespace widget
public:
/**
* @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
virtual bvec2 CanExpand(void);
public:
@ -49,38 +49,38 @@ namespace widget
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)
* @param[in] newWidget the element pointer
* @param[in] _newWidget the element pointer
*/
virtual void SubWidgetAdd(ewol::Widget* newWidget);
inline void SubWidgetAddBack(ewol::Widget* newWidget) { SubWidgetAdd(newWidget); };
inline void SubWidgetAddEnd(ewol::Widget* newWidget) { SubWidgetAdd(newWidget); };
virtual void SubWidgetAdd(ewol::Widget* _newWidget);
inline void SubWidgetAddBack(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)
* @param[in] newWidget the element pointer
* @param[in] _newWidget the element pointer
*/
virtual void SubWidgetAddStart(ewol::Widget* newWidget);
inline void SubWidgetAddFront(ewol::Widget* newWidget) { SubWidgetAddStart(newWidget); };
virtual void SubWidgetAddStart(ewol::Widget* _newWidget);
inline void SubWidgetAddFront(ewol::Widget* _newWidget) { SubWidgetAddStart(_newWidget); };
/**
* @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 ...)
* @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
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
public:// Derived function
virtual void OnRegenerateDisplay(void);
virtual void OnObjectRemove(ewol::EObject* removeObject);
virtual void CalculateSize(const vec2& availlable);
virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateMinMaxSize(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);
virtual ewol::Widget* GetWidgetNamed(const etk::UString& widgetName);
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
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();
}
}
bool widget::ContextMenu::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos)
bool widget::ContextMenu::OnEventInput(const ewol::EventInput& _event)
{
//EWOL_INFO("Event ouside the context menu");
if (IdInput > 0) {
if( typeEvent == ewol::keyEvent::statusDown
|| typeEvent == ewol::keyEvent::statusMove
|| typeEvent == ewol::keyEvent::statusSingle
|| typeEvent == ewol::keyEvent::statusUp
|| typeEvent == ewol::keyEvent::statusEnter
|| typeEvent == ewol::keyEvent::statusLeave ) {
if (_event.GetId() > 0) {
if( _event.GetStatus() == ewol::keyEvent::statusDown
|| _event.GetStatus() == ewol::keyEvent::statusMove
|| _event.GetStatus() == ewol::keyEvent::statusSingle
|| _event.GetStatus() == ewol::keyEvent::statusUp
|| _event.GetStatus() == ewol::keyEvent::statusEnter
|| _event.GetStatus() == ewol::keyEvent::statusLeave ) {
// Auto-remove ...
AutoDestroy();
return true;

View File

@ -42,7 +42,7 @@ namespace widget {
virtual void OnDraw(ewol::DrawProperty& displayProp);
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 OnEventInput(const ewol::EventInput& _event);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "ewol::ContextMenu"; };

View File

@ -47,30 +47,32 @@ void widget::Entry::UnInit(void)
}
widget::Entry::Entry(etk::UString newData) :
widget::Entry::Entry(etk::UString _newData) :
m_shaper("THEME:GUI:widgetEntry.conf"),
m_data(""),
m_textColorFg(draw::color::black),
m_textColorBg(draw::color::white),
m_userSize(50),
m_maxCharacter(0x7FFFFFFF),
m_regExp(".*"),
m_needUpdateTextPos(true),
m_displayStartPosition(0),
m_displayCursor(false),
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;
SetCanHaveFocus(true);
AddEventId(ewolEventEntryClick);
AddEventId(ewolEventEntryEnter);
AddEventId(ewolEventEntryModify);
ShortCutAdd("ctrl+w", ewolEventEntryClean);
ShortCutAdd("ctrl+x", ewolEventEntryCut);
ShortCutAdd("ctrl+c", ewolEventEntryCopy);
ShortCutAdd("ctrl+v", ewolEventEntryPaste);
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
ShortCutAdd("ctrl+w", ewolEventEntryClean);
ShortCutAdd("ctrl+x", ewolEventEntryCut);
ShortCutAdd("ctrl+c", ewolEventEntryCopy);
ShortCutAdd("ctrl+v", ewolEventEntryPaste);
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
SetValue(newData);
UpdateTextPosition();
SetValue(_newData);
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();
int32_t minHeight = m_oObjectText.CalculateSize('A').y();
m_minSize.setValue(m_userSize + 2*padding.x(),
minHeight + 2*padding.y());
UpdateTextPosition();
MarkToRedraw();
if (_nbMax<=0) {
m_maxCharacter = 0x7FFFFFFF;
} else {
m_maxCharacter = _nbMax;
}
}
int32_t widget::Entry::SetMaxChar(void)
{
return m_maxCharacter;
}
void widget::Entry::SetValue(etk::UString newData)
void widget::Entry::CalculateMinMaxSize(void)
{
m_data = newData;
m_displayCursorPos = m_data.Size();
m_displayCursorPosSelection = m_displayCursorPos;
EWOL_DEBUG("Set ... " << 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_displayCursorPosSelection = m_displayCursorPos;
EWOL_DEBUG("Set ... " << newData);
}
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_oObjectText.Draw();
@ -123,56 +152,55 @@ void widget::Entry::OnRegenerateDisplay(void)
UpdateTextPosition();
vec2 padding = m_shaper.GetPadding();
int32_t tmpSizeX = m_minSize.x();
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();
vec2 tmpSizeShaper = m_minSize;
if (true==m_userFill.x()) {
tmpSizeX = m_size.x();
tmpSizeShaper.setX(m_size.x());
}
if (true==m_userFill.y()) {
//tmpSizeY = m_size.y;
tmpOriginY = 0;
tmpTextOriginY = tmpOriginY + padding.y();
tmpSizeShaper.setY(m_size.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,
tmpTextOriginY,
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);
m_oObjectText.SetClippingWidth(tmpOriginText, tmpSizeText);
m_oObjectText.SetPos(tmpOriginText+vec2(m_displayStartPosition,0));
if (m_displayCursorPosSelection != m_displayCursorPos) {
m_oObjectText.SetCursorSelection(m_displayCursorPos, m_displayCursorPosSelection);
} else {
m_oObjectText.SetCursorPos(m_displayCursorPos);
}
m_oObjectText.Print(m_data);
if (0!=m_data.Size()) {
m_oObjectText.Print(m_data);
} else {
if (0!=m_textWhenNothing.Size()) {
m_oObjectText.PrintDecorated(m_textWhenNothing);
}
}
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 relPos = RelativePosition(pos);
vec2 relPos = RelativePosition(_pos);
relPos.setX(relPos.x()-m_displayStartPosition - padding.x());
// try to find the new cursor position :
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) {
newCursorPosition = m_data.Size();
}
if (false == selection) {
if (false == _selection) {
m_displayCursorPos = newCursorPosition;
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
@ -202,7 +230,7 @@ void widget::Entry::UpdateCursorPosition(const vec2& pos, bool selection)
m_displayCursorPos = newCursorPosition;
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) {
// nothing to cut ...
@ -240,20 +268,20 @@ void widget::Entry::CopySelectionToClipBoard(ewol::clipBoard::clipboardListe_te
}
// Copy
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);
if (1 == IdInput) {
if (ewol::keyEvent::statusSingle == typeEvent) {
if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
KeepFocus();
GenerateEventId(ewolEventEntryClick);
//nothing to do ...
return true;
} else if (ewol::keyEvent::statusDouble == typeEvent) {
} else if (ewol::keyEvent::statusDouble == _event.GetStatus()) {
KeepFocus();
// select word
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 ...
CopySelectionToClipBoard(ewol::clipBoard::clipboardSelection);
MarkToRedraw();
} else if (ewol::keyEvent::statusTriple == typeEvent) {
} else if (ewol::keyEvent::statusTriple == _event.GetStatus()) {
KeepFocus();
m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data.Size();
} else if (ewol::keyEvent::statusDown == typeEvent) {
} else if (ewol::keyEvent::statusDown == _event.GetStatus()) {
KeepFocus();
UpdateCursorPosition(pos);
UpdateCursorPosition(_event.GetPos());
MarkToRedraw();
} else if (ewol::keyEvent::statusMove == typeEvent) {
} else if (ewol::keyEvent::statusMove == _event.GetStatus()) {
KeepFocus();
UpdateCursorPosition(pos, true);
UpdateCursorPosition(_event.GetPos(), true);
MarkToRedraw();
} else if (ewol::keyEvent::statusUp == typeEvent) {
} else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
KeepFocus();
UpdateCursorPosition(pos, true);
UpdateCursorPosition(_event.GetPos(), true);
// Copy to clipboard Middle ...
CopySelectionToClipBoard(ewol::clipBoard::clipboardSelection);
MarkToRedraw();
}
}
else if( ewol::keyEvent::typeMouse == type
&& 2 == IdInput) {
if( typeEvent == ewol::keyEvent::statusDown
|| typeEvent == ewol::keyEvent::statusMove
|| typeEvent == ewol::keyEvent::statusUp) {
else if( ewol::keyEvent::typeMouse == _event.GetType()
&& 2 == _event.GetId()) {
if( _event.GetStatus() == ewol::keyEvent::statusDown
|| _event.GetStatus() == ewol::keyEvent::statusMove
|| _event.GetStatus() == ewol::keyEvent::statusUp) {
KeepFocus();
// updatethe cursor position :
UpdateCursorPosition(pos);
UpdateCursorPosition(_event.GetPos());
}
// Paste current selection only when up button
if (typeEvent == ewol::keyEvent::statusUp) {
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
KeepFocus();
// middle button => past data...
ewol::clipBoard::Request(ewol::clipBoard::clipboardSelection);
@ -338,114 +366,142 @@ 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) {
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
//return GenEventInputExternal(ewolEventEntryEnter, -1, -1);
// remove curent selected data ...
RemoveSelected();
if( '\n' == unicodeData
|| '\r' == unicodeData) {
GenerateEventId(ewolEventEntryEnter, m_data);
if (_event.GetType() == ewol::keyEvent::keyboardChar) {
if(_event.GetStatus() == ewol::keyEvent::statusDown) {
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
//return GenEventInputExternal(ewolEventEntryEnter, -1, -1);
// remove curent selected data ...
RemoveSelected();
if( '\n' == _event.GetChar()
|| '\r' == _event.GetChar()) {
GenerateEventId(ewolEventEntryEnter, m_data);
return true;
} else if (0x7F == _event.GetChar()) {
// SUPPR :
if (m_data.Size() > 0 && m_displayCursorPos<m_data.Size()) {
m_data.Remove(m_displayCursorPos, 1);
m_displayCursorPos = etk_max(m_displayCursorPos, 0);
m_displayCursorPosSelection = m_displayCursorPos;
}
} else if (0x08 == _event.GetChar()) {
// DEL :
if (m_data.Size() > 0 && m_displayCursorPos != 0) {
m_data.Remove(m_displayCursorPos-1, 1);
m_displayCursorPos--;
m_displayCursorPos = etk_max(m_displayCursorPos, 0);
m_displayCursorPosSelection = m_displayCursorPos;
}
} else if(_event.GetChar() >= 20) {
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_displayCursorPosSelection = m_displayCursorPos;
}
}
}
GenerateEventId(ewolEventEntryModify, m_data);
MarkToRedraw();
return true;
} else if (0x7F == unicodeData) {
// SUPPR :
if (m_data.Size() > 0 && m_displayCursorPos<m_data.Size()) {
m_data.Remove(m_displayCursorPos, 1);
m_displayCursorPos = etk_max(m_displayCursorPos, 0);
m_displayCursorPosSelection = m_displayCursorPos;
}
return false;
} else {
if(_event.GetStatus() == ewol::keyEvent::statusDown) {
switch (_event.GetType())
{
case ewol::keyEvent::keyboardLeft:
m_displayCursorPos--;
break;
case ewol::keyEvent::keyboardRight:
m_displayCursorPos++;
break;
case ewol::keyEvent::keyboardStart:
m_displayCursorPos = 0;
break;
case ewol::keyEvent::keyboardEnd:
m_displayCursorPos = m_data.Size();
break;
default:
return false;
}
} else if (0x08 == unicodeData) {
// DEL :
if (m_data.Size() > 0 && m_displayCursorPos != 0) {
m_data.Remove(m_displayCursorPos-1, 1);
m_displayCursorPos--;
m_displayCursorPos = etk_max(m_displayCursorPos, 0);
m_displayCursorPosSelection = m_displayCursorPos;
}
} else if(unicodeData >= 20) {
m_data.Add(m_displayCursorPos, unicodeData);
m_displayCursorPos++;
m_displayCursorPos = etk_avg(0, m_displayCursorPos, m_data.Size());
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
return true;
}
GenerateEventId(ewolEventEntryModify, m_data);
MarkToRedraw();
return true;
}
return false;
}
bool widget::Entry::OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent)
void widget::Entry::SetInternalValue(const etk::UString& _newData)
{
if(typeEvent == ewol::keyEvent::statusDown) {
switch (moveTypeEvent)
{
case ewol::keyEvent::keyboardLeft:
m_displayCursorPos--;
break;
case ewol::keyEvent::keyboardRight:
m_displayCursorPos++;
break;
case ewol::keyEvent::keyboardStart:
m_displayCursorPos = 0;
break;
case ewol::keyEvent::keyboardEnd:
m_displayCursorPos = m_data.Size();
break;
default:
return false;
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_displayCursorPos = etk_avg(0, m_displayCursorPos, m_data.Size());
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
return true;
}
return false;
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 ...
RemoveSelected();
// get current selection / Copy :
etk::UString tmpData = Get(clipboardID);
etk::UString tmpData = Get(_clipboardID);
// add it on the current display :
if (tmpData.Size() >= 0) {
m_data.Add(m_displayCursorPos, &tmpData[0]);
if (m_data.Size() == tmpData.Size()) {
m_displayCursorPos = tmpData.Size();
} else {
m_displayCursorPos += tmpData.Size();
etk::UString newData = m_data;
newData.Add(m_displayCursorPos, &tmpData[0]);
SetInternalValue(newData);
if (m_data == newData) {
if (m_data.Size() == tmpData.Size()) {
m_displayCursorPos = tmpData.Size();
} else {
m_displayCursorPos += tmpData.Size();
}
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
}
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
}
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);
if(eventId == ewolEventEntryClean) {
ewol::Widget::OnReceiveMessage(_CallerObject, _eventId, _data);
if(_eventId == ewolEventEntryClean) {
m_data = "";
m_displayStartPosition = 0;
m_displayCursorPos = 0;
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
} else if(eventId == ewolEventEntryCut) {
} else if(_eventId == ewolEventEntryCut) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
RemoveSelected();
GenerateEventId(ewolEventEntryModify, m_data);
} else if(eventId == ewolEventEntryCopy) {
} else if(_eventId == ewolEventEntryCopy) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
} else if(eventId == ewolEventEntryPaste) {
} else if(_eventId == ewolEventEntryPaste) {
ewol::clipBoard::Request(ewol::clipBoard::clipboardStd);
} else if(eventId == ewolEventEntrySelect) {
if(data == "ALL") {
} else if(_eventId == ewolEventEntrySelect) {
if(_data == "ALL") {
m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data.Size();
} 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)
{
if (false==m_needUpdateTextPos) {
return;
}
vec2 padding = m_shaper.GetPadding();
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);
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);
}
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__
#include <etk/types.h>
#include <etk/RegExp.h>
#include <ewol/debug.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
@ -38,78 +39,157 @@ namespace widget {
static void UnInit(void);
private:
ewol::Shaper m_shaper;
ewol::Text m_oObjectText; //!< text display
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
ewol::Text m_oObjectText; //!< text display m_text
public:
/**
* @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
*/
virtual ~Entry(void);
void SetValue(etk::UString newData);
etk::UString GetValue(void);
void SetWidth(int32_t width)
{
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);
private:
etk::UString m_data; //!< sting that must be displayed
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
/**
* @brief Change the cursor position with the curent position requested on the display
* @param[in] pos Absolute position of the event
* @note The display is automaticly requested when change apear.
* @return ---
* @brief internal check the value with RegExp checking
* @param[in] _newData The new string to display
*/
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
* @param ---
* @return ---
* @change m_displayStartPosition <== updated
*/
virtual void UpdateTextPosition(void);
/**
* @brief Copy the selected data on the specify clipboard
* @param[in] clipboardID Selected clipboard
* @return ---
* @brief Change the cursor position with the curent position requested on the display
* @param[in] _pos Absolute position of the event
* @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
* @note This request a regeneration of the display
* @return ---
*/
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);
// Derived function
virtual void OnLostFocus(void);
// change the current shaper display :
void ChangeStatusIn(int32_t newStatusId);
// Derived function
virtual void PeriodicCall(int64_t localTime);
virtual void ChangeStatusIn(int32_t _newStatusId);
virtual void PeriodicCall(int64_t _localTime);
virtual bool LoadXML(TiXmlNode* _node);
};
};

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_keepRatio(true)
{
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 :
m_fileName = file;
m_fileName = _file;
// Force redraw all :
MarkToRedraw();
ewol::RequestUpdateSize();
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 :
m_border = border;
m_border = _border;
// Force redraw all :
MarkToRedraw();
// TODO : Change the size with no size requested ...
ewol::RequestUpdateSize();
}
void widget::Image::SetKeepRatio(bool keep)
void widget::Image::SetKeepRatio(bool _keep)
{
if (m_keepRatio != keep) {
if (m_keepRatio != _keep) {
// copy data :
m_keepRatio = keep;
m_keepRatio = _keep;
// Force redraw all :
MarkToRedraw();
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();
ewol::RequestUpdateSize();
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 :
m_border = border;
m_fileName = file;
m_border = _border;
m_fileName = _file;
// Force redraw all :
MarkToRedraw();
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();
}
@ -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 ...");
if (1 == IdInput) {
if( ewol::keyEvent::statusSingle == typeEvent) {
if (1 == _event.GetId()) {
if( ewol::keyEvent::statusSingle == _event.GetStatus()) {
GenerateEventId(ewolEventImagePressed);
return true;
}
@ -165,15 +165,15 @@ bool widget::Image::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
return false;
}
bool widget::Image::LoadXML(TiXmlNode* node)
bool widget::Image::LoadXML(TiXmlNode* _node)
{
if (NULL==node) {
if (NULL==_node) {
return false;
}
ewol::Widget::LoadXML(node);
ewol::Widget::LoadXML(_node);
// get internal data :
const char *tmpAttributeValue = node->ToElement()->Attribute("ratio");
const char *tmpAttributeValue = _node->ToElement()->Attribute("ratio");
if (NULL != tmpAttributeValue) {
if (strcmp(tmpAttributeValue,"true")==0) {
m_keepRatio = true;
@ -183,21 +183,21 @@ bool widget::Image::LoadXML(TiXmlNode* node)
m_keepRatio = false;
}
}
tmpAttributeValue = node->ToElement()->Attribute("size");
tmpAttributeValue = _node->ToElement()->Attribute("size");
if (NULL != tmpAttributeValue) {
//EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue);
m_imageSize = tmpAttributeValue;
//EWOL_CRITICAL(" ==> " << m_imageSize);
}
tmpAttributeValue = node->ToElement()->Attribute("border");
tmpAttributeValue = _node->ToElement()->Attribute("border");
if (NULL != tmpAttributeValue) {
m_border = tmpAttributeValue;
}
//EWOL_DEBUG("Load label:" << node->ToElement()->GetText());
if (node->ToElement()->GetText() != NULL) {
SetFile(node->ToElement()->GetText());
if (_node->ToElement()->GetText() != NULL) {
SetFile(_node->ToElement()->GetText());
} else {
tmpAttributeValue = node->ToElement()->Attribute("src");
tmpAttributeValue = _node->ToElement()->Attribute("src");
if (NULL != tmpAttributeValue) {
SetFile(tmpAttributeValue);
}

View File

@ -35,66 +35,65 @@ namespace widget {
/**
* @brief
*/
Image(const etk::UString& file="",
const ewol::Dimension& border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
Image(const etk::UString& _file="",
const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
/**
* @brief
*/
virtual ~Image(void) { };
/**
* @brief Set All the configuration of the current image
* @param[in] file Filaneme of the new image
* @param[in] border New border size to set
* @param[in] size new size of the display
* @param[in] _file Filaneme of the new image
* @param[in] _border New border size to set
*/
void Set(const etk::UString& file, const ewol::Dimension& border);
void Set(const etk::UString& _file, const ewol::Dimension& _border);
protected:
etk::UString m_fileName; //!< File name of the image.
public:
/**
* @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
* @return the filename of the image
*/
const etk::UString& GetFile() { return m_fileName; };
const etk::UString& GetFile(void) { return m_fileName; };
protected:
ewol::Dimension m_border; //!< border to add at the image.
public:
/**
* @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
* @return the border size
*/
const ewol::Dimension& GetBorder() { return m_border; };
const ewol::Dimension& GetBorder(void) { return m_border; };
protected:
ewol::Dimension m_imageSize; //!< border to add at the image.
public:
/**
* @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
* @return the border size
*/
const ewol::Dimension& GetImageSize() { return m_imageSize; };
const ewol::Dimension& GetImageSize(void) { return m_imageSize; };
protected:
bool m_keepRatio; //!< Keep the image ratio between width and hight
public:
/**
* @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.
* @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 void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
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 LoadXML(TiXmlNode* node);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool LoadXML(TiXmlNode* _node);
};
};

View File

@ -118,7 +118,7 @@ Sine Function: sin(teta) = Opposite / Hypotenuse
Cosine Function: cos(teta) = Adjacent / Hypotenuse
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) {

View File

@ -46,7 +46,7 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "Ewol::Joystick"; };
virtual void CalculateSize(const vec2& availlable);
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 SetDisplayMode(joystickMode_te newMode) { m_displayMode = newMode; };

View File

@ -32,9 +32,9 @@ void widget::Label::UnInit(void)
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);
SetCanHaveFocus(false);
}
@ -51,9 +51,9 @@ void widget::Label::CalculateMinMaxSize(void)
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();
ewol::RequestUpdateSize();
}
@ -63,7 +63,7 @@ etk::UString widget::Label::GetLabel(void)
return m_label;
}
void widget::Label::OnDraw(ewol::DrawProperty& displayProp)
void widget::Label::OnDraw(ewol::DrawProperty& _displayProp)
{
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 ...");
if (1 == IdInput) {
if (ewol::keyEvent::statusSingle == typeEvent) {
if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
// nothing to do ...
GenerateEventId(ewolEventLabelPressed);
return true;
@ -131,15 +131,15 @@ bool widget::Label::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
return false;
}
bool widget::Label::LoadXML(TiXmlNode* node)
bool widget::Label::LoadXML(TiXmlNode* _node)
{
if (NULL==node) {
if (NULL==_node) {
return false;
}
ewol::Widget::LoadXML(node);
ewol::Widget::LoadXML(_node);
// get internal data :
// TODO : Unparse data type XML ...
EWOL_DEBUG("Load label:" << node->ToElement()->GetText());
SetLabel(node->ToElement()->GetText());
EWOL_DEBUG("Load label:" << _node->ToElement()->GetText());
SetLabel(_node->ToElement()->GetText());
return true;
}

View File

@ -34,18 +34,18 @@ namespace widget {
public:
/**
* @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
*/
virtual ~Label(void) { };
/**
* @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
* @return The displayed decorated text.
@ -56,9 +56,9 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "Ewol::Label"; };
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
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 LoadXML(TiXmlNode* node);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
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);
// nothing to do ... done on upper widet ...
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 << "");
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) {
// TODO : this generate bugs ... I did not understand why ..
//ewol::widgetManager::FocusKeep(this);

View File

@ -46,7 +46,7 @@ namespace widget {
// Derived function
virtual void OnRegenerateDisplay(void);
// 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:
// function call to display the list :
virtual draw::Color GetBasicBG(void) {

View File

@ -102,11 +102,11 @@ void widget::Mesh::PeriodicCall(int64_t 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 ...");
if (1 == IdInput) {
if( ewol::keyEvent::statusSingle == typeEvent) {
if (1 == _event.GetId()) {
if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
GenerateEventId(ewolEventMeshPressed);
return true;
}

View File

@ -37,7 +37,7 @@ namespace widget {
virtual void OnRegenerateDisplay(void);
virtual void GenDraw(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);
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);
if (type == ewol::keyEvent::typeMouse) {
if (0 != IdInput) {
if (_event.GetType() == ewol::keyEvent::typeMouse) {
if (0 != _event.GetId()) {
KeepFocus();
GrabCursor();
SetCursor(ewol::cursorNone);
}
if (true == GetGrabStatus() ) {
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();
oldAngles.setZ(oldAngles.z() + tmpPos.x());
oldAngles.setY(oldAngles.y() + tmpPos.y());
m_camera.SetAngle(oldAngles);
}
}
} else if (type == ewol::keyEvent::typeFinger) {
} else if (_event.GetType() == ewol::keyEvent::typeFinger) {
KeepFocus();
}
// note : we did not parse the oether media ...
@ -1159,117 +1160,117 @@ 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)
{
EWOL_DEBUG("KB EVENT : \"" << unicodeData << "\"" << "type=" << statusEvent);
// escape case :
if(unicodeData == 27) {
if (statusEvent == ewol::keyEvent::statusDown) {
UnGrabCursor();
SetCursor(ewol::cursorArrow);
if (_event.GetType() == ewol:::keyEvent:keyboardChar) {
EWOL_DEBUG("KB EVENT : \"" << _event.GetChar() << "\"" << "type=" << _event.GetStatus());
// escape case :
if(_event.GetChar() == 27) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
UnGrabCursor();
SetCursor(ewol::cursorArrow);
}
return false;
}
if (false == GetGrabStatus()) {
GrabCursor();
SetCursor(ewol::cursorNone);
}
if( _event.GetChar() == 'z'
|| _event.GetChar() == 'Z') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD;
}
}
}
if( _event.GetChar() == 's'
|| _event.GetChar() == 'S') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK;
}
}
}
if( _event.GetChar() == 'q'
|| _event.GetChar() == 'Q') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT;
}
}
}
if( _event.GetChar() == 'd'
|| _event.GetChar() == 'D') {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT;
}
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT;
}
}
}
EWOL_DEBUG("m_walk=" << m_walk);
return false;
}
if (false == GetGrabStatus()) {
GrabCursor();
SetCursor(ewol::cursorNone);
}
if( unicodeData == 'z'
|| unicodeData == 'Z') {
if (statusEvent == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD;
}
}
}
if( unicodeData == 's'
|| unicodeData == 'S') {
if (statusEvent == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK;
}
}
}
if( unicodeData == 'q'
|| unicodeData == 'Q') {
if (statusEvent == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT;
}
}
}
if( unicodeData == 'd'
|| unicodeData == 'D') {
if (statusEvent == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT;
}
}
}
EWOL_DEBUG("m_walk=" << m_walk);
return false;
}
bool widget::Scene::OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey)
{
if (specialKey == ewol::keyEvent::keyboardUp) {
// --------------------
// -- move mode :
// --------------------
if (_event.GetType() == ewol::keyEvent::keyboardUp) {
EWOL_DEBUG("test ..." << specialKey << " " << statusEvent);
if (statusEvent == ewol::keyEvent::statusDown) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_FORWARD;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_FORWARD) != 0) {
m_walk -= WALK_FLAG_FORWARD;
}
}
}
if (specialKey == ewol::keyEvent::keyboardDown) {
if (statusEvent == ewol::keyEvent::statusDown) {
if (_event.GetType() == ewol::keyEvent::keyboardDown) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_BACK;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_BACK) != 0) {
m_walk -= WALK_FLAG_BACK;
}
}
}
if (specialKey == ewol::keyEvent::keyboardLeft) {
if (statusEvent == ewol::keyEvent::statusDown) {
if (_event.GetType() == ewol::keyEvent::keyboardLeft) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_LEFT;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_LEFT) != 0) {
m_walk -= WALK_FLAG_LEFT;
}
}
}
if (specialKey == ewol::keyEvent::keyboardRight) {
if (statusEvent == ewol::keyEvent::statusDown) {
if (_event.GetType() == ewol::keyEvent::keyboardRight) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_walk |= WALK_FLAG_RIGHT;
}
if (statusEvent == ewol::keyEvent::statusUp) {
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if ((m_walk&WALK_FLAG_RIGHT) != 0) {
m_walk -= WALK_FLAG_RIGHT;
}
}
}
EWOL_DEBUG("m_walk=" << m_walk);
return false;
return true;
}

View File

@ -97,25 +97,14 @@ namespace widget {
* @return the relative position
*/
virtual vec2 RelativePosition(vec2 pos);
// Derived function
public: // dericed function:
virtual const char * const GetObjectType(void) { return "Ewol::Scene"; };
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void PeriodicCall(int64_t localTime);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
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 bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual void OnGetFocus(void);
// Derived function
virtual void OnLostFocus(void);
void renderscene(int pass);
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 ...");
if (1 == IdInput) {
if( ewol::keyEvent::statusSingle == typeEvent
|| ewol::keyEvent::statusMove == typeEvent) {
if (1 == _event.GetId()) {
if( ewol::keyEvent::statusSingle == _event.GetStatus()
|| ewol::keyEvent::statusMove == _event.GetStatus()) {
// get the new position :
EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")");
int32_t oldValue = m_value;

View File

@ -31,17 +31,17 @@ namespace widget {
void SetMax(int32_t val);
void SetColor(draw::Color newColor) { m_textColorFg = newColor; };
private:
int32_t m_value;
int32_t m_min;
int32_t m_max;
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
int32_t m_value;
int32_t m_min;
int32_t m_max;
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
public:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Slider"; } ;
virtual void CalculateMinMaxSize(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"
ewol::Widget::Widget(void) :
m_up(NULL),
m_size(10,10),
m_minSize(0,0),
m_maxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)),
@ -49,6 +50,26 @@ ewol::Widget::~Widget(void)
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)
{
@ -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();
}
@ -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) {
(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){
// widget is hidden ...
return;
}
// check if the element is displayable in the windows :
if( displayProp.m_windowsSize.x() < m_origin.x()
|| displayProp.m_windowsSize.y() < m_origin.y() ) {
if( _displayProp.m_windowsSize.x() < m_origin.x()
|| _displayProp.m_windowsSize.y() < m_origin.y() ) {
// out of the windows ==> nothing to display ...
return;
}
ewol::openGL::Push();
if( (displayProp.m_origin.x() > m_origin.x())
|| (displayProp.m_origin.x() + displayProp.m_size.x() < m_size.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()) ) {
// 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 tmppp1 = displayProp.m_origin.x() + displayProp.m_size.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 tmppp2 = m_origin.x() + m_size.x();
int32_t tmpclipX = etk_min(tmppp1, tmppp2) - tmpOriginX;
int32_t tmpOriginY = etk_max(displayProp.m_origin.y(), m_origin.y());
tmppp1 = displayProp.m_origin.y() + displayProp.m_size.y();
int32_t tmpOriginY = etk_max(_displayProp.m_origin.y(), m_origin.y());
tmppp1 = _displayProp.m_origin.y() + _displayProp.m_size.y();
tmppp2 = m_origin.y() + m_size.y();
//int32_t tmpclipY = etk_min(tmppp1, tmppp2) - tmpOriginX;
@ -147,10 +168,10 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
// Call the widget drawing methode
displayProp.m_origin.setValue(tmpOriginX, tmpOriginY);
displayProp.m_size.setValue(tmpclipX, m_size.y());
_displayProp.m_origin.setValue(tmpOriginX, tmpOriginY);
_displayProp.m_size.setValue(tmpclipX, m_size.y());
//int64_t ___startTime = ewol::GetTime();
OnDraw(displayProp);
OnDraw(_displayProp);
//float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget1 : " << ___localTime << "ms ");
} else {
@ -165,10 +186,10 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
// Call the widget drawing methode
displayProp.m_origin = m_origin;
displayProp.m_size = m_size;
_displayProp.m_origin = m_origin;
_displayProp.m_size = m_size;
//int64_t ___startTime = ewol::GetTime();
OnDraw(displayProp);
OnDraw(_displayProp);
//float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f;
//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);
} else {
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();
}
@ -205,9 +226,9 @@ float ewol::Widget::GetZoom(void)
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)
@ -215,9 +236,9 @@ vec2 ewol::Widget::GetOrigin(void)
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)
@ -243,9 +264,9 @@ vec2 ewol::Widget::GetCalculateMaxSize(void)
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();
// check minimum & maximum compatibility :
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 ...");
return;
}
m_userMinSize = size;
m_userMinSize = _size;
ewol::RequestUpdateSize();
}
@ -275,10 +296,10 @@ void ewol::Widget::CheckMinSize(void)
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 pixelMax = size.GetPixel();
vec2 pixelMax = _size.GetPixel();
// check minimum & maximum compatibility :
bool error=false;
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 ...");
return;
}
m_userMaxSize = size;
m_userMaxSize = _size;
ewol::RequestUpdateSize();
}
@ -315,11 +336,11 @@ vec2 ewol::Widget::GetSize(void)
return vec2(0,0);
}
void ewol::Widget::SetExpand(const bvec2& newExpand)
void ewol::Widget::SetExpand(const bvec2& _newExpand)
{
if( m_userExpand.x() != newExpand.x()
|| m_userExpand.y() != newExpand.y()) {
m_userExpand = newExpand;
if( m_userExpand.x() != _newExpand.x()
|| m_userExpand.y() != _newExpand.y()) {
m_userExpand = _newExpand;
ewol::RequestUpdateSize();
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()
|| m_userFill.y() != newFill.y()) {
m_userFill = newFill;
if( m_userFill.x() != _newFill.x()
|| m_userFill.y() != _newFill.y()) {
m_userFill = _newFill;
ewol::RequestUpdateSize();
MarkToRedraw();
}
@ -353,10 +374,10 @@ const bvec2& ewol::Widget::CanFill(void)
// -- 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
|| 0==strlen(descriptiveString))
if( NULL==_descriptiveString
|| 0==strlen(_descriptiveString))
{
EWOL_ERROR("try to add shortcut with no descriptive string ...");
return;
@ -367,83 +388,83 @@ void ewol::Widget::ShortCutAdd(const char * descriptiveString, const char * gene
EWOL_ERROR("allocation error ... Memory error ...");
return;
}
tmpElement->broadcastEvent = broadcast;
tmpElement->generateEventId = generateEventId;
tmpElement->eventData = data;
tmpElement->broadcastEvent = _broadcast;
tmpElement->generateEventId = _generateEventId;
tmpElement->eventData = _data;
// parsing of the string :
//"ctrl+shift+alt+meta+s"
const char * tmp = strstr(descriptiveString, "ctrl");
const char * tmp = strstr(_descriptiveString, "ctrl");
if(NULL != tmp) {
tmpElement->specialKey.ctrl = true;
}
tmp = strstr(descriptiveString, "shift");
tmp = strstr(_descriptiveString, "shift");
if(NULL != tmp) {
tmpElement->specialKey.shift = true;
}
tmp = strstr(descriptiveString, "alt");
tmp = strstr(_descriptiveString, "alt");
if(NULL != tmp) {
tmpElement->specialKey.alt = true;
}
tmp = strstr(descriptiveString, "meta");
tmp = strstr(_descriptiveString, "meta");
if(NULL != tmp) {
tmpElement->specialKey.meta = true;
}
if(NULL != strstr(descriptiveString, "F12") ) {
if(NULL != strstr(_descriptiveString, "F12") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF12;
} else if(NULL != strstr(descriptiveString, "F11") ) {
} else if(NULL != strstr(_descriptiveString, "F11") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF11;
} else if(NULL != strstr(descriptiveString, "F10") ) {
} else if(NULL != strstr(_descriptiveString, "F10") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF10;
} else if(NULL != strstr(descriptiveString, "F9") ) {
} else if(NULL != strstr(_descriptiveString, "F9") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF9;
} else if(NULL != strstr(descriptiveString, "F8") ) {
} else if(NULL != strstr(_descriptiveString, "F8") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF8;
} else if(NULL != strstr(descriptiveString, "F7") ) {
} else if(NULL != strstr(_descriptiveString, "F7") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF7;
} else if(NULL != strstr(descriptiveString, "F6") ) {
} else if(NULL != strstr(_descriptiveString, "F6") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF6;
} else if(NULL != strstr(descriptiveString, "F5") ) {
} else if(NULL != strstr(_descriptiveString, "F5") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF5;
} else if(NULL != strstr(descriptiveString, "F4") ) {
} else if(NULL != strstr(_descriptiveString, "F4") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF4;
} else if(NULL != strstr(descriptiveString, "F3") ) {
} else if(NULL != strstr(_descriptiveString, "F3") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF3;
} else if(NULL != strstr(descriptiveString, "F2") ) {
} else if(NULL != strstr(_descriptiveString, "F2") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF2;
} else if(NULL != strstr(descriptiveString, "F1") ) {
} else if(NULL != strstr(_descriptiveString, "F1") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardF1;
} else if(NULL != strstr(descriptiveString, "LEFT") ) {
} else if(NULL != strstr(_descriptiveString, "LEFT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardLeft;
} else if(NULL != strstr(descriptiveString, "RIGHT") ) {
} else if(NULL != strstr(_descriptiveString, "RIGHT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardRight;
} else if(NULL != strstr(descriptiveString, "UP") ) {
} else if(NULL != strstr(_descriptiveString, "UP") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardUp;
} else if(NULL != strstr(descriptiveString, "DOWN") ) {
} else if(NULL != strstr(_descriptiveString, "DOWN") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardDown;
} else if(NULL != strstr(descriptiveString, "PAGE_UP") ) {
} else if(NULL != strstr(_descriptiveString, "PAGE_UP") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPageUp;
} else if(NULL != strstr(descriptiveString, "PAGE_DOWN") ) {
} else if(NULL != strstr(_descriptiveString, "PAGE_DOWN") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPageDown;
} else if(NULL != strstr(descriptiveString, "START") ) {
} else if(NULL != strstr(_descriptiveString, "START") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardStart;
} else if(NULL != strstr(descriptiveString, "END") ) {
} else if(NULL != strstr(_descriptiveString, "END") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardEnd;
} else if(NULL != strstr(descriptiveString, "PRINT") ) {
} else if(NULL != strstr(_descriptiveString, "PRINT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardPrint;
} else if(NULL != strstr(descriptiveString, "ARRET_DEFIL") ) {
} else if(NULL != strstr(_descriptiveString, "ARRET_DEFIL") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardStopDefil;
} else if(NULL != strstr(descriptiveString, "WAIT") ) {
} else if(NULL != strstr(_descriptiveString, "WAIT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardWait;
} else if(NULL != strstr(descriptiveString, "INSERT") ) {
} else if(NULL != strstr(_descriptiveString, "INSERT") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardInsert;
} else if(NULL != strstr(descriptiveString, "CAPLOCK") ) {
} else if(NULL != strstr(_descriptiveString, "CAPLOCK") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardCapLock;
} else if(NULL != strstr(descriptiveString, "CONTEXT_MENU") ) {
} else if(NULL != strstr(_descriptiveString, "CONTEXT_MENU") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardContextMenu;
} else if(NULL != strstr(descriptiveString, "NUM_LOCK") ) {
} else if(NULL != strstr(_descriptiveString, "NUM_LOCK") ) {
tmpElement->keyboardMoveValue = ewol::keyEvent::keyboardNumLock;
} else {
tmpElement->unicodeValue = descriptiveString[strlen(descriptiveString) -1];
tmpElement->unicodeValue = _descriptiveString[strlen(_descriptiveString) -1];
}
// add it on the List ...
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') {
unicodeValue += 'a' - 'A';
if (_unicodeValue >= 'A' && _unicodeValue <='Z') {
_unicodeValue += 'a' - 'A';
}
//EWOL_INFO("Try to find generic shortcut ...");
for(int32_t iii=m_localShortcut.Size()-1; iii>=0; iii--) {
if(NULL != m_localShortcut[iii]) {
if( m_localShortcut[iii]->specialKey.shift == special.shift
&& m_localShortcut[iii]->specialKey.ctrl == special.ctrl
&& m_localShortcut[iii]->specialKey.alt == special.alt
&& m_localShortcut[iii]->specialKey.meta == special.meta
if( m_localShortcut[iii]->specialKey.shift == _special.shift
&& m_localShortcut[iii]->specialKey.ctrl == _special.ctrl
&& m_localShortcut[iii]->specialKey.alt == _special.alt
&& m_localShortcut[iii]->specialKey.meta == _special.meta
&& ( ( m_localShortcut[iii]->keyboardMoveValue == ewol::keyEvent::keyboardUnknow
&& m_localShortcut[iii]->unicodeValue == unicodeValue)
|| ( m_localShortcut[iii]->keyboardMoveValue == kbMove
&& m_localShortcut[iii]->unicodeValue == _unicodeValue)
|| ( m_localShortcut[iii]->keyboardMoveValue == _kbMove
&& m_localShortcut[iii]->unicodeValue == 0)
) )
{
if (isDown) {
if (_isDown) {
if (true == m_localShortcut[iii]->broadcastEvent) {
// send message at all the widget (exepted this one)
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);
m_cursorDisplay = newCursor;
EWOL_DEBUG("Change Cursor in " << _newCursor);
m_cursorDisplay = _newCursor;
guiInterface::SetCursor(m_cursorDisplay);
}
@ -532,17 +553,17 @@ ewol::cursorDisplay_te ewol::Widget::GetCursor(void)
return m_cursorDisplay;
}
bool ewol::Widget::LoadXML(TiXmlNode* node)
bool ewol::Widget::LoadXML(TiXmlNode* _node)
{
if (NULL==node) {
if (NULL==_node) {
return false;
}
bool ret = true;
const char *tmpAttributeValue = node->ToElement()->Attribute("name");
const char *tmpAttributeValue = _node->ToElement()->Attribute("name");
if (NULL != tmpAttributeValue) {
SetName(tmpAttributeValue);
}
tmpAttributeValue = node->ToElement()->Attribute("fill");
tmpAttributeValue = _node->ToElement()->Attribute("fill");
if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) {
SetFill(bvec2(false,false));
@ -556,7 +577,7 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
SetFill(bvec2(true,true));
}
}
tmpAttributeValue = node->ToElement()->Attribute("expand");
tmpAttributeValue = _node->ToElement()->Attribute("expand");
if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) {
SetExpand(bvec2(false,false));
@ -570,7 +591,7 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
SetExpand(bvec2(true,true));
}
}
tmpAttributeValue = node->ToElement()->Attribute("hide");
tmpAttributeValue = _node->ToElement()->Attribute("hide");
if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) {
Hide();
@ -578,17 +599,17 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
Show();
}
}
tmpAttributeValue = node->ToElement()->Attribute("focus");
tmpAttributeValue = _node->ToElement()->Attribute("focus");
if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) {
KeepFocus();
}
}
tmpAttributeValue = node->ToElement()->Attribute("min-size");
tmpAttributeValue = _node->ToElement()->Attribute("min-size");
if (NULL != tmpAttributeValue) {
m_userMinSize.SetString(tmpAttributeValue);
}
tmpAttributeValue = node->ToElement()->Attribute("max-size");
tmpAttributeValue = _node->ToElement()->Attribute("max-size");
if (NULL != tmpAttributeValue) {
m_userMaxSize.SetString(tmpAttributeValue);
}
@ -597,9 +618,9 @@ bool ewol::Widget::LoadXML(TiXmlNode* node)
return ret;
}
bool ewol::Widget::StoreXML(TiXmlNode* node)
bool ewol::Widget::StoreXML(TiXmlNode* _node)
{
if (NULL==node) {
if (NULL==_node) {
return false;
}
/*
@ -608,39 +629,59 @@ bool ewol::Widget::StoreXML(TiXmlNode* node)
EWOL_ERROR("TinyXML node allocation error");
return false;
}
node->LinkEndChild(element);
_node->LinkEndChild(element);
*/
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)) {
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)) {
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)) {
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)) {
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) {
node->ToElement()->SetAttribute("hide", "true" );
_node->ToElement()->SetAttribute("hide", "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 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/key.h>
#include <ewol/cursor.h>
#include <ewol/renderer/EventInput.h>
#include <ewol/renderer/EventEntry.h>
#define ULTIMATE_MAX_SIZE (99999999)
@ -34,16 +36,14 @@ namespace ewol {
ivec2 m_origin;
ivec2 m_size;
};
class EventShortCut {
public:
bool broadcastEvent; // if it is true, then the message is sent to all the system
const char * generateEventId; // Local generated event
etk::UString eventData; // data link with the event
ewol::SpecialKey specialKey; // special board key
uniChar_t unicodeValue; // 0 if not used
ewol::keyEvent::keyboard_te keyboardMoveValue; // ewol::EVENT_KB_MOVE_TYPE_NONE if not used
bool broadcastEvent; //!< if it is true, then the message is sent to all the system
const char* generateEventId; //!< Local generated event
etk::UString eventData; //!< data link with the event
ewol::SpecialKey specialKey; //!< special board key
uniChar_t unicodeValue; //!< 0 if not used
ewol::keyEvent::keyboard_te keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used
EventShortCut(void) {
broadcastEvent = false;
generateEventId = NULL;
@ -71,6 +71,26 @@ namespace ewol {
*/
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:
// ----------------------------------------------------------------------------------------------------------------
protected:
@ -80,17 +100,17 @@ namespace ewol {
public:
/**
* @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
*/
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
* 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
*/
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateSize(const vec2& _availlable);
/**
* @brief Get the widget size
* @return Requested size
@ -120,9 +140,9 @@ namespace ewol {
public:
/**
* @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
* @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).
* 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
*/
virtual void SetOrigin(const vec2& pos);
virtual void SetOrigin(const vec2& _pos);
/**
* @brief Get the origin (obsolute position in the windows)
* @return coordonate of the origin requested
@ -148,9 +168,9 @@ namespace ewol {
public:
/**
* @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.
*/
@ -171,9 +191,9 @@ namespace ewol {
public:
/**
* @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.
*/
@ -194,9 +214,9 @@ namespace ewol {
public:
/**
* @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)
* @return 2D boolean repensent the capacity to expend
@ -213,9 +233,9 @@ namespace ewol {
public:
/**
* @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
* @return bvec2 repensent the capacity to x&y filling (set by the user)
@ -272,9 +292,9 @@ namespace ewol {
virtual bool RmFocus(void);
/**
* @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
*/
@ -302,9 +322,9 @@ namespace ewol {
virtual int32_t GetMouseLimit(void) { return m_limitMouseEvent; };
/**
* @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
@ -320,9 +340,9 @@ namespace ewol {
virtual bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; };
/**
* @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
@ -336,69 +356,84 @@ namespace ewol {
public:
/**
* @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:
/**
* @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 pointer on the widget found
* @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
* @param[in] widgetName name of the widget
* @param[in] _widgetName name of the widget
* @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
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
* @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
* @brief system event input (only meta widget might overwrite this function).
* @param[in] _event Event properties
* @return true the event is 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).
* @param[in] type of the event (ewol::EVENT_KB_TYPE_DOWN or ewol::EVENT_KB_TYPE_UP)
* @param[in] unicodeValue key pressed by the user
* @brief Event on an input of this Widget (finger, mouse, stilet)
* @param[in] _event Event properties
* @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 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 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
* @note : need to have focus ...
* @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
// ----------------------------------------------------------------------------------------------------------------
private:
etk::Vector<EventShortCut*> m_localShortcut;
etk::Vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget
protected:
/**
* @brief Add a specific shortcut with his description
* @param[in] descriptiveString Description string of the shortcut
* @param[in] generateEventId Event generic of the element
* @param[in] data Associate data wit the event
* @param[in] _descriptiveString Description string of the shortcut
* @param[in] _generateEventId Event generic of the element
* @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
*/
@ -406,14 +441,14 @@ namespace ewol {
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)
* @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] kbMove special key of the keyboard
* @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] _kbMove special key of the keyboard
* @return true if the event has 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
*/
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...
// ----------------------------------------------------------------------------------------------------------------
@ -434,16 +469,17 @@ namespace ewol {
* @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
* @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
*/
virtual void GenDraw(DrawProperty displayProp);
// TODO : Rename SystemDraw()
virtual void GenDraw(DrawProperty _displayProp);
protected:
/**
* @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:
/**
* @brief Event generated when a redraw is needed
@ -473,9 +509,9 @@ namespace ewol {
public:
/**
* @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.
* @return the type of the cursor.
@ -484,18 +520,20 @@ namespace ewol {
public:
/**
* @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 false : An error occured.
*/
virtual bool LoadXML(TiXmlNode* node);
virtual bool LoadXML(TiXmlNode* _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 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 namespace

View File

@ -20,6 +20,7 @@
#include <ewol/widget/Gird.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/Scroll.h>
#include <etk/Vector.h>
#undef __class__
@ -70,6 +71,7 @@ void ewol::widgetManager::Init(void)
widget::Gird::Init();
widget::Entry::Init();
widget::CheckBox::Init();
widget::Scroll::Init();
IsInit = true;
}
@ -80,7 +82,7 @@ void ewol::widgetManager::UnInit(void)
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
widget::Scroll::UnInit();
widget::CheckBox::UnInit();
widget::Entry::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 ...
relativePos.setY(m_size.y() - relativePos.y());
if (SCROLL_MODE_NORMAL == m_scroollingMode) {
if (ewol::keyEvent::typeMouse==type && ( ewol::keyEvent::typeUnknow==m_highSpeedType || ewol::keyEvent::typeMouse==m_highSpeedType )) {
if (1 == IdInput && ewol::keyEvent::statusDown == typeEvent) {
if( ewol::keyEvent::typeMouse==_event.GetType()
&& ( 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 ...
if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) {
if( m_size.y() < m_maxSize.y()
@ -117,7 +119,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
}
}
return false;
} else if (4 == IdInput && ewol::keyEvent::statusUp == typeEvent) {
} else if (4 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
/*
if (true == ewol::IsSetCtrl()) {
float zoom = GetZoom()*1.1;
@ -131,7 +133,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true;
}
}
} else if (5 == IdInput && ewol::keyEvent::statusUp == typeEvent) {
} else if (5 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
/*
if (true == ewol::IsSetCtrl()) {
float zoom = GetZoom()*0.9;
@ -145,7 +147,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true;
}
}
}else if (2 == IdInput) {
}else if (2 == _event.GetId()) {
/*
if (true == ewol::IsSetCtrl()) {
if (ewol::keyEvent::statusDown == typeEvent) {
@ -153,7 +155,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
SetZoom(zoom);
}
} else */{
if (ewol::keyEvent::statusDown == typeEvent) {
if (ewol::keyEvent::statusDown == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_INIT;
m_highSpeedType = ewol::keyEvent::typeMouse;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
@ -161,14 +163,14 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
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_highSpeedType = ewol::keyEvent::typeUnknow;
MarkToRedraw();
return true;
}
if (IdInput==m_highSpeedButton && widget::SCROLL_DISABLE!=m_highSpeedMode) {
if (ewol::keyEvent::statusUp == typeEvent) {
if (_event.GetId()==m_highSpeedButton && widget::SCROLL_DISABLE!=m_highSpeedMode) {
if (ewol::keyEvent::statusUp == _event.GetStatus()) {
if (widget::SCROLL_INIT==m_highSpeedMode) {
// TODO : Generate back the down event ...
m_highSpeedMode = widget::SCROLL_DISABLE;
@ -180,14 +182,14 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
return true;
}
} 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_highSpeedType = ewol::keyEvent::typeUnknow;
m_highSpeedButton = -1;
MarkToRedraw();
}
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 :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 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)));
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(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
MarkToRedraw();
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(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
MarkToRedraw();
return true;
}
}
} else if (ewol::keyEvent::typeFinger==type && ( ewol::keyEvent::typeUnknow==m_highSpeedType || ewol::keyEvent::typeFinger==m_highSpeedType )) {
if (1 == IdInput) {
} else if( ewol::keyEvent::typeFinger==_event.GetType()
&& ( ewol::keyEvent::typeUnknow==m_highSpeedType
|| ewol::keyEvent::typeFinger==m_highSpeedType ) ) {
if (1 == _event.GetId()) {
//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_highSpeedType = ewol::keyEvent::typeFinger;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
EWOL_VERBOSE("SCROOL ==> INIT");
return true;
} else if (ewol::keyEvent::statusUp == typeEvent) {
} else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow;
EWOL_VERBOSE("SCROOL ==> DISABLE");
MarkToRedraw();
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 :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
@ -252,7 +256,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
MarkToRedraw();
}
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.setX(m_originScrooled.x() - relativePos.x() - m_highSpeedStartPos.x());
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();
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_highSpeedType = ewol::keyEvent::typeUnknow;
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) {
if (ewol::keyEvent::typeMouse==type) {
if (ewol::keyEvent::typeMouse==_event.GetType()) {
float tmp1=m_size.x() / m_maxSize.y();
float tmp2=m_size.y() / m_maxSize.x();
//EWOL_INFO(" elements Zoom : " << 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;
if (tmp1 < 1.0) {
m_zoom = etk_max(tmp1, m_zoom);
@ -286,7 +290,7 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
}
MarkToRedraw();
return true;
} else if (5 == IdInput && ewol::keyEvent::statusUp == typeEvent) {
} else if (5 == _event.GetId() && ewol::keyEvent::statusUp == _event.GetStatus()) {
m_zoom += 0.1;
if (tmp1 > 1.0) {
m_zoom = etk_min(tmp1, m_zoom);
@ -305,16 +309,16 @@ bool widget::WidgetScrooled::OnEventInput(ewol::keyEvent::type_te type, int32_t
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");
return;
}
if (pos < 0 || pos >= m_listOObject.Size() ) {
m_listOObject.PushBack(newObject);
if (_pos < 0 || _pos >= m_listOObject.Size() ) {
m_listOObject.PushBack(_newObject);
} else {
m_listOObject.Insert(pos, newObject);
m_listOObject.Insert(_pos, _newObject);
}
}

View File

@ -32,50 +32,43 @@ namespace widget {
class WidgetScrooled : public ewol::Widget
{
private:
etk::Vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
void AddOObject(ewol::Compositing* newObject, int32_t pos=-1);
void ClearOObjectList(void);
etk::Vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
void AddOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
void ClearOObjectList(void);
protected:
vec2 m_originScrooled;
vec2 m_maxSize;
float m_limitScrolling;
vec2 m_originScrooled;
vec2 m_maxSize;
float m_limitScrolling;
private:
scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling
float m_pixelScrolling;
vec2 m_highSpeedStartPos;
highSpeedMode_te m_highSpeedMode;
int32_t m_highSpeedButton;
scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling
float m_pixelScrolling;
vec2 m_highSpeedStartPos;
highSpeedMode_te m_highSpeedMode;
int32_t m_highSpeedButton;
ewol::keyEvent::type_te m_highSpeedType;
public:
WidgetScrooled(void);
virtual ~WidgetScrooled(void);
// Derived function
public: // Derived function
virtual const char * const GetObjectType(void) { return "EwolWidgetScrooled"; };
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos);
// Derived function
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void GenDraw(ewol::DrawProperty displayProp);
protected:
/**
* @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
* @return ---
*/
void SetScrollingSize(float nbPixel) { m_pixelScrolling = nbPixel; };
/**
* @brief Specify the mode of scrolling for this windows
* @param[in] newMode the selected mode for the scrolling...
* @return ---
*/
void ScroolingMode(scrollingMode_te newMode);
/**
* @brief Set the specific mawimum size of the widget
* @param[in] localSize new Maximum size
* @return ---
*/
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] currentPosition Position that is requested to view
* @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);
/**
* @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 ...
* @return ---
*/
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->SetExpand(bvec2(true,false));
m_widgetCurrentFileName->SetFill(bvec2(true,false));
m_widgetCurrentFileName->SetWidth(200);
//m_widgetCurrentFileName->SetWidth(200);
mySizerHori->SubWidgetAdd(m_widgetCurrentFileName);
}
}
@ -273,7 +273,7 @@ widget::FileChooser::FileChooser(void)
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFolderEnter);
m_widgetCurrentFolder->SetExpand(bvec2(true,false));
m_widgetCurrentFolder->SetFill(bvec2(true,false));
m_widgetCurrentFolder->SetWidth(200);
//m_widgetCurrentFolder->SetWidth(200);
mySizerHori->SubWidgetAdd(m_widgetCurrentFolder);
}
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);
// nothing to do ... done on upper widet ...
return true;
}
if (IdInput == 1 && typeEvent == ewol::keyEvent::statusSingle) {
vec2 relativePos = RelativePosition(pos);
if (_event.GetId() == 1 && _event.GetStatus() == ewol::keyEvent::statusSingle) {
vec2 relativePos = RelativePosition(_event.GetPos());
// corection for the openGl abstraction
relativePos.setY(m_size.y() - relativePos.y());
// TODO : Rework this ...

View File

@ -67,7 +67,7 @@ namespace widget {
// Derived function
void OnRegenerateDisplay(void);
// 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:
// Derived function
void OnGetFocus(void);

View File

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