[DEV] Start the writing of the Text compositing
This commit is contained in:
parent
a04e79f0c7
commit
303b08da9d
@ -6,8 +6,8 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/compositing/Compisiting.h>
|
#include <ewol/compositing/Compositing.h>
|
||||||
|
|
||||||
|
|
||||||
ewol::Compositing::Compositing(void)
|
ewol::Compositing::Compositing(void)
|
||||||
@ -30,17 +30,17 @@ void ewol::Compositing::ResetMatrix(void)
|
|||||||
|
|
||||||
void ewol::Compositing::Tranlate(etk::Vector3D<float> vect)
|
void ewol::Compositing::Tranlate(etk::Vector3D<float> vect)
|
||||||
{
|
{
|
||||||
m_matrixApply *= ewol::matrix::Translate(vect.x, vect.y, vect.z);
|
m_matrixApply *= etk::matrix::Translate(vect.x, vect.y, vect.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Compositing::Rotate(etk::Vector3D<float> vect)
|
void ewol::Compositing::Rotate(etk::Vector3D<float> vect)
|
||||||
{
|
{
|
||||||
m_matrixApply *= ewol::matrix::rotate(vect.x, vect.y, vect.z);
|
m_matrixApply *= etk::matrix::rotate(vect.x, vect.y, vect.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Compositing::Scale(etk::Vector3D<float> vect)
|
void ewol::Compositing::Scale(etk::Vector3D<float> vect)
|
||||||
{
|
{
|
||||||
m_matrixApply *= ewol::matrix::Scale(vect.x, vect.y, vect.z);
|
m_matrixApply *= etk::matrix::Scale(vect.x, vect.y, vect.z);
|
||||||
}
|
}
|
@ -9,6 +9,10 @@
|
|||||||
#ifndef __EWOL_COMPOSITING_H__
|
#ifndef __EWOL_COMPOSITING_H__
|
||||||
#define __EWOL_COMPOSITING_H__
|
#define __EWOL_COMPOSITING_H__
|
||||||
|
|
||||||
|
#include <ewol/Debug.h>
|
||||||
|
#include <etk/math/Matrix4.h>
|
||||||
|
#include <etk/UString.h>
|
||||||
|
|
||||||
namespace ewol
|
namespace ewol
|
||||||
{
|
{
|
||||||
class Compositing
|
class Compositing
|
||||||
@ -27,7 +31,7 @@ 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
|
||||||
*/
|
*/
|
||||||
virtual Draw(void)=0;
|
void virtual Draw(void)=0;
|
||||||
/**
|
/**
|
||||||
* @brief Reset to the eye matrix the openGL mouving system
|
* @brief Reset to the eye matrix the openGL mouving system
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,260 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <ewol/Debug.h>
|
||||||
|
#include <ewol/compositing/Text.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// curent Drawing position
|
||||||
|
etk::Vector3D<float> m_position; //!< the next position to draw the text
|
||||||
|
// clipping section
|
||||||
|
etk::Vector3D<float> m_clippingPosition;
|
||||||
|
etk::Vector3D<float> m_clippingSize;
|
||||||
|
bool m_clippingEnable;
|
||||||
|
// Basic color
|
||||||
|
etk::Color m_color;
|
||||||
|
*/
|
||||||
|
|
||||||
|
ewol::Text::Text(void) :
|
||||||
|
m_GLprogram(NULL),
|
||||||
|
m_font(NULL)
|
||||||
|
{
|
||||||
|
m_color = draw::color::black;
|
||||||
|
m_colorBg = draw::color::none;
|
||||||
|
SetFontProperty(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize());
|
||||||
|
LoadProgram();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::Text::Text(etk::UString fontName, int32_t fontSize) :
|
||||||
|
m_GLprogram(NULL),
|
||||||
|
m_font(NULL)
|
||||||
|
{
|
||||||
|
m_color = draw::color::black;
|
||||||
|
m_colorBg = draw::color::none;
|
||||||
|
SetFontProperty(fontName, fontSize);
|
||||||
|
LoadProgram();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::Text::~Text(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (NULL != m_font) {
|
||||||
|
ewol::resource::Release(m_font);
|
||||||
|
m_font = NULL;
|
||||||
|
}
|
||||||
|
ewol::resource::Release(m_GLprogram);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadProgram(void)
|
||||||
|
{
|
||||||
|
etk::UString tmpString("DATA:text.prog");
|
||||||
|
// get the shader resource :
|
||||||
|
m_GLPosition = 0;
|
||||||
|
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||||
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
|
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
||||||
|
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
|
||||||
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
|
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::Text::Draw(void)
|
||||||
|
{
|
||||||
|
if (m_coord.Size()<=0 || NULL == m_font) {
|
||||||
|
// TODO : a remètre ...
|
||||||
|
//EWOL_WARNING("Nothink to draw...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_WARNING("no font...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_GLprogram==NULL) {
|
||||||
|
EWOL_ERROR("No shader ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_GLprogram->Use();
|
||||||
|
// set Matrix : translation/positionMatrix
|
||||||
|
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
|
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
|
// TextureID
|
||||||
|
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
|
||||||
|
// position :
|
||||||
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
|
// Texture :
|
||||||
|
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||||
|
// color :
|
||||||
|
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||||
|
// Request the draw od the elements :
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
|
m_GLprogram->UnUse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::Clear(void)
|
||||||
|
{
|
||||||
|
m_coord.Clear();
|
||||||
|
m_coordTex.Clear();
|
||||||
|
m_coordColor.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetPos(etk::Vector3D<float> pos)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetRelPos(etk::Vector3D<float> pos)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetColor(draw::Color color)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetColorBG(draw::Color color)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetClipping(etk::Vector3D<float> pos, etk::Vector3D<float> width)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetClippingMode(bool newMode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetFontSize(int32_t fontSize)
|
||||||
|
{
|
||||||
|
// get old size
|
||||||
|
etk::UString fontName = ewol::font::GetDefaultFont();
|
||||||
|
if (NULL != m_font) {
|
||||||
|
fontName = m_font->GetName();
|
||||||
|
}
|
||||||
|
SetFont(fontName, fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetFontName(etk::UString fontName)
|
||||||
|
{
|
||||||
|
// get old size
|
||||||
|
int32_t fontSize = ewol::font::GetDefaultSize();
|
||||||
|
if (NULL != m_font) {
|
||||||
|
fontSize = m_font->GetFontSize();
|
||||||
|
}
|
||||||
|
SetFont(fontName, fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetFont(etk::UString fontName, int32_t fontSize)
|
||||||
|
{
|
||||||
|
// remove old one
|
||||||
|
if (NULL != m_font) {
|
||||||
|
ewol::resource::Release(m_font);
|
||||||
|
m_font = NULL;
|
||||||
|
}
|
||||||
|
etk::UString tmpName = fontName;
|
||||||
|
tmpName += ":";
|
||||||
|
tmpName += fontSize;
|
||||||
|
// link to new One
|
||||||
|
if (false == ewol::resource::Keep(tmpName, m_font)) {
|
||||||
|
EWOL_ERROR("Can not get font resource");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetFontMode(ewol::font::mode_te mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetKerningMode(bool newMode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetDistanceFieldMode(bool newMode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::Print(etk::UString& text)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::PrintDecorated(etk::UString& text)
|
||||||
|
{
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int32_t nbElementInTheArray = m_coord.Size();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::Print(uniChar_t charcode)
|
||||||
|
{
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int32_t nbElementInTheArray = m_coord.Size();
|
||||||
|
int32_t size = 0;
|
||||||
|
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex, m_displayMode, m_hasClipping, m_clipping, displayMode);
|
||||||
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
|
m_coordColor.PushBack(m_color);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::SetTextAlignement(float startTextpos, float stopTextPos, aligneMode_te alignement)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Text::DisableAlignement(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -9,15 +9,20 @@
|
|||||||
#ifndef __EWOL_TEXT_H__
|
#ifndef __EWOL_TEXT_H__
|
||||||
#define __EWOL_TEXT_H__
|
#define __EWOL_TEXT_H__
|
||||||
|
|
||||||
|
#include <ewol/Debug.h>
|
||||||
|
#include <ewol/compositing/Compositing.h>
|
||||||
|
#include <draw/Color.h>
|
||||||
|
#include <ewol/ResourceManager.h>
|
||||||
|
|
||||||
namespace ewol
|
namespace ewol
|
||||||
{
|
{
|
||||||
class TextDecoration
|
class TextDecoration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
etk::Color m_colorBg;
|
draw::Color m_colorBg;
|
||||||
etk::Color m_colorFg;
|
draw::Color m_colorFg;
|
||||||
ewol::font::mode_te m_mode;
|
ewol::font::mode_te m_mode;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
class Text : public ewol::Compositing
|
class Text : public ewol::Compositing
|
||||||
@ -30,7 +35,7 @@ namespace ewol
|
|||||||
alignJustify
|
alignJustify
|
||||||
} aligneMode_te;
|
} aligneMode_te;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
// curent Drawing position
|
// curent Drawing position
|
||||||
etk::Vector3D<float> m_position; //!< the next position to draw the text
|
etk::Vector3D<float> m_position; //!< the next position to draw the text
|
||||||
// clipping section
|
// clipping section
|
||||||
@ -38,7 +43,34 @@ namespace ewol
|
|||||||
etk::Vector3D<float> m_clippingSize;
|
etk::Vector3D<float> m_clippingSize;
|
||||||
bool m_clippingEnable;
|
bool m_clippingEnable;
|
||||||
// Basic color
|
// Basic color
|
||||||
etk::Color m_color;
|
draw::Color m_color;
|
||||||
|
draw::Color m_colorBg;
|
||||||
|
// font property :
|
||||||
|
// alignement propoerty
|
||||||
|
float m_startTextpos;
|
||||||
|
float m_stopTextPos;
|
||||||
|
aligneMode_te m_alignement;
|
||||||
|
// OpenGL interface for shader
|
||||||
|
ewol::Program* m_GLprogram;
|
||||||
|
int32_t m_GLPosition;
|
||||||
|
int32_t m_GLMatrix;
|
||||||
|
int32_t m_GLColor;
|
||||||
|
int32_t m_GLtextMode;
|
||||||
|
int32_t m_GLtexture;
|
||||||
|
int32_t m_GLtexID;
|
||||||
|
// Font resource :
|
||||||
|
ewol::TexturedFont* m_font; //!< ewol font system
|
||||||
|
// data vector for all the display :
|
||||||
|
// Note : the X texture range change to select the Regular / Bold / italic / BoldItalic mode , and the next is for no font but background color
|
||||||
|
// ==> associate with a special shader
|
||||||
|
etk::Vector<etk::Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
|
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||||
|
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Load the openGL program and get all the ID needed
|
||||||
|
*/
|
||||||
|
void LoadProgram(void);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief generic constructor
|
* @brief generic constructor
|
||||||
@ -77,12 +109,12 @@ namespace ewol
|
|||||||
* @brief Set the Color of the current foreground font
|
* @brief Set the Color of the current foreground font
|
||||||
* @param[in] color Color to set on foreground (for next print)
|
* @param[in] color Color to set on foreground (for next print)
|
||||||
*/
|
*/
|
||||||
void SetColor(etk::Color color);
|
void SetColor(draw::Color color);
|
||||||
/**
|
/**
|
||||||
* @brief Set the background color of the font (for selected Text (not the global BG))
|
* @brief Set the background color of the font (for selected Text (not the global BG))
|
||||||
* @param[in] color Color to set on background (for next print)
|
* @param[in] color Color to set on background (for next print)
|
||||||
*/
|
*/
|
||||||
void SetColorBG(etk::Color color);
|
void SetColorBG(draw::Color color);
|
||||||
/**
|
/**
|
||||||
* @brief Request a clipping area for the text (next draw only)
|
* @brief Request a clipping area for the text (next draw only)
|
||||||
* @param[in] pos Start position of the clipping
|
* @param[in] pos Start position of the clipping
|
||||||
@ -125,7 +157,7 @@ namespace ewol
|
|||||||
* @param[in] newMode Enable/Diasable the Distance Field on this font.
|
* @param[in] newMode Enable/Diasable the Distance Field on this font.
|
||||||
* @todo : not implemented for now
|
* @todo : not implemented for now
|
||||||
*/
|
*/
|
||||||
void SetDistanceFieldMode(bool newMode) { };
|
void SetDistanceFieldMode(bool newMode);
|
||||||
/**
|
/**
|
||||||
* @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.
|
||||||
|
@ -26,6 +26,10 @@ FILE_LIST+= ewol/game/GameElement.cpp \
|
|||||||
ewol/game/GameElementLua.cpp \
|
ewol/game/GameElementLua.cpp \
|
||||||
ewol/game/SceneElement.cpp
|
ewol/game/SceneElement.cpp
|
||||||
|
|
||||||
|
# Compositing
|
||||||
|
FILE_LIST+= ewol/compositing/Compositing.cpp \
|
||||||
|
ewol/compositing/Text.cpp
|
||||||
|
|
||||||
# Object abstraction for OpenGl
|
# Object abstraction for OpenGl
|
||||||
FILE_LIST+= ewol/oObject/OObject.cpp \
|
FILE_LIST+= ewol/oObject/OObject.cpp \
|
||||||
ewol/oObject/2DTextColored.cpp \
|
ewol/oObject/2DTextColored.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user