[DEV] Text compisiting element is now OK

This commit is contained in:
Edouard DUPIN 2012-11-19 21:16:14 +01:00
parent 3a41e938a6
commit 6356d8b1d5
9 changed files with 143 additions and 23 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 668f19abbe82a4ccb078d64844e8974ac17ea87f
Subproject commit 83a25600f6254f755271c96c898a3892e86080fa

View File

@ -28,7 +28,7 @@ void ewol::Compositing::ResetMatrix(void)
}
void ewol::Compositing::Tranlate(etk::Vector3D<float> vect)
void ewol::Compositing::Translate(etk::Vector3D<float> vect)
{
m_matrixApply *= etk::matrix::Translate(vect);
}

View File

@ -39,22 +39,22 @@ namespace ewol
/**
* @brief Reset to the eye matrix the openGL mouving system
*/
void ResetMatrix(void);
virtual void ResetMatrix(void);
/**
* @brief Translate the current display of this element
* @param[in] vect The translation vector to apply at the transformation matrix
*/
void Tranlate(etk::Vector3D<float> vect);
virtual void Translate(etk::Vector3D<float> vect);
/**
* @brief Rotate the curent display of this element
* @param[in] vect The rotation vector to apply at the transformation matrix
*/
void Rotate(etk::Vector3D<float> vect, float angle);
virtual void Rotate(etk::Vector3D<float> vect, float angle);
/**
* @brief Scale the current diaplsy of this element
* @param[in] vect The scaling vector to apply at the transformation matrix
*/
void Scale(etk::Vector3D<float> vect);
virtual void Scale(etk::Vector3D<float> vect);
};
};

View File

@ -7,7 +7,7 @@
*/
#include <ewol/Debug.h>
#include <ewol/compositing/Draw.h>
#include <ewol/compositing/Drawing.h>
#if 0
@ -346,6 +346,12 @@ void ewol::Drawing::Clear(void)
}
etk::Vector3D<float> ewol::Drawing::GetPos(void)
{
return m_position;
}
void ewol::Drawing::SetPos(etk::Vector3D<float> pos)
{
m_position = pos;
@ -364,7 +370,7 @@ void ewol::Drawing::SetColor(draw::Color color)
}
void ewol::Drawing::SetColorBG(draw::Color color)
void ewol::Drawing::SetColorBg(draw::Color color)
{
m_colorBg = color;
}

View File

@ -82,6 +82,11 @@ namespace ewol
* @brief Clear alll tre registered element in the current element
*/
void Clear(void);
/**
* @brief Get the current display position (sometime needed in the gui control)
* @return the current position.
*/
etk::Vector3D<float> GetPos(void);
/**
* @brief Set position for the next text writen
* @param[in] pos Position of the text (in 3D)
@ -101,7 +106,7 @@ namespace ewol
* @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)
*/
void SetColorBG(draw::Color color);
void SetColorBg(draw::Color color);
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] pos Start position of the clipping

View File

