Rework the button system to work with the fill system in X and Y
This commit is contained in:
parent
7150727dd5
commit
2e50ce7690
@ -75,8 +75,8 @@ bool ewol::Button::CalculateMinSize(void)
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||
int32_t minHeight = ewol::GetHeight(fontId);
|
||||
m_minSize.x = 10+minWidth;
|
||||
m_minSize.y = 10+minHeight;
|
||||
m_minSize.x = 16+minWidth;
|
||||
m_minSize.y = 16+minHeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -101,74 +101,59 @@ void ewol::Button::OnRegenerateDisplay(void)
|
||||
{
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
/*
|
||||
|
||||
// TODO later : Add this in the basic element of the widget ...
|
||||
int32_t borderSize = 2;
|
||||
int32_t paddingSize = 3;
|
||||
int32_t tmpSizeX = 0;
|
||||
int32_t tmpSizeY = 0;
|
||||
int32_t tmpOriginX = 0;
|
||||
int32_t tmpOriginX = 0;
|
||||
|
||||
int32_t tmpSizeX = m_minSize.x;
|
||||
int32_t tmpSizeY = m_minSize.y;
|
||||
int32_t tmpOriginX = (m_size.x - tmpSizeX) / 2;
|
||||
int32_t tmpOriginY = (m_size.y - tmpSizeY) / 2;
|
||||
// no change for the text orogin :
|
||||
int32_t tmpTextOriginX = (m_size.x - tmpSizeX) / 2 + borderSize + 2*paddingSize;
|
||||
int32_t tmpTextOriginY = (m_size.y - tmpSizeY) / 2 + borderSize + 2*paddingSize;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
tmpOObjects->SetColor(0.0, 0.0, 0.0, 1.0);
|
||||
tmpOObjects->Rectangle( 2, 2, m_size.x-4, m_size.y-4);
|
||||
tmpOObjects->SetColor(1.0, 1.0, 1.0, 1.0);
|
||||
tmpOObjects->Rectangle( 3, 3, m_size.x-6, m_size.y-6);
|
||||
AddOObject(tmpOObjects, "BouttonDecoration");
|
||||
|
||||
*/
|
||||
#if 1
|
||||
int32_t borderWidth = 2;
|
||||
tmpOriginX += paddingSize;
|
||||
tmpOriginY += paddingSize;
|
||||
tmpSizeX -= 2*paddingSize;
|
||||
tmpSizeY -= 2*paddingSize;
|
||||
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
||||
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
||||
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;
|
||||
tmpText->Text(posx+2, posy, m_label.c_str());
|
||||
|
||||
tmpText->Text(tmpTextOriginX, tmpTextOriginY, m_label.c_str());
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
int32_t radius = fontHeight / 2;
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->Rectangle( ((m_size.x-fontWidth-10)/2)+radius, posy, fontWidth-radius, radius*2);
|
||||
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
//EWOL_DEBUG("m_textColorFg=(" << m_textColorFg.red << " " << m_textColorFg.green << " " << m_textColorFg.blue << " " << m_textColorFg.alpha << ")" );
|
||||
tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy, ((m_size.x-fontWidth-10)/2)+fontWidth, posy, borderWidth);
|
||||
tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy+fontHeight, ((m_size.x-fontWidth-10)/2)+fontWidth, posy+fontHeight, borderWidth);
|
||||
posy += fontHeight/2;
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->DiscPart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, 180, 360);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, borderWidth, 180, 360);
|
||||
tmpOObjects->SetColor(m_textColorBg);
|
||||
tmpOObjects->DiscPart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, 0, 180);
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, borderWidth, 0, 180);
|
||||
|
||||
tmpOObjects->RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, borderSize);
|
||||
|
||||
AddOObject(tmpOObjects, "BouttonDecoration");
|
||||
|
||||
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;
|
||||
origin.x = tmpOriginX;
|
||||
origin.y = tmpOriginY;
|
||||
size.x = tmpSizeX;
|
||||
size.y = tmpSizeY;
|
||||
AddEventArea(origin, size, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventButtonPressed);
|
||||
AddEventArea(origin, size, FLAG_EVENT_INPUT_ENTER, ewolEventButtonEnter);
|
||||
AddEventArea(origin, size, FLAG_EVENT_INPUT_LEAVE, ewolEventButtonLeave);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user