Add clipping methode for the Rectangle diaplay
This commit is contained in:
parent
2650ff1e5a
commit
d8b9535016
@ -100,6 +100,14 @@ extern "C"
|
||||
etkFloat_t u;
|
||||
etkFloat_t v;
|
||||
}texCoord_ts;
|
||||
|
||||
typedef struct {
|
||||
etkFloat_t x;
|
||||
etkFloat_t y;
|
||||
etkFloat_t w;
|
||||
etkFloat_t h;
|
||||
}clipping_ts;
|
||||
|
||||
typedef struct {
|
||||
etkFloat_t red;
|
||||
etkFloat_t green;
|
||||
|
@ -96,8 +96,7 @@ namespace ewol
|
||||
etk::VectorType<texCoord_ts> & coordTex);
|
||||
int32_t DrawText(int32_t fontID,
|
||||
coord2D_ts textPos,
|
||||
coord2D_ts& drawOrigin,
|
||||
coord2D_ts& drawSize,
|
||||
clipping_ts & drawClipping,
|
||||
const uniChar_t * unicodeString,
|
||||
uint32_t & fontTextureId,
|
||||
etk::VectorType<coord2D_ts> & coord,
|
||||
|
@ -675,8 +675,7 @@ int32_t ewol::DrawText(int32_t fontID,
|
||||
|
||||
int32_t ewol::DrawText(int32_t fontID,
|
||||
coord2D_ts textPos,
|
||||
coord2D_ts & drawOrigin,
|
||||
coord2D_ts & drawSize,
|
||||
clipping_ts & drawClipping,
|
||||
const uniChar_t * unicodeString,
|
||||
uint32_t & fontTextureId,
|
||||
etk::VectorType<coord2D_ts> & coord,
|
||||
@ -735,32 +734,28 @@ int32_t ewol::DrawText(int32_t fontID,
|
||||
|
||||
|
||||
// Clipping and drawing area
|
||||
coord2D_ts drawStart = drawOrigin;
|
||||
coord2D_ts drawStop;
|
||||
drawStop.x = drawOrigin.x + drawSize.x;
|
||||
drawStop.y = drawOrigin.y + drawSize.y;
|
||||
// TODO : clipping in Y too ...
|
||||
if( dxB < drawStart.x
|
||||
|| dxA > drawStop.x)
|
||||
if( dxB < drawClipping.x
|
||||
|| dxA > drawClipping.x + drawClipping.w)
|
||||
{
|
||||
// Nothing to diplay ...
|
||||
} else {
|
||||
// generata positions...
|
||||
etkFloat_t TexSizeX = tuB - tuA;
|
||||
if (dxA < drawStart.x) {
|
||||
if (dxA < drawClipping.x) {
|
||||
// clip display
|
||||
etkFloat_t drawSize = drawStart.x - dxA;
|
||||
etkFloat_t drawSize = drawClipping.x - dxA;
|
||||
// Update element start display
|
||||
dxA = drawStart.x;
|
||||
dxA = drawClipping.x;
|
||||
etkFloat_t addElement = TexSizeX * drawSize / listOfElement[charIndex].size.x;
|
||||
// update texture start X Pos
|
||||
tuA += addElement;
|
||||
}
|
||||
if (dxB > drawStop.x) {
|
||||
if (dxB > drawClipping.x + drawClipping.w) {
|
||||
// clip display
|
||||
etkFloat_t drawSize = dxB - drawStop.x;
|
||||
etkFloat_t drawSize = dxB - (drawClipping.x + drawClipping.w);
|
||||
// Update element start display
|
||||
dxB = drawStop.x;
|
||||
dxB = drawClipping.x + drawClipping.w;
|
||||
etkFloat_t addElement = TexSizeX * drawSize / listOfElement[charIndex].size.x;
|
||||
// update texture start X Pos
|
||||
tuB -= addElement;
|
||||
|
@ -450,6 +450,47 @@ void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w,
|
||||
SetPoint(x , y + h);
|
||||
}
|
||||
|
||||
|
||||
void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, clipping_ts& drawClipping)
|
||||
{
|
||||
ResetCount();
|
||||
|
||||
/* Bitmap position
|
||||
* xA xB
|
||||
* yC *------*
|
||||
* | |
|
||||
* | |
|
||||
* yD *------*
|
||||
*/
|
||||
etkFloat_t dxA = x;
|
||||
etkFloat_t dxB = y;
|
||||
etkFloat_t dyC = x + w;
|
||||
etkFloat_t dyD = y + h;
|
||||
|
||||
|
||||
if (dxA < drawClipping.x) {
|
||||
dxA = drawClipping.x;
|
||||
}
|
||||
if (dxB > drawClipping.x + drawClipping.w) {
|
||||
dxB = drawClipping.x + drawClipping.w;
|
||||
}
|
||||
if (dyC < drawClipping.y) {
|
||||
dyC = drawClipping.y;
|
||||
}
|
||||
if (dyD > drawClipping.y + drawClipping.h) {
|
||||
dyD = drawClipping.y + drawClipping.h;
|
||||
}
|
||||
|
||||
|
||||
SetPoint(dxA, dyD);
|
||||
SetPoint(dxA, dxB);
|
||||
SetPoint(dyC, dxB);
|
||||
|
||||
SetPoint(dyC, dxB);
|
||||
SetPoint(dyC, dyD);
|
||||
SetPoint(dxA, dyD);
|
||||
}
|
||||
|
||||
void ewol::OObject2DColored::RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness)
|
||||
{
|
||||
// TODO : This did not manage the thickness of the line ...
|
||||
|
@ -51,6 +51,7 @@ namespace ewol {
|
||||
void SetPoint(etkFloat_t x, etkFloat_t y);
|
||||
void Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey, etkFloat_t thickness);
|
||||
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h);
|
||||
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, clipping_ts& drawClipping);
|
||||
//void RectangleAngle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t angle);
|
||||
void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness);
|
||||
//void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness, etkFloat_t angle);
|
||||
|
@ -111,7 +111,7 @@ int32_t ewol::OObject2DTextColored::TextAdd(etkFloat_t x, etkFloat_t y, const ch
|
||||
return size;
|
||||
}
|
||||
|
||||
int32_t ewol::OObject2DTextColored::TextAdd(coord2D_ts textPos, coord2D_ts drawOrigin, coord2D_ts drawSize, const uniChar_t* unicodeString)
|
||||
int32_t ewol::OObject2DTextColored::TextAdd(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t* unicodeString)
|
||||
{
|
||||
m_FontTextureId = 0;
|
||||
if (m_FontId == -1) {
|
||||
@ -119,7 +119,7 @@ int32_t ewol::OObject2DTextColored::TextAdd(coord2D_ts textPos, coord2D_ts drawO
|
||||
return 0;
|
||||
}
|
||||
int32_t nbElementInTheArray = m_coord.Size();
|
||||
int32_t size = ewol::DrawText(m_FontId, textPos, drawOrigin, drawSize, unicodeString, m_FontTextureId, m_coord, m_coordTex);
|
||||
int32_t size = ewol::DrawText(m_FontId, textPos, drawClipping, unicodeString, m_FontTextureId, m_coord, m_coordTex);
|
||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||
m_coordColor.PushBack(m_color);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace ewol {
|
||||
// set a specific text
|
||||
int32_t Text(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX);
|
||||
int32_t TextAdd(etkFloat_t x, etkFloat_t y, const char* utf8String, int32_t clippingPositionX);
|
||||
int32_t TextAdd(coord2D_ts textPos, coord2D_ts drawOrigin, coord2D_ts drawSize, const uniChar_t* unicodeString);
|
||||
int32_t TextAdd(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t* unicodeString);
|
||||
protected:
|
||||
int32_t m_FontId; //!< font internal ID
|
||||
color_ts m_color; //!< tmp text color ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user