Button event is OK ... so good
This commit is contained in:
parent
e3668827e6
commit
e8bd90cb48
@ -53,10 +53,10 @@ class Plop :public ewol::Windows
|
||||
|
||||
myButton = new ewol::Button("BT 3");
|
||||
myButton->SetExpendX(true);
|
||||
myButton->SetExpendY(true);
|
||||
//myButton->SetExpendY(true);
|
||||
mySizerVert->SubWidgetAdd(myButton);
|
||||
myButton = new ewol::Button(" 4 4 BT");
|
||||
myButton->SetExpendY(true);
|
||||
//myButton->SetExpendY(true);
|
||||
mySizerVert->SubWidgetAdd(myButton);
|
||||
|
||||
myButton = new ewol::Button("Exemple 2");
|
||||
|
@ -143,7 +143,8 @@ bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const
|
||||
newEvent.generateEventId = generateEventId;
|
||||
newEvent.widgetCall = -1; // by default no widget is called
|
||||
newEvent.mode = EWOL_EVENT_AREA;
|
||||
newEvent.area.origin = origin;
|
||||
newEvent.area.origin.x = origin.x + m_origin.x;
|
||||
newEvent.area.origin.y = origin.y + m_origin.y;
|
||||
newEvent.area.size = size;
|
||||
newEvent.area.flags = flags;
|
||||
m_inputEvent.PushBack(newEvent);
|
||||
@ -179,7 +180,7 @@ void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name)
|
||||
return;
|
||||
}
|
||||
newObject->SetName(name);
|
||||
EWOL_INFO("UPDATE AT origin : (" << m_origin.x << "," << m_origin.y << ")");
|
||||
//EWOL_INFO("UPDATE AT origin : (" << m_origin.x << "," << m_origin.y << ")");
|
||||
newObject->UpdateOrigin(m_origin.x, m_origin.y);
|
||||
m_listOObject.PushBack(newObject);
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ namespace ewol {
|
||||
bool m_userExpendY;
|
||||
public:
|
||||
void SetOrigin(double x, double y) { m_origin.x=x; m_origin.y=y; };
|
||||
coord GetOrigin(void) { return m_origin; };
|
||||
virtual bool CalculateSize(double availlableX, double availlableY); // this generate the current size ...
|
||||
virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; return true; }; //update the min Size ... and the expend parameters for the sizer
|
||||
virtual void SetMinSise(double x=-1, double y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; };
|
||||
@ -217,6 +218,7 @@ namespace ewol {
|
||||
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y); // call when input event arrive and call OnEventInput, if no event detected
|
||||
bool GenEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE]);
|
||||
protected:
|
||||
void EventAreaRemoveAll(void) { m_inputEvent.Clear(); };
|
||||
bool AddEventArea(coord origin, coord size, uint64_t flags, const char * generateEventId);
|
||||
bool AddEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE], const char * generateEventId);
|
||||
bool AddEventShortCut(char * descriptiveString, const char * generateEventId);
|
||||
|
@ -122,6 +122,9 @@ bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, d
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->GenEventInput(IdInput, typeEvent, x, y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -181,27 +184,6 @@ bool ewol::Windows::OnDraw(void)
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->GenDraw();
|
||||
}
|
||||
/*
|
||||
// Test AREA :
|
||||
ewol::OObject2DColored tmpOObjects;
|
||||
tmpOObjects.Rectangle( 50, 50, 200, 300, 1.0, 0.0, 0.0, 1.0);
|
||||
tmpOObjects.Draw();
|
||||
|
||||
glColor4f(0.0, 0.0, 0.0, 1.0);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 1);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex3f(50.0, 50.0, 0.0);
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glVertex3f(250.0, 50.0, 0.0);
|
||||
glTexCoord2f(1.0, 1.0);
|
||||
glVertex3f(250.0, 350.0, 0.0);
|
||||
glTexCoord2f(0.0, 1.0);
|
||||
glVertex3f(50.0, 350.0, 0.0);
|
||||
glEnd();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -220,6 +202,7 @@ bool ewol::Windows::OnEventArea(const char * generateEventId, double x, double y
|
||||
EWOL_INFO("Request Expend of the windows");
|
||||
eventIsOK = true;
|
||||
}
|
||||
|
||||
return eventIsOK;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace ewol {
|
||||
virtual bool OnEventArea(const char * generateEventId, double x, double y);
|
||||
// Widget overwrite function
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y);
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y);
|
||||
private:
|
||||
bool m_hasDecoration;
|
||||
public:
|
||||
|
@ -26,6 +26,12 @@
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
|
||||
|
||||
const char * ewolEventButtonPressed = "ewol Button Pressed";
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::Button"
|
||||
|
||||
@ -91,8 +97,41 @@ void ewol::Button::OnRegenerateDisplay(void)
|
||||
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
||||
int32_t pos = (m_size.y - fontHeight)/2;
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText(5, pos, "", -1, FONT_MODE_BOLD, textColorFg, m_label.c_str());
|
||||
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||
int32_t posy = (m_size.y - fontHeight - 6)/2 + 3;
|
||||
int32_t posx = (m_size.x - fontWidth - 6)/2 + 3;
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText(posx, posy, "", -1, FONT_MODE_BOLD, textColorFg, m_label.c_str());
|
||||
|
||||
AddOObject(tmpText, "BouttonText");
|
||||
|
||||
|
||||
// Regenerate the event Area:
|
||||
EventAreaRemoveAll();
|
||||
coord origin;
|
||||
coord size;
|
||||
origin.x = 3.0;
|
||||
origin.y = 3.0;
|
||||
size.x = m_size.x-6;
|
||||
size.y = m_size.y-6;
|
||||
AddEventArea(origin, size, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventButtonPressed);
|
||||
}
|
||||
|
||||
/*
|
||||
bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y)
|
||||
{
|
||||
EWOL_DEBUG("Event on BT ...");
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool ewol::Button::OnEventArea(const char * generateEventId, double x, double y)
|
||||
{
|
||||
bool eventIsOK = false;
|
||||
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
|
||||
if(ewolEventButtonPressed == generateEventId) {
|
||||
EWOL_INFO("BT pressed ... " << m_label);
|
||||
eventIsOK = true;
|
||||
}
|
||||
|
||||
return eventIsOK;
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ namespace ewol {
|
||||
etk::String m_label;
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
//virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y);
|
||||
virtual bool OnEventArea(const char * generateEventId, double x, double y);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -213,3 +213,20 @@ void ewol::SizerHori::OnRegenerateDisplay(void)
|
||||
}
|
||||
|
||||
|
||||
bool ewol::SizerHori::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
|
||||
if (NULL != m_subWidget[iii]) {
|
||||
coord tmpSize = m_subWidget[iii]->GetSize();
|
||||
coord tmpOrigin = m_subWidget[iii]->GetOrigin();
|
||||
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
|
||||
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
|
||||
{
|
||||
return m_subWidget[iii]->GenEventInput(IdInput, typeEvent, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +52,8 @@ namespace ewol {
|
||||
virtual bool OnDraw(void);
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -212,3 +212,19 @@ void ewol::SizerVert::OnRegenerateDisplay(void)
|
||||
}
|
||||
|
||||
|
||||
bool ewol::SizerVert::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
|
||||
if (NULL != m_subWidget[iii]) {
|
||||
coord tmpSize = m_subWidget[iii]->GetSize();
|
||||
coord tmpOrigin = m_subWidget[iii]->GetOrigin();
|
||||
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
|
||||
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
|
||||
{
|
||||
return m_subWidget[iii]->GenEventInput(IdInput, typeEvent, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,8 @@ namespace ewol {
|
||||
virtual bool OnDraw(void);
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user