[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,
|
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||||
const etk::UString& unicodeString,
|
const etk::UString& unicodeString,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
etk::Vector<texCoord_ts> & coordTex)
|
etk::Vector<texCoord_ts> & coordTex,
|
||||||
|
bool hasClipping,
|
||||||
|
clipping_ts& clipping)
|
||||||
{
|
{
|
||||||
float totalSize = 0;
|
float totalSize = 0;
|
||||||
Vector2D<float> tmpPos = textPos;
|
Vector2D<float> tmpPos = textPos;
|
||||||
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
|
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;
|
tmpPos.x += ret;
|
||||||
totalSize += ret;
|
totalSize += ret;
|
||||||
}
|
}
|
||||||
@ -308,7 +310,9 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
|||||||
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||||
const uniChar_t unicodeChar,
|
const uniChar_t unicodeChar,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
etk::Vector<texCoord_ts> & coordTex)
|
etk::Vector<texCoord_ts> & coordTex,
|
||||||
|
bool hasClipping,
|
||||||
|
clipping_ts& clipping)
|
||||||
{
|
{
|
||||||
float posDrawX = textPos.x;
|
float posDrawX = textPos.x;
|
||||||
|
|
||||||
@ -347,8 +351,55 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
|||||||
|
|
||||||
|
|
||||||
// Clipping and drawing area
|
// 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
|
if( dxB <= dxA
|
||||||
|| dyD >= dyC) {
|
|| dyD <= dyC) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
} else {
|
} else {
|
||||||
/* Bitmap position
|
/* Bitmap position
|
||||||
@ -416,7 +467,7 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
|||||||
coord.PushBack(bitmapDrawPos[0]);
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
coord.PushBack(bitmapDrawPos[2]);
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
coord.PushBack(bitmapDrawPos[3]);
|
coord.PushBack(bitmapDrawPos[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
posDrawX += m_listElement[charIndex].property.m_advance.x;
|
posDrawX += m_listElement[charIndex].property.m_advance.x;
|
||||||
|
@ -57,11 +57,15 @@ namespace ewol
|
|||||||
int32_t Draw(Vector2D<float> textPos,
|
int32_t Draw(Vector2D<float> textPos,
|
||||||
const etk::UString& unicodeString,
|
const etk::UString& unicodeString,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
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,
|
int32_t Draw(Vector2D<float> textPos,
|
||||||
const uniChar_t unicodeChar,
|
const uniChar_t unicodeChar,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
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 etk::UString & unicodeString);
|
||||||
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
||||||
// TODO : Remove this element, it is stupid ...
|
// 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 nbElementInTheArray = m_coord.Size();
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (true==m_hasClipping) {
|
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex, m_hasClipping, m_clipping);
|
||||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
|
||||||
} else {
|
|
||||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
|
||||||
}
|
|
||||||
// set the color ...
|
// set the color ...
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
m_coordColor.PushBack(m_color);
|
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 nbElementInTheArray = m_coord.Size();
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (true==m_hasClipping) {
|
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex, m_hasClipping, m_clipping);
|
||||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
|
||||||
} else {
|
|
||||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
|
||||||
}
|
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
m_coordColor.PushBack(m_color);
|
m_coordColor.PushBack(m_color);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user