A little clean in font system
This commit is contained in:
parent
06f6cf283e
commit
172c5d31ec
@ -32,18 +32,6 @@
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
// deprecated...
|
||||
typedef enum {
|
||||
FONT_MODE_NORMAL=0,
|
||||
FONT_MODE_BOLD,
|
||||
FONT_MODE_ITALIC,
|
||||
FONT_MODE_BOLD_ITALIC,
|
||||
FONT_MODE_NUMBER,
|
||||
}fontMode_te;
|
||||
|
||||
|
||||
//typedef char* Utf8Char_t;
|
||||
|
||||
// set default folder name of the font :
|
||||
void SetFontFolder(etk::String folderName);
|
||||
void SetDefaultFont(etk::String fontName, int32_t size);
|
||||
|
@ -28,9 +28,26 @@
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DText"
|
||||
|
||||
ewol::OObject2DText::OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String)
|
||||
ewol::OObject2DText::OObject2DText(etk::String FontName, int32_t size, color_ts textColorFg)
|
||||
{
|
||||
Text(x, y, FontName, size, mode, textColorFg, utf8String);
|
||||
m_textColorFg = textColorFg;
|
||||
if (FontName == "") {
|
||||
m_FontId = GetDefaultFontId();
|
||||
} else {
|
||||
EWOL_TODO("pas encore fait...");
|
||||
//m_FontId = GetFontIdWithName(FontName);
|
||||
m_FontId = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// open with default font ...
|
||||
ewol::OObject2DText::OObject2DText(void)
|
||||
{
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
m_FontId = GetDefaultFontId();
|
||||
}
|
||||
|
||||
ewol::OObject2DText::~OObject2DText(void)
|
||||
@ -59,24 +76,14 @@ void ewol::OObject2DText::Draw(void)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String)
|
||||
void ewol::OObject2DText::Text(float x, float y, const char* utf8String)
|
||||
{
|
||||
m_FontTextureId = 0;
|
||||
m_coord.Clear();
|
||||
m_coordTex.Clear();
|
||||
// get font Name :
|
||||
if (FontName == "") {
|
||||
m_FontId = GetDefaultFontId();
|
||||
} else {
|
||||
EWOL_TODO("pas encore fait...");
|
||||
//m_FontId = GetFontIdWithName(FontName);
|
||||
return;
|
||||
}
|
||||
if (m_FontId == -1) {
|
||||
EWOL_ERROR("Can not find the font with the name : " << FontName);
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
}
|
||||
EWOL_DEBUG("Font name : " << FontName << " id=" << m_FontId);
|
||||
m_textColorFg = textColorFg;
|
||||
coord2D_ts drawPosition;
|
||||
drawPosition.x = x;
|
||||
drawPosition.y = y;
|
||||
|
@ -31,12 +31,13 @@ namespace ewol {
|
||||
class OObject2DText :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String);
|
||||
OObject2DText(etk::String FontName, int32_t size, color_ts textColorFg);
|
||||
OObject2DText(void);
|
||||
virtual ~OObject2DText(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
// set a specific text
|
||||
void Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String);
|
||||
void Text(float x, float y, const char* utf8String);
|
||||
protected:
|
||||
int32_t m_FontId; //!< font internal ID
|
||||
color_ts m_textColorFg; //!< text color ...
|
||||
|
@ -70,12 +70,8 @@ ewol::Windows::Windows(void)
|
||||
|
||||
AddOObject(myOObject, "leftBoutton");
|
||||
|
||||
color_ts textColorFg;
|
||||
textColorFg.red = .0;
|
||||
textColorFg.green = .0;
|
||||
textColorFg.blue = .0;
|
||||
textColorFg.alpha = 1.0;
|
||||
ewol::OObject2DText * myOObjectText = new ewol::OObject2DText(62, 2, "Monospace", 17 , FONT_MODE_BOLD, textColorFg, "My Title ...");
|
||||
ewol::OObject2DText * myOObjectText = new ewol::OObject2DText();
|
||||
myOObjectText->Text(62, 2, "My Title ...");
|
||||
AddOObject(myOObjectText, "Title");
|
||||
}
|
||||
}
|
||||
|
@ -95,13 +95,15 @@ void ewol::Button::OnRegenerateDisplay(void)
|
||||
textColorFg.blue = 0.0;
|
||||
textColorFg.alpha = 1.0;
|
||||
|
||||
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, 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;
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText(posx, posy, "", -1, FONT_MODE_BOLD, textColorFg, m_label.c_str());
|
||||
|
||||
tmpText->Text(posx, posy, m_label.c_str());
|
||||
AddOObject(tmpText, "BouttonText");
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user