[DEV] Basic display of the compositing font (justify availlable)
This commit is contained in:
parent
303b08da9d
commit
640810ee8d
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
|||||||
Subproject commit c35e883279632dda8743a3d1f9bbe5ac2748146f
|
Subproject commit 1f9db2550cc2a08f9118ac1b2686f17ebd1e3a73
|
@ -30,17 +30,23 @@ void ewol::Compositing::ResetMatrix(void)
|
|||||||
|
|
||||||
void ewol::Compositing::Tranlate(etk::Vector3D<float> vect)
|
void ewol::Compositing::Tranlate(etk::Vector3D<float> vect)
|
||||||
{
|
{
|
||||||
m_matrixApply *= etk::matrix::Translate(vect.x, vect.y, vect.z);
|
m_matrixApply *= etk::matrix::Translate(vect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Compositing::Rotate(etk::Vector3D<float> vect)
|
void ewol::Compositing::Rotate(etk::Vector3D<float> vect, float angle)
|
||||||
{
|
{
|
||||||
m_matrixApply *= etk::matrix::rotate(vect.x, vect.y, vect.z);
|
m_matrixApply *= etk::matrix::Rotate(vect, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Compositing::Scale(etk::Vector3D<float> vect)
|
void ewol::Compositing::Scale(etk::Vector3D<float> vect)
|
||||||
{
|
{
|
||||||
m_matrixApply *= etk::matrix::Scale(vect.x, vect.y, vect.z);
|
m_matrixApply *= etk::matrix::Scale(vect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Compositing::Clear(void)
|
||||||
|
{
|
||||||
|
m_matrixApply.Identity();
|
||||||
}
|
}
|
@ -31,7 +31,11 @@ namespace ewol
|
|||||||
/**
|
/**
|
||||||
* @brief Virtal pure function that request the draw of all openGl elements
|
* @brief Virtal pure function that request the draw of all openGl elements
|
||||||
*/
|
*/
|
||||||
void virtual Draw(void)=0;
|
virtual void Draw(void)=0;
|
||||||
|
/**
|
||||||
|
* @brief Clear alll tre registered element in the current element
|
||||||
|
*/
|
||||||
|
virtual void Clear(void);
|
||||||
/**
|
/**
|
||||||
* @brief Reset to the eye matrix the openGL mouving system
|
* @brief Reset to the eye matrix the openGL mouving system
|
||||||
*/
|
*/
|
||||||
@ -45,7 +49,7 @@ namespace ewol
|
|||||||
* @brief Rotate the curent display of this element
|
* @brief Rotate the curent display of this element
|
||||||
* @param[in] vect The rotation vector to apply at the transformation matrix
|
* @param[in] vect The rotation vector to apply at the transformation matrix
|
||||||
*/
|
*/
|
||||||
void Rotate(etk::Vector3D<float> vect);
|
void Rotate(etk::Vector3D<float> vect, float angle);
|
||||||
/**
|
/**
|
||||||
* @brief Scale the current diaplsy of this element
|
* @brief Scale the current diaplsy of this element
|
||||||
* @param[in] vect The scaling vector to apply at the transformation matrix
|
* @param[in] vect The scaling vector to apply at the transformation matrix
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/compositing/Text.h>
|
#include <ewol/compositing/Text.h>
|
||||||
|
#include <ewol/font/FontManager.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -23,23 +24,55 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ewol::Text::Text(void) :
|
ewol::Text::Text(void) :
|
||||||
|
m_position(0.0, 0.0, 0.0),
|
||||||
|
m_clippingPosition(0.0, 0.0, 0.0),
|
||||||
|
m_clippingSize(0.0, 0.0, 0.0),
|
||||||
|
m_clippingEnable(false),
|
||||||
|
m_color(draw::color::black),
|
||||||
|
m_colorBg(draw::color::none),
|
||||||
|
m_mode(ewol::font::Regular),
|
||||||
|
m_kerning(true),
|
||||||
|
m_distanceField(false),
|
||||||
|
m_previousCharcode(0),
|
||||||
|
m_startTextpos(0),
|
||||||
|
m_stopTextPos(0),
|
||||||
|
m_alignement(ewol::Text::alignDisable),
|
||||||
m_GLprogram(NULL),
|
m_GLprogram(NULL),
|
||||||
|
m_GLPosition(-1),
|
||||||
|
m_GLMatrix(-1),
|
||||||
|
m_GLColor(-1),
|
||||||
|
m_GLtexture(-1),
|
||||||
|
m_GLtexID(-1),
|
||||||
m_font(NULL)
|
m_font(NULL)
|
||||||
{
|
{
|
||||||
m_color = draw::color::black;
|
SetFont(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize());
|
||||||
m_colorBg = draw::color::none;
|
|
||||||
SetFontProperty(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize());
|
|
||||||
LoadProgram();
|
LoadProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ewol::Text::Text(etk::UString fontName, int32_t fontSize) :
|
ewol::Text::Text(etk::UString fontName, int32_t fontSize) :
|
||||||
|
m_position(0.0, 0.0, 0.0),
|
||||||
|
m_clippingPosition(0.0, 0.0, 0.0),
|
||||||
|
m_clippingSize(0.0, 0.0, 0.0),
|
||||||
|
m_clippingEnable(false),
|
||||||
|
m_color(draw::color::black),
|
||||||
|
m_colorBg(draw::color::none),
|
||||||
|
m_mode(ewol::font::Regular),
|
||||||
|
m_kerning(true),
|
||||||
|
m_distanceField(false),
|
||||||
|
m_previousCharcode(0),
|
||||||
|
m_startTextpos(0),
|
||||||
|
m_stopTextPos(0),
|
||||||
|
m_alignement(ewol::Text::alignDisable),
|
||||||
m_GLprogram(NULL),
|
m_GLprogram(NULL),
|
||||||
|
m_GLPosition(-1),
|
||||||
|
m_GLMatrix(-1),
|
||||||
|
m_GLColor(-1),
|
||||||
|
m_GLtexture(-1),
|
||||||
|
m_GLtexID(-1),
|
||||||
m_font(NULL)
|
m_font(NULL)
|
||||||
{
|
{
|
||||||
m_color = draw::color::black;
|
SetFont(fontName, fontSize);
|
||||||
m_colorBg = draw::color::none;
|
|
||||||
SetFontProperty(fontName, fontSize);
|
|
||||||
LoadProgram();
|
LoadProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +87,7 @@ ewol::Text::~Text(void)
|
|||||||
ewol::resource::Release(m_GLprogram);
|
ewol::resource::Release(m_GLprogram);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadProgram(void)
|
void ewol::Text::LoadProgram(void)
|
||||||
{
|
{
|
||||||
etk::UString tmpString("DATA:text.prog");
|
etk::UString tmpString("DATA:text.prog");
|
||||||
// get the shader resource :
|
// get the shader resource :
|
||||||
@ -85,7 +118,7 @@ void ewol::Text::Draw(void)
|
|||||||
}
|
}
|
||||||
m_GLprogram->Use();
|
m_GLprogram->Use();
|
||||||
// set Matrix : translation/positionMatrix
|
// set Matrix : translation/positionMatrix
|
||||||
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
|
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix()*m_matrixApply;
|
||||||
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
// TextureID
|
// TextureID
|
||||||
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
|
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
|
||||||
@ -103,45 +136,65 @@ void ewol::Text::Draw(void)
|
|||||||
|
|
||||||
void ewol::Text::Clear(void)
|
void ewol::Text::Clear(void)
|
||||||
{
|
{
|
||||||
|
// call upper class
|
||||||
|
ewol::Compositing::Clear();
|
||||||
|
// Reset Buffer :
|
||||||
m_coord.Clear();
|
m_coord.Clear();
|
||||||
m_coordTex.Clear();
|
m_coordTex.Clear();
|
||||||
m_coordColor.Clear();
|
m_coordColor.Clear();
|
||||||
|
// Reset temporal variables :
|
||||||
|
m_position = etk::Vector3D<float>(0.0, 0.0, 0.0);
|
||||||
|
m_clippingPosition = etk::Vector3D<float>(0.0, 0.0, 0.0);
|
||||||
|
m_clippingSize = etk::Vector3D<float>(0.0, 0.0, 0.0);
|
||||||
|
m_clippingEnable = false;
|
||||||
|
m_color = draw::color::black;
|
||||||
|
m_colorBg = draw::color::none;
|
||||||
|
m_mode = ewol::font::Regular;
|
||||||
|
m_kerning = false;
|
||||||
|
m_previousCharcode = 0;
|
||||||
|
m_startTextpos = 0;
|
||||||
|
m_stopTextPos = 0;
|
||||||
|
m_alignement = ewol::Text::alignDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetPos(etk::Vector3D<float> pos)
|
void ewol::Text::SetPos(etk::Vector3D<float> pos)
|
||||||
{
|
{
|
||||||
|
m_position = pos;
|
||||||
|
m_previousCharcode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetRelPos(etk::Vector3D<float> pos)
|
void ewol::Text::SetRelPos(etk::Vector3D<float> pos)
|
||||||
{
|
{
|
||||||
|
m_position += pos;
|
||||||
|
m_previousCharcode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetColor(draw::Color color)
|
void ewol::Text::SetColor(draw::Color color)
|
||||||
{
|
{
|
||||||
|
m_color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetColorBG(draw::Color color)
|
void ewol::Text::SetColorBG(draw::Color color)
|
||||||
{
|
{
|
||||||
|
m_colorBg = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetClipping(etk::Vector3D<float> pos, etk::Vector3D<float> width)
|
void ewol::Text::SetClipping(etk::Vector3D<float> pos, etk::Vector3D<float> width)
|
||||||
{
|
{
|
||||||
|
m_clippingPosition = pos;
|
||||||
|
m_clippingSize = width;
|
||||||
|
m_clippingEnable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetClippingMode(bool newMode)
|
void ewol::Text::SetClippingMode(bool newMode)
|
||||||
{
|
{
|
||||||
|
m_clippingEnable = newMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -186,75 +239,379 @@ void ewol::Text::SetFont(etk::UString fontName, int32_t fontSize)
|
|||||||
|
|
||||||
void ewol::Text::SetFontMode(ewol::font::mode_te mode)
|
void ewol::Text::SetFontMode(ewol::font::mode_te mode)
|
||||||
{
|
{
|
||||||
|
m_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetKerningMode(bool newMode)
|
void ewol::Text::SetKerningMode(bool newMode)
|
||||||
{
|
{
|
||||||
|
m_kerning = newMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetDistanceFieldMode(bool newMode)
|
void ewol::Text::SetDistanceFieldMode(bool newMode)
|
||||||
{
|
{
|
||||||
|
m_distanceField = newMode;
|
||||||
|
EWOL_TODO("The Distance field mode is not availlable for now ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::Print(etk::UString& text)
|
void ewol::Text::Print(const etk::UString& text)
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::PrintDecorated(etk::UString& text)
|
|
||||||
{
|
{
|
||||||
if (m_font == NULL) {
|
if (m_font == NULL) {
|
||||||
EWOL_ERROR("Font Id is not corectly defined");
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
int32_t nbElementInTheArray = m_coord.Size();
|
switch(m_alignement)
|
||||||
int32_t size = 0;
|
|
||||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex, m_displayMode, m_hasClipping, m_clipping, displayMode);
|
|
||||||
// set the color ...
|
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
|
||||||
m_coordColor.PushBack(m_color);
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::Print(etk::UString& text, etk::Vector<TextDecoration>& decoration)
|
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
|
case ewol::Text::alignDisable:
|
||||||
|
for(int32_t iii=0; iii<text.Size(); iii++) {
|
||||||
|
Print(text[iii]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ewol::Text::alignJustify:
|
||||||
|
{
|
||||||
|
float basicSpaceWidth = CalculateSize(' ').x;
|
||||||
|
int32_t currentId = 0;
|
||||||
|
int32_t stop;
|
||||||
|
int32_t space;
|
||||||
|
int32_t freeSpace;
|
||||||
|
while (currentId < text.Size()) {
|
||||||
|
bool needNoJustify = ExtrapolateLastId(text, currentId, stop, space, freeSpace);
|
||||||
|
|
||||||
|
float interpolation = basicSpaceWidth;
|
||||||
|
if (needNoJustify == false) {
|
||||||
|
interpolation += (float)freeSpace / (float)(space-1);
|
||||||
|
}
|
||||||
|
for(int32_t iii=currentId; iii<stop && iii<text.Size(); iii++) {
|
||||||
|
if (text[iii] == (uniChar_t)' ') {
|
||||||
|
// Must generate a dynamic space :
|
||||||
|
SetPos(etk::Vector3D<float>(m_position.x + interpolation,
|
||||||
|
m_position.y,
|
||||||
|
m_position.z) );
|
||||||
|
} else {
|
||||||
|
Print(text[iii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentId == stop) {
|
||||||
|
currentId++;
|
||||||
|
} else if( text[stop] == (uniChar_t)' '
|
||||||
|
|| text[stop] == (uniChar_t)'\n') {
|
||||||
|
currentId = stop+1;
|
||||||
|
} else {
|
||||||
|
currentId = stop;
|
||||||
|
}
|
||||||
|
// Reset position :
|
||||||
|
SetPos(etk::Vector3D<float>(m_startTextpos,
|
||||||
|
(float)(m_position.y - m_font->GetHeight(m_mode)),
|
||||||
|
m_position.z) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::Print(uniChar_t charcode)
|
void ewol::Text::PrintDecorated(const etk::UString& text)
|
||||||
|
{
|
||||||
|
EWOL_TODO("The Decorated print is not supported now ...");
|
||||||
|
Print(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoration>& decoration)
|
||||||
|
{
|
||||||
|
EWOL_TODO("The Advenced print is not supported now ...");
|
||||||
|
Print(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::Print(const uniChar_t charcode)
|
||||||
{
|
{
|
||||||
if (m_font == NULL) {
|
if (m_font == NULL) {
|
||||||
EWOL_ERROR("Font Id is not corectly defined");
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
int32_t nbElementInTheArray = m_coord.Size();
|
// get a pointer on the glyph property :
|
||||||
int32_t size = 0;
|
ewol::GlyphProperty * myGlyph = m_font->GetGlyphPointer(charcode, m_mode);
|
||||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex, m_displayMode, m_hasClipping, m_clipping, displayMode);
|
int32_t fontSize = m_font->GetFontSize();
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
int32_t fontHeigh = m_font->GetHeight(m_mode);
|
||||||
|
|
||||||
|
// Get the kerning ofset :
|
||||||
|
float kerningOffset = 0.0;
|
||||||
|
if (true==m_kerning) {
|
||||||
|
kerningOffset = myGlyph->KerningGet(m_previousCharcode);
|
||||||
|
if (kerningOffset != 0) {
|
||||||
|
//EWOL_DEBUG("Kerning between : '" << (char)m_previousCharcode << "'&'" << (char)myGlyph->m_UVal << "' value : " << kerningOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 0x01 == 0x20 == ' ';
|
||||||
|
if (charcode != 0x01) {
|
||||||
|
/* Bitmap position
|
||||||
|
* xA xB
|
||||||
|
* yC *------*
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* yD *------*
|
||||||
|
*/
|
||||||
|
float dxA = m_position.x + myGlyph->m_bearing.x + kerningOffset;
|
||||||
|
float dxB = dxA + myGlyph->m_sizeTexture.x;
|
||||||
|
float dyC = m_position.y + myGlyph->m_bearing.y + fontHeigh - fontSize;
|
||||||
|
float dyD = dyC - myGlyph->m_sizeTexture.y;
|
||||||
|
|
||||||
|
float tuA = myGlyph->m_texturePosStart.u;
|
||||||
|
float tuB = myGlyph->m_texturePosStop.u;
|
||||||
|
float tvC = myGlyph->m_texturePosStart.v;
|
||||||
|
float tvD = myGlyph->m_texturePosStop.v;
|
||||||
|
|
||||||
|
|
||||||
|
// Clipping and drawing area
|
||||||
|
/*
|
||||||
|
if( true == hasClipping
|
||||||
|
&& ( 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)myGlyph->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)myGlyph->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)myGlyph->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)myGlyph->m_sizeTexture.x;
|
||||||
|
// update texture start X Pos
|
||||||
|
tvD -= addElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if( dxB <= dxA
|
||||||
|
|| dyD >= dyC) {
|
||||||
|
// nothing to do ...
|
||||||
|
} else {
|
||||||
|
/* Bitmap position
|
||||||
|
* 0------1
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
etk::Vector2D<int32_t> bitmapDrawPos[4];
|
||||||
|
bitmapDrawPos[0].x = (int32_t)dxA;
|
||||||
|
bitmapDrawPos[1].x = (int32_t)dxB;
|
||||||
|
bitmapDrawPos[2].x = (int32_t)dxB;
|
||||||
|
bitmapDrawPos[3].x = (int32_t)dxA;
|
||||||
|
|
||||||
|
bitmapDrawPos[0].y = (int32_t)dyC;
|
||||||
|
bitmapDrawPos[1].y = (int32_t)dyC;
|
||||||
|
bitmapDrawPos[2].y = (int32_t)dyD;
|
||||||
|
bitmapDrawPos[3].y = (int32_t)dyD;
|
||||||
|
/* texture Position :
|
||||||
|
* 0------1
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
texCoord_ts texturePos[4];
|
||||||
|
texturePos[0].u = tuA+m_mode;
|
||||||
|
texturePos[1].u = tuB+m_mode;
|
||||||
|
texturePos[2].u = tuB+m_mode;
|
||||||
|
texturePos[3].u = tuA+m_mode;
|
||||||
|
|
||||||
|
texturePos[0].v = tvC;
|
||||||
|
texturePos[1].v = tvC;
|
||||||
|
texturePos[2].v = tvD;
|
||||||
|
texturePos[3].v = tvD;
|
||||||
|
|
||||||
|
// NOTE : Android does not support the Quads elements ...
|
||||||
|
/* Step 1 :
|
||||||
|
* ********
|
||||||
|
* ******
|
||||||
|
* ****
|
||||||
|
* **
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
m_coordTex.PushBack(texturePos[0]);
|
||||||
|
m_coordTex.PushBack(texturePos[1]);
|
||||||
|
m_coordTex.PushBack(texturePos[2]);
|
||||||
|
// set display positions :
|
||||||
|
m_coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
m_coord.PushBack(bitmapDrawPos[1]);
|
||||||
|
m_coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
// set the color
|
||||||
|
m_coordColor.PushBack(m_color);
|
||||||
|
m_coordColor.PushBack(m_color);
|
||||||
|
m_coordColor.PushBack(m_color);
|
||||||
|
|
||||||
|
/* Step 2 :
|
||||||
|
*
|
||||||
|
* **
|
||||||
|
* ****
|
||||||
|
* ******
|
||||||
|
* ********
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
m_coordTex.PushBack(texturePos[0]);
|
||||||
|
m_coordTex.PushBack(texturePos[2]);
|
||||||
|
m_coordTex.PushBack(texturePos[3]);
|
||||||
|
// set display positions :
|
||||||
|
m_coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
m_coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
m_coord.PushBack(bitmapDrawPos[3]);
|
||||||
|
// set the color
|
||||||
|
m_coordColor.PushBack(m_color);
|
||||||
|
m_coordColor.PushBack(m_color);
|
||||||
m_coordColor.PushBack(m_color);
|
m_coordColor.PushBack(m_color);
|
||||||
}
|
}
|
||||||
return size;
|
//}
|
||||||
|
}
|
||||||
|
// move the position :
|
||||||
|
m_position.x += myGlyph->m_advance.x + kerningOffset;
|
||||||
|
// Register the previous character
|
||||||
|
m_previousCharcode = charcode;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::SetTextAlignement(float startTextpos, float stopTextPos, aligneMode_te alignement)
|
void ewol::Text::SetTextAlignement(float startTextpos, float stopTextPos, aligneMode_te alignement)
|
||||||
{
|
{
|
||||||
|
m_startTextpos = startTextpos;
|
||||||
|
m_stopTextPos = stopTextPos;
|
||||||
|
m_alignement = alignement;
|
||||||
|
if (m_startTextpos >= m_stopTextPos) {
|
||||||
|
EWOL_ERROR("Request allignement with Borne position error : " << startTextpos << " => " << stopTextPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Text::DisableAlignement(void)
|
void ewol::Text::DisableAlignement(void)
|
||||||
{
|
{
|
||||||
|
m_alignement = ewol::Text::alignDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
etk::Vector3D<float> ewol::Text::CalculateSize(const etk::UString& text)
|
||||||
|
{
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
|
return etk::Vector3D<float>(0,0,0);
|
||||||
|
}
|
||||||
|
etk::Vector3D<float> outputSize(0, 0, 0);
|
||||||
|
for(int32_t iii=0; iii<text.Size(); iii++) {
|
||||||
|
etk::Vector3D<float> tmpp = CalculateSize(text[iii]);
|
||||||
|
if (outputSize.y == 0) {
|
||||||
|
outputSize.y += tmpp.y;
|
||||||
|
}
|
||||||
|
outputSize.x += tmpp.x;
|
||||||
|
}
|
||||||
|
return outputSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Vector3D<float> ewol::Text::CalculateSize(const uniChar_t charcode)
|
||||||
|
{
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
|
return etk::Vector3D<float>(0,0,0);
|
||||||
|
}
|
||||||
|
// get a pointer on the glyph property :
|
||||||
|
ewol::GlyphProperty * myGlyph = m_font->GetGlyphPointer(charcode, m_mode);
|
||||||
|
int32_t fontHeigh = m_font->GetHeight(m_mode);
|
||||||
|
|
||||||
|
// Get the kerning ofset :
|
||||||
|
float kerningOffset = 0.0;
|
||||||
|
if (true==m_kerning) {
|
||||||
|
kerningOffset = myGlyph->KerningGet(m_previousCharcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::Vector3D<float> outputSize((float)(myGlyph->m_advance.x + kerningOffset),
|
||||||
|
(float)(fontHeigh),
|
||||||
|
(float)(0.0));
|
||||||
|
// Register the previous character
|
||||||
|
m_previousCharcode = charcode;
|
||||||
|
return outputSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ewol::Text::ExtrapolateLastId(const etk::UString& text, const int32_t start, int32_t& stop, int32_t& space, int32_t& freeSpace)
|
||||||
|
{
|
||||||
|
// store previous :
|
||||||
|
uniChar_t storePrevious = m_previousCharcode;
|
||||||
|
|
||||||
|
stop = text.Size();
|
||||||
|
space = 0;
|
||||||
|
|
||||||
|
int32_t lastSpacePosition = start;
|
||||||
|
int32_t lastSpacefreeSize;
|
||||||
|
|
||||||
|
float endPos = m_position.x;
|
||||||
|
bool endOfLine = false;
|
||||||
|
for (int32_t iii=start; iii<text.Size(); iii++) {
|
||||||
|
etk::Vector3D<float> tmpSize = CalculateSize(text[iii]);
|
||||||
|
// check oveflow :
|
||||||
|
if (endPos + tmpSize.x > m_stopTextPos) {
|
||||||
|
stop = iii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// update local size :
|
||||||
|
endPos += tmpSize.x;
|
||||||
|
// save number of space :
|
||||||
|
if (text[iii] == (uniChar_t)' ') {
|
||||||
|
space++;
|
||||||
|
lastSpacePosition = iii;
|
||||||
|
lastSpacefreeSize = m_stopTextPos - endPos;
|
||||||
|
} else if (text[iii] == (uniChar_t)'\n') {
|
||||||
|
stop = iii;
|
||||||
|
endOfLine = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
freeSpace = m_stopTextPos - endPos;
|
||||||
|
// retore previous :
|
||||||
|
m_previousCharcode = storePrevious;
|
||||||
|
// need to align left or right ...
|
||||||
|
if(stop == text.Size()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (endOfLine) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (space == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
stop = lastSpacePosition;
|
||||||
|
freeSpace = lastSpacefreeSize;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ namespace ewol
|
|||||||
|
|
||||||
class Text : public ewol::Compositing
|
class Text : public ewol::Compositing
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
typedef enum {
|
typedef enum {
|
||||||
alignDisable,
|
alignDisable,
|
||||||
alignRight,
|
alignRight,
|
||||||
@ -46,6 +47,10 @@ namespace ewol
|
|||||||
draw::Color m_color;
|
draw::Color m_color;
|
||||||
draw::Color m_colorBg;
|
draw::Color m_colorBg;
|
||||||
// font property :
|
// font property :
|
||||||
|
ewol::font::mode_te m_mode;
|
||||||
|
bool m_kerning;
|
||||||
|
bool m_distanceField;
|
||||||
|
uniChar_t m_previousCharcode;
|
||||||
// alignement propoerty
|
// alignement propoerty
|
||||||
float m_startTextpos;
|
float m_startTextpos;
|
||||||
float m_stopTextPos;
|
float m_stopTextPos;
|
||||||
@ -55,7 +60,6 @@ namespace ewol
|
|||||||
int32_t m_GLPosition;
|
int32_t m_GLPosition;
|
||||||
int32_t m_GLMatrix;
|
int32_t m_GLMatrix;
|
||||||
int32_t m_GLColor;
|
int32_t m_GLColor;
|
||||||
int32_t m_GLtextMode;
|
|
||||||
int32_t m_GLtexture;
|
int32_t m_GLtexture;
|
||||||
int32_t m_GLtexID;
|
int32_t m_GLtexID;
|
||||||
// Font resource :
|
// Font resource :
|
||||||
@ -162,7 +166,7 @@ namespace ewol
|
|||||||
* @brief Display a compleat string in the current element.
|
* @brief Display a compleat string in the current element.
|
||||||
* @param[in] text The string to display.
|
* @param[in] text The string to display.
|
||||||
*/
|
*/
|
||||||
void Print(etk::UString& text);
|
void Print(const etk::UString& text);
|
||||||
/**
|
/**
|
||||||
* @brief Display a compleat string in the current element with the generic decoration specification.
|
* @brief Display a compleat string in the current element with the generic decoration specification.
|
||||||
* \<b\> ... \</b\> For bold text.
|
* \<b\> ... \</b\> For bold text.
|
||||||
@ -174,18 +178,18 @@ namespace ewol
|
|||||||
* \<justify\> ... \</justify\> To align justify.
|
* \<justify\> ... \</justify\> To align justify.
|
||||||
* @param[in] text The string to display.
|
* @param[in] text The string to display.
|
||||||
*/
|
*/
|
||||||
void PrintDecorated(etk::UString& text);
|
void PrintDecorated(const etk::UString& text);
|
||||||
/**
|
/**
|
||||||
* @brief Display a compleat string in the current element whith specific decorations (advence mode).
|
* @brief Display a compleat string in the current element whith specific decorations (advence mode).
|
||||||
* @param[in] text The string to display.
|
* @param[in] text The string to display.
|
||||||
* @param[in] decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get)
|
* @param[in] decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get)
|
||||||
*/
|
*/
|
||||||
void Print(etk::UString& text, etk::Vector<TextDecoration>& decoration);
|
void Print(const etk::UString& text, const etk::Vector<TextDecoration>& decoration);
|
||||||
/**
|
/**
|
||||||
* @brief Display the current char in the current element (note that the kerning is availlable if the position is not changed)
|
* @brief Display the current char in the current element (note that the kerning is availlable if the position is not changed)
|
||||||
* @param[in] char that might be dispalyed
|
* @param[in] char that might be dispalyed
|
||||||
*/
|
*/
|
||||||
void Print(uniChar_t charcode);
|
void Print(const uniChar_t charcode);
|
||||||
/**
|
/**
|
||||||
* @brief This generate the possibility to generate the big text property
|
* @brief This generate the possibility to generate the big text property
|
||||||
* @param[in] startTextpos The x text start position of the display.
|
* @param[in] startTextpos The x text start position of the display.
|
||||||
@ -198,6 +202,29 @@ namespace ewol
|
|||||||
* @brief Disable the alignement system
|
* @brief Disable the alignement system
|
||||||
*/
|
*/
|
||||||
void DisableAlignement(void);
|
void DisableAlignement(void);
|
||||||
|
/**
|
||||||
|
* @brief Calculate a theoric text size
|
||||||
|
* @param[in] text The string to calculate dimention.
|
||||||
|
* @return The theoric size used.
|
||||||
|
*/
|
||||||
|
etk::Vector3D<float> CalculateSize(const etk::UString& text);
|
||||||
|
/**
|
||||||
|
* @brief Calculate a theoric charcode size
|
||||||
|
* @param[in] charcode The µUnicode value to calculate dimention.
|
||||||
|
* @return The theoric size used.
|
||||||
|
*/
|
||||||
|
etk::Vector3D<float> CalculateSize(const uniChar_t charcode);
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Calculate the element number that is the first out the alignement range
|
||||||
|
* (start at the specify ID, and use start pos with current one)
|
||||||
|
* @param[in] text The string that might be parsed.
|
||||||
|
* @param[in] start The first elemnt that might be used to calculate.
|
||||||
|
* @param[out] stop The last Id availlable in the current string.
|
||||||
|
* @param[out] space Number of space in the string.
|
||||||
|
* @return true if need not alligne justify (end of string)
|
||||||
|
*/
|
||||||
|
bool ExtrapolateLastId(const etk::UString& text, const int32_t start, int32_t& stop, int32_t& space, int32_t& freeSpace);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,7 +98,9 @@ ewol::TexturedFont::TexturedFont(etk::UString fontName) :
|
|||||||
//EWOL_DEBUG(" file : " << output[iii]);
|
//EWOL_DEBUG(" file : " << output[iii]);
|
||||||
if( true == output[iii].EndWith(m_name+"-"+"bold"+".ttf", false)
|
if( true == output[iii].EndWith(m_name+"-"+"bold"+".ttf", false)
|
||||||
|| true == output[iii].EndWith(m_name+"-"+"b"+".ttf", false)
|
|| true == output[iii].EndWith(m_name+"-"+"b"+".ttf", false)
|
||||||
|
|| true == output[iii].EndWith(m_name+"-"+"bd"+".ttf", false)
|
||||||
|| true == output[iii].EndWith(m_name+"bold"+".ttf", false)
|
|| true == output[iii].EndWith(m_name+"bold"+".ttf", false)
|
||||||
|
|| true == output[iii].EndWith(m_name+"bd"+".ttf", false)
|
||||||
|| true == output[iii].EndWith(m_name+"b"+".ttf", false)) {
|
|| true == output[iii].EndWith(m_name+"b"+".ttf", false)) {
|
||||||
EWOL_INFO(" find Font [Bold] : " << output[iii]);
|
EWOL_INFO(" find Font [Bold] : " << output[iii]);
|
||||||
m_fileName[ewol::font::Bold] = output[iii];
|
m_fileName[ewol::font::Bold] = output[iii];
|
||||||
@ -502,3 +504,25 @@ etk::Vector2D<float> ewol::TexturedFont::GetSize(const uniChar_t unicodeChar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t ewol::TexturedFont::GetIndex(const uniChar_t charcode, const ewol::font::mode_te displayMode) const
|
||||||
|
{
|
||||||
|
if (charcode < 0x20) {
|
||||||
|
return 0;
|
||||||
|
} else if (charcode < 0x80) {
|
||||||
|
return charcode - 0x1F;
|
||||||
|
} else {
|
||||||
|
for (int32_t iii=0x80-0x20; iii < m_listElement[displayMode].Size(); iii++) {
|
||||||
|
if ((m_listElement[displayMode])[iii].m_UVal == charcode) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::GlyphProperty* ewol::TexturedFont::GetGlyphPointer(const uniChar_t charcode, const ewol::font::mode_te displayMode)
|
||||||
|
{
|
||||||
|
int32_t index = GetIndex(charcode, displayMode);
|
||||||
|
return &((m_listElement[displayMode])[index]);
|
||||||
|
}
|
||||||
|
@ -34,7 +34,9 @@ namespace ewol
|
|||||||
// ==> otherwise I can just generate italic ...
|
// ==> otherwise I can just generate italic ...
|
||||||
// ==> Bold is a little more complicated (maybe with the bordersize)
|
// ==> Bold is a little more complicated (maybe with the bordersize)
|
||||||
ewol::Font* m_font[4];
|
ewol::Font* m_font[4];
|
||||||
|
public:
|
||||||
etk::Vector<GlyphProperty> m_listElement[4];
|
etk::Vector<GlyphProperty> m_listElement[4];
|
||||||
|
private:
|
||||||
// for the texture generation :
|
// for the texture generation :
|
||||||
etk::Vector2D<int32_t> m_lastGlyphPos[4];
|
etk::Vector2D<int32_t> m_lastGlyphPos[4];
|
||||||
int32_t m_lastRawHeigh[4];
|
int32_t m_lastRawHeigh[4];
|
||||||
@ -44,6 +46,7 @@ namespace ewol
|
|||||||
virtual bool HasName(etk::UString& fileName);
|
virtual bool HasName(etk::UString& fileName);
|
||||||
const char* GetType(void) { return "ewol::TexturedFont"; };
|
const char* GetType(void) { return "ewol::TexturedFont"; };
|
||||||
int32_t getFontSize(void) { return m_size; };
|
int32_t getFontSize(void) { return m_size; };
|
||||||
|
// TODO : Remove : DEPRECATED ...
|
||||||
int32_t Draw(etk::Vector2D<float> textPos,
|
int32_t Draw(etk::Vector2D<float> textPos,
|
||||||
const etk::UString& unicodeString,
|
const etk::UString& unicodeString,
|
||||||
etk::Vector<etk::Vector2D<float> > & coord,
|
etk::Vector<etk::Vector2D<float> > & coord,
|
||||||
@ -53,6 +56,7 @@ namespace ewol
|
|||||||
clipping_ts& clipping,
|
clipping_ts& clipping,
|
||||||
ewol::font::mode_te displayMode);
|
ewol::font::mode_te displayMode);
|
||||||
|
|
||||||
|
// TODO : Remove : DEPRECATED ...
|
||||||
int32_t Draw(etk::Vector2D<float> textPos,
|
int32_t Draw(etk::Vector2D<float> textPos,
|
||||||
const uniChar_t unicodeChar,
|
const uniChar_t unicodeChar,
|
||||||
etk::Vector<etk::Vector2D<float> > & coord,
|
etk::Vector<etk::Vector2D<float> > & coord,
|
||||||
@ -63,6 +67,7 @@ namespace ewol
|
|||||||
ewol::font::mode_te displayMode,
|
ewol::font::mode_te displayMode,
|
||||||
const uniChar_t unicodeCharPrevious = 0);
|
const uniChar_t unicodeCharPrevious = 0);
|
||||||
|
|
||||||
|
// TODO : Remove : DEPRECATED ...
|
||||||
/**
|
/**
|
||||||
* @brief Get the size of the specified String
|
* @brief Get the size of the specified String
|
||||||
* @param[in] unicodeString The string that we might calculate the display size
|
* @param[in] unicodeString The string that we might calculate the display size
|
||||||
@ -72,6 +77,7 @@ namespace ewol
|
|||||||
etk::Vector2D<float> GetSize(const etk::UString & unicodeString,
|
etk::Vector2D<float> GetSize(const etk::UString & unicodeString,
|
||||||
const ewol::font::mode_te displayMode = ewol::font::Regular);
|
const ewol::font::mode_te displayMode = ewol::font::Regular);
|
||||||
|
|
||||||
|
// TODO : Remove : DEPRECATED ...
|
||||||
/**
|
/**
|
||||||
* @brief Get the size of the specified unicode value
|
* @brief Get the size of the specified unicode value
|
||||||
* @param[in] unicodeChar the char that might be displayed
|
* @param[in] unicodeChar the char that might be displayed
|
||||||
@ -82,6 +88,7 @@ namespace ewol
|
|||||||
etk::Vector2D<float> GetSize(const uniChar_t unicodeChar,
|
etk::Vector2D<float> GetSize(const uniChar_t unicodeChar,
|
||||||
const uniChar_t unicodeCharPrevious = 0,
|
const uniChar_t unicodeCharPrevious = 0,
|
||||||
const ewol::font::mode_te displayMode = ewol::font::Regular);
|
const ewol::font::mode_te displayMode = ewol::font::Regular);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the display height of this font
|
* @brief Get the display height of this font
|
||||||
* @param[in] displayMode Mode to display the currrent font
|
* @param[in] displayMode Mode to display the currrent font
|
||||||
@ -93,6 +100,20 @@ namespace ewol
|
|||||||
* @return Dimention of the font the user requested
|
* @return Dimention of the font the user requested
|
||||||
*/
|
*/
|
||||||
int32_t GetFontSize(void) { return m_size; };
|
int32_t GetFontSize(void) { return m_size; };
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of a unicode charcode
|
||||||
|
* @param[in] charcode The unicodeValue
|
||||||
|
* @param[in] displayMode Mode to display the currrent font
|
||||||
|
* @return The ID in the table (if it does not exist : return 0)
|
||||||
|
*/
|
||||||
|
int32_t GetIndex(const uniChar_t charcode, const ewol::font::mode_te displayMode) const;
|
||||||
|
/**
|
||||||
|
* @brief Get the pointer on the coresponding glyph
|
||||||
|
* @param[in] charcode The unicodeValue
|
||||||
|
* @param[in] displayMode Mode to display the currrent font
|
||||||
|
* @return The pointer on the glyph ==> never NULL
|
||||||
|
*/
|
||||||
|
ewol::GlyphProperty* GetGlyphPointer(const uniChar_t charcode, const ewol::font::mode_te displayMode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +114,8 @@ bool ewol::Button::CalculateMinSize(void)
|
|||||||
etk::Vector2D<int32_t> padding;
|
etk::Vector2D<int32_t> padding;
|
||||||
padding.x = m_config->GetInteger(m_confIdPaddingX);
|
padding.x = m_config->GetInteger(m_confIdPaddingX);
|
||||||
padding.y = m_config->GetInteger(m_confIdPaddingY);
|
padding.y = m_config->GetInteger(m_confIdPaddingY);
|
||||||
etk::Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
|
||||||
|
etk::Vector3D<int32_t> minSize = m_displayText.CalculateSize(m_label);
|
||||||
m_minSize.x = padding.x*2 + minSize.x;
|
m_minSize.x = padding.x*2 + minSize.x;
|
||||||
m_minSize.y = padding.y*2 + minSize.y;
|
m_minSize.y = padding.y*2 + minSize.y;
|
||||||
// Add the image element ...
|
// Add the image element ...
|
||||||
@ -214,7 +215,8 @@ void ewol::Button::OnDraw(DrawProperty& displayProp)
|
|||||||
if (NULL != m_oObjectImage) {
|
if (NULL != m_oObjectImage) {
|
||||||
m_oObjectImage->Draw();
|
m_oObjectImage->Draw();
|
||||||
}
|
}
|
||||||
m_oObjectText.Draw();
|
//m_oObjectText.Draw();
|
||||||
|
m_displayText.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::Button::OnRegenerateDisplay(void)
|
void ewol::Button::OnRegenerateDisplay(void)
|
||||||
@ -225,35 +227,36 @@ void ewol::Button::OnRegenerateDisplay(void)
|
|||||||
padding.x = m_config->GetInteger(m_confIdPaddingX);
|
padding.x = m_config->GetInteger(m_confIdPaddingX);
|
||||||
padding.y = m_config->GetInteger(m_confIdPaddingY);
|
padding.y = m_config->GetInteger(m_confIdPaddingY);
|
||||||
|
|
||||||
m_oObjectText.Clear();
|
|
||||||
if (NULL != m_oObjectImage) {
|
if (NULL != m_oObjectImage) {
|
||||||
m_oObjectImage->Clear();
|
m_oObjectImage->Clear();
|
||||||
}
|
}
|
||||||
int32_t tmpSizeX = m_minSize.x;
|
int32_t tmpSizeX = m_minSize.x;
|
||||||
int32_t tmpSizeY = m_minSize.y;
|
int32_t tmpSizeY = m_minSize.y;
|
||||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
etk::Vector3D<float> tmpOrigin((float)((m_size.x - m_minSize.x) / 2.0),
|
||||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
(float)((m_size.y - m_minSize.y) / 2.0),
|
||||||
|
(float)(0.0));
|
||||||
// no change for the text orogin :
|
// no change for the text orogin :
|
||||||
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + padding.x;
|
etk::Vector3D<float> tmpTextOrigin((float)((m_size.x - m_minSize.x) / 2.0 + padding.x),
|
||||||
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + padding.y;
|
(float)((m_size.y - m_minSize.y) / 2.0 + padding.y),
|
||||||
|
(float)(0.0));
|
||||||
|
|
||||||
if (true==m_userFill.x) {
|
if (true==m_userFill.x) {
|
||||||
tmpSizeX = m_size.x;
|
tmpSizeX = m_size.x;
|
||||||
tmpOriginX = 0;
|
tmpOrigin.x = 0.0;
|
||||||
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
|
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
|
||||||
tmpTextOriginX = padding.x;
|
tmpTextOrigin.x = padding.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (true==m_userFill.y) {
|
if (true==m_userFill.y) {
|
||||||
tmpSizeY = m_size.y;
|
tmpSizeY = m_size.y;
|
||||||
tmpOriginY = 0;
|
tmpOrigin.y = 0.0;
|
||||||
}
|
}
|
||||||
tmpOriginX += padding.x;
|
tmpOrigin.x += padding.x;
|
||||||
tmpOriginY += padding.y;
|
tmpOrigin.x += padding.y;
|
||||||
tmpSizeX -= 2*padding.x;
|
tmpSizeX -= 2*padding.x;
|
||||||
tmpSizeY -= 2*padding.y;
|
tmpSizeY -= 2*padding.y;
|
||||||
|
|
||||||
etk::Vector2D<float> textPos(tmpTextOriginX, tmpTextOriginY);
|
etk::Vector2D<float> textPos(tmpTextOrigin.x, tmpTextOrigin.x);
|
||||||
|
|
||||||
/*ewol::OObject2DTextured * tmpImage = NULL;
|
/*ewol::OObject2DTextured * tmpImage = NULL;
|
||||||
if (true == m_hasAnImage) {
|
if (true == m_hasAnImage) {
|
||||||
@ -265,16 +268,22 @@ void ewol::Button::OnRegenerateDisplay(void)
|
|||||||
textPos.x += m_padding.x + fontHeight;
|
textPos.x += m_padding.x + fontHeight;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
clipping_ts drawClipping;
|
etk::Vector3D<float> drawClippingPos((float)padding.x, (float)padding.y, (float)-0.5);
|
||||||
drawClipping.x = padding.x;
|
etk::Vector3D<float> drawClippingSize((float)(m_size.x - 2*padding.x),
|
||||||
drawClipping.y = padding.y;
|
(float)(m_size.y - 2*padding.y),
|
||||||
drawClipping.w = m_size.x - 2*padding.x;
|
(float)1.0);
|
||||||
drawClipping.h = m_size.y - 2*padding.y;
|
|
||||||
//EWOL_DEBUG("draw tex at pos : " <<textPos << "in element size:" << m_size);
|
// clean the element
|
||||||
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
m_displayText.Clear();
|
||||||
|
m_displayText.SetClipping(drawClippingPos, drawClippingSize);
|
||||||
|
m_displayText.Print(m_label);
|
||||||
|
m_displayText.Tranlate(tmpTextOrigin);
|
||||||
|
|
||||||
|
|
||||||
m_widgetProperty.m_insidePos = textPos;
|
m_widgetProperty.m_insidePos = textPos;
|
||||||
m_widgetProperty.m_insideSize = m_oObjectText.GetSize(m_label);
|
etk::Vector3D<float> tmpp = m_displayText.CalculateSize(m_label);
|
||||||
|
etk::Vector2D<float> tmpp2(tmpp.x, tmpp.y);
|
||||||
|
m_widgetProperty.m_insideSize = tmpp2;
|
||||||
|
|
||||||
Rectangle(0, 0, m_size.x, m_size.y);
|
Rectangle(0, 0, m_size.x, m_size.y);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/oObject/OObject.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
|
#include <ewol/compositing/Text.h>
|
||||||
|
|
||||||
extern const char * const ewolEventButtonPressed;
|
extern const char * const ewolEventButtonPressed;
|
||||||
extern const char * const ewolEventButtonDown;
|
extern const char * const ewolEventButtonDown;
|
||||||
@ -85,7 +86,7 @@ namespace ewol {
|
|||||||
void SetPoint(float x, float y);
|
void SetPoint(float x, float y);
|
||||||
void Rectangle(float x, float y, float w, float h);
|
void Rectangle(float x, float y, float w, float h);
|
||||||
private:
|
private:
|
||||||
ewol::OObject2DTextColored m_oObjectText;
|
ewol::Text m_displayText;
|
||||||
ewol::OObject2DTextured* m_oObjectImage;
|
ewol::OObject2DTextured* m_oObjectImage;
|
||||||
bool m_hasAnImage;
|
bool m_hasAnImage;
|
||||||
etk::UString m_imageSelected;
|
etk::UString m_imageSelected;
|
||||||
|
@ -1 +1 @@
|
|||||||
0.4.2
|
0.4.3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user