diff --git a/.classpath b/.classpath index d43dd0c..bd70087 100644 --- a/.classpath +++ b/.classpath @@ -21,7 +21,22 @@ - + + + + + + + + + + + + + + + + diff --git a/CheckStyle.xml b/CheckStyle.xml index d68aedd..1bae003 100755 --- a/CheckStyle.xml +++ b/CheckStyle.xml @@ -3,12 +3,12 @@ +-. +-. diff --git a/CleanUp.xml b/CleanUp.xml index 6cf4cba..543d7b0 100644 --- a/CleanUp.xml +++ b/CleanUp.xml @@ -41,7 +41,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -90,7 +90,7 @@ - + diff --git a/Formatter.xml b/Formatter.xml index 14a5d6c..aec36fe 100644 --- a/Formatter.xml +++ b/Formatter.xml @@ -2,19 +2,19 @@ - + - + - + - + @@ -22,18 +22,18 @@ - + - + - + @@ -43,7 +43,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -96,16 +96,16 @@ - + - + - + @@ -141,15 +141,15 @@ - + - + - + @@ -167,15 +167,15 @@ - - + + - + @@ -218,7 +218,7 @@ - + @@ -245,20 +245,20 @@ - + - + - + @@ -266,7 +266,7 @@ - + @@ -289,14 +289,14 @@ - + - + @@ -306,7 +306,7 @@ - + @@ -317,7 +317,7 @@ - + @@ -327,14 +327,14 @@ - + - + - + @@ -358,24 +358,24 @@ - + - + - + - - + + - - - + + + diff --git a/lib/svgSalamander-1.1.2.jar b/lib/svgSalamander-1.1.2.jar new file mode 100644 index 0000000..36ce4eb Binary files /dev/null and b/lib/svgSalamander-1.1.2.jar differ diff --git a/src/module-info.java b/src/module-info.java index fd1ce90..4e3001e 100644 --- a/src/module-info.java +++ b/src/module-info.java @@ -2,8 +2,11 @@ * * @author Edouard DUPIN */ -open module org.atriasoft.etk { - exports org.atriasoft.etk; - exports org.atriasoft.etk.math; +open module org.atriasoft.ewol { + exports org.atriasoft.ewol; + + requires transitive org.atriasoft.gale; + requires transitive org.atriasoft.etk; + requires transitive org.atriasoft.exml; requires transitive io.scenarium.logger; } diff --git a/src/org/atriasoft/echrono/Clock.java b/src/org/atriasoft/echrono/Clock.java new file mode 100644 index 0000000..0f1f4af --- /dev/null +++ b/src/org/atriasoft/echrono/Clock.java @@ -0,0 +1,42 @@ +package org.atriasoft.echrono; + +/** + * @brief Clock is a compleate virtual clock that is used to virtualize the urrent clock used (can be non real-time, ex:for simulation) + */ +public class Clock { + public static Time now() { + return new Time(System.nanoTime()); + } + + private final long data; //!< virtual clock + + public Clock() { + this.data = 0; + } + + public Clock(final double _val) { //value in second + this.data = (long) (_val * 1000000000.0); + } + + public Clock(final int _val) { //value in nanosecond + this.data = _val; + } + + public Clock(final long _val) { //value in nanosecond + this.data = _val; + } + + public Clock(final long _valSec, final long _valNano) { //value in second and nanosecond + this.data = _valSec * 1000000000L + _valNano; + } + + public long get() { + return this.data; + } + + public Duration less(final Clock timeUpAppl) { + // TODO Auto-generated method stub + return new Duration(this.data - timeUpAppl.data); + } + +} diff --git a/src/org/atriasoft/echrono/Duration.java b/src/org/atriasoft/echrono/Duration.java new file mode 100644 index 0000000..c75ef1f --- /dev/null +++ b/src/org/atriasoft/echrono/Duration.java @@ -0,0 +1,35 @@ +package org.atriasoft.echrono; + +public class Duration { + private final long data; // stored in ns + + public Duration() { + this.data = 0; + } + + public Duration(final double _val) { //value in second + this.data = (long) (_val * 1000000000.0); + } + + public Duration(final int _val) { //value in nanosecond + this.data = _val; + } + + public Duration(final long _val) { //value in nanosecond + this.data = _val; + } + + public Duration(final long _valSec, final long _valNano) { //value in second and nanosecond + this.data = _valSec * 1000000000L + _valNano; + } + + public long get() { + return this.data; + } + + public float toSeconds() { + // TODO Auto-generated method stub + return (float) (this.data / 1000000000.0); + } + +} diff --git a/src/org/atriasoft/echrono/Steady.java b/src/org/atriasoft/echrono/Steady.java new file mode 100644 index 0000000..80cc55b --- /dev/null +++ b/src/org/atriasoft/echrono/Steady.java @@ -0,0 +1,32 @@ +package org.atriasoft.echrono; + +/** + * @brief Steady is a Program start time clock + */ +public class Steady { + private final long data; //!< Monotonic clock since computer start (ns) + + public Steady() { + this.data = 0; + } + + public Steady(final double _val) { //value in second + this.data = (long) (_val * 1000000000.0); + } + + public Steady(final int _val) { //value in nanosecond + this.data = _val; + } + + public Steady(final long _val) { //value in nanosecond + this.data = _val; + } + + public Steady(final long _valSec, final long _valNano) { //value in second and nanosecond + this.data = _valSec * 1000000000L + _valNano; + } + + public long get() { + return this.data; + } +} diff --git a/src/org/atriasoft/echrono/Time.java b/src/org/atriasoft/echrono/Time.java new file mode 100644 index 0000000..5a887b5 --- /dev/null +++ b/src/org/atriasoft/echrono/Time.java @@ -0,0 +1,36 @@ +package org.atriasoft.echrono; + +/** + * @brief Represent the earth clock (if computer is synchronized) + */ +public class Time { + public static Time now() { + return new Time(System.nanoTime()); + } + + private final long data; //!< earth time since Epock in ns + + public Time() { + this.data = 0; + } + + public Time(final double _val) { //value in second + this.data = (long) (_val * 1000000000.0); + } + + public Time(final int _val) { //value in nanosecond + this.data = _val; + } + + public Time(final long _val) { //value in nanosecond + this.data = _val; + } + + public Time(final long _valSec, final long _valNano) { //value in second and nanosecond + this.data = _valSec * 1000000000L + _valNano; + } + + public long get() { + return this.data; + } +} diff --git a/src/org/atriasoft/esignal/Connection.java b/src/org/atriasoft/esignal/Connection.java new file mode 100644 index 0000000..2e5f4e3 --- /dev/null +++ b/src/org/atriasoft/esignal/Connection.java @@ -0,0 +1,5 @@ +package org.atriasoft.esignal; + +public class Connection { + +} diff --git a/src/org/atriasoft/esignal/Signal.java b/src/org/atriasoft/esignal/Signal.java new file mode 100644 index 0000000..2a85c7b --- /dev/null +++ b/src/org/atriasoft/esignal/Signal.java @@ -0,0 +1,63 @@ +package org.atriasoft.esignal; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.function.Consumer; + +class connectedElement { + private final WeakReference reference; + private final Consumer consumer; + + public connectedElement(final WeakReference reference, final Consumer consumer) { + this.reference = reference; + this.consumer = consumer; + } + + public Consumer getConsumer() { + return this.consumer; + } + + public WeakReference getReference() { + return this.reference; + } + +} + +public class Signal { + + List> data = new ArrayList<>(); + + public void clear(final Object obj) { + + } + + public Connection connect(final Object reference, final T fucntion) { + + return null; + } + + public void disconnect(final Connection connection) { + + } + + public void disconnect(final Object obj) { + + } + + public void emit(final T value) { + final Iterator> iterator = this.data.iterator(); + while (iterator.hasNext()) { + final connectedElement elem = iterator.next(); + if (elem.getReference().get() == null) { + iterator.remove(); + } + elem.getConsumer().accept(value); + } + } + + public int size() { + return this.data.size(); + } +} diff --git a/src/org/atriasoft/ewol/DrawProperty.cpp b/src/org/atriasoft/ewol/DrawProperty.cpp index 6859e2a..43076be 100644 --- a/src/org/atriasoft/ewol/DrawProperty.cpp +++ b/src/org/atriasoft/ewol/DrawProperty.cpp @@ -10,15 +10,15 @@ #include ETK_DECLARE_TYPE(ewol::DrawProperty); -etk::Stream& ewol::operator <<(etk::Stream& _os, const ewol::DrawProperty& _obj) { - _os << "{ windowsSize=" << _obj.m_windowsSize << " start=" << _obj.m_origin << " stop=" << (_obj.m_origin+_obj.m_size) << "}"; +etk::Stream ewol::operator +(etk::Stream _os, ewol::DrawProperty _obj) { + _os + "{ windowsSize=" + _obj.this.windowsSize + " start=" + _obj.this.origin + " stop=" + (_obj.this.origin+_obj.this.size) + "}"; return _os; } -void ewol::DrawProperty::limit(const Vector2f& _origin, const Vector2f& _size) { - m_size += m_origin; - m_origin.setMax(_origin); - m_size.setMin(_origin+_size); - m_size -= m_origin; +void ewol::DrawProperty::limit( Vector2f _origin, Vector2f _size) { + this.size += this.origin; + this.origin.setMax(_origin); + this.size.setMin(_origin+_size); + this.size -= this.origin; } diff --git a/src/org/atriasoft/ewol/DrawProperty.java b/src/org/atriasoft/ewol/DrawProperty.java index 963c8b6..8a5d8ec 100644 --- a/src/org/atriasoft/ewol/DrawProperty.java +++ b/src/org/atriasoft/ewol/DrawProperty.java @@ -14,11 +14,11 @@ namespace ewol { */ class DrawProperty{ /* - /--> m_windowsSize + /-. this.windowsSize *--------------------------------------------------* | g | | | - | m_size | + | this.size | | / | | o-------------------o | | | | | @@ -31,18 +31,18 @@ namespace ewol { | | | | | o-------------------o | | / | - | m_origin | + | this.origin | | | *--------------------------------------------------* / (0,0) */ public : - Vector2i m_windowsSize; //!< Windows compleate size - Vector2i m_origin; //!< Windows clipping upper widget (can not be <0) - Vector2i m_size; //!< Windows clipping upper widget (can not be <0 and >m_windowsSize) - void limit(const Vector2f& _origin, const Vector2f& _size); + Vector2i this.windowsSize; //!< Windows compleate size + Vector2i this.origin; //!< Windows clipping upper widget (can not be <0) + Vector2i this.size; //!< Windows clipping upper widget (can not be <0 and >this.windowsSize) + void limit( Vector2f _origin, Vector2f _size); }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::DrawProperty& _obj); + etk::Stream operator +(etk::Stream _os, ewol::DrawProperty _obj); } diff --git a/src/org/atriasoft/ewol/Gravity.java b/src/org/atriasoft/ewol/Gravity.java new file mode 100644 index 0000000..23ddee8 --- /dev/null +++ b/src/org/atriasoft/ewol/Gravity.java @@ -0,0 +1,21 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +package org.atriasoft.ewol; + +/** + * @brief Gravity of the widget property + */ +public enum Gravity { + center, //!< gravity is in center + top, //!< gravity is in top + buttom, //!< gravity is in buttom + right, //!< gravity is in right + left, //!< gravity is in left + topRight, //!< gravity is in top-right + topLeft, //!< gravity is in top-left + buttomRight, //!< gravity is in buttom-right + buttomLeft, //!< gravity is in buttom-left +} diff --git a/src/org/atriasoft/ewol/Padding.cpp b/src/org/atriasoft/ewol/Padding.cpp index 36a5a92..66e1af5 100644 --- a/src/org/atriasoft/ewol/Padding.cpp +++ b/src/org/atriasoft/ewol/Padding.cpp @@ -17,77 +17,77 @@ ewol::Padding::Padding(float _xl, float _yt, float _xr, float _yb) { } void ewol::Padding::setValue(float _xl, float _yt, float _xr, float _yb) { - m_value[0] = _xl; - m_value[1] = _yt; - m_value[2] = _xr; - m_value[3] = _yb; + this.value[0] = _xl; + this.value[1] = _yt; + this.value[2] = _xr; + this.value[3] = _yb; } -float ewol::Padding::x() const { - return m_value[0] + m_value[2]; +float ewol::Padding::x() { + return this.value[0] + this.value[2]; } -float ewol::Padding::y() const { - return m_value[1] + m_value[3]; +float ewol::Padding::y() { + return this.value[1] + this.value[3]; } -float ewol::Padding::xLeft() const { - return m_value[0]; +float ewol::Padding::xLeft() { + return this.value[0]; } void ewol::Padding::setXLeft(float _val) { - m_value[0] = _val; + this.value[0] = _val; } -float ewol::Padding::xRight() const { - return m_value[2]; +float ewol::Padding::xRight() { + return this.value[2]; } void ewol::Padding::setXRight(float _val) { - m_value[2] = _val; + this.value[2] = _val; } -float ewol::Padding::yTop() const { - return m_value[1]; +float ewol::Padding::yTop() { + return this.value[1]; } void ewol::Padding::setYTop(float _val) { - m_value[1] = _val; + this.value[1] = _val; } -float ewol::Padding::yButtom() const { - return m_value[3]; +float ewol::Padding::yButtom() { + return this.value[3]; } void ewol::Padding::setYButtom(float _val) { - m_value[3] = _val; + this.value[3] = _val; } -ewol::Padding& ewol::Padding::operator+=(const Padding& _v) { - m_value[0] += _v.m_value[0]; - m_value[1] += _v.m_value[1]; - m_value[2] += _v.m_value[2]; - m_value[3] += _v.m_value[3]; +ewol::Padding ewol::Padding::operator+=( Padding _v) { + this.value[0] += _v.this.value[0]; + this.value[1] += _v.this.value[1]; + this.value[2] += _v.this.value[2]; + this.value[3] += _v.this.value[3]; return *this; } -ewol::Padding ewol::Padding::operator+(const Padding& _v) { - return Padding(m_value[0] + _v.m_value[0], - m_value[1] + _v.m_value[1], - m_value[2] + _v.m_value[2], - m_value[3] + _v.m_value[3]); +ewol::Padding ewol::Padding::operator+( Padding _v) { + return Padding(this.value[0] + _v.this.value[0], + this.value[1] + _v.this.value[1], + this.value[2] + _v.this.value[2], + this.value[3] + _v.this.value[3]); } -etk::Stream& ewol::operator <<(etk::Stream& _os, const ewol::Padding& _obj) { - _os << "{"; - _os << _obj.xLeft(); - _os << ","; - _os << _obj.yTop(); - _os << ","; - _os << _obj.xRight(); - _os << ","; - _os << _obj.yButtom(); - _os << "}"; +etk::Stream ewol::operator +(etk::Stream _os, ewol::Padding _obj) { + _os + "{"; + _os + _obj.xLeft(); + _os + ","; + _os + _obj.yTop(); + _os + ","; + _os + _obj.xRight(); + _os + ","; + _os + _obj.yButtom(); + _os + "}"; return _os; } diff --git a/src/org/atriasoft/ewol/Padding.java b/src/org/atriasoft/ewol/Padding.java index b03d61c..a43057c 100644 --- a/src/org/atriasoft/ewol/Padding.java +++ b/src/org/atriasoft/ewol/Padding.java @@ -14,30 +14,30 @@ namespace ewol { */ class Padding { private: - float m_value[4]; //!< this represent the 4 padding value Left top right buttom (like css) + float this.value[4]; //!< this represent the 4 padding value Left top right buttom (like css) public: Padding(); Padding(float _xl, float _yt=0.0f, float _xr=0.0f, float _yb=0.0f); void setValue(float _xl, float _yt=0.0f, float _xr=0.0f, float _yb=0.0f); - float x() const; - float y() const; - float xLeft() const; + float x() ; + float y() ; + float xLeft() ; void setXLeft(float _val); - float xRight() const; + float xRight() ; void setXRight(float _val); - float yTop() const; + float yTop() ; void setYTop(float _val); - float yButtom() const; + float yButtom() ; void setYButtom(float _val); /** * @brief Add a vector to this one * @param _v The vector to add to this one */ - Padding& operator+=(const Padding& _v); + Padding operator+=( Padding _v); //! @previous - Padding operator+(const Padding& _v); + Padding operator+( Padding _v); }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::Padding& _obj); + etk::Stream operator +(etk::Stream _os, ewol::Padding _obj); }; diff --git a/src/org/atriasoft/ewol/annotation/EwolAnnotation.java b/src/org/atriasoft/ewol/annotation/EwolAnnotation.java new file mode 100644 index 0000000..fa14477 --- /dev/null +++ b/src/org/atriasoft/ewol/annotation/EwolAnnotation.java @@ -0,0 +1,20 @@ +package org.atriasoft.ewol.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Meta-annotation (annotations used on other annotations) + * used for marking all annotations that are + * part of Exml package. Can be used for recognizing all + * Exml annotations generically, and in future also for + * passing other generic annotation configuration. + */ +@Target({ ElementType.ANNOTATION_TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface EwolAnnotation { + // for now, a pure tag annotation, no parameters + +} diff --git a/src/org/atriasoft/ewol/annotation/EwolDescription.java b/src/org/atriasoft/ewol/annotation/EwolDescription.java new file mode 100644 index 0000000..e09b124 --- /dev/null +++ b/src/org/atriasoft/ewol/annotation/EwolDescription.java @@ -0,0 +1,13 @@ +package org.atriasoft.ewol.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.FIELD, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@EwolAnnotation +public @interface EwolDescription { + String[] value(); +} diff --git a/src/org/atriasoft/ewol/annotation/EwolSignal.java b/src/org/atriasoft/ewol/annotation/EwolSignal.java new file mode 100644 index 0000000..292b528 --- /dev/null +++ b/src/org/atriasoft/ewol/annotation/EwolSignal.java @@ -0,0 +1,6 @@ +package org.atriasoft.ewol.annotation; + +public @interface EwolSignal { + String[] name(); + +} diff --git a/src/org/atriasoft/ewol/compositing/Area.cpp b/src/org/atriasoft/ewol/compositing/Area.cpp index c82c7f9..276c065 100644 --- a/src/org/atriasoft/ewol/compositing/Area.cpp +++ b/src/org/atriasoft/ewol/compositing/Area.cpp @@ -10,32 +10,32 @@ ETK_DECLARE_TYPE(ewol::compositing::Area); // VBO table property: -const int32_t ewol::compositing::Area::m_vboIdCoord(0); -const int32_t ewol::compositing::Area::m_vboIdCoordText(1); -const int32_t ewol::compositing::Area::m_vboIdColor(2); + int ewol::compositing::Area::this.vboIdCoord(0); + int ewol::compositing::Area::this.vboIdCoordText(1); + int ewol::compositing::Area::this.vboIdColor(2); #define NB_VBO (3) -ewol::compositing::Area::Area(const Vector2i& _size) : - m_position(0.0, 0.0, 0.0), - m_color(etk::color::white), - m_GLprogram(null), - m_GLPosition(-1), - m_GLMatrix(-1), - m_GLColor(-1), - m_GLtexture(-1), - m_GLtexID(-1), - m_resource(null) { - m_resource = ewol::resource::Texture::create(); - m_resource->setImageSize(_size); - m_resource->flush(); +ewol::compositing::Area::Area( Vector2i _size) : + this.position(0.0, 0.0, 0.0), + this.color(etk::color::white), + this.GLprogram(null), + this.GLPosition(-1), + this.GLMatrix(-1), + this.GLColor(-1), + this.GLtexture(-1), + this.GLtexID(-1), + this.resource(null) { + this.resource = ewol::resource::Texture::create(); + this.resource.setImageSize(_size); + this.resource.flush(); // Create the VBO: - m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); - if (m_VBO == null) { + 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: - m_VBO->setName("[VBO] of ewol::compositing::Area"); + this.VBO.setName("[VBO] of ewol::compositing::Area"); loadProgram(); } @@ -45,98 +45,98 @@ ewol::compositing::Area::~Area() { void ewol::compositing::Area::loadProgram() { // get the shader resource : - m_GLPosition = 0; - m_GLprogram = gale::resource::Program::create(etk::String("DATA:///textured3D.prog?lib=ewol")); - if (m_GLprogram != null) { - m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); - m_GLColor = m_GLprogram->getAttribute("EW_color"); - m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->getUniform("EW_texID"); + this.GLPosition = 0; + this.GLprogram = gale::resource::Program::create(String("DATA:///textured3D.prog?lib=ewol")); + if (this.GLprogram != null) { + this.GLPosition = this.GLprogram.getAttribute("EW_coord3d"); + this.GLColor = this.GLprogram.getAttribute("EW_color"); + this.GLtexture = this.GLprogram.getAttribute("EW_texture2d"); + this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation"); + this.GLtexID = this.GLprogram.getUniform("EW_texID"); } } -void ewol::compositing::Area::draw(bool _disableDepthTest) { - if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { - //EWOL_WARNING("Nothink to draw..."); +void ewol::compositing::Area::draw(boolean _disableDepthTest) { + if (this.VBO.bufferSize(this.vboIdCoord) <= 0) { + //Log.warning("Nothink to draw..."); return; } - if (m_resource == null) { + if (this.resource == null) { // this is a normale case ... the user can choice to have no image ... return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply; + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // TextureID - m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); + this.GLprogram.setTexture0(this.GLtexID, this.resource.getRendererId()); // position: - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); // Texture: - m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdColor); + this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdColor); // color: - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdCoordText); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdCoordText); // Request the draw od the elements : - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord)); + this.GLprogram.unUse(); } void ewol::compositing::Area::clear() { // call upper class ewol::Compositing::clear(); // reset all VBOs: - m_VBO->clear(); + this.VBO.clear(); // reset temporal variables : - m_position = Vector3f(0.0, 0.0, 0.0); + this.position = Vector3f(0.0, 0.0, 0.0); } -void ewol::compositing::Area::print(const Vector2i& _size) { +void ewol::compositing::Area::print( Vector2i _size) { Vector3f point(0,0,0); Vector2f tex(0,1); - point.setX(m_position.x()); - point.setY(m_position.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdCoordText, tex); + point.setX(this.position.x()); + point.setY(this.position.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdCoordText, tex); tex.setValue(1,1); - point.setX(m_position.x() + _size.x()); - point.setY(m_position.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdCoordText, tex); + point.setX(this.position.x() + _size.x()); + point.setY(this.position.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdCoordText, tex); tex.setValue(1,0); - point.setX(m_position.x() + _size.x()); - point.setY(m_position.y() + _size.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdCoordText, tex); + point.setX(this.position.x() + _size.x()); + point.setY(this.position.y() + _size.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdCoordText, tex); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdCoordText, tex); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdCoordText, tex); tex.setValue(0,0); - point.setX(m_position.x()); - point.setY(m_position.y() + _size.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdCoordText, tex); + point.setX(this.position.x()); + point.setY(this.position.y() + _size.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdCoordText, tex); tex.setValue(0,1); - point.setX(m_position.x()); - point.setY(m_position.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdCoordText, tex); + point.setX(this.position.x()); + point.setY(this.position.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdCoordText, tex); - m_VBO->flush(); + this.VBO.flush(); } diff --git a/src/org/atriasoft/ewol/compositing/Area.java b/src/org/atriasoft/ewol/compositing/Area.java index 80650dd..ec97617 100644 --- a/src/org/atriasoft/ewol/compositing/Area.java +++ b/src/org/atriasoft/ewol/compositing/Area.java @@ -17,22 +17,22 @@ namespace ewol { namespace compositing { class Area : public ewol::Compositing { private: - Vector3f m_position; //!< The current position to draw - etk::Color m_color; //!< The text foreground color + Vector3f this.position; //!< The current position to draw + etk::Color this.color; //!< The text foreground color private: - ememory::SharedPtr m_GLprogram; //!< pointer on the opengl display program - int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) - int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) - int32_t m_GLColor; //!< openGL id on the element (color buffer) - int32_t m_GLtexture; //!< openGL id on the element (Texture position) - int32_t m_GLtexID; //!< openGL id on the element (texture ID) + ememory::Ptr 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.GLColor; //!< openGL id on the element (color buffer) + int this.GLtexture; //!< openGL id on the element (Texture position) + int this.GLtexID; //!< openGL id on the element (texture ID) private: - ememory::SharedPtr m_resource; //!< texture resources + ememory::Ptr this.resource; //!< texture resources protected: - static const int32_t m_vboIdCoord; - static const int32_t m_vboIdCoordText; - static const int32_t m_vboIdColor; - ememory::SharedPtr m_VBO; + static int this.vboIdCoord; + static int this.vboIdCoordText; + static int this.vboIdColor; + ememory::Ptr this.VBO; private: /** * @brief load the openGL program and get all the ID needed @@ -40,19 +40,19 @@ namespace ewol { void loadProgram(); public: /** - * @brief generic constructor + * @brief generic ructor * @param[in] _size Basic size of the area. */ - Area(const Vector2i& _size); + Area( Vector2i _size); /** * @brief generic destructor */ - virtual ~Area(); + ~Area(); public: /** * @brief draw All the refistered text in the current element on openGL */ - void draw(bool _disableDepthTest=true); + void draw(boolean _disableDepthTest=true); /** * @brief clear alll the registered element in the current element */ @@ -61,40 +61,40 @@ namespace ewol { * @brief get the current display position (sometime needed in the gui control) * @return the current position. */ - const Vector3f& getPos() { - return m_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(const Vector3f& _pos) { - m_position = _pos; + void setPos( Vector3f _pos) { + this.position = _pos; }; - inline void setPos(const Vector2f& _pos) { + 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(const Vector3f& _pos) { - m_position += _pos; + void setRelPos( Vector3f _pos) { + this.position += _pos; }; - inline void setRelPos(const Vector2f& _pos) { + void setRelPos( Vector2f _pos) { setRelPos(Vector3f(_pos.x(),_pos.y(),0)); }; /** * @brief add a compleate of the image to display with the requested size * @param[in] _size size of the output image */ - void print(const Vector2i& _size); + void print( Vector2i _size); - egami::Image& get() { - return m_resource->get(); + egami::Image get() { + return this.resource.get(); }; void flush() { - m_resource->flush(); + this.resource.flush(); }; }; }; diff --git a/src/org/atriasoft/ewol/compositing/Compositing.cpp b/src/org/atriasoft/ewol/compositing/Compositing.cpp index 5715a8e..26f620f 100644 --- a/src/org/atriasoft/ewol/compositing/Compositing.cpp +++ b/src/org/atriasoft/ewol/compositing/Compositing.cpp @@ -18,30 +18,30 @@ ewol::Compositing::Compositing() { void ewol::Compositing::resetMatrix() { - m_matrixApply.identity(); + this.matrixApply.identity(); } -void ewol::Compositing::translate(const Vector3f& _vect) { - m_matrixApply *= etk::matTranslate(_vect); +void ewol::Compositing::translate( Vector3f _vect) { + this.matrixApply *= etk::matTranslate(_vect); } -void ewol::Compositing::rotate(const Vector3f& _vect, float _angle) { - m_matrixApply *= etk::matRotate(_vect, _angle); +void ewol::Compositing::rotate( Vector3f _vect, float _angle) { + this.matrixApply *= etk::matRotate(_vect, _angle); } -void ewol::Compositing::scale(const Vector3f& _vect) { - m_matrixApply *= etk::matScale(_vect); +void ewol::Compositing::scale( Vector3f _vect) { + this.matrixApply *= etk::matScale(_vect); } void ewol::Compositing::clear() { - m_matrixApply.identity(); + this.matrixApply.identity(); } -void ewol::Compositing::setMatrix(const mat4& _mat) { - m_matrixApply = _mat; +void ewol::Compositing::setMatrix( mat4 _mat) { + this.matrixApply = _mat; } diff --git a/src/org/atriasoft/ewol/compositing/Compositing.java b/src/org/atriasoft/ewol/compositing/Compositing.java index 6f8bb06..c2a3dfa 100644 --- a/src/org/atriasoft/ewol/compositing/Compositing.java +++ b/src/org/atriasoft/ewol/compositing/Compositing.java @@ -12,47 +12,47 @@ namespace ewol { class Compositing { protected: - mat4 m_matrixApply; + mat4 this.matrixApply; public: /** - * @brief generic constructor + * @brief generic ructor */ Compositing(); /** * @brief Generic destructor */ - virtual ~Compositing() = default; + ~Compositing() = default; /** * @brief Virtal pure function that request the draw of all openGl elements */ - virtual void draw(bool _disableDepthTest = true) = 0; + void draw(boolean _disableDepthTest = true) = 0; /** * @brief clear alll tre registered element in the current element */ - virtual void clear(); + void clear(); /** * @brief reset to the eye matrix the openGL mouving system */ - virtual void resetMatrix(); + void resetMatrix(); /** * @brief translate the current display of this element * @param[in] _vect The translation vector to apply at the transformation matrix */ - virtual void translate(const Vector3f& _vect); + void translate( Vector3f _vect); /** * @brief rotate the curent display of this element * @param[in] _vect The rotation vector to apply at the transformation matrix */ - virtual void rotate(const Vector3f& _vect, float _angle); + void rotate( Vector3f _vect, float _angle); /** * @brief scale the current diaplsy of this element * @param[in] _vect The scaling vector to apply at the transformation matrix */ - virtual void scale(const Vector3f& _vect); + void scale( Vector3f _vect); /** * @brief set the transformation matrix * @param[in] _mat The new matrix. */ - virtual void setMatrix(const mat4& _mat); + void setMatrix( mat4 _mat); }; }; diff --git a/src/org/atriasoft/ewol/compositing/Drawing.cpp b/src/org/atriasoft/ewol/compositing/Drawing.cpp index 7cc9204..9c37acc 100644 --- a/src/org/atriasoft/ewol/compositing/Drawing.cpp +++ b/src/org/atriasoft/ewol/compositing/Drawing.cpp @@ -11,42 +11,42 @@ ETK_DECLARE_TYPE(ewol::compositing::Drawing); // VBO table property: -const int32_t ewol::compositing::Drawing::m_vboIdCoord(0); -const int32_t ewol::compositing::Drawing::m_vboIdColor(1); + int ewol::compositing::Drawing::this.vboIdCoord(0); + int ewol::compositing::Drawing::this.vboIdColor(1); #define NB_VBO (2) #if 0 -static void generatePolyGone(List & input, List & output ) +static void generatePolyGone(List input, List output ) { if (input.size()<3) { return; } // TODO : Regenerate a linear poligone generation - for (int32_t iii=1; iii " << output.size() ); + //Log.debug("generate Plygone : " + input.size() + " == > " + output.size() ); } -static void SutherlandHodgman(List & input, List & output, float sx, float sy, float ex, float ey) +static void SutherlandHodgman(List input, List output, float sx, float sy, float ex, float ey) { // with Sutherland-Hodgman-Algorithm if (input.size() <0) { return; } - //int32_t sizeInit=input.size(); + //int sizeInit=input.size(); // last element : Vector2f destPoint; Vector2f lastElement = input[input.size()-1]; - bool inside = true; + boolean inside = true; if (lastElement.x < sx) { inside = false; } //Log.debug("generate an crop : "); - for(int32_t iii=0; iii OUT "); @@ -83,7 +83,7 @@ static void SutherlandHodgman(List & input, List & output, lastElement.y = input[iii].y; } - //Log.debug("generate an crop on element : " << sizeInit << " == > " << output.size() << "intermediate (1)"); + //Log.debug("generate an crop on element : " + sizeInit + " == > " + output.size() + "intermediate (1)"); input = output; output.clear(); lastElement = input[input.size()-1]; @@ -91,7 +91,7 @@ static void SutherlandHodgman(List & input, List & output, if (lastElement.y < sy) { inside = false; } - for(int32_t iii=0; iii OUT "); @@ -136,7 +136,7 @@ static void SutherlandHodgman(List & input, List & output, inside = false; } //Log.debug("generate an crop : "); - for(int32_t iii=0; iii ex) { if(true == inside) { //Log.debug("element IN == > OUT "); @@ -180,7 +180,7 @@ static void SutherlandHodgman(List & input, List & output, if (lastElement.y > ey) { inside = false; } - for(int32_t iii=0; iii ey) { if(true == inside) { //Log.debug("element IN == > OUT "); @@ -218,37 +218,37 @@ static void SutherlandHodgman(List & input, List & output, } - //Log.debug("generate an crop on element : " << sizeInit << " == > " << output.size() ); + //Log.debug("generate an crop on element : " + sizeInit + " == > " + output.size() ); } #endif ewol::compositing::Drawing::Drawing() : - m_position(0.0, 0.0, 0.0), - m_clippingPosStart(0.0, 0.0, 0.0), - m_clippingPosStop(0.0, 0.0, 0.0), - m_clippingEnable(false), - m_color(etk::color::black), - m_colorBg(etk::color::none), - m_GLprogram(null), - m_GLPosition(-1), - m_GLMatrix(-1), - m_GLMatrixPosition(-1), - m_GLColor(-1), - m_thickness(0.0), - m_triElement(0) { + 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 (int32_t iii=0; iii<3; iii++) { - m_triangle[iii] = m_position; - m_tricolor[iii] = m_color; + for (int iii=0; iii<3; iii++) { + this.triangle[iii] = this.position; + this.tricolor[iii] = this.color; } // Create the VBO: - m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); - if (m_VBO == null) { + 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: - m_VBO->setName("[VBO] of ewol::compositing::Area"); + this.VBO.setName("[VBO] of ewol::compositing::Area"); } ewol::compositing::Drawing::~Drawing() { @@ -256,181 +256,181 @@ ewol::compositing::Drawing::~Drawing() { } void ewol::compositing::Drawing::generateTriangle() { - m_triElement = 0; + this.triElement = 0; - m_VBO->pushOnBuffer(m_vboIdCoord, m_triangle[0]); - m_VBO->pushOnBuffer(m_vboIdColor, m_tricolor[0]); - m_VBO->pushOnBuffer(m_vboIdCoord, m_triangle[1]); - m_VBO->pushOnBuffer(m_vboIdColor, m_tricolor[1]); - m_VBO->pushOnBuffer(m_vboIdCoord, m_triangle[2]); - m_VBO->pushOnBuffer(m_vboIdColor, m_tricolor[2]); + 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(const etk::Color<>& _color) { - if (m_triElement < 1) { - m_tricolor[0] = _color; +void ewol::compositing::Drawing::internalSetColor( etk::Color<> _color) { + if (this.triElement < 1) { + this.tricolor[0] = _color; } - if (m_triElement < 2) { - m_tricolor[1] = _color; + if (this.triElement < 2) { + this.tricolor[1] = _color; } - if (m_triElement < 3) { - m_tricolor[2] = _color; + if (this.triElement < 3) { + this.tricolor[2] = _color; } } -void ewol::compositing::Drawing::setPoint(const Vector3f& _point) { - m_triangle[m_triElement] = _point; - m_triElement++; - if (m_triElement >= 3) { +void ewol::compositing::Drawing::setPoint( Vector3f _point) { + this.triangle[this.triElement] = _point; + this.triElement++; + if (this.triElement >= 3) { generateTriangle(); } - m_VBO->flush(); + this.VBO.flush(); } void ewol::compositing::Drawing::resetCount() { - m_triElement = 0; + this.triElement = 0; } void ewol::compositing::Drawing::unLoadProgram() { - m_GLprogram.reset(); + this.GLprogram.reset(); } void ewol::compositing::Drawing::loadProgram() { // remove previous loading ... in case unLoadProgram(); // oad the new ... - m_GLprogram = gale::resource::Program::create("DATA:///color3.prog?lib=ewol"); + this.GLprogram = gale::resource::Program::create("DATA:///color3.prog?lib=ewol"); // get the shader resource : - if (m_GLprogram != null) { - m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); - m_GLColor = m_GLprogram->getAttribute("EW_color"); - m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); - m_GLMatrixPosition = m_GLprogram->getUniform("EW_MatrixPosition"); + 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(bool _disableDepthTest) { - if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { +void ewol::compositing::Drawing::draw(boolean _disableDepthTest) { + if (this.VBO.bufferSize(this.vboIdCoord) <= 0) { // TODO : set it back ... - //EWOL_WARNING("Nothink to draw..."); + //Log.warning("Nothink to draw..."); return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply; + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); mat4 tmpMatrix2; - m_GLprogram->uniformMatrix(m_GLMatrixPosition, tmpMatrix2); + this.GLprogram.uniformMatrix(this.GLMatrixPosition, tmpMatrix2); // position: - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); // color: - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor); // Request the draw od the elements : - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + 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 : - m_VBO->clear(); + this.VBO.clear(); // reset temporal variables : - m_position = Vector3f(0.0, 0.0, 0.0); + this.position = Vector3f(0.0, 0.0, 0.0); - m_clippingPosStart = Vector3f(0.0, 0.0, 0.0); - m_clippingPosStop = Vector3f(0.0, 0.0, 0.0); - m_clippingEnable = false; + this.clippingPosStart = Vector3f(0.0, 0.0, 0.0); + this.clippingPosStop = Vector3f(0.0, 0.0, 0.0); + this.clippingEnable = false; - m_color = etk::color::black; - m_colorBg = etk::color::none; + this.color = etk::color::black; + this.colorBg = etk::color::none; - for (int32_t iii=0; iii<3; iii++) { - m_triangle[iii] = m_position; - m_tricolor[iii] = m_color; + for (int iii=0; iii<3; iii++) { + this.triangle[iii] = this.position; + this.tricolor[iii] = this.color; } } -void ewol::compositing::Drawing::setClipping(const Vector3f& _pos, const Vector3f& _posEnd) { +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()) { - m_clippingPosStart.setX(_pos.x()); - m_clippingPosStop.setX(_posEnd.x()); + this.clippingPosStart.setX(_pos.x()); + this.clippingPosStop.setX(_posEnd.x()); } else { - m_clippingPosStart.setX(_posEnd.x()); - m_clippingPosStop.setX(_pos.x()); + this.clippingPosStart.setX(_posEnd.x()); + this.clippingPosStop.setX(_pos.x()); } if (_pos.y() <= _posEnd.y()) { - m_clippingPosStart.setY(_pos.y()); - m_clippingPosStop.setY(_posEnd.y()); + this.clippingPosStart.setY(_pos.y()); + this.clippingPosStop.setY(_posEnd.y()); } else { - m_clippingPosStart.setY(_posEnd.y()); - m_clippingPosStop.setY(_pos.y()); + this.clippingPosStart.setY(_posEnd.y()); + this.clippingPosStop.setY(_pos.y()); } if (_pos.z() <= _posEnd.z()) { - m_clippingPosStart.setZ(_pos.z()); - m_clippingPosStop.setZ(_posEnd.z()); + this.clippingPosStart.setZ(_pos.z()); + this.clippingPosStop.setZ(_posEnd.z()); } else { - m_clippingPosStart.setZ(_posEnd.z()); - m_clippingPosStop.setZ(_pos.z()); + this.clippingPosStart.setZ(_posEnd.z()); + this.clippingPosStop.setZ(_pos.z()); } - m_clippingEnable = true; + this.clippingEnable = true; } void ewol::compositing::Drawing::setThickness(float _thickness) { - m_thickness = _thickness; + this.thickness = _thickness; // thickness must be positive - if (m_thickness < 0) { - m_thickness *= -1; + if (this.thickness < 0) { + this.thickness *= -1; } } void ewol::compositing::Drawing::addVertex() { - internalSetColor(m_color); - setPoint(m_position); + internalSetColor(this.color); + setPoint(this.position); } -void ewol::compositing::Drawing::lineTo(const Vector3f& _dest) { +void ewol::compositing::Drawing::lineTo( Vector3f _dest) { resetCount(); - internalSetColor(m_color); - //Log.verbose("DrawLine : " << m_position << " to " << _dest); - if (m_position.x() == _dest.x() && m_position.y() == _dest.y() && m_position.z() == _dest.z()) { - //EWOL_WARNING("Try to draw a line width 0"); + 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 (m_position.x() <= _dest.x()) { - teta = atan((_dest.y()-m_position.y())/(_dest.x()-m_position.x())); + 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()-m_position.y())/(_dest.x()-m_position.x())); + 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) * (m_thickness/2); - float offsetx = cos(teta-M_PI/2) * (m_thickness/2); - setPoint(Vector3f(m_position.x() - offsetx, m_position.y() - offsety, m_position.z()) ); - setPoint(Vector3f(m_position.x() + offsetx, m_position.y() + offsety, m_position.z()) ); - setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, m_position.z()) ); + //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(m_position.x() - offsetx, m_position.y() - offsety, _dest.z()) ); + setPoint(Vector3f(this.position.x() - offsetx, this.position.y() - offsety, _dest.z()) ); // update the system position : - m_position = _dest; + this.position = _dest; } -void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) { +void ewol::compositing::Drawing::rectangle( Vector3f _dest) { resetCount(); - internalSetColor(m_color); + internalSetColor(this.color); /* Bitmap position * xA xB * yC *------* @@ -438,7 +438,7 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) { * | | * yD *------* */ - float dxA = m_position.x(); + float dxA = this.position.x(); float dxB = _dest.x(); if (dxA > dxB) { // inverse order : @@ -446,7 +446,7 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) { dxA = dxB; dxB = tmp; } - float dyC = m_position.y(); + float dyC = this.position.y(); float dyD = _dest.y(); if (dyC > dyD) { // inverse order : @@ -454,18 +454,18 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) { dyC = dyD; dyD = tmp; } - if (true == m_clippingEnable) { - if (dxA < m_clippingPosStart.x()) { - dxA = m_clippingPosStart.x(); + if (true == this.clippingEnable) { + if (dxA < this.clippingPosStart.x()) { + dxA = this.clippingPosStart.x(); } - if (dxB > m_clippingPosStop.x()) { - dxB = m_clippingPosStop.x(); + if (dxB > this.clippingPosStop.x()) { + dxB = this.clippingPosStop.x(); } - if (dyC < m_clippingPosStart.y()) { - dyC = m_clippingPosStart.y(); + if (dyC < this.clippingPosStart.y()) { + dyC = this.clippingPosStart.y(); } - if (dyD > m_clippingPosStop.y()) { - dyD = m_clippingPosStop.y(); + if (dyD > this.clippingPosStop.y()) { + dyD = this.clippingPosStop.y(); } } if( dyC >= dyD @@ -481,7 +481,7 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) { setPoint(Vector3f(dxA, dyD, 0) ); } -void ewol::compositing::Drawing::cube(const Vector3f& _dest) { +void ewol::compositing::Drawing::cube( Vector3f _dest) { } @@ -494,65 +494,65 @@ void ewol::compositing::Drawing::circle(float _radius, float _angleStart, float _angleStop = _angleStop-_angleStart; - int32_t nbOcurence = _radius; + int nbOcurence = _radius; if (nbOcurence < 10) { nbOcurence = 10; } // display background : - if (m_colorBg.a()!=0) { - internalSetColor(m_colorBg); - for (int32_t iii=0; iii m_color; //!< The text foreground color - etk::Color<> m_colorBg; //!< The text background color + etk::Color<> this.color; //!< The text foreground color + etk::Color<> this.colorBg; //!< The text background color private: - ememory::SharedPtr m_GLprogram; //!< pointer on the opengl display program - int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) - int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) - int32_t m_GLMatrixPosition; //!< position matrix - int32_t m_GLColor; //!< openGL id on the element (color buffer) + ememory::Ptr 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.GLMatrixPosition; //!< position matrix + int this.GLColor; //!< openGL id on the element (color buffer) protected: - static const int32_t m_vboIdCoord; - static const int32_t m_vboIdColor; - ememory::SharedPtr m_VBO; + static int this.vboIdCoord; + static int this.vboIdColor; + ememory::Ptr this.VBO; public: /** - * @brief Basic constructor + * @brief Basic ructor */ Drawing(); /** * @brief Basic destructor */ - virtual ~Drawing(); + ~Drawing(); private: /** * @brief load the openGL program and get all the ID needed @@ -51,10 +51,10 @@ namespace ewol { * @brief Un-Load the openGL program and get all the ID needed */ void unLoadProgram(); - float m_thickness; //!< when drawing line and other things - int32_t m_triElement; //!< special counter of the single dot generated - Vector3f m_triangle[3]; //!< Register every system with a combinaison of tiangle - etk::Color m_tricolor[3]; //!< Register every the associated color foreground + float this.thickness; //!< when drawing line and other things + int this.triElement; //!< special counter of the single dot generated + Vector3f this.triangle[3]; //!< Register every system with a combinaison of tiangle + etk::Color this.tricolor[3]; //!< Register every the associated color foreground // internal API for the generation abstraction of triangles /** * @brief Lunch the generation of triangle @@ -68,18 +68,18 @@ namespace ewol { * @brief set the Color of the current triangle drawing * @param[in] _color Color to current dots generated */ - void internalSetColor(const etk::Color<>& _color); + void internalSetColor( etk::Color<> _color); /** * @brief internal add of the specific point * @param[in] _point The requeste dpoint to add */ - void setPoint(const Vector3f& point); + void setPoint( Vector3f point); public: /** * @brief draw All the refistered text in the current element on openGL */ - void draw(bool _disableDepthTest=true); + void draw(boolean _disableDepthTest=true); /** * @brief clear alll tre registered element in the current element */ @@ -88,66 +88,66 @@ namespace ewol { * @brief get the current display position (sometime needed in the gui control) * @return the current position. */ - const Vector3f& getPos() { - return m_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(const Vector3f& _pos) { - m_position = _pos; + void setPos( Vector3f _pos) { + this.position = _pos; }; - inline void setPos(const Vector2f& _pos) { + 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(const Vector3f& _pos) { - m_position += _pos; + void setRelPos( Vector3f _pos) { + this.position += _pos; }; - inline void setRelPos(const Vector2f& _pos) { + void setRelPos( 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) */ - void setColor(const etk::Color<>& _color) { - m_color = _color; + void setColor( etk::Color<> _color) { + this.color = _color; }; /** * @brief Get the foreground color of the font. * @return Foreground color. */ - const etk::Color<>& getColor() { - return m_color; + etk::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) */ - void setColorBg(const etk::Color<>& _color) { - m_colorBg = _color; + void setColorBg( etk::Color<> _color) { + this.colorBg = _color; }; /** * @brief Get the background color of the font. * @return Background color. */ - const etk::Color<>& getColorBg() { - return m_colorBg; + etk::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 */ - void setClippingWidth(const Vector3f& _pos, const Vector3f& _width) { + void setClippingWidth( Vector3f _pos, Vector3f _width) { setClipping(_pos, _pos+_width); }; - inline void setClippingWidth(const Vector2f& _pos, const Vector2f& _width) { + void setClippingWidth( Vector2f _pos, Vector2f _width) { setClippingWidth(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_width.x(),_width.y(), 2)); }; /** @@ -155,16 +155,16 @@ namespace ewol { * @param[in] _pos Start position of the clipping * @param[in] _posEnd End position of the clipping */ - void setClipping(const Vector3f& _pos, const Vector3f& _posEnd); - inline void setClipping(const Vector2f& _pos, const Vector2f& _posEnd) { + void setClipping( Vector3f _pos, Vector3f _posEnd); + 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 */ - void setClippingMode(bool _newMode) { - m_clippingEnable = _newMode; + void setClippingMode(boolean _newMode) { + this.clippingEnable = _newMode; }; /** * @brief Specify the line thickness for the next elements @@ -179,43 +179,43 @@ namespace ewol { * @brief draw a line to a specific position * @param[in] _dest Position of the end of the line. */ - void lineTo(const Vector3f& _dest); - inline void lineTo(const Vector2f& _dest) { + void lineTo( Vector3f _dest); + void lineTo( Vector2f _dest) { lineTo(Vector3f(_dest.x(), _dest.y(), 0)); }; /** * @brief Relative drawing a line (spacial vector) * @param[in] _vect Vector of the curent line. */ - void lineRel(const Vector3f& _vect) { - lineTo(m_position+_vect); + void lineRel( Vector3f _vect) { + lineTo(this.position+_vect); }; - inline void lineRel(const Vector2f& _vect) { + void lineRel( Vector2f _vect) { lineRel(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 */ - void rectangle(const Vector3f& _dest); - inline void rectangle(const Vector2f& _dest) { + void rectangle( Vector3f _dest); + void rectangle( 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 */ - void rectangleWidth(const Vector3f& _size) { - rectangle(m_position+_size); + void rectangleWidth( Vector3f _size) { + rectangle(this.position+_size); }; - inline void rectangleWidth(const Vector2f& _size) { + void rectangleWidth( 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 */ - void cube(const Vector3f& _dest); + void cube( Vector3f _dest); /** * @brief draw a 2D circle with the specify rafdius parameter. * @param[in] _radius Distence to the dorder diff --git a/src/org/atriasoft/ewol/compositing/Image.cpp b/src/org/atriasoft/ewol/compositing/Image.cpp index 2e85a72..37b13fc 100644 --- a/src/org/atriasoft/ewol/compositing/Image.cpp +++ b/src/org/atriasoft/ewol/compositing/Image.cpp @@ -9,42 +9,42 @@ #include ETK_DECLARE_TYPE(ewol::compositing::Image); -const int32_t ewol::compositing::Image::sizeAuto(0); + int ewol::compositing::Image::sizeAuto(0); // VBO table property: -const int32_t ewol::compositing::Image::m_vboIdCoord(0); -const int32_t ewol::compositing::Image::m_vboIdCoordTex(1); -const int32_t ewol::compositing::Image::m_vboIdColor(2); + int ewol::compositing::Image::this.vboIdCoord(0); + int ewol::compositing::Image::this.vboIdCoordTex(1); + int ewol::compositing::Image::this.vboIdColor(2); #define NB_VBO (3) -ewol::compositing::Image::Image(const etk::Uri& _imageName, - bool _df, - int32_t _size) : - m_filename(_imageName), - m_requestSize(2,2), - m_position(0.0, 0.0, 0.0), - m_clippingPosStart(0.0, 0.0, 0.0), - m_clippingPosStop(0.0, 0.0, 0.0), - m_clippingEnable(false), - m_color(etk::color::white), - m_angle(0.0), - m_GLprogram(null), - m_GLPosition(-1), - m_GLMatrix(-1), - m_GLColor(-1), - m_GLtexture(-1), - m_GLtexID(-1), - m_distanceFieldMode(_df), - m_resource(null), - m_resourceDF(null) { +ewol::compositing::Image::Image( etk::Uri _imageName, + boolean _df, + int _size) : + this.filename(_imageName), + this.requestSize(2,2), + 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::white), + this.angle(0.0), + this.GLprogram(null), + this.GLPosition(-1), + this.GLMatrix(-1), + this.GLColor(-1), + this.GLtexture(-1), + this.GLtexID(-1), + this.distanceFieldMode(_df), + this.resource(null), + this.resourceDF(null) { // Create the VBO: - m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); - if (m_VBO == null) { + 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: - m_VBO->setName("[VBO] of ewol::compositing::Image"); + this.VBO.setName("[VBO] of ewol::compositing::Image"); setSource(_imageName, _size); loadProgram(); } @@ -55,310 +55,310 @@ ewol::compositing::Image::~Image() { void ewol::compositing::Image::loadProgram() { // get the shader resource: - m_GLPosition = 0; - m_GLprogram.reset(); - if (m_distanceFieldMode == true) { - m_GLprogram = gale::resource::Program::create("DATA:///texturedDF.prog?lib=ewol"); + this.GLPosition = 0; + this.GLprogram.reset(); + if (this.distanceFieldMode == true) { + this.GLprogram = gale::resource::Program::create("DATA:///texturedDF.prog?lib=ewol"); } else { - m_GLprogram = gale::resource::Program::create("DATA:///textured3D.prog?lib=ewol"); + this.GLprogram = gale::resource::Program::create("DATA:///textured3D.prog?lib=ewol"); } - if (m_GLprogram != null) { - m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); - m_GLColor = m_GLprogram->getAttribute("EW_color"); - m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->getUniform("EW_texID"); + if (this.GLprogram != null) { + this.GLPosition = this.GLprogram.getAttribute("EW_coord3d"); + this.GLColor = this.GLprogram.getAttribute("EW_color"); + this.GLtexture = this.GLprogram.getAttribute("EW_texture2d"); + this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation"); + this.GLtexID = this.GLprogram.getUniform("EW_texID"); } } -void ewol::compositing::Image::draw(bool _disableDepthTest) { - if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { - //EWOL_WARNING("Nothink to draw..."); +void ewol::compositing::Image::draw(boolean _disableDepthTest) { + if (this.VBO.bufferSize(this.vboIdCoord) <= 0) { + //Log.warning("Nothink to draw..."); return; } - if ( m_resource == null - && m_resourceDF == null - && m_resourceImage == null) { + if ( this.resource == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceDF == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceImage == null) { // this is a normale case ... the user can choice to have no image ... return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } - //EWOL_WARNING("Display image : " << m_VBO->bufferSize(m_vboIdCoord)); + //Log.warning("Display image : " + this.VBO.bufferSize(this.vboIdCoord)); if (_disableDepthTest == true) { gale::openGL::disable(gale::openGL::flag_depthTest); } else { gale::openGL::enable(gale::openGL::flag_depthTest); } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply; + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // TextureID - if (m_resourceImage != null) { - m_GLprogram->setTexture0(m_GLtexID, m_resourceImage->getRendererId()); - } else if (m_resource != null) { - if (m_distanceFieldMode == true) { + if (this.resourceImage != null) { + this.GLprogram.setTexture0(this.GLtexID, this.resourceImage.getRendererId()); + } else if (this.resource != null) { + if (this.distanceFieldMode == true) { Log.error("FONT type error Request distance field and display normal ..."); } - m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); + this.GLprogram.setTexture0(this.GLtexID, this.resource.getRendererId()); } else { - if (m_distanceFieldMode == false) { + if (this.distanceFieldMode == false) { Log.error("FONT type error Request normal and display distance field ..."); } - m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getRendererId()); + this.GLprogram.setTexture0(this.GLtexID, this.resourceDF.getRendererId()); } // position: - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); // Texture: - m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordTex); + this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordTex); // color: - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor); // Request the draw of the elements: - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord)); + this.GLprogram.unUse(); } void ewol::compositing::Image::clear() { // call upper class ewol::Compositing::clear(); // reset Buffer : - m_VBO->clear(); + this.VBO.clear(); // reset temporal variables : - m_position = Vector3f(0.0, 0.0, 0.0); - m_clippingPosStart = Vector3f(0.0, 0.0, 0.0); - m_clippingPosStop = Vector3f(0.0, 0.0, 0.0); - m_clippingEnable = false; - m_color = etk::color::white; - m_angle = 0.0; + 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::white; + this.angle = 0.0; } -void ewol::compositing::Image::setClipping(const Vector3f& _pos, Vector3f _posEnd) { +void ewol::compositing::Image::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()) { - m_clippingPosStart.setX(_pos.x()); - m_clippingPosStop.setX(_posEnd.x()); + this.clippingPosStart.setX(_pos.x()); + this.clippingPosStop.setX(_posEnd.x()); } else { - m_clippingPosStart.setX(_posEnd.x()); - m_clippingPosStop.setX(_pos.x()); + this.clippingPosStart.setX(_posEnd.x()); + this.clippingPosStop.setX(_pos.x()); } if (_pos.y() <= _posEnd.y()) { - m_clippingPosStart.setY(_pos.y()); - m_clippingPosStop.setY(_posEnd.y()); + this.clippingPosStart.setY(_pos.y()); + this.clippingPosStop.setY(_posEnd.y()); } else { - m_clippingPosStart.setY(_posEnd.y()); - m_clippingPosStop.setY(_pos.y()); + this.clippingPosStart.setY(_posEnd.y()); + this.clippingPosStop.setY(_pos.y()); } if (_pos.z() <= _posEnd.z()) { - m_clippingPosStart.setZ(_pos.z()); - m_clippingPosStop.setZ(_posEnd.z()); + this.clippingPosStart.setZ(_pos.z()); + this.clippingPosStop.setZ(_posEnd.z()); } else { - m_clippingPosStart.setZ(_posEnd.z()); - m_clippingPosStop.setZ(_pos.z()); + this.clippingPosStart.setZ(_posEnd.z()); + this.clippingPosStop.setZ(_pos.z()); } - m_clippingEnable = true; + this.clippingEnable = true; } void ewol::compositing::Image::setAngle(float _angle) { - m_angle = _angle; + this.angle = _angle; } -void ewol::compositing::Image::print(const Vector2f& _size) { +void ewol::compositing::Image::print( Vector2f _size) { printPart(_size, Vector2f(0,0), Vector2f(1.0,1.0)); } -void ewol::compositing::Image::printPart(const Vector2f& _size, +void ewol::compositing::Image::printPart( Vector2f _size, Vector2f _sourcePosStart, Vector2f _sourcePosStop) { - if (m_resource == null) { + if (this.resource == null) { return; } - Vector2f openGLSize = Vector2f(m_resource->getOpenGlSize().x(), m_resource->getOpenGlSize().y()); - Vector2f usefullSize = m_resource->getUsableSize(); + Vector2f openGLSize = Vector2f(this.resource.getOpenGlSize().x(), this.resource.getOpenGlSize().y()); + Vector2f usefullSize = this.resource.getUsableSize(); Vector2f ratio = usefullSize/openGLSize; _sourcePosStart *= ratio; _sourcePosStop *= ratio; - Log.verbose(" openGLSize=" << openGLSize << " usableSize=" << usefullSize << " start=" << _sourcePosStart << " stop=" << _sourcePosStop); + Log.verbose(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + _sourcePosStart + " stop=" + _sourcePosStop); - //Log.error("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop); - if (m_angle == 0.0f) { - Vector3f point = m_position; + //Log.error("Debug image " + this.filename + " ==> " + this.position + " " + _size + " " + _sourcePosStart + " " << _sourcePosStop); + if (this.angle == 0.0f) { + Vector3f point = this.position; Vector2f tex(_sourcePosStart.x(),_sourcePosStop.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStop.x(),_sourcePosStop.y()); - point.setX(m_position.x() + _size.x()); - point.setY(m_position.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point.setX(this.position.x() + _size.x()); + point.setY(this.position.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStop.x(),_sourcePosStart.y()); - point.setX(m_position.x() + _size.x()); - point.setY(m_position.y() + _size.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point.setX(this.position.x() + _size.x()); + point.setY(this.position.y() + _size.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStart.x(),_sourcePosStart.y()); - point.setX(m_position.x()); - point.setY(m_position.y() + _size.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point.setX(this.position.x()); + point.setY(this.position.y() + _size.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStart.x(),_sourcePosStop.y()); - point.setX(m_position.x()); - point.setY(m_position.y()); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->flush(); + point.setX(this.position.x()); + point.setY(this.position.y()); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.flush(); return; } - Vector3f center = m_position + Vector3f(_size.x(),_size.y(),0)/2.0f; + Vector3f center = this.position + Vector3f(_size.x(),_size.y(),0)/2.0f; Vector3f limitedSize(_size.x()*0.5f, _size.y()*0.5f, 0.0f); Vector3f point(0,0,0); Vector2f tex(_sourcePosStart.x(),_sourcePosStop.y()); point.setValue(-limitedSize.x(), -limitedSize.y(), 0); - point = point.rotate(Vector3f(0,0,1), m_angle) + center; - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point = point.rotate(Vector3f(0,0,1), this.angle) + center; + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStop.x(),_sourcePosStop.y()); point.setValue(limitedSize.x(), -limitedSize.y(), 0); - point = point.rotate(Vector3f(0,0,1), m_angle) + center; - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point = point.rotate(Vector3f(0,0,1), this.angle) + center; + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStop.x(),_sourcePosStart.y()); point.setValue(limitedSize.x(), limitedSize.y(), 0); - point = point.rotate(Vector3f(0,0,1), m_angle) + center; - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point = point.rotate(Vector3f(0,0,1), this.angle) + center; + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStart.x(),_sourcePosStart.y()); point.setValue(-limitedSize.x(), limitedSize.y(), 0); - point = point.rotate(Vector3f(0,0,1), m_angle) + center; - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point = point.rotate(Vector3f(0,0,1), this.angle) + center; + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); tex.setValue(_sourcePosStart.x(),_sourcePosStop.y()); point.setValue(-limitedSize.x(), -limitedSize.y(), 0); - point = point.rotate(Vector3f(0,0,1), m_angle) + center; - m_VBO->pushOnBuffer(m_vboIdCoord, point); - m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + point = point.rotate(Vector3f(0,0,1), this.angle) + center; + this.VBO.pushOnBuffer(this.vboIdCoord, point); + this.VBO.pushOnBuffer(this.vboIdCoordTex, tex); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); - m_VBO->flush(); + this.VBO.flush(); } -void ewol::compositing::Image::setSource(const etk::Uri& _uri, const Vector2f& _size) { +void ewol::compositing::Image::setSource( etk::Uri _uri, Vector2f _size) { clear(); - if ( m_filename == _uri - && m_requestSize == _size) { + if ( this.filename == _uri + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.requestSize == _size) { // Nothing to do ... return; } - ememory::SharedPtr resource = m_resource; - ememory::SharedPtr resourceDF = m_resourceDF; - ememory::SharedPtr resourceTex = m_resourceImage; - m_filename = _uri; - m_requestSize = _size; - m_resource.reset(); - m_resourceDF.reset(); - m_resourceImage.reset(); + ememory::Ptr resource = this.resource; + ememory::Ptr resourceDF = this.resourceDF; + ememory::Ptr resourceTex = this.resourceImage; + this.filename = _uri; + this.requestSize = _size; + this.resource.reset(); + this.resourceDF.reset(); + this.resourceImage.reset(); Vector2i tmpSize(_size.x(),_size.y()); // note that no image can be loaded... if (_uri.isEmpty() == false) { // link to new one - if (m_distanceFieldMode == false) { - m_resource = ewol::resource::TextureFile::create(m_filename, tmpSize); - if (m_resource == null) { + if (this.distanceFieldMode == false) { + this.resource = ewol::resource::TextureFile::create(this.filename, tmpSize); + if (this.resource == null) { Log.error("Can not get Image resource"); } } else { - m_resourceDF = ewol::resource::ImageDF::create(m_filename, tmpSize); - if (m_resourceDF == null) { + this.resourceDF = ewol::resource::ImageDF::create(this.filename, tmpSize); + if (this.resourceDF == null) { Log.error("Can not get Image resource DF"); } } } - if ( m_resource == null - && m_resourceDF == null - && m_resourceImage == null) { + if ( this.resource == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceDF == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceImage == null) { if (resource != null) { - EWOL_WARNING("Retrive previous resource"); - m_resource = resource; + Log.warning("Retrive previous resource"); + this.resource = resource; } if (resourceDF != null) { - EWOL_WARNING("Retrive previous resource (DF)"); - m_resourceDF = resourceDF; + Log.warning("Retrive previous resource (DF)"); + this.resourceDF = resourceDF; } if (resourceTex != null) { - EWOL_WARNING("Retrive previous resource (image)"); - m_resourceImage = resourceTex; + Log.warning("Retrive previous resource (image)"); + this.resourceImage = resourceTex; } } } void ewol::compositing::Image::setSource(egami::Image _image) { clear(); - m_filename = "direct image BUFFER"; - m_requestSize = _image.getSize(); - m_resourceImage = ewol::resource::Texture::create(); - m_resourceImage->set(etk::move(_image)); + this.filename = "direct image BUFFER"; + this.requestSize = _image.getSize(); + this.resourceImage = ewol::resource::Texture::create(); + this.resourceImage.set(etk::move(_image)); } -bool ewol::compositing::Image::hasSources() { - return m_resource != null - || m_resourceDF != null; +boolean ewol::compositing::Image::hasSources() { + return this.resource != null + || this.resourceDF != null; } Vector2f ewol::compositing::Image::getRealSize() { - if ( m_resource == null - && m_resourceDF == null - && m_resourceImage == null) { + if ( this.resource == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceDF == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceImage == null) { return Vector2f(0,0); } - if (m_resource != null) { - return m_resource->getRealSize(); + if (this.resource != null) { + return this.resource.getRealSize(); } - if (m_resourceDF != null) { - return m_resourceDF->getRealSize(); + if (this.resourceDF != null) { + return this.resourceDF.getRealSize(); } - if (m_resourceImage != null) { - return m_resourceImage->getUsableSize(); + if (this.resourceImage != null) { + return this.resourceImage.getUsableSize(); } return Vector2f(0,0); } -void ewol::compositing::Image::setDistanceFieldMode(bool _mode) { - if (m_distanceFieldMode == _mode) { +void ewol::compositing::Image::setDistanceFieldMode(boolean _mode) { + if (this.distanceFieldMode == _mode) { return; } - m_distanceFieldMode = _mode; + this.distanceFieldMode = _mode; // Force reload input - setSource(m_filename, m_requestSize); + setSource(this.filename, this.requestSize); loadProgram(); } diff --git a/src/org/atriasoft/ewol/compositing/Image.java b/src/org/atriasoft/ewol/compositing/Image.java index a35794b..18d2c60 100644 --- a/src/org/atriasoft/ewol/compositing/Image.java +++ b/src/org/atriasoft/ewol/compositing/Image.java @@ -15,33 +15,33 @@ namespace ewol { namespace compositing { class Image : public ewol::Compositing { public: - static const int32_t sizeAuto; + static int sizeAuto; private: - etk::Uri m_filename; - Vector2i m_requestSize; - Vector3f m_position; //!< The current position to draw - Vector3f m_clippingPosStart; //!< Clipping start position - Vector3f m_clippingPosStop; //!< Clipping stop position - bool m_clippingEnable; //!< true if the clipping must be activated + etk::Uri this.filename; + Vector2i this.requestSize; + 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 private: - etk::Color m_color; //!< The text foreground color - float m_angle; //!< Angle to set at the axes + etk::Color this.color; //!< The text foreground color + float this.angle; //!< Angle to set at the axes private: - ememory::SharedPtr m_GLprogram; //!< pointer on the opengl display program - int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) - int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) - int32_t m_GLColor; //!< openGL id on the element (color buffer) - int32_t m_GLtexture; //!< openGL id on the element (Texture position) - int32_t m_GLtexID; //!< openGL id on the element (texture ID) + ememory::Ptr 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.GLColor; //!< openGL id on the element (color buffer) + int this.GLtexture; //!< openGL id on the element (Texture position) + int this.GLtexID; //!< openGL id on the element (texture ID) private: - bool m_distanceFieldMode; //!< select distance field mode - ememory::SharedPtr m_resource; //!< texture resources - ememory::SharedPtr m_resourceImage; //!< texture resources - ememory::SharedPtr m_resourceDF; //!< texture resources - static const int32_t m_vboIdCoord; - static const int32_t m_vboIdCoordTex; - static const int32_t m_vboIdColor; - ememory::SharedPtr m_VBO; + boolean this.distanceFieldMode; //!< select distance field mode + ememory::Ptr this.resource; //!< texture resources + ememory::Ptr this.resourceImage; //!< texture resources + ememory::Ptr this.resourceDF; //!< texture resources + static int this.vboIdCoord; + static int this.vboIdCoordTex; + static int this.vboIdColor; + ememory::Ptr this.VBO; private: /** * @brief load the openGL program and get all the ID needed @@ -49,24 +49,24 @@ namespace ewol { void loadProgram(); public: /** - * @brief generic constructor + * @brief generic ructor * @param[in] _uri URI of the file that might be loaded * @param[in] _df enable distance field mode * @param[in] _size for the image when Verctorial image loading is requested */ - Image(const etk::Uri& _uri="", - bool _df=false, - int32_t _size=ewol::compositing::Image::sizeAuto); + Image( etk::Uri _uri="", + boolean _df=false, + int _size=ewol::compositing::Image::sizeAuto); /** * @brief generic destructor */ - virtual ~Image(); + ~Image(); public: /** * @brief draw All the refistered text in the current element on openGL * @param[in] _disableDepthTest disable the Depth test for display */ - void draw(bool _disableDepthTest=true); + void draw(boolean _disableDepthTest=true); /** * @brief clear alll tre registered element in the current element */ @@ -75,45 +75,45 @@ namespace ewol { * @brief get the current display position (sometime needed in the gui control) * @return the current position. */ - const Vector3f& getPos() { - return m_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(const Vector3f& _pos) { - m_position = _pos; + void setPos( Vector3f _pos) { + this.position = _pos; }; - inline void setPos(const Vector2f& _pos) { + 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(const Vector3f& _pos) { - m_position += _pos; + void setRelPos( Vector3f _pos) { + this.position += _pos; }; - inline void setRelPos(const Vector2f& _pos) { + void setRelPos( 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) */ - void setColor(const etk::Color<>& _color) { - m_color = _color; + void setColor( etk::Color<> _color) { + this.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(const Vector3f& _pos, Vector3f _width) { + void setClippingWidth( Vector3f _pos, Vector3f _width) { setClipping(_pos, _pos+_width); }; - inline void setClippingWidth(const Vector2f& _pos, const Vector2f& _width) { + void setClippingWidth( Vector2f _pos, Vector2f _width) { setClippingWidth(Vector3f(_pos.x(),_pos.y(),0), Vector3f(_width.x(),_width.y(),0)); }; /** @@ -121,16 +121,16 @@ namespace ewol { * @param[in] _pos Start position of the clipping * @param[in] _posEnd End position of the clipping */ - void setClipping(const Vector3f& _pos, Vector3f _posEnd); - inline void setClipping(const Vector2f& _pos, const Vector2f& _posEnd) { + void setClipping( Vector3f _pos, Vector3f _posEnd); + void setClipping( Vector2f _pos, Vector2f _posEnd) { setClipping(Vector3f(_pos.x(),_pos.y(),0), Vector3f(_posEnd.x(),_posEnd.y(),0)); }; /** * @brief enable/Disable the clipping (without lose the current clipping position) * @brief _newMode The new status of the clipping */ - void setClippingMode(bool _newMode) { - m_clippingEnable = _newMode; + void setClippingMode(boolean _newMode) { + this.clippingEnable = _newMode; }; /** * @brief set a unique rotation of this element (not set in the rotate Generic system) @@ -141,17 +141,17 @@ namespace ewol { * @brief add a compleate of the image to display with the requested size * @param[in] _size size of the output image */ - void print(const Vector2i& _size) { + void print( Vector2i _size) { print(Vector2f(_size.x(),_size.y())); }; - void print(const Vector2f& _size); + void print( Vector2f _size); /** * @brief add a part of the image to display with the requested size * @param[in] _size size of the output image * @param[in] _sourcePosStart Start position in the image [0..1] (can be bigger but this repeate the image). * @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image). */ - void printPart(const Vector2f& _size, + void printPart( Vector2f _size, Vector2f _sourcePosStart, Vector2f _sourcePosStop); /** @@ -159,16 +159,16 @@ namespace ewol { * @param[in] _uri New file of the Image * @param[in] _size for the image when Verctorial image loading is requested */ - void setSource(const etk::Uri& _uri, int32_t _size=32) { + void setSource( etk::Uri _uri, int _size=32) { setSource(_uri, Vector2f(_size,_size)); }; - void setSource(const etk::Uri& _uri, const Vector2f& _size); + void setSource( etk::Uri _uri, Vector2f _size); void setSource(egami::Image _image); /** * @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. */ - bool hasSources(); + boolean hasSources(); /** * @brief get the source image registered size in the file (<0 when multiple size image) * @return tre image registered size @@ -179,13 +179,13 @@ namespace ewol { * @brief Set render mode of the image * @param[in] _mode Activation of distance field mode */ - void setDistanceFieldMode(bool _mode); + void setDistanceFieldMode(boolean _mode); /** * @brief Get the render methode. * @return The render mode of the image. */ - bool getDistanceFieldMode() const { - return m_distanceFieldMode; + boolean getDistanceFieldMode() { + return this.distanceFieldMode; } }; }; diff --git a/src/org/atriasoft/ewol/compositing/Shaper.cpp b/src/org/atriasoft/ewol/compositing/Shaper.cpp index ff6f80e..a87ec62 100644 --- a/src/org/atriasoft/ewol/compositing/Shaper.cpp +++ b/src/org/atriasoft/ewol/compositing/Shaper.cpp @@ -11,50 +11,50 @@ ETK_DECLARE_TYPE(ewol::compositing::Shaper); // VBO table property: -const int32_t ewol::compositing::Shaper::m_vboIdCoord(0); -const int32_t ewol::compositing::Shaper::m_vboIdPos(1); + int ewol::compositing::Shaper::this.vboIdCoord(0); + int ewol::compositing::Shaper::this.vboIdPos(1); #define NB_VBO (2) -ewol::compositing::Shaper::Shaper(const etk::Uri& _uri) : - m_uri(_uri), - m_config(null), - m_confIdMode(-1), - m_confIdDisplayOutside(-1), - m_confIdChangeTime(-1), - m_confProgramFile(-1), - m_confColorFile(-1), - m_confImageFile(-1), - m_GLprogram(null), - m_GLPosition(-1), - m_GLMatrix(-1), - m_GLStateActivate(-1), - m_GLStateOld(-1), - m_GLStateNew(-1), - m_GLStateTransition(-1), - m_resourceTexture(null), - m_nextStatusRequested(-1), - m_propertyOrigin(0,0), - m_propertySize(0,0), - m_propertyInsidePosition(0,0), - m_propertyInsideSize(0,0), - m_stateActivate(0), - m_stateOld(0), - m_stateNew(0), - m_stateTransition(1.0), - m_nbVertexToDisplay(0) { - for (size_t iii=0; iiisetName("[VBO] of ewol::compositing::Shaper"); + this.VBO.setName("[VBO] of ewol::compositing::Shaper"); loadProgram(); } @@ -63,225 +63,225 @@ ewol::compositing::Shaper::~Shaper() { } void ewol::compositing::Shaper::unLoadProgram() { - m_GLprogram.reset(); - m_resourceTexture.reset(); - m_config.reset(); - m_colorProperty.reset(); - for (size_t iii=0; iiiclear(); - m_confIdMode = -1; - m_confIdDisplayOutside = -1; - m_nbVertexToDisplay = 0; - m_confIdChangeTime = -1; - m_confProgramFile = -1; - m_confImageFile = -1; - m_listAssiciatedId.clear(); + 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 (m_uri.isEmpty() == true) { + if (this.uri.isEmpty() == true) { Log.debug("no Shaper set for loading resources ..."); return; } - m_config = ewol::resource::ConfigFile::create(m_uri.get()); - if (m_config != null) { - m_confIdMode = m_config->request("mode"); - m_confIdDisplayOutside = m_config->request("display-outside"); - m_confIdPaddingOut[shaperPosLeft] = m_config->request("padding-out-left"); - m_confIdPaddingOut[shaperPosRight] = m_config->request("padding-out-right"); - m_confIdPaddingOut[shaperPosTop] = m_config->request("padding-out-top"); - m_confIdPaddingOut[shaperPosButtom] = m_config->request("padding-out-buttom"); - m_confIdBorder[shaperPosLeft] = m_config->request("border-left"); - m_confIdBorder[shaperPosRight] = m_config->request("border-right"); - m_confIdBorder[shaperPosTop] = m_config->request("border-top"); - m_confIdBorder[shaperPosButtom] = m_config->request("border-buttom"); - m_confIdPaddingIn[shaperPosLeft] = m_config->request("padding-in-left"); - m_confIdPaddingIn[shaperPosRight] = m_config->request("padding-in-right"); - m_confIdPaddingIn[shaperPosTop] = m_config->request("padding-in-top"); - m_confIdPaddingIn[shaperPosButtom] = m_config->request("padding-in-buttom"); - m_confIdChangeTime = m_config->request("change-time"); - m_confProgramFile = m_config->request("program"); - m_confImageFile = m_config->request("image"); - m_confColorFile = m_config->request("color"); + 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"); } - etk::String basicShaderFile = m_config->getString(m_confProgramFile); + String basicShaderFile = this.config.getString(this.confProgramFile); if (basicShaderFile != "") { - etk::String tmpFilename(basicShaderFile); - if (tmpFilename.find(':') == etk::String::npos) { + String tmpFilename(basicShaderFile); + if (tmpFilename.find(':') == String::npos) { // get the relative position of the current file ... - etk::Uri tmpUri = m_uri; - tmpUri.setPath(m_uri.getPath().getParent() / basicShaderFile); + 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 << "'"); + Log.debug("Shaper try load shader : '" + tmpFilename + "' with base : '" + basicShaderFile + "'"); } else { - Log.debug("Shaper try load shader : '" << tmpFilename << "'"); + Log.debug("Shaper try load shader : '" + tmpFilename + "'"); } // get the shader resource : - m_GLPosition = 0; - m_GLprogram = gale::resource::Program::create(tmpFilename); - if (m_GLprogram != null) { - m_GLPosition = m_GLprogram->getAttribute("EW_coord2d"); - m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); + 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 - m_GLPropertyPos = m_GLprogram->getAttribute("EW_widgetPropertyPos"); + this.GLPropertyPos = this.GLprogram.getAttribute("EW_widgetPropertyPos"); // status property == > for the fragment shader - m_GLStateActivate = m_GLprogram->getUniform("EW_status.activate"); - m_GLStateOld = m_GLprogram->getUniform("EW_status.stateOld"); - m_GLStateNew = m_GLprogram->getUniform("EW_status.stateNew"); - m_GLStateTransition = m_GLprogram->getUniform("EW_status.transition"); + 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 : - m_GLtexID = m_GLprogram->getUniform("EW_texID"); + this.GLtexID = this.GLprogram.getUniform("EW_texID"); } - etk::String basicImageFile = m_config->getString(m_confImageFile); + String basicImageFile = this.config.getString(this.confImageFile); if (basicImageFile != "") { - etk::String tmpFilename(basicImageFile); - if (tmpFilename.find(':') == etk::String::npos) { + String tmpFilename(basicImageFile); + if (tmpFilename.find(':') == String::npos) { // get the relative position of the current file ... - etk::Uri tmpUri = m_uri; - tmpUri.setPath(m_uri.getPath().getParent() / basicImageFile); + 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 << "'"); + Log.debug("Shaper try load shaper image : '" + tmpFilename + "' with base : '" + basicImageFile + "'"); } else { - Log.debug("Shaper try load shaper image : '" << tmpFilename << "'"); + Log.debug("Shaper try load shaper image : '" + tmpFilename + "'"); } Vector2i size(64,64); - m_resourceTexture = ewol::resource::TextureFile::create(tmpFilename, size); + this.resourceTexture = ewol::resource::TextureFile::create(tmpFilename, size); } } - etk::String basicColorFile = m_config->getString(m_confColorFile); + String basicColorFile = this.config.getString(this.confColorFile); if (basicColorFile != "") { - etk::String tmpFilename(basicColorFile); - if (tmpFilename.find(':') == etk::String::npos) { + String tmpFilename(basicColorFile); + if (tmpFilename.find(':') == String::npos) { // get the relative position of the current file ... - etk::Uri tmpUri = m_uri; - tmpUri.setPath(m_uri.getPath().getParent() / basicColorFile); + 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 << "'"); + Log.debug("Shaper try load colorFile : '" + tmpFilename + "' with base : '" + basicColorFile + "'"); } else { - Log.debug("Shaper try load colorFile : '" << tmpFilename << "'"); + Log.debug("Shaper try load colorFile : '" + tmpFilename + "'"); } - m_colorProperty = ewol::resource::ColorFile::create(tmpFilename); - if ( m_GLprogram != null - && m_colorProperty != null) { - List listColor = m_colorProperty->getColors(); + this.colorProperty = ewol::resource::ColorFile::create(tmpFilename); + if ( this.GLprogram != null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorProperty != null) { + List listColor = this.colorProperty.getColors(); for (auto tmpColor : listColor) { - int32_t glId = m_GLprogram->getUniform(tmpColor); - int32_t colorID = m_colorProperty->request(tmpColor); - m_listAssiciatedId.pushBack(Vector2i(glId, colorID)); + int glId = this.GLprogram.getUniform(tmpColor); + int colorID = this.colorProperty.request(tmpColor); + this.listAssiciatedId.pushBack(Vector2i(glId, colorID)); } } } } -void ewol::compositing::Shaper::draw(bool _disableDepthTest) { - if (m_config == null) { +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 (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } - if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { + if (this.VBO.bufferSize(this.vboIdCoord) <= 0) { return; } - //glScalef(m_scaling.x, m_scaling.y, 1.0); - m_GLprogram->use(); + //glScalef(this.scaling.x, this.scaling.y, 1.0); + this.GLprogram.use(); // set Matrix : translation/positionMatrix mat4 tmpMatrix = gale::openGL::getMatrix(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // position: - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); // property - m_GLprogram->sendAttributePointer(m_GLPropertyPos, m_VBO, m_vboIdPos); + this.GLprogram.sendAttributePointer(this.GLPropertyPos, this.VBO, this.vboIdPos); // all entry parameters : - m_GLprogram->uniform1i(m_GLStateActivate, m_stateActivate); - m_GLprogram->uniform1i(m_GLStateOld, m_stateOld); - m_GLprogram->uniform1i(m_GLStateNew, m_stateNew); - m_GLprogram->uniform1f(m_GLStateTransition, m_stateTransition); - for (auto element : m_listAssiciatedId) { - m_GLprogram->uniform(element.x(), m_colorProperty->get(element.y())); + 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 (m_resourceTexture != null) { + if (this.resourceTexture != null) { // TextureID - m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getRendererId()); + 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, m_nbVertexToDisplay); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangleStrip, 0, this.nbVertexToDisplay); + this.GLprogram.unUse(); } void ewol::compositing::Shaper::clear() { // nothing to do ... - m_propertySize = Vector2f(0,0); - m_propertyOrigin = Vector2f(0,0); - m_propertyInsidePosition = Vector2f(0,0); - m_propertyInsideSize = Vector2f(0,0); - m_VBO->clear(); + this.propertySize = Vector2f(0,0); + this.propertyOrigin = Vector2f(0,0); + this.propertyInsidePosition = Vector2f(0,0); + this.propertyInsideSize = Vector2f(0,0); + this.VBO.clear(); } -bool ewol::compositing::Shaper::setState(int32_t _newState) { - if (m_stateActivate == _newState) { +boolean ewol::compositing::Shaper::setState(int _newState) { + if (this.stateActivate == _newState) { return false; } - m_stateActivate = _newState; + this.stateActivate = _newState; return true; } -bool ewol::compositing::Shaper::changeStatusIn(int32_t _newStatusId) { - if (_newStatusId != m_stateNew) { - m_nextStatusRequested = _newStatusId; +boolean ewol::compositing::Shaper::changeStatusIn(int _newStatusId) { + if (_newStatusId != this.stateNew) { + this.nextStatusRequested = _newStatusId; return true; } - if( m_nextStatusRequested != -1 - || m_stateNew != m_stateOld) { + if( this.nextStatusRequested != -1 + || this.stateNew != this.stateOld) { return true; } return false; } -bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) { - Log.verbose("call=" << _event << "state transition=" << m_stateTransition << " speedTime=" << m_config->getNumber(m_confIdChangeTime)); +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 (m_stateTransition >= 1.0) { - m_stateOld = m_stateNew; - if( m_nextStatusRequested != -1 - && m_nextStatusRequested != m_stateOld) { - m_stateNew = m_nextStatusRequested; - m_nextStatusRequested = -1; - m_stateTransition = 0.0; + 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 { - m_nextStatusRequested = -1; + this.nextStatusRequested = -1; // disable periodic call ... return false; } } - if (m_stateTransition<1.0) { + if (this.stateTransition<1.0) { // check if no new state requested: - if (m_nextStatusRequested != -1 && m_stateTransition<0.5) { + if (this.nextStatusRequested != -1 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.stateTransition<0.5) { // invert sources with destination - int32_t tmppp = m_stateOld; - m_stateOld = m_stateNew; - m_stateNew = tmppp; - m_stateTransition = 1.0 - m_stateTransition; - if (m_nextStatusRequested == m_stateNew) { - m_nextStatusRequested = -1; + 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 (m_config != null) { - timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0; + if (this.config != null) { + timeRelativity = this.config.getNumber(this.confIdChangeTime) / 1000.0; } - m_stateTransition += _event.getDeltaCall() / timeRelativity; - //m_stateTransition += _event.getDeltaCall(); - m_stateTransition = etk::avg(0.0f, m_stateTransition, 1.0f); - Log.verbose("relative=" << timeRelativity << " Transition : " << m_stateTransition); + 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; } @@ -299,112 +299,112 @@ void ewol::compositing::Shaper::addVertexLine(float _yTop, float _x8, float _yValTop, float _yValButtom, - const float* _table, - bool _displayOutside) { - if (m_nbVertexToDisplay != 0) { + float* _table, + boolean _displayOutside) { + if (this.nbVertexToDisplay != 0) { // change line ... - m_VBO->pushOnBuffer(m_vboIdCoord, - m_VBO->getOnBufferVec2(m_vboIdCoord, m_nbVertexToDisplay-1)); - m_VBO->pushOnBuffer(m_vboIdPos, - m_VBO->getOnBufferVec2(m_vboIdPos, m_nbVertexToDisplay-1)); + 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)); - m_nbVertexToDisplay++; + this.nbVertexToDisplay++; if (_displayOutside == true) { - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x1, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[0],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValButtom)); + this.nbVertexToDisplay++; } else { - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom)); + this.nbVertexToDisplay++; } } if (_displayOutside == true) { // A - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x1, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[0],_yValButtom)); - m_nbVertexToDisplay++; - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x1, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[0],_yValTop)); - m_nbVertexToDisplay++; - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValButtom)); - m_nbVertexToDisplay++; + 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 - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValTop)); + this.nbVertexToDisplay++; // C - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x3, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[2],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValButtom)); + this.nbVertexToDisplay++; } else { // C - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValButtom)); - m_nbVertexToDisplay++; - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValTop)); - m_nbVertexToDisplay++; - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x3, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[2],_yValButtom)); - m_nbVertexToDisplay++; + 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 - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x3, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[2],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValTop)); + this.nbVertexToDisplay++; // E - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x4, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[3],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x4, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[3],_yValButtom)); + this.nbVertexToDisplay++; // F - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x4, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[3],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x4, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[3],_yValTop)); + this.nbVertexToDisplay++; // G - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x5, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[4],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x5, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[4],_yValButtom)); + this.nbVertexToDisplay++; // H - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x5, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[4],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x5, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[4],_yValTop)); + this.nbVertexToDisplay++; // I - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x6, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[5],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x6, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[5],_yValButtom)); + this.nbVertexToDisplay++; // J - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x6, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[5],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x6, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[5],_yValTop)); + this.nbVertexToDisplay++; // K - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x7, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[6],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x7, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[6],_yValButtom)); + this.nbVertexToDisplay++; // L - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x7, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[6],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x7, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[6],_yValTop)); + this.nbVertexToDisplay++; if (_displayOutside == true) { // M - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x8, _yButtom)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[7],_yValButtom)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x8, _yButtom)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[7],_yValButtom)); + this.nbVertexToDisplay++; // N - m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x8, _yTop)); - m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[7],_yValTop)); - m_nbVertexToDisplay++; + this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x8, _yTop)); + this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[7],_yValTop)); + this.nbVertexToDisplay++; } } -const float modeDisplay[][8] = { + float modeDisplay[][8] = { /* !! 0 !! * / ******* * / ****** / @@ -451,8 +451,8 @@ const float modeDisplay[][8] = { { 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f } }; -void ewol::compositing::Shaper::setShape(const Vector2f& _origin, const Vector2f& _size, const Vector2f& _insidePos, const Vector2f& _insideSize) { - m_VBO->clear(); +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(); @@ -490,17 +490,17 @@ void ewol::compositing::Shaper::setShape(const Vector2f& _origin, const Vector2f #endif /* - Log.error(" enveloppe = " << enveloppe); - Log.error(" border = " << border); - Log.error(" inside = " << inside); + Log.error(" enveloppe = " + enveloppe); + Log.error(" border = " + border); + Log.error(" inside = " + inside); */ - int32_t mode = 0; - bool displayOutside = false; - if (m_config != null) { - mode = m_config->getNumber(m_confIdMode); - displayOutside = m_config->getBoolean(m_confIdDisplayOutside); + int mode = 0; + boolean displayOutside = false; + if (this.config != null) { + mode = this.config.getNumber(this.confIdMode); + displayOutside = this.config.getBoolean(this.confIdDisplayOutside); } - m_nbVertexToDisplay = 0; + this.nbVertexToDisplay = 0; if (displayOutside == true) { addVertexLine(enveloppe.yTop(), border.yTop(), enveloppe.xLeft(), @@ -589,7 +589,7 @@ void ewol::compositing::Shaper::setShape(const Vector2f& _origin, const Vector2f modeDisplay[mode], displayOutside); } - m_VBO->flush(); + this.VBO.flush(); } ewol::Padding ewol::compositing::Shaper::getPadding() { @@ -598,96 +598,96 @@ ewol::Padding ewol::compositing::Shaper::getPadding() { ewol::Padding ewol::compositing::Shaper::getPaddingIn() { ewol::Padding padding(0,0,0,0); - if (m_config != null) { - padding.setValue(m_config->getNumber(m_confIdPaddingIn[shaperPosLeft]), - m_config->getNumber(m_confIdPaddingIn[shaperPosTop]), - m_config->getNumber(m_confIdPaddingIn[shaperPosRight]), - m_config->getNumber(m_confIdPaddingIn[shaperPosButtom])); + 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 (m_config != null) { - padding.setValue(m_config->getNumber(m_confIdPaddingOut[shaperPosLeft]), - m_config->getNumber(m_confIdPaddingOut[shaperPosTop]), - m_config->getNumber(m_confIdPaddingOut[shaperPosRight]), - m_config->getNumber(m_confIdPaddingOut[shaperPosButtom])); + 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 (m_config != null) { - padding.setValue(m_config->getNumber(m_confIdBorder[shaperPosLeft]), - m_config->getNumber(m_confIdBorder[shaperPosTop]), - m_config->getNumber(m_confIdBorder[shaperPosRight]), - m_config->getNumber(m_confIdBorder[shaperPosButtom])); + 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(const etk::Uri& _uri) { +void ewol::compositing::Shaper::setSource( etk::Uri _uri) { clear(); unLoadProgram(); - m_uri = _uri; + this.uri = _uri; loadProgram(); } -bool ewol::compositing::Shaper::hasSources() { - return m_GLprogram != null; +boolean ewol::compositing::Shaper::hasSources() { + return this.GLprogram != null; } -const etk::Color& ewol::compositing::Shaper::getColor(int32_t _id) { - static const etk::Color errorValue(0,0,0,0); - if (m_colorProperty == null) { - EWOL_WARNING("null of m_colorProperty ==> return #0000 for id " << _id); + etk::Color ewol::compositing::Shaper::getColor(int _id) { + static etk::Color errorValue(0,0,0,0); + if (this.colorProperty == null) { + Log.warning("null of this.colorProperty ==> return #0000 for id " + _id); return errorValue; } - return m_colorProperty->get(_id); + return this.colorProperty.get(_id); } -int32_t ewol::compositing::Shaper::requestColor(const etk::String& _name) { - if (m_colorProperty == null) { - EWOL_WARNING("null of m_colorProperty ==> return -1 for name " << _name); +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 m_colorProperty->request(_name); + return this.colorProperty.request(_name); } -int32_t ewol::compositing::Shaper::requestConfig(const etk::String& _name) { - if (m_config == null) { - EWOL_WARNING("null of m_config ==> return -1 for name " << _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 m_config->request(_name); + return this.config.request(_name); } -double ewol::compositing::Shaper::getConfigNumber(int32_t _id) { +double ewol::compositing::Shaper::getConfigNumber(int _id) { if ( _id == -1 - || m_config == null) { - EWOL_WARNING("null of m_config ==> return 0.0 for id " << _id); + || this.config == null) { + Log.warning("null of this.config ==> return 0.0 for id " + _id); return 0.0; } - return m_config->getNumber(_id); + return this.config.getNumber(_id); } namespace etk { - template<> etk::String toString(const ewol::compositing::Shaper& _obj) { + template<> String toString( ewol::compositing::Shaper _obj) { return _obj.getSource().get(); } - template<> etk::UString toUString(const ewol::compositing::Shaper& _obj) { + template<> etk::UString toUString( ewol::compositing::Shaper _obj) { return etk::toUString(etk::toString(_obj)); } - template<> bool from_string(ewol::compositing::Shaper& _variableRet, const etk::String& _value) { + template<> boolean frothis.string(ewol::compositing::Shaper _variableRet, String _value) { _variableRet.setSource(_value); return true; } - template<> bool from_string(ewol::compositing::Shaper& _variableRet, const etk::UString& _value) { - return from_string(_variableRet, etk::toString(_value)); + template<> boolean frothis.string(ewol::compositing::Shaper _variableRet, etk::UString _value) { + return frothis.string(_variableRet, etk::toString(_value)); } }; \ No newline at end of file diff --git a/src/org/atriasoft/ewol/compositing/Shaper.java b/src/org/atriasoft/ewol/compositing/Shaper.java index 68d49e4..33690c0 100644 --- a/src/org/atriasoft/ewol/compositing/Shaper.java +++ b/src/org/atriasoft/ewol/compositing/Shaper.java @@ -38,48 +38,48 @@ namespace ewol { // TODO : Abstaraction between states (call by name and the system greate IDs class Shaper : public ewol::Compositing { private: - etk::Uri m_uri; //!< Name of the configuration of the shaper. + etk::Uri this.uri; //!< Name of the configuration of the shaper. // External theme config: - ememory::SharedPtr m_config; //!< pointer on the config file resources - int32_t m_confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom - int32_t m_confIdBorder[shaperPosCount]; //!< border property : X-left X-right Y-top Y-buttom - int32_t m_confIdPaddingIn[shaperPosCount]; //!< Padding in property : X-left X-right Y-top Y-buttom - int32_t m_confIdMode; //!< Display mode - int32_t m_confIdDisplayOutside; //!< Display outside of the shape... - int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property - int32_t m_confProgramFile; //!< ConfigFile opengGl program Name - int32_t m_confColorFile; //!< ConfigFile opengGl color file Name - int32_t m_confImageFile; //!< ConfigFile opengGl program Name + ememory::Ptr 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::SharedPtr m_GLprogram; //!< pointer on the opengl display program - int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) - int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) - int32_t m_GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on Vector2f(X,Y)) - int32_t m_GLStateActivate; //!< openGL id on the element (activate state displayed) - int32_t m_GLStateOld; //!< openGL id on the element (old state displayed) - int32_t m_GLStateNew; //!< openGL id on the element (new state displayed) - int32_t m_GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] ) - int32_t m_GLtexID; //!< openGL id on the element (texture image) + ememory::Ptr 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::SharedPtr m_resourceTexture; //!< texture resources (for the image) + ememory::Ptr this.resourceTexture; //!< texture resources (for the image) // internal needed data : - int32_t m_nextStatusRequested; //!< when status is changing, this represent the next step of it - Vector2f m_propertyOrigin; //!< widget origin - Vector2f m_propertySize; //!< widget size - Vector2f m_propertyInsidePosition; //!< internal subwidget position - Vector2f m_propertyInsideSize; //!< internal subwidget size - int32_t m_stateActivate; //!< Activate state of the element - int32_t m_stateOld; //!< previous state - int32_t m_stateNew; //!< destination state - float m_stateTransition; //!< working state between 2 states - int32_t m_nbVertexToDisplay; + 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::SharedPtr m_colorProperty; //!< input resource for color management - List m_listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X) + ememory::Ptr this.colorProperty; //!< input resource for color management + List this.listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X) protected: - static const int32_t m_vboIdCoord; - static const int32_t m_vboIdPos; - ememory::SharedPtr m_VBO; + static int this.vboIdCoord; + static int this.vboIdPos; + ememory::Ptr this.VBO; private: /** * @brief load the openGL program and get all the ID needed @@ -91,19 +91,19 @@ namespace ewol { void unLoadProgram(); public: /** - * @brief generic constructor + * @brief generic ructor * @param[in] _uri URI of the file that might be loaded */ - Shaper(const etk::Uri& _uri=""); + Shaper( etk::Uri _uri=""); /** * @brief generic destructor */ - virtual ~Shaper(); + ~Shaper(); public: /** * @brief draw All the refistered text in the current element on openGL */ - void draw(bool _disableDepthTest=true); + void draw(boolean _disableDepthTest=true); /** * @brief clear alll tre registered element in the current element */ @@ -114,34 +114,34 @@ namespace ewol { * @return true Need redraw. * @return false No need redraw. */ - bool setState(int32_t _newState); + 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. */ - bool changeStatusIn(int32_t _newStatusId); + boolean changeStatusIn(int _newStatusId); /** * @brief get the current displayed status of the shaper * @return The Status Id */ - int32_t getCurrentDisplayedStatus() { - return m_stateNew; + 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) */ - int32_t getNextDisplayedStatus() { - return m_nextStatusRequested; + 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 m_stateTransition; + return this.stateTransition; }; /** * @brief Same as the widfget periodic call (this is for change display) @@ -149,7 +149,7 @@ namespace ewol { * @return true The widget must call this fuction periodicly (and redraw itself) * @return false No need to request the periodic call. */ - bool periodicCall(const ewol::event::Time& _event); + boolean periodicCall( ewol::event::Time _event); /** * @brief get the padding declared by the user in the config file * @return the padding property @@ -166,19 +166,19 @@ namespace ewol { * @brief change the shaper Source * @param[in] _uri New file of the shaper */ - void setSource(const etk::Uri& _uri); + void setSource( etk::Uri _uri); /** * @brief get the shaper file Source * @return the shapper file name */ - const etk::Uri& getSource() const { - return m_uri; + 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. */ - bool hasSources(); + boolean hasSources(); public: /** * @brief set the shape property: @@ -224,9 +224,9 @@ namespace ewol { * @param[in] _insidePos Positin of the internal data * @param[in] _insideSize Size of the internal data */ - void setShape(const Vector2f& _origin, const Vector2f& _size, const Vector2f& _insidePos, const Vector2f& _insideSize); + void setShape( Vector2f _origin, Vector2f _size, Vector2f _insidePos, Vector2f _insideSize); // @previous - void setShape(const Vector2f& _origin, const Vector2f& _size) { + 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())); } @@ -236,33 +236,33 @@ namespace ewol { * @param[in] _name Name of the element requested * @return The Id of the color */ - int32_t requestColor(const etk::String& _name); + 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 */ - const etk::Color& getColor(int32_t _id); + etk::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 */ - int32_t requestConfig(const etk::String& _name); + 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(int32_t _id); + double getConfigNumber(int _id); public: /** * @brief Set activate state of the element * @param[in] _status New activate status */ - void setActivateState(int32_t _status) { - m_stateActivate = _status; + void setActivateState(int _status) { + this.stateActivate = _status; } private: void addVertexLine(float _yTop, @@ -277,17 +277,17 @@ namespace ewol { float _x8, float _yValTop, float _yValButtom, - const float* _table, - bool _displayOutside); + float* _table, + boolean _displayOutside); public: /* **************************************************** * == operator *****************************************************/ - bool operator== (const Shaper& _obj) const { - return _obj.m_uri == m_uri; + boolean operator== ( Shaper _obj) { + return _obj.this.uri == this.uri; } - bool operator!= (const Shaper& _obj) const { - return _obj.m_uri != m_uri; + boolean operator!= ( Shaper _obj) { + return _obj.this.uri != this.uri; } }; } diff --git a/src/org/atriasoft/ewol/compositing/Sprite.cpp b/src/org/atriasoft/ewol/compositing/Sprite.cpp index 7a119f6..21114f9 100644 --- a/src/org/atriasoft/ewol/compositing/Sprite.cpp +++ b/src/org/atriasoft/ewol/compositing/Sprite.cpp @@ -10,30 +10,30 @@ #include ETK_DECLARE_TYPE(ewol::compositing::Sprite); -ewol::compositing::Sprite::Sprite(const etk::String& _imageName, const Vector2i& _nbSprite, int32_t _size) : +ewol::compositing::Sprite::Sprite( String _imageName, Vector2i _nbSprite, int _size) : ewol::compositing::Image(_imageName, false, _size), - m_nbSprite(_nbSprite), - m_unitarySpriteSize(0,0) { + this.nbSprite(_nbSprite), + this.unitarySpriteSize(0,0) { /* Vector2f imageSize = getRealSize(); - m_unitarySpriteSize.setValue(imageSize.x()/(float)m_nbSprite.x(), - imageSize.y()/(float)m_nbSprite.y()); + this.unitarySpriteSize.setValue(imageSize.x()/(float)this.nbSprite.x(), + imageSize.y()/(float)this.nbSprite.y()); */ - m_unitarySpriteSize.setValue(1.0/(float)m_nbSprite.x(), - 1.0/(float)m_nbSprite.y()); + this.unitarySpriteSize.setValue(1.0/(float)this.nbSprite.x(), + 1.0/(float)this.nbSprite.y()); } -void ewol::compositing::Sprite::printSprite(const Vector2i& _spriteID, const Vector3f& _size) { +void ewol::compositing::Sprite::printSprite( Vector2i _spriteID, Vector3f _size) { if( _spriteID.x()<0 || _spriteID.y()<0 - || _spriteID.x() >= m_nbSprite.x() - || _spriteID.y() >= m_nbSprite.y()) { + || _spriteID.x() >= this.nbSprite.x() + || _spriteID.y() >= this.nbSprite.y()) { return; } printPart(Vector2f(_size.x(),_size.y()), - Vector2f((float)(_spriteID.x() )*m_unitarySpriteSize.x(), (float)(_spriteID.y() )*m_unitarySpriteSize.y()), - Vector2f((float)(_spriteID.x()+1)*m_unitarySpriteSize.x(), (float)(_spriteID.y()+1)*m_unitarySpriteSize.y())); + Vector2f((float)(_spriteID.x() )*this.unitarySpriteSize.x(), (float)(_spriteID.y() )*this.unitarySpriteSize.y()), + Vector2f((float)(_spriteID.x()+1)*this.unitarySpriteSize.x(), (float)(_spriteID.y()+1)*this.unitarySpriteSize.y())); } diff --git a/src/org/atriasoft/ewol/compositing/Sprite.java b/src/org/atriasoft/ewol/compositing/Sprite.java index 9888435..b834eed 100644 --- a/src/org/atriasoft/ewol/compositing/Sprite.java +++ b/src/org/atriasoft/ewol/compositing/Sprite.java @@ -12,17 +12,17 @@ namespace ewol { namespace compositing { class Sprite : public ewol::compositing::Image { protected: - Vector2i m_nbSprite; //!< number of sprite in vertical and horizontal - Vector2f m_unitarySpriteSize; //!< size of a unique sprite + Vector2i this.nbSprite; //!< number of sprite in vertical and horizontal + Vector2f this.unitarySpriteSize; //!< size of a unique sprite public: - Sprite(const etk::String& _imageName, - const Vector2i& _nbSprite, - int32_t _size=ewol::compositing::Image::sizeAuto); - virtual ~Sprite() {}; - void printSprite(const Vector2i& _spriteID, const Vector2f& _size) { + Sprite( String _imageName, + Vector2i _nbSprite, + int _size=ewol::compositing::Image::sizeAuto); + ~Sprite() {}; + void printSprite( Vector2i _spriteID, Vector2f _size) { printSprite(_spriteID, Vector3f(_size.x(), _size.y(),0)); }; - void printSprite(const Vector2i& _spriteID, const Vector3f& _size); + void printSprite( Vector2i _spriteID, Vector3f _size); }; } } diff --git a/src/org/atriasoft/ewol/compositing/Text.cpp b/src/org/atriasoft/ewol/compositing/Text.cpp index 82a21ad..01ae569 100644 --- a/src/org/atriasoft/ewol/compositing/Text.cpp +++ b/src/org/atriasoft/ewol/compositing/Text.cpp @@ -12,8 +12,8 @@ #include ETK_DECLARE_TYPE(ewol::compositing::Text); -ewol::compositing::Text::Text(const etk::String& _fontName, int32_t _fontSize) : - m_font(null) { +ewol::compositing::Text::Text( String _fontName, int _fontSize) : + this.font(null) { setFont(_fontName, _fontSize); } @@ -21,22 +21,22 @@ ewol::compositing::Text::~Text() { } -void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) { +void ewol::compositing::Text::drawMT( mat4 _transformationMatrix, boolean _enableDepthTest) { // draw BG in any case: - m_vectorialDraw.draw(); + this.vectorialDraw.draw(); - if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 - || m_font == null) { + if ( this.VBO.bufferSize(this.vboIdCoord) <= 0 + || this.font == null) { // TODO : set it back ... - //EWOL_WARNING("Nothink to draw..."); + //Log.warning("Nothink to draw..."); return; } - if (m_font == null) { - EWOL_WARNING("no font..."); + if (this.font == null) { + Log.warning("no font..."); return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } @@ -47,109 +47,109 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // Texture: - m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); - m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); - m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); + this.GLprogram.setTexture0(this.GLtexID, this.font.getRendererId()); + this.GLprogram.uniform1i(this.GLtextWidth, this.font.getOpenGlSize().x()); + this.GLprogram.uniform1i(this.GLtextHeight, this.font.getOpenGlSize().x()); // position: - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); // Texture: - m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); + this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText); // color: - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor); // Request the draw od the elements: - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord)); + this.GLprogram.unUse(); if (_enableDepthTest == true) { gale::openGL::disable(gale::openGL::flag_depthTest); } } -void ewol::compositing::Text::drawD(bool _disableDepthTest) { +void ewol::compositing::Text::drawD(boolean _disableDepthTest) { // draw BG in any case: - m_vectorialDraw.draw(_disableDepthTest); + this.vectorialDraw.draw(_disableDepthTest); - if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 - || m_font == null) { - //EWOL_WARNING("Nothink to draw..."); + if ( this.VBO.bufferSize(this.vboIdCoord) <= 0 + || this.font == null) { + //Log.warning("Nothink to draw..."); return; } - if (m_font == null) { - EWOL_WARNING("no font..."); + if (this.font == null) { + Log.warning("no font..."); return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply; + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // Texture : - m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); - m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); - m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); + this.GLprogram.setTexture0(this.GLtexID, this.font.getRendererId()); + this.GLprogram.uniform1i(this.GLtextWidth, this.font.getOpenGlSize().x()); + this.GLprogram.uniform1i(this.GLtextHeight, this.font.getOpenGlSize().x()); // position: - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); // Texture: - m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); + this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText); // color: - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor); // Request the draw od the elements : - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord)); + this.GLprogram.unUse(); } float ewol::compositing::Text::getSize() { - if (m_font == null) { - EWOL_WARNING("no font..."); + if (this.font == null) { + Log.warning("no font..."); return 1.0f; } - return m_font->getFontSize(); + return this.font.getFontSize(); } float ewol::compositing::Text::getHeight() { - if (m_font == null) { - EWOL_WARNING("no font..."); + if (this.font == null) { + Log.warning("no font..."); return 10.0f; } - return m_font->getHeight(m_mode); + return this.font.getHeight(this.mode); } -ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(char32_t _charcode) { - if (m_font == null) { - EWOL_WARNING("no font..."); +ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(Character _charcode) { + if (this.font == null) { + Log.warning("no font..."); return null; } - return m_font->getGlyphPointer(_charcode, m_mode); + return this.font.getGlyphPointer(_charcode, this.mode); } -void ewol::compositing::Text::setFontSize(int32_t _fontSize) { +void ewol::compositing::Text::setFontSize(int _fontSize) { // get old size - etk::String fontName = ""; - if (m_font != null) { - fontName = m_font->getName(); + String fontName = ""; + if (this.font != null) { + fontName = this.font.getName(); // Remove the :XX for the size ... - size_t pos = fontName.rfind(':'); + int pos = fontName.rfind(':'); fontName.erase(pos, fontName.size()-pos); } setFont(fontName, _fontSize); } -void ewol::compositing::Text::setFontName(const etk::String& _fontName) { +void ewol::compositing::Text::setFontName( String _fontName) { // get old size - int32_t fontSize = -1; - if (m_font != null) { - fontSize = m_font->getFontSize(); + int fontSize = -1; + if (this.font != null) { + fontSize = this.font.getFontSize(); } setFont(_fontName, fontSize); } -void ewol::compositing::Text::setFont(etk::String _fontName, int32_t _fontSize) { +void ewol::compositing::Text::setFont(String _fontName, int _fontSize) { clear(); // remove old one - ememory::SharedPtr previousFont = m_font; + ememory::Ptr previousFont = this.font; if (_fontSize <= 0) { _fontSize = ewol::getContext().getFontDefault().getSize(); } @@ -158,37 +158,37 @@ void ewol::compositing::Text::setFont(etk::String _fontName, int32_t _fontSize) } _fontName += ":"; _fontName += etk::toString(_fontSize); - Log.verbose("plop : " << _fontName << " size=" << _fontSize << " result :" << _fontName); + Log.verbose("plop : " + _fontName + " size=" + _fontSize + " result :" + _fontName); // link to new one - m_font = ewol::resource::TexturedFont::create(_fontName); - if (m_font == null) { + this.font = ewol::resource::TexturedFont::create(_fontName); + if (this.font == null) { Log.error("Can not get font resource"); - m_font = previousFont; + this.font = previousFont; } } void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) { - if (m_font != null) { - m_mode = m_font->getWrappingMode(_mode); + if (this.font != null) { + this.mode = this.font.getWrappingMode(_mode); } } -void ewol::compositing::Text::printChar(const char32_t& _charcode) { +void ewol::compositing::Text::printChar( Character _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode); if (null == myGlyph) { Log.error(" font does not really existed ..."); return; } - int32_t fontSize = getSize(); - int32_t fontHeigh = getHeight(); + int fontSize = getSize(); + int fontHeigh = getHeight(); // get the kerning ofset : float kerningOffset = 0; - if (m_kerning == true) { - kerningOffset = myGlyph->kerningGet(m_previousCharcode); + if (this.kerning == true) { + kerningOffset = myGlyph.kerningGet(this.previousCharcode); if (kerningOffset != 0) { - //Log.debug("Kerning between : '" << m_previousCharcode << "'&'" << myGlyph->m_UVal << "' value : " << kerningOffset); + //Log.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.this.UVal + "' value : " + kerningOffset); } } // 0x01 == 0x20 == ' '; @@ -200,62 +200,62 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) { * | | * yD *------* */ - float dxA = m_position.x() + myGlyph->m_bearing.x() + kerningOffset; - float dxB = dxA + myGlyph->m_sizeTexture.x(); - float dyC = m_position.y() + myGlyph->m_bearing.y() + fontHeigh - fontSize; - float dyD = dyC - myGlyph->m_sizeTexture.y(); + float dxA = this.position.x() + myGlyph.this.bearing.x() + kerningOffset; + float dxB = dxA + myGlyph.this.sizeTexture.x(); + float dyC = this.position.y() + myGlyph.this.bearing.y() + fontHeigh - fontSize; + float dyD = dyC - myGlyph.this.sizeTexture.y(); - float tuA = myGlyph->m_texturePosStart.x(); - float tuB = tuA + myGlyph->m_texturePosSize.x(); - float tvC = myGlyph->m_texturePosStart.y(); - float tvD = tvC + myGlyph->m_texturePosSize.y(); + float tuA = myGlyph.this.texturePosStart.x(); + float tuB = tuA + myGlyph.this.texturePosSize.x(); + float tvC = myGlyph.this.texturePosStart.y(); + float tvD = tvC + myGlyph.this.texturePosSize.y(); // Clipping and drawing area - if( m_clippingEnable == true - && ( dxB < m_clippingPosStart.x() - || dxA > m_clippingPosStop.x() - || dyC < m_clippingPosStart.y() - || dyD > m_clippingPosStop.y() ) ) { + if( this.clippingEnable == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( dxB < this.clippingPosStart.x() + || dxA > this.clippingPosStop.x() + || dyC < this.clippingPosStart.y() + || dyD > this.clippingPosStop.y() ) ) { // Nothing to diplay ... } else { - if (m_clippingEnable == true) { + if (this.clippingEnable == true) { // generata positions... float TexSizeX = tuB - tuA; - if (dxA < m_clippingPosStart.x()) { + if (dxA < this.clippingPosStart.x()) { // clip display - float drawSize = m_clippingPosStart.x() - dxA; + float drawSize = this.clippingPosStart.x() - dxA; // update element start display - dxA = m_clippingPosStart.x(); - float addElement = TexSizeX * drawSize / (float)myGlyph->m_sizeTexture.x(); + dxA = this.clippingPosStart.x(); + float addElement = TexSizeX * drawSize / (float)myGlyph.this.sizeTexture.x(); // update texture start X Pos tuA += addElement; } - if (dxB > m_clippingPosStop.x()) { + if (dxB > this.clippingPosStop.x()) { // clip display - float drawSize = dxB - m_clippingPosStop.x(); + float drawSize = dxB - this.clippingPosStop.x(); // update element start display - dxB = m_clippingPosStop.x(); - float addElement = TexSizeX * drawSize / (float)myGlyph->m_sizeTexture.x(); + dxB = this.clippingPosStop.x(); + float addElement = TexSizeX * drawSize / (float)myGlyph.this.sizeTexture.x(); // update texture start X Pos tuB -= addElement; } float TexSizeY = tvC - tvD; - if (dyC > m_clippingPosStop.y()) { + if (dyC > this.clippingPosStop.y()) { // clip display - float drawSize = dyC - m_clippingPosStop.y(); + float drawSize = dyC - this.clippingPosStop.y(); // update element start display - dyC = m_clippingPosStop.y(); - float addElement = TexSizeY * drawSize / (float)myGlyph->m_sizeTexture.y(); + dyC = this.clippingPosStop.y(); + float addElement = TexSizeY * drawSize / (float)myGlyph.this.sizeTexture.y(); // update texture start X Pos tvC -= addElement; } - if (dyD < m_clippingPosStart.y()) { + if (dyD < this.clippingPosStart.y()) { // clip display - float drawSize = m_clippingPosStart.y() - dyD; + float drawSize = this.clippingPosStart.y() - dyD; // update element start display - dyD = m_clippingPosStart.y(); - float addElement = TexSizeY * drawSize / (float)myGlyph->m_sizeTexture.y(); + dyD = this.clippingPosStart.y(); + float addElement = TexSizeY * drawSize / (float)myGlyph.this.sizeTexture.y(); // update texture start X Pos tvD += addElement; } @@ -270,12 +270,12 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) { * | | * 3------2 */ - if (m_needDisplay == true) { + if (this.needDisplay == true) { Vector3f bitmapDrawPos[4]; - bitmapDrawPos[0].setValue((int32_t)dxA, (int32_t)dyC, 0); - bitmapDrawPos[1].setValue((int32_t)dxB, (int32_t)dyC, 0); - bitmapDrawPos[2].setValue((int32_t)dxB, (int32_t)dyD, 0); - bitmapDrawPos[3].setValue((int32_t)dxA, (int32_t)dyD, 0); + bitmapDrawPos[0].setValue((int)dxA, (int)dyC, 0); + bitmapDrawPos[1].setValue((int)dxB, (int)dyC, 0); + bitmapDrawPos[2].setValue((int)dxB, (int)dyD, 0); + bitmapDrawPos[3].setValue((int)dxA, (int)dyD, 0); /* texture Position : * 0------1 * | | @@ -283,10 +283,10 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) { * 3------2 */ Vector2f texturePos[4]; - texturePos[0].setValue(tuA+m_mode, tvC); - texturePos[1].setValue(tuB+m_mode, tvC); - texturePos[2].setValue(tuB+m_mode, tvD); - texturePos[3].setValue(tuA+m_mode, tvD); + texturePos[0].setValue(tuA+this.mode, tvC); + texturePos[1].setValue(tuB+this.mode, tvC); + texturePos[2].setValue(tuB+this.mode, tvD); + texturePos[3].setValue(tuA+this.mode, tvD); // NOTE : Android does not support the Quads elements ... /* Step 1 : @@ -297,17 +297,17 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) { * */ // set texture coordonates : - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[1]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[1]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]); // set display positions : - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[1]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[1]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]); // set the color - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); /* Step 2 : * * ** @@ -316,41 +316,41 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) { * ******** */ // set texture coordonates : - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[3]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[3]); // set display positions : - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[3]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[3]); // set the color - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); } } } } // move the position : - //Log.debug(" 5 pos=" << m_position << " advance=" << myGlyph->m_advance.x() << " kerningOffset=" << kerningOffset); - m_position.setX(m_position.x() + myGlyph->m_advance.x() + kerningOffset); - //Log.debug(" 6 print '" << charcode << "' : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 5 pos=" + this.position + " advance=" + myGlyph.this.advance.x() + " kerningOffset=" + kerningOffset); + this.position.setX(this.position.x() + myGlyph.this.advance.x() + kerningOffset); + //Log.debug(" 6 print '" + charcode + "' : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // Register the previous character - m_previousCharcode = _charcode; - m_VBO->flush(); + this.previousCharcode = _charcode; + this.VBO.flush(); return; } -Vector3f ewol::compositing::Text::calculateSizeChar(const char32_t& _charcode) { +Vector3f ewol::compositing::Text::calculateSizeChar( Character _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode); - int32_t fontHeigh = getHeight(); + int fontHeigh = getHeight(); if (myGlyph == null) { - if (m_font == null) { - EWOL_WARNING("no Glyph... in no font"); + if (this.font == null) { + Log.warning("no Glyph... in no font"); } else { - EWOL_WARNING("no Glyph... in font : " << m_font->getName()); + Log.warning("no Glyph... in font : " + this.font.getName()); } return Vector3f((float)(0.2), (float)(fontHeigh), @@ -358,15 +358,15 @@ Vector3f ewol::compositing::Text::calculateSizeChar(const char32_t& _charcode) { } // get the kerning ofset : float kerningOffset = 0.0; - if (m_kerning == true) { - kerningOffset = myGlyph->kerningGet(m_previousCharcode); + if (this.kerning == true) { + kerningOffset = myGlyph.kerningGet(this.previousCharcode); } - Vector3f outputSize((float)(myGlyph->m_advance.x() + kerningOffset), + Vector3f outputSize((float)(myGlyph.this.advance.x() + kerningOffset), (float)(fontHeigh), (float)(0.0)); // Register the previous character - m_previousCharcode = _charcode; + this.previousCharcode = _charcode; return outputSize; } diff --git a/src/org/atriasoft/ewol/compositing/Text.java b/src/org/atriasoft/ewol/compositing/Text.java index 5916387..80f89e3 100644 --- a/src/org/atriasoft/ewol/compositing/Text.java +++ b/src/org/atriasoft/ewol/compositing/Text.java @@ -21,35 +21,35 @@ namespace ewol { namespace compositing { class Text : public ewol::compositing::TextBase { protected: - ememory::SharedPtr m_font; //!< Font resources + ememory::Ptr this.font; //!< Font resources public: /** - * @brief generic constructor + * @brief generic ructor * @param[in] _fontName Name of the font that might be loaded * @param[in] _fontSize size of the font that might be loaded */ - Text(const etk::String& _fontName="", int32_t _fontSize=-1); + Text( String _fontName="", int _fontSize=-1); /** * @brief generic destructor */ - virtual ~Text(); + ~Text(); public: - virtual void drawD(bool _disableDepthTest); - virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest); + void drawD(boolean _disableDepthTest); + void drawMT( mat4 _transformationMatrix, boolean _enableDepthTest); protected: - float m_size; + float this.size; public: - virtual float getHeight(); - virtual float getSize(); - virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode); + float getHeight(); + float getSize(); + ewol::GlyphProperty * getGlyphPointer(Character _charcode); public: - virtual void setFontSize(int32_t _fontSize); - virtual void setFontName(const etk::String& _fontName); - virtual void setFont(etk::String _fontName, int32_t _fontSize); - virtual void setFontMode(enum ewol::font::mode _mode); - virtual void printChar(const char32_t& _charcode); - virtual Vector3f calculateSizeChar(const char32_t& _charcode); + void setFontSize(int _fontSize); + void setFontName( String _fontName); + void setFont(String _fontName, int _fontSize); + void setFontMode(enum ewol::font::mode _mode); + void printChar( Character _charcode); + Vector3f calculateSizeChar( Character _charcode); }; } } diff --git a/src/org/atriasoft/ewol/compositing/TextBase.cpp b/src/org/atriasoft/ewol/compositing/TextBase.cpp index 56c8dba..b0ef78e 100644 --- a/src/org/atriasoft/ewol/compositing/TextBase.cpp +++ b/src/org/atriasoft/ewol/compositing/TextBase.cpp @@ -12,48 +12,48 @@ #include ETK_DECLARE_TYPE(ewol::compositing::TextBase); -const int32_t ewol::compositing::TextBase::m_vboIdCoord(0); -const int32_t ewol::compositing::TextBase::m_vboIdCoordText(1); -const int32_t ewol::compositing::TextBase::m_vboIdColor(2); -const int32_t ewol::compositing::TextBase::m_vboIdGlyphLevel(3); + int ewol::compositing::TextBase::this.vboIdCoord(0); + int ewol::compositing::TextBase::this.vboIdCoordText(1); + int ewol::compositing::TextBase::this.vboIdColor(2); + int ewol::compositing::TextBase::this.vboIdGlyphLevel(3); #define NB_VBO (4) -ewol::compositing::TextBase::TextBase(const etk::String& _shaderName, bool _loadProgram) : - m_position(0.0, 0.0, 0.0), - m_clippingPosStart(0.0, 0.0, 0.0), - m_clippingPosStop(0.0, 0.0, 0.0), - m_clippingEnable(false), - m_defaultColorFg(etk::color::black), - m_defaultColorBg(etk::color::none), - m_color(etk::color::black), - m_colorBg(etk::color::none), - m_colorCursor(etk::color::black), - m_colorSelection(etk::color::olive), - m_mode(ewol::font::Regular), - m_kerning(true), - m_previousCharcode(0), - m_startTextpos(0), - m_stopTextPos(0), - m_alignement(alignDisable), - m_GLprogram(null), - m_GLPosition(-1), - m_GLMatrix(-1), - m_GLColor(-1), - m_GLtexture(-1), - m_GLtexID(-1), - m_selectionStartPos(-100), - m_cursorPos(-100) { +ewol::compositing::TextBase::TextBase( String _shaderName, boolean _loadProgram) : + 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.defaultColorFg(etk::color::black), + this.defaultColorBg(etk::color::none), + this.color(etk::color::black), + this.colorBg(etk::color::none), + this.colorCursor(etk::color::black), + this.colorSelection(etk::color::olive), + this.mode(ewol::font::Regular), + this.kerning(true), + this.previousCharcode(0), + this.startTextpos(0), + this.stopTextPos(0), + this.alignement(alignDisable), + this.GLprogram(null), + this.GLPosition(-1), + this.GLMatrix(-1), + this.GLColor(-1), + this.GLtexture(-1), + this.GLtexID(-1), + this.selectionStartPos(-100), + this.cursorPos(-100) { if (_loadProgram == true) { loadProgram(_shaderName); } // Create the VBO: - m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); - if (m_VBO == null) { + 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: - m_VBO->setName("[VBO] of ewol::compositing::TextBase"); + this.VBO.setName("[VBO] of ewol::compositing::TextBase"); } @@ -61,200 +61,200 @@ ewol::compositing::TextBase::~TextBase() { } -void ewol::compositing::TextBase::loadProgram(const etk::String& _shaderName) { +void ewol::compositing::TextBase::loadProgram( String _shaderName) { // get the shader resource: - m_GLPosition = 0; - ememory::SharedPtr old = m_GLprogram; - m_GLprogram = gale::resource::Program::create(_shaderName); - if (m_GLprogram != null) { - m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); - m_GLColor = m_GLprogram->getAttribute("EW_color"); - m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); - m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); - m_GLtexID = m_GLprogram->getUniform("EW_texID"); - m_GLtextWidth = m_GLprogram->getUniform("EW_texWidth"); - m_GLtextHeight = m_GLprogram->getUniform("EW_texHeight"); + this.GLPosition = 0; + ememory::Ptr old = this.GLprogram; + this.GLprogram = gale::resource::Program::create(_shaderName); + if (this.GLprogram != null) { + this.GLPosition = this.GLprogram.getAttribute("EW_coord3d"); + this.GLColor = this.GLprogram.getAttribute("EW_color"); + this.GLtexture = this.GLprogram.getAttribute("EW_texture2d"); + this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation"); + this.GLtexID = this.GLprogram.getUniform("EW_texID"); + this.GLtextWidth = this.GLprogram.getUniform("EW_texWidth"); + this.GLtextHeight = this.GLprogram.getUniform("EW_texHeight"); } else { Log.error("Can not load the program => create previous one..."); - m_GLprogram = old; + this.GLprogram = old; old = null; } } -void ewol::compositing::TextBase::translate(const Vector3f& _vect) { +void ewol::compositing::TextBase::translate( Vector3f _vect) { ewol::Compositing::translate(_vect); - m_vectorialDraw.translate(_vect); + this.vectorialDraw.translate(_vect); } -void ewol::compositing::TextBase::rotate(const Vector3f& _vect, float _angle) { +void ewol::compositing::TextBase::rotate( Vector3f _vect, float _angle) { ewol::Compositing::rotate(_vect, _angle); - m_vectorialDraw.rotate(_vect, _angle); + this.vectorialDraw.rotate(_vect, _angle); } -void ewol::compositing::TextBase::scale(const Vector3f& _vect) { +void ewol::compositing::TextBase::scale( Vector3f _vect) { ewol::Compositing::scale(_vect); - m_vectorialDraw.scale(_vect); + this.vectorialDraw.scale(_vect); } void ewol::compositing::TextBase::clear() { // call upper class ewol::Compositing::clear(); // remove sub draw system - m_vectorialDraw.clear(); + this.vectorialDraw.clear(); // reset Buffer: - m_VBO->clear(); + this.VBO.clear(); // reset temporal variables: reset(); } void ewol::compositing::TextBase::reset() { - m_position = Vector3f(0,0,0); - m_clippingPosStart = Vector3f(0,0,0); - m_clippingPosStop = Vector3f(0,0,0); - m_sizeDisplayStart = m_position; - m_sizeDisplayStop = m_position; - m_nbCharDisplayed = 0; - m_clippingEnable = false; - m_color = m_defaultColorFg; - m_colorBg = m_defaultColorBg; - m_mode = ewol::font::Regular; - m_previousCharcode = 0; - m_startTextpos = 0; - m_stopTextPos = 0; - m_alignement = alignDisable; - m_htmlCurrrentLine = U""; - m_selectionStartPos = -100; - m_cursorPos = -100; - m_htmlDecoration.clear(); - m_needDisplay = true; - m_nbCharDisplayed = 0; + this.position = Vector3f(0,0,0); + this.clippingPosStart = Vector3f(0,0,0); + this.clippingPosStop = Vector3f(0,0,0); + this.sizeDisplayStart = this.position; + this.sizeDisplayStop = this.position; + this.nbCharDisplayed = 0; + this.clippingEnable = false; + this.color = this.defaultColorFg; + this.colorBg = this.defaultColorBg; + this.mode = ewol::font::Regular; + this.previousCharcode = 0; + this.startTextpos = 0; + this.stopTextPos = 0; + this.alignement = alignDisable; + this.htmlCurrrentLine = U""; + this.selectionStartPos = -100; + this.cursorPos = -100; + this.htmlDecoration.clear(); + this.needDisplay = true; + this.nbCharDisplayed = 0; } -void ewol::compositing::TextBase::setPos(const Vector3f& _pos) { +void ewol::compositing::TextBase::setPos( Vector3f _pos) { // check min max for display area - if (m_nbCharDisplayed != 0) { - Log.verbose("update size 1 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); - m_sizeDisplayStop.setX(etk::max(m_position.x(), m_sizeDisplayStop.x())); - m_sizeDisplayStop.setY(etk::max(m_position.y(), m_sizeDisplayStop.y())); - m_sizeDisplayStart.setX(etk::min(m_position.x(), m_sizeDisplayStart.x())); - m_sizeDisplayStart.setY(etk::min(m_position.y(), m_sizeDisplayStart.y())); - Log.verbose("update size 2 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); + if (this.nbCharDisplayed != 0) { + Log.verbose("update size 1 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); + this.sizeDisplayStop.setX(etk::max(this.position.x(), this.sizeDisplayStop.x())); + this.sizeDisplayStop.setY(etk::max(this.position.y(), this.sizeDisplayStop.y())); + this.sizeDisplayStart.setX(etk::min(this.position.x(), this.sizeDisplayStart.x())); + this.sizeDisplayStart.setY(etk::min(this.position.y(), this.sizeDisplayStart.y())); + Log.verbose("update size 2 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); } // update position - m_position = _pos; - m_previousCharcode = 0; - m_vectorialDraw.setPos(m_position); + this.position = _pos; + this.previousCharcode = 0; + this.vectorialDraw.setPos(this.position); // update min max of the display area: - if (m_nbCharDisplayed == 0) { - m_sizeDisplayStart = m_position; - m_sizeDisplayStop = m_position; - m_sizeDisplayStop.setY( m_sizeDisplayStop.y()+ getHeight()); - Log.verbose("update size 0 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); + if (this.nbCharDisplayed == 0) { + this.sizeDisplayStart = this.position; + this.sizeDisplayStop = this.position; + this.sizeDisplayStop.setY( this.sizeDisplayStop.y()+ getHeight()); + Log.verbose("update size 0 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); } else { - Log.verbose("update size 3 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); - m_sizeDisplayStop.setX(etk::max(m_position.x(), m_sizeDisplayStop.x())); - m_sizeDisplayStop.setY(etk::max(m_position.y(), m_sizeDisplayStop.y())); - m_sizeDisplayStart.setX(etk::min(m_position.x(), m_sizeDisplayStart.x())); - m_sizeDisplayStart.setY(etk::min(m_position.y(), m_sizeDisplayStart.y())); - Log.verbose("update size 4 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); + Log.verbose("update size 3 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); + this.sizeDisplayStop.setX(etk::max(this.position.x(), this.sizeDisplayStop.x())); + this.sizeDisplayStop.setY(etk::max(this.position.y(), this.sizeDisplayStop.y())); + this.sizeDisplayStart.setX(etk::min(this.position.x(), this.sizeDisplayStart.x())); + this.sizeDisplayStart.setY(etk::min(this.position.y(), this.sizeDisplayStart.y())); + Log.verbose("update size 4 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); } } -void ewol::compositing::TextBase::setRelPos(const Vector3f& _pos) { - m_position += _pos; - m_previousCharcode = 0; - m_vectorialDraw.setPos(m_position); +void ewol::compositing::TextBase::setRelPos( Vector3f _pos) { + this.position += _pos; + this.previousCharcode = 0; + this.vectorialDraw.setPos(this.position); } -void ewol::compositing::TextBase::setColorBg(const etk::Color<>& _color) { - m_colorBg = _color; - m_vectorialDraw.setColor(_color); +void ewol::compositing::TextBase::setColorBg( etk::Color<> _color) { + this.colorBg = _color; + this.vectorialDraw.setColor(_color); } -void ewol::compositing::TextBase::setClipping(const Vector3f& _pos, const Vector3f& _posEnd) { +void ewol::compositing::TextBase::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()) { - m_clippingPosStart.setX(_pos.x()); - m_clippingPosStop.setX(_posEnd.x()); + this.clippingPosStart.setX(_pos.x()); + this.clippingPosStop.setX(_posEnd.x()); } else { - m_clippingPosStart.setX(_posEnd.x()); - m_clippingPosStop.setX(_pos.x()); + this.clippingPosStart.setX(_posEnd.x()); + this.clippingPosStop.setX(_pos.x()); } if (_pos.y() <= _posEnd.y()) { - m_clippingPosStart.setY(_pos.y()); - m_clippingPosStop.setY(_posEnd.y()); + this.clippingPosStart.setY(_pos.y()); + this.clippingPosStop.setY(_posEnd.y()); } else { - m_clippingPosStart.setY(_posEnd.y()); - m_clippingPosStop.setY(_pos.y()); + this.clippingPosStart.setY(_posEnd.y()); + this.clippingPosStop.setY(_pos.y()); } if (_pos.z() <= _posEnd.z()) { - m_clippingPosStart.setZ(_pos.z()); - m_clippingPosStop.setZ(_posEnd.z()); + this.clippingPosStart.setZ(_pos.z()); + this.clippingPosStop.setZ(_posEnd.z()); } else { - m_clippingPosStart.setZ(_posEnd.z()); - m_clippingPosStop.setZ(_pos.z()); + this.clippingPosStart.setZ(_posEnd.z()); + this.clippingPosStop.setZ(_pos.z()); } - m_clippingEnable = true; - //m_vectorialDraw.setClipping(m_clippingPosStart, m_clippingPosStop); + this.clippingEnable = true; + //this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop); } -void ewol::compositing::TextBase::setClippingMode(bool _newMode) { - m_clippingEnable = _newMode; - //m_vectorialDraw.setClippingMode(m_clippingEnable); +void ewol::compositing::TextBase::setClippingMode(boolean _newMode) { + this.clippingEnable = _newMode; + //this.vectorialDraw.setClippingMode(this.clippingEnable); } -void ewol::compositing::TextBase::setFontBold(bool _status) { +void ewol::compositing::TextBase::setFontBold(boolean _status) { if (_status == true) { // enable - if (m_mode == ewol::font::Regular) { + if (this.mode == ewol::font::Regular) { setFontMode(ewol::font::Bold); - } else if (m_mode == ewol::font::Italic) { + } else if (this.mode == ewol::font::Italic) { setFontMode(ewol::font::BoldItalic); } } else { // disable - if (m_mode == ewol::font::Bold) { + if (this.mode == ewol::font::Bold) { setFontMode(ewol::font::Regular); - } else if (m_mode == ewol::font::BoldItalic) { + } else if (this.mode == ewol::font::BoldItalic) { setFontMode(ewol::font::Italic); } } } -void ewol::compositing::TextBase::setFontItalic(bool _status) { +void ewol::compositing::TextBase::setFontItalic(boolean _status) { if (_status == true) { // enable - if (m_mode == ewol::font::Regular) { + if (this.mode == ewol::font::Regular) { setFontMode(ewol::font::Italic); - } else if (m_mode == ewol::font::Bold) { + } else if (this.mode == ewol::font::Bold) { setFontMode(ewol::font::BoldItalic); } } else { // disable - if (m_mode == ewol::font::Italic) { + if (this.mode == ewol::font::Italic) { setFontMode(ewol::font::Regular); - } else if (m_mode == ewol::font::BoldItalic) { + } else if (this.mode == ewol::font::BoldItalic) { setFontMode(ewol::font::Bold); } } } -void ewol::compositing::TextBase::setKerningMode(bool _newMode) { - m_kerning = _newMode; +void ewol::compositing::TextBase::setKerningMode(boolean _newMode) { + this.kerning = _newMode; } -void ewol::compositing::TextBase::print(const etk::UString& _text) { +void ewol::compositing::TextBase::print( etk::UString _text) { List decorationEmpty; print(_text, decorationEmpty); } -void ewol::compositing::TextBase::print(const etk::String& _text) { +void ewol::compositing::TextBase::print( String _text) { List decorationEmpty; print(_text, decorationEmpty); } -void ewol::compositing::TextBase::parseHtmlNode(const exml::Element& _element) { +void ewol::compositing::TextBase::parseHtmlNode( exml::Element _element) { // get the static real pointer if (_element.exist() == false) { Log.error( "Error Input node does not existed ..."); @@ -266,10 +266,10 @@ void ewol::compositing::TextBase::parseHtmlNode(const exml::Element& _element) { continue; } else if (it.isText() == true) { htmlAddData(etk::toUString(it.getValue())); - Log.verbose("XML add : " << it.getValue()); + Log.verbose("XML add : " + it.getValue()); continue; } else if (it.isElement() == false) { - Log.error("(l "<< it.getPos() << ") node not suported type : " << it.getType() << " val='"<< it.getValue() << "'" ); + Log.error("(l "+ it.getPos() + ") node not suported type : " + it.getType() + " val='"+ it.getValue() + "'" ); continue; } exml::Element elem = it.toElement(); @@ -279,43 +279,43 @@ void ewol::compositing::TextBase::parseHtmlNode(const exml::Element& _element) { } if(etk::compare_no_case(elem.getValue(), "br") == true) { htmlFlush(); - Log.verbose("XML flush & newLine"); + Log.verbose("XML flush newLine"); forceLineReturn(); } else if (etk::compare_no_case(elem.getValue(), "font") == true) { Log.verbose("XML Font ..."); - TextDecoration tmpDeco = m_htmlDecoTmp; - etk::String colorValue = elem.attributes["color"]; + TextDecoration tmpDeco = this.htmlDecoTmp; + String colorValue = elem.attributes["color"]; if (colorValue.size() != 0) { - m_htmlDecoTmp.m_colorFg = colorValue; + this.htmlDecoTmp.this.colorFg = colorValue; } colorValue = elem.attributes["colorBg"]; if (colorValue.size() != 0) { - m_htmlDecoTmp.m_colorBg = colorValue; + this.htmlDecoTmp.this.colorBg = colorValue; } parseHtmlNode(elem); - m_htmlDecoTmp = tmpDeco; + this.htmlDecoTmp = tmpDeco; } else if( etk::compare_no_case(elem.getValue(), "b") == true || etk::compare_no_case(elem.getValue(), "bold") == true) { Log.verbose("XML bold ..."); - TextDecoration tmpDeco = m_htmlDecoTmp; - if (m_htmlDecoTmp.m_mode == ewol::font::Regular) { - m_htmlDecoTmp.m_mode = ewol::font::Bold; - } else if (m_htmlDecoTmp.m_mode == ewol::font::Italic) { - m_htmlDecoTmp.m_mode = ewol::font::BoldItalic; + TextDecoration tmpDeco = this.htmlDecoTmp; + if (this.htmlDecoTmp.this.mode == ewol::font::Regular) { + this.htmlDecoTmp.this.mode = ewol::font::Bold; + } else if (this.htmlDecoTmp.this.mode == ewol::font::Italic) { + this.htmlDecoTmp.this.mode = ewol::font::BoldItalic; } parseHtmlNode(elem); - m_htmlDecoTmp = tmpDeco; + this.htmlDecoTmp = tmpDeco; } else if( etk::compare_no_case(elem.getValue(), "i") == true || etk::compare_no_case(elem.getValue(), "italic") == true) { Log.verbose("XML italic ..."); - TextDecoration tmpDeco = m_htmlDecoTmp; - if (m_htmlDecoTmp.m_mode == ewol::font::Regular) { - m_htmlDecoTmp.m_mode = ewol::font::Italic; - } else if (m_htmlDecoTmp.m_mode == ewol::font::Bold) { - m_htmlDecoTmp.m_mode = ewol::font::BoldItalic; + TextDecoration tmpDeco = this.htmlDecoTmp; + if (this.htmlDecoTmp.this.mode == ewol::font::Regular) { + this.htmlDecoTmp.this.mode = ewol::font::Italic; + } else if (this.htmlDecoTmp.this.mode == ewol::font::Bold) { + this.htmlDecoTmp.this.mode = ewol::font::BoldItalic; } parseHtmlNode(elem); - m_htmlDecoTmp = tmpDeco; + this.htmlDecoTmp = tmpDeco; } else if( etk::compare_no_case(elem.getValue(), "u") == true || etk::compare_no_case(elem.getValue(), "underline") == true) { Log.verbose("XML underline ..."); @@ -324,59 +324,59 @@ void ewol::compositing::TextBase::parseHtmlNode(const exml::Element& _element) { || etk::compare_no_case(elem.getValue(), "paragraph") == true) { Log.verbose("XML paragraph ..."); htmlFlush(); - m_alignement = alignLeft; + this.alignement = alignLeft; forceLineReturn(); parseHtmlNode(elem); forceLineReturn(); } else if (etk::compare_no_case(elem.getValue(), "center") == true) { Log.verbose("XML center ..."); htmlFlush(); - m_alignement = alignCenter; + this.alignement = alignCenter; parseHtmlNode(elem); } else if (etk::compare_no_case(elem.getValue(), "left") == true) { Log.verbose("XML left ..."); htmlFlush(); - m_alignement = alignLeft; + this.alignement = alignLeft; parseHtmlNode(elem); } else if (etk::compare_no_case(elem.getValue(), "right") == true) { Log.verbose("XML right ..."); htmlFlush(); - m_alignement = alignRight; + this.alignement = alignRight; parseHtmlNode(elem); } else if (etk::compare_no_case(elem.getValue(), "justify") == true) { Log.verbose("XML justify ..."); htmlFlush(); - m_alignement = alignJustify; + this.alignement = alignJustify; parseHtmlNode(elem); } else { - Log.error("(l "<< elem.getPos() << ") node not suported type: " << elem.getType() << " val='"<< elem.getValue() << "'" ); + Log.error("(l "+ elem.getPos() + ") node not suported type: " + elem.getType() + " val='"+ elem.getValue() + "'" ); } } } -void ewol::compositing::TextBase::printDecorated(const etk::String& _text) { - etk::String tmpData("\n\n"); +void ewol::compositing::TextBase::printDecorated( String _text) { + String tmpData("\n\n"); tmpData += _text; tmpData += "\n\n\n"; - //Log.debug("plop : " << tmpData); + //Log.debug("plop : " + tmpData); printHTML(tmpData); } -void ewol::compositing::TextBase::printDecorated(const etk::UString& _text) { +void ewol::compositing::TextBase::printDecorated( etk::UString _text) { etk::UString tmpData(U"\n\n"); tmpData += _text; tmpData += U"\n\n\n"; - //Log.debug("plop : " << tmpData); + //Log.debug("plop : " + tmpData); printHTML(tmpData); } -void ewol::compositing::TextBase::printHTML(const etk::String& _text) { +void ewol::compositing::TextBase::printHTML( String _text) { exml::Document doc; // reset parameter : - m_htmlDecoTmp.m_colorBg = m_defaultColorBg; - m_htmlDecoTmp.m_colorFg = m_defaultColorFg; - m_htmlDecoTmp.m_mode = ewol::font::Regular; + this.htmlDecoTmp.this.colorBg = this.defaultColorBg; + this.htmlDecoTmp.this.colorFg = this.defaultColorFg; + this.htmlDecoTmp.this.mode = ewol::font::Regular; if (doc.parse(_text) == false) { Log.error( "can not load XML: PARSING error: Decorated text "); @@ -398,13 +398,13 @@ void ewol::compositing::TextBase::printHTML(const etk::String& _text) { htmlFlush(); } -void ewol::compositing::TextBase::printHTML(const etk::UString& _text) { +void ewol::compositing::TextBase::printHTML( etk::UString _text) { exml::Document doc; // reset parameter : - m_htmlDecoTmp.m_colorBg = m_defaultColorBg; - m_htmlDecoTmp.m_colorFg = m_defaultColorFg; - m_htmlDecoTmp.m_mode = ewol::font::Regular; + this.htmlDecoTmp.this.colorBg = this.defaultColorBg; + this.htmlDecoTmp.this.colorFg = this.defaultColorFg; + this.htmlDecoTmp.this.mode = ewol::font::Regular; // TODO : Create an instance of xml parser to manage etk::UString... if (doc.parse(etk::toString(_text)) == false) { Log.error( "can not load XML: PARSING error: Decorated text "); @@ -426,77 +426,77 @@ void ewol::compositing::TextBase::printHTML(const etk::UString& _text) { htmlFlush(); } -void ewol::compositing::TextBase::print(const etk::String& _text, const List& _decoration) { - etk::Color<> tmpFg(m_color); - etk::Color<> tmpBg(m_colorBg); - if (m_alignement == alignDisable) { - //Log.debug(" 1 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); +void ewol::compositing::TextBase::print( String _text, List _decoration) { + etk::Color<> tmpFg(this.color); + etk::Color<> tmpBg(this.colorBg); + if (this.alignement == alignDisable) { + //Log.debug(" 1 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // display the cursor if needed (if it is at the start position...) - if (m_needDisplay == true) { - if (0 == m_cursorPos) { - m_vectorialDraw.setPos(m_position); - setColorBg(m_colorCursor); + if (this.needDisplay == true) { + if (0 == this.cursorPos) { + this.vectorialDraw.setPos(this.position); + setColorBg(this.colorCursor); printCursor(false); } } // note this is faster when nothing is requested ... - for(size_t iii=0; iii<_text.size(); iii++) { + for(int iii=0; iii<_text.size(); iii++) { // check if ve have decoration if (iii<_decoration.size()) { - tmpFg = _decoration[iii].m_colorFg; - tmpBg = _decoration[iii].m_colorBg; - setFontMode(_decoration[iii].m_mode); + tmpFg = _decoration[iii].this.colorFg; + tmpBg = _decoration[iii].this.colorBg; + setFontMode(_decoration[iii].this.mode); } // if real display : ( not display is for size calculation) - if (m_needDisplay == true) { - if( ( m_selectionStartPos-1 < (int64_t)iii - && (int64_t)iii <= m_cursorPos-1) - || ( m_selectionStartPos-1 >= (int64_t)iii - && (int64_t)iii > m_cursorPos-1) ) { + if (this.needDisplay == true) { + if( ( this.selectionStartPos-1 < (long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii <= this.cursorPos-1) + || ( this.selectionStartPos-1 >= (long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii > this.cursorPos-1) ) { setColor( 0x000000FF); - setColorBg(m_colorSelection); + setColorBg(this.colorSelection); } else { setColor( tmpFg); setColorBg(tmpBg); } } - if( m_needDisplay == true - && m_colorBg.a() != 0) { - Vector3f pos = m_position; - m_vectorialDraw.setPos(pos); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + Vector3f pos = this.position; + this.vectorialDraw.setPos(pos); printChar(_text[iii]); float fontHeigh = getHeight(); - m_vectorialDraw.rectangleWidth(Vector3f(m_position.x()-pos.x(),fontHeigh,0.0f) ); - m_nbCharDisplayed++; + this.vectorialDraw.rectangleWidth(Vector3f(this.position.x()-pos.x(),fontHeigh,0.0f) ); + this.nbCharDisplayed++; } else { printChar(_text[iii]); - m_nbCharDisplayed++; + this.nbCharDisplayed++; } // display the cursor if needed (if it is at the other position...) - if (m_needDisplay == true) { - if ((int64_t)iii == m_cursorPos-1) { - m_vectorialDraw.setPos(m_position); - setColorBg(m_colorCursor); + if (this.needDisplay == true) { + if ((long)iii == this.cursorPos-1) { + this.vectorialDraw.setPos(this.position); + setColorBg(this.colorCursor); printCursor(false); } } } - //Log.debug(" 2 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 2 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); } else { - //Log.debug(" 3 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 3 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // special start case at the right of the endpoint : - if (m_stopTextPos < m_position.x()) { + if (this.stopTextPos < this.position.x()) { forceLineReturn(); } - float basicSpaceWidth = calculateSize(char32_t(' ')).x(); - int32_t currentId = 0; - int32_t stop; - int32_t space; - int32_t freeSpace; - while (currentId < (int64_t)_text.size()) { - bool needNoJustify = extrapolateLastId(_text, currentId, stop, space, freeSpace); + float basicSpaceWidth = calculateSize(Character(' ')).x(); + int currentId = 0; + int stop; + int space; + int freeSpace; + while (currentId < (long)_text.size()) { + boolean needNoJustify = extrapolateLastId(_text, currentId, stop, space, freeSpace); float interpolation = basicSpaceWidth; - switch (m_alignement) { + switch (this.alignement) { case alignJustify: if (needNoJustify == false) { interpolation += (float)freeSpace / (float)(space-1); @@ -507,181 +507,181 @@ void ewol::compositing::TextBase::print(const etk::String& _text, const List= (int64_t)iii - && (int64_t)iii > m_cursorPos-1) ) { + if (this.needDisplay == true) { + if( ( this.selectionStartPos-1<(long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii <= this.cursorPos-1) + || ( this.selectionStartPos-1 >= (long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii > this.cursorPos-1) ) { setColor( 0x000000FF); - setColorBg(m_colorSelection); + setColorBg(this.colorSelection); } else { setColor( tmpFg); setColorBg(tmpBg); } } // special for the justify mode - if ((char32_t)_text[iii] == u32char::Space) { + if ((Character)_text[iii] == u32char::Space) { //Log.debug(" generateString : \" \""); - if( m_needDisplay == true - && m_colorBg.a() != 0) { - m_vectorialDraw.setPos(m_position); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + this.vectorialDraw.setPos(this.position); } // Must generate a dynamic space : - setPos(Vector3f(m_position.x() + interpolation, - m_position.y(), - m_position.z()) ); - if( m_needDisplay == true - && m_colorBg.a() != 0) { - m_vectorialDraw.rectangleWidth(Vector3f(interpolation,fontHeigh,0.0f) ); + setPos(Vector3f(this.position.x() + interpolation, + this.position.y(), + this.position.z()) ); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + this.vectorialDraw.rectangleWidth(Vector3f(interpolation,fontHeigh,0.0f) ); } } else { - //Log.debug(" generateString : \"" << (char)text[iii] << "\""); - if( m_needDisplay == true - && m_colorBg.a() != 0) { - Vector3f pos = m_position; - m_vectorialDraw.setPos(pos); + //Log.debug(" generateString : \"" + (char)text[iii] + "\""); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + Vector3f pos = this.position; + this.vectorialDraw.setPos(pos); printChar(_text[iii]); - m_vectorialDraw.rectangleWidth(Vector3f(m_position.x()-pos.x(),fontHeigh,0.0f) ); - m_nbCharDisplayed++; + this.vectorialDraw.rectangleWidth(Vector3f(this.position.x()-pos.x(),fontHeigh,0.0f) ); + this.nbCharDisplayed++; } else { printChar(_text[iii]); - m_nbCharDisplayed++; + this.nbCharDisplayed++; } } - if (m_needDisplay == true) { - if ((int64_t)iii == m_cursorPos-1) { - m_vectorialDraw.setPos(m_position); - setColorBg(m_colorCursor); + if (this.needDisplay == true) { + if ((long)iii == this.cursorPos-1) { + this.vectorialDraw.setPos(this.position); + setColorBg(this.colorCursor); printCursor(false); } } } if (currentId == stop) { currentId++; - } else if((char32_t)_text[stop] == u32char::Space) { + } else if((Character)_text[stop] == u32char::Space) { currentId = stop+1; // reset position : - setPos(Vector3f(m_startTextpos, - (float)(m_position.y() - getHeight()), - m_position.z()) ); - m_nbCharDisplayed++; - } else if((char32_t)_text[stop] == u32char::Return) { + setPos(Vector3f(this.startTextpos, + (float)(this.position.y() - getHeight()), + this.position.z()) ); + this.nbCharDisplayed++; + } else if((Character)_text[stop] == u32char::Return) { currentId = stop+1; // reset position : - setPos(Vector3f(m_startTextpos, - (float)(m_position.y() - getHeight()), - m_position.z()) ); - m_nbCharDisplayed++; + setPos(Vector3f(this.startTextpos, + (float)(this.position.y() - getHeight()), + this.position.z()) ); + this.nbCharDisplayed++; } else { currentId = stop; } } - //Log.debug(" 4 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 4 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); } } -void ewol::compositing::TextBase::print(const etk::UString& _text, const List& _decoration) { - etk::Color<> tmpFg(m_color); - etk::Color<> tmpBg(m_colorBg); - if (m_alignement == alignDisable) { - //Log.debug(" 1 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); +void ewol::compositing::TextBase::print( etk::UString _text, List _decoration) { + etk::Color<> tmpFg(this.color); + etk::Color<> tmpBg(this.colorBg); + if (this.alignement == alignDisable) { + //Log.debug(" 1 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // display the cursor if needed (if it is at the start position...) - if (m_needDisplay == true) { - if (0 == m_cursorPos) { - m_vectorialDraw.setPos(m_position); - setColorBg(m_colorCursor); + if (this.needDisplay == true) { + if (0 == this.cursorPos) { + this.vectorialDraw.setPos(this.position); + setColorBg(this.colorCursor); printCursor(false); } } // note this is faster when nothing is requested ... - for(size_t iii=0; iii<_text.size(); iii++) { + for(int iii=0; iii<_text.size(); iii++) { // check if ve have decoration if (iii<_decoration.size()) { - tmpFg = _decoration[iii].m_colorFg; - tmpBg = _decoration[iii].m_colorBg; - setFontMode(_decoration[iii].m_mode); + tmpFg = _decoration[iii].this.colorFg; + tmpBg = _decoration[iii].this.colorBg; + setFontMode(_decoration[iii].this.mode); } // if real display : ( not display is for size calculation) - if (m_needDisplay == true) { - if( ( m_selectionStartPos-1<(int64_t)iii - && (int64_t)iii <= m_cursorPos-1) - || ( m_selectionStartPos-1 >= (int64_t)iii - && (int64_t)iii > m_cursorPos-1) ) { + if (this.needDisplay == true) { + if( ( this.selectionStartPos-1<(long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii <= this.cursorPos-1) + || ( this.selectionStartPos-1 >= (long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii > this.cursorPos-1) ) { setColor( 0x000000FF); - setColorBg(m_colorSelection); + setColorBg(this.colorSelection); } else { setColor( tmpFg); setColorBg(tmpBg); } } - if( m_needDisplay == true - && m_colorBg.a() != 0) { - Vector3f pos = m_position; - m_vectorialDraw.setPos(pos); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + Vector3f pos = this.position; + this.vectorialDraw.setPos(pos); printChar(_text[iii]); float fontHeigh = getHeight(); - m_vectorialDraw.rectangleWidth(Vector3f(m_position.x()-pos.x(),fontHeigh,0.0f) ); - m_nbCharDisplayed++; + this.vectorialDraw.rectangleWidth(Vector3f(this.position.x()-pos.x(),fontHeigh,0.0f) ); + this.nbCharDisplayed++; } else { printChar(_text[iii]); - m_nbCharDisplayed++; + this.nbCharDisplayed++; } // display the cursor if needed (if it is at the other position...) - if (m_needDisplay == true) { - if ((int64_t)iii == m_cursorPos-1) { - m_vectorialDraw.setPos(m_position); - setColorBg(m_colorCursor); + if (this.needDisplay == true) { + if ((long)iii == this.cursorPos-1) { + this.vectorialDraw.setPos(this.position); + setColorBg(this.colorCursor); printCursor(false); } } } - //Log.debug(" 2 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 2 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); } else { - //Log.debug(" 3 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 3 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // special start case at the right of the endpoint : - if (m_stopTextPos < m_position.x()) { + if (this.stopTextPos < this.position.x()) { forceLineReturn(); } - float basicSpaceWidth = calculateSize(char32_t(' ')).x(); - int32_t currentId = 0; - int32_t stop; - int32_t space; - int32_t freeSpace; - while (currentId < (int64_t)_text.size()) { - bool needNoJustify = extrapolateLastId(_text, currentId, stop, space, freeSpace); + float basicSpaceWidth = calculateSize(Character(' ')).x(); + int currentId = 0; + int stop; + int space; + int freeSpace; + while (currentId < (long)_text.size()) { + boolean needNoJustify = extrapolateLastId(_text, currentId, stop, space, freeSpace); float interpolation = basicSpaceWidth; - switch (m_alignement) { + switch (this.alignement) { case alignJustify: if (needNoJustify == false) { interpolation += (float)freeSpace / (float)(space-1); @@ -692,82 +692,82 @@ void ewol::compositing::TextBase::print(const etk::UString& _text, const List= (int64_t)iii - && (int64_t)iii > m_cursorPos-1) ) { + if (this.needDisplay == true) { + if( ( this.selectionStartPos-1<(long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii <= this.cursorPos-1) + || ( this.selectionStartPos-1 >= (long)iii + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (long)iii > this.cursorPos-1) ) { setColor( 0x000000FF); - setColorBg(m_colorSelection); + setColorBg(this.colorSelection); } else { setColor( tmpFg); setColorBg(tmpBg); } } // special for the justify mode - if ((char32_t)_text[iii] == u32char::Space) { + if ((Character)_text[iii] == u32char::Space) { //Log.debug(" generateString : \" \""); - if( m_needDisplay == true - && m_colorBg.a() != 0) { - m_vectorialDraw.setPos(m_position); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + this.vectorialDraw.setPos(this.position); } // Must generate a dynamic space : - setPos(Vector3f(m_position.x() + interpolation, - m_position.y(), - m_position.z()) ); - if( m_needDisplay == true - && m_colorBg.a() != 0) { - m_vectorialDraw.rectangleWidth(Vector3f(interpolation,fontHeigh,0.0f) ); + setPos(Vector3f(this.position.x() + interpolation, + this.position.y(), + this.position.z()) ); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + this.vectorialDraw.rectangleWidth(Vector3f(interpolation,fontHeigh,0.0f) ); } } else { - //Log.debug(" generateString : \"" << (char)text[iii] << "\""); - if( m_needDisplay == true - && m_colorBg.a() != 0) { - Vector3f pos = m_position; - m_vectorialDraw.setPos(pos); + //Log.debug(" generateString : \"" + (char)text[iii] + "\""); + if( this.needDisplay == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorBg.a() != 0) { + Vector3f pos = this.position; + this.vectorialDraw.setPos(pos); printChar(_text[iii]); - m_vectorialDraw.rectangleWidth(Vector3f(m_position.x()-pos.x(),fontHeigh,0.0f) ); - m_nbCharDisplayed++; + this.vectorialDraw.rectangleWidth(Vector3f(this.position.x()-pos.x(),fontHeigh,0.0f) ); + this.nbCharDisplayed++; } else { printChar(_text[iii]); - m_nbCharDisplayed++; + this.nbCharDisplayed++; } } - if (m_needDisplay == true) { - if ((int64_t)iii == m_cursorPos-1) { - m_vectorialDraw.setPos(m_position); - setColorBg(m_colorCursor); + if (this.needDisplay == true) { + if ((long)iii == this.cursorPos-1) { + this.vectorialDraw.setPos(this.position); + setColorBg(this.colorCursor); printCursor(false); } } @@ -777,22 +777,22 @@ void ewol::compositing::TextBase::print(const etk::UString& _text, const List " << _stopTextPos); + Log.verbose("Request allignement with Borne position error : " + _startTextpos + " => " + _stopTextPos); } } enum ewol::compositing::aligneMode ewol::compositing::TextBase::getAlignement() { - return m_alignement; + return this.alignement; } void ewol::compositing::TextBase::disableAlignement() { - m_alignement = alignDisable; + this.alignement = alignDisable; } -Vector3f ewol::compositing::TextBase::calculateSizeHTML(const etk::String& _text) { +Vector3f ewol::compositing::TextBase::calculateSizeHTML( String _text) { // remove intermediate result reset(); - //Log.debug(" 0 size for=\n" << text); + //Log.debug(" 0 size for=\n" + text); // disable display system - m_needDisplay = false; + this.needDisplay = false; setPos(Vector3f(0,0,0) ); // same as print without the end display ... printHTML(_text); - //Log.debug(" 1 Start pos=" << m_sizeDisplayStart); - //Log.debug(" 1 Stop pos=" << m_sizeDisplayStop); + //Log.debug(" 1 Start pos=" + this.sizeDisplayStart); + //Log.debug(" 1 Stop pos=" + this.sizeDisplayStop); // get the last elements - m_sizeDisplayStop.setValue(etk::max(m_position.x(), m_sizeDisplayStop.x()) , - etk::max(m_position.y(), m_sizeDisplayStop.y()) , + this.sizeDisplayStop.setValue(etk::max(this.position.x(), this.sizeDisplayStop.x()) , + etk::max(this.position.y(), this.sizeDisplayStop.y()) , 0); - m_sizeDisplayStart.setValue(etk::min(m_position.x(), m_sizeDisplayStart.x()) , - etk::min(m_position.y(), m_sizeDisplayStart.y()) , + this.sizeDisplayStart.setValue(etk::min(this.position.x(), this.sizeDisplayStart.x()) , + etk::min(this.position.y(), this.sizeDisplayStart.y()) , 0); - //Log.debug(" 2 Start pos=" << m_sizeDisplayStart); - //Log.debug(" 2 Stop pos=" << m_sizeDisplayStop); + //Log.debug(" 2 Start pos=" + this.sizeDisplayStart); + //Log.debug(" 2 Stop pos=" + this.sizeDisplayStop); // set back the display system - m_needDisplay = true; + this.needDisplay = true; - return Vector3f( m_sizeDisplayStop.x()-m_sizeDisplayStart.x(), - m_sizeDisplayStop.y()-m_sizeDisplayStart.y(), - m_sizeDisplayStop.z()-m_sizeDisplayStart.z()); + return Vector3f( this.sizeDisplayStop.x()-this.sizeDisplayStart.x(), + this.sizeDisplayStop.y()-this.sizeDisplayStart.y(), + this.sizeDisplayStop.z()-this.sizeDisplayStart.z()); } -Vector3f ewol::compositing::TextBase::calculateSizeHTML(const etk::UString& _text) { +Vector3f ewol::compositing::TextBase::calculateSizeHTML( etk::UString _text) { // remove intermediate result reset(); - //Log.debug(" 0 size for=\n" << text); + //Log.debug(" 0 size for=\n" + text); // disable display system - m_needDisplay = false; + this.needDisplay = false; setPos(Vector3f(0,0,0) ); // same as print without the end display ... printHTML(_text); - //Log.debug(" 1 Start pos=" << m_sizeDisplayStart); - //Log.debug(" 1 Stop pos=" << m_sizeDisplayStop); + //Log.debug(" 1 Start pos=" + this.sizeDisplayStart); + //Log.debug(" 1 Stop pos=" + this.sizeDisplayStop); // get the last elements - m_sizeDisplayStop.setValue(etk::max(m_position.x(), m_sizeDisplayStop.x()) , - etk::max(m_position.y(), m_sizeDisplayStop.y()) , + this.sizeDisplayStop.setValue(etk::max(this.position.x(), this.sizeDisplayStop.x()) , + etk::max(this.position.y(), this.sizeDisplayStop.y()) , 0); - m_sizeDisplayStart.setValue(etk::min(m_position.x(), m_sizeDisplayStart.x()) , - etk::min(m_position.y(), m_sizeDisplayStart.y()) , + this.sizeDisplayStart.setValue(etk::min(this.position.x(), this.sizeDisplayStart.x()) , + etk::min(this.position.y(), this.sizeDisplayStart.y()) , 0); - //Log.debug(" 2 Start pos=" << m_sizeDisplayStart); - //Log.debug(" 2 Stop pos=" << m_sizeDisplayStop); + //Log.debug(" 2 Start pos=" + this.sizeDisplayStart); + //Log.debug(" 2 Stop pos=" + this.sizeDisplayStop); // set back the display system - m_needDisplay = true; + this.needDisplay = true; - return Vector3f( m_sizeDisplayStop.x()-m_sizeDisplayStart.x(), - m_sizeDisplayStop.y()-m_sizeDisplayStart.y(), - m_sizeDisplayStop.z()-m_sizeDisplayStart.z()); + return Vector3f( this.sizeDisplayStop.x()-this.sizeDisplayStart.x(), + this.sizeDisplayStop.y()-this.sizeDisplayStart.y(), + this.sizeDisplayStop.z()-this.sizeDisplayStart.z()); } -Vector3f ewol::compositing::TextBase::calculateSizeDecorated(const etk::String& _text) { +Vector3f ewol::compositing::TextBase::calculateSizeDecorated( String _text) { if (_text.size() == 0) { return Vector3f(0,0,0); } - etk::String tmpData("\n"); + String tmpData("\n"); tmpData+=_text; tmpData+="\n\n"; Vector3f tmpVal = calculateSizeHTML(tmpData); return tmpVal; } -Vector3f ewol::compositing::TextBase::calculateSizeDecorated(const etk::UString& _text) { +Vector3f ewol::compositing::TextBase::calculateSizeDecorated( etk::UString _text) { if (_text.size() == 0) { return Vector3f(0,0,0); } @@ -906,7 +906,7 @@ Vector3f ewol::compositing::TextBase::calculateSizeDecorated(const etk::UString& return tmpVal; } -Vector3f ewol::compositing::TextBase::calculateSize(const etk::String& _text) { +Vector3f ewol::compositing::TextBase::calculateSize( String _text) { Vector3f outputSize(0, 0, 0); for(auto element : _text) { Vector3f tmpp = calculateSize(element); @@ -918,7 +918,7 @@ Vector3f ewol::compositing::TextBase::calculateSize(const etk::String& _text) { return outputSize; } -Vector3f ewol::compositing::TextBase::calculateSize(const etk::UString& _text) { +Vector3f ewol::compositing::TextBase::calculateSize( etk::UString _text) { Vector3f outputSize(0, 0, 0); for(auto element : _text) { Vector3f tmpp = calculateSize(element); @@ -930,41 +930,41 @@ Vector3f ewol::compositing::TextBase::calculateSize(const etk::UString& _text) { return outputSize; } -void ewol::compositing::TextBase::printCursor(bool _isInsertMode, float _cursorSize) { - int32_t fontHeigh = getHeight(); +void ewol::compositing::TextBase::printCursor(boolean _isInsertMode, float _cursorSize) { + int fontHeigh = getHeight(); if (true == _isInsertMode) { - m_vectorialDraw.rectangleWidth(Vector3f(_cursorSize, fontHeigh, 0) ); + this.vectorialDraw.rectangleWidth(Vector3f(_cursorSize, fontHeigh, 0) ); } else { - m_vectorialDraw.setThickness(2); - m_vectorialDraw.lineRel( Vector3f(0, fontHeigh, 0) ); - m_vectorialDraw.setThickness(0); + this.vectorialDraw.setThickness(2); + this.vectorialDraw.lineRel( Vector3f(0, fontHeigh, 0) ); + this.vectorialDraw.setThickness(0); } } -bool ewol::compositing::TextBase::extrapolateLastId(const etk::String& _text, - const int32_t _start, - int32_t& _stop, - int32_t& _space, - int32_t& _freeSpace) { +boolean ewol::compositing::TextBase::extrapolateLastId( String _text, + int _start, + int _stop, + int _space, + int _freeSpace) { // store previous : - char32_t storePrevious = m_previousCharcode; + Character storePrevious = this.previousCharcode; _stop = _text.size(); _space = 0; - int32_t lastSpacePosition = _start; - int32_t lastSpacefreeSize = 0; + int lastSpacePosition = _start; + int lastSpacefreeSize = 0; - float endPos = m_position.x(); - bool endOfLine = false; + float endPos = this.position.x(); + boolean endOfLine = false; - float stopPosition = m_stopTextPos; - if( m_needDisplay == false - || m_stopTextPos == m_startTextpos) { - stopPosition = m_startTextpos + 3999999999.0; + float stopPosition = this.stopTextPos; + if( this.needDisplay == false + || this.stopTextPos == this.startTextpos) { + stopPosition = this.startTextpos + 3999999999.0; } - for (size_t iii=_start; iii<_text.size(); iii++) { + for (int iii=_start; iii<_text.size(); iii++) { Vector3f tmpSize = calculateSize(_text[iii]); // check oveflow : if (endPos + tmpSize.x() > stopPosition) { @@ -972,11 +972,11 @@ bool ewol::compositing::TextBase::extrapolateLastId(const etk::String& _text, break; } // save number of space : - if ((char32_t)_text[iii] == u32char::Space) { + if ((Character)_text[iii] == u32char::Space) { _space++; lastSpacePosition = iii; lastSpacefreeSize = stopPosition - endPos; - } else if ((char32_t)_text[iii] == u32char::Return) { + } else if ((Character)_text[iii] == u32char::Return) { _stop = iii; endOfLine = true; break; @@ -986,9 +986,9 @@ bool ewol::compositing::TextBase::extrapolateLastId(const etk::String& _text, } _freeSpace = stopPosition - endPos; // retore previous : - m_previousCharcode = storePrevious; + this.previousCharcode = storePrevious; // need to align left or right ... - if(_stop == (int64_t)_text.size()) { + if(_stop == (long)_text.size()) { return true; } else { if (endOfLine) { @@ -1004,30 +1004,30 @@ bool ewol::compositing::TextBase::extrapolateLastId(const etk::String& _text, } } -bool ewol::compositing::TextBase::extrapolateLastId(const etk::UString& _text, - const int32_t _start, - int32_t& _stop, - int32_t& _space, - int32_t& _freeSpace) { +boolean ewol::compositing::TextBase::extrapolateLastId( etk::UString _text, + int _start, + int _stop, + int _space, + int _freeSpace) { // store previous : - char32_t storePrevious = m_previousCharcode; + Character storePrevious = this.previousCharcode; _stop = _text.size(); _space = 0; - int32_t lastSpacePosition = _start; - int32_t lastSpacefreeSize = 0; + int lastSpacePosition = _start; + int lastSpacefreeSize = 0; - float endPos = m_position.x(); - bool endOfLine = false; + float endPos = this.position.x(); + boolean endOfLine = false; - float stopPosition = m_stopTextPos; - if( m_needDisplay == false - || m_stopTextPos == m_startTextpos) { - stopPosition = m_startTextpos + 3999999999.0; + float stopPosition = this.stopTextPos; + if( this.needDisplay == false + || this.stopTextPos == this.startTextpos) { + stopPosition = this.startTextpos + 3999999999.0; } - for (size_t iii=_start; iii<_text.size(); iii++) { + for (int iii=_start; iii<_text.size(); iii++) { Vector3f tmpSize = calculateSize(_text[iii]); // check oveflow : if (endPos + tmpSize.x() > stopPosition) { @@ -1049,9 +1049,9 @@ bool ewol::compositing::TextBase::extrapolateLastId(const etk::UString& _text, } _freeSpace = stopPosition - endPos; // retore previous : - m_previousCharcode = storePrevious; + this.previousCharcode = storePrevious; // need to align left or right ... - if(_stop == (int64_t)_text.size()) { + if(_stop == (long)_text.size()) { return true; } else { if (endOfLine) { @@ -1067,50 +1067,50 @@ bool ewol::compositing::TextBase::extrapolateLastId(const etk::UString& _text, } } -void ewol::compositing::TextBase::htmlAddData(const etk::UString& _data) { - if( m_htmlCurrrentLine.size()>0 - && m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') { - m_htmlCurrrentLine += U" "; - if(m_htmlDecoration.size()>0) { - TextDecoration tmp = m_htmlDecoration[m_htmlDecoration.size()-1]; - m_htmlDecoration.pushBack(tmp); +void ewol::compositing::TextBase::htmlAddData( etk::UString _data) { + if( this.htmlCurrrentLine.size()>0 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.htmlCurrrentLine[this.htmlCurrrentLine.size()-1] != ' ') { + this.htmlCurrrentLine += U" "; + if(this.htmlDecoration.size()>0) { + TextDecoration tmp = this.htmlDecoration[this.htmlDecoration.size()-1]; + this.htmlDecoration.pushBack(tmp); } else { - m_htmlDecoration.pushBack(m_htmlDecoTmp); + this.htmlDecoration.pushBack(this.htmlDecoTmp); } } - m_htmlCurrrentLine += _data; - for(size_t iii=0; iii<_data.size() ; iii++) { - m_htmlDecoration.pushBack(m_htmlDecoTmp); + this.htmlCurrrentLine += _data; + for(int iii=0; iii<_data.size() ; iii++) { + this.htmlDecoration.pushBack(this.htmlDecoTmp); } } void ewol::compositing::TextBase::htmlFlush() { - if (m_htmlCurrrentLine.size()>0) { - print(m_htmlCurrrentLine, m_htmlDecoration); + if (this.htmlCurrrentLine.size()>0) { + print(this.htmlCurrrentLine, this.htmlDecoration); } - m_htmlCurrrentLine = U""; - m_htmlDecoration.clear(); + this.htmlCurrrentLine = U""; + this.htmlDecoration.clear(); } void ewol::compositing::TextBase::disableCursor() { - m_selectionStartPos = -100; - m_cursorPos = -100; + this.selectionStartPos = -100; + this.cursorPos = -100; } -void ewol::compositing::TextBase::setCursorPos(int32_t _cursorPos) { - m_selectionStartPos = _cursorPos; - m_cursorPos = _cursorPos; +void ewol::compositing::TextBase::setCursorPos(int _cursorPos) { + this.selectionStartPos = _cursorPos; + this.cursorPos = _cursorPos; } -void ewol::compositing::TextBase::setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos) { - m_selectionStartPos = _selectionStartPos; - m_cursorPos = _cursorPos; +void ewol::compositing::TextBase::setCursorSelection(int _cursorPos, int _selectionStartPos) { + this.selectionStartPos = _selectionStartPos; + this.cursorPos = _cursorPos; } -void ewol::compositing::TextBase::setSelectionColor(const etk::Color<>& _color) { - m_colorSelection = _color; +void ewol::compositing::TextBase::setSelectionColor( etk::Color<> _color) { + this.colorSelection = _color; } -void ewol::compositing::TextBase::setCursorColor(const etk::Color<>& _color) { - m_colorCursor = _color; +void ewol::compositing::TextBase::setCursorColor( etk::Color<> _color) { + this.colorCursor = _color; } diff --git a/src/org/atriasoft/ewol/compositing/TextBase.java b/src/org/atriasoft/ewol/compositing/TextBase.java index f500650..15a8643 100644 --- a/src/org/atriasoft/ewol/compositing/TextBase.java +++ b/src/org/atriasoft/ewol/compositing/TextBase.java @@ -22,13 +22,13 @@ namespace ewol { */ class TextDecoration { public: - etk::Color m_colorBg; //!< display background color - etk::Color m_colorFg; //!< display foreground color - enum ewol::font::mode m_mode; //!< display mode Regular/Bold/Italic/BoldItalic + etk::Color this.colorBg; //!< display background color + etk::Color this.colorFg; //!< display foreground color + enum ewol::font::mode this.mode; //!< display mode Regular/Bold/Italic/BoldItalic TextDecoration() { - m_colorBg = etk::color::blue; - m_colorBg = etk::color::green; - m_mode = ewol::font::Regular; + this.colorBg = etk::color::blue; + this.colorBg = etk::color::green; + this.mode = ewol::font::Regular; } }; @@ -42,158 +42,158 @@ namespace ewol { class TextBase : public ewol::Compositing { protected: - ewol::compositing::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ... + ewol::compositing::Drawing this.vectorialDraw; //!< This is used to draw background selection and other things ... public: - virtual ewol::compositing::Drawing& getDrawing() { - return m_vectorialDraw; + ewol::compositing::Drawing getDrawing() { + return this.vectorialDraw; }; protected: - int32_t m_nbCharDisplayed; //!< prevent some error in calculation size. - Vector3f m_sizeDisplayStart; //!< The start windows of the display. - Vector3f m_sizeDisplayStop; //!< The end windows of the display. - bool m_needDisplay; //!< This just need the display and not the size rendering. - Vector3f m_position; //!< The current position to draw - Vector3f m_clippingPosStart; //!< Clipping start position - Vector3f m_clippingPosStop; //!< Clipping stop position - bool m_clippingEnable; //!< true if the clipping must be activated + 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 m_defaultColorFg; //!< The text foreground color - etk::Color m_defaultColorBg; //!< The text background color + etk::Color this.defaultColorFg; //!< The text foreground color + etk::Color this.defaultColorBg; //!< The text background color protected: - etk::Color m_color; //!< The text foreground color - etk::Color m_colorBg; //!< The text background color - etk::Color m_colorCursor; //!< The text cursor color - etk::Color m_colorSelection; //!< The text Selection color + etk::Color this.color; //!< The text foreground color + etk::Color this.colorBg; //!< The text background color + etk::Color this.colorCursor; //!< The text cursor color + etk::Color this.colorSelection; //!< The text Selection color protected: - enum ewol::font::mode m_mode; //!< font display property : Regular/Bold/Italic/BoldItalic - bool m_kerning; //!< Kerning enable or disable on the next elements displayed - char32_t m_previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning + 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 m_startTextpos; //!< start position of the Alignement (when \n the text return at this position) - float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one) - enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...) + 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::SharedPtr m_GLprogram; //!< pointer on the opengl display program - int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) - int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) - int32_t m_GLColor; //!< openGL id on the element (color buffer) - int32_t m_GLtexture; //!< openGL id on the element (Texture position) - int32_t m_GLtexID; //!< openGL id on the element (texture ID) - int32_t m_GLtextWidth; //!< openGL Id on the texture width - int32_t m_GLtextHeight; //!< openGL Id on the texture height + ememory::Ptr 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.GLColor; //!< openGL id on the element (color buffer) + int this.GLtexture; //!< openGL id on the element (Texture position) + int this.GLtexID; //!< openGL id on the element (texture ID) + int this.GLtextWidth; //!< openGL Id on the texture width + int this.GLtextHeight; //!< openGL Id on the texture height protected: - int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection) - int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100) + int this.selectionStartPos; //!< start position of the Selection (if == this.cursorPos ==> no selection) + int this.cursorPos; //!< Cursor position (default no cursor == > -100) protected: // Text - static const int32_t m_vboIdCoord; - static const int32_t m_vboIdCoordText; - static const int32_t m_vboIdColor; - static const int32_t m_vboIdGlyphLevel; - ememory::SharedPtr m_VBO; + static int this.vboIdCoord; + static int this.vboIdCoordText; + static int this.vboIdColor; + static int this.vboIdGlyphLevel; + ememory::Ptr this.VBO; public: /** * @brief load the openGL program and get all the ID needed */ - virtual void loadProgram(const etk::String& _shaderName); + void loadProgram( String _shaderName); public: /** - * @brief generic constructor + * @brief generic ructor */ - TextBase(const etk::String& _shaderName = "DATA:///text.prog?lib=ewol", bool _loadProgram = true); + TextBase( String _shaderName = "DATA:///text.prog?lib=ewol", boolean _loadProgram = true); /** * @brief generic destructor */ - virtual ~TextBase(); + ~TextBase(); public: // Derived function - void translate(const Vector3f& _vect); - void rotate(const Vector3f& _vect, float _angle); - void scale(const Vector3f& _vect); + 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(bool _disableDepthTest=true) { + void draw(boolean _disableDepthTest=true) { drawD(_disableDepthTest); } //! @previous - void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false) { + void draw( mat4 _transformationMatrix, boolean _enableDepthTest=false) { drawMT(_transformationMatrix, _enableDepthTest); } /** * @brief draw All the refistered text in the current element on openGL */ - virtual void drawD(bool _disableDepthTest) = 0; + void drawD(boolean _disableDepthTest) = 0; //! @previous - virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) = 0; + void drawMT( mat4 _transformationMatrix, boolean _enableDepthTest) = 0; /** * @brief clear all the registered element in the current element */ - virtual void clear(); + void clear(); /** * @brief clear all the intermediate result detween 2 prints */ - virtual void reset(); + void reset(); /** * @brief get the current display position (sometime needed in the gui control) * @return the current position. */ - const Vector3f& getPos() { - return m_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(const Vector3f& _pos); + void setPos( Vector3f _pos); //! @previous - inline void setPos(const Vector2f& _pos) { + 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(const Vector3f& _pos); + void setRelPos( Vector3f _pos); //! @previous - inline void setRelPos(const Vector2f& _pos) { + 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(const etk::Color<>& _color) { - m_defaultColorBg = _color; + 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(const etk::Color<>& _color) { - m_defaultColorFg = _color; + 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(const etk::Color<>& _color) { - m_color = _color; + 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(const etk::Color<>& _color); + 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(const Vector3f& _pos, const Vector3f& _width) { + void setClippingWidth( Vector3f _pos, Vector3f _width) { setClipping(_pos, _pos+_width); } //! @previous - void setClippingWidth(const Vector2f& _pos, const Vector2f& _width) { + void setClippingWidth( Vector2f _pos, Vector2f _width) { setClipping(_pos, _pos+_width); }; /** @@ -201,9 +201,9 @@ namespace ewol { * @param[in] _pos Start position of the clipping * @param[in] _posEnd End position of the clipping */ - void setClipping(const Vector3f& _pos, const Vector3f& _posEnd); + void setClipping( Vector3f _pos, Vector3f _posEnd); //! @previous - void setClipping(const Vector2f& _pos, const Vector2f& _posEnd) { + void setClipping( Vector2f _pos, Vector2f _posEnd) { setClipping(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_posEnd.x(),_posEnd.y(),1) ); }; /** @@ -211,60 +211,60 @@ namespace ewol { * @brief _newMode The new status of the clipping */ // TODO : Rename setClippingActivity - void setClippingMode(bool _newMode); + 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 */ - virtual void setFontSize(int32_t _fontSize) = 0; + void setFontSize(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 */ - virtual void setFontName(const etk::String& _fontName) = 0; + void setFontName( 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 */ - virtual void setFont(etk::String _fontName, int32_t _fontSize) = 0; + void setFont(String _fontName, int _fontSize) = 0; /** * @brief Specify the font mode for the next @ref print * @param[in] mode The font mode requested */ - virtual void setFontMode(enum ewol::font::mode _mode) = 0; + 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 m_mode; + return this.mode; }; - virtual float getHeight() = 0; - virtual float getSize() = 0; - virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode) = 0; + 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(bool _status); + void setFontBold(boolean _status); /** * @brief enable or disable the italic mode * @param[in] _status The new status for this display property */ - void setFontItalic(bool _status); + 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(bool _newMode); + void setKerningMode(boolean _newMode); /** * @brief display a compleat string in the current element. * @param[in] _text The string to display. */ - void print(const etk::String& _text); + void print( String _text); //! @previous - void print(const etk::UString& _text); + void print( etk::UString _text); /** * @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * @@ -294,9 +294,9 @@ namespace ewol { * @param[in] _text The string to display. * @TODO : implementation not done .... */ - void printDecorated(const etk::String& _text); + void printDecorated( String _text); //! @previous - void printDecorated(const etk::UString& _text); + void printDecorated( etk::UString _text); /** * @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * @@ -330,22 +330,22 @@ namespace ewol { * @param[in] _text The string to display. * @TODO : implementation not done .... */ - void printHTML(const etk::String& _text); + void printHTML( String _text); //! @previous - void printHTML(const etk::UString& _text); + 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(const etk::String& _text, const List& _decoration); + void print( String _text, List _decoration); //! @previous - void print(const etk::UString& _text, const List& _decoration); + void print( etk::UString _text, List _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 */ - virtual void printChar(const char32_t& _charcode) = 0; + 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 */ @@ -355,7 +355,7 @@ namespace ewol { * @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include). * @param[in] _element the exml element. */ - void parseHtmlNode(const exml::Element& _element); + void parseHtmlNode( exml::Element _element); public: /** * @brief This generate the possibility to generate the big text property @@ -379,43 +379,43 @@ namespace ewol { * @param[in] _text The string to calculate dimention. * @return The theoric size used. */ - Vector3f calculateSizeHTML(const etk::String& _text); + Vector3f calculateSizeHTML( String _text); //! @previous - Vector3f calculateSizeHTML(const etk::UString& _text); + 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(const etk::String& _text); + Vector3f calculateSizeDecorated( String _text); //! @previous - Vector3f calculateSizeDecorated(const etk::UString& _text); + 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(const etk::String& _text); + Vector3f calculateSize( String _text); //! @previous - Vector3f calculateSize(const etk::UString& _text); + 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. */ - inline Vector3f calculateSize(const char32_t& _charcode) { + Vector3f calculateSize( Character _charcode) { return calculateSizeChar(_charcode); }; protected: //! @previous - virtual Vector3f calculateSizeChar(const char32_t& _charcode) = 0; + 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(bool _isInsertMode, float _cursorSize = 20.0f); + void printCursor(boolean _isInsertMode, float _cursorSize = 20.0f); protected: /** * @brief calculate the element number that is the first out the alignement range @@ -428,19 +428,19 @@ namespace ewol { * @return true if the rifht has free space that can be use for jystify. * @return false if we find '\n' */ - bool extrapolateLastId(const etk::String& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); + boolean extrapolateLastId( String _text, int _start, int _stop, int _space, int _freeSpace); //! @previous - bool extrapolateLastId(const etk::UString& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); + 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 m_htmlCurrrentLine; //!< current line for HTML display - List m_htmlDecoration; //!< current decoration for the HTML display - TextDecoration m_htmlDecoTmp; //!< current decoration + etk::UString this.htmlCurrrentLine; //!< current line for HTML display + List this.htmlDecoration; //!< current decoration for the HTML display + TextDecoration this.htmlDecoTmp; //!< current decoration /** - * @brief add a line with the current m_htmlDecoTmp decoration + * @brief add a line with the current this.htmlDecoTmp decoration * @param[in] _data The cuurent data to add. */ - void htmlAddData(const etk::UString& _data); + void htmlAddData( etk::UString _data); /** * @brief draw the current line */ @@ -454,23 +454,23 @@ namespace ewol { * @brief set a cursor at a specific position: * @param[in] _cursorPos id of the cursor position */ - void setCursorPos(int32_t _cursorPos); + 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(int32_t _cursorPos, int32_t _selectionStartPos); + void setCursorSelection(int _cursorPos, int _selectionStartPos); /** * @brief change the selection color * @param[in] _color New color for the Selection */ - void setSelectionColor(const etk::Color<>& _color); + void setSelectionColor( etk::Color<> _color); /** * @brief change the cursor color * @param[in] _color New color for the Selection */ - void setCursorColor(const etk::Color<>& _color); + void setCursorColor( etk::Color<> _color); }; } } diff --git a/src/org/atriasoft/ewol/compositing/TextDF.cpp b/src/org/atriasoft/ewol/compositing/TextDF.cpp index 1c275d3..0f97e22 100644 --- a/src/org/atriasoft/ewol/compositing/TextDF.cpp +++ b/src/org/atriasoft/ewol/compositing/TextDF.cpp @@ -11,11 +11,11 @@ #include ETK_DECLARE_TYPE(ewol::compositing::TextDF); -ewol::compositing::TextDF::TextDF(const etk::String& _fontName, int32_t _fontSize) : +ewol::compositing::TextDF::TextDF( String _fontName, int _fontSize) : ewol::compositing::TextBase("", false), - m_fontDF(null), - m_GLglyphLevel(-1), - m_size(12.0) { + this.fontDF(null), + this.GLglyphLevel(-1), + this.size(12.0) { setFont(_fontName, _fontSize); loadProgram("DATA:///fontDistanceField/font1.prog?lib=ewol"); } @@ -24,26 +24,26 @@ ewol::compositing::TextDF::~TextDF() { } -void ewol::compositing::TextDF::updateSizeToRender(const Vector2f& _size) { +void ewol::compositing::TextDF::updateSizeToRender( Vector2f _size) { float minSize = etk::min(_size.x(), _size.y()); - if (m_fontDF != null) { - setFontSize(m_fontDF->getSize(minSize)); + if (this.fontDF != null) { + setFontSize(this.fontDF.getSize(minSize)); } } -void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) { +void ewol::compositing::TextDF::drawMT( mat4 _transformationMatrix, boolean _enableDepthTest) { // draw BG in any case: - m_vectorialDraw.draw(); - if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 - || m_fontDF == null) { - //EWOL_WARNING("Nothink to draw..."); + this.vectorialDraw.draw(); + if ( this.VBO.bufferSize(this.vboIdCoord) <= 0 + || this.fontDF == null) { + //Log.warning("Nothink to draw..."); return; } - if (m_fontDF == null) { - EWOL_WARNING("no font..."); + if (this.fontDF == null) { + Log.warning("no font..."); return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } @@ -54,127 +54,127 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _ mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // Texture: - m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId()); - m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); - m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); - m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); - m_GLprogram->sendAttributePointer(m_GLglyphLevel, m_VBO, m_vboIdGlyphLevel); + this.GLprogram.setTexture0(this.GLtexID, this.fontDF.getRendererId()); + this.GLprogram.uniform1i(this.GLtextWidth, this.fontDF.getOpenGlSize().x()); + this.GLprogram.uniform1i(this.GLtextHeight, this.fontDF.getOpenGlSize().x()); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor); + this.GLprogram.sendAttributePointer(this.GLglyphLevel, this.VBO, this.vboIdGlyphLevel); // Request the draw od the elements: - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord)); + this.GLprogram.unUse(); if (_enableDepthTest == true) { gale::openGL::disable(gale::openGL::flag_depthTest); } } -void ewol::compositing::TextDF::drawD(bool _disableDepthTest) { +void ewol::compositing::TextDF::drawD(boolean _disableDepthTest) { // draw BG in any case: - m_vectorialDraw.draw(); + this.vectorialDraw.draw(); - if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 - || m_fontDF == null) { + if ( this.VBO.bufferSize(this.vboIdCoord) <= 0 + || this.fontDF == null) { // TODO : Set it back - //EWOL_WARNING("Nothink to draw..."); + //Log.warning("Nothink to draw..."); return; } - if (m_fontDF == null) { - EWOL_WARNING("no font..."); + if (this.fontDF == null) { + Log.warning("no font..."); return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } // set Matrix: translation/positionMatrix - mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; - m_GLprogram->use(); - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply; + this.GLprogram.use(); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // Texture: - m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId()); - m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); - m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); - m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); - m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); - m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); - m_GLprogram->sendAttributePointer(m_GLglyphLevel, m_VBO, m_vboIdGlyphLevel); + this.GLprogram.setTexture0(this.GLtexID, this.fontDF.getRendererId()); + this.GLprogram.uniform1i(this.GLtextWidth, this.fontDF.getOpenGlSize().x()); + this.GLprogram.uniform1i(this.GLtextHeight, this.fontDF.getOpenGlSize().x()); + this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord); + this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText); + this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor); + this.GLprogram.sendAttributePointer(this.GLglyphLevel, this.VBO, this.vboIdGlyphLevel); // Request the draw od the elements: - gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); - m_GLprogram->unUse(); + gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord)); + this.GLprogram.unUse(); } -void ewol::compositing::TextDF::loadProgram(const etk::String& _shaderName) { +void ewol::compositing::TextDF::loadProgram( String _shaderName) { ewol::compositing::TextBase::loadProgram(_shaderName); - if (m_GLprogram != null) { - m_GLglyphLevel = m_GLprogram->getAttribute("EW_glyphLevel"); + if (this.GLprogram != null) { + this.GLglyphLevel = this.GLprogram.getAttribute("EW_glyphLevel"); } } float ewol::compositing::TextDF::getHeight() { - if (m_fontDF == null) { - EWOL_WARNING("no font..."); + if (this.fontDF == null) { + Log.warning("no font..."); return 1; } - return m_fontDF->getHeight(m_size); + return this.fontDF.getHeight(this.size); } -ewol::GlyphProperty * ewol::compositing::TextDF::getGlyphPointer(char32_t _charcode) { - if (m_fontDF == null) { - EWOL_WARNING("no font..."); +ewol::GlyphProperty * ewol::compositing::TextDF::getGlyphPointer(Character _charcode) { + if (this.fontDF == null) { + Log.warning("no font..."); return null; } - return m_fontDF->getGlyphPointer(_charcode); + return this.fontDF.getGlyphPointer(_charcode); } -void ewol::compositing::TextDF::setFontSize(int32_t _fontSize) { +void ewol::compositing::TextDF::setFontSize(int _fontSize) { clear(); - Log.verbose("Set font Size: " << _fontSize); + Log.verbose("Set font Size: " + _fontSize); if (_fontSize <= 1) { - m_size = ewol::getContext().getFontDefault().getSize(); + this.size = ewol::getContext().getFontDefault().getSize(); } else { - m_size = _fontSize; + this.size = _fontSize; } } -void ewol::compositing::TextDF::setFontName(const etk::String& _fontName) { +void ewol::compositing::TextDF::setFontName( String _fontName) { clear(); // remove old one - ememory::SharedPtr previousFont = m_fontDF; - etk::String fontName; + ememory::Ptr previousFont = this.fontDF; + String fontName; if (_fontName == "") { fontName = ewol::getContext().getFontDefault().getName(); } else { fontName = _fontName; } - Log.verbose("Set font name: '" << fontName << "'"); + Log.verbose("Set font name: '" + fontName + "'"); // link to new one - m_fontDF = ewol::resource::DistanceFieldFont::create(fontName); - if (m_fontDF == null) { + this.fontDF = ewol::resource::DistanceFieldFont::create(fontName); + if (this.fontDF == null) { Log.error("Can not get find resource"); - m_fontDF = previousFont; + this.fontDF = previousFont; } } -void ewol::compositing::TextDF::setFont(etk::String _fontName, int32_t _fontSize) { +void ewol::compositing::TextDF::setFont(String _fontName, int _fontSize) { setFontSize(_fontSize); setFontName(_fontName); } void ewol::compositing::TextDF::setFontMode(enum ewol::font::mode _mode) { - m_mode = _mode; + this.mode = _mode; } //#define ANGLE_OF_ITALIC (tan(0.4)) #define ANGLE_OF_ITALIC (0.00698143f) -void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { +void ewol::compositing::TextDF::printChar( Character _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode); if (null == myGlyph) { @@ -184,29 +184,29 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { float fontSize = getSize(); float fontHeigh = getHeight(); - float factorDisplay = m_fontDF->getDisplayRatio(fontSize); + float factorDisplay = this.fontDF.getDisplayRatio(fontSize); // get the kerning ofset : float kerningOffset = 0; - if (true == m_kerning) { - kerningOffset = myGlyph->kerningGet(m_previousCharcode); + if (true == this.kerning) { + kerningOffset = myGlyph.kerningGet(this.previousCharcode); if (kerningOffset != 0) { - //Log.debug("Kerning between : '" << m_previousCharcode << "'&'" << myGlyph->m_UVal << "' value : " << kerningOffset); + //Log.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.this.UVal + "' value : " + kerningOffset); } } // 0x01 == 0x20 == ' '; if ( _charcode != 0x01 - && _charcode != 0x20) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _charcode != 0x20) { float glyphLevel = 0.5f; - if ( m_mode == ewol::font::BoldItalic - || m_mode == ewol::font::Bold) { + if ( this.mode == ewol::font::BoldItalic + || this.mode == ewol::font::Bold) { glyphLevel = 0.41f; } float italicMove = 0.0f; - if ( m_mode == ewol::font::BoldItalic - || m_mode == ewol::font::Italic) { + if ( this.mode == ewol::font::BoldItalic + || this.mode == ewol::font::Italic) { // This is a simple version of Italic mode, in theory we need to move the up and the down... - italicMove = (float)myGlyph->m_sizeTexture.y() * factorDisplay * ANGLE_OF_ITALIC; + italicMove = (float)myGlyph.this.sizeTexture.y() * factorDisplay * ANGLE_OF_ITALIC; // TODO : pb on the clipper... } @@ -218,79 +218,79 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { * yD *------* */ #if 0 - float dxA = m_position.x() + (myGlyph->m_bearing.x() + kerningOffset) * factorDisplay; - float dxB = dxA + myGlyph->m_sizeTexture.x() * factorDisplay; - float dyC = m_position.y() + (myGlyph->m_bearing.y() + fontHeigh - fontSize) * factorDisplay; - float dyD = dyC - myGlyph->m_sizeTexture.y() * factorDisplay; + float dxA = this.position.x() + (myGlyph.this.bearing.x() + kerningOffset) * factorDisplay; + float dxB = dxA + myGlyph.this.sizeTexture.x() * factorDisplay; + float dyC = this.position.y() + (myGlyph.this.bearing.y() + fontHeigh - fontSize) * factorDisplay; + float dyD = dyC - myGlyph.this.sizeTexture.y() * factorDisplay; #else - //Log.debug(" plop : fontHeigh" << fontHeigh << " fontSize=" << fontSize); - float dxA = m_position.x() + ((float)myGlyph->m_bearing.x() + kerningOffset - (float)m_fontDF->getPixelBorderSize()*0.5f) * factorDisplay; - float dxB = dxA + ((float)myGlyph->m_sizeTexture.x() + (float)m_fontDF->getPixelBorderSize()) * factorDisplay; - float dyC = m_position.y() + (fontHeigh - fontSize + ((float)myGlyph->m_bearing.y() + (float)m_fontDF->getPixelBorderSize()*0.5f) * factorDisplay); - float dyD = dyC - ((float)myGlyph->m_sizeTexture.y() + (float)m_fontDF->getPixelBorderSize()) * factorDisplay; + //Log.debug(" plop : fontHeigh" + fontHeigh + " fontSize=" + fontSize); + float dxA = this.position.x() + ((float)myGlyph.this.bearing.x() + kerningOffset - (float)this.fontDF.getPixelBorderSize()*0.5f) * factorDisplay; + float dxB = dxA + ((float)myGlyph.this.sizeTexture.x() + (float)this.fontDF.getPixelBorderSize()) * factorDisplay; + float dyC = this.position.y() + (fontHeigh - fontSize + ((float)myGlyph.this.bearing.y() + (float)this.fontDF.getPixelBorderSize()*0.5f) * factorDisplay); + float dyD = dyC - ((float)myGlyph.this.sizeTexture.y() + (float)this.fontDF.getPixelBorderSize()) * factorDisplay; #endif - float tuA = myGlyph->m_texturePosStart.x(); - float tuB = tuA + myGlyph->m_texturePosSize.x(); - float tvC = myGlyph->m_texturePosStart.y(); - float tvD = tvC + myGlyph->m_texturePosSize.y(); + float tuA = myGlyph.this.texturePosStart.x(); + float tuB = tuA + myGlyph.this.texturePosSize.x(); + float tvC = myGlyph.this.texturePosStart.y(); + float tvD = tvC + myGlyph.this.texturePosSize.y(); /* - Vector3f drawingPos = m_vectorialDraw.getPos(); - etk::Color<> backColor = m_vectorialDraw.getColor(); + Vector3f drawingPos = this.vectorialDraw.getPos(); + etk::Color<> backColor = this.vectorialDraw.getColor(); - m_vectorialDraw.setPos(Vector2f(dxA, dyC)); + this.vectorialDraw.setPos(Vector2f(dxA, dyC)); - m_vectorialDraw.setColor(etk::Color<>(0.0,1.0,0.0,1.0)); - m_vectorialDraw.rectangle(Vector2f(dxB, dyD)); + this.vectorialDraw.setColor(etk::Color<>(0.0,1.0,0.0,1.0)); + this.vectorialDraw.rectangle(Vector2f(dxB, dyD)); - m_vectorialDraw.setPos(drawingPos); - m_vectorialDraw.setColor(backColor); + this.vectorialDraw.setPos(drawingPos); + this.vectorialDraw.setColor(backColor); */ // Clipping and drawing area - if( m_clippingEnable == true - && ( dxB < m_clippingPosStart.x() - || dxA > m_clippingPosStop.x() - || dyC < m_clippingPosStart.y() - || dyD > m_clippingPosStop.y() ) ) { + if( this.clippingEnable == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( dxB < this.clippingPosStart.x() + || dxA > this.clippingPosStop.x() + || dyC < this.clippingPosStart.y() + || dyD > this.clippingPosStop.y() ) ) { // Nothing to diplay ... } else { - if (m_clippingEnable == true) { + if (this.clippingEnable == true) { // generata positions... float TexSizeX = tuB - tuA; - if (dxA < m_clippingPosStart.x()) { + if (dxA < this.clippingPosStart.x()) { // clip display - float drawSize = m_clippingPosStart.x() - dxA; + float drawSize = this.clippingPosStart.x() - dxA; // update element start display - dxA = m_clippingPosStart.x(); - float addElement = TexSizeX * drawSize / ((float)myGlyph->m_sizeTexture.x() * factorDisplay); + dxA = this.clippingPosStart.x(); + float addElement = TexSizeX * drawSize / ((float)myGlyph.this.sizeTexture.x() * factorDisplay); // update texture start X Pos tuA += addElement; } - if (dxB > m_clippingPosStop.x()) { + if (dxB > this.clippingPosStop.x()) { // clip display - float drawSize = dxB - m_clippingPosStop.x(); + float drawSize = dxB - this.clippingPosStop.x(); // update element start display - dxB = m_clippingPosStop.x(); - float addElement = TexSizeX * drawSize / ((float)myGlyph->m_sizeTexture.x() * factorDisplay); + dxB = this.clippingPosStop.x(); + float addElement = TexSizeX * drawSize / ((float)myGlyph.this.sizeTexture.x() * factorDisplay); // update texture start X Pos tuB -= addElement; } float TexSizeY = tvC - tvD; - if (dyC > m_clippingPosStop.y()) { + if (dyC > this.clippingPosStop.y()) { // clip display - float drawSize = dyC - m_clippingPosStop.y(); + float drawSize = dyC - this.clippingPosStop.y(); // update element start display - dyC = m_clippingPosStop.y(); - float addElement = TexSizeY * drawSize / ((float)myGlyph->m_sizeTexture.y() * factorDisplay); + dyC = this.clippingPosStop.y(); + float addElement = TexSizeY * drawSize / ((float)myGlyph.this.sizeTexture.y() * factorDisplay); // update texture start X Pos tvC -= addElement; } - if (dyD < m_clippingPosStart.y()) { + if (dyD < this.clippingPosStart.y()) { // clip display - float drawSize = m_clippingPosStart.y() - dyD; + float drawSize = this.clippingPosStart.y() - dyD; // update element start display - dyD = m_clippingPosStart.y(); - float addElement = TexSizeY * drawSize / ((float)myGlyph->m_sizeTexture.y() * factorDisplay); + dyD = this.clippingPosStart.y(); + float addElement = TexSizeY * drawSize / ((float)myGlyph.this.sizeTexture.y() * factorDisplay); // update texture start X Pos tvD += addElement; } @@ -305,7 +305,7 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { * | | * 3------2 */ - if (m_needDisplay == true) { + if (this.needDisplay == true) { Vector3f bitmapDrawPos[4]; bitmapDrawPos[0].setValue(dxA+italicMove, dyC, 0); bitmapDrawPos[1].setValue(dxB+italicMove, dyC, 0); @@ -318,10 +318,10 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { * 3------2 */ Vector2f texturePos[4]; - texturePos[0].setValue(tuA+m_mode, tvC); - texturePos[1].setValue(tuB+m_mode, tvC); - texturePos[2].setValue(tuB+m_mode, tvD); - texturePos[3].setValue(tuA+m_mode, tvD); + texturePos[0].setValue(tuA+this.mode, tvC); + texturePos[1].setValue(tuB+this.mode, tvC); + texturePos[2].setValue(tuB+this.mode, tvD); + texturePos[3].setValue(tuA+this.mode, tvD); // NOTE : Android does not support the Quads elements ... /* Step 1 : @@ -332,21 +332,21 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { * */ // set texture coordonates : - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[1]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[1]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]); // set display positions : - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[1]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[1]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]); // set the color - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); // set the bliph level - m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); - m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); - m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); + this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel); + this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel); + this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel); /* Step 2 : * * ** @@ -355,52 +355,52 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { * ******** */ // set texture coordonates : - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); - m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[3]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]); + this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[3]); // set display positions : - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); - m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[3]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]); + this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[3]); // set the color - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); - m_VBO->pushOnBuffer(m_vboIdColor, m_color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); + this.VBO.pushOnBuffer(this.vboIdColor, this.color); // set the bliph level - m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); - m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); - m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); + this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel); + this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel); + this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel); } } } } // move the position : - //Log.debug(" 5 pos=" << m_position << " advance=" << myGlyph->m_advance.x() << " kerningOffset=" << kerningOffset); - m_position.setX(m_position.x() + (myGlyph->m_advance.x() + kerningOffset) * factorDisplay); - //Log.debug(" 6 print '" << charcode << "' : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); + //Log.debug(" 5 pos=" + this.position + " advance=" + myGlyph.this.advance.x() + " kerningOffset=" + kerningOffset); + this.position.setX(this.position.x() + (myGlyph.this.advance.x() + kerningOffset) * factorDisplay); + //Log.debug(" 6 print '" + charcode + "' : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // Register the previous character - m_previousCharcode = _charcode; - m_VBO->flush(); + this.previousCharcode = _charcode; + this.VBO.flush(); return; } -Vector3f ewol::compositing::TextDF::calculateSizeChar(const char32_t& _charcode) { +Vector3f ewol::compositing::TextDF::calculateSizeChar( Character _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode); - int32_t fontHeigh = getHeight(); + int fontHeigh = getHeight(); // get the kerning ofset : float kerningOffset = 0.0; - if (true == m_kerning) { - kerningOffset = myGlyph->kerningGet(m_previousCharcode); + if (true == this.kerning) { + kerningOffset = myGlyph.kerningGet(this.previousCharcode); } - Vector3f outputSize((float)(myGlyph->m_advance.x() + kerningOffset)*m_fontDF->getDisplayRatio(getSize()), + Vector3f outputSize((float)(myGlyph.this.advance.x() + kerningOffset)*this.fontDF.getDisplayRatio(getSize()), (float)(fontHeigh), (float)(0.0)); // Register the previous character - m_previousCharcode = _charcode; + this.previousCharcode = _charcode; return outputSize; } diff --git a/src/org/atriasoft/ewol/compositing/TextDF.java b/src/org/atriasoft/ewol/compositing/TextDF.java index 16daf9e..636e598 100644 --- a/src/org/atriasoft/ewol/compositing/TextDF.java +++ b/src/org/atriasoft/ewol/compositing/TextDF.java @@ -19,50 +19,50 @@ namespace ewol { namespace compositing { class TextDF : public ewol::compositing::TextBase { protected: - ememory::SharedPtr m_fontDF; //!< Font resources + ememory::Ptr this.fontDF; //!< Font resources protected: - int32_t m_GLglyphLevel; //!< openGL Id on the glyph level display + int this.GLglyphLevel; //!< openGL Id on the glyph level display public: /** - * @brief generic constructor + * @brief generic ructor * @param[in] _fontName Name of the font that might be loaded * @param[in] _fontSize size of the font that might be loaded */ - TextDF(const etk::String& _fontName="", int32_t _fontSize=-1); + TextDF( String _fontName="", int _fontSize=-1); /** * @brief generic destructor */ - virtual ~TextDF(); + ~TextDF(); public: /** * @brief Calculate size to be at the best size for a render in this special size. * @note special for Distance field mode. * @param[in] _size request dimention. */ - void updateSizeToRender(const Vector2f& _size); + void updateSizeToRender( Vector2f _size); public: - virtual void drawD(bool _disableDepthTest); - virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest); + void drawD(boolean _disableDepthTest); + void drawMT( mat4 _transformationMatrix, boolean _enableDepthTest); protected: - float m_size; + float this.size; public: - virtual float getHeight(); - virtual float getSize() { - return m_size; + float getHeight(); + float getSize() { + return this.size; } - virtual void setSize(float _size) { - m_size = _size; + void setSize(float _size) { + this.size = _size; } - virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode); + ewol::GlyphProperty * getGlyphPointer(Character _charcode); public: - virtual void loadProgram(const etk::String& _shaderName); - virtual void setFontSize(int32_t _fontSize); - virtual void setFontName(const etk::String& _fontName); - virtual void setFont(etk::String _fontName, int32_t _fontSize); - virtual void setFontMode(enum ewol::font::mode _mode); - virtual void printChar(const char32_t& _charcode); - virtual Vector3f calculateSizeChar(const char32_t& _charcode); + void loadProgram( String _shaderName); + void setFontSize(int _fontSize); + void setFontName( String _fontName); + void setFont(String _fontName, int _fontSize); + void setFontMode(enum ewol::font::mode _mode); + void printChar( Character _charcode); + Vector3f calculateSizeChar( Character _charcode); }; } } diff --git a/src/org/atriasoft/ewol/context/Application.cpp b/src/org/atriasoft/ewol/context/Application.cpp index cbc08b3..ff6843c 100644 --- a/src/org/atriasoft/ewol/context/Application.cpp +++ b/src/org/atriasoft/ewol/context/Application.cpp @@ -9,41 +9,41 @@ #include #include -ETK_DECLARE_TYPE(ewol::context::Application); +ETK_DECLARE_TYPE(EwolApplication); -ewol::context::Application::Application() { +EwolApplication::Application() { } -ewol::context::Application::~Application() { +EwolApplication::~Application() { } -void ewol::context::Application::onCreate(ewol::Context& _context) { +void EwolApplication::onCreate(EwolContext _context) { } -void ewol::context::Application::onStart(ewol::Context& _context) { +void EwolApplication::onStart(EwolContext _context) { } -void ewol::context::Application::onResume(ewol::Context& _context) { +void EwolApplication::onResume(EwolContext _context) { } -void ewol::context::Application::onPause(ewol::Context& _context) { +void EwolApplication::onPause(EwolContext _context) { } -void ewol::context::Application::onStop(ewol::Context& _context) { +void EwolApplication::onStop(EwolContext _context) { } -void ewol::context::Application::onDestroy(ewol::Context& _context) { +void EwolApplication::onDestroy(EwolContext _context) { } -void ewol::context::Application::onKillDemand(ewol::Context& _context) { +void EwolApplication::onKillDemand(EwolContext _context) { _context.exit(0); } diff --git a/src/org/atriasoft/ewol/context/Application.java b/src/org/atriasoft/ewol/context/Application.java deleted file mode 100644 index 0dacf17..0000000 --- a/src/org/atriasoft/ewol/context/Application.java +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#pragma once - -namespace ewol { - class Context; - namespace context { - class Application { - public: - Application(); - virtual ~Application(); - public: - /** - * @brief The application is created. - * @param[in] _context Current ewol context. - */ - virtual void onCreate(ewol::Context& _context); - /** - * @brief The application is started. - * @param[in] _context Current ewol context. - */ - virtual void onStart(ewol::Context& _context); - /** - * @brief The application is resumed (now visible). - * @param[in] _context Current ewol context. - */ - virtual void onResume(ewol::Context& _context); - /** - * @brief The application is Hide / not visible. - * @param[in] _context Current ewol context. - */ - virtual void onPause(ewol::Context& _context); - /** - * @brief The application is stopped. - * @param[in] _context Current ewol context. - */ - virtual void onStop(ewol::Context& _context); - /** - * @brief The application is removed (call destructor just adter it.). - * @param[in] _context Current ewol context. - */ - virtual void onDestroy(ewol::Context& _context); - /** - * @brief The user request application removing. - * @param[in] _context Current ewol context. - */ - virtual void onKillDemand(ewol::Context& _context); - }; - }; -}; diff --git a/src/org/atriasoft/ewol/context/ConfigFont.cpp b/src/org/atriasoft/ewol/context/ConfigFont.cpp index 34ce697..c0aa5be 100644 --- a/src/org/atriasoft/ewol/context/ConfigFont.cpp +++ b/src/org/atriasoft/ewol/context/ConfigFont.cpp @@ -7,37 +7,37 @@ #include #include #include -ETK_DECLARE_TYPE(ewol::context::ConfigFont); +ETK_DECLARE_TYPE(ConfigFont); -ewol::context::ConfigFont::ConfigFont() : - m_folder("DATA:///fonts?lib=ewol"), - m_name("Arial;Helvetica"), - m_size(10), - m_useExternal(false) { +ConfigFont::ConfigFont() : + this.folder("DATA:///fonts?lib=ewol"), + this.name("Arial;Helvetica"), + this.size(10), + this.useExternal(false) { #ifdef __TARGET_OS__Android - m_name = "Roboto;DroidSans"; + this.name = "Roboto;DroidSans"; #endif ewol::resource::freeTypeInit(); } -ewol::context::ConfigFont::~ConfigFont() { +ConfigFont::~ConfigFont() { // UnInit FreeTypes ewol::resource::freeTypeUnInit(); } -void ewol::context::ConfigFont::set(const etk::String& _fontName, int32_t _size) { - m_name = _fontName; - m_size = _size; - Log.debug("Set default Font : '" << m_name << "' size=" << m_size); +void ConfigFont::set( String _fontName, int _size) { + this.name = _fontName; + this.size = _size; + Log.debug("Set default Font : '" + this.name + "' size=" + this.size); } -void ewol::context::ConfigFont::setSize(int32_t _size) { - m_size = _size; - Log.debug("Set default Font : '" << m_name << "' size=" << m_size << " (change size only)"); +void ConfigFont::setSize(int _size) { + this.size = _size; + Log.debug("Set default Font : '" + this.name + "' size=" + this.size + " (change size only)"); } -void ewol::context::ConfigFont::setName(const etk::String& _fontName) { - m_name = _fontName; - Log.debug("Set default Font : '" << m_name << "' size=" << m_size << " (change name only)"); +void ConfigFont::setName( String _fontName) { + this.name = _fontName; + Log.debug("Set default Font : '" + this.name + "' size=" + this.size + " (change name only)"); } diff --git a/src/org/atriasoft/ewol/context/ConfigFont.java b/src/org/atriasoft/ewol/context/ConfigFont.java index 837d696..e3f2232 100644 --- a/src/org/atriasoft/ewol/context/ConfigFont.java +++ b/src/org/atriasoft/ewol/context/ConfigFont.java @@ -16,74 +16,74 @@ namespace ewol { * Constructor / destructor */ ConfigFont(); - virtual ~ConfigFont(); + ~ConfigFont(); private: - etk::Uri m_folder; + etk::Uri this.folder; public: /** * @brief Specify the default font folder for the Ewol search system (only needed when embended font) * @param[in] _folder basic folder of the font (ex: DATA:fonts) */ - void setFolder(const etk::Uri& _folder) { - m_folder = _folder; + void setFolder( etk::Uri _folder) { + this.folder = _folder; }; /** * @brief get the default font folder. * @return The default font folder. */ - const etk::Uri& getFolder() { - return m_folder; + etk::Uri getFolder() { + return this.folder; }; private: - etk::String m_name; - int32_t m_size; + String this.name; + int this.size; public: /** * @brief set the defaut font for all the widgets and basics display. * @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica". * @param[in] _size The default size of the font default=10. */ - void set(const etk::String& _fontName, int32_t _size); + void set( String _fontName, int _size); /** * @brief get the current default font name * @raturn a reference on the font name string */ - const etk::String& getName() { - return m_name; + String getName() { + return this.name; }; /** * @brief Set the current default font name * @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica". */ - void setName(const etk::String& _fontName); + void setName( String _fontName); /** * @brief get the default font size. * @return the font size. */ - int32_t getSize() { - return m_size; + int getSize() { + return this.size; }; /** * @brief Set the default font size. * @param[in] _size new font size. */ - void setSize(int32_t _size); + void setSize(int _size); private: - bool m_useExternal; + boolean this.useExternal; public: /** * @brief set use of internal/external Font * @param[in] _val true to enable search of internal data. */ - void setUseExternal(bool _val) { - m_useExternal=_val; + void setUseExternal(boolean _val) { + this.useExternal=_val; }; /** * @brief get the use of internal/external Font * @return true to enable search of internal data. */ - bool getUseExternal() { - return m_useExternal; + boolean getUseExternal() { + return this.useExternal; }; }; }; diff --git a/src/org/atriasoft/ewol/context/Context.cpp b/src/org/atriasoft/ewol/context/Context.cpp index f761fbd..eafca84 100644 --- a/src/org/atriasoft/ewol/context/Context.cpp +++ b/src/org/atriasoft/ewol/context/Context.cpp @@ -1,382 +1,57 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#include -#include -#include -#include +void EwolContext::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -ETK_DECLARE_TYPE(ewol::Context); - -static ewol::Context* l_curentInterface=null; -ewol::Context& ewol::getContext() { - gale::Context& context = gale::getContext(); - ememory::SharedPtr appl = context.getApplication(); - if (appl == null) { - Log.critical("[CRITICAL] try acces at an empty GALE application (can not get Context)"); - // ??? - } - return *(ememory::staticPointerCast(appl)); -} - - -void ewol::Context::setInitImage(const etk::Uri& _fileName) { - //m_initDisplayImageName = _fileName; -} - - - -void ewol::Context::inputEventTransfertWidget(ewol::WidgetShared _source, - ewol::WidgetShared _destination) { - m_input.transfertEvent(_source, _destination); -} - - -void ewol::Context::inputEventGrabPointer(ewol::WidgetShared _widget) { - m_input.grabPointer(_widget); -} - -void ewol::Context::inputEventUnGrabPointer() { - m_input.unGrabPointer(); -} - - -void ewol::Context::onCreate(gale::Context& _context) { - Log.info(" == > Ewol system create (BEGIN)"); - // Add basic ewol translation: - etranslate::addPath("ewol", "DATA:///translate/ewol/?lib=ewol"); - etranslate::autoDetectLanguage(); - // By default we set 2 themes (1 color and 1 shape ...) : - etk::theme::setNameDefault("GUI", "shape/square/"); - etk::theme::setNameDefault("COLOR", "color/black/"); - // parse for help: - for(int32_t iii = 0; iii < _context.getCmd().size() ; ++iii) { - if ( _context.getCmd().get(iii) == "-h" - || _context.getCmd().get(iii) == "--help") { - Log.print("ewol - help : "); - Log.print(" " << etk::getApplicationName() << " [options]"); - Log.print(" -h/--help: Display this help"); - Log.print(" example:"); - Log.print(" " << etk::getApplicationName() << " --help"); - // this is a global help system does not remove it - continue; - } else { - continue; - } - _context.getCmd().remove(iii); - --iii; - } - - Log.info("EWOL v:" << ewol::getVersion()); - // force a recalculation - /* - requestUpdateSize(); - #if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__) - forceOrientation(ewol::screenLandscape); - #elif defined(__EWOL_ANDROID_ORIENTATION_PORTRAIT__) - forceOrientation(ewol::screenPortrait); - #else - forceOrientation(ewol::screenAuto); - #endif - */ - ememory::SharedPtr appl = m_application; - if (appl == null) { - Log.error(" == > Create without application"); - return; - } - appl->onCreate(*this); - Log.info(" == > Ewol system create (END)"); -} - -void ewol::Context::onStart(gale::Context& _context) { - Log.info(" == > Ewol system start (BEGIN)"); - ememory::SharedPtr appl = m_application; - if (appl == null) { - // TODO : Request exit of the application .... with error ... - return; - } - appl->onStart(*this); - Log.info(" == > Ewol system start (END)"); -} - -void ewol::Context::onResume(gale::Context& _context) { - Log.info(" == > Ewol system resume (BEGIN)"); - ememory::SharedPtr appl = m_application; - if (appl == null) { - return; - } - appl->onResume(*this); - Log.info(" == > Ewol system resume (END)"); -} - -void ewol::Context::onRegenerateDisplay(gale::Context& _context) { - //Log.info("REGENERATE_DISPLAY"); - // check if the user selected a windows - ewol::widget::WindowsShared window = m_windowsCurrent; - if (window == null) { - Log.debug("No windows ..."); - return; - } - // Redraw all needed elements - window->onRegenerateDisplay(); - if (m_widgetManager.isDrawingNeeded() == true) { - markDrawingIsNeeded(); - } - //markDrawingIsNeeded(); -} - -void ewol::Context::onDraw(gale::Context& _context) { - //Log.info("DRAW"); - // clean internal data... - m_objectManager.cleanInternalRemoved(); - // real draw... - ewol::widget::WindowsShared window = m_windowsCurrent; - if (window == null) { - return; - } - window->sysDraw(); -} - -void ewol::Context::onPause(gale::Context& _context) { - Log.info(" == > Ewol system pause (BEGIN)"); - ememory::SharedPtr appl = m_application; - if (appl == null) { - return; - } - appl->onPause(*this); - Log.info(" == > Ewol system pause (END)"); -} - -void ewol::Context::onStop(gale::Context& _context) { - Log.info(" == > Ewol system stop (BEGIN)"); - ememory::SharedPtr appl = m_application; - if (appl == null) { - return; - } - appl->onStop(*this); - Log.info(" == > Ewol system stop (END)"); -} - -void ewol::Context::onDestroy(gale::Context& _context) { - Log.info(" == > Ewol system destroy (BEGIN)"); - // Remove current windows - m_windowsCurrent.reset(); - // clean all widget and sub widget with their resources: - m_objectManager.cleanInternalRemoved(); - ememory::SharedPtr appl = m_application; - if (appl != null) { - // call application to uninit - appl->onDestroy(*this); - m_application.reset(); - } - // internal clean elements - m_objectManager.cleanInternalRemoved(); - Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing"); - m_objectManager.displayListObject(); - // now All must be removed !!! - m_objectManager.unInit(); - Log.info(" == > Ewol system destroy (END)"); -} - -void ewol::Context::onKillDemand(gale::Context& _context) { - Log.info(" == > User demand a destroy (BEGIN)"); - ememory::SharedPtr appl = m_application; - if (appl == null) { - exit(0); - return; - } - appl->onKillDemand(*this); - Log.info(" == > User demand a destroy (END)"); -} - -void ewol::Context::onPointer(enum gale::key::type _type, - int32_t _pointerID, - const Vector2f& _pos, - gale::key::status _state) { - switch (_state) { - case gale::key::status::move: - //Log.debug("Receive MSG : THREAD_INPUT_MOTION"); - m_input.motion(_type, _pointerID, _pos); - break; - case gale::key::status::down: - case gale::key::status::downRepeate: - //Log.debug("Receive MSG : THREAD_INPUT_STATE"); - m_input.state(_type, _pointerID, true, _pos); - break; - case gale::key::status::up: - //Log.debug("Receive MSG : THREAD_INPUT_STATE"); - m_input.state(_type, _pointerID, false, _pos); - break; - default: - Log.debug("Unknow state : " << _state); - break; - } -} -void ewol::Context::onKeyboard(const gale::key::Special& _special, - enum gale::key::keyboard _type, - char32_t _value, - gale::key::status _state) { - Log.verbose("event {" << _special << "} " << _type << " " << _value << " " << _state); - // store the keyboard special key status for mouse event... - m_input.setLastKeyboardSpecial(_special); - if (m_windowsCurrent == null) { - // No windows ... - return; - } - bool repeate = (_state == gale::key::status::downRepeate); - bool isDown = (_state == gale::key::status::downRepeate) - || (_state == gale::key::status::down); - if (m_windowsCurrent->onEventShortCut(_special, - _value, - _type, - isDown) == true) { - // Keep a shortcut ... - return; - } - // get the current focused Widget : - ewol::WidgetShared tmpWidget = m_widgetManager.focusGet(); - if (tmpWidget == null) { - // no Widget ... - return; - } - // check if the widget allow repeating key events. - //Log.info("repeating test :" << repeate << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << isDown); - if( repeate == false - || ( repeate == true - && tmpWidget->getKeyboardRepeat() == true) ) { - // check Widget shortcut - if (tmpWidget->onEventShortCut(_special, - _value, - _type, - isDown) == false) { - // generate the direct event ... - if (_type == gale::key::keyboard::character) { - ewol::event::EntrySystem tmpEntryEvent(gale::key::keyboard::character, - gale::key::status::up, - _special, - _value); - if(isDown == true) { - tmpEntryEvent.m_event.setStatus(gale::key::status::down); - } - tmpWidget->systemEventEntry(tmpEntryEvent); - } else { // THREAD_KEYBORAD_MOVE - ewol::event::EntrySystem tmpEntryEvent(_type, - gale::key::status::up, - _special, - 0); - if(isDown == true) { - tmpEntryEvent.m_event.setStatus(gale::key::status::down); - } - tmpWidget->systemEventEntry(tmpEntryEvent); - } - } else { - Log.debug("remove Repeate key ..."); - } - } -} - -/* -void ewol::Context::processEvents() { - case eSystemMessage::msgResize: - //Log.debug("Receive MSG : THREAD_RESIZE"); - m_windowsSize = data->dimention; - ewol::Dimension::setPixelWindowsSize(m_windowsSize); - forceRedrawAll(); - break; -*/ - -void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) { - ewol::WidgetShared tmpWidget = m_widgetManager.focusGet(); - if (tmpWidget != null) { - tmpWidget->onEventClipboard(_clipboardId); - } -} - - -ewol::Context::Context(ewol::context::Application* _application) : - //m_application(ememory::makeShared(_application)), - m_application(_application), - m_objectManager(*this), - m_input(*this), - m_windowsCurrent(null), - m_initStepId(0) { - if (m_application == null) { - Log.critical("Can not start context with no Application ==> rtfm ..."); - } -} - -ewol::Context::~Context() { +EwolContext::Context(EwolApplication* _application) : +EwolContext::~Context() { // nothing to do ... } -void ewol::Context::requestUpdateSize() { - gale::Context& context = gale::getContext(); +void EwolContext::requestUpdateSize() { + Context context = gale::getContext(); context.requestUpdateSize(); } -void ewol::Context::onPeriod(const echrono::Clock& _time) { - m_objectManager.timeCall(_time); +void EwolContext::onPeriod( echrono::Clock _time) { + this.objectManager.timeCall(_time); } -void ewol::Context::resetIOEvent() { - m_input.newLayerSet(); +void EwolContext::resetIOEvent() { + this.input.newLayerSet(); } -void ewol::Context::setWindows(const ewol::widget::WindowsShared& _windows) { +void EwolContext::setWindows( ewol::widget::WindowsShared _windows) { Log.info("set New windows"); // remove current focus : - m_widgetManager.focusSetDefault(null); - m_widgetManager.focusRelease(); + this.widgetManager.focusSetDefault(null); + this.widgetManager.focusRelease(); // set the new pointer as windows system - m_windowsCurrent = _windows; + this.windowsCurrent = _windows; // set the new default focus: - m_widgetManager.focusSetDefault(_windows); + this.widgetManager.focusSetDefault(_windows); // display the title of the Windows: - if (m_windowsCurrent != null) { - setTitle(m_windowsCurrent->propertyTitle.get()); + if (this.windowsCurrent != null) { + setTitle(this.windowsCurrent.propertyTitle.get()); } // request all the widget redrawing forceRedrawAll(); } -ewol::widget::WindowsShared ewol::Context::getWindows() { - return m_windowsCurrent; +ewol::widget::WindowsShared EwolContext::getWindows() { + return this.windowsCurrent; }; -void ewol::Context::onResize(const Vector2i& _size) { - Log.verbose("Resize: " << _size); +void EwolContext::onResize( Vector2i _size) { + Log.verbose("Resize: " + _size); forceRedrawAll(); } -void ewol::Context::forceRedrawAll() { - if (m_windowsCurrent == null) { +void EwolContext::forceRedrawAll() { + if (this.windowsCurrent == null) { return; } Vector2i size = getSize(); - m_windowsCurrent->setSize(Vector2f(size.x(), size.y())); - m_windowsCurrent->onChangeSize(); + this.windowsCurrent.setSize(Vector2f(size.x(), size.y())); + this.windowsCurrent.onChangeSize(); } diff --git a/src/org/atriasoft/ewol/context/Context.java b/src/org/atriasoft/ewol/context/Context.java deleted file mode 100644 index b0f1f9e..0000000 --- a/src/org/atriasoft/ewol/context/Context.java +++ /dev/null @@ -1,159 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ewol { - // Here we hereted from the gale application to be agnostic of the OW where we work ... - class Context : public gale::Application { - private: - ememory::SharedPtr m_application; //!< Application handle - public: - ememory::SharedPtr getApplication() { - return m_application; - } - public: - gale::context::CommandLine& getCmd() { - return gale::getContext().getCmd(); - }; - private: - ewol::context::ConfigFont m_configFont; //!< global font configuration - public: - ewol::context::ConfigFont& getFontDefault() { - return m_configFont; - }; - private: - ewol::object::Manager m_objectManager; //!< Object Manager main instance - public: - ewol::object::Manager& getEObjectManager() { - return m_objectManager; - }; - private: - ewol::widget::Manager m_widgetManager; //!< global widget manager - public: - ewol::widget::Manager& getWidgetManager() { - return m_widgetManager; - }; - public: - gale::resource::Manager& getResourcesManager() { - return gale::getContext().getResourcesManager(); - }; - public: - Context(ewol::context::Application* _application); - virtual ~Context(); - private: - ewol::context::InputManager m_input; - public: // herited function: - void onCreate(gale::Context& _context) override; - void onStart(gale::Context& _context) override; - void onResume(gale::Context& _context) override; - void onRegenerateDisplay(gale::Context& _context) override; - void onDraw(gale::Context& _context) override; - void onPause(gale::Context& _context) override; - void onStop(gale::Context& _context) override; - void onDestroy(gale::Context& _context) override; - void onKillDemand(gale::Context& _context) override; - void onPointer(enum gale::key::type _type, - int32_t _pointerID, - const Vector2f& _pos, - gale::key::status _state) override; - void onKeyboard(const gale::key::Special& _special, - enum gale::key::keyboard _type, - char32_t _value, - gale::key::status _state) override; - void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) override; - public: - /** - * @brief reset event management for the IO like Input ou Mouse or keyborad - */ - void resetIOEvent(); - private: - ewol::widget::WindowsShared m_windowsCurrent; //!< curent displayed windows - public: - /** - * @brief set the current windows to display : - * @param _windows Windows that might be displayed - */ - void setWindows(const ewol::widget::WindowsShared& _windows); - /** - * @brief get the current windows that is displayed - * @return the current handle on the windows (can be null) - */ - ewol::widget::WindowsShared getWindows(); - - /** - * @brief Redraw all the windows - */ - void forceRedrawAll(); - - /** - * @brief This is to transfert the event from one widget to another one - * @param source the widget where the event came from - * @param destination the widget where the event mitgh be generated now - */ - void inputEventTransfertWidget(ewol::WidgetShared _source, ewol::WidgetShared _destination); - /** - * @brief This fonction lock the pointer properties to move in relative instead of absolute - * @param[in] widget The widget that lock the pointer events - */ - void inputEventGrabPointer(ewol::WidgetShared _widget); - /** - * @brief This fonction un-lock the pointer properties to move in relative instead of absolute - */ - void inputEventUnGrabPointer(); - void onResize(const Vector2i& _size) override; - public: - /** - * @brief This is the only one things the User might done in his main(); - * @note : must be implemented in all system OPS implementation - * @note To answare you before you ask the question, this is really simple: - * Due to the fect that the current system is multiple-platform, you "main" - * Does not exist in the android platform, then ewol call other start - * and stop function, to permit to have only one code - * @note The main can not be in the ewol, due to the fact thet is an librairy - * @param[in] _argc Standard argc - * @param[in] _argv Standard argv - * @return normal error int for the application error management - */ - static int main(int _argc, const char *_argv[]); - private: - size_t m_initStepId; - size_t m_initTotalStep; - public: - /** - * @brief Special for init (main) set the start image when loading data - * @param[in] _fileName Name of the image to load - */ - void setInitImage(const etk::Uri& _fileName); - public: - /** - * @brief Request a display after call a resize - */ - void requestUpdateSize(); - void onPeriod(const echrono::Clock& _time) override; - }; - /** - * @brief From everyware in the program, we can get the context inteface. - * @return current reference on the instance. - */ - Context& getContext(); -}; - diff --git a/src/org/atriasoft/ewol/context/EwolApplication.java b/src/org/atriasoft/ewol/context/EwolApplication.java new file mode 100644 index 0000000..db923af --- /dev/null +++ b/src/org/atriasoft/ewol/context/EwolApplication.java @@ -0,0 +1,53 @@ +package org.atriasoft.ewol.context; + +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +public interface EwolApplication { + /** + * @brief The application is created. + * @param[in] _context Current ewol context. + */ + void onCreate(EwolContext _context); + + /** + * @brief The application is removed (call destructor just adter it.). + * @param[in] _context Current ewol context. + */ + void onDestroy(EwolContext _context); + + /** + * @brief The user request application removing. + * @param[in] _context Current ewol context. + */ + default void onKillDemand(final EwolContext _context) { + _context.exit(0); + } + + /** + * @brief The application is Hide / not visible. + * @param[in] _context Current ewol context. + */ + void onPause(EwolContext _context); + + /** + * @brief The application is resumed (now visible). + * @param[in] _context Current ewol context. + */ + void onResume(EwolContext _context); + + /** + * @brief The application is started. + * @param[in] _context Current ewol context. + */ + void onStart(EwolContext _context); + + /** + * @brief The application is stopped. + * @param[in] _context Current ewol context. + */ + void onStop(EwolContext _context); +} \ No newline at end of file diff --git a/src/org/atriasoft/ewol/context/EwolContext.java b/src/org/atriasoft/ewol/context/EwolContext.java new file mode 100644 index 0000000..b8bc932 --- /dev/null +++ b/src/org/atriasoft/ewol/context/EwolContext.java @@ -0,0 +1,430 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +package org.atriasoft.ewol.context; + +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.ewol.internal.Log; +import org.atriasoft.ewol.object.ObjectManager; +import org.atriasoft.ewol.widget.WidgetManager; +import org.atriasoft.gale.Application; +import org.atriasoft.gale.Gale; +import org.atriasoft.gale.context.ClipboardList; +import org.atriasoft.gale.context.CommandLine; +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.gale.key.KeyType; +import org.atriasoft.gale.resource.ResourceManager; + +// Here we hereted from the gale application to be agnostic of the OW where we work ... +public abstract class EwolContext extends Application { + private static EwolContext curentInterface = null; + + /** + * @brief From everyware in the program, we can get the context inteface. + * @return current reference on the instance. + */ + static EwolContext getContext() { + return curentInterface; + } + + private final EwolApplication application; //!< Application handle + + public EwolApplication getApplication() { + return this.application; + } + + public CommandLine getCmd() { + return Gale.getContext().getCmd(); + } + + private ConfigFont configFont; //!< global font configuration + + public ConfigFont getFontDefault() { + return this.configFont; + } + + private final ObjectManager objectManager; //!< Object Manager main instance + + public ObjectManager getEObjectManager() { + return this.objectManager; + } + + private WidgetManager widgetManager; //!< global widget manager + + public WidgetManager getWidgetManager() { + return this.widgetManager; + } + + public ResourceManager getResourcesManager() { + return Gale.getContext().getResourcesManager(); + } + + public EwolContext(final EwolApplication _application) { + this.application = _application; + this.objectManager = new ObjectManager(this); + this.input = new InputManager(this); + if (this.application == null) { + Log.critical("Can not start context with no Application ==> rtfm ..."); + } + } + + private final InputManager input; + + public void onCreate(final Context _context) { + Log.info(" == > Ewol system create (BEGIN)"); + // Add basic ewol translation: + etranslate::addPath("ewol", "DATA:///translate/ewol/?lib=ewol"); + etranslate::autoDetectLanguage(); + // By default we set 2 themes (1 color and 1 shape ...) : + etk::theme::setNameDefault("GUI", "shape/square/"); + etk::theme::setNameDefault("COLOR", "color/black/"); + // parse for help: + for(int iii = 0; iii < _context.getCmd().size() ; ++iii) { + if ( _context.getCmd().get(iii) == "-h" + || _context.getCmd().get(iii) == "--help") { + Log.print("ewol - help : "); + Log.print(" " + etk::getApplicationName() + " [options]"); + Log.print(" -h/--help: Display this help"); + Log.print(" example:"); + Log.print(" " + etk::getApplicationName() + " --help"); + // this is a global help system does not remove it + continue; + } else { + continue; + } + _context.getCmd().remove(iii); + --iii; + } + + Log.info("EWOL v:" + ewol::getVersion()); + // force a recalculation + /* + requestUpdateSize(); + #if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__) + forceOrientation(ewol::screenLandscape); + #elif defined(__EWOL_ANDROID_ORIENTATION_PORTRAIT__) + forceOrientation(ewol::screenPortrait); + #else + forceOrientation(ewol::screenAuto); + #endif + */ + EwolApplication appl = this.application; + if (appl == null) { + Log.error(" == > Create without application"); + return; + } + appl.onCreate(*this); + Log.info(" == > Ewol system create (END)"); + } + + public abstract void onStart(final Context _context) { + Log.info(" == > Ewol system start (BEGIN)"); + EwolApplication appl = this.application; + if (appl == null) { + // TODO : Request exit of the application .... with error ... + return; + } + appl.onStart(*this); + Log.info(" == > Ewol system start (END)"); + } + + public abstract void onResume(final Context _context){ + Log.info(" == > Ewol system resume (BEGIN)"); + EwolApplication appl = this.application; + if (appl == null) { + return; + } + appl.onResume(*this); + Log.info(" == > Ewol system resume (END)"); + } + + public abstract void onRegenerateDisplay(final Context _context) { + //Log.info("REGENERATE_DISPLAY"); + // check if the user selected a windows + ewol::widget::WindowsShared window = this.windowsCurrent; + if (window == null) { + Log.debug("No windows ..."); + return; + } + // Redraw all needed elements + window.onRegenerateDisplay(); + if (this.widgetManager.isDrawingNeeded() == true) { + markDrawingIsNeeded(); + } + //markDrawingIsNeeded(); + } + + public abstract void onDraw(final Context _context) { + //Log.info("DRAW"); + // clean internal data... + this.objectManager.cleanInternalRemoved(); + // real draw... + ewol::widget::WindowsShared window = this.windowsCurrent; + if (window == null) { + return; + } + window.sysDraw(); + } + + public abstract void onPause(final Context _context){ + Log.info(" == > Ewol system pause (BEGIN)"); + EwolApplication appl = this.application; + if (appl == null) { + return; + } + appl.onPause(*this); + Log.info(" == > Ewol system pause (END)"); + } + + public abstract void onStop(final Context _context){ + Log.info(" == > Ewol system stop (BEGIN)"); + EwolApplication appl = this.application; + if (appl == null) { + return; + } + appl.onStop(*this); + Log.info(" == > Ewol system stop (END)"); + } + + public abstract void onDestroy(final Context _context){ + Log.info(" == > Ewol system destroy (BEGIN)"); + // Remove current windows + this.windowsCurrent.reset(); + // clean all widget and sub widget with their resources: + this.objectManager.cleanInternalRemoved(); + EwolApplication appl = this.application; + if (appl != null) { + // call application to uninit + appl.onDestroy(*this); + this.application.reset(); + } + // internal clean elements + this.objectManager.cleanInternalRemoved(); + Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing"); + this.objectManager.displayListObject(); + // now All must be removed !!! + this.objectManager.unInit(); + Log.info(" == > Ewol system destroy (END)"); + } + + public abstract void onKillDemand(final Context _context){ + Log.info(" == > User demand a destroy (BEGIN)"); + EwolApplication appl = this.application; + if (appl == null) { + exit(0); + return; + } + appl.onKillDemand(*this); + Log.info(" == > User demand a destroy (END)"); + } + + public abstract void onPointer(final KeyType _type, final int _pointerID, final Vector2f _pos, final KeyStatus _state) { + switch (_state) { + case KeyStatus::move: + //Log.debug("Receive MSG : THREAD_INPUT_MOTION"); + this.input.motion(_type, _pointerID, _pos); + break; + case KeyStatus::down: + case KeyStatus::downRepeate: + //Log.debug("Receive MSG : THREAD_INPUT_STATE"); + this.input.state(_type, _pointerID, true, _pos); + break; + case KeyStatus::up: + //Log.debug("Receive MSG : THREAD_INPUT_STATE"); + this.input.state(_type, _pointerID, false, _pos); + break; + default: + Log.debug("Unknow state : " + _state); + break; + } + } + + @Override + public abstract void onKeyboard(final KeySpecial _special, final KeyKeyboard _type, final Character _value, final KeyStatus _state) { + Log.verbose("event {" + _special + "} " + _type + " " + _value + " " + _state); + // store the keyboard special key status for mouse event... + this.input.setLastKeyboardSpecial(_special); + if (this.windowsCurrent == null) { + // No windows ... + return; + } + boolean repeate = (_state == KeyStatus::downRepeate); + boolean isDown = (_state == KeyStatus::downRepeate) + || (_state == KeyStatus::down); + if (this.windowsCurrent.onEventShortCut(_special, + _value, + _type, + isDown) == true) { + // Keep a shortcut ... + return; + } + // get the current focused Widget : + Widget tmpWidget = this.widgetManager.focusGet(); + if (tmpWidget == null) { + // no Widget ... + return; + } + // check if the widget allow repeating key events. + //Log.info("repeating test :" + repeate + " widget=" + tmpWidget.getKeyboardRepeate() + " state=" + isDown); + if( repeate == false + || ( repeate == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpWidget.getKeyboardRepeat() == true) ) { + // check Widget shortcut + if (tmpWidget.onEventShortCut(_special, + _value, + _type, + isDown) == false) { + // generate the direct event ... + if (_type == KeyKeyboard::character) { + ewol::event::EntrySystem tmpEntryEvent(KeyKeyboard::character, + KeyStatus::up, + _special, + _value); + if(isDown == true) { + tmpEntryEvent.this.event.setStatus(KeyStatus::down); + } + tmpWidget.systemEventEntry(tmpEntryEvent); + } else { // THREAD_KEYBORAD_MOVE + ewol::event::EntrySystem tmpEntryEvent(_type, + KeyStatus::up, + _special, + 0); + if(isDown == true) { + tmpEntryEvent.this.event.setStatus(KeyStatus::down); + } + tmpWidget.systemEventEntry(tmpEntryEvent); + } + } else { + Log.debug("remove Repeate key ..."); + } + } + } + + @Override + public void onClipboardEvent(final ClipboardList _clipboardId) { + final Widget tmpWidget = this.widgetManager.focusGet(); + if (tmpWidget != null) { + tmpWidget.onEventClipboard(_clipboardId); + } + } + + /** + * @brief reset event management for the IO like Input ou Mouse or keyborad + */ + public void resetIOEvent() { + this.input.newLayerSet(); + } + + private final Windows windowsCurrent = null; //!< current displayed windows + + /** + * @brief set the current windows to display : + * @param _windows Windows that might be displayed + */ + public void setWindows(final Windows _windows) { + Log.info("set New windows"); + // remove current focus : + this.widgetManager.focusSetDefault(null); + this.widgetManager.focusRelease(); + // set the new pointer as windows system + this.windowsCurrent = _windows; + // set the new default focus: + this.widgetManager.focusSetDefault(_windows); + // display the title of the Windows: + if (this.windowsCurrent != null) { + setTitle(this.windowsCurrent.propertyTitle.get()); + } + // request all the widget redrawing + forceRedrawAll(); + } + + /** + * @brief get the current windows that is displayed + * @return the current handle on the windows (can be null) + */ + public Windows getWindows() { + return this.windowsCurrent; + }; + + /** + * @brief Redraw all the windows + */ + public void forceRedrawAll() { + if (this.windowsCurrent == null) { + return; + } + final Vector2i size = getSize(); + this.windowsCurrent.setSize(Vector2f(size.x(), size.y())); + this.windowsCurrent.onChangeSize(); + } + + /** + * @brief This is to transfert the event from one widget to another one + * @param source the widget where the event came from + * @param destination the widget where the event mitgh be generated now + */ + public void inputEventTransfertWidget(final Widget _source, final Widget _destination) { + this.input.transfertEvent(_source, _destination); + } + + /** + * @brief This fonction lock the pointer properties to move in relative instead of absolute + * @param[in] widget The widget that lock the pointer events + */ + public void inputEventGrabPointer(final Widget _widget) { + this.input.grabPointer(_widget); + } + + /** + * @brief This fonction un-lock the pointer properties to move in relative instead of absolute + */ + public void inputEventUnGrabPointer() { + this.input.unGrabPointer(); + } + + public void onResize(final Vector2i _size) { + Log.verbose("Resize: " + _size); + forceRedrawAll(); + } + + /** + * @brief This is the only one things the User might done in his main(); + * @note : must be implemented in all system OPS implementation + * @note To answare you before you ask the question, this is really simple: + * Due to the fect that the current system is multiple-platform, you "main" + * Does not exist in the android platform, then ewol call other start + * and stop function, to permit to have only one code + * @note The main can not be in the ewol, due to the fact thet is an librairy + * @param[in] _argc Standard argc + * @param[in] _argv Standard argv + * @return normal error int for the application error management + */ + public static int main(String[] _args); + + private final int initStepId = 0; + private final int initTotalStep = 0; + + /** + * @brief Special for init (main) set the start image when loading data + * @param[in] _fileName Name of the image to load + */ + public void setInitImage(final Uri _fileName) { + //this.initDisplayImageName = _fileName; + } + + /** + * @brief Request a display after call a resize + */ + public void requestUpdateSize() { + final Context context = gale::getContext(); + context.requestUpdateSize(); + } + + public void onPeriod(final Clock _time) { + this.objectManager.timeCall(_time); + } +} diff --git a/src/org/atriasoft/ewol/context/InputManager.cpp b/src/org/atriasoft/ewol/context/InputManager.cpp index 0ac496c..40810b2 100644 --- a/src/org/atriasoft/ewol/context/InputManager.cpp +++ b/src/org/atriasoft/ewol/context/InputManager.cpp @@ -23,30 +23,30 @@ ETK_DECLARE_TYPE(ewol::context::InputManager); //#define EVENT_DEBUG EWOL_DEBUG void ewol::context::InputManager::calculateLimit() { - m_eventInputLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300)); - m_eventInputLimit.DpiOffset = m_dpi*100; - m_eventMouseLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300)); - m_eventMouseLimit.DpiOffset = float(m_dpi)*0.1f; + this.eventInputLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300)); + this.eventInputLimit.DpiOffset = this.dpi*100; + this.eventMouseLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300)); + this.eventMouseLimit.DpiOffset = float(this.dpi)*0.1f; } -void ewol::context::InputManager::setDpi(int32_t newDPI) { - m_dpi = newDPI; +void ewol::context::InputManager::setDpi(int newDPI) { + this.dpi = newDPI; // recalculate the DPI system ... calculateLimit(); } -bool ewol::context::InputManager::localEventInput(enum gale::key::type _type, - ewol::WidgetShared _destWidget, - int32_t _IdInput, - enum gale::key::status _status, +boolean ewol::context::InputManager::localEventInput(KeyType _type, + Widget _destWidget, + int _IdInput, + KeyStatus _status, Vector2f _pos) { if (_destWidget != null) { - if ( _type == gale::key::type::mouse - || _type == gale::key::type::finger) { + if ( _type == KeyType::mouse + || _type == KeyType::finger) { // create the system Event : - ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, m_specialKey); // TODO : set the real ID ... + ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, this.specialKey); // TODO : set the real ID ... // generate the event : - return _destWidget->systemEventInput(tmpEventSystem); + return _destWidget.systemEventInput(tmpEventSystem); } else { return false; } @@ -55,8 +55,8 @@ bool ewol::context::InputManager::localEventInput(enum gale::key::type _type, } void ewol::context::InputManager::abortElement(InputPoperty *_eventTable, - int32_t _idInput, - enum gale::key::type _type) { + int _idInput, + KeyType _type) { if (_eventTable == null) { return; } @@ -64,17 +64,17 @@ void ewol::context::InputManager::abortElement(InputPoperty *_eventTable, localEventInput(_type, _eventTable[_idInput].curentWidgetEvent.lock(), _eventTable[_idInput].destinationInputId, - gale::key::status::abort, + KeyStatus::abort, _eventTable[_idInput].posEvent); } } void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable, - int32_t _idInput) { + int _idInput) { if (_eventTable == null) { return; } - //Log.info("CleanElement[" << idInput << "] = @" << (int64_t)eventTable); + //Log.info("CleanElement[" + idInput + "] = @" + (long)eventTable); _eventTable[_idInput].isUsed = false; _eventTable[_idInput].destinationInputId = 0; _eventTable[_idInput].lastTimeEvent.reset(); @@ -88,74 +88,74 @@ void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable, _eventTable[_idInput].posEvent.setValue(0,0); } -void ewol::context::InputManager::transfertEvent(ewol::WidgetShared _source, ewol::WidgetShared _destination) { +void ewol::context::InputManager::transfertEvent(Widget _source, Widget _destination) { if( _source == null || _destination == null) { // prevent errors ... return; } - for(int32_t iii=0; iii" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventInputSaved[iii].posEvent); - localEventInput(gale::key::type::finger, tmpWidget, m_eventInputSaved[iii].destinationInputId, gale::key::status::abort, m_eventInputSaved[iii].posEvent); + EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_ABORT] " + this.eventInputSaved[iii].posEvent); + localEventInput(KeyType::finger, tmpWidget, this.eventInputSaved[iii].destinationInputId, KeyStatus::abort, this.eventInputSaved[iii].posEvent); // set the new widget ... - m_eventInputSaved[iii].curentWidgetEvent = _destination; + this.eventInputSaved[iii].curentWidgetEvent = _destination; // inform the widget that he receive the event property now... - EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventInputSaved[iii].posEvent); - localEventInput(gale::key::type::finger, _destination, m_eventInputSaved[iii].destinationInputId, gale::key::status::transfert, m_eventInputSaved[iii].posEvent); + EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_TRANSFERT] " + this.eventInputSaved[iii].posEvent); + localEventInput(KeyType::finger, _destination, this.eventInputSaved[iii].destinationInputId, KeyStatus::transfert, this.eventInputSaved[iii].posEvent); } - tmpWidget = m_eventMouseSaved[iii].curentWidgetEvent.lock(); + tmpWidget = this.eventMouseSaved[iii].curentWidgetEvent.lock(); if (tmpWidget == _source) { // inform the widget that it does not receive the event now - EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventMouseSaved[iii].posEvent); - localEventInput(gale::key::type::mouse, tmpWidget, m_eventMouseSaved[iii].destinationInputId, gale::key::status::abort, m_eventMouseSaved[iii].posEvent); + EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_ABORT] " + this.eventMouseSaved[iii].posEvent); + localEventInput(KeyType::mouse, tmpWidget, this.eventMouseSaved[iii].destinationInputId, KeyStatus::abort, this.eventMouseSaved[iii].posEvent); // set the new widget ... - m_eventMouseSaved[iii].curentWidgetEvent = _destination; + this.eventMouseSaved[iii].curentWidgetEvent = _destination; // inform the widget that he receive the event property now... - EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventMouseSaved[iii].posEvent); - localEventInput(gale::key::type::mouse, _destination, m_eventMouseSaved[iii].destinationInputId, gale::key::status::transfert, m_eventMouseSaved[iii].posEvent); + EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_TRANSFERT] " + this.eventMouseSaved[iii].posEvent); + localEventInput(KeyType::mouse, _destination, this.eventMouseSaved[iii].destinationInputId, KeyStatus::transfert, this.eventMouseSaved[iii].posEvent); } } } -void ewol::context::InputManager::grabPointer(ewol::WidgetShared _widget) { +void ewol::context::InputManager::grabPointer(Widget _widget) { if(_widget == null) { return; } - m_grabWidget = _widget; + this.grabWidget = _widget; /* TODO : - m_context.grabPointerEvents(true, _widget->getOrigin() - + Vector2i(_widget->getSize().x()/2.0f, - _widget->getSize().y()/2.0f) ); + this.context.grabPointerEvents(true, _widget.getOrigin() + + Vector2i(_widget.getSize().x()/2.0f, + _widget.getSize().y()/2.0f) ); */ } void ewol::context::InputManager::unGrabPointer() { - m_grabWidget.reset(); - // TODO: m_context.grabPointerEvents(false, Vector2f(0,0)); + this.grabWidget.reset(); + // TODO: this.context.grabPointerEvents(false, Vector2f(0,0)); } void ewol::context::InputManager::newLayerSet() { - for(int32_t iii=0; iii the it was finger event ... -void ewol::context::InputManager::motion(enum gale::key::type _type, +void ewol::context::InputManager::motion(KeyType _type, int _pointerID, Vector2f _pos) { - EVENT_DEBUG("motion event : " << _type << " " << _pointerID << " " << _pos); + EVENT_DEBUG("motion event : " + _type + " " + _pointerID + " " + _pos); if (MAX_MANAGE_INPUT <= _pointerID) { // reject pointer == > out of IDs... return; } InputPoperty *eventTable = null; - if (_type == gale::key::type::mouse) { - eventTable = m_eventMouseSaved; - } else if (_type == gale::key::type::finger) { - eventTable = m_eventInputSaved; + if (_type == KeyType::mouse) { + eventTable = this.eventMouseSaved; + } else if (_type == KeyType::finger) { + eventTable = this.eventInputSaved; } else { Log.error("Unknown type of event"); return; @@ -208,34 +208,34 @@ void ewol::context::InputManager::motion(enum gale::key::type _type, // not manage input return; } - ewol::widget::WindowsShared tmpWindows = m_context.getWindows(); + ewol::widget::Windows tmpWindows = this.context.getWindows(); // special case for the mouse event 0 that represent the hover event of the system : - if ( _type == gale::key::type::mouse - && _pointerID == 0) { + if ( _type == KeyType::mouse + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _pointerID == 0) { // this event is all time on the good widget ... and manage the enter and leave ... // NOTE : the "layer widget" force us to get the widget at the specific position all the time : - ewol::WidgetShared tmpWidget; - if (m_grabWidget.lock() != null) { + Widget tmpWidget; + if (this.grabWidget.lock() != null) { // grab all events ... - tmpWidget = m_grabWidget.lock(); + tmpWidget = this.grabWidget.lock(); } else { if (tmpWindows != null) { - tmpWidget = tmpWindows->getWidgetAtPos(_pos); + tmpWidget = tmpWindows.getWidgetAtPos(_pos); } } if( tmpWidget != eventTable[_pointerID].curentWidgetEvent.lock() || ( eventTable[_pointerID].isInside == true - && ( eventTable[_pointerID].origin.x() > _pos.x() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( eventTable[_pointerID].origin.x() > _pos.x() || eventTable[_pointerID].origin.y() > _pos.y() || (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x() || (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) ) ) { eventTable[_pointerID].isInside = false; - EVENT_DEBUG("GUI : Input ID=" << _pointerID << " == >" << eventTable[_pointerID].destinationInputId << " [LEAVE] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + " == >" + eventTable[_pointerID].destinationInputId + " [LEAVE] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - gale::key::status::leave, + KeyStatus::leave, _pos); } if (eventTable[_pointerID].isInside == false) { @@ -246,28 +246,28 @@ void ewol::context::InputManager::motion(enum gale::key::type _type, if (tmpWidget == null) { eventTable[_pointerID].isInside = false; } else { - eventTable[_pointerID].origin = tmpWidget->getOrigin(); - eventTable[_pointerID].size = tmpWidget->getSize(); + eventTable[_pointerID].origin = tmpWidget.getOrigin(); + eventTable[_pointerID].size = tmpWidget.getSize(); } eventTable[_pointerID].destinationInputId = 0; - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [ENTER] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [ENTER] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - gale::key::status::enter, + KeyStatus::enter, _pos); } - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [MOVE] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [MOVE] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - gale::key::status::move, + KeyStatus::move, _pos); } else if (eventTable[_pointerID].isUsed == true) { if (eventTable[_pointerID].isInside == true) { @@ -276,63 +276,63 @@ void ewol::context::InputManager::motion(enum gale::key::type _type, || (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x() || (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) { eventTable[_pointerID].isInside = false; - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [LEAVE] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [LEAVE] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - gale::key::status::leave, + KeyStatus::leave, _pos); } } else { if( ( eventTable[_pointerID].origin.x() <= _pos.x() - && (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) >= _pos.x() ) - && ( eventTable[_pointerID].origin.y() <= _pos.y() - && (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) >= _pos.y() ) ) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) >= _pos.x() ) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( eventTable[_pointerID].origin.y() <= _pos.y() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) >= _pos.y() ) ) { eventTable[_pointerID].isInside = true; - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [ENTER] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [ENTER] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - gale::key::status::enter, + KeyStatus::enter, _pos); } } - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [MOVE] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [MOVE] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - gale::key::status::move, + KeyStatus::move, _pos); } } -void ewol::context::InputManager::state(enum gale::key::type _type, +void ewol::context::InputManager::state(KeyType _type, int _pointerID, - bool _isDown, + boolean _isDown, Vector2f _pos) { if (_pointerID >= MAX_MANAGE_INPUT) { // reject pointer == > out of IDs... return; } - EVENT_DEBUG("event pointerId=" << _pointerID); + EVENT_DEBUG("event pointerId=" + _pointerID); // convert position in open-GL coordonates ... InputPoperty *eventTable = null; InputLimit localLimit; - if (_type == gale::key::type::mouse) { - eventTable = m_eventMouseSaved; - localLimit = m_eventMouseLimit; - } else if (_type == gale::key::type::finger) { - eventTable = m_eventInputSaved; - localLimit = m_eventInputLimit; + if (_type == KeyType::mouse) { + eventTable = this.eventMouseSaved; + localLimit = this.eventMouseLimit; + } else if (_type == KeyType::finger) { + eventTable = this.eventInputSaved; + localLimit = this.eventInputLimit; } else { Log.error("Unknown type of event"); return; @@ -344,12 +344,12 @@ void ewol::context::InputManager::state(enum gale::key::type _type, } // get the curent time ... echrono::Clock currentTime = echrono::Clock::now(); - ewol::widget::WindowsShared tmpWindows = m_context.getWindows(); + ewol::widget::Windows tmpWindows = this.context.getWindows(); if (_isDown == true) { - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [DOWN] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [DOWN] " + _pos); if(eventTable[_pointerID].isUsed == true) { // we have an event previously ... check delay between click and offset position if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) { @@ -363,14 +363,14 @@ void ewol::context::InputManager::state(enum gale::key::type _type, // save start time eventTable[_pointerID].lastTimeEvent = currentTime; // generate DOWN Event - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [DOWN] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [DOWN] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - gale::key::status::down, + KeyStatus::down, _pos); } else { // Mark it used : @@ -381,19 +381,19 @@ void ewol::context::InputManager::state(enum gale::key::type _type, eventTable[_pointerID].lastTimeEvent = currentTime; // set the element inside ... eventTable[_pointerID].isInside = true; - ewol::WidgetShared tmpWidget = m_grabWidget.lock(); + Widget tmpWidget = this.grabWidget.lock(); // get destination widget : if(tmpWindows != null) { if ( tmpWidget != null - && _type == gale::key::type::mouse) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _type == KeyType::mouse) { eventTable[_pointerID].curentWidgetEvent = tmpWidget; } else { - tmpWidget = tmpWindows->getWidgetAtPos(_pos); + tmpWidget = tmpWindows.getWidgetAtPos(_pos); eventTable[_pointerID].curentWidgetEvent = tmpWidget; if (tmpWidget != null) { - EVENT_DEBUG("Get widget at pos=" << _pos << " type: " << tmpWidget->getObjectType()); + EVENT_DEBUG("Get widget at pos=" + _pos + " type: " + tmpWidget.getObjectType()); } else { - EVENT_DEBUG("Get widget at pos=" << _pos << " NO WIDGET"); + EVENT_DEBUG("Get widget at pos=" + _pos + " NO WIDGET"); } } } else { @@ -401,28 +401,28 @@ void ewol::context::InputManager::state(enum gale::key::type _type, } tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); if (tmpWidget != null) { - eventTable[_pointerID].origin = tmpWidget->getOrigin(); - eventTable[_pointerID].size = tmpWidget->getSize(); + eventTable[_pointerID].origin = tmpWidget.getOrigin(); + eventTable[_pointerID].size = tmpWidget.getSize(); eventTable[_pointerID].destinationInputId = localGetDestinationId(_type, tmpWidget, _pointerID); } else { eventTable[_pointerID].destinationInputId = -1; } // generate DOWN Event - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [DOWN] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [DOWN] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - gale::key::status::down, + KeyStatus::down, _pos); } } else { - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [UP] " << _pos); - ewol::WidgetShared tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [UP] " + _pos); + Widget tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); if(eventTable[_pointerID].isUsed == false) { // bad case ... ??? Log.debug("Up event without previous down ... "); @@ -439,44 +439,44 @@ void ewol::context::InputManager::state(enum gale::key::type _type, eventTable[_pointerID].curentWidgetEvent.reset(); } else { // generate UP Event - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [UP] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [UP] " + _pos); eventTable[_pointerID].posEvent = _pos; // send up event after the single event to prevent multiple widget getting elements localEventInput(_type, tmpWidget, _pointerID, - gale::key::status::up, + KeyStatus::up, _pos); // generate event (single) if( etk::abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset - && etk::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){ + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM etk::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){ // Save current position : eventTable[_pointerID].downStart = _pos; // save start time eventTable[_pointerID].lastTimeEvent = currentTime; - int32_t nbClickMax = 0; + int nbClickMax = 0; if(tmpWidget != null) { - nbClickMax = tmpWidget->getMouseLimit(); + nbClickMax = tmpWidget.getMouseLimit(); if (nbClickMax>5) { nbClickMax = 5; } } // in grab mode the single to quinte event are not generated .... - if( ( m_grabWidget.lock() == null - || _type != gale::key::type::mouse ) - && eventTable[_pointerID].nbClickEvent < nbClickMax) { + if( ( this.grabWidget.lock() == null + || _type != KeyType::mouse ) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM eventTable[_pointerID].nbClickEvent < nbClickMax) { // generate event SINGLE : eventTable[_pointerID].nbClickEvent++; - EVENT_DEBUG("GUI : Input ID=" << _pointerID - << " == >" << eventTable[_pointerID].destinationInputId - << " [" << eventTable[_pointerID].nbClickEvent << "] " << _pos); + EVENT_DEBUG("GUI : Input ID=" + _pointerID + + " == >" + eventTable[_pointerID].destinationInputId + + " [" + eventTable[_pointerID].nbClickEvent + "] " + _pos); eventTable[_pointerID].posEvent = _pos; localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - (enum gale::key::status)(uint32_t(gale::key::status::pressSingle) + eventTable[_pointerID].nbClickEvent-1), + (KeyStatus)(uint(KeyStatus::pressSingle) + eventTable[_pointerID].nbClickEvent-1), _pos); if( eventTable[_pointerID].nbClickEvent >= nbClickMax) { eventTable[_pointerID].nbClickEvent = 0; @@ -489,10 +489,10 @@ void ewol::context::InputManager::state(enum gale::key::type _type, localEventInput(_type, tmpWidget, _pointerID, - gale::key::status::upAfter, + KeyStatus::upAfter, _pos); // specific for tuch event - if (_type == gale::key::type::finger) { + if (_type == KeyType::finger) { cleanElement(eventTable, _pointerID); } } diff --git a/src/org/atriasoft/ewol/context/InputManager.java b/src/org/atriasoft/ewol/context/InputManager.java index d4ef1e6..c6dd671 100644 --- a/src/org/atriasoft/ewol/context/InputManager.java +++ b/src/org/atriasoft/ewol/context/InputManager.java @@ -16,17 +16,17 @@ namespace ewol { */ class InputPoperty { public: - bool isUsed; - int32_t destinationInputId; + boolean isUsed; + int destinationInputId; echrono::Clock lastTimeEvent; - ewol::WidgetWeak curentWidgetEvent; + WeakReference curentWidgetEvent; Vector2f origin; Vector2f size; Vector2f downStart; Vector2f posEvent; - bool isDown; - bool isInside; - int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3 + boolean isDown; + boolean isInside; + int nbClickEvent; // 0 .. 1 .. 2 .. 3 }; /** @@ -36,22 +36,22 @@ namespace ewol { class InputLimit { public: echrono::Duration sepatateTime; - int32_t DpiOffset; + int DpiOffset; }; class Context; class InputManager{ // special grab pointer mode : private: - ewol::WidgetWeak m_grabWidget; //!< widget that grab the curent pointer. + WeakReference this.grabWidget; //!< widget that grab the curent pointer. private: - int32_t m_dpi; - InputLimit m_eventInputLimit; - InputLimit m_eventMouseLimit; + int this.dpi; + InputLimit this.eventInputLimit; + InputLimit this.eventMouseLimit; void calculateLimit(); - InputPoperty m_eventInputSaved[MAX_MANAGE_INPUT]; - InputPoperty m_eventMouseSaved[MAX_MANAGE_INPUT]; - void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum gale::key::type _type); - void cleanElement(InputPoperty* _eventTable, int32_t _idInput); + InputPoperty this.eventInputSaved[MAX_MANAGE_INPUT]; + InputPoperty this.eventMouseSaved[MAX_MANAGE_INPUT]; + void abortElement(InputPoperty* _eventTable, int _idInput, KeyType _type); + void cleanElement(InputPoperty* _eventTable, int _idInput); /** * @brief generate the event on the destinated widget. * @param[in] _type Type of the event that might be sended. @@ -61,10 +61,10 @@ namespace ewol { * @param[in] _pos position of the event * @return true if event has been greped */ - bool localEventInput(enum gale::key::type _type, - ewol::WidgetShared _destWidget, - int32_t _IdInput, - enum gale::key::status _typeEvent, + boolean localEventInput(KeyType _type, + Widget _destWidget, + int _IdInput, + KeyStatus _typeEvent, Vector2f _pos); /** * @brief convert the system event id in the correct EWOL id depending of the system management mode @@ -75,19 +75,19 @@ namespace ewol { * @param[in] _realInputId system Id * @return the ewol input id */ - int32_t localGetDestinationId(enum gale::key::type _type, - ewol::WidgetShared _destWidget, - int32_t _realInputId); + int localGetDestinationId(KeyType _type, + Widget _destWidget, + int _realInputId); private: - ewol::Context& m_context; + EwolContext this.context; public: - InputManager(ewol::Context& _context); + InputManager(EwolContext _context); ~InputManager(); - void setDpi(int32_t _newDPI); + void setDpi(int _newDPI); // note if id<0 == > the it was finger event ... - void motion(enum gale::key::type _type, int _pointerID, Vector2f _pos ); - void state(enum gale::key::type _type, int _pointerID, bool _isDown, Vector2f _pos); + void motion(KeyType _type, int _pointerID, Vector2f _pos ); + void state(KeyType _type, int _pointerID, boolean _isDown, Vector2f _pos); public: /** * @brief a new layer on the windows is set == > might remove all the property of the current element ... @@ -98,21 +98,21 @@ namespace ewol { * @param _source the widget where the event came from * @param _destination the widget where the event mitgh be generated now */ - void transfertEvent(ewol::WidgetShared _source, ewol::WidgetShared _destination); + void transfertEvent(Widget _source, Widget _destination); /** * @brief This fonction lock the pointer properties to move in relative instead of absolute * @param[in] _widget The widget that lock the pointer events */ - void grabPointer(ewol::WidgetShared _widget); + void grabPointer(Widget _widget); /** * @brief This fonction un-lock the pointer properties to move in relative instead of absolute */ void unGrabPointer(); private: - gale::key::Special m_specialKey; + KeySpecial this.specialKey; public: - void setLastKeyboardSpecial(const gale::key::Special& _specialKey) { - m_specialKey = _specialKey; + void setLastKeyboardSpecial( KeySpecial _specialKey) { + this.specialKey = _specialKey; } }; }; diff --git a/src/org/atriasoft/ewol/debug.cpp b/src/org/atriasoft/ewol/debug.cpp deleted file mode 100644 index 643e481..0000000 --- a/src/org/atriasoft/ewol/debug.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include - -int32_t ewol::getLogId() { - static int32_t g_val = elog::registerInstance("ewol"); - return g_val; -} diff --git a/src/org/atriasoft/ewol/event/Entry.cpp b/src/org/atriasoft/ewol/event/Entry.cpp deleted file mode 100644 index 912e1a8..0000000 --- a/src/org/atriasoft/ewol/event/Entry.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include - -#include -ETK_DECLARE_TYPE(ewol::event::Entry); - -etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::Entry& _obj) { - _os << "{type=" << _obj.getType(); - _os << " status=" << _obj.getStatus(); - if (_obj.getType() == gale::key::keyboard::character) { - _os << " char=" << _obj.getChar(); - } - _os << "}"; - return _os; -} - -etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::EntrySystem& _obj) { - _os << _obj.m_event; - return _os; -} diff --git a/src/org/atriasoft/ewol/event/Entry.java b/src/org/atriasoft/ewol/event/Entry.java index 427e060..a071fb0 100644 --- a/src/org/atriasoft/ewol/event/Entry.java +++ b/src/org/atriasoft/ewol/event/Entry.java @@ -1,70 +1,43 @@ +package org.atriasoft.ewol.event; + +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.key.KeyStatus; + /** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ -#pragma once -#include -#include - -namespace ewol { - namespace event { - class Entry { - private: - enum gale::key::keyboard m_type; //!< type of hardware event - enum gale::key::status m_status; //!< status of hardware event - gale::key::Special m_specialKey; //!< input key status (prevent change in time..) - char32_t m_unicodeData; //!< Unicode data (in some case) - public: - Entry(enum gale::key::keyboard _type, - enum gale::key::status _status, - gale::key::Special _specialKey, - char32_t _char) : - m_type(_type), - m_status(_status), - m_specialKey(_specialKey), - m_unicodeData(_char) { - - }; - void setType(enum gale::key::keyboard _type) { - m_type = _type; - }; - inline const enum gale::key::keyboard& getType() const { - return m_type; - }; - void setStatus(enum gale::key::status _status) { - m_status = _status; - }; - inline const enum gale::key::status& getStatus() const { - return m_status; - }; - void setSpecialKey(const gale::key::Special& _specialKey) { - m_specialKey = _specialKey; - }; - inline const gale::key::Special& getSpecialKey() const { - return m_specialKey; - }; - void setChar(char32_t _char) { - m_unicodeData = _char; - }; - inline const char32_t& getChar() const { - return m_unicodeData; - }; - }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::event::Entry& _obj); +public class Entry { + private final KeyKeyboard type; //!< type of hardware event + private final KeyStatus status; //!< status of hardware event + private final KeySpecial specialKey; //!< input key status (prevent change in time..) + private final Character unicodeData; //!< Unicode data (in some case) + + public Entry(final KeyKeyboard _type, final KeyStatus _status, final KeySpecial _specialKey, final Character _char) { + this.type = _type; + this.status = _status; + this.specialKey = _specialKey; + this.unicodeData = _char; - class EntrySystem { - public: - EntrySystem(enum gale::key::keyboard _type, - enum gale::key::status _status, - gale::key::Special _specialKey, - char32_t _char) : - m_event(_type, _status, _specialKey, _char) { - - }; - ewol::event::Entry m_event; - }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::event::EntrySystem& _obj); + } + + public Character getChar() { + return this.unicodeData; }; -}; + + public KeySpecial getSpecialKey() { + return this.specialKey; + }; + + public KeyStatus getStatus() { + return this.status; + }; + + public KeyKeyboard getType() { + return this.type; + }; + +}; \ No newline at end of file diff --git a/src/org/atriasoft/ewol/event/EntrySystem.java b/src/org/atriasoft/ewol/event/EntrySystem.java new file mode 100644 index 0000000..c08f5f6 --- /dev/null +++ b/src/org/atriasoft/ewol/event/EntrySystem.java @@ -0,0 +1,13 @@ +package org.atriasoft.ewol.event; + +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.key.KeyStatus; + +public class EntrySystem { + public final Entry event; + + public EntrySystem(final KeyKeyboard _type, final KeyStatus _status, final KeySpecial _specialKey, final Character _char) { + this.event = new Entry(_type, _status, _specialKey, _char); + } +} \ No newline at end of file diff --git a/src/org/atriasoft/ewol/event/EvantInput.java b/src/org/atriasoft/ewol/event/EvantInput.java new file mode 100644 index 0000000..a7e954c --- /dev/null +++ b/src/org/atriasoft/ewol/event/EvantInput.java @@ -0,0 +1,76 @@ +package org.atriasoft.ewol.event; + +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.gale.key.KeyType; + +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +public class EventInput { + private KeyType type; + private KeyStatus status; + private int inputId; + private Vector2f pos; + private KeySpecial specialKey; //!< input key status (prevent change in time..) + + public EventInput(final KeyType _type, final KeyStatus _status, final int _id, final Vector2f _pos, final KeySpecial _specialKey) { + this.type = _type; + this.status = _status; + this.inputId = _id; + this.pos = _pos; + this.specialKey = _specialKey; + + }; + + public int getId() { + return this.inputId; + }; + + public Vector2f getPos() { + return this.pos; + }; + + public KeySpecial getSpecialKey() { + return this.specialKey; + }; + + public KeyStatus getStatus() { + return this.status; + }; + + public KeyType getType() { + return this.type; + }; + + /** + * @brief Reset the input property of the curent event. + */ + public void reset() { + // TODO : Call the entry element ant rest it ... + }; + + public void setId(final int _id) { + this.inputId = _id; + }; + + public void setPos(final Vector2f _pos) { + this.pos = _pos; + }; + + public void setSpecialKey(final KeySpecial _specialKey) { + this.specialKey = _specialKey; + }; + + public void setStatus(final KeyStatus _status) { + this.status = _status; + }; + + public void setType(final KeyType _type) { + this.type = _type; + } +} diff --git a/src/org/atriasoft/ewol/event/EventTime.java b/src/org/atriasoft/ewol/event/EventTime.java new file mode 100644 index 0000000..b953297 --- /dev/null +++ b/src/org/atriasoft/ewol/event/EventTime.java @@ -0,0 +1,68 @@ +package org.atriasoft.ewol.event; + +import org.atriasoft.echrono.Clock; +import org.atriasoft.echrono.Duration; + +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ +public class EventTime { + private Clock timeSystem; //!< Current system time (micro-second) + private Clock timeUpAppl; //!< Current application wake up-time (micro-second) + private Duration timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second) + private Duration timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second) + + public EventTime(final Clock _timeSystem, final Clock _timeUpAppl, final Duration _timeDelta, final Duration _timeDeltaCall) { + this.timeSystem = _timeSystem; + this.timeUpAppl = _timeUpAppl; + this.timeDelta = _timeDelta; + this.timeDeltaCall = _timeDeltaCall; + + }; + + public Duration getApplUpTime() { + return this.timeSystem.less(this.timeUpAppl); + }; + + public Clock getApplWakeUpTime() { + return this.timeUpAppl; + }; + + public float getDelta() { + return this.timeDelta.toSeconds(); + }; + + public float getDeltaCall() { + return this.timeDeltaCall.toSeconds(); + }; + + public Duration getDeltaCallDuration() { + return this.timeDeltaCall; + }; + + public Duration getDeltaDuration() { + return this.timeDelta; + }; + + public Clock getTime() { + return this.timeSystem; + }; + + public void setApplWakeUpTime(final Clock _timeUpAppl) { + this.timeUpAppl = _timeUpAppl; + }; + + public void setDelta(final Duration _timeDelta) { + this.timeDelta = _timeDelta; + }; + + public void setDeltaCall(final Duration _timeDeltaCall) { + this.timeDeltaCall = _timeDeltaCall; + }; + + public void setTime(final Clock _timeSystem) { + this.timeSystem = _timeSystem; + }; +} diff --git a/src/org/atriasoft/ewol/event/Input.cpp b/src/org/atriasoft/ewol/event/Input.cpp deleted file mode 100644 index a846a3f..0000000 --- a/src/org/atriasoft/ewol/event/Input.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include - -#include -ETK_DECLARE_TYPE(ewol::event::Input); - -etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::Input& _obj) { - _os << "{type=" << _obj.getType(); - _os << " status=" << _obj.getStatus(); - _os << " id=" << etk::toString(_obj.getId()); - _os << " pos=" << _obj.getPos(); - _os << "}"; - return _os; -} - -etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::InputSystem& _obj) { - _os << _obj.m_event; - return _os; -} diff --git a/src/org/atriasoft/ewol/event/Input.java b/src/org/atriasoft/ewol/event/Input.java deleted file mode 100644 index 3c9562e..0000000 --- a/src/org/atriasoft/ewol/event/Input.java +++ /dev/null @@ -1,104 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include - -namespace ewol { - namespace event { - class Input { - private: - enum gale::key::type m_type; - enum gale::key::status m_status; - uint8_t m_inputId; - Vector2f m_pos; - gale::key::Special m_specialKey; //!< input key status (prevent change in time..) - public: - Input(enum gale::key::type _type, - enum gale::key::status _status, - uint8_t _id, - const Vector2f& _pos, - gale::key::Special _specialKey): - m_type(_type), - m_status(_status), - m_inputId(_id), - m_pos(_pos), - m_specialKey(_specialKey) { - - }; - void setType(enum gale::key::type _type) { - m_type = _type; - }; - inline const enum gale::key::type& getType() const { - return m_type; - }; - void setStatus(enum gale::key::status _status) { - m_status = _status; - }; - inline const enum gale::key::status& getStatus() const { - return m_status; - }; - void setId(uint8_t _id) { - m_inputId = _id; - }; - inline const uint8_t& getId() const { - return m_inputId; - }; - void setPos(const Vector2f& _pos) { - m_pos = _pos; - }; - inline const Vector2f& getPos() const { - return m_pos; - }; - void setSpecialKey(const gale::key::Special& _specialKey) { - m_specialKey = _specialKey; - }; - inline const gale::key::Special& getSpecialKey() const { - return m_specialKey; - }; - /** - * @brief Reset the input property of the curent event. - */ - void reset() const { - // TODO : Call the entry element ant rest it ... - } - }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::event::Input& _obj); - - class InputSystem { - public: - InputSystem(enum gale::key::type _type, - enum gale::key::status _status, - uint8_t _id, - const Vector2f& _pos, - ewol::WidgetShared _dest, - int32_t _realIdEvent, - gale::key::Special _specialKey) : - m_event(_type, _status, _id, _pos, _specialKey), - m_dest(_dest), - m_realIdEvent(_realIdEvent) { }; - ewol::event::Input m_event; - private: - ewol::WidgetShared m_dest; - int32_t m_realIdEvent; - public: - void setDestWidget(ewol::WidgetShared _dest) { - m_dest = _dest; - }; - inline ewol::WidgetShared getDestWidget() const { - return m_dest; - }; - void setRealId(int32_t _realIdEvent) { - m_realIdEvent = _realIdEvent; - }; - inline int32_t getRealId() const { - return m_realIdEvent; - }; - }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::event::InputSystem& _obj); - }; -}; - diff --git a/src/org/atriasoft/ewol/event/InputSystem.java b/src/org/atriasoft/ewol/event/InputSystem.java new file mode 100644 index 0000000..465f5eb --- /dev/null +++ b/src/org/atriasoft/ewol/event/InputSystem.java @@ -0,0 +1,38 @@ +package org.atriasoft.ewol.event; + +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.gale.key.KeyType; + +import jdk.internal.org.jline.reader.Widget; + +public class InputSystem { + public EventInput event; + + private Widget dest; + + private int realIdEvent; + + public InputSystem(final KeyType _type, final KeyStatus _status, final int _id, final Vector2f _pos, final Widget _dest, final int _realIdEvent, final KeySpecial _specialKey) { + this.event = new EventInput(_type, _status, _id, _pos, _specialKey); + this.dest = _dest; + this.realIdEvent = _realIdEvent; + } + + public Widget getDestWidget() { + return this.dest; + } + + public int getRealId() { + return this.realIdEvent; + } + + public void setDestWidget(final Widget _dest) { + this.dest = _dest; + } + + public void setRealId(final int _realIdEvent) { + this.realIdEvent = _realIdEvent; + } +} \ No newline at end of file diff --git a/src/org/atriasoft/ewol/event/Time.cpp b/src/org/atriasoft/ewol/event/Time.cpp deleted file mode 100644 index a843bf4..0000000 --- a/src/org/atriasoft/ewol/event/Time.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include -#include -ETK_DECLARE_TYPE(ewol::event::Time); - -etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::Time& _obj) { - _os << "{time=" << _obj.getTime(); - _os << " uptime=" << _obj.getApplUpTime(); - _os << " delta=" << _obj.getDelta(); - _os << " deltaCall=" << _obj.getDeltaCall(); - _os << "}"; - return _os; -} - -namespace etk { - template<> etk::String toString(ewol::event::Time const& _obj) { - etk::String out; - out = "{[ewol::event::Time]time=" + etk::toString(_obj.getTime()); - out += ";uptime=" + etk::toString(_obj.getApplUpTime()); - out += ";delta=" + etk::toString(_obj.getDelta()); - out += ";deltaCall=" + etk::toString(_obj.getDeltaCall()); - out += "}"; - return out; - } -} - -// declare for signal event -#include -ESIGNAL_DECLARE_SIGNAL(ewol::event::Time); - diff --git a/src/org/atriasoft/ewol/event/Time.java b/src/org/atriasoft/ewol/event/Time.java deleted file mode 100644 index de66d18..0000000 --- a/src/org/atriasoft/ewol/event/Time.java +++ /dev/null @@ -1,69 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include - -namespace ewol { - namespace event { - class Time { - private: - echrono::Clock m_timeSystem; //!< Current system time (micro-second) - echrono::Clock m_timeUpAppl; //!< Current application wake up-time (micro-second) - echrono::Duration m_timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second) - echrono::Duration m_timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second) - public: - Time(const echrono::Clock& _timeSystem, - const echrono::Clock& _timeUpAppl, - const echrono::Duration& _timeDelta, - const echrono::Duration& _timeDeltaCall) : - m_timeSystem(_timeSystem), - m_timeUpAppl(_timeUpAppl), - m_timeDelta(_timeDelta), - m_timeDeltaCall(_timeDeltaCall){ - - }; - public: - void setTime(const echrono::Clock& _timeSystem) { - m_timeSystem = _timeSystem; - }; - inline const echrono::Clock& getTime() const { - return m_timeSystem; - }; - void setApplWakeUpTime(const echrono::Clock& _timeUpAppl) { - m_timeUpAppl = _timeUpAppl; - }; - inline const echrono::Clock& getApplWakeUpTime() const { - return m_timeUpAppl; - }; - inline echrono::Duration getApplUpTime() const { - return m_timeSystem-m_timeUpAppl; - }; - void setDelta(const echrono::Duration& _timeDelta) { - m_timeDelta = _timeDelta; - }; - inline const echrono::Duration& getDeltaDuration() const { - return m_timeDelta; - }; - inline float getDelta() const { - return m_timeDelta.toSeconds(); - }; - void setDeltaCall(const echrono::Duration& _timeDeltaCall) { - m_timeDeltaCall = _timeDeltaCall; - }; - inline const echrono::Duration& getDeltaCallDuration() const { - return m_timeDeltaCall; - }; - inline float getDeltaCall() const { - return m_timeDeltaCall.toSeconds(); - }; - }; - etk::Stream& operator <<(etk::Stream& _os, const ewol::event::Time& _obj); - } -} - diff --git a/src/org/atriasoft/ewol/ewol.cpp b/src/org/atriasoft/ewol/ewol.cpp index 079b52a..0d5d735 100644 --- a/src/org/atriasoft/ewol/ewol.cpp +++ b/src/org/atriasoft/ewol/ewol.cpp @@ -17,16 +17,16 @@ #define EWOL_VERSION "0.0.0" #endif -etk::String ewol::getVersion() { +String ewol::getVersion() { return EWOL_VERSION; } -int32_t ewol::run(ewol::context::Application* _application, - int32_t _argc, - const char* _argv[]) { +int ewol::run(EwolApplication* _application, + int _argc, + char* _argv[]) { etranslate::init(_argc, _argv); - return gale::run(ETK_NEW(ewol::Context, _application), _argc, _argv); + return gale::run(ETK_NEW(EwolContext, _application), _argc, _argv); } diff --git a/src/org/atriasoft/ewol/ewol.java b/src/org/atriasoft/ewol/ewol.java index 1e5ba30..a14a0a6 100644 --- a/src/org/atriasoft/ewol/ewol.java +++ b/src/org/atriasoft/ewol/ewol.java @@ -1,14 +1,18 @@ + /** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ -#pragma once +import org.atriasoft.ewol.context.EwolApplication; +import org.atriasoft.ewol.context.EwolContext; -#include -#include - -namespace ewol { +class Ewol { + public static EwolContext getContext() { + // TODO Auto-generated method stub + return EwolContext.getContext(); + } + /** * @brief This is the only one things the User might done in his main(); * @note To answare you before you ask the question, this is really simple: @@ -21,10 +25,5 @@ namespace ewol { * @param[in] _argv Standard argv * @return normal error int for the application error management */ - int32_t run(ewol::context::Application* _application, int32_t _argc = 0, const char* _argv[] = null); - /** - * @brief get EWOL version - * @return The string that describe ewol version - */ - etk::String getVersion(); -}; + public static int run(final EwolApplication _application, String[] _argv); +} diff --git a/src/org/atriasoft/ewol/gravity.cpp b/src/org/atriasoft/ewol/gravity.cpp index 3dd641c..dfb7371 100644 --- a/src/org/atriasoft/ewol/gravity.cpp +++ b/src/org/atriasoft/ewol/gravity.cpp @@ -10,7 +10,7 @@ #include ETK_DECLARE_TYPE(enum ewol::gravity); -etk::String ewol::gravityToString(const enum ewol::gravity _obj) { +String ewol::gravityToString( enum ewol::gravity _obj) { switch(_obj) { case ewol::gravity_center: return "center"; @@ -34,7 +34,7 @@ etk::String ewol::gravityToString(const enum ewol::gravity _obj) { return "unknow"; } -enum ewol::gravity ewol::stringToGravity(const etk::String& _obj) { +enum ewol::gravity ewol::stringToGravity( String _obj) { if (_obj == "center") { return ewol::gravity_center; } else if (_obj == "top-left") { @@ -56,31 +56,31 @@ enum ewol::gravity ewol::stringToGravity(const etk::String& _obj) { } return ewol::gravity_center; } -Vector2f ewol::gravityGenerateDelta(const enum ewol::gravity _gravity, const Vector2f& _deltas) { +Vector2f ewol::gravityGenerateDelta( enum ewol::gravity _gravity, Vector2f _deltas) { Vector2f out(0.0f,0.0f); if (_deltas.x() > 0.0001f) { - if ((uint32_t(_gravity) & uint32_t(ewol::gravity_left)) != 0) { + if ((uint(_gravity) uint(ewol::gravity_left)) != 0) { // nothing to do - } else if ((uint32_t(_gravity) & uint32_t(ewol::gravity_right)) != 0) { - out = Vector2f(int32_t(_deltas.x()), 0.0f); + } else if ((uint(_gravity) uint(ewol::gravity_right)) != 0) { + out = Vector2f(int(_deltas.x()), 0.0f); } else { - out = Vector2f(int32_t(_deltas.x()*0.5f), 0.0f); + out = Vector2f(int(_deltas.x()*0.5f), 0.0f); } } if (_deltas.y() > 0.0001f) { - if ((uint32_t(_gravity) & uint32_t(ewol::gravity_buttom)) != 0) { + if ((uint(_gravity) uint(ewol::gravity_buttom)) != 0) { // nothing to do - } else if ((uint32_t(_gravity) & uint32_t(ewol::gravity_top)) != 0) { - out += Vector2f(0.0f, int32_t(_deltas.y())); + } else if ((uint(_gravity) uint(ewol::gravity_top)) != 0) { + out += Vector2f(0.0f, int(_deltas.y())); } else { - out += Vector2f(0.0f, int32_t(_deltas.y()*0.5f)); + out += Vector2f(0.0f, int(_deltas.y()*0.5f)); } } return out; } -etk::Stream& ewol::operator <<(etk::Stream& _os, const enum ewol::gravity _obj) { - _os << ewol::gravityToString(_obj); +etk::Stream ewol::operator +(etk::Stream _os, enum ewol::gravity _obj) { + _os + ewol::gravityToString(_obj); return _os; } diff --git a/src/org/atriasoft/ewol/gravity.java b/src/org/atriasoft/ewol/gravity.java deleted file mode 100644 index ad2cb88..0000000 --- a/src/org/atriasoft/ewol/gravity.java +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include - -namespace ewol { - /** - * @brief Gravity of the widget property - * @not_in_doc - */ - enum gravity { - gravity_center = 0x00, //!< gravity is in center - gravity_top = 0x01, //!< gravity is in top - gravity_buttom = 0x02, //!< gravity is in buttom - gravity_right = 0x04, //!< gravity is in right - gravity_left = 0x08, //!< gravity is in left - gravity_topRight = gravity_top|gravity_right, //!< gravity is in top-right - gravity_topLeft = gravity_top|gravity_left, //!< gravity is in top-left - gravity_buttomRight = gravity_buttom|gravity_right, //!< gravity is in buttom-right - gravity_buttomLeft = gravity_buttom|gravity_left, //!< gravity is in buttom-left - }; - etk::Stream& operator <<(etk::Stream& _os, const enum ewol::gravity _obj); - etk::String gravityToString(const enum ewol::gravity _obj); - enum ewol::gravity stringToGravity(const etk::String& _obj); - Vector2f gravityGenerateDelta(const enum ewol::gravity _gravity, const Vector2f& _deltas); -} diff --git a/src/org/atriasoft/ewol/internal/Log.java b/src/org/atriasoft/ewol/internal/Log.java index 46f2fa1..5f1e4df 100644 --- a/src/org/atriasoft/ewol/internal/Log.java +++ b/src/org/atriasoft/ewol/internal/Log.java @@ -3,7 +3,7 @@ package org.atriasoft.ewol.internal; import io.scenarium.logger.LogLevel; import io.scenarium.logger.Logger; -class Log { +public class Log { private static final String LIB_NAME = "ewol"; private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME); private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL); diff --git a/src/org/atriasoft/ewol/object/EwolObject.java b/src/org/atriasoft/ewol/object/EwolObject.java new file mode 100644 index 0000000..92b9813 --- /dev/null +++ b/src/org/atriasoft/ewol/object/EwolObject.java @@ -0,0 +1,237 @@ +package org.atriasoft.ewol.object; + +import java.lang.ref.WeakReference; + +import org.atriasoft.ewol.context.EwolContext; +import org.atriasoft.ewol.internal.Log; + +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +/** + * @brief Basic message classes for ewol system + * this class mermit at every Object to communicate between them. + */ +public class EwolObject { + private static Integer valUID = 0; //!< Static used for the unique ID definition + + /** + * @brief get the curent the system inteface. + * @return current reference on the instance. + */ + protected static EwolContext getContext() { + return Ewol.getContext(); + } + + /** + * @breif get the current Object manager. + * @return the requested object manager. + */ + public static ObjectManager getObjectManager() { + return Ewol.getContext().getEObjectManager(); + } + + /** + * @brief Retrive an object with his name (in the global list) + * @param[in] _name Name of the object + * @return the requested object or null + */ + public static EwolObject getObjectNamed(final String _objectName) { + return getObjectManager().getObjectNamed(_objectName); + } + + //@EwolPropertyDescription("Object name, might be a unique reference in all the program") + //@JacksonXmlProperty(isAttribute = true, localName = "name") + private String name = ""; //!< name of the element ... + + protected WeakReference parent = null; //!< Reference on the current parent. + + protected boolean destroy = false; //!< Flag to know if the object is requesting has destroy. + + private final boolean staticObject = false; //!< set this variable at true if this element must not be auto destroy (exemple : use static object); + + private final int uniqueId; //!< Object UniqueID == > TODO : Check if it use is needed + + private boolean isResource = false; //!< enable this when you want to declare this element is auto-remove + + /** + * @brief Constructor. + */ + public EwolObject() { + // note this is nearly atomic ... (but it is enough) + synchronized (valUID) { + this.uniqueId = EwolObject.valUID++; + } + Log.debug("new Object : [" + this.uniqueId + "]"); + + getObjectManager().add(this); + } + + /** + * @brief Auto-destroy the object + */ + protected void autoDestroy() { + Log.verbose("Destroy object: [" + getId() + "] type:" + this.getClass().getCanonicalName()); + final EwolObject parent = this.parent.get(); + // TODO : set a signal to do this ... + if (parent != null) { + Log.verbose("Destroy object: Call parrent"); + parent.requestDestroyFromChild(this); + } + //if no parent ==> noting to do ... + this.destroy = true; + + } + + /** + * @brief Destroy the current object + */ + public void destroy() { + autoDestroy(); + }; + + /** + * @brief get the UniqueId of the Object + * @return the requested ID + */ + public int getId() { + return this.uniqueId; + } + + public String getName() { + return this.name; + }; + + /** + * @brief load attribute properties with an XML node. + * @param[in] _node Reference on the XML node. + * @return true : All has been done corectly. + * @return false : An error occured. + */ + /* + boolean loadXMLAttributes( exml::Element _node){ + if (_node.exist() == false) { + return false; + } + boolean errorOccured = false; + + for( auto it : _node.attributes) { + auto pair = it.getPair(); + if (pair.first == "") { + continue; + } + if (properties.set(pair.first, pair.second) == false) { + errorOccured = true; + } + } + return errorOccured; + } + */ + + /** + * @brief load properties with an XML node. + * @param[in] _node Reference on the XML node. + * @return true : All has been done corectly. + * @return false : An error occured. + */ + //boolean loadXML( exml::Element _node); + + /** + * @brief store properties in this XML node. + * @param[in,out] _node Reference on the XML node. + * @return true : All has been done corectly. + * @return false : An error occured. + */ + /* + boolean storeXML(exml::Element _node){ + if (_node.exist() == false) { + return false; + } + boolean errorOccured = true; + for (auto it : properties.getAll(true)) { + _node.attributes.set(it.first, it.second); + } + return errorOccured; + } + */ + + /** + * @brief get the static status of the Object == > mark at true if the user set the object mark as static allocated element ==> not auto remove element + * @return true if it might not be removed == > usefull for conficuration class + */ + public boolean getStatic() { + return this.staticObject; + } + + /** + * @brief Get the resource status of the element. + * @return the resource status. + */ + public boolean getStatusResource() { + return this.isResource; + } + + /** + * @brief Retrive an object with his name (in the global list) + * @param[in] _name Name of the object + * @return the requested object or null + */ + public EwolObject getSubObjectNamed(final String _objectName) { + Log.verbose("check if name : " + _objectName + " ?= " + this.propertyName); + if (_objectName == this.propertyName) { + return this; + } + return null; + } + + /** + * @brief Check if the current objetc his destroy (in removing) + * @return true The object is removed + * @return false The object is not removed + */ + boolean isDestroyed() { + return this.destroy; + } + + /** + * @brief Remove the current parenting. + */ + void removeParent() { + this.parent = null; + } + + /** + * @brief Called by a whild that want to remove pointer of itself from the current list of his parrent + * @param[in] _child Object of the child that want to remove itself + */ + protected void requestDestroyFromChild(final EwolObject _child) { + Log.info("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ..."); + Log.critical("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)"); + } + + public void setName(final String name) { + this.name = name; + } + + /** + * @brief Set the Object has new parrent. + * @param[in] _newParent Object that requesting the parenting + */ + public void setParent(final EwolObject _newParent) { + // TODO : Implement change of parent ... + this.parent = new WeakReference<>(_newParent); + } + + /** + * @brief Declare this element as a resource (or singleton) this mean the element will + * not be auto Remove at the end of the programm. It just notify that it is not removed. + * @param[in] _val Value of the type of the element. + */ + public void setStatusResource(final boolean _val) { + this.isResource = _val; + } + +} diff --git a/src/org/atriasoft/ewol/object/Manager.cpp b/src/org/atriasoft/ewol/object/Manager.cpp index 2867e9d..daa2fee 100644 --- a/src/org/atriasoft/ewol/object/Manager.cpp +++ b/src/org/atriasoft/ewol/object/Manager.cpp @@ -10,25 +10,25 @@ #include #include -ETK_DECLARE_TYPE(ewol::object::Manager); +ETK_DECLARE_TYPE(ObjectManager); -ewol::object::Manager::Manager(ewol::Context& _context) : - m_context(_context), +ObjectManager::Manager(EwolContext _context) : + this.context(_context), periodicCall(this, "periodic", "Call every time system render"), - m_applWakeUpTime(0), - m_lastPeriodicCallTime(0) { + this.applWakeUpTime(0), + this.lastPeriodicCallTime(0) { Log.debug(" == > init Object-Manager"); periodicCall.setPeriodic(true); // set the basic time properties : - m_applWakeUpTime = echrono::Clock::now(); - m_lastPeriodicCallTime = m_applWakeUpTime; + this.applWakeUpTime = echrono::Clock::now(); + this.lastPeriodicCallTime = this.applWakeUpTime; } -ewol::object::Manager::~Manager() { - ethread::RecursiveLock lock(m_mutex); - m_workerList.clear(); - bool hasError = false; - if (m_eObjectList.size()!=0) { +ObjectManager::~Manager() { + ethread::RecursiveLock lock(this.mutex); + this.workerList.clear(); + boolean hasError = false; + if (this.eObjectList.size()!=0) { Log.error("Must not have anymore eObject !!!"); hasError = true; } @@ -38,76 +38,76 @@ ewol::object::Manager::~Manager() { displayListObject(); } -void ewol::object::Manager::displayListObject() { - ethread::RecursiveLock lock(m_mutex); +void ObjectManager::displayListObject() { + ethread::RecursiveLock lock(this.mutex); Log.info("List loaded object : "); - for (auto &it : m_eObjectList) { - ewol::ObjectShared element = it.lock(); + for (auto it : this.eObjectList) { + EwolObject element = it.lock(); if (element != null) { - Log.info(" [" << element->getId() << "] ref=" << element.useCount()-1 << " name='" << element->propertyName.get() << "' type=" << element->getObjectType()); + Log.info(" [" + element.getId() + "] ref=" + element.useCount()-1 + " name='" + element.propertyName.get() + "' type=" + element.getObjectType()); } } } -void ewol::object::Manager::unInit() { - ethread::RecursiveLock lock(m_mutex); +void ObjectManager::unInit() { + ethread::RecursiveLock lock(this.mutex); Log.debug(" == > Un-Init Object-Manager"); - if (m_workerList.size() > 0) { + if (this.workerList.size() > 0) { Log.debug(" == > Remove all workers"); - m_workerList.clear(); + this.workerList.clear(); } - for (auto &it : m_eObjectList) { - ewol::ObjectShared element = it.lock(); + for (auto it : this.eObjectList) { + EwolObject element = it.lock(); if (element != null) { - //it->removeObject(); + //it.removeObject(); } } - if (m_eObjectList.size() != 0) { - Log.error("Have " << m_eObjectList.size() << " active Object"); + if (this.eObjectList.size() != 0) { + Log.error("Have " + this.eObjectList.size() + " active Object"); } - m_eObjectList.clear(); + this.eObjectList.clear(); } -void ewol::object::Manager::add(const ewol::ObjectShared& _object) { - ethread::RecursiveLock lock(m_mutex); +void ObjectManager::add( EwolObject _object) { + ethread::RecursiveLock lock(this.mutex); if (_object == null) { Log.error("try to add an inexistant Object in manager"); } - m_eObjectList.pushBack(_object); + this.eObjectList.pushBack(_object); } -int32_t ewol::object::Manager::getNumberObject() { - ethread::RecursiveLock lock(m_mutex); - return m_eObjectList.size(); +int ObjectManager::getNumberObject() { + ethread::RecursiveLock lock(this.mutex); + return this.eObjectList.size(); } // clean all Object that request an autoRemove ... -void ewol::object::Manager::cleanInternalRemoved() { - ethread::RecursiveLock lock(m_mutex); - size_t nbObject = m_eObjectList.size(); - Log.verbose("Clean Object List (if needed) : " << m_eObjectList.size() << " elements"); - auto it(m_eObjectList.begin()); - while (it != m_eObjectList.end()) { - if (it->expired() == true) { - it = m_eObjectList.erase(it); +void ObjectManager::cleanInternalRemoved() { + ethread::RecursiveLock lock(this.mutex); + int nbObject = this.eObjectList.size(); + Log.verbose("Clean Object List (if needed) : " + this.eObjectList.size() + " elements"); + auto it(this.eObjectList.begin()); + while (it != this.eObjectList.end()) { + if (it.expired() == true) { + it = this.eObjectList.erase(it); } else { ++it; } } - if (m_eObjectList.size() != nbObject) { - Log.verbose(" remove " << nbObject - m_eObjectList.size() << " deprecated objects"); + if (this.eObjectList.size() != nbObject) { + Log.verbose(" remove " + nbObject - this.eObjectList.size() + " deprecated objects"); } } -ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) { - ethread::RecursiveLock lock(m_mutex); +EwolObject ObjectManager::get( String _name) { + ethread::RecursiveLock lock(this.mutex); if (_name == "") { return null; } - for (auto &it : m_eObjectList) { - ewol::ObjectShared element = it.lock(); + for (auto it : this.eObjectList) { + EwolObject element = it.lock(); if ( element != null - && element->propertyName.get() == _name) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM element.propertyName.get() == _name) { return element; } } @@ -115,47 +115,47 @@ ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) { } -ewol::ObjectShared ewol::object::Manager::getObjectNamed(const etk::String& _name) { - ethread::RecursiveLock lock(m_mutex); - return ewol::object::Manager::get(_name); +EwolObject ObjectManager::getObjectNamed( String _name) { + ethread::RecursiveLock lock(this.mutex); + return ObjectManager::get(_name); } -void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) { - ethread::RecursiveLock lock(m_mutex); - m_workerList.pushBack(_worker); +void ObjectManager::workerAdd( EwolObject _worker) { + ethread::RecursiveLock lock(this.mutex); + this.workerList.pushBack(_worker); } -void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) { - ethread::RecursiveLock lock(m_mutex); - auto it(m_workerList.begin()); - while (it != m_workerList.end()) { +void ObjectManager::workerRemove( EwolObject _worker) { + ethread::RecursiveLock lock(this.mutex); + auto it(this.workerList.begin()); + while (it != this.workerList.end()) { if (*it == _worker) { - it = m_workerList.erase(it); + it = this.workerList.erase(it); } else { ++it; } } } -void ewol::object::Manager::timeCall(const echrono::Clock& _localTime) { - ethread::RecursiveLock lock(m_mutex); - echrono::Clock previousTime = m_lastPeriodicCallTime; - m_lastPeriodicCallTime = _localTime; +void ObjectManager::timeCall( echrono::Clock _localTime) { + ethread::RecursiveLock lock(this.mutex); + echrono::Clock previousTime = this.lastPeriodicCallTime; + this.lastPeriodicCallTime = _localTime; if (periodicCall.size() <= 0) { return; } echrono::Duration deltaTime = _localTime - previousTime; - ewol::event::Time myTime(_localTime, m_applWakeUpTime, deltaTime, deltaTime); + ewol::event::Time myTime(_localTime, this.applWakeUpTime, deltaTime, deltaTime); periodicCall.emit(myTime); } -void ewol::object::Manager::timeCallResume(const echrono::Clock& _localTime) { - ethread::RecursiveLock lock(m_mutex); - m_lastPeriodicCallTime = _localTime; +void ObjectManager::timeCallResume( echrono::Clock _localTime) { + ethread::RecursiveLock lock(this.mutex); + this.lastPeriodicCallTime = _localTime; } -bool ewol::object::Manager::timeCallHave() { - ethread::RecursiveLock lock(m_mutex); +boolean ObjectManager::timeCallHave() { + ethread::RecursiveLock lock(this.mutex); return periodicCall.size() > 0; } diff --git a/src/org/atriasoft/ewol/object/Manager.java b/src/org/atriasoft/ewol/object/Manager.java deleted file mode 100644 index 8c2dbe1..0000000 --- a/src/org/atriasoft/ewol/object/Manager.java +++ /dev/null @@ -1,105 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace ewol { - class Context; - namespace object { - class Manager : public esignal::Interface { - protected: - ethread::MutexRecursive m_mutex; - private: - List m_eObjectList; // all widget allocated == > all time increment ... never removed ... - Context& m_context; - public: - Manager(Context& _context); - virtual ~Manager(); - /** - * @brief remove all resources (un-init) out of the destructor (due to the system implementation) - */ - void unInit(); - /** - * @brief Get the number of loaded object in the system - * @return number of Object - */ - int32_t getNumberObject(); - /** - * @brief Display all object Open. - */ - void displayListObject(); - private: - //! @not_in_doc - friend class ewol::Object; - /** - * @brief Internal API that used only with Object toi reference itself in the manager. - * @note The manager remove the object when the refecence Low down 1 (last keeper) - * @param[in] _object Reference shared pointer on the object - */ - void add(const ewol::ObjectShared& _object); - public: - /** - * @brief clean the weak pointer list (remove weak_ptr that is remoed) - */ - void cleanInternalRemoved(); - /** - * @brief Retrive an Object with his name - * @param[in] _name Name of the Object - * @return Pointer on the finded Object. - */ - ewol::ObjectShared get(const etk::String& _name); - public: - /** - * @brief retrive an object with his name - * @param[in] _name Name of the object - * @return the requested object or null - */ - ewol::ObjectShared getObjectNamed(const etk::String& _name); - private: - List m_workerList; - public: - /** - * @brief Add a worker on the system list. - * @param[in] _worker Worker to add in the list. - */ - void workerAdd(const ewol::ObjectShared& _worker); - /** - * @brief Remove a worker on the system list. - * @param[in] _worker Worker to add in the list. - */ - void workerRemove(const ewol::ObjectShared& _worker); - public: - esignal::Signal periodicCall; - private: - echrono::Clock m_applWakeUpTime; //!< Time of the application initialize - echrono::Clock m_lastPeriodicCallTime; //!< last call time ... - public: // ewol system internal : - /** - * @brief Call every time we can with the current time - * @param[in] _localTime Current system Time. - */ - void timeCall(const echrono::Clock& _localTime); - /** - * @brief If the application is suspended The Ewol Object manager does not know it, just call this to update delta call - * @param[in] _localTime Current system Time. - */ - void timeCallResume(const echrono::Clock& _localTime); - /** - * @breif check if the Interface have some user that request a periodic call - * @return true, have some periodic event... - */ - bool timeCallHave(); - - }; - }; -}; diff --git a/src/org/atriasoft/ewol/object/Object.cpp b/src/org/atriasoft/ewol/object/Object.cpp index 8cf17f9..e69de29 100644 --- a/src/org/atriasoft/ewol/object/Object.cpp +++ b/src/org/atriasoft/ewol/object/Object.cpp @@ -1,186 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -ETK_DECLARE_TYPE(ewol::Object); - -size_t ewol::Object::m_valUID = 0; - -void ewol::Object::autoDestroy() { - if (m_objectHasBeenInit == false) { - EWOL_WARNING("try to auto destroy inside a constructor"); - return; - } - Log.verbose("Destroy object: [" << getId() << "] type:" << getObjectType()); - ewol::ObjectShared parent = m_parent.lock(); - // TODO : set a signal to do this ... - if (parent != null) { - Log.verbose("Destroy object: Call parrent"); - parent->requestDestroyFromChild(sharedFromThis()); - } - //if no parent ==> noting to do ... - m_destroy = true; -} - -bool ewol::Object::objectHasBeenCorectlyInit() { - return m_objectHasBeenInit; -} - -void ewol::Object::requestDestroyFromChild(const ewol::ObjectShared& _child) { - Log.info("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ..."); - Log.critical("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)"); -} - -void ewol::Object::destroy() { - autoDestroy(); -} - -bool ewol::Object::isDestroyed() const { - return m_destroy; -} - -void ewol::Object::setParent(const ewol::ObjectShared& _newParent) { - // TODO : Implement change of parent ... - m_parent = _newParent; -} - -void ewol::Object::removeParent() { - m_parent.reset(); -} - -ewol::Object::Object() : - propertyName(this, "name", "", "Object name, might be a unique reference in all the program"), - m_objectHasBeenInit(false), - m_destroy(false), - m_static(false), - m_isResource(false) { - // note this is nearly atomic ... (but it is enough) - m_uniqueId = m_valUID++; - Log.debug("new Object : [" << m_uniqueId << "]"); -} - -ewol::Object::~Object() { - Log.debug("delete Object : [" << m_uniqueId << "] : " << getTypeDescription()); - m_uniqueId = -1; -} - - -void ewol::Object::init() { - getObjectManager().add(sharedFromThis()); - //parameterDisplay(); - m_objectHasBeenInit = true; -} - -const char * const ewol::Object::getObjectType() const { - if (m_listType.size() == 0) { - return "ewol::Object"; - } - return m_listType.back(); -} - -void ewol::Object::addObjectType(const char* _type) { - if (_type == null) { - Log.error(" try to add a type with no value..."); - return; - } - m_listType.pushBack(_type); -} -etk::String ewol::Object::getTypeDescription() const { - etk::String ret("ewol::Object"); - for(auto element : m_listType) { - ret += "|"; - ret += element; - } - return ret; -} - -bool ewol::Object::isTypeCompatible(const etk::String& _type) const { - if (_type == "ewol::Object") { - return true; - } - for(auto element : m_listType) { - if (_type == element) { - return true; - } - } - return false; -} - -bool ewol::Object::loadXMLAttributes(const exml::Element& _node) { - if (_node.exist() == false) { - return false; - } - bool errorOccured = false; - - for(const auto it : _node.attributes) { - auto pair = it.getPair(); - if (pair.first == "") { - continue; - } - if (properties.set(pair.first, pair.second) == false) { - errorOccured = true; - } - } - return errorOccured; -} - -bool ewol::Object::loadXML(const exml::Element& _node) { - return true; //loadXMLAttributes(_node); -} - -bool ewol::Object::storeXML(exml::Element& _node) const { - if (_node.exist() == false) { - return false; - } - bool errorOccured = true; - for (auto &it : properties.getAll(true)) { - _node.attributes.set(it.first, it.second); - } - return errorOccured; -} - -bool ewol::Object::propertySetOnWidgetNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value) { - ewol::ObjectShared object = getObjectManager().get(_objectName); - if (object == null) { - return false; - } - return object->properties.set(_config, _value); -} - -ewol::object::Manager& ewol::Object::getObjectManager() { - ewol::object::Manager& tmp = ewol::getContext().getEObjectManager(); - return tmp; -} - -ewol::Context& ewol::Object::getContext() { - return ewol::getContext(); -} - -ewol::ObjectShared ewol::Object::getObjectNamed(const etk::String& _objectName) { - return getObjectManager().getObjectNamed(_objectName); -} - -ewol::ObjectShared ewol::Object::getSubObjectNamed(const etk::String& _objectName) { - Log.verbose("check if name : " << _objectName << " ?= " << propertyName.get()); - if (_objectName == propertyName.get()) { - return sharedFromThis(); - } - return null; -} - - -bool ewol::propertySetOnObjectNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value) { - ewol::ObjectShared object = ewol::getContext().getEObjectManager().get(_objectName); - if (object == null) { - return false; - } - return object->properties.set(_config, _value); -} - diff --git a/src/org/atriasoft/ewol/object/Object.java b/src/org/atriasoft/ewol/object/Object.java deleted file mode 100644 index de4c392..0000000 --- a/src/org/atriasoft/ewol/object/Object.java +++ /dev/null @@ -1,339 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -namespace ewol { - // some class need to define element befor other ... - class Object; - namespace object { - class Manager; - } - class Context; -} - -template static void baseInit(const ememory::SharedPtr& _object) { - // end of recurtion - return; -} - -template static void baseInit(const ememory::SharedPtr& _object, const etk::String& _name, const TYPE_VAL& _val, TYPE&& ... _all ) { - eproperty::Property* prop(null); - eproperty::PropertyType* propType(null); - if (_object == null) { - Log.error("EMPTY pointer"); - return; - } - prop = _object->properties.getRaw(_name); - if (prop == null) { - Log.error("property does not exit ... '" << _name << "'"); - goto exit_on_error; - } - propType = dynamic_cast*>(prop); - if (propType == null) { - Log.error("property does not cast in requested type ... '" << _name << "' require type : " << /*typeid(_val).name()*/ "?TODO?" << "' instead of '" << prop->getType() << "'"); - goto exit_on_error; - } - propType->setDirectCheck(_val); -exit_on_error: - baseInit(_object, etk::forward(_all)... ); - return; -} - -#define UN_DECLARE_FACTORY(className) \ - template static ememory::SharedPtr create(const EWOL_FACTORY_CREATE_TYPE& ... _all) = delete; - -#define DECLARE_FACTORY(className) \ - template static ememory::SharedPtr create(const EWOL_FACTORY_CREATE_TYPE& ... _all) { \ - ememory::SharedPtr object(ETK_NEW(className)); \ - if (object == null) { \ - Log.error("Factory error"); \ - return null; \ - } \ - baseInit(object, _all... ); \ - object->init(); \ - if (object->objectHasBeenCorectlyInit() == false) { \ - Log.critical("Object Is not correctly init : " << #className ); \ - } \ - return object; \ - } \ - static ememory::SharedPtr createXml(const exml::Element& _node) { \ - ememory::SharedPtr object(ETK_NEW(className)); \ - if (object == null) { \ - Log.error("Factory error"); \ - return null; \ - } \ - object->loadXMLAttributes(_node); \ - object->init(); \ - if (object->objectHasBeenCorectlyInit() == false) { \ - Log.critical("Object Is not correctly init : " << #className ); \ - } \ - return object; \ - } - -#define DECLARE_SINGLE_FACTORY(className, uniqueName) \ - template static ememory::SharedPtr create(const EWOL_FACTORY_CREATE_TYPE& ... _all) { \ - ememory::SharedPtr object; \ - ememory::SharedPtr object2 = getObjectNamed(uniqueName); \ - if (object2 != null) { \ - object = ememory::dynamicPointerCast(object2); \ - if (object == null) { \ - Log.critical("Request object element: '" << uniqueName << "' With the wrong type (dynamic cast error)"); \ - return null; \ - } \ - } \ - if (object != null) { \ - return object; \ - } \ - object = ememory::SharedPtr(ETK_NEW(className)); \ - if (object == null) { \ - Log.error("Factory error"); \ - return null; \ - } \ - baseInit(object, "name", etk::String(uniqueName), _all... ); \ - object->init(); \ - if (object->objectHasBeenCorectlyInit() == false) { \ - Log.critical("Object Is not correctly init : " << #className ); \ - } \ - return object; \ - } - -namespace ewol { - using ObjectShared = ememory::SharedPtr; - using ObjectWeak = ememory::WeakPtr; - /** - * @brief Basic message classes for ewol system - * this class mermit at every Object to communicate between them. - */ - class Object : public ememory::EnableSharedFromThis, - public eproperty::Interface, - public esignal::Interface { - public: // Event list - - public: // propertie list - eproperty::Value propertyName; //!< name of the element ... - private: - static size_t m_valUID; //!< Static used for the unique ID definition - private: - bool m_objectHasBeenInit; //!< Know if the init function has bben called - public: - /** - * @brief Destructor - */ - virtual ~Object(); - protected: - /** - * @brief Constructor. - */ - Object(); - virtual void init(); - public: - /** - * @brief Factory - */ - DECLARE_FACTORY(Object); - bool objectHasBeenCorectlyInit(); - protected: - ewol::ObjectWeak m_parent; //!< Reference on the current parrent. - bool m_destroy; //!< Flag to know if the object is requesting has destroy. - protected: - /** - * @brief Auto-destroy the object - */ - virtual void autoDestroy(); - public: - /** - * @brief Destroy the current object - */ - virtual void destroy(); - /** - * @brief Check if the current objetc his destroy (in removing) - * @return true The object is removed - * @return false The object is not removed - */ - bool isDestroyed() const; - protected: - /** - * @brief Called by a whild that want to remove pointer of itself from the current list of his parrent - * @param[in] _child Object of the child that want to remove itself - */ - virtual void requestDestroyFromChild(const ewol::ObjectShared& _child); - public: - /** - * @brief Set the Object has new parrent. - * @param[in] _newParent Object that requesting the parenting - */ - virtual void setParent(const ewol::ObjectShared& _newParent); - /** - * @brief Remove the current parenting. - */ - virtual void removeParent(); - private: - List m_listType; - public: - /** - * @brief get the current Object type of the Object - * @return the last type name of the element - */ - const char * const getObjectType() const; - /** - * @brief Get the herarchie of the Object type. - * @return descriptive string. - */ - etk::String getTypeDescription() const; - /** - * @brief check if the element herited from a specific type - * @param[in] _type Type to check. - * @return true if the element is compatible. - */ - bool isTypeCompatible(const etk::String& _type) const; - protected: - /** - * @brief Add a type of the list of Object. - * @param[in] _type new type to add. - */ - void addObjectType(const char* _type); - protected: - bool m_static; //!< set this variable at true if this element must not be auto destroy (exemple : use static object) - public: - /** - * @brief get the static status of the Object == > mark at true if the user set the object mark as static allocated element ==> not auto remove element - * @return true if it might not be removed == > usefull for conficuration class - */ - bool getStatic(){ - return m_static; - }; - private: - int32_t m_uniqueId; //!< Object UniqueID == > TODO : Check if it use is needed - public: - /** - * @brief get the UniqueId of the Object - * @return the requested ID - */ - int32_t getId(){ - return m_uniqueId; - }; - public: - // TODO : Rework the position on this function ... This is a convignent function ... - bool propertySetOnWidgetNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value); - public: - /** - * @brief load attribute properties with an XML node. - * @param[in] _node Reference on the XML node. - * @return true : All has been done corectly. - * @return false : An error occured. - */ - bool loadXMLAttributes(const exml::Element& _node); - /** - * @brief load properties with an XML node. - * @param[in] _node Reference on the XML node. - * @return true : All has been done corectly. - * @return false : An error occured. - */ - virtual bool loadXML(const exml::Element& _node); - /** - * @brief store properties in this XML node. - * @param[in,out] _node Reference on the XML node. - * @return true : All has been done corectly. - * @return false : An error occured. - */ - virtual bool storeXML(exml::Element& _node) const; - public: - /** - * @breif get the current Object manager. - * @return the requested object manager. - */ - static ewol::object::Manager& getObjectManager(); - /** - * @brief get the curent the system inteface. - * @return current reference on the instance. - */ - static ewol::Context& getContext(); - private: - bool m_isResource; //!< enable this when you want to declare this element is auto-remove - public: - /** - * @brief Declare this element as a resource (or singleton) this mean the element will - * not be auto Remove at the end of the programm. It just notify that it is not removed. - * @param[in] _val Value of the type of the element. - */ - void setStatusResource(bool _val) { - m_isResource = _val; - } - /** - * @brief Get the resource status of the element. - * @return the resource status. - */ - bool getStatusResource() const { - return m_isResource; - } - /** - * @brief Retrive an object with his name (in the global list) - * @param[in] _name Name of the object - * @return the requested object or null - */ - static ewol::ObjectShared getObjectNamed(const etk::String& _objectName); - /** - * @brief Retrive an object with his name (in the global list) - * @param[in] _name Name of the object - * @return the requested object or null - */ - virtual ewol::ObjectShared getSubObjectNamed(const etk::String& _objectName); - protected: - // TODO : Create a template ... - /** - * @brief link on an signal in the subwiget with his name - */ - #define subBind(_type, _name, _event, _shared_ptr, _func, ...) do {\ - ememory::SharedPtr<_type> myObject = ememory::dynamicPointerCast<_type>(getSubObjectNamed(_name)); \ - if (myObject != null) { \ - myObject->_event.connect(_shared_ptr, _func, ##__VA_ARGS__); \ - } else { \ - Log.error("object named='" << _name << "' not exit or can not be cast in : " << #_type); \ - } \ - } while (false) - }; - bool propertySetOnObjectNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value); -}; - -/** - * @brief link on an signal in the global object list with his name - */ -#define globalBind(_type, _name, _event, _obj, _func, ...) do {\ - ememory::SharedPtr<_type> myObject = ememory::dynamicPointerCast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \ - if (myObject != null) { \ - myObject->_event.connect(_obj, _func, ##__VA_ARGS__); \ - } else { \ - Log.error("object named='" << _name << "' not exit or can not be cast in : " << #_type); \ - } \ -} while (false) - -/** - * @brief link on an signal in the subWidget of an object with his name - */ -#define externSubBind(_object, _type, _name, _event, _obj, _func, ...) do {\ - ememory::SharedPtr<_type> myObject = ememory::dynamicPointerCast<_type>(_object->getObjectNamed(_name)); \ - if (myObject != null) { \ - myObject->_event.connect(_obj, _func, ##__VA_ARGS__); \ - } else { \ - Log.error("object named='" << _name << "' not exit or can not be cast in : " << #_type); \ - } \ -} while (false) - diff --git a/src/org/atriasoft/ewol/object/ObjectManager.java b/src/org/atriasoft/ewol/object/ObjectManager.java new file mode 100644 index 0000000..bd0ea9a --- /dev/null +++ b/src/org/atriasoft/ewol/object/ObjectManager.java @@ -0,0 +1,199 @@ +package org.atriasoft.ewol.object; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.atriasoft.echrono.Clock; +import org.atriasoft.echrono.Steady; +import org.atriasoft.echrono.Time; +import org.atriasoft.esignal.Signal; +import org.atriasoft.ewol.context.EwolContext; +import org.atriasoft.ewol.internal.Log; +import org.atriasoft.gale.event.EventTime; + +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +public class ObjectManager { + private final List> eObjectList = new ArrayList<>(); // all widget allocated == > all time increment ... never removed ... + private final EwolContext context; + + public ObjectManager(final EwolContext _context) { + this.context = _context; + //periodicCall(this, "periodic", "Call every time system render"); + Log.debug(" == > init Object-Manager"); + this.periodicCall.setPeriodic(true); + // set the basic time properties : + this.applWakeUpTime = Clock.now(); + this.lastPeriodicCallTime = new Clock(this.applWakeUpTime.get()); + } + + /** + * @brief remove all resources (un-init) out of the destructor (due to the system implementation) + */ + synchronized void unInit() { + Log.debug(" == > Un-Init Object-Manager"); + if (this.workerList.size() > 0) { + Log.debug(" == > Remove all workers"); + this.workerList.clear(); + } + for (final WeakReference it : this.eObjectList) { + final EwolObject element = it.get(); + if (element != null) { + //it.removeObject(); + } + } + if (this.eObjectList.size() != 0) { + Log.error("Have " + this.eObjectList.size() + " active Object"); + } + this.eObjectList.clear(); + } + + /** + * @brief Get the number of loaded object in the system + * @return number of Object + */ + synchronized + + int getNumberObject() { + return this.eObjectList.size(); + } + + /** + * @brief Display all object Open. + */ + synchronized void displayListObject() { + Log.info("List loaded object : "); + for (final WeakReference it : this.eObjectList) { + final EwolObject element = it.get(); + if (element != null) { + Log.info(" [" + element.getId() + "] name='" + element.getName() + "' type=" + element.getClass().getCanonicalName()); + } + } + } + + /** + * @brief Internal API that used only with Object toi reference itself in the manager. + * @note The manager remove the object when the refecence Low down 1 (last keeper) + * @param[in] _object Reference shared pointer on the object + */ + private synchronized void add(final EwolObject _object) { + if (_object == null) { + Log.error("try to add an inexistant Object in manager"); + } + this.eObjectList.add(new WeakReference<>(_object)); + } + + /** + * @brief clean the weak pointer list (remove weak_ptr that is remoed) + */ + public synchronized void cleanInternalRemoved() { + final int nbObject = this.eObjectList.size(); + Log.verbose("Clean Object List (if needed) : " + this.eObjectList.size() + " elements"); + final Iterator> iterator = this.eObjectList.iterator(); + while (iterator.hasNext()) { + final WeakReference elem = iterator.next(); + if (elem.get() == null) { + iterator.remove(); + } + } + if (this.eObjectList.size() != nbObject) { + Log.verbose(" remove " + (nbObject - this.eObjectList.size()) + " deprecated objects"); + } + } + + /** + * @brief Retrive an Object with his name + * @param[in] _name Name of the Object + * @return Pointer on the finded Object. + */ + public synchronized EwolObject get(final String _name) { + if (_name.isEmpty() == true) { + return null; + } + for (final WeakReference it : this.eObjectList) { + final EwolObject element = it.get(); + if (element != null && element.getName().contentEquals(_name)) { + return element; + } + } + return null; + } + + /** + * @brief retrive an object with his name + * @param[in] _name Name of the object + * @return the requested object or null + */ + public synchronized EwolObject getObjectNamed(final String _name) { + return ObjectManager.get(_name); + } + + private final List workerList = new ArrayList<>(); + + /** + * @brief Add a worker on the system list. + * @param[in] _worker Worker to add in the list. + */ + public synchronized void workerAdd(final EwolObject _worker) { + this.workerList.add(_worker); + } + + /** + * @brief Remove a worker on the system list. + * @param[in] _worker Worker to add in the list. + */ + public synchronized void workerRemove(final EwolObject _worker) { + + final Iterator iterator = this.workerList.iterator(); + while (iterator.hasNext()) { + final EwolObject elem = iterator.next(); + if (elem == _worker) { + iterator.remove(); + } + } + } + + public final Signal periodicCall = new Signal<>(); + + private final Time applWakeUpTime; //!< Time of the application initialize + private Clock lastPeriodicCallTime; //!< last call time ... + + /** + * @brief Call every time we can with the current time + * @param[in] _localTime Current system Time. + */ + public synchronized void timeCall( final Clock _localTime){ + final Clock previousTime = this.lastPeriodicCallTime; + this.lastPeriodicCallTime = _localTime; + if (this.periodicCall.size() <= 0) { + return; + } + final Duration deltaTime = new Duration(_localTime.get() - previousTime.get()); + + final EventTime myTime(final _localTime, this.applWakeUpTime, deltaTime, deltaTime); + this.periodicCall.emit(myTime); + } + + /** + * @brief If the application is suspended The Ewol Object manager does not know it, just call this to update delta call + * @param[in] _localTime Current system Time. + */ + public synchronized void timeCallResume(final Clock _localTime) { + this.lastPeriodicCallTime = _localTime; + } + + /** + * @breif check if the Interface have some user that request a periodic call + * @return true, have some periodic event... + */ + public synchronized boolean timeCallHave() { + return this.periodicCall.size() > 0; + } + +} diff --git a/src/org/atriasoft/ewol/object/Worker.cpp b/src/org/atriasoft/ewol/object/Worker.cpp index 6a148cb..e9d87c8 100644 --- a/src/org/atriasoft/ewol/object/Worker.cpp +++ b/src/org/atriasoft/ewol/object/Worker.cpp @@ -15,7 +15,7 @@ ewol::object::Worker::Worker() { } void ewol::object::Worker::init() { - ewol::Object::init(); + EwolObject::init(); getObjectManager().workerAdd(sharedFromThis()); } @@ -24,6 +24,6 @@ ewol::object::Worker::~Worker() { } void ewol::object::Worker::destroy() { - ewol::Object::destroy(); + EwolObject::destroy(); getObjectManager().workerRemove(sharedFromThis()); } diff --git a/src/org/atriasoft/ewol/object/Worker.java b/src/org/atriasoft/ewol/object/Worker.java index ca0fd0f..7b58ce7 100644 --- a/src/org/atriasoft/ewol/object/Worker.java +++ b/src/org/atriasoft/ewol/object/Worker.java @@ -3,37 +3,20 @@ * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ -#pragma once -#include -#include - -namespace ewol { - namespace object { - class Worker; - using WorkerShared = ememory::SharedPtr; - using WorkerWeak = ememory::WeakPtr; - /** - * @brief A worker might not been possesed by someone, then the system might keep a pointer on it. - */ - class Worker : public ewol::Object { - protected: - /** - * @brief Constructor. - */ - Worker(); - void init() override; - public: - /** - * @brief Factory - */ - DECLARE_FACTORY(Worker); - /** - * @brief Destructor - */ - virtual ~Worker(); - public: - void destroy() override; - }; +/** + * @brief A worker might not been possesed by someone, then the system might keep a pointer on it. + */ +public class Worker extends EwolObject { + /** + * @brief Constructor. + */ + public Worker() { + getObjectManager().workerAdd(this); + } + + @Override + public void destroy() { + getObjectManager().workerRemove(this); } } diff --git a/src/org/atriasoft/ewol/resource/ColorFile.cpp b/src/org/atriasoft/ewol/resource/ColorFile.cpp index ff1fd6a..e497e58 100644 --- a/src/org/atriasoft/ewol/resource/ColorFile.cpp +++ b/src/org/atriasoft/ewol/resource/ColorFile.cpp @@ -14,73 +14,73 @@ ETK_DECLARE_TYPE(ewol::resource::ColorFile); ewol::resource::ColorFile::ColorFile() : gale::Resource(), // Set the list unodered - m_list(0, false), - m_errorColor(etk::color::orange) { + this.list(0, false), + this.errorColor(etk::color::orange) { addResourceType("ewol::ColorFile"); } -void ewol::resource::ColorFile::init(const etk::Uri& _uri) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::ColorFile::init( etk::Uri _uri) { + ethread::RecursiveLock lock(this.mutex); gale::Resource::init(_uri.get()); - Log.debug("CF : load \"" << _uri << "\""); + Log.debug("CF : load \"" + _uri + "\""); reload(); - Log.debug("List of all color : " << m_list.getKeys()); + Log.debug("List of all color : " + this.list.getKeys()); } ewol::resource::ColorFile::~ColorFile() { // remove all element - m_list.clear(); + this.list.clear(); } void ewol::resource::ColorFile::reload() { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); // remove all previous set of value : - for (size_t iii = 0; iii < m_list.size() ; ++iii) { - m_list.getValue(iii) = m_errorColor; + for (int iii = 0; iii < this.list.size() ; ++iii) { + this.list.getValue(iii) = this.errorColor; } // open and read all json elements: ejson::Document doc; - if (doc.load(etk::Uri(m_name)) == false) { - Log.error("Can not load file : '" << m_name << "'"); + if (doc.load(etk::Uri(this.name)) == false) { + Log.error("Can not load file : '" + this.name + "'"); return; } ejson::Array baseArray = doc["color"].toArray(); if (baseArray.exist() == false) { - Log.error("Can not get basic array : 'color' in file:" << m_name); + Log.error("Can not get basic array : 'color' in file:" + this.name); doc.display(); return; } - bool findError = false; - for (const auto it : baseArray) { + boolean findError = false; + for ( auto it : baseArray) { ejson::Object tmpObj = it.toObject(); if (tmpObj.exist() == false) { - Log.error(" can not get object in 'color' : " << it); + Log.error(" can not get object in 'color' : " + it); findError = true; continue; } - etk::String name = tmpObj["name"].toString().get(); - etk::String color = tmpObj["color"].toString().get(m_errorColor.getHexString()); - Log.debug("find new color : '" << name << "' color='" << color << "'"); + String name = tmpObj["name"].toString().get(); + String color = tmpObj["color"].toString().get(this.errorColor.getHexString()); + Log.debug("find new color : '" + name + "' color='" + color + "'"); if (name.size() == 0) { Log.error("Drop an empty name"); findError = true; continue; } - m_list.add(name, etk::Color(color)); + this.list.add(name, etk::Color(color)); } if (findError == true) { - Log.error("pb in parsing file:" << m_name); + Log.error("pb in parsing file:" + this.name); doc.display(); } } -int32_t ewol::resource::ColorFile::request(const etk::String& _paramName) { - ethread::RecursiveLock lock(m_mutex); +int ewol::resource::ColorFile::request( String _paramName) { + ethread::RecursiveLock lock(this.mutex); // check if the parameters existed : - if (m_list.exist(_paramName) == false) { - m_list.add(_paramName, m_errorColor); + if (this.list.exist(_paramName) == false) { + this.list.add(_paramName, this.errorColor); } - return m_list.getId(_paramName); + return this.list.getId(_paramName); } diff --git a/src/org/atriasoft/ewol/resource/ColorFile.java b/src/org/atriasoft/ewol/resource/ColorFile.java index 38b684a..f49e51b 100644 --- a/src/org/atriasoft/ewol/resource/ColorFile.java +++ b/src/org/atriasoft/ewol/resource/ColorFile.java @@ -18,52 +18,52 @@ namespace ewol { */ class ColorFile : public gale::Resource { private: - etk::Map > m_list; //!< List of all color in the file - etk::Color m_errorColor; //!< Error returned color + etk::Map > this.list; //!< List of all color in the file + etk::Color this.errorColor; //!< Error returned color protected: /** * @brief Constructor of the color property file * @param[in] _uri Name of the file needed */ ColorFile(); - void init(const etk::Uri& _uri); + void init( etk::Uri _uri); public: DECLARE_RESOURCE_URI_FACTORY(ColorFile); /** * @brief Simple Destructor of this class (nothing specific ...) */ - virtual ~ColorFile(); + ~ColorFile(); public: /** * @brief Set the error color. * @param[in] _errorColor Color that might be set when not finding a color */ - void setErrorColor(const etk::Color& _errorColor) { - m_errorColor = _errorColor; + void setErrorColor( etk::Color _errorColor) { + this.errorColor = _errorColor; } /** * @brief Request the presence of a specific color. * @param[in] _paramName Name of the color. * @return A unique ID of the color (or -1 if an error occured). */ - int32_t request(const etk::String& _paramName); + int request( String _paramName); /** * @brief Get the associated color of the ID. * @param[in] _Id Id of the color. * @return The requested color. */ - const etk::Color& get(int32_t _id) const { + etk::Color get(int _id) { if (_id < 0) { - return m_errorColor; + return this.errorColor; } - return m_list.getValue(_id); + return this.list.getValue(_id); }; /** * @brief Get All color name * @return list of all color existing */ - List getColors() const { - return m_list.getKeys(); + List getColors() { + return this.list.getKeys(); } public: // herited function: void reload(); diff --git a/src/org/atriasoft/ewol/resource/Colored3DObject.cpp b/src/org/atriasoft/ewol/resource/Colored3DObject.cpp index e49e6d4..522066f 100644 --- a/src/org/atriasoft/ewol/resource/Colored3DObject.cpp +++ b/src/org/atriasoft/ewol/resource/Colored3DObject.cpp @@ -16,19 +16,19 @@ ETK_DECLARE_TYPE(ewol::resource::Colored3DObject); ewol::resource::Colored3DObject::Colored3DObject() : - m_GLprogram(null) { + this.GLprogram(null) { addResourceType("ewol::Colored3DObject"); } void ewol::resource::Colored3DObject::init() { gale::Resource::init(); // get the shader resource : - m_GLPosition = 0; - m_GLprogram = gale::resource::Program::create("DATA:///simple3D.prog?lib=ewol"); - if (m_GLprogram != null) { - m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); - m_GLColor = m_GLprogram->getUniform("EW_color"); - m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); + this.GLPosition = 0; + this.GLprogram = gale::resource::Program::create("DATA:///simple3D.prog?lib=ewol"); + if (this.GLprogram != null) { + this.GLPosition = this.GLprogram.getAttribute("EW_coord3d"); + this.GLColor = this.GLprogram.getUniform("EW_color"); + this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation"); } } @@ -37,14 +37,14 @@ ewol::resource::Colored3DObject::~Colored3DObject() { } -void ewol::resource::Colored3DObject::draw(const List& _vertices, - const etk::Color& _color, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::draw( List _vertices, + etk::Color _color, + boolean _updateDepthBuffer, + boolean _depthtest) { if (_vertices.size() <= 0) { return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } @@ -54,23 +54,23 @@ void ewol::resource::Colored3DObject::draw(const List& _vertices, glDepthMask(GL_FALSE); } } - //Log.debug(" display " << m_coord.size() << " elements" ); - m_GLprogram->use(); + //Log.debug(" display " + this.coord.size() + " elements" ); + this.GLprogram.use(); // set Matrix: translation/positionMatrix mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix; - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // position : - m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z,unused*/, &_vertices[0], 4*sizeof(float)); + this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z,unused*/, _vertices[0], 4*sizeof(float)); // color : - m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); + this.GLprogram.uniform4fv(this.GLColor, 1/*r,g,b,a*/, (float*)_color); // Request the draw od the elements: gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, _vertices.size()); - m_GLprogram->unUse(); + this.GLprogram.unUse(); // Request the draw od the elements: //glDrawArrays(GL_LINES, 0, vertices.size()); - //m_GLprogram->UnUse(); + //this.GLprogram.UnUse(); if (true == _depthtest) { if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); @@ -79,15 +79,15 @@ void ewol::resource::Colored3DObject::draw(const List& _vertices, } } -void ewol::resource::Colored3DObject::draw(const List& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::draw( List _vertices, + etk::Color _color, + mat4 _transformationMatrix, + boolean _updateDepthBuffer, + boolean _depthtest) { if (_vertices.size() <= 0) { return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } @@ -97,20 +97,20 @@ void ewol::resource::Colored3DObject::draw(const List& _vertices, glDepthMask(GL_FALSE); } } - //Log.debug(" display " << m_coord.size() << " elements" ); - m_GLprogram->use(); + //Log.debug(" display " + this.coord.size() + " elements" ); + this.GLprogram.use(); // set Matrix: translation/positionMatrix mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // position : - m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &_vertices[0], 4*sizeof(float)); + this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z*/, _vertices[0], 4*sizeof(float)); // color : - m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); + this.GLprogram.uniform4fv(this.GLColor, 1/*r,g,b,a*/, (float*)_color); // Request the draw od the elements: gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, _vertices.size()); - m_GLprogram->unUse(); + this.GLprogram.unUse(); if (true == _depthtest) { if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); @@ -119,15 +119,15 @@ void ewol::resource::Colored3DObject::draw(const List& _vertices, } } -void ewol::resource::Colored3DObject::drawLine(List& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::drawLine(List _vertices, + etk::Color _color, + mat4 _transformationMatrix, + boolean _updateDepthBuffer, + boolean _depthtest) { if (_vertices.size() <= 0) { return; } - if (m_GLprogram == null) { + if (this.GLprogram == null) { Log.error("No shader ..."); return; } @@ -137,20 +137,20 @@ void ewol::resource::Colored3DObject::drawLine(List& _vertices, glDepthMask(GL_FALSE); } } - //Log.debug(" display " << m_coord.size() << " elements" ); - m_GLprogram->use(); + //Log.debug(" display " + this.coord.size() + " elements" ); + this.GLprogram.use(); // set Matrix: translation/positionMatrix mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; - m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); + this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); // position : - m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &_vertices[0], 4*sizeof(float)); + this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z*/, _vertices[0], 4*sizeof(float)); // color : - m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); + this.GLprogram.uniform4fv(this.GLColor, 1/*r,g,b,a*/, (float*)_color); // Request the draw od the elements: gale::openGL::drawArrays(gale::openGL::renderMode::line, 0, _vertices.size()); - m_GLprogram->unUse(); + this.GLprogram.unUse(); if (true == _depthtest) { if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); @@ -160,12 +160,12 @@ void ewol::resource::Colored3DObject::drawLine(List& _vertices, } -void ewol::resource::Colored3DObject::drawCubeLine(const Vector3f& _min, - const Vector3f& _max, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::drawCubeLine( Vector3f _min, + Vector3f _max, + etk::Color _color, + mat4 _transformationMatrix, + boolean _updateDepthBuffer, + boolean _depthtest) { List vertices; vertices.pushBack(Vector3f(_min.x(), _min.y(),_min.z())); vertices.pushBack(Vector3f(_max.x(), _min.y(),_min.z())); @@ -208,9 +208,9 @@ void ewol::resource::Colored3DObject::drawCubeLine(const Vector3f& _min, drawLine(vertices, _color, _transformationMatrix, _updateDepthBuffer, _depthtest); } -void ewol::resource::Colored3DObject::drawSquare(const Vector3f& _size, - mat4& _transformationMatrix, - const etk::Color& _tmpColor) { +void ewol::resource::Colored3DObject::drawSquare( Vector3f _size, + mat4 _transformationMatrix, + etk::Color _tmpColor) { List tmpVertices; static int indices[36] = { 0,1,2, 3,2,1, 4,0,6, 6,0,2, 5,1,4, 4,1,0, @@ -225,7 +225,7 @@ void ewol::resource::Colored3DObject::drawSquare(const Vector3f& _size, Vector3f(_size[0],-_size[1],-_size[2]), Vector3f(-_size[0],-_size[1],-_size[2])}; tmpVertices.clear(); - for (int32_t iii=0 ; iii<36 ; iii+=3) { + for (int iii=0 ; iii<36 ; iii+=3) { // normal calculation : //btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]); //normal.normalize (); @@ -239,10 +239,10 @@ void ewol::resource::Colored3DObject::drawSquare(const Vector3f& _size, void ewol::resource::Colored3DObject::drawSphere(float _radius, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor) { + mat4 _transformationMatrix, + etk::Color _tmpColor) { List tmpVertices; - for(int32_t iii=0; iii<=_lats; ++iii) { + for(int iii=0; iii<=_lats; ++iii) { float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats); float z0 = _radius*sin(lat0); float zr0 = _radius*cos(lat0); @@ -251,7 +251,7 @@ void ewol::resource::Colored3DObject::drawSphere(float _radius, float z1 = _radius*sin(lat1); float zr1 = _radius*cos(lat1); - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float x = cos(lng); float y = sin(lng); @@ -279,13 +279,13 @@ void ewol::resource::Colored3DObject::drawCylinder(float _radius, float _size, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor) { + mat4 _transformationMatrix, + etk::Color _tmpColor) { List tmpVertices; // center to border (TOP) // center to border (TOP) - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float z = _size*0.5f; @@ -304,7 +304,7 @@ void ewol::resource::Colored3DObject::drawCylinder(float _radius, tmpVertices.pushBack(v2); } // Cylinder - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float z = _size*0.5f; @@ -329,7 +329,7 @@ void ewol::resource::Colored3DObject::drawCylinder(float _radius, tmpVertices.pushBack(v2b); } // center to border (BUTTOM) - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float z = _size*-0.5f; @@ -353,14 +353,14 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius, float _size, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor) { + mat4 _transformationMatrix, + etk::Color _tmpColor) { List tmpVertices; - _lats = int32_t(_lats / 2)*2; + _lats = int(_lats / 2)*2; // center to border (TOP) float offset = _size*0.5f; - for(int32_t iii=_lats/2+1; iii<=_lats; ++iii) { + for(int iii=_lats/2+1; iii<=_lats; ++iii) { float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats); float z0 = _radius*sin(lat0); float zr0 = _radius*cos(lat0); @@ -369,7 +369,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius, float z1 = _radius*sin(lat1); float zr1 = _radius*cos(lat1); - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float x = cos(lng); float y = sin(lng); @@ -391,7 +391,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius, } } // Cylinder - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float z = _size*0.5f; @@ -417,7 +417,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius, } // center to border (BUTTOM) offset = -_size*0.5f; - for(int32_t iii=0; iii<=_lats/2; ++iii) { + for(int iii=0; iii<=_lats/2; ++iii) { float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats); float z0 = _radius*sin(lat0); float zr0 = _radius*cos(lat0); @@ -426,7 +426,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius, float z1 = _radius*sin(lat1); float zr1 = _radius*cos(lat1); - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float x = cos(lng); float y = sin(lng); @@ -454,11 +454,11 @@ void ewol::resource::Colored3DObject::drawCone(float _radius, float _size, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor) { + mat4 _transformationMatrix, + etk::Color _tmpColor) { List tmpVertices; // center to border (TOP) - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; Vector3f v1 = Vector3f(0.0f, 0.0f, -_size/2); @@ -475,7 +475,7 @@ void ewol::resource::Colored3DObject::drawCone(float _radius, tmpVertices.pushBack(v2); } // center to border (BUTTOM) - for(int32_t jjj=0; jjj<_longs; ++jjj) { + for(int jjj=0; jjj<_longs; ++jjj) { float lng = 2.0f * M_PI * float(jjj - 1) / _longs; Vector3f v1 = Vector3f(0.0f, 0.0f, _size/2); @@ -495,25 +495,25 @@ void ewol::resource::Colored3DObject::drawCone(float _radius, draw(tmpVertices, _tmpColor, _transformationMatrix); } -void ewol::resource::Colored3DObject::drawTriangles(const List& _vertex, - const List& _indice, - mat4& _transformationMatrix, - const etk::Color& _tmpColor, - const Vector3f& _offset) { +void ewol::resource::Colored3DObject::drawTriangles( List _vertex, + List _indice, + mat4 _transformationMatrix, + etk::Color _tmpColor, + Vector3f _offset) { List tmpVertices; - for (size_t iii=0; iii<_indice.size()/3; ++iii) { + for (int iii=0; iii<_indice.size()/3; ++iii) { tmpVertices.pushBack(_vertex[_indice[iii*3 + 0]]+_offset); tmpVertices.pushBack(_vertex[_indice[iii*3 + 1]]+_offset); tmpVertices.pushBack(_vertex[_indice[iii*3 + 2]]+_offset); - //Log.info(" indices " << _indice[iii*3 + 0] << " " << _indice[iii*3 + 1] << " " << _indice[iii*3 + 2]); - //Log.info(" triangle " << _vertex[_indice[iii*3 + 0]] << " " << _vertex[_indice[iii*3 + 1]] << " " << _vertex[_indice[iii*3 + 2]]); + //Log.info(" indices " + _indice[iii*3 + 0] + " " + _indice[iii*3 + 1] + " " + _indice[iii*3 + 2]); + //Log.info(" triangle " + _vertex[_indice[iii*3 + 0]] + " " + _vertex[_indice[iii*3 + 1]] + " " + _vertex[_indice[iii*3 + 2]]); } - //Log.info("display " << tmpVertices.size() << " vertices form " << _indice.size()); + //Log.info("display " + tmpVertices.size() + " vertices form " + _indice.size()); draw(tmpVertices, _tmpColor, _transformationMatrix); } namespace etk { - template<> etk::String toString(ewol::resource::Colored3DObject const&) { + template<> String toString(ewol::resource::Colored3DObject ) { return "!!ewol::resource::Colored3DObject!ERROR!CAN_NOT_BE_CONVERT!!"; } } @@ -521,7 +521,7 @@ namespace etk { // declare for signal event ESIGNAL_DECLARE_SIGNAL(ewol::resource::Colored3DObject); -ESIGNAL_DECLARE_SIGNAL(ememory::SharedPtr); +ESIGNAL_DECLARE_SIGNAL(ememory::Ptr); #endif diff --git a/src/org/atriasoft/ewol/resource/Colored3DObject.java b/src/org/atriasoft/ewol/resource/Colored3DObject.java index fe4ba3f..28caea8 100644 --- a/src/org/atriasoft/ewol/resource/Colored3DObject.java +++ b/src/org/atriasoft/ewol/resource/Colored3DObject.java @@ -19,69 +19,69 @@ namespace ewol { */ class Colored3DObject : public gale::Resource { protected: - ememory::SharedPtr m_GLprogram; - int32_t m_GLPosition; - int32_t m_GLMatrix; - int32_t m_GLColor; + ememory::Ptr this.GLprogram; + int this.GLPosition; + int this.GLMatrix; + int this.GLColor; protected: Colored3DObject(); void init(); public: DECLARE_RESOURCE_FACTORY(Colored3DObject); - virtual ~Colored3DObject(); + ~Colored3DObject(); public: - virtual void draw(const List& _vertices, - const etk::Color& _color, - bool _updateDepthBuffer=true, - bool _depthtest=true); - virtual void draw(const List& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer=true, - bool _depthtest=true); - virtual void drawLine(List& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer=true, - bool _depthtest=true); - virtual void drawCubeLine(const Vector3f& _min, - const Vector3f& _max, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer=true, - bool _depthtest=true); + void draw( List _vertices, + etk::Color _color, + boolean _updateDepthBuffer=true, + boolean _depthtest=true); + void draw( List _vertices, + etk::Color _color, + mat4 _transformationMatrix, + boolean _updateDepthBuffer=true, + boolean _depthtest=true); + void drawLine(List _vertices, + etk::Color _color, + mat4 _transformationMatrix, + boolean _updateDepthBuffer=true, + boolean _depthtest=true); + void drawCubeLine( Vector3f _min, + Vector3f _max, + etk::Color _color, + mat4 _transformationMatrix, + boolean _updateDepthBuffer=true, + boolean _depthtest=true); public: - void drawSquare(const Vector3f& _size, - mat4& _transformationMatrix, - const etk::Color& _tmpColor); + void drawSquare( Vector3f _size, + mat4 _transformationMatrix, + etk::Color _tmpColor); void drawSphere(float _radius, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor); + mat4 _transformationMatrix, + etk::Color _tmpColor); void drawCylinder(float _radius, float _size, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor); + mat4 _transformationMatrix, + etk::Color _tmpColor); void drawCapsule(float _radius, float _size, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor); + mat4 _transformationMatrix, + etk::Color _tmpColor); void drawCone(float _radius, float _size, int _lats, int _longs, - mat4& _transformationMatrix, - const etk::Color& _tmpColor); - void drawTriangles(const List& _vertex, - const List& _indice, - mat4& _transformationMatrix, - const etk::Color& _tmpColor, - const Vector3f& _offset=Vector3f(0,0,0.1)); + mat4 _transformationMatrix, + etk::Color _tmpColor); + void drawTriangles( List _vertex, + List _indice, + mat4 _transformationMatrix, + etk::Color _tmpColor, + Vector3f _offset=Vector3f(0,0,0.1)); }; }; }; diff --git a/src/org/atriasoft/ewol/resource/ConfigFile.cpp b/src/org/atriasoft/ewol/resource/ConfigFile.cpp index e1aa7f1..9ae4b63 100644 --- a/src/org/atriasoft/ewol/resource/ConfigFile.cpp +++ b/src/org/atriasoft/ewol/resource/ConfigFile.cpp @@ -17,76 +17,76 @@ ETK_DECLARE_TYPE(ewol::resource::ConfigFile); ewol::resource::ConfigFile::ConfigFile() : gale::Resource(), // set map unorderred - m_list(0, false) { + this.list(0, false) { addResourceType("ewol::ConfigFile"); } -void ewol::resource::ConfigFile::init(const etk::Uri& _uri) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::ConfigFile::init( etk::Uri _uri) { + ethread::RecursiveLock lock(this.mutex); gale::Resource::init(_uri.get()); - Log.debug("SFP : load \"" << _uri << "\""); + Log.debug("SFP : load \"" + _uri + "\""); reload(); } ewol::resource::ConfigFile::~ConfigFile() { - m_list.clear(); + this.list.clear(); } void ewol::resource::ConfigFile::reload() { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); // reset all parameters - for (size_t iii=0; iii m_list; + ejson::Document this.doc; + etk::Map this.list; protected: ConfigFile(); - void init(const etk::Uri& _filename); + void init( etk::Uri _filename); public: - virtual ~ConfigFile(); + ~ConfigFile(); DECLARE_RESOURCE_URI_FACTORY(ConfigFile); public: void reload(); - int32_t request(const etk::String& _paramName); + int request( String _paramName); - double getNumber(int32_t _id); - etk::String getString(int32_t _id); - bool getBoolean(int32_t _id); + double getNumber(int _id); + String getString(int _id); + boolean getBoolean(int _id); public: /** * @brief keep the resource pointer. @@ -38,7 +38,7 @@ namespace ewol { * @param[in] _filename Name of the configuration file. * @return pointer on the resource or null if an error occured. */ - static ememory::SharedPtr keep(const etk::String& _filename); + static ememory::Ptr keep( String _filename); }; }; }; diff --git a/src/org/atriasoft/ewol/resource/DistanceFieldFont.cpp b/src/org/atriasoft/ewol/resource/DistanceFieldFont.cpp index edf8264..3f8ff71 100644 --- a/src/org/atriasoft/ewol/resource/DistanceFieldFont.cpp +++ b/src/org/atriasoft/ewol/resource/DistanceFieldFont.cpp @@ -25,13 +25,13 @@ ETK_DECLARE_TYPE(ewol::resource::DistanceFieldFont); ewol::resource::DistanceFieldFont::DistanceFieldFont() : ewol::resource::Texture(), - m_borderSize(10), - m_textureBorderSize(0,0) { + this.borderSize(10), + this.textureBorderSize(0,0) { addResourceType("ewol::resource::DistanceFieldFont"); - m_font = null; - m_lastGlyphPos.setValue(1,1); - m_lastRawHeigh = 0; - m_sizeRatio = 1.0f; + this.font = null; + this.lastGlyphPos.setValue(1,1); + this.lastRawHeigh = 0; + this.sizeRatio = 1.0f; } /** @@ -43,7 +43,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() : * // out contain: {"DATA:///font", "DATA:///font?lib=ewol"} * @example[stop] */ -static List explodeMultiplePath(const etk::Uri& _uri) { +static List explodeMultiplePath( etk::Uri _uri) { List out; out.pushBack(_uri); if (_uri.getQuery().exist("lib") == true) { @@ -54,10 +54,10 @@ static List explodeMultiplePath(const etk::Uri& _uri) { return out; } -void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::DistanceFieldFont::init( String _fontName) { + ethread::RecursiveLock lock(this.mutex); ewol::resource::Texture::init(_fontName); - etk::String localName = _fontName; + String localName = _fontName; List folderList; if (ewol::getContext().getFontDefault().getUseExternal() == true) { #if defined(__TARGET_OS__Android) @@ -67,61 +67,61 @@ void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) { #endif } etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); - for (auto &it : explodeMultiplePath(applicationBaseFont)) { + for (auto it : explodeMultiplePath(applicationBaseFont)) { folderList.pushBack(it); } - for (size_t folderID = 0; folderID < folderList.size() ; folderID++) { + for (int folderID = 0; folderID < folderList.size() ; folderID++) { List output = etk::uri::listRecursive(folderList[folderID]); - List split = etk::split(localName, ';'); - Log.info("try to find font named : " << split << " in: " << output); - //Log.critical("parse string : " << split); - bool hasFindAFont = false; - for (size_t jjj=0; jjj split = etk::split(localName, ';'); + Log.info("try to find font named : " + split + " in: " + output); + //Log.critical("parse string : " + split); + boolean hasFindAFont = false; + for (int jjj=0; jjjgetHeight(SIZE_GENERATION)); + this.sizeRatio = ((float)SIZE_GENERATION) / ((float)this.font.getHeight(SIZE_GENERATION)); // TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ??? setImageSize(Vector2i(512,32)); // now we can acces directly on the image - m_data.clear(etk::Color<>(0x00000000)); + this.data.clear(etk::Color<>(0x00000000)); // add error glyph addGlyph(0); // by default we set only the first AINSI char availlable - for (int32_t iii=0x20; iii<0x7F; iii++) { + for (int iii=0x20; iii<0x7F; iii++) { addGlyph(iii); } flush(); if (true) { Log.error("Save in cache the loaded data ..... "); - egami::store(m_data, "CACHE:///fileFont.bmp"); // ==> for debug test only ... - egami::store(m_data, "CACHE:///fileFont.png"); + egami::store(this.data, "CACHE:///fileFont.bmp"); // ==> for debug test only ... + egami::store(this.data, "CACHE:///fileFont.png"); } exportOnFile(); } @@ -156,16 +156,16 @@ ewol::resource::DistanceFieldFont::~DistanceFieldFont() { float ewol::resource::DistanceFieldFont::getDisplayRatio(float _size) { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); return _size / (float)SIZE_GENERATION; } -void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) { +void ewol::resource::DistanceFieldFont::generateDistanceField( egami::ImageMono _input, egami::Image _output) { Log.info("Generate Distance field font [START]"); - Log.info(" _input.getSize()=" << _input.getSize()); - ethread::RecursiveLock lock(m_mutex); - int32_t size = _input.getSize().x() * _input.getSize().y(); + Log.info(" _input.getSize()=" + _input.getSize()); + ethread::RecursiveLock lock(this.mutex); + int size = _input.getSize().x() * _input.getSize().y(); List xdist; List ydist; List gx; @@ -180,12 +180,12 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image data.resize(size, 0.0); outside.resize(size, 0.0); inside.resize(size, 0.0); - Log.info(" size=" << size); + Log.info(" size=" + size); // Convert img into double (data) double img_min = 255, img_max = -255; - for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { - for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { - int32_t iii = yyy * _input.getSize().x() + xxx; + for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) { + for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) { + int iii = yyy * _input.getSize().x() + xxx; double v = _input.get(Vector2i(xxx, yyy)); data[iii] = v; if (v > img_max) { @@ -197,43 +197,43 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image } } // Rescale image levels between 0 and 1 - for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { - for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { - int32_t iii = yyy * _input.getSize().x() + xxx; + for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) { + for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) { + int iii = yyy * _input.getSize().x() + xxx; data[iii] = (_input.get(Vector2i(xxx, yyy))-img_min)/img_max; } } // Compute outside = edtaa3(bitmap); % Transform background (0's) - computegradient(&data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); - edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &outside[0]); - for(size_t iii = 0; iii < outside.size(); ++iii) { + computegradient(data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]); + edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &outside[0]); + for(int iii = 0; iii < outside.size(); ++iii) { if( outside[iii] < 0 ) { outside[iii] = 0.0; } } // Compute inside = edtaa3(1-bitmap); % Transform foreground (1's) - for(size_t iii = 0; iii < gx.size(); ++iii) { + for(int iii = 0; iii < gx.size(); ++iii) { gx[iii] = 0; } - for(size_t iii = 0; iii < gy.size(); ++iii) { + for(int iii = 0; iii < gy.size(); ++iii) { gy[iii] = 0; } - for(size_t iii = 0; iii < data.size(); ++iii) { + for(int iii = 0; iii < data.size(); ++iii) { data[iii] = 1 - data[iii]; } - computegradient( &data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); - edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &inside[0]); - for(size_t iii = 0; iii < inside.size(); ++iii) { + computegradient( data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]); + edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &inside[0]); + for(int iii = 0; iii < inside.size(); ++iii) { if( inside[iii] < 0 ) { inside[iii] = 0.0; } } - Log.info(" _output=" << _output); + Log.info(" _output=" + _output); _output.resize(_input.getSize(), etk::Color<>(0)); _output.clear(etk::Color<>(0)); - for (int32_t xxx = 0; xxx < _output.getSize().x(); ++xxx) { - for (int32_t yyy = 0; yyy < _output.getSize().y(); ++yyy) { - int32_t iii = yyy * _output.getSize().x() + xxx; + for (int xxx = 0; xxx < _output.getSize().x(); ++xxx) { + for (int yyy = 0; yyy < _output.getSize().y(); ++yyy) { + int iii = yyy * _output.getSize().x() + xxx; outside[iii] -= inside[iii]; outside[iii] = 128+outside[iii]*16; if( outside[iii] < 0 ) { @@ -242,112 +242,112 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image if( outside[iii] > 255 ) { outside[iii] = 255; } - uint8_t val = 255 - (unsigned char) outside[iii]; + int val = 255 - (unsigned char) outside[iii]; // TODO : Remove multiple size of the map ... - _output.set(Vector2i(xxx, yyy), etk::Color<>((int32_t)val,(int32_t)val,(int32_t)val,255)); + _output.set(Vector2i(xxx, yyy), etk::Color<>((int)val,(int)val,(int)val,255)); } } - Log.info(" _output=" << _output); + Log.info(" _output=" + _output); } -bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) { - ethread::RecursiveLock lock(m_mutex); - bool hasChange = false; - if (m_font == null) { +boolean ewol::resource::DistanceFieldFont::addGlyph( Character _val) { + ethread::RecursiveLock lock(this.mutex); + boolean hasChange = false; + if (this.font == null) { return false; } // add the curent "char" GlyphProperty tmpchar; - tmpchar.m_UVal = _val; + tmpchar.this.UVal = _val; egami::ImageMono imageGlyphRaw; egami::Image imageGlyphDistanceField(Vector2i(32,32), egami::colorType::RGBA8); - Log.debug("Generate Glyph : " << _val); + Log.debug("Generate Glyph : " + _val); - if (m_font->getGlyphProperty(SIZE_GENERATION, tmpchar) == true) { - //Log.debug("load char: '" << _val << "'=" << _val); + if (this.font.getGlyphProperty(SIZE_GENERATION, tmpchar) == true) { + //Log.debug("load char: '" + _val + "'=" + _val); hasChange = true; // change line if needed ... - if (m_lastGlyphPos.x() + tmpchar.m_sizeTexture.x()+m_borderSize*2.0 > m_data.getSize().x()) { - m_lastGlyphPos.setX(1); - m_lastGlyphPos += Vector2i(0, m_lastRawHeigh); - m_lastRawHeigh = 0; + if (this.lastGlyphPos.x() + tmpchar.this.sizeTexture.x()+this.borderSize*2.0 > this.data.getSize().x()) { + this.lastGlyphPos.setX(1); + this.lastGlyphPos += Vector2i(0, this.lastRawHeigh); + this.lastRawHeigh = 0; } - while(m_lastGlyphPos.y()+tmpchar.m_sizeTexture.y()+m_borderSize*2.0 > m_data.getSize().y()) { - Vector2i size = m_data.getSize(); + while(this.lastGlyphPos.y()+tmpchar.this.sizeTexture.y()+this.borderSize*2.0 > this.data.getSize().y()) { + Vector2i size = this.data.getSize(); size.setY(size.y()*2); - Log.verbose("resize " << m_data.getSize() << " => " << size); - m_data.resize(size, etk::Color<>(0)); + Log.verbose("resize " + this.data.getSize() + " => " + size); + this.data.resize(size, etk::Color<>(0)); // change the coordonate on the element in the texture - for (size_t jjj = 0; jjj < m_listElement.size(); ++jjj) { - m_listElement[jjj].m_texturePosStart *= Vector2f(1.0f, 0.5f); - m_listElement[jjj].m_texturePosSize *= Vector2f(1.0f, 0.5f); + for (int jjj = 0; jjj < this.listElement.size(); ++jjj) { + this.listElement[jjj].this.texturePosStart *= Vector2f(1.0f, 0.5f); + this.listElement[jjj].this.texturePosSize *= Vector2f(1.0f, 0.5f); } } - m_textureBorderSize = Vector2f(m_borderSize/(float)m_data.getSize().x(), - m_borderSize/(float)m_data.getSize().y() ); + this.textureBorderSize = Vector2f(this.borderSize/(float)this.data.getSize().x(), + this.borderSize/(float)this.data.getSize().y() ); // draw the glyph - m_font->drawGlyph(imageGlyphRaw, SIZE_GENERATION, tmpchar, m_borderSize); + this.font.drawGlyph(imageGlyphRaw, SIZE_GENERATION, tmpchar, this.borderSize); generateDistanceField(imageGlyphRaw, imageGlyphDistanceField); if (_val == 100) { - Log.debug("print char: " << _val << " size=" << imageGlyphDistanceField.getSize()); - for (int32_t yyy = 0; yyy < imageGlyphDistanceField.getSize().y(); ++yyy) { - for (int32_t xxx = 0; xxx < imageGlyphDistanceField.getSize().x(); ++xxx) { - Log.print((int)(imageGlyphDistanceField.get(Vector2i(xxx, yyy)).r()) << " "); + Log.debug("print char: " + _val + " size=" + imageGlyphDistanceField.getSize()); + for (int yyy = 0; yyy < imageGlyphDistanceField.getSize().y(); ++yyy) { + for (int xxx = 0; xxx < imageGlyphDistanceField.getSize().x(); ++xxx) { + Log.print((int)(imageGlyphDistanceField.get(Vector2i(xxx, yyy)).r()) + " "); } } } - m_data.insert(m_lastGlyphPos, imageGlyphDistanceField); + this.data.insert(this.lastGlyphPos, imageGlyphDistanceField); // set image position - tmpchar.m_texturePosStart.setValue( ((float)m_lastGlyphPos.x()+(m_borderSize*0.5f)) / (float)m_data.getSize().x(), - ((float)m_lastGlyphPos.y()+(m_borderSize*0.5f)) / (float)m_data.getSize().y() ); - tmpchar.m_texturePosSize.setValue( ((float)imageGlyphRaw.getSize().x()-m_borderSize) / (float)m_data.getSize().x(), - ((float)imageGlyphRaw.getSize().y()-m_borderSize) / (float)m_data.getSize().y() ); + tmpchar.this.texturePosStart.setValue( ((float)this.lastGlyphPos.x()+(this.borderSize*0.5f)) / (float)this.data.getSize().x(), + ((float)this.lastGlyphPos.y()+(this.borderSize*0.5f)) / (float)this.data.getSize().y() ); + tmpchar.this.texturePosSize.setValue( ((float)imageGlyphRaw.getSize().x()-this.borderSize) / (float)this.data.getSize().x(), + ((float)imageGlyphRaw.getSize().y()-this.borderSize) / (float)this.data.getSize().y() ); // update the maximum of the line hight : - if (m_lastRawHeigh < imageGlyphRaw.getSize().y()) { + if (this.lastRawHeigh < imageGlyphRaw.getSize().y()) { // note : +1 is for the overlapping of the glyph (Part 2) - m_lastRawHeigh = imageGlyphRaw.getSize().y()+1; + this.lastRawHeigh = imageGlyphRaw.getSize().y()+1; } // note : +1 is for the overlapping of the glyph (Part 3) // update the Bitmap position drawing : - m_lastGlyphPos += Vector2i(imageGlyphRaw.getSize().x()+1, 0); + this.lastGlyphPos += Vector2i(imageGlyphRaw.getSize().x()+1, 0); } else { - EWOL_WARNING("Did not find char : '" << _val << "'=" << _val); + Log.warning("Did not find char : '" + _val + "'=" + _val); tmpchar.setNotExist(); } - m_listElement.pushBack(tmpchar); - //m_font[iii]->display(); + this.listElement.pushBack(tmpchar); + //this.font[iii].display(); // generate the kerning for all the characters : if (tmpchar.exist() == true) { // TODO : set the kerning back ... - //m_font[iii]->generateKerning(m_size, m_listElement[iii]); + //this.font[iii].generateKerning(this.size, this.listElement[iii]); } if (hasChange == true) { flush(); //Log.error("Save in cache the loaded data ..... "); - //egami::store(m_data, "CACHE:///fileFont.bmp"); // ==> for debug test only ... - //egami::store(m_data, "CACHE:///fileFont.png"); + //egami::store(this.data, "CACHE:///fileFont.bmp"); // ==> for debug test only ... + //egami::store(this.data, "CACHE:///fileFont.png"); } return hasChange; } -int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) { - ethread::RecursiveLock lock(m_mutex); +int ewol::resource::DistanceFieldFont::getIndex(Character _charcode) { + ethread::RecursiveLock lock(this.mutex); if (_charcode < 0x20) { return 0; } else if (_charcode < 0x80) { return _charcode - 0x1F; } else { - for (size_t iii=0x80-0x20; iii < m_listElement.size(); iii++) { - //Log.debug("search : '" << charcode << "' =?= '" << (m_listElement[displayMode])[iii].m_UVal << "'"); - if (_charcode == (m_listElement)[iii].m_UVal) { - //Log.debug("search : '" << charcode << "'"); - if ((m_listElement)[iii].exist()) { - //Log.debug("return " << iii); + for (int iii=0x80-0x20; iii < this.listElement.size(); iii++) { + //Log.debug("search : '" + charcode + "' =?= '" + (this.listElement[displayMode])[iii].this.UVal + "'"); + if (_charcode == (this.listElement)[iii].this.UVal) { + //Log.debug("search : '" + charcode + "'"); + if ((this.listElement)[iii].exist()) { + //Log.debug("return " + iii); return iii; } else { return 0; @@ -362,68 +362,68 @@ int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) { return 0; } -ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const char32_t& _charcode) { - ethread::RecursiveLock lock(m_mutex); - Log.verbose("getGlyphPointer : " << uint32_t(_charcode)); - int32_t index = getIndex(_charcode); +ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer( Character _charcode) { + ethread::RecursiveLock lock(this.mutex); + Log.verbose("getGlyphPointer : " + uint(_charcode)); + int index = getIndex(_charcode); if( index < 0 - || (size_t)index >= m_listElement.size() ) { - Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" << index); - if (m_listElement.size() > 0) { - return &((m_listElement)[0]); + || (int)index >= this.listElement.size() ) { + Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" + index); + if (this.listElement.size() > 0) { + return ((this.listElement)[0]); } return null; } - //Log.error(" index=" << index); - //Log.error(" m_UVal=" << m_listElement[_displayMode][index].m_UVal); - //Log.error(" m_glyphIndex=" << m_listElement[_displayMode][index].m_glyphIndex); - //Log.error(" m_advance=" << m_listElement[_displayMode][index].m_advance); - //Log.error(" m_bearing=" << m_listElement[_displayMode][index].m_bearing); - return &((m_listElement)[index]); + //Log.error(" index=" + index); + //Log.error(" this.UVal=" + this.listElement[_displayMode][index].this.UVal); + //Log.error(" this.glyphIndex=" + this.listElement[_displayMode][index].this.glyphIndex); + //Log.error(" this.advance=" + this.listElement[_displayMode][index].this.advance); + //Log.error(" this.bearing=" + this.listElement[_displayMode][index].this.bearing); + return ((this.listElement)[index]); } void ewol::resource::DistanceFieldFont::exportOnFile() { - ethread::RecursiveLock lock(m_mutex); - Log.debug("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'"); + ethread::RecursiveLock lock(this.mutex); + Log.debug("EXPORT: DistanceFieldFont : file : '" + this.fileName + ".json'"); ejson::Document doc; ejson::Array tmpList; - for (size_t iii=0; iii otherwise I can just generate italic ... // == > Bold is a little more complicated (maybe with the bordersize) - ememory::SharedPtr m_font; + ememory::Ptr this.font; public: - List m_listElement; + List this.listElement; private: // for the texture generation : - Vector2i m_lastGlyphPos; - int32_t m_lastRawHeigh; + Vector2i this.lastGlyphPos; + int this.lastRawHeigh; protected: DistanceFieldFont(); - void init(const etk::String& _fontName); + void init( String _fontName); public: DECLARE_RESOURCE_NAMED_FACTORY(DistanceFieldFont); - virtual ~DistanceFieldFont(); + ~DistanceFieldFont(); public: float getDisplayRatio(float _size); /** @@ -39,7 +39,7 @@ namespace ewol { * @return Dimention of the font need between 2 lines */ float getHeight(float _size) { - return ((float)m_font->getHeight(_size)); + return ((float)this.font.getHeight(_size)); }; /** * @brief get the font size with a specific display size @@ -47,20 +47,20 @@ namespace ewol { * @return Dimention of the font for this compleate line size. */ float getSize(float _fontHeight) { - return m_font->getSizeWithHeight(_fontHeight); + return this.font.getSizeWithHeight(_fontHeight); } /** * @brief get the ID of a unicode charcode * @param[in] _charcode The unicodeValue * @return The ID in the table (if it does not exist : return 0) */ - int32_t getIndex(char32_t _charcode); + int getIndex(Character _charcode); /** * @brief get the pointer on the coresponding glyph * @param[in] _charcode The unicodeValue * @return The pointer on the glyph == > never null */ - ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode); + ewol::GlyphProperty* getGlyphPointer( Character _charcode); public: /** * @brief keep the resource pointer. @@ -68,29 +68,29 @@ namespace ewol { * @param[in] _filename Name of the texture font. * @return pointer on the resource or null if an error occured. */ - static ememory::SharedPtr keep(const etk::String& _filename); + static ememory::Ptr keep( String _filename); private: /** * @brief add a glyph in a texture font. * @param[in] _val Char value to add. * @return true if the image size have change, false otherwise */ - bool addGlyph(const char32_t& _val); + boolean addGlyph( Character _val); - void generateDistanceField(const egami::ImageMono& _input, egami::Image& _output); + void generateDistanceField( egami::ImageMono _input, egami::Image _output); private: - float m_borderSize; //!< number of pixel added on the border of a glyph - Vector2f m_textureBorderSize; //!< Transformed the border size in the texture dimention + float this.borderSize; //!< number of pixel added on the border of a glyph + Vector2f this.textureBorderSize; //!< Transformed the border size in the texture dimention public: float getPixelBorderSize() { - return m_borderSize; + return this.borderSize; } - const Vector2f& getTextureBorderSize() { - return m_textureBorderSize; + Vector2f getTextureBorderSize() { + return this.textureBorderSize; } public: void exportOnFile(); - bool importFromFile(); + boolean importFromFile(); }; }; }; diff --git a/src/org/atriasoft/ewol/resource/FontFreeType.cpp b/src/org/atriasoft/ewol/resource/FontFreeType.cpp index 83ceade..319ec63 100644 --- a/src/org/atriasoft/ewol/resource/FontFreeType.cpp +++ b/src/org/atriasoft/ewol/resource/FontFreeType.cpp @@ -19,7 +19,7 @@ ETK_DECLARE_TYPE(ewol::resource::FontFreeType); // free Font hnadle of librairies ... entry for acces ... -static int32_t l_countLoaded=0; +static int l_countLoaded=0; static FT_Library library; void ewol::resource::freeTypeInit() { @@ -29,7 +29,7 @@ void ewol::resource::freeTypeInit() { // already loaded ... return; } - int32_t error = FT_Init_FreeType( &library ); + int error = FT_Init_FreeType( library ); if(0 != error) { Log.critical(" when loading FreeType Librairy ..."); } @@ -42,7 +42,7 @@ void ewol::resource::freeTypeUnInit() { // already needed ... return; } - int32_t error = FT_Done_FreeType( library ); + int error = FT_Done_FreeType( library ); library = null; if(0 != error) { Log.critical(" when Un-loading FreeType Librairy ..."); @@ -51,50 +51,50 @@ void ewol::resource::freeTypeUnInit() { ewol::resource::FontFreeType::FontFreeType() { addResourceType("ewol::FontFreeType"); - m_init = false; - m_FileSize = 0; + this.init = false; + this.FileSize = 0; } -void ewol::resource::FontFreeType::init(const etk::Uri& _uri) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::FontFreeType::init( etk::Uri _uri) { + ethread::RecursiveLock lock(this.mutex); ewol::resource::FontBase::init(_uri); auto fileIO = etk::uri::get(_uri); if (fileIO == null) { - Log.error("File Does not exist : " << _uri); + Log.error("File Does not exist : " + _uri); return; } - if (fileIO->open(etk::io::OpenMode::Read) == false) { - Log.error("Can not open the file : " << _uri); + if (fileIO.open(etk::io::OpenMode::Read) == false) { + Log.error("Can not open the file : " + _uri); return; } - m_FileBuffer = fileIO->readAll(); + this.FileBuffer = fileIO.readAll(); // close the file: - fileIO->close(); + fileIO.close(); // load Face ... - int32_t error = FT_New_Memory_Face(library, &m_FileBuffer[0], m_FileBuffer.size(), 0, &m_fftFace ); + int error = FT_New_Memory_Face(library, this.FileBuffer[0], this.FileBuffer.size(), 0, this.fftFace ); if( FT_Err_Unknown_File_Format == error) { Log.error("... the font file could be opened and read, but it appears ... that its font format is unsupported"); } else if (0 != error) { Log.error("... another error code means that the font file could not ... be opened or read, or simply that it is broken..."); } else { // all OK - Log.debug("load font : \"" << _uri << "\" glyph count = " << (int)m_fftFace->num_glyphs); - m_init = true; + Log.debug("load font : \"" + _uri + "\" glyph count = " + (int)this.fftFace.nuthis.glyphs); + this.init = true; //display(); } } ewol::resource::FontFreeType::~FontFreeType() { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); // clean the tmp memory - m_FileBuffer.clear(); + this.FileBuffer.clear(); // must be deleted fftFace - FT_Done_Face(m_fftFace); + FT_Done_Face(this.fftFace); } -Vector2f ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::String& _unicodeString) { - ethread::RecursiveLock lock(m_mutex); - if (m_init == false) { +Vector2f ewol::resource::FontFreeType::getSize(int _fontSize, String _unicodeString) { + ethread::RecursiveLock lock(this.mutex); + if (this.init == false) { return Vector2f(0,0); } // TODO : ... @@ -102,35 +102,35 @@ Vector2f ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::Str return outputSize; } -int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) { - ethread::RecursiveLock lock(m_mutex); +int ewol::resource::FontFreeType::getHeight(int _fontSize) { + ethread::RecursiveLock lock(this.mutex); return _fontSize*1.43f; // this is a really "magic" number ... } float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); return _fontHeight*0.6993f; // this is a really "magic" number ... } -bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) { - ethread::RecursiveLock lock(m_mutex); - if(false == m_init) { +boolean ewol::resource::FontFreeType::getGlyphProperty(int _fontSize, ewol::GlyphProperty _property) { + ethread::RecursiveLock lock(this.mutex); + if(false == this.init) { return false; } // 300dpi (hight quality) 96 dpi (normal quality) - int32_t fontQuality = 96; + int fontQuality = 96; // Select size ... - // note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype - int32_t error = FT_Set_Char_Size(m_fftFace, _fontSize<<6, _fontSize<<6, fontQuality, fontQuality); + // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype + int error = FT_Set_Char_Size(this.fftFace, _fontSize+6, _fontSize+6, fontQuality, fontQuality); if (0!=error ) { Log.error("FT_Set_Char_Size == > error in settings ..."); return false; } // a small shortcut - FT_GlyphSlot slot = m_fftFace->glyph; + FT_GlyphSlot slot = this.fftFace.glyph; // retrieve glyph index from character code - int32_t glyph_index = FT_Get_Char_Index(m_fftFace, _property.m_UVal); + int glyph_index = FT_Get_Char_Index(this.fftFace, _property.this.UVal); // load glyph image into the slot (erase previous one) - error = FT_Load_Glyph(m_fftFace, // handle to face object + error = FT_Load_Glyph(this.fftFace, // handle to face object glyph_index, // glyph index FT_LOAD_DEFAULT ); if (0!=error ) { @@ -144,37 +144,37 @@ bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::Gly return false; } // set properties : - _property.m_glyphIndex = glyph_index; - _property.m_sizeTexture.setValue(slot->bitmap.width, slot->bitmap.rows); - _property.m_bearing.setValue( slot->metrics.horiBearingX>>6 , slot->metrics.horiBearingY>>6 ); - _property.m_advance.setValue( slot->metrics.horiAdvance>>6 , slot->metrics.vertAdvance>>6 ); + _property.this.glyphIndex = glyph_index; + _property.this.sizeTexture.setValue(slot.bitmap.width, slot.bitmap.rows); + _property.this.bearing.setValue( slot.metrics.horiBearingX>>6 , slot.metrics.horiBearingY>>6 ); + _property.this.advance.setValue( slot.metrics.horiAdvance>>6 , slot.metrics.vertAdvance>>6 ); return true; } -bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut, - int32_t _fontSize, +boolean ewol::resource::FontFreeType::drawGlyph(egami::Image _imageOut, + int _fontSize, Vector2i _glyphPosition, - ewol::GlyphProperty& _property, + ewol::GlyphProperty _property, int8_t _posInImage) { - ethread::RecursiveLock lock(m_mutex); - if(m_init == false) { + ethread::RecursiveLock lock(this.mutex); + if(this.init == false) { return false; } // 300dpi (hight quality) 96 dpi (normal quality) - int32_t fontQuality = 96; + int fontQuality = 96; // Select size ... - // note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype - int32_t error = FT_Set_Char_Size(m_fftFace, _fontSize<<6, _fontSize<<6, fontQuality, fontQuality); + // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype + int error = FT_Set_Char_Size(this.fftFace, _fontSize+6, _fontSize+6, fontQuality, fontQuality); if (0!=error ) { Log.error("FT_Set_Char_Size == > error in settings ..."); return false; } // a small shortcut - FT_GlyphSlot slot = m_fftFace->glyph; + FT_GlyphSlot slot = this.fftFace.glyph; // load glyph image into the slot (erase previous one) - error = FT_Load_Glyph(m_fftFace, // handle to face object - _property.m_glyphIndex, // glyph index + error = FT_Load_Glyph(this.fftFace, // handle to face object + _property.this.glyphIndex, // glyph index FT_LOAD_DEFAULT ); if (0!=error ) { Log.error("FT_Load_Glyph specify Glyph"); @@ -188,10 +188,10 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut, } // draw it on the output Image : etk::Color<> tlpppp(0xFF, 0xFF, 0xFF, 0x00); - for(size_t jjj=0; jjj < slot->bitmap.rows;jjj++) { - for(size_t iii=0; iii < slot->bitmap.width; iii++){ + for(int jjj=0; jjj < slot.bitmap.rows;jjj++) { + for(int iii=0; iii < slot.bitmap.width; iii++){ tlpppp = _imageOut.get(Vector2i(_glyphPosition.x()+iii, _glyphPosition.y()+jjj)); - uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj]; + int valueColor = slot.bitmap.buffer[iii + slot.bitmap.width*jjj]; // set only alpha : switch(_posInImage) { default: @@ -215,28 +215,28 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut, return true; } -bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut, - int32_t _fontSize, - ewol::GlyphProperty& _property, - int32_t _borderSize) { - ethread::RecursiveLock lock(m_mutex); - if(false == m_init) { +boolean ewol::resource::FontFreeType::drawGlyph(egami::ImageMono _imageOut, + int _fontSize, + ewol::GlyphProperty _property, + int _borderSize) { + ethread::RecursiveLock lock(this.mutex); + if(false == this.init) { return false; } // 300dpi (hight quality) 96 dpi (normal quality) - int32_t fontQuality = 96; + int fontQuality = 96; // Select size ... - // note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype - int32_t error = FT_Set_Char_Size(m_fftFace, _fontSize<<6, _fontSize<<6, fontQuality, fontQuality); + // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype + int error = FT_Set_Char_Size(this.fftFace, _fontSize+6, _fontSize+6, fontQuality, fontQuality); if (0!=error ) { Log.error("FT_Set_Char_Size == > error in settings ..."); return false; } // a small shortcut - FT_GlyphSlot slot = m_fftFace->glyph; + FT_GlyphSlot slot = this.fftFace.glyph; // load glyph image into the slot (erase previous one) - error = FT_Load_Glyph(m_fftFace, // handle to face object - _property.m_glyphIndex, // glyph index + error = FT_Load_Glyph(this.fftFace, // handle to face object + _property.this.glyphIndex, // glyph index FT_LOAD_DEFAULT ); if (0!=error ) { Log.error("FT_Load_Glyph specify Glyph"); @@ -249,11 +249,11 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut, return false; } // resize output image : - _imageOut.resize(Vector2i(slot->bitmap.width+2*_borderSize, slot->bitmap.rows+2*_borderSize), 0); + _imageOut.resize(Vector2i(slot.bitmap.width+2*_borderSize, slot.bitmap.rows+2*_borderSize), 0); - for(size_t jjj=0; jjj < slot->bitmap.rows;jjj++) { - for(size_t iii=0; iii < slot->bitmap.width; iii++){ - uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj]; + for(int jjj=0; jjj < slot.bitmap.rows;jjj++) { + for(int iii=0; iii < slot.bitmap.width; iii++){ + int valueColor = slot.bitmap.buffer[iii + slot.bitmap.width*jjj]; // real set of color _imageOut.set(Vector2i(_borderSize+iii, _borderSize+jjj), valueColor ); } @@ -262,34 +262,34 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut, } -void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, List& listGlyph) { - ethread::RecursiveLock lock(m_mutex); - if(m_init == false) { +void ewol::resource::FontFreeType::generateKerning(int fontSize, List listGlyph) { + ethread::RecursiveLock lock(this.mutex); + if(this.init == false) { return; } - if ((FT_FACE_FLAG_KERNING & m_fftFace->face_flags) == 0) { + if ((FT_FACE_FLAG_KERNING this.fftFace.face_flags) == 0) { Log.info("No kerning generation (disable) in the font"); } // 300dpi (hight quality) 96 dpi (normal quality) - int32_t fontQuality = 96; + int fontQuality = 96; // Select size ... - // note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype - int32_t error = FT_Set_Char_Size(m_fftFace, fontSize<<6, fontSize<<6, fontQuality, fontQuality); + // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype + int error = FT_Set_Char_Size(this.fftFace, fontSize+6, fontSize+6, fontQuality, fontQuality); if (0!=error ) { Log.error("FT_Set_Char_Size == > error in settings ..."); return; } // For all the kerning element we get the kerning value : - for(size_t iii=0; iii " << (kerning.x/64.0f)); + //Log.debug("Kerning between : '" + (char)listGlyph[iii].this.UVal + "''" + (char)listGlyph[kkk].this.UVal + "' value : " + kerning.x + " => " + (kerning.x/64.0f)); } } } @@ -297,88 +297,88 @@ void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, Listface_flags) != 0) { + if ((FT_FACE_FLAG_FIXED_SIZES this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_FIXED_SIZES (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_FIXED_SIZES (disable)"); } - if ((FT_FACE_FLAG_FIXED_WIDTH & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_FIXED_WIDTH this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_FIXED_WIDTH (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_FIXED_WIDTH (disable)"); } - if ((FT_FACE_FLAG_SFNT & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_SFNT this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_SFNT (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_SFNT (disable)"); } - if ((FT_FACE_FLAG_HORIZONTAL & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_HORIZONTAL this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_HORIZONTAL (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_HORIZONTAL (disable)"); } - if ((FT_FACE_FLAG_VERTICAL & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_VERTICAL this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_VERTICAL (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_VERTICAL (disable)"); } - if ((FT_FACE_FLAG_KERNING & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_KERNING this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_KERNING (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_KERNING (disable)"); } /* Deprecated flag - if ((FT_FACE_FLAG_FAST_GLYPHS & face->face_flags) != 0) { + if ((FT_FACE_FLAG_FAST_GLYPHS face.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_FAST_GLYPHS (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_FAST_GLYPHS (disable)"); } */ - if ((FT_FACE_FLAG_MULTIPLE_MASTERS & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_MULTIPLE_MASTERS this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_MULTIPLE_MASTERS (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_MULTIPLE_MASTERS (disable)"); } - if ((FT_FACE_FLAG_GLYPH_NAMES & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_GLYPH_NAMES this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_GLYPH_NAMES (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_GLYPH_NAMES (disable)"); } - if ((FT_FACE_FLAG_EXTERNAL_STREAM & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_EXTERNAL_STREAM this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_EXTERNAL_STREAM (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_EXTERNAL_STREAM (disable)"); } - if ((FT_FACE_FLAG_HINTER & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_HINTER this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_HINTER (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_HINTER (disable)"); } - if ((FT_FACE_FLAG_CID_KEYED & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_CID_KEYED this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_CID_KEYED (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_CID_KEYED (disable)"); } /* - if ((FT_FACE_FLAG_TRICKY & m_fftFace->face_flags) != 0) { + if ((FT_FACE_FLAG_TRICKY this.fftFace.face_flags) != 0) { Log.info(" flags = FT_FACE_FLAG_TRICKY (enable)"); } else { Log.debug(" flags = FT_FACE_FLAG_TRICKY (disable)"); } */ - Log.info(" unit per EM = " << m_fftFace->units_per_EM); - Log.info(" num of fixed sizes = " << m_fftFace->num_fixed_sizes); - //Log.info(" Availlable sizes = " << (int)m_fftFace->available_sizes); + Log.info(" unit per EM = " + this.fftFace.units_per_EM); + Log.info(" num of fixed sizes = " + this.fftFace.nuthis.fixed_sizes); + //Log.info(" Availlable sizes = " + (int)this.fftFace.available_sizes); - //Log.info(" Current size = " << (int)m_fftFace->size); + //Log.info(" Current size = " + (int)this.fftFace.size); } diff --git a/src/org/atriasoft/ewol/resource/FontFreeType.java b/src/org/atriasoft/ewol/resource/FontFreeType.java index 03b0576..9279162 100644 --- a/src/org/atriasoft/ewol/resource/FontFreeType.java +++ b/src/org/atriasoft/ewol/resource/FontFreeType.java @@ -20,39 +20,39 @@ namespace ewol { // show : http://www.freetype.org/freetype2/docs/tutorial/step2.html class FontFreeType : public ewol::resource::FontBase { private: - List m_FileBuffer; - int32_t m_FileSize; - FT_Face m_fftFace; - bool m_init; + List this.FileBuffer; + int this.FileSize; + FT_Face this.fftFace; + boolean this.init; void display(); protected: FontFreeType(); - void init(const etk::Uri& _uri); + void init( etk::Uri _uri); public: DECLARE_RESOURCE_URI_FACTORY(FontFreeType); - virtual ~FontFreeType(); + ~FontFreeType(); public: - bool getGlyphProperty(int32_t _fontSize, - ewol::GlyphProperty& _property); + boolean getGlyphProperty(int _fontSize, + ewol::GlyphProperty _property); - bool drawGlyph(egami::Image& _imageOut, - int32_t _fontSize, + boolean drawGlyph(egami::Image _imageOut, + int _fontSize, Vector2i _glyphPosition, - ewol::GlyphProperty& _property, + ewol::GlyphProperty _property, int8_t _posInImage); - bool drawGlyph(egami::ImageMono& _imageOut, - int32_t _fontSize, - ewol::GlyphProperty& _property, - int32_t _borderSize = 0); + boolean drawGlyph(egami::ImageMono _imageOut, + int _fontSize, + ewol::GlyphProperty _property, + int _borderSize = 0); - Vector2f getSize(int32_t _fontSize, const etk::String& _unicodeString); + Vector2f getSize(int _fontSize, String _unicodeString); - int32_t getHeight(int32_t _fontSize); + int getHeight(int _fontSize); float getSizeWithHeight(float _fontHeight); - void generateKerning(int32_t _fontSize, List& _listGlyph); + void generateKerning(int _fontSize, List _listGlyph); }; void freeTypeInit(); void freeTypeUnInit(); diff --git a/src/org/atriasoft/ewol/resource/ImageDF.cpp b/src/org/atriasoft/ewol/resource/ImageDF.cpp index 3a33149..de6aaa3 100644 --- a/src/org/atriasoft/ewol/resource/ImageDF.cpp +++ b/src/org/atriasoft/ewol/resource/ImageDF.cpp @@ -21,39 +21,39 @@ ewol::resource::ImageDF::ImageDF() { void ewol::resource::ImageDF::init() { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); ewol::resource::Texture::init(); } -void ewol::resource::ImageDF::init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::ImageDF::init(String _genName, etk::Uri _uri, Vector2i _size) { + ethread::RecursiveLock lock(this.mutex); ewol::resource::Texture::init(_genName); - Log.debug("create a new resource::Image : _genName=" << _genName << " _uri=" << _uri << " size=" << _size); - m_data = egami::load(_uri, _size); - if (m_data.exist() == false) { - Log.error("ERROR when loading the image : " << _uri); + Log.debug("create a new resource::Image : _genName=" + _genName + " _uri=" + _uri + " size=" + _size); + this.data = egami::load(_uri, _size); + if (this.data.exist() == false) { + Log.error("ERROR when loading the image : " + _uri); } - Vector2i tmp = m_data.getSize(); - m_realImageSize = Vector2f(tmp.x(), tmp.y()); + Vector2i tmp = this.data.getSize(); + this.realImageSize = Vector2f(tmp.x(), tmp.y()); // distance field Generation // TODO : if it is not a .edf ==> generate dynamicly ... /* egami::ImageMono input; input.resize(tmp); - for (size_t yyy = 0; yyy < tmp.y(); ++yyy) { - for (size_t xxx = 0; xxx < tmp.x(); ++xxx) { - input.set(Vector2i(xxx, yyy), m_data.get(Vector2i(xxx, yyy)).a() ); + for (int yyy = 0; yyy < tmp.y(); ++yyy) { + for (int xxx = 0; xxx < tmp.x(); ++xxx) { + input.set(Vector2i(xxx, yyy), this.data.get(Vector2i(xxx, yyy)).a() ); } } - generateDistanceField(input, m_data); + generateDistanceField(input, this.data); */ flush(); } -void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) { - ethread::RecursiveLock lock(m_mutex); - int32_t size = _input.getSize().x() * _input.getSize().y(); +void ewol::resource::ImageDF::generateDistanceField( egami::ImageMono _input, egami::Image _output) { + ethread::RecursiveLock lock(this.mutex); + int size = _input.getSize().x() * _input.getSize().y(); List xdist; List ydist; List gx; @@ -70,9 +70,9 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp inside.resize(size, 0.0); // Convert img into double (data) double img_min = 255, img_max = -255; - for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { - for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { - int32_t iii = yyy * _input.getSize().x() + xxx; + for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) { + for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) { + int iii = yyy * _input.getSize().x() + xxx; double v = _input.get(Vector2i(xxx, yyy)); data[iii] = v; if (v > img_max) { @@ -84,35 +84,35 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp } } // Rescale image levels between 0 and 1 - for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { - for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { - int32_t iii = yyy * _input.getSize().x() + xxx; + for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) { + for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) { + int iii = yyy * _input.getSize().x() + xxx; data[iii] = (_input.get(Vector2i(xxx, yyy))-img_min)/img_max; } } // Compute outside = edtaa3(bitmap); % Transform background (0's) - computegradient(&data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); - edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &outside[0]); - for(size_t iii = 0; iii < outside.size(); ++iii) { + computegradient(data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]); + edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &outside[0]); + for(int iii = 0; iii < outside.size(); ++iii) { if( outside[iii] < 0 ) { outside[iii] = 0.0; } } // Compute inside = edtaa3(1-bitmap); % Transform foreground (1's) - for(size_t iii = 0; iii < gx.size(); ++iii) { + for(int iii = 0; iii < gx.size(); ++iii) { gx[iii] = 0; } - for(size_t iii = 0; iii < gy.size(); ++iii) { + for(int iii = 0; iii < gy.size(); ++iii) { gy[iii] = 0; } - for(size_t iii = 0; iii < data.size(); ++iii) { + for(int iii = 0; iii < data.size(); ++iii) { data[iii] = 1 - data[iii]; } - computegradient( &data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); - edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &inside[0]); - for(size_t iii = 0; iii < inside.size(); ++iii) { + computegradient( data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]); + edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &inside[0]); + for(int iii = 0; iii < inside.size(); ++iii) { if( inside[iii] < 0 ) { inside[iii] = 0.0; } @@ -120,9 +120,9 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp _output.resize(_input.getSize(), etk::Color<>(0)); _output.clear(etk::Color<>(0)); - for (int32_t xxx = 0; xxx < _output.getSize().x(); ++xxx) { - for (int32_t yyy = 0; yyy < _output.getSize().y(); ++yyy) { - int32_t iii = yyy * _output.getSize().x() + xxx; + for (int xxx = 0; xxx < _output.getSize().x(); ++xxx) { + for (int yyy = 0; yyy < _output.getSize().y(); ++yyy) { + int iii = yyy * _output.getSize().x() + xxx; outside[iii] -= inside[iii]; outside[iii] = 128+outside[iii]*16; if( outside[iii] < 0 ) { @@ -131,9 +131,9 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp if( outside[iii] > 255 ) { outside[iii] = 255; } - uint8_t val = 255 - (unsigned char) outside[iii]; + int val = 255 - (unsigned char) outside[iii]; // TODO : Remove multiple size of the map ... - _output.set(Vector2i(xxx, yyy), etk::Color<>((int32_t)val,(int32_t)val,(int32_t)val,255)); + _output.set(Vector2i(xxx, yyy), etk::Color<>((int)val,(int)val,(int)val,255)); } } } @@ -145,30 +145,30 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp * @param[in] _value Value that we want the next power of 2 * @return result value */ -static int32_t nextP2(int32_t _value) { - int32_t val=1; - for (int32_t iii=1; iii<31; iii++) { +static int nextP2(int _value) { + int val=1; + for (int iii=1; iii<31; iii++) { if (_value <= val) { return val; } val *=2; } - Log.critical("impossible CASE.... request P2 of " << _value); + Log.critical("impossible CASE.... request P2 of " + _value); return val; } #endif -ememory::SharedPtr ewol::resource::ImageDF::create(const etk::Uri& _uri, Vector2i _size) { - Log.verbose("KEEP: TextureFile: '" << _uri << "' size=" << _size); +ememory::Ptr ewol::resource::ImageDF::create( etk::Uri _uri, Vector2i _size) { + Log.verbose("KEEP: TextureFile: '" + _uri + "' size=" + _size); if (_uri.isEmpty() == true) { - ememory::SharedPtr object(ETK_NEW(ewol::resource::ImageDF)); + ememory::Ptr object(ETK_NEW(ewol::resource::ImageDF)); if (object == null) { Log.error("allocation error of a resource : ??TEX??"); return null; } - object->init(); + object.init(); getManager().localAdd(object); return object; } @@ -189,8 +189,8 @@ ememory::SharedPtr ewol::resource::ImageDF::create(cons _size = Vector2i(64,64); #endif if ( _size.x() > 0 - && _size.y() > 0) { - Log.verbose(" == > specific size : " << _size); + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _size.y() > 0) { + Log.verbose(" == > specific size : " + _size); #ifdef __TARGET_OS__Android _size.setValue(nextP2(_size.x()), nextP2(_size.y())); #endif @@ -198,27 +198,27 @@ ememory::SharedPtr ewol::resource::ImageDF::create(cons tmpFilename.getQuery().set("y", etk::toString(_size.y())); } - Log.verbose("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); - ememory::SharedPtr object = null; - ememory::SharedPtr object2 = getManager().localKeep("DF__" + tmpFilename.getString()); + Log.verbose("KEEP: TextureFile: '" + tmpFilename + "' new size=" + _size); + ememory::Ptr object = null; + ememory::Ptr object2 = getManager().localKeep("DF__" + tmpFilename.getString()); if (object2 != null) { object = ememory::dynamicPointerCast(object2); if (object == null) { - Log.critical("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); + Log.critical("Request resource file : '" + tmpFilename + "' With the wrong type (dynamic cast error)"); return null; } } if (object != null) { return object; } - Log.info("CREATE: ImageDF: '" << tmpFilename << "' size=" << _size); + Log.info("CREATE: ImageDF: '" + tmpFilename + "' size=" + _size); // need to crate a new one ... - object = ememory::SharedPtr(ETK_NEW(ewol::resource::ImageDF)); + object = ememory::Ptr(ETK_NEW(ewol::resource::ImageDF)); if (object == null) { - Log.error("allocation error of a resource : " << _uri); + Log.error("allocation error of a resource : " + _uri); return null; } - object->init("DF__" + tmpFilename.getString(), _uri, _size); + object.init("DF__" + tmpFilename.getString(), _uri, _size); getManager().localAdd(object); return object; } diff --git a/src/org/atriasoft/ewol/resource/ImageDF.java b/src/org/atriasoft/ewol/resource/ImageDF.java index a59ffa1..90110dd 100644 --- a/src/org/atriasoft/ewol/resource/ImageDF.java +++ b/src/org/atriasoft/ewol/resource/ImageDF.java @@ -14,23 +14,23 @@ namespace ewol { namespace resource { class ImageDF : public ewol::resource::Texture { protected: - Vector2f m_realImageSize; + Vector2f this.realImageSize; protected: ImageDF(); void init(); - void init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size); + void init(String _genName, etk::Uri _uri, Vector2i _size); public: - virtual ~ImageDF() { }; + ~ImageDF() { }; protected: /** * @brief Generate distance field of this Image input. * @param[in] _input Input image to change in distance field mode. * @param[out] _output New image generate with this image _input. */ - void generateDistanceField(const egami::ImageMono& _input, egami::Image& _output); + void generateDistanceField( egami::ImageMono _input, egami::Image _output); public: - const Vector2f& getRealSize() { - return m_realImageSize; + Vector2f getRealSize() { + return this.realImageSize; }; public: /** @@ -40,7 +40,7 @@ namespace ewol { * @param[in] _requested size of the image (usefull when loading .svg to automatic rescale) * @return pointer on the resource or null if an error occured. */ - static ememory::SharedPtr create(const etk::Uri& _uri, Vector2i _size=Vector2i(-1,-1)); + static ememory::Ptr create( etk::Uri _uri, Vector2i _size=Vector2i(-1,-1)); }; }; }; diff --git a/src/org/atriasoft/ewol/resource/Texture.cpp b/src/org/atriasoft/ewol/resource/Texture.cpp index c73b6c5..b612312 100644 --- a/src/org/atriasoft/ewol/resource/Texture.cpp +++ b/src/org/atriasoft/ewol/resource/Texture.cpp @@ -20,9 +20,9 @@ ETK_DECLARE_TYPE(ewol::resource::Texture); * @param[in] value Value that we want the next power of 2 * @return result value */ -static int32_t nextP2(int32_t _value) { - int32_t val=1; - for (int32_t iii=1; iii<31; iii++) { +static int nextP2(int _value) { + int val=1; + for (int iii=1; iii<31; iii++) { if (_value <= val) { return val; } @@ -32,7 +32,7 @@ static int32_t nextP2(int32_t _value) { return val; } -void ewol::resource::Texture::init(const etk::String& _filename) { +void ewol::resource::Texture::init( String _filename) { gale::Resource::init(_filename); } void ewol::resource::Texture::init() { @@ -40,18 +40,18 @@ void ewol::resource::Texture::init() { } ewol::resource::Texture::Texture() : - m_texId(0), + this.texId(0), #ifdef EWOL_USE_FBO - m_texPboId(0), + this.texPboId(0), #endif - m_data(Vector2i(32,32),egami::colorType::RGBA8), - m_realImageSize(1,1), - m_lastSize(1,1), - m_loaded(false), - m_lastTypeObject(0), - m_lastSizeObject(0), - m_repeat(false), - m_filter(ewol::resource::TextureFilter::linear) { + this.data(Vector2i(32,32),egami::colorType::RGBA8), + this.realImageSize(1,1), + this.lastSize(1,1), + this.loaded(false), + this.lastTypeObject(0), + this.lastSizeObject(0), + this.repeat(false), + this.filter(ewol::resource::TextureFilter::linear) { addResourceType("ewol::compositing::Texture"); } @@ -60,34 +60,34 @@ ewol::resource::Texture::~Texture() { } -void ewol::resource::Texture::setRepeat(bool _value) { - m_repeat = _value; +void ewol::resource::Texture::setRepeat(boolean _value) { + this.repeat = _value; } void ewol::resource::Texture::setFilterMode(enum ewol::resource::TextureFilter _filter) { - m_filter = _filter; + this.filter = _filter; } #include -bool ewol::resource::Texture::updateContext() { +boolean ewol::resource::Texture::updateContext() { Log.verbose("updateContext [START]"); if (false) { echrono::Steady tic = echrono::Steady::now(); gale::openGL::flush(); echrono::Steady toc = echrono::Steady::now(); - Log.verbose(" updateContext [FLUSH] ==> " << (toc - tic)); + Log.verbose(" updateContext [FLUSH] ==> " + (toc - tic)); } - ethread::RecursiveLock lock(m_mutex, true); + ethread::RecursiveLock lock(this.mutex, true); echrono::Steady tic = echrono::Steady::now(); if (lock.tryLock() == false) { //Lock error ==> try later ... return false; } - int32_t typeObject = GL_RGBA; - int32_t sizeObject = GL_UNSIGNED_BYTE; - int32_t sizeByte = 1; - switch (m_data.getType()) { + int typeObject = GL_RGBA; + int sizeObject = GL_UNSIGNED_BYTE; + int sizeByte = 1; + switch (this.data.getType()) { case egami::colorType::RGBA8: typeObject = GL_RGBA; sizeObject = GL_UNSIGNED_BYTE; @@ -112,52 +112,52 @@ bool ewol::resource::Texture::updateContext() { case egami::colorType::unsignedInt32: case egami::colorType::float32: case egami::colorType::float64: - Log.error("Not manage the type " << m_data.getType() << " for texture"); + Log.error("Not manage the type " + this.data.getType() + " for texture"); break; } - if (m_loaded == true) { - if ( m_lastTypeObject != typeObject - || m_lastSizeObject != sizeObject - || m_lastSize != m_data.getSize()) { - EWOL_WARNING("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); - glDeleteTextures(1, &m_texId); - m_loaded = false; + if (this.loaded == true) { + if ( this.lastTypeObject != typeObject + || this.lastSizeObject != sizeObject + || this.lastSize != this.data.getSize()) { + Log.warning("TEXTURE: Rm [" + getId() + "] texId=" + this.texId); + glDeleteTextures(1, this.texId); + this.loaded = false; } } - if (m_loaded == false) { + if (this.loaded == false) { // Request a new texture at openGl : - glGenTextures(1, &m_texId); + glGenTextures(1, this.texId); #ifdef EWOL_USE_FBO Log.error("CREATE PBO"); - glGenBuffers(1, &m_texPboId); + glGenBuffers(1, this.texPboId); Log.error("CREATE PBO 1"); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_texPboId); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this.texPboId); Log.error("CREATE PBO 2"); - glBufferData(GL_PIXEL_UNPACK_BUFFER, m_data.getGPUSize().x()*m_data.getGPUSize().y()*sizeByte, 0, GL_STREAM_DRAW); + glBufferData(GL_PIXEL_UNPACK_BUFFER, this.data.getGPUSize().x()*this.data.getGPUSize().y()*sizeByte, 0, GL_STREAM_DRAW); Log.error("CREATE PBO 3"); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); Log.error("CREATE PBO 4 (done)"); #endif - m_lastSize = m_data.getSize(); - m_lastTypeObject = typeObject; - m_lastSizeObject = sizeObject; - Log.debug("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << "=>" << m_data.getGPUSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType()); + this.lastSize = this.data.getSize(); + this.lastTypeObject = typeObject; + this.lastSizeObject = sizeObject; + Log.debug("TEXTURE: add [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize() + " OGl_Id=" + this.texId + " type=" << this.data.getType()); } else { - Log.debug("TEXTURE: update [" << getId() << "]=" << m_data.getSize() << "=>" << m_data.getGPUSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType()); + Log.debug("TEXTURE: update [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize() + " OGl_Id=" + this.texId + " type=" << this.data.getType()); } // in all case we set the texture properties : // TODO : check error ??? - glBindTexture(GL_TEXTURE_2D, m_texId); - if (m_loaded == false) { - if (m_repeat == false) { + glBindTexture(GL_TEXTURE_2D, this.texId); + if (this.loaded == false) { + if (this.repeat == false) { glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); } else { glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); } - if (m_filter == ewol::resource::TextureFilter::linear) { + if (this.filter == ewol::resource::TextureFilter::linear) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { @@ -167,30 +167,30 @@ bool ewol::resource::Texture::updateContext() { } //glPixelStorei(GL_UNPACK_ALIGNMENT,1); echrono::Steady toc1 = echrono::Steady::now(); - Log.verbose(" BIND ==> " << (toc1 - tic)); - //egami::store(m_data, etk::String("~/texture_") + etk::toString(getId()) + ".bmp"); + Log.verbose(" BIND ==> " + (toc1 - tic)); + //egami::store(this.data, String("~/texture_") + etk::toString(getId()) + ".bmp"); #if defined(__TARGET_OS__Android) \ || defined(__TARGET_OS__IOs) // On some embended target, the texture size must be square of 2: - if (m_loaded == false) { + if (this.loaded == false) { // 1: Create the square 2 texture: - int32_t bufferSize = m_data.getGPUSize().x() * m_data.getGPUSize().y() * 8; + int bufferSize = this.data.getGPUSize().x() * this.data.getGPUSize().y() * 8; static List tmpData; if (tmpData.size() < bufferSize) { tmpData.resize(bufferSize, 0.0f); } - Log.debug(" CREATE texture ==> " << m_data.getGPUSize()); + Log.debug(" CREATE texture ==> " + this.data.getGPUSize()); // 2 create a new empty texture: #ifdef EWOL_USE_FBO - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_texPboId); - void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_data.getGPUSize().x() * m_data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT); - memcpy(pBuff, &tmpData[0], m_data.getGPUSize().x()*m_data.getGPUSize().y()*sizeByte); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this.texPboId); + void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, this.data.getGPUSize().x() * this.data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT); + memcpy(pBuff, tmpData[0], this.data.getGPUSize().x()*this.data.getGPUSize().y()*sizeByte); glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); glTexImage2D(GL_TEXTURE_2D, // Target 0, // Level typeObject, // Format internal - m_data.getGPUSize().x(), - m_data.getGPUSize().y(), + this.data.getGPUSize().x(), + this.data.getGPUSize().y(), 0, // Border typeObject, // format sizeObject, // type @@ -199,26 +199,26 @@ bool ewol::resource::Texture::updateContext() { glTexImage2D(GL_TEXTURE_2D, // Target 0, // Level typeObject, // Format internal - m_data.getGPUSize().x(), - m_data.getGPUSize().y(), + this.data.getGPUSize().x(), + this.data.getGPUSize().y(), 0, // Border typeObject, // format sizeObject, // type - &tmpData[0] ); + tmpData[0] ); #endif } #ifdef EWOL_USE_FBO - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_texPboId); - void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_data.getGPUSize().x() * m_data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT); - memcpy(pBuff, m_data.getTextureDataPointer(), m_data.getWidth()*m_data.getHeight()*sizeByte); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this.texPboId); + void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, this.data.getGPUSize().x() * this.data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT); + memcpy(pBuff, this.data.getTextureDataPointer(), this.data.getWidth()*this.data.getHeight()*sizeByte); glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); //3 Flush all time the data: glTexSubImage2D(GL_TEXTURE_2D, // Target 0, // Level 0, // x offset 0, // y offset - m_data.getWidth(), - m_data.getHeight(), + this.data.getWidth(), + this.data.getHeight(), typeObject, // format sizeObject, // type (void *)0 ); @@ -230,90 +230,90 @@ bool ewol::resource::Texture::updateContext() { 0, // Level 0, // x offset 0, // y offset - m_data.getWidth(), - m_data.getHeight(), + this.data.getWidth(), + this.data.getHeight(), typeObject, // format sizeObject, // type - (void*)((char*)m_data.getTextureDataPointer()) ); + (void*)((char*)this.data.getTextureDataPointer()) ); echrono::Steady toc2 = echrono::Steady::now(); - Log.info(" updateContext [STOP] ==> " << (toc2 - tic1)); + Log.info(" updateContext [STOP] ==> " + (toc2 - tic1)); #endif #else // This is the normal case ==> set the image and after set just the update of the data - if (m_loaded == false) { + if (this.loaded == false) { glTexImage2D(GL_TEXTURE_2D, // Target 0, // Level typeObject, // Format internal - m_data.getWidth(), - m_data.getHeight(), + this.data.getWidth(), + this.data.getHeight(), 0, // Border typeObject, // format sizeObject, // type - m_data.getTextureDataPointer() ); + this.data.getTextureDataPointer() ); } else { glTexSubImage2D(GL_TEXTURE_2D, // Target 0, // Level 0, // x offset 0, // y offset - m_data.getWidth(), - m_data.getHeight(), + this.data.getWidth(), + this.data.getHeight(), typeObject, // format sizeObject, // type - m_data.getTextureDataPointer() ); + this.data.getTextureDataPointer() ); } #endif // now the data is loaded - m_loaded = true; + this.loaded = true; echrono::Steady toc = echrono::Steady::now(); - //Log.error(" updateContext [STOP] ==> " << (toc - toc1)); + //Log.error(" updateContext [STOP] ==> " + (toc - toc1)); return true; } void ewol::resource::Texture::removeContext() { - ethread::RecursiveLock lock(m_mutex); - if (m_loaded == true) { + ethread::RecursiveLock lock(this.mutex); + if (this.loaded == true) { // Request remove texture ... - Log.debug("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); + Log.debug("TEXTURE: Rm [" + getId() + "] texId=" + this.texId); // TODO: Check if we are in the correct thread - glDeleteTextures(1, &m_texId); - m_loaded = false; + glDeleteTextures(1, this.texId); + this.loaded = false; } } void ewol::resource::Texture::removeContextToLate() { - ethread::RecursiveLock lock(m_mutex); - m_loaded = false; - m_texId=0; + ethread::RecursiveLock lock(this.mutex); + this.loaded = false; + this.texId=0; } void ewol::resource::Texture::flush() { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); // request to the manager to be call at the next update ... Log.verbose("Request UPDATE of Element"); getManager().update(ememory::dynamicPointerCast(sharedFromThis())); } void ewol::resource::Texture::setImageSize(Vector2i _newSize) { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); _newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) ); - m_data.resize(_newSize); + this.data.resize(_newSize); } void ewol::resource::Texture::set(egami::Image _image) { Log.debug("Set a new image in a texture:"); - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); if (_image.exist() == false) { Log.error("ERROR when loading the image : [raw data]"); return; } - Log.debug(" size=" << _image.getSize()); - etk::swap(m_data, _image); - Vector2i tmp = m_data.getSize(); - m_realImageSize = Vector2f(tmp.x(), tmp.y()); + Log.debug(" size=" + _image.getSize()); + etk::swap(this.data, _image); + Vector2i tmp = this.data.getSize(); + this.realImageSize = Vector2f(tmp.x(), tmp.y()); Vector2f compatibilityHWSize = Vector2f(nextP2(tmp.x()), nextP2(tmp.y())); - if (m_realImageSize != compatibilityHWSize) { - Log.verbose("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize); - m_data.resize(Vector2i(compatibilityHWSize.x(),compatibilityHWSize.y())); + if (this.realImageSize != compatibilityHWSize) { + Log.verbose("RESIZE Image for HArwareCompatibility:" + this.realImageSize + " => " + compatibilityHWSize); + this.data.resize(Vector2i(compatibilityHWSize.x(),compatibilityHWSize.y())); } flush(); } diff --git a/src/org/atriasoft/ewol/resource/Texture.java b/src/org/atriasoft/ewol/resource/Texture.java index 237586d..df8e52d 100644 --- a/src/org/atriasoft/ewol/resource/Texture.java +++ b/src/org/atriasoft/ewol/resource/Texture.java @@ -20,30 +20,30 @@ namespace ewol { }; class Texture : public gale::Resource { protected: - uint32_t m_texId; //!< openGl textureID. + uint this.texId; //!< openGl textureID. #ifdef EWOL_USE_FBO - uint32_t m_texPboId; //!< openGl textureID. + uint this.texPboId; //!< openGl textureID. #endif // openGl Context propoerties : - egami::Image m_data; + egami::Image this.data; //! Last loaded size in the system openGL - Vector2f m_lastSize; - //! some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0 - Vector2f m_realImageSize; + Vector2f this.lastSize; + //! some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 . 1.0 + Vector2f this.realImageSize; // internal state of the openGl system : - bool m_loaded; - int32_t m_lastTypeObject; - int32_t m_lastSizeObject; + boolean this.loaded; + int this.lastTypeObject; + int this.lastSizeObject; protected: - bool m_repeat; //!< repeate mode of the image (repeat the image if out of range [0..1] + boolean this.repeat; //!< repeate mode of the image (repeat the image if out of range [0..1] public: /** * @brief Set the repeate mode of the images if UV range is out of [0..1] * @param[in] _value Value of the new repeate mode */ - void setRepeat(bool _value); + void setRepeat(boolean _value); protected: - enum ewol::resource::TextureFilter m_filter; //!< Filter apply at the image when rendering it + enum ewol::resource::TextureFilter this.filter; //!< Filter apply at the image when rendering it public: /** * @brief Set the Filter mode to apply at the image when display with a scale (not 1:1 ratio) @@ -52,18 +52,18 @@ namespace ewol { void setFilterMode(enum ewol::resource::TextureFilter _filter); // Public API: protected: - void init(const etk::String& _filename); + void init( String _filename); void init(); Texture(); public: DECLARE_RESOURCE_FACTORY(Texture); - virtual ~Texture(); + ~Texture(); public: // You must set the size here, because it will be set in multiple of pow(2) void setImageSize(Vector2i _newSize); // Get the reference on this image to draw nomething on it ... - inline egami::Image& get() { - return m_data; + egami::Image get() { + return this.data; }; /** * @brief Set the image in the texture system @@ -73,17 +73,17 @@ namespace ewol { void set(egami::Image _image); // Flush the data to send it at the openGl system void flush(); - bool updateContext(); + boolean updateContext(); void removeContext(); void removeContextToLate(); - const Vector2i& getOpenGlSize() const { - return m_data.getSize(); + Vector2i getOpenGlSize() { + return this.data.getSize(); }; - const Vector2f& getUsableSize() const { - return m_realImageSize; + Vector2f getUsableSize() { + return this.realImageSize; }; - uint32_t getRendererId() const { - return m_texId; + uint getRendererId() { + return this.texId; }; }; } diff --git a/src/org/atriasoft/ewol/resource/TextureFile.cpp b/src/org/atriasoft/ewol/resource/TextureFile.cpp index a7c5193..576de46 100644 --- a/src/org/atriasoft/ewol/resource/TextureFile.cpp +++ b/src/org/atriasoft/ewol/resource/TextureFile.cpp @@ -14,23 +14,23 @@ #include ETK_DECLARE_TYPE(ewol::resource::TextureFile); -const Vector2i ewol::resource::TextureFile::sizeAuto(-1,-1); -const Vector2i ewol::resource::TextureFile::sizeDefault(0,0); + Vector2i ewol::resource::TextureFile::sizeAuto(-1,-1); + Vector2i ewol::resource::TextureFile::sizeDefault(0,0); /** * @brief get the next power 2 if the input * @param[in] _value Value that we want the next power of 2 * @return result value */ -static int32_t nextP2(int32_t _value) { - int32_t val=1; - for (int32_t iii=1; iii<31; iii++) { +static int nextP2(int _value) { + int val=1; + for (int iii=1; iii<31; iii++) { if (_value <= val) { return val; } val *=2; } - Log.critical("impossible CASE.... request P2 of " << _value); + Log.critical("impossible CASE.... request P2 of " + _value); return val; } @@ -41,32 +41,32 @@ ewol::resource::TextureFile::TextureFile() { } void ewol::resource::TextureFile::init() { - ethread::RecursiveLock lock(m_mutex); + ethread::RecursiveLock lock(this.mutex); ewol::resource::Texture::init(); } -void ewol::resource::TextureFile::init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::TextureFile::init(String _genName, etk::Uri _uri, Vector2i _size) { + ethread::RecursiveLock lock(this.mutex); ewol::resource::Texture::init(_genName); - Log.debug("create a new resource::Image : _genName=" << _genName << " _uri=" << _uri << " size=" << _size); + Log.debug("create a new resource::Image : _genName=" + _genName + " _uri=" + _uri + " size=" + _size); egami::Image tmp = egami::load(_uri, _size); set(etk::move(tmp)); - //m_lastSize = m_realImageSize; + //this.lastSize = this.realImageSize; #ifdef GENERATE_DISTANCE_FIELD_MODE - //egami::generateDistanceFieldFile(_uri, etk::String(_uri, 0, _uri.size()-4) + ".bmp"); - egami::generateDistanceFieldFile(_uri, etk::String(_uri, 0, _uri.size()-4) + ".edf"); + //egami::generateDistanceFieldFile(_uri, String(_uri, 0, _uri.size()-4) + ".bmp"); + egami::generateDistanceFieldFile(_uri, String(_uri, 0, _uri.size()-4) + ".edf"); #endif } -ememory::SharedPtr ewol::resource::TextureFile::create(const etk::Uri& _uri, Vector2i _size, Vector2i _sizeRegister) { - Log.verbose("KEEP: TextureFile: '" << _uri << "' size=" << _size << " sizeRegister=" << _sizeRegister); +ememory::Ptr ewol::resource::TextureFile::create( etk::Uri _uri, Vector2i _size, Vector2i _sizeRegister) { + Log.verbose("KEEP: TextureFile: '" + _uri + "' size=" + _size + " sizeRegister=" + _sizeRegister); if (_uri.isEmpty() == true) { - ememory::SharedPtr object(ETK_NEW(ewol::resource::TextureFile)); + ememory::Ptr object(ETK_NEW(ewol::resource::TextureFile)); if (object == null) { Log.error("allocation error of a resource : ??TEX??"); return null; } - object->init(); + object.init(); getManager().localAdd(object); return object; } @@ -82,8 +82,8 @@ ememory::SharedPtr ewol::resource::TextureFile::cre if (etk::toLower(_uri.getPath().getExtention()) != "svg") { _size = ewol::resource::TextureFile::sizeAuto; } - if (_size.x()>0 && _size.y()>0) { - Log.verbose(" == > specific size : " << _size); + if (_size.x()>0 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _size.y()>0) { + Log.verbose(" == > specific size : " + _size); _size.setValue(nextP2(_size.x()), nextP2(_size.y())); if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) { if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) { @@ -93,27 +93,27 @@ ememory::SharedPtr ewol::resource::TextureFile::cre } } - Log.verbose("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); - ememory::SharedPtr object = null; - ememory::SharedPtr object2 = getManager().localKeep(tmpFilename.getString()); + Log.verbose("KEEP: TextureFile: '" + tmpFilename + "' new size=" + _size); + ememory::Ptr object = null; + ememory::Ptr object2 = getManager().localKeep(tmpFilename.getString()); if (object2 != null) { object = ememory::dynamicPointerCast(object2); if (object == null) { - Log.critical("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); + Log.critical("Request resource file : '" + tmpFilename + "' With the wrong type (dynamic cast error)"); return null; } } if (object != null) { return object; } - Log.debug("CREATE: TextureFile: '" << tmpFilename << "' size=" << _size); + Log.debug("CREATE: TextureFile: '" + tmpFilename + "' size=" + _size); // need to crate a new one ... - object = ememory::SharedPtr(ETK_NEW(ewol::resource::TextureFile)); + object = ememory::Ptr(ETK_NEW(ewol::resource::TextureFile)); if (object == null) { - Log.error("allocation error of a resource : " << _uri); + Log.error("allocation error of a resource : " + _uri); return null; } - object->init(tmpFilename.getString(), _uri, _size); + object.init(tmpFilename.getString(), _uri, _size); getManager().localAdd(object); return object; } diff --git a/src/org/atriasoft/ewol/resource/TextureFile.java b/src/org/atriasoft/ewol/resource/TextureFile.java index 28f81c5..9ae3b1b 100644 --- a/src/org/atriasoft/ewol/resource/TextureFile.java +++ b/src/org/atriasoft/ewol/resource/TextureFile.java @@ -17,17 +17,17 @@ namespace ewol { namespace resource { class TextureFile : public ewol::resource::Texture { public: - static const Vector2i sizeAuto; - static const Vector2i sizeDefault; + static Vector2i sizeAuto; + static Vector2i sizeDefault; protected: TextureFile(); void init(); - void init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size); + void init(String _genName, etk::Uri _uri, Vector2i _size); public: - virtual ~TextureFile() { }; + ~TextureFile() { }; public: - const Vector2f& getRealSize() { - return m_realImageSize; + Vector2f getRealSize() { + return this.realImageSize; }; public: /** @@ -38,7 +38,7 @@ namespace ewol { * @param[in] _sizeRegister size register in named (When you preaload the images the size write here will be ) * @return pointer on the resource or null if an error occured. */ - static ememory::SharedPtr create(const etk::Uri& _filename, + static ememory::Ptr create( etk::Uri _filename, Vector2i _size=ewol::resource::TextureFile::sizeAuto, Vector2i _sizeRegister=ewol::resource::TextureFile::sizeAuto); }; diff --git a/src/org/atriasoft/ewol/resource/TexturedFont.cpp b/src/org/atriasoft/ewol/resource/TexturedFont.cpp index ea79679..ee1c505 100644 --- a/src/org/atriasoft/ewol/resource/TexturedFont.cpp +++ b/src/org/atriasoft/ewol/resource/TexturedFont.cpp @@ -17,29 +17,29 @@ ETK_DECLARE_TYPE(ewol::font::mode); ETK_DECLARE_TYPE(ewol::resource::TexturedFont); -etk::Stream& ewol::operator <<(etk::Stream& _os, enum ewol::font::mode _obj) { +etk::Stream ewol::operator +(etk::Stream _os, enum ewol::font::mode _obj) { switch(_obj) { default : - _os << "error"; + _os + "error"; break; case ewol::font::Regular: - _os << "Regular"; + _os + "Regular"; break; case ewol::font::Italic: - _os << "Italic"; + _os + "Italic"; break; case ewol::font::Bold: - _os << "Bold"; + _os + "Bold"; break; case ewol::font::BoldItalic: - _os << "BoldItalic"; + _os + "BoldItalic"; break; } return _os; } ewol::resource::TexturedFont::TexturedFont(): - m_size(10) { + this.size(10) { addResourceType("ewol::resource::TexturedFont"); } @@ -52,7 +52,7 @@ ewol::resource::TexturedFont::TexturedFont(): * // out contain: {"DATA:///font", "DATA:///font?lib=ewol"} * @example[stop] */ -static List explodeMultiplePath(const etk::Uri& _uri) { +static List explodeMultiplePath( etk::Uri _uri) { List out; out.pushBack(_uri); if (_uri.getQuery().exist("lib") == true) { @@ -63,53 +63,53 @@ static List explodeMultiplePath(const etk::Uri& _uri) { return out; } -void ewol::resource::TexturedFont::init(const etk::String& _fontName) { - ethread::RecursiveLock lock(m_mutex); +void ewol::resource::TexturedFont::init( String _fontName) { + ethread::RecursiveLock lock(this.mutex); ewol::resource::Texture::init(_fontName); - Log.debug("Load font : '" << _fontName << "'" ); + Log.debug("Load font : '" + _fontName + "'" ); - m_font[0] = null; - m_font[1] = null; - m_font[2] = null; - m_font[3] = null; + this.font[0] = null; + this.font[1] = null; + this.font[2] = null; + this.font[3] = null; - m_modeWraping[0] = ewol::font::Regular; - m_modeWraping[1] = ewol::font::Regular; - m_modeWraping[2] = ewol::font::Regular; - m_modeWraping[3] = ewol::font::Regular; + this.modeWraping[0] = ewol::font::Regular; + this.modeWraping[1] = ewol::font::Regular; + this.modeWraping[2] = ewol::font::Regular; + this.modeWraping[3] = ewol::font::Regular; - m_lastGlyphPos[0].setValue(1,1); - m_lastGlyphPos[1].setValue(1,1); - m_lastGlyphPos[2].setValue(1,1); - m_lastGlyphPos[3].setValue(1,1); + this.lastGlyphPos[0].setValue(1,1); + this.lastGlyphPos[1].setValue(1,1); + this.lastGlyphPos[2].setValue(1,1); + this.lastGlyphPos[3].setValue(1,1); - m_lastRawHeigh[0] = 0; - m_lastRawHeigh[1] = 0; - m_lastRawHeigh[2] = 0; - m_lastRawHeigh[3] = 0; + this.lastRawHeigh[0] = 0; + this.lastRawHeigh[1] = 0; + this.lastRawHeigh[2] = 0; + this.lastRawHeigh[3] = 0; - int32_t tmpSize = 0; + int tmpSize = 0; // extarct name and size : - const char * tmpData = _fontName.c_str(); - const char * tmpPos = strchr(tmpData, ':'); + char * tmpData = _fontName.c_str(); + char * tmpPos = strchr(tmpData, ':'); if (tmpPos == null) { - m_size = 1; - Log.critical("Can not parse the font name: '" << _fontName << "' ??? ':' " ); + this.size = 1; + Log.critical("Can not parse the font name: '" + _fontName + "' ??? ':' " ); return; } else { - if (sscanf(tmpPos+1, "%d", &tmpSize)!=1) { - m_size = 1; - Log.critical("Can not parse the font name: '" << _fontName << "' == > size ???"); + if (sscanf(tmpPos+1, "%d", tmpSize)!=1) { + this.size = 1; + Log.critical("Can not parse the font name: '" + _fontName + "' == > size ???"); return; } } - etk::String localName(_fontName, 0, (tmpPos - tmpData)); + String localName(_fontName, 0, (tmpPos - tmpData)); if (tmpSize>400) { - Log.error("Font size too big ==> limit at 400 when exxeed ==> error: " << tmpSize << "==>30"); + Log.error("Font size too big ==> limit at 400 when exxeed ==> error: " + tmpSize + "==>30"); tmpSize = 30; } - m_size = tmpSize; + this.size = tmpSize; List folderList; if (ewol::getContext().getFontDefault().getUseExternal() == true) { @@ -120,29 +120,29 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) { #endif } etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); - for (auto &it : explodeMultiplePath(applicationBaseFont)) { + for (auto it : explodeMultiplePath(applicationBaseFont)) { folderList.pushBack(it); } - for (size_t folderID = 0; folderID < folderList.size() ; folderID++) { + for (int folderID = 0; folderID < folderList.size() ; folderID++) { List output = etk::uri::listRecursive(folderList[folderID]); - List split = etk::split(localName, ';'); - Log.debug("try to find font named : " << split << " in: " << output); - //Log.critical("parse string : " << split); - bool hasFindAFont = false; - for (size_t jjj=0; jjj split = etk::split(localName, ';'); + Log.debug("try to find font named : " + split + " in: " + output); + //Log.critical("parse string : " + split); + boolean hasFindAFont = false; + for (int jjj=0; jjj= 0; iii--) { - if (m_fileName[iii].isEmpty() == false) { + for(int iii=3; iii >= 0; iii--) { + if (this.fileName[iii].isEmpty() == false) { refMode = (enum ewol::font::mode)iii; } } - Log.debug(" set reference mode : " << refMode); + Log.debug(" set reference mode : " + refMode); // generate the wrapping on the preventing error - for(int32_t iii=3; iii >= 0; iii--) { - if (m_fileName[iii].isEmpty() == false) { - m_modeWraping[iii] = (enum ewol::font::mode)iii; + for(int iii=3; iii >= 0; iii--) { + if (this.fileName[iii].isEmpty() == false) { + this.modeWraping[iii] = (enum ewol::font::mode)iii; } else { - m_modeWraping[iii] = refMode; + this.modeWraping[iii] = refMode; } } - for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { - if (m_fileName[iiiFontId].isEmpty() == true) { - Log.debug("can not load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size ); - m_font[iiiFontId] = null; + for (int iiiFontId=0; iiiFontId<4 ; iiiFontId++) { + if (this.fileName[iiiFontId].isEmpty() == true) { + Log.debug("can not load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size ); + this.font[iiiFontId] = null; continue; } - Log.debug("Load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size); - m_font[iiiFontId] = ewol::resource::FontFreeType::create(m_fileName[iiiFontId]); - if (m_font[iiiFontId] == null) { - Log.debug("error in loading FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size ); + Log.debug("Load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size); + this.font[iiiFontId] = ewol::resource::FontFreeType::create(this.fileName[iiiFontId]); + if (this.font[iiiFontId] == null) { + Log.debug("error in loading FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size ); } } - for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { + for (int iiiFontId=0; iiiFontId<4 ; iiiFontId++) { // set the bassic charset: - m_listElement[iiiFontId].clear(); - if (m_font[iiiFontId] == null) { + this.listElement[iiiFontId].clear(); + if (this.font[iiiFontId] == null) { continue; } - m_height[iiiFontId] = m_font[iiiFontId]->getHeight(m_size); + this.height[iiiFontId] = this.font[iiiFontId].getHeight(this.size); // TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ??? setImageSize(Vector2i(256,32)); // now we can acces directly on the image - m_data.clear(etk::Color<>(0x00000000)); + this.data.clear(etk::Color<>(0x00000000)); } // add error glyph addGlyph(0); // by default we set only the first AINSI char availlable - for (int32_t iii=0x20; iii<0x7F; iii++) { - Log.verbose("Add clyph :" << iii); + for (int iii=0x20; iii<0x7F; iii++) { + Log.verbose("Add clyph :" + iii); addGlyph(iii); } flush(); Log.debug("Wrapping properties : "); - Log.debug(" " << ewol::font::Regular << " == >" << getWrappingMode(ewol::font::Regular)); - Log.debug(" " << ewol::font::Italic << " == >" << getWrappingMode(ewol::font::Italic)); - Log.debug(" " << ewol::font::Bold << " == >" << getWrappingMode(ewol::font::Bold)); - Log.debug(" " << ewol::font::BoldItalic << " == >" << getWrappingMode(ewol::font::BoldItalic)); + Log.debug(" " + ewol::font::Regular + " == >" + getWrappingMode(ewol::font::Regular)); + Log.debug(" " + ewol::font::Italic + " == >" + getWrappingMode(ewol::font::Italic)); + Log.debug(" " + ewol::font::Bold + " == >" + getWrappingMode(ewol::font::Bold)); + Log.debug(" " + ewol::font::BoldItalic + " == >" + getWrappingMode(ewol::font::BoldItalic)); } ewol::resource::TexturedFont::~TexturedFont() { } -bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) { - ethread::RecursiveLock lock(m_mutex); - bool hasChange = false; +boolean ewol::resource::TexturedFont::addGlyph( Character _val) { + ethread::RecursiveLock lock(this.mutex); + boolean hasChange = false; // for each font : - for (int32_t iii=0; iii<4 ; iii++) { - if (m_font[iii] == null) { + for (int iii=0; iii<4 ; iii++) { + if (this.font[iii] == null) { continue; } // add the curent "char" GlyphProperty tmpchar; - tmpchar.m_UVal = _val; + tmpchar.this.UVal = _val; - if (m_font[iii]->getGlyphProperty(m_size, tmpchar) == true) { - //Log.debug("load char : '" << _val << "'=" << _val.get()); + if (this.font[iii].getGlyphProperty(this.size, tmpchar) == true) { + //Log.debug("load char : '" + _val + "'=" + _val.get()); hasChange = true; // change line if needed ... - if (m_lastGlyphPos[iii].x()+tmpchar.m_sizeTexture.x()+3 > m_data.getSize().x()) { - m_lastGlyphPos[iii].setX(1); - m_lastGlyphPos[iii] += Vector2i(0, m_lastRawHeigh[iii]); - m_lastRawHeigh[iii] = 0; + if (this.lastGlyphPos[iii].x()+tmpchar.this.sizeTexture.x()+3 > this.data.getSize().x()) { + this.lastGlyphPos[iii].setX(1); + this.lastGlyphPos[iii] += Vector2i(0, this.lastRawHeigh[iii]); + this.lastRawHeigh[iii] = 0; } - while(m_lastGlyphPos[iii].y()+tmpchar.m_sizeTexture.y()+3 > m_data.getSize().y()) { - Vector2i size = m_data.getSize(); + while(this.lastGlyphPos[iii].y()+tmpchar.this.sizeTexture.y()+3 > this.data.getSize().y()) { + Vector2i size = this.data.getSize(); size.setY(size.y()*2); - m_data.resize(size, etk::Color<>(0)); + this.data.resize(size, etk::Color<>(0)); // note : need to rework all the lyer due to the fact that the texture is used by the faur type... - for (size_t kkk=0; kkk<4 ; kkk++) { + for (int kkk=0; kkk<4 ; kkk++) { // change the coordonate on the element in the texture - for (size_t jjj=0 ; jjjdrawGlyph(m_data, m_size, m_lastGlyphPos[iii], tmpchar, iii); + this.font[iii].drawGlyph(this.data, this.size, this.lastGlyphPos[iii], tmpchar, iii); // set video position - tmpchar.m_texturePosStart.setValue( (float)m_lastGlyphPos[iii].x() / (float)m_data.getSize().x(), - (float)m_lastGlyphPos[iii].y() / (float)m_data.getSize().y() ); - tmpchar.m_texturePosSize.setValue( (float)tmpchar.m_sizeTexture.x() / (float)m_data.getSize().x(), - (float)tmpchar.m_sizeTexture.y() / (float)m_data.getSize().y() ); + tmpchar.this.texturePosStart.setValue( (float)this.lastGlyphPos[iii].x() / (float)this.data.getSize().x(), + (float)this.lastGlyphPos[iii].y() / (float)this.data.getSize().y() ); + tmpchar.this.texturePosSize.setValue( (float)tmpchar.this.sizeTexture.x() / (float)this.data.getSize().x(), + (float)tmpchar.this.sizeTexture.y() / (float)this.data.getSize().y() ); // update the maximum of the line hight : - if (m_lastRawHeigh[iii] for debug test only ... + //egami::store(this.data, "fileFont.bmp"); // ==> for debug test only ... } return hasChange; } -int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) { - ethread::RecursiveLock lock(m_mutex); +int ewol::resource::TexturedFont::getIndex(Character _charcode, enum ewol::font::mode _displayMode) { + ethread::RecursiveLock lock(this.mutex); if (_charcode < 0x20) { return 0; } else if (_charcode < 0x80) { return _charcode - 0x1F; } else { - for (size_t iii=0x80-0x20; iii < m_listElement[_displayMode].size(); iii++) { - //Log.debug("search : '" << charcode << "' =?= '" << (m_listElement[displayMode])[iii].m_UVal << "'"); - if (_charcode == (m_listElement[_displayMode])[iii].m_UVal) { - //Log.debug("search : '" << charcode << "'"); - if ((m_listElement[_displayMode])[iii].exist()) { - //Log.debug("return " << iii); + for (int iii=0x80-0x20; iii < this.listElement[_displayMode].size(); iii++) { + //Log.debug("search : '" + charcode + "' =?= '" + (this.listElement[displayMode])[iii].this.UVal + "'"); + if (_charcode == (this.listElement[_displayMode])[iii].this.UVal) { + //Log.debug("search : '" + charcode + "'"); + if ((this.listElement[_displayMode])[iii].exist()) { + //Log.debug("return " + iii); return iii; } else { return 0; @@ -347,23 +347,23 @@ int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ew return 0; } -ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) { - ethread::RecursiveLock lock(m_mutex); - //Log.debug("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]); - int32_t index = getIndex(_charcode, _displayMode); +ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer( Character _charcode, enum ewol::font::mode _displayMode) { + ethread::RecursiveLock lock(this.mutex); + //Log.debug("Get glyph property for mode: " + _displayMode + " == > wrapping index : " + this.modeWraping[_displayMode]); + int index = getIndex(_charcode, _displayMode); if( index < 0 - || (size_t)index >= m_listElement[_displayMode].size() ) { - Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" << index); - if (m_listElement[_displayMode].size() > 0) { - return &((m_listElement[_displayMode])[0]); + || (int)index >= this.listElement[_displayMode].size() ) { + Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" + index); + if (this.listElement[_displayMode].size() > 0) { + return ((this.listElement[_displayMode])[0]); } - return &m_emptyGlyph; + return this.emptyGlyph; } - //Log.error(" index=" << index); - //Log.error(" m_UVal=" << m_listElement[_displayMode][index].m_UVal); - //Log.error(" m_glyphIndex=" << m_listElement[_displayMode][index].m_glyphIndex); - //Log.error(" m_advance=" << m_listElement[_displayMode][index].m_advance); - //Log.error(" m_bearing=" << m_listElement[_displayMode][index].m_bearing); - return &((m_listElement[_displayMode])[index]); + //Log.error(" index=" + index); + //Log.error(" this.UVal=" + this.listElement[_displayMode][index].this.UVal); + //Log.error(" this.glyphIndex=" + this.listElement[_displayMode][index].this.glyphIndex); + //Log.error(" this.advance=" + this.listElement[_displayMode][index].this.advance); + //Log.error(" this.bearing=" + this.listElement[_displayMode][index].this.bearing); + return ((this.listElement[_displayMode])[index]); } diff --git a/src/org/atriasoft/ewol/resource/TexturedFont.java b/src/org/atriasoft/ewol/resource/TexturedFont.java index 3ee914a..b71f794 100644 --- a/src/org/atriasoft/ewol/resource/TexturedFont.java +++ b/src/org/atriasoft/ewol/resource/TexturedFont.java @@ -20,47 +20,47 @@ namespace ewol { BoldItalic, }; } - etk::Stream& operator <<(etk::Stream& _os, enum ewol::font::mode _obj); + etk::Stream operator +(etk::Stream _os, enum ewol::font::mode _obj); namespace resource { class TexturedFont : public ewol::resource::Texture { private: - etk::Uri m_fileName[4]; - int32_t m_size; - int32_t m_height[4]; + etk::Uri this.fileName[4]; + int this.size; + int this.height[4]; // specific element to have the the know if the specify element is known... // == > otherwise I can just generate italic ... // == > Bold is a little more complicated (maybe with the bordersize) - ememory::SharedPtr m_font[4]; - enum ewol::font::mode m_modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode + ememory::Ptr this.font[4]; + enum ewol::font::mode this.modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode public: - GlyphProperty m_emptyGlyph; - List m_listElement[4]; + GlyphProperty this.emptyGlyph; + List this.listElement[4]; private: // for the texture generation : - Vector2i m_lastGlyphPos[4]; - int32_t m_lastRawHeigh[4]; + Vector2i this.lastGlyphPos[4]; + int this.lastRawHeigh[4]; protected: TexturedFont(); - void init(const etk::String& _fontName); + void init( String _fontName); public: DECLARE_RESOURCE_NAMED_FACTORY(TexturedFont); - virtual ~TexturedFont(); + ~TexturedFont(); public: /** * @brief get the display height of this font * @param[in] _displayMode Mode to display the currrent font * @return Dimention of the font need between 2 lines */ - int32_t getHeight(const enum ewol::font::mode _displayMode = ewol::font::Regular) { - return m_height[_displayMode]; + int getHeight( enum ewol::font::mode _displayMode = ewol::font::Regular) { + return this.height[_displayMode]; }; /** * @brief get the font height (user friendly) * @return Dimention of the font the user requested */ - int32_t getFontSize() { - return m_size; + int getFontSize() { + return this.size; }; /** * @brief get the ID of a unicode charcode @@ -68,22 +68,22 @@ namespace ewol { * @param[in] _displayMode Mode to display the currrent font * @return The ID in the table (if it does not exist : return 0) */ - int32_t getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode); + int getIndex(Character _charcode, enum ewol::font::mode _displayMode); /** * @brief get the pointer on the coresponding glyph * @param[in] _charcode The unicodeValue * @param[in] _displayMode Mode to display the currrent font * @return The pointer on the glyph == > never null */ - ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode); + ewol::GlyphProperty* getGlyphPointer( Character _charcode, enum ewol::font::mode _displayMode); /** * @brief The wrapping mode is used to prevent the non existance of a specific mode. * For exemple when a blod mode does not exist, this resend a regular mode. * @param[in] _source The requested mode. * @return the best mode we have in stock. */ - enum ewol::font::mode getWrappingMode(const enum ewol::font::mode _source) { - return m_modeWraping[_source]; + enum ewol::font::mode getWrappingMode( enum ewol::font::mode _source) { + return this.modeWraping[_source]; }; private: /** @@ -91,7 +91,7 @@ namespace ewol { * @param[in] _val Char value to add. * @return true if the image size have change, false otherwise */ - bool addGlyph(const char32_t& _val); + boolean addGlyph( Character _val); }; } } diff --git a/src/org/atriasoft/ewol/resource/font/FontBase.java b/src/org/atriasoft/ewol/resource/font/FontBase.java index 1aea490..833f1c5 100644 --- a/src/org/atriasoft/ewol/resource/font/FontBase.java +++ b/src/org/atriasoft/ewol/resource/font/FontBase.java @@ -21,34 +21,34 @@ namespace ewol { FontBase() { addResourceType("ewol::FontFreeType"); } - void init(const etk::Uri& _uri) { + void init( etk::Uri _uri) { gale::Resource::init(_uri); }; - virtual ~FontBase() { }; + ~FontBase() { }; - virtual bool getGlyphProperty(int32_t _fontSize, - ewol::GlyphProperty& _property) = 0; + boolean getGlyphProperty(int _fontSize, + ewol::GlyphProperty _property) = 0; - virtual bool drawGlyph(egami::Image& _imageOut, - int32_t _fontSize, + boolean drawGlyph(egami::Image _imageOut, + int _fontSize, Vector2i _glyphPosition, - ewol::GlyphProperty& _property, + ewol::GlyphProperty _property, int8_t _posInImage) = 0; - virtual bool drawGlyph(egami::ImageMono& _imageOut, - int32_t _fontSize, - ewol::GlyphProperty& _property, - int32_t _borderSize = 0) = 0; + boolean drawGlyph(egami::ImageMono _imageOut, + int _fontSize, + ewol::GlyphProperty _property, + int _borderSize = 0) = 0; - virtual Vector2f getSize(int32_t _fontSize, const etk::String& _unicodeString) = 0; - virtual float getSizeWithHeight(float _fontHeight) = 0; + Vector2f getSize(int _fontSize, String _unicodeString) = 0; + float getSizeWithHeight(float _fontHeight) = 0; - virtual int32_t getHeight(int32_t _fontSize) = 0; + int getHeight(int _fontSize) = 0; - virtual void generateKerning(int32_t _fontSize, List& _listGlyph) { }; + void generateKerning(int _fontSize, List _listGlyph) { }; - virtual void display() {}; + void display() {}; }; }; }; diff --git a/src/org/atriasoft/ewol/resource/font/GlyphProperty.java b/src/org/atriasoft/ewol/resource/font/GlyphProperty.java index 1259469..12f9d2e 100644 --- a/src/org/atriasoft/ewol/resource/font/GlyphProperty.java +++ b/src/org/atriasoft/ewol/resource/font/GlyphProperty.java @@ -15,10 +15,10 @@ namespace ewol { Y | | | | ^ |------------| |------------| | - m_advance.y:/-> | + this.advance.y:/. | | | | | - m_sizeTex.x/-> | | |------------| |------------| + this.sizeTex.x/. | | |------------| |------------| | | | | | | | | | | | | | | | | | | | | | @@ -28,18 +28,18 @@ namespace ewol { | | | | | | | | | | | | | | | | | | | | | - \-> | | |------------| |------------| - /--> | | - \--> \-> | - m_bearing.y | + \. | | |------------| |------------| + /-. | | + \-. \. | + this.bearing.y | |____*________________________*____________>> X - <------------------------> : m_advance.x + <-----------------------. : this.advance.x - <------------> : m_sizeTexture.x + <-----------. : this.sizeTexture.x - <---> : m_bearing.x + <--. : this.bearing.x */ /** @@ -47,56 +47,56 @@ namespace ewol { */ class GlyphProperty { public: - char32_t m_UVal; //!< Unicode value + Character this.UVal; //!< Unicode value public: - bool m_exist; + boolean this.exist; public: - int32_t m_glyphIndex; //!< Glyph index in the system - Vector2i m_sizeTexture; //!< size of the element to display - Vector2i m_bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string) - Vector2i m_advance; //!< space use in the display for this specific char - Vector2f m_texturePosStart; //!< Texture normalized position (START) - Vector2f m_texturePosSize; //!< Texture normalized position (SIZE) + int this.glyphIndex; //!< Glyph index in the system + Vector2i this.sizeTexture; //!< size of the element to display + Vector2i this.bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string) + Vector2i this.advance; //!< space use in the display for this specific char + Vector2f this.texturePosStart; //!< Texture normalized position (START) + Vector2f this.texturePosSize; //!< Texture normalized position (SIZE) private: - List m_kerning; //!< kerning values of link of all elements + List this.kerning; //!< kerning values of link of all elements public: GlyphProperty() : - m_UVal(0), - m_exist(true), - m_glyphIndex(0), - m_sizeTexture(10,10), - m_bearing(2,2), - m_advance(10,10), - m_texturePosStart(0,0), - m_texturePosSize(0,0) { + this.UVal(0), + this.exist(true), + this.glyphIndex(0), + this.sizeTexture(10,10), + this.bearing(2,2), + this.advance(10,10), + this.texturePosStart(0,0), + this.texturePosSize(0,0) { }; - float kerningGet(const char32_t _charcode) { - for(size_t iii=0; iii #include -void ewol::tools::message::create(enum ewol::tools::message::type _type, const etk::String& _message) { - ewol::widget::StdPopUpShared tmpPopUp = widget::StdPopUp::create(); +void ewol::tools::message::create(enum ewol::tools::message::type _type, String _message) { + ewol::widget::StdPopUp tmpPopUp = widget::StdPopUp::create(); if (tmpPopUp == null) { Log.error("Can not create a simple pop-up"); return; } switch(_type) { case ewol::tools::message::type::info: - tmpPopUp->propertyTitle.set("_T{Info}"); + tmpPopUp.propertyTitle.set("_T{Info}"); break; case ewol::tools::message::type::warning: - tmpPopUp->propertyTitle.set("_T{Warning}"); + tmpPopUp.propertyTitle.set("_T{Warning}"); break; case ewol::tools::message::type::error: - tmpPopUp->propertyTitle.set("_T{Error}"); + tmpPopUp.propertyTitle.set("_T{Error}"); break; case ewol::tools::message::type::critical: - tmpPopUp->propertyTitle.set("_T{Critical}"); + tmpPopUp.propertyTitle.set("_T{Critical}"); break; } - tmpPopUp->propertyComment.set(_message); - tmpPopUp->addButton("_T{close}", true); - tmpPopUp->propertyCloseOutEvent.set(true); + tmpPopUp.propertyComment.set(_message); + tmpPopUp.addButton("_T{close}", true); + tmpPopUp.propertyCloseOutEvent.set(true); // get windows: - ewol::Context& context = ewol::getContext(); - ewol::widget::WindowsShared windows = context.getWindows(); + EwolContext context = ewol::getContext(); + ewol::widget::Windows windows = context.getWindows(); if (windows == null) { - Log.error("can not get the current windows ... ==> can not display message : " << _message); + Log.error("can not get the current windows ... ==> can not display message : " + _message); return; } - windows->popUpWidgetPush(tmpPopUp); + windows.popUpWidgetPush(tmpPopUp); } -void ewol::tools::message::displayInfo(const etk::String& _message) { +void ewol::tools::message::displayInfo( String _message) { ewol::tools::message::create(ewol::tools::message::type::info, _message); } -void ewol::tools::message::displayWarning(const etk::String& _message) { +void ewol::tools::message::displayWarning( String _message) { ewol::tools::message::create(ewol::tools::message::type::warning, _message); } -void ewol::tools::message::displayError(const etk::String& _message) { +void ewol::tools::message::displayError( String _message) { ewol::tools::message::create(ewol::tools::message::type::error, _message); } -void ewol::tools::message::displayCritical(const etk::String& _message) { +void ewol::tools::message::displayCritical( String _message) { ewol::tools::message::create(ewol::tools::message::type::critical, _message); } diff --git a/src/org/atriasoft/ewol/tools/message.java b/src/org/atriasoft/ewol/tools/message.java index f0be75d..f48cb4d 100644 --- a/src/org/atriasoft/ewol/tools/message.java +++ b/src/org/atriasoft/ewol/tools/message.java @@ -25,27 +25,27 @@ namespace ewol { * @param[in] _type Type of the error. * @param[in] _message message to display (decorated text) */ - void create(enum ewol::tools::message::type _type, const etk::String& _message); + void create(enum ewol::tools::message::type _type, String _message); /** * @brief Create a simple information message * @param[in] _message message to display (decorated text) */ - void displayInfo(const etk::String& _message); + void displayInfo( String _message); /** * @brief Create a simple warning message * @param[in] _message message to display (decorated text) */ - void displayWarning(const etk::String& _message); + void displayWarning( String _message); /** * @brief Create a simple error message * @param[in] _message message to display (decorated text) */ - void displayError(const etk::String& _message); + void displayError( String _message); /** * @brief Create a simple critical message * @param[in] _message message to display (decorated text) */ - void displayCritical(const etk::String& _message); + void displayCritical( String _message); } } } diff --git a/src/org/atriasoft/ewol/widget/Button.cpp b/src/org/atriasoft/ewol/widget/Button.cpp index 79d93e1..b35afe3 100644 --- a/src/org/atriasoft/ewol/widget/Button.cpp +++ b/src/org/atriasoft/ewol/widget/Button.cpp @@ -12,10 +12,10 @@ ETK_DECLARE_TYPE(ewol::widget::Button); ETK_DECLARE_TYPE(ewol::widget::Button::buttonLock); // DEFINE for the shader display system: -const static int32_t STATUS_UP(0); -const static int32_t STATUS_HOVER(2); -const static int32_t STATUS_PRESSED(1); -const static int32_t STATUS_DOWN(3); + static int STATUS_UP(0); + static int STATUS_HOVER(2); + static int STATUS_PRESSED(1); + static int STATUS_DOWN(3); ewol::widget::Button::Button() : signalPressed(this, "pressed", "Button is pressed"), @@ -24,15 +24,15 @@ ewol::widget::Button::Button() : signalEnter(this, "enter", "The cursor enter inside the button"), signalLeave(this, "leave", "the cursor leave the button"), signalValue(this, "value", "button value change"), - propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "The display name for config file", &ewol::widget::Button::onChangePropertyShape), - propertyValue(this, "value", false, "Value of the Button", &ewol::widget::Button::onChangePropertyValue), - propertyLock(this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder", &ewol::widget::Button::onChangePropertyLock), - propertyToggleMode(this, "toggle", false, "The Button can toogle", &ewol::widget::Button::onChangePropertyToggleMode), - propertyEnableSingle(this, "enable-single", false, "If one element set in the Button ==> display only set", &ewol::widget::Button::onChangePropertyEnableSingle), - m_mouseHover(false), - m_buttonPressed(false), - m_selectableAreaPos(0,0), - m_selectableAreaSize(0,0) { + propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "The display name for config file", ewol::widget::Button::onChangePropertyShape), + propertyValue(this, "value", false, "Value of the Button", ewol::widget::Button::onChangePropertyValue), + propertyLock(this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder", ewol::widget::Button::onChangePropertyLock), + propertyToggleMode(this, "toggle", false, "The Button can toogle", ewol::widget::Button::onChangePropertyToggleMode), + propertyEnableSingle(this, "enable-single", false, "If one element set in the Button ==> display only set", ewol::widget::Button::onChangePropertyEnableSingle), + this.mouseHover(false), + this.buttonPressed(false), + this.selectableAreaPos(0,0), + this.selectableAreaSize(0,0) { addObjectType("ewol::widget::Button"); // set property list: @@ -59,22 +59,22 @@ ewol::widget::Button::~Button() { } void ewol::widget::Button::onChangeSize() { - ewol::Padding padding = m_shaper.getPadding(); + ewol::Padding padding = this.shaper.getPadding(); ewol::Padding ret = onChangeSizePadded(padding); - //Log.debug(" configuring : origin=" << origin << " size=" << subElementSize << ""); - m_selectableAreaPos = Vector2f(ret.xLeft(), ret.yButtom()); - m_selectableAreaSize = m_size - (m_selectableAreaPos + Vector2f(ret.xRight(), ret.yTop())); + //Log.debug(" configuring : origin=" + origin + " size=" + subElementSize + ""); + this.selectableAreaPos = Vector2f(ret.xLeft(), ret.yButtom()); + this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop())); } void ewol::widget::Button::calculateMinMaxSize() { - ewol::Padding padding = m_shaper.getPadding(); + ewol::Padding padding = this.shaper.getPadding(); calculateMinMaxSizePadded(padding); } void ewol::widget::Button::onDraw() { // draw the shaaper (if needed indeed) - m_shaper.draw(); + this.shaper.draw(); } void ewol::widget::Button::onRegenerateDisplay() { @@ -82,70 +82,70 @@ void ewol::widget::Button::onRegenerateDisplay() { if (needRedraw() == false) { return; } - ewol::Padding padding = m_shaper.getPadding(); - m_shaper.setShape(Vector2f(0,0), - m_size, - Vector2fClipInt32(m_selectableAreaPos+Vector2f(padding.xLeft(),padding.yButtom()) ), - Vector2fClipInt32(m_selectableAreaSize-Vector2f(padding.x(),padding.y()) ) ); - //Log.error("pos=" << m_origin << " size=" << m_size); + ewol::Padding padding = this.shaper.getPadding(); + this.shaper.setShape(Vector2f(0,0), + this.size, + Vector2fClipInt32(this.selectableAreaPos+Vector2f(padding.xLeft(),padding.yButtom()) ), + Vector2fClipInt32(this.selectableAreaSize-Vector2f(padding.x(),padding.y()) ) ); + //Log.error("pos=" + this.origin + " size=" + this.size); } -bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { - Log.verbose("Event on BT : " << _event); +boolean ewol::widget::Button::onEventInput( ewol::event::Input _event) { + Log.verbose("Event on BT : " + _event); // disable event in the lock access mode : if(ewol::widget::Button::lockAccess == *propertyLock) { return false; } - if( _event.getStatus() == gale::key::status::leave - || _event.getStatus() == gale::key::status::abort) { - m_mouseHover = false; - m_buttonPressed = false; + if( _event.getStatus() == KeyStatus::leave + || _event.getStatus() == KeyStatus::abort) { + this.mouseHover = false; + this.buttonPressed = false; } else { Vector2f relativePos = relativePosition(_event.getPos()); // prevent error from ouside the button - if( relativePos.x() < m_selectableAreaPos.x() - || relativePos.y() < m_selectableAreaPos.y() - || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() - || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { - m_mouseHover = false; - m_buttonPressed = false; + if( relativePos.x() < this.selectableAreaPos.x() + || relativePos.y() < this.selectableAreaPos.y() + || relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x() + || relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) { + this.mouseHover = false; + this.buttonPressed = false; } else { - m_mouseHover = true; + this.mouseHover = true; } } - Log.verbose("Event on BT ... mouse hover : " << m_mouseHover); - if (m_mouseHover == true) { + Log.verbose("Event on BT ... mouse hover : " + this.mouseHover); + if (this.mouseHover == true) { if (_event.getId() == 1) { - if(_event.getStatus() == gale::key::status::down) { - Log.verbose(*propertyName << " : Generate event : " << signalDown); + if(_event.getStatus() == KeyStatus::down) { + Log.verbose(*propertyName + " : Generate event : " + signalDown); signalDown.emit(); - m_buttonPressed = true; + this.buttonPressed = true; markToRedraw(); } - if(_event.getStatus() == gale::key::status::up) { - Log.verbose(*propertyName << " : Generate event : " << signalUp); + if(_event.getStatus() == KeyStatus::up) { + Log.verbose(*propertyName + " : Generate event : " + signalUp); signalUp.emit(); - m_buttonPressed = false; + this.buttonPressed = false; markToRedraw(); } - if(_event.getStatus() == gale::key::status::pressSingle) { + if(_event.getStatus() == KeyStatus::pressSingle) { if ( ( *propertyValue == true - && *propertyLock == ewol::widget::Button::lockWhenPressed) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenPressed) || ( *propertyValue == false - && *propertyLock == ewol::widget::Button::lockWhenReleased) ) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenReleased) ) { // nothing to do : Lock mode ... // user might set himself the new correct value with @ref setValue(xxx) } else { // inverse value : propertyValue.set((*propertyValue)?false:true); - Log.verbose(*propertyName << " : Generate event : " << signalPressed); + Log.verbose(*propertyName + " : Generate event : " + signalPressed); signalPressed.emit(); - Log.verbose(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue ); + Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue ); signalValue.emit(*propertyValue); if( *propertyToggleMode == false - && *propertyValue == true) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyValue == true) { propertyValue.set(false); - Log.verbose(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue); + Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue); signalValue.emit(*propertyValue); } } @@ -154,15 +154,15 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { } } CheckStatus(); - return m_mouseHover; + return this.mouseHover; } -bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { - //Log.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); - if( _event.getType() == gale::key::keyboard::character - && _event.getStatus() == gale::key::status::down - && _event.getChar() == '\r') { +boolean ewol::widget::Button::onEventEntry( ewol::event::Entry _event) { + //Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data)); + if( _event.getType() == KeyKeyboard::character + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') { signalEnter.emit(); return true; } @@ -170,17 +170,17 @@ bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { } void ewol::widget::Button::onLostFocus() { - m_buttonPressed = false; - Log.verbose(propertyName.get() << " : Remove Focus ..."); + this.buttonPressed = false; + Log.verbose(propertyName.get() + " : Remove Focus ..."); CheckStatus(); } void ewol::widget::Button::CheckStatus() { - if (m_buttonPressed == true) { + if (this.buttonPressed == true) { changeStatusIn(STATUS_PRESSED); return; } - if (m_mouseHover == true) { + if (this.mouseHover == true) { changeStatusIn(STATUS_HOVER); return; } @@ -190,42 +190,42 @@ void ewol::widget::Button::CheckStatus() { changeStatusIn(STATUS_UP); } -void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) { - if (m_shaper.changeStatusIn(_newStatusId) == true) { - m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::Button::periodicCall); +void ewol::widget::Button::changeStatusIn(int _newStatusId) { + if (this.shaper.changeStatusIn(_newStatusId) == true) { + this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::Button::periodicCall); markToRedraw(); } } -void ewol::widget::Button::periodicCall(const ewol::event::Time& _event) { - if (m_shaper.periodicCall(_event) == false) { - m_PCH.disconnect(); +void ewol::widget::Button::periodicCall( ewol::event::Time _event) { + if (this.shaper.periodicCall(_event) == false) { + this.PCH.disconnect(); } markToRedraw(); } void ewol::widget::Button::onChangePropertyShape() { - m_shaper.setSource(*propertyShape); + this.shaper.setSource(*propertyShape); markToRedraw(); } void ewol::widget::Button::onChangePropertyValue() { if (*propertyToggleMode == true) { if (*propertyValue == false) { - m_idWidgetDisplayed = 0; + this.idWidgetDisplayed = 0; } else { - m_idWidgetDisplayed = 1; + this.idWidgetDisplayed = 1; } } if (*propertyEnableSingle == true) { - if ( m_idWidgetDisplayed == 0 - && m_subWidget[0] == null - && m_subWidget[1] != null) { - m_idWidgetDisplayed = 1; - } else if ( m_idWidgetDisplayed == 1 - && m_subWidget[1] == null - && m_subWidget[0] != null) { - m_idWidgetDisplayed = 0; + if ( this.idWidgetDisplayed == 0 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) { + this.idWidgetDisplayed = 1; + } else if ( this.idWidgetDisplayed == 1 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) { + this.idWidgetDisplayed = 0; } } CheckStatus(); @@ -234,8 +234,8 @@ void ewol::widget::Button::onChangePropertyValue() { void ewol::widget::Button::onChangePropertyLock() { if(ewol::widget::Button::lockAccess == *propertyLock) { - m_buttonPressed = false; - m_mouseHover = false; + this.buttonPressed = false; + this.mouseHover = false; } CheckStatus(); markToRedraw(); @@ -247,23 +247,23 @@ void ewol::widget::Button::onChangePropertyToggleMode() { // TODO : change display and send event ... } if (*propertyToggleMode == false) { - m_idWidgetDisplayed = 0; + this.idWidgetDisplayed = 0; } else { if (*propertyValue == false) { - m_idWidgetDisplayed = 0; + this.idWidgetDisplayed = 0; } else { - m_idWidgetDisplayed = 1; + this.idWidgetDisplayed = 1; } } if (*propertyEnableSingle == true) { - if ( m_idWidgetDisplayed == 0 - && m_subWidget[0] == null - && m_subWidget[1] != null) { - m_idWidgetDisplayed = 1; - } else if ( m_idWidgetDisplayed == 1 - && m_subWidget[1] == null - && m_subWidget[0] != null) { - m_idWidgetDisplayed = 0; + if ( this.idWidgetDisplayed == 0 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) { + this.idWidgetDisplayed = 1; + } else if ( this.idWidgetDisplayed == 1 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) { + this.idWidgetDisplayed = 0; } } CheckStatus(); @@ -272,17 +272,17 @@ void ewol::widget::Button::onChangePropertyToggleMode() { void ewol::widget::Button::onChangePropertyEnableSingle() { if (*propertyEnableSingle == true) { - if ( m_idWidgetDisplayed == 0 - && m_subWidget[0] == null - && m_subWidget[1] != null) { - m_idWidgetDisplayed = 1; - } else if ( m_idWidgetDisplayed == 1 - && m_subWidget[1] == null - && m_subWidget[0] != null) { - m_idWidgetDisplayed = 0; - } else if ( m_subWidget[0] == null - && m_subWidget[1] == null) { - m_idWidgetDisplayed = 0; + if ( this.idWidgetDisplayed == 0 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) { + this.idWidgetDisplayed = 1; + } else if ( this.idWidgetDisplayed == 1 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) { + this.idWidgetDisplayed = 0; + } else if ( this.subWidget[0] == null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null) { + this.idWidgetDisplayed = 0; } } } diff --git a/src/org/atriasoft/ewol/widget/Button.java b/src/org/atriasoft/ewol/widget/Button.java index 78c3775..e7d8b72 100644 --- a/src/org/atriasoft/ewol/widget/Button.java +++ b/src/org/atriasoft/ewol/widget/Button.java @@ -19,7 +19,7 @@ namespace ewol { namespace widget { class Button; - using ButtonShared = ememory::SharedPtr; + using Button = ememory::Ptr; using ButtonWeak = ememory::WeakPtr; /** * @brief a composed button is a button with an inside composed with the specify XML element @@ -47,61 +47,61 @@ namespace ewol { eproperty::Value propertyToggleMode; //!< The button is able to toggle. eproperty::Value propertyEnableSingle; //!< When a single subwidget is set display all time it. private: - ewol::compositing::Shaper m_shaper; //!< Compositing theme. + ewol::compositing::Shaper this.shaper; //!< Compositing theme. protected: /** * @brief Constructor * @param[in] _shaperName Shaper file properties */ Button(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(Button, "Button"); /** * @brief Destructor */ - virtual ~Button(); + ~Button(); private: - bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). - bool m_buttonPressed; //!< Flag to know if the button is curently pressed. + boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). + boolean this.buttonPressed; //!< Flag to know if the button is curently pressed. // hover area : - Vector2f m_selectableAreaPos; //!< Start position of the events - Vector2f m_selectableAreaSize; //!< size of the event positions + Vector2f this.selectableAreaPos; //!< Start position of the events + Vector2f this.selectableAreaSize; //!< size of the event positions private: /** * @brief internal system to change the property of the current status * @param[in] _newStatusId new state */ - void changeStatusIn(int32_t _newStatusId); + void changeStatusIn(int _newStatusId); /** * @brief update the status with the internal satte of the button ... */ void CheckStatus(); protected: // Derived function - virtual void onDraw() override; + void onDraw() ; public: - void calculateMinMaxSize() override; - void onChangeSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - bool onEventEntry(const ewol::event::Entry& _event) override; - void onDetectPresenceToggleWidget() override { + void calculateMinMaxSize() ; + void onChangeSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + boolean onEventEntry( ewol::event::Entry _event) ; + void onDetectPresenceToggleWidget() { propertyToggleMode.set(true); } protected: - esignal::Connection m_PCH; //!< Periodic Call Handle to remove it when needed + esignal::Connection this.PCH; //!< Periodic Call Handle to remove it when needed /** * @brief Periodic call to update grapgic display * @param[in] _event Time generic event */ - void periodicCall(const ewol::event::Time& _event); - void onLostFocus() override; + void periodicCall( ewol::event::Time _event); + void onLostFocus() ; protected: - virtual void onChangePropertyShape(); - virtual void onChangePropertyValue(); - virtual void onChangePropertyLock(); - virtual void onChangePropertyToggleMode(); - virtual void onChangePropertyEnableSingle(); + void onChangePropertyShape(); + void onChangePropertyValue(); + void onChangePropertyLock(); + void onChangePropertyToggleMode(); + void onChangePropertyEnableSingle(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/ButtonColor.cpp b/src/org/atriasoft/ewol/widget/ButtonColor.cpp index 5369175..2c094c0 100644 --- a/src/org/atriasoft/ewol/widget/ButtonColor.cpp +++ b/src/org/atriasoft/ewol/widget/ButtonColor.cpp @@ -24,9 +24,9 @@ ETK_DECLARE_TYPE(ewol::widget::ButtonColor); ewol::widget::ButtonColor::ButtonColor() : signalChange(this, "change", "Button color change value"), - propertyValue(this, "color", etk::color::black, "Current color", &ewol::widget::ButtonColor::onChangePropertyValue), - propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "shape of the widget", &ewol::widget::ButtonColor::onChangePropertyShape), - m_widgetContextMenu(null) { + propertyValue(this, "color", etk::color::black, "Current color", ewol::widget::ButtonColor::onChangePropertyValue), + propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "shape of the widget", ewol::widget::ButtonColor::onChangePropertyShape), + this.widgetContextMenu(null) { addObjectType("ewol::widget::ButtonColor"); changeStatusIn(STATUS_UP); // Limit event at 1: @@ -35,7 +35,7 @@ ewol::widget::ButtonColor::ButtonColor() : } void ewol::widget::ButtonColor::init() { - ewol::Widget::init(); + Widget::init(); propertyShape.notifyChange(); propertyValue.notifyChange(); } @@ -45,19 +45,19 @@ ewol::widget::ButtonColor::~ButtonColor() { } void ewol::widget::ButtonColor::calculateMinMaxSize() { - ewol::Padding padding = m_shaper.getPadding(); - etk::String label = propertyValue.getString(); - Vector3f minSize = m_text.calculateSize(label); - m_minSize.setX(padding.x()*2 + minSize.x() + 7); - m_minSize.setY(padding.y()*2 + minSize.y() ); + ewol::Padding padding = this.shaper.getPadding(); + String label = propertyValue.getString(); + Vector3f minSize = this.text.calculateSize(label); + this.minSize.setX(padding.x()*2 + minSize.x() + 7); + this.minSize.setY(padding.y()*2 + minSize.y() ); markToRedraw(); } void ewol::widget::ButtonColor::onDraw() { - m_shaper.draw(); - m_text.draw(); + this.shaper.draw(); + this.text.draw(); } @@ -66,153 +66,153 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() { return; } Log.debug("redraw"); - m_text.clear(); - m_shaper.clear(); + this.text.clear(); + this.shaper.clear(); - ewol::Padding padding = m_shaper.getPadding(); + ewol::Padding padding = this.shaper.getPadding(); - etk::String label = propertyValue.getString(); + String label = propertyValue.getString(); - Vector2i localSize = m_minSize; + Vector2i localSize = this.minSize; - Vector3f tmpOrigin((m_size.x() - m_minSize.x()) / 2.0, - (m_size.y() - m_minSize.y()) / 2.0, + Vector3f tmpOrigin((this.size.x() - this.minSize.x()) / 2.0, + (this.size.y() - this.minSize.y()) / 2.0, 0); // no change for the text orogin : - Vector3f tmpTextOrigin((m_size.x() - m_minSize.x()) / 2.0, - (m_size.y() - m_minSize.y()) / 2.0, + Vector3f tmpTextOrigin((this.size.x() - this.minSize.x()) / 2.0, + (this.size.y() - this.minSize.y()) / 2.0, 0); - if (propertyFill->x() == true) { - localSize.setX(m_size.x()); + if (propertyFill.x() == true) { + localSize.setX(this.size.x()); tmpOrigin.setX(0); tmpTextOrigin.setX(0); } - if (propertyFill->y() == true) { - localSize.setY(m_size.y()); + if (propertyFill.y() == true) { + localSize.setY(this.size.y()); } tmpOrigin += Vector3f(padding.xLeft(), padding.yButtom(), 0); tmpTextOrigin += Vector3f(padding.xLeft(), padding.yButtom(), 0); localSize -= Vector2i(padding.x(), padding.y()); // clean the element - m_text.reset(); + this.text.reset(); if( propertyValue.get().r() < 100 || propertyValue.get().g() < 100 || propertyValue.get().b() < 100) { - m_text.setColor(etk::color::white); + this.text.setColor(etk::color::white); } else { - m_text.setColor(etk::color::black); + this.text.setColor(etk::color::black); } - m_text.setPos(tmpTextOrigin); - m_text.setColorBg(propertyValue.get()); - m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignCenter); - m_text.print(label); + this.text.setPos(tmpTextOrigin); + this.text.setColorBg(propertyValue.get()); + this.text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignCenter); + this.text.print(label); - if (propertyFill->y() == true) { + if (propertyFill.y() == true) { tmpOrigin.setY(padding.yButtom()); } // selection area : - m_selectableAreaPos = Vector2f(tmpOrigin.x()-padding.xLeft(), tmpOrigin.y()-padding.yButtom()); - m_selectableAreaSize = localSize + Vector2f(padding.x(),padding.y()); - Vector3f tmpp = m_text.calculateSize(label); - m_shaper.setShape(m_selectableAreaPos, - m_selectableAreaSize, + this.selectableAreaPos = Vector2f(tmpOrigin.x()-padding.xLeft(), tmpOrigin.y()-padding.yButtom()); + this.selectableAreaSize = localSize + Vector2f(padding.x(),padding.y()); + Vector3f tmpp = this.text.calculateSize(label); + this.shaper.setShape(this.selectableAreaPos, + this.selectableAreaSize, Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y()), Vector2f(tmpp.x(), tmpp.y())); } -bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { - bool previousHoverState = m_mouseHover; - if(gale::key::status::leave == _event.getStatus()) { - m_mouseHover = false; - m_buttonPressed = false; +boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) { + boolean previousHoverState = this.mouseHover; + if(KeyStatus::leave == _event.getStatus()) { + this.mouseHover = false; + this.buttonPressed = false; } else { Vector2f relativePos = relativePosition(_event.getPos()); // prevent error from ouside the button - if( relativePos.x() < m_selectableAreaPos.x() - || relativePos.y() < m_selectableAreaPos.y() - || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() - || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { - m_mouseHover = false; - m_buttonPressed = false; + if( relativePos.x() < this.selectableAreaPos.x() + || relativePos.y() < this.selectableAreaPos.y() + || relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x() + || relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) { + this.mouseHover = false; + this.buttonPressed = false; } else { - m_mouseHover = true; + this.mouseHover = true; } } - bool previousPressed = m_buttonPressed; - //Log.debug("Event on BT ... mouse position : " << m_mouseHover); - if (true == m_mouseHover) { + boolean previousPressed = this.buttonPressed; + //Log.debug("Event on BT ... mouse position : " + this.mouseHover); + if (true == this.mouseHover) { if (1 == _event.getId()) { - if(gale::key::status::down == _event.getStatus()) { - m_buttonPressed = true; + if(KeyStatus::down == _event.getStatus()) { + this.buttonPressed = true; markToRedraw(); } - if(gale::key::status::up == _event.getStatus()) { - m_buttonPressed = false; + if(KeyStatus::up == _event.getStatus()) { + this.buttonPressed = false; markToRedraw(); } - if(gale::key::status::pressSingle == _event.getStatus()) { - m_buttonPressed = false; - m_mouseHover = false; + if(KeyStatus::pressSingle == _event.getStatus()) { + this.buttonPressed = false; + this.mouseHover = false; // create a context menu : - m_widgetContextMenu = ewol::widget::ContextMenu::create(); - if (m_widgetContextMenu == null) { + this.widgetContextMenu = ewol::widget::ContextMenu::create(); + if (this.widgetContextMenu == null) { Log.error("Allocation Error"); return true; } - Vector2f tmpPos = m_origin + m_selectableAreaPos + m_selectableAreaSize; - tmpPos.setX( tmpPos.x() - m_minSize.x()/2.0); - m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); + Vector2f tmpPos = this.origin + this.selectableAreaPos + this.selectableAreaSize; + tmpPos.setX( tmpPos.x() - this.minSize.x()/2.0); + this.widgetContextMenu.setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); - ewol::widget::ColorChooserShared myColorChooser = widget::ColorChooser::create(); - myColorChooser->propertyValue.set(propertyValue.get()); + ewol::widget::ColorChooser myColorChooser = widget::ColorChooser::create(); + myColorChooser.propertyValue.set(propertyValue.get()); // set it in the pop-up-system : - m_widgetContextMenu->setSubWidget(myColorChooser); - myColorChooser->signalChange.connect(sharedFromThis(), &ewol::widget::ButtonColor::onCallbackColorChange); - ewol::widget::WindowsShared currentWindows = getWindows(); + this.widgetContextMenu.setSubWidget(myColorChooser); + myColorChooser.signalChange.connect(sharedFromThis(), ewol::widget::ButtonColor::onCallbackColorChange); + ewol::widget::Windows currentWindows = getWindows(); if (currentWindows == null) { Log.error("Can not get the curent Windows..."); - m_widgetContextMenu.reset(); + this.widgetContextMenu.reset(); } else { - currentWindows->popUpWidgetPush(m_widgetContextMenu); + currentWindows.popUpWidgetPush(this.widgetContextMenu); } markToRedraw(); } } } - if( m_mouseHover != previousHoverState - || m_buttonPressed != previousPressed) { - if (m_buttonPressed == true) { + if( this.mouseHover != previousHoverState + || this.buttonPressed != previousPressed) { + if (this.buttonPressed == true) { changeStatusIn(STATUS_PRESSED); } else { - if (m_mouseHover == true) { + if (this.mouseHover == true) { changeStatusIn(STATUS_HOVER); } else { changeStatusIn(STATUS_UP); } } } - return m_mouseHover; + return this.mouseHover; } -void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color) { +void ewol::widget::ButtonColor::onCallbackColorChange( etk::Color<> _color) { propertyValue.set(_color); } -void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { - if (m_shaper.changeStatusIn(_newStatusId) == true) { - m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::ButtonColor::periodicCall); +void ewol::widget::ButtonColor::changeStatusIn(int _newStatusId) { + if (this.shaper.changeStatusIn(_newStatusId) == true) { + this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::ButtonColor::periodicCall); markToRedraw(); } } -void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) { - if (m_shaper.periodicCall(_event) == false) { - m_PCH.disconnect(); +void ewol::widget::ButtonColor::periodicCall( ewol::event::Time _event) { + if (this.shaper.periodicCall(_event) == false) { + this.PCH.disconnect(); } markToRedraw(); } @@ -222,7 +222,7 @@ void ewol::widget::ButtonColor::onChangePropertyValue() { } void ewol::widget::ButtonColor::onChangePropertyShape() { - m_shaper.setSource(propertyShape.get()); + this.shaper.setSource(propertyShape.get()); markToRedraw(); } diff --git a/src/org/atriasoft/ewol/widget/ButtonColor.java b/src/org/atriasoft/ewol/widget/ButtonColor.java index d139f3a..a084438 100644 --- a/src/org/atriasoft/ewol/widget/ButtonColor.java +++ b/src/org/atriasoft/ewol/widget/ButtonColor.java @@ -18,60 +18,60 @@ namespace ewol { namespace widget { class ButtonColor; - using ButtonColorShared = ememory::SharedPtr; + using ButtonColor = ememory::Ptr; using ButtonColorWeak = ememory::WeakPtr; - class ButtonColor : public ewol::Widget { + class ButtonColor : public Widget { public: // signals esignal::Signal> signalChange; public: // properties eproperty::Value> propertyValue; //!< Current color. eproperty::Value propertyShape; //!< Current color. private: - ewol::compositing::Shaper m_shaper; //!< Compositing theme. - ewol::compositing::Text m_text; //!< Compositing Test display. - ewol::widget::ContextMenuShared m_widgetContextMenu; //!< Specific context menu. - bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). - bool m_buttonPressed; //!< Flag to know if the button is curently pressed. + ewol::compositing::Shaper this.shaper; //!< Compositing theme. + ewol::compositing::Text this.text; //!< Compositing Test display. + ewol::widget::ContextMenu this.widgetContextMenu; //!< Specific context menu. + boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). + boolean this.buttonPressed; //!< Flag to know if the button is curently pressed. // hover area : - Vector2f m_selectableAreaPos; //!< Start position of the events - Vector2f m_selectableAreaSize; //!< size of the event positions + Vector2f this.selectableAreaPos; //!< Start position of the events + Vector2f this.selectableAreaSize; //!< size of the event positions protected: /** - * @brief Main constructor. + * @brief Main ructor. * @param[in] _baseColor basic displayed color. * @param[in] _shaperName The new shaper filename. */ ButtonColor(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(ButtonColor, "ButtonColor"); /** * @brief Main destructor. */ - virtual ~ButtonColor(); + ~ButtonColor(); protected: - void onDraw() override; + void onDraw() ; public: - void calculateMinMaxSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; + void calculateMinMaxSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; private: /** * @brief internal system to change the property of the current status * @param[in] _newStatusId new state */ - void changeStatusIn(int32_t _newStatusId); - esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed + void changeStatusIn(int _newStatusId); + esignal::Connection this.PCH; //!< Periodic call handle to remove it when needed /** * @brief Periodic call to update grapgic display * @param[in] _event Time generic event */ - void periodicCall(const ewol::event::Time& _event); + void periodicCall( ewol::event::Time _event); // Callback function: - void onCallbackColorChange(const etk::Color<>& _color); + void onCallbackColorChange( etk::Color<> _color); protected: - virtual void onChangePropertyValue(); - virtual void onChangePropertyShape(); + void onChangePropertyValue(); + void onChangePropertyShape(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/CheckBox.cpp b/src/org/atriasoft/ewol/widget/CheckBox.cpp index 5ccce7d..1414536 100644 --- a/src/org/atriasoft/ewol/widget/CheckBox.cpp +++ b/src/org/atriasoft/ewol/widget/CheckBox.cpp @@ -25,17 +25,17 @@ ewol::widget::CheckBox::CheckBox() : propertyValue(this, "value", false, "Basic value of the widget", - &ewol::widget::CheckBox::onChangePropertyValue), + ewol::widget::CheckBox::onChangePropertyValue), propertyShape(this, "shape", etk::Uri("THEME_GUI:///CheckBox.json?lib=ewol"), "The display name for config file", - &ewol::widget::CheckBox::onChangePropertyShape), - m_mouseHover(false), - m_buttonPressed(false), - m_selectableAreaPos(0,0), - m_selectableAreaSize(0,0), - m_shaperIdSize(-1), - m_shaperIdSizeInsize(-1) { + ewol::widget::CheckBox::onChangePropertyShape), + this.mouseHover(false), + this.buttonPressed(false), + this.selectableAreaPos(0,0), + this.selectableAreaSize(0,0), + this.shaperIdSize(-1), + this.shaperIdSizeInsize(-1) { addObjectType("ewol::widget::CheckBox"); // shaper satatus update: CheckStatus(); @@ -55,28 +55,28 @@ ewol::widget::CheckBox::~CheckBox() { } void ewol::widget::CheckBox::onChangeSize() { - ewol::Padding padding = m_shaper.getPadding(); - float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); + ewol::Padding padding = this.shaper.getPadding(); + float boxSize = this.shaper.getConfigNumber(this.shaperIdSize); padding.setXLeft(padding.xLeft()*2.0f + boxSize); ewol::Padding ret = onChangeSizePadded(padding); - Log.debug(" configuring : padding=" << padding << " boxSize=" << boxSize << ""); - m_selectableAreaPos = Vector2f(ret.xLeft()/*-boxSize*/, ret.yButtom()); - m_selectableAreaSize = m_size - (m_selectableAreaPos + Vector2f(ret.xRight(), ret.yTop())); + Log.debug(" configuring : padding=" + padding + " boxSize=" + boxSize + ""); + this.selectableAreaPos = Vector2f(ret.xLeft()/*-boxSize*/, ret.yButtom()); + this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop())); } void ewol::widget::CheckBox::calculateMinMaxSize() { - ewol::Padding padding = m_shaper.getPadding(); - float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); + ewol::Padding padding = this.shaper.getPadding(); + float boxSize = this.shaper.getConfigNumber(this.shaperIdSize); padding.setXLeft(padding.xLeft()*2.0f + boxSize); calculateMinMaxSizePadded(padding); - if (m_minSize.y() < padding.y()+boxSize) { - m_minSize.setY(padding.y()+boxSize); + if (this.minSize.y() < padding.y()+boxSize) { + this.minSize.setY(padding.y()+boxSize); } } void ewol::widget::CheckBox::onDraw() { // draw the shaaper (if needed indeed) - m_shaper.draw(); + this.shaper.draw(); } void ewol::widget::CheckBox::onRegenerateDisplay() { @@ -84,83 +84,83 @@ void ewol::widget::CheckBox::onRegenerateDisplay() { if (needRedraw() == false) { return; } - ewol::Padding padding = m_shaper.getPadding(); - float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); - float boxInside = m_shaper.getConfigNumber(m_shaperIdSizeInsize); - m_shaper.clear(); - Log.debug(" configuring : boxSize=" << boxSize << " boxInside=" << boxInside << ""); - Vector2f origin(m_selectableAreaPos + Vector2f(0, (m_selectableAreaSize.y() - (boxSize+padding.y()))*0.5f)); + ewol::Padding padding = this.shaper.getPadding(); + float boxSize = this.shaper.getConfigNumber(this.shaperIdSize); + float boxInside = this.shaper.getConfigNumber(this.shaperIdSizeInsize); + this.shaper.clear(); + Log.debug(" configuring : boxSize=" + boxSize + " boxInside=" + boxInside + ""); + Vector2f origin(this.selectableAreaPos + Vector2f(0, (this.selectableAreaSize.y() - (boxSize+padding.y()))*0.5f)); Vector2f size = Vector2f(boxSize+padding.x(), boxSize+padding.y()); - Vector2f origin2 = m_selectableAreaPos + Vector2f((boxSize-boxInside)*0.5f, (m_selectableAreaSize.y() - (boxInside+padding.y()))*0.5f); + Vector2f origin2 = this.selectableAreaPos + Vector2f((boxSize-boxInside)*0.5f, (this.selectableAreaSize.y() - (boxInside+padding.y()))*0.5f); Vector2f size2 = Vector2f(boxInside+padding.x(), boxInside+padding.y()); - m_shaper.setShape(Vector2fClipInt32(origin), + this.shaper.setShape(Vector2fClipInt32(origin), Vector2fClipInt32(size), Vector2fClipInt32(origin2+Vector2f(padding.xLeft(),padding.yButtom()) ), Vector2fClipInt32(size2-Vector2f(padding.x(),padding.y()) )); } -bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { - Log.verbose("Event on BT : " << _event); +boolean ewol::widget::CheckBox::onEventInput( ewol::event::Input _event) { + Log.verbose("Event on BT : " + _event); - bool previousHoverState = m_mouseHover; - if( gale::key::status::leave == _event.getStatus() - || gale::key::status::abort == _event.getStatus()) { - m_mouseHover = false; - m_buttonPressed = false; + boolean previousHoverState = this.mouseHover; + if( KeyStatus::leave == _event.getStatus() + || KeyStatus::abort == _event.getStatus()) { + this.mouseHover = false; + this.buttonPressed = false; } else { Vector2f relativePos = relativePosition(_event.getPos()); // prevent error from ouside the button - if( relativePos.x() < m_selectableAreaPos.x() - || relativePos.y() < m_selectableAreaPos.y() - || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() - || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { - m_mouseHover = false; - m_buttonPressed = false; + if( relativePos.x() < this.selectableAreaPos.x() + || relativePos.y() < this.selectableAreaPos.y() + || relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x() + || relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) { + this.mouseHover = false; + this.buttonPressed = false; } else { - m_mouseHover = true; + this.mouseHover = true; } } - bool previousPressed = m_buttonPressed; - Log.verbose("Event on BT ... mouse hover : " << m_mouseHover); - if (m_mouseHover == true) { + boolean previousPressed = this.buttonPressed; + Log.verbose("Event on BT ... mouse hover : " + this.mouseHover); + if (this.mouseHover == true) { if (_event.getId() == 1) { - if(gale::key::status::down == _event.getStatus()) { - Log.verbose(*propertyName << " : Generate event : " << signalDown); + if(KeyStatus::down == _event.getStatus()) { + Log.verbose(*propertyName + " : Generate event : " + signalDown); signalDown.emit(); - m_buttonPressed = true; + this.buttonPressed = true; markToRedraw(); } - if(gale::key::status::up == _event.getStatus()) { - Log.verbose(*propertyName << " : Generate event : " << signalUp); + if(KeyStatus::up == _event.getStatus()) { + Log.verbose(*propertyName + " : Generate event : " + signalUp); signalUp.emit(); - m_buttonPressed = false; + this.buttonPressed = false; markToRedraw(); } - if(gale::key::status::pressSingle == _event.getStatus()) { + if(KeyStatus::pressSingle == _event.getStatus()) { // inverse value : propertyValue.set((*propertyValue)?false:true); - Log.verbose(*propertyName << " : Generate event : " << signalPressed); + Log.verbose(*propertyName + " : Generate event : " + signalPressed); signalPressed.emit(); - Log.verbose(*propertyName << " : Generate event : " << signalValue << " val=" << propertyValue ); + Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + propertyValue ); signalValue.emit(*propertyValue); markToRedraw(); } } } - if( m_mouseHover != previousHoverState - || m_buttonPressed != previousPressed) { + if( this.mouseHover != previousHoverState + || this.buttonPressed != previousPressed) { CheckStatus(); } - return m_mouseHover; + return this.mouseHover; } -bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { - //Log.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); - if( _event.getType() == gale::key::keyboard::character - && _event.getStatus() == gale::key::status::down - && _event.getChar() == '\r') { +boolean ewol::widget::CheckBox::onEventEntry( ewol::event::Entry _event) { + //Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data)); + if( _event.getType() == KeyKeyboard::character + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') { signalEnter.emit(); return true; } @@ -168,49 +168,49 @@ bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { } void ewol::widget::CheckBox::CheckStatus() { - if (m_shaper.setState(*propertyValue==true?1:0) == true) { + if (this.shaper.setState(*propertyValue==true?1:0) == true) { markToRedraw(); } - if (m_buttonPressed == true) { + if (this.buttonPressed == true) { changeStatusIn(STATUS_PRESSED); return; } - if (m_mouseHover == true) { + if (this.mouseHover == true) { changeStatusIn(STATUS_HOVER); return; } changeStatusIn(STATUS_UP); } -void ewol::widget::CheckBox::changeStatusIn(int32_t _newStatusId) { - if (m_shaper.changeStatusIn(_newStatusId) == true) { - m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::CheckBox::periodicCall); +void ewol::widget::CheckBox::changeStatusIn(int _newStatusId) { + if (this.shaper.changeStatusIn(_newStatusId) == true) { + this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::CheckBox::periodicCall); markToRedraw(); } } -void ewol::widget::CheckBox::periodicCall(const ewol::event::Time& _event) { - if (m_shaper.periodicCall(_event) == false) { - m_PCH.disconnect(); +void ewol::widget::CheckBox::periodicCall( ewol::event::Time _event) { + if (this.shaper.periodicCall(_event) == false) { + this.PCH.disconnect(); } markToRedraw(); } void ewol::widget::CheckBox::onChangePropertyShape() { - m_shaper.setSource(*propertyShape); - m_shaperIdSize = m_shaper.requestConfig("box-size"); - m_shaperIdSizeInsize = m_shaper.requestConfig("box-inside"); + this.shaper.setSource(*propertyShape); + this.shaperIdSize = this.shaper.requestConfig("box-size"); + this.shaperIdSizeInsize = this.shaper.requestConfig("box-inside"); markToRedraw(); } void ewol::widget::CheckBox::onChangePropertyValue() { if (*propertyValue == false) { - m_idWidgetDisplayed = convertId(0); + this.idWidgetDisplayed = convertId(0); } else { - m_idWidgetDisplayed = convertId(1); + this.idWidgetDisplayed = convertId(1); } CheckStatus(); markToRedraw(); - m_shaper.setActivateState(*propertyValue==true?1:0); + this.shaper.setActivateState(*propertyValue==true?1:0); } diff --git a/src/org/atriasoft/ewol/widget/CheckBox.java b/src/org/atriasoft/ewol/widget/CheckBox.java index 49a2987..86f8fbd 100644 --- a/src/org/atriasoft/ewol/widget/CheckBox.java +++ b/src/org/atriasoft/ewol/widget/CheckBox.java @@ -16,7 +16,7 @@ namespace ewol { namespace widget { class CheckBox; - using CheckBoxShared = ememory::SharedPtr; + using CheckBox = ememory::Ptr; using CheckBoxWeak = ememory::WeakPtr; class CheckBox : public ewol::widget::Container2 { public: // Event list @@ -29,56 +29,56 @@ namespace ewol { eproperty::Value propertyValue; //!< Current state of the checkbox. eproperty::Value propertyShape; //!< shape of the widget private: - ewol::compositing::Shaper m_shaper; //!< Compositing theme. - bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). - bool m_buttonPressed; //!< Flag to know if the button is curently pressed. + ewol::compositing::Shaper this.shaper; //!< Compositing theme. + boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). + boolean this.buttonPressed; //!< Flag to know if the button is curently pressed. // hover area : - Vector2f m_selectableAreaPos; //!< Start position of the events - Vector2f m_selectableAreaSize; //!< size of the event positions + Vector2f this.selectableAreaPos; //!< Start position of the events + Vector2f this.selectableAreaSize; //!< size of the event positions // shaper ids: - int32_t m_shaperIdSize; - int32_t m_shaperIdSizeInsize; + int this.shaperIdSize; + int this.shaperIdSizeInsize; protected: /** - * @brief Main checkbox constructor + * @brief Main checkbox ructor * @param[in] _shaperName Shaper file properties */ CheckBox(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(CheckBox, "CheckBox"); /** * @brief main destructor. */ - virtual ~CheckBox(); + ~CheckBox(); protected: /** * @brief internal system to change the property of the current status * @param[in] _newStatusId new state */ - void changeStatusIn(int32_t _newStatusId); + void changeStatusIn(int _newStatusId); /** * @brief update the status with the internal satte of the button ... */ void CheckStatus(); protected: - void onDraw() override; + void onDraw() ; public: - void calculateMinMaxSize() override; - void onChangeSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - bool onEventEntry(const ewol::event::Entry& _event) override; + void calculateMinMaxSize() ; + void onChangeSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + boolean onEventEntry( ewol::event::Entry _event) ; protected: - esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed + esignal::Connection this.PCH; //!< Periodic call handle to remove it when needed /** * @brief Periodic call to update grapgic display * @param[in] _event Time generic event */ - void periodicCall(const ewol::event::Time& _event); + void periodicCall( ewol::event::Time _event); protected: - virtual void onChangePropertyShape(); - virtual void onChangePropertyValue(); + void onChangePropertyShape(); + void onChangePropertyValue(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/ColorBar.cpp b/src/org/atriasoft/ewol/widget/ColorBar.cpp index b2d1973..f6a4815 100644 --- a/src/org/atriasoft/ewol/widget/ColorBar.cpp +++ b/src/org/atriasoft/ewol/widget/ColorBar.cpp @@ -18,9 +18,9 @@ ewol::widget::ColorBar::ColorBar() : propertyValue(this, "color", etk::color::black, "Current color", - &ewol::widget::ColorBar::onChangePropertyValue) { + ewol::widget::ColorBar::onChangePropertyValue) { addObjectType("ewol::widget::ColorBar"); - m_currentUserPos.setValue(0,0); + this.currentUserPos.setValue(0,0); propertyCanFocus.setDirectCheck(true); setMouseLimit(1); } @@ -31,7 +31,7 @@ ewol::widget::ColorBar::~ColorBar() { void ewol::widget::ColorBar::calculateMinMaxSize() { - m_minSize.setValue(160, 80); + this.minSize.setValue(160, 80); markToRedraw(); } @@ -55,7 +55,7 @@ void ewol::widget::ColorBar::onChangePropertyValue() { } void ewol::widget::ColorBar::onDraw() { - m_draw.draw(); + this.draw.draw(); } @@ -64,23 +64,23 @@ void ewol::widget::ColorBar::onRegenerateDisplay() { return; } // clean the object list ... - m_draw.clear(); + this.draw.clear(); - int32_t tmpSizeX = m_minSize.x(); - int32_t tmpSizeY = m_minSize.y(); - int32_t tmpOriginX = (m_size.x() - m_minSize.x()) / 2; - int32_t tmpOriginY = (m_size.y() - m_minSize.y()) / 2; + int tmpSizeX = this.minSize.x(); + int tmpSizeY = this.minSize.y(); + int tmpOriginX = (this.size.x() - this.minSize.x()) / 2; + int tmpOriginY = (this.size.y() - this.minSize.y()) / 2; - if (propertyFill->x() == true) { - tmpSizeX = m_size.x(); + if (propertyFill.x() == true) { + tmpSizeX = this.size.x(); tmpOriginX = 0; } - if (propertyFill->y() == true) { - tmpSizeY = m_size.y(); + if (propertyFill.y() == true) { + tmpSizeY = this.size.y(); tmpOriginY = 0; } - for(int32_t iii=0; iii 0.5) { - m_draw.setColor(etk::color::white); + if (this.currentUserPos.y() > 0.5) { + this.draw.setColor(etk::color::white); } else { - m_draw.setColor(etk::color::black); + this.draw.setColor(etk::color::black); } - m_draw.setPos(Vector3f(m_currentUserPos.x()*m_size.x(), m_currentUserPos.y()*m_size.y(), 0) ); - m_draw.setThickness(1); - m_draw.circle(3.0); + this.draw.setPos(Vector3f(this.currentUserPos.x()*this.size.x(), this.currentUserPos.y()*this.size.y(), 0) ); + this.draw.setThickness(1); + this.draw.circle(3.0); } -bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::ColorBar::onEventInput( ewol::event::Input _event) { Vector2f relativePos = relativePosition(_event.getPos()); //Log.debug("Event on BT ..."); if (1 == _event.getId()) { - relativePos.setValue( etk::avg(0.0f, m_size.x(),relativePos.x()), - etk::avg(0.0f, m_size.y(),relativePos.y()) ); - if( gale::key::status::pressSingle == _event.getStatus() - || gale::key::status::move == _event.getStatus()) { + relativePos.setValue( etk::avg(0.0f, this.size.x(),relativePos.x()), + etk::avg(0.0f, this.size.y(),relativePos.y()) ); + if( KeyStatus::pressSingle == _event.getStatus() + || KeyStatus::move == _event.getStatus()) { // nothing to do ... - m_currentUserPos.setValue( relativePos.x()/m_size.x(), - relativePos.y()/m_size.y() ); + this.currentUserPos.setValue( relativePos.x()/this.size.x(), + relativePos.y()/this.size.y() ); markToRedraw(); // == > try to estimate color - Log.verbose("event on (" << relativePos.x() << "," << relativePos.y() << ")"); - int32_t bandID = (int32_t)(relativePos.x()/(m_size.x()/6)); - float localPos = relativePos.x() - (m_size.x()/6) * bandID; - float poroportionnalPos = localPos/(m_size.x()/6); - Log.verbose("bandId=" << bandID << " relative pos=" << localPos); + Log.verbose("event on (" + relativePos.x() + "," + relativePos.y() + ")"); + int bandID = (int)(relativePos.x()/(this.size.x()/6)); + float localPos = relativePos.x() - (this.size.x()/6) * bandID; + float poroportionnalPos = localPos/(this.size.x()/6); + Log.verbose("bandId=" + bandID + " relative pos=" + localPos); etk::Color<> estimateColor = etk::color::white; if (s_listColor[bandID].r() == s_listColor[bandID+1].r()) { estimateColor.setR(s_listColor[bandID].r()); @@ -198,15 +198,15 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { estimateColor.setB(s_listColor[bandID+1].b() + (s_listColor[bandID].b()-s_listColor[bandID+1].b())*(1-poroportionnalPos)); } // step 2 generate the white and black ... - if (m_currentUserPos.y() == 0.5) { + if (this.currentUserPos.y() == 0.5) { // nothing to do ... just get the current color ... - } else if (m_currentUserPos.y() < 0.5) { - float poroportionnalWhite = (0.5-m_currentUserPos.y())*2.0; + } else if (this.currentUserPos.y() < 0.5) { + float poroportionnalWhite = (0.5-this.currentUserPos.y())*2.0; estimateColor.setR(estimateColor.r() + (0xFF-estimateColor.r())*poroportionnalWhite); estimateColor.setG(estimateColor.g() + (0xFF-estimateColor.g())*poroportionnalWhite); estimateColor.setB(estimateColor.b() + (0xFF-estimateColor.b())*poroportionnalWhite); } else { - float poroportionnalBlack = (m_currentUserPos.y()-0.5)*2.0; + float poroportionnalBlack = (this.currentUserPos.y()-0.5)*2.0; estimateColor.setR(estimateColor.r() - estimateColor.r()*poroportionnalBlack); estimateColor.setG(estimateColor.g() - estimateColor.g()*poroportionnalBlack); estimateColor.setB(estimateColor.b() - estimateColor.b()*poroportionnalBlack); diff --git a/src/org/atriasoft/ewol/widget/ColorBar.java b/src/org/atriasoft/ewol/widget/ColorBar.java index cf6d164..542a161 100644 --- a/src/org/atriasoft/ewol/widget/ColorBar.java +++ b/src/org/atriasoft/ewol/widget/ColorBar.java @@ -16,9 +16,9 @@ namespace ewol { namespace widget { class ColorBar; - using ColorBarShared = ememory::SharedPtr; + using ColorBar = ememory::Ptr; using ColorBarWeak = ememory::WeakPtr; - class ColorBar : public ewol::Widget { + class ColorBar : public Widget { public: // signals esignal::Signal> signalChange; public: @@ -27,18 +27,18 @@ namespace ewol { ColorBar(); public: DECLARE_WIDGET_FACTORY(ColorBar, "ColorBar"); - virtual ~ColorBar(); + ~ColorBar(); private: - ewol::compositing::Drawing m_draw; //!< Compositing drawing element - Vector2f m_currentUserPos; + ewol::compositing::Drawing this.draw; //!< Compositing drawing element + Vector2f this.currentUserPos; protected: - void onDraw() override; + void onDraw() ; public: - void calculateMinMaxSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; + void calculateMinMaxSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; protected: - virtual void onChangePropertyValue(); + void onChangePropertyValue(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Composer.cpp b/src/org/atriasoft/ewol/widget/Composer.cpp index 91063ab..2b4a66f 100644 --- a/src/org/atriasoft/ewol/widget/Composer.cpp +++ b/src/org/atriasoft/ewol/widget/Composer.cpp @@ -15,27 +15,27 @@ ETK_DECLARE_TYPE(ewol::widget::Composer); ewol::widget::Composer::Composer() : propertyRemoveIfUnderRemove(this, "remove-if-under-remove", true, "Demand the remove iof the widget if the subObject demand a remove"), - propertySubFile(this, "sub-file", "", "compose with a subXML file", &ewol::widget::Composer::onChangePropertySubFile) { + propertySubFile(this, "sub-file", "", "compose with a subXML file", ewol::widget::Composer::onChangePropertySubFile) { addObjectType("ewol::widget::Composer"); // nothing to do ... } -ewol::WidgetShared ewol::widget::composerGenerateFile(const etk::Uri& _uri, uint64_t _id) { - etk::String tmpData; +Widget ewol::widget::composerGenerateFile( etk::Uri _uri, ulong _id) { + String tmpData; if (etk::uri::readAll(_uri, tmpData) == false) { - Log.error("Can not read the file: " << _uri); + Log.error("Can not read the file: " + _uri); return null; } return ewol::widget::composerGenerateString(tmpData, _id); } -ewol::WidgetShared ewol::widget::composerGenerateString(const etk::String& _data, uint64_t _id) { - ewol::widget::Manager& widgetManager = ewol::getContext().getWidgetManager(); +Widget ewol::widget::composerGenerateString( String _data, ulong _id) { + ewol::widget::Manager widgetManager = ewol::getContext().getWidgetManager(); if (_data == "") { return null; } exml::Document doc; - etk::String tmpData = _data; + String tmpData = _data; // replace all elements: if (_id != 0) { tmpData.replace("{ID}", etk::toString(_id)); @@ -50,26 +50,26 @@ ewol::WidgetShared ewol::widget::composerGenerateString(const etk::String& _data return null; } if (root.nodes.size() > 1) { - EWOL_WARNING(" (l ?) More than 1 node in the XML file/string. (JUST parse the first)"); + Log.warning(" (l ?) More than 1 node in the XML file/string. (JUST parse the first)"); } exml::Element pNode = root.nodes[0].toElement(); if (pNode.exist() == false) { Log.error(" (l ?) No node in the XML file/string. {2}"); return null; } - etk::String widgetName = pNode.getValue(); + String widgetName = pNode.getValue(); if (widgetManager.exist(widgetName) == false) { - Log.error("(l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in : [" << widgetManager.list() << "]" ); + Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [" + widgetManager.list() + "]" ); return null; } - Log.debug("try to create subwidget : '" << widgetName << "'"); - ewol::WidgetShared tmpWidget = widgetManager.create(widgetName); + Log.debug("try to create subwidget : '" + widgetName + "'"); + Widget tmpWidget = widgetManager.create(widgetName); if (tmpWidget == null) { - EWOL_ERROR ("(l " << pNode.getPos() << ") Can not create the widget : '" << widgetName << "'"); + EWOL_ERROR ("(l " + pNode.getPos() + ") Can not create the widget : '" + widgetName + "'"); return null; } - if (tmpWidget->loadXML(pNode) == false) { - EWOL_ERROR ("(l " << pNode.getPos() << ") can not load widget properties : '" << widgetName << "'"); + if (tmpWidget.loadXML(pNode) == false) { + EWOL_ERROR ("(l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'"); } return tmpWidget; } @@ -78,18 +78,18 @@ ewol::widget::Composer::~Composer() { } -bool ewol::widget::Composer::loadFromFile(const etk::Uri& _uri, uint64_t _id) { - etk::String tmpData; +boolean ewol::widget::Composer::loadFromFile( etk::Uri _uri, ulong _id) { + String tmpData; if (etk::uri::readAll(_uri, tmpData) == false) { - Log.error("Can not read the file: " << _uri); + Log.error("Can not read the file: " + _uri); return false; } return loadFromString(tmpData, _id); } -bool ewol::widget::Composer::loadFromString(const etk::String& _composerXmlString, uint64_t _id) { +boolean ewol::widget::Composer::loadFromString( String _composerXmlString, ulong _id) { exml::Document doc; - etk::String tmpData = _composerXmlString; + String tmpData = _composerXmlString; // replace all elements: if (_id != 0) { tmpData.replace("{ID}", etk::toString(_id)); @@ -103,20 +103,20 @@ bool ewol::widget::Composer::loadFromString(const etk::String& _composerXmlStrin // Maybe a multiple node XML for internal config: root = doc.toElement(); if (root.exist() == false) { - Log.error("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: 'composer' ..."); + Log.error("[" + getId() + "] {" + getObjectType() + "} (l ?) main node not find: 'composer' ..."); return false; } if (root.nodes.size() == 0) { - Log.error("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element."); + Log.error("[" + getId() + "] {" + getObjectType() + "} (l ?) no node in the Container XML element."); return false; } } // call upper class to parse his elements ... ewol::widget::Container::loadXML(root); - if (m_subWidget == null) { - EWOL_WARNING("Load data from composer and have no under Widget after loading"); + if (this.subWidget == null) { + Log.warning("Load data from composer and have no under Widget after loading"); if (_composerXmlString.size() != 0) { - Log.error("Error Loading XML data : " << _composerXmlString); + Log.error("Error Loading XML data : " + _composerXmlString); return false; } } @@ -124,7 +124,7 @@ bool ewol::widget::Composer::loadFromString(const etk::String& _composerXmlStrin return true; } -void ewol::widget::Composer::requestDestroyFromChild(const ewol::ObjectShared& _child) { +void ewol::widget::Composer::requestDestroyFromChild( EwolObject _child) { ewol::widget::Container::requestDestroyFromChild(_child); if (*propertyRemoveIfUnderRemove == true) { Log.debug("Child widget remove ==> auto-remove"); @@ -133,30 +133,30 @@ void ewol::widget::Composer::requestDestroyFromChild(const ewol::ObjectShared& _ } void ewol::widget::Composer::onChangePropertySubFile() { - Log.info("Load compositing form external file : " << propertySubFile); + Log.info("Load compositing form external file : " + propertySubFile); if (*propertySubFile == "") { // remove all elements: subWidgetRemove(); return; } if (loadFromFile(*propertySubFile, getId()) == false) { - Log.error("Can not load Player GUI from file ... " << propertySubFile); + Log.error("Can not load Player GUI from file ... " + propertySubFile); return; } } -bool ewol::widget::Composer::loadXML(const exml::Element& _node) { - //Log.verbose("[" << getId() << "] t=" << getObjectType() << " Load XML (start)"); +boolean ewol::widget::Composer::loadXML( exml::Element _node) { + //Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load XML (start)"); if (_node.exist() == false) { return false; } // parse generic properties: - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // parse all the elements: if (_node.nodes.size() != 0) { Log.error("a composer Node Can not have Sub-element in XML ==> must be done in an external file and load it with attribute: 'sub-file'"); } //drawWidgetTree(); - //Log.verbose("[" << getId() << "] t=" << getObjectType() << " Load XML (stop)"); + //Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load XML (stop)"); return true; } \ No newline at end of file diff --git a/src/org/atriasoft/ewol/widget/Composer.java b/src/org/atriasoft/ewol/widget/Composer.java index 7f46063..ae72d5a 100644 --- a/src/org/atriasoft/ewol/widget/Composer.java +++ b/src/org/atriasoft/ewol/widget/Composer.java @@ -13,7 +13,7 @@ namespace ewol { namespace widget { class Composer; - using ComposerShared = ememory::SharedPtr; + using Composer = ememory::Ptr; using ComposerWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -33,7 +33,7 @@ namespace ewol { /** * @brief Destructor */ - virtual ~Composer(); + ~Composer(); /** * @brief load a composition with a file * @param[in] _uri Name of the file @@ -41,7 +41,7 @@ namespace ewol { * @return true == > all done OK * @return false == > some error occured */ - bool loadFromFile(const etk::Uri& _uri, uint64_t _id=0); + boolean loadFromFile( etk::Uri _uri, ulong _id=0); /** * @brief load a composition with a file * @param[in] _composerXmlString xml to parse directly @@ -49,15 +49,15 @@ namespace ewol { * @return true == > all done OK * @return false == > some error occured */ - bool loadFromString(const etk::String& _composerXmlString, uint64_t _id=0); + boolean loadFromString( String _composerXmlString, ulong _id=0); private: - void requestDestroyFromChild(const ewol::ObjectShared& _child) override; + void requestDestroyFromChild( EwolObject _child) ; public: - bool loadXML(const exml::Element& _node) override; + boolean loadXML( exml::Element _node) ; protected: - virtual void onChangePropertySubFile(); + void onChangePropertySubFile(); }; - ewol::WidgetShared composerGenerateString(const etk::String& _data = "", uint64_t _id=0); - ewol::WidgetShared composerGenerateFile(const etk::Uri& _uri = "", uint64_t _id=0); + Widget composerGenerateString( String _data = "", ulong _id=0); + Widget composerGenerateFile( etk::Uri _uri = "", ulong _id=0); }; }; diff --git a/src/org/atriasoft/ewol/widget/Container.cpp b/src/org/atriasoft/ewol/widget/Container.cpp index 032b06c..063ee81 100644 --- a/src/org/atriasoft/ewol/widget/Container.cpp +++ b/src/org/atriasoft/ewol/widget/Container.cpp @@ -21,195 +21,195 @@ ewol::widget::Container::~Container() { subWidgetRemove(); } -ewol::WidgetShared ewol::widget::Container::getSubWidget() { - return m_subWidget; +Widget ewol::widget::Container::getSubWidget() { + return this.subWidget; } -void ewol::widget::Container::setSubWidget(ewol::WidgetShared _newWidget) { +void ewol::widget::Container::setSubWidget(Widget _newWidget) { if (_newWidget == null) { return; } subWidgetRemove(); - m_subWidget = _newWidget; - if (m_subWidget != null) { - m_subWidget->setParent(sharedFromThis()); + this.subWidget = _newWidget; + if (this.subWidget != null) { + this.subWidget.setParent(sharedFromThis()); } markToRedraw(); requestUpdateSize(); } -void ewol::widget::Container::subWidgetReplace(const ewol::WidgetShared& _oldWidget, - const ewol::WidgetShared& _newWidget) { - if (m_subWidget != _oldWidget) { - EWOL_WARNING("Request replace with a wrong old widget"); +void ewol::widget::Container::subWidgetReplace( Widget _oldWidget, + Widget _newWidget) { + if (this.subWidget != _oldWidget) { + Log.warning("Request replace with a wrong old widget"); return; } - m_subWidget->removeParent(); - m_subWidget.reset(); - m_subWidget = _newWidget; - if (m_subWidget != null) { - m_subWidget->setParent(sharedFromThis()); + this.subWidget.removeParent(); + this.subWidget.reset(); + this.subWidget = _newWidget; + if (this.subWidget != null) { + this.subWidget.setParent(sharedFromThis()); } markToRedraw(); requestUpdateSize(); } void ewol::widget::Container::subWidgetRemove() { - if (m_subWidget != null) { - m_subWidget->removeParent(); - m_subWidget.reset(); + if (this.subWidget != null) { + this.subWidget.removeParent(); + this.subWidget.reset(); markToRedraw(); requestUpdateSize(); } } void ewol::widget::Container::subWidgetUnLink() { - if (m_subWidget != null) { - m_subWidget->removeParent(); + if (this.subWidget != null) { + this.subWidget.removeParent(); } - m_subWidget.reset(); + this.subWidget.reset(); } -ewol::ObjectShared ewol::widget::Container::getSubObjectNamed(const etk::String& _objectName) { - ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_objectName); +EwolObject ewol::widget::Container::getSubObjectNamed( String _objectName) { + EwolObject tmpObject = Widget::getSubObjectNamed(_objectName); if (tmpObject != null) { return tmpObject; } - if (m_subWidget != null) { - return m_subWidget->getSubObjectNamed(_objectName); + if (this.subWidget != null) { + return this.subWidget.getSubObjectNamed(_objectName); } return null; } -void ewol::widget::Container::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::Container::systemDraw( ewol::DrawProperty _displayProp) { if (propertyHide.get() == true){ // widget is hidden ... return; } - ewol::Widget::systemDraw(_displayProp); - if (m_subWidget != null) { + Widget::systemDraw(_displayProp); + if (this.subWidget != null) { ewol::DrawProperty prop = _displayProp; - prop.limit(m_origin, m_size); - //Log.info("Draw : [" << propertyName << "] t=" << getObjectType() << " o=" << m_origin << " s=" << m_size); - m_subWidget->systemDraw(prop); + prop.limit(this.origin, this.size); + //Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size); + this.subWidget.systemDraw(prop); } else { - Log.info("[" << getId() << "] ++++++ : [null]"); + Log.info("[" + getId() + "] ++++++ : [null]"); } } void ewol::widget::Container::onChangeSize() { - ewol::Widget::onChangeSize(); + Widget::onChangeSize(); if (*propertyHide == true) { return; } - if (m_subWidget == null) { + if (this.subWidget == null) { return; } - Vector2f origin = m_origin+m_offset; - Vector2f minSize = m_subWidget->getCalculateMinSize(); - Vector2b expand = m_subWidget->propertyExpand.get(); - origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - m_size); - m_subWidget->setOrigin(origin); - m_subWidget->setSize(m_size); - m_subWidget->onChangeSize(); + Vector2f origin = this.origin+this.offset; + Vector2f minSize = this.subWidget.getCalculateMinSize(); + Vector2b expand = this.subWidget.propertyExpand.get(); + origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - this.size); + this.subWidget.setOrigin(origin); + this.subWidget.setSize(this.size); + this.subWidget.onChangeSize(); } void ewol::widget::Container::calculateMinMaxSize() { // call main class - ewol::Widget::calculateMinMaxSize(); + Widget::calculateMinMaxSize(); // call sub classes - if (m_subWidget != null) { - m_subWidget->calculateMinMaxSize(); - Vector2f min = m_subWidget->getCalculateMinSize(); - m_minSize.setMax(min); + if (this.subWidget != null) { + this.subWidget.calculateMinMaxSize(); + Vector2f min = this.subWidget.getCalculateMinSize(); + this.minSize.setMax(min); } - //Log.error("[" << getId() << "] Result min size : " << m_minSize); + //Log.error("[" + getId() + "] Result min size : " + this.minSize); } void ewol::widget::Container::onRegenerateDisplay() { - if (m_subWidget != null) { - m_subWidget->onRegenerateDisplay(); + if (this.subWidget != null) { + this.subWidget.onRegenerateDisplay(); } } -ewol::WidgetShared ewol::widget::Container::getWidgetAtPos(const Vector2f& _pos) { +Widget ewol::widget::Container::getWidgetAtPos( Vector2f _pos) { if (propertyHide.get() == false) { - if (m_subWidget != null) { - return m_subWidget->getWidgetAtPos(_pos); + if (this.subWidget != null) { + return this.subWidget.getWidgetAtPos(_pos); } } return null; }; -bool ewol::widget::Container::loadXML(const exml::Element& _node) { +boolean ewol::widget::Container::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } // parse generic properties: - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // remove previous element: subWidgetRemove(); // parse all the elements: - for (const auto it : _node.nodes) { + for ( auto it : _node.nodes) { exml::Element pNode = it.toElement(); if (pNode.exist() == false) { // trash here all that is not element continue; } - etk::String widgetName = pNode.getValue(); - Log.verbose("[" << getId() << "] t=" << getObjectType() << " Load node name : '" << widgetName << "'"); + String widgetName = pNode.getValue(); + Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load node name : '" + widgetName + "'"); if (getWidgetManager().exist(widgetName) == false) { - Log.error("(l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in : [" << getWidgetManager().list() << "]" ); + Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]" ); continue; } if (getSubWidget() != null) { - Log.error("(l " << pNode.getPos() << ") Can only have one subWidget ??? node='" << widgetName << "'" ); + Log.error("(l " + pNode.getPos() + ") Can only have one subWidget ??? node='" + widgetName + "'" ); continue; } - Log.debug("try to create subwidget : '" << widgetName << "'"); - ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName, pNode); + Log.debug("try to create subwidget : '" + widgetName + "'"); + Widget tmpWidget = getWidgetManager().create(widgetName, pNode); if (tmpWidget == null) { - EWOL_ERROR ("(l " << pNode.getPos() << ") Can not create the widget : '" << widgetName << "'"); + EWOL_ERROR ("(l " + pNode.getPos() + ") Can not create the widget : '" + widgetName + "'"); continue; } // add widget : setSubWidget(tmpWidget); - if (tmpWidget->loadXML(pNode) == false) { - EWOL_ERROR ("(l " << pNode.getPos() << ") can not load widget properties : '" << widgetName << "'"); + if (tmpWidget.loadXML(pNode) == false) { + EWOL_ERROR ("(l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'"); return false; } } if ( _node.nodes.size() != 0 - && m_subWidget == null) { - EWOL_WARNING("Load container with no data inside"); + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget == null) { + Log.warning("Load container with no data inside"); } return true; } -void ewol::widget::Container::setOffset(const Vector2f& _newVal) { - if (m_offset != _newVal) { - ewol::Widget::setOffset(_newVal); +void ewol::widget::Container::setOffset( Vector2f _newVal) { + if (this.offset != _newVal) { + Widget::setOffset(_newVal); // recalculate the new sise and position of sub widget ... onChangeSize(); } } -void ewol::widget::Container::requestDestroyFromChild(const ewol::ObjectShared& _child) { - if (m_subWidget != _child) { +void ewol::widget::Container::requestDestroyFromChild( EwolObject _child) { + if (this.subWidget != _child) { return; } - if (m_subWidget == null) { + if (this.subWidget == null) { return; } - m_subWidget->removeParent(); - m_subWidget.reset(); + this.subWidget.removeParent(); + this.subWidget.reset(); markToRedraw(); } -void ewol::widget::Container::drawWidgetTree(int32_t _level) { - ewol::Widget::drawWidgetTree(_level); +void ewol::widget::Container::drawWidgetTree(int _level) { + Widget::drawWidgetTree(_level); _level++; - if (m_subWidget != null) { - m_subWidget->drawWidgetTree(_level); + if (this.subWidget != null) { + this.subWidget.drawWidgetTree(_level); } } diff --git a/src/org/atriasoft/ewol/widget/Container.java b/src/org/atriasoft/ewol/widget/Container.java index 4dc6cc0..d10aa88 100644 --- a/src/org/atriasoft/ewol/widget/Container.java +++ b/src/org/atriasoft/ewol/widget/Container.java @@ -12,15 +12,15 @@ namespace ewol { namespace widget { class Container; - using ContainerShared = ememory::SharedPtr; + using Container = ememory::Ptr; using ContainerWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the Cotainer widget is a widget that have an only one subWidget */ - class Container : public ewol::Widget { + class Container : public Widget { protected: - ewol::WidgetShared m_subWidget; + Widget this.subWidget; protected: /** * @brief Constructor @@ -30,25 +30,25 @@ namespace ewol { /** * @brief Destructor */ - virtual ~Container(); + ~Container(); public: /** * @brief get the main node widget * @return the requested pointer on the node */ - ewol::WidgetShared getSubWidget(); + Widget getSubWidget(); /** * @brief set the subWidget node widget. * @param[in] _newWidget The widget to add. */ - void setSubWidget(ewol::WidgetShared _newWidget); + void setSubWidget(Widget _newWidget); /** * @brief Replace a old subwidget with a new one. * @param[in] _oldWidget The widget to replace. * @param[in] _newWidget The widget to set. */ - virtual void subWidgetReplace(const ewol::WidgetShared& _oldWidget, - const ewol::WidgetShared& _newWidget); + void subWidgetReplace( Widget _oldWidget, + Widget _newWidget); /** * @brief remove the subWidget node (async). */ @@ -58,16 +58,16 @@ namespace ewol { */ void subWidgetUnLink(); public: - void systemDraw(const ewol::DrawProperty& _displayProp) override; - void onRegenerateDisplay() override; - void onChangeSize() override; - void calculateMinMaxSize() override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; - ewol::ObjectShared getSubObjectNamed(const etk::String& _objectName) override; - bool loadXML(const exml::Element& _node) override; - void setOffset(const Vector2f& _newVal) override; - void requestDestroyFromChild(const ewol::ObjectShared& _child) override; - void drawWidgetTree(int32_t _level=0) override; + void systemDraw( ewol::DrawProperty _displayProp) ; + void onRegenerateDisplay() ; + void onChangeSize() ; + void calculateMinMaxSize() ; + Widget getWidgetAtPos( Vector2f _pos) ; + EwolObject getSubObjectNamed( String _objectName) ; + boolean loadXML( exml::Element _node) ; + void setOffset( Vector2f _newVal) ; + void requestDestroyFromChild( EwolObject _child) ; + void drawWidgetTree(int _level=0) ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Container2.cpp b/src/org/atriasoft/ewol/widget/Container2.cpp index 75488dc..f02de2f 100644 --- a/src/org/atriasoft/ewol/widget/Container2.cpp +++ b/src/org/atriasoft/ewol/widget/Container2.cpp @@ -13,7 +13,7 @@ ETK_DECLARE_TYPE(ewol::widget::Container2); ewol::widget::Container2::Container2() : - m_idWidgetDisplayed(0) { + this.idWidgetDisplayed(0) { addObjectType("ewol::widget::Container2"); } @@ -22,34 +22,34 @@ ewol::widget::Container2::~Container2() { subWidgetRemoveToggle(); } -void ewol::widget::Container2::setSubWidget(ewol::WidgetShared _newWidget, int32_t _idWidget) { +void ewol::widget::Container2::setSubWidget(Widget _newWidget, int _idWidget) { subWidgetRemove(_idWidget); - m_subWidget[_idWidget] = _newWidget; - if (m_subWidget[_idWidget] != null) { - Log.verbose("Add widget : " << _idWidget); - m_subWidget[_idWidget]->setParent(sharedFromThis()); + this.subWidget[_idWidget] = _newWidget; + if (this.subWidget[_idWidget] != null) { + Log.verbose("Add widget : " + _idWidget); + this.subWidget[_idWidget].setParent(sharedFromThis()); } markToRedraw(); requestUpdateSize(); } -void ewol::widget::Container2::subWidgetReplace(const ewol::WidgetShared& _oldWidget, - const ewol::WidgetShared& _newWidget) { - bool haveChange = false; - for (size_t iii=0; iii<2; ++iii) { - if (m_subWidget[iii] != _oldWidget) { +void ewol::widget::Container2::subWidgetReplace( Widget _oldWidget, + Widget _newWidget) { + boolean haveChange = false; + for (int iii=0; iii<2; ++iii) { + if (this.subWidget[iii] != _oldWidget) { continue; } - m_subWidget[iii]->removeParent(); - m_subWidget[iii].reset(); - m_subWidget[iii] = _newWidget; - if (m_subWidget[iii] != null) { - m_subWidget[iii]->setParent(sharedFromThis()); + this.subWidget[iii].removeParent(); + this.subWidget[iii].reset(); + this.subWidget[iii] = _newWidget; + if (this.subWidget[iii] != null) { + this.subWidget[iii].setParent(sharedFromThis()); } haveChange = true; } if (haveChange == false) { - EWOL_WARNING("Request replace with a wrong old widget"); + Log.warning("Request replace with a wrong old widget"); return; } markToRedraw(); @@ -57,80 +57,80 @@ void ewol::widget::Container2::subWidgetReplace(const ewol::WidgetShared& _oldWi } -void ewol::widget::Container2::subWidgetRemove(int32_t _idWidget) { - if (m_subWidget[_idWidget] != null) { - Log.verbose("Remove widget : " << _idWidget); - m_subWidget[_idWidget]->removeParent(); - m_subWidget[_idWidget].reset(); +void ewol::widget::Container2::subWidgetRemove(int _idWidget) { + if (this.subWidget[_idWidget] != null) { + Log.verbose("Remove widget : " + _idWidget); + this.subWidget[_idWidget].removeParent(); + this.subWidget[_idWidget].reset(); markToRedraw(); requestUpdateSize(); } } -void ewol::widget::Container2::subWidgetUnLink(int32_t _idWidget) { - if (m_subWidget[_idWidget] != null) { - m_subWidget[_idWidget]->removeParent(); - Log.verbose("Unlink widget : " << _idWidget); +void ewol::widget::Container2::subWidgetUnLink(int _idWidget) { + if (this.subWidget[_idWidget] != null) { + this.subWidget[_idWidget].removeParent(); + Log.verbose("Unlink widget : " + _idWidget); } - m_subWidget[_idWidget].reset(); + this.subWidget[_idWidget].reset(); } -ewol::ObjectShared ewol::widget::Container2::getSubObjectNamed(const etk::String& _widgetName) { - ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_widgetName); +EwolObject ewol::widget::Container2::getSubObjectNamed( String _widgetName) { + EwolObject tmpObject = Widget::getSubObjectNamed(_widgetName); if (tmpObject != null) { return tmpObject; } - if (m_subWidget[0] != null) { - tmpObject = m_subWidget[0]->getSubObjectNamed(_widgetName); + if (this.subWidget[0] != null) { + tmpObject = this.subWidget[0].getSubObjectNamed(_widgetName); if (tmpObject != null) { return tmpObject; } } - if (m_subWidget[1] != null) { - return m_subWidget[1]->getSubObjectNamed(_widgetName); + if (this.subWidget[1] != null) { + return this.subWidget[1].getSubObjectNamed(_widgetName); } return null; } -void ewol::widget::Container2::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::Container2::systemDraw( ewol::DrawProperty _displayProp) { if (propertyHide.get() == true){ // widget is hidden ... return; } - ewol::Widget::systemDraw(_displayProp); - if (m_subWidget[m_idWidgetDisplayed] != null) { - //Log.info("Draw : [" << propertyName << "] t=" << getObjectType() << " o=" << m_origin << " s=" << m_size); - m_subWidget[m_idWidgetDisplayed]->systemDraw(_displayProp); + Widget::systemDraw(_displayProp); + if (this.subWidget[this.idWidgetDisplayed] != null) { + //Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size); + this.subWidget[this.idWidgetDisplayed].systemDraw(_displayProp); } } -ewol::Padding ewol::widget::Container2::onChangeSizePadded(const ewol::Padding& _padding) { - ewol::Widget::onChangeSize(); - Vector2f localAvaillable = m_size - Vector2f(_padding.x(), _padding.y()); +ewol::Padding ewol::widget::Container2::onChangeSizePadded( ewol::Padding _padding) { + Widget::onChangeSize(); + Vector2f localAvaillable = this.size - Vector2f(_padding.x(), _padding.y()); // Checkin the filling properties == > for the subElements: - Vector2f subElementSize = m_minSize; - if (propertyFill->x() == true) { - subElementSize.setX(m_size.x()); + Vector2f subElementSize = this.minSize; + if (propertyFill.x() == true) { + subElementSize.setX(this.size.x()); } - if (propertyFill->y() == true) { - subElementSize.setY(m_size.y()); + if (propertyFill.y() == true) { + subElementSize.setY(this.size.y()); } - Vector2f delta = ewol::gravityGenerateDelta(propertyGravity, m_size - subElementSize); + Vector2f delta = ewol::gravityGenerateDelta(propertyGravity, this.size - subElementSize); Vector2f origin = delta + Vector2f(_padding.xLeft(), _padding.yButtom()); subElementSize -= Vector2f(_padding.x(), _padding.y()); - for (size_t iii = 0; iii < 2; ++iii) { - if (m_subWidget[iii] != null) { - Vector2f origin2 = origin+m_offset; - Vector2f minSize = m_subWidget[iii]->getCalculateMinSize(); - //Vector2b expand = m_subWidget[iii]->propertyExpand.get(); + for (int iii = 0; iii < 2; ++iii) { + if (this.subWidget[iii] != null) { + Vector2f origin2 = origin+this.offset; + Vector2f minSize = this.subWidget[iii].getCalculateMinSize(); + //Vector2b expand = this.subWidget[iii].propertyExpand.get(); origin2 += ewol::gravityGenerateDelta(propertyGravity, minSize - localAvaillable); - m_subWidget[iii]->setOrigin(m_origin + origin); - m_subWidget[iii]->setSize(subElementSize); - m_subWidget[iii]->onChangeSize(); + this.subWidget[iii].setOrigin(this.origin + origin); + this.subWidget[iii].setSize(subElementSize); + this.subWidget[iii].onChangeSize(); } } Vector2f selectableAreaPos = origin-Vector2f(_padding.xLeft(), _padding.yButtom()); - Vector2f selectableAreaEndPos = m_size - (selectableAreaPos + subElementSize + Vector2f(_padding.x(), _padding.y())); + Vector2f selectableAreaEndPos = this.size - (selectableAreaPos + subElementSize + Vector2f(_padding.x(), _padding.y())); markToRedraw(); return ewol::Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), @@ -138,74 +138,74 @@ ewol::Padding ewol::widget::Container2::onChangeSizePadded(const ewol::Padding& selectableAreaPos.y()); } -void ewol::widget::Container2::calculateMinMaxSizePadded(const ewol::Padding& _padding) { +void ewol::widget::Container2::calculateMinMaxSizePadded( ewol::Padding _padding) { // call main class - m_minSize = Vector2f(0,0); + this.minSize = Vector2f(0,0); // call sub classes - for (size_t iii = 0; iii < 2; ++iii) { - if (m_subWidget[iii] != null) { - m_subWidget[iii]->calculateMinMaxSize(); - Vector2f min = m_subWidget[iii]->getCalculateMinSize(); - m_minSize.setMax(min); + for (int iii = 0; iii < 2; ++iii) { + if (this.subWidget[iii] != null) { + this.subWidget[iii].calculateMinMaxSize(); + Vector2f min = this.subWidget[iii].getCalculateMinSize(); + this.minSize.setMax(min); } } // add padding : - m_minSize += Vector2f(_padding.x(), _padding.y()); + this.minSize += Vector2f(_padding.x(), _padding.y()); // verify the min max of the min size ... checkMinSize(); markToRedraw(); } void ewol::widget::Container2::onRegenerateDisplay() { - if (m_subWidget[m_idWidgetDisplayed] != null) { - m_subWidget[m_idWidgetDisplayed]->onRegenerateDisplay(); + if (this.subWidget[this.idWidgetDisplayed] != null) { + this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay(); } } /* -ewol::WidgetShared ewol::widget::Container2::getWidgetAtPos(const Vector2f& _pos) { +Widget ewol::widget::Container2::getWidgetAtPos( Vector2f _pos) { if (isHide() == false) { - if (m_subWidget[m_idWidgetDisplayed] != null) { - return m_subWidget[m_idWidgetDisplayed]->getWidgetAtPos(_pos); + if (this.subWidget[this.idWidgetDisplayed] != null) { + return this.subWidget[this.idWidgetDisplayed].getWidgetAtPos(_pos); } } return null; } */ -bool ewol::widget::Container2::loadXML(const exml::Element& _node) { +boolean ewol::widget::Container2::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } // parse generic properties : - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // remove previous element : subWidgetRemove(); - Log.verbose("Create en element 2 ... with nodes.size()=" << _node.nodes.size()); + Log.verbose("Create en element 2 ... with nodes.size()=" + _node.nodes.size()); // parse all the elements: - for(const auto it : _node.nodes) { - Log.verbose(" node: " << it); + for( auto it : _node.nodes) { + Log.verbose(" node: " + it); exml::Element pNode = it.toElement(); if (pNode.exist() == false) { // trash here all that is not element continue; } - etk::String widgetName = pNode.getValue(); + String widgetName = pNode.getValue(); if (getWidgetManager().exist(widgetName) == false) { - Log.error("(l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in: [" << getWidgetManager().list() << "]" ); + Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in: [" + getWidgetManager().list() + "]" ); continue; } - bool toogleMode=false; + boolean toogleMode=false; if (getSubWidget() != null) { toogleMode=true; if (getSubWidgetToggle() != null) { - Log.error("(l " << pNode.getPos() << ") Can only have one subWidget ??? node='" << widgetName << "'" ); + Log.error("(l " + pNode.getPos() + ") Can only have one subWidget ??? node='" + widgetName + "'" ); continue; } } - Log.debug("try to create subwidget : '" << widgetName << "'"); - ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName, pNode); + Log.debug("try to create subwidget : '" + widgetName + "'"); + Widget tmpWidget = getWidgetManager().create(widgetName, pNode); if (tmpWidget == null) { - EWOL_ERROR ("(l " << pNode.getPos() << ") Can not create the widget: '" << widgetName << "'"); + EWOL_ERROR ("(l " + pNode.getPos() + ") Can not create the widget: '" + widgetName + "'"); continue; } // add widget : @@ -214,48 +214,48 @@ bool ewol::widget::Container2::loadXML(const exml::Element& _node) { } else { setSubWidgetToggle(tmpWidget); } - if (tmpWidget->loadXML(pNode) == false) { - EWOL_ERROR ("(l "<removeParent(); - m_subWidget[0].reset(); + this.subWidget[0].removeParent(); + this.subWidget[0].reset(); markToRedraw(); } - if (m_subWidget[1] == _child) { - if (m_subWidget[1] == null) { + if (this.subWidget[1] == _child) { + if (this.subWidget[1] == null) { return; } - m_subWidget[1]->removeParent(); - m_subWidget[1].reset(); + this.subWidget[1].removeParent(); + this.subWidget[1].reset(); markToRedraw(); } } -void ewol::widget::Container2::drawWidgetTree(int32_t _level) { - ewol::Widget::drawWidgetTree(_level); +void ewol::widget::Container2::drawWidgetTree(int _level) { + Widget::drawWidgetTree(_level); _level++; - if (m_subWidget[0] != null) { - m_subWidget[0]->drawWidgetTree(_level); + if (this.subWidget[0] != null) { + this.subWidget[0].drawWidgetTree(_level); } - if (m_subWidget[1] != null) { - m_subWidget[1]->drawWidgetTree(_level); + if (this.subWidget[1] != null) { + this.subWidget[1].drawWidgetTree(_level); } } diff --git a/src/org/atriasoft/ewol/widget/Container2.java b/src/org/atriasoft/ewol/widget/Container2.java index 6048a43..11b9ce9 100644 --- a/src/org/atriasoft/ewol/widget/Container2.java +++ b/src/org/atriasoft/ewol/widget/Container2.java @@ -13,16 +13,16 @@ namespace ewol { namespace widget { class Container2; - using Container2Shared = ememory::SharedPtr; + using Container2 = ememory::Ptr; using Container2Weak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the Cotainer widget is a widget that have an only one subWidget */ - class Container2 : public ewol::Widget { + class Container2 : public Widget { protected: - ewol::WidgetShared m_subWidget[2]; //!< 2 subwidget possible - int32_t m_idWidgetDisplayed; //!< current widget displayed + Widget this.subWidget[2]; //!< 2 subwidget possible + int this.idWidgetDisplayed; //!< current widget displayed protected: /** * @brief Constructor @@ -34,27 +34,27 @@ namespace ewol { /** * @brief Destructor */ - virtual ~Container2(); + ~Container2(); private: /** * @brief Specify the current widget * @param[in] _subWidget Widget to add normal * @param[in] _idWidget Id of the widget to set */ - void setSubWidget(ewol::WidgetShared _subWidget, int32_t _idWidget); + void setSubWidget(Widget _subWidget, int _idWidget); public: /** * @brief Specify the current widget * @param[in] _subWidget Widget to add normal */ - void setSubWidget(ewol::WidgetShared _subWidget) { + void setSubWidget(Widget _subWidget) { setSubWidget(_subWidget, 0); } /** * @brief Specify the current toggle widget * @param[in] _subWidget Widget to add Toggle */ - void setSubWidgetToggle(ewol::WidgetShared _subWidget) { + void setSubWidgetToggle(Widget _subWidget) { setSubWidget(_subWidget, 1); } private: @@ -63,22 +63,22 @@ namespace ewol { * @param[in] _idWidget Id of the widget to set * @return The base widget */ - ewol::WidgetShared getSubWidget(int32_t _idWidget) const { - return m_subWidget[_idWidget]; + Widget getSubWidget(int _idWidget) { + return this.subWidget[_idWidget]; }; public: /** * @brief get the current displayed composition * @return The base widget */ - ewol::WidgetShared getSubWidget() const { + Widget getSubWidget() { return getSubWidget(0); }; /** * @brief get the current displayed composition * @return The toggle widget */ - ewol::WidgetShared getSubWidgetToggle() const { + Widget getSubWidgetToggle() { return getSubWidget(1); }; private: @@ -86,7 +86,7 @@ namespace ewol { * @brief remove the subWidget node (async). * @param[in] _idWidget Id of the widget to set */ - void subWidgetRemove(int32_t _idWidget); + void subWidgetRemove(int _idWidget); public: /** * @brief remove the subWidget node (async). @@ -105,7 +105,7 @@ namespace ewol { * @brief Unlink the subwidget Node. * @param[in] _idWidget Id of the widget to set */ - void subWidgetUnLink(int32_t _idWidget); + void subWidgetUnLink(int _idWidget); public: /** * @brief Unlink the subwidget Node. @@ -126,24 +126,24 @@ namespace ewol { * @param[in] _padding Padding of the widget. * @note : INTERNAL EWOL SYSTEM */ - virtual ewol::Padding onChangeSizePadded(const ewol::Padding& _padding = ewol::Padding(0,0,0,0)); + ewol::Padding onChangeSizePadded( ewol::Padding _padding = ewol::Padding(0,0,0,0)); /** * @brief calculate the minimum and maximum size (need to estimate expend properties of the widget) * @param[in] _padding Padding of the widget. * @note : INTERNAL EWOL SYSTEM */ - virtual void calculateMinMaxSizePadded(const ewol::Padding& _padding = ewol::Padding(0,0,0,0)); + void calculateMinMaxSizePadded( ewol::Padding _padding = ewol::Padding(0,0,0,0)); /** * @brief Called when parsing a XML and detect the presence of a second Widget */ - virtual void onDetectPresenceToggleWidget() {} + void onDetectPresenceToggleWidget() {} /** * @brief convert ID of the widget if not existed * @param[in] _id Id of the widget to display. * @return the id of the widget displayable */ - int32_t convertId(int32_t _id) { - if (m_subWidget[_id] == null) { + int convertId(int _id) { + if (this.subWidget[_id] == null) { return (_id+1)%2; } return _id; @@ -153,22 +153,22 @@ namespace ewol { * @param[in] _oldWidget The widget to replace. * @param[in] _newWidget The widget to set. */ - virtual void subWidgetReplace(const ewol::WidgetShared& _oldWidget, - const ewol::WidgetShared& _newWidget); + void subWidgetReplace( Widget _oldWidget, + Widget _newWidget); public: - void systemDraw(const ewol::DrawProperty& _displayProp) override; - void onRegenerateDisplay() override; - void onChangeSize() override { + void systemDraw( ewol::DrawProperty _displayProp) ; + void onRegenerateDisplay() ; + void onChangeSize() { onChangeSizePadded(); } - void calculateMinMaxSize() override { + void calculateMinMaxSize() { calculateMinMaxSizePadded(); } - ewol::ObjectShared getSubObjectNamed(const etk::String& _objectName) override; - bool loadXML(const exml::Element& _node) override; - void setOffset(const Vector2f& _newVal) override; - void requestDestroyFromChild(const ewol::ObjectShared& _child) override; - void drawWidgetTree(int32_t _level=0) override; + EwolObject getSubObjectNamed( String _objectName) ; + boolean loadXML( exml::Element _node) ; + void setOffset( Vector2f _newVal) ; + void requestDestroyFromChild( EwolObject _child) ; + void drawWidgetTree(int _level=0) ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/ContainerN.cpp b/src/org/atriasoft/ewol/widget/ContainerN.cpp index 31ab58e..6ec2429 100644 --- a/src/org/atriasoft/ewol/widget/ContainerN.cpp +++ b/src/org/atriasoft/ewol/widget/ContainerN.cpp @@ -16,8 +16,8 @@ ewol::widget::ContainerN::ContainerN() : propertyLockExpand(this, "lock", Vector2f(false,false), "Lock the subwidget expand", - &ewol::widget::ContainerN::onChangePropertyLockExpand), - m_subExpend(false,false) { + ewol::widget::ContainerN::onChangePropertyLockExpand), + this.subExpend(false,false) { addObjectType("ewol::widget::ContainerN"); // nothing to do ... } @@ -29,17 +29,17 @@ ewol::widget::ContainerN::~ContainerN() { Vector2b ewol::widget::ContainerN::canExpand() { Vector2b res = propertyExpand.get(); - if (propertyLockExpand->x() == false) { - if (m_subExpend.x() == true) { + if (propertyLockExpand.x() == false) { + if (this.subExpend.x() == true) { res.setX(true); } } - if (propertyLockExpand->y() == false) { - if (m_subExpend.y() == true) { + if (propertyLockExpand.y() == false) { + if (this.subExpend.y() == true) { res.setY(true); } } - //Log.debug("Expend check : user=" << m_userExpand << " lock=" << propertyLockExpand << " sub=" << m_subExpend << " res=" << res); + //Log.debug("Expend check : user=" + this.userExpand + " lock=" + propertyLockExpand + " sub=" + this.subExpend + " res=" + res); return res; } @@ -48,68 +48,68 @@ void ewol::widget::ContainerN::onChangePropertyLockExpand() { requestUpdateSize(); } -void ewol::widget::ContainerN::subWidgetReplace(ewol::WidgetShared _oldWidget, - ewol::WidgetShared _newWidget) { - bool haveChange = false; - for (auto &it : m_subWidget) { +void ewol::widget::ContainerN::subWidgetReplace(Widget _oldWidget, + Widget _newWidget) { + boolean haveChange = false; + for (auto it : this.subWidget) { if (it != _oldWidget) { continue; } - it->removeParent(); + it.removeParent(); it.reset(); if (_newWidget != null) { - _newWidget->setParent(sharedFromThis()); + _newWidget.setParent(sharedFromThis()); } it = _newWidget; haveChange = true; } if (haveChange == false) { - EWOL_WARNING("Request replace with a wrong old widget"); + Log.warning("Request replace with a wrong old widget"); return; } markToRedraw(); requestUpdateSize(); } -int32_t ewol::widget::ContainerN::subWidgetAdd(ewol::WidgetShared _newWidget) { +int ewol::widget::ContainerN::subWidgetAdd(Widget _newWidget) { if (_newWidget == null) { - Log.error("[" << getId() << "] {" << getObjectType() << "} Try to add An empty Widget ... "); + Log.error("[" + getId() + "] {" + getObjectType() + "} Try to add An empty Widget ... "); return -1; } - _newWidget->setParent(sharedFromThis()); - m_subWidget.pushBack(_newWidget); + _newWidget.setParent(sharedFromThis()); + this.subWidget.pushBack(_newWidget); markToRedraw(); requestUpdateSize(); // added at the last eelement : - return _newWidget->getId(); + return _newWidget.getId(); } -int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::WidgetShared _newWidget) { +int ewol::widget::ContainerN::subWidgetAddStart(Widget _newWidget) { if (_newWidget == null) { - Log.error("[" << getId() << "] {" << getObjectType() << "} Try to add start An empty Widget ... "); + Log.error("[" + getId() + "] {" + getObjectType() + "} Try to add start An empty Widget ... "); return -1; } if (_newWidget != null) { - _newWidget->setParent(sharedFromThis()); + _newWidget.setParent(sharedFromThis()); } - m_subWidget.insert(m_subWidget.begin(), _newWidget); + this.subWidget.insert(this.subWidget.begin(), _newWidget); markToRedraw(); requestUpdateSize(); - return _newWidget->getId(); + return _newWidget.getId(); } -void ewol::widget::ContainerN::subWidgetRemove(ewol::WidgetShared _newWidget) { +void ewol::widget::ContainerN::subWidgetRemove(Widget _newWidget) { if (_newWidget == null) { return; } - size_t errorControl = m_subWidget.size(); + int errorControl = this.subWidget.size(); - auto it(m_subWidget.begin()); - while (it != m_subWidget.end()) { + auto it(this.subWidget.begin()); + while (it != this.subWidget.end()) { if (_newWidget == *it) { - (*it)->removeParent(); - m_subWidget.erase(it); - it = m_subWidget.begin(); + (*it).removeParent(); + this.subWidget.erase(it); + it = this.subWidget.begin(); markToRedraw(); requestUpdateSize(); } else { @@ -118,17 +118,17 @@ void ewol::widget::ContainerN::subWidgetRemove(ewol::WidgetShared _newWidget) { } } -void ewol::widget::ContainerN::subWidgetUnLink(ewol::WidgetShared _newWidget) { +void ewol::widget::ContainerN::subWidgetUnLink(Widget _newWidget) { if (_newWidget == null) { return; } - auto it(m_subWidget.begin()); - while (it != m_subWidget.end()) { + auto it(this.subWidget.begin()); + while (it != this.subWidget.end()) { if (_newWidget == *it) { - (*it)->removeParent(); + (*it).removeParent(); (*it).reset(); - m_subWidget.erase(it); - it = m_subWidget.begin(); + this.subWidget.erase(it); + it = this.subWidget.begin(); markToRedraw(); requestUpdateSize(); } else { @@ -138,27 +138,27 @@ void ewol::widget::ContainerN::subWidgetUnLink(ewol::WidgetShared _newWidget) { } void ewol::widget::ContainerN::subWidgetRemoveAll() { - for(auto &it : m_subWidget) { + for(auto it : this.subWidget) { if (it != null) { - it->removeParent(); + it.removeParent(); } it.reset(); } - m_subWidget.clear(); + this.subWidget.clear(); } void ewol::widget::ContainerN::subWidgetRemoveAllDelayed() { subWidgetRemoveAll(); } -ewol::ObjectShared ewol::widget::ContainerN::getSubObjectNamed(const etk::String& _objectName) { - ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_objectName); +EwolObject ewol::widget::ContainerN::getSubObjectNamed( String _objectName) { + EwolObject tmpObject = Widget::getSubObjectNamed(_objectName); if (tmpObject != null) { return tmpObject; } - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it != null) { - tmpObject = it->getSubObjectNamed(_objectName); + tmpObject = it.getSubObjectNamed(_objectName); if (tmpObject != null) { return tmpObject; } @@ -167,79 +167,79 @@ ewol::ObjectShared ewol::widget::ContainerN::getSubObjectNamed(const etk::String return null; } -void ewol::widget::ContainerN::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::ContainerN::systemDraw( ewol::DrawProperty _displayProp) { if (*propertyHide == true){ // widget is hidden ... return; } // local widget draw - ewol::Widget::systemDraw(_displayProp); + Widget::systemDraw(_displayProp); // subwidget draw ewol::DrawProperty prop = _displayProp; - prop.limit(m_origin, m_size); - for (int64_t iii = m_subWidget.size()-1; iii>=0; --iii) { - if (m_subWidget[iii] != null) { - //Log.info(" ***** : [" << (*it)->propertyName << "] t=" << (*it)->getObjectType() << " o=" << (*it)->m_origin << " s=" << (*it)->m_size); - m_subWidget[iii]->systemDraw(prop); + prop.limit(this.origin, this.size); + for (long iii = this.subWidget.size()-1; iii>=0; --iii) { + if (this.subWidget[iii] != null) { + //Log.info(" ***** : [" + (*it).propertyName + "] t=" + (*it).getObjectType() + " o=" + (*it).this.origin + " s=" + (*it).this.size); + this.subWidget[iii].systemDraw(prop); } } } void ewol::widget::ContainerN::onChangeSize() { - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - it->setOrigin(m_origin+m_offset); - it->setSize(m_size); - it->onChangeSize(); + it.setOrigin(this.origin+this.offset); + it.setSize(this.size); + it.onChangeSize(); } } void ewol::widget::ContainerN::calculateMinMaxSize() { - m_subExpend.setValue(false, false); - m_minSize.setValue(0,0); - m_maxSize.setValue(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE); - //Log.error("[" << getId() << "] {" << getObjectType() << "} set min size : " << m_minSize); - for (auto &it : m_subWidget) { + this.subExpend.setValue(false, false); + this.minSize.setValue(0,0); + this.maxSize.setValue(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE); + //Log.error("[" + getId() + "] {" + getObjectType() + "} set min size : " + this.minSize); + for (auto it : this.subWidget) { if (it != null) { - it->calculateMinMaxSize(); - Vector2b subExpendProp = it->canExpand(); + it.calculateMinMaxSize(); + Vector2b subExpendProp = it.canExpand(); if (true == subExpendProp.x()) { - m_subExpend.setX(true); + this.subExpend.setX(true); } if (true == subExpendProp.y()) { - m_subExpend.setY(true); + this.subExpend.setY(true); } - Vector2f tmpSize = it->getCalculateMinSize(); - m_minSize.setValue( etk::max(tmpSize.x(), m_minSize.x()), - etk::max(tmpSize.y(), m_minSize.y()) ); + Vector2f tmpSize = it.getCalculateMinSize(); + this.minSize.setValue( etk::max(tmpSize.x(), this.minSize.x()), + etk::max(tmpSize.y(), this.minSize.y()) ); } } - //Log.error("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize); + //Log.error("[" + getId() + "] {" + getObjectType() + "} Result min size : " + this.minSize); } void ewol::widget::ContainerN::onRegenerateDisplay() { - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it != null) { - it->onRegenerateDisplay(); + it.onRegenerateDisplay(); } } } -ewol::WidgetShared ewol::widget::ContainerN::getWidgetAtPos(const Vector2f& _pos) { +Widget ewol::widget::ContainerN::getWidgetAtPos( Vector2f _pos) { if (*propertyHide == true) { return null; } // for all element in the sizer ... - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it != null) { - Vector2f tmpSize = it->getSize(); - Vector2f tmpOrigin = it->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) + Vector2f tmpSize = it.getSize(); + Vector2f tmpOrigin = it.getOrigin(); + if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x()) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - ewol::WidgetShared tmpWidget = it->getWidgetAtPos(_pos); + Widget tmpWidget = it.getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } @@ -251,41 +251,41 @@ ewol::WidgetShared ewol::widget::ContainerN::getWidgetAtPos(const Vector2f& _pos return null; }; -bool ewol::widget::ContainerN::loadXML(const exml::Element& _node) { +boolean ewol::widget::ContainerN::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } // parse generic properties : - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // remove previous element : subWidgetRemoveAll(); - etk::String tmpAttributeValue = _node.attributes["lock"]; + String tmpAttributeValue = _node.attributes["lock"]; if (tmpAttributeValue.size()!=0) { propertyLockExpand.set(tmpAttributeValue); } - bool invertAdding=false; + boolean invertAdding=false; tmpAttributeValue = _node.attributes["addmode"]; if(etk::compare_no_case(tmpAttributeValue, "invert")) { invertAdding=true; } // parse all the elements : - for (const auto nodeIt : _node.nodes) { - const exml::Element pNode = nodeIt.toElement(); + for ( auto nodeIt : _node.nodes) { + exml::Element pNode = nodeIt.toElement(); if (pNode.exist() == false) { // trash here all that is not element continue; } - etk::String widgetName = pNode.getValue(); - Log.verbose(" t=" << getObjectType() << " Load node name : '" << widgetName << "'"); + String widgetName = pNode.getValue(); + Log.verbose(" t=" + getObjectType() + " Load node name : '" + widgetName + "'"); if (getWidgetManager().exist(widgetName) == false) { - Log.error("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in : [" << getWidgetManager().list() << "]" ); + Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [" << getWidgetManager().list() << "]" ); continue; } - Log.debug("[" << getId() << "] {" << getObjectType() << "} load new element : '" << widgetName << "'"); - ewol::WidgetShared subWidget = getWidgetManager().create(widgetName, pNode); + Log.debug("[" + getId() + "] {" + getObjectType() + "} load new element : '" + widgetName + "'"); + Widget subWidget = getWidgetManager().create(widgetName, pNode); if (subWidget == null) { - EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") Can not create the widget : '" << widgetName << "'"); + EWOL_ERROR ("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Can not create the widget : '" + widgetName + "'"); continue; } // add sub element : @@ -294,8 +294,8 @@ bool ewol::widget::ContainerN::loadXML(const exml::Element& _node) { } else { subWidgetAddStart(subWidget); } - if (subWidget->loadXML(pNode) == false) { - Log.error("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") can not load widget properties : '" << widgetName << "'"); + if (subWidget.loadXML(pNode) == false) { + Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'"); return false; } } @@ -303,27 +303,27 @@ bool ewol::widget::ContainerN::loadXML(const exml::Element& _node) { } -void ewol::widget::ContainerN::setOffset(const Vector2f& _newVal) { - if (m_offset != _newVal) { - ewol::Widget::setOffset(_newVal); +void ewol::widget::ContainerN::setOffset( Vector2f _newVal) { + if (this.offset != _newVal) { + Widget::setOffset(_newVal); // recalculate the new sise and position of sub widget ... onChangeSize(); } } -void ewol::widget::ContainerN::requestDestroyFromChild(const ewol::ObjectShared& _child) { - auto it = m_subWidget.begin(); - while (it != m_subWidget.end()) { +void ewol::widget::ContainerN::requestDestroyFromChild( EwolObject _child) { + auto it = this.subWidget.begin(); + while (it != this.subWidget.end()) { if (*it == _child) { if (*it == null) { - m_subWidget.erase(it); - it = m_subWidget.begin(); + this.subWidget.erase(it); + it = this.subWidget.begin(); continue; } - (*it)->removeParent(); + (*it).removeParent(); (*it).reset(); - m_subWidget.erase(it); - it = m_subWidget.begin(); + this.subWidget.erase(it); + it = this.subWidget.begin(); markToRedraw(); continue; } @@ -331,12 +331,12 @@ void ewol::widget::ContainerN::requestDestroyFromChild(const ewol::ObjectShared& } } -void ewol::widget::ContainerN::drawWidgetTree(int32_t _level) { - ewol::Widget::drawWidgetTree(_level); +void ewol::widget::ContainerN::drawWidgetTree(int _level) { + Widget::drawWidgetTree(_level); _level++; - for (auto &it: m_subWidget) { + for (auto it: this.subWidget) { if (it != null) { - it->drawWidgetTree(_level); + it.drawWidgetTree(_level); } } } diff --git a/src/org/atriasoft/ewol/widget/ContainerN.java b/src/org/atriasoft/ewol/widget/ContainerN.java index 3010cc2..a27f574 100644 --- a/src/org/atriasoft/ewol/widget/ContainerN.java +++ b/src/org/atriasoft/ewol/widget/ContainerN.java @@ -12,17 +12,17 @@ namespace ewol { namespace widget { class ContainerN; - using ContainerNShared = ememory::SharedPtr; + using ContainerN = ememory::Ptr; using ContainerNWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup * @brief the Cotainer widget is a widget that have an only one subWidget */ - class ContainerN : public ewol::Widget { + class ContainerN : public Widget { public: // properties: eproperty::Value propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget protected: - List m_subWidget; + List this.subWidget; protected: /** * @brief Constructor @@ -32,39 +32,39 @@ namespace ewol { /** * @brief Destructor */ - virtual ~ContainerN(); + ~ContainerN(); protected: - Vector2b m_subExpend; //!< reference of the sub element expention requested. + Vector2b this.subExpend; //!< reference of the sub element expention requested. // herited function - virtual Vector2b canExpand() override; + Vector2b canExpand() ; public: /** * @brief remove all sub element from the widget. */ - virtual void subWidgetRemoveAll(); + void subWidgetRemoveAll(); /** * @brief remove all sub element from the widget (delayed to prevent remove in the callbback). */ - virtual void subWidgetRemoveAllDelayed(); + void subWidgetRemoveAllDelayed(); /** * @brief Replace a old subwidget with a new one. * @param[in] _oldWidget The widget to replace. * @param[in] _newWidget The widget to set. */ - virtual void subWidgetReplace(ewol::WidgetShared _oldWidget, - ewol::WidgetShared _newWidget); + void subWidgetReplace(Widget _oldWidget, + Widget _newWidget); /** * @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @param[in] _newWidget the element pointer * @return the ID of the set element */ - virtual int32_t subWidgetAdd(ewol::WidgetShared _newWidget); + int subWidgetAdd(Widget _newWidget); //! @previous - inline int32_t subWidgetAddBack(ewol::WidgetShared _newWidget) { + int subWidgetAddBack(Widget _newWidget) { return subWidgetAdd(_newWidget); }; //! @previous - inline int32_t subWidgetAddEnd(ewol::WidgetShared _newWidget) { + int subWidgetAddEnd(Widget _newWidget) { return subWidgetAdd(_newWidget); }; /** @@ -72,34 +72,34 @@ namespace ewol { * @param[in] _newWidget the element pointer * @return the ID of the set element */ - virtual int32_t subWidgetAddStart(ewol::WidgetShared _newWidget); + int subWidgetAddStart(Widget _newWidget); //! @previous - inline int32_t subWidgetAddFront(ewol::WidgetShared _newWidget) { + int subWidgetAddFront(Widget _newWidget) { return subWidgetAddStart(_newWidget); }; /** * @brief remove definitly a widget from the system and this layer. * @param[in] _newWidget the element pointer. */ - virtual void subWidgetRemove(ewol::WidgetShared _newWidget); + void subWidgetRemove(Widget _newWidget); /** * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...) * @param[in] _newWidget the element pointer. */ - virtual void subWidgetUnLink(ewol::WidgetShared _newWidget); + void subWidgetUnLink(Widget _newWidget); public: - void systemDraw(const ewol::DrawProperty& _displayProp) override; - void onRegenerateDisplay() override; - void onChangeSize() override; - void calculateMinMaxSize() override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; - ewol::ObjectShared getSubObjectNamed(const etk::String& _objectName) override; - bool loadXML(const exml::Element& _node) override; - void setOffset(const Vector2f& _newVal) override; - void requestDestroyFromChild(const ewol::ObjectShared& _child) override; - void drawWidgetTree(int32_t _level=0) override; + void systemDraw( ewol::DrawProperty _displayProp) ; + void onRegenerateDisplay() ; + void onChangeSize() ; + void calculateMinMaxSize() ; + Widget getWidgetAtPos( Vector2f _pos) ; + EwolObject getSubObjectNamed( String _objectName) ; + boolean loadXML( exml::Element _node) ; + void setOffset( Vector2f _newVal) ; + void requestDestroyFromChild( EwolObject _child) ; + void drawWidgetTree(int _level=0) ; protected: - virtual void onChangePropertyLockExpand(); + void onChangePropertyLockExpand(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/ContextMenu.cpp b/src/org/atriasoft/ewol/widget/ContextMenu.cpp index 1da8dbe..a8386f2 100644 --- a/src/org/atriasoft/ewol/widget/ContextMenu.cpp +++ b/src/org/atriasoft/ewol/widget/ContextMenu.cpp @@ -20,15 +20,15 @@ ewol::widget::ContextMenu::ContextMenu(): propertyShape(this, "shape", etk::Uri("THEME_GUI:///ContextMenu.json?lib=ewol"), "the display name for config file", - &ewol::widget::ContextMenu::onChangePropertyShape), + ewol::widget::ContextMenu::onChangePropertyShape), propertyArrowPos(this, "arrow-position", Vector2f(0,0), "Position of the arrow in the pop-up", - &ewol::widget::ContextMenu::onChangePropertyArrowPos), + ewol::widget::ContextMenu::onChangePropertyArrowPos), propertyArrawBorder(this, "arrow-mode", markTop, "position of the arrow", - &ewol::widget::ContextMenu::onChangePropertyArrawBorder) { + ewol::widget::ContextMenu::onChangePropertyArrawBorder) { addObjectType("ewol::widget::ContextMenu"); propertyArrawBorder.add(markTop, "top"); propertyArrawBorder.add(markRight, "right"); @@ -37,11 +37,11 @@ ewol::widget::ContextMenu::ContextMenu(): propertyArrawBorder.add(markNone, "none"); - m_offset = 20; + this.offset = 20; - m_colorBorder = etk::color::black; - m_colorBorder.setA(0x7F); + this.colorBorder = etk::color::black; + this.colorBorder.setA(0x7F); setMouseLimit(1); } @@ -58,67 +58,67 @@ ewol::widget::ContextMenu::~ContextMenu() { void ewol::widget::ContextMenu::onChangeSize() { markToRedraw(); // pop-up fill all the display : - ewol::Padding padding = m_shaper.getPadding(); - Log.verbose("our origin=" << m_origin << " size=" << m_size); - if (m_subWidget == null) { + ewol::Padding padding = this.shaper.getPadding(); + Log.verbose("our origin=" + this.origin + " size=" + this.size); + if (this.subWidget == null) { return; } Vector2f subWidgetSize(0,0); Vector2f subWidgetOrigin(0,0); - subWidgetSize = m_subWidget->getCalculateMinSize(); - if (m_subWidget->canExpand().x() == true) { - subWidgetSize.setX(m_size.x()); + subWidgetSize = this.subWidget.getCalculateMinSize(); + if (this.subWidget.canExpand().x() == true) { + subWidgetSize.setX(this.size.x()); } - if (m_subWidget->canExpand().y() == true) { - subWidgetSize.setY(m_size.y()); + if (this.subWidget.canExpand().y() == true) { + subWidgetSize.setY(this.size.y()); } - int32_t minWidth = 100; - int32_t maxWidth = 300; - subWidgetSize.setX((int32_t)etk::max(minWidth, (int32_t)subWidgetSize.x())); - subWidgetSize.setX((int32_t)etk::min(maxWidth, (int32_t)subWidgetSize.x())); - subWidgetSize.setY((int32_t)subWidgetSize.y()); + int minWidth = 100; + int maxWidth = 300; + subWidgetSize.setX((int)etk::max(minWidth, (int)subWidgetSize.x())); + subWidgetSize.setX((int)etk::min(maxWidth, (int)subWidgetSize.x())); + subWidgetSize.setY((int)subWidgetSize.y()); // set config to the Sub-widget switch (propertyArrawBorder.get()) { case markTop: - subWidgetOrigin.setX((int32_t)(propertyArrowPos->x() - subWidgetSize.x()/2)); - subWidgetOrigin.setY((int32_t)(propertyArrowPos->y() - m_offset - subWidgetSize.y())); + subWidgetOrigin.setX((int)(propertyArrowPos.x() - subWidgetSize.x()/2)); + subWidgetOrigin.setY((int)(propertyArrowPos.y() - this.offset - subWidgetSize.y())); break; case markButtom: - subWidgetOrigin.setX((int32_t)(propertyArrowPos->x() - subWidgetSize.x()/2)); - subWidgetOrigin.setY((int32_t)(propertyArrowPos->y() + m_offset)); + subWidgetOrigin.setX((int)(propertyArrowPos.x() - subWidgetSize.x()/2)); + subWidgetOrigin.setY((int)(propertyArrowPos.y() + this.offset)); break; case markRight: case markLeft: default: - subWidgetOrigin.setX((int32_t)(m_size.x() - m_origin.x() - subWidgetSize.x())/2 + m_origin.x()); - subWidgetOrigin.setY((int32_t)(m_size.y() - m_origin.y() - subWidgetSize.y())/2 + m_origin.y()); + subWidgetOrigin.setX((int)(this.size.x() - this.origin.x() - subWidgetSize.x())/2 + this.origin.x()); + subWidgetOrigin.setY((int)(this.size.y() - this.origin.y() - subWidgetSize.y())/2 + this.origin.y()); break; } // set the widget position at the border of the screen - subWidgetOrigin.setX( (int32_t)( etk::max(0, (int32_t)(subWidgetOrigin.x()-padding.x())) + subWidgetOrigin.setX( (int)( etk::max(0, (int)(subWidgetOrigin.x()-padding.x())) + padding.x()) ); - subWidgetOrigin.setY( (int32_t)( etk::max(0, (int32_t)(subWidgetOrigin.y()-padding.y())) + subWidgetOrigin.setY( (int)( etk::max(0, (int)(subWidgetOrigin.y()-padding.y())) + padding.y()) ); switch (propertyArrawBorder.get()) { default: case markTop: case markButtom: - if (propertyArrowPos->x() <= m_offset ) { - subWidgetOrigin.setX(propertyArrowPos->x()+padding.xLeft()); + if (propertyArrowPos.x() <= this.offset ) { + subWidgetOrigin.setX(propertyArrowPos.x()+padding.xLeft()); } break; case markRight: case markLeft: - if (propertyArrowPos->y() <= m_offset ) { - subWidgetOrigin.setY(propertyArrowPos->y()+padding.yButtom()); + if (propertyArrowPos.y() <= this.offset ) { + subWidgetOrigin.setY(propertyArrowPos.y()+padding.yButtom()); } break; } - Log.verbose(" == > sub origin=" << subWidgetOrigin << " size=" << subWidgetSize); - m_subWidget->setOrigin(subWidgetOrigin); - m_subWidget->setSize(subWidgetSize); - m_subWidget->onChangeSize(); + Log.verbose(" == > sub origin=" + subWidgetOrigin + " size=" + subWidgetSize); + this.subWidget.setOrigin(subWidgetOrigin); + this.subWidget.setSize(subWidgetSize); + this.subWidget.onChangeSize(); } @@ -126,16 +126,16 @@ void ewol::widget::ContextMenu::calculateMinMaxSize() { // call main class to calculate the min size... ewol::widget::Container::calculateMinMaxSize(); // add padding of the display - ewol::Padding padding = m_shaper.getPadding(); - m_minSize += Vector2f(padding.x(), padding.y()); - //Log.debug("CalculateMinSize=>>" << m_minSize); + ewol::Padding padding = this.shaper.getPadding(); + this.minSize += Vector2f(padding.x(), padding.y()); + //Log.debug("CalculateMinSize=>>" + this.minSize); markToRedraw(); } void ewol::widget::ContextMenu::onDraw() { - m_compositing.draw(); - m_shaper.draw(); + this.compositing.draw(); + this.shaper.draw(); } @@ -145,51 +145,51 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() { if (needRedraw() == false) { return; } - m_compositing.clear(); - m_shaper.clear(); - ewol::Padding padding = m_shaper.getPadding(); + this.compositing.clear(); + this.shaper.clear(); + ewol::Padding padding = this.shaper.getPadding(); - if (m_subWidget == null) { + if (this.subWidget == null) { return; } - Vector2f tmpSize = m_subWidget->getSize(); - Vector2f tmpOrigin = m_subWidget->getOrigin(); + Vector2f tmpSize = this.subWidget.getSize(); + Vector2f tmpOrigin = this.subWidget.getOrigin(); // display border ... - m_compositing.setColor(m_colorBorder); + this.compositing.setColor(this.colorBorder); switch (propertyArrawBorder) { case markTop: - m_compositing.setPos(Vector3f(propertyArrowPos->x(), propertyArrowPos->y(), 0.0f) ); - m_compositing.addVertex(); - if (propertyArrowPos->x() <= tmpOrigin.x() ) { - float laking = m_offset - padding.yTop(); - m_compositing.setPos(Vector3f(propertyArrowPos->x()+laking, propertyArrowPos->y()-laking, 0.0f) ); - m_compositing.addVertex(); - m_compositing.setPos(Vector3f(propertyArrowPos->x(), propertyArrowPos->y()-laking, 0.0f) ); - m_compositing.addVertex(); + this.compositing.setPos(Vector3f(propertyArrowPos.x(), propertyArrowPos.y(), 0.0f) ); + this.compositing.addVertex(); + if (propertyArrowPos.x() <= tmpOrigin.x() ) { + float laking = this.offset - padding.yTop(); + this.compositing.setPos(Vector3f(propertyArrowPos.x()+laking, propertyArrowPos.y()-laking, 0.0f) ); + this.compositing.addVertex(); + this.compositing.setPos(Vector3f(propertyArrowPos.x(), propertyArrowPos.y()-laking, 0.0f) ); + this.compositing.addVertex(); } else { - float laking = m_offset - padding.yTop(); - m_compositing.setPos(Vector3f(propertyArrowPos->x()+laking, propertyArrowPos->y()-laking, 0.0f) ); - m_compositing.addVertex(); - m_compositing.setPos(Vector3f(propertyArrowPos->x()-laking, propertyArrowPos->y()-laking, 0.0f) ); - m_compositing.addVertex(); + float laking = this.offset - padding.yTop(); + this.compositing.setPos(Vector3f(propertyArrowPos.x()+laking, propertyArrowPos.y()-laking, 0.0f) ); + this.compositing.addVertex(); + this.compositing.setPos(Vector3f(propertyArrowPos.x()-laking, propertyArrowPos.y()-laking, 0.0f) ); + this.compositing.addVertex(); } break; case markButtom: - m_compositing.setPos(Vector3f(propertyArrowPos->x(), propertyArrowPos->y(), 0) ); - m_compositing.addVertex(); - if (propertyArrowPos->x() <= tmpOrigin.x() ) { - int32_t laking = m_offset - padding.yTop(); - m_compositing.setPos(Vector3f(propertyArrowPos->x()+laking, propertyArrowPos->y()+laking, 0.0f) ); - m_compositing.addVertex(); - m_compositing.setPos(Vector3f(propertyArrowPos->x(), propertyArrowPos->y()+laking, 0.0f) ); - m_compositing.addVertex(); + this.compositing.setPos(Vector3f(propertyArrowPos.x(), propertyArrowPos.y(), 0) ); + this.compositing.addVertex(); + if (propertyArrowPos.x() <= tmpOrigin.x() ) { + int laking = this.offset - padding.yTop(); + this.compositing.setPos(Vector3f(propertyArrowPos.x()+laking, propertyArrowPos.y()+laking, 0.0f) ); + this.compositing.addVertex(); + this.compositing.setPos(Vector3f(propertyArrowPos.x(), propertyArrowPos.y()+laking, 0.0f) ); + this.compositing.addVertex(); } else { - int32_t laking = m_offset - padding.yTop(); - m_compositing.setPos(Vector3f(propertyArrowPos->x()+laking, propertyArrowPos->y()+laking, 0.0f) ); - m_compositing.addVertex(); - m_compositing.setPos(Vector3f(propertyArrowPos->x()-laking, propertyArrowPos->y()+laking, 0.0f) ); - m_compositing.addVertex(); + int laking = this.offset - padding.yTop(); + this.compositing.setPos(Vector3f(propertyArrowPos.x()+laking, propertyArrowPos.y()+laking, 0.0f) ); + this.compositing.addVertex(); + this.compositing.setPos(Vector3f(propertyArrowPos.x()-laking, propertyArrowPos.y()+laking, 0.0f) ); + this.compositing.addVertex(); } break; default: @@ -201,21 +201,21 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() { Vector2f shaperOrigin = tmpOrigin-Vector2f(padding.xLeft(), padding.yButtom()); Vector2f shaperSize = tmpSize+Vector2f(padding.x(), padding.y()); - m_shaper.setShape(Vector2fClipInt32(shaperOrigin), + this.shaper.setShape(Vector2fClipInt32(shaperOrigin), Vector2fClipInt32(shaperSize)); } -bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::ContextMenu::onEventInput( ewol::event::Input _event) { if (_event.getId() > 0) { if (ewol::widget::Container::getWidgetAtPos(_event.getPos()) != null) { return false; } - if( _event.getStatus() == gale::key::status::down - || _event.getStatus() == gale::key::status::move - || _event.getStatus() == gale::key::status::pressSingle - || _event.getStatus() == gale::key::status::up - || _event.getStatus() == gale::key::status::enter - || _event.getStatus() == gale::key::status::leave ) { + if( _event.getStatus() == KeyStatus::down + || _event.getStatus() == KeyStatus::move + || _event.getStatus() == KeyStatus::pressSingle + || _event.getStatus() == KeyStatus::up + || _event.getStatus() == KeyStatus::enter + || _event.getStatus() == KeyStatus::leave ) { // Auto-remove ... autoDestroy(); return true; @@ -224,12 +224,12 @@ bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { return false; } -ewol::WidgetShared ewol::widget::ContextMenu::getWidgetAtPos(const Vector2f& _pos) { - ewol::WidgetShared val = ewol::widget::Container::getWidgetAtPos(_pos); +Widget ewol::widget::ContextMenu::getWidgetAtPos( Vector2f _pos) { + Widget val = ewol::widget::Container::getWidgetAtPos(_pos); if (val != null) { return val; } - return ememory::dynamicPointerCast(sharedFromThis()); + return ememory::dynamicPointerCast(sharedFromThis()); } void ewol::widget::ContextMenu::onChangePropertyArrowPos() { @@ -241,14 +241,14 @@ void ewol::widget::ContextMenu::onChangePropertyArrawBorder() { } void ewol::widget::ContextMenu::onChangePropertyShape() { - m_shaper.setSource(propertyShape.get()); + this.shaper.setSource(propertyShape.get()); markToRedraw(); } -void ewol::widget::ContextMenu::setPositionMarkAuto(const Vector2f& _origin, const Vector2f& _size) { - ewol::widget::WindowsShared windows = getWindows(); - Vector2f globalSize = windows->getSize(); +void ewol::widget::ContextMenu::setPositionMarkAuto( Vector2f _origin, Vector2f _size) { + ewol::widget::Windows windows = getWindows(); + Vector2f globalSize = windows.getSize(); // TODO : Support left and right float upperSize = globalSize.y() - (_origin.y() + _size.y()); float underSize = _origin.y(); @@ -260,7 +260,7 @@ void ewol::widget::ContextMenu::setPositionMarkAuto(const Vector2f& _origin, con setPositionMark(ewol::widget::ContextMenu::markTop, pos); } } -void ewol::widget::ContextMenu::setPositionMark(enum markPosition _position, const Vector2f& _arrowPos) { +void ewol::widget::ContextMenu::setPositionMark(enum markPosition _position, Vector2f _arrowPos) { propertyArrawBorder.set(_position); propertyArrowPos.set(_arrowPos); } diff --git a/src/org/atriasoft/ewol/widget/ContextMenu.java b/src/org/atriasoft/ewol/widget/ContextMenu.java index d93f73e..15a3b42 100644 --- a/src/org/atriasoft/ewol/widget/ContextMenu.java +++ b/src/org/atriasoft/ewol/widget/ContextMenu.java @@ -16,7 +16,7 @@ namespace ewol { namespace widget { class ContextMenu; - using ContextMenuShared = ememory::SharedPtr; + using ContextMenu = ememory::Ptr; using ContextMenuWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -36,34 +36,34 @@ namespace ewol { eproperty::List propertyArrawBorder; protected: ContextMenu(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(ContextMenu, "ContextMenu"); - virtual ~ContextMenu(); + ~ContextMenu(); private: - ewol::compositing::Shaper m_shaper; //!< Compositing theme. + ewol::compositing::Shaper this.shaper; //!< Compositing theme. // TODO : Use shaper for the arraw ... - ewol::compositing::Drawing m_compositing; - etk::Color<> m_colorBorder; // use shaper ID + ewol::compositing::Drawing this.compositing; + etk::Color<> this.colorBorder; // use shaper ID - float m_offset; + float this.offset; public: - void setPositionMarkAuto(const Vector2f& _origin, const Vector2f& _size); - void setPositionMark(enum markPosition _position, const Vector2f& _arrowPos); + void setPositionMarkAuto( Vector2f _origin, Vector2f _size); + void setPositionMark(enum markPosition _position, Vector2f _arrowPos); protected: - void onDraw() override; + void onDraw() ; public: - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - void onChangeSize() override; - void calculateMinMaxSize() override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + void onChangeSize() ; + void calculateMinMaxSize() ; + Widget getWidgetAtPos( Vector2f _pos) ; protected: - virtual void onChangePropertyArrowPos(); - virtual void onChangePropertyArrawBorder(); - virtual void onChangePropertyShape(); + void onChangePropertyArrowPos(); + void onChangePropertyArrawBorder(); + void onChangePropertyShape(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Entry.cpp b/src/org/atriasoft/ewol/widget/Entry.cpp index 549de7e..17b5893 100644 --- a/src/org/atriasoft/ewol/widget/Entry.cpp +++ b/src/org/atriasoft/ewol/widget/Entry.cpp @@ -25,43 +25,43 @@ ewol::widget::Entry::Entry() : propertyPassword(this, "password", false, "Not display content in password mode", - &ewol::widget::Entry::onChangePropertyPassword), + ewol::widget::Entry::onChangePropertyPassword), propertyShape(this, "shape", etk::Uri("THEME_GUI:///Entry.json?lib=ewol"), "Shaper to display the background", - &ewol::widget::Entry::onChangePropertyShaper), + ewol::widget::Entry::onChangePropertyShaper), propertyValue(this, "value", "", "Value display in the entry (decorated text)", - &ewol::widget::Entry::onChangePropertyValue), + ewol::widget::Entry::onChangePropertyValue), propertyMaxCharacter(this, "max", 0x7FFFFFFF, 0, 0x7FFFFFFF, "Maximum char that can be set on the Entry", - &ewol::widget::Entry::onChangePropertyMaxCharacter), + ewol::widget::Entry::onChangePropertyMaxCharacter), propertyRegex(this, "regex", ".*", "Control what it is write with a regular expression", - &ewol::widget::Entry::onChangePropertyRegex), + ewol::widget::Entry::onChangePropertyRegex), propertyTextWhenNothing(this, "empty-text", "", "Text when nothing is written", - &ewol::widget::Entry::onChangePropertyTextWhenNothing), - m_needUpdateTextPos(true), - m_displayStartPosition(0), - m_displayCursor(false), - m_displayCursorPos(0), - m_displayCursorPosSelection(0) { + ewol::widget::Entry::onChangePropertyTextWhenNothing), + this.needUpdateTextPos(true), + this.displayStartPosition(0), + this.displayCursor(false), + this.displayCursorPos(0), + this.displayCursorPosSelection(0) { addObjectType("ewol::widget::Entry"); propertyCanFocus.setDirectCheck(true); } void ewol::widget::Entry::init() { - ewol::Widget::init(); + Widget::init(); propertyShape.notifyChange(); - m_regex.compile(propertyRegex.get()); - if (m_regex.getStatus() == false) { - Log.error("can not parse regex for : " << propertyRegex); + this.regex.compile(propertyRegex.get()); + if (this.regex.getStatus() == false) { + Log.error("can not parse regex for : " + propertyRegex); } markToRedraw(); @@ -71,7 +71,7 @@ void ewol::widget::Entry::init() { shortCutAdd("ctrl+v", "paste"); shortCutAdd("ctrl+a", "select:all"); shortCutAdd("ctrl+shift+a", "select:none"); - signalShortcut.connect(sharedFromThis(), &ewol::widget::Entry::onCallbackShortCut); + signalShortcut.connect(sharedFromThis(), ewol::widget::Entry::onCallbackShortCut); } @@ -79,7 +79,7 @@ ewol::widget::Entry::~Entry() { } -void ewol::widget::Entry::onCallbackShortCut(const etk::String& _value) { +void ewol::widget::Entry::onCallbackShortCut( String _value) { if (_value == "clean") { onCallbackEntryClean(); } else if (_value == "cut") { @@ -87,133 +87,133 @@ void ewol::widget::Entry::onCallbackShortCut(const etk::String& _value) { } else if (_value == "copy") { onCallbackCopy(); } else if (_value == "paste") { - EWOL_WARNING("Request past ..."); + Log.warning("Request past ..."); onCallbackPaste(); } else if (_value == "select:all") { onCallbackSelect(true); } else if (_value == "select:none") { onCallbackSelect(false); } else { - EWOL_WARNING("Unknow event from ShortCut : " << _value); + Log.warning("Unknow event from ShortCut : " + _value); } } void ewol::widget::Entry::calculateMinMaxSize() { // call main class - ewol::Widget::calculateMinMaxSize(); + Widget::calculateMinMaxSize(); // get generic padding - ewol::Padding padding = m_shaper.getPadding(); - int32_t minHeight = m_text.calculateSize(char32_t('A')).y(); + ewol::Padding padding = this.shaper.getPadding(); + int minHeight = this.text.calculateSize(Character('A')).y(); Vector2f minimumSizeBase(20, minHeight); // add padding : minimumSizeBase += Vector2f(padding.x(), padding.y()); - m_minSize.setMax(minimumSizeBase); + this.minSize.setMax(minimumSizeBase); // verify the min max of the min size ... checkMinSize(); } void ewol::widget::Entry::onDraw() { - m_shaper.draw(); - m_text.draw(); + this.shaper.draw(); + this.text.draw(); } void ewol::widget::Entry::onRegenerateDisplay() { if (needRedraw() == true) { - m_shaper.clear(); - m_text.clear(); - if (m_colorIdTextFg >= 0) { - m_text.setDefaultColorFg(m_shaper.getColor(m_colorIdTextFg)); - m_text.setDefaultColorBg(m_shaper.getColor(m_colorIdTextBg)); - m_text.setCursorColor(m_shaper.getColor(m_colorIdCursor)); - m_text.setSelectionColor(m_shaper.getColor(m_colorIdSelection)); + this.shaper.clear(); + this.text.clear(); + if (this.colorIdTextFg >= 0) { + this.text.setDefaultColorFg(this.shaper.getColor(this.colorIdTextFg)); + this.text.setDefaultColorBg(this.shaper.getColor(this.colorIdTextBg)); + this.text.setCursorColor(this.shaper.getColor(this.colorIdCursor)); + this.text.setSelectionColor(this.shaper.getColor(this.colorIdSelection)); } updateTextPosition(); - ewol::Padding padding = m_shaper.getPadding(); + ewol::Padding padding = this.shaper.getPadding(); - Vector2f tmpSizeShaper = m_minSize; - if (propertyFill->x() == true) { - tmpSizeShaper.setX(m_size.x()); + Vector2f tmpSizeShaper = this.minSize; + if (propertyFill.x() == true) { + tmpSizeShaper.setX(this.size.x()); } - if (propertyFill->y() == true) { - tmpSizeShaper.setY(m_size.y()); + if (propertyFill.y() == true) { + tmpSizeShaper.setY(this.size.y()); } - Vector2f tmpOriginShaper = (m_size - tmpSizeShaper) / 2.0f; + Vector2f tmpOriginShaper = (this.size - tmpSizeShaper) / 2.0f; Vector2f tmpSizeText = tmpSizeShaper - Vector2f(padding.x(), padding.y()); - Vector2f tmpOriginText = (m_size - tmpSizeText) / 2.0f; + Vector2f tmpOriginText = (this.size - tmpSizeText) / 2.0f; // sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ... - int32_t minHeight = m_text.calculateSize(char32_t('A')).y(); + int minHeight = this.text.calculateSize(Character('A')).y(); if (tmpSizeText.y() > minHeight) { tmpOriginText += Vector2f(0,(tmpSizeText.y()-minHeight)/2.0f); } - // fix all the position in the int32_t class: + // fix all the position in the int class: tmpSizeShaper = Vector2fClipInt32(tmpSizeShaper); tmpOriginShaper = Vector2fClipInt32(tmpOriginShaper); tmpSizeText = Vector2fClipInt32(tmpSizeText); tmpOriginText = Vector2fClipInt32(tmpOriginText); - m_text.reset(); - m_text.setClippingWidth(tmpOriginText, tmpSizeText); - m_text.setPos(tmpOriginText+Vector2f(m_displayStartPosition,0)); - if (m_displayCursorPosSelection != m_displayCursorPos) { - m_text.setCursorSelection(m_displayCursorPos, m_displayCursorPosSelection); + this.text.reset(); + this.text.setClippingWidth(tmpOriginText, tmpSizeText); + this.text.setPos(tmpOriginText+Vector2f(this.displayStartPosition,0)); + if (this.displayCursorPosSelection != this.displayCursorPos) { + this.text.setCursorSelection(this.displayCursorPos, this.displayCursorPosSelection); } else { - m_text.setCursorPos(m_displayCursorPos); + this.text.setCursorPos(this.displayCursorPos); } etk::UString valueToDisplay = etk::toUString(*propertyValue); if (*propertyPassword == true) { - for (auto &it: valueToDisplay) { + for (auto it: valueToDisplay) { it = '*'; } } if (valueToDisplay.size() != 0) { - m_text.print(valueToDisplay); + this.text.print(valueToDisplay); } else { - if (propertyTextWhenNothing->size() != 0) { - m_text.printDecorated(propertyTextWhenNothing); + if (propertyTextWhenNothing.size() != 0) { + this.text.printDecorated(propertyTextWhenNothing); } } - m_text.setClippingMode(false); + this.text.setClippingMode(false); - m_shaper.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); + this.shaper.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); } } -void ewol::widget::Entry::updateCursorPosition(const Vector2f& _pos, bool _selection) { - ewol::Padding padding = m_shaper.getPadding(); +void ewol::widget::Entry::updateCursorPosition( Vector2f _pos, boolean _selection) { + ewol::Padding padding = this.shaper.getPadding(); Vector2f relPos = relativePosition(_pos); - relPos.setX(relPos.x()-m_displayStartPosition - padding.xLeft()); + relPos.setX(relPos.x()-this.displayStartPosition - padding.xLeft()); // try to find the new cursor position : - etk::String tmpDisplay = etk::String(propertyValue, 0, m_displayStartPosition); - int32_t displayHidenSize = m_text.calculateSize(tmpDisplay).x(); - //Log.debug("hidenSize : " << displayHidenSize); - int32_t newCursorPosition = -1; - int32_t tmpTextOriginX = padding.xLeft(); - for (size_t iii=0; iiisize(); iii++) { - tmpDisplay = etk::String(propertyValue, 0, iii); - int32_t tmpWidth = m_text.calculateSize(tmpDisplay).x() - displayHidenSize; + String tmpDisplay = String(propertyValue, 0, this.displayStartPosition); + int displayHidenSize = this.text.calculateSize(tmpDisplay).x(); + //Log.debug("hidenSize : " + displayHidenSize); + int newCursorPosition = -1; + int tmpTextOriginX = padding.xLeft(); + for (int iii=0; iii= relPos.x()-tmpTextOriginX) { newCursorPosition = iii; break; } } if (newCursorPosition == -1) { - newCursorPosition = propertyValue->size(); + newCursorPosition = propertyValue.size(); } if (_selection == false) { - m_displayCursorPos = newCursorPosition; - m_displayCursorPosSelection = m_displayCursorPos; + this.displayCursorPos = newCursorPosition; + this.displayCursorPosSelection = this.displayCursorPos; markToRedraw(); } else { - if (m_displayCursorPos == m_displayCursorPosSelection) { - m_displayCursorPosSelection = m_displayCursorPos; + if (this.displayCursorPos == this.displayCursorPosSelection) { + this.displayCursorPosSelection = this.displayCursorPos; } - m_displayCursorPos = newCursorPosition; + this.displayCursorPos = newCursorPosition; markToRedraw(); } markToUpdateTextPosition(); @@ -221,107 +221,107 @@ void ewol::widget::Entry::updateCursorPosition(const Vector2f& _pos, bool _selec void ewol::widget::Entry::removeSelected() { - if (m_displayCursorPosSelection == m_displayCursorPos) { + if (this.displayCursorPosSelection == this.displayCursorPos) { // nothing to cut ... return; } - int32_t pos1 = m_displayCursorPosSelection; - int32_t pos2 = m_displayCursorPos; - if(m_displayCursorPosSelection>m_displayCursorPos) { - pos2 = m_displayCursorPosSelection; - pos1 = m_displayCursorPos; + int pos1 = this.displayCursorPosSelection; + int pos2 = this.displayCursorPos; + if(this.displayCursorPosSelection>this.displayCursorPos) { + pos2 = this.displayCursorPosSelection; + pos1 = this.displayCursorPos; } // remove data ... - m_displayCursorPos = pos1; - m_displayCursorPosSelection = pos1; + this.displayCursorPos = pos1; + this.displayCursorPosSelection = pos1; propertyValue.getDirect().erase(pos1, pos2-pos1); markToRedraw(); } void ewol::widget::Entry::copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID) { - if (m_displayCursorPosSelection == m_displayCursorPos) { + if (this.displayCursorPosSelection == this.displayCursorPos) { // nothing to cut ... return; } - int32_t pos1 = m_displayCursorPosSelection; - int32_t pos2 = m_displayCursorPos; - if(m_displayCursorPosSelection>m_displayCursorPos) { - pos2 = m_displayCursorPosSelection; - pos1 = m_displayCursorPos; + int pos1 = this.displayCursorPosSelection; + int pos2 = this.displayCursorPos; + if(this.displayCursorPosSelection>this.displayCursorPos) { + pos2 = this.displayCursorPosSelection; + pos1 = this.displayCursorPos; } // Copy - etk::String tmpData = etk::String(propertyValue, pos1, pos2); + String tmpData = String(propertyValue, pos1, pos2); gale::context::clipBoard::set(_clipboardID, tmpData); } -bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { - EWOL_WARNING("Event on Input ... " << _event); +boolean ewol::widget::Entry::onEventInput( ewol::event::Input _event) { + Log.warning("Event on Input ... " + _event); if (_event.getId() == 1) { - if (gale::key::status::pressSingle == _event.getStatus()) { + if (KeyStatus::pressSingle == _event.getStatus()) { keepFocus(); signalClick.emit(); //nothing to do ... return true; - } else if (gale::key::status::pressDouble == _event.getStatus()) { + } else if (KeyStatus::pressDouble == _event.getStatus()) { keepFocus(); // select word - m_displayCursorPosSelection = m_displayCursorPos-1; + this.displayCursorPosSelection = this.displayCursorPos-1; // search forward - for (size_t iii=m_displayCursorPos; iii <= propertyValue->size(); iii++) { - if(iii == propertyValue->size()) { - m_displayCursorPos = iii; + for (int iii=this.displayCursorPos; iii <= propertyValue.size(); iii++) { + if(iii == propertyValue.size()) { + this.displayCursorPos = iii; break; } if(!( ( propertyValue.get()[iii] >= 'a' - && propertyValue.get()[iii] <= 'z') + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyValue.get()[iii] <= 'z') || ( propertyValue.get()[iii] >= 'A' - && propertyValue.get()[iii] <= 'Z') + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyValue.get()[iii] <= 'Z') || ( propertyValue.get()[iii] >= '0' - && propertyValue.get()[iii] <= '9') + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyValue.get()[iii] <= '9') || propertyValue.get()[iii] == '_' || propertyValue.get()[iii] == '-' ) ) { - m_displayCursorPos = iii; + this.displayCursorPos = iii; break; } } // search backward - for (int64_t iii=m_displayCursorPosSelection; iii >= -1; iii--) { + for (long iii=this.displayCursorPosSelection; iii >= -1; iii--) { if(iii == -1) { - m_displayCursorPosSelection = 0; + this.displayCursorPosSelection = 0; break; } if(!( ( propertyValue.get()[iii] >= 'a' - && propertyValue.get()[iii] <= 'z') + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyValue.get()[iii] <= 'z') || ( propertyValue.get()[iii] >= 'A' - && propertyValue.get()[iii] <= 'Z') + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyValue.get()[iii] <= 'Z') || ( propertyValue.get()[iii] >= '0' - && propertyValue.get()[iii] <= '9') + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyValue.get()[iii] <= '9') || propertyValue.get()[iii] == '_' || propertyValue.get()[iii] == '-' ) ) { - m_displayCursorPosSelection = iii+1; + this.displayCursorPosSelection = iii+1; break; } } // Copy to clipboard Middle ... copySelectionToClipBoard(gale::context::clipBoard::clipboardSelection); markToRedraw(); - } else if (gale::key::status::pressTriple == _event.getStatus()) { + } else if (KeyStatus::pressTriple == _event.getStatus()) { keepFocus(); - m_displayCursorPosSelection = 0; - m_displayCursorPos = propertyValue->size(); - } else if (gale::key::status::down == _event.getStatus()) { + this.displayCursorPosSelection = 0; + this.displayCursorPos = propertyValue.size(); + } else if (KeyStatus::down == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos()); markToRedraw(); - } else if (gale::key::status::move == _event.getStatus()) { + } else if (KeyStatus::move == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos(), true); markToRedraw(); - } else if (gale::key::status::up == _event.getStatus()) { + } else if (KeyStatus::up == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos(), true); // Copy to clipboard Middle ... @@ -329,17 +329,17 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { markToRedraw(); } } - else if( gale::key::type::mouse == _event.getType() - && _event.getId() == 2) { - if( _event.getStatus() == gale::key::status::down - || _event.getStatus() == gale::key::status::move - || _event.getStatus() == gale::key::status::up) { + else if( KeyType::mouse == _event.getType() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getId() == 2) { + if( _event.getStatus() == KeyStatus::down + || _event.getStatus() == KeyStatus::move + || _event.getStatus() == KeyStatus::up) { keepFocus(); // updatethe cursor position : updateCursorPosition(_event.getPos()); } // Paste current selection only when up button - if (_event.getStatus() == gale::key::status::up) { + if (_event.getStatus() == KeyStatus::up) { keepFocus(); // middle button => past data... gale::context::clipBoard::request(gale::context::clipBoard::clipboardSelection); @@ -349,10 +349,10 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { } -bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { - EWOL_WARNING("Event on Entry ... " << _event); - if (_event.getType() == gale::key::keyboard::character) { - if(_event.getStatus() == gale::key::status::down) { +boolean ewol::widget::Entry::onEventEntry( ewol::event::Entry _event) { + Log.warning("Event on Entry ... " + _event); + if (_event.getType() == KeyKeyboard::character) { + if(_event.getStatus() == KeyStatus::down) { // remove curent selected data ... removeSelected(); if( _event.getChar() == '\n' @@ -361,31 +361,31 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { return true; } else if (_event.getChar() == 0x7F) { // SUPPR : - if (propertyValue->size() > 0 && m_displayCursorPos < (int64_t)propertyValue->size()) { - propertyValue.getDirect().erase(m_displayCursorPos, 1); - m_displayCursorPos = etk::max(m_displayCursorPos, 0); - m_displayCursorPosSelection = m_displayCursorPos; + if (propertyValue.size() > 0 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.displayCursorPos < (long)propertyValue.size()) { + propertyValue.getDirect().erase(this.displayCursorPos, 1); + this.displayCursorPos = etk::max(this.displayCursorPos, 0); + this.displayCursorPosSelection = this.displayCursorPos; } } else if (_event.getChar() == 0x08) { // DEL : - if (propertyValue->size() > 0 && m_displayCursorPos != 0) { - propertyValue.getDirect().erase(m_displayCursorPos-1, 1); - m_displayCursorPos--; - m_displayCursorPos = etk::max(m_displayCursorPos, 0); - m_displayCursorPosSelection = m_displayCursorPos; + if (propertyValue.size() > 0 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.displayCursorPos != 0) { + propertyValue.getDirect().erase(this.displayCursorPos-1, 1); + this.displayCursorPos--; + this.displayCursorPos = etk::max(this.displayCursorPos, 0); + this.displayCursorPosSelection = this.displayCursorPos; } } else if(_event.getChar() >= 20) { - Log.error("get data: '" << _event.getChar() << "' = '" << u32char::convertToUtf8(_event.getChar()) << "'"); - if ((int64_t)propertyValue->size() > propertyMaxCharacter) { - Log.info("Reject data for entry : '" << _event.getChar() << "'"); + Log.error("get data: '" + _event.getChar() + "' = '" + u32char::convertToUtf8(_event.getChar()) + "'"); + if ((long)propertyValue.size() > propertyMaxCharacter) { + Log.info("Reject data for entry : '" + _event.getChar() + "'"); } else { - etk::String newData = propertyValue; - etk::String inputData = u32char::convertToUtf8(_event.getChar()); - newData.insert(newData.begin()+m_displayCursorPos, inputData); + String newData = propertyValue; + String inputData = u32char::convertToUtf8(_event.getChar()); + newData.insert(newData.begin()+this.displayCursorPos, inputData); setInternalValue(newData); if (propertyValue.get() == newData) { - m_displayCursorPos += inputData.size(); - m_displayCursorPosSelection = m_displayCursorPos; + this.displayCursorPos += inputData.size(); + this.displayCursorPosSelection = this.displayCursorPos; } } } @@ -395,25 +395,25 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { } return false; } else { - if(_event.getStatus() == gale::key::status::down) { + if(_event.getStatus() == KeyStatus::down) { switch (_event.getType()) { - case gale::key::keyboard::left: - m_displayCursorPos--; + case KeyKeyboard::left: + this.displayCursorPos--; break; - case gale::key::keyboard::right: - m_displayCursorPos++; + case KeyKeyboard::right: + this.displayCursorPos++; break; - case gale::key::keyboard::start: - m_displayCursorPos = 0; + case KeyKeyboard::start: + this.displayCursorPos = 0; break; - case gale::key::keyboard::end: - m_displayCursorPos = propertyValue->size(); + case KeyKeyboard::end: + this.displayCursorPos = propertyValue.size(); break; default: return false; } - m_displayCursorPos = etk::avg(0, m_displayCursorPos, (int32_t)propertyValue->size()); - m_displayCursorPosSelection = m_displayCursorPos; + this.displayCursorPos = etk::avg(0, this.displayCursorPos, (int)propertyValue.size()); + this.displayCursorPosSelection = this.displayCursorPos; markToRedraw(); return true; } @@ -421,21 +421,21 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { return false; } -void ewol::widget::Entry::setInternalValue(const etk::String& _newData) { - etk::String previous = propertyValue; +void ewol::widget::Entry::setInternalValue( String _newData) { + String previous = propertyValue; // check the RegExp : if (_newData.size()>0) { /* - if (m_regex.parse(_newData, 0, _newData.size()) == false) { - Log.info("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "'" ); + if (this.regex.parse(_newData, 0, _newData.size()) == false) { + Log.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "'" ); return; } - if (m_regex.start() != 0) { - Log.info("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (start position error)" ); + if (this.regex.start() != 0) { + Log.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "' (start position error)" ); return; } - if (m_regex.stop() != _newData.size()) { - Log.info("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (stop position error)" ); + if (this.regex.stop() != _newData.size()) { + Log.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "' (stop position error)" ); return; } */ @@ -448,19 +448,19 @@ void ewol::widget::Entry::onEventClipboard(enum gale::context::clipBoard::clipbo // remove curent selected data ... removeSelected(); // get current selection / Copy : - etk::String tmpData = get(_clipboardID); + String tmpData = get(_clipboardID); // add it on the current display : if (tmpData.size() != 0) { - etk::String newData = propertyValue; - newData.insert(m_displayCursorPos, &tmpData[0]); + String newData = propertyValue; + newData.insert(this.displayCursorPos, tmpData[0]); setInternalValue(newData); if (propertyValue.get() == newData) { - if (propertyValue->size() == tmpData.size()) { - m_displayCursorPos = tmpData.size(); + if (propertyValue.size() == tmpData.size()) { + this.displayCursorPos = tmpData.size(); } else { - m_displayCursorPos += tmpData.size(); + this.displayCursorPos += tmpData.size(); } - m_displayCursorPosSelection = m_displayCursorPos; + this.displayCursorPosSelection = this.displayCursorPos; markToRedraw(); } } @@ -469,9 +469,9 @@ void ewol::widget::Entry::onEventClipboard(enum gale::context::clipBoard::clipbo void ewol::widget::Entry::onCallbackEntryClean() { propertyValue.setDirect(""); - m_displayStartPosition = 0; - m_displayCursorPos = 0; - m_displayCursorPosSelection = m_displayCursorPos; + this.displayStartPosition = 0; + this.displayCursorPos = 0; + this.displayCursorPosSelection = this.displayCursorPos; markToRedraw(); } @@ -489,79 +489,79 @@ void ewol::widget::Entry::onCallbackPaste() { gale::context::clipBoard::request(gale::context::clipBoard::clipboardStd); } -void ewol::widget::Entry::onCallbackSelect(bool _all) { +void ewol::widget::Entry::onCallbackSelect(boolean _all) { if(_all == true) { - m_displayCursorPosSelection = 0; - m_displayCursorPos = propertyValue->size(); + this.displayCursorPosSelection = 0; + this.displayCursorPos = propertyValue.size(); } else { - m_displayCursorPosSelection = m_displayCursorPos; + this.displayCursorPosSelection = this.displayCursorPos; } markToRedraw(); } void ewol::widget::Entry::markToUpdateTextPosition() { - m_needUpdateTextPos = true; + this.needUpdateTextPos = true; } void ewol::widget::Entry::updateTextPosition() { - if (m_needUpdateTextPos == false) { + if (this.needUpdateTextPos == false) { return; } - ewol::Padding padding = m_shaper.getPadding(); + ewol::Padding padding = this.shaper.getPadding(); - int32_t tmpSizeX = m_minSize.x(); - if (propertyFill->x() == true) { - tmpSizeX = m_size.x(); + int tmpSizeX = this.minSize.x(); + if (propertyFill.x() == true) { + tmpSizeX = this.size.x(); } - int32_t tmpUserSize = tmpSizeX - padding.x(); - int32_t totalWidth = m_text.calculateSize(propertyValue).x(); + int tmpUserSize = tmpSizeX - padding.x(); + int totalWidth = this.text.calculateSize(propertyValue).x(); // Check if the data inside the display can be contain in the entry box if (totalWidth < tmpUserSize) { // all can be display : - m_displayStartPosition = 0; + this.displayStartPosition = 0; } else { // all can not be set : - etk::String tmpDisplay = etk::String(propertyValue, 0, m_displayCursorPos); - int32_t pixelCursorPos = m_text.calculateSize(tmpDisplay).x(); + String tmpDisplay = String(propertyValue, 0, this.displayCursorPos); + int pixelCursorPos = this.text.calculateSize(tmpDisplay).x(); // check if the Cussor is visible at 10px nearest the border : - int32_t tmp1 = pixelCursorPos+m_displayStartPosition; - Log.debug("cursorPos=" << pixelCursorPos << "px maxSize=" << tmpUserSize << "px tmp1=" << tmp1); + int tmp1 = pixelCursorPos+this.displayStartPosition; + Log.debug("cursorPos=" + pixelCursorPos + "px maxSize=" + tmpUserSize + "px tmp1=" + tmp1); if (tmp1<10) { // set the cursor on le left - m_displayStartPosition = etk::min(-pixelCursorPos+10, 0); + this.displayStartPosition = etk::min(-pixelCursorPos+10, 0); } else if (tmp1>tmpUserSize-10) { // set the cursor of the Right - m_displayStartPosition = etk::min(-pixelCursorPos + tmpUserSize - 10, 0); + this.displayStartPosition = etk::min(-pixelCursorPos + tmpUserSize - 10, 0); } // else : the cursor is inside the display - //m_displayStartPosition = -totalWidth + tmpUserSize; + //this.displayStartPosition = -totalWidth + tmpUserSize; } } void ewol::widget::Entry::onGetFocus() { - m_displayCursor = true; + this.displayCursor = true; changeStatusIn(STATUS_SELECTED); showKeyboard(); markToRedraw(); } void ewol::widget::Entry::onLostFocus() { - m_displayCursor = false; + this.displayCursor = false; changeStatusIn(STATUS_NORMAL); hideKeyboard(); markToRedraw(); } -void ewol::widget::Entry::changeStatusIn(int32_t _newStatusId) { - if (m_shaper.changeStatusIn(_newStatusId) == true) { - m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::Entry::periodicCall); +void ewol::widget::Entry::changeStatusIn(int _newStatusId) { + if (this.shaper.changeStatusIn(_newStatusId) == true) { + this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::Entry::periodicCall); markToRedraw(); } } -void ewol::widget::Entry::periodicCall(const ewol::event::Time& _event) { - if (m_shaper.periodicCall(_event) == false) { - m_PCH.disconnect(); +void ewol::widget::Entry::periodicCall( ewol::event::Time _event) { + if (this.shaper.periodicCall(_event) == false) { + this.PCH.disconnect(); } markToRedraw(); } @@ -571,25 +571,25 @@ void ewol::widget::Entry::onChangePropertyPassword() { } void ewol::widget::Entry::onChangePropertyShaper() { - m_shaper.setSource(propertyShape.get()); - m_colorIdTextFg = m_shaper.requestColor("text-foreground"); - m_colorIdTextBg = m_shaper.requestColor("text-background"); - m_colorIdCursor = m_shaper.requestColor("text-cursor"); - m_colorIdSelection = m_shaper.requestColor("text-selection"); + this.shaper.setSource(propertyShape.get()); + this.colorIdTextFg = this.shaper.requestColor("text-foreground"); + this.colorIdTextBg = this.shaper.requestColor("text-background"); + this.colorIdCursor = this.shaper.requestColor("text-cursor"); + this.colorIdSelection = this.shaper.requestColor("text-selection"); } void ewol::widget::Entry::onChangePropertyValue() { - etk::String newData = propertyValue.get(); - if ((int64_t)newData.size() > propertyMaxCharacter) { - newData = etk::String(newData, 0, propertyMaxCharacter); - Log.debug("Limit entry set of data... " << etk::String(newData, propertyMaxCharacter)); + String newData = propertyValue.get(); + if ((long)newData.size() > propertyMaxCharacter) { + newData = String(newData, 0, propertyMaxCharacter); + Log.debug("Limit entry set of data... " + String(newData, propertyMaxCharacter)); } // set the value with the check of the RegExp ... setInternalValue(newData); if (newData == propertyValue.get()) { - m_displayCursorPos = propertyValue->size(); - m_displayCursorPosSelection = m_displayCursorPos; - Log.verbose("Set : '" << newData << "'"); + this.displayCursorPos = propertyValue.size(); + this.displayCursorPosSelection = this.displayCursorPos; + Log.verbose("Set : '" + newData + "'"); } markToRedraw(); } @@ -599,9 +599,9 @@ void ewol::widget::Entry::onChangePropertyMaxCharacter() { } void ewol::widget::Entry::onChangePropertyRegex() { - m_regex.compile(propertyRegex.get()); - if (m_regex.getStatus() == false) { - Log.error("can not parse regex for : " << propertyRegex); + this.regex.compile(propertyRegex.get()); + if (this.regex.getStatus() == false) { + Log.error("can not parse regex for : " + propertyRegex); } markToRedraw(); } diff --git a/src/org/atriasoft/ewol/widget/Entry.java b/src/org/atriasoft/ewol/widget/Entry.java index f231277..fabc5e0 100644 --- a/src/org/atriasoft/ewol/widget/Entry.java +++ b/src/org/atriasoft/ewol/widget/Entry.java @@ -19,7 +19,7 @@ namespace ewol { namespace widget { class Entry; - using EntryShared = ememory::SharedPtr; + using Entry = ememory::Ptr; using EntryWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -31,111 +31,111 @@ namespace ewol { * ---------------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~ */ - class Entry : public ewol::Widget { + class Entry : public Widget { public: // Event list esignal::Signal<> signalClick; //!< bang on click the entry box - esignal::Signal signalEnter; //!< Enter key is pressed - esignal::Signal signalModify; //!< data change + esignal::Signal signalEnter; //!< Enter key is pressed + esignal::Signal signalModify; //!< data change public: // propertie list eproperty::Value propertyPassword; //!< Disable display of the content of the entry eproperty::Value propertyShape; - eproperty::Value propertyValue; //!< string that must be displayed - eproperty::Range propertyMaxCharacter; //!< number max of xharacter in the list - eproperty::Value propertyRegex; //!< regular expression value - eproperty::Value propertyTextWhenNothing; //!< Text to display when nothing in in the entry (decorated text...) + eproperty::Value propertyValue; //!< string that must be displayed + eproperty::Range propertyMaxCharacter; //!< number max of xharacter in the list + eproperty::Value propertyRegex; //!< regular expression value + eproperty::Value propertyTextWhenNothing; //!< Text to display when nothing in in the entry (decorated text...) private: - ewol::compositing::Shaper m_shaper; - int32_t m_colorIdTextFg; //!< color property of the text foreground - int32_t m_colorIdTextBg; //!< color property of the text background - int32_t m_colorIdCursor; //!< color property of the text cursor - int32_t m_colorIdSelection; //!< color property of the text selection - ewol::compositing::Text m_text; //!< text display m_text + ewol::compositing::Shaper this.shaper; + int this.colorIdTextFg; //!< color property of the text foreground + int this.colorIdTextBg; //!< color property of the text background + int this.colorIdCursor; //!< color property of the text cursor + int this.colorIdSelection; //!< color property of the text selection + ewol::compositing::Text this.text; //!< text display this.text protected: /** * @brief Contuctor * @param[in] _newData The USting that might be set in the Entry box (no event generation!!) */ Entry(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(Entry, "Entry"); /** * @brief Destuctor */ - virtual ~Entry(); + ~Entry(); protected: /** * @brief internal check the value with RegExp checking * @param[in] _newData The new string to display */ - void setInternalValue(const etk::String& _newData); + void setInternalValue( String _newData); private: - etk::RegEx m_regex; //!< regular expression to check content + etk::RegEx this.regex; //!< regular expression to check content private: - bool m_needUpdateTextPos; //!< text position can have change - int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString - bool m_displayCursor; //!< Cursor must be display only when the widget has the focus - int32_t m_displayCursorPos; //!< Cursor position in number of Char - int32_t m_displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == m_displayCursorPos chan no selection availlable + boolean this.needUpdateTextPos; //!< text position can have change + int this.displayStartPosition; //!< ofset in pixel of the display of the UString + boolean this.displayCursor; //!< Cursor must be display only when the widget has the focus + int this.displayCursorPos; //!< Cursor position in number of Char + int this.displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == this.displayCursorPos chan no selection availlable protected: /** * @brief informe the system thet the text change and the start position change */ - virtual void markToUpdateTextPosition(); + void markToUpdateTextPosition(); /** * @brief update the display position start == > depending of the position of the Cursor and the size of the Data inside - * @change m_displayStartPosition < == updated + * @change this.displayStartPosition < == updated */ - virtual void updateTextPosition(); + void updateTextPosition(); /** * @brief change the cursor position with the curent position requested on the display * @param[in] _pos Absolute position of the event * @note The display is automaticly requested when change apear. */ - virtual void updateCursorPosition(const Vector2f& _pos, bool _Selection=false); + void updateCursorPosition( Vector2f _pos, boolean _Selection=false); public: /** * @brief Copy the selected data on the specify clipboard * @param[in] _clipboardID Selected clipboard */ - virtual void copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID); + void copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID); /** * @brief remove the selected area * @note This request a regeneration of the display */ - virtual void removeSelected(); + void removeSelected(); public: - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - bool onEventEntry(const ewol::event::Entry& _event) override; - void onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID) override; - void calculateMinMaxSize() override; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + boolean onEventEntry( ewol::event::Entry _event) ; + void onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID) ; + void calculateMinMaxSize() ; protected: - void onDraw() override; - void onGetFocus() override; - void onLostFocus() override; - virtual void changeStatusIn(int32_t _newStatusId); + void onDraw() ; + void onGetFocus() ; + void onLostFocus() ; + void changeStatusIn(int _newStatusId); protected: - esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed + esignal::Connection this.PCH; //!< Periodic call handle to remove it when needed /** * @brief Periodic call to update grapgic display * @param[in] _event Time generic event */ - void periodicCall(const ewol::event::Time& _event); + void periodicCall( ewol::event::Time _event); private: // callback functions - void onCallbackShortCut(const etk::String& _value); + void onCallbackShortCut( String _value); void onCallbackEntryClean(); void onCallbackCut(); void onCallbackCopy(); void onCallbackPaste(); - void onCallbackSelect(bool _all); + void onCallbackSelect(boolean _all); protected: - virtual void onChangePropertyPassword(); - virtual void onChangePropertyShaper(); - virtual void onChangePropertyValue(); - virtual void onChangePropertyMaxCharacter(); - virtual void onChangePropertyRegex(); - virtual void onChangePropertyTextWhenNothing(); + void onChangePropertyPassword(); + void onChangePropertyShaper(); + void onChangePropertyValue(); + void onChangePropertyMaxCharacter(); + void onChangePropertyRegex(); + void onChangePropertyTextWhenNothing(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Gird.cpp b/src/org/atriasoft/ewol/widget/Gird.cpp index a3e8292..c957bf2 100644 --- a/src/org/atriasoft/ewol/widget/Gird.cpp +++ b/src/org/atriasoft/ewol/widget/Gird.cpp @@ -12,28 +12,28 @@ ETK_DECLARE_TYPE(ewol::widget::Gird); ewol::widget::Gird::Gird() : - m_sizeRow(0), - m_tmpWidget(null), - m_gavityButtom(true), - m_borderSize(0,0) { + this.sizeRow(0), + this.tmpWidget(null), + this.gavityButtom(true), + this.borderSize(0,0) { addObjectType("ewol::widget::Gird"); requestUpdateSize(); } ewol::widget::Gird::~Gird() { - Log.debug("[" << getId() << "]={" << getObjectType() << "} Gird : destroy"); + Log.debug("[" + getId() + "]={" + getObjectType() + "} Gird : destroy"); subWidgetRemoveAll(); } -void ewol::widget::Gird::setBorderSize(const Vector2i& _newBorderSize) { - m_borderSize = _newBorderSize; - if (m_borderSize.x() < 0) { - Log.error("Try to set a border size <0 on x : " << m_borderSize.x() << " == > restore to 0"); - m_borderSize.setX(0); +void ewol::widget::Gird::setBorderSize( Vector2i _newBorderSize) { + this.borderSize = _newBorderSize; + if (this.borderSize.x() < 0) { + Log.error("Try to set a border size <0 on x : " + this.borderSize.x() + " == > restore to 0"); + this.borderSize.setX(0); } - if (m_borderSize.y() < 0) { - Log.error("Try to set a border size <0 on y : " << m_borderSize.y() << " == > restore to 0"); - m_borderSize.setY(0); + if (this.borderSize.y() < 0) { + Log.error("Try to set a border size <0 on y : " + this.borderSize.y() + " == > restore to 0"); + this.borderSize.setY(0); } markToRedraw(); requestUpdateSize(); @@ -41,154 +41,154 @@ void ewol::widget::Gird::setBorderSize(const Vector2i& _newBorderSize) { void ewol::widget::Gird::onChangeSize() { //Log.debug("Update size"); - m_size -= m_borderSize*2; + this.size -= this.borderSize*2; - for (size_t iii=0; iiigetPixel(); - m_maxSize = propertyMaxSize->getPixel(); - m_uniformSizeRow = 0; - m_minSize += m_borderSize*2; - int32_t lastLineID = 0; - for (size_t iii=0; iii lastLineID) { + this.minSize = propertyMinSize.getPixel(); + this.maxSize = propertyMaxSize.getPixel(); + this.uniformSizeRow = 0; + this.minSize += this.borderSize*2; + int lastLineID = 0; + for (int iii=0; iii lastLineID) { // change of line : - lastLineID = m_subWidget[iii].row; + lastLineID = this.subWidget[iii].row; } - if (m_subWidget[iii].widget != null) { - m_subWidget[iii].widget->calculateMinMaxSize(); - Vector2f tmpSize = m_subWidget[iii].widget->getCalculateMinSize(); - Log.debug(" [" << iii << "] subWidgetMinSize=" << tmpSize); + if (this.subWidget[iii].widget != null) { + this.subWidget[iii].widget.calculateMinMaxSize(); + Vector2f tmpSize = this.subWidget[iii].widget.getCalculateMinSize(); + Log.debug(" [" + iii + "] subWidgetMinSize=" + tmpSize); // for all we get the max size : - m_uniformSizeRow = etk::max((int32_t)tmpSize.y(), m_uniformSizeRow); + this.uniformSizeRow = etk::max((int)tmpSize.y(), this.uniformSizeRow); // for the colomn size : We set the autamatic value in negative : - if (m_sizeCol[m_subWidget[iii].col] <= 0) { - m_sizeCol[m_subWidget[iii].col] = etk::min(m_sizeCol[m_subWidget[iii].col], (int32_t)-tmpSize.x() ); + if (this.sizeCol[this.subWidget[iii].col] <= 0) { + this.sizeCol[this.subWidget[iii].col] = etk::min(this.sizeCol[this.subWidget[iii].col], (int)-tmpSize.x() ); } } } - if (m_sizeRow > 0) { - m_uniformSizeRow = m_sizeRow; + if (this.sizeRow > 0) { + this.uniformSizeRow = this.sizeRow; } - int32_t tmpSizeWidth = 0; - for (size_t iii=0; iii it is not the case ==> the herited class must call the \"OnObjectRemove\" function..."); + if (errorControl == this.subWidget.size()) { + Log.critical("[" + getId() + "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function..."); } } else { - EWOL_WARNING("[" << getId() << "] Must not have null pointer on the subWidget list ..."); - m_subWidget.erase(m_subWidget.begin()+iii); + Log.warning("[" + getId() + "] Must not have null pointer on the subWidget list ..."); + this.subWidget.erase(this.subWidget.begin()+iii); } - errorControl = m_subWidget.size(); + errorControl = this.subWidget.size(); } } // just add the col size: - m_sizeCol.erase(m_sizeCol.end()); + this.sizeCol.erase(this.sizeCol.end()); } else { // just add the col size: - for (int32_t iii=m_sizeCol.size()-1; iii<_colNumber-1 ; iii++) { - m_sizeCol.pushBack(0); + for (int iii=this.sizeCol.size()-1; iii<_colNumber-1 ; iii++) { + this.sizeCol.pushBack(0); } } } -void ewol::widget::Gird::setColSize(int32_t _colId, int32_t _size) { - if ((int64_t)m_sizeCol.size() > _colId) { - m_sizeCol[_colId] = _size; +void ewol::widget::Gird::setColSize(int _colId, int _size) { + if ((long)this.sizeCol.size() > _colId) { + this.sizeCol[_colId] = _size; } else { - Log.error("Can not set the Colomn size : " << _colId+1 - << " at " << _size << "px we have " - << m_sizeCol.size() << " colomn"); + Log.error("Can not set the Colomn size : " + _colId+1 + + " at " + _size + "px we have " + + this.sizeCol.size() + " colomn"); } } -void ewol::widget::Gird::setRowSize(int32_t _size) { - m_sizeRow = _size; +void ewol::widget::Gird::setRowSize(int _size) { + this.sizeRow = _size; } -int32_t ewol::widget::Gird::getColSize(int32_t _colId) { - if ((int64_t)m_sizeCol.size() > _colId) { - if (m_sizeCol[_colId] <= 0) { +int ewol::widget::Gird::getColSize(int _colId) { + if ((long)this.sizeCol.size() > _colId) { + if (this.sizeCol[_colId] <= 0) { return 0; } - return m_sizeCol[_colId]; + return this.sizeCol[_colId]; } - Log.error("Can not get the Colomn size : " << _colId+1 << " we have "<< m_sizeCol.size() << " colomn"); + Log.error("Can not get the Colomn size : " + _colId+1 + " we have "+ this.sizeCol.size() + " colomn"); return 0; } -int32_t ewol::widget::Gird::getRowSize() { - return m_sizeRow; +int ewol::widget::Gird::getRowSize() { + return this.sizeRow; } void ewol::widget::Gird::subWidgetRemoveAll() { - size_t errorControl = m_subWidget.size(); - m_subWidget.clear(); + int errorControl = this.subWidget.size(); + this.subWidget.clear(); } -void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::WidgetShared _newWidget) { +void ewol::widget::Gird::subWidgetAdd(int _colId, int _rowId, Widget _newWidget) { if (_newWidget == null) { return; } @@ -198,126 +198,126 @@ void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widg prop.widget = _newWidget; // need to find the correct position : - for (size_t iii=0; iii prop.row) { + } else if (this.subWidget[iii].row > prop.row) { // find a new position; - m_subWidget.insert(m_subWidget.begin()+iii, prop); + this.subWidget.insert(this.subWidget.begin()+iii, prop); return; } else { - if (m_subWidget[iii].col < prop.col) { + if (this.subWidget[iii].col < prop.col) { continue; - } else if (m_subWidget[iii].col > prop.col) { + } else if (this.subWidget[iii].col > prop.col) { // find a new position; - m_subWidget.insert(m_subWidget.begin()+iii, prop); + this.subWidget.insert(this.subWidget.begin()+iii, prop); return; } else { // The element already exist == > replace it ... - m_tmpWidget = m_subWidget[iii].widget; - m_subWidget[iii].widget = _newWidget; - if (m_tmpWidget != null) { - m_tmpWidget.reset(); - if (m_tmpWidget != null) { - Log.critical("[" << getId() << "] Error while replacing a widget ... == > never call when free"); - m_tmpWidget = null; + this.tmpWidget = this.subWidget[iii].widget; + this.subWidget[iii].widget = _newWidget; + if (this.tmpWidget != null) { + this.tmpWidget.reset(); + if (this.tmpWidget != null) { + Log.critical("[" + getId() + "] Error while replacing a widget ... == > never call when free"); + this.tmpWidget = null; } } } } } // not find == > just adding it ... - m_subWidget.pushBack(prop); + this.subWidget.pushBack(prop); } -void ewol::widget::Gird::subWidgetRemove(ewol::WidgetShared _newWidget) { - for (size_t iii=0; iiisystemDraw(_displayProp); + it.widget.systemDraw(_displayProp); } } } void ewol::widget::Gird::onRegenerateDisplay() { - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it.widget != null) { - it.widget->onRegenerateDisplay(); + it.widget.onRegenerateDisplay(); } } } -ewol::WidgetShared ewol::widget::Gird::getWidgetAtPos(const Vector2f& _pos) { +Widget ewol::widget::Gird::getWidgetAtPos( Vector2f _pos) { if (*propertyHide == true) { return null; } // for all element in the sizer ... - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it.widget == null) { continue; } - Vector2f tmpSize = it.widget->getSize(); - Vector2f tmpOrigin = it.widget->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - ewol::WidgetShared tmpWidget = it.widget->getWidgetAtPos(_pos); + Vector2f tmpSize = it.widget.getSize(); + Vector2f tmpOrigin = it.widget.getOrigin(); + if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x()) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { + Widget tmpWidget = it.widget.getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } diff --git a/src/org/atriasoft/ewol/widget/Gird.java b/src/org/atriasoft/ewol/widget/Gird.java index 3029bbe..97a4c89 100644 --- a/src/org/atriasoft/ewol/widget/Gird.java +++ b/src/org/atriasoft/ewol/widget/Gird.java @@ -14,25 +14,25 @@ namespace ewol { namespace widget { class Gird; - using GirdShared = ememory::SharedPtr; + using Gird = ememory::Ptr; using GirdWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class Gird :public ewol::Widget { + class Gird :public Widget { private: class GirdProperties { public: - ewol::WidgetShared widget; - int32_t row; - int32_t col; + Widget widget; + int row; + int col; }; - int32_t m_sizeRow; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ... - int32_t m_uniformSizeRow; - List m_sizeCol; //!< size of all colomn (if set (otherwise 0)) - List m_subWidget; //!< all sub widget are contained in this element - ewol::WidgetShared m_tmpWidget; //!< use when replace a widget ... - bool m_gavityButtom; + int this.sizeRow; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ... + int this.uniformSizeRow; + List this.sizeCol; //!< size of all colomn (if set (otherwise 0)) + List this.subWidget; //!< all sub widget are contained in this element + Widget this.tmpWidget; //!< use when replace a widget ... + boolean this.gavityButtom; protected: /** * @brief Constructor @@ -43,104 +43,104 @@ namespace ewol { /** * @brief Desstructor */ - virtual ~Gird(); + ~Gird(); /** * @brief set the number of colomn * @param[in] colNumber Nuber of colomn */ - void setColNumber(int32_t _colNumber); + void setColNumber(int _colNumber); /** * @brief change a size view of a colomn. * @param[in] colId Id of the colomn [0..x]. * @param[in] size size of the colomn. */ - void setColSize(int32_t _colId, int32_t _size); + void setColSize(int _colId, int _size); /** * @brief change a size view of a line. * @param[in] size size of the line. */ - void setRowSize(int32_t _size); + void setRowSize(int _size); /** * @brief get the size view of a colomn. * @param[in] colId Id of the colomn [0..x]. * @return The size of the colomn. */ - int32_t getColSize(int32_t _colId); + int getColSize(int _colId); /** * @brief get the size view of the lines. * @return The size of the lines. */ - int32_t getRowSize(); + int getRowSize(); /** * @brief set the gravity of the widget on the Button (index 0 is on buttom) */ void setGravityButtom() { - m_gavityButtom = true; + this.gavityButtom = true; markToRedraw(); } /** * @brief set the gravity of the widget on the Top (index 0 is on top) */ void setGravityTop() { - m_gavityButtom = false; + this.gavityButtom = false; markToRedraw(); } public: /** * @brief remove all sub element from the widget. */ - virtual void subWidgetRemoveAll(); + void subWidgetRemoveAll(); /** * @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @param[in] _colId Id of the colomn [0..x]. * @param[in] _rowId Id of the row [0..y]. * @param[in] _newWidget the element pointer */ - virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::WidgetShared _newWidget); + void subWidgetAdd(int _colId, int _rowId, Widget _newWidget); /** * @brief remove definitly a widget from the system and this Gird. * @param[in] _newWidget the element pointer. */ - virtual void subWidgetRemove(ewol::WidgetShared _newWidget); + void subWidgetRemove(Widget _newWidget); /** * @brief remove definitly a widget from the system and this Gird. * @param[in] _colId Id of the colomn [0..x]. * @param[in] _rowId Id of the row [0..y]. */ - virtual void subWidgetRemove(int32_t _colId, int32_t _rowId); + void subWidgetRemove(int _colId, int _rowId); /** * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). * @param[in] _newWidget the element pointer. */ - virtual void subWidgetUnLink(ewol::WidgetShared _newWidget); + void subWidgetUnLink(Widget _newWidget); /** * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). * @param[in] _colId Id of the colomn [0..x]. * @param[in] _rowId Id of the row [0..y]. */ - virtual void subWidgetUnLink(int32_t _colId, int32_t _rowId); + void subWidgetUnLink(int _colId, int _rowId); private: // TODO : property - Vector2i m_borderSize; //!< Border size needed for all the display + Vector2i this.borderSize; //!< Border size needed for all the display public: /** * @brief set the current border size of the current element: * @param[in] _newBorderSize The border size to set (0 if not used) */ - void setBorderSize(const Vector2i& _newBorderSize); + void setBorderSize( Vector2i _newBorderSize); /** * @brief get the current border size of the current element: * @return the border size (0 if not used) */ - const Vector2i& getBorderSize() { - return m_borderSize; + Vector2i getBorderSize() { + return this.borderSize; }; public: - virtual void systemDraw(const ewol::DrawProperty& _displayProp) override; - virtual void onRegenerateDisplay() override; - virtual ewol::WidgetShared getWidgetAtPos(const Vector2f& pos) override; - virtual void onChangeSize() override; - virtual void calculateMinMaxSize() override; + void systemDraw( ewol::DrawProperty _displayProp) ; + void onRegenerateDisplay() ; + Widget getWidgetAtPos( Vector2f pos) ; + void onChangeSize() ; + void calculateMinMaxSize() ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Image.cpp b/src/org/atriasoft/ewol/widget/Image.cpp index 7509b31..327dda2 100644 --- a/src/org/atriasoft/ewol/widget/Image.cpp +++ b/src/org/atriasoft/ewol/widget/Image.cpp @@ -15,22 +15,22 @@ ETK_DECLARE_TYPE(ewol::widget::Image); ewol::widget::Image::Image() : signalPressed(this, "pressed", "Image is pressed"), - propertySource(this, "src", "", "Image source path", &ewol::widget::Image::onChangePropertySource), - propertyBorder(this, "border", Vector2f(0,0), "Border of the image", &ewol::widget::Image::onChangePropertyGlobalSize), - propertyImageSize(this, "size", Vector2f(0,0), "Basic display size of the image", &ewol::widget::Image::onChangePropertyGlobalSize), - propertyKeepRatio(this, "ratio", true, "Keep ratio of the image", &ewol::widget::Image::onChangePropertyGlobalSize), - propertyPosStart(this, "part-start", Vector2f(0.0f, 0.0f), Vector2f(0.0f, 0.0f), Vector2f(1.0f, 1.0f), "Start display position in the image", &ewol::widget::Image::onChangePropertyGlobalSize), - propertyPosStop(this, "part-stop", Vector2f(1.0f, 1.0f), Vector2f(0.0f, 0.0f), Vector2f(1.0f, 1.0f), "Start display position in the image", &ewol::widget::Image::onChangePropertyGlobalSize), - propertyDistanceFieldMode(this, "distance-field", false, "Distance field mode", &ewol::widget::Image::onChangePropertyDistanceFieldMode), - propertySmooth(this, "smooth", true, "Smooth display of the image", &ewol::widget::Image::onChangePropertySmooth), - propertyUseThemeColor(this, "use-theme-color", false, "use the theme color to display images", &ewol::widget::Image::onChangePropertyUseThemeColor), - m_colorProperty(null), - m_colorId(-1) { + propertySource(this, "src", "", "Image source path", ewol::widget::Image::onChangePropertySource), + propertyBorder(this, "border", Vector2f(0,0), "Border of the image", ewol::widget::Image::onChangePropertyGlobalSize), + propertyImageSize(this, "size", Vector2f(0,0), "Basic display size of the image", ewol::widget::Image::onChangePropertyGlobalSize), + propertyKeepRatio(this, "ratio", true, "Keep ratio of the image", ewol::widget::Image::onChangePropertyGlobalSize), + propertyPosStart(this, "part-start", Vector2f(0.0f, 0.0f), Vector2f(0.0f, 0.0f), Vector2f(1.0f, 1.0f), "Start display position in the image", ewol::widget::Image::onChangePropertyGlobalSize), + propertyPosStop(this, "part-stop", Vector2f(1.0f, 1.0f), Vector2f(0.0f, 0.0f), Vector2f(1.0f, 1.0f), "Start display position in the image", ewol::widget::Image::onChangePropertyGlobalSize), + propertyDistanceFieldMode(this, "distance-field", false, "Distance field mode", ewol::widget::Image::onChangePropertyDistanceFieldMode), + propertySmooth(this, "smooth", true, "Smooth display of the image", ewol::widget::Image::onChangePropertySmooth), + propertyUseThemeColor(this, "use-theme-color", false, "use the theme color to display images", ewol::widget::Image::onChangePropertyUseThemeColor), + this.colorProperty(null), + this.colorId(-1) { addObjectType("ewol::widget::Image"); - m_imageRenderSize = Vector2f(0,0); - m_colorProperty = ewol::resource::ColorFile::create(etk::Uri("THEME_COLOR:///Image.json?lib=ewol")); - if (m_colorProperty != null) { - m_colorId = m_colorProperty->request("foreground"); + this.imageRenderSize = Vector2f(0,0); + this.colorProperty = ewol::resource::ColorFile::create(etk::Uri("THEME_COLOR:///Image.json?lib=ewol")); + if (this.colorProperty != null) { + this.colorId = this.colorProperty.request("foreground"); } } ewol::widget::Image::~Image() { @@ -38,27 +38,27 @@ ewol::widget::Image::~Image() { } void ewol::widget::Image::init() { - ewol::Widget::init(); + Widget::init(); if (*propertySource != "") { onChangePropertySource(); } } -void ewol::widget::Image::set(const etk::Uri& _uri, const gale::Dimension& _border) { - Log.verbose("Set Image : " << _uri << " border=" << _border); +void ewol::widget::Image::set( etk::Uri _uri, gale::Dimension _border) { + Log.verbose("Set Image : " + _uri + " border=" + _border); propertyBorder.set(_border); propertySource.set(_uri); } -void ewol::widget::Image::setCustumSource(const egami::Image& _image) { +void ewol::widget::Image::setCustumSource( egami::Image _image) { // TODO : Better interfacing of all element internal ==> this is a temporary prototype - m_compositing.setSource(_image); + this.compositing.setSource(_image); markToRedraw(); requestUpdateSize(); } void ewol::widget::Image::onDraw() { - m_compositing.draw(); + this.compositing.draw(); } void ewol::widget::Image::onRegenerateDisplay() { @@ -66,34 +66,34 @@ void ewol::widget::Image::onRegenerateDisplay() { return; } // remove data of the previous composition : - m_compositing.clear(); + this.compositing.clear(); if ( *propertyUseThemeColor == true - && m_colorProperty != null) { - m_compositing.setColor(m_colorProperty->get(m_colorId)); + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorProperty != null) { + this.compositing.setColor(this.colorProperty.get(this.colorId)); } // Calculate the new position and size: - Vector2f imageBoder = propertyBorder->getPixel(); + Vector2f imageBoder = propertyBorder.getPixel(); Vector2f origin = imageBoder; imageBoder *= 2.0f; - Vector2f imageRealSize = m_imageRenderSize - imageBoder; - Vector2f imageRealSizeMax = m_size - imageBoder; + Vector2f imageRealSize = this.imageRenderSize - imageBoder; + Vector2f imageRealSizeMax = this.size - imageBoder; Vector2f ratioSizeDisplayRequested = *propertyPosStop - *propertyPosStart; //imageRealSizeMax *= ratioSizeDisplayRequested; - Vector2f delta = ewol::gravityGenerateDelta(*propertyGravity, m_size-m_imageRenderSize); - if (propertyFill->x() == true) { + Vector2f delta = ewol::gravityGenerateDelta(*propertyGravity, this.size-this.imageRenderSize); + if (propertyFill.x() == true) { imageRealSize.setX(imageRealSizeMax.x()); delta.setX(0.0); } - if (propertyFill->y() == true) { + if (propertyFill.y() == true) { imageRealSize.setY(imageRealSizeMax.y()); delta.setY(0.0); } origin += delta; if (*propertyKeepRatio == true) { - Vector2f tmpSize = m_compositing.getRealSize(); + Vector2f tmpSize = this.compositing.getRealSize(); //float ratio = tmpSize.x() / tmpSize.y(); float ratio = (tmpSize.x()*ratioSizeDisplayRequested.x()) / (tmpSize.y() * ratioSizeDisplayRequested.y()); //float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y()); @@ -113,48 +113,48 @@ void ewol::widget::Image::onRegenerateDisplay() { // set the somposition properties : if (*propertySmooth == true) { - m_compositing.setPos(origin); + this.compositing.setPos(origin); } else { - m_compositing.setPos(Vector2i(origin)); + this.compositing.setPos(Vector2i(origin)); } - m_compositing.printPart(imageRealSize, *propertyPosStart, *propertyPosStop); - Log.debug("Paint Image at : " << origin << " size=" << imageRealSize); - Log.debug("Paint Image :" << *propertySource << " realsize=" << m_compositing.getRealSize() << " origin=" << origin << " size=" << imageRealSize); - Log.debug(" start=" << *propertyPosStart << " stop=" << *propertyPosStop); + this.compositing.printPart(imageRealSize, *propertyPosStart, *propertyPosStop); + Log.debug("Paint Image at : " + origin + " size=" + imageRealSize); + Log.debug("Paint Image :" + *propertySource + " realsize=" + this.compositing.getRealSize() + " origin=" + origin + " size=" + imageRealSize); + Log.debug(" start=" + *propertyPosStart + " stop=" + *propertyPosStop); } void ewol::widget::Image::calculateMinMaxSize() { - Log.debug("calculate min size: border=" << propertyBorder << " size=" << propertyImageSize << " min-size=" << propertyMinSize); - Vector2f imageBoder = propertyBorder->getPixel()*2.0f; - Vector2f imageSize = propertyImageSize->getPixel(); - Vector2f size = propertyMinSize->getPixel(); - Log.debug(" ==> border=" << imageBoder << " size=" << imageSize << " min-size=" << size); + Log.debug("calculate min size: border=" + propertyBorder + " size=" + propertyImageSize + " min-size=" + propertyMinSize); + Vector2f imageBoder = propertyBorder.getPixel()*2.0f; + Vector2f imageSize = propertyImageSize.getPixel(); + Vector2f size = propertyMinSize.getPixel(); + Log.debug(" ==> border=" + imageBoder + " size=" + imageSize + " min-size=" + size); if (imageSize != Vector2f(0,0)) { - m_minSize = imageBoder+imageSize; - m_maxSize = m_minSize; + this.minSize = imageBoder+imageSize; + this.maxSize = this.minSize; } else { - Vector2f imageSizeReal = m_compositing.getRealSize(); - Log.verbose(" Real Size = " << imageSizeReal); - Vector2f min1 = imageBoder+propertyMinSize->getPixel(); - m_minSize = imageBoder+imageSizeReal; - Log.verbose(" set max : " << m_minSize << " min1=" << min1); - m_minSize.setMax(min1); - Log.verbose(" result : " << m_minSize); - m_maxSize = imageBoder+propertyMaxSize->getPixel(); - m_minSize.setMin(m_maxSize); + Vector2f imageSizeReal = this.compositing.getRealSize(); + Log.verbose(" Real Size = " + imageSizeReal); + Vector2f min1 = imageBoder+propertyMinSize.getPixel(); + this.minSize = imageBoder+imageSizeReal; + Log.verbose(" set max : " + this.minSize + " min1=" + min1); + this.minSize.setMax(min1); + Log.verbose(" result : " + this.minSize); + this.maxSize = imageBoder+propertyMaxSize.getPixel(); + this.minSize.setMin(this.maxSize); } - m_imageRenderSize = m_minSize; - m_minSize.setMax(size); - m_maxSize.setMax(m_minSize); - Log.debug("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << propertyImageSize); + this.imageRenderSize = this.minSize; + this.minSize.setMax(size); + this.maxSize.setMax(this.minSize); + Log.debug("set widget min=" + this.minSize + " max=" + this.maxSize + " with real Image size=" + this.imageRenderSize + " img size=" + imageSize + " " << propertyImageSize); markToRedraw(); } -bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::Image::onEventInput( ewol::event::Input _event) { //Log.debug("Event on BT ..."); if (_event.getId() == 1) { - if(gale::key::status::pressSingle == _event.getStatus()) { + if(KeyStatus::pressSingle == _event.getStatus()) { signalPressed.emit(); return true; } @@ -162,14 +162,14 @@ bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) { return false; } -bool ewol::widget::Image::loadXML(const exml::Element& _node) { +boolean ewol::widget::Image::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // get internal data : - etk::String tmpAttributeValue = _node.attributes["ratio"]; + String tmpAttributeValue = _node.attributes["ratio"]; if (tmpAttributeValue.size() != 0) { if (etk::compare_no_case(tmpAttributeValue, "true") == true) { propertyKeepRatio.setDirect(true); @@ -181,9 +181,9 @@ bool ewol::widget::Image::loadXML(const exml::Element& _node) { } tmpAttributeValue = _node.attributes["size"]; if (tmpAttributeValue.size() != 0) { - //Log.critical(" Parse SIZE : " << tmpAttributeValue); + //Log.critical(" Parse SIZE : " + tmpAttributeValue); propertyImageSize.setDirect(tmpAttributeValue); - //Log.critical(" == > " << propertyImageSize); + //Log.critical(" == > " + propertyImageSize); } tmpAttributeValue = _node.attributes["border"]; if (tmpAttributeValue.size() != 0) { @@ -193,7 +193,7 @@ bool ewol::widget::Image::loadXML(const exml::Element& _node) { if (tmpAttributeValue.size() != 0) { propertySmooth.setDirect(etk::string_to_bool(tmpAttributeValue)); } - //Log.debug("Load label:" << node->ToElement()->getText()); + //Log.debug("Load label:" + node.ToElement().getText()); if (_node.nodes.size() != 0) { propertySource.set(_node.getText()); } else { @@ -208,15 +208,15 @@ bool ewol::widget::Image::loadXML(const exml::Element& _node) { void ewol::widget::Image::onChangePropertySource() { markToRedraw(); requestUpdateSize(); - Log.verbose("Set sources : " << *propertySource << " size=" << *propertyImageSize); - m_compositing.setSource(*propertySource, propertyImageSize->getPixel()); + Log.verbose("Set sources : " + *propertySource + " size=" + *propertyImageSize); + this.compositing.setSource(*propertySource, propertyImageSize.getPixel()); } void ewol::widget::Image::onChangePropertyImageSize() { markToRedraw(); requestUpdateSize(); - Log.verbose("Set sources : " << *propertySource << " size=" << *propertyImageSize); - m_compositing.setSource(*propertySource, propertyImageSize->getPixel()); + Log.verbose("Set sources : " + *propertySource + " size=" + *propertyImageSize); + this.compositing.setSource(*propertySource, propertyImageSize.getPixel()); } void ewol::widget::Image::onChangePropertyGlobalSize() { @@ -229,7 +229,7 @@ void ewol::widget::Image::onChangePropertySmooth() { } void ewol::widget::Image::onChangePropertyDistanceFieldMode() { - m_compositing.setDistanceFieldMode(*propertyDistanceFieldMode); + this.compositing.setDistanceFieldMode(*propertyDistanceFieldMode); markToRedraw(); } diff --git a/src/org/atriasoft/ewol/widget/Image.java b/src/org/atriasoft/ewol/widget/Image.java index 0247fb5..e072358 100644 --- a/src/org/atriasoft/ewol/widget/Image.java +++ b/src/org/atriasoft/ewol/widget/Image.java @@ -16,12 +16,12 @@ namespace ewol { namespace widget { class Image; - using ImageShared = ememory::SharedPtr; + using Image = ememory::Ptr; using ImageWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class Image :public ewol::Widget { + class Image :public Widget { public: // signals esignal::Signal<> signalPressed; public: // properties @@ -35,48 +35,48 @@ namespace ewol { eproperty::Value propertySmooth; //!< display is done in the pixed approximation if false eproperty::Value propertyUseThemeColor; //!< Use the themo color management ("THEME_COLOR:///Image.json?lib=ewol") default false protected: - ewol::compositing::Image m_compositing; //!< compositing element of the image. - ememory::SharedPtr m_colorProperty; //!< theme color property - int32_t m_colorId; //!< Color of the image. + ewol::compositing::Image this.compositing; //!< compositing element of the image. + ememory::Ptr this.colorProperty; //!< theme color property + int this.colorId; //!< Color of the image. public: /** * @brief */ Image(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(Image, "Image"); /** * @brief */ - virtual ~Image(); + ~Image(); /** * @brief set All the configuration of the current image * @param[in] _uri URI of the new image * @param[in] _border New border size to set */ - void set(const etk::Uri& _uri, const gale::Dimension& _border); + void set( etk::Uri _uri, gale::Dimension _border); /** * @brief Set an image with direct elements * @param[in] _image Image to set in the display */ - void setCustumSource(const egami::Image& _image); + void setCustumSource( egami::Image _image); protected: - Vector2f m_imageRenderSize; //!< size of the image when we render it + Vector2f this.imageRenderSize; //!< size of the image when we render it protected: - void onDraw() override; + void onDraw() ; public: - void calculateMinMaxSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - bool loadXML(const exml::Element& _node) override; + void calculateMinMaxSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + boolean loadXML( exml::Element _node) ; protected: - virtual void onChangePropertySource(); - virtual void onChangePropertyImageSize(); - virtual void onChangePropertyGlobalSize(); - virtual void onChangePropertySmooth(); - virtual void onChangePropertyDistanceFieldMode(); - virtual void onChangePropertyUseThemeColor(); + void onChangePropertySource(); + void onChangePropertyImageSize(); + void onChangePropertyGlobalSize(); + void onChangePropertySmooth(); + void onChangePropertyDistanceFieldMode(); + void onChangePropertyUseThemeColor(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Joystick.cpp b/src/org/atriasoft/ewol/widget/Joystick.cpp index d00e731..2b628fe 100644 --- a/src/org/atriasoft/ewol/widget/Joystick.cpp +++ b/src/org/atriasoft/ewol/widget/Joystick.cpp @@ -12,9 +12,9 @@ #include ETK_DECLARE_TYPE(ewol::widget::Joystick); -static bool l_displayBackground(true); -static etk::String l_background(""); -static etk::String l_foreground(""); +static boolean l_displayBackground(true); +static String l_background(""); +static String l_foreground(""); static float l_ratio(1.0/7.0); ewol::widget::Joystick::Joystick() : @@ -23,23 +23,23 @@ ewol::widget::Joystick::Joystick() : signalMove(this, "move", "") { addObjectType("ewol::widget::Joystick"); // by default the joy does not lock when free out - m_lock = false; - m_displayMode = modeNormal; + this.lock = false; + this.displayMode = modeNormal; - m_colorFg = etk::color::blue; + this.colorFg = etk::color::blue; - m_colorBg = etk::color::black; - m_colorBg.setA(0x3F); + this.colorBg = etk::color::black; + this.colorBg.setA(0x3F); - m_displayPos.setValue(0,0); - m_distance = 0.0; - m_angle = -0.1; + this.displayPos.setValue(0,0); + this.distance = 0.0; + this.angle = -0.1; // set the generic parameters: - m_displayBackground = l_displayBackground; - m_background = l_background; - m_foreground = l_foreground; - m_ratio = l_ratio; + this.displayBackground = l_displayBackground; + this.background = l_background; + this.foreground = l_foreground; + this.ratio = l_ratio; propertyCanFocus.setDirectCheck(true); } @@ -56,29 +56,29 @@ void ewol::widget::Joystick::onRegenerateDisplay() { ewol::OObject2DTextured * tmpOOtexBg = null; ewol::OObject2DTextured * tmpOOtexFg = null; // set background - if (true == m_displayBackground) { - if (m_background == "") { + if (true == this.displayBackground) { + if (this.background == "") { tmpOObjects = ne w ewol::OObject2DColored; - tmpOObjects->setColor(m_colorBg); - tmpOObjects->Disc( m_size.x/2, m_size.y/2, m_size.x/2-1); + tmpOObjects.setColor(this.colorBg); + tmpOObjects.Disc( this.size.x/2, this.size.y/2, this.size.x/2-1); } else { - tmpOOtexBg = n ew ewol::OObject2DTextured(m_background, m_size.x, m_size.y); - tmpOOtexBg->rectangle(0, 0, m_size.x, m_size.y); + tmpOOtexBg = n ew ewol::OObject2DTextured(this.background, this.size.x, this.size.y); + tmpOOtexBg.rectangle(0, 0, this.size.x, this.size.y); } } // set cursor point - float sizeElement = m_size.x*m_ratio; - if (m_foreground == "") { + float sizeElement = this.size.x*this.ratio; + if (this.foreground == "") { if (null == tmpOObjects) { tmpOObjects = ne w ewol::OObject2DColored; } - tmpOObjects->setColor(m_colorFg); - tmpOObjects->Disc( ((m_displayPos.x+1.0)/2.0)*(m_size.x-2*sizeElement) + sizeElement, - ((m_displayPos.y+1.0)/2.0)*(m_size.y-2*sizeElement) + sizeElement, sizeElement); + tmpOObjects.setColor(this.colorFg); + tmpOObjects.Disc( ((this.displayPos.x+1.0)/2.0)*(this.size.x-2*sizeElement) + sizeElement, + ((this.displayPos.y+1.0)/2.0)*(this.size.y-2*sizeElement) + sizeElement, sizeElement); } else { - tmpOOtexFg = ne w ewol::OObject2DTextured(m_foreground,sizeElement*2, sizeElement*2); - tmpOOtexFg->rectangle(((m_displayPos.x+1.0)/2.0)*(m_size.x-2*sizeElement), - ((m_displayPos.y+1.0)/2.0)*(m_size.y-2*sizeElement), sizeElement*2, sizeElement*2); + tmpOOtexFg = ne w ewol::OObject2DTextured(this.foreground,sizeElement*2, sizeElement*2); + tmpOOtexFg.rectangle(((this.displayPos.x+1.0)/2.0)*(this.size.x-2*sizeElement), + ((this.displayPos.y+1.0)/2.0)*(this.size.y-2*sizeElement), sizeElement*2, sizeElement*2); } // add all needed objects ... if (null != tmpOObjects) { @@ -99,53 +99,53 @@ Sine Function: sin(teta) = Opposite / Hypotenuse Cosine Function: cos(teta) = Adjacent / Hypotenuse Tangent Function: tan(teta) = Opposite / Adjacent */ -bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::Joystick::onEventInput( ewol::event::Input _event) { /* if (1 == IdInput) { - if( gale::key::status::down == typeEvent - || gale::key::status::move == typeEvent) { + if( KeyStatus::down == typeEvent + || KeyStatus::move == typeEvent) { // get local relative position Vector2f relativePos = relativePosition(pos); - float sizeElement = m_size.x*m_ratio; + float sizeElement = this.size.x*this.ratio; // calculate the position of the cursor... - m_displayPos.x = (relativePos.x-sizeElement)/(m_size.x-sizeElement*2)*2.0 - 1.0; - m_displayPos.y = (relativePos.y-sizeElement)/(m_size.y-sizeElement*2)*2.0 - 1.0; + this.displayPos.x = (relativePos.x-sizeElement)/(this.size.x-sizeElement*2)*2.0 - 1.0; + this.displayPos.y = (relativePos.y-sizeElement)/(this.size.y-sizeElement*2)*2.0 - 1.0; // distance : - m_distance = m_displayPos.y*m_displayPos.y + m_displayPos.x * m_displayPos.x; - m_distance = sqrt(m_distance); + this.distance = this.displayPos.y*this.displayPos.y + this.displayPos.x * this.displayPos.x; + this.distance = sqrt(this.distance); // angle : - m_angle = atan(m_displayPos.y/m_displayPos.x); - if (m_displayPos.x < 0) { - m_angle += M_PI; + this.angle = atan(this.displayPos.y/this.displayPos.x); + if (this.displayPos.x < 0) { + this.angle += M_PI; } // clip if needed ... - if (m_distance > 1.0) { - m_distance = 1.0; + if (this.distance > 1.0) { + this.distance = 1.0; // regenerate n ew display position : - m_displayPos.x = cos(m_angle)*m_distance; - m_displayPos.y = sin(m_angle)*m_distance; + this.displayPos.x = cos(this.angle)*this.distance; + this.displayPos.y = sin(this.angle)*this.distance; } markToRedraw(); - if(gale::key::status::down == typeEvent) { + if(KeyStatus::down == typeEvent) { signalEnable.emit(); } else { - etk::String tmp = etk::String("distance=") + etk::String(m_distance) + etk::String("angle=") + etk::String(m_angle+M_PI/2); - signalMove.emit(m_angle+M_PI/2); + String tmp = String("distance=") + String(this.distance) + String("angle=") + String(this.angle+M_PI/2); + signalMove.emit(this.angle+M_PI/2); } //teta += M_PI/2; - //Log.debug("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance); + //Log.debug("TETA = " + (this.angle*180/M_PI) + " deg distance = " + this.distance); return true; - } else if( gale::key::status::up == typeEvent) { - if( true == m_lock - && m_distance == 1) { + } else if( KeyStatus::up == typeEvent) { + if( true == this.lock + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.distance == 1) { // nothing to do ... } else { - m_displayPos.x = 0.0; - m_displayPos.y = 0.0; - m_angle = -0.1; - m_distance = 0; + this.displayPos.x = 0.0; + this.displayPos.y = 0.0; + this.angle = -0.1; + this.distance = 0; } markToRedraw(); signalDisable.emit(); @@ -162,29 +162,29 @@ void ewol::widget::Joystick::ratio(float _newRatio) { if (_newRatio > 1) { _newRatio = 1; } - m_ratio = _newRatio; - Log.info("Set default Joystick ratio at " << m_ratio); + this.ratio = _newRatio; + Log.info("Set default Joystick ratio at " + this.ratio); } -void ewol::widget::Joystick::background(etk::String _imageNameInData, bool _display) { +void ewol::widget::Joystick::background(String _imageNameInData, boolean _display) { // TODO : check if it existed - m_background = _imageNameInData; - m_displayBackground = _display; - Log.info("Set default Joystick background at " << m_background << " display it=" << m_displayBackground); + this.background = _imageNameInData; + this.displayBackground = _display; + Log.info("Set default Joystick background at " + this.background + " display it=" + this.displayBackground); } -void ewol::widget::Joystick::foreground(etk::String imageNameInData) { +void ewol::widget::Joystick::foreground(String imageNameInData) { // TODO : check if it existed - m_foreground = imageNameInData; - Log.info("Set default Joystick Foreground at " << m_foreground); + this.foreground = imageNameInData; + Log.info("Set default Joystick Foreground at " + this.foreground); } -void ewol::widget::Joystick::getProperty(float& distance, float& angle) { - distance = m_distance; - angle = m_angle+M_PI/2; +void ewol::widget::Joystick::getProperty(float distance, float angle) { + distance = this.distance; + angle = this.angle+M_PI/2; } diff --git a/src/org/atriasoft/ewol/widget/Joystick.java b/src/org/atriasoft/ewol/widget/Joystick.java index 1917771..7850295 100644 --- a/src/org/atriasoft/ewol/widget/Joystick.java +++ b/src/org/atriasoft/ewol/widget/Joystick.java @@ -16,12 +16,12 @@ namespace ewol { namespace widget { class Joystick; - using JoystickShared = ememory::SharedPtr; + using Joystick = ememory::Ptr; using JoystickWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class Joystick :public ewol::Widget { + class Joystick :public Widget { public: // Event list of properties esignal::Signal<> signalEnable; @@ -33,30 +33,30 @@ namespace ewol { modeArrow, }; private: - etk::Color<> m_colorFg; //!< Forground color - etk::Color<> m_colorBg; //!< Background color - Vector2f m_displayPos; //!< direction of the cursor ... - float m_distance; //!< dintance from the center - float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ... - bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle - enum joystickMode m_displayMode; //!< Type of fonctionnal mode of the joystick + etk::Color<> this.colorFg; //!< Forground color + etk::Color<> this.colorBg; //!< Background color + Vector2f this.displayPos; //!< direction of the cursor ... + float this.distance; //!< dintance from the center + float this.angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ... + boolean this.lock; //!< flag to mark the lock when the cursor is free when we are outside the circle + enum joystickMode this.displayMode; //!< Type of fonctionnal mode of the joystick private: // generic property of the joystick: - bool m_displayBackground; - etk::String m_background; - etk::String m_foreground; - float m_ratio; + boolean this.displayBackground; + String this.background; + String this.foreground; + float this.ratio; protected: Joystick(); public: DECLARE_WIDGET_FACTORY(Joystick, "Joystick"); - virtual ~Joystick(); + ~Joystick(); public: - void setLockMode(bool _lockWhenOut) { - m_lock = _lockWhenOut; + void setLockMode(boolean _lockWhenOut) { + this.lock = _lockWhenOut; }; void setDisplayMode(enum joystickMode _newMode) { - m_displayMode = _newMode; + this.displayMode = _newMode; }; /** * @brief set the ratio of the widget joystick @@ -68,22 +68,22 @@ namespace ewol { * @param[in] _imageNameInData the new rbackground that might be set * @param[in] _display */ - void background(etk::String _imageNameInData, bool _display=true); + void background(String _imageNameInData, boolean _display=true); /** * @brief set the Foreground of the widget joystick * @param[in] _imageNameInData the new Foreground that might be set */ - void foreground(etk::String _imageNameInData); + void foreground(String _imageNameInData); /** * @brief get the property of the joystick * @param[out] _distance distance to the center * @param[out] _angle angle of the joy */ - void getProperty(float& _distance, float& _angle); + void getProperty(float _distance, float _angle); public: - virtual void onRegenerateDisplay() override; - virtual bool onEventInput(const ewol::event::Input& _event) override; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Label.cpp b/src/org/atriasoft/ewol/widget/Label.cpp index 7c04897..d056a17 100644 --- a/src/org/atriasoft/ewol/widget/Label.cpp +++ b/src/org/atriasoft/ewol/widget/Label.cpp @@ -12,30 +12,30 @@ #include ETK_DECLARE_TYPE(ewol::widget::Label); -// TODO : Remove the label name in the constructor ... +// TODO : Remove the label name in the ructor ... ewol::widget::Label::Label() : signalPressed(this, "pressed", ""), propertyAutoTranslate(this, "auto-translate", true, "Translate the String with the marker _{T:xxxxxx}", - &ewol::widget::Label::onChangePropertyAutoTranslate), + ewol::widget::Label::onChangePropertyAutoTranslate), propertyValue(this, "value", "", "displayed value string", - &ewol::widget::Label::onChangePropertyValue), + ewol::widget::Label::onChangePropertyValue), propertyFontSize(this, "font-size", 0, "default font size (0=> system default)", - &ewol::widget::Label::onChangePropertyFontSize), - m_value(U""), - m_colorProperty(null), - m_colorDefaultFgText(-1), - m_colorDefaultBgText(-1){ + ewol::widget::Label::onChangePropertyFontSize), + this.value(U""), + this.colorProperty(null), + this.colorDefaultFgText(-1), + this.colorDefaultBgText(-1){ addObjectType("ewol::widget::Label"); - m_colorProperty = ewol::resource::ColorFile::create(etk::Uri("THEME_COLOR:///Label.json?lib=ewol")); - if (m_colorProperty != null) { - m_colorDefaultFgText = m_colorProperty->request("foreground"); - m_colorDefaultBgText = m_colorProperty->request("background"); + this.colorProperty = ewol::resource::ColorFile::create(etk::Uri("THEME_COLOR:///Label.json?lib=ewol")); + if (this.colorProperty != null) { + this.colorDefaultFgText = this.colorProperty.request("foreground"); + this.colorDefaultBgText = this.colorProperty.request("background"); } setMouseLimit(1); propertyCanFocus.setDirectCheck(false); @@ -46,97 +46,97 @@ ewol::widget::Label::~Label() { } void ewol::widget::Label::init() { - ewol::Widget::init(); + Widget::init(); // Force update the value of internal display onChangePropertyValue(); } void ewol::widget::Label::calculateMinMaxSize() { - Vector2f tmpMax = propertyMaxSize->getPixel(); - Vector2f tmpMin = propertyMinSize->getPixel(); - //Log.debug("[" << getId() << "] {" << getObjectType() << "} tmpMax : " << tmpMax); + Vector2f tmpMax = propertyMaxSize.getPixel(); + Vector2f tmpMin = propertyMinSize.getPixel(); + //Log.debug("[" + getId() + "] {" + getObjectType() + "} tmpMax : " + tmpMax); if (tmpMax.x() <= 999999) { - m_text.setTextAlignement(0, tmpMax.x()-4, ewol::compositing::alignLeft); - //Log.debug("[" << getId() << "] {" << getObjectType() << "} forcez Alignement "); + this.text.setTextAlignement(0, tmpMax.x()-4, ewol::compositing::alignLeft); + //Log.debug("[" + getId() + "] {" + getObjectType() + "} forcez Alignement "); } - Vector3f minSize = m_text.calculateSizeDecorated(m_value); - //Log.debug("[" << getId() << "] {" << getObjectType() << "} minSize : " << minSize); + Vector3f minSize = this.text.calculateSizeDecorated(this.value); + //Log.debug("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize); - m_minSize.setX(etk::avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x())); - m_minSize.setY(etk::avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y())); - Log.verbose("[" << getId() << "] {" << getObjectType() << "} Result min size : " << tmpMin << " < " << m_minSize << " < " << tmpMax); + this.minSize.setX(etk::avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x())); + this.minSize.setY(etk::avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y())); + Log.verbose("[" + getId() + "] {" + getObjectType() + "} Result min size : " + tmpMin + " < " + this.minSize + " < " << tmpMax); } void ewol::widget::Label::onDraw() { - m_text.draw(); + this.text.draw(); } void ewol::widget::Label::onRegenerateDisplay() { if (needRedraw() == false) { return; } - m_text.clear(); - int32_t paddingSize = 2; + this.text.clear(); + int paddingSize = 2; - Vector2f tmpMax = propertyMaxSize->getPixel(); + Vector2f tmpMax = propertyMaxSize.getPixel(); // to know the size of one line : - Vector3f minSize = m_text.calculateSize(char32_t('A')); + Vector3f minSize = this.text.calculateSize(Character('A')); - //minSize.setX(etk::max(minSize.x(), m_minSize.x())); - //minSize.setY(etk::max(minSize.y(), m_minSize.y())); + //minSize.setX(etk::max(minSize.x(), this.minSize.x())); + //minSize.setY(etk::max(minSize.y(), this.minSize.y())); if (tmpMax.x() <= 999999) { - m_text.setTextAlignement(0, tmpMax.x()-2*paddingSize, ewol::compositing::alignLeft); + this.text.setTextAlignement(0, tmpMax.x()-2*paddingSize, ewol::compositing::alignLeft); } - Vector3f curentTextSize = m_text.calculateSizeDecorated(m_value); + Vector3f curentTextSize = this.text.calculateSizeDecorated(this.value); - Vector2i localSize = m_minSize; + Vector2i localSize = this.minSize; // no change for the text orogin : - Vector3f tmpTextOrigin((m_size.x() - m_minSize.x()) / 2.0, - (m_size.y() - m_minSize.y()) / 2.0, + Vector3f tmpTextOrigin((this.size.x() - this.minSize.x()) / 2.0, + (this.size.y() - this.minSize.y()) / 2.0, 0); - if (propertyFill->x() == true) { - localSize.setX(m_size.x()); + if (propertyFill.x() == true) { + localSize.setX(this.size.x()); tmpTextOrigin.setX(0); } - if (propertyFill->y() == true) { - localSize.setY(m_size.y()); - tmpTextOrigin.setY(m_size.y() - 2*paddingSize - curentTextSize.y()); + if (propertyFill.y() == true) { + localSize.setY(this.size.y()); + tmpTextOrigin.setY(this.size.y() - 2*paddingSize - curentTextSize.y()); } tmpTextOrigin += Vector3f(paddingSize, paddingSize, 0); localSize -= Vector2f(2*paddingSize,2*paddingSize); - tmpTextOrigin.setY( tmpTextOrigin.y() + (m_minSize.y()-2*paddingSize) - minSize.y()); + tmpTextOrigin.setY( tmpTextOrigin.y() + (this.minSize.y()-2*paddingSize) - minSize.y()); Vector2f textPos(tmpTextOrigin.x(), tmpTextOrigin.y()); Vector3f drawClippingPos(paddingSize, paddingSize, -0.5); - Vector3f drawClippingSize((m_size.x() - paddingSize), - (m_size.y() - paddingSize), + Vector3f drawClippingSize((this.size.x() - paddingSize), + (this.size.y() - paddingSize), 1); // clean the element - m_text.reset(); + this.text.reset(); if (propertyFontSize.get() != 0) { - m_text.setFontSize(propertyFontSize.get()); + this.text.setFontSize(propertyFontSize.get()); } - if (m_colorProperty != null) { - m_text.setDefaultColorFg(m_colorProperty->get(m_colorDefaultFgText)); - m_text.setDefaultColorBg(m_colorProperty->get(m_colorDefaultBgText)); + if (this.colorProperty != null) { + this.text.setDefaultColorFg(this.colorProperty.get(this.colorDefaultFgText)); + this.text.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText)); } - m_text.setPos(tmpTextOrigin); - Log.verbose("[" << getId() << "] {" << m_value << "} display at pos : " << tmpTextOrigin); - m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignLeft); - m_text.setClipping(drawClippingPos, drawClippingSize); - m_text.printDecorated(m_value); + this.text.setPos(tmpTextOrigin); + Log.verbose("[" + getId() + "] {" + this.value + "} display at pos : " + tmpTextOrigin); + this.text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignLeft); + this.text.setClipping(drawClippingPos, drawClippingSize); + this.text.printDecorated(this.value); } -bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::Label::onEventInput( ewol::event::Input _event) { //Log.debug("Event on Label ..."); if (_event.getId() == 1) { - if (gale::key::status::pressSingle == _event.getStatus()) { + if (KeyStatus::pressSingle == _event.getStatus()) { // nothing to do ... signalPressed.emit(); return true; @@ -145,22 +145,22 @@ bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) { return false; } -bool ewol::widget::Label::loadXML(const exml::Element& _node) { +boolean ewol::widget::Label::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // get internal data : - Log.debug("Load label:" << _node.getText()); + Log.debug("Load label:" + _node.getText()); propertyValue.set(_node.getText()); return true; } void ewol::widget::Label::onChangePropertyValue() { if (*propertyAutoTranslate == true) { - m_value = etk::toUString(etranslate::get(*propertyValue)); + this.value = etk::toUString(etranslate::get(*propertyValue)); } else { - m_value = etk::toUString(*propertyValue); + this.value = etk::toUString(*propertyValue); } markToRedraw(); requestUpdateSize(); diff --git a/src/org/atriasoft/ewol/widget/Label.java b/src/org/atriasoft/ewol/widget/Label.java index e1a2505..ed4e6da 100644 --- a/src/org/atriasoft/ewol/widget/Label.java +++ b/src/org/atriasoft/ewol/widget/Label.java @@ -16,48 +16,48 @@ namespace ewol { namespace widget { class Label; - using LabelShared = ememory::SharedPtr; + using Label = ememory::Ptr; using LabelWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class Label : public ewol::Widget { + class Label : public Widget { public: // signals esignal::Signal<> signalPressed; public: // properties eproperty::Value propertyAutoTranslate; //!< if at true the data is translate automaticaly translate. - eproperty::Value propertyValue; //!< decorated text to display. - eproperty::Value propertyFontSize; //!< default size of the font. + eproperty::Value propertyValue; //!< decorated text to display. + eproperty::Value propertyFontSize; //!< default size of the font. private: - ewol::compositing::Text m_text; //!< Compositing text element. - etk::UString m_value; - ememory::SharedPtr m_colorProperty; //!< theme color property - int32_t m_colorDefaultFgText; //!< Default color of the text - int32_t m_colorDefaultBgText; //!< Default Background color of the text + ewol::compositing::Text this.text; //!< Compositing text element. + etk::UString this.value; + ememory::Ptr this.colorProperty; //!< theme color property + int this.colorDefaultFgText; //!< Default color of the text + int this.colorDefaultBgText; //!< Default Background color of the text protected: /** * @brief Constructor * @param[in] _newLabel The displayed decorated text. */ Label(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(Label, "Label"); /** * @brief destructor */ - virtual ~Label(); + ~Label(); protected: - void onDraw() override; + void onDraw() ; public: - void calculateMinMaxSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - bool loadXML(const exml::Element& _node) override; + void calculateMinMaxSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + boolean loadXML( exml::Element _node) ; protected: - virtual void onChangePropertyValue(); - virtual void onChangePropertyAutoTranslate(); - virtual void onChangePropertyFontSize(); + void onChangePropertyValue(); + void onChangePropertyAutoTranslate(); + void onChangePropertyFontSize(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Layer.cpp b/src/org/atriasoft/ewol/widget/Layer.cpp index 03df151..ba40b28 100644 --- a/src/org/atriasoft/ewol/widget/Layer.cpp +++ b/src/org/atriasoft/ewol/widget/Layer.cpp @@ -15,23 +15,23 @@ ewol::widget::Layer::Layer() { } ewol::widget::Layer::~Layer() { - Log.debug("[" << getId() << "] Layer : destroy"); + Log.debug("[" + getId() + "] Layer : destroy"); } -ewol::WidgetShared ewol::widget::Layer::getWidgetAtPos(const Vector2f& _pos) { +Widget ewol::widget::Layer::getWidgetAtPos( Vector2f _pos) { if (*propertyHide == true) { return null; } // for all element in the sizer ... - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - Vector2f tmpSize = it->getSize(); - Vector2f tmpOrigin = it->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - ewol::WidgetShared tmpWidget = it->getWidgetAtPos(_pos); + Vector2f tmpSize = it.getSize(); + Vector2f tmpOrigin = it.getOrigin(); + if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x()) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { + Widget tmpWidget = it.getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } diff --git a/src/org/atriasoft/ewol/widget/Layer.java b/src/org/atriasoft/ewol/widget/Layer.java index c137306..c3989f1 100644 --- a/src/org/atriasoft/ewol/widget/Layer.java +++ b/src/org/atriasoft/ewol/widget/Layer.java @@ -13,7 +13,7 @@ namespace ewol { namespace widget { class Layer; - using LayerShared = ememory::SharedPtr; + using Layer = ememory::Ptr; using LayerWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -29,9 +29,9 @@ namespace ewol { /** * @brief Desstructor */ - virtual ~Layer(); + ~Layer(); public: - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; + Widget getWidgetAtPos( Vector2f _pos) ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/List.cpp b/src/org/atriasoft/ewol/widget/List.cpp index 1635fe2..f6653b7 100644 --- a/src/org/atriasoft/ewol/widget/List.cpp +++ b/src/org/atriasoft/ewol/widget/List.cpp @@ -15,89 +15,89 @@ ETK_DECLARE_TYPE(ewol::widget::List); ewol::widget::List::List() { addObjectType("ewol::widget::List"); - m_paddingSizeX = 2; + this.paddingSizeX = 2; #ifdef __TARGET_OS__Android - m_paddingSizeY = 10; + this.paddingSizeY = 10; #else - m_paddingSizeY = 2; + this.paddingSizeY = 2; #endif - m_nbVisibleRaw = 0; + this.nbVisibleRaw = 0; propertyCanFocus.setDirectCheck(true); - m_limitScrolling = Vector2f(1, 0.5); + this.limitScrolling = Vector2f(1, 0.5); } void ewol::widget::List::init() { ewol::widget::WidgetScrolled::init(); - addComposeElemnent("drawing", ememory::makeShared()); - addComposeElemnent("text", ememory::makeShared()); + addComposeElemnent("drawing", ememory::make()); + addComposeElemnent("text", ememory::make()); } ewol::widget::List::~List() { } -void ewol::widget::List::addComposeElemnent(const etk::String& _name, const ememory::SharedPtr& _element) { - m_compositingElements.set(_name, _element); - m_listOObject.pushBack(_element); +void ewol::widget::List::addComposeElemnent( String _name, ememory::Ptr _element) { + this.compositingElements.set(_name, _element); + this.listOObject.pushBack(_element); } void ewol::widget::List::clearComposeElemnent() { - for (auto &it: m_compositingElements) { - it.second->clear(); + for (auto it: this.compositingElements) { + it.second.clear(); } } void ewol::widget::List::removeComposeElemnent() { - m_compositingElements.clear(); + this.compositingElements.clear(); } -ememory::SharedPtr ewol::widget::List::getComposeElemnent(const etk::String& _name) { - return m_compositingElements[_name]; +ememory::Ptr ewol::widget::List::getComposeElemnent( String _name) { + return this.compositingElements[_name]; } /* -void ewol::widget::List::setRawVisible(int32_t _id) { - Log.debug("Set Raw visible : " << _id); +void ewol::widget::List::setRawVisible(int _id) { + Log.debug("Set Raw visible : " + _id); if (_id<0) { return; } - if (_id == m_displayStartRaw) { + if (_id == this.displayStartRaw) { // nothing to do ... return; } - if (_id < m_displayStartRaw) { - m_displayStartRaw = _id-2; + if (_id < this.displayStartRaw) { + this.displayStartRaw = _id-2; } else { - if (m_displayStartRaw + m_nbVisibleRaw < _id) { - m_displayStartRaw = _id - m_nbVisibleRaw + 2; + if (this.displayStartRaw + this.nbVisibleRaw < _id) { + this.displayStartRaw = _id - this.nbVisibleRaw + 2; } } Vector2i matrixSize = getMatrixSize(); - if (m_displayStartRaw > matrixSize.y()) { - m_displayStartRaw = matrixSize.y()-2; + if (this.displayStartRaw > matrixSize.y()) { + this.displayStartRaw = matrixSize.y()-2; } - if (m_displayStartRaw<0) { - m_displayStartRaw = 0; + if (this.displayStartRaw<0) { + this.displayStartRaw = 0; } - Log.debug("Set start raw : " << m_displayStartRaw); + Log.debug("Set start raw : " + this.displayStartRaw); markToRedraw(); } */ void ewol::widget::List::calculateMinMaxSize() { - /*int32_t fontId = getDefaultFontId(); - int32_t minWidth = ewol::getWidth(fontId, m_label); - int32_t minHeight = ewol::getHeight(fontId); - m_minSize.x = 3+minWidth; - m_minSize.y = 3+minHeight; + /*int fontId = getDefaultFontId(); + int minWidth = ewol::getWidth(fontId, this.label); + int minHeight = ewol::getHeight(fontId); + this.minSize.x = 3+minWidth; + this.minSize.y = 3+minHeight; */ - m_minSize.setValue(200, 150); + this.minSize.setValue(200, 150); } void ewol::widget::List::onDraw() { - for (size_t iii=0; iiidraw(); + for (int iii=0; iii m_listSizeX[xxx]) { - m_listSizeX[xxx] = elementSize.x(); + if (elementSize.x() > this.listSizeX[xxx]) { + this.listSizeX[xxx] = elementSize.x(); } - if (elementSize.y() > m_listSizeY[yyy]) { - m_listSizeY[yyy] = elementSize.y(); + if (elementSize.y() > this.listSizeY[yyy]) { + this.listSizeY[yyy] = elementSize.y(); } } } // ------------------------------------------------------- // -- Fill property applyence // ------------------------------------------------------- - if (propertyFill->x() == true) { - int32_t fullSize = 0; - for (auto &size: m_listSizeX) { + if (propertyFill.x() == true) { + int fullSize = 0; + for (auto size: this.listSizeX) { fullSize += size; } - if (fullSize < m_size.x() ) { + if (fullSize < this.size.x() ) { // need to expand all elements: - int32_t residualAdd = (m_size.x() - fullSize) / matrixSize.x(); + int residualAdd = (this.size.x() - fullSize) / matrixSize.x(); if (residualAdd != 0) { - for (auto &size: m_listSizeX) { + for (auto size: this.listSizeX) { size += residualAdd; } } } } /* - if (propertyFill->y() == true) { - int32_t fullSize = 0; - for (auto &size: m_listSizeY) { + if (propertyFill.y() == true) { + int fullSize = 0; + for (auto size: this.listSizeY) { fullSize += size; } - if (fullSize < m_size.y() ) { + if (fullSize < this.size.y() ) { // need to expand all elements: - int32_t residualAdd = (m_size.y() - fullSize) / matrixSize.y(); + int residualAdd = (this.size.y() - fullSize) / matrixSize.y(); if (residualAdd != 0) { - for (auto &size: m_listSizeY) { + for (auto size: this.listSizeY) { size += residualAdd; } } @@ -165,22 +165,22 @@ void ewol::widget::List::onRegenerateDisplay() { // ------------------------------------------------------- // -- Calculate the start position size of each element // ------------------------------------------------------- - List listStartPosX; - List listStartPosY; - int32_t lastPositionX = 0; - for (auto &size: m_listSizeX) { + List listStartPosX; + List listStartPosY; + int lastPositionX = 0; + for (auto size: this.listSizeX) { listStartPosX.pushBack(lastPositionX); lastPositionX += size; } - int32_t lastPositionY = 0; - for (auto &size: m_listSizeY) { + int lastPositionY = 0; + for (auto size: this.listSizeY) { lastPositionY += size; listStartPosY.pushBack(lastPositionY); } // ------------------------------------------------------- // -- Update the scroolBar // ------------------------------------------------------- - m_maxSize = Vector2i(lastPositionX, lastPositionY); + this.maxSize = Vector2i(lastPositionX, lastPositionY); // ------------------------------------------------------- // -- Clean the background // ------------------------------------------------------- @@ -189,29 +189,29 @@ void ewol::widget::List::onRegenerateDisplay() { // -- Draw each element // ------------------------------------------------------- for (int_t yyy=0; yyy element out of range ==> nothing to display break; } - if (startYposition > m_size.y()) { + if (startYposition > this.size.y()) { // ==> element out of range ==> nothing to display continue; } for (int_t xxx=0; xxx element out of range ==> nothing to display continue; } - if (startXposition > m_size.x()) { + if (startXposition > this.size.x()) { // ==> element out of range ==> nothing to display break; } drawElement(Vector2i(xxx, yyy), Vector2f(startXposition, startYposition), - Vector2f(m_listSizeX[xxx], m_listSizeY[yyy])); + Vector2f(this.listSizeX[xxx], this.listSizeY[yyy])); } } // ------------------------------------------------------- @@ -221,17 +221,17 @@ void ewol::widget::List::onRegenerateDisplay() { } } -Vector2i ewol::widget::List::getMatrixSize() const { +Vector2i ewol::widget::List::getMatrixSize() { return Vector2i(1,0); } -Vector2f ewol::widget::List::calculateElementSize(const Vector2i& _pos) { +Vector2f ewol::widget::List::calculateElementSize( Vector2i _pos) { auto tmpText = ememory::staticPointerCast(getComposeElemnent("text")); - etk::String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); - Vector3f textSize = tmpText->calculateSize(myTextToWrite); + String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); + Vector3f textSize = tmpText.calculateSize(myTextToWrite); Vector2i count = getMatrixSize(); return Vector2f(textSize.x(), - textSize.y() + m_paddingSizeY*3 + textSize.y() + this.paddingSizeY*3 ); } @@ -239,86 +239,86 @@ void ewol::widget::List::drawBackground() { auto BGOObjects = ememory::staticPointerCast(getComposeElemnent("drawing")); if (BGOObjects != null) { etk::Color<> basicBG = getBasicBG(); - BGOObjects->setColor(basicBG); - BGOObjects->setPos(Vector3f(0, 0, 0) ); - BGOObjects->rectangleWidth(m_size); + BGOObjects.setColor(basicBG); + BGOObjects.setPos(Vector3f(0, 0, 0) ); + BGOObjects.rectangleWidth(this.size); } } -void ewol::widget::List::drawElement(const Vector2i& _pos, const Vector2f& _start, const Vector2f& _size) { - etk::String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); +void ewol::widget::List::drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) { + String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); etk::Color<> fg = getData(ListRole::FgColor, _pos).getSafeColor(); auto backgroundVariant = getData(ListRole::BgColor, _pos); if (backgroundVariant.isColor() == true) { etk::Color<> bg = backgroundVariant.getColor(); auto BGOObjects = ememory::staticPointerCast(getComposeElemnent("drawing")); if (BGOObjects != null) { - BGOObjects->setColor(bg); - BGOObjects->setPos(Vector3f(_start.x(), _start.y(), 0) ); - BGOObjects->rectangleWidth(_size); + BGOObjects.setColor(bg); + BGOObjects.setPos(Vector3f(_start.x(), _start.y(), 0) ); + BGOObjects.rectangleWidth(_size); } } if (myTextToWrite != "") { auto tmpText = ememory::staticPointerCast(getComposeElemnent("text")); if (tmpText != null) { - int32_t displayPositionY = _start.y() + m_paddingSizeY; - tmpText->setColor(fg); - tmpText->setPos(Vector3f(_start.x() + m_paddingSizeX, displayPositionY, 0) ); - tmpText->print(myTextToWrite);; + int displayPositionY = _start.y() + this.paddingSizeY; + tmpText.setColor(fg); + tmpText.setPos(Vector3f(_start.x() + this.paddingSizeX, displayPositionY, 0) ); + tmpText.print(myTextToWrite);; } } } -bool ewol::widget::List::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::List::onEventInput( ewol::event::Input _event) { Vector2f relativePos = relativePosition(_event.getPos()); if (WidgetScrolled::onEventInput(_event) == true) { keepFocus(); // nothing to do ... done on upper widet ... return true; } - if (m_listSizeY.size() == 0) { + if (this.listSizeY.size() == 0) { return false; } - relativePos = Vector2f(relativePos.x(),m_size.y() - relativePos.y()) + m_originScrooled; + relativePos = Vector2f(relativePos.x(),this.size.y() - relativePos.y()) + this.originScrooled; // Find the colomn and the row Vector2i pos{0,0}; float_t offsetY = 0; - for (size_t iii=0; iii= previous ) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.y() >= previous ) { pos.setY(iii); offsetY = previous; break; } - if ( iii == m_listSizeY.size()-2 - && relativePos.y() >= offsetY ) { + if ( iii == this.listSizeY.size()-2 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.y() >= offsetY ) { pos.setY(iii+1); break; } } float_t offsetX = 0; - for (size_t iii=0; iii= previous ) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.x() >= previous ) { pos.setX(iii); offsetX = previous; break; } - if ( iii == m_listSizeX.size()-2 - && relativePos.x() >= offsetX ) { + if ( iii == this.listSizeX.size()-2 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.x() >= offsetX ) { pos.setX(iii+1); break; } } Vector2f posInternalMouse = relativePos - Vector2f(offsetX, offsetY); - bool isUsed = onItemEvent(_event, pos, posInternalMouse); + boolean isUsed = onItemEvent(_event, pos, posInternalMouse); if (isUsed == true) { // TODO : this generate bugs ... I did not understand why .. - //ewol::WidgetSharedManager::focusKeep(this); + //WidgetManager::focusKeep(this); } return isUsed; } diff --git a/src/org/atriasoft/ewol/widget/List.java b/src/org/atriasoft/ewol/widget/List.java index f7812d9..b593212 100644 --- a/src/org/atriasoft/ewol/widget/List.java +++ b/src/org/atriasoft/ewol/widget/List.java @@ -15,7 +15,7 @@ namespace ewol { namespace widget { class List; - using ListShared = ememory::SharedPtr; + using List = ememory::Ptr; using ListWeak = ememory::WeakPtr; enum ListRole { @@ -39,33 +39,33 @@ namespace ewol { class List : public ewol::widget::WidgetScrolled { protected: List(); - void init() override; + void init() ; public: - virtual ~List(); - void calculateMinMaxSize() override; + ~List(); + void calculateMinMaxSize() ; // drawing capabilities .... protected: - List> m_listOObject; //!< generic element to display... - List m_listSizeX; //!< size of every colomns - List m_listSizeY; //!< size of every rows + List> this.listOObject; //!< generic element to display... + List this.listSizeX; //!< size of every colomns + List this.listSizeY; //!< size of every rows protected: - etk::Map> m_compositingElements; - void addComposeElemnent(const etk::String& _name, const ememory::SharedPtr& _element); + etk::Map> this.compositingElements; + void addComposeElemnent( String _name, ememory::Ptr _element); void clearComposeElemnent(); void removeComposeElemnent(); - ememory::SharedPtr getComposeElemnent(const etk::String& _name); + ememory::Ptr getComposeElemnent( String _name); public: void clearOObjectList(); // list properties ... protected: - int32_t m_paddingSizeX; - int32_t m_paddingSizeY; - int32_t m_displayStartRaw; //!< Current starting diaplayed raw - int32_t m_displayCurrentNbLine; //!< Number of line in the display - int32_t m_nbVisibleRaw; // set the number of visible raw (calculate don display) + int this.paddingSizeX; + int this.paddingSizeY; + int this.displayStartRaw; //!< Current starting diaplayed raw + int this.displayCurrentNbLine; //!< Number of line in the display + int this.nbVisibleRaw; // set the number of visible raw (calculate don display) protected: // function call to display the list : - virtual etk::Color<> getBasicBG() { + etk::Color<> getBasicBG() { return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF); } @@ -73,9 +73,9 @@ namespace ewol { * @brief Get the number of colomn and row availlable in the list * @return Number of colomn and row */ - virtual Vector2i getMatrixSize() const; + Vector2i getMatrixSize() ; - virtual fluorine::Variant getData(int32_t _role, const Vector2i& _pos) { + fluorine::Variant getData(int _role, Vector2i _pos) { switch (_role) { case ListRole::Text: return ""; @@ -95,7 +95,7 @@ namespace ewol { * @param[in] _pos Position of colomn and Raw of the element. * @return The estimate size of the element. */ - virtual Vector2f calculateElementSize(const Vector2i& _pos); + Vector2f calculateElementSize( Vector2i _pos); /** * @brief Draw an element in the specific size and position. * @param[in] _pos Position of colomn and Raw of the element. @@ -103,27 +103,27 @@ namespace ewol { * @param[in] _size Render raw size * @return The estimate size of the element. */ - virtual void drawElement(const Vector2i& _pos, const Vector2f& _start, const Vector2f& _size); + void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size); /** * @brief Draw the background */ - virtual void drawBackground(); + void drawBackground(); - virtual bool onItemEvent(const ewol::event::Input& _event, const Vector2i& _pos, const Vector2f& _mousePosition) { + boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) { return false; } /** * @brief set a raw visible in the main display * @param[in] _id Id of the raw that might be visible. */ - //void setRawVisible(int32_t _id); + //void setRawVisible(int _id); protected: - void onGetFocus() override; - void onLostFocus() override; - void onDraw() override; + void onGetFocus() ; + void onLostFocus() ; + void onDraw() ; public: - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/ListFileSystem.cpp b/src/org/atriasoft/ewol/widget/ListFileSystem.cpp index 959fcd0..23447c2 100644 --- a/src/org/atriasoft/ewol/widget/ListFileSystem.cpp +++ b/src/org/atriasoft/ewol/widget/ListFileSystem.cpp @@ -19,38 +19,38 @@ ewol::widget::ListFileSystem::ListFileSystem() : propertyPath(this, "path", etk::Path("/"), "Path to display", - &ewol::widget::ListFileSystem::onChangePropertyPath), + ewol::widget::ListFileSystem::onChangePropertyPath), propertyFile(this, "select", etk::Path(), "selection af a specific file", - &ewol::widget::ListFileSystem::onChangePropertyFile), + ewol::widget::ListFileSystem::onChangePropertyFile), propertyShowFile(this, "show-file", true, "display files", - &ewol::widget::ListFileSystem::onChangePropertyShowFile), + ewol::widget::ListFileSystem::onChangePropertyShowFile), propertyShowFolder(this, "show-folder", true, "display folders", - &ewol::widget::ListFileSystem::onChangePropertyShowFolder), + ewol::widget::ListFileSystem::onChangePropertyShowFolder), propertyShowHidden(this, "show-hidden", true, "Show the hidden element (file, folder, ...)", - &ewol::widget::ListFileSystem::onChangePropertyShowHidden), + ewol::widget::ListFileSystem::onChangePropertyShowHidden), propertyFilter(this, "filter", "", "regex to filter files ...", - &ewol::widget::ListFileSystem::onChangePropertyFilter), - m_selectedLine(-1) { + ewol::widget::ListFileSystem::onChangePropertyFilter), + this.selectedLine(-1) { addObjectType("ewol::widget::ListFileSystem"); #if defined(__TARGET_OS__Windows) propertyPath.setDirectCheck("c:/"); #endif - m_colorProperty = ewol::resource::ColorFile::create("THEME_COLOR:///ListFileSystem.json?lib=ewol"); - if (m_colorProperty != null) { - m_colorIdText = m_colorProperty->request("text"); - m_colorIdBackground1 = m_colorProperty->request("background1"); - m_colorIdBackground2 = m_colorProperty->request("background2"); - m_colorIdBackgroundSelected = m_colorProperty->request("selected"); + this.colorProperty = ewol::resource::ColorFile::create("THEME_COLOR:///ListFileSystem.json?lib=ewol"); + if (this.colorProperty != null) { + this.colorIdText = this.colorProperty.request("text"); + this.colorIdBackground1 = this.colorProperty.request("background1"); + this.colorIdBackground2 = this.colorProperty.request("background2"); + this.colorIdBackgroundSelected = this.colorProperty.request("selected"); } setMouseLimit(2); } @@ -60,23 +60,23 @@ ewol::widget::ListFileSystem::~ListFileSystem() { } void ewol::widget::ListFileSystem::clearList() { - m_list.clear(); + this.list.clear(); } etk::Color<> ewol::widget::ListFileSystem::getBasicBG() { - return m_colorProperty->get(m_colorIdBackground1); + return this.colorProperty.get(this.colorIdBackground1); } -static bool localSort(const etk::Path& _left, const etk::Path& _right) { +static boolean localSort( etk::Path _left, etk::Path _right) { return _left.getString().toUpper() <= _right.getString().toUpper(); } void ewol::widget::ListFileSystem::regenerateView() { clearList(); - m_selectedLine = -1; - m_list.clear(); - m_originScrooled.setValue(0,0); - uint32_t flags = 0; + this.selectedLine = -1; + this.list.clear(); + this.originScrooled.setValue(0,0); + uint flags = 0; if (*propertyShowHidden == true) { flags |= etk::path::LIST_HIDDEN; } @@ -86,39 +86,39 @@ void ewol::widget::ListFileSystem::regenerateView() { if (*propertyShowFile == true) { flags |= etk::path::LIST_FILE; } - m_list = etk::path::list(*propertyPath, flags); - Log.error("Lsit of element: " << m_list.size() ); + this.list = etk::path::list(*propertyPath, flags); + Log.error("Lsit of element: " + this.list.size() ); // Sort the list: - etk::algorithm::quickSort(m_list, localSort); + etk::algorithm::quickSort(this.list, localSort); // request a redraw ... markToRedraw(); } -etk::Path ewol::widget::ListFileSystem::getSelect() const { - etk::String tmpVal = ""; - if (m_selectedLine >= 0) { - tmpVal = m_list[m_selectedLine].getFileName(); +etk::Path ewol::widget::ListFileSystem::getSelect() { + String tmpVal = ""; + if (this.selectedLine >= 0) { + tmpVal = this.list[this.selectedLine].getFileName(); } return tmpVal; } // select the specific file -void ewol::widget::ListFileSystem::setSelect(const etk::Path& _data) { +void ewol::widget::ListFileSystem::setSelect( etk::Path _data) { // remove selected line - m_selectedLine = -1; + this.selectedLine = -1; // search the coresponding file : - for (size_t iii=0; iii= 0 - && _pos.y()-offset < (int32_t)m_list.size()) { - Log.verbose("get filename for : '" << m_list[_pos.y()-offset] << ":'" << m_list[_pos.y()-offset].getFileName() << "'"); - return m_list[_pos.y()-offset].getFileName(); + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _pos.y()-offset < (int)this.list.size()) { + Log.verbose("get filename for : '" + this.list[_pos.y()-offset] + ":'" + this.list[_pos.y()-offset].getFileName() + "'"); + return this.list[_pos.y()-offset].getFileName(); } } - return "<<>>"; + return "+>>"; case ListRole::FgColor: - return m_colorProperty->get(m_colorIdText); + return this.colorProperty.get(this.colorIdText); case ListRole::BgColor: - if (m_selectedLine == _pos.y()) { - return m_colorProperty->get(m_colorIdBackgroundSelected); + if (this.selectedLine == _pos.y()) { + return this.colorProperty.get(this.colorIdBackgroundSelected); } if (_pos.y() % 2) { - return m_colorProperty->get(m_colorIdBackground1); + return this.colorProperty.get(this.colorIdBackground1); } - return m_colorProperty->get(m_colorIdBackground2); + return this.colorProperty.get(this.colorIdBackground2); } return fluorine::Variant(); } -bool ewol::widget::ListFileSystem::onItemEvent(const ewol::event::Input& _event, - const Vector2i& _pos, - const Vector2f& _mousePosition) { - int32_t offset = 0; +boolean ewol::widget::ListFileSystem::onItemEvent( ewol::event::Input _event, + Vector2i _pos, + Vector2f _mousePosition) { + int offset = 0; if (*propertyShowFolder == true) { if (*propertyPath == "/") { offset = 1; @@ -179,45 +179,45 @@ bool ewol::widget::ListFileSystem::onItemEvent(const ewol::event::Input& _event, offset = 2; } } - if ( _event.getStatus() == gale::key::status::pressSingle - || _event.getStatus() == gale::key::status::pressDouble) { - Log.verbose("Event on List : IdInput=" << _event.getId() << " _pos=" << _pos ); + if ( _event.getStatus() == KeyStatus::pressSingle + || _event.getStatus() == KeyStatus::pressDouble) { + Log.verbose("Event on List : IdInput=" + _event.getId() + " _pos=" + _pos ); if (1 == _event.getId()) { - if (_pos.y() > (int32_t)m_list.size()+offset ) { - m_selectedLine = -1; + if (_pos.y() > (int)this.list.size()+offset ) { + this.selectedLine = -1; } else { - m_selectedLine = _pos.y(); + this.selectedLine = _pos.y(); } if( *propertyShowFolder == true - && m_selectedLine == 0) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.selectedLine == 0) { // "." folder - if (_event.getStatus() == gale::key::status::pressSingle) { + if (_event.getStatus() == KeyStatus::pressSingle) { signalFolderSelect.emit(*propertyPath); } else { signalFolderValidate.emit(*propertyPath); } } else if ( *propertyShowFolder == true - && m_selectedLine == 1) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.selectedLine == 1) { // ".." folder - if (_event.getStatus() == gale::key::status::pressSingle) { - signalFolderSelect.emit(propertyPath->getParent()); + if (_event.getStatus() == KeyStatus::pressSingle) { + signalFolderSelect.emit(propertyPath.getParent()); } else { - signalFolderValidate.emit(propertyPath->getParent()); + signalFolderValidate.emit(propertyPath.getParent()); } - } else if( m_selectedLine-offset >= 0 - && m_selectedLine-offset < (int32_t)m_list.size() ) { + } else if( this.selectedLine-offset >= 0 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.selectedLine-offset < (int)this.list.size() ) { // generate event extern: - if(etk::path::isDirectory(m_list[m_selectedLine-offset])) { - if (_event.getStatus() == gale::key::status::pressSingle) { - signalFolderSelect.emit(m_list[m_selectedLine-offset]); + if(etk::path::isDirectory(this.list[this.selectedLine-offset])) { + if (_event.getStatus() == KeyStatus::pressSingle) { + signalFolderSelect.emit(this.list[this.selectedLine-offset]); } else { - signalFolderValidate.emit(m_list[m_selectedLine-offset]); + signalFolderValidate.emit(this.list[this.selectedLine-offset]); } } else { - if (_event.getStatus() == gale::key::status::pressSingle) { - signalFileSelect.emit(m_list[m_selectedLine-offset]); + if (_event.getStatus() == KeyStatus::pressSingle) { + signalFileSelect.emit(this.list[this.selectedLine-offset]); } else { - signalFileValidate.emit(m_list[m_selectedLine-offset]); + signalFileValidate.emit(this.list[this.selectedLine-offset]); } } } @@ -230,7 +230,7 @@ bool ewol::widget::ListFileSystem::onItemEvent(const ewol::event::Input& _event, } void ewol::widget::ListFileSystem::onChangePropertyPath() { - EWOL_WARNING("Change Path: " << *propertyPath << " selected File=" << *propertyFile);; + Log.warning("Change Path: " + *propertyPath + " selected File=" + *propertyFile);; regenerateView(); } diff --git a/src/org/atriasoft/ewol/widget/ListFileSystem.java b/src/org/atriasoft/ewol/widget/ListFileSystem.java index 03d21bb..1a9ea86 100644 --- a/src/org/atriasoft/ewol/widget/ListFileSystem.java +++ b/src/org/atriasoft/ewol/widget/ListFileSystem.java @@ -12,7 +12,7 @@ namespace ewol { namespace widget { class ListFileSystem; - using ListFileSystemShared = ememory::SharedPtr; + using ListFileSystem = ememory::Ptr; using ListFileSystemWeak = ememory::WeakPtr; /** * @brief Generic display folder class. This widget display the content of a single folder : @@ -29,25 +29,25 @@ namespace ewol { eproperty::Value propertyShowFile; //!< Show files elements eproperty::Value propertyShowFolder; //!< Display the folders elements eproperty::Value propertyShowHidden; //!< Display hidden elements - eproperty::Value propertyFilter; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e") + eproperty::Value propertyFilter; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e") protected: ListFileSystem(); public: DECLARE_WIDGET_FACTORY(ListFileSystem, "ListFileSystem"); - virtual ~ListFileSystem(); + ~ListFileSystem(); protected: - ememory::SharedPtr m_colorProperty; //!< theme color property. - int32_t m_colorIdText; //!< Color of the text. - int32_t m_colorIdBackground1; //!< Color of the Background. - int32_t m_colorIdBackground2; //!< Color of the Background 2. - int32_t m_colorIdBackgroundSelected; //!< Color of line selected. + ememory::Ptr this.colorProperty; //!< theme color property. + int this.colorIdText; //!< Color of the text. + int this.colorIdBackground1; //!< Color of the Background. + int this.colorIdBackground2; //!< Color of the Background 2. + int this.colorIdBackgroundSelected; //!< Color of line selected. protected: - etk::Color<> getBasicBG() override; - Vector2i getMatrixSize() const override; - fluorine::Variant getData(int32_t _role, const Vector2i& _pos) override; - bool onItemEvent(const ewol::event::Input& _event, const Vector2i& _pos, const Vector2f& _mousePosition) override; + etk::Color<> getBasicBG() ; + Vector2i getMatrixSize() ; + fluorine::Variant getData(int _role, Vector2i _pos) ; + boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ; protected: - List m_list; //!< List of all element in the path. (they are filtered) + List this.list; //!< List of all element in the path. (they are filtered) /** * @brief Clean the list of element. */ @@ -55,27 +55,27 @@ namespace ewol { /** * @brief Regenerate the content of the view. this is actually not automation on the system update. */ - virtual void regenerateView(); + void regenerateView(); protected: - int32_t m_selectedLine; //!< Current Line ID that is selected + int this.selectedLine; //!< Current Line ID that is selected public: /** * @brief Select a specific file in the path * @param[in] _data File to selested. */ - virtual void setSelect(const etk::Path& _data); + void setSelect( etk::Path _data); /** * @brief Get the current selected file/folder/... in the list * @return the String of the element selected. */ - etk::Path getSelect() const ; + etk::Path getSelect() ; protected: - virtual void onChangePropertyPath(); - virtual void onChangePropertyFile(); - virtual void onChangePropertyShowFile(); - virtual void onChangePropertyShowFolder(); - virtual void onChangePropertyShowHidden(); - virtual void onChangePropertyFilter(); + void onChangePropertyPath(); + void onChangePropertyFile(); + void onChangePropertyShowFile(); + void onChangePropertyShowFolder(); + void onChangePropertyShowHidden(); + void onChangePropertyFilter(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Manager.cpp b/src/org/atriasoft/ewol/widget/Manager.cpp deleted file mode 100644 index f9da32b..0000000 --- a/src/org/atriasoft/ewol/widget/Manager.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -ETK_DECLARE_TYPE(ewol::widget::Manager); - -ewol::widget::Manager::Manager() : - m_creatorList(0, false), - m_creatorListXml(0, false), - m_haveRedraw(true) { - Log.debug(" == > init Widget-Manager"); - - ewol::widget::Button::createManagerWidget(*this); - ewol::widget::ButtonColor::createManagerWidget(*this); - ewol::widget::Spacer::createManagerWidget(*this); - ewol::widget::Slider::createManagerWidget(*this); - ewol::widget::Sizer::createManagerWidget(*this); - ewol::widget::ProgressBar::createManagerWidget(*this); - ewol::widget::Layer::createManagerWidget(*this); - ewol::widget::Label::createManagerWidget(*this); - ewol::widget::Image::createManagerWidget(*this); - ewol::widget::Gird::createManagerWidget(*this); - ewol::widget::Entry::createManagerWidget(*this); - ewol::widget::Menu::createManagerWidget(*this); - ewol::widget::CheckBox::createManagerWidget(*this); - ewol::widget::Scroll::createManagerWidget(*this); - ewol::widget::ContextMenu::createManagerWidget(*this); - ewol::widget::PopUp::createManagerWidget(*this); - ewol::widget::WSlider::createManagerWidget(*this); - ewol::widget::ListFileSystem::createManagerWidget(*this); - ewol::widget::Composer::createManagerWidget(*this); - ewol::widget::Select::createManagerWidget(*this); - ewol::widget::Spin::createManagerWidget(*this); -} - -ewol::widget::Manager::~Manager() { - Log.debug(" == > Un-Init Widget-Manager"); - Log.info("Realease all FOCUS"); - focusSetDefault(null); - focusRelease(); - - m_creatorList.clear(); -} - -/* ************************************************************************* - * focus Area : - * *************************************************************************/ - -void ewol::widget::Manager::focusKeep(ewol::WidgetShared _newWidget) { - if (_newWidget == null) { - // nothing to do ... - return; - } - Log.debug("focusKeep=" << _newWidget->getId() ); - //elog::displayBacktrace(); - auto focusWidgetCurrent = m_focusWidgetCurrent.lock(); - if (_newWidget == focusWidgetCurrent) { - // nothing to do ... - return; - } - if (focusWidgetCurrent != null) { - Log.debug("Rm focus on WidgetID=" << focusWidgetCurrent->getId() ); - focusWidgetCurrent->rmFocus(); - focusWidgetCurrent.reset(); - } - if (_newWidget->propertyCanFocus.get() == false) { - Log.debug("Widget can not have focus, id=" << _newWidget->getId() ); - return; - } - m_focusWidgetCurrent = _newWidget; - if (_newWidget != null) { - Log.debug("Set focus on WidgetID=" << _newWidget->getId() ); - _newWidget->setFocus(); - } -} - -void ewol::widget::Manager::focusSetDefault(ewol::WidgetShared _newWidget) { - if( _newWidget != null - && _newWidget->propertyCanFocus.get() == false) { - Log.verbose("Widget can not have focus, id=" << _newWidget->getId() ); - return; - } - ewol::WidgetShared focusWidgetDefault = m_focusWidgetDefault.lock(); - ewol::WidgetShared focusWidgetCurrent = m_focusWidgetCurrent.lock(); - if (focusWidgetDefault == focusWidgetCurrent) { - if (focusWidgetCurrent != null) { - Log.debug("Rm focus on WidgetID=" << focusWidgetCurrent->getId() ); - focusWidgetCurrent->rmFocus(); - } - m_focusWidgetCurrent = _newWidget; - if (_newWidget != null) { - Log.debug("Set focus on WidgetID=" << _newWidget->getId() ); - _newWidget->setFocus(); - } - } - m_focusWidgetDefault = _newWidget; -} - -void ewol::widget::Manager::focusRelease() { - ewol::WidgetShared focusWidgetDefault = m_focusWidgetDefault.lock(); - ewol::WidgetShared focusWidgetCurrent = m_focusWidgetCurrent.lock(); - if (focusWidgetDefault == focusWidgetCurrent) { - // nothink to do ... - return; - } - if (focusWidgetCurrent != null) { - Log.debug("Rm focus on WidgetID=" << focusWidgetCurrent->getId() ); - focusWidgetCurrent->rmFocus(); - } - m_focusWidgetCurrent = m_focusWidgetDefault; - focusWidgetCurrent = m_focusWidgetCurrent.lock(); - if (focusWidgetCurrent != null) { - Log.debug("Set focus on WidgetID=" << focusWidgetCurrent->getId() ); - focusWidgetCurrent->setFocus(); - } -} - -ewol::WidgetShared ewol::widget::Manager::focusGet() { - return m_focusWidgetCurrent.lock(); -} - -void ewol::widget::Manager::setCallbackonRedrawNeeded(const etk::Function& _func) { - m_funcRedrawNeeded = _func; -} - -void ewol::widget::Manager::markDrawingIsNeeded() { - if (m_haveRedraw == true) { - return; - } - m_haveRedraw = true; - if (m_funcRedrawNeeded != null) { - m_funcRedrawNeeded(); - } -} - -bool ewol::widget::Manager::isDrawingNeeded() { - bool tmp = m_haveRedraw; - m_haveRedraw = false; - return tmp; -} - -// element that generate the list of elements -void ewol::widget::Manager::addWidgetCreator(const etk::String& _name, - ewol::widget::Manager::widgetCreatorFunction _pointer, - ewol::widget::Manager::widgetCreatorFunctionXml _pointerXml) { - if ( _pointer == null - || _pointerXml == null) { - return; - } - //Keep name in lower case : - etk::String nameLower = etk::toLower(_name); - bool find = false; - { - auto it = m_creatorList.find(nameLower); - if (it != m_creatorList.end()) { - EWOL_WARNING("Replace Creator of a specify widget : " << nameLower); - it->second = _pointer; - find = true; - } - } - { - auto it = m_creatorListXml.find(nameLower); - if (it != m_creatorListXml.end()) { - EWOL_WARNING("Replace CreatorXml of a specify widget : " << nameLower); - it->second = _pointerXml; - find = true; - } - } - if (find == true) { - return; - } - Log.info("Add Creator of a specify widget : " << nameLower); - m_creatorList.set(nameLower, _pointer); - m_creatorListXml.set(nameLower, _pointerXml); -} - -ewol::WidgetShared ewol::widget::Manager::create(const etk::String& _name) { - etk::String nameLower = etk::toLower(_name); - auto it = m_creatorList.find(nameLower); - if (it != m_creatorList.end()) { - if (it->second != null) { - return it->second(); - } - } - EWOL_WARNING("try to create an UnExistant widget : " << nameLower); - return null; -} - -ewol::WidgetShared ewol::widget::Manager::create(const etk::String& _name, const exml::Element& _node) { - etk::String nameLower = etk::toLower(_name); - auto it = m_creatorListXml.find(nameLower); - if (it != m_creatorListXml.end()) { - if (it->second != null) { - return it->second(_node); - } - } - EWOL_WARNING("try to create an UnExistant widget : " << nameLower); - return null; -} - -bool ewol::widget::Manager::exist(const etk::String& _name) { - etk::String nameLower = etk::toLower(_name); - auto it = m_creatorList.find(nameLower); - if (it == m_creatorList.end()) { - return false; - } - return true; -} - -etk::String ewol::widget::Manager::list() { - etk::String tmpVal; - for (auto &it : m_creatorList) { - if (tmpVal.size() != 0) { - tmpVal += ","; - } - tmpVal += it.first; - } - return tmpVal; -} - diff --git a/src/org/atriasoft/ewol/widget/Manager.java b/src/org/atriasoft/ewol/widget/Manager.java deleted file mode 100644 index a726e47..0000000 --- a/src/org/atriasoft/ewol/widget/Manager.java +++ /dev/null @@ -1,115 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include - -namespace ewol { - namespace widget { - class Manager { - public: - Manager(); - virtual ~Manager(); - // --------------------------------------------- - // -- Focus area - // --------------------------------------------- - private: - ewol::WidgetWeak m_focusWidgetDefault; //!< default focus when no current focus is set - ewol::WidgetWeak m_focusWidgetCurrent; //!< Currect focus selected - public: - /** - * @brief Request a focus on a specify widget. - * @param[in] _newWidget Widget that might get the focus. - */ - void focusKeep(ewol::WidgetShared _newWidget); - /** - * @brief Set the default focus when none selected. - * @param[in] _newWidget Widget that might get the focus (when nothing else). - */ - void focusSetDefault(ewol::WidgetShared _newWidget); - /** - * @brief Release the current focus (back on default if possible). - */ - void focusRelease(); - /** - * @brief Get the current Focused widget. - * @return The pointer on the current focused element. - */ - ewol::WidgetShared focusGet(); - // --------------------------------------------- - // -- Factory area - // --------------------------------------------- - public: - using widgetCreatorFunction = etk::Function; //!< funtion factory basic definition - using widgetCreatorFunctionXml = etk::Function; //!< funtion factory basic definition - private: - etk::Map m_creatorList; //!< List of factory of a widget - etk::Map m_creatorListXml; //!< List of factory of a widget - public: - /** - * @brief add a factory of a specific widget. - * @param[in] _name Name of the widget that is associated of the factory. - * @param[in] _factory Function pointer to create the widget - * @param[in] _factoryXml Function pointer to create the widget with XML node for parsing of XML - */ - void addWidgetCreator(const etk::String& _name, widgetCreatorFunction _factory, widgetCreatorFunctionXml _factoryXml); - /** - * @brief Create a widget with his name. - * @param[in] _name Name of the widget to create. - * @return The widget created (null if it does not exist). - */ - ewol::WidgetShared create(const etk::String& _name); - /** - * @brief Create a widget with his name. - * @param[in] _name Name of the widget to create. - * @param[in] _node Reference on the XML node. - * @return The widget created (null if it does not exist). - */ - ewol::WidgetShared create(const etk::String& _name, const exml::Element& _node); - /** - * @brief Check if an Widget exist - * @param[in] _name Name of the widget to check. - * @return true The Widget exist. - * @return false The Widget Does NOT exist. - */ - bool exist(const etk::String& _name); - /** - * @brief Get the list of all Widget that can be created. - * @return Separate with ',' string list. - */ - etk::String list(); - // --------------------------------------------- - // -- Something change area (TODO: maybe set it in the windows) - // --------------------------------------------- - private: - bool m_haveRedraw; //!< something request a redraw - private: - etk::Function m_funcRedrawNeeded; - public: - /** - * @brief Mark the display to redraw - */ - void markDrawingIsNeeded(); - /** - * @brief Check if a redraw has been requested (set the local value back at false) - * @return true if something to be redraw - */ - bool isDrawingNeeded(); - private: - - /** - * @brief Set a callback when we need redraw the display (need by MacOs) - * @param[in] _func function to call - */ - void setCallbackonRedrawNeeded(const etk::Function& _func); - - }; - }; -}; - diff --git a/src/org/atriasoft/ewol/widget/Menu.cpp b/src/org/atriasoft/ewol/widget/Menu.cpp index 81f962d..4ba5613 100644 --- a/src/org/atriasoft/ewol/widget/Menu.cpp +++ b/src/org/atriasoft/ewol/widget/Menu.cpp @@ -19,7 +19,7 @@ ETK_DECLARE_TYPE(ewol::widget::Menu); ewol::widget::Menu::Menu() : signalSelect(this, "select", "") { addObjectType("ewol::widget::Menu"); - m_staticId = 666; + this.staticObjectId = 666; propertyLockExpand.setDirect(Vector2b(true,true)); } @@ -32,298 +32,298 @@ void ewol::widget::Menu::subWidgetRemoveAll() { ewol::widget::Sizer::subWidgetRemoveAll(); } -int32_t ewol::widget::Menu::subWidgetAdd(ewol::WidgetShared _newWidget) { +int ewol::widget::Menu::subWidgetAdd(Widget _newWidget) { Log.error("Not availlable"); return -1; } -void ewol::widget::Menu::subWidgetRemove(ewol::WidgetShared _newWidget) { +void ewol::widget::Menu::subWidgetRemove(Widget _newWidget) { Log.error("Not availlable"); } -void ewol::widget::Menu::subWidgetUnLink(ewol::WidgetShared _newWidget) { +void ewol::widget::Menu::subWidgetUnLink(Widget _newWidget) { Log.error("Not availlable"); } void ewol::widget::Menu::clear() { - m_listElement.clear(); + this.listElement.clear(); } -int32_t ewol::widget::Menu::addTitle(const etk::String& _label, - const etk::String& _image, - const etk::String& _message) { +int ewol::widget::Menu::addTitle( String _label, + String _image, + String _message) { return add(-1, _label, _image, _message); } -static const char* eventButtonPressed = "menu-local-pressed"; +static char* eventButtonPressed = "menu-local-pressed"; -int32_t ewol::widget::Menu::get(const etk::String& _label) { - for (auto &it : m_listElement) { - if (it.m_label == _label) { - return it.m_localId; +int ewol::widget::Menu::get( String _label) { + for (auto it : this.listElement) { + if (it.this.label == _label) { + return it.this.localId; } } return -1; } -int32_t ewol::widget::Menu::add(int32_t _parent, - const etk::String& _label, - const etk::String& _image, - const etk::String& _message) { +int ewol::widget::Menu::add(int _parent, + String _label, + String _image, + String _message) { // try to find one already created: - int32_t previous = get(_label); + int previous = get(_label); if (previous != -1) { return previous; } ewol::widget::MenuElement tmpObject; - tmpObject.m_localId = m_staticId++; - tmpObject.m_parentId = _parent; - tmpObject.m_label = _label; - tmpObject.m_image = _image; - tmpObject.m_message = _message; - if (tmpObject.m_parentId == -1) { - ewol::widget::ButtonShared myButton = ewol::widget::Button::create(); + tmpObject.this.localId = this.staticObjectId++; + tmpObject.this.parentId = _parent; + tmpObject.this.label = _label; + tmpObject.this.image = _image; + tmpObject.this.message = _message; + if (tmpObject.this.parentId == -1) { + ewol::widget::Button myButton = ewol::widget::Button::create(); if (myButton == null) { Log.error("Allocation button error"); - return tmpObject.m_localId; + return tmpObject.this.localId; } - if (tmpObject.m_image.size()!=0) { - etk::String composeString ="\n"; - if (etk::end_with(tmpObject.m_image, ".edf") == true) { - composeString+=" \n"; + if (tmpObject.this.image.size()!=0) { + String composeString ="\n"; + if (etk::end_with(tmpObject.this.image, ".edf") == true) { + composeString+=" \n"; } else { - composeString+=" \n"; + composeString+=" \n"; } - composeString+=" \n"; + composeString+=" \n"; composeString+="\n"; - myButton->setSubWidget(ewol::widget::composerGenerateString(composeString)); + myButton.setSubWidget(ewol::widget::composerGenerateString(composeString)); } else { - ewol::widget::LabelShared label = ewol::widget::Label::create(); - label->propertyValue.set("" + tmpObject.m_label + ""); - myButton->setSubWidget(label); + ewol::widget::Label label = ewol::widget::Label::create(); + label.propertyValue.set("" + tmpObject.this.label + ""); + myButton.setSubWidget(label); } // add it in the widget list ewol::widget::Sizer::subWidgetAdd(myButton); // keep the specific event ... - myButton->signalPressed.connect(sharedFromThis(), &ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); - tmpObject.m_widgetPointer = myButton; + myButton.signalPressed.connect(sharedFromThis(), ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); + tmpObject.this.widgetPointer = myButton; } - m_listElement.pushBack(tmpObject); - return tmpObject.m_localId; + this.listElement.pushBack(tmpObject); + return tmpObject.this.localId; } -void ewol::widget::Menu::remove(int32_t _id) { +void ewol::widget::Menu::remove(int _id) { Log.todo("NOT remove..."); } -int32_t ewol::widget::Menu::addSpacer(int32_t _parent) { +int ewol::widget::Menu::addSpacer(int _parent) { ewol::widget::MenuElement tmpObject; - tmpObject.m_localId = m_staticId++; - tmpObject.m_parentId = _parent; - tmpObject.m_label = ""; - tmpObject.m_image = ""; - tmpObject.m_message = ""; - if (tmpObject.m_parentId == -1) { - ewol::widget::SpacerShared mySpacer = ewol::widget::Spacer::create(); + tmpObject.this.localId = this.staticObjectId++; + tmpObject.this.parentId = _parent; + tmpObject.this.label = ""; + tmpObject.this.image = ""; + tmpObject.this.message = ""; + if (tmpObject.this.parentId == -1) { + ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); if (mySpacer == null) { Log.error("Allocation spacer error"); - return tmpObject.m_localId; + return tmpObject.this.localId; } - mySpacer->propertyExpand.set(Vector2b(true,true)); - mySpacer->propertyFill.set(Vector2b(true,true)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(2,0), gale::distance::pixel)); - mySpacer->propertyMaxSize.set(gale::Dimension(Vector2f(2,10000), gale::distance::pixel)); - mySpacer->propertyColor.set(etk::Color<>(0,0,0,0xFF)); + mySpacer.propertyExpand.set(Vector2b(true,true)); + mySpacer.propertyFill.set(Vector2b(true,true)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(2,0), gale::distance::pixel)); + mySpacer.propertyMaxSize.set(gale::Dimension(Vector2f(2,10000), gale::distance::pixel)); + mySpacer.propertyColor.set(etk::Color<>(0,0,0,0xFF)); // add it in the widget list ewol::widget::Sizer::subWidgetAdd(mySpacer); } - m_listElement.pushBack(tmpObject); - return tmpObject.m_localId; + this.listElement.pushBack(tmpObject); + return tmpObject.this.localId; } void ewol::widget::Menu::onButtonPressed(ewol::widget::ButtonWeak _button) { - ewol::widget::ButtonShared caller = _button.lock(); + ewol::widget::Button caller = _button.lock(); if (caller == null) { return; } - for (auto &it : m_listElement) { - if (caller != it.m_widgetPointer.lock()) { + for (auto it : this.listElement) { + if (caller != it.this.widgetPointer.lock()) { continue; } // 2 posible case (have a message or have a child ... - if (it.m_message.size() > 0) { + if (it.this.message.size() > 0) { Log.debug("Menu == > generate Event"); // Send a multicast event ... - signalSelect.emit(it.m_message); - ewol::widget::ContextMenuShared tmpContext = m_widgetContextMenu.lock(); + signalSelect.emit(it.this.message); + ewol::widget::ContextMenu tmpContext = this.widgetContextMenu.lock(); if (tmpContext != null) { Log.debug("Mark the menu to remove ..."); - tmpContext->destroy(); + tmpContext.destroy(); } return; } Log.debug("Menu == > load Sub Menu"); - bool findChild = false; - for (auto &it2 : m_listElement) { - if (it.m_localId == it2.m_parentId) { + boolean findChild = false; + for (auto it2 : this.listElement) { + if (it.this.localId == it2.this.parentId) { findChild = true; break; } } if (false == findChild) { - EWOL_WARNING("Event on menu element with no child an no event... label=" << it.m_label); + Log.warning("Event on menu element with no child an no event... label=" + it.this.label); return; } // create a context menu: - ewol::widget::ContextMenuShared tmpContext = ewol::widget::ContextMenu::create(); - m_widgetContextMenu = tmpContext; + ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create(); + this.widgetContextMenu = tmpContext; if (tmpContext == null) { Log.error("Allocation Error"); return; } // get the button widget: Vector2f newPosition; - ewol::WidgetShared eventFromWidget = ememory::dynamicPointerCast(caller); + Widget eventFromWidget = ememory::dynamicPointerCast(caller); if (eventFromWidget != null) { - Vector2f tmpOri = eventFromWidget->getOrigin(); - Vector2f tmpSize = eventFromWidget->getSize(); + Vector2f tmpOri = eventFromWidget.getOrigin(); + Vector2f tmpSize = eventFromWidget.getSize(); // calculate the correct position newPosition.setValue(tmpOri.x() + tmpSize.x()/2, tmpOri.y() ); } - tmpContext->setPositionMark(ewol::widget::ContextMenu::markTop, newPosition); - ewol::widget::SizerShared mySizer; - ewol::widget::ButtonShared myButton; + tmpContext.setPositionMark(ewol::widget::ContextMenu::markTop, newPosition); + ewol::widget::Sizer mySizer; + ewol::widget::Button myButton; mySizer = ewol::widget::Sizer::create(); if (mySizer != null) { - mySizer->propertyMode.set(widget::Sizer::modeVert); - mySizer->propertyLockExpand.set(Vector2f(true,true)); - mySizer->propertyFill.set(Vector2f(true,true)); + mySizer.propertyMode.set(widget::Sizer::modeVert); + mySizer.propertyLockExpand.set(Vector2f(true,true)); + mySizer.propertyFill.set(Vector2f(true,true)); // set it in the pop-up-system: - tmpContext->setSubWidget(mySizer); - bool menuHaveImage = false; - for (auto &it2 : m_listElement) { - if (it.m_localId != it2.m_parentId) { + tmpContext.setSubWidget(mySizer); + boolean menuHaveImage = false; + for (auto it2 : this.listElement) { + if (it.this.localId != it2.this.parentId) { continue; } - if (it2.m_image.size()!=0) { + if (it2.this.image.size()!=0) { menuHaveImage = true; break; } } - for (int64_t iii=m_listElement.size()-1; iii>=0; --iii) { - if (it.m_localId != m_listElement[iii].m_parentId) { + for (long iii=this.listElement.size()-1; iii>=0; --iii) { + if (it.this.localId != this.listElement[iii].this.parentId) { continue; } - if (m_listElement[iii].m_message == "" && m_listElement[iii].m_label == "") { - ewol::widget::SpacerShared mySpacer = ewol::widget::Spacer::create(); + if (this.listElement[iii].this.message == "" LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listElement[iii].this.label == "") { + ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); if (mySpacer == null) { Log.error("Allocation spacer error"); continue; } - mySpacer->propertyExpand.set(Vector2b(true,true)); - mySpacer->propertyFill.set(Vector2b(true,true)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(0,2), gale::distance::pixel)); - mySpacer->propertyMaxSize.set(gale::Dimension(Vector2f(10000,2), gale::distance::pixel)); - mySpacer->propertyColor.set(etk::Color<>(0,0,0,0xFF)); + mySpacer.propertyExpand.set(Vector2b(true,true)); + mySpacer.propertyFill.set(Vector2b(true,true)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,2), gale::distance::pixel)); + mySpacer.propertyMaxSize.set(gale::Dimension(Vector2f(10000,2), gale::distance::pixel)); + mySpacer.propertyColor.set(etk::Color<>(0,0,0,0xFF)); // add it in the widget list - mySizer->subWidgetAdd(mySpacer); + mySizer.subWidgetAdd(mySpacer); } else { myButton = ewol::widget::Button::create(); if (myButton == null) { Log.error("Allocation Error"); continue; } - myButton->propertyExpand.set(Vector2b(true,true)); - myButton->propertyFill.set(Vector2b(true,true)); + myButton.propertyExpand.set(Vector2b(true,true)); + myButton.propertyFill.set(Vector2b(true,true)); // set callback - myButton->signalPressed.connect(sharedFromThis(), &ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); + myButton.signalPressed.connect(sharedFromThis(), ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); // add it in the widget list - mySizer->subWidgetAdd(myButton); - if (m_listElement[iii].m_image.size() != 0) { - etk::String composeString; + mySizer.subWidgetAdd(myButton); + if (this.listElement[iii].this.image.size() != 0) { + String composeString; composeString+= " \n"; - if (etk::end_with(m_listElement[iii].m_image, ".edf") == true) { - composeString+=" \n"; + if (etk::end_with(this.listElement[iii].this.image, ".edf") == true) { + composeString+=" \n"; } else { - composeString+=" \n"; + composeString+=" \n"; } - composeString+=" \n"; + composeString+=" \n"; composeString+=" \n"; - myButton->setSubWidget(ewol::widget::composerGenerateString(composeString)); + myButton.setSubWidget(ewol::widget::composerGenerateString(composeString)); } else { if (menuHaveImage == true) { - myButton->setSubWidget(ewol::widget::composerGenerateString( - etk::String() + + myButton.setSubWidget(ewol::widget::composerGenerateString( + String() + " \n" " \n" - " \n" + " \n" " \n") ); } else { - ewol::widget::LabelShared tmpLabel = widget::Label::create(); + ewol::widget::Label tmpLabel = widget::Label::create(); if (tmpLabel != null) { - tmpLabel->propertyValue.set(etk::String("") + m_listElement[iii].m_label + "\n"); - tmpLabel->propertyExpand.set(Vector2b(true,false)); - tmpLabel->propertyFill.set(Vector2b(true,true)); - myButton->setSubWidget(tmpLabel); + tmpLabel.propertyValue.set(String("") + this.listElement[iii].this.label + "\n"); + tmpLabel.propertyExpand.set(Vector2b(true,false)); + tmpLabel.propertyFill.set(Vector2b(true,true)); + myButton.setSubWidget(tmpLabel); } } } - m_listElement[iii].m_widgetPointer = myButton; + this.listElement[iii].this.widgetPointer = myButton; } } } - ewol::widget::WindowsShared currentWindows = getWindows(); + ewol::widget::Windows currentWindows = getWindows(); if (currentWindows == null) { Log.error("Can not get the curent Windows..."); } else { - currentWindows->popUpWidgetPush(tmpContext); + currentWindows.popUpWidgetPush(tmpContext); } return; } } -bool ewol::widget::Menu::loadXML(const exml::Element& _node) { +boolean ewol::widget::Menu::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } // parse generic properties: - ewol::Widget::loadXML(_node); + Widget::loadXML(_node); // parse all the elements : - for (const auto nodeIt : _node.nodes) { - const exml::Element pNode = nodeIt.toElement(); + for ( auto nodeIt : _node.nodes) { + exml::Element pNode = nodeIt.toElement(); if (pNode.exist() == false) { // trash here all that is not element continue; } - etk::String widgetName = pNode.getValue(); - Log.info("Get node : " << pNode); + String widgetName = pNode.getValue(); + Log.info("Get node : " + pNode); if (widgetName == "elem") { // - int32_t idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]); - for (const auto nodeIt2 : pNode.nodes) { + int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]); + for ( auto nodeIt2 : pNode.nodes) { - const exml::Element pNode2 = nodeIt2.toElement(); + exml::Element pNode2 = nodeIt2.toElement(); if (pNode2.exist() == false) { // trash here all that is not element continue; } - etk::String widgetName2 = pNode2.getValue(); + String widgetName2 = pNode2.getValue(); if (widgetName2 == "elem") { // add(idMenu, pNode2.attributes["title"], pNode2.attributes["image"], pNode2.attributes["event"]); } else if (widgetName2 == "separator") { addSpacer(idMenu); } else { - Log.error("[" << getId() << "] {" << getObjectType() << "} (l " << pNode2.getPos() << ") Unknown basic node='" << widgetName2 << "' not in : [elem,separator]" ); + Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode2.getPos() + ") Unknown basic node='" + widgetName2 + "' not in : [elem,separator]" ); } } } else if (widgetName == "separator") { addSpacer(); } else { - Log.error("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in : [elem,separator]" ); + Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [elem,separator]" ); } } return true; diff --git a/src/org/atriasoft/ewol/widget/Menu.hpp b/src/org/atriasoft/ewol/widget/Menu.hpp deleted file mode 100644 index d894b0a..0000000 --- a/src/org/atriasoft/ewol/widget/Menu.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace ewol { - namespace widget { - class MenuElement { - public : - MenuElement() { }; - int32_t m_localId; - int32_t m_parentId; - ewol::WidgetWeak m_widgetPointer; - etk::String m_label; - etk::String m_image; - etk::String m_message; - }; - class Menu; - using MenuShared = ememory::SharedPtr; - using MenuWeak = ememory::WeakPtr; - /** - * @ingroup ewolWidgetGroup - */ - class Menu :public ewol::widget::Sizer { - public: - esignal::Signal signalSelect; // event on a menu button or ... - protected: - Menu(); - public: - DECLARE_WIDGET_FACTORY(Menu, "Menu"); - virtual ~Menu(); - private: - void subWidgetRemoveAll() override; - int32_t subWidgetAdd(ewol::WidgetShared _newWidget) override; - void subWidgetRemove(ewol::WidgetShared _newWidget) override; - void subWidgetUnLink(ewol::WidgetShared _newWidget) override; - bool loadXML(const exml::Element& _node) override; - private: - List m_listElement; - int32_t m_staticId; // unique ID for every element of the menu ... - ewol::widget::ContextMenuWeak m_widgetContextMenu; - int32_t get(const etk::String& _label); - public: - void clear(); - int32_t addTitle(const etk::String& _label, const etk::String& _image="", const etk::String& _message = ""); - int32_t add(int32_t _parent, const etk::String& _label, const etk::String& _image="", const etk::String& _message = ""); - int32_t addSpacer(int32_t _parent=-1); - void remove(int32_t _id); - private: - void onButtonPressed(ewol::widget::ButtonWeak _button); - }; - }; -}; - diff --git a/src/org/atriasoft/ewol/widget/Menu.java b/src/org/atriasoft/ewol/widget/Menu.java new file mode 100644 index 0000000..a121270 --- /dev/null +++ b/src/org/atriasoft/ewol/widget/Menu.java @@ -0,0 +1,55 @@ +/** + * @ingroup ewolWidgetGroup + */ +class Menu:public ewol::widget::Sizer +{ + public: + esignal::Signal signalSelect; // event on a menu button or ... + protected: + Menu(); + public: + DECLARE_WIDGET_FACTORY(Menu, "Menu"); + ~Menu(); + private: + + void subWidgetRemoveAll(); + + int subWidgetAdd(Widget _newWidget); + + void subWidgetRemove(Widget _newWidget); + + void subWidgetUnLink(Widget _newWidget); + + boolean loadXML( exml::Element _node) ; + private: + List this.listElement; + int this.staticObjectId; // unique ID for every element of the menu ... + ewol::widget::ContextMenuWeak this.widgetContextMenu; + + int get(String _label); + + public: + void clear(); + + int addTitle( final String _label, final String _image="", String _message = ""); + + int add(final int _parent, final String _label, final String _image="", String _message = ""); + + int addSpacer(final int _parent=-1); + + void remove(int _id); + + private: + void onButtonPressed(ewol::widget::ButtonWeak _button); +}; + + ; + + /** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + class MenuElement { + public MenuElement() { };int this.localId;int this.parentId;WeakReferencethis.widgetPointer;String this.label;String this.image;String this.message; +} \ No newline at end of file diff --git a/src/org/atriasoft/ewol/widget/PopUp.cpp b/src/org/atriasoft/ewol/widget/PopUp.cpp index 837fe56..153ca63 100644 --- a/src/org/atriasoft/ewol/widget/PopUp.cpp +++ b/src/org/atriasoft/ewol/widget/PopUp.cpp @@ -13,17 +13,17 @@ #include ETK_DECLARE_TYPE(ewol::widget::PopUp); -static const char* annimationIncrease = "increase"; +static char* annimationIncrease = "increase"; ewol::widget::PopUp::PopUp() : propertyShape(this, "shaper", etk::Uri("THEME_GUI:///PopUp.json?lib=ewol"), "The shaper properties", - &ewol::widget::PopUp::onChangePropertyShape), + ewol::widget::PopUp::onChangePropertyShape), propertyLockExpand(this, "lock", Vector2b(true,true), "Lock expand contamination", - &ewol::widget::PopUp::onChangePropertyLockExpand), + ewol::widget::PopUp::onChangePropertyLockExpand), propertyCloseOutEvent(this, "out-click-remove", false, "Remove the widget if the use click outside") { @@ -44,99 +44,99 @@ ewol::widget::PopUp::~PopUp() { void ewol::widget::PopUp::onChangeSize() { markToRedraw(); - if (m_subWidget == null) { + if (this.subWidget == null) { return; } - ewol::Padding padding = m_shaper.getPadding(); - Vector2f subWidgetSize = m_subWidget->getCalculateMinSize(); - if (m_subWidget->canExpand().x() == true) { - if (propertyLockExpand->x() == true) { - subWidgetSize.setX(m_minSize.x()); + ewol::Padding padding = this.shaper.getPadding(); + Vector2f subWidgetSize = this.subWidget.getCalculateMinSize(); + if (this.subWidget.canExpand().x() == true) { + if (propertyLockExpand.x() == true) { + subWidgetSize.setX(this.minSize.x()); } else { - subWidgetSize.setX(m_size.x()-padding.xLeft()); + subWidgetSize.setX(this.size.x()-padding.xLeft()); } } - if (m_subWidget->canExpand().y() == true) { - if (propertyLockExpand->y() == true) { - subWidgetSize.setY(m_minSize.y()); + if (this.subWidget.canExpand().y() == true) { + if (propertyLockExpand.y() == true) { + subWidgetSize.setY(this.minSize.y()); } else { - subWidgetSize.setY(m_size.y()-padding.yButtom()); + subWidgetSize.setY(this.size.y()-padding.yButtom()); } } // limit the size of the element : - //subWidgetSize.setMin(m_minSize); - // posiition at a int32_t pos : + //subWidgetSize.setMin(this.minSize); + // posiition at a int pos : subWidgetSize = Vector2fClipInt32(subWidgetSize); // set config to the Sub-widget - Vector2f subWidgetOrigin = m_origin + (m_size-subWidgetSize)/2.0f; + Vector2f subWidgetOrigin = this.origin + (this.size-subWidgetSize)/2.0f; subWidgetOrigin = Vector2fClipInt32(subWidgetOrigin); - m_subWidget->setOrigin(subWidgetOrigin); - m_subWidget->setSize(subWidgetSize); - m_subWidget->onChangeSize(); + this.subWidget.setOrigin(subWidgetOrigin); + this.subWidget.setSize(subWidgetSize); + this.subWidget.onChangeSize(); } -void ewol::widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::PopUp::systemDraw( ewol::DrawProperty _displayProp) { if (*propertyHide == true){ // widget is hidden ... return; } - ewol::Widget::systemDraw(_displayProp); - if (m_subWidget == null) { + Widget::systemDraw(_displayProp); + if (this.subWidget == null) { return; } - if( m_shaper.getNextDisplayedStatus() == -1 - && m_shaper.getTransitionStatus() >= 1.0) { + if( this.shaper.getNextDisplayedStatus() == -1 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.shaper.getTransitionStatus() >= 1.0) { ewol::DrawProperty prop = _displayProp; - prop.limit(m_origin, m_size); - m_subWidget->systemDraw(prop); + prop.limit(this.origin, this.size); + this.subWidget.systemDraw(prop); } } void ewol::widget::PopUp::onDraw() { - m_shaper.draw(); + this.shaper.draw(); } void ewol::widget::PopUp::onRegenerateDisplay() { if (needRedraw() == true) { - m_shaper.clear(); - ewol::Padding padding = m_shaper.getPadding(); + this.shaper.clear(); + ewol::Padding padding = this.shaper.getPadding(); Vector2f tmpSize(0,0); Vector2b expand = canExpand(); Vector2b fill = canFill(); if (fill.x() == true) { - tmpSize.setX(m_size.x()-padding.x()); + tmpSize.setX(this.size.x()-padding.x()); } if (fill.y() == true) { - tmpSize.setY(m_size.y()-padding.y()); + tmpSize.setY(this.size.y()-padding.y()); } - if (m_subWidget != null) { - Vector2f tmpSize = m_subWidget->getSize(); + if (this.subWidget != null) { + Vector2f tmpSize = this.subWidget.getSize(); } - tmpSize.setMax(m_minSize); - Vector2f tmpOrigin = (m_size-tmpSize)/2.0f; - m_shaper.setShape(Vector2f(0,0), - Vector2fClipInt32(m_size), + tmpSize.setMax(this.minSize); + Vector2f tmpOrigin = (this.size-tmpSize)/2.0f; + this.shaper.setShape(Vector2f(0,0), + Vector2fClipInt32(this.size), Vector2fClipInt32(tmpOrigin-Vector2f(padding.xLeft(), padding.yButtom())), Vector2fClipInt32(tmpSize + Vector2f(padding.x(), padding.y()))); } // SUBwIDGET GENERATION ... - if (m_subWidget != null) { - m_subWidget->onRegenerateDisplay(); + if (this.subWidget != null) { + this.subWidget.onRegenerateDisplay(); } } -ewol::WidgetShared ewol::widget::PopUp::getWidgetAtPos(const Vector2f& _pos) { - ewol::WidgetShared val = ewol::widget::Container::getWidgetAtPos(_pos); +Widget ewol::widget::PopUp::getWidgetAtPos( Vector2f _pos) { + Widget val = ewol::widget::Container::getWidgetAtPos(_pos); if (val != null) { return val; } - return ememory::dynamicPointerCast(sharedFromThis()); + return ememory::dynamicPointerCast(sharedFromThis()); } void ewol::widget::PopUp::onChangePropertyShape() { - m_shaper.setSource(*propertyShape); + this.shaper.setSource(*propertyShape); markToRedraw(); requestUpdateSize(); } @@ -146,23 +146,23 @@ void ewol::widget::PopUp::onChangePropertyLockExpand() { requestUpdateSize(); } -bool ewol::widget::PopUp::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::PopUp::onEventInput( ewol::event::Input _event) { if (_event.getId() == 0) { return false; } - if (_event.getStatus() == gale::key::status::move) { + if (_event.getStatus() == KeyStatus::move) { return false; } if (*propertyCloseOutEvent == true) { return false; } - ewol::Padding padding = m_shaper.getPadding(); + ewol::Padding padding = this.shaper.getPadding(); Vector2f tmpSize(0,0); - if (m_subWidget != null) { - Vector2f tmpSize = m_subWidget->getSize(); + if (this.subWidget != null) { + Vector2f tmpSize = this.subWidget.getSize(); } - tmpSize.setMax(m_minSize); - Vector2f tmpOrigin = (m_size-tmpSize)/2.0f; + tmpSize.setMax(this.minSize); + Vector2f tmpOrigin = (this.size-tmpSize)/2.0f; tmpOrigin -= Vector2f(padding.xLeft(), padding.yButtom()); tmpSize += Vector2f(padding.x(), padding.y()); diff --git a/src/org/atriasoft/ewol/widget/PopUp.java b/src/org/atriasoft/ewol/widget/PopUp.java index aafb330..5ffac7e 100644 --- a/src/org/atriasoft/ewol/widget/PopUp.java +++ b/src/org/atriasoft/ewol/widget/PopUp.java @@ -16,7 +16,7 @@ namespace ewol { namespace widget { class PopUp; - using PopUpShared = ememory::SharedPtr; + using PopUp = ememory::Ptr; using PopUpWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -32,26 +32,26 @@ namespace ewol { * @param[in] _shaperName Shaper file properties */ PopUp(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(PopUp, "PopUp"); /** * @brief Destructor */ - virtual ~PopUp(); + ~PopUp(); protected: - ewol::compositing::Shaper m_shaper; //!< Compositing theme. + ewol::compositing::Shaper this.shaper; //!< Compositing theme. protected: - void onDraw() override; + void onDraw() ; public: - void systemDraw(const ewol::DrawProperty& _displayProp) override; - void onRegenerateDisplay() override; - void onChangeSize() override; - bool onEventInput(const ewol::event::Input& _event) override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; + void systemDraw( ewol::DrawProperty _displayProp) ; + void onRegenerateDisplay() ; + void onChangeSize() ; + boolean onEventInput( ewol::event::Input _event) ; + Widget getWidgetAtPos( Vector2f _pos) ; protected: - virtual void onChangePropertyShape(); - virtual void onChangePropertyLockExpand(); + void onChangePropertyShape(); + void onChangePropertyLockExpand(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/ProgressBar.cpp b/src/org/atriasoft/ewol/widget/ProgressBar.cpp index 9d76572..a6f847d 100644 --- a/src/org/atriasoft/ewol/widget/ProgressBar.cpp +++ b/src/org/atriasoft/ewol/widget/ProgressBar.cpp @@ -11,30 +11,30 @@ #include ETK_DECLARE_TYPE(ewol::widget::ProgressBar); -const int32_t dotRadius = 6; + int dotRadius = 6; ewol::widget::ProgressBar::ProgressBar() : propertyValue(this, "value", 0.0f, 0.0f, 1.0f, "Value of the progress bar", - &ewol::widget::ProgressBar::onChangePropertyValue), + ewol::widget::ProgressBar::onChangePropertyValue), propertyTextColorFg(this, "color-bg", etk::color::black, "Background color", - &ewol::widget::ProgressBar::onChangePropertyTextColorFg), + ewol::widget::ProgressBar::onChangePropertyTextColorFg), propertyTextColorBgOn(this, "color-on", etk::Color<>(0x00, 0xFF, 0x00, 0xFF), "Color of the true value", - &ewol::widget::ProgressBar::onChangePropertyTextColorBgOn), + ewol::widget::ProgressBar::onChangePropertyTextColorBgOn), propertyTextColorBgOff(this, "color-off", etk::color::none, "Color of the false value", - &ewol::widget::ProgressBar::onChangePropertyTextColorBgOff) { + ewol::widget::ProgressBar::onChangePropertyTextColorBgOff) { addObjectType("ewol::widget::ProgressBar"); } void ewol::widget::ProgressBar::init() { - ewol::Widget::init(); + Widget::init(); propertyCanFocus.set(true); } @@ -43,14 +43,14 @@ ewol::widget::ProgressBar::~ProgressBar() { } void ewol::widget::ProgressBar::calculateMinMaxSize() { - Vector2f tmpMin = propertyMinSize->getPixel(); - m_minSize.setValue( etk::max(tmpMin.x(), 40.0f), + Vector2f tmpMin = propertyMinSize.getPixel(); + this.minSize.setValue( etk::max(tmpMin.x(), 40.0f), etk::max(tmpMin.y(), dotRadius*2.0f) ); markToRedraw(); } void ewol::widget::ProgressBar::onDraw() { - m_draw.draw(); + this.draw.draw(); } void ewol::widget::ProgressBar::onRegenerateDisplay() { @@ -58,24 +58,24 @@ void ewol::widget::ProgressBar::onRegenerateDisplay() { return; } // clean the object list ... - m_draw.clear(); + this.draw.clear(); - m_draw.setColor(propertyTextColorFg); + this.draw.setColor(propertyTextColorFg); - int32_t tmpSizeX = m_size.x() - 10; - int32_t tmpSizeY = m_size.y() - 10; - int32_t tmpOriginX = 5; - int32_t tmpOriginY = 5; - m_draw.setColor(propertyTextColorBgOn); - m_draw.setPos(Vector3f(tmpOriginX, tmpOriginY, 0) ); - m_draw.rectangleWidth(Vector3f(tmpSizeX*propertyValue, tmpSizeY, 0) ); - m_draw.setColor(propertyTextColorBgOff); - m_draw.setPos(Vector3f(tmpOriginX+tmpSizeX*propertyValue, tmpOriginY, 0) ); - m_draw.rectangleWidth(Vector3f(tmpSizeX*(1.0-propertyValue), tmpSizeY, 0) ); + int tmpSizeX = this.size.x() - 10; + int tmpSizeY = this.size.y() - 10; + int tmpOriginX = 5; + int tmpOriginY = 5; + this.draw.setColor(propertyTextColorBgOn); + this.draw.setPos(Vector3f(tmpOriginX, tmpOriginY, 0) ); + this.draw.rectangleWidth(Vector3f(tmpSizeX*propertyValue, tmpSizeY, 0) ); + this.draw.setColor(propertyTextColorBgOff); + this.draw.setPos(Vector3f(tmpOriginX+tmpSizeX*propertyValue, tmpOriginY, 0) ); + this.draw.rectangleWidth(Vector3f(tmpSizeX*(1.0-propertyValue), tmpSizeY, 0) ); // TODO : Create a better progress Bar ... - //m_draw.setColor(propertyTextColorFg); - //m_draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1); + //this.draw.setColor(propertyTextColorFg); + //this.draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1); } void ewol::widget::ProgressBar::onChangePropertyValue() { diff --git a/src/org/atriasoft/ewol/widget/ProgressBar.java b/src/org/atriasoft/ewol/widget/ProgressBar.java index 7b709ea..2e0c2fb 100644 --- a/src/org/atriasoft/ewol/widget/ProgressBar.java +++ b/src/org/atriasoft/ewol/widget/ProgressBar.java @@ -15,12 +15,12 @@ namespace ewol { namespace widget { class ProgressBar; - using ProgressBarShared = ememory::SharedPtr; + using ProgressBar = ememory::Ptr; using ProgressBarWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class ProgressBar : public ewol::Widget { + class ProgressBar : public Widget { public: // properties eproperty::Range propertyValue; //!< % used eproperty::Value> propertyTextColorFg; //!< forder bar color @@ -28,22 +28,22 @@ namespace ewol { eproperty::Value> propertyTextColorBgOff; //!< bar color disable protected: ProgressBar(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(ProgressBar, "ProgressBar"); - virtual ~ProgressBar(); + ~ProgressBar(); private: - ewol::compositing::Drawing m_draw; // basic drawing element + ewol::compositing::Drawing this.draw; // basic drawing element protected: - void onDraw() override; + void onDraw() ; public: - void onRegenerateDisplay() override; - void calculateMinMaxSize() override; + void onRegenerateDisplay() ; + void calculateMinMaxSize() ; protected: - virtual void onChangePropertyValue(); - virtual void onChangePropertyTextColorFg(); - virtual void onChangePropertyTextColorBgOn(); - virtual void onChangePropertyTextColorBgOff(); + void onChangePropertyValue(); + void onChangePropertyTextColorFg(); + void onChangePropertyTextColorBgOn(); + void onChangePropertyTextColorBgOff(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Scroll.cpp b/src/org/atriasoft/ewol/widget/Scroll.cpp index 476d5dd..8b730bf 100644 --- a/src/org/atriasoft/ewol/widget/Scroll.cpp +++ b/src/org/atriasoft/ewol/widget/Scroll.cpp @@ -16,23 +16,23 @@ ewol::widget::Scroll::Scroll() : propertyLimit(this, "limit", Vector2f(0.15,0.5), Vector2f(0.0,0.0), Vector2f(1.0,1.0), "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end", - &ewol::widget::Scroll::onChangePropertyLimit), + ewol::widget::Scroll::onChangePropertyLimit), propertyShapeVert(this, "shape-vert", etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"), "shape for the vertical display", - &ewol::widget::Scroll::onChangePropertyShapeVert), + ewol::widget::Scroll::onChangePropertyShapeVert), propertyShapeHori(this, "shape-hori", etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"), "shape for the horizonal display", - &ewol::widget::Scroll::onChangePropertyShapeHori), + ewol::widget::Scroll::onChangePropertyShapeHori), propertyHover(this, "hover", true, "the display bar are hover the subWidget"), - m_pixelScrolling(20), - m_highSpeedStartPos(0,0), - m_highSpeedMode(speedModeDisable), - m_highSpeedButton(-1), - m_highSpeedType(gale::key::type::unknow) { + this.pixelScrolling(20), + this.highSpeedStartPos(0,0), + this.highSpeedMode(speedModeDisable), + this.highSpeedButton(-1), + this.highSpeedType(KeyType::unknow) { addObjectType("ewol::widget::Scroll"); // Remove gravity property: (only keep top/buttom) propertyGravity.remove("center"); @@ -62,34 +62,34 @@ ewol::widget::Scroll::~Scroll() { // note: The widget will expand has possible and will control itself the display property void ewol::widget::Scroll::onChangeSize() { // Note: No call of container ==> normal case ... - ewol::Widget::onChangeSize(); + Widget::onChangeSize(); if (*propertyHide == true) { return; } - if (m_subWidget == null) { + if (this.subWidget == null) { return; } // remove the bar if hover - Vector2f basicSize = m_size; + Vector2f basicSize = this.size; if (*propertyHover == false) { basicSize -= Vector2f(SCROLL_BAR_SPACE,SCROLL_BAR_SPACE); } - Vector2f origin = m_origin+m_offset; - Vector2f minSize = m_subWidget->getCalculateMinSize(); - Vector2b expand = m_subWidget->propertyExpand.get(); + Vector2f origin = this.origin+this.offset; + Vector2f minSize = this.subWidget.getCalculateMinSize(); + Vector2b expand = this.subWidget.propertyExpand.get(); //The gravity is not set on the sub element ==> special use of the widget - //origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - m_size); + //origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - this.size); if ( expand.x() == true - && minSize.x() < basicSize.x()) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM minSize.x() < basicSize.x()) { minSize.setX(basicSize.x()); } if ( expand.y() == true - && minSize.y() < basicSize.y()) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM minSize.y() < basicSize.y()) { minSize.setY(basicSize.y()); } - m_subWidget->setSize(minSize); + this.subWidget.setSize(minSize); if (*propertyGravity == ewol::gravity_top) { origin += Vector2f(0.0f, basicSize.y()-minSize.y()); if (*propertyHover == false) { @@ -100,40 +100,40 @@ void ewol::widget::Scroll::onChangeSize() { } else { Log.error(" Not manage other gravity ..."); } - m_subWidget->setOrigin(origin); - m_subWidget->onChangeSize(); + this.subWidget.setOrigin(origin); + this.subWidget.onChangeSize(); } void ewol::widget::Scroll::calculateMinMaxSize() { // Note: No call of container ==> normal case ... - ewol::Widget::calculateMinMaxSize(); + Widget::calculateMinMaxSize(); // call sub classes - if (m_subWidget != null) { - m_subWidget->calculateMinMaxSize(); + if (this.subWidget != null) { + this.subWidget.calculateMinMaxSize(); } } -void ewol::widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::Scroll::systemDraw( ewol::DrawProperty _displayProp) { if (*propertyHide == true) { return; } - if (m_subWidget != null) { + if (this.subWidget != null) { ewol::DrawProperty prop = _displayProp; - prop.limit(m_origin, m_size); - m_subWidget->systemDraw(prop); + prop.limit(this.origin, this.size); + this.subWidget.systemDraw(prop); } - ewol::Widget::systemDraw(_displayProp); + Widget::systemDraw(_displayProp); } void ewol::widget::Scroll::onDraw() { - m_shaperH.draw(); - m_shaperV.draw(); + this.shaperH.draw(); + this.shaperV.draw(); /* ewol::compositing::Drawing draw; draw.setPos(Vector2f(10,10)); draw.setColor(etk::color::orange); draw.rectangleWidth(Vector2f(25,25)); - draw.setPos(m_size - Vector2f(35,35)); + draw.setPos(this.size - Vector2f(35,35)); draw.setColor(etk::color::green); draw.rectangleWidth(Vector2f(25,25)); draw.draw(); @@ -150,268 +150,268 @@ void ewol::widget::Scroll::onRegenerateDisplay() { return; } // clear all previous display - m_shaperH.clear(); - m_shaperV.clear(); - ewol::Padding paddingVert = m_shaperV.getPadding(); - ewol::Padding paddingHori = m_shaperH.getPadding(); + this.shaperH.clear(); + this.shaperV.clear(); + ewol::Padding paddingVert = this.shaperV.getPadding(); + ewol::Padding paddingHori = this.shaperH.getPadding(); Vector2f scrollOffset(0,0); Vector2f scrollSize(0,0); - if (m_subWidget != null) { - scrollOffset = m_subWidget->getOffset(); - scrollSize = m_subWidget->getSize(); + if (this.subWidget != null) { + scrollOffset = this.subWidget.getOffset(); + scrollSize = this.subWidget.getSize(); } - if( m_size.y() < scrollSize.y() + if( this.size.y() < scrollSize.y() || scrollOffset.y() != 0) { - float lenScrollBar = m_size.y()*m_size.y() / scrollSize.y(); - lenScrollBar = etk::avg(10.0f, lenScrollBar, m_size.y()); - float originScrollBar = scrollOffset.y() / (scrollSize.y()-m_size.y()*propertyLimit->y()); + float lenScrollBar = this.size.y()*this.size.y() / scrollSize.y(); + lenScrollBar = etk::avg(10.0f, lenScrollBar, this.size.y()); + float originScrollBar = scrollOffset.y() / (scrollSize.y()-this.size.y()*propertyLimit.y()); originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f); - originScrollBar *= (m_size.y()-lenScrollBar); - m_shaperV.setShape(Vector2f(m_size.x() - paddingVert.x(), 0), - Vector2f(paddingVert.x(), m_size.y()), - Vector2f(m_size.x() - paddingVert.xRight(), m_size.y() - originScrollBar - lenScrollBar), + originScrollBar *= (this.size.y()-lenScrollBar); + this.shaperV.setShape(Vector2f(this.size.x() - paddingVert.x(), 0), + Vector2f(paddingVert.x(), this.size.y()), + Vector2f(this.size.x() - paddingVert.xRight(), this.size.y() - originScrollBar - lenScrollBar), Vector2f(0, lenScrollBar)); } - if( m_size.x() < scrollSize.x() + if( this.size.x() < scrollSize.x() || scrollOffset.x() != 0) { - float lenScrollBar = (m_size.x()-paddingHori.xLeft())*(m_size.x()-paddingVert.x()) / scrollSize.x(); - lenScrollBar = etk::avg(10.0f, lenScrollBar, (m_size.x()-paddingVert.x())); - float originScrollBar = scrollOffset.x() / (scrollSize.x()-m_size.x()*propertyLimit->x()); + float lenScrollBar = (this.size.x()-paddingHori.xLeft())*(this.size.x()-paddingVert.x()) / scrollSize.x(); + lenScrollBar = etk::avg(10.0f, lenScrollBar, (this.size.x()-paddingVert.x())); + float originScrollBar = scrollOffset.x() / (scrollSize.x()-this.size.x()*propertyLimit.x()); originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f); - originScrollBar *= (m_size.x()-paddingHori.xRight()-lenScrollBar); - m_shaperH.setShape(Vector2f(0, 0), - Vector2f(m_size.x()-paddingVert.x(), paddingHori.y()), + originScrollBar *= (this.size.x()-paddingHori.xRight()-lenScrollBar); + this.shaperH.setShape(Vector2f(0, 0), + Vector2f(this.size.x()-paddingVert.x(), paddingHori.y()), Vector2f(originScrollBar, paddingHori.yButtom()), Vector2f(lenScrollBar, 0)); } } -bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::Scroll::onEventInput( ewol::event::Input _event) { //ewol::event::Input _event = event; - //_event.setType(gale::key::type::finger); + //_event.setType(KeyType::finger); Vector2f relativePos = relativePosition(_event.getPos()); Vector2f scrollOffset(0,0); Vector2f scrollSize(0,0); - if (m_subWidget != null) { - scrollOffset = m_subWidget->getOffset(); - scrollSize = m_subWidget->getSize(); + if (this.subWidget != null) { + scrollOffset = this.subWidget.getOffset(); + scrollSize = this.subWidget.getSize(); } - Log.verbose("Get Event on scroll : " << _event); - relativePos.setY(m_size.y() - relativePos.y()); - if( _event.getType() == gale::key::type::mouse - && ( m_highSpeedType == gale::key::type::unknow - || m_highSpeedType == gale::key::type::mouse) ) { + Log.verbose("Get Event on scroll : " + _event); + relativePos.setY(this.size.y() - relativePos.y()); + if( _event.getType() == KeyType::mouse + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow + || this.highSpeedType == KeyType::mouse) ) { if( _event.getId() == 1 - && _event.getStatus() == gale::key::status::down) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down) { // check if selected the scrolling position whth the scrolling bar ... - if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) { - if( m_size.y() < scrollSize.y() + if (relativePos.x() >= (this.size.x()-SCROLL_BAR_SPACE)) { + if( this.size.y() < scrollSize.y() || scrollOffset.y() != 0) { - m_highSpeedMode = speedModeEnableVertical; - m_highSpeedType = gale::key::type::mouse; - m_highSpeedStartPos.setX(relativePos.x()); - m_highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (m_size.y()-SCROLL_BAR_SPACE*2)); - m_highSpeedButton = 1; + this.highSpeedMode = speedModeEnableVertical; + this.highSpeedType = KeyType::mouse; + this.highSpeedStartPos.setX(relativePos.x()); + this.highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (this.size.y()-SCROLL_BAR_SPACE*2)); + this.highSpeedButton = 1; // force direct scrolling in this case - scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2))); - scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); + scrollOffset.setY((int)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (this.size.y()-SCROLL_BAR_SPACE*2))); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y()))); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } - } else if (relativePos.y() >= (m_size.y()-SCROLL_BAR_SPACE)) { - if( m_size.x() < scrollSize.x() + } else if (relativePos.y() >= (this.size.y()-SCROLL_BAR_SPACE)) { + if( this.size.x() < scrollSize.x() || scrollOffset.x()!=0) { - m_highSpeedMode = speedModeEnableHorizontal; - m_highSpeedType = gale::key::type::mouse; - m_highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (m_size.x()-SCROLL_BAR_SPACE*2)); - m_highSpeedStartPos.setY(relativePos.y()); - m_highSpeedButton = 1; + this.highSpeedMode = speedModeEnableHorizontal; + this.highSpeedType = KeyType::mouse; + this.highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (this.size.x()-SCROLL_BAR_SPACE*2)); + this.highSpeedStartPos.setY(relativePos.y()); + this.highSpeedButton = 1; // force direct scrolling in this case - scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2))); - scrollOffset.setY(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*propertyLimit->x()))); + scrollOffset.setX((int)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (this.size.x()-SCROLL_BAR_SPACE*2))); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x()))); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } } return false; } else if( _event.getId() == 4 - && _event.getStatus() == gale::key::status::up) { - Log.verbose(" mode UP " << m_size.y() << "<" << scrollSize.y()); - if(m_size.y() < scrollSize.y()) { - scrollOffset.setY(scrollOffset.y()-m_pixelScrolling); - scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { + Log.verbose(" mode UP " + this.size.y() + "<" + scrollSize.y()); + if(this.size.y() < scrollSize.y()) { + scrollOffset.setY(scrollOffset.y()-this.pixelScrolling); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y()))); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } } else if( _event.getId() == 5 - && _event.getStatus() == gale::key::status::up) { - Log.verbose(" mode DOWN " << m_size.y() << "<" << scrollSize.y()); - if(m_size.y() < scrollSize.y()) { - scrollOffset.setY(scrollOffset.y()+m_pixelScrolling); - scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { + Log.verbose(" mode DOWN " + this.size.y() + "<" + scrollSize.y()); + if(this.size.y() < scrollSize.y()) { + scrollOffset.setY(scrollOffset.y()+this.pixelScrolling); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y()))); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } }else if (_event.getId() == 2) { - if (_event.getStatus() == gale::key::status::down) { - m_highSpeedMode = speedModeInit; - m_highSpeedType = gale::key::type::mouse; - m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); - m_highSpeedButton = 2; + if (_event.getStatus() == KeyStatus::down) { + this.highSpeedMode = speedModeInit; + this.highSpeedType = KeyType::mouse; + this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); + this.highSpeedButton = 2; // not really use... == > just keep some informations return false; } - } else if( m_highSpeedMode != speedModeDisable - && _event.getStatus() == gale::key::status::leave) { - m_highSpeedMode = speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + } else if( this.highSpeedMode != speedModeDisable + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) { + this.highSpeedMode = speedModeDisable; + this.highSpeedType = KeyType::unknow; markToRedraw(); return true; } - if ( _event.getId() == m_highSpeedButton - && m_highSpeedMode != speedModeDisable) { - if (_event.getStatus() == gale::key::status::up) { - if (m_highSpeedMode == speedModeInit) { + if ( _event.getId() == this.highSpeedButton + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.highSpeedMode != speedModeDisable) { + if (_event.getStatus() == KeyStatus::up) { + if (this.highSpeedMode == speedModeInit) { // TODO : generate back the down event ... - m_highSpeedMode = speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + this.highSpeedMode = speedModeDisable; + this.highSpeedType = KeyType::unknow; return false; } else { - m_highSpeedMode = speedModeGrepEndEvent; + this.highSpeedMode = speedModeGrepEndEvent; markToRedraw(); return true; } - } else if (m_highSpeedMode == speedModeGrepEndEvent) { - if (_event.getStatus() == gale::key::status::pressSingle) { - m_highSpeedMode = speedModeDisable; - m_highSpeedType = gale::key::type::unknow; - m_highSpeedButton = -1; + } else if (this.highSpeedMode == speedModeGrepEndEvent) { + if (_event.getStatus() == KeyStatus::pressSingle) { + this.highSpeedMode = speedModeDisable; + this.highSpeedType = KeyType::unknow; + this.highSpeedButton = -1; markToRedraw(); } return true; - } else if( m_highSpeedMode == speedModeInit - && _event.getStatus() == gale::key::status::move) { + } else if( this.highSpeedMode == speedModeInit + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { // wait that the cursor move more than 10 px to enable it : - if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 + || etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : - if (relativePos.x() == m_highSpeedStartPos.x()) { - m_highSpeedMode = speedModeEnableVertical; - } else if (relativePos.y() == m_highSpeedStartPos.y()) { - m_highSpeedMode = speedModeEnableHorizontal; + if (relativePos.x() == this.highSpeedStartPos.x()) { + this.highSpeedMode = speedModeEnableVertical; + } else if (relativePos.y() == this.highSpeedStartPos.y()) { + this.highSpeedMode = speedModeEnableHorizontal; } else { - float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x()); + float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x()); if (etk::abs(coef) <= 1 ) { - m_highSpeedMode = speedModeEnableHorizontal; + this.highSpeedMode = speedModeEnableHorizontal; } else { - m_highSpeedMode = speedModeEnableVertical; + this.highSpeedMode = speedModeEnableVertical; } } - if (m_highSpeedMode == speedModeEnableHorizontal) { - m_highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (m_size.x()-SCROLL_BAR_SPACE*2)); + if (this.highSpeedMode == speedModeEnableHorizontal) { + this.highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (this.size.x()-SCROLL_BAR_SPACE*2)); } else { - m_highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (m_size.y()-SCROLL_BAR_SPACE*2)); + this.highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (this.size.y()-SCROLL_BAR_SPACE*2)); } markToRedraw(); } - scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y()))); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } - if( m_highSpeedMode == speedModeEnableHorizontal - && _event.getStatus() == gale::key::status::move) { - scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2))); - scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*propertyLimit->x() ))); + if( this.highSpeedMode == speedModeEnableHorizontal + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { + scrollOffset.setX((int)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (this.size.x()-SCROLL_BAR_SPACE*2))); + scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x() ))); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } - if( m_highSpeedMode == speedModeEnableVertical - && _event.getStatus() == gale::key::status::move) { - scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2))); - scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->x()))); + if( this.highSpeedMode == speedModeEnableVertical + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { + scrollOffset.setY((int)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (this.size.y()-SCROLL_BAR_SPACE*2))); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.x()))); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } } - } else if( gale::key::type::finger == _event.getType() - && ( gale::key::type::unknow == m_highSpeedType - || gale::key::type::finger == m_highSpeedType ) ) { + } else if( KeyType::finger == _event.getType() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( KeyType::unknow == this.highSpeedType + || KeyType::finger == this.highSpeedType ) ) { if (1 == _event.getId()) { - Log.verbose("event: " << _event); - if (gale::key::status::down == _event.getStatus()) { - m_highSpeedMode = speedModeInit; - m_highSpeedType = gale::key::type::finger; - m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); - Log.verbose("SCROOL == > INIT pos=" << m_highSpeedStartPos << " && curent scrollOffset=" << scrollOffset); + Log.verbose("event: " + _event); + if (KeyStatus::down == _event.getStatus()) { + this.highSpeedMode = speedModeInit; + this.highSpeedType = KeyType::finger; + this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); + Log.verbose("SCROOL == > INIT pos=" + this.highSpeedStartPos + " LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM curent scrollOffset=" + scrollOffset); return true; - } else if (gale::key::status::upAfter == _event.getStatus()) { - m_highSpeedMode = speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + } else if (KeyStatus::upAfter == _event.getStatus()) { + this.highSpeedMode = speedModeDisable; + this.highSpeedType = KeyType::unknow; Log.verbose("SCROOL == > DISABLE"); markToRedraw(); return true; - } else if ( m_highSpeedMode == speedModeInit - && gale::key::status::move == _event.getStatus()) { + } else if ( this.highSpeedMode == speedModeInit + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::move == _event.getStatus()) { // wait that the cursor move more than 10 px to enable it : - if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 + || etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : - m_highSpeedMode = speedModeEnableFinger; + this.highSpeedMode = speedModeEnableFinger; Log.verbose("SCROOL == > ENABLE"); markToRedraw(); } return true; } - if ( m_highSpeedMode == speedModeEnableFinger - && gale::key::status::move == _event.getStatus()) { - Log.verbose("SCROOL == > INIT scrollOffset=" << scrollOffset.y() << " relativePos=" << relativePos.y() << " m_highSpeedStartPos=" << m_highSpeedStartPos.y()); - //scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x); - if (propertyLimit->x() != 0.0f) { - scrollOffset.setX(scrollOffset.x() + (relativePos.x() - m_highSpeedStartPos.x())); - scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*propertyLimit->x()))); + if ( this.highSpeedMode == speedModeEnableFinger + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::move == _event.getStatus()) { + Log.verbose("SCROOL == > INIT scrollOffset=" + scrollOffset.y() + " relativePos=" + relativePos.y() + " this.highSpeedStartPos=" + this.highSpeedStartPos.y()); + //scrollOffset.x = (int)(scrollSize.x * x / this.size.x); + if (propertyLimit.x() != 0.0f) { + scrollOffset.setX(scrollOffset.x() + (relativePos.x() - this.highSpeedStartPos.x())); + scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x()))); } - if (propertyLimit->y() != 0.0f) { - scrollOffset.setY(scrollOffset.y() - (relativePos.y() - m_highSpeedStartPos.y())); - scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); + if (propertyLimit.y() != 0.0f) { + scrollOffset.setY(scrollOffset.y() - (relativePos.y() - this.highSpeedStartPos.y())); + scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y()))); } // update current position: - m_highSpeedStartPos = relativePos; - Log.verbose("SCROOL == > MOVE " << scrollOffset); + this.highSpeedStartPos = relativePos; + Log.verbose("SCROOL == > MOVE " + scrollOffset); markToRedraw(); - if (m_subWidget != null) { - m_subWidget->setOffset(scrollOffset); + if (this.subWidget != null) { + this.subWidget.setOffset(scrollOffset); } return true; } - if (m_highSpeedMode == speedModeEnableFinger) { + if (this.highSpeedMode == speedModeEnableFinger) { return true; } - } else if ( m_highSpeedMode != speedModeDisable - && gale::key::status::leave == _event.getStatus()) { - m_highSpeedMode = speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + } else if ( this.highSpeedMode != speedModeDisable + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::leave == _event.getStatus()) { + this.highSpeedMode = speedModeDisable; + this.highSpeedType = KeyType::unknow; Log.verbose("SCROOL == > DISABLE"); markToRedraw(); return true; @@ -420,12 +420,12 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return false; } -ewol::WidgetShared ewol::widget::Scroll::getWidgetAtPos(const Vector2f& _pos) { - ewol::WidgetShared tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos); +Widget ewol::widget::Scroll::getWidgetAtPos( Vector2f _pos) { + Widget tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } - return ememory::dynamicPointerCast(sharedFromThis());; + return ememory::dynamicPointerCast(sharedFromThis());; } void ewol::widget::Scroll::onChangePropertyLimit() { @@ -433,12 +433,12 @@ void ewol::widget::Scroll::onChangePropertyLimit() { } void ewol::widget::Scroll::onChangePropertyShapeVert() { - m_shaperV.setSource(propertyShapeVert); + this.shaperV.setSource(propertyShapeVert); markToRedraw(); } void ewol::widget::Scroll::onChangePropertyShapeHori() { - m_shaperH.setSource(propertyShapeHori); + this.shaperH.setSource(propertyShapeHori); markToRedraw(); } diff --git a/src/org/atriasoft/ewol/widget/Scroll.java b/src/org/atriasoft/ewol/widget/Scroll.java index bda8874..8801a1e 100644 --- a/src/org/atriasoft/ewol/widget/Scroll.java +++ b/src/org/atriasoft/ewol/widget/Scroll.java @@ -15,7 +15,7 @@ namespace ewol { namespace widget { class Scroll; - using ScrollShared = ememory::SharedPtr; + using Scroll = ememory::Ptr; using ScrollWeak = ememory::WeakPtr; class Scroll : public ewol::widget::Container { public: // properties @@ -33,33 +33,33 @@ namespace ewol { speedModeGrepEndEvent }; private: - ewol::compositing::Shaper m_shaperH; //!< Compositing theme Horizontal. - ewol::compositing::Shaper m_shaperV; //!< Compositing theme Vertical. + ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal. + ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical. private: - float m_pixelScrolling; - Vector2f m_highSpeedStartPos; - enum highSpeedMode m_highSpeedMode; - int32_t m_highSpeedButton; - enum gale::key::type m_highSpeedType; + float this.pixelScrolling; + Vector2f this.highSpeedStartPos; + enum highSpeedMode this.highSpeedMode; + int this.highSpeedButton; + KeyType this.highSpeedType; protected: Scroll(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(Scroll, "Scroll"); - virtual ~Scroll(); + ~Scroll(); public: - void onChangeSize() override; - void calculateMinMaxSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - void systemDraw(const ewol::DrawProperty& _displayProp) override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; + void onChangeSize() ; + void calculateMinMaxSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + void systemDraw( ewol::DrawProperty _displayProp) ; + Widget getWidgetAtPos( Vector2f _pos) ; protected: - void onDraw() override; + void onDraw() ; protected: - virtual void onChangePropertyLimit(); - virtual void onChangePropertyShapeVert(); - virtual void onChangePropertyShapeHori(); + void onChangePropertyLimit(); + void onChangePropertyShapeVert(); + void onChangePropertyShapeHori(); }; } } diff --git a/src/org/atriasoft/ewol/widget/Select.cpp b/src/org/atriasoft/ewol/widget/Select.cpp index 49f6862..f407be4 100644 --- a/src/org/atriasoft/ewol/widget/Select.cpp +++ b/src/org/atriasoft/ewol/widget/Select.cpp @@ -13,10 +13,10 @@ #include ETK_DECLARE_TYPE(ewol::widget::Select); -ewol::widget::Select::Element::Element(int32_t _value, etk::String _name, bool _selected): - m_value(_value), - m_name(_name), - m_selected(_selected) { +ewol::widget::Select::Element::Element(int _value, String _name, boolean _selected): + this.value(_value), + this.name(_name), + this.selected(_selected) { } @@ -25,9 +25,9 @@ ewol::widget::Select::Select() : propertyValue(this, "value", -1, "Value of the Select", - &ewol::widget::Select::onChangePropertyValue) { + ewol::widget::Select::onChangePropertyValue) { addObjectType("ewol::widget::Select"); - // override the basic parameter: + // the basic parameter: propertyShape.setDirectCheck(etk::Uri("THEME_GUI:///Select.json?lib=ewol")); propertySpinMode.setDirect(ewol::widget::spinPosition_noneRight); propertySpinMode.changeDefault(ewol::widget::spinPosition_noneRight); @@ -45,44 +45,44 @@ ewol::widget::Select::~Select() { void ewol::widget::Select::onChangePropertyValue() { markToRedraw(); - if (m_widgetEntry == null) { + if (this.widgetEntry == null) { Log.error("Can not acces at entry ..."); return; } - for (auto &it : m_listElement) { - if (it.m_value == propertyValue.get()) { - if (it.m_selected == false) { - it.m_selected = true; - m_widgetEntry->propertyValue.set(it.m_name); + for (auto it : this.listElement) { + if (it.this.value == propertyValue.get()) { + if (it.this.selected == false) { + it.this.selected = true; + this.widgetEntry.propertyValue.set(it.this.name); signalValue.emit(propertyValue.get()); } } else { - it.m_selected = false; + it.this.selected = false; } } } void ewol::widget::Select::optionSelectDefault() { - if (m_widgetEntry == null) { + if (this.widgetEntry == null) { Log.error("Can not acces at entry ..."); return; } - for (auto &it : m_listElement) { - if (it.m_selected == true) { + for (auto it : this.listElement) { + if (it.this.selected == true) { return; } } - if (m_listElement.size() == 0) { - m_widgetEntry->propertyValue.set(""); + if (this.listElement.size() == 0) { + this.widgetEntry.propertyValue.set(""); } - m_widgetEntry->propertyValue.set(m_listElement[0].m_name); + this.widgetEntry.propertyValue.set(this.listElement[0].this.name); } -void ewol::widget::Select::optionRemove(int32_t _value) { - for (auto it=m_listElement.begin(); it != m_listElement.end(); ++it) { - if (_value == it->m_value) { - Log.debug("remove element: " << _value); - m_listElement.erase(it); +void ewol::widget::Select::optionRemove(int _value) { + for (auto it=this.listElement.begin(); it != this.listElement.end(); ++it) { + if (_value == it.this.value) { + Log.debug("remove element: " + _value); + this.listElement.erase(it); break; } } @@ -90,21 +90,21 @@ void ewol::widget::Select::optionRemove(int32_t _value) { } void ewol::widget::Select::optionClear() { - m_listElement.clear(); + this.listElement.clear(); optionSelectDefault(); } -void ewol::widget::Select::optionAdd(int32_t _value, etk::String _data) { - for (auto &it : m_listElement) { - if (_value == it.m_value) { - Log.debug("replace element: " << _value << " with: '" << _data << "'"); - it.m_name = _data; +void ewol::widget::Select::optionAdd(int _value, String _data) { + for (auto it : this.listElement) { + if (_value == it.this.value) { + Log.debug("replace element: " + _value + " with: '" + _data + "'"); + it.this.name = _data; } } - m_listElement.pushBack(ewol::widget::Select::Element(_value, _data, false)); + this.listElement.pushBack(ewol::widget::Select::Element(_value, _data, false)); } -bool ewol::widget::Select::loadXML(const exml::Element& _node) { +boolean ewol::widget::Select::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } @@ -113,26 +113,26 @@ bool ewol::widget::Select::loadXML(const exml::Element& _node) { // remove previous element: //subWidgetRemove(); // parse all the elements: - for(const auto it : _node.nodes) { + for( auto it : _node.nodes) { exml::Element pNode = it.toElement(); if (pNode.exist() == false) { // trash here all that is not element continue; } if (pNode.getValue() != "option") { - Log.error("(l " << pNode.getPos() << ") Unknown basic node='" << pNode.getValue() << "' not in : [option]" ); + Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + pNode.getValue() + "' not in : [option]" ); continue; } - etk::String valId = pNode.attributes["id"]; - etk::String valIsSelected = pNode.attributes["select"]; - etk::String valText = pNode.getText(); - int32_t id = etk::string_to_int32_t(valId); - bool select = etk::string_to_bool(valIsSelected); + String valId = pNode.attributes["id"]; + String valIsSelected = pNode.attributes["select"]; + String valText = pNode.getText(); + int id = etk::string_to_int(valId); + boolean select = etk::string_to_bool(valIsSelected); optionAdd(id, valText); if (select == true) { propertyValue.set(id); } - EWOL_WARNING("Add option : id='" << valId << "' select='" << valIsSelected << "' text='" << valText << "'"); + Log.warning("Add option : id='" + valId + "' select='" + valIsSelected + "' text='" + valText + "'"); } return true; } @@ -140,66 +140,66 @@ bool ewol::widget::Select::loadXML(const exml::Element& _node) { void ewol::widget::Select::updateGui() { ewol::widget::SpinBase::updateGui(); - if ( m_widgetEntry != null - && m_connectionEntry.isConnected() == false) { + if ( this.widgetEntry != null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionEntry.isConnected() == false) { } - if ( m_widgetButtonUp != null - && m_connectionButton.isConnected() == false) { - m_connectionButton = m_widgetButtonUp->signalPressed.connect(this, &ewol::widget::Select::onCallbackOpenMenu); + if ( this.widgetButtonUp != null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButton.isConnected() == false) { + this.connectionButton = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Select::onCallbackOpenMenu); } } -void ewol::widget::Select::onCallbackLabelPressed(int32_t _value) { - Log.verbose("User select:" << _value); +void ewol::widget::Select::onCallbackLabelPressed(int _value) { + Log.verbose("User select:" + _value); propertyValue.set(_value); } void ewol::widget::Select::onCallbackOpenMenu() { // create a context menu: - ewol::widget::ContextMenuShared tmpContext = ewol::widget::ContextMenu::create(); + ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create(); if (tmpContext == null) { Log.error("Allocation Error"); return; } // auto-select mark position: - tmpContext->setPositionMarkAuto(m_origin, m_size); - ewol::widget::SizerShared mySizer; + tmpContext.setPositionMarkAuto(this.origin, this.size); + ewol::widget::Sizer mySizer; mySizer = ewol::widget::Sizer::create(); if (mySizer == null) { Log.error("Allocation Error or sizer"); return; } - mySizer->propertyMode.set(widget::Sizer::modeVert); - mySizer->propertyLockExpand.set(Vector2f(true,true)); - mySizer->propertyFill.set(Vector2f(true,true)); + mySizer.propertyMode.set(widget::Sizer::modeVert); + mySizer.propertyLockExpand.set(Vector2f(true,true)); + mySizer.propertyFill.set(Vector2f(true,true)); // set it in the pop-up-system: - tmpContext->setSubWidget(mySizer); - for (auto &it : m_listElement) { - ewol::widget::LabelShared myLabel = ewol::widget::Label::create(); + tmpContext.setSubWidget(mySizer); + for (auto it : this.listElement) { + ewol::widget::Label myLabel = ewol::widget::Label::create(); if (myLabel == null) { Log.error("Allocation Error"); continue; } - if (it.m_selected == true) { - myLabel->propertyValue.set(etk::String("") + it.m_name + ""); + if (it.this.selected == true) { + myLabel.propertyValue.set(String("") + it.this.name + ""); } else { - myLabel->propertyValue.set(it.m_name); + myLabel.propertyValue.set(it.this.name); } - myLabel->propertyExpand.set(Vector2b(true,true)); - myLabel->propertyFill.set(Vector2b(true,true)); + myLabel.propertyExpand.set(Vector2b(true,true)); + myLabel.propertyFill.set(Vector2b(true,true)); // set callback - myLabel->signalPressed.connect(sharedFromThis(), &ewol::widget::Select::onCallbackLabelPressed, it.m_value); - myLabel->signalPressed.connect(tmpContext, &ewol::widget::ContextMenu::destroy); + myLabel.signalPressed.connect(sharedFromThis(), ewol::widget::Select::onCallbackLabelPressed, it.this.value); + myLabel.signalPressed.connect(tmpContext, ewol::widget::ContextMenu::destroy); // add it in the widget list - mySizer->subWidgetAddStart(myLabel); + mySizer.subWidgetAddStart(myLabel); } - ewol::widget::WindowsShared currentWindows = getWindows(); + ewol::widget::Windows currentWindows = getWindows(); if (currentWindows == null) { Log.error("Can not get the curent Windows..."); } else { - currentWindows->popUpWidgetPush(tmpContext); + currentWindows.popUpWidgetPush(tmpContext); } } diff --git a/src/org/atriasoft/ewol/widget/Select.java b/src/org/atriasoft/ewol/widget/Select.java index 2f54092..8158488 100644 --- a/src/org/atriasoft/ewol/widget/Select.java +++ b/src/org/atriasoft/ewol/widget/Select.java @@ -12,7 +12,7 @@ namespace ewol { namespace widget { class Select; - using SelectShared = ememory::SharedPtr; + using Select = ememory::Ptr; using SelectWeak = ememory::WeakPtr; /** * @brief a composed Select is a Select with an inside composed with the specify XML element @@ -20,9 +20,9 @@ namespace ewol { */ class Select : public ewol::widget::SpinBase { public: // signals - esignal::Signal signalValue; + esignal::Signal signalValue; public: // properties - eproperty::Value propertyValue; //!< Current state of the Select. + eproperty::Value propertyValue; //!< Current state of the Select. protected: /** * @brief Constructor @@ -34,35 +34,35 @@ namespace ewol { /** * @brief Destructor */ - virtual ~Select(); + ~Select(); protected: class Element { public: - int32_t m_value; - etk::String m_name; - bool m_selected; + int this.value; + String this.name; + boolean this.selected; public: // TODO: Remove this: due to the fact my List is not full implemented Element() {} - Element(int32_t _value, etk::String _name, bool _selected=false); + Element(int _value, String _name, boolean _selected=false); }; - List m_listElement; + List this.listElement; public: void optionSelectDefault(); - void optionRemove(int32_t _value); + void optionRemove(int _value); void optionClear(); - void optionAdd(int32_t _value, etk::String _name); + void optionAdd(int _value, String _name); protected: - bool loadXML(const exml::Element& _node) override; - void updateGui() override; + boolean loadXML( exml::Element _node) ; + void updateGui() ; protected: void onCallbackOpenMenu(); - void onCallbackLabelPressed(int32_t _value); + void onCallbackLabelPressed(int _value); protected: - esignal::Connection m_connectionEntry; - esignal::Connection m_connectionButton; + esignal::Connection this.connectionEntry; + esignal::Connection this.connectionButton; protected: - virtual void onChangePropertyValue(); + void onChangePropertyValue(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/Sizer.cpp b/src/org/atriasoft/ewol/widget/Sizer.cpp index 4e3aedf..c61880b 100644 --- a/src/org/atriasoft/ewol/widget/Sizer.cpp +++ b/src/org/atriasoft/ewol/widget/Sizer.cpp @@ -15,11 +15,11 @@ ewol::widget::Sizer::Sizer() : propertyMode(this, "mode", modeHori, "The display mode", - &ewol::widget::Sizer::onChangePropertyMode), + ewol::widget::Sizer::onChangePropertyMode), propertyBorderSize(this, "border", Vector2f(0,0), "The sizer border size", - &ewol::widget::Sizer::onChangePropertyBorderSize), + ewol::widget::Sizer::onChangePropertyBorderSize), propertyAnimation(this, "annimation", animationNone, "sizer annimation"), @@ -37,23 +37,23 @@ ewol::widget::Sizer::Sizer() : } ewol::widget::Sizer::~Sizer() { - //Log.debug("[" << getId() << "]={" << getObjectType() << "} sizer : destroy (mode=" << (propertyMode == ewol::widget::Sizer::modeVert?"Vert":"Hori") << ")"); + //Log.debug("[" + getId() + "]={" + getObjectType() + "} sizer : destroy (mode=" + (propertyMode == ewol::widget::Sizer::modeVert?"Vert":"Hori") + ")"); } void ewol::widget::Sizer::onChangeSize() { - ewol::Widget::onChangeSize(); - Vector2f tmpBorderSize = propertyBorderSize->getPixel(); - Log.verbose("[" << getId() << "] update size : " << m_size << " nbElement : " << m_subWidget.size() << " borderSize=" << tmpBorderSize << " from border=" << propertyBorderSize); - Vector2f localWidgetSize = m_size - tmpBorderSize*2.0f; + Widget::onChangeSize(); + Vector2f tmpBorderSize = propertyBorderSize.getPixel(); + Log.verbose("[" + getId() + "] update size : " + this.size + " nbElement : " + this.subWidget.size() + " borderSize=" + tmpBorderSize + " from border=" << propertyBorderSize); + Vector2f localWidgetSize = this.size - tmpBorderSize*2.0f; // -1- calculate min-size and expand requested: Vector2f minSize(0.0f, 0.0f); Vector2i nbWidgetExpand(0,0); - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - Vector2f tmpSize = it->getCalculateMinSize(); + Vector2f tmpSize = it.getCalculateMinSize(); if (*propertyMode == ewol::widget::Sizer::modeVert) { minSize = Vector2f(etk::max(minSize.x(), tmpSize.x()), minSize.y() + tmpSize.y()); @@ -61,7 +61,7 @@ void ewol::widget::Sizer::onChangeSize() { minSize = Vector2f(minSize.x() + tmpSize.x(), etk::max(minSize.y(), tmpSize.y())); } - Vector2b expand = it->canExpand(); + Vector2b expand = it.canExpand(); nbWidgetExpand += Vector2i(expand.x()==true?1:0, expand.y()==true?1:0); } @@ -78,30 +78,30 @@ void ewol::widget::Sizer::onChangeSize() { } } // -3- Configure all at the min size ... - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - it->setSize(it->getCalculateMinSize()); + it.setSize(it.getCalculateMinSize()); } // -4- For each element we apply the minmax range and update if needed while (deltaExpandSize > 0.0001f) { float residualNext = 0.0f; // get the number of element that need to devide... - int32_t countCalculation = nbWidgetExpand.x(); + int countCalculation = nbWidgetExpand.x(); if (*propertyMode == ewol::widget::Sizer::modeVert) { countCalculation = nbWidgetExpand.y(); } // -4.1- Update every subWidget size - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - Vector2f tmpSizeMin = it->getSize(); - Vector2f tmpSizeMax = it->getCalculateMaxSize(); + Vector2f tmpSizeMin = it.getSize(); + Vector2f tmpSizeMax = it.getCalculateMaxSize(); // Now update his size his size in X and the curent sizer size in Y: if (*propertyMode == ewol::widget::Sizer::modeVert) { - if (it->canExpand().y() == true) { + if (it.canExpand().y() == true) { float sizeExpand = tmpSizeMin.y() + deltaExpandSize; if (sizeExpand > tmpSizeMax.y()) { residualNext += (sizeExpand - tmpSizeMax.y()); @@ -110,9 +110,9 @@ void ewol::widget::Sizer::onChangeSize() { } tmpSizeMin.setY(sizeExpand); } - it->setSize(tmpSizeMin); + it.setSize(tmpSizeMin); } else { - if (it->canExpand().x() == true) { + if (it.canExpand().x() == true) { float sizeExpand = tmpSizeMin.x() + deltaExpandSize; if (sizeExpand > tmpSizeMax.x()) { residualNext += (sizeExpand - tmpSizeMax.x()); @@ -121,7 +121,7 @@ void ewol::widget::Sizer::onChangeSize() { } tmpSizeMin.setX(sizeExpand); } - it->setSize(tmpSizeMin); + it.setSize(tmpSizeMin); } } // Reset size add ... @@ -143,41 +143,41 @@ void ewol::widget::Sizer::onChangeSize() { } } // -5- Update the expand in the second size if vert ==> X and if hori ==> Y - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } // Now update his size his size in X and the curent sizer size in Y: if (*propertyMode == ewol::widget::Sizer::modeVert) { - if (it->canExpand().x() == false) { + if (it.canExpand().x() == false) { continue; } - Vector2f tmpSizeMin = it->getSize(); - tmpSizeMin.setX(etk::avg(tmpSizeMin.x(), localWidgetSize.x(), it->getCalculateMaxSize().x())); - it->setSize(tmpSizeMin); + Vector2f tmpSizeMin = it.getSize(); + tmpSizeMin.setX(etk::avg(tmpSizeMin.x(), localWidgetSize.x(), it.getCalculateMaxSize().x())); + it.setSize(tmpSizeMin); } else { - if (it->canExpand().y() == false) { + if (it.canExpand().y() == false) { continue; } - Vector2f tmpSizeMin = it->getSize(); - tmpSizeMin.setY(etk::avg(tmpSizeMin.y(), localWidgetSize.y(), it->getCalculateMaxSize().y())); - it->setSize(tmpSizeMin); + Vector2f tmpSizeMin = it.getSize(); + tmpSizeMin.setY(etk::avg(tmpSizeMin.y(), localWidgetSize.y(), it.getCalculateMaxSize().y())); + it.setSize(tmpSizeMin); } } // -6- Force size at the entire number: - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - it->setSize(Vector2fClipInt32(it->getSize())); + it.setSize(Vector2fClipInt32(it.getSize())); } // -7- get under Size Vector2f underSize(0,0); - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - Vector2f size = it->getSize(); + Vector2f size = it.getSize(); if (*propertyMode == ewol::widget::Sizer::modeVert) { underSize += Vector2f(0.0f, size.y()); underSize.setX(etk::max(underSize.x(), size.x())); @@ -189,20 +189,20 @@ void ewol::widget::Sizer::onChangeSize() { Vector2f deltas = localWidgetSize - underSize; // -8- Calculate the local origin, depending of the gravity: - Vector2f tmpOrigin = m_origin + tmpBorderSize + ewol::gravityGenerateDelta(propertyGravity, deltas); + Vector2f tmpOrigin = this.origin + tmpBorderSize + ewol::gravityGenerateDelta(propertyGravity, deltas); // -9- Set sub widget origin: - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } Vector2f origin; - Vector2f size = it->getSize(); + Vector2f size = it.getSize(); if (*propertyMode == ewol::widget::Sizer::modeVert) { - origin = Vector2fClipInt32(tmpOrigin+m_offset + ewol::gravityGenerateDelta(propertyGravity, Vector2f(underSize.x()-size.x(),0.0f))); + origin = Vector2fClipInt32(tmpOrigin+this.offset + ewol::gravityGenerateDelta(propertyGravity, Vector2f(underSize.x()-size.x(),0.0f))); } else { - origin = Vector2fClipInt32(tmpOrigin+m_offset + ewol::gravityGenerateDelta(propertyGravity, Vector2f(0.0f, underSize.y()-size.y()))); + origin = Vector2fClipInt32(tmpOrigin+this.offset + ewol::gravityGenerateDelta(propertyGravity, Vector2f(0.0f, underSize.y()-size.y()))); } - it->setOrigin(origin); + it.setOrigin(origin); if (*propertyMode == ewol::widget::Sizer::modeVert) { tmpOrigin.setY(tmpOrigin.y() + size.y()); } else { @@ -210,52 +210,52 @@ void ewol::widget::Sizer::onChangeSize() { } } // -10- Update all subSize at every element: - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { if (it == null) { continue; } - it->onChangeSize(); + it.onChangeSize(); } markToRedraw(); } void ewol::widget::Sizer::calculateMinMaxSize() { - Log.verbose("[" << getId() << "] update minimum size"); - m_subExpend.setValue(false, false); - m_minSize = propertyMinSize->getPixel(); - Vector2f tmpBorderSize = propertyBorderSize->getPixel(); - Log.verbose("[" << getId() << "] {" << getObjectType() << "} set min size : " << m_minSize); - for (auto &it : m_subWidget) { + Log.verbose("[" + getId() + "] update minimum size"); + this.subExpend.setValue(false, false); + this.minSize = propertyMinSize.getPixel(); + Vector2f tmpBorderSize = propertyBorderSize.getPixel(); + Log.verbose("[" + getId() + "] {" + getObjectType() + "} set min size : " + this.minSize); + for (auto it : this.subWidget) { if (it == null) { continue; } - it->calculateMinMaxSize(); - if (it->canExpand().x() == true) { - m_subExpend.setX(true); + it.calculateMinMaxSize(); + if (it.canExpand().x() == true) { + this.subExpend.setX(true); } - if (it->canExpand().y() == true) { - m_subExpend.setY(true); + if (it.canExpand().y() == true) { + this.subExpend.setY(true); } - Vector2f tmpSize = it->getCalculateMinSize(); - Log.verbose("[" << getId() << "] NewMinSize=" << tmpSize); - Log.verbose("[" << getId() << "] {" << getObjectType() << "} Get minSize="<< tmpSize); + Vector2f tmpSize = it.getCalculateMinSize(); + Log.verbose("[" + getId() + "] NewMinSize=" + tmpSize); + Log.verbose("[" + getId() + "] {" + getObjectType() + "} Get minSize="+ tmpSize); if (*propertyMode == ewol::widget::Sizer::modeVert) { - m_minSize.setY(m_minSize.y() + tmpSize.y()); - if (tmpSize.x()>m_minSize.x()) { - m_minSize.setX(tmpSize.x()); + this.minSize.setY(this.minSize.y() + tmpSize.y()); + if (tmpSize.x()>this.minSize.x()) { + this.minSize.setX(tmpSize.x()); } } else { - m_minSize.setX(m_minSize.x() + tmpSize.x()); - if (tmpSize.y()>m_minSize.y()) { - m_minSize.setY(tmpSize.y()); + this.minSize.setX(this.minSize.x() + tmpSize.x()); + if (tmpSize.y()>this.minSize.y()) { + this.minSize.setY(tmpSize.y()); } } } - m_minSize += tmpBorderSize*2; - //Log.error("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize); + this.minSize += tmpBorderSize*2; + //Log.error("[" + getId() + "] {" + getObjectType() + "} Result min size : " + this.minSize); } -int32_t ewol::widget::Sizer::subWidgetAdd(ewol::WidgetShared _newWidget) { +int ewol::widget::Sizer::subWidgetAdd(Widget _newWidget) { if (*propertyAnimation == animationNone) { return ewol::widget::ContainerN::subWidgetAdd(_newWidget); } @@ -263,7 +263,7 @@ int32_t ewol::widget::Sizer::subWidgetAdd(ewol::WidgetShared _newWidget) { return ewol::widget::ContainerN::subWidgetAdd(_newWidget); } -int32_t ewol::widget::Sizer::subWidgetAddStart(ewol::WidgetShared _newWidget) { +int ewol::widget::Sizer::subWidgetAddStart(Widget _newWidget) { if (*propertyAnimation == animationNone) { return ewol::widget::ContainerN::subWidgetAddStart(_newWidget); } @@ -271,7 +271,7 @@ int32_t ewol::widget::Sizer::subWidgetAddStart(ewol::WidgetShared _newWidget) { return ewol::widget::ContainerN::subWidgetAddStart(_newWidget); } -void ewol::widget::Sizer::subWidgetRemove(ewol::WidgetShared _newWidget) { +void ewol::widget::Sizer::subWidgetRemove(Widget _newWidget) { if (*propertyAnimation == animationNone) { ewol::widget::ContainerN::subWidgetRemove(_newWidget); return; @@ -280,7 +280,7 @@ void ewol::widget::Sizer::subWidgetRemove(ewol::WidgetShared _newWidget) { ewol::widget::ContainerN::subWidgetRemove(_newWidget); } -void ewol::widget::Sizer::subWidgetUnLink(ewol::WidgetShared _newWidget) { +void ewol::widget::Sizer::subWidgetUnLink(Widget _newWidget) { if (*propertyAnimation == animationNone) { ewol::widget::ContainerN::subWidgetUnLink(_newWidget); return; diff --git a/src/org/atriasoft/ewol/widget/Sizer.java b/src/org/atriasoft/ewol/widget/Sizer.java index 8edaa27..9f6145b 100644 --- a/src/org/atriasoft/ewol/widget/Sizer.java +++ b/src/org/atriasoft/ewol/widget/Sizer.java @@ -15,7 +15,7 @@ namespace ewol { namespace widget { class Sizer; - using SizerShared = ememory::SharedPtr; + using Sizer = ememory::Ptr; using SizerWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -50,18 +50,18 @@ namespace ewol { /** * @brief Destructor */ - virtual ~Sizer(); + ~Sizer(); public: - void onChangeSize() override; - void calculateMinMaxSize() override; + void onChangeSize() ; + void calculateMinMaxSize() ; // overwrite the set fuction to start annimations ... - int32_t subWidgetAdd(ewol::WidgetShared _newWidget) override; - int32_t subWidgetAddStart(ewol::WidgetShared _newWidget) override; - void subWidgetRemove(ewol::WidgetShared _newWidget) override; - void subWidgetUnLink(ewol::WidgetShared _newWidget) override; + int subWidgetAdd(Widget _newWidget) ; + int subWidgetAddStart(Widget _newWidget) ; + void subWidgetRemove(Widget _newWidget) ; + void subWidgetUnLink(Widget _newWidget) ; protected: - virtual void onChangePropertyMode(); - virtual void onChangePropertyBorderSize(); + void onChangePropertyMode(); + void onChangePropertyBorderSize(); }; } } diff --git a/src/org/atriasoft/ewol/widget/Slider.cpp b/src/org/atriasoft/ewol/widget/Slider.cpp index f106f2d..936d946 100644 --- a/src/org/atriasoft/ewol/widget/Slider.cpp +++ b/src/org/atriasoft/ewol/widget/Slider.cpp @@ -10,32 +10,32 @@ #include ETK_DECLARE_TYPE(ewol::widget::Slider); -const int32_t dotRadius = 6; + int dotRadius = 6; ewol::widget::Slider::Slider() : signalChange(this, "change", ""), propertyValue(this, "value", 0.0f, "Value of the Slider", - &ewol::widget::Slider::onChangePropertyValue), + ewol::widget::Slider::onChangePropertyValue), propertyMinimum(this, "min", 0.0f, "Minium value", - &ewol::widget::Slider::onChangePropertyMinimum), + ewol::widget::Slider::onChangePropertyMinimum), propertyMaximum(this, "max", 10.0f, "Maximum value", - &ewol::widget::Slider::onChangePropertyMaximum), + ewol::widget::Slider::onChangePropertyMaximum), propertyStep(this, "step", 1.0f, "Step size", - &ewol::widget::Slider::onChangePropertyStep) { + ewol::widget::Slider::onChangePropertyStep) { addObjectType("ewol::widget::Slider"); - m_textColorFg = etk::color::black; + this.textColorFg = etk::color::black; - m_textColorBg = etk::color::black; - m_textColorBg.setA(0x3F); + this.textColorBg = etk::color::black; + this.textColorBg.setA(0x3F); propertyCanFocus.setDirectCheck(true); // Limit event at 1: @@ -47,14 +47,14 @@ ewol::widget::Slider::~Slider() { } void ewol::widget::Slider::calculateMinMaxSize() { - Vector2f minTmp = propertyMinSize->getPixel(); - m_minSize.setValue(etk::max(minTmp.x(), 40.0f), + Vector2f minTmp = propertyMinSize.getPixel(); + this.minSize.setValue(etk::max(minTmp.x(), 40.0f), etk::max(minTmp.y(), dotRadius*2.0f) ); markToRedraw(); } void ewol::widget::Slider::onDraw() { - m_draw.draw(); + this.draw.draw(); } void ewol::widget::Slider::onRegenerateDisplay() { @@ -62,35 +62,35 @@ void ewol::widget::Slider::onRegenerateDisplay() { return; } // clean the object list ... - m_draw.clear(); - m_draw.setColor(m_textColorFg); + this.draw.clear(); + this.draw.setColor(this.textColorFg); // draw a line : - m_draw.setThickness(1); - m_draw.setPos(Vector3f(dotRadius, m_size.y()/2, 0) ); - m_draw.lineTo(Vector3f(m_size.x()-dotRadius, m_size.y()/2, 0) ); - m_draw.setThickness(0); + this.draw.setThickness(1); + this.draw.setPos(Vector3f(dotRadius, this.size.y()/2, 0) ); + this.draw.lineTo(Vector3f(this.size.x()-dotRadius, this.size.y()/2, 0) ); + this.draw.setThickness(0); - etk::Color<> borderDot = m_textColorFg; + etk::Color<> borderDot = this.textColorFg; borderDot.setA(borderDot.a()/2); - m_draw.setPos(Vector3f(4+((propertyValue-propertyMinimum)/(propertyMaximum-propertyMinimum))*(m_size.x()-2*dotRadius), m_size.y()/2, 0) ); - m_draw.setColorBg(borderDot); - m_draw.circle(dotRadius); - m_draw.setColorBg(m_textColorFg); - m_draw.circle(dotRadius/1.6); + this.draw.setPos(Vector3f(4+((propertyValue-propertyMinimum)/(propertyMaximum-propertyMinimum))*(this.size.x()-2*dotRadius), this.size.y()/2, 0) ); + this.draw.setColorBg(borderDot); + this.draw.circle(dotRadius); + this.draw.setColorBg(this.textColorFg); + this.draw.circle(dotRadius/1.6); } -bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::Slider::onEventInput( ewol::event::Input _event) { Vector2f relativePos = relativePosition(_event.getPos()); - //Log.debug("Event on Slider ..." << _event); + //Log.debug("Event on Slider ..." + _event); if (1 == _event.getId()) { - if( gale::key::status::pressSingle == _event.getStatus() - || gale::key::status::move == _event.getStatus()) { + if( KeyStatus::pressSingle == _event.getStatus() + || KeyStatus::move == _event.getStatus()) { // get the new position : - Log.verbose("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")"); + Log.verbose("Event on Slider (" + relativePos.x() + "," + relativePos.y() + ")"); float oldValue = *propertyValue; - updateValue(*propertyMinimum + (float)(relativePos.x() - dotRadius) / (m_size.x()-2*dotRadius) * (*propertyMaximum-*propertyMinimum)); + updateValue(*propertyMinimum + (float)(relativePos.x() - dotRadius) / (this.size.x()-2*dotRadius) * (*propertyMaximum-*propertyMinimum)); if (oldValue != *propertyValue) { - Log.verbose(" new value : " << *propertyValue << " in [" << *propertyMinimum << ".." << *propertyMaximum << "]"); + Log.verbose(" new value : " + *propertyValue + " in [" + *propertyMinimum + ".." + *propertyMaximum + "]"); signalChange.emit(*propertyValue); } return true; @@ -104,7 +104,7 @@ void ewol::widget::Slider::updateValue(float _newValue) { if (*propertyStep == 0.0f) { propertyValue.setDirect(_newValue); } else { - float basicVal = (int64_t)(_newValue / *propertyStep); + float basicVal = (long)(_newValue / *propertyStep); propertyValue.setDirect(basicVal * *propertyStep); } markToRedraw(); diff --git a/src/org/atriasoft/ewol/widget/Slider.java b/src/org/atriasoft/ewol/widget/Slider.java index 3ef1874..6a2c1c1 100644 --- a/src/org/atriasoft/ewol/widget/Slider.java +++ b/src/org/atriasoft/ewol/widget/Slider.java @@ -15,16 +15,16 @@ namespace ewol { namespace widget { class Slider; - using SliderShared = ememory::SharedPtr; + using Slider = ememory::Ptr; using SliderWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class Slider : public ewol::Widget { + class Slider : public Widget { public: // signals esignal::Signal signalChange; public: - //eproperty::Value propertyShape; //!< name of the shape used + //eproperty::Value propertyShape; //!< name of the shape used eproperty::Value propertyValue; //!< current value of the Slider eproperty::Value propertyMinimum; //!< minimum value of the slider eproperty::Value propertyMaximum; //!< maximum value of the slider @@ -33,27 +33,27 @@ namespace ewol { Slider(); public: DECLARE_WIDGET_FACTORY(Slider, "Slider"); - virtual ~Slider(); + ~Slider(); public: // TODO : Rewoek the color in the theme ... void setColor(etk::Color<> _newColor) { - m_textColorFg = _newColor; + this.textColorFg = _newColor; }; protected: - ewol::compositing::Drawing m_draw; //!< drawing tool. - etk::Color<> m_textColorFg; //!< Text color - etk::Color<> m_textColorBg; //!< Background color + ewol::compositing::Drawing this.draw; //!< drawing tool. + etk::Color<> this.textColorFg; //!< Text color + etk::Color<> this.textColorBg; //!< Background color void updateValue(float _newValue); public: // Derived function - void onDraw() override; - void calculateMinMaxSize() override; - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; + void onDraw() ; + void calculateMinMaxSize() ; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; protected: - virtual void onChangePropertyValue(); - virtual void onChangePropertyMinimum(); - virtual void onChangePropertyMaximum(); - virtual void onChangePropertyStep(); + void onChangePropertyValue(); + void onChangePropertyMinimum(); + void onChangePropertyMaximum(); + void onChangePropertyStep(); }; } } diff --git a/src/org/atriasoft/ewol/widget/Spacer.cpp b/src/org/atriasoft/ewol/widget/Spacer.cpp index 18b0536..cd9dba1 100644 --- a/src/org/atriasoft/ewol/widget/Spacer.cpp +++ b/src/org/atriasoft/ewol/widget/Spacer.cpp @@ -15,7 +15,7 @@ ewol::widget::Spacer::Spacer() : propertyColor(this, "color", etk::color::none, "background of the spacer", - &ewol::widget::Spacer::onChangePropertyColor) { + ewol::widget::Spacer::onChangePropertyColor) { addObjectType("ewol::widget::Spacer"); propertyMinSize.setDirectCheck(gale::Dimension(Vector2f(10,10))); propertyCanFocus.setDirectCheck(true); @@ -26,7 +26,7 @@ ewol::widget::Spacer::~Spacer() { } void ewol::widget::Spacer::onDraw() { - m_draw.draw(); + this.draw.draw(); } #define BORDER_SIZE_TMP (4) @@ -34,14 +34,14 @@ void ewol::widget::Spacer::onRegenerateDisplay() { if (false == needRedraw()) { return; } - m_draw.clear(); + this.draw.clear(); - if (propertyColor->a() == 0) { + if (propertyColor.a() == 0) { return; } - m_draw.setColor(propertyColor); - m_draw.setPos(Vector3f(0, 0, 0) ); - m_draw.rectangleWidth(Vector3f(m_size.x(), m_size.y(),0) ); + this.draw.setColor(propertyColor); + this.draw.setPos(Vector3f(0, 0, 0) ); + this.draw.rectangleWidth(Vector3f(this.size.x(), this.size.y(),0) ); } void ewol::widget::Spacer::onChangePropertyColor() { diff --git a/src/org/atriasoft/ewol/widget/Spacer.java b/src/org/atriasoft/ewol/widget/Spacer.java index 479f1e8..a426f27 100644 --- a/src/org/atriasoft/ewol/widget/Spacer.java +++ b/src/org/atriasoft/ewol/widget/Spacer.java @@ -15,17 +15,17 @@ namespace ewol { namespace widget { class Spacer; - using SpacerShared = ememory::SharedPtr; + using Spacer = ememory::Ptr; using SpacerWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ - class Spacer : public ewol::Widget { + class Spacer : public Widget { public: // properties: eproperty::Value> propertyColor; //!< Background color protected: /** - * @brief Main constructer + * @brief Main ructer */ Spacer(); public: @@ -33,17 +33,17 @@ namespace ewol { /** * @brief Main destructer */ - virtual ~Spacer(); + ~Spacer(); private: - ewol::compositing::Drawing m_draw; //!< Compositing drawing element + ewol::compositing::Drawing this.draw; //!< Compositing drawing element public: - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override { + Widget getWidgetAtPos( Vector2f _pos) { return null; }; - void onRegenerateDisplay() override; - void onDraw() override; + void onRegenerateDisplay() ; + void onDraw() ; protected: - virtual void onChangePropertyColor(); + void onChangePropertyColor(); }; } } diff --git a/src/org/atriasoft/ewol/widget/Spin.cpp b/src/org/atriasoft/ewol/widget/Spin.cpp index d4167f4..85579f1 100644 --- a/src/org/atriasoft/ewol/widget/Spin.cpp +++ b/src/org/atriasoft/ewol/widget/Spin.cpp @@ -20,23 +20,23 @@ ewol::widget::Spin::Spin() : propertyValue(this, "value", 0, "Value of the Spin", - &ewol::widget::Spin::onChangePropertyValue), + ewol::widget::Spin::onChangePropertyValue), propertyMin(this, "min", -9999999999, "Minimum value of the spin", - &ewol::widget::Spin::onChangePropertyMin), + ewol::widget::Spin::onChangePropertyMin), propertyMax(this, "max", 9999999999, "Maximum value of the spin", - &ewol::widget::Spin::onChangePropertyMax), + ewol::widget::Spin::onChangePropertyMax), propertyIncrement(this, "increment", 1, "Increment value at each button event or keybord event", - &ewol::widget::Spin::onChangePropertyIncrement), + ewol::widget::Spin::onChangePropertyIncrement), propertyMantis(this, "mantis", 0, "fix-point mantis", - &ewol::widget::Spin::onChangePropertyMantis) { + ewol::widget::Spin::onChangePropertyMantis) { addObjectType("ewol::widget::Spin"); propertyShape.setDirectCheck(etk::Uri("THEME_GUI:///Spin.json?lib=ewol")); } @@ -47,7 +47,7 @@ ewol::widget::Spin::~Spin() { void ewol::widget::Spin::onChangePropertyValue() { markToRedraw(); - if (m_widgetEntry == null) { + if (this.widgetEntry == null) { Log.error("Can not acces at entry ..."); return; } @@ -71,36 +71,36 @@ void ewol::widget::Spin::onChangePropertyMantis() { } void ewol::widget::Spin::updateGui() { - EWOL_WARNING("updateGui [START]"); + Log.warning("updateGui [START]"); ewol::widget::SpinBase::updateGui(); - if ( m_widgetEntry != null - && m_connectionEntry.isConnected() == false) { + if ( this.widgetEntry != null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionEntry.isConnected() == false) { } - if ( m_widgetButtonUp != null - && m_connectionButtonUp.isConnected() == false) { - m_connectionButtonUp = m_widgetButtonUp->signalPressed.connect(this, &ewol::widget::Spin::onCallbackUp); + if ( this.widgetButtonUp != null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButtonUp.isConnected() == false) { + this.connectionButtonUp = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Spin::onCallbackUp); } - if ( m_widgetButtonDown != null - && m_connectionButtonDown.isConnected() == false) { - m_connectionButtonDown = m_widgetButtonDown->signalPressed.connect(this, &ewol::widget::Spin::onCallbackDown); + if ( this.widgetButtonDown != null + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButtonDown.isConnected() == false) { + this.connectionButtonDown = this.widgetButtonDown.signalPressed.connect(this, ewol::widget::Spin::onCallbackDown); } - EWOL_WARNING("updateGui [STOP]"); + Log.warning("updateGui [STOP]"); } -void ewol::widget::Spin::checkValue(int64_t _value) { +void ewol::widget::Spin::checkValue(long _value) { _value = etk::avg(propertyMin.get(), _value, propertyMax.get()); propertyValue.setDirect(_value); - m_widgetEntry->propertyValue.set(etk::toString(_value)); + this.widgetEntry.propertyValue.set(etk::toString(_value)); } void ewol::widget::Spin::onCallbackUp() { - int64_t value = propertyValue.get() + propertyIncrement.get(); + long value = propertyValue.get() + propertyIncrement.get(); checkValue(value); } void ewol::widget::Spin::onCallbackDown() { - int64_t value = propertyValue.get() - propertyIncrement.get(); + long value = propertyValue.get() - propertyIncrement.get(); checkValue(value); } diff --git a/src/org/atriasoft/ewol/widget/Spin.java b/src/org/atriasoft/ewol/widget/Spin.java index 5fbe49e..ea58159 100644 --- a/src/org/atriasoft/ewol/widget/Spin.java +++ b/src/org/atriasoft/ewol/widget/Spin.java @@ -12,7 +12,7 @@ namespace ewol { namespace widget { class Spin; - using SpinShared = ememory::SharedPtr; + using Spin = ememory::Ptr; using SpinWeak = ememory::WeakPtr; /** * @brief a composed Spin is a Spin with an inside composed with the specify XML element @@ -21,13 +21,13 @@ namespace ewol { class Spin : public ewol::widget::SpinBase { public: // Event list of properties - esignal::Signal signalValue; + esignal::Signal signalValue; esignal::Signal signalValueDouble; public: - eproperty::Value propertyValue; //!< Current value of the Spin. - eproperty::Value propertyMin; //!< Minimum value - eproperty::Value propertyMax; //!< Maximum value - eproperty::Value propertyIncrement; //!< Increment value + eproperty::Value propertyValue; //!< Current value of the Spin. + eproperty::Value propertyMin; //!< Minimum value + eproperty::Value propertyMax; //!< Maximum value + eproperty::Value propertyIncrement; //!< Increment value eproperty::Value propertyMantis; //!< number of value under '.' value protected: /** @@ -41,23 +41,23 @@ namespace ewol { /** * @brief Destructor */ - virtual ~Spin(); + ~Spin(); protected: - virtual void checkValue(int64_t _value); - virtual void updateGui(); + void checkValue(long _value); + void updateGui(); protected: void onCallbackUp(); void onCallbackDown(); protected: - esignal::Connection m_connectionEntry; - esignal::Connection m_connectionButtonUp; - esignal::Connection m_connectionButtonDown; + esignal::Connection this.connectionEntry; + esignal::Connection this.connectionButtonUp; + esignal::Connection this.connectionButtonDown; protected: - virtual void onChangePropertyValue(); - virtual void onChangePropertyMin(); - virtual void onChangePropertyMax(); - virtual void onChangePropertyIncrement(); - virtual void onChangePropertyMantis(); + void onChangePropertyValue(); + void onChangePropertyMin(); + void onChangePropertyMax(); + void onChangePropertyIncrement(); + void onChangePropertyMantis(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/TreeView.cpp b/src/org/atriasoft/ewol/widget/TreeView.cpp index 402cf6e..62b0fb3 100644 --- a/src/org/atriasoft/ewol/widget/TreeView.cpp +++ b/src/org/atriasoft/ewol/widget/TreeView.cpp @@ -19,37 +19,37 @@ ewol::widget::TreeView::TreeView(): propertyOffsetTreeView(this, "offsetTreeView", 15, "Offset indentation for each node", - &ewol::widget::TreeView::onChangePropertyOffsetTreeView), + ewol::widget::TreeView::onChangePropertyOffsetTreeView), propertyIconTreeViewSize(this, "iconTreeViewSize", 20, "Size of the icon for treeView", - &ewol::widget::TreeView::onChangePropertyOffsetTreeView), + ewol::widget::TreeView::onChangePropertyOffsetTreeView), propertyTextIsDecorated(this, "textIsDecorated", true, "Text is draw as decorated mode", - &ewol::widget::TreeView::onChangePropertyTextDecorated) { + ewol::widget::TreeView::onChangePropertyTextDecorated) { addObjectType("ewol::widget::TreeView"); } void ewol::widget::TreeView::init() { ewol::widget::List::init(); propertyFill.set(Vector2b(true,false)); - addComposeElemnent("image_ChevronRight", ememory::makeShared("THEME_GUI:///ChevronRight.svg?lib=ewol")); - addComposeElemnent("image_ChevronMore", ememory::makeShared("THEME_GUI:///ChevronMore.svg?lib=ewol")); + addComposeElemnent("image_ChevronRight", ememory::make("THEME_GUI:///ChevronRight.svg?lib=ewol")); + addComposeElemnent("image_ChevronMore", ememory::make("THEME_GUI:///ChevronMore.svg?lib=ewol")); } ewol::widget::TreeView::~TreeView() { } -Vector2f ewol::widget::TreeView::calculateElementSize(const Vector2i& _pos) { +Vector2f ewol::widget::TreeView::calculateElementSize( Vector2i _pos) { auto tmpText = ememory::staticPointerCast(getComposeElemnent("text")); - etk::String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); + String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); float_t treeOffset = 0; if (_pos.x() == 0) { treeOffset += getData(ListRole::DistanceToRoot, _pos).getSafeNumber() * propertyOffsetTreeView.get(); #if 0 - bool haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); + boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); if (haveChild == true) { treeOffset += propertyOffsetTreeView.get(); } @@ -57,7 +57,7 @@ Vector2f ewol::widget::TreeView::calculateElementSize(const Vector2i& _pos) { treeOffset += propertyOffsetTreeView.get(); #endif } - etk::String iconName; + String iconName; float_t iconSize = 0; if (_pos.x() == 0) { iconName = getData(ListRole::Icon, _pos).getSafeString(); @@ -67,19 +67,19 @@ Vector2f ewol::widget::TreeView::calculateElementSize(const Vector2i& _pos) { } Vector3f textSize; if (propertyTextIsDecorated.get() == true) { - textSize = tmpText->calculateSizeDecorated(myTextToWrite); + textSize = tmpText.calculateSizeDecorated(myTextToWrite); } else { - textSize = tmpText->calculateSize(myTextToWrite); + textSize = tmpText.calculateSize(myTextToWrite); } Vector2i count = getMatrixSize(); return Vector2f(textSize.x() + treeOffset + iconSize, - etk::max(textSize.y(), iconSize) + m_paddingSizeY*2 + etk::max(textSize.y(), iconSize) + this.paddingSizeY*2 ); } -void ewol::widget::TreeView::drawElement(const Vector2i& _pos, const Vector2f& _start, const Vector2f& _size) { +void ewol::widget::TreeView::drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) { Vector2f posStart = _start; - etk::String iconName; + String iconName; etk::Color<> fg = getData(ListRole::FgColor, _pos).getSafeColor(); if (_pos.x() == 0) { auto value = getData(ListRole::DistanceToRoot, _pos); @@ -87,44 +87,44 @@ void ewol::widget::TreeView::drawElement(const Vector2i& _pos, const Vector2f& _ posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get()); } iconName = getData(ListRole::Icon, _pos).getSafeString(); - bool haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); + boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); if (haveChild == true) { - ememory::SharedPtr tmpImage = null; + ememory::Ptr tmpImage = null; if ( getData(ListRole::IsExpand, _pos).getSafeBoolean() == false) { tmpImage = ememory::staticPointerCast(getComposeElemnent("image_ChevronRight")); } else { tmpImage = ememory::staticPointerCast(getComposeElemnent("image_ChevronMore")); } if (tmpImage != null) { - tmpImage->setColor(fg); - tmpImage->setPos(posStart); - tmpImage->print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get())); + tmpImage.setColor(fg); + tmpImage.setPos(posStart); + tmpImage.print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get())); } } // move right posStart.setX(posStart.x() + propertyIconTreeViewSize.get()); } - etk::String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); + String myTextToWrite = getData(ListRole::Text, _pos).getSafeString(); auto backgroundVariant = getData(ListRole::BgColor, _pos); if (backgroundVariant.isColor() == true) { etk::Color<> bg = backgroundVariant.getColor(); auto BGOObjects = ememory::staticPointerCast(getComposeElemnent("drawing")); if (BGOObjects != null) { - BGOObjects->setColor(bg); - BGOObjects->setPos(_start); - BGOObjects->rectangleWidth(_size); + BGOObjects.setColor(bg); + BGOObjects.setPos(_start); + BGOObjects.rectangleWidth(_size); } } - posStart += Vector2f(m_paddingSizeX, m_paddingSizeY); + posStart += Vector2f(this.paddingSizeX, this.paddingSizeY); if (iconName != "") { auto tmpImage = ememory::staticPointerCast(getComposeElemnent(iconName)); if (tmpImage != null) { - tmpImage->setColor(fg); - tmpImage->setPos(posStart); - tmpImage->print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get())); + tmpImage.setColor(fg); + tmpImage.setPos(posStart); + tmpImage.print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get())); } else { - Log.error("can not get : " << iconName ); + Log.error("can not get : " + iconName ); } // move right posStart.setX(posStart.x() + propertyIconTreeViewSize.get()); @@ -132,12 +132,12 @@ void ewol::widget::TreeView::drawElement(const Vector2i& _pos, const Vector2f& _ if (myTextToWrite != "") { auto tmpText = ememory::staticPointerCast(getComposeElemnent("text")); if (tmpText != null) { - tmpText->setColor(fg); - tmpText->setPos(posStart); + tmpText.setColor(fg); + tmpText.setPos(posStart); if (propertyTextIsDecorated.get() == true) { - tmpText->printDecorated(myTextToWrite); + tmpText.printDecorated(myTextToWrite); } else { - tmpText->print(myTextToWrite); + tmpText.print(myTextToWrite); } } } @@ -151,8 +151,8 @@ void ewol::widget::TreeView::onChangePropertyOffsetTreeView() { markToRedraw(); } -bool ewol::widget::TreeView::onItemEvent(const ewol::event::Input& _event, const Vector2i& _pos, const Vector2f& _mousePosition) { - if (_event.getStatus() != gale::key::status::pressSingle) { +boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) { + if (_event.getStatus() != KeyStatus::pressSingle) { return false; } if (_event.getId() != 1) { @@ -161,9 +161,9 @@ bool ewol::widget::TreeView::onItemEvent(const ewol::event::Input& _event, const if (_pos.x() != 0) { return false; } - //Log.info("event: " << _event); + //Log.info("event: " + _event); Vector2f posStart = Vector2f(0,0); - bool haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); + boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); if (haveChild == false) { return false; } @@ -172,13 +172,13 @@ bool ewol::widget::TreeView::onItemEvent(const ewol::event::Input& _event, const posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get()); } // Inverse the display of Y - Log.verbose("check: " << Vector2f(_mousePosition.x(), m_listSizeY[_pos.y()] - _mousePosition.y()) - << " in " << posStart - << " -> " << (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get()))); + Log.verbose("check: " + Vector2f(_mousePosition.x(), this.listSizeY[_pos.y()] - _mousePosition.y()) + + " in " + posStart + + " . " + (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get()))); if ( _mousePosition.x() >= posStart.x() - && _mousePosition.x() <= posStart.x()+propertyIconTreeViewSize.get() - && m_listSizeY[_pos.y()] - _mousePosition.y() >= posStart.y() - && m_listSizeY[_pos.y()] - _mousePosition.y() <= propertyIconTreeViewSize.get() ) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _mousePosition.x() <= posStart.x()+propertyIconTreeViewSize.get() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listSizeY[_pos.y()] - _mousePosition.y() >= posStart.y() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listSizeY[_pos.y()] - _mousePosition.y() <= propertyIconTreeViewSize.get() ) { onItemExpandEvent(_pos); return true; } diff --git a/src/org/atriasoft/ewol/widget/TreeView.java b/src/org/atriasoft/ewol/widget/TreeView.java index 42642a6..fb0a7e3 100644 --- a/src/org/atriasoft/ewol/widget/TreeView.java +++ b/src/org/atriasoft/ewol/widget/TreeView.java @@ -15,7 +15,7 @@ namespace ewol { namespace widget { class TreeView; - using TreeViewShared = ememory::SharedPtr; + using TreeView = ememory::Ptr; using TreeViewWeak = ememory::WeakPtr; /** @@ -29,9 +29,9 @@ namespace ewol { eproperty::Value propertyTextIsDecorated; //!< Size of the icon. protected: TreeView(); - void init() override; + void init() ; public: - virtual ~TreeView(); + ~TreeView(); protected: /** * @brief Calculate an element size to extimate the render size. @@ -39,7 +39,7 @@ namespace ewol { * @param[in] _pos Position of colomn and Raw of the element. * @return The estimate size of the element. */ - Vector2f calculateElementSize(const Vector2i& _pos) override; + Vector2f calculateElementSize( Vector2i _pos) ; /** * @brief Draw an element in the specific size and position. * @param[in] _pos Position of colomn and Raw of the element. @@ -47,13 +47,13 @@ namespace ewol { * @param[in] _size Render raw size * @return The estimate size of the element. */ - void drawElement(const Vector2i& _pos, const Vector2f& _start, const Vector2f& _size) override; + void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) ; protected: - virtual void onChangePropertyOffsetTreeView(); - virtual void onChangePropertyTextDecorated(); + void onChangePropertyOffsetTreeView(); + void onChangePropertyTextDecorated(); - bool onItemEvent(const ewol::event::Input& _event, const Vector2i& _pos, const Vector2f& _mousePosition) override; - virtual void onItemExpandEvent(const Vector2i& _pos) { }; + boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ; + void onItemExpandEvent( Vector2i _pos) { }; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/WSlider.cpp b/src/org/atriasoft/ewol/widget/WSlider.cpp index 7e38294..d0cfccc 100644 --- a/src/org/atriasoft/ewol/widget/WSlider.cpp +++ b/src/org/atriasoft/ewol/widget/WSlider.cpp @@ -12,13 +12,13 @@ ETK_DECLARE_TYPE(enum ewol::widget::WSlider::sladingMode); ETK_DECLARE_TYPE(ewol::widget::WSlider); -static const char* l_listsladingMode[ewol::widget::WSlider::sladingTransition_count] = { +static char* l_listsladingMode[ewol::widget::WSlider::sladingTransition_count] = { "transition vertical", "transition horisantal" }; -etk::Stream& operator <<(etk::Stream& _os, const enum ewol::widget::WSlider::sladingMode _obj) { - _os << l_listsladingMode[_obj]; +etk::Stream operator +(etk::Stream _os, enum ewol::widget::WSlider::sladingMode _obj) { + _os + l_listsladingMode[_obj]; return _os; } @@ -31,15 +31,15 @@ ewol::widget::WSlider::WSlider() : propertyTransitionMode(this, "mode", sladingTransitionHori, "Transition mode of the slider", - &ewol::widget::WSlider::onChangePropertyTransitionMode), + ewol::widget::WSlider::onChangePropertyTransitionMode), propertySelectWidget(this, "select", "", "Select the requested widget to display", - &ewol::widget::WSlider::onChangePropertySelectWidget), - m_windowsSources(0), - m_windowsDestination(0), - m_windowsRequested(-1), - m_slidingProgress(1.0f) { + ewol::widget::WSlider::onChangePropertySelectWidget), + this.windowsSources(0), + this.windowsDestination(0), + this.windowsRequested(-1), + this.slidingProgress(1.0f) { addObjectType("ewol::widget::WSlider"); propertyTransitionMode.add(sladingTransitionVert, "vert"); propertyTransitionMode.add(sladingTransitionHori, "hori"); @@ -52,79 +52,79 @@ ewol::widget::WSlider::~WSlider() { void ewol::widget::WSlider::onChangeSize() { ewol::widget::ContainerN::onChangeSize(); - if (m_windowsDestination == m_windowsSources) { - auto it = m_subWidget.begin(); - it+= m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - (*it)->setOrigin(m_origin+m_offset); - (*it)->setSize(m_size); - (*it)->onChangeSize(); + if (this.windowsDestination == this.windowsSources) { + auto it = this.subWidget.begin(); + it+= this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + (*it).setOrigin(this.origin+this.offset); + (*it).setSize(this.size); + (*it).onChangeSize(); } } else { float factor = -1.0f; - if (m_windowsSources < m_windowsDestination) { + if (this.windowsSources < this.windowsDestination) { factor = 1.0f; } - auto it = m_subWidget.begin(); - it += m_windowsSources; - if ( it != m_subWidget.end() - && *it != null) { + auto it = this.subWidget.begin(); + it += this.windowsSources; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { if (*propertyTransitionMode == sladingTransitionHori) { - (*it)->setOrigin( Vector2f(m_origin.x() + factor*(m_size.x()*m_slidingProgress), - m_origin.y()) - + m_offset); + (*it).setOrigin( Vector2f(this.origin.x() + factor*(this.size.x()*this.slidingProgress), + this.origin.y()) + + this.offset); } else { - (*it)->setOrigin( Vector2f(m_origin.x(), - m_origin.y() + factor*(m_size.y()*m_slidingProgress)) - + m_offset); + (*it).setOrigin( Vector2f(this.origin.x(), + this.origin.y() + factor*(this.size.y()*this.slidingProgress)) + + this.offset); } - (*it)->setSize(m_size); - (*it)->onChangeSize(); + (*it).setSize(this.size); + (*it).onChangeSize(); } - it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { + it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { if (*propertyTransitionMode == sladingTransitionHori) { - (*it)->setOrigin( Vector2f(m_origin.x() + factor*(m_size.x()*m_slidingProgress - m_size.x()), - m_origin.y()) - + m_offset); + (*it).setOrigin( Vector2f(this.origin.x() + factor*(this.size.x()*this.slidingProgress - this.size.x()), + this.origin.y()) + + this.offset); } else { - (*it)->setOrigin( Vector2f(m_origin.x(), - m_origin.y() + factor*(m_size.y()*m_slidingProgress - m_size.y())) - + m_offset); + (*it).setOrigin( Vector2f(this.origin.x(), + this.origin.y() + factor*(this.size.y()*this.slidingProgress - this.size.y())) + + this.offset); } - (*it)->setSize(m_size); - (*it)->onChangeSize(); + (*it).setSize(this.size); + (*it).onChangeSize(); } } markToRedraw(); } -void ewol::widget::WSlider::subWidgetSelectSetVectorId(int32_t _id) { +void ewol::widget::WSlider::subWidgetSelectSetVectorId(int _id) { if (_id<0) { - Log.error("Can not change to a widget not present : vectID=" << _id); + Log.error("Can not change to a widget not present : vectID=" + _id); return; } - if (_id != m_windowsDestination) { - m_windowsRequested = _id; + if (_id != this.windowsDestination) { + this.windowsRequested = _id; signalStartSlide.emit(); - m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::WSlider::periodicCall); + this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::WSlider::periodicCall); markToRedraw(); } } -void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) { - size_t elementID = 0; +void ewol::widget::WSlider::subWidgetSelectSet(int _id) { + int elementID = 0; // search element in the list : - for (auto &it : m_subWidget) { + for (auto it : this.subWidget) { elementID ++; if (it != null) { - if (it->getId() == _id) { - if (it->propertyName.get() != "") { + if (it.getId() == _id) { + if (it.propertyName.get() != "") { // change the internal event parameter (in case...) ==> no event generation - propertySelectWidget.setDirect(it->propertyName.get()); + propertySelectWidget.setDirect(it.propertyName.get()); } else { propertySelectWidget.setDirect(""); } @@ -132,7 +132,7 @@ void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) { } } } - if (elementID < m_subWidget.size()) { + if (elementID < this.subWidget.size()) { subWidgetSelectSetVectorId(elementID); } else { subWidgetSelectSetVectorId(-1); @@ -141,19 +141,19 @@ void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) { } } -void ewol::widget::WSlider::subWidgetSelectSet(const ewol::WidgetShared& _widgetPointer) { +void ewol::widget::WSlider::subWidgetSelectSet( Widget _widgetPointer) { if (_widgetPointer == null) { Log.error("Can not change to a widget null"); return; } - int32_t iii = 0; - for (auto &it : m_subWidget) { + int iii = 0; + for (auto it : this.subWidget) { if ( it != null - && it == _widgetPointer) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM it == _widgetPointer) { subWidgetSelectSetVectorId(iii); - if (_widgetPointer->propertyName.get() != "") { + if (_widgetPointer.propertyName.get() != "") { // change the internal event parameter (in case...) ==> no event generation - propertySelectWidget.setDirect(_widgetPointer->propertyName.get()); + propertySelectWidget.setDirect(_widgetPointer.propertyName.get()); } else { propertySelectWidget.setDirect(""); } @@ -164,16 +164,16 @@ void ewol::widget::WSlider::subWidgetSelectSet(const ewol::WidgetShared& _widget Log.error("Can not change to a widget not present"); } -void ewol::widget::WSlider::subWidgetSelectSet(const etk::String& _widgetName) { +void ewol::widget::WSlider::subWidgetSelectSet( String _widgetName) { if (_widgetName == "") { Log.error("Can not change to a widget with no name (input)"); return; } - Log.verbose("Select a new sub-widget to dosplay : '" << _widgetName << "'"); - int32_t iii = 0; - for (auto &it : m_subWidget) { + Log.verbose("Select a new sub-widget to dosplay : '" + _widgetName + "'"); + int iii = 0; + for (auto it : this.subWidget) { if ( it != null - && it->propertyName.get() == _widgetName) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM it.propertyName.get() == _widgetName) { subWidgetSelectSetVectorId(iii); // change the internal event parameter (in case...) ==> no event generation propertySelectWidget.setDirect(_widgetName); @@ -183,107 +183,107 @@ void ewol::widget::WSlider::subWidgetSelectSet(const etk::String& _widgetName) { } Log.error("Can not change to a widget not present"); } -void ewol::widget::WSlider::periodicCall(const ewol::event::Time& _event) { - Log.error("Periodic: " << m_slidingProgress << "/1.0 " << m_windowsSources << " ==> " << m_windowsDestination << " " << _event); - if (m_slidingProgress >= 1.0) { - m_windowsSources = m_windowsDestination; - if( m_windowsRequested != -1 - && m_windowsRequested != m_windowsSources) { - m_windowsDestination = m_windowsRequested; - m_slidingProgress = 0.0; +void ewol::widget::WSlider::periodicCall( ewol::event::Time _event) { + Log.error("Periodic: " + this.slidingProgress + "/1.0 " + this.windowsSources + " ==> " + this.windowsDestination + " " + _event); + if (this.slidingProgress >= 1.0) { + this.windowsSources = this.windowsDestination; + if( this.windowsRequested != -1 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.windowsRequested != this.windowsSources) { + this.windowsDestination = this.windowsRequested; + this.slidingProgress = 0.0; } else { // end of periodic : - m_PCH.disconnect(); + this.PCH.disconnect(); signalStopSlide.emit(); } - m_windowsRequested = -1; + this.windowsRequested = -1; } - if (m_slidingProgress < 1.0) { - if ( m_windowsRequested != -1 - && m_slidingProgress<0.5 ) { + if (this.slidingProgress < 1.0) { + if ( this.windowsRequested != -1 + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.slidingProgress<0.5 ) { // invert sources with destination - int32_t tmppp = m_windowsDestination; - m_windowsDestination = m_windowsSources; - m_windowsSources = tmppp; - m_slidingProgress = 1.0f - m_slidingProgress; - if (m_windowsRequested == m_windowsDestination) { - m_windowsRequested = -1; + int tmppp = this.windowsDestination; + this.windowsDestination = this.windowsSources; + this.windowsSources = tmppp; + this.slidingProgress = 1.0f - this.slidingProgress; + if (this.windowsRequested == this.windowsDestination) { + this.windowsRequested = -1; } } - m_slidingProgress += _event.getDeltaCall()/propertyTransitionSpeed; - m_slidingProgress = etk::avg(0.0f, m_slidingProgress, 1.0f); + this.slidingProgress += _event.getDeltaCall()/propertyTransitionSpeed; + this.slidingProgress = etk::avg(0.0f, this.slidingProgress, 1.0f); } onChangeSize(); } -void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::WSlider::systemDraw( ewol::DrawProperty _displayProp) { if (*propertyHide == true){ // widget is hidden ... return; } // note : do not call the widget container == > overload this one ... - ewol::Widget::systemDraw(_displayProp); + Widget::systemDraw(_displayProp); // subwidget draw ewol::DrawProperty prop = _displayProp; - prop.limit(m_origin, m_size); + prop.limit(this.origin, this.size); - if (m_windowsDestination == m_windowsSources) { - //Log.debug("Draw : " << m_windowsDestination); - auto it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - //Log.info("Draw : [" << propertyName << "] t=" << getObjectType() << "o=" << m_origin << " s=" << m_size); - (*it)->systemDraw(prop); + if (this.windowsDestination == this.windowsSources) { + //Log.debug("Draw : " + this.windowsDestination); + auto it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + //Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + "o=" + this.origin + " s=" + this.size); + (*it).systemDraw(prop); } } else { - //Log.debug("Draw : " << m_windowsSources << "=>" << m_windowsDestination << "progress=" << ((float)m_slidingProgress/1000.) ); + //Log.debug("Draw : " + this.windowsSources + "=>" + this.windowsDestination + "progress=" + ((float)this.slidingProgress/1000.) ); // draw Sources : - auto it = m_subWidget.begin(); - it += m_windowsSources; - if ( it != m_subWidget.end() - && *it != null) { - (*it)->systemDraw(prop); + auto it = this.subWidget.begin(); + it += this.windowsSources; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + (*it).systemDraw(prop); } // draw Destination : - it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - (*it)->systemDraw(prop); + it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + (*it).systemDraw(prop); } } } void ewol::widget::WSlider::onRegenerateDisplay() { - if (m_windowsDestination == m_windowsSources) { - auto it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - (*it)->onRegenerateDisplay(); + if (this.windowsDestination == this.windowsSources) { + auto it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + (*it).onRegenerateDisplay(); } } else { - auto it = m_subWidget.begin(); - it += m_windowsSources; - if ( it != m_subWidget.end() - && *it != null) { - (*it)->onRegenerateDisplay(); + auto it = this.subWidget.begin(); + it += this.windowsSources; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + (*it).onRegenerateDisplay(); } - it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - (*it)->onRegenerateDisplay(); + it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + (*it).onRegenerateDisplay(); } } } void ewol::widget::WSlider::onChangePropertySelectWidget() { if (propertySelectWidget.get() != "") { - Log.error("SELECT new widget: " << propertySelectWidget.get()); + Log.error("SELECT new widget: " + propertySelectWidget.get()); subWidgetSelectSet(*propertySelectWidget); } } @@ -293,21 +293,21 @@ void ewol::widget::WSlider::onChangePropertyTransitionMode() { } -ewol::WidgetShared ewol::widget::WSlider::getWidgetAtPos(const Vector2f& _pos) { +Widget ewol::widget::WSlider::getWidgetAtPos( Vector2f _pos) { if (*propertyHide == true) { return null; } - if (m_windowsDestination == m_windowsSources) { - auto it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - Vector2f tmpSize = (*it)->getSize(); - Vector2f tmpOrigin = (*it)->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) + if (this.windowsDestination == this.windowsSources) { + auto it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + Vector2f tmpSize = (*it).getSize(); + Vector2f tmpOrigin = (*it).getOrigin(); + if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x()) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - ewol::WidgetShared tmpWidget = (*it)->getWidgetAtPos(_pos); + Widget tmpWidget = (*it).getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } @@ -315,32 +315,32 @@ ewol::WidgetShared ewol::widget::WSlider::getWidgetAtPos(const Vector2f& _pos) { } } } else { - auto it = m_subWidget.begin(); - it += m_windowsDestination; - if ( it != m_subWidget.end() - && *it != null) { - Vector2f tmpSize = (*it)->getSize(); - Vector2f tmpOrigin = (*it)->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) + auto it = this.subWidget.begin(); + it += this.windowsDestination; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + Vector2f tmpSize = (*it).getSize(); + Vector2f tmpOrigin = (*it).getOrigin(); + if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x()) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - ewol::WidgetShared tmpWidget = (*it)->getWidgetAtPos(_pos); + Widget tmpWidget = (*it).getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } return null; } } - it = m_subWidget.begin(); - it += m_windowsSources; - if ( it != m_subWidget.end() - && *it != null) { - Vector2f tmpSize = (*it)->getSize(); - Vector2f tmpOrigin = (*it)->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) + it = this.subWidget.begin(); + it += this.windowsSources; + if ( it != this.subWidget.end() + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { + Vector2f tmpSize = (*it).getSize(); + Vector2f tmpOrigin = (*it).getOrigin(); + if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x()) + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - ewol::WidgetShared tmpWidget = (*it)->getWidgetAtPos(_pos); + Widget tmpWidget = (*it).getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } diff --git a/src/org/atriasoft/ewol/widget/WSlider.java b/src/org/atriasoft/ewol/widget/WSlider.java index 917743a..d10c8d2 100644 --- a/src/org/atriasoft/ewol/widget/WSlider.java +++ b/src/org/atriasoft/ewol/widget/WSlider.java @@ -14,7 +14,7 @@ namespace ewol { namespace widget { class WSlider; - using WSliderShared = ememory::SharedPtr; + using WSlider = ememory::Ptr; using WSliderWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -32,56 +32,56 @@ namespace ewol { public: // properties: eproperty::Range propertyTransitionSpeed; //!< speed of the transition (default 1 == > 1s) eproperty::List propertyTransitionMode; //!< mode to slide the widgets - eproperty::Value propertySelectWidget; //!< current select configuration + eproperty::Value propertySelectWidget; //!< current select configuration protected: WSlider(); public: DECLARE_WIDGET_FACTORY(WSlider, "WSlider"); - virtual ~WSlider(); + ~WSlider(); private: - int32_t m_windowsSources; //!< widget source viewed - int32_t m_windowsDestination; //!< widget destinated viewed - int32_t m_windowsRequested; //!< widget destination requested when change in modification in progress - float m_slidingProgress; //!< ratio progression of a sliding + int this.windowsSources; //!< widget source viewed + int this.windowsDestination; //!< widget destinated viewed + int this.windowsRequested; //!< widget destination requested when change in modification in progress + float this.slidingProgress; //!< ratio progression of a sliding protected: /** * @brief Generate the move on the specific vector ID (This is not a public acces, because the vector can have some null pointer inside ...) * @param[in] _id Id in the vector */ - void subWidgetSelectSetVectorId(int32_t _id); + void subWidgetSelectSetVectorId(int _id); public: /** * @brief Select a new subwidget to display * @param[in] _id Id of the subwidget requested */ - void subWidgetSelectSet(int32_t _id); + void subWidgetSelectSet(int _id); /** * @brief Select a new subwidget to display * @param[in] _widgetPointer Pointer on the widget selected (must be added before) */ - void subWidgetSelectSet(const ewol::WidgetShared& _widgetPointer); + void subWidgetSelectSet( Widget _widgetPointer); /** * @brief Select a new subwidget to display * @param[in] _widgetName Name of the subwidget name */ - void subWidgetSelectSet(const etk::String& _widgetName); + void subWidgetSelectSet( String _widgetName); public: - void onChangeSize() override; - void systemDraw(const ewol::DrawProperty& _displayProp) override; - void onRegenerateDisplay() override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; + void onChangeSize() ; + void systemDraw( ewol::DrawProperty _displayProp) ; + void onRegenerateDisplay() ; + Widget getWidgetAtPos( Vector2f _pos) ; protected: - esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed + esignal::Connection this.PCH; //!< Periodic call handle to remove it when needed /** * @brief Periodic call to update grapgic display * @param[in] _event Time generic event */ - void periodicCall(const ewol::event::Time& _event); + void periodicCall( ewol::event::Time _event); protected: - virtual void onChangePropertySelectWidget(); - virtual void onChangePropertyTransitionMode(); + void onChangePropertySelectWidget(); + void onChangePropertyTransitionMode(); }; } - etk::Stream& operator <<(etk::Stream& _os, const enum ewol::widget::WSlider::sladingMode _obj); + etk::Stream operator +(etk::Stream _os, enum ewol::widget::WSlider::sladingMode _obj); } diff --git a/src/org/atriasoft/ewol/widget/Widget.cpp b/src/org/atriasoft/ewol/widget/Widget.cpp index e9926ad..8b13789 100644 --- a/src/org/atriasoft/ewol/widget/Widget.cpp +++ b/src/org/atriasoft/ewol/widget/Widget.cpp @@ -1,636 +1 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#include -#include -#include -#include -#include -#include -#include -#include -ETK_DECLARE_TYPE(ewol::Widget); - -ewol::Widget::Widget() : - propertyMinSize(this, "min-size", - gale::Dimension(Vector2f(0,0),gale::distance::pixel), - "User minimum size", - &ewol::Widget::onChangePropertyMinSize), - propertyMaxSize(this, "max-size", - gale::Dimension(Vector2f(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::distance::pixel), - "User maximum size", - &ewol::Widget::onChangePropertyMaxSize), - propertyExpand(this, "expand", - Vector2b(false,false), - "Request the widget Expand size wile space is available", - &ewol::Widget::onChangePropertyExpand), - propertyFill(this, "fill", - Vector2b(true,true), - "Fill the widget available size", - &ewol::Widget::onChangePropertyFill), - propertyHide(this, "hide", - false, - "The widget start hided", - &ewol::Widget::onChangePropertyHide), - propertyGravity(this, "gravity", - ewol::gravity_buttomLeft, - "Gravity orientation", - &ewol::Widget::onChangePropertyGravity), - // TODO : je pense que c'est une erreur, c'est surement un event to get the cocus ... - propertyCanFocus(this, "focus", - false, - "enable the widget to have the focus capacity", - &ewol::Widget::onChangePropertyCanFocus), - m_size(10,10), - m_minSize(0,0), - m_maxSize(Vector2f(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)), - m_offset(0,0), - m_zoom(1.0f), - m_origin(0,0), - m_hasFocus(false), - m_limitMouseEvent(3), - m_allowRepeatKeyboardEvent(true), - signalShortcut(this, "shortcut", ""), - m_needRegenerateDisplay(true), - m_grabCursor(false), - m_cursorDisplay(gale::context::cursor::arrow){ - addObjectType("ewol::Widget"); - - // TODO : Set a static interface for list ==> this methode create a multiple allocation - propertyGravity.add(ewol::gravity_center, "center"); - propertyGravity.add(ewol::gravity_topLeft, "top-left"); - propertyGravity.add(ewol::gravity_top, "top"); - propertyGravity.add(ewol::gravity_topRight, "top-right"); - propertyGravity.add(ewol::gravity_right, "right"); - propertyGravity.add(ewol::gravity_buttomRight, "buttom-right"); - propertyGravity.add(ewol::gravity_buttom, "buttom"); - propertyGravity.add(ewol::gravity_buttomLeft, "buttom-left"); - propertyGravity.add(ewol::gravity_left, "left"); -} - - -void ewol::Widget::onChangeSize() { - Log.verbose("[" << getId() << "] {" << getObjectType() << "} update size : " << m_size); - markToRedraw(); -} - -bool ewol::Widget::setFocus() { - Log.verbose("set focus (start) *propertyCanFocus=" << *propertyCanFocus << " m_hasFocus=" << m_hasFocus); - if (*propertyCanFocus == true) { - if (m_hasFocus == false) { - m_hasFocus = true; - onGetFocus(); - } - Log.verbose("set focus (stop) ret true"); - return true; - } - Log.verbose("set focus (stop) ret false"); - return false; -} - -bool ewol::Widget::rmFocus() { - if (*propertyCanFocus == true) { - if (m_hasFocus == true) { - m_hasFocus = false; - onLostFocus(); - } - return true; - } - return false; -} - -void ewol::Widget::keepFocus() { - getWidgetManager().focusKeep(ememory::dynamicPointerCast(sharedFromThis())); -} - -void ewol::Widget::setOffset(const Vector2f& _newVal) { - Log.info("Set offset: " << _newVal); - if (m_offset != _newVal) { - m_offset = _newVal; - markToRedraw(); - } -} - -/* - /--> _displayProp.m_windowsSize - *------------------------------------------------------* - | | - | m_size | - | / | - | *-----------------------* | - | ' ' | - | ' _displayProp.m_size ' | - | Viewport ' / ' | - | o---------'---------o ' | - | | ' | ' | - | | ' | ' | - | | ' | ' | - | | ' | ' | - | | *-----------------------* | - | | / | | - | | m_offset | | - | | | | - | o-------------------o | - | / | - | _displayProp.m_origin | - | | - *------------------------------------------------------* - / - (0,0) -*/ -void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) { - //Log.info("[" << getId() << "] Draw : [" << propertyName << "] t=" << getObjectType() << " o=" << m_origin << " s=" << m_size << " hide=" << propertyHide); - if (*propertyHide == true){ - // widget is hidden ... - return; - } - Vector2f displayOrigin = m_origin + m_offset; - - // check if the element is displayable in the windows : - if( _displayProp.m_windowsSize.x() < m_origin.x() - || _displayProp.m_windowsSize.y() < m_origin.y() ) { - // out of the windows == > nothing to display ... - return; - } - - ewol::DrawProperty tmpSize = _displayProp; - tmpSize.limit(m_origin, m_size); - if (tmpSize.m_size.x() <= 0 || tmpSize.m_size.y() <= 0) { - return; - } - glViewport( (int32_t)tmpSize.m_origin.x(), - (int32_t)tmpSize.m_origin.y(), - (int32_t)tmpSize.m_size.x(), - (int32_t)tmpSize.m_size.y()); - // special case, when origin < display origin, we need to cut the display : - Vector2i downOffset = m_origin - tmpSize.m_origin; - downOffset.setMin(Vector2i(0,0)); - - mat4 tmpTranslate = etk::matTranslate(Vector3fClipInt32(Vector3f(-tmpSize.m_size.x()/2+m_offset.x() + downOffset.x(), - -tmpSize.m_size.y()/2+m_offset.y() + downOffset.y(), - -1.0f))); - mat4 tmpScale = etk::matScale(Vector3f(m_zoom, m_zoom, 1.0f)); - mat4 tmpProjection = etk::matOrtho((int32_t)(-tmpSize.m_size.x())>>1, - (int32_t)( tmpSize.m_size.x())>>1, - (int32_t)(-tmpSize.m_size.y())>>1, - (int32_t)( tmpSize.m_size.y())>>1, - (int32_t)(-1), - (int32_t)( 1)); - mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; - - gale::openGL::push(); - // set internal matrix system : - gale::openGL::setMatrix(tmpMat); - //int64_t ___startTime = ewol::getTime(); - onDraw(); - - #ifdef old_PLOP - if( (_displayProp.m_origin.x() > m_origin.x()) - || (_displayProp.m_origin.x() + _displayProp.m_size.x() < m_size.x() + m_origin.x()) ) { - // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left - int32_t tmpOriginX = etk::max(_displayProp.m_origin.x(), m_origin.x()); - int32_t tmppp1 = _displayProp.m_origin.x() + _displayProp.m_size.x(); - int32_t tmppp2 = m_origin.x() + m_size.x(); - int32_t tmpclipX = etk::min(tmppp1, tmppp2) - tmpOriginX; - - int32_t tmpOriginY = etk::max(_displayProp.m_origin.y(), m_origin.y()); - tmppp1 = _displayProp.m_origin.y() + _displayProp.m_size.y(); - tmppp2 = m_origin.y() + m_size.y(); - //int32_t tmpclipY = etk::min(tmppp1, tmppp2) - tmpOriginX; - - glViewport( tmpOriginX, - tmpOriginY, - tmpclipX, - m_size.y()); - mat4 tmpTranslate = etk::matTranslate(Vector3f((float)(-tmpclipX/2 - (tmpOriginX-m_origin.x())), (float)(-m_size.y()/2.0), -1.0f)); - mat4 tmpScale = etk::matScale(Vector3f(m_zoom, m_zoom, 1)); - mat4 tmpProjection = etk::matOrtho(-tmpclipX/2, tmpclipX/2, -m_size.y()/2, m_size.y()/2, -1, 1); - mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; - // set internal matrix system : - gale::openGL::setMatrix(tmpMat); - //int64_t ___startTime = ewol::getTime(); - onDraw(); - //float ___localTime = (float)(ewol::getTime() - ___startTime) / 1000.0f; - //Log.debug(" Widget1 : " << ___localTime << "ms "); - } else { - Log.debug("rasta.."); - glViewport( m_origin.x(), - m_origin.y(), - m_size.x(), - m_size.y()); - mat4 tmpTranslate = etk::matTranslate(Vector3f(-m_size.x()/2, -m_size.y()/2, -1.0f)); - mat4 tmpScale = etk::matScale(Vector3f(m_zoom, m_zoom, 1.0f)); - mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1); - mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; - // set internal matrix system : - gale::openGL::setMatrix(tmpMat); - //int64_t ___startTime = ewol::getTime(); - onDraw(); - //float ___localTime = (float)(ewol::getTime() - ___startTime) / 1000.0f; - //Log.debug(" Widget2 : " << ___localTime << "ms "); - } - #endif - gale::openGL::pop(); - return; -} - -void ewol::Widget::markToRedraw() { - if (m_needRegenerateDisplay == true) { - return; - } - m_needRegenerateDisplay = true; - getWidgetManager().markDrawingIsNeeded(); -} - -void ewol::Widget::setZoom(float _newVal) { - if (m_zoom == _newVal) { - return; - } - m_zoom = etk::avg(0.0000001f,_newVal,1000000.0f); - markToRedraw(); -} - -float ewol::Widget::getZoom() { - return m_zoom; -} - -void ewol::Widget::setOrigin(const Vector2f& _pos) { - #if DEBUG_LEVEL > 2 - if( m_origin.x() < -5000 - || m_origin.y() < -5000) { - EWOL_WARNING("[" << getId() << "] set origin < 5000 : " << m_origin); - } - #endif - m_origin = _pos; -} - -Vector2f ewol::Widget::getOrigin() { - return m_origin; -} - -Vector2f ewol::Widget::relativePosition(const Vector2f& _pos) { - return _pos - m_origin; -} - -void ewol::Widget::calculateMinMaxSize() { - m_minSize = propertyMinSize->getPixel(); - //Log.error("[" << getId() << "] convert in min size : " << propertyMinSize << " out=" << m_minSize); - m_maxSize = propertyMaxSize->getPixel(); - markToRedraw(); -} - -Vector2f ewol::Widget::getCalculateMinSize() { - if (*propertyHide == false) { - return m_minSize; - } - return Vector2f(0,0); -} - -Vector2f ewol::Widget::getCalculateMaxSize() { - if (*propertyHide == false) { - return m_maxSize; - } - return Vector2f(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE); -} - -void ewol::Widget::setNoMinSize() { - propertyMinSize.set(gale::Dimension(Vector2f(0,0),gale::distance::pixel)); -} - -void ewol::Widget::checkMinSize() { - Vector2f pixelSize = propertyMinSize->getPixel(); - m_minSize.setX(etk::max(m_minSize.x(), pixelSize.x())); - m_minSize.setY(etk::max(m_minSize.y(), pixelSize.y())); -} - -void ewol::Widget::setNoMaxSize() { - propertyMaxSize.set(gale::Dimension(Vector2f(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::distance::pixel)); -} - -void ewol::Widget::checkMaxSize() { - Vector2f pixelSize = propertyMaxSize->getPixel(); - m_maxSize.setX(etk::min(m_maxSize.x(), pixelSize.x())); - m_maxSize.setY(etk::min(m_maxSize.y(), pixelSize.y())); -} - -Vector2f ewol::Widget::getSize() { - if (*propertyHide == false) { - return m_size; - } - return Vector2f(0,0); -} - -Vector2b ewol::Widget::canExpand() { - if (*propertyHide == false) { - return *propertyExpand; - } - return Vector2b(false,false); -} - -const Vector2b& ewol::Widget::canFill() { - return *propertyFill; -} - -// ---------------------------------------------------------------------------------------------------------------- -// -- Shortcut : management of the shortcut -// ---------------------------------------------------------------------------------------------------------------- - -void ewol::Widget::shortCutAdd(const etk::String& _descriptiveString, const etk::String& _message) { - if (_descriptiveString.size() == 0) { - Log.error("try to add shortcut with no descriptive string ..."); - return; - } - EventShortCut tmpElement; - if (_message.size() == 0) { - tmpElement.message = _descriptiveString; - } else { - tmpElement.message = _message; - } - // parsing of the string: - //"ctrl+shift+alt+meta+s" - if(_descriptiveString.find("ctrl") != etk::String::npos) { - tmpElement.specialKey.setCtrlLeft(true); - } - if(_descriptiveString.find("shift") != etk::String::npos) { - tmpElement.specialKey.setShiftLeft(true); - } - if(_descriptiveString.find("alt") != etk::String::npos) { - tmpElement.specialKey.setAltLeft(true); - } - if(_descriptiveString.find("meta") != etk::String::npos) { - tmpElement.specialKey.setMetaLeft(true); - } - if(_descriptiveString.find("F12") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f12; - } else if(_descriptiveString.find("F11") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f11; - } else if(_descriptiveString.find("F10") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f10; - } else if(_descriptiveString.find("F9") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f9; - } else if(_descriptiveString.find("F8") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f8; - } else if(_descriptiveString.find("F7") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f7; - } else if(_descriptiveString.find("F6") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f6; - } else if(_descriptiveString.find("F5") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f5; - } else if(_descriptiveString.find("F4") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f4; - } else if(_descriptiveString.find("F3") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f3; - } else if(_descriptiveString.find("F2") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f2; - } else if(_descriptiveString.find("F1") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::f1; - } else if(_descriptiveString.find("LEFT") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::left; - } else if(_descriptiveString.find("RIGHT") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::right; - } else if(_descriptiveString.find("UP") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::up; - } else if(_descriptiveString.find("DOWN") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::down; - } else if(_descriptiveString.find("PAGE_UP") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::pageUp; - } else if(_descriptiveString.find("PAGE_DOWN") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::pageDown; - } else if(_descriptiveString.find("START") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::start; - } else if(_descriptiveString.find("END") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::end; - } else if(_descriptiveString.find("PRINT") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::print; - } else if(_descriptiveString.find("ARRET_DEFIL") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::stopDefil; - } else if(_descriptiveString.find("WAIT") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::wait; - } else if(_descriptiveString.find("INSERT") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::insert; - } else if(_descriptiveString.find("CAPLOCK") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::capLock; - } else if(_descriptiveString.find("CONTEXT_MENU") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::contextMenu; - } else if(_descriptiveString.find("NUM_LOCK") != etk::String::npos) { - tmpElement.keyboardMoveValue = gale::key::keyboard::numLock; - } else { - tmpElement.unicodeValue = _descriptiveString[_descriptiveString.size() -1]; - } - // add it on the List ... - m_localShortcut.pushBack(etk::move(tmpElement)); -} - -void ewol::Widget::shortCutRemove(const etk::String& _message) { - auto it(m_localShortcut.begin()); - while(it != m_localShortcut.end()) { - if (it->message != _message) { - ++it; - continue; - } - m_localShortcut.erase(it); - it = m_localShortcut.begin(); - } -} - -void ewol::Widget::shortCutClean() { - m_localShortcut.clear(); -} - -bool ewol::Widget::onEventShortCut(const gale::key::Special& _special, - char32_t _unicodeValue, - enum gale::key::keyboard _kbMove, - bool _isDown) { - if ( _unicodeValue >= 'A' - && _unicodeValue <= 'Z') { - _unicodeValue += 'a' - 'A'; - } - Log.verbose("check shortcut...." << _special << " " << _unicodeValue << " " << _kbMove << " " << (_isDown?"DOWN":"UP") << " nb shortcut:" << m_localShortcut.size()); - // Remove the up event of the shortcut... - if (_isDown == false) { - for (int32_t iii=m_localShortcut.size()-1; iii >= 0; iii--) { - if (m_localShortcut[iii].isActive == false) { - continue; - } - if ( ( m_localShortcut[iii].keyboardMoveValue == gale::key::keyboard::unknow - && m_localShortcut[iii].unicodeValue == _unicodeValue) - || ( m_localShortcut[iii].keyboardMoveValue == _kbMove - && m_localShortcut[iii].unicodeValue == 0) - ) { - // In this case we grap the event in case of an error can occured ... - m_localShortcut[iii].isActive = false; - Log.verbose("detect up of a shortcut"); - return true; - } - } - } - //Log.info("Try to find generic shortcut ..."); - for (int32_t iii=m_localShortcut.size()-1; iii >= 0; iii--) { - if ( m_localShortcut[iii].specialKey.getShift() == _special.getShift() - && m_localShortcut[iii].specialKey.getCtrl() == _special.getCtrl() - && m_localShortcut[iii].specialKey.getAlt() == _special.getAlt() - && m_localShortcut[iii].specialKey.getMeta() == _special.getMeta() - && ( ( m_localShortcut[iii].keyboardMoveValue == gale::key::keyboard::unknow - && m_localShortcut[iii].unicodeValue == _unicodeValue) - || ( m_localShortcut[iii].keyboardMoveValue == _kbMove - && m_localShortcut[iii].unicodeValue == 0) - ) - ) { - if (_isDown == true) { - m_localShortcut[iii].isActive = true; - Log.verbose("Generate shortCut: " << m_localShortcut[iii].message); - signalShortcut.emit(m_localShortcut[iii].message); - } - return true; - } - } - return false; -} - - -void ewol::Widget::grabCursor() { - if (m_grabCursor == false) { - getContext().inputEventGrabPointer(ememory::dynamicPointerCast(sharedFromThis())); - m_grabCursor = true; - } -} - -void ewol::Widget::unGrabCursor() { - if (m_grabCursor == true) { - getContext().inputEventUnGrabPointer(); - m_grabCursor = false; - } -} - -bool ewol::Widget::getGrabStatus() { - return m_grabCursor; -} - -void ewol::Widget::setCursor(enum gale::context::cursor _newCursor) { - Log.debug("Change Cursor in " << _newCursor); - m_cursorDisplay = _newCursor; - getContext().setCursor(m_cursorDisplay); -} - -enum gale::context::cursor ewol::Widget::getCursor() { - return m_cursorDisplay; -} - -bool ewol::Widget::loadXML(const exml::Element& _node) { - ewol::Object::loadXML(_node); - markToRedraw(); - return true; -} - -bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) { - ewol::WidgetShared up = ememory::dynamicPointerCast(m_parent.lock()); - if (up != null) { - if (up->systemEventEntry(_event) == true) { - return true; - } - } - return onEventEntry(_event.m_event); -} - -bool ewol::Widget::systemEventInput(ewol::event::InputSystem& _event) { - ewol::WidgetShared up = ememory::dynamicPointerCast(m_parent.lock()); - if (up != null) { - if (up->systemEventInput(_event) == true) { - return true; - } - } - return onEventInput(_event.m_event); -} - -void ewol::Widget::onChangePropertyCanFocus() { - if (m_hasFocus == true) { - rmFocus(); - } -} - -void ewol::Widget::onChangePropertyGravity() { - markToRedraw(); - requestUpdateSize(); -} - -void ewol::Widget::onChangePropertyHide() { - markToRedraw(); - requestUpdateSize(); -} - -void ewol::Widget::onChangePropertyFill() { - markToRedraw(); - requestUpdateSize(); -} - -void ewol::Widget::onChangePropertyExpand() { - requestUpdateSize(); - markToRedraw(); -} - -void ewol::Widget::onChangePropertyMaxSize() { - Vector2f pixelMin = propertyMinSize->getPixel(); - Vector2f pixelMax = propertyMaxSize->getPixel(); - // check minimum & maximum compatibility : - bool error=false; - if (pixelMin.x()>pixelMax.x()) { - error=true; - } - if (pixelMin.y()>pixelMax.y()) { - error=true; - } - if (error == true) { - Log.error("Can not set a 'min size' > 'max size' reset to maximum ..."); - propertyMaxSize.setDirect(gale::Dimension(Vector2f(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::distance::pixel)); - } - requestUpdateSize(); -} - -void ewol::Widget::onChangePropertyMinSize() { - Vector2f pixelMin = propertyMinSize->getPixel(); - Vector2f pixelMax = propertyMaxSize->getPixel(); - // check minimum & maximum compatibility : - bool error=false; - if (pixelMin.x()>pixelMax.x()) { - error=true; - } - if (pixelMin.y()>pixelMax.y()) { - error=true; - } - if (error == true) { - Log.error("Can not set a 'min size' > 'max size' set nothing ..."); - propertyMinSize.setDirect(gale::Dimension(Vector2f(0,0),gale::distance::pixel)); - } - requestUpdateSize(); -} - -void ewol::Widget::requestUpdateSize() { - getContext().requestUpdateSize(); -} - -ewol::widget::Manager& ewol::Widget::getWidgetManager() { - return getContext().getWidgetManager(); -} - -ewol::widget::WindowsShared ewol::Widget::getWindows() { - return getContext().getWindows(); -} - -void ewol::Widget::showKeyboard() { - getContext().keyboardShow(); -} - -void ewol::Widget::hideKeyboard() { - getContext().keyboardHide(); -} - -void ewol::Widget::drawWidgetTree(int32_t _level) { - etk::String space; - for (int32_t iii=0; iii<_level; ++iii) { - space += " "; - } - Log.print(space << "[" << getId() << "] name='" << propertyName << "' type=" << getObjectType() << " o=" << m_origin << " s=" << m_size << " hide=" << propertyHide); -} \ No newline at end of file diff --git a/src/org/atriasoft/ewol/widget/Widget.java b/src/org/atriasoft/ewol/widget/Widget.java index 0cc0427..eabd6d5 100644 --- a/src/org/atriasoft/ewol/widget/Widget.java +++ b/src/org/atriasoft/ewol/widget/Widget.java @@ -1,532 +1,961 @@ + /** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ -#pragma once +package org.atriasoft.ewol.widget; -#include -#include -#include +import org.atriasoft.esignal.Signal; +import org.atriasoft.etk.math.FMath; +import org.atriasoft.etk.math.Vector2b; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.ewol.Gravity; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.annotation.EwolSignal; +import org.atriasoft.ewol.event.EventInput; +import org.atriasoft.ewol.event.InputSystem; +import org.atriasoft.ewol.internal.Log; +import org.atriasoft.ewol.object.EwolObject; +import org.atriasoft.exml.annotation.XmlDefaultManaged; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; +import org.atriasoft.exml.annotation.XmlProperty; +import org.atriasoft.gale.Dimension; +import org.atriasoft.gale.Distance; +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeySpecial; +import org.atriasoft.gale.context.ClipboardList; +import org.atriasoft.gale.context.Cursor; +import org.atriasoft.gale.event.EventEntry; -#include -#include -#include -#include - -namespace ewol { - class Widget; - namespace widget { - class Manager; - class Windows; - }; - using WidgetShared = ememory::SharedPtr; - using WidgetWeak = ememory::WeakPtr; -}; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ULTIMATE_MAX_SIZE (99999999) - -#define DECLARE_WIDGET_FACTORY(className, name) \ - DECLARE_FACTORY(className); \ - static void createManagerWidget(ewol::widget::Manager& _widgetManager) { \ - _widgetManager.addWidgetCreator(name, \ - []() -> ewol::WidgetShared { \ - return className::create(); \ - }, \ - [](const exml::Element& _node) -> ewol::WidgetShared { \ - return className::createXml(_node); \ - }); \ +// TODO: change position of this ... +class EventShortCut { + public final String message; //!< data link with the event + public final KeySpecial specialKey; //!< special board key + public final Character unicodeValue; //!< 0 if not used + public final KeyKeyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used + public final boolean isActive; //!< If true, we need to filter the up key of ascii element (not control) + + public EventShortCut(final String message, final KeySpecial specialKey, final Character unicodeValue, final KeyKeyboard keyboardMoveValue, final boolean isActive) { + super(); + this.message = message; + this.specialKey = specialKey; + this.unicodeValue = unicodeValue; + this.keyboardMoveValue = keyboardMoveValue; + this.isActive = isActive; } +}; -namespace ewol { +/** + * @brief Widget class is the main widget interface, it has so me generic properties: + * :** known his parent + * :** Can be display at a special position with a special scale + * :** Can get focus + * :** Receive Event (keyboard / mouse / ...) + * + */ +@XmlDefaultManaged(value = false) +class Widget extends EwolObject { + @XmlManaged() + @XmlProperty() + @XmlName(value = "min-size") + @EwolDescription(value = "User minimum size") + protected Dimension propertyMinSize = new Dimension(new Vector2f(0, 0), Distance.PIXEL); //!< user define the minimum size of the widget + + @XmlManaged() + @XmlProperty() + @XmlName(value = "max-size") + @EwolDescription(value = "User maximum size") + protected Dimension propertyMaxSize = new Dimension(new Vector2f(999999, 999999), Distance.PIXEL); //!< user define the maximum size of the widget + + @XmlManaged() + @XmlProperty() + @XmlName(value = "gravity") + @EwolDescription(value = "Gravity orientation") + protected Gravity propertyGravity = Gravity.buttomLeft; //!< Gravity of the widget + + @XmlManaged() + @XmlProperty() + @XmlName(value = "focus") + @EwolDescription(value = "enable the widget to have the focus capacity") + protected boolean propertyCanFocus = false; //!< the focus can be done on this widget + + @XmlManaged() + @XmlProperty() + @XmlName(value = "expand") + @EwolDescription(value = "Request the widget Expand size while space is available") + Vector2b propertyExpand = new Vector2b(false, false); //!< the widget will expand if possible + + @XmlManaged() + @XmlProperty() + @XmlName(value = "fill") + @EwolDescription(value = "Fill the widget available size") + Vector2b propertyFill = new Vector2b(true, true); //!< the widget will fill all the space provided by the parent. + + @XmlManaged() + @XmlProperty() + @XmlName(value = "hide") + @EwolDescription(value = "The widget start hided") + boolean propertyHide = false; //!< hide a widget on the display + + // ---------------------------------------------------------------------------------------------------------------- + // -- Widget size: + // ---------------------------------------------------------------------------------------------------------------- + protected Vector2f size = new Vector2f(10, 10); //!< internal: current size of the widget + protected Vector2f minSize = new Vector2f(0, 0); //!< internal: minimum size of the widget + protected Vector2f maxSize = new Vector2f(999999, 999999); //!< internal: maximum size of the widget + /** - * @not_in_doc + * @brief Constructor of the widget classes + * @return (no exception generated (not managed in embedded platform)) */ - // TODO: change position of this ... - class EventShortCut { - public: - etk::String message; //!< data link with the event - gale::key::Special specialKey; //!< special board key - char32_t unicodeValue; //!< 0 if not used - enum gale::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used - bool isActive; //!< If true, we need to filter the up key of ascii element (not control) - EventShortCut() : - message(""), - specialKey(), - unicodeValue(0), - keyboardMoveValue(gale::key::keyboard::unknow), - isActive(false) { - // nothing to do - }; - virtual ~EventShortCut() { }; + public Widget() {} + + /** + * @brief Convert the absolute position in the local Position (Relative) + * @param[in] _pos Absolute position that you request conversion. + * @return The relative position. + */ + public Vector2f relativePosition(final Vector2f _pos) { + return _pos.lessNew(this.origin); + } + + /** + * @brief Parent have set the size and the origin. The container need to update the child widget property + * @note INTERNAL EWOL SYSTEM + */ + public void onChangeSize() { + Log.verbose("[" + getId() + "] {" + getObjectType() + "} update size : " + this.size); + markToRedraw(); + } + + public void calculateSize() {}; + + /** + * @brief get the widget size + * @return Requested size + * @note : INTERNAL EWOL SYSTEM + */ + public Vector2f getSize() { + if (this.propertyHide == false) { + return this.size; + } + return new Vector2f(0, 0); + } + + /** + * @brief set the widget size + * @return Requested size + * @note : INTERNAL EWOL SYSTEM Do not modify the size yourself: calculation is complex and need knowledge of around widget + */ + public void setSize(final Vector2f _value) { + this.size = _value; + } + + /** + * @brief calculate the minimum and maximum size (need to estimate expend properties of the widget) + * @note : INTERNAL EWOL SYSTEM + */ + public void calculateMinMaxSize() { + this.minSize = this.propertyMinSize.getPixel(); + //Log.error("[" + getId() + "] convert in min size : " + propertyMinSize + " out=" + this.minSize); + this.maxSize = this.propertyMaxSize.getPixel(); + markToRedraw(); + } + + /** + * @brief get the widget minimum size calculated + * @return Requested size + * @note : INTERNAL EWOL SYSTEM + */ + public Vector2f getCalculateMinSize() { + if (this.propertyHide == false) { + return this.minSize; + } + return new Vector2f(0, 0); + } + + /** + * @brief get the widget maximum size calculated + * @return Requested size + * @note : INTERNAL EWOL SYSTEM + */ + public Vector2f getCalculateMaxSize() { + if (this.propertyHide == false) { + return this.maxSize; + } + return new Vector2f(999999, 999999); + } + + protected Vector2f offset = new Vector2f(0, 0); //!< Offset of the display in the view-port + + /** + * @brief set the zoom property of the widget. + * @param[in] _newVal offset value. + */ + public void setOffset(final Vector2f _newVal) { + Log.info("Set offset: " + _newVal); + if (this.offset != _newVal) { + this.offset = _newVal; + markToRedraw(); + } + } + + /** + * @brief get the offset property of the widget. + * @return The current offset value. + */ + Vector2f getOffset() { + return this.offset; }; + + // internal element calculated by the system + protected float zoom = 1.0f; //!< generic widget zoom + /** - * @brief Widget class is the main widget interface, it has some generic properties: - * :** known his parent - * :** Can be display at a special position with a special scale - * :** Can get focus - * :** Receive Event (keyboard / mouse / ...) - * + * @brief set the zoom property of the widget + * @param[in] _newVal newZoom value */ - class Widget : public ewol::Object { - public: // signals: - - public: // properties: - eproperty::Value propertyMinSize; //!< user define the minimum size of the widget - eproperty::Value propertyMaxSize; //!< user define the maximum size of the widget - eproperty::Value propertyExpand; //!< the widget will expand if possible - eproperty::Value propertyFill; //!< the widget will fill all the space provided by the parent. - eproperty::Value propertyHide; //!< hide a widget on the display - eproperty::List propertyGravity; //!< Gravity of the widget - eproperty::Value propertyCanFocus; //!< the focus can be done on this widget - protected: - /** - * @brief Constructor of the widget classes - * @return (no exception generated (not managed in embedded platform)) - */ - Widget(); - public: - /** - * @brief Destructor of the widget classes - */ - virtual ~Widget() = default; - // ---------------------------------------------------------------------------------------------------------------- - // -- Widget size: - // ---------------------------------------------------------------------------------------------------------------- - protected: - Vector2f m_size; //!< internal: current size of the widget - Vector2f m_minSize; //!< internal: minimum size of the widget - Vector2f m_maxSize; //!< internal: maximum size of the widget - public: - /** - * @brief Convert the absolute position in the local Position (Relative) - * @param[in] _pos Absolute position that you request conversion. - * @return The relative position. - */ - virtual Vector2f relativePosition(const Vector2f& _pos); - /** - * @brief Parent have set the size and the origin. The container need to update the child widget property - * @note INTERNAL EWOL SYSTEM - */ - virtual void onChangeSize(); - virtual void calculateSize() {}; - /** - * @brief get the widget size - * @return Requested size - * @note : INTERNAL EWOL SYSTEM - */ - virtual Vector2f getSize(); - /** - * @brief set the widget size - * @return Requested size - * @note : INTERNAL EWOL SYSTEM Do not modify the size yourself: calculation is complex and need knowledge of around widget - */ - virtual void setSize(const Vector2f& _value) { - m_size = _value; - } - /** - * @brief calculate the minimum and maximum size (need to estimate expend properties of the widget) - * @note : INTERNAL EWOL SYSTEM - */ - virtual void calculateMinMaxSize(); - /** - * @brief get the widget minimum size calculated - * @return Requested size - * @note : INTERNAL EWOL SYSTEM - */ - virtual Vector2f getCalculateMinSize(); - /** - * @brief get the widget maximum size calculated - * @return Requested size - * @note : INTERNAL EWOL SYSTEM - */ - virtual Vector2f getCalculateMaxSize(); - protected: - Vector2f m_offset; //!< Offset of the display in the view-port - public: - /** - * @brief set the zoom property of the widget. - * @param[in] _newVal offset value. - */ - virtual void setOffset(const Vector2f& _newVal); - /** - * @brief get the offset property of the widget. - * @return The current offset value. - */ - virtual const Vector2f& getOffset() { - return m_offset; - }; - protected: - // internal element calculated by the system - float m_zoom; //!< generic widget zoom - public: - /** - * @brief set the zoom property of the widget - * @param[in] _newVal newZoom value - */ - virtual void setZoom(float _newVal); - /** - * @brief get the zoom property of the widget - * @return the current zoom value - */ - virtual float getZoom(); - /** - * @brief Change Zoom property. - * @param[in] _range Range of the zoom change. - */ - virtual void changeZoom(float _range) {}; - protected: - Vector2f m_origin; //!< internal ... I do not really known how if can use it ... - public: - /** - * @brief Set origin at the widget (must be an parent widget that set this parameter). - * This represent the absolute origin in the program windows. - * @param[in] _pos Position of the origin. - * @note : INTERNAL EWOL SYSTEM - */ - virtual void setOrigin(const Vector2f& _pos); - /** - * @brief Get the origin (absolute position in the windows). - * @return Coordinate of the origin requested. - */ - virtual Vector2f getOrigin(); - public: - /** - * @brief User set No minimum size. - */ - void setNoMinSize(); // TODO : Remove ==> default ... of the property - /** - * @brief Check if the current min size is compatible with the user minimum size - * If it is not the user minimum size will overWrite the minimum size set. - * @note : INTERNAL EWOL SYSTEM - */ - virtual void checkMinSize(); - protected: - - public: - /** - * @brief User set No maximum size. - */ - void setNoMaxSize(); // TODO : Remove ==> default ... of the property - /** - * @brief Check if the current max size is compatible with the user maximum size - * If it is not the user maximum size will overWrite the maximum size set. - * @note : INTERNAL EWOL SYSTEM - */ - virtual void checkMaxSize(); - public: - /** - * @brief get the expend capabilities (x&y) - * @return 2D boolean represents the capacity to expend - * @note : INTERNAL EWOL SYSTEM - */ - virtual Vector2b canExpand(); - public: - /** - * @brief get the filling capabilities x&y - * @return Vector2b repensent the capacity to x&y filling - * @note : INTERNAL EWOL SYSTEM - */ - const Vector2b& canFill(); - // ---------------------------------------------------------------------------------------------------------------- - // -- focus Area - // ---------------------------------------------------------------------------------------------------------------- - private: - bool m_hasFocus; //!< set the focus on this widget - - public: - /** - * @brief get the focus state of the widget - * @return focus state - */ - virtual bool getFocus() { - return m_hasFocus; - }; - /** - * @brief set focus on this widget - * @return return true if the widget keep the focus - */ - virtual bool setFocus(); - /** - * @brief remove the focus on this widget - * @return return true if the widget have release his focus (if he has it) - */ - virtual bool rmFocus(); - /** - * @brief keep the focus on this widget == > this remove the previous focus on all other widget - */ - virtual void keepFocus(); - protected: - /** - * @brief Event of the focus has been grabed by the current widget - */ - virtual void onGetFocus() {}; - /** - * @brief Event of the focus has been lost by the current widget - */ - virtual void onLostFocus() {}; + public void setZoom(final float _newVal) { + if (this.zoom == _newVal) { + return; + } + this.zoom = FMath.avg(0.0000001f, _newVal, 1000000.0f); + markToRedraw(); + } + + /** + * @brief get the zoom property of the widget + * @return the current zoom value + */ + public float getZoom() { + return this.zoom; + } + + /** + * @brief Change Zoom property. + * @param[in] _range Range of the zoom change. + */ + void changeZoom(final float _range) { - // ---------------------------------------------------------------------------------------------------------------- - // -- Mouse event properties Area - // ---------------------------------------------------------------------------------------------------------------- - private: - int32_t m_limitMouseEvent; //!< this is to limit the number of mouse event that the widget can supported - public: - /** - * @brief get the number of mouse event supported - * @return return the number of event that the mouse supported [0..3] - */ - virtual int32_t getMouseLimit() { - return m_limitMouseEvent; - }; - /** - * @brief get the number of mouse event supported - * @param[in] _numberState The number of event that the mouse supported [0..3] - */ - virtual void setMouseLimit(int32_t _numberState) { - m_limitMouseEvent = _numberState; - }; - // ---------------------------------------------------------------------------------------------------------------- - // -- keyboard event properties Area - // ---------------------------------------------------------------------------------------------------------------- - private: - bool m_allowRepeatKeyboardEvent; //!< This remove the repeating keybord event due to the constant pressing key. - public: - /** - * @brief get the keyboard repeating event supporting. - * @return true : the event can be repeated. - * @return false : the event must not be repeated. - */ - virtual bool getKeyboardRepeat() { - return m_allowRepeatKeyboardEvent; - }; - protected: - /** - * @brief set the keyboard repeating event supporting. - * @param[in] _state The repeating status (true: enable, false disable). - */ - virtual void setKeyboardRepeat(bool _state) { - m_allowRepeatKeyboardEvent = _state; - }; - /** - * @brief display the virtual keyboard (if needed) - */ - virtual void showKeyboard(); - /** - * @brief Hide the virtual keyboard (if needed) - */ - virtual void hideKeyboard(); - public: - /** + }; + + protected Vector2f origin = new Vector2f(0, 0); //!< internal ... I do not really known how if can use it ... + + /** + * @brief Set origin at the widget (must be an parent widget that set this parameter). + * This represent the absolute origin in the program windows. + * @param[in] _pos Position of the origin. + * @note : INTERNAL EWOL SYSTEM + */ + public void setOrigin(final Vector2f _pos) { + this.origin = _pos; + } + + /** + * @brief Get the origin (absolute position in the windows). + * @return Coordinate of the origin requested. + */ + public Vector2f getOrigin() { + return this.origin; + } + + /** + * @brief User set No minimum size. + */ + public void setNoMinSize() { + this.propertyMinSize.set(new Dimension(new Vector2f(0, 0), Distance.PIXEL)); + } + + /** + * @brief Check if the current min size is compatible with the user minimum size + * If it is not the user minimum size will overWrite the minimum size set. + * @note : INTERNAL EWOL SYSTEM + */ + public void checkMinSize() { + final Vector2f pixelSize = this.propertyMinSize.getPixel(); + this.minSize.setX(FMath.max(this.minSize.x, pixelSize.x)); + this.minSize.setY(FMath.max(this.minSize.y, pixelSize.y)); + } + + /** + * @brief User set No maximum size. + */ + public void setNoMaxSize() { + this.propertyMaxSize.set(new Dimension(new Vector2f(999999, 999999), Distance.PIXEL)); + } + + /** + * @brief Check if the current max size is compatible with the user maximum size + * If it is not the user maximum size will overWrite the maximum size set. + * @note : INTERNAL EWOL SYSTEM + */ + public void checkMaxSize() { + final Vector2f pixelSize = this.propertyMaxSize.getPixel(); + this.maxSize.setX(FMath.min(this.maxSize.x, pixelSize.x)); + this.maxSize.setY(FMath.min(this.maxSize.y, pixelSize.y)); + } + + /** + * @brief get the expend capabilities (xy) + * @return 2D boolean represents the capacity to expend + * @note : INTERNAL EWOL SYSTEM + */ + public Vector2b canExpand() { + if (this.propertyHide == false) { + return this.propertyExpand; + } + return new Vector2b(false, false); + } + + /** + * @brief get the filling capabilities xy + * @return Vector2b repensent the capacity to xy filling + * @note : INTERNAL EWOL SYSTEM + */ + public Vector2b canFill() { + return this.propertyFill; + } + + // ---------------------------------------------------------------------------------------------------------------- + // -- focus Area + // ---------------------------------------------------------------------------------------------------------------- + private final boolean hasFocus = false; //!< set the focus on this widget + + /** + * @brief get the focus state of the widget + * @return focus state + */ + public boolean getFocus() { + return this.hasFocus; + }; + + /** + * @brief set focus on this widget + * @return return true if the widget keep the focus + */ + public boolean setFocus() { + Log.verbose("set focus (start) *propertyCanFocus=" + this.propertyCanFocus + " this.hasFocus=" + this.hasFocus); + if (this.propertyCanFocus == true) { + if (this.hasFocus == false) { + this.hasFocus = true; + onGetFocus(); + } + Log.verbose("set focus (stop) ret true"); + return true; + } + Log.verbose("set focus (stop) ret false"); + return false; + } + + /** + * @brief remove the focus on this widget + * @return return true if the widget have release his focus (if he has it) + */ + public boolean rmFocus() { + if (this.propertyCanFocus == true) { + if (this.hasFocus == true) { + this.hasFocus = false; + onLostFocus(); + } + return true; + } + return false; + } + + /** + * @brief keep the focus on this widget == > this remove the previous focus on all other widget + */ + public void keepFocus() { + getWidgetManager().focusKeep(this); + } + + /** + * @brief Event of the focus has been grabed by the current widget + */ + protected void onGetFocus() {}; + + /** + * @brief Event of the focus has been lost by the current widget + */ + protected void onLostFocus() {}; + + // ---------------------------------------------------------------------------------------------------------------- + // -- Mouse event properties Area + // ---------------------------------------------------------------------------------------------------------------- + private int limitMouseEvent = 3; //!< this is to limit the number of mouse event that the widget can supported + + /** + * @brief get the number of mouse event supported + * @return return the number of event that the mouse supported [0..3] + */ + public int getMouseLimit() { + return this.limitMouseEvent; + }; + + /** + * @brief get the number of mouse event supported + * @param[in] _numberState The number of event that the mouse supported [0..3] + */ + public void setMouseLimit(final int _numberState) { + this.limitMouseEvent = _numberState; + }; + + // ---------------------------------------------------------------------------------------------------------------- + // -- keyboard event properties Area + // ---------------------------------------------------------------------------------------------------------------- + private boolean allowRepeatKeyboardEvent = true; //!< This remove the repeating keybord event due to the ant pressing key. + + /** + * @brief get the keyboard repeating event supporting. + * @return true : the event can be repeated. + * @return false : the event must not be repeated. + */ + public boolean getKeyboardRepeat() { + return this.allowRepeatKeyboardEvent; + }; + + /** + * @brief set the keyboard repeating event supporting. + * @param[in] _state The repeating status (true: enable, false disable). + */ + protected void setKeyboardRepeat(final boolean _state) { + this.allowRepeatKeyboardEvent = _state; + }; + + /** + * @brief display the keyboard (if needed) + */ + protected void showKeyboard() { + getContext().keyboardShow(); + } + + /** + * @brief Hide the keyboard (if needed) + */ + protected void hideKeyboard() { + getContext().keyboardHide(); + } + + /** * @brief get the widget at the specific windows absolute position * @param[in] _pos gAbsolute position of the requested widget knowledge * @return null No widget found * @return pointer on the widget found * @note : INTERNAL EWOL SYSTEM */ - virtual ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) { - if (propertyHide.get() == false) { - return ememory::dynamicPointerCast(sharedFromThis()); - } - return null; - }; - - // event section: - public: - /** + public Widget getWidgetAtPos(final Vector2f _pos) { + if (this.propertyHide == false) { + return this; + } + return null; + } + + // event section: + /** * @brief {SYSTEM} system event input (only meta widget might overwrite this function). * @param[in] _event Event properties * @return true the event is used * @return false the event is not used */ - virtual bool systemEventInput(ewol::event::InputSystem& _event); - protected: - /** - * @brief Event on an input of this Widget (finger, mouse, stylet) - * @param[in] _event Event properties - * @return true the event is used - * @return false the event is not used - */ - virtual bool onEventInput(const ewol::event::Input& _event) { - return false; - }; - public: - /** - * @brief {SYSTEM} Entry event (only meta widget might overwrite this function). - * @param[in] _event Event properties - * @return true if the event has been used - * @return false if the event has not been used - */ - virtual bool systemEventEntry(ewol::event::EntrySystem& _event); - protected: - /** - * @brief Entry event. - * represent the physical event : - * - Keyboard (key event and move event) - * - Accelerometer - * - Joystick - * @param[in] _event Event properties - * @return true if the event has been used - * @return false if the event has not been used - */ - virtual bool onEventEntry(const ewol::event::Entry& _event) { - return false; - }; - public: - /** - * @brief Event on a past event == > this event is asynchronous due to all system does not support direct getting data. - * @note : need to have focus ... - * @param[in] mode Mode of data requested - */ - virtual void onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID) { }; - - // ---------------------------------------------------------------------------------------------------------------- - // -- Shortcut : management of the shortcut - // ---------------------------------------------------------------------------------------------------------------- - public: - esignal::Signal signalShortcut; //!< signal handle of the message - private: - List m_localShortcut; //!< list of all shortcut in the widget - protected: - /** - * @brief add a specific shortcut with his description - * @param[in] _descriptiveString Description string of the shortcut - * @param[in] _message massage to generate (or shortcut name) - */ - virtual void shortCutAdd(const etk::String& _descriptiveString, - const etk::String& _message=""); - /** - * @brief remove all current shortCut - */ - virtual void shortCutClean(); - /** + public boolean systemEventInput(final InputSystem _event) { + final Widget up = (Widget) this.parent.get(); + if (up != null) { + if (up.systemEventInput(_event) == true) { + return true; + } + } + return onEventInput(_event.event); + } + + /** + * @brief Event on an input of this Widget (finger, mouse, stylet) + * @param[in] _event Event properties + * @return true the event is used + * @return false the event is not used + */ + protected boolean onEventInput(final EventInput _event) { + return false; + }; + + /** + * @brief {SYSTEM} Entry event (only meta widget might overwrite this function). + * @param[in] _event Event properties + * @return true if the event has been used + * @return false if the event has not been used + */ + public boolean systemEventEntry(final EntrySystem _event) { + final Widget up = (Widget) this.parent.get(); + if (up != null) { + if (up.systemEventEntry(_event) == true) { + return true; + } + } + return onEventEntry(_event.event); + } + + /** + * @brief Entry event. + * represent the physical event : + * - Keyboard (key event and move event) + * - Accelerometer + * - Joystick + * @param[in] _event Event properties + * @return true if the event has been used + * @return false if the event has not been used + */ + protected boolean onEventEntry(final EventEntry _event) { + return false; + }; + + /** + * @brief Event on a past event == > this event is asynchronous due to all system does not support direct getting data. + * @note : need to have focus ... + * @param[in] mode Mode of data requested + */ + public void onEventClipboard(final ClipboardList _clipboardID) {}; + + // ---------------------------------------------------------------------------------------------------------------- + // -- Shortcut : management of the shortcut + // ---------------------------------------------------------------------------------------------------------------- + @EwolSignal(name = "shortcut") + public Signal signalShortcut; //!< signal handle of the message + private List localShortcut; //!< list of all shortcut in the widget + + /** + * @brief add a specific shortcut with his description + * @param[in] _descriptiveString Description string of the shortcut + * @param[in] _message massage to generate (or shortcut name) + */ + protected void shortCutAdd(final String _descriptiveString) { + shortCutAdd(_descriptiveString, ""); + } + + protected void shortCutAdd( final String _descriptiveString, + final String _message){ + if (_descriptiveString.size() == 0) { + Log.error("try to add shortcut with no descriptive string ..."); + return; + } + final EventShortCut tmpElement; + if (_message.size() == 0) { + tmpElement.message = _descriptiveString; + } else { + tmpElement.message = _message; + } + // parsing of the string: + //"ctrl+shift+alt+meta+s" + if(_descriptiveString.find("ctrl") != String::npos) { + tmpElement.specialKey.setCtrlLeft(true); + } + if(_descriptiveString.find("shift") != String::npos) { + tmpElement.specialKey.setShiftLeft(true); + } + if(_descriptiveString.find("alt") != String::npos) { + tmpElement.specialKey.setAltLeft(true); + } + if(_descriptiveString.find("meta") != String::npos) { + tmpElement.specialKey.setMetaLeft(true); + } + if(_descriptiveString.find("F12") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f12; + } else if(_descriptiveString.find("F11") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f11; + } else if(_descriptiveString.find("F10") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f10; + } else if(_descriptiveString.find("F9") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f9; + } else if(_descriptiveString.find("F8") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f8; + } else if(_descriptiveString.find("F7") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f7; + } else if(_descriptiveString.find("F6") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f6; + } else if(_descriptiveString.find("F5") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f5; + } else if(_descriptiveString.find("F4") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f4; + } else if(_descriptiveString.find("F3") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f3; + } else if(_descriptiveString.find("F2") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f2; + } else if(_descriptiveString.find("F1") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::f1; + } else if(_descriptiveString.find("LEFT") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::left; + } else if(_descriptiveString.find("RIGHT") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::right; + } else if(_descriptiveString.find("UP") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::up; + } else if(_descriptiveString.find("DOWN") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::down; + } else if(_descriptiveString.find("PAGE_UP") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::pageUp; + } else if(_descriptiveString.find("PAGE_DOWN") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::pageDown; + } else if(_descriptiveString.find("START") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::start; + } else if(_descriptiveString.find("END") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::end; + } else if(_descriptiveString.find("PRINT") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::print; + } else if(_descriptiveString.find("ARRET_DEFIL") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::stopDefil; + } else if(_descriptiveString.find("WAIT") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::wait; + } else if(_descriptiveString.find("INSERT") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::insert; + } else if(_descriptiveString.find("CAPLOCK") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::capLock; + } else if(_descriptiveString.find("CONTEXT_MENU") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::contextMenu; + } else if(_descriptiveString.find("NUM_LOCK") != String::npos) { + tmpElement.keyboardMoveValue = KeyKeyboard::numLock; + } else { + tmpElement.unicodeValue = _descriptiveString[_descriptiveString.size() -1]; + } + // add it on the List ... + this.localShortcut.pushBack(etk::move(tmpElement)); + } + + /** + * @brief remove all current shortCut + */ + protected void shortCutClean() { + this.localShortcut.clear(); + } + + /** * @brief remove a specific shortCut with his event name * @param[in] _message generated event name */ - virtual void shortCutRemove(const etk::String& _message); - public: - /** - * @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref onEventKb). - * @param[in] _special All the special kay pressed at this time. - * @param[in] _unicodeValue Key pressed by the user not used if the kbMove!=ewol::EVENT_KB_MOVE_TYPE_NONE. - * @param[in] _kbMove Special key of the keyboard. - * @return true if the event has been used. - * @return false if the event has not been used. - * @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some mistake in the error. - */ - virtual bool onEventShortCut(const gale::key::Special& _special, - char32_t _unicodeValue, - enum gale::key::keyboard _kbMove, - bool _isDown); - // ---------------------------------------------------------------------------------------------------------------- - // -- drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working... - // ---------------------------------------------------------------------------------------------------------------- - protected: - bool m_needRegenerateDisplay; //!< the display might be done the next regeneration - public: - /** - * @brief The widget mark itself that it need to regenerate the nest time. - */ - virtual void markToRedraw(); - protected: - /** - * @brief get the need of the redrawing of the widget and reset it to false - * @return true if we need to redraw - * @return false if we have no need to redraw - */ - virtual bool needRedraw() { - bool tmpData = m_needRegenerateDisplay; - m_needRegenerateDisplay = false; - return tmpData; - }; - public: - /** + protected void shortCutRemove( final String _message){ + + auto it(this.localShortcut.begin()); + while(it != this.localShortcut.end()) { + if (it.message != _message) { + ++it; + continue; + } + this.localShortcut.erase(it); + it = this.localShortcut.begin(); + } + } + + /** + * @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref onEventKb). + * @param[in] _special All the special kay pressed at this time. + * @param[in] _unicodeValue Key pressed by the user not used if the kbMove!=ewol::EVENT_KB_MOVE_TYPE_NONE. + * @param[in] _kbMove Special key of the keyboard. + * @return true if the event has been used. + * @return false if the event has not been used. + * @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some mistake in the error. + */ + public boolean onEventShortCut(final KeySpecial _special, Character _unicodeValue, final KeyKeyboard _kbMove, final boolean _isDown) { + if (_unicodeValue >= 'A' && _unicodeValue <= 'Z') { + _unicodeValue += 'a' - 'A'; + } + Log.verbose("check shortcut...." + _special + " " + _unicodeValue + " " + _kbMove + " " + (_isDown ? "DOWN" : "UP") + " nb shortcut:" << this.localShortcut.size()); + // Remove the up event of the shortcut... + if (_isDown == false) { + for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) { + if (this.localShortcut[iii].isActive == false) { + continue; + } + if ((this.localShortcut[iii].keyboardMoveValue == KeyKeyboard::unknow && this.localShortcut[iii].unicodeValue == _unicodeValue) + || (this.localShortcut[iii].keyboardMoveValue == _kbMove && this.localShortcut[iii].unicodeValue == 0)) { + // In this case we grap the event in case of an error can occured ... + this.localShortcut[iii].isActive = false; + Log.verbose("detect up of a shortcut"); + return true; + } + } + } + //Log.info("Try to find generic shortcut ..."); + for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) { + if (this.localShortcut[iii].specialKey.getShift() == _special.getShift() && this.localShortcut[iii].specialKey.getCtrl() == _special.getCtrl() + && this.localShortcut[iii].specialKey.getAlt() == _special.getAlt() && this.localShortcut[iii].specialKey.getMeta() == _special.getMeta() + && ((this.localShortcut[iii].keyboardMoveValue == KeyKeyboard::unknow && this.localShortcut[iii].unicodeValue == _unicodeValue) + || (this.localShortcut[iii].keyboardMoveValue == _kbMove && this.localShortcut[iii].unicodeValue == 0))) { + if (_isDown == true) { + this.localShortcut[iii].isActive = true; + Log.verbose("Generate shortCut: " + this.localShortcut[iii].message); + this.signalShortcut.emit(this.localShortcut[iii].message); + } + return true; + } + } + return false; + } + + // ---------------------------------------------------------------------------------------------------------------- + // -- drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working... + // ---------------------------------------------------------------------------------------------------------------- + protected boolean needRegenerateDisplay = true; //!< the display might be done the next regeneration + + /** + * @brief The widget mark itself that it need to regenerate the nest time. + */ + public void markToRedraw() { + if (this.needRegenerateDisplay == true) { + return; + } + this.needRegenerateDisplay = true; + getWidgetManager().markDrawingIsNeeded(); + } + + /** + * @brief get the need of the redrawing of the widget and reset it to false + * @return true if we need to redraw + * @return false if we have no need to redraw + */ + protected boolean needRedraw() { + final boolean tmpData = this.needRegenerateDisplay; + this.needRegenerateDisplay = false; + return tmpData; + }; + + /** * @brief {SYSTEM} extern interface to request a draw ... (called by the drawing thread [Android, X11, ...]) * This function generate a clipping with the view-port openGL system. Like this a widget draw can not draw over an other widget - * @note This function is virtual for the scrolled widget, and the more complicated openGL widget + * @note This function is for the scrolled widget, and the more complicated openGL widget * @param[in] _displayProp properties of the current display * @note : INTERNAL EWOL SYSTEM + /-. _displayProp.this.windowsSize + *------------------------------------------------------* + | | + | this.size | + | / | + | *-----------------------* | + | ' ' | + | ' _displayProp.this.size ' | + | Viewport ' / ' | + | o---------'---------o ' | + | | ' | ' | + | | ' | ' | + | | ' | ' | + | | ' | ' | + | | *-----------------------* | + | | / | | + | | this.offset | | + | | | | + | o-------------------o | + | / | + | _displayProp.this.origin | + | | + *------------------------------------------------------* + / + (0,0) */ - virtual void systemDraw(const DrawProperty& _displayProp); - protected: - /** - * @brief Common widget drawing function (called by the drawing thread [Android, X11, ...]) - */ - virtual void onDraw() { }; - public: - /** - * @brief Event generated when a redraw is needed - */ - virtual void onRegenerateDisplay() { }; - // grab cursor mode - private: - bool m_grabCursor; - public: - /** + public void systemDraw( final DrawProperty _displayProp){ + //Log.info("[" + getId() + "] Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" << this.size << " hide=" << propertyHide); + if (this.propertyHide == true){ + // widget is hidden ... + return; + } + final Vector2f displayOrigin = this.origin + this.offset; + + // check if the element is displayable in the windows : + if( _displayProp.this.windowsSize.x() < this.origin.x() + || _displayProp.this.windowsSize.y() < this.origin.y() ) { + // out of the windows == > nothing to display ... + return; + } + + final DrawProperty tmpSize = _displayProp.clone(); + tmpSize.limit(this.origin, this.size); + if (tmpSize.this.size.x() <= 0 || tmpSize.this.size.y() <= 0) { + return; + } + glViewport( (int)tmpSize.this.origin.x(), + (int)tmpSize.this.origin.y(), + (int)tmpSize.this.size.x(), + (int)tmpSize.this.size.y()); + // special case, when origin < display origin, we need to cut the display : + final Vector2i downOffset = this.origin - tmpSize.this.origin; + downOffset.setMin(Vector2i(0,0)); + + final mat4 tmpTranslate = etk::matTranslate(Vector3fClipInt32(Vector3f(-tmpSize.this.size.x()/2+this.offset.x() + downOffset.x(), + -tmpSize.this.size.y()/2+this.offset.y() + downOffset.y(), + -1.0f))); + final mat4 tmpScale = etk::matScale(Vector3f(this.zoom, this.zoom, 1.0f)); + final mat4 tmpProjection = etk::matOrtho((int)(-tmpSize.this.size.x())>>1, + (int)( tmpSize.this.size.x())>>1, + (int)(-tmpSize.this.size.y())>>1, + (int)( tmpSize.this.size.y())>>1, + (int)(-1), + (int)( 1)); + mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; + + gale::openGL::push(); + // set internal matrix system : + gale::openGL::setMatrix(tmpMat); + //long ___startTime = ewol::getTime(); + onDraw(); + gale::openGL::pop(); + return; + } + + /** + * @brief Common widget drawing function (called by the drawing thread [Android, X11, ...]) + */ + protected void onDraw() {}; + + /** + * @brief Event generated when a redraw is needed + */ + public void onRegenerateDisplay() {}; + + // grab cursor mode + private boolean grabCursor = false; + + /** * @brief Grab the cursor : This get all the movement of the mouse in PC mode, and generate an offset instead of a position. * @note : the generation of the offset is due to the fact the cursor position is forced at the center of the widget. * @note This done nothing in "Finger" or "Stylet" mode. */ - virtual void grabCursor(); - /** - * @brief Un-Grab the cursor (default mode cursor offset) - */ - virtual void unGrabCursor(); - /** - * @brief get the grabbing status of the cursor. - * @return true if the cursor is currently grabbed - */ - virtual bool getGrabStatus(); - private: - enum gale::context::cursor m_cursorDisplay; - public: - /** +public void grabCursor() +if (this.grabCursor == false) { + getContext().inputEventGrabPointer(ememory::dynamicPointerCast(sharedFromThis())); + this.grabCursor = true; +} +} + + /** + * @brief Un-Grab the cursor (default mode cursor offset) + */ + public void unGrabCursor() { + if (this.grabCursor == true) { + getContext().inputEventUnGrabPointer(); + this.grabCursor = false; + } + } + + /** + * @brief get the grabbing status of the cursor. + * @return true if the cursor is currently grabbed + */ + public boolean getGrabStatus() { + return this.grabCursor; + } + + private final Cursor cursorDisplay = Cursor.arrow; + + /** * @brief set the cursor display type. * @param[in] _newCursor selected new cursor. */ - virtual void setCursor(enum gale::context::cursor _newCursor); - /** - * @brief get the current cursor. - * @return the type of the cursor. - */ - virtual enum gale::context::cursor getCursor(); - public: - virtual bool loadXML(const exml::Element& _node) override; - public: - /** - * @brief Need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions. - */ - void requestUpdateSize(); - /** - * @brief Get the current Widget Manager. - */ - ewol::widget::Manager& getWidgetManager(); - /** - * @brief Get the current Windows. - */ - ememory::SharedPtr getWindows(); - protected: - virtual void onChangePropertyCanFocus(); - virtual void onChangePropertyGravity(); - virtual void onChangePropertyHide(); - virtual void onChangePropertyFill(); - virtual void onChangePropertyExpand(); - virtual void onChangePropertyMaxSize(); - virtual void onChangePropertyMinSize(); - public: - virtual void drawWidgetTree(int32_t _level=0); - }; -}; - -#include - + public void setCursor(enum gale::context::cursor _newCursor) { + Log.debug("Change Cursor in " + _newCursor); + this.cursorDisplay = _newCursor; + getContext().setCursor(this.cursorDisplay); + } + + /** + * @brief get the current cursor. + * @return the type of the cursor. + */ + public Cursor getCursor() { + return this.cursorDisplay; + } + + /* + public boolean loadXML( XmlElement _node){ + EwolObject::loadXML(_node); + markToRedraw(); + return true; + } + + */ + /** + * @brief Need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions. + */ + public void requestUpdateSize() { + getContext().requestUpdateSize(); + } + + /** + * @brief Get the current Widget Manager. + */ + public WidgetManager getWidgetManager() { + return getContext().getWidgetManager(); + } + + /** + * @brief Get the current Windows. + */ + public Windows getWindows() { + return getContext().getWindows(); + } + + protected void onChangePropertyCanFocus() { + if (this.hasFocus == true) { + rmFocus(); + } + } + + protected void onChangePropertyGravity() { + markToRedraw(); + requestUpdateSize(); + } + + protected void onChangePropertyHide() { + markToRedraw(); + requestUpdateSize(); + } + + protected void onChangePropertyFill() { + markToRedraw(); + requestUpdateSize(); + } + + protected void onChangePropertyExpand() { + requestUpdateSize(); + markToRedraw(); + } + + protected void onChangePropertyMaxSize() { + final Vector2f pixelMin = this.propertyMinSize.getPixel(); + final Vector2f pixelMax = this.propertyMaxSize.getPixel(); + // check minimum maximum compatibility : + boolean error=false; + if (pixelMin.x()>pixelMax.x()) { + error=true; + } + if (pixelMin.y()>pixelMax.y()) { + error=true; + } + if (error == true) { + Log.error("Can not set a 'min size' > 'max size' reset to maximum ..."); + this.propertyMaxSize.setDirect(gale::Dimension(Vector2f(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::distance::pixel)); + } + requestUpdateSize(); + } + + protected void onChangePropertyMinSize() { + final Vector2f pixelMin = this.propertyMinSize.getPixel(); + final Vector2f pixelMax = this.propertyMaxSize.getPixel(); + // check minimum maximum compatibility : + boolean error=false; + if (pixelMin.x()>pixelMax.x()) { + error=true; + } + if (pixelMin.y()>pixelMax.y()) { + error=true; + } + if (error == true) { + Log.error("Can not set a 'min size' > 'max size' set nothing ..."); + this.propertyMinSize.setDirect(gale::Dimension(Vector2f(0,0),gale::distance::pixel)); + } + requestUpdateSize(); + } + + public void drawWidgetTree(final int _level) { + String space; + for (int iii = 0; iii < _level; ++iii) { + space += " "; + } + Log.print(space + "[" + getId() + "] name='" + propertyName + "' type=" + getObjectType() + " o=" + this.origin << " s=" << this.size << " hide=" << this.propertyHide); + } +};}; \ No newline at end of file diff --git a/src/org/atriasoft/ewol/widget/WidgetManager.java b/src/org/atriasoft/ewol/widget/WidgetManager.java new file mode 100644 index 0000000..fc914d5 --- /dev/null +++ b/src/org/atriasoft/ewol/widget/WidgetManager.java @@ -0,0 +1,260 @@ +package org.atriasoft.ewol.widget; + +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import org.atriasoft.ewol.internal.Log; + +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL v2.0 (see license file) + */ + +public class WidgetManager { + // --------------------------------------------- + // -- Focus area + // --------------------------------------------- + private WeakReference focusWidgetDefault; //!< default focus when no current focus is set + private WeakReference focusWidgetCurrent; //!< Current focus selected + // --------------------------------------------- + // -- Factory area + // --------------------------------------------- + private final Map> creatorList = new HashMap<>(); //!< List of factory of a widget + + // --------------------------------------------- + // -- Something change area (TODO: maybe set it in the windows) + // --------------------------------------------- + private boolean haveRedraw = true; //!< something request a redraw + + private Runnable funcRedrawNeeded = null; + + /** + * @brief Create a widget with his name. + * @param[in] _name Name of the widget to create. + * @param[in] _node Reference on the XML node. + * @return The widget created (null if it does not exist). + */ + /* + public Widget create( final String _name, exml::Element _node){ + final String nameLower = _name.toLowerCase(); + final Class it = this.creatorList.get(nameLower); + if (it != null) { + try { + return it.getConstructor().newInstance(_node); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + Log.warning("try to create an UnExistant widget : " + nameLower); + return null; + } + */ + + public WidgetManager() { + this.creatorList.put("Button", Button.class); + this.creatorList.put("ButtonColor", ButtonColor.class); + this.creatorList.put("Spacer", Spacer.class); + this.creatorList.put("Slider", Slider.class); + this.creatorList.put("Sizer", Sizer.class); + this.creatorList.put("ProgressBar", ProgressBar.class); + this.creatorList.put("Layer", Layer.class); + this.creatorList.put("Label", Label.class); + this.creatorList.put("Image", Image.class); + this.creatorList.put("Gird", Gird.class); + this.creatorList.put("Entry", Entry.class); + this.creatorList.put("Menu", Menu.class); + this.creatorList.put("CheckBox", CheckBox.class); + this.creatorList.put("Scroll", Scroll.class); + this.creatorList.put("ContextMenu", ContextMenu.class); + this.creatorList.put("PopUp", PopUp.class); + this.creatorList.put("WSlider", WSlider.class); + this.creatorList.put("ListFileSystem", ListFileSystem.class); + this.creatorList.put("Composer", Composer.class); + this.creatorList.put("Select", Select.class); + this.creatorList.put("Spin", Spin.class); + } + + /** + * @throws Exception + * @brief add a factory of a specific widget. + * @param[in] _name Name of the widget that is associated of the factory. + * @param[in] _class class interface + */ + public void addWidgetCreator(final String _name, final Class _class) throws Exception { + if (_class == null) { + throw new Exception("Can not add widget creator without specified class."); + } + //Keep name in lower case : + final String nameLower = _name.toLowerCase(); + final Class it = this.creatorList.get(nameLower); + if (it != null) { + Log.warning("Replace Creator of a specify widget : " + nameLower); + return; + } + this.creatorList.put(nameLower, _class); + // TODO check constructors ... + } + + /** + * @brief Create a widget with his name. + * @param[in] _name Name of the widget to create. + * @return The widget created (null if it does not exist). + */ + public Widget create(final String _name) { + final String nameLower = _name.toLowerCase(); + final Class it = this.creatorList.get(nameLower); + if (it != null) { + try { + return (Widget) it.getConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + Log.warning("try to create an UnExistant widget : " + nameLower); + return null; + } + + /** + * @brief Check if an Widget exist + * @param[in] _name Name of the widget to check. + * @return true The Widget exist. + * @return false The Widget Does NOT exist. + */ + public boolean exist(final String _name) { + return this.creatorList.get(_name.toLowerCase()) != null; + } + + /** + * @brief Get the current Focused widget. + * @return The pointer on the current focused element. + */ + public public Widget focusGet() { + return this.focusWidgetCurrent.get(); + } + + /** + * @brief Request a focus on a specify widget. + * @param[in] _newWidget Widget that might get the focus. + */ + public void focusKeep(final Widget _newWidget) { + if (_newWidget == null) { + // nothing to do ... + return; + } + Log.debug("focusKeep=" + _newWidget.getId()); + //elog::displayBacktrace(); + Widget focusWidgetCurrent = this.focusWidgetCurrent.get(); + if (_newWidget == focusWidgetCurrent) { + // nothing to do ... + return; + } + if (focusWidgetCurrent != null) { + Log.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId()); + focusWidgetCurrent.rmFocus(); + focusWidgetCurrent = null; + } + if (_newWidget.propertyCanFocus.get() == false) { + Log.debug("Widget can not have focus, id=" + _newWidget.getId()); + return; + } + this.focusWidgetCurrent = _newWidget; + if (_newWidget != null) { + Log.debug("Set focus on WidgetID=" + _newWidget.getId()); + _newWidget.setFocus(); + } + } + + /** + * @brief Release the current focus (back on default if possible). + */ + public void focusRelease() { + final Widget focusWidgetDefault = this.focusWidgetDefault.get(); + final Widget focusWidgetCurrent = this.focusWidgetCurrent.get(); + if (focusWidgetDefault == focusWidgetCurrent) { + // nothink to do ... + return; + } + if (focusWidgetCurrent != null) { + Log.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId()); + focusWidgetCurrent.rmFocus(); + } + this.focusWidgetCurrent = this.focusWidgetDefault; + focusWidgetCurrent = this.focusWidgetCurrent.get(); + if (focusWidgetCurrent != null) { + Log.debug("Set focus on WidgetID=" + focusWidgetCurrent.getId()); + focusWidgetCurrent.setFocus(); + } + } + + /** + * @brief Set the default focus when none selected. + * @param[in] _newWidget Widget that might get the focus (when nothing else). + */ + public void focusSetDefault(final Widget _newWidget) { + if (_newWidget != null && _newWidget.propertyCanFocus.get() == false) { + Log.verbose("Widget can not have focus, id=" + _newWidget.getId()); + return; + } + final EwolWidget focusWidgetDefault = this.focusWidgetDefault.lock(); + final EwolWidget focusWidgetCurrent = this.focusWidgetCurrent.lock(); + if (focusWidgetDefault == focusWidgetCurrent) { + if (focusWidgetCurrent != null) { + Log.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId()); + focusWidgetCurrent.rmFocus(); + } + this.focusWidgetCurrent = _newWidget; + if (_newWidget != null) { + Log.debug("Set focus on WidgetID=" + _newWidget.getId()); + _newWidget.setFocus(); + } + } + this.focusWidgetDefault = _newWidget; + } + + /** + * @brief Check if a redraw has been requested (set the local value back at false) + * @return true if something to be redraw + */ + public boolean isDrawingNeeded() { + final boolean tmp = this.haveRedraw; + this.haveRedraw = false; + return tmp; + } + + /** + * @brief Get the list of all Widget that can be created. + * @return Separate with ',' string list. + */ + public String list() { + return this.creatorList.keySet().toString(); + } + + /** + * @brief Mark the display to redraw + */ + public void markDrawingIsNeeded() { + if (this.haveRedraw == true) { + return; + } + this.haveRedraw = true; + if (this.funcRedrawNeeded != null) { + this.funcRedrawNeeded.run(); + } + } + + /** + * @brief Set a callback when we need redraw the display (need by MacOs) + * @param[in] _func function to call + */ + private void setCallbackonRedrawNeeded(final Runnable _func) { + this.funcRedrawNeeded = _func; + } + +} diff --git a/src/org/atriasoft/ewol/widget/WidgetScrolled.cpp b/src/org/atriasoft/ewol/widget/WidgetScrolled.cpp index 4ab970b..70a27f1 100644 --- a/src/org/atriasoft/ewol/widget/WidgetScrolled.cpp +++ b/src/org/atriasoft/ewol/widget/WidgetScrolled.cpp @@ -17,31 +17,31 @@ ewol::widget::WidgetScrolled::WidgetScrolled() : propertyShapeVert(this, "shape-vert", etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"), "shape for the vertical display", - &ewol::widget::WidgetScrolled::onChangePropertyShapeVert), + ewol::widget::WidgetScrolled::onChangePropertyShapeVert), propertyShapeHori(this, "shape-hori", etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"), "shape for the horizonal display", - &ewol::widget::WidgetScrolled::onChangePropertyShapeHori), - m_shaperH(), - m_shaperV(), - m_singleFingerMode(true) { + ewol::widget::WidgetScrolled::onChangePropertyShapeHori), + this.shaperH(), + this.shaperV(), + this.singleFingerMode(true) { addObjectType("ewol::widget::WidgetScrolled"); - m_originScrooled.setValue(0,0); - m_pixelScrolling = 20; - m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_scroollingMode = scroolModeNormal; - m_highSpeedType = gale::key::type::unknow; - m_highSpeedButton = -1; - m_limitScrolling = Vector2f(0.5f, 0.5f); + this.originScrooled.setValue(0,0); + this.pixelScrolling = 20; + this.highSpeedMode = ewol::widget::Scroll::speedModeDisable; + this.scroollingMode = scroolModeNormal; + this.highSpeedType = KeyType::unknow; + this.highSpeedButton = -1; + this.limitScrolling = Vector2f(0.5f, 0.5f); - m_fingerScoolActivated = false; - for (size_t iii = 0; iii < CALCULATE_SIMULTANEOUS_FINGER; ++iii) { - m_fingerPresent[iii] = false; + this.fingerScoolActivated = false; + for (int iii = 0; iii < CALCULATE_SIMULTANEOUS_FINGER; ++iii) { + this.fingerPresent[iii] = false; } } void ewol::widget::WidgetScrolled::init() { - ewol::Widget::init(); + Widget::init(); propertyShapeVert.notifyChange(); propertyShapeHori.notifyChange(); } @@ -51,86 +51,86 @@ ewol::widget::WidgetScrolled::~WidgetScrolled() { } void ewol::widget::WidgetScrolled::onRegenerateDisplay() { - m_shaperH.clear(); - m_shaperV.clear(); - if (m_scroollingMode == scroolModeGame) { + this.shaperH.clear(); + this.shaperV.clear(); + if (this.scroollingMode == scroolModeGame) { // nothing to do ... return; } - ewol::Padding paddingVert = m_shaperV.getPadding(); - ewol::Padding paddingHori = m_shaperH.getPadding(); - if( m_size.y() < m_maxSize.y() - || m_originScrooled.y()!=0) { - float lenScrollBar = m_size.y()*m_size.y() / m_maxSize.y(); - lenScrollBar = etk::avg(10.0f, lenScrollBar, m_size.y()); - float originScrollBar = m_originScrooled.y() / (m_maxSize.y()-m_size.y()*m_limitScrolling.y()); + ewol::Padding paddingVert = this.shaperV.getPadding(); + ewol::Padding paddingHori = this.shaperH.getPadding(); + if( this.size.y() < this.maxSize.y() + || this.originScrooled.y()!=0) { + float lenScrollBar = this.size.y()*this.size.y() / this.maxSize.y(); + lenScrollBar = etk::avg(10.0f, lenScrollBar, this.size.y()); + float originScrollBar = this.originScrooled.y() / (this.maxSize.y()-this.size.y()*this.limitScrolling.y()); originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f); - originScrollBar *= (m_size.y()-lenScrollBar); - m_shaperV.setShape(Vector2f(m_size.x() - paddingVert.x(), 0), - Vector2f(paddingVert.x(), m_size.y()), - Vector2f(m_size.x() - paddingVert.xRight(), m_size.y() - originScrollBar - lenScrollBar), + originScrollBar *= (this.size.y()-lenScrollBar); + this.shaperV.setShape(Vector2f(this.size.x() - paddingVert.x(), 0), + Vector2f(paddingVert.x(), this.size.y()), + Vector2f(this.size.x() - paddingVert.xRight(), this.size.y() - originScrollBar - lenScrollBar), Vector2f(0, lenScrollBar)); } - if( m_size.x() < m_maxSize.x() - || m_originScrooled.x()!=0) { - float lenScrollBar = (m_size.x()-paddingHori.xLeft())*(m_size.x()-paddingVert.x()) / m_maxSize.x(); - lenScrollBar = etk::avg(10.0f, lenScrollBar, (m_size.x()-paddingVert.x())); - float originScrollBar = m_originScrooled.x() / (m_maxSize.x()-m_size.x()*m_limitScrolling.x()); + if( this.size.x() < this.maxSize.x() + || this.originScrooled.x()!=0) { + float lenScrollBar = (this.size.x()-paddingHori.xLeft())*(this.size.x()-paddingVert.x()) / this.maxSize.x(); + lenScrollBar = etk::avg(10.0f, lenScrollBar, (this.size.x()-paddingVert.x())); + float originScrollBar = this.originScrooled.x() / (this.maxSize.x()-this.size.x()*this.limitScrolling.x()); originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f); - originScrollBar *= (m_size.x()-paddingHori.xRight()-lenScrollBar); - m_shaperH.setShape(Vector2f(0, 0), - Vector2f(m_size.x()-paddingVert.x(), paddingHori.y()), + originScrollBar *= (this.size.x()-paddingHori.xRight()-lenScrollBar); + this.shaperH.setShape(Vector2f(0, 0), + Vector2f(this.size.x()-paddingVert.x(), paddingHori.y()), Vector2f(originScrollBar, paddingHori.yButtom()), Vector2f(lenScrollBar, 0)); } } -bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event) { - Log.verbose("event XXX " << _event); +boolean ewol::widget::WidgetScrolled::onEventInput( ewol::event::Input _event) { + Log.verbose("event XXX " + _event); Vector2f relativePos = relativePosition(_event.getPos()); // corection due to the open Gl invertion ... - relativePos.setY(m_size.y() - relativePos.y()); - ewol::Padding paddingV = m_shaperV.getPadding(); - ewol::Padding paddingH = m_shaperH.getPadding(); - if (m_scroollingMode == scroolModeNormal) { - if ( _event.getType() == gale::key::type::mouse - && ( m_highSpeedType == gale::key::type::unknow - || m_highSpeedType == gale::key::type::mouse) ) { + relativePos.setY(this.size.y() - relativePos.y()); + ewol::Padding paddingV = this.shaperV.getPadding(); + ewol::Padding paddingH = this.shaperH.getPadding(); + if (this.scroollingMode == scroolModeNormal) { + if ( _event.getType() == KeyType::mouse + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow + || this.highSpeedType == KeyType::mouse) ) { if ( _event.getId() == 1 - && _event.getStatus() == gale::key::status::down) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down) { // check if selected the scrolling position whth the scrolling bar ... - if (relativePos.x() >= (m_size.x()-paddingV.x())) { - if( m_size.y() < m_maxSize.y() - || m_originScrooled.y() != 0) { - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; - m_highSpeedType = gale::key::type::mouse; - m_highSpeedStartPos.setX(relativePos.x()); - m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.yButtom()*2)); - m_highSpeedButton = 1; + if (relativePos.x() >= (this.size.x()-paddingV.x())) { + if( this.size.y() < this.maxSize.y() + || this.originScrooled.y() != 0) { + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; + this.highSpeedType = KeyType::mouse; + this.highSpeedStartPos.setX(relativePos.x()); + this.highSpeedStartPos.setY(this.originScrooled.y() / this.maxSize.y() * (this.size.y()-paddingV.yButtom()*2)); + this.highSpeedButton = 1; // force direct scrolling in this case - m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (m_size.y()-paddingV.yButtom()*2))); - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); + this.originScrooled.setY((int)(this.maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (this.size.y()-paddingV.yButtom()*2))); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); markToRedraw(); return true; } - } else if (relativePos.y() >= (m_size.y()-paddingH.y())) { - if( m_size.x() < m_maxSize.x() - || m_originScrooled.x()!=0) { - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; - m_highSpeedType = gale::key::type::mouse; - m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingH.xLeft()*2)); - m_highSpeedStartPos.setY(relativePos.y()); - m_highSpeedButton = 1; + } else if (relativePos.y() >= (this.size.y()-paddingH.y())) { + if( this.size.x() < this.maxSize.x() + || this.originScrooled.x()!=0) { + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; + this.highSpeedType = KeyType::mouse; + this.highSpeedStartPos.setX(this.originScrooled.x() / this.maxSize.x() * (this.size.x()-paddingH.xLeft()*2)); + this.highSpeedStartPos.setY(relativePos.y()); + this.highSpeedButton = 1; // force direct scrolling in this case - m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (m_size.x()-paddingH.xLeft()*2))); - m_originScrooled.setX(etk::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling.x()))); + this.originScrooled.setX((int)(this.maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (this.size.x()-paddingH.xLeft()*2))); + this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x()))); markToRedraw(); return true; } } return false; } else if ( _event.getId() == 4 - && _event.getStatus() == gale::key::status::up) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { if (true == _event.getSpecialKey().getCtrl()) { changeZoom(1); /* @@ -139,17 +139,17 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event setZoom(zoom); */ } else { - if(m_size.y() < m_maxSize.y() - || m_originScrooled.y() != 0 - || m_size.y()*m_limitScrolling.y() < m_maxSize.y() ) { - m_originScrooled.setY(m_originScrooled.y()-m_pixelScrolling); - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); + if(this.size.y() < this.maxSize.y() + || this.originScrooled.y() != 0 + || this.size.y()*this.limitScrolling.y() < this.maxSize.y() ) { + this.originScrooled.setY(this.originScrooled.y()-this.pixelScrolling); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); markToRedraw(); return true; } } } else if ( _event.getId() == 5 - && _event.getStatus() == gale::key::status::up) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { if (true == _event.getSpecialKey().getCtrl()) { changeZoom(-1); /* @@ -158,162 +158,162 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event setZoom(zoom); */ } else { - if(m_size.y() < m_maxSize.y() - || m_originScrooled.y()!=0 - || m_size.y()*m_limitScrolling.y() < m_maxSize.y() ) { - m_originScrooled.setY(m_originScrooled.y()+m_pixelScrolling); - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); + if(this.size.y() < this.maxSize.y() + || this.originScrooled.y()!=0 + || this.size.y()*this.limitScrolling.y() < this.maxSize.y() ) { + this.originScrooled.setY(this.originScrooled.y()+this.pixelScrolling); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); markToRedraw(); return true; } } } else if ( _event.getId() == 11 - && _event.getStatus() == gale::key::status::up) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { // Scrool Left - if(m_size.x() < m_maxSize.x() - || m_originScrooled.x()!=0 - || m_size.x()*m_limitScrolling.x() < m_maxSize.x() ) { - m_originScrooled.setX(m_originScrooled.x()-m_pixelScrolling); - m_originScrooled.setX(etk::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling.x()))); + if(this.size.x() < this.maxSize.x() + || this.originScrooled.x()!=0 + || this.size.x()*this.limitScrolling.x() < this.maxSize.x() ) { + this.originScrooled.setX(this.originScrooled.x()-this.pixelScrolling); + this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x()))); markToRedraw(); return true; } } else if ( _event.getId() == 10 - && _event.getStatus() == gale::key::status::up) { + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { // Scrool Right - if(m_size.x() < m_maxSize.x() - || m_originScrooled.x()!=0 - || m_size.x()*m_limitScrolling.x() < m_maxSize.x() ) { - m_originScrooled.setX(m_originScrooled.x()+m_pixelScrolling); - m_originScrooled.setX(etk::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling.x()))); + if(this.size.x() < this.maxSize.x() + || this.originScrooled.x()!=0 + || this.size.x()*this.limitScrolling.x() < this.maxSize.x() ) { + this.originScrooled.setX(this.originScrooled.x()+this.pixelScrolling); + this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x()))); markToRedraw(); return true; } }else if (_event.getId() == 2) { /* if (true == ewol::isSetCtrl()) { - if (gale::key::status::down == typeEvent) { + if (KeyStatus::down == typeEvent) { float zoom = 1.0; setZoom(zoom); } } else */{ - if (_event.getStatus() == gale::key::status::down) { - m_highSpeedMode = ewol::widget::Scroll::speedModeInit; - m_highSpeedType = gale::key::type::mouse; - m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); - m_highSpeedButton = 2; + if (_event.getStatus() == KeyStatus::down) { + this.highSpeedMode = ewol::widget::Scroll::speedModeInit; + this.highSpeedType = KeyType::mouse; + this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); + this.highSpeedButton = 2; return true; } } - } else if ( m_highSpeedMode != ewol::widget::Scroll::speedModeDisable - && _event.getStatus() == gale::key::status::leave) { - m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + } else if ( this.highSpeedMode != ewol::widget::Scroll::speedModeDisable + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) { + this.highSpeedMode = ewol::widget::Scroll::speedModeDisable; + this.highSpeedType = KeyType::unknow; markToRedraw(); return true; } - if ( _event.getId() == m_highSpeedButton - && m_highSpeedMode != ewol::widget::Scroll::speedModeDisable) { - if (_event.getStatus() == gale::key::status::upAfter) { - m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + if ( _event.getId() == this.highSpeedButton + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.highSpeedMode != ewol::widget::Scroll::speedModeDisable) { + if (_event.getStatus() == KeyStatus::upAfter) { + this.highSpeedMode = ewol::widget::Scroll::speedModeDisable; + this.highSpeedType = KeyType::unknow; return false; - } else if (m_highSpeedMode == ewol::widget::Scroll::speedModeGrepEndEvent) { - if (_event.getStatus() == gale::key::status::pressSingle) { - m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = gale::key::type::unknow; - m_highSpeedButton = -1; + } else if (this.highSpeedMode == ewol::widget::Scroll::speedModeGrepEndEvent) { + if (_event.getStatus() == KeyStatus::pressSingle) { + this.highSpeedMode = ewol::widget::Scroll::speedModeDisable; + this.highSpeedType = KeyType::unknow; + this.highSpeedButton = -1; markToRedraw(); } return true; - } else if (_event.getStatus() == gale::key::status::up) { + } else if (_event.getStatus() == KeyStatus::up) { return true; - } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit - && _event.getStatus() == gale::key::status::move) { + } else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeInit + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { // wait that the cursor move more than 10 px to enable it : - if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 + || etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : - if (relativePos.x() == m_highSpeedStartPos.x()) { - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; - } else if (relativePos.y() == m_highSpeedStartPos.y()) { - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; + if (relativePos.x() == this.highSpeedStartPos.x()) { + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; + } else if (relativePos.y() == this.highSpeedStartPos.y()) { + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; } else { - float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x()); + float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x()); if (etk::abs(coef) <= 1 ) { - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; } else { - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; } } - if (m_highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal) { - m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingV.x())); + if (this.highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal) { + this.highSpeedStartPos.setX(this.originScrooled.x() / this.maxSize.x() * (this.size.x()-paddingV.x())); } else { - m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.y())); + this.highSpeedStartPos.setY(this.originScrooled.y() / this.maxSize.y() * (this.size.y()-paddingV.y())); } markToRedraw(); } - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); return true; } - if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal - && _event.getStatus() == gale::key::status::move) { - m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (m_size.x()-paddingH.x()))); - m_originScrooled.setX(etk::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling.x()))); + if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { + this.originScrooled.setX((int)(this.maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (this.size.x()-paddingH.x()))); + this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x()))); markToRedraw(); return true; } - if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableVertical - && _event.getStatus() == gale::key::status::move) { - m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (m_size.y()-paddingV.y()))); - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); + if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableVertical + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { + this.originScrooled.setY((int)(this.maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (this.size.y()-paddingV.y()))); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); markToRedraw(); return true; } } - } else if ( _event.getType() == gale::key::type::finger - && ( m_highSpeedType == gale::key::type::unknow - || m_highSpeedType == gale::key::type::finger) ) { - if (m_singleFingerMode == false) { + } else if ( _event.getType() == KeyType::finger + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow + || this.highSpeedType == KeyType::finger) ) { + if (this.singleFingerMode == false) { // *********************** // ** Two finger mode : ** // *********************** if (_event.getId() >= 3) { return false; } - int32_t idTable = _event.getId()-1; - if (_event.getStatus() == gale::key::status::down) { - m_fingerPresent[idTable] = true; - } else if (_event.getStatus() == gale::key::status::upAfter) { - m_fingerPresent[idTable] = false; + int idTable = _event.getId()-1; + if (_event.getStatus() == KeyStatus::down) { + this.fingerPresent[idTable] = true; + } else if (_event.getStatus() == KeyStatus::upAfter) { + this.fingerPresent[idTable] = false; } - if (m_fingerScoolActivated == false) { - m_fingerMoveStartPos[idTable] = relativePos; + if (this.fingerScoolActivated == false) { + this.fingerMoveStartPos[idTable] = relativePos; } - if ( m_fingerPresent[0] == true - && m_fingerPresent[1] == true - && m_fingerScoolActivated == false) { - m_fingerScoolActivated = true; - Log.verbose("SCROOL == > START pos=" << m_fingerMoveStartPos); + if ( this.fingerPresent[0] == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerPresent[1] == true + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerScoolActivated == false) { + this.fingerScoolActivated = true; + Log.verbose("SCROOL == > START pos=" + this.fingerMoveStartPos); } - if (m_fingerScoolActivated == true) { + if (this.fingerScoolActivated == true) { // 1: scroll... // 2: remove all unneeded sub event ... ==> maybe a better methode ... - if (_event.getStatus() == gale::key::status::move) { - m_originScrooled.setX(m_originScrooled.x() - (relativePos.x() - m_fingerMoveStartPos[idTable].x())*0.5f); - m_originScrooled.setY(m_originScrooled.y() - (relativePos.y() - m_fingerMoveStartPos[idTable].y())*0.5f); - m_originScrooled.setX(etk::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling.x()))); - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); - m_fingerMoveStartPos[idTable] = relativePos; - Log.verbose("SCROOL == > MOVE m_originScrooled=" << m_originScrooled << " " << relativePos << " " << m_highSpeedStartPos); + if (_event.getStatus() == KeyStatus::move) { + this.originScrooled.setX(this.originScrooled.x() - (relativePos.x() - this.fingerMoveStartPos[idTable].x())*0.5f); + this.originScrooled.setY(this.originScrooled.y() - (relativePos.y() - this.fingerMoveStartPos[idTable].y())*0.5f); + this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x()))); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); + this.fingerMoveStartPos[idTable] = relativePos; + Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos); markToRedraw(); } - if ( m_fingerPresent[0] == false - && m_fingerPresent[1] == false) { - if (_event.getStatus() == gale::key::status::upAfter) { + if ( this.fingerPresent[0] == false + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerPresent[1] == false) { + if (_event.getStatus() == KeyStatus::upAfter) { // TODO : Reset event ... - m_fingerScoolActivated = false; + this.fingerScoolActivated = false; _event.reset(); } } @@ -324,178 +324,178 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event // ** Single finger mode : ** // ************************** if (_event.getId() == 1) { - Log.verbose("event 1 " << _event); - if (_event.getStatus() == gale::key::status::down) { - m_highSpeedMode = ewol::widget::Scroll::speedModeInit; - m_highSpeedType = gale::key::type::finger; - m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); + Log.verbose("event 1 " + _event); + if (_event.getStatus() == KeyStatus::down) { + this.highSpeedMode = ewol::widget::Scroll::speedModeInit; + this.highSpeedType = KeyType::finger; + this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); Log.verbose("SCROOL == > INIT"); return true; - } else if (_event.getStatus() == gale::key::status::upAfter) { - m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + } else if (_event.getStatus() == KeyStatus::upAfter) { + this.highSpeedMode = ewol::widget::Scroll::speedModeDisable; + this.highSpeedType = KeyType::unknow; Log.verbose("SCROOL == > DISABLE"); markToRedraw(); return true; - } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit - && _event.getStatus() == gale::key::status::move) { + } else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeInit + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { // wait that the cursor move more than 10 px to enable it : - if( etk::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || etk::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 + || etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : - m_highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger; + this.highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger; Log.debug("SCROOL == > ENABLE"); markToRedraw(); } return true; - } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger - && _event.getStatus() == gale::key::status::pressSingle) { + } else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressSingle) { // Keep all event in the range of moving return true; - } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger - && _event.getStatus() == gale::key::status::pressDouble) { + } else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressDouble) { // Keep all event in the range of moving return true; - } if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger - && _event.getStatus() == gale::key::status::move) { - //m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x); - m_originScrooled.setX(m_originScrooled.x() - (relativePos.x() - m_highSpeedStartPos.x())); - m_originScrooled.setY(m_originScrooled.y() - (relativePos.y() - m_highSpeedStartPos.y())); - m_originScrooled.setX(etk::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling.x()))); - m_originScrooled.setY(etk::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling.y()))); - m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); - Log.verbose("SCROOL == > MOVE m_originScrooled=" << m_originScrooled << " " << relativePos << " " << m_highSpeedStartPos); + } if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) { + //this.originScrooled.x = (int)(this.maxSize.x * x / this.size.x); + this.originScrooled.setX(this.originScrooled.x() - (relativePos.x() - this.highSpeedStartPos.x())); + this.originScrooled.setY(this.originScrooled.y() - (relativePos.y() - this.highSpeedStartPos.y())); + this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x()))); + this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y()))); + this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); + Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos); markToRedraw(); return true; } - } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeDisable - && _event.getStatus() == gale::key::status::leave) { - m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = gale::key::type::unknow; + } else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeDisable + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) { + this.highSpeedMode = ewol::widget::Scroll::speedModeDisable; + this.highSpeedType = KeyType::unknow; Log.verbose("SCROOL == > DISABLE"); markToRedraw(); return true; } } } - } else if (m_scroollingMode == scroolModeCenter) { - if (_event.getType() == gale::key::type::mouse) { - float tmp1=m_size.x() / m_maxSize.y(); - float tmp2=m_size.y() / m_maxSize.x(); - //Log.info(" elements Zoom : " << tmp1 << " " << tmp2); + } else if (this.scroollingMode == scroolModeCenter) { + if (_event.getType() == KeyType::mouse) { + float tmp1=this.size.x() / this.maxSize.y(); + float tmp2=this.size.y() / this.maxSize.x(); + //Log.info(" elements Zoom : " + tmp1 + " " + tmp2); tmp1 = etk::min(tmp1, tmp2); if ( _event.getId() == 4 - && _event.getStatus() == gale::key::status::up) { - m_zoom -= 0.1; + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { + this.zoom -= 0.1; if (tmp1 < 1.0) { - m_zoom = etk::max(tmp1, m_zoom); + this.zoom = etk::max(tmp1, this.zoom); } else { - m_zoom = etk::max(1.0f, m_zoom); + this.zoom = etk::max(1.0f, this.zoom); } markToRedraw(); return true; } else if ( _event.getId() == 5 - && _event.getStatus() == gale::key::status::up) { - m_zoom += 0.1; + LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) { + this.zoom += 0.1; if (tmp1 > 1.0) { - m_zoom = etk::min(tmp1, m_zoom); + this.zoom = etk::min(tmp1, this.zoom); } else { - m_zoom = etk::min(1.0f, m_zoom); + this.zoom = etk::min(1.0f, this.zoom); } markToRedraw(); return true; } } - } else if (m_scroollingMode == scroolModeGame) { + } else if (this.scroollingMode == scroolModeGame) { } else { - Log.error("Scrolling mode unknow ... " << m_scroollingMode ); + Log.error("Scrolling mode unknow ... " + this.scroollingMode ); } return false; } void ewol::widget::WidgetScrolled::onDraw() { - m_shaperH.draw(); - m_shaperV.draw(); + this.shaperH.draw(); + this.shaperV.draw(); } -void ewol::widget::WidgetScrolled::systemDraw(const ewol::DrawProperty& _displayProp) { +void ewol::widget::WidgetScrolled::systemDraw( ewol::DrawProperty _displayProp) { gale::openGL::push(); - if (m_scroollingMode == scroolModeCenter) { + if (this.scroollingMode == scroolModeCenter) { // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left - gale::openGL::setViewPort(m_origin, m_size); - mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1); - mat4 tmpScale = etk::matScale(Vector3f(m_zoom, m_zoom, 1.0) ); - mat4 tmpTranslate = etk::matTranslate(Vector3f(-m_maxSize.x()/2, -m_maxSize.y()/2, -1.0) ); + gale::openGL::setViewPort(this.origin, this.size); + mat4 tmpProjection = etk::matOrtho(-this.size.x()/2, this.size.x()/2, -this.size.y()/2, this.size.y()/2, -1, 1); + mat4 tmpScale = etk::matScale(Vector3f(this.zoom, this.zoom, 1.0) ); + mat4 tmpTranslate = etk::matTranslate(Vector3f(-this.maxSize.x()/2, -this.maxSize.y()/2, -1.0) ); mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; // set internal matrix system : gale::openGL::setMatrix(tmpMat); // Call the widget drawing methode onDraw(); - } if (m_scroollingMode == scroolModeGame) { + } if (this.scroollingMode == scroolModeGame) { // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left - gale::openGL::setViewPort(m_origin, m_size); - mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1); - mat4 tmpTranslate = etk::matTranslate(Vector3f( -m_maxSize.x()/2, -m_maxSize.y()/2, -1.0) ); + gale::openGL::setViewPort(this.origin, this.size); + mat4 tmpProjection = etk::matOrtho(-this.size.x()/2, this.size.x()/2, -this.size.y()/2, this.size.y()/2, -1, 1); + mat4 tmpTranslate = etk::matTranslate(Vector3f( -this.maxSize.x()/2, -this.maxSize.y()/2, -1.0) ); mat4 tmpMat = tmpProjection * tmpTranslate; // set internal matrix system : gale::openGL::setMatrix(tmpMat); // Call the widget drawing methode onDraw(); } else { - ewol::Widget::systemDraw(_displayProp); + Widget::systemDraw(_displayProp); } gale::openGL::pop(); } -void ewol::widget::WidgetScrolled::setScrollingPositionDynamic(Vector2f _borderWidth, const Vector2f& _currentPosition, bool _center) { +void ewol::widget::WidgetScrolled::setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center) { if (true == _center) { - _borderWidth.setValue(m_size.x() / 2 - _borderWidth.x(), - m_size.y() / 2 - _borderWidth.y() ); + _borderWidth.setValue(this.size.x() / 2 - _borderWidth.x(), + this.size.y() / 2 - _borderWidth.y() ); } // check scrooling in X - if (_currentPosition.x() < (m_originScrooled.x() + _borderWidth.x()) ) { - m_originScrooled.setX(_currentPosition.x() - _borderWidth.x()); - m_originScrooled.setX(etk::max(0.0f, m_originScrooled.x())); - } else if (_currentPosition.x() > (m_originScrooled.x()+m_size.x()-2*_borderWidth.x()) ) { - m_originScrooled.setX(_currentPosition.x() - m_size.x() + 2*_borderWidth.x()); - m_originScrooled.setX(etk::max(0.0f, m_originScrooled.x())); + if (_currentPosition.x() < (this.originScrooled.x() + _borderWidth.x()) ) { + this.originScrooled.setX(_currentPosition.x() - _borderWidth.x()); + this.originScrooled.setX(etk::max(0.0f, this.originScrooled.x())); + } else if (_currentPosition.x() > (this.originScrooled.x()+this.size.x()-2*_borderWidth.x()) ) { + this.originScrooled.setX(_currentPosition.x() - this.size.x() + 2*_borderWidth.x()); + this.originScrooled.setX(etk::max(0.0f, this.originScrooled.x())); } // check scrooling in Y - if (_currentPosition.y() < (m_originScrooled.y() + _borderWidth.y()) ) { - m_originScrooled.setY(_currentPosition.y() - _borderWidth.y()); - m_originScrooled.setY(etk::max(0.0f, m_originScrooled.y())); - } else if (_currentPosition.y() > (m_originScrooled.y()+m_size.y()-2*_borderWidth.y()) ) { - m_originScrooled.setY(_currentPosition.y() - m_size.y() + 2*_borderWidth.y()); - m_originScrooled.setY(etk::max(0.0f, m_originScrooled.y())); + if (_currentPosition.y() < (this.originScrooled.y() + _borderWidth.y()) ) { + this.originScrooled.setY(_currentPosition.y() - _borderWidth.y()); + this.originScrooled.setY(etk::max(0.0f, this.originScrooled.y())); + } else if (_currentPosition.y() > (this.originScrooled.y()+this.size.y()-2*_borderWidth.y()) ) { + this.originScrooled.setY(_currentPosition.y() - this.size.y() + 2*_borderWidth.y()); + this.originScrooled.setY(etk::max(0.0f, this.originScrooled.y())); } } void ewol::widget::WidgetScrolled::scroolingMode(enum scrollingMode _newMode) { - m_scroollingMode = _newMode; - if (m_scroollingMode == scroolModeGame) { + this.scroollingMode = _newMode; + if (this.scroollingMode == scroolModeGame) { // set the scene maximum size : - m_maxSize.setValue(etk::max(m_size.x(), m_size.y()), - m_maxSize.x()); - m_zoom = 1; + this.maxSize.setValue(etk::max(this.size.x(), this.size.y()), + this.maxSize.x()); + this.zoom = 1; } } -void ewol::widget::WidgetScrolled::setSingleFinger(bool _status) { - if (m_singleFingerMode == _status) { +void ewol::widget::WidgetScrolled::setSingleFinger(boolean _status) { + if (this.singleFingerMode == _status) { return; } - m_singleFingerMode = _status; + this.singleFingerMode = _status; } void ewol::widget::WidgetScrolled::onChangePropertyShapeVert() { - m_shaperV.setSource(propertyShapeVert); + this.shaperV.setSource(propertyShapeVert); markToRedraw(); } void ewol::widget::WidgetScrolled::onChangePropertyShapeHori() { - m_shaperH.setSource(propertyShapeHori); + this.shaperH.setSource(propertyShapeHori); markToRedraw(); } diff --git a/src/org/atriasoft/ewol/widget/WidgetScrolled.java b/src/org/atriasoft/ewol/widget/WidgetScrolled.java index b38d09a..0b19318 100644 --- a/src/org/atriasoft/ewol/widget/WidgetScrolled.java +++ b/src/org/atriasoft/ewol/widget/WidgetScrolled.java @@ -16,12 +16,12 @@ namespace ewol { namespace widget { class WidgetScrolled; - using WidgetScrolledShared = ememory::SharedPtr; + using WidgetScrolled = ememory::Ptr; using WidgetScrolledWeak = ememory::WeakPtr; /** * @brief Widget to integrate a scrool bar in a widget. This is not a stadalone widget. */ - class WidgetScrolled : public ewol::Widget { + class WidgetScrolled : public Widget { public: // properties: eproperty::Value propertyShapeVert; //!< Vertical shaper name eproperty::Value propertyShapeHori; //!< Horizontal shaper name @@ -33,71 +33,71 @@ namespace ewol { scroolModeGame, //!< Zoom enable, no move left and right }; private: - ewol::compositing::Shaper m_shaperH; //!< Compositing theme Horizontal. - ewol::compositing::Shaper m_shaperV; //!< Compositing theme Vertical. + ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal. + ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical. protected: - Vector2f m_originScrooled; //!< pixel distance from the origin of the display (Bottum left) - Vector2f m_maxSize; //!< Maximum size of the Widget ==> to display scrollbar - Vector2f m_limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible) + Vector2f this.originScrooled; //!< pixel distance from the origin of the display (Bottum left) + Vector2f this.maxSize; //!< Maximum size of the Widget ==> to display scrollbar + Vector2f this.limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible) private: // Mouse section : - enum scrollingMode m_scroollingMode; //!< mode of management of the scrooling - float m_pixelScrolling; - Vector2f m_highSpeedStartPos; - enum Scroll::highSpeedMode m_highSpeedMode; - int32_t m_highSpeedButton; - enum gale::key::type m_highSpeedType; + enum scrollingMode this.scroollingMode; //!< mode of management of the scrooling + float this.pixelScrolling; + Vector2f this.highSpeedStartPos; + enum Scroll::highSpeedMode this.highSpeedMode; + int this.highSpeedButton; + KeyType this.highSpeedType; private: // finger section: - bool m_singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select... + boolean this.singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select... public: /** * @brief Set the single finger capabilities/ * @param[in] _status True if single inger mode, two otherwise/ */ - void setSingleFinger(bool _status); + void setSingleFinger(boolean _status); /** * @brief Get the single finger capabilities * @return true The single finger mode is active * @return false The To finger mode is active */ - bool getSingleFinger() { - return m_singleFingerMode; + boolean getSingleFinger() { + return this.singleFingerMode; } /** * @brief Reset the scoll of the subWidget */ void resetScrollOrigin() { - m_originScrooled = Vector2f(0,0); + this.originScrooled = Vector2f(0,0); } private: - bool m_fingerPresent[CALCULATE_SIMULTANEOUS_FINGER]; - bool m_fingerScoolActivated; - Vector2f m_fingerMoveStartPos[CALCULATE_SIMULTANEOUS_FINGER]; + boolean this.fingerPresent[CALCULATE_SIMULTANEOUS_FINGER]; + boolean this.fingerScoolActivated; + Vector2f this.fingerMoveStartPos[CALCULATE_SIMULTANEOUS_FINGER]; protected: /** - * @brief Scroll Widget main constructor to be herited from an other widget (this is not a stand-alone widget) + * @brief Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget) * @param[in] _shaperName Shaper name if the scrolled widget. */ WidgetScrolled(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(WidgetScrolled, "WidgetScrolled"); /** * @brief Scroll widget destructor. */ - virtual ~WidgetScrolled(); + ~WidgetScrolled(); protected: - void onDraw() override; + void onDraw() ; public: - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - void systemDraw(const ewol::DrawProperty& _displayProp) override; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + void systemDraw( ewol::DrawProperty _displayProp) ; protected: /** * @brief For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled * @param[in] _nbPixel number of pixel scrolling */ void setScrollingSize(float _nbPixel) { - m_pixelScrolling = _nbPixel; + this.pixelScrolling = _nbPixel; }; /** * @brief Specify the mode of scrolling for this windows @@ -108,8 +108,8 @@ namespace ewol { * @brief set the specific mawimum size of the widget * @param[in] _localSize new Maximum size */ - void setMaxSize(const Vector2f& _localSize) { - m_maxSize = _localSize; + void setMaxSize( Vector2f _localSize) { + this.maxSize = _localSize; }; /** * @brief Request a specific position for the scrolling of the current windows. @@ -117,25 +117,25 @@ namespace ewol { * @param[in] _currentPosition Position that is requested to view * @param[in] _center True if the position might be at the center of the widget */ - void setScrollingPositionDynamic(Vector2f _borderWidth, const Vector2f& _currentPosition, bool _center = false); + void setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center = false); /** * @brief set the scrolling limit when arriving at he end of the widget * @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ... */ void setLimitScrolling(float _poucentageLimit) { _poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f); - m_limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit); + this.limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit); }; /** * @brief set the scrolling limit when arriving at he end of the widget * @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific... */ - void setLimitScrolling(const Vector2f& _poucentageLimit) { - m_limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f)); + void setLimitScrolling( Vector2f _poucentageLimit) { + this.limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f)); }; protected: - virtual void onChangePropertyShapeVert(); - virtual void onChangePropertyShapeHori(); + void onChangePropertyShapeVert(); + void onChangePropertyShapeHori(); }; } } diff --git a/src/org/atriasoft/ewol/widget/Windows.cpp b/src/org/atriasoft/ewol/widget/Windows.cpp index c5b2264..c8df178 100644 --- a/src/org/atriasoft/ewol/widget/Windows.cpp +++ b/src/org/atriasoft/ewol/widget/Windows.cpp @@ -22,14 +22,14 @@ ewol::widget::Windows::Windows() : "file-color", etk::Uri("THEME_COLOR:///Windows.json?lib=ewol"), "File color of the Windows", - &ewol::widget::Windows::onChangePropertyColor), + ewol::widget::Windows::onChangePropertyColor), propertyTitle(this, "title", "No title", "Title of the windows", - &ewol::widget::Windows::onChangePropertyTitle), - m_resourceColor(null), - m_colorBg(-1) { + ewol::widget::Windows::onChangePropertyTitle), + this.resourceColor(null), + this.colorBg(-1) { addObjectType("ewol::widget::Windows"); propertyCanFocus.setDirectCheck(true); //KeyboardShow(KEYBOARD_MODE_CODE); @@ -37,53 +37,53 @@ ewol::widget::Windows::Windows() : void ewol::widget::Windows::init() { - ewol::Widget::init(); + Widget::init(); onChangePropertyColor(); } ewol::widget::Windows::~Windows() { - m_subWidget.reset(); - m_popUpWidgetList.clear(); + this.subWidget.reset(); + this.popUpWidgetList.clear(); } void ewol::widget::Windows::onChangeSize() { - ewol::Widget::onChangeSize(); - if (m_subWidget != null) { - m_subWidget->calculateMinMaxSize(); + Widget::onChangeSize(); + if (this.subWidget != null) { + this.subWidget.calculateMinMaxSize(); // TODO : do it better ... and manage gravity ... - m_subWidget->setSize(m_size); - m_subWidget->setOrigin(Vector2f(0.0f, 0.0f)); - m_subWidget->onChangeSize(); + this.subWidget.setSize(this.size); + this.subWidget.setOrigin(Vector2f(0.0f, 0.0f)); + this.subWidget.onChangeSize(); } - for (auto &it : m_popUpWidgetList) { + for (auto it : this.popUpWidgetList) { if(it != null) { - it->calculateMinMaxSize(); - it->setSize(m_size); - it->setOrigin(Vector2f(0.0f, 0.0f)); - it->onChangeSize(); + it.calculateMinMaxSize(); + it.setSize(this.size); + it.setOrigin(Vector2f(0.0f, 0.0f)); + it.onChangeSize(); } } } -ewol::WidgetShared ewol::widget::Windows::getWidgetAtPos(const Vector2f& _pos) { - Log.verbose("Get widget at pos : " << _pos); +Widget ewol::widget::Windows::getWidgetAtPos( Vector2f _pos) { + Log.verbose("Get widget at pos : " + _pos); // calculate relative position Vector2f relativePos = relativePosition(_pos); // event go directly on the pop-up - if (m_popUpWidgetList.size() != 0) { - return m_popUpWidgetList.back()->getWidgetAtPos(_pos); + if (this.popUpWidgetList.size() != 0) { + return this.popUpWidgetList.back().getWidgetAtPos(_pos); // otherwise in the normal windows - } else if (m_subWidget != null) { - return m_subWidget->getWidgetAtPos(_pos); + } else if (this.subWidget != null) { + return this.subWidget.getWidgetAtPos(_pos); } // otherwise the event go to this widget ... - return ememory::dynamicPointerCast(sharedFromThis()); + return ememory::dynamicPointerCast(sharedFromThis()); } void ewol::widget::Windows::sysDraw() { - Log.verbose("Draw on " << m_size); + Log.verbose("Draw on " + this.size); // set the size of the open GL system - gale::openGL::setViewPort(Vector2f(0,0), m_size); + gale::openGL::setViewPort(Vector2f(0,0), this.size); gale::openGL::disable(gale::openGL::flag_dither); //gale::openGL::disable(gale::openGL::flag_blend); gale::openGL::disable(gale::openGL::flag_stencilTest); @@ -100,94 +100,94 @@ void ewol::widget::Windows::sysDraw() { gale::openGL::setBasicMatrix(newOne); ewol::DrawProperty displayProp; - displayProp.m_windowsSize = m_size; - displayProp.m_origin.setValue(0,0); - displayProp.m_size = m_size; + displayProp.this.windowsSize = this.size; + displayProp.this.origin.setValue(0,0); + displayProp.this.size = this.size; systemDraw(displayProp); gale::openGL::disable(gale::openGL::flag_blend); return; } void ewol::widget::Windows::onRegenerateDisplay() { - if (m_subWidget != null) { - m_subWidget->onRegenerateDisplay(); + if (this.subWidget != null) { + this.subWidget.onRegenerateDisplay(); } - for (auto &it : m_popUpWidgetList) { + for (auto it : this.popUpWidgetList) { if (it != null) { - it->onRegenerateDisplay(); + it.onRegenerateDisplay(); } } } //#define TEST_PERFO_WINDOWS -void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) { - ewol::Widget::systemDraw(_displayProp); +void ewol::widget::Windows::systemDraw( ewol::DrawProperty _displayProp) { + Widget::systemDraw(_displayProp); #ifdef TEST_PERFO_WINDOWS - int64_t ___startTime0 = ewol::getTime(); + long ___startTime0 = ewol::getTime(); #endif // clear the screen with transparency ... etk::Color colorBg(0.5, 0.5, 0.5, 0.5); - if (m_resourceColor != null) { - colorBg = m_resourceColor->get(m_colorBg); + if (this.resourceColor != null) { + colorBg = this.resourceColor.get(this.colorBg); } gale::openGL::clearColor(colorBg); - gale::openGL::clear( uint32_t(gale::openGL::clearFlag_colorBuffer) - | uint32_t(gale::openGL::clearFlag_depthBuffer)); + gale::openGL::clear( uint(gale::openGL::clearFlag_colorBuffer) + | uint(gale::openGL::clearFlag_depthBuffer)); #ifdef TEST_PERFO_WINDOWS float ___localTime0 = (float)(ewol::getTime() - ___startTime0) / 1000.0f; - Log.error(" Windows000 : " << ___localTime0 << "ms "); - int64_t ___startTime1 = ewol::getTime(); + Log.error(" Windows000 : " + ___localTime0 + "ms "); + long ___startTime1 = ewol::getTime(); #endif - //EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId); + //Log.warning(" WINDOWS draw on " + this.currentDrawId); // first display the windows on the display - if (m_subWidget != null) { - m_subWidget->systemDraw(_displayProp); + if (this.subWidget != null) { + this.subWidget.systemDraw(_displayProp); //Log.debug("Draw Windows"); } #ifdef TEST_PERFO_WINDOWS float ___localTime1 = (float)(ewol::getTime() - ___startTime1) / 1000.0f; - Log.error(" Windows111 : " << ___localTime1 << "ms "); - int64_t ___startTime2 = ewol::getTime(); + Log.error(" Windows111 : " + ___localTime1 + "ms "); + long ___startTime2 = ewol::getTime(); #endif // second display the pop-up - for (auto &it : m_popUpWidgetList) { + for (auto it : this.popUpWidgetList) { if (it != null) { - it->systemDraw(_displayProp); + it.systemDraw(_displayProp); //Log.debug("Draw Pop-up"); } } #ifdef TEST_PERFO_WINDOWS float ___localTime2 = (float)(ewol::getTime() - ___startTime2) / 1000.0f; - Log.error(" Windows222 : " << ___localTime2 << "ms "); + Log.error(" Windows222 : " + ___localTime2 + "ms "); #endif } -void ewol::widget::Windows::setSubWidget(ewol::WidgetShared _widget) { - if (m_subWidget != null) { +void ewol::widget::Windows::setSubWidget(Widget _widget) { + if (this.subWidget != null) { Log.info("Remove current main windows Widget..."); - m_subWidget->removeParent(); - m_subWidget.reset(); + this.subWidget.removeParent(); + this.subWidget.reset(); } if (_widget != null) { - m_subWidget = _widget; - m_subWidget->setParent(sharedFromThis()); + this.subWidget = _widget; + this.subWidget.setParent(sharedFromThis()); } // Regenerate the size calculation : onChangeSize(); } -void ewol::widget::Windows::popUpWidgetPush(ewol::WidgetShared _widget) { +void ewol::widget::Windows::popUpWidgetPush(Widget _widget) { if (_widget == null) { // nothing to do an error appear : Log.error("can not set widget pop-up (null pointer)"); return; } - m_popUpWidgetList.pushBack(_widget); - _widget->setParent(sharedFromThis()); + this.popUpWidgetList.pushBack(_widget); + _widget.setParent(sharedFromThis()); // force the focus on the basic widget ==> this remove many time the virual keyboard area - _widget->keepFocus(); + _widget.keepFocus(); // Regenerate the size calculation : onChangeSize(); // TODO : it is dangerous to access directly to the system ... @@ -195,23 +195,23 @@ void ewol::widget::Windows::popUpWidgetPush(ewol::WidgetShared _widget) { } void ewol::widget::Windows::popUpWidgetPop() { - if (m_popUpWidgetList.size() == 0) { + if (this.popUpWidgetList.size() == 0) { return; } - m_popUpWidgetList.popBack(); + this.popUpWidgetList.popBack(); } void ewol::widget::Windows::onChangePropertyColor() { - m_resourceColor = ewol::resource::ColorFile::create(*propertyColorConfiguration); - if (m_resourceColor != null) { - m_colorBg = m_resourceColor->request("background"); + this.resourceColor = ewol::resource::ColorFile::create(*propertyColorConfiguration); + if (this.resourceColor != null) { + this.colorBg = this.resourceColor.request("background"); } else { - EWOL_WARNING("Can not open the default color configuration file for the windows: " << *propertyColorConfiguration); + Log.warning("Can not open the default color configuration file for the windows: " + *propertyColorConfiguration); } } void ewol::widget::Windows::onChangePropertyTitle() { - ewol::Context& context = getContext(); + EwolContext context = getContext(); if (context.getWindows() == sharedFromThis()) { context.setTitle(*propertyTitle); } else { @@ -219,53 +219,53 @@ void ewol::widget::Windows::onChangePropertyTitle() { } } -void ewol::widget::Windows::requestDestroyFromChild(const ewol::ObjectShared& _child) { +void ewol::widget::Windows::requestDestroyFromChild( EwolObject _child) { Log.verbose("A child has been removed"); - auto it = m_popUpWidgetList.begin(); - while (it != m_popUpWidgetList.end()) { + auto it = this.popUpWidgetList.begin(); + while (it != this.popUpWidgetList.end()) { if (*it == _child) { Log.verbose(" Find it ..."); if (*it == null) { - m_popUpWidgetList.erase(it); - it = m_popUpWidgetList.begin(); + this.popUpWidgetList.erase(it); + it = this.popUpWidgetList.begin(); continue; } - (*it)->removeParent(); + (*it).removeParent(); (*it).reset(); - m_popUpWidgetList.erase(it); - it = m_popUpWidgetList.begin(); + this.popUpWidgetList.erase(it); + it = this.popUpWidgetList.begin(); markToRedraw(); continue; } ++it; } - if (m_subWidget == _child) { + if (this.subWidget == _child) { Log.verbose(" Find it ... 2"); - if (m_subWidget == null) { + if (this.subWidget == null) { return; } - m_subWidget->removeParent(); - m_subWidget.reset(); + this.subWidget.removeParent(); + this.subWidget.reset(); markToRedraw(); } } -ewol::ObjectShared ewol::widget::Windows::getSubObjectNamed(const etk::String& _objectName) { - ewol::ObjectShared tmpObject = ewol::Widget::getSubObjectNamed(_objectName); +EwolObject ewol::widget::Windows::getSubObjectNamed( String _objectName) { + EwolObject tmpObject = Widget::getSubObjectNamed(_objectName); if (tmpObject != null) { return tmpObject; } // check direct subwidget - if (m_subWidget != null) { - tmpObject = m_subWidget->getSubObjectNamed(_objectName); + if (this.subWidget != null) { + tmpObject = this.subWidget.getSubObjectNamed(_objectName); if (tmpObject != null) { return tmpObject; } } // get all subwidget "pop-up" - for (auto &it : m_popUpWidgetList) { + for (auto it : this.popUpWidgetList) { if (it != null) { - tmpObject = it->getSubObjectNamed(_objectName); + tmpObject = it.getSubObjectNamed(_objectName); if (tmpObject != null) { return tmpObject; } @@ -275,15 +275,15 @@ ewol::ObjectShared ewol::widget::Windows::getSubObjectNamed(const etk::String& _ return null; } -void ewol::widget::Windows::drawWidgetTree(int32_t _level) { - ewol::Widget::drawWidgetTree(_level); +void ewol::widget::Windows::drawWidgetTree(int _level) { + Widget::drawWidgetTree(_level); _level++; - if (m_subWidget != null) { - m_subWidget->drawWidgetTree(_level); + if (this.subWidget != null) { + this.subWidget.drawWidgetTree(_level); } - for (auto &it: m_popUpWidgetList) { + for (auto it: this.popUpWidgetList) { if (it != null) { - it->drawWidgetTree(_level); + it.drawWidgetTree(_level); } } } diff --git a/src/org/atriasoft/ewol/widget/Windows.java b/src/org/atriasoft/ewol/widget/Windows.java index d7dc3d6..6605089 100644 --- a/src/org/atriasoft/ewol/widget/Windows.java +++ b/src/org/atriasoft/ewol/widget/Windows.java @@ -14,42 +14,42 @@ namespace ewol { namespace widget { class Windows; - using WindowsShared = ememory::SharedPtr; + using Windows = ememory::Ptr; using WindowsWeak = ememory::WeakPtr; /** * @brief Windows basic interface */ - class Windows : public ewol::Widget { + class Windows : public Widget { public: eproperty::Value propertyColorConfiguration; //!< Configuration file of the windows theme - eproperty::Value propertyTitle; //!< Current title of the windows + eproperty::Value propertyTitle; //!< Current title of the windows protected: - ememory::SharedPtr m_resourceColor; //!< theme color property (name of file in @ref propertyColorConfiguration) - int32_t m_colorBg; //!< Default background color of the windows + ememory::Ptr this.resourceColor; //!< theme color property (name of file in @ref propertyColorConfiguration) + int this.colorBg; //!< Default background color of the windows protected: Windows(); - void init() override; + void init() ; public: - virtual ~Windows(); + ~Windows(); // internal event at ewol system: public: void sysDraw(); protected: - ewol::WidgetShared m_subWidget; //!< main sub-widget of the Windows. + Widget this.subWidget; //!< main sub-widget of the Windows. public: /** * @brief Set the main widget of the application. * @param[in] _widget Widget to set in the windows. */ - void setSubWidget(ewol::WidgetShared _widget); + void setSubWidget(Widget _widget); protected: - List m_popUpWidgetList; //!< List of pop-up displayed + List this.popUpWidgetList; //!< List of pop-up displayed public: /** * @brief Add a pop-up on the Windows. * @param[in] _widget Widget to set on top of the pop-up. */ - void popUpWidgetPush(ewol::WidgetShared _widget); + void popUpWidgetPush(Widget _widget); /** * @brief Remove the pop-up on top. */ @@ -58,27 +58,27 @@ namespace ewol { * @brief Get the number of pop-up * @return Count of pop-up */ - size_t popUpCount() { - return m_popUpWidgetList.size(); + int popUpCount() { + return this.popUpWidgetList.size(); } protected: - void systemDraw(const ewol::DrawProperty& _displayProp) override; + void systemDraw( ewol::DrawProperty _displayProp) ; public: - void onRegenerateDisplay() override; - void onChangeSize() override; - ewol::WidgetShared getWidgetAtPos(const Vector2f& _pos) override; - void requestDestroyFromChild(const ewol::ObjectShared& _child) override; - ewol::ObjectShared getSubObjectNamed(const etk::String& _objectName) override; - void drawWidgetTree(int32_t _level=0) override; + void onRegenerateDisplay() ; + void onChangeSize() ; + Widget getWidgetAtPos( Vector2f _pos) ; + void requestDestroyFromChild( EwolObject _child) ; + EwolObject getSubObjectNamed( String _objectName) ; + void drawWidgetTree(int _level=0) ; protected: /** * @brief Called when property change: Title */ - virtual void onChangePropertyTitle(); + void onChangePropertyTitle(); /** * @brief Called when property change: Color configuration file */ - virtual void onChangePropertyColor(); + void onChangePropertyColor(); }; } } diff --git a/src/org/atriasoft/ewol/widget/meta/ColorChooser.cpp b/src/org/atriasoft/ewol/widget/meta/ColorChooser.cpp index ad12f84..a2d1c86 100644 --- a/src/org/atriasoft/ewol/widget/meta/ColorChooser.cpp +++ b/src/org/atriasoft/ewol/widget/meta/ColorChooser.cpp @@ -24,7 +24,7 @@ ewol::widget::ColorChooser::ColorChooser() : propertyValue(this, "value", etk::color::white, "color to select", - &ewol::widget::ColorChooser::onChangePropertyValue) { + ewol::widget::ColorChooser::onChangePropertyValue) { addObjectType("ewol::widget::ColorChooser"); } @@ -32,48 +32,48 @@ void ewol::widget::ColorChooser::init() { ewol::widget::Sizer::init(); propertyMode.set(ewol::widget::Sizer::modeVert); propertyLockExpand.set(Vector2b(true,true)); - m_widgetColorBar = ewol::widget::ColorBar::create(); - m_widgetColorBar->signalChange.connect(sharedFromThis(), &ewol::widget::ColorChooser::onCallbackColorChange); - m_widgetColorBar->propertyFill.set(Vector2b(true,true)); - subWidgetAdd(m_widgetColorBar); + this.widgetColorBar = ewol::widget::ColorBar::create(); + this.widgetColorBar.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChange); + this.widgetColorBar.propertyFill.set(Vector2b(true,true)); + subWidgetAdd(this.widgetColorBar); etk::Color<> sliderColor; sliderColor = etk::color::black; - m_widgetRed = ewol::widget::Slider::create(); - m_widgetRed->signalChange.connect(sharedFromThis(), &ewol::widget::ColorChooser::onCallbackColorChangeRed); - m_widgetRed->propertyExpand.set(Vector2b(true,false)); - m_widgetRed->propertyFill.set(Vector2b(true,false)); - m_widgetRed->propertyMinimum.set(0); - m_widgetRed->propertyMaximum.set(255); + this.widgetRed = ewol::widget::Slider::create(); + this.widgetRed.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeRed); + this.widgetRed.propertyExpand.set(Vector2b(true,false)); + this.widgetRed.propertyFill.set(Vector2b(true,false)); + this.widgetRed.propertyMinimum.set(0); + this.widgetRed.propertyMaximum.set(255); sliderColor = etk::Color<>(0xFF, 0x00, 0x00, 0xFF); - m_widgetRed->setColor(sliderColor); - subWidgetAdd(m_widgetRed); - m_widgetGreen = ewol::widget::Slider::create(); - m_widgetGreen->signalChange.connect(sharedFromThis(), &ewol::widget::ColorChooser::onCallbackColorChangeGreen); - m_widgetGreen->propertyExpand.set(Vector2b(true,false)); - m_widgetGreen->propertyFill.set(Vector2b(true,false)); - m_widgetGreen->propertyMinimum.set(0); - m_widgetGreen->propertyMaximum.set(255); + this.widgetRed.setColor(sliderColor); + subWidgetAdd(this.widgetRed); + this.widgetGreen = ewol::widget::Slider::create(); + this.widgetGreen.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeGreen); + this.widgetGreen.propertyExpand.set(Vector2b(true,false)); + this.widgetGreen.propertyFill.set(Vector2b(true,false)); + this.widgetGreen.propertyMinimum.set(0); + this.widgetGreen.propertyMaximum.set(255); sliderColor = etk::Color<>(0x00, 0xFF, 0x00, 0xFF); - m_widgetGreen->setColor(sliderColor); - subWidgetAdd(m_widgetGreen); - m_widgetBlue = ewol::widget::Slider::create(); - m_widgetBlue->signalChange.connect(sharedFromThis(), &ewol::widget::ColorChooser::onCallbackColorChangeBlue); - m_widgetBlue->propertyExpand.set(Vector2b(true,false)); - m_widgetBlue->propertyFill.set(Vector2b(true,false)); - m_widgetBlue->propertyMinimum.set(0); - m_widgetBlue->propertyMaximum.set(255); + this.widgetGreen.setColor(sliderColor); + subWidgetAdd(this.widgetGreen); + this.widgetBlue = ewol::widget::Slider::create(); + this.widgetBlue.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeBlue); + this.widgetBlue.propertyExpand.set(Vector2b(true,false)); + this.widgetBlue.propertyFill.set(Vector2b(true,false)); + this.widgetBlue.propertyMinimum.set(0); + this.widgetBlue.propertyMaximum.set(255); sliderColor = etk::Color<>(0x00, 0x00, 0xFF, 0xFF); - m_widgetBlue->setColor(sliderColor); - subWidgetAdd(m_widgetBlue); - m_widgetAlpha = ewol::widget::Slider::create(); - m_widgetAlpha->signalChange.connect(sharedFromThis(), &ewol::widget::ColorChooser::onCallbackColorChangeAlpha); - m_widgetAlpha->propertyExpand.set(Vector2b(true,false)); - m_widgetAlpha->propertyFill.set(Vector2b(true,false)); - m_widgetAlpha->propertyMinimum.set(0); - m_widgetAlpha->propertyMaximum.set(255); - subWidgetAdd(m_widgetAlpha); + this.widgetBlue.setColor(sliderColor); + subWidgetAdd(this.widgetBlue); + this.widgetAlpha = ewol::widget::Slider::create(); + this.widgetAlpha.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeAlpha); + this.widgetAlpha.propertyExpand.set(Vector2b(true,false)); + this.widgetAlpha.propertyFill.set(Vector2b(true,false)); + this.widgetAlpha.propertyMinimum.set(0); + this.widgetAlpha.propertyMaximum.set(255); + subWidgetAdd(this.widgetAlpha); } @@ -83,71 +83,71 @@ ewol::widget::ColorChooser::~ColorChooser() { void ewol::widget::ColorChooser::onChangePropertyValue() { - if (m_widgetRed != null) { - m_widgetRed->propertyValue.set(propertyValue->r()); + if (this.widgetRed != null) { + this.widgetRed.propertyValue.set(propertyValue.r()); } - if (m_widgetGreen != null) { - m_widgetGreen->propertyValue.set(propertyValue->g()); + if (this.widgetGreen != null) { + this.widgetGreen.propertyValue.set(propertyValue.g()); } - if (m_widgetBlue != null) { - m_widgetBlue->propertyValue.set(propertyValue->b()); + if (this.widgetBlue != null) { + this.widgetBlue.propertyValue.set(propertyValue.b()); } - if (m_widgetAlpha != null) { - m_widgetAlpha->propertyValue.set(propertyValue->a()); + if (this.widgetAlpha != null) { + this.widgetAlpha.propertyValue.set(propertyValue.a()); } - if (m_widgetColorBar != null) { - m_widgetColorBar->propertyValue.set(propertyValue); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); } } -void ewol::widget::ColorChooser::onCallbackColorChangeRed(const float& _newColor) { +void ewol::widget::ColorChooser::onCallbackColorChangeRed( float _newColor) { propertyValue.getDirect().setR(_newColor); - if (m_widgetColorBar != null) { - m_widgetColorBar->propertyValue.set(propertyValue); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); } signalChange.emit(propertyValue); } -void ewol::widget::ColorChooser::onCallbackColorChangeGreen(const float& _newColor) { +void ewol::widget::ColorChooser::onCallbackColorChangeGreen( float _newColor) { propertyValue.getDirect().setG(_newColor); - if (m_widgetColorBar != null) { - m_widgetColorBar->propertyValue.set(propertyValue); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); } signalChange.emit(propertyValue); } -void ewol::widget::ColorChooser::onCallbackColorChangeBlue(const float& _newColor) { +void ewol::widget::ColorChooser::onCallbackColorChangeBlue( float _newColor) { propertyValue.getDirect().setB(_newColor); - if (m_widgetColorBar != null) { - m_widgetColorBar->propertyValue.set(propertyValue); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); } signalChange.emit(propertyValue); } -void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const float& _newColor) { +void ewol::widget::ColorChooser::onCallbackColorChangeAlpha( float _newColor) { propertyValue.getDirect().setA(_newColor); - if (m_widgetColorBar != null) { - m_widgetColorBar->propertyValue.set(propertyValue); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); } signalChange.emit(propertyValue); } -void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) { +void ewol::widget::ColorChooser::onCallbackColorChange( etk::Color<> _newColor) { // == > colorBar has change ... - uint8_t tmpAlpha = propertyValue->a(); + int tmpAlpha = propertyValue.a(); propertyValue.getDirect() = _newColor; propertyValue.getDirect().setA(tmpAlpha); - if (m_widgetRed != null) { - m_widgetRed->propertyValue.set(propertyValue->r()); + if (this.widgetRed != null) { + this.widgetRed.propertyValue.set(propertyValue.r()); } - if (m_widgetGreen != null) { - m_widgetGreen->propertyValue.set(propertyValue->g()); + if (this.widgetGreen != null) { + this.widgetGreen.propertyValue.set(propertyValue.g()); } - if (m_widgetBlue != null) { - m_widgetBlue->propertyValue.set(propertyValue->b()); + if (this.widgetBlue != null) { + this.widgetBlue.propertyValue.set(propertyValue.b()); } - if (m_widgetAlpha != null) { - m_widgetAlpha->propertyValue.set(propertyValue->a()); + if (this.widgetAlpha != null) { + this.widgetAlpha.propertyValue.set(propertyValue.a()); } signalChange.emit(propertyValue); } \ No newline at end of file diff --git a/src/org/atriasoft/ewol/widget/meta/ColorChooser.java b/src/org/atriasoft/ewol/widget/meta/ColorChooser.java index b963058..3e80c39 100644 --- a/src/org/atriasoft/ewol/widget/meta/ColorChooser.java +++ b/src/org/atriasoft/ewol/widget/meta/ColorChooser.java @@ -19,7 +19,7 @@ namespace ewol { namespace widget { class ColorChooser; - using ColorChooserShared = ememory::SharedPtr; + using ColorChooser = ememory::Ptr; using ColorChooserWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -31,23 +31,23 @@ namespace ewol { eproperty::Value> propertyValue; protected: ColorChooser(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser"); - virtual ~ColorChooser(); + ~ColorChooser(); private: - ewol::widget::ColorBarShared m_widgetColorBar; - ewol::widget::SliderShared m_widgetRed; - ewol::widget::SliderShared m_widgetGreen; - ewol::widget::SliderShared m_widgetBlue; - ewol::widget::SliderShared m_widgetAlpha; - void onCallbackColorChangeRed(const float& _newColor); - void onCallbackColorChangeGreen(const float& _newColor); - void onCallbackColorChangeBlue(const float& _newColor); - void onCallbackColorChangeAlpha(const float& _newColor); - void onCallbackColorChange(const etk::Color<>& _newColor); + ewol::widget::ColorBar this.widgetColorBar; + ewol::widget::Slider this.widgetRed; + ewol::widget::Slider this.widgetGreen; + ewol::widget::Slider this.widgetBlue; + ewol::widget::Slider this.widgetAlpha; + void onCallbackColorChangeRed( float _newColor); + void onCallbackColorChangeGreen( float _newColor); + void onCallbackColorChangeBlue( float _newColor); + void onCallbackColorChangeAlpha( float _newColor); + void onCallbackColorChange( etk::Color<> _newColor); protected: - virtual void onChangePropertyValue(); + void onChangePropertyValue(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/meta/FileChooser.cpp b/src/org/atriasoft/ewol/widget/meta/FileChooser.cpp index 2cee75e..429890b 100644 --- a/src/org/atriasoft/ewol/widget/meta/FileChooser.cpp +++ b/src/org/atriasoft/ewol/widget/meta/FileChooser.cpp @@ -36,23 +36,23 @@ ewol::widget::FileChooser::FileChooser() : propertyPath(this, "path", etk::path::getHomePath(), "", - &ewol::widget::FileChooser::onChangePropertyPath), + ewol::widget::FileChooser::onChangePropertyPath), propertyFile(this, "file", "", "", - &ewol::widget::FileChooser::onChangePropertyFile), + ewol::widget::FileChooser::onChangePropertyFile), propertyLabelTitle(this, "title", "_T{FileChooser}", "", - &ewol::widget::FileChooser::onChangePropertyLabelTitle), + ewol::widget::FileChooser::onChangePropertyLabelTitle), propertyLabelValidate(this, "label-validate", "_T{Validate}", "", - &ewol::widget::FileChooser::onChangePropertyLabelValidate), + ewol::widget::FileChooser::onChangePropertyLabelValidate), propertyLabelCancel(this, "label-cancel", "_T{Cancel}", "", - &ewol::widget::FileChooser::onChangePropertyLabelCancel) { + ewol::widget::FileChooser::onChangePropertyLabelCancel) { addObjectType("ewol::widget::FileChooser"); } @@ -65,17 +65,17 @@ void ewol::widget::FileChooser::init() { propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:validate-label", "value", propertyLabelValidate); propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel); - subBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:show-hiden-file", signalValue, sharedFromThis(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue); - subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-validate", signalPressed, sharedFromThis(), &ewol::widget::FileChooser::onCallbackListValidate); - subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-cancel", signalPressed, sharedFromThis(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed); - subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-folder", signalFolderValidate, sharedFromThis(), &ewol::widget::FileChooser::onCallbackListFolderSelectChange); - subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileSelect, sharedFromThis(), &ewol::widget::FileChooser::onCallbackListFileSelectChange); - subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileValidate, sharedFromThis(), &ewol::widget::FileChooser::onCallbackListFileValidate); - subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalModify, sharedFromThis(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValue); - subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalEnter, sharedFromThis(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValidate); - subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalModify, sharedFromThis(), &ewol::widget::FileChooser::onCallbackEntryFolderChangeValue); - //composerBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalEnter, sharedFromThis(), &ewol::widget::FileChooser::); - subBind(ewol::widget::Image, "[" + etk::toString(getId()) + "]file-shooser:img-home", signalPressed, sharedFromThis(), &ewol::widget::FileChooser::onCallbackHomePressed); + subBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:show-hiden-file", signalValue, sharedFromThis(), ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-validate", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackListValidate); + subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-cancel", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackButtonCancelPressed); + subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-folder", signalFolderValidate, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFolderSelectChange); + subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileSelect, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFileSelectChange); + subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileValidate, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFileValidate); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalModify, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFileChangeValue); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalEnter, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFileChangeValidate); + subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalModify, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFolderChangeValue); + //composerBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalEnter, sharedFromThis(), ewol::widget::FileChooser::); + subBind(ewol::widget::Image, "[" + etk::toString(getId()) + "]file-shooser:img-home", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackHomePressed); // set the default Folder properties: updateCurrentFolder(); propertyCanFocus.set(true); @@ -96,7 +96,7 @@ void ewol::widget::FileChooser::onChangePropertyPath() { } void ewol::widget::FileChooser::onChangePropertyFile() { - propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-file", "value", propertyFile->getFileName()); + propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-file", "value", propertyFile.getFileName()); //updateCurrentFolder(); } @@ -112,12 +112,12 @@ void ewol::widget::FileChooser::onChangePropertyLabelCancel() { propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel); } -void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue(const etk::String& _value) { +void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue( String _value) { // == > change the folder name // TODO : change the folder, if it exit ... } -void ewol::widget::FileChooser::onCallbackEntryFileChangeValue(const etk::String& _value) { +void ewol::widget::FileChooser::onCallbackEntryFileChangeValue( String _value) { // == > change the file name.get(.get( propertyFile.setDirect(_value); // update the selected file in the list : @@ -130,7 +130,7 @@ void ewol::widget::FileChooser::onCallbackButtonCancelPressed() { autoDestroy(); } -void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue(const bool& _value) { +void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue( bool _value) { if (_value == true) { propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "show-hidden", "true"); propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "show-hidden", "true"); @@ -140,49 +140,49 @@ void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue(const bool& } } -void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const etk::Path& _value) { +void ewol::widget::FileChooser::onCallbackListFolderSelectChange( etk::Path _value) { // == > this is an internal event ... - Log.debug(" old PATH: '" << *propertyPath << "' ==> '" << _value << "'"); + Log.debug(" old PATH: '" + *propertyPath + "' ==> '" + _value + "'"); propertyPath.setDirect(_value); - Log.debug("new PATH: '" << *propertyPath << "'"); + Log.debug("new PATH: '" + *propertyPath + "'"); propertyFile.setDirect(""); updateCurrentFolder(); } -void ewol::widget::FileChooser::onCallbackListFileSelectChange(const etk::Path& _value) { +void ewol::widget::FileChooser::onCallbackListFileSelectChange( etk::Path _value) { propertyFile.set(_value); /* - etk::String tmpFileCompleatName = m_folder; - tmpFileCompleatName += m_file; + String tmpFileCompleatName = this.folder; + tmpFileCompleatName += this.file; // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); */ } -void ewol::widget::FileChooser::onCallbackListFileValidate(const etk::Path& _value) { +void ewol::widget::FileChooser::onCallbackListFileValidate( etk::Path _value) { // select the file == > generate a validate propertyFile.set(_value); - Log.verbose(" generate a fiel opening : '" << propertyFile << "'"); + Log.verbose(" generate a fiel opening : '" + propertyFile + "'"); signalValidate.emit(_value); autoDestroy(); } -void ewol::widget::FileChooser::onCallbackEntryFileChangeValidate(const etk::String& _value) { +void ewol::widget::FileChooser::onCallbackEntryFileChangeValidate( String _value) { onCallbackListFileValidate(_value); } void ewol::widget::FileChooser::onCallbackListValidate() { if (propertyFile.get() == "") { - EWOL_WARNING(" Validate : '" << *propertyFile << "' ==> error No name ..."); + Log.warning(" Validate : '" + *propertyFile + "' ==> error No name ..."); return; } - Log.debug(" generate a file opening : '" << *propertyFile << "'"); + Log.debug(" generate a file opening : '" + *propertyFile + "'"); signalValidate.emit(*propertyFile); autoDestroy(); } void ewol::widget::FileChooser::onCallbackHomePressed() { etk::Path tmpUserFolder = etk::path::getHomePath(); - Log.debug("new PATH: '" << tmpUserFolder << "'"); + Log.debug("new PATH: '" + tmpUserFolder + "'"); propertyPath.setDirect(tmpUserFolder); propertyFile.setDirect(""); diff --git a/src/org/atriasoft/ewol/widget/meta/FileChooser.java b/src/org/atriasoft/ewol/widget/meta/FileChooser.java index 0df12f4..8cd15c9 100644 --- a/src/org/atriasoft/ewol/widget/meta/FileChooser.java +++ b/src/org/atriasoft/ewol/widget/meta/FileChooser.java @@ -13,7 +13,7 @@ namespace ewol { namespace widget { class FileChooser; - using FileChooserShared = ememory::SharedPtr; + using FileChooser = ememory::Ptr; using FileChooserWeak = ememory::WeakPtr; /** * @brief File Chooser is a simple selector of file for opening, saving, and what you want ... @@ -25,37 +25,37 @@ namespace ewol { * #include * [/code] * - * The first step is to create the file chooser pop-up : (never in the constructor!!!) + * The first step is to create the file chooser pop-up : (never in the ructor!!!) * [code style=c++] - * ewol::widget::FileChooserShared tmpWidget = ewol::widget::FileChooser::create(); + * ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create(); * if (tmpWidget == null) { * APPL_ERROR("Can not open File chooser !!! "); * return -1; * } * // register on the Validate event: - * tmpWidget->signalValidate.connect(sharedFromThis(), &****::onCallbackOpenFile); + * tmpWidget.signalValidate.connect(sharedFromThis(), ****::onCallbackOpenFile); * // no need of this event watching ... - * tmpWidget->signalCancel.connect(sharedFromThis(), &****::onCallbackClosePopUp); + * tmpWidget.signalCancel.connect(sharedFromThis(), ****::onCallbackClosePopUp); * // set the title: - * tmpWidget->propertyLabelTitle.set("Open files ..."); + * tmpWidget.propertyLabelTitle.set("Open files ..."); * // Set the validate Label: - * tmpWidget->propertyLabelValidate.set("Open"); + * tmpWidget.propertyLabelValidate.set("Open"); * // simply set a folder (by default this is the home folder) - * //tmpWidget->propertyPath.set("/home/me"); + * //tmpWidget.propertyPath.set("/home/me"); * // add the widget as windows pop-up ... - * ewol::widget::WindowsShared tmpWindows = getWindows(); + * ewol::widget::Windows tmpWindows = getWindows(); * if (tmpWindows == null) { * APPL_ERROR("Can not get the current windows !!! "); * return -1; * } - * tmpWindows->popUpWidgetPush(tmpWidget); + * tmpWindows.popUpWidgetPush(tmpWidget); * [/code] * * Now we just need to wait the the open event message. * * [code style=c++] - * void ****::onCallbackOpenFile(const etk::String& _value) { - * APPL_INFO("Request open file : '" << _value << "'"); + * void ****::onCallbackOpenFile( String _value) { + * APPL_INFO("Request open file : '" + _value + "'"); * } * void ****::onCallbackClosePopUp() { * APPL_INFO("The File chooser has been closed"); @@ -70,37 +70,37 @@ namespace ewol { public: // properties eproperty::Value propertyPath; //!< Current path to explore eproperty::Value propertyFile; //!< Selected file - eproperty::Value propertyLabelTitle; //!< Label of the pop-up (can use translation) - eproperty::Value propertyLabelValidate; //!< Label of validate button of the pop-up (can use translation) - eproperty::Value propertyLabelCancel; //!< Label of cancel/close button of the pop-up (can use translation) + eproperty::Value propertyLabelTitle; //!< Label of the pop-up (can use translation) + eproperty::Value propertyLabelValidate; //!< Label of validate button of the pop-up (can use translation) + eproperty::Value propertyLabelCancel; //!< Label of cancel/close button of the pop-up (can use translation) protected: FileChooser(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(FileChooser, "FileChooser"); - virtual ~FileChooser(); + ~FileChooser(); private: void updateCurrentFolder(); public: - void onGetFocus() override; + void onGetFocus() ; private: // callback functions: - void onCallbackEntryFolderChangeValue(const etk::String& _value); - void onCallbackEntryFileChangeValue(const etk::String& _value); - void onCallbackEntryFileChangeValidate(const etk::String& _value); + void onCallbackEntryFolderChangeValue( String _value); + void onCallbackEntryFileChangeValue( String _value); + void onCallbackEntryFileChangeValidate( String _value); void onCallbackButtonCancelPressed(); - void onCallbackHidenFileChangeChangeValue(const bool& _value); - void onCallbackListFolderSelectChange(const etk::Path& _value); - void onCallbackListFileSelectChange(const etk::Path& _value); - void onCallbackListFileValidate(const etk::Path& _value); + void onCallbackHidenFileChangeChangeValue( bool _value); + void onCallbackListFolderSelectChange( etk::Path _value); + void onCallbackListFileSelectChange( etk::Path _value); + void onCallbackListFileValidate( etk::Path _value); void onCallbackListValidate(); void onCallbackHomePressed(); protected: - virtual void onChangePropertyPath(); - virtual void onChangePropertyFile(); - virtual void onChangePropertyLabelTitle(); - virtual void onChangePropertyLabelValidate(); - virtual void onChangePropertyLabelCancel(); + void onChangePropertyPath(); + void onChangePropertyFile(); + void onChangePropertyLabelTitle(); + void onChangePropertyLabelValidate(); + void onChangePropertyLabelCancel(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/meta/Parameter.cpp b/src/org/atriasoft/ewol/widget/meta/Parameter.cpp index 567ec47..ad6bc7c 100644 --- a/src/org/atriasoft/ewol/widget/meta/Parameter.cpp +++ b/src/org/atriasoft/ewol/widget/meta/Parameter.cpp @@ -23,19 +23,19 @@ ewol::widget::Parameter::Parameter() : propertyLabelTitle(this, "title", "_T{Parameter}", "Title of the parameter interface", - &ewol::widget::Parameter::onChangePropertyLabelTitle), - m_currentIdList(0), - m_widgetTitle(), - m_paramList() { + ewol::widget::Parameter::onChangePropertyLabelTitle), + this.currentIdList(0), + this.widgetTitle(), + this.paramList() { addObjectType("ewol::widget::Parameter"); } void ewol::widget::Parameter::init() { ewol::widget::PopUp::init(); - ewol::widget::SizerShared mySizerVert = null; - ewol::widget::SizerShared mySizerHori = null; - ewol::widget::SpacerShared mySpacer = null; + ewol::widget::Sizer mySizerVert = null; + ewol::widget::Sizer mySizerHori = null; + ewol::widget::Spacer mySpacer = null; #ifdef __TARGET_OS__Android propertyMinSize.set(gale::Dimension(Vector2f(90, 90), gale::distance::pourcent)); #else @@ -47,9 +47,9 @@ void ewol::widget::Parameter::init() { Log.error("Can not allocate widget == > display might be in error"); } else { Log.info("add widget"); - mySizerVert->propertyMode.set(widget::Sizer::modeVert); - mySizerVert->propertyLockExpand.set(Vector2b(true,true)); - mySizerVert->propertyExpand.set(Vector2b(true,true)); + mySizerVert.propertyMode.set(widget::Sizer::modeVert); + mySizerVert.propertyLockExpand.set(Vector2b(true,true)); + mySizerVert.propertyExpand.set(Vector2b(true,true)); // set it in the pop-up-system : setSubWidget(mySizerVert); @@ -57,50 +57,50 @@ void ewol::widget::Parameter::init() { if (mySizerHori == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySizerHori->propertyMode.set(widget::Sizer::modeHori); - mySizerVert->subWidgetAdd(mySizerHori); + mySizerHori.propertyMode.set(widget::Sizer::modeHori); + mySizerVert.subWidgetAdd(mySizerHori); mySpacer = ewol::widget::Spacer::create(); if (mySpacer == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySizerHori->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySizerHori.subWidgetAdd(mySpacer); } - ewol::widget::ButtonShared tmpButton = widget::Button::create(); + ewol::widget::Button tmpButton = widget::Button::create(); if (tmpButton == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - tmpButton->setSubWidget(ewol::widget::composerGenerateString( + tmpButton.setSubWidget(ewol::widget::composerGenerateString( "\n" " \n" " \n" "\n")); - tmpButton->signalPressed.connect(sharedFromThis(), &ewol::widget::Parameter::onCallbackParameterSave); - mySizerHori->subWidgetAdd(tmpButton); + tmpButton.signalPressed.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackParameterSave); + mySizerHori.subWidgetAdd(tmpButton); } mySpacer = ewol::widget::Spacer::create(); if (mySpacer == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySpacer->propertyExpand.set(Vector2b(false,false)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(10,0))); - mySizerHori->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(false,false)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(10,0))); + mySizerHori.subWidgetAdd(mySpacer); } tmpButton = ewol::widget::Button::create(); if (tmpButton == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - tmpButton->setSubWidget(ewol::widget::composerGenerateString( + tmpButton.setSubWidget(ewol::widget::composerGenerateString( "\n" " \n" " \n" "\n")); - tmpButton->signalPressed.connect(sharedFromThis(), &ewol::widget::Parameter::onCallbackMenuclosed); - mySizerHori->subWidgetAdd(tmpButton); + tmpButton.signalPressed.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackMenuclosed); + mySizerHori.subWidgetAdd(tmpButton); } } @@ -108,54 +108,54 @@ void ewol::widget::Parameter::init() { if (mySizerHori == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySizerHori->propertyMode.set(widget::Sizer::modeHori); - mySizerVert->subWidgetAdd(mySizerHori); + mySizerHori.propertyMode.set(widget::Sizer::modeHori); + mySizerVert.subWidgetAdd(mySizerHori); - m_paramList = ewol::widget::ParameterList::create(); - if (m_paramList == null) { + this.paramList = ewol::widget::ParameterList::create(); + if (this.paramList == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - m_paramList->signalSelect.connect(sharedFromThis(), &ewol::widget::Parameter::onCallbackMenuSelected); - m_paramList->propertyFill.set(Vector2b(false,true)); - m_paramList->propertyExpand.set(Vector2b(false,true)); - mySizerHori->subWidgetAdd(m_paramList); + this.paramList.signalSelect.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackMenuSelected); + this.paramList.propertyFill.set(Vector2b(false,true)); + this.paramList.propertyExpand.set(Vector2b(false,true)); + mySizerHori.subWidgetAdd(this.paramList); } mySpacer = ewol::widget::Spacer::create(); if (mySpacer == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySpacer->propertyFill.set(Vector2b(false,true)); - mySpacer->propertyMinSize.set(Vector2f(5,5)); - mySpacer->propertyColor.set(0x000000BF); - mySizerHori->subWidgetAdd(mySpacer); + mySpacer.propertyFill.set(Vector2b(false,true)); + mySpacer.propertyMinSize.set(Vector2f(5,5)); + mySpacer.propertyColor.set(0x000000BF); + mySizerHori.subWidgetAdd(mySpacer); } - ewol::widget::SizerShared mySizerVert2 = widget::Sizer::create(); + ewol::widget::Sizer mySizerVert2 = widget::Sizer::create(); if (mySizerVert2 == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySizerVert2->propertyMode.set(widget::Sizer::modeVert); - mySizerHori->subWidgetAdd(mySizerVert2); + mySizerVert2.propertyMode.set(widget::Sizer::modeVert); + mySizerHori.subWidgetAdd(mySizerVert2); mySpacer = ewol::widget::Spacer::create(); if (mySpacer == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySpacer->propertyMinSize.set(Vector2f(5,5)); - mySpacer->propertyColor.set(0x000000BF); - mySizerVert2->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySpacer.propertyMinSize.set(Vector2f(5,5)); + mySpacer.propertyColor.set(0x000000BF); + mySizerVert2.subWidgetAdd(mySpacer); } - m_wSlider = ewol::widget::WSlider::create(); - if (m_wSlider == null) { + this.wSlider = ewol::widget::WSlider::create(); + if (this.wSlider == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - m_wSlider->propertyTransitionSpeed.set(0.5); - m_wSlider->propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert); - m_wSlider->propertyExpand.set(Vector2b(true,true)); - mySizerVert2->subWidgetAdd(m_wSlider); + this.wSlider.propertyTransitionSpeed.set(0.5); + this.wSlider.propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert); + this.wSlider.propertyExpand.set(Vector2b(true,true)); + mySizerVert2.subWidgetAdd(this.wSlider); } } } @@ -164,19 +164,19 @@ void ewol::widget::Parameter::init() { if (mySpacer == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySpacer->propertyMinSize.set(Vector2f(5,5)); - mySpacer->propertyColor.set(0x000000BF); - mySizerVert->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySpacer.propertyMinSize.set(Vector2f(5,5)); + mySpacer.propertyColor.set(0x000000BF); + mySizerVert.subWidgetAdd(mySpacer); } - m_widgetTitle = ewol::widget::Label::create(); - if (m_widgetTitle == null) { + this.widgetTitle = ewol::widget::Label::create(); + if (this.widgetTitle == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - m_widgetTitle->propertyValue.set(propertyLabelTitle); - m_widgetTitle->propertyExpand.set(Vector2b(true,false)); - mySizerVert->subWidgetAdd(m_widgetTitle); + this.widgetTitle.propertyValue.set(propertyLabelTitle); + this.widgetTitle.propertyExpand.set(Vector2b(true,false)); + mySizerVert.subWidgetAdd(this.widgetTitle); } } markToRedraw(); @@ -187,8 +187,8 @@ ewol::widget::Parameter::~Parameter() { } void ewol::widget::Parameter::onChangePropertyLabelTitle() { - if (m_widgetTitle != null) { - m_widgetTitle->propertyValue.set(propertyLabelTitle); + if (this.widgetTitle != null) { + this.widgetTitle.propertyValue.set(propertyLabelTitle); } } @@ -202,54 +202,54 @@ void ewol::widget::Parameter::onCallbackParameterSave() { //ewol::userConfig::Save(); Log.todo("Save Parameter !!! "); } -void ewol::widget::Parameter::onCallbackMenuSelected(const int32_t& _value) { - if (m_wSlider != null) { - Log.debug("event on the parameter : Menu-select select ID=" << _value << ""); - m_wSlider->subWidgetSelectSet(_value); +void ewol::widget::Parameter::onCallbackMenuSelected( int _value) { + if (this.wSlider != null) { + Log.debug("event on the parameter : Menu-select select ID=" + _value + ""); + this.wSlider.subWidgetSelectSet(_value); } } -void ewol::widget::Parameter::menuAdd(etk::String _label, etk::String _image, ewol::WidgetShared _associateWidget) { - if (m_paramList != null) { - m_paramList->menuAdd(_label, m_currentIdList, _image); - if (m_wSlider != null) { +void ewol::widget::Parameter::menuAdd(String _label, String _image, Widget _associateWidget) { + if (this.paramList != null) { + this.paramList.menuAdd(_label, this.currentIdList, _image); + if (this.wSlider != null) { if (_associateWidget != null) { - m_wSlider->subWidgetAdd(_associateWidget); + this.wSlider.subWidgetAdd(_associateWidget); } else { Log.debug("Associate an empty widget on it ..."); - ewol::widget::LabelShared myLabel = widget::Label::create(); + ewol::widget::Label myLabel = widget::Label::create(); if (myLabel == null) { Log.error("Can not allocate widget == > display might be in error"); } else { - myLabel->propertyValue.set(etk::String("No widget for : ") + _label); - myLabel->propertyExpand.set(Vector2b(true,true)); - m_wSlider->subWidgetAdd(myLabel); + myLabel.propertyValue.set(String("No widget for : ") + _label); + myLabel.propertyExpand.set(Vector2b(true,true)); + this.wSlider.subWidgetAdd(myLabel); } } - if (m_currentIdList == 0) { - m_wSlider->subWidgetSelectSet(0); + if (this.currentIdList == 0) { + this.wSlider.subWidgetSelectSet(0); } } - m_currentIdList++; + this.currentIdList++; } } -void ewol::widget::Parameter::menuAddGroup(etk::String _label) { - if (m_paramList != null) { - m_paramList->menuSeparator(); - m_paramList->menuAddGroup(_label); +void ewol::widget::Parameter::menuAddGroup(String _label) { + if (this.paramList != null) { + this.paramList.menuSeparator(); + this.paramList.menuAddGroup(_label); } } void ewol::widget::Parameter::menuClear() { - if (m_paramList != null) { - m_paramList->menuClear(); - m_currentIdList = 0; + if (this.paramList != null) { + this.paramList.menuClear(); + this.currentIdList = 0; } } void ewol::widget::Parameter::menuSeparator() { - if (m_paramList != null) { - m_paramList->menuSeparator(); + if (this.paramList != null) { + this.paramList.menuSeparator(); } } diff --git a/src/org/atriasoft/ewol/widget/meta/Parameter.java b/src/org/atriasoft/ewol/widget/meta/Parameter.java index 44dbbbf..0eb3a66 100644 --- a/src/org/atriasoft/ewol/widget/meta/Parameter.java +++ b/src/org/atriasoft/ewol/widget/meta/Parameter.java @@ -20,7 +20,7 @@ namespace ewol { namespace widget { class Parameter; - using ParameterShared = ememory::SharedPtr; + using Parameter = ememory::Ptr; using ParameterWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -29,29 +29,29 @@ namespace ewol { public: // signals esignal::Signal<> signalClose; public: // properties - eproperty::Value propertyLabelTitle; + eproperty::Value propertyLabelTitle; protected: Parameter(); void init(); public: DECLARE_WIDGET_FACTORY(Parameter, "Parameter"); - virtual ~Parameter(); + ~Parameter(); public: - void menuAdd(etk::String _label, etk::String _image, ewol::WidgetShared _associateWidget); - void menuAddGroup(etk::String _label); + void menuAdd(String _label, String _image, Widget _associateWidget); + void menuAddGroup(String _label); void menuClear(); void menuSeparator(); private: - int32_t m_currentIdList; - ewol::widget::LabelShared m_widgetTitle; - ewol::widget::ParameterListShared m_paramList; - ewol::widget::WSliderShared m_wSlider; + int this.currentIdList; + ewol::widget::Label this.widgetTitle; + ewol::widget::ParameterList this.paramList; + ewol::widget::WSlider this.wSlider; private: void onCallbackMenuclosed(); void onCallbackParameterSave(); - void onCallbackMenuSelected(const int32_t& _value); + void onCallbackMenuSelected( int _value); protected: - virtual void onChangePropertyLabelTitle(); + void onChangePropertyLabelTitle(); }; }; }; diff --git a/src/org/atriasoft/ewol/widget/meta/ParameterList.cpp b/src/org/atriasoft/ewol/widget/meta/ParameterList.cpp index 96a2d3f..8bc9f60 100644 --- a/src/org/atriasoft/ewol/widget/meta/ParameterList.cpp +++ b/src/org/atriasoft/ewol/widget/meta/ParameterList.cpp @@ -20,12 +20,12 @@ ewol::widget::ParameterList::ParameterList() : signalSelect(this, "select", "") { addObjectType("ewol::widget::ParameterList"); - m_idSelected = -1; - m_paddingSizeX = 2; + this.idSelected = -1; + this.paddingSizeX = 2; #ifdef __TARGET_OS__Android - m_paddingSizeY = 10; + this.paddingSizeY = 10; #else - m_paddingSizeY = 2; + this.paddingSizeY = 2; #endif } @@ -36,40 +36,40 @@ void ewol::widget::ParameterList::init() { ewol::widget::ParameterList::~ParameterList() { //clean all the object - m_listOObject.clear(); + this.listOObject.clear(); menuClear(); } void ewol::widget::ParameterList::calculateMinMaxSize() { - /*int32_t fontId = getDefaultFontId(); - int32_t minWidth = ewol::getWidth(fontId, m_label); - int32_t minHeight = ewol::getHeight(fontId); - m_minSize.x = 3+minWidth; - m_minSize.y = 3+minHeight; + /*int fontId = getDefaultFontId(); + int minWidth = ewol::getWidth(fontId, this.label); + int minHeight = ewol::getHeight(fontId); + this.minSize.x = 3+minWidth; + this.minSize.y = 3+minHeight; */ - m_minSize.setValue(150, 150); + this.minSize.setValue(150, 150); } -void ewol::widget::ParameterList::addOObject(const ememory::SharedPtr& _newObject, int32_t _pos) { +void ewol::widget::ParameterList::addOObject( ememory::Ptr _newObject, int _pos) { if (_newObject == null) { Log.error("Try to add an empty object in the Widget generic display system"); return; } - if (_pos < 0 || (size_t)_pos >= m_listOObject.size() ) { - m_listOObject.pushBack(_newObject); + if (_pos < 0 || (int)_pos >= this.listOObject.size() ) { + this.listOObject.pushBack(_newObject); } else { - m_listOObject.insert(m_listOObject.begin()+_pos, _newObject); + this.listOObject.insert(this.listOObject.begin()+_pos, _newObject); } } void ewol::widget::ParameterList::clearOObjectList() { - m_listOObject.clear(); + this.listOObject.clear(); } void ewol::widget::ParameterList::onDraw() { - for (auto &it : m_listOObject) { + for (auto it : this.listOObject) { if (it != null) { - it->draw(); + it.draw(); } } WidgetScrolled::onDraw(); @@ -79,49 +79,49 @@ void ewol::widget::ParameterList::onRegenerateDisplay() { if (needRedraw() == true) { // clean the object list ... clearOObjectList(); - //Log.debug("OnRegenerateDisplay(" << m_size.x << "," << m_size.y << ")"); + //Log.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")"); - int32_t tmpOriginX = 0; - int32_t tmpOriginY = 0; + int tmpOriginX = 0; + int tmpOriginY = 0; /* - if (true == m_userFill.x) { + if (true == this.userFill.x) { tmpOriginX = 0; } - if (true == m_userFill.y) { + if (true == this.userFill.y) { tmpOriginY = 0; }*/ - tmpOriginX += m_paddingSizeX; - tmpOriginY += m_paddingSizeY; + tmpOriginX += this.paddingSizeX; + tmpOriginY += this.paddingSizeY; /* - int32_t fontId = getDefaultFontId(); - //int32_t minWidth = ewol::getWidth(fontId, m_label); - int32_t minHeight = ewol::getHeight(fontId); + int fontId = getDefaultFontId(); + //int minWidth = ewol::getWidth(fontId, this.label); + int minHeight = ewol::getHeight(fontId); */ // TODO : Rework this ... - int32_t minHeight=20; + int minHeight=20; - //uint32_t nbColomn = getNuberOfColomn(); - int32_t nbRaw = m_list.size(); + //uint nbColomn = getNuberOfColomn(); + int nbRaw = this.list.size(); // For the scrooling windows - m_maxSize.setValue(m_size.x(), - (minHeight + 2*m_paddingSizeY) * nbRaw ); + this.maxSize.setValue(this.size.x(), + (minHeight + 2*this.paddingSizeY) * nbRaw ); - List listSizeColomn; + List listSizeColomn; // set background color : - ememory::SharedPtr tmpDraw = ememory::makeShared(); + ememory::Ptr tmpDraw = ememory::make(); if (tmpDraw == null) { return; } - tmpDraw->setColor(etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF)); - tmpDraw->setPos(Vector3f(0,0,0) ); - tmpDraw->rectangleWidth(Vector3f(m_size.x(), m_size.y(), 0) ); + tmpDraw.setColor(etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF)); + tmpDraw.setPos(Vector3f(0,0,0) ); + tmpDraw.rectangleWidth(Vector3f(this.size.x(), this.size.y(), 0) ); - uint32_t displayableRaw = m_size.y() / (minHeight + 2*m_paddingSizeY) +2; + uint displayableRaw = this.size.y() / (minHeight + 2*this.paddingSizeY) +2; - int32_t startRaw = m_originScrooled.y() / (minHeight + 2*m_paddingSizeY); + int startRaw = this.originScrooled.y() / (minHeight + 2*this.paddingSizeY); if (startRaw >= nbRaw-1 ) { startRaw = nbRaw - 1; @@ -130,28 +130,28 @@ void ewol::widget::ParameterList::onRegenerateDisplay() { startRaw = 0; } // calculate the real position ... - tmpOriginY = m_size.y() - (-m_originScrooled.y() + (startRaw+1)*(minHeight + 2*m_paddingSizeY)); + tmpOriginY = this.size.y() - (-this.originScrooled.y() + (startRaw+1)*(minHeight + 2*this.paddingSizeY)); - for (int32_t iii=startRaw; iii fg(0x00, 0x00, 0x00, 0xFF); - if (m_list[iii] != null) { - myTextToWrite = TRANSLATE(m_list[iii]->m_label); + if (this.list[iii] != null) { + myTextToWrite = TRANSLATE(this.list[iii].this.label); } - ememory::SharedPtr tmpText = ememory::makeShared(); + ememory::Ptr tmpText = ememory::make(); Vector3f textPos; - textPos.setX((int32_t)tmpOriginX); - if (m_list[iii]->m_group == false) { + textPos.setX((int)tmpOriginX); + if (this.list[iii].this.group == false) { textPos.setX(textPos.x() + minHeight); } - textPos.setY((int32_t)(tmpOriginY + m_paddingSizeY)); - tmpText->setPos(textPos); - tmpText->print(myTextToWrite); + textPos.setY((int)(tmpOriginY + this.paddingSizeY)); + tmpText.setPos(textPos); + tmpText.print(myTextToWrite); addOObject(tmpText); - tmpOriginY -= minHeight + 2* m_paddingSizeY; + tmpOriginY -= minHeight + 2* this.paddingSizeY; } addOObject(tmpDraw, 0); @@ -161,30 +161,30 @@ void ewol::widget::ParameterList::onRegenerateDisplay() { } -bool ewol::widget::ParameterList::onEventInput(const ewol::event::Input& _event) { +boolean ewol::widget::ParameterList::onEventInput( ewol::event::Input _event) { if (true == WidgetScrolled::onEventInput(_event)) { keepFocus(); // nothing to do ... done on upper widet ... return true; } - if (_event.getId() == 1 && _event.getStatus() == gale::key::status::pressSingle) { + if (_event.getId() == 1 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressSingle) { Vector2f relativePos = relativePosition(_event.getPos()); // corection for the openGl abstraction - relativePos.setY(m_size.y() - relativePos.y()); + relativePos.setY(this.size.y() - relativePos.y()); // TODO : Rework this ... /* - int32_t fontId = getDefaultFontId(); - //int32_t minWidth = ewol::getWidth(fontId, m_label.c_str()); - int32_t minHeight = ewol::getHeight(fontId); + int fontId = getDefaultFontId(); + //int minWidth = ewol::getWidth(fontId, this.label.c_str()); + int minHeight = ewol::getHeight(fontId); */ - int32_t minHeight = 20; - int32_t rawID = (relativePos.y()+m_originScrooled.y()) / (minHeight + 2*m_paddingSizeY); + int minHeight = 20; + int rawID = (relativePos.y()+this.originScrooled.y()) / (minHeight + 2*this.paddingSizeY); // generate an event on a rawId if the element request change and Select it ... - if (rawID >= 0 && (size_t)rawID < m_list.size()) { - if (m_list[rawID]!=null) { - if (m_list[rawID]->m_refId >= 0) { - signalSelect.emit(m_list[rawID]->m_refId); - m_idSelected = rawID; + if (rawID >= 0 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (int)rawID < this.list.size()) { + if (this.list[rawID]!=null) { + if (this.list[rawID].this.refId >= 0) { + signalSelect.emit(this.list[rawID].this.refId); + this.idSelected = rawID; markToRedraw(); return true; } @@ -202,39 +202,39 @@ void ewol::widget::ParameterList::onLostFocus() { Log.debug("Ewol::List Lost focus"); } -void ewol::widget::ParameterList::menuAdd(etk::String& _label, int32_t _refId, etk::String& _image) { - ememory::SharedPtr tmpEmement = ememory::makeShared(_label, _refId, _image, false); +void ewol::widget::ParameterList::menuAdd(String _label, int _refId, String _image) { + ememory::Ptr tmpEmement = ememory::make(_label, _refId, _image, false); if (tmpEmement == null) { Log.error("Can not allocacte menu parameter"); return; } - m_list.pushBack(tmpEmement); - if (m_idSelected == -1 && _label != "---" && _refId>0) { - m_idSelected = m_list.size()-1; + this.list.pushBack(tmpEmement); + if (this.idSelected == -1 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _label != "---" LOMLOMLOMLOMLOM _refId>0) { + this.idSelected = this.list.size()-1; } markToRedraw(); } -void ewol::widget::ParameterList::menuAddGroup(etk::String& _label) { - etk::String image = ""; - ememory::SharedPtr tmpEmement = ememory::makeShared(_label, -1, image, true); +void ewol::widget::ParameterList::menuAddGroup(String _label) { + String image = ""; + ememory::Ptr tmpEmement = ememory::make(_label, -1, image, true); if (tmpEmement == null) { Log.error("Can not allocacte menu parameter"); return; } - m_list.pushBack(tmpEmement); + this.list.pushBack(tmpEmement); markToRedraw(); } void ewol::widget::ParameterList::menuClear() { - m_idSelected = -1; - m_list.clear(); + this.idSelected = -1; + this.list.clear(); } void ewol::widget::ParameterList::menuSeparator() { - if (m_list.size()>0) { - etk::String label = ""; - etk::String image = ""; + if (this.list.size()>0) { + String label = ""; + String image = ""; menuAdd(label, -1, image); } } diff --git a/src/org/atriasoft/ewol/widget/meta/ParameterList.java b/src/org/atriasoft/ewol/widget/meta/ParameterList.java index 41859ff..3205b32 100644 --- a/src/org/atriasoft/ewol/widget/meta/ParameterList.java +++ b/src/org/atriasoft/ewol/widget/meta/ParameterList.java @@ -14,66 +14,66 @@ namespace ewol { namespace widget { class elementPL { public : - bool m_group; - etk::String m_label; - int32_t m_refId; - etk::String m_image; - elementPL(etk::String& _label, int32_t _refId, etk::String& _image, bool _isGroup) : - m_group(_isGroup), - m_label(_label), - m_refId(_refId), - m_image(_image) { + boolean this.group; + String this.label; + int this.refId; + String this.image; + elementPL(String _label, int _refId, String _image, boolean _isGroup) : + this.group(_isGroup), + this.label(_label), + this.refId(_refId), + this.image(_image) { }; - virtual ~elementPL() {}; + ~elementPL() {}; }; class ParameterList; - using ParameterListShared = ememory::SharedPtr; + using ParameterList = ememory::Ptr; using ParameterListWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup */ class ParameterList :public ewol::widget::WidgetScrolled { public: //signals - esignal::Signal signalSelect; + esignal::Signal signalSelect; public: // properties private: - int32_t m_idSelected; - List> m_list; + int this.idSelected; + List> this.list; protected: ParameterList(); - void init() override; + void init() ; public: DECLARE_WIDGET_FACTORY(ParameterList, "ParameterList"); - virtual ~ParameterList(); - void setLabel(etk::String _newLabel); + ~ParameterList(); + void setLabel(String _newLabel); // drawing capabilities .... private: - List> m_listOObject; //!< generic element to display... + List> this.listOObject; //!< generic element to display... public: - void addOObject(const ememory::SharedPtr& _newObject, int32_t _pos=-1); + void addOObject( ememory::Ptr _newObject, int _pos=-1); void clearOObjectList(); // list properties ... private: - int32_t m_paddingSizeX; - int32_t m_paddingSizeY; - int32_t m_displayStartRaw; //!< Current starting diaplayed raw - int32_t m_displayCurrentNbLine; //!< Number of line in the display + int this.paddingSizeX; + int this.paddingSizeY; + int this.displayStartRaw; //!< Current starting diaplayed raw + int this.displayCurrentNbLine; //!< Number of line in the display public: - void menuAdd(etk::String& _label, int32_t _refId, etk::String& _image); - void menuAddGroup(etk::String& _label); + void menuAdd(String _label, int _refId, String _image); + void menuAddGroup(String _label); void menuClear(); void menuSeparator(); public: - void onRegenerateDisplay() override; - bool onEventInput(const ewol::event::Input& _event) override; - void calculateMinMaxSize() override; + void onRegenerateDisplay() ; + boolean onEventInput( ewol::event::Input _event) ; + void calculateMinMaxSize() ; protected: - void onGetFocus() override; - void onLostFocus() override; - void onDraw() override; + void onGetFocus() ; + void onLostFocus() ; + void onDraw() ; }; }; }; diff --git a/src/org/atriasoft/ewol/widget/meta/SpinBase.cpp b/src/org/atriasoft/ewol/widget/meta/SpinBase.cpp index 5062950..13df605 100644 --- a/src/org/atriasoft/ewol/widget/meta/SpinBase.cpp +++ b/src/org/atriasoft/ewol/widget/meta/SpinBase.cpp @@ -17,16 +17,16 @@ ewol::widget::SpinBase::SpinBase() : propertyShape(this, "shape", "", "shape for the display", - &ewol::widget::SpinBase::onChangePropertyShape), + ewol::widget::SpinBase::onChangePropertyShape), propertySpinMode(this, "spin-mode", ewol::widget::spinPosition_RightRight, "The display spin mode", - &ewol::widget::SpinBase::onChangePropertySpinMode), - m_confIdEntryShaper(-1), - m_confIdUpShaper(-1), - m_confIdDownShaper(-1), - m_confIdUpData(-1), - m_confIdDownData(-1) { + ewol::widget::SpinBase::onChangePropertySpinMode), + this.confIdEntryShaper(-1), + this.confIdUpShaper(-1), + this.confIdDownShaper(-1), + this.confIdUpData(-1), + this.confIdDownData(-1) { addObjectType("ewol::widget::SpinBase"); propertySpinMode.add(ewol::widget::spinPosition_noneNone, "none-none"); @@ -54,13 +54,13 @@ void ewol::widget::SpinBase::onChangePropertySpinMode() { } void ewol::widget::SpinBase::onChangePropertyShape() { - m_config = ewol::resource::ConfigFile::create(propertyShape); - if (m_config != null) { - m_confIdEntryShaper = m_config->request("entry-shaper"); - m_confIdUpShaper = m_config->request("up-shaper"); - m_confIdDownShaper = m_config->request("down-shaper"); - m_confIdUpData = m_config->request("up-data"); - m_confIdDownData = m_config->request("down-data"); + this.config = ewol::resource::ConfigFile::create(propertyShape); + if (this.config != null) { + this.confIdEntryShaper = this.config.request("entry-shaper"); + this.confIdUpShaper = this.config.request("up-shaper"); + this.confIdDownShaper = this.config.request("down-shaper"); + this.confIdUpData = this.config.request("up-data"); + this.confIdDownData = this.config.request("down-data"); } markToRedraw(); } @@ -71,82 +71,82 @@ void ewol::widget::SpinBase::updateGui() { subWidgetRemoveAll(); markToRedraw(); requestUpdateSize(); - if (m_widgetEntry == null) { - etk::String shaper; - if (m_config != null) { - shaper = m_config->getString(m_confIdEntryShaper); - Log.verbose("shaper entry : " << shaper); + if (this.widgetEntry == null) { + String shaper; + if (this.config != null) { + shaper = this.config.getString(this.confIdEntryShaper); + Log.verbose("shaper entry : " + shaper); } - m_widgetEntry = ewol::widget::Entry::create("shape", shaper); - if (m_widgetEntry != null) { - m_widgetEntry->propertyExpand.set(Vector2b(true,false)); - m_widgetEntry->propertyFill.set(Vector2b(true,true)); + this.widgetEntry = ewol::widget::Entry::create("shape", shaper); + if (this.widgetEntry != null) { + this.widgetEntry.propertyExpand.set(Vector2b(true,false)); + this.widgetEntry.propertyFill.set(Vector2b(true,true)); } } - if (m_widgetButtonDown == null) { - etk::String shaper; - if (m_config != null) { - shaper = m_config->getString(m_confIdDownShaper); - Log.verbose("shaper button DOWN : " << shaper); + if (this.widgetButtonDown == null) { + String shaper; + if (this.config != null) { + shaper = this.config.getString(this.confIdDownShaper); + Log.verbose("shaper button DOWN : " + shaper); } - m_widgetButtonDown = ewol::widget::Button::create("shape", shaper); - if (m_widgetButtonDown != null) { - m_widgetButtonDown->propertyExpand.set(Vector2b(false,false)); - m_widgetButtonDown->propertyFill.set(Vector2b(true,true)); - etk::String data = m_config->getString(m_confIdDownData); - ewol::WidgetShared widget = ewol::widget::composerGenerateString(data); - m_widgetButtonDown->setSubWidget(widget); + this.widgetButtonDown = ewol::widget::Button::create("shape", shaper); + if (this.widgetButtonDown != null) { + this.widgetButtonDown.propertyExpand.set(Vector2b(false,false)); + this.widgetButtonDown.propertyFill.set(Vector2b(true,true)); + String data = this.config.getString(this.confIdDownData); + Widget widget = ewol::widget::composerGenerateString(data); + this.widgetButtonDown.setSubWidget(widget); } } - if (m_widgetButtonUp == null) { - etk::String shaper; - if (m_config != null) { - shaper = m_config->getString(m_confIdUpShaper); - Log.verbose("shaper button UP : " << shaper); + if (this.widgetButtonUp == null) { + String shaper; + if (this.config != null) { + shaper = this.config.getString(this.confIdUpShaper); + Log.verbose("shaper button UP : " + shaper); } - m_widgetButtonUp = ewol::widget::Button::create("shape", shaper); - if (m_widgetButtonUp != null) { - m_widgetButtonUp->propertyExpand.set(Vector2b(false,false)); - m_widgetButtonUp->propertyFill.set(Vector2b(true,true)); - etk::String data = m_config->getString(m_confIdUpData); - ewol::WidgetShared widget = ewol::widget::composerGenerateString(data); - m_widgetButtonUp->setSubWidget(widget); + this.widgetButtonUp = ewol::widget::Button::create("shape", shaper); + if (this.widgetButtonUp != null) { + this.widgetButtonUp.propertyExpand.set(Vector2b(false,false)); + this.widgetButtonUp.propertyFill.set(Vector2b(true,true)); + String data = this.config.getString(this.confIdUpData); + Widget widget = ewol::widget::composerGenerateString(data); + this.widgetButtonUp.setSubWidget(widget); } } switch (propertySpinMode) { case ewol::widget::spinPosition_noneNone: - subWidgetAdd(m_widgetEntry); + subWidgetAdd(this.widgetEntry); break; case ewol::widget::spinPosition_noneRight: - subWidgetAdd(m_widgetEntry); - subWidgetAdd(m_widgetButtonUp); + subWidgetAdd(this.widgetEntry); + subWidgetAdd(this.widgetButtonUp); break; case ewol::widget::spinPosition_leftNone: - subWidgetAdd(m_widgetButtonDown); - subWidgetAdd(m_widgetEntry); + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetEntry); break; case ewol::widget::spinPosition_leftRight: - subWidgetAdd(m_widgetButtonDown); - subWidgetAdd(m_widgetEntry); - subWidgetAdd(m_widgetButtonUp); + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetEntry); + subWidgetAdd(this.widgetButtonUp); break; case ewol::widget::spinPosition_leftLeft: - subWidgetAdd(m_widgetButtonDown); - subWidgetAdd(m_widgetButtonUp); - subWidgetAdd(m_widgetEntry); + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetButtonUp); + subWidgetAdd(this.widgetEntry); break; case ewol::widget::spinPosition_RightRight: - subWidgetAdd(m_widgetEntry); - subWidgetAdd(m_widgetButtonDown); - subWidgetAdd(m_widgetButtonUp); + subWidgetAdd(this.widgetEntry); + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetButtonUp); break; } } -bool ewol::widget::SpinBase::loadXML(const exml::Element& _node) { +boolean ewol::widget::SpinBase::loadXML( exml::Element _node) { if (_node.exist() == false) { return false; } // parse generic properties: (we not parse the sizer property, it remove all subwidget) - return ewol::Widget::loadXML(_node); + return Widget::loadXML(_node); } \ No newline at end of file diff --git a/src/org/atriasoft/ewol/widget/meta/SpinBase.java b/src/org/atriasoft/ewol/widget/meta/SpinBase.java index 9dbdff5..d28882f 100644 --- a/src/org/atriasoft/ewol/widget/meta/SpinBase.java +++ b/src/org/atriasoft/ewol/widget/meta/SpinBase.java @@ -56,7 +56,7 @@ namespace ewol { spinPosition_RightRight }; class SpinBase; - using SpinBaseShared = ememory::SharedPtr; + using SpinBase = ememory::Ptr; using SpinBaseWeak = ememory::WeakPtr; /** * @ingroup ewolWidgetGroup @@ -68,34 +68,34 @@ namespace ewol { public: UN_DECLARE_FACTORY(SpinBase); protected: - ememory::SharedPtr m_config; - int32_t m_confIdEntryShaper; - int32_t m_confIdUpShaper; - int32_t m_confIdDownShaper; - int32_t m_confIdUpData; - int32_t m_confIdDownData; + ememory::Ptr this.config; + int this.confIdEntryShaper; + int this.confIdUpShaper; + int this.confIdDownShaper; + int this.confIdUpData; + int this.confIdDownData; protected: /** * @brief Constructor * @param[in] _mode The mode to display the elements */ SpinBase(); - void init() override; + void init() ; public: /** * @brief Destructor */ - virtual ~SpinBase(); + ~SpinBase(); protected: - ewol::widget::EntryShared m_widgetEntry; - ewol::widget::ButtonShared m_widgetButtonDown; - ewol::widget::ButtonShared m_widgetButtonUp; - virtual void updateGui(); + ewol::widget::Entry this.widgetEntry; + ewol::widget::Button this.widgetButtonDown; + ewol::widget::Button this.widgetButtonUp; + void updateGui(); public: - virtual bool loadXML(const exml::Element& _node) override; + boolean loadXML( exml::Element _node) ; protected: - virtual void onChangePropertySpinMode(); - virtual void onChangePropertyShape(); + void onChangePropertySpinMode(); + void onChangePropertyShape(); }; } } diff --git a/src/org/atriasoft/ewol/widget/meta/StdPopUp.cpp b/src/org/atriasoft/ewol/widget/meta/StdPopUp.cpp index 2a19c0a..9fbbada 100644 --- a/src/org/atriasoft/ewol/widget/meta/StdPopUp.cpp +++ b/src/org/atriasoft/ewol/widget/meta/StdPopUp.cpp @@ -18,68 +18,68 @@ ewol::widget::StdPopUp::StdPopUp() : propertyTitle(this, "title", "Message", "Title of the pop-up", - &ewol::widget::StdPopUp::onChangePropertyTitle), + ewol::widget::StdPopUp::onChangePropertyTitle), propertyComment(this, "comment", "No Label", "Comment of the pop-up", - &ewol::widget::StdPopUp::onChangePropertyComment), - m_title(null), - m_comment(null), - m_subBar(null) { + ewol::widget::StdPopUp::onChangePropertyComment), + this.title(null), + this.comment(null), + this.subBar(null) { addObjectType("ewol::widget::StdPopUp"); } void ewol::widget::StdPopUp::init() { ewol::widget::PopUp::init(); propertyMinSize.set(gale::Dimension(Vector2f(20,10),gale::distance::pourcent)); - ewol::widget::SizerShared mySizerVert; - ewol::widget::SpacerShared mySpacer; + ewol::widget::Sizer mySizerVert; + ewol::widget::Spacer mySpacer; mySizerVert = ewol::widget::Sizer::create(); // set it in the pop-up-system : setSubWidget(mySizerVert); - mySizerVert->propertyMode.set(widget::Sizer::modeVert); - m_subBar = ewol::widget::Sizer::create(); - m_subBar->propertyMode.set(widget::Sizer::modeHori); - m_subBar->propertyLockExpand.set(Vector2b(true,true)); - m_subBar->propertyExpand.set(Vector2b(true,false)); - mySizerVert->subWidgetAdd(m_subBar); + mySizerVert.propertyMode.set(widget::Sizer::modeVert); + this.subBar = ewol::widget::Sizer::create(); + this.subBar.propertyMode.set(widget::Sizer::modeHori); + this.subBar.propertyLockExpand.set(Vector2b(true,true)); + this.subBar.propertyExpand.set(Vector2b(true,false)); + mySizerVert.subWidgetAdd(this.subBar); mySpacer = ewol::widget::Spacer::create(); - mySpacer->propertyExpand.set(Vector2b(true,false)); - m_subBar->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + this.subBar.subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySpacer->propertyColor.set(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(0,3),gale::distance::pixel)); - mySizerVert->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySpacer.propertyColor.set(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,3),gale::distance::pixel)); + mySizerVert.subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(0,5),gale::distance::pixel)); - mySizerVert->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,5),gale::distance::pixel)); + mySizerVert.subWidgetAdd(mySpacer); - m_comment = ewol::widget::Label::create(); - m_comment->propertyValue.set(*propertyComment); - m_comment->propertyExpand.set(Vector2b(true,true)); - mySizerVert->subWidgetAdd(m_comment); + this.comment = ewol::widget::Label::create(); + this.comment.propertyValue.set(*propertyComment); + this.comment.propertyExpand.set(Vector2b(true,true)); + mySizerVert.subWidgetAdd(this.comment); mySpacer = ewol::widget::Spacer::create(); - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(0,5),gale::distance::pixel)); - mySizerVert->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,5),gale::distance::pixel)); + mySizerVert.subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); - mySpacer->propertyExpand.set(Vector2b(true,false)); - mySpacer->propertyColor.set(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); - mySpacer->propertyMinSize.set(gale::Dimension(Vector2f(0,3),gale::distance::pixel)); - mySizerVert->subWidgetAdd(mySpacer); + mySpacer.propertyExpand.set(Vector2b(true,false)); + mySpacer.propertyColor.set(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,3),gale::distance::pixel)); + mySizerVert.subWidgetAdd(mySpacer); - m_title = ewol::widget::Label::create(); - m_title->propertyValue.set(*propertyTitle); - m_title->propertyExpand.set(Vector2b(true,false)); - m_title->propertyFill.set(Vector2b(true,true)); - mySizerVert->subWidgetAdd(m_title); + this.title = ewol::widget::Label::create(); + this.title.propertyValue.set(*propertyTitle); + this.title.propertyExpand.set(Vector2b(true,false)); + this.title.propertyFill.set(Vector2b(true,true)); + mySizerVert.subWidgetAdd(this.title); } ewol::widget::StdPopUp::~StdPopUp() { @@ -87,42 +87,42 @@ ewol::widget::StdPopUp::~StdPopUp() { } void ewol::widget::StdPopUp::onChangePropertyTitle() { - if (m_title == null) { + if (this.title == null) { return; } - m_title->propertyValue.set(*propertyTitle); + this.title.propertyValue.set(*propertyTitle); markToRedraw(); } void ewol::widget::StdPopUp::onChangePropertyComment() { - if (m_comment == null) { + if (this.comment == null) { return; } - m_comment->propertyValue.set(*propertyComment); + this.comment.propertyValue.set(*propertyComment); markToRedraw(); } -ewol::widget::ButtonShared ewol::widget::StdPopUp::addButton(const etk::String& _text, bool _autoExit) { - if (m_subBar == null) { +ewol::widget::Button ewol::widget::StdPopUp::addButton( String _text, boolean _autoExit) { + if (this.subBar == null) { Log.error("button-bar does not existed ..."); return null; } - ewol::widget::ButtonShared myButton = widget::Button::create(); + ewol::widget::Button myButton = widget::Button::create(); if (myButton == null) { Log.error("Can not allocate new button ..."); return null; } - ewol::widget::LabelShared myLabel = ewol::widget::Label::create(); + ewol::widget::Label myLabel = ewol::widget::Label::create(); if (myLabel == null) { Log.error("Can not allocate new label ..."); return null; } - myLabel->propertyValue.set(_text); - myButton->setSubWidget(myLabel); + myLabel.propertyValue.set(_text); + myButton.setSubWidget(myLabel); if(_autoExit == true) { - myButton->signalPressed.connect(sharedFromThis(), &ewol::widget::StdPopUp::onCallBackButtonExit); + myButton.signalPressed.connect(sharedFromThis(), ewol::widget::StdPopUp::onCallBackButtonExit); } - m_subBar->subWidgetAdd(myButton); + this.subBar.subWidgetAdd(myButton); markToRedraw(); return myButton; } diff --git a/src/org/atriasoft/ewol/widget/meta/StdPopUp.java b/src/org/atriasoft/ewol/widget/meta/StdPopUp.java index 76d01e0..437f0cc 100644 --- a/src/org/atriasoft/ewol/widget/meta/StdPopUp.java +++ b/src/org/atriasoft/ewol/widget/meta/StdPopUp.java @@ -12,7 +12,7 @@ namespace ewol { namespace widget { class StdPopUp; - using StdPopUpShared = ememory::SharedPtr; + using StdPopUp = ememory::Ptr; using StdPopUpWeak = ememory::WeakPtr; /** * @brief The std pop up widget is a siple message widget to notify user of some simple things, like: @@ -40,11 +40,11 @@ namespace ewol { */ class StdPopUp : public ewol::widget::PopUp { public: // properties: - eproperty::Value propertyTitle; //!< Title of the pop-up - eproperty::Value propertyComment; //!< comment in the pop-up (can be decorated text) + eproperty::Value propertyTitle; //!< Title of the pop-up + eproperty::Value propertyComment; //!< comment in the pop-up (can be decorated text) protected: /** - * @brief std-pop-up constructor. + * @brief std-pop-up ructor. */ StdPopUp(); void init(); @@ -53,28 +53,28 @@ namespace ewol { /** * @brief std-pop-up destructor. */ - virtual ~StdPopUp(); + ~StdPopUp(); protected: - ewol::widget::LabelShared m_title; //!< Title Label widget + ewol::widget::Label this.title; //!< Title Label widget /** * @brief property callback when request a change of the title. */ void onChangePropertyTitle(); - ewol::widget::LabelShared m_comment; //!< Comment label widget + ewol::widget::Label this.comment; //!< Comment label widget /** * @brief property callback when request a change of the Comment. */ void onChangePropertyComment(); protected: - ewol::widget::SizerShared m_subBar; //!< subwidget bar containing all the button. + ewol::widget::Sizer this.subBar; //!< subwidget bar containing all the button. public: /** * @brief Add a buttom button. * @param[in] _text Decorated text to diplay in button. */ - ewol::widget::ButtonShared addButton(const etk::String& _text, bool _autoExit=false); + ewol::widget::Button addButton( String _text, boolean _autoExit=false); public: - virtual void onCallBackButtonExit(); + void onCallBackButtonExit(); }; } }