@ -134,6 +134,26 @@ void ewol::Text::Draw(void)
m_GLprogram->UnUse();
}
void ewol::Text::Translate(etk::Vector3D<float> vect)
{
ewol::Compositing::Translate(vect);
m_vectorialDraw.Translate(vect);
}
void ewol::Text::Rotate(etk::Vector3D<float> vect, float angle)
{
ewol::Compositing::Rotate(vect, angle);
m_vectorialDraw.Rotate(vect, angle);
}
void ewol::Text::Scale(etk::Vector3D<float> vect)
{
ewol::Compositing::Scale(vect);
m_vectorialDraw.Scale(vect);
}
void ewol::Text::Clear(void)
{
@ -161,6 +181,12 @@ void ewol::Text::Clear(void)
}
etk::Vector3D<float> ewol::Text::GetPos(void)
{
return m_position;
}
void ewol::Text::SetPos(etk::Vector3D<float> pos)
{
m_position = pos;
@ -183,7 +209,7 @@ void ewol::Text::SetColor(draw::Color color)
}
void ewol::Text::SetColorBG(draw::Color color)
void ewol::Text::SetColorBg(draw::Color color)
{
m_colorBg = color;
m_vectorialDraw.SetColor(color);
@ -278,6 +304,45 @@ void ewol::Text::SetFontMode(ewol::font::mode_te mode)
}
void ewol::Text::SetFontBold(bool status)
{
if (true == status) {
// enable
if (m_mode == ewol::font::Regular) {
SetFontMode(ewol::font::Bold);
} else if (m_mode == ewol::font::Italic) {
SetFontMode(ewol::font::BoldItalic);
}
} else {
// disable
if (m_mode == ewol::font::Bold) {
SetFontMode(ewol::font::Regular);
} else if (m_mode == ewol::font::BoldItalic) {
SetFontMode(ewol::font::Italic);
}
}
}
void ewol::Text::SetFontItalic(bool status)
{
if (true == status) {
// enable
if (m_mode == ewol::font::Regular) {
SetFontMode(ewol::font::Italic);
} else if (m_mode == ewol::font::Bold) {
SetFontMode(ewol::font::BoldItalic);
}
} else {
// disable
if (m_mode == ewol::font::Italic) {
SetFontMode(ewol::font::Regular);
} else if (m_mode == ewol::font::BoldItalic) {
SetFontMode(ewol::font::Bold);
}
}
}
void ewol::Text::SetKerningMode(bool newMode)
{
m_kerning = newMode;
@ -316,7 +381,7 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
for(int32_t iii=0; iii<text.Size(); iii++) {
if (iii<decoration.Size()) {
SetColor(decoration[iii].m_colorFg);
SetColorBG(decoration[iii].m_colorBg);
SetColorBg(decoration[iii].m_colorBg);
SetFontMode(decoration[iii].m_mode);
}
if (m_colorBg.a != 0) {
@ -369,7 +434,7 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
// Get specific decoration if provided
if (iii<decoration.Size()) {
SetColor(decoration[iii].m_colorFg);
SetColorBG(decoration[iii].m_colorBg);
SetColorBg(decoration[iii].m_colorBg);
SetFontMode(decoration[iii].m_mode);
}
// special for the justify mode
@ -393,16 +458,17 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
}
if (currentId == stop) {
currentId++;
} else if( text[stop] == (uniChar_t)' '
|| text[stop] == (uniChar_t)'\n') {
} else if(text[stop] == (uniChar_t)' ') {
currentId = stop+1;
} else if(text[stop] == (uniChar_t)'\n') {
currentId = stop+1;
// Reset position :
SetPos(etk::Vector3D<float>(m_startTextpos,
(float)(m_position.y - m_font->GetHeight(m_mode)),
m_position.z) );
} else {
currentId = stop;
}
// Reset position :
SetPos(etk::Vector3D<float>(m_startTextpos,
(float)(m_position.y - m_font->GetHeight(m_mode)),
m_position.z) );
}
}
}
@ -608,6 +674,14 @@ void ewol::Text::Print(const uniChar_t charcode)
return;
}
void ewol::Text::ForceLineReturn(void)
{
// Reset position :
SetPos(etk::Vector3D<float>(m_startTextpos,
(float)(m_position.y - m_font->GetHeight(m_mode)),
m_position.z) );
}
void ewol::Text::SetTextAlignement(float startTextpos, float stopTextPos, aligneMode_te alignement)
{

View File

@ -11,7 +11,7 @@
#include <ewol/Debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Draw.h>
#include <ewol/compositing/Drawing.h>
#include <draw/Color.h>
#include <ewol/ResourceManager.h>
@ -97,7 +97,23 @@ namespace ewol
* @brief generic destructor
*/
~Text(void);
public :
public:
/**
* @brief Translate the current display of this element
* @param[in] vect The translation vector to apply at the transformation matrix
*/
virtual void Translate(etk::Vector3D<float> vect);
/**
* @brief Rotate the curent display of this element
* @param[in] vect The rotation vector to apply at the transformation matrix
*/
virtual void Rotate(etk::Vector3D<float> vect, float angle);
/**
* @brief Scale the current diaplsy of this element
* @param[in] vect The scaling vector to apply at the transformation matrix
*/
virtual void Scale(etk::Vector3D<float> vect);
public:
/**
* @brief Draw All the refistered text in the current element on openGL
*/
@ -106,6 +122,11 @@ namespace ewol
* @brief Clear alll tre registered element in the current element
*/
void Clear(void);
/**
* @brief Get the current display position (sometime needed in the gui control)
* @return the current position.
*/
etk::Vector3D<float> GetPos(void);
/**
* @brief Set position for the next text writen
* @param[in] pos Position of the text (in 3D)
@ -125,7 +146,7 @@ namespace ewol
* @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)
*/
void SetColorBG(draw::Color color);
void SetColorBg(draw::Color color);
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] pos Start position of the clipping
@ -164,6 +185,16 @@ namespace ewol
* @param[in] mode The font mode requested
*/
void SetFontMode(ewol::font::mode_te mode);
/**
* @brief Enable or disable the bold mode
* @param[in] status The new status for this display property
*/
void SetFontBold(bool status);
/**
* @brief Enable or disable the italic mode
* @param[in] status The new status for this display property
*/
void SetFontItalic(bool status);
/**
* @brief Set the activation of the Kerning for the display (if it existed)
* @param[in] newMode Enable/Diasable the kerning on this font.
@ -204,6 +235,10 @@ namespace ewol
* @param[in] char that might be dispalyed
*/
void Print(const uniChar_t charcode);
/**
* @brief This Generate the line return ==> it return to the alignement position start and at the correct line position ==> it might be use to not know the line height
*/
void ForceLineReturn(void);
/**
* @brief This generate the possibility to generate the big text property
* @param[in] startTextpos The x text start position of the display.

View File

@ -277,7 +277,7 @@ void ewol::Button::OnRegenerateDisplay(void)
m_displayText.Clear();
m_displayText.SetClipping(drawClippingPos, drawClippingSize);
m_displayText.Print(m_label);
m_displayText.Tranlate(tmpTextOrigin);
m_displayText.Translate(tmpTextOrigin);
m_widgetProperty.m_insidePos = textPos;

View File

@ -29,7 +29,7 @@ FILE_LIST+= ewol/game/GameElement.cpp \
# Compositing
FILE_LIST+= ewol/compositing/Compositing.cpp \
ewol/compositing/Text.cpp \
ewol/compositing/Draw.cpp
ewol/compositing/Drawing.cpp
# Object abstraction for OpenGl
FILE_LIST+= ewol/oObject/OObject.cpp \