[DEV] continue rework

This commit is contained in:
Edouard DUPIN 2021-03-16 00:31:42 +01:00
parent 53685bb0f1
commit 84630233c0
6 changed files with 404 additions and 2226 deletions

View File

@ -1,558 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/debug.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::compositing::Drawing);
// VBO table property:
int ewol::compositing::Drawing::this.vboIdCoord(0);
int ewol::compositing::Drawing::this.vboIdColor(1);
#define NB_VBO (2)
#if 0
static void generatePolyGone(List<Vector2f > input, List<Vector2f > output )
{
if (input.size()<3) {
return;
}
// TODO : Regenerate a linear poligone generation
for (int iii=1; iii<input.size()-1; iii++) {
output.pushBack(input[0]);
output.pushBack(input[iii]);
output.pushBack(input[iii+1]);
}
//Log.debug("generate Plygone : " + input.size() + " == > " + output.size() );
}
static void SutherlandHodgman(List<Vector2f > input, List<Vector2f > output, float sx, float sy, float ex, float ey)
{
// with Sutherland-Hodgman-Algorithm
if (input.size() <0) {
return;
}
//int sizeInit=input.size();
// last element :
Vector2f destPoint;
Vector2f lastElement = input[input.size()-1];
boolean inside = true;
if (lastElement.x < sx) {
inside = false;
}
//Log.debug("generate an crop : ");
for(int iii=0; iii<input.size(); iii++) {
if(input[iii].x < sx) {
if(true == inside) {
//Log.debug("element IN == > OUT ");
//new point intersection ...
//y=aaax+bbb
float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
float bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*sx + bbb;
destPoint.x = sx;
output.pushBack(destPoint);
} else {
//Log.debug("element OUT == > OUT ");
}
inside = false;
} else {
if(true == inside) {
//Log.debug("element IN == > IN ");
output.pushBack(input[iii]);
} else {
//Log.debug("element OUT == > IN ");
//new point intersection ...
//y=aaax+bbb
float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
float bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*sx + bbb;
destPoint.x = sx;
output.pushBack(destPoint);
output.pushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
//Log.debug("generate an crop on element : " + sizeInit + " == > " + output.size() + "intermediate (1)");
input = output;
output.clear();
lastElement = input[input.size()-1];
inside = true;
if (lastElement.y < sy) {
inside = false;
}
for(int iii=0; iii<input.size(); iii++) {
if(input[iii].y < sy) {
if(true == inside) {
//Log.debug("element IN == > OUT ");
//new point intersection ...
//x=aaay+bbb
float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
float bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = sy;
destPoint.x = sy*aaa + bbb;
output.pushBack(destPoint);
} else {
//Log.debug("element OUT == > OUT ");
}
inside = false;
} else {
if(true == inside) {
//Log.debug("element IN == > IN ");
output.pushBack(input[iii]);
} else {
//Log.debug("element OUT == > IN ");
//new point intersection ...
//y=aaax+bbb
float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
float bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = sy;
destPoint.x = sy*aaa + bbb;
output.pushBack(destPoint);
output.pushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
input = output;
output.clear();
lastElement = input[input.size()-1];
inside = true;
if (lastElement.x > ex) {
inside = false;
}
//Log.debug("generate an crop : ");
for(int iii=0; iii<input.size(); iii++) {
if(input[iii].x > ex) {
if(true == inside) {
//Log.debug("element IN == > OUT ");
//new point intersection ...
//y=aaax+bbb
float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
float bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*ex + bbb;
destPoint.x = ex;
output.pushBack(destPoint);
} else {
//Log.debug("element OUT == > OUT ");
}
inside = false;
} else {
if(true == inside) {
//Log.debug("element IN == > IN ");
output.pushBack(input[iii]);
} else {
//Log.debug("element OUT == > IN ");
//new point intersection ...
//y=aaax+bbb
float aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
float bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*ex + bbb;
destPoint.x = ex;
output.pushBack(destPoint);
output.pushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
input = output;
output.clear();
lastElement = input[input.size()-1];
inside = true;
if (lastElement.y > ey) {
inside = false;
}
for(int iii=0; iii<input.size(); iii++) {
if(input[iii].y > ey) {
if(true == inside) {
//Log.debug("element IN == > OUT ");
//new point intersection ...
//x=aaay+bbb
float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
float bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = ey;
destPoint.x = ey*aaa + bbb;
output.pushBack(destPoint);
} else {
//Log.debug("element OUT == > OUT ");
}
inside = false;
} else {
if(true == inside) {
//Log.debug("element IN == > IN ");
output.pushBack(input[iii]);
} else {
//Log.debug("element OUT == > IN ");
//new point intersection ...
//y=aaax+bbb
float aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
float bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = ey;
destPoint.x = ey*aaa + bbb;
output.pushBack(destPoint);
output.pushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
//Log.debug("generate an crop on element : " + sizeInit + " == > " + output.size() );
}
#endif
ewol::compositing::Drawing::Drawing() :
this.position(0.0, 0.0, 0.0),
this.clippingPosStart(0.0, 0.0, 0.0),
this.clippingPosStop(0.0, 0.0, 0.0),
this.clippingEnable(false),
this.color(etk::color::black),
this.colorBg(etk::color::none),
this.GLprogram(null),
this.GLPosition(-1),
this.GLMatrix(-1),
this.GLMatrixPosition(-1),
this.GLColor(-1),
this.thickness(0.0),
this.triElement(0) {
loadProgram();
for (int iii=0; iii<3; iii++) {
this.triangle[iii] = this.position;
this.tricolor[iii] = this.color;
}
// Create the VBO:
this.VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
if (this.VBO == null) {
Log.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO:
this.VBO.setName("[VBO] of ewol::compositing::Area");
}
ewol::compositing::Drawing::~Drawing() {
unLoadProgram();
}
void ewol::compositing::Drawing::generateTriangle() {
this.triElement = 0;
this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[0]);
this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[0]);
this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[1]);
this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[1]);
this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[2]);
this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[2]);
}
void ewol::compositing::Drawing::internalSetColor( etk::Color<> _color) {
if (this.triElement < 1) {
this.tricolor[0] = _color;
}
if (this.triElement < 2) {
this.tricolor[1] = _color;
}
if (this.triElement < 3) {
this.tricolor[2] = _color;
}
}
void ewol::compositing::Drawing::setPoint( Vector3f _point) {
this.triangle[this.triElement] = _point;
this.triElement++;
if (this.triElement >= 3) {
generateTriangle();
}
this.VBO.flush();
}
void ewol::compositing::Drawing::resetCount() {
this.triElement = 0;
}
void ewol::compositing::Drawing::unLoadProgram() {
this.GLprogram.reset();
}
void ewol::compositing::Drawing::loadProgram() {
// remove previous loading ... in case
unLoadProgram();
// oad the new ...
this.GLprogram = gale::resource::Program::create("DATA:///color3.prog?lib=ewol");
// get the shader resource :
if (this.GLprogram != null) {
this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
this.GLColor = this.GLprogram.getAttribute("EW_color");
this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
this.GLMatrixPosition = this.GLprogram.getUniform("EW_MatrixPosition");
}
}
void ewol::compositing::Drawing::draw(boolean _disableDepthTest) {
if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
// TODO : set it back ...
//Log.warning("Nothink to draw...");
return;
}
if (this.GLprogram == null) {
Log.error("No shader ...");
return;
}
// set Matrix : translation/positionMatrix
Matrix4f tmpMatrix = gale::openGL::getMatrix()*this.matrixApply;
this.GLprogram.use();
this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
Matrix4f tmpMatrix2;
this.GLprogram.uniformMatrix(this.GLMatrixPosition, tmpMatrix2);
// position:
this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// color:
this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
// Request the draw od the elements :
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
this.GLprogram.unUse();
}
void ewol::compositing::Drawing::clear() {
// call upper class
ewol::Compositing::clear();
// reset Buffer :
this.VBO.clear();
// reset temporal variables :
this.position = Vector3f(0.0, 0.0, 0.0);
this.clippingPosStart = Vector3f(0.0, 0.0, 0.0);
this.clippingPosStop = Vector3f(0.0, 0.0, 0.0);
this.clippingEnable = false;
this.color = etk::color::black;
this.colorBg = etk::color::none;
for (int iii=0; iii<3; iii++) {
this.triangle[iii] = this.position;
this.tricolor[iii] = this.color;
}
}
void ewol::compositing::Drawing::setClipping( Vector3f _pos, Vector3f _posEnd) {
// note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) {
this.clippingPosStart.setX(_pos.x());
this.clippingPosStop.setX(_posEnd.x());
} else {
this.clippingPosStart.setX(_posEnd.x());
this.clippingPosStop.setX(_pos.x());
}
if (_pos.y() <= _posEnd.y()) {
this.clippingPosStart.setY(_pos.y());
this.clippingPosStop.setY(_posEnd.y());
} else {
this.clippingPosStart.setY(_posEnd.y());
this.clippingPosStop.setY(_pos.y());
}
if (_pos.z() <= _posEnd.z()) {
this.clippingPosStart.setZ(_pos.z());
this.clippingPosStop.setZ(_posEnd.z());
} else {
this.clippingPosStart.setZ(_posEnd.z());
this.clippingPosStop.setZ(_pos.z());
}
this.clippingEnable = true;
}
void ewol::compositing::Drawing::setThickness(float _thickness) {
this.thickness = _thickness;
// thickness must be positive
if (this.thickness < 0) {
this.thickness *= -1;
}
}
void ewol::compositing::Drawing::addVertex() {
internalSetColor(this.color);
setPoint(this.position);
}
void ewol::compositing::Drawing::lineTo( Vector3f _dest) {
resetCount();
internalSetColor(this.color);
//Log.verbose("DrawLine : " + this.position + " to " + _dest);
if (this.position.x() == _dest.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.position.y() == _dest.y() LOMLOMLOMLOMLOM this.position.z() == _dest.z()) {
//Log.warning("Try to draw a line width 0");
return;
}
//teta = tan-1(oposer/adjacent)
float teta = 0;
if (this.position.x() <= _dest.x()) {
teta = atan((_dest.y()-this.position.y())/(_dest.x()-this.position.x()));
} else {
teta = M_PI + atan((_dest.y()-this.position.y())/(_dest.x()-this.position.x()));
}
if (teta < 0) {
teta += 2*M_PI;
} else if (teta > 2*M_PI) {
teta -= 2*M_PI;
}
//Log.debug("teta = " + (teta*180/(M_PI)) + " deg." );
float offsety = sin(teta-M_PI/2) * (this.thickness/2);
float offsetx = cos(teta-M_PI/2) * (this.thickness/2);
setPoint(Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z()) );
setPoint(Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z()) );
setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, this.position.z()) );
setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, _dest.z()) );
setPoint(Vector3f(_dest.x() - offsetx, _dest.y() - offsety, _dest.z()) );
setPoint(Vector3f(this.position.x() - offsetx, this.position.y() - offsety, _dest.z()) );
// update the system position :
this.position = _dest;
}
void ewol::compositing::Drawing::rectangle( Vector3f _dest) {
resetCount();
internalSetColor(this.color);
/* Bitmap position
* xA xB
* yC *------*
* | |
* | |
* yD *------*
*/
float dxA = this.position.x();
float dxB = _dest.x();
if (dxA > dxB) {
// inverse order :
float tmp = dxA;
dxA = dxB;
dxB = tmp;
}
float dyC = this.position.y();
float dyD = _dest.y();
if (dyC > dyD) {
// inverse order :
float tmp = dyC;
dyC = dyD;
dyD = tmp;
}
if (true == this.clippingEnable) {
if (dxA < this.clippingPosStart.x()) {
dxA = this.clippingPosStart.x();
}
if (dxB > this.clippingPosStop.x()) {
dxB = this.clippingPosStop.x();
}
if (dyC < this.clippingPosStart.y()) {
dyC = this.clippingPosStart.y();
}
if (dyD > this.clippingPosStop.y()) {
dyD = this.clippingPosStop.y();
}
}
if( dyC >= dyD
|| dxA >= dxB) {
return;
}
setPoint(Vector3f(dxA, dyD, 0) );
setPoint(Vector3f(dxA, dyC, 0) );
setPoint(Vector3f(dxB, dyC, 0) );
setPoint(Vector3f(dxB, dyC, 0) );
setPoint(Vector3f(dxB, dyD, 0) );
setPoint(Vector3f(dxA, dyD, 0) );
}
void ewol::compositing::Drawing::cube( Vector3f _dest) {
}
void ewol::compositing::Drawing::circle(float _radius, float _angleStart, float _angleStop) {
resetCount();
if (_radius<0) {
_radius *= -1;
}
_angleStop = _angleStop-_angleStart;
int nbOcurence = _radius;
if (nbOcurence < 10)
{
nbOcurence = 10;
}
// display background :
if (this.colorBg.a()!=0) {
internalSetColor(this.colorBg);
for (int iii=0; iii<nbOcurence; iii++) {
setPoint(Vector3f(this.position.x(),
this.position.y(),
0) );
float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ;
float offsety = sin(angleOne) * _radius;
float offsetx = cos(angleOne) * _radius;
setPoint(Vector3f(this.position.x() + offsetx,
this.position.y() + offsety,
0) );
float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence) ;
offsety = sin(angleTwo) * _radius;
offsetx = cos(angleTwo) * _radius;
setPoint(Vector3f(this.position.x() + offsetx,
this.position.y() + offsety,
0) );
}
}
// show if we have a border :
if( this.thickness == 0
|| this.color.a() == 0) {
return;
}
internalSetColor(this.color);
for (int iii=0; iii<nbOcurence; iii++) {
float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ;
float offsetExty = sin(angleOne) * (_radius+this.thickness/2);
float offsetExtx = cos(angleOne) * (_radius+this.thickness/2);
float offsetInty = sin(angleOne) * (_radius-this.thickness/2);
float offsetIntx = cos(angleOne) * (_radius-this.thickness/2);
float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence );
float offsetExt2y = sin(angleTwo) * (_radius+this.thickness/2);
float offsetExt2x = cos(angleTwo) * (_radius+this.thickness/2);
float offsetInt2y = sin(angleTwo) * (_radius-this.thickness/2);
float offsetInt2x = cos(angleTwo) * (_radius-this.thickness/2);
setPoint(Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
setPoint(Vector3f(this.position.x() + offsetExtx, this.position.y() + offsetExty, 0));
setPoint(Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
setPoint(Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
setPoint(Vector3f(this.position.x() + offsetInt2x, this.position.y() + offsetInt2y, 0));
setPoint(Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
}
}

View File

@ -1,275 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.ewol.compositing;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualBufferObject;
class Drawing extends Compositing {
private Vector3f position = new Vector3f(0, 0, 0); //!< The current position to draw
private final Vector3f clippingPosStart = new Vector3f(0, 0, 0); //!< Clipping start position
private final Vector3f clippingPosStop = new Vector3f(0, 0, 0); //!< Clipping stop position
private boolean clippingEnable = false; //!< true if the clipping must be activated
private Color color = Color.BLACK.clone(); //!< The text foreground color
private Color colorBg = Color.NONE.clone(); //!< The text background color
private ResourceProgram GLprogram; //!< pointer on the opengl display program
private final int GLPosition = -1; //!< openGL id on the element (vertex buffer)
private final int GLMatrix = -1; //!< openGL id on the element (transformation matrix)
private final int GLMatrixPosition = -1; //!< position matrix
private final int GLColor = -1; //!< openGL id on the element (color buffer)
protected static int vboIdCoord = 0;
protected static int vboIdColor = 1;
protected ResourceVirtualBufferObject VBO;
/**
* @brief Basic ructor
*/
public Drawing() {
loadProgram();
for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position;
this.tricolor[iii] = this.color;
}
// Create the VBO:
this.VBO = ResourceVirtualBufferObject.create(4);
if (this.VBO == null) {
Log.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO:
this.VBO.setName("[VBO] of ewol::compositing::Area");
}
/**
* @brief load the openGL program and get all the ID needed
*/
private void loadProgram();
/**
* @brief Un-Load the openGL program and get all the ID needed
*/
private void unLoadProgram();
private final float thickness = 0; //!< when drawing line and other things
private final int triElement = 0; //!< special counter of the single dot generated
private final Vector3f[] triangle = new Vector3f[3]; //!< Register every system with a combinaison of tiangle
private final Color[] tricolor = new Color[3]; //!< Register every the associated color foreground
// internal API for the generation abstraction of triangles
/**
* @brief Lunch the generation of triangle
*/
private void generateTriangle() {
this.triElement = 0;
this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[0]);
this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[0]);
this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[1]);
this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[1]);
this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[2]);
this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[2]);
};
/**
* @brief in case of some error the count can be reset
*/
private void resetCount();
/**
* @brief set the Color of the current triangle drawing
* @param[in] _color Color to current dots generated
*/
private void internalSetColor(Color _color);
/**
* @brief internal add of the specific point
* @param[in] _point The requeste dpoint to add
*/
private void setPoint(Vector3f point);
/**
* @brief draw All the refistered text in the current element on openGL
*/
@Override
public void draw(final boolean _disableDepthTest=true);
/**
* @brief clear alll tre registered element in the current element
*/
@Override
public void clear();
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current position.
*/
public Vector3f getPos() {
return this.position;
};
/**
* @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D)
*/
public void setPos(final Vector3f _pos) {
this.position = _pos;
};
public void setPos(final Vector2f _pos) {
setPos(Vector3f(_pos.x(), _pos.y(), 0));
};
/**
* @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D)
*/
public void setRelPos(final Vector3f _pos) {
this.position += _pos;
};
public void setRelPos(final Vector2f _pos) {
setRelPos(Vector3f(_pos.x(), _pos.y(), 0));
};
/**
* @brief set the Color of the current foreground font
* @param[in] _color Color to set on foreground (for next print)
*/
public void setColor(final Color _color) {
this.color = _color;
};
/**
* @brief Get the foreground color of the font.
* @return Foreground color.
*/
public Color getColor() {
return this.color;
};
/**
* @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)
*/
public void setColorBg(final Color _color) {
this.colorBg = _color;
};
/**
* @brief Get the background color of the font.
* @return Background color.
*/
public Color getColorBg() {
return this.colorBg;
};
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in]_ pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
public void setClippingWidth(final Vector3f _pos, final Vector3f _width) {
setClipping(_pos, _pos + _width);
};
public void setClippingWidth(final Vector2f _pos, final Vector2f _width) {
setClippingWidth(Vector3f(_pos.x(), _pos.y(), -1), Vector3f(_width.x(), _width.y(), 2));
};
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _posEnd End position of the clipping
*/
public void setClipping(Vector3f _pos, Vector3f _posEnd);
public void setClipping(final Vector2f _pos, final Vector2f _posEnd) {
setClipping(Vector3f(_pos.x(), _pos.y(), -1), Vector3f(_posEnd.x(), _posEnd.y(), 1));
};
/**
* @brief enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping
*/
public void setClippingMode(final boolean _newMode) {
this.clippingEnable = _newMode;
};
/**
* @brief Specify the line thickness for the next elements
* @param[in] _thickness The thickness disired for the next print
*/
public void setThickness(float _thickness);
/**
* @brief add a point reference at the current position (this is a vertex reference at the current position
*/
public void addVertex();
/**
* @brief draw a line to a specific position
* @param[in] _dest Position of the end of the line.
*/
public void lineTo(Vector3f _dest);
public void lineTo(final Vector2f _dest) {
lineTo(new Vector3f(_dest.x, _dest.y, 0));
};
/**
* @brief Relative drawing a line (spacial vector)
* @param[in] _vect Vector of the curent line.
*/
public void lineRel(final Vector3f _vect) {
lineTo(this.position.addNew(_vect));
};
public void lineRel(final Vector2f _vect) {
lineRel(new Vector3f(_vect.x, _vect.y, 0));
};
/**
* @brief draw a 2D rectangle to the position requested.
* @param[in] _dest Position the the end of the rectangle
*/
public void rectangle(Vector3f _dest);
public void rectangle(final Vector2f _dest) {
rectangle(Vector3f(_dest.x(), _dest.y(), 0));
};
/**
* @brief draw a 2D rectangle to the requested size.
* @param[in] _size size of the rectangle
*/
public void rectangleWidth(final Vector3f _size) {
rectangle(this.position + _size);
};
public void rectangleWidth(final Vector2f _size) {
rectangleWidth(Vector3f(_size.x(), _size.y(), 0));
};
/**
* @brief draw a 3D rectangle to the position requested.
* @param[in] _dest Position the the end of the rectangle
*/
public void cube(Vector3f _dest);
/**
* @brief draw a 2D circle with the specify rafdius parameter.
* @param[in] _radius Distence to the dorder
* @param[in] _angleStart start angle of this circle ([0..2PI] otherwithe == > disable)
* @param[in] _angleStop stop angle of this circle ([0..2PI] otherwithe == > disable)
*/
public void circle(final float _radius, final float _angleStart = 0, float _angleStop = 2*M_PI);
}

