[TEST] the compositing system

This commit is contained in:
Edouard DUPIN 2012-11-19 08:00:52 +01:00
parent f63828b3d6
commit 600bbd2a94
3 changed files with 179 additions and 9 deletions

View File

@ -37,5 +37,5 @@ CONFIG_APPL_BUFFER_FONT_NORMAL=y
#
# General
#
CONFIG___EWOL_INTEGRATED_FONT__=y
# CONFIG___EWOL_INTEGRATED_FONT__ is not set
CONFIG___EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"

View File

@ -43,6 +43,7 @@
void CodeView::Init(void)
{
m_alignement = ewol::Text::alignJustify;
m_label = "CodeView is disable ...";
m_bufferID = -1;
@ -80,7 +81,8 @@ void CodeView::Init(void)
CodeView::CodeView(etk::UString fontName, int32_t fontSize) :
m_OObjectText(fontName, fontSize),
m_displayText("Times_New_Roman", 14)
//m_displayText("Times_New_Roman", 14)
m_displayText("Arial", 14)
{
Init();
}
@ -135,6 +137,7 @@ void CodeView::OnDraw(ewol::DrawProperty& displayProp)
{
m_OObjectsColored.Draw();
//m_OObjectText.Draw();
m_displayDrawing.Draw();
m_displayText.Draw();
WidgetScrooled::OnDraw(displayProp);
}
@ -148,31 +151,171 @@ void CodeView::OnRegenerateDisplay(void)
CalculateMaxSize();
m_OObjectText.Clear();
m_displayDrawing.Clear();
m_displayText.Clear();
m_OObjectsColored.Clear();
#if 1
m_OObjectsColored.SetColor(draw::color::white);
m_OObjectsColored.Rectangle( 0, 0, m_size.x, m_size.y);
m_OObjectsColored.SetColor(draw::color::aqua);
m_OObjectsColored.Rectangle( 20, 0, m_size.x-40, m_size.y-50);
m_displayText.SetColor(draw::color::red);
etk::UString tmpString("PETIT test sur les Text Display : ");
etk::UString tmpString("PETIT test géant pour voir si ca fonctionne");
// clean the element
switch (m_alignement)
{
case ewol::Text::alignJustify:
m_displayText.SetFontMode(ewol::font::Regular);
tmpString += "mode JUSTIFY";
break;
case ewol::Text::alignLeft:
m_displayText.SetFontMode(ewol::font::Bold);
tmpString += "mode Left";
break;
case ewol::Text::alignRight:
m_displayText.SetFontMode(ewol::font::Italic);
tmpString += "mode Right";
break;
case ewol::Text::alignCenter:
m_displayText.SetFontMode(ewol::font::BoldItalic);
tmpString += "mode Center";
break;
case ewol::Text::alignDisable:
tmpString += "mode Disable";
break;
}
m_displayText.SetPos(etk::Vector3D<float>((float)20,(float)m_size.y-20,(float)0) );
m_displayText.Print(tmpString);
tmpString = "test de text complexe ...";
etk::Vector<ewol::TextDecoration> decoration;
ewol::TextDecoration plop;
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
m_displayText.SetPos(etk::Vector3D<float>((float)20,(float)m_size.y-50,(float)0) );
m_displayText.Print(tmpString, decoration);
m_displayText.SetColor(draw::color::black);
m_displayText.SetFontMode(ewol::font::Regular);
m_OObjectsColored.SetColor(draw::color::aqua);
m_OObjectsColored.Rectangle( 20, 0, m_size.x-40, m_size.y-100);
m_displayText.SetColorBG(draw::color::none);
m_OObjectsColored.SetColor(draw::color::green);
m_OObjectsColored.Rectangle( 200, 200, 200, 200);
etk::Vector3D<float> drawClippingPos(200.0, 200.0, -0.5);
etk::Vector3D<float> drawClippingSize(400.0, 400.0, 1.0);
m_displayText.SetClipping(drawClippingPos, drawClippingSize);
tmpString = "Un jour Cosette se regarda par hasard dans son miroir et se dit: Tiens! Il lui semblait presque qu'elle était jolie. Ceci la jeta dans un trouble singulier. Jusqu'à ce moment elle n'avait point songé à sa figure. Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide ; Jean Valjean seul disait doucement : Mais non! mais non! Quoi qu'il en fût, Cosette s'était toujours crue laide, et avait grandi dans cette idée avec la résignation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si j'étais jolie ? pensait-elle, comme cela serait drôle que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté faisait effet dans le couvent, et elle se disait : Comment ! je serais comme mademoiselle une telle!\n"
"sdfsqdfqsdjfhqlskdjhf qlksjdhflqkjsdhlfkqjshdlkfjqhslkdjfhqlskdjhfqlksjdhflqkjsdhflkqjsdhlkfqjshdlkfjqshldkjqfhsldkfjqhslkdjfqhlskdjfhqlskjdhflqksjdhflkqjshdlfkqjsdf\n\n"
"Le lendemain elle se regarda, mais non par hasard, et elle douta: Où avais-je l'esprit ? dit-elle, non, je suis laide. Elle avait tout simplement mal dormi, elle avait les yeux battus et elle était pâle. Elle ne s'était pas sentie très joyeuse la veille de croire à sa beauté, mais elle fut triste de n'y plus croire. Elle ne se regarda plus, et pendant plus de quinze jours elle tâcha de se coiffer tournant le dos au miroir.\n"
"Le soir, après le dîner, elle faisait assez habituellement de la tapisserie dans le salon, ou quelque ouvrage de couvent, et Jean Valjean lisait à côté d'elle. Une fois elle leva les yeux de son ouvrage et elle fut toute surprise de la façon inquiète dont son père la regardait.\n"
"Une autre fois, elle passait dans la rue, et il lui sembla que quelqu'un qu'elle ne vit pas disait derrière elle : Jolie femme ! mais mal mise. Bah ! pensa-t-elle, ce n'est pas moi. Je suis bien mise et laide. Elle avait alors son chapeau de peluche et sa robe de mérinos.\n"
"Un jour enfin, elle était dans le jardin, et elle entendit la pauvre vieille Toussaint qui disait : Monsieur, remarquez-vous comme mademoiselle devient jolie ? Cosette n'entendit pas ce que son père répondit, les paroles de Toussaint furent pour elle une sorte de commotion. Elle s'échappa du jardin, monta à sa chambre, courut à la glace, il y avait trois mois qu'elle ne s'était regardée, et poussa un cri. Elle venait de s'éblouir elle-même.";
m_displayText.SetPos(etk::Vector3D<float>((float)40,(float)m_size.y-50,(float)0) );
m_displayText.SetTextAlignement(20, m_size.x-20, ewol::Text::alignJustify);
m_displayText.SetPos(etk::Vector3D<float>((float)40,(float)m_size.y-100,(float)0) );
m_displayText.SetTextAlignement(20, m_size.x-20, m_alignement);
m_displayText.Print(tmpString);
draw::Color tmpColor = 0x0000FF55;
m_displayDrawing.SetColor(tmpColor);
m_displayDrawing.Tranlate(etk::Vector3D<float>(100, 100, 0) );
m_displayDrawing.SetThickness(2);
m_displayDrawing.Rectangle(etk::Vector3D<float>(200, 200, 0) );
m_displayDrawing.SetColor(0x00F46799);
m_displayDrawing.SetPos(etk::Vector3D<float>(300, 0, 0) );
m_displayDrawing.SetThickness(20);
m_displayDrawing.LineTo(etk::Vector3D<float>(200, 200, 0) );
// force the redraw
PeriodicCallSet(true);
MarkToRedraw();
@ -253,6 +396,30 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even
etk::Vector2D<float> limitedPos = relativePos;
limitedPos.x = etk_avg(1, limitedPos.x, m_size.x-1);
limitedPos.y = etk_avg(1, limitedPos.y, m_size.y-1);
if (1 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
APPL_DEBUG("Must change the display ... ");
switch (m_alignement)
{
case ewol::Text::alignJustify:
m_alignement = ewol::Text::alignLeft;
break;
case ewol::Text::alignLeft:
m_alignement = ewol::Text::alignRight;
break;
case ewol::Text::alignRight:
m_alignement = ewol::Text::alignCenter;
break;
case ewol::Text::alignCenter:
m_alignement = ewol::Text::alignDisable;
break;
case ewol::Text::alignDisable:
m_alignement = ewol::Text::alignJustify;
break;
}
MarkToRedraw();
}
}
if (m_bufferID < 0) {
return false;

View File

@ -35,6 +35,7 @@
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/ResourceManager.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Draw.h>
class CodeView :public ewol::WidgetScrooled
{
@ -62,8 +63,10 @@ class CodeView :public ewol::WidgetScrooled
// drawing elements :
ewol::TEXT_DISPLAY_TYPE m_OObjectText;
ewol::Text m_displayText;
ewol::Drawing m_displayDrawing;
ewol::OObject2DColored m_OObjectsColored;
// TODO : Remove :
ewol::Text::aligneMode_te m_alignement;
public:
virtual void OnRegenerateDisplay(void);
/**