[DEV] display font with clipping availlable
This commit is contained in:
parent
ace466b7bd
commit
ba0b1256d6
@ -222,12 +222,14 @@ bool ewol::TexturedFont::HasName(etk::UString& fileName)
|
||||
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||
const etk::UString& unicodeString,
|
||||
etk::Vector<Vector2D<float> > & coord,
|
||||
etk::Vector<texCoord_ts> & coordTex)
|
||||
etk::Vector<texCoord_ts> & coordTex,
|
||||
bool hasClipping,
|
||||
clipping_ts& clipping)
|
||||
{
|
||||
float totalSize = 0;
|
||||
Vector2D<float> tmpPos = textPos;
|
||||
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
|
||||
int32_t ret = Draw(tmpPos, unicodeString[iii], coord, coordTex);
|
||||
int32_t ret = Draw(tmpPos, unicodeString[iii], coord, coordTex, hasClipping, clipping);
|
||||
tmpPos.x += ret;
|
||||
totalSize += ret;
|
||||
}
|
||||
@ -308,7 +310,9 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||
const uniChar_t unicodeChar,
|
||||
etk::Vector<Vector2D<float> > & coord,
|
||||
etk::Vector<texCoord_ts> & coordTex)
|
||||
etk::Vector<texCoord_ts> & coordTex,
|
||||
bool hasClipping,
|
||||
clipping_ts& clipping)
|
||||
{
|
||||
float posDrawX = textPos.x;
|
||||
|
||||
@ -347,8 +351,55 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||
|
||||
|
||||
// Clipping and drawing area
|
||||
|
||||
if( dxB < clipping.x
|
||||
|| dxA > clipping.x + clipping.w)
|
||||
{
|
||||
// Nothing to diplay ...
|
||||
} else {
|
||||
if (true == hasClipping) {
|
||||
// generata positions...
|
||||
float TexSizeX = tuB - tuA;
|
||||
if (dxA < clipping.x) {
|
||||
// clip display
|
||||
float drawSize = clipping.x - dxA;
|
||||
// Update element start display
|
||||
dxA = clipping.x;
|
||||
float addElement = TexSizeX * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||
// update texture start X Pos
|
||||
tuA += addElement;
|
||||
}
|
||||
if (dxB > clipping.x + clipping.w) {
|
||||
// clip display
|
||||
float drawSize = dxB - (clipping.x + clipping.w);
|
||||
// Update element start display
|
||||
dxB = clipping.x + clipping.w;
|
||||
float addElement = TexSizeX * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||
// update texture start X Pos
|
||||
tuB -= addElement;
|
||||
}
|
||||
float TexSizeY = tvD - tvC;
|
||||
if (dyC < clipping.y) {
|
||||
// clip display
|
||||
float drawSize = clipping.y - dyC;
|
||||
// Update element start display
|
||||
dyC = clipping.y;
|
||||
float addElement = TexSizeY * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||
// update texture start X Pos
|
||||
tvC += addElement;
|
||||
}
|
||||
if (dyD > clipping.y + clipping.h) {
|
||||
// clip display
|
||||
float drawSize = dyD - (clipping.y + clipping.h);
|
||||
// Update element start display
|
||||
dyD = clipping.y + clipping.h;
|
||||
float addElement = TexSizeX * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||
// update texture start X Pos
|
||||
tvD -= addElement;
|
||||
}
|
||||
}
|
||||
if( dxB <= dxA
|
||||
|| dyD >= dyC) {
|
||||
|| dyD <= dyC) {
|
||||
// nothing to do ...
|
||||
} else {
|
||||
/* Bitmap position
|
||||
@ -416,7 +467,7 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||
coord.PushBack(bitmapDrawPos[0]);
|
||||
coord.PushBack(bitmapDrawPos[2]);
|
||||
coord.PushBack(bitmapDrawPos[3]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
posDrawX += m_listElement[charIndex].property.m_advance.x;
|
||||
|
@ -57,11 +57,15 @@ namespace ewol
|
||||
int32_t Draw(Vector2D<float> textPos,
|
||||
const etk::UString& unicodeString,
|
||||
etk::Vector<Vector2D<float> > & coord,
|
||||
etk::Vector<texCoord_ts> & coordTex);
|
||||
etk::Vector<texCoord_ts> & coordTex,
|
||||
bool hasClipping,
|
||||
clipping_ts& clipping);
|
||||
int32_t Draw(Vector2D<float> textPos,
|
||||
const uniChar_t unicodeChar,
|
||||
etk::Vector<Vector2D<float> > & coord,
|
||||
etk::Vector<texCoord_ts> & coordTex);
|
||||
etk::Vector<texCoord_ts> & coordTex,
|
||||
bool hasClipping,
|
||||
clipping_ts& clipping);
|
||||
Vector2D<float> GetSize(const etk::UString & unicodeString);
|
||||
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
||||
// TODO : Remove this element, it is stupid ...
|
||||
|
@ -183,11 +183,7 @@ int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const etk::USt
|
||||
}
|
||||
int32_t nbElementInTheArray = m_coord.Size();
|
||||
int32_t size = 0;
|
||||
if (true==m_hasClipping) {
|
||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
||||
} else {
|
||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
||||
}
|
||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex, m_hasClipping, m_clipping);
|
||||
// set the color ...
|
||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||
m_coordColor.PushBack(m_color);
|
||||
@ -203,11 +199,7 @@ int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const uniChar_
|
||||
}
|
||||
int32_t nbElementInTheArray = m_coord.Size();
|
||||
int32_t size = 0;
|
||||
if (true==m_hasClipping) {
|
||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
||||
} else {
|
||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
||||
}
|
||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex, m_hasClipping, m_clipping);
|
||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||
m_coordColor.PushBack(m_color);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user