View File

@ -1,693 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/uri/uri.hpp>
#include <ewol/debug.hpp>
#include <ewol/compositing/Shaper.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::compositing::Shaper);
// VBO table property:
int ewol::compositing::Shaper::this.vboIdCoord(0);
int ewol::compositing::Shaper::this.vboIdPos(1);
#define NB_VBO (2)
ewol::compositing::Shaper::Shaper( etk::Uri _uri) :
this.uri(_uri),
this.config(null),
this.confIdMode(-1),
this.confIdDisplayOutside(-1),
this.confIdChangeTime(-1),
this.confProgramFile(-1),
this.confColorFile(-1),
this.confImageFile(-1),
this.GLprogram(null),
this.GLPosition(-1),
this.GLMatrix(-1),
this.GLStateActivate(-1),
this.GLStateOld(-1),
this.GLStateNew(-1),
this.GLStateTransition(-1),
this.resourceTexture(null),
this.nextStatusRequested(-1),
this.propertyOrigin(0,0),
this.propertySize(0,0),
this.propertyInsidePosition(0,0),
this.propertyInsideSize(0,0),
this.stateActivate(0),
this.stateOld(0),
this.stateNew(0),
this.stateTransition(1.0),
this.nbVertexToDisplay(0) {
for (int iii=0; iii<shaperPosCount; ++iii) {
this.confIdPaddingOut[iii] = -1;
this.confIdBorder[iii] = -1;
this.confIdPaddingIn[iii] = -1;
}
// Create the VBO:
this.VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
if (this.VBO == null) {
Log.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO:
this.VBO.setName("[VBO] of ewol::compositing::Shaper");
loadProgram();
}
ewol::compositing::Shaper::~Shaper() {
unLoadProgram();
}
void ewol::compositing::Shaper::unLoadProgram() {
this.GLprogram.reset();
this.resourceTexture.reset();
this.config.reset();
this.colorProperty.reset();
for (int iii=0; iii<shaperPosCount; ++iii) {
this.confIdPaddingOut[iii] = -1;
this.confIdBorder[iii] = -1;
this.confIdPaddingIn[iii] = -1;
}
this.VBO.clear();
this.confIdMode = -1;
this.confIdDisplayOutside = -1;
this.nbVertexToDisplay = 0;
this.confIdChangeTime = -1;
this.confProgramFile = -1;
this.confImageFile = -1;
this.listAssiciatedId.clear();
}
void ewol::compositing::Shaper::loadProgram() {
if (this.uri.isEmpty() == true) {
Log.debug("no Shaper set for loading resources ...");
return;
}
this.config = ewol::resource::ConfigFile::create(this.uri.get());
if (this.config != null) {
this.confIdMode = this.config.request("mode");
this.confIdDisplayOutside = this.config.request("display-outside");
this.confIdPaddingOut[shaperPosLeft] = this.config.request("padding-out-left");
this.confIdPaddingOut[shaperPosRight] = this.config.request("padding-out-right");
this.confIdPaddingOut[shaperPosTop] = this.config.request("padding-out-top");
this.confIdPaddingOut[shaperPosButtom] = this.config.request("padding-out-buttom");
this.confIdBorder[shaperPosLeft] = this.config.request("border-left");
this.confIdBorder[shaperPosRight] = this.config.request("border-right");
this.confIdBorder[shaperPosTop] = this.config.request("border-top");
this.confIdBorder[shaperPosButtom] = this.config.request("border-buttom");
this.confIdPaddingIn[shaperPosLeft] = this.config.request("padding-in-left");
this.confIdPaddingIn[shaperPosRight] = this.config.request("padding-in-right");
this.confIdPaddingIn[shaperPosTop] = this.config.request("padding-in-top");
this.confIdPaddingIn[shaperPosButtom] = this.config.request("padding-in-buttom");
this.confIdChangeTime = this.config.request("change-time");
this.confProgramFile = this.config.request("program");
this.confImageFile = this.config.request("image");
this.confColorFile = this.config.request("color");
}
String basicShaderFile = this.config.getString(this.confProgramFile);
if (basicShaderFile != "") {
String tmpFilename(basicShaderFile);
if (tmpFilename.find(':') == String::npos) {
// get the relative position of the current file ...
etk::Uri tmpUri = this.uri;
tmpUri.setPath(this.uri.getPath().getParent() / basicShaderFile);
tmpFilename = tmpUri.get();
Log.debug("Shaper try load shader : '" + tmpFilename + "' with base : '" + basicShaderFile + "'");
} else {
Log.debug("Shaper try load shader : '" + tmpFilename + "'");
}
// get the shader resource :
this.GLPosition = 0;
this.GLprogram = gale::resource::Program::create(tmpFilename);
if (this.GLprogram != null) {
this.GLPosition = this.GLprogram.getAttribute("EW_coord2d");
this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
// Widget property == > for the Vertex shader
this.GLPropertyPos = this.GLprogram.getAttribute("EW_widgetPropertyPos");
// status property == > for the fragment shader
this.GLStateActivate = this.GLprogram.getUniform("EW_status.activate");
this.GLStateOld = this.GLprogram.getUniform("EW_status.stateOld");
this.GLStateNew = this.GLprogram.getUniform("EW_status.stateNew");
this.GLStateTransition = this.GLprogram.getUniform("EW_status.transition");
// for the texture ID :
this.GLtexID = this.GLprogram.getUniform("EW_texID");
}
String basicImageFile = this.config.getString(this.confImageFile);
if (basicImageFile != "") {
String tmpFilename(basicImageFile);
if (tmpFilename.find(':') == String::npos) {
// get the relative position of the current file ...
etk::Uri tmpUri = this.uri;
tmpUri.setPath(this.uri.getPath().getParent() / basicImageFile);
tmpFilename = tmpUri.get();
Log.debug("Shaper try load shaper image : '" + tmpFilename + "' with base : '" + basicImageFile + "'");
} else {
Log.debug("Shaper try load shaper image : '" + tmpFilename + "'");
}
Vector2i size(64,64);
this.resourceTexture = ewol::resource::TextureFile::create(tmpFilename, size);
}
}
String basicColorFile = this.config.getString(this.confColorFile);
if (basicColorFile != "") {
String tmpFilename(basicColorFile);
if (tmpFilename.find(':') == String::npos) {
// get the relative position of the current file ...
etk::Uri tmpUri = this.uri;
tmpUri.setPath(this.uri.getPath().getParent() / basicColorFile);
tmpFilename = tmpUri.get();
Log.debug("Shaper try load colorFile : '" + tmpFilename + "' with base : '" + basicColorFile + "'");
} else {
Log.debug("Shaper try load colorFile : '" + tmpFilename + "'");
}
this.colorProperty = ewol::resource::ColorFile::create(tmpFilename);
if ( this.GLprogram != null
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorProperty != null) {
List<String> listColor = this.colorProperty.getColors();
for (auto tmpColor : listColor) {
int glId = this.GLprogram.getUniform(tmpColor);
int colorID = this.colorProperty.request(tmpColor);
this.listAssiciatedId.pushBack(Vector2i(glId, colorID));
}
}
}
}
void ewol::compositing::Shaper::draw(boolean _disableDepthTest) {
if (this.config == null) {
// this is a normale case ... the user can choice to have no config basic file ...
return;
}
if (this.GLprogram == null) {
Log.error("No shader ...");
return;
}
if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
return;
}
//glScalef(this.scaling.x, this.scaling.y, 1.0);
this.GLprogram.use();
// set Matrix : translation/positionMatrix
Matrix4f tmpMatrix = gale::openGL::getMatrix();
this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position:
this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// property
this.GLprogram.sendAttributePointer(this.GLPropertyPos, this.VBO, this.vboIdPos);
// all entry parameters :
this.GLprogram.uniform1i(this.GLStateActivate, this.stateActivate);
this.GLprogram.uniform1i(this.GLStateOld, this.stateOld);
this.GLprogram.uniform1i(this.GLStateNew, this.stateNew);
this.GLprogram.uniform1f(this.GLStateTransition, this.stateTransition);
for (auto element : this.listAssiciatedId) {
this.GLprogram.uniform(element.x(), this.colorProperty.get(element.y()));
}
if (this.resourceTexture != null) {
// TextureID
this.GLprogram.setTexture0(this.GLtexID, this.resourceTexture.getRendererId());
}
// Request the draw of the elements :
//gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, SHAPER_NB_MAX_VERTEX);
gale::openGL::drawArrays(gale::openGL::renderMode::triangleStrip, 0, this.nbVertexToDisplay);
this.GLprogram.unUse();
}
void ewol::compositing::Shaper::clear() {
// nothing to do ...
this.propertySize = Vector2f(0,0);
this.propertyOrigin = Vector2f(0,0);
this.propertyInsidePosition = Vector2f(0,0);
this.propertyInsideSize = Vector2f(0,0);
this.VBO.clear();
}
boolean ewol::compositing::Shaper::setState(int _newState) {
if (this.stateActivate == _newState) {
return false;
}
this.stateActivate = _newState;
return true;
}
boolean ewol::compositing::Shaper::changeStatusIn(int _newStatusId) {
if (_newStatusId != this.stateNew) {
this.nextStatusRequested = _newStatusId;
return true;
}
if( this.nextStatusRequested != -1
|| this.stateNew != this.stateOld) {
return true;
}
return false;
}
boolean ewol::compositing::Shaper::periodicCall( ewol::event::Time _event) {
Log.verbose("call=" + _event + "state transition=" + this.stateTransition + " speedTime=" + this.config.getNumber(this.confIdChangeTime));
// start :
if (this.stateTransition >= 1.0) {
this.stateOld = this.stateNew;
if( this.nextStatusRequested != -1
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.nextStatusRequested != this.stateOld) {
this.stateNew = this.nextStatusRequested;
this.nextStatusRequested = -1;
this.stateTransition = 0.0;
Log.verbose(" ##### START ##### ");
} else {
this.nextStatusRequested = -1;
// disable periodic call ...
return false;
}
}
if (this.stateTransition<1.0) {
// check if no new state requested:
if (this.nextStatusRequested != -1 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.stateTransition<0.5) {
// invert sources with destination
int tmppp = this.stateOld;
this.stateOld = this.stateNew;
this.stateNew = tmppp;
this.stateTransition = 1.0 - this.stateTransition;
if (this.nextStatusRequested == this.stateNew) {
this.nextStatusRequested = -1;
}
}
float timeRelativity = 0.0f;
if (this.config != null) {
timeRelativity = this.config.getNumber(this.confIdChangeTime) / 1000.0;
}
this.stateTransition += _event.getDeltaCall() / timeRelativity;
//this.stateTransition += _event.getDeltaCall();
this.stateTransition = etk::avg(0.0f, this.stateTransition, 1.0f);
Log.verbose("relative=" + timeRelativity + " Transition : " + this.stateTransition);
}
return true;
}
//Create Line:
void ewol::compositing::Shaper::addVertexLine(float _yTop,
float _yButtom,
float _x1,
float _x2,
float _x3,
float _x4,
float _x5,
float _x6,
float _x7,
float _x8,
float _yValTop,
float _yValButtom,
float* _table,
boolean _displayOutside) {
if (this.nbVertexToDisplay != 0) {
// change line ...
this.VBO.pushOnBuffer(this.vboIdCoord,
this.VBO.getOnBufferVec2(this.vboIdCoord, this.nbVertexToDisplay-1));
this.VBO.pushOnBuffer(this.vboIdPos,
this.VBO.getOnBufferVec2(this.vboIdPos, this.nbVertexToDisplay-1));
this.nbVertexToDisplay++;
if (_displayOutside == true) {
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValButtom));
this.nbVertexToDisplay++;
} else {
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom));
this.nbVertexToDisplay++;
}
}
if (_displayOutside == true) {
// A
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValButtom));
this.nbVertexToDisplay++;
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValTop));
this.nbVertexToDisplay++;
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom));
this.nbVertexToDisplay++;
// B
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValTop));
this.nbVertexToDisplay++;
// C
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValButtom));
this.nbVertexToDisplay++;
} else {
// C
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom));
this.nbVertexToDisplay++;
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValTop));
this.nbVertexToDisplay++;
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValButtom));
this.nbVertexToDisplay++;
}
// D
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValTop));
this.nbVertexToDisplay++;
// E
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x4, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[3],_yValButtom));
this.nbVertexToDisplay++;
// F
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x4, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[3],_yValTop));
this.nbVertexToDisplay++;
// G
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x5, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[4],_yValButtom));
this.nbVertexToDisplay++;
// H
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x5, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[4],_yValTop));
this.nbVertexToDisplay++;
// I
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x6, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[5],_yValButtom));
this.nbVertexToDisplay++;
// J
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x6, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[5],_yValTop));
this.nbVertexToDisplay++;
// K
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x7, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[6],_yValButtom));
this.nbVertexToDisplay++;
// L
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x7, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[6],_yValTop));
this.nbVertexToDisplay++;
if (_displayOutside == true) {
// M
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x8, _yButtom));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[7],_yValButtom));
this.nbVertexToDisplay++;
// N
this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x8, _yTop));
this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[7],_yValTop));
this.nbVertexToDisplay++;
}
}
float modeDisplay[][8] = {
/* !! 0 !!
* / *******
* / ****** /
* ****** /
*/
{ 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f },
/* !! 1 !!
* ****** \
* \ ****** \
* \ *******
*/
{ 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f },
/* !! 2 !!
* / ****** \
* ****** / \ *******
*/
{ 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f },
/* !! 3 !!
* ****** \ / *******
* \ ****** /
*/
{ 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f },
/* !! 4 !!
* / *******
* / ****** /
* ****** /
*/
{ -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f },
/* !! 5 !!
* ****** \
* \ ****** \
* \ *******
*/
{ 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, -1.0f },
/* !! 6 !!
* / ****** \
* ****** / \ *******
*/
{ -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f },
/* !! 7 !!
* ****** \ / *******
* \ ****** /
*/
{ 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f }
};
void ewol::compositing::Shaper::setShape( Vector2f _origin, Vector2f _size, Vector2f _insidePos, Vector2f _insideSize) {
this.VBO.clear();
ewol::Padding borderTmp = getBorder();
ewol::Padding paddingIn = getPaddingIn();
ewol::Padding paddingOut = getPaddingOut();
ewol::Padding padding = paddingIn + borderTmp + paddingOut;
ewol::Padding enveloppe(_origin.x(),
_origin.y() + _size.y(),
_origin.x() + _size.x(),
_origin.y());
#if 0
ewol::Padding inside(_insidePos.x(),
_insidePos.y() + _insideSize.y(),
_insidePos.x() + _insideSize.x(),
_insidePos.y());
ewol::Padding insideBorder(inside.xLeft() - paddingIn.xLeft(),
inside.yTop() + paddingIn.yTop(),
inside.xRight() + paddingIn.xRight(),
inside.yButtom() - paddingIn.yButtom());
ewol::Padding border(insideBorder.xLeft() - borderTmp.xLeft(),
insideBorder.yTop() + borderTmp.yTop(),
insideBorder.xRight() + borderTmp.xRight(),
insideBorder.yButtom() - borderTmp.yButtom());
#else
ewol::Padding border(_insidePos.x() - padding.xLeft() + paddingOut.xLeft(),
_insidePos.y() + _insideSize.y() + padding.yTop() - paddingOut.yTop(),
_insidePos.x() + _insideSize.x() + padding.xRight() - paddingOut.xRight(),
_insidePos.y() - padding.yButtom() + paddingOut.yButtom());
ewol::Padding insideBorder(border.xLeft() + borderTmp.xLeft(),
border.yTop() - borderTmp.yTop(),
border.xRight() - borderTmp.xRight(),
border.yButtom() + borderTmp.yButtom());
ewol::Padding inside(insideBorder.xLeft() + etk::max(0.0f, paddingIn.xLeft()),
insideBorder.yTop() - etk::max(0.0f, paddingIn.yTop()),
insideBorder.xRight() - etk::max(0.0f, paddingIn.xRight()),
insideBorder.yButtom() + etk::max(0.0f, paddingIn.yButtom()));
#endif
/*
Log.error(" enveloppe = " + enveloppe);
Log.error(" border = " + border);
Log.error(" inside = " + inside);
*/
int mode = 0;
boolean displayOutside = false;
if (this.config != null) {
mode = this.config.getNumber(this.confIdMode);
displayOutside = this.config.getBoolean(this.confIdDisplayOutside);
}
this.nbVertexToDisplay = 0;
if (displayOutside == true) {
addVertexLine(enveloppe.yTop(), border.yTop(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][7], modeDisplay[mode][6],
modeDisplay[mode],
displayOutside);
}
addVertexLine(border.yTop(), insideBorder.yTop(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][6], modeDisplay[mode][5],
modeDisplay[mode],
displayOutside);
addVertexLine(insideBorder.yTop(), inside.yTop(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][5], modeDisplay[mode][4],
modeDisplay[mode],
displayOutside);
addVertexLine(inside.yTop(), inside.yButtom(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][4], modeDisplay[mode][3],
modeDisplay[mode],
displayOutside);
addVertexLine(inside.yButtom(), insideBorder.yButtom(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][3], modeDisplay[mode][2],
modeDisplay[mode],
displayOutside);
addVertexLine(insideBorder.yButtom(), border.yButtom(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][2], modeDisplay[mode][1],
modeDisplay[mode],
displayOutside);
if (displayOutside == true) {
addVertexLine(border.yButtom(), enveloppe.yButtom(),
enveloppe.xLeft(),
border.xLeft(),
insideBorder.xLeft(),
inside.xLeft(),
inside.xRight(),
insideBorder.xRight(),
border.xRight(),
enveloppe.xRight(),
modeDisplay[mode][1], modeDisplay[mode][0],
modeDisplay[mode],
displayOutside);
}
this.VBO.flush();
}
ewol::Padding ewol::compositing::Shaper::getPadding() {
return getPaddingOut() + getBorder() + getPaddingIn();
}
ewol::Padding ewol::compositing::Shaper::getPaddingIn() {
ewol::Padding padding(0,0,0,0);
if (this.config != null) {
padding.setValue(this.config.getNumber(this.confIdPaddingIn[shaperPosLeft]),
this.config.getNumber(this.confIdPaddingIn[shaperPosTop]),
this.config.getNumber(this.confIdPaddingIn[shaperPosRight]),
this.config.getNumber(this.confIdPaddingIn[shaperPosButtom]));
}
return padding;
}
ewol::Padding ewol::compositing::Shaper::getPaddingOut() {
ewol::Padding padding(0,0,0,0);
if (this.config != null) {
padding.setValue(this.config.getNumber(this.confIdPaddingOut[shaperPosLeft]),
this.config.getNumber(this.confIdPaddingOut[shaperPosTop]),
this.config.getNumber(this.confIdPaddingOut[shaperPosRight]),
this.config.getNumber(this.confIdPaddingOut[shaperPosButtom]));
}
return padding;
}
ewol::Padding ewol::compositing::Shaper::getBorder() {
ewol::Padding padding(0,0,0,0);
if (this.config != null) {
padding.setValue(this.config.getNumber(this.confIdBorder[shaperPosLeft]),
this.config.getNumber(this.confIdBorder[shaperPosTop]),
this.config.getNumber(this.confIdBorder[shaperPosRight]),
this.config.getNumber(this.confIdBorder[shaperPosButtom]));
}
return padding;
}
void ewol::compositing::Shaper::setSource( etk::Uri _uri) {
clear();
unLoadProgram();
this.uri = _uri;
loadProgram();
}
boolean ewol::compositing::Shaper::hasSources() {
return this.GLprogram != null;
}
Color ewol::compositing::Shaper::getColor(int _id) {
static Color errorValue(0,0,0,0);
if (this.colorProperty == null) {
Log.warning("null of this.colorProperty ==> return #0000 for id " + _id);
return errorValue;
}
return this.colorProperty.get(_id);
}
int ewol::compositing::Shaper::requestColor( String _name) {
if (this.colorProperty == null) {
Log.warning("null of this.colorProperty ==> return -1 for name " + _name);
return -1;
}
return this.colorProperty.request(_name);
}
int ewol::compositing::Shaper::requestConfig( String _name) {
if (this.config == null) {
Log.warning("null of this.config ==> return -1 for name " + _name);
return -1;
}
return this.config.request(_name);
}
double ewol::compositing::Shaper::getConfigNumber(int _id) {
if ( _id == -1
|| this.config == null) {
Log.warning("null of this.config ==> return 0.0 for id " + _id);
return 0.0;
}
return this.config.getNumber(_id);
}
namespace etk {
template<> String toString<ewol::compositing::Shaper>( ewol::compositing::Shaper _obj) {
return _obj.getSource().get();
}
template<> etk::UString toUString<ewol::compositing::Shaper>( ewol::compositing::Shaper _obj) {
return etk::toUString(etk::toString(_obj));
}
template<> boolean frothis.string<ewol::compositing::Shaper>(ewol::compositing::Shaper _variableRet, String _value) {
_variableRet.setSource(_value);
return true;
}
template<> boolean frothis.string<ewol::compositing::Shaper>(ewol::compositing::Shaper _variableRet, etk::UString _value) {
return frothis.string(_variableRet, etk::toString(_value));
}
};

View File

@ -1,296 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <ewol/debug.hpp>
#include <ewol/compositing/Compositing.hpp>
#include <gale/resource/Program.hpp>
#include <ewol/resource/ConfigFile.hpp>
#include <ewol/resource/ColorFile.hpp>
#include <ewol/resource/TextureFile.hpp>
#include <ewol/event/Time.hpp>
#include <ewol/Padding.hpp>
namespace ewol {
namespace compositing {
enum renderMode {
renderSingleSquare, //!< basic historic render mode
renderBorder, //!< Render 4 squares for coiner, and renctangle for border, a big rentangle for background and 8 rectangle for the outside part
renderOneBorder,
};
#define SHAPER_NB_MAX_QUAD (5*5)
#define SHAPER_NB_MAX_TRIANGLE (SHAPER_NB_MAX_QUAD*2)
#define SHAPER_NB_MAX_VERTEX (SHAPER_NB_MAX_TRIANGLE*3)
enum shaperPos {
shaperPosLeft,
shaperPosRight,
shaperPosTop,
shaperPosButtom,
shaperPosCount,
};
/**
* @brief the Shaper system is a basic theme configuration for every widget, it corespond at a background display described by a pool of files
*/
// TODO : load image
// TODO : Abstaraction between states (call by name and the system greate IDs
class Shaper : public ewol::Compositing {
private:
etk::Uri this.uri; //!< Name of the configuration of the shaper.
// External theme config:
ememory::Ptr<ewol::resource::ConfigFile> this.config; //!< pointer on the config file resources
int this.confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom
int this.confIdBorder[shaperPosCount]; //!< border property : X-left X-right Y-top Y-buttom
int this.confIdPaddingIn[shaperPosCount]; //!< Padding in property : X-left X-right Y-top Y-buttom
int this.confIdMode; //!< Display mode
int this.confIdDisplayOutside; //!< Display outside of the shape...
int this.confIdChangeTime; //!< ConfigFile padding transition time property
int this.confProgramFile; //!< ConfigFile opengGl program Name
int this.confColorFile; //!< ConfigFile opengGl color file Name
int this.confImageFile; //!< ConfigFile opengGl program Name
// openGL shaders programs:
ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int this.GLPosition; //!< openGL id on the element (vertex buffer)
int this.GLMatrix; //!< openGL id on the element (transformation matrix)
int this.GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on Vector2f(X,Y))
int this.GLStateActivate; //!< openGL id on the element (activate state displayed)
int this.GLStateOld; //!< openGL id on the element (old state displayed)
int this.GLStateNew; //!< openGL id on the element (new state displayed)
int this.GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] )
int this.GLtexID; //!< openGL id on the element (texture image)
// For the Image :
ememory::Ptr<ewol::resource::TextureFile> this.resourceTexture; //!< texture resources (for the image)
// internal needed data :
int this.nextStatusRequested; //!< when status is changing, this represent the next step of it
Vector2f this.propertyOrigin; //!< widget origin
Vector2f this.propertySize; //!< widget size
Vector2f this.propertyInsidePosition; //!< internal subwidget position
Vector2f this.propertyInsideSize; //!< internal subwidget size
int this.stateActivate; //!< Activate state of the element
int this.stateOld; //!< previous state
int this.stateNew; //!< destination state
float this.stateTransition; //!< working state between 2 states
int this.nbVertexToDisplay;
// color management theme:
ememory::Ptr<ewol::resource::ColorFile> this.colorProperty; //!< input resource for color management
List<Vector2i> this.listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X)
protected:
static int this.vboIdCoord;
static int this.vboIdPos;
ememory::Ptr<gale::resource::VirtualBufferObject> this.VBO;
private:
/**
* @brief load the openGL program and get all the ID needed
*/
void loadProgram();
/**
* @brief Un-Load the openGL program and get all the ID needed
*/
void unLoadProgram();
public:
/**
* @brief generic ructor
* @param[in] _uri URI of the file that might be loaded
*/
Shaper( etk::Uri _uri="");
/**
* @brief generic destructor
*/
~Shaper();
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(boolean _disableDepthTest=true);
/**
* @brief clear alll tre registered element in the current element
*/
void clear();
/**
* @brief Change the current state
* @param[in] _newState Current state of the configuration
* @return true Need redraw.
* @return false No need redraw.
*/
boolean setState(int _newState);
/**
* @brief change the current status in an other
* @param[in] _newStatusId the next new status requested
* @return true The widget must call this fuction periodicly (and redraw itself)
* @return false No need to request the periodic call.
*/
boolean changeStatusIn(int _newStatusId);
/**
* @brief get the current displayed status of the shaper
* @return The Status Id
*/
int getCurrentDisplayedStatus() {
return this.stateNew;
};
/**
* @brief get the next displayed status of the shaper
* @return The next status Id (-1 if no status in next)
*/
int getNextDisplayedStatus() {
return this.nextStatusRequested;
};
/**
* @brief get the current trasion status
* @return value of the transition status (0.0f when no activity)
*/
float getTransitionStatus() {
return this.stateTransition;
};
/**
* @brief Same as the widfget periodic call (this is for change display)
* @param[in] _event The current time of the call.
* @return true The widget must call this fuction periodicly (and redraw itself)
* @return false No need to request the periodic call.
*/
boolean periodicCall( ewol::event::Time _event);
/**
* @brief get the padding declared by the user in the config file
* @return the padding property
*/
ewol::Padding getPadding();
ewol::Padding getPaddingIn();
ewol::Padding getPaddingOut();
/**
* @brief get the padding declared by the user in the config file
* @return the padding property
*/
ewol::Padding getBorder();
/**
* @brief change the shaper Source
* @param[in] _uri New file of the shaper
*/
void setSource( etk::Uri _uri);
/**
* @brief get the shaper file Source
* @return the shapper file name
*/
etk::Uri getSource() {
return this.uri;
};
/**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources.
*/
boolean hasSources();
public:
/**
* @brief set the shape property:
*
* ********************************************************************************
* * _size *
* * *
* * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *
* * *
* * | | *
* * *************************************************** *
* * | * * | *
* * * * *
* * | * * - - - - - - - - - - - - - - - - - - * * | *
* * * _insideSize * *
* * | * | | * | *
* * * * *
* * | * | | * | *
* * * * *
* * | * | | * | *
* * * * *
* * | * | | * | *
* * * * *
* * | * | | * | *
* * * * *
* * | * | | * | *
* * * _insidePos * *
* * | * * - - - - - - - - - - - - - - - - - - * * | *
* * * * *
* * | *************************************************** | *
* * *
* * | | *
* * *
* * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *
* * *
* * *
* ********************************************************************************
* _origin
*
*
* @param[in] _origin Origin of the display
* @param[in] _size Size of the display
* @param[in] _insidePos Positin of the internal data
* @param[in] _insideSize Size of the internal data
*/
void setShape( Vector2f _origin, Vector2f _size, Vector2f _insidePos, Vector2f _insideSize);
// @previous
void setShape( Vector2f _origin, Vector2f _size) {
ewol::Padding tmp = getPadding();
setShape(_origin, _size, _origin+Vector2f(tmp.xLeft(), tmp.yButtom()), _size - Vector2f(tmp.x(), tmp.y()));
}
public:
/**
* @brief Get an ID on the color instance element
* @param[in] _name Name of the element requested
* @return The Id of the color
*/
int requestColor( String _name);
/**
* @brief Get The color associated at an ID.
* @param[in] _id Id of the color
* @return the reference on the color
*/
Color getColor(int _id);
public:
/**
* @brief Get an ID on the configuration instance element
* @param[in] _name Name of the element requested
* @return The Id of the element
*/
int requestConfig( String _name);
/**
* @brief Get The number associated at an ID.
* @param[in] _id Id of the parameter
* @return the requested number.
*/
double getConfigNumber(int _id);
public:
/**
* @brief Set activate state of the element
* @param[in] _status New activate status
*/
void setActivateState(int _status) {
this.stateActivate = _status;
}
private:
void addVertexLine(float _yTop,
float _yButtom,
float _x1,
float _x2,
float _x3,
float _x4,
float _x5,
float _x6,
float _x7,
float _x8,
float _yValTop,
float _yValButtom,
float* _table,
boolean _displayOutside);
public:
/* ****************************************************
* == operator
*****************************************************/
boolean operator== ( Shaper _obj) {
return _obj.this.uri == this.uri;
}
boolean operator!= ( Shaper _obj) {
return _obj.this.uri != this.uri;
}
};
}
}

View File

@ -5,74 +5,51 @@
*/
#pragma once
#include <etk/Color.hpp>
#include<etk/Color.hpp>
#include <ewol/debug.hpp>
#include <ewol/compositing/Compositing.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <ewol/resource/TexturedFont.hpp>
#include <exml/exml.hpp>
#include <etk/String.hpp>
#include<ewol/debug.hpp>#include<ewol/compositing/Compositing.hpp>#include<ewol/compositing/Drawing.hpp>#include<ewol/resource/TexturedFont.hpp>#include<exml/exml.hpp>#include<etk/String.hpp>
namespace ewol {
namespace compositing {
/**
* @brief This class represent the specific display for every char in the string ...
* @not_in_doc
*/
class TextDecoration {
public:
etk::Color<float,4> this.colorBg; //!< display background color
etk::Color<float,4> this.colorFg; //!< display foreground color
enum ewol::font::mode this.mode; //!< display mode Regular/Bold/Italic/BoldItalic
TextDecoration() {
this.colorBg = etk::color::blue;
this.colorBg = etk::color::green;
this.mode = ewol::font::Regular;
}
};
enum aligneMode {
alignDisable,
alignRight,
alignLeft,
alignCenter,
alignJustify
};
class TextBase : public ewol::Compositing {
namespace ewol{namespace compositing{enum aligneMode {
alignDisable,
alignRight,
alignLeft,
alignCenter,
alignJustify
};
class TextBase:public ewol::Compositing
{
protected:
ewol::compositing::Drawing this.vectorialDraw; //!< This is used to draw background selection and other things ...
public:
ewol::compositing::Drawing getDrawing() {
return this.vectorialDraw;
};
protected:
int this.nbCharDisplayed; //!< prevent some error in calculation size.
Vector3f this.sizeDisplayStart; //!< The start windows of the display.
Vector3f this.sizeDisplayStop; //!< The end windows of the display.
boolean this.needDisplay; //!< This just need the display and not the size rendering.
Vector3f this.position; //!< The current position to draw
Vector3f this.clippingPosStart; //!< Clipping start position
Vector3f this.clippingPosStop; //!< Clipping stop position
boolean this.clippingEnable; //!< true if the clipping must be activated
protected:
etk::Color<float,4> this.defaultColorFg; //!< The text foreground color
etk::Color<float,4> this.defaultColorBg; //!< The text background color
protected:
etk::Color<float,4> this.color; //!< The text foreground color
etk::Color<float,4> this.colorBg; //!< The text background color
etk::Color<float,4> this.colorCursor; //!< The text cursor color
etk::Color<float,4> this.colorSelection; //!< The text Selection color
protected:
enum ewol::font::mode this.mode; //!< font display property : Regular/Bold/Italic/BoldItalic
boolean this.kerning; //!< Kerning enable or disable on the next elements displayed
Character this.previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning
protected:
float this.startTextpos; //!< start position of the Alignement (when \n the text return at this position)
float this.stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this line and the center is perform with this one)
enum aligneMode this.alignement; //!< Current Alignement mode (justify/left/right ...)
protected:
};protected:int this.nbCharDisplayed; //!< prevent some error in calculation size.
Vector3f this.sizeDisplayStart; //!< The start windows of the display.
Vector3f this.sizeDisplayStop; //!< The end windows of the display.
boolean this.needDisplay; //!< This just need the display and not the size rendering.
Vector3f this.position; //!< The current position to draw
Vector3f this.clippingPosStart; //!< Clipping start position
Vector3f this.clippingPosStop; //!< Clipping stop position
boolean this.clippingEnable; //!< true if the clipping must be activated
protected:etk::Color<float,4>this.defaultColorFg; //!< The text foreground color
etk::Color<float,4>this.defaultColorBg; //!< The text background color
protected:etk::Color<float,4>this.color; //!< The text foreground color
etk::Color<float,4>this.colorBg; //!< The text background color
etk::Color<float,4>this.colorCursor; //!< The text cursor color
etk::Color<float, 4>this.colorSelection; //!< The text Selection color
protected:
enum ewol::
font::
mode this.mode; //!< font display property : Regular/Bold/Italic/BoldItalic
boolean this.kerning; //!< Kerning enable or disable on the next elements displayed
Character this.previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning
protected:float this.startTextpos; //!< start position of the Alignement (when \n the text return at this position)
float this.stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this line and the center is perform with this one)
enum aligneMode this.alignement; //!< Current Alignement mode (justify/left/right ...)
protected:
ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int this.GLPosition; //!< openGL id on the element (vertex buffer)
int this.GLMatrix; //!< openGL id on the element (transformation matrix)
@ -95,384 +72,397 @@ namespace ewol {
* @brief load the openGL program and get all the ID needed
*/
void loadProgram( String _shaderName);
public:
public:
/**
* @brief generic ructor
*/
TextBase( String _shaderName = "DATA:///text.prog?lib=ewol", boolean _loadProgram = true);
TextBase( final String _shaderName = "DATA:///text.prog?lib=ewol", boolean _loadProgram = true);
/**
* @brief generic destructor
*/
~TextBase();
public: // Derived function
void translate( Vector3f _vect);
void rotate( Vector3f _vect, float _angle);
void scale( Vector3f _vect);
public:
void translate(Vector3f _vect);
void rotate(Vector3f _vect, float _angle);
void scale(Vector3f _vect);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(boolean _disableDepthTest=true) {
void draw(final boolean _disableDepthTest=true) {
drawD(_disableDepthTest);
}
//! @previous
void draw( Matrix4f _transformationMatrix, boolean _enableDepthTest=false) {
//! @previous
void draw( final Matrix4f _transformationMatrix, final boolean _enableDepthTest=false) {
drawMT(_transformationMatrix, _enableDepthTest);
}
/**
/**
* @brief draw All the refistered text in the current element on openGL
*/
void drawD(boolean _disableDepthTest) = 0;
void drawD(final boolean _disableDepthTest) = 0;
//! @previous
void drawMT( Matrix4f _transformationMatrix, boolean _enableDepthTest) = 0;
/**
* @brief clear all the registered element in the current element
*/
void clear();
/**
* @brief clear all the intermediate result detween 2 prints
*/
void reset();
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current position.
*/
Vector3f getPos() {
return this.position;
};
/**
* @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D)
*/
void setPos( Vector3f _pos);
//! @previous
void setPos( Vector2f _pos) {
setPos(Vector3f(_pos.x(),_pos.y(),0));
};
/**
* @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D)
*/
void setRelPos( Vector3f _pos);
//! @previous
void setRelPos( Vector2f _pos) {
setRelPos(Vector3f(_pos.x(),_pos.y(),0));
};
/**
* @brief set the default background color of the font (when reset, set this value ...)
* @param[in] _color Color to set on background
*/
void setDefaultColorBg( etk::Color<> _color) {
this.defaultColorBg = _color;
}
/**
* @brief set the default Foreground color of the font (when reset, set this value ...)
* @param[in] _color Color to set on foreground
*/
void setDefaultColorFg( etk::Color<> _color) {
this.defaultColorFg = _color;
}
/**
void drawMT( final Matrix4f _transformationMatrix, final boolean _enableDepthTest) = 0;
/**
* @brief clear all the registered element in the current element
*/
void clear();
/**
* @brief clear all the intermediate result detween 2 prints
*/
void reset();
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current position.
*/
Vector3f getPos() {
return this.position;
};
/**
* @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D)
*/
void setPos(Vector3f _pos);
//! @previous
void setPos(final Vector2f _pos) {
setPos(Vector3f(_pos.x(), _pos.y(), 0));
};
/**
* @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D)
*/
void setRelPos(Vector3f _pos);
//! @previous
void setRelPos(final Vector2f _pos) {
setRelPos(Vector3f(_pos.x(), _pos.y(), 0));
};
/**
* @brief set the default background color of the font (when reset, set this value ...)
* @param[in] _color Color to set on background
*/
void setDefaultColorBg(etk::Color<>_color) {this.defaultColorBg=_color;}
/**
* @brief set the default Foreground color of the font (when reset, set this value ...)
* @param[in] _color Color to set on foreground
*/
void setDefaultColorFg(etk::Color<>_color) {this.defaultColorFg=_color;}
/**
* @brief set the Color of the current foreground font
* @param[in] _color Color to set on foreground (for next print)
*/
void setColor( etk::Color<> _color) {
this.color = _color;
};
/**
/**
* @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( etk::Color<> _color);
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
void setClippingWidth( Vector3f _pos, Vector3f _width) {
setClipping(_pos, _pos+_width);
}
//! @previous
void setClippingWidth( Vector2f _pos, Vector2f _width) {
setClipping(_pos, _pos+_width);
};
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _posEnd End position of the clipping
*/
void setClipping( Vector3f _pos, Vector3f _posEnd);
//! @previous
void setClipping( Vector2f _pos, Vector2f _posEnd) {
setClipping(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_posEnd.x(),_posEnd.y(),1) );
};
/**
* @brief enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping
*/
// TODO : Rename setClippingActivity
void setClippingMode(boolean _newMode);
/**
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
void setClippingWidth(final Vector3f _pos, final Vector3f _width) {
setClipping(_pos, _pos + _width);
}
//! @previous
void setClippingWidth(final Vector2f _pos, final Vector2f _width) {
setClipping(_pos, _pos + _width);
};
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _posEnd End position of the clipping
*/
void setClipping(Vector3f _pos, Vector3f _posEnd);
//! @previous
void setClipping(final Vector2f _pos, final Vector2f _posEnd) {
setClipping(Vector3f(_pos.x(), _pos.y(), -1), Vector3f(_posEnd.x(), _posEnd.y(), 1));
};
/**
* @brief enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping
*/
// TODO : Rename setClippingActivity
void setClippingMode(boolean _newMode);
/**
* @brief Specify the font size (this reset the internal element of the current text (system requirement)
* @param[in] _fontSize New font size
*/
void setFontSize(int _fontSize) = 0;
/**
void setFontSize(final int _fontSize) = 0;
/**
* @brief Specify the font name (this reset the internal element of the current text (system requirement)
* @param[in] _fontName Current name of the selected font
*/
void setFontName( String _fontName) = 0;
/**
void setFontName( final String _fontName) = 0;
/**
* @brief Specify the font property (this reset the internal element of the current text (system requirement)
* @param[in] fontName Current name of the selected font
* @param[in] fontSize New font size
*/
void setFont(String _fontName, int _fontSize) = 0;
/**
* @brief Specify the font mode for the next @ref print
* @param[in] mode The font mode requested
*/
void setFontMode(enum ewol::font::mode _mode) = 0;
/**
* @brief get the current font mode
* @return The font mode applied
*/
enum ewol::font::mode getFontMode() {
return this.mode;
};
float getHeight() = 0;
float getSize() = 0;
ewol::GlyphProperty * getGlyphPointer(Character _charcode) = 0;
/**
* @brief enable or disable the bold mode
* @param[in] _status The new status for this display property
*/
void setFontBold(boolean _status);
/**
* @brief enable or disable the italic mode
* @param[in] _status The new status for this display property
*/
void setFontItalic(boolean _status);
/**
* @brief set the activation of the Kerning for the display (if it existed)
* @param[in] _newMode enable/Diasable the kerning on this font.
*/
void setKerningMode(boolean _newMode);
/**
* @brief display a compleat string in the current element.
* @param[in] _text The string to display.
*/
void print( String _text);
//! @previous
void print( etk::UString _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
*
* [code style=xml]
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <font color="#FF0000">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* [/code]
*
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
* @param[in] _text The string to display.
* @TODO : implementation not done ....
*/
void printDecorated( String _text);
//! @previous
void printDecorated( etk::UString _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
*
* [code style=xml]
* <html>
* <body>
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <font color="#FF0000">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* </body>
* </html>
* [/code]
*
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
* @param[in] _text The string to display.
* @TODO : implementation not done ....
*/
void printHTML( String _text);
//! @previous
void printHTML( etk::UString _text);
/**
* @brief display a compleat string in the current element whith specific decorations (advence mode).
* @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)
*/
void print( String _text, List<TextDecoration> _decoration);
//! @previous
void print( etk::UString _text, List<TextDecoration> _decoration);
/**
* @brief display the current char in the current element (note that the kerning is availlable if the position is not changed)
* @param[in] _charcode Char that might be dispalyed
*/
void printChar( Character _charcode) = 0;
/**
* @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();
protected:
/**
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
* @param[in] _element the exml element.
*/
void parseHtmlNode( exml::Element _element);
public:
/**
* @brief This generate the possibility to generate the big text property
* @param[in] _startTextpos The x text start position of the display.
* @param[in] _stopTextPos The x text stop position of the display.
* @param[in] _alignement mode of alignement for the Text.
* @note The text align in center change of line every display done (even if it was just a char)
*/
void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::compositing::aligneMode _alignement=ewol::compositing::alignDisable);
/**
* @brief disable the alignement system
*/
void disableAlignement();
/**
* @brief get the current alignement property
* @return the curent alignement type
*/
enum ewol::compositing::aligneMode getAlignement();
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSizeHTML( String _text);
//! @previous
Vector3f calculateSizeHTML( etk::UString _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSizeDecorated( String _text);
//! @previous
Vector3f calculateSizeDecorated( etk::UString _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSize( String _text);
//! @previous
Vector3f calculateSize( etk::UString _text);
/**
* @brief calculate a theoric charcode size
* @param[in] _charcode The Unicode value to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSize( Character _charcode) {
return calculateSizeChar(_charcode);
};
protected:
//! @previous
Vector3f calculateSizeChar( Character _charcode) = 0;
public:
/**
* @brief draw a cursor at the specify position
* @param[in] _isInsertMode True if the insert mode is activated
* @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20]
*/
void printCursor(boolean _isInsertMode, float _cursorSize = 20.0f);
protected:
/**
* @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.
* @param[out] _freespace This represent the number of pixel present in the right white space.
* @return true if the rifht has free space that can be use for jystify.
* @return false if we find '\n'
*/
boolean extrapolateLastId( String _text, int _start, int _stop, int _space, int _freeSpace);
//! @previous
boolean extrapolateLastId( etk::UString _text, int _start, int _stop, int _space, int _freeSpace);
protected:
// this section is reserved for HTML parsing and display:
etk::UString this.htmlCurrrentLine; //!< current line for HTML display
List<TextDecoration> this.htmlDecoration; //!< current decoration for the HTML display
TextDecoration this.htmlDecoTmp; //!< current decoration
/**
* @brief add a line with the current this.htmlDecoTmp decoration
* @param[in] _data The cuurent data to add.
*/
void htmlAddData( etk::UString _data);
/**
* @brief draw the current line
*/
void htmlFlush();
public:
/**
* @brief remove the cursor display
*/
void disableCursor();
/**
* @brief set a cursor at a specific position:
* @param[in] _cursorPos id of the cursor position
*/
void setCursorPos(int _cursorPos);
/**
* @brief set a cursor at a specific position with his associated selection:
* @param[in] _cursorPos id of the cursor position
* @param[in] _selectionStartPos id of the starting of the selection
*/
void setCursorSelection(int _cursorPos, int _selectionStartPos);
/**
* @brief change the selection color
* @param[in] _color New color for the Selection
*/
void setSelectionColor( etk::Color<> _color);
/**
* @brief change the cursor color
* @param[in] _color New color for the Selection
*/
void setCursorColor( etk::Color<> _color);
};
}
}
void setFont(final String _fontName, final int _fontSize) = 0;
/**
* @brief Specify the font mode for the next @ref print
* @param[in] mode The font mode requested
*/
void setFontMode(enum ewol::font::mode _mode)=0;
/**
* @brief get the current font mode
* @return The font mode applied
*/
enum ewol::font::mode getFontMode(){return this.mode;};float getHeight()=0;float getSize()=0;ewol::GlyphProperty*getGlyphPointer(Character _charcode)=0;
/**
* @brief enable or disable the bold mode
* @param[in] _status The new status for this display property
*/
void setFontBold(boolean _status);
/**
* @brief enable or disable the italic mode
* @param[in] _status The new status for this display property
*/
void setFontItalic(boolean _status);
/**
* @brief set the activation of the Kerning for the display (if it existed)
* @param[in] _newMode enable/Diasable the kerning on this font.
*/
void setKerningMode(boolean _newMode);
/**
* @brief display a compleat string in the current element.
* @param[in] _text The string to display.
*/
void print(String _text);
//! @previous
void print(etk::UString _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
*
* [code style=xml]
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <font color="#FF0000">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* [/code]
*
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
* @param[in] _text The string to display.
* @TODO : implementation not done ....
*/
void printDecorated(String _text);
//! @previous
void printDecorated(etk::UString _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
*
* [code style=xml]
* <html>
* <body>
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <font color="#FF0000">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* </body>
* </html>
* [/code]
*
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
* @param[in] _text The string to display.
* @TODO : implementation not done ....
*/
void printHTML(String _text);
//! @previous
void printHTML(etk::UString _text);
/**
* @brief display a compleat string in the current element whith specific decorations (advence mode).
* @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)
*/
void print(String _text,List<TextDecoration>_decoration);
//! @previous
void print(etk::UString _text,List<TextDecoration>_decoration);
/**
* @brief display the current char in the current element (note that the kerning is availlable if the position is not changed)
* @param[in] _charcode Char that might be dispalyed
*/
void printChar(Character _charcode)=0;
/**
* @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();protected:
/**
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
* @param[in] _element the exml element.
*/
void parseHtmlNode(exml::Element _element);public:
/**
* @brief This generate the possibility to generate the big text property
* @param[in] _startTextpos The x text start position of the display.
* @param[in] _stopTextPos The x text stop position of the display.
* @param[in] _alignement mode of alignement for the Text.
* @note The text align in center change of line every display done (even if it was just a char)
*/
void setTextAlignement(float _startTextpos,float _stopTextPos,enum ewol::compositing::aligneMode _alignement=ewol::compositing::alignDisable);
/**
* @brief disable the alignement system
*/
void disableAlignement();
/**
* @brief get the current alignement property
* @return the curent alignement type
*/
enum ewol::compositing::aligneMode getAlignement();
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSizeHTML(String _text);
//! @previous
Vector3f calculateSizeHTML(etk::UString _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSizeDecorated(String _text);
//! @previous
Vector3f calculateSizeDecorated(etk::UString _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSize(String _text);
//! @previous
Vector3f calculateSize(etk::UString _text);
/**
* @brief calculate a theoric charcode size
* @param[in] _charcode The Unicode value to calculate dimention.
* @return The theoric size used.
*/
Vector3f calculateSize(Character _charcode){return calculateSizeChar(_charcode);};protected:
//! @previous
Vector3f calculateSizeChar(Character _charcode)=0;public:
/**
* @brief draw a cursor at the specify position
* @param[in] _isInsertMode True if the insert mode is activated
* @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20]
*/
void printCursor(boolean _isInsertMode,float _cursorSize=20.0f);protected:
/**
* @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.
* @param[out] _freespace This represent the number of pixel present in the right white space.
* @return true if the rifht has free space that can be use for jystify.
* @return false if we find '\n'
*/
boolean extrapolateLastId(String _text,int _start,int _stop,int _space,int _freeSpace);
//! @previous
boolean extrapolateLastId(etk::UString _text,int _start,int _stop,int _space,int _freeSpace);protected:
// this section is reserved for HTML parsing and display:
etk::UString this.htmlCurrrentLine; //!< current line for HTML display
List<TextDecoration>this.htmlDecoration; //!< current decoration for the HTML display
TextDecoration this.htmlDecoTmp; //!< current decoration
/**
* @brief add a line with the current this.htmlDecoTmp decoration
* @param[in] _data The cuurent data to add.
*/
void htmlAddData(etk::UString _data);
/**
* @brief draw the current line
*/
void htmlFlush();public:
/**
* @brief remove the cursor display
*/
void disableCursor();
/**
* @brief set a cursor at a specific position:
* @param[in] _cursorPos id of the cursor position
*/
void setCursorPos(int _cursorPos);
/**
* @brief set a cursor at a specific position with his associated selection:
* @param[in] _cursorPos id of the cursor position
* @param[in] _selectionStartPos id of the starting of the selection
*/
void setCursorSelection(int _cursorPos,int _selectionStartPos);
/**
* @brief change the selection color
* @param[in] _color New color for the Selection
*/
void setSelectionColor(etk::Color<>_color);
/**
* @brief change the cursor color
* @param[in] _color New color for the Selection
*/
void setCursorColor(etk::Color<>_color);};}}
;
/**
* @brief This class represent the specific display for every char in the string ...
* @not_in_doc
*/
class TextDecoration{
}

View File

@ -0,0 +1,10 @@
package org.atriasoft.ewol.compositing.tools;
import org.atriasoft.ewol.resource.font.FontMode;
public record TextDecoration(
final Color colorBG,
final Color colorFg,
final FontMode mode) {
}