[DEV] continue transcription

This commit is contained in:
Edouard DUPIN 2021-03-23 09:05:07 +01:00
parent 4f5a929b2f
commit c43eae6857
89 changed files with 2216 additions and 2149 deletions

16
ewol.iml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="gale" exported="" />
<orderEntry type="module" module-name="ejson" exported="" />
<orderEntry type="module" module-name="exml" exported="" />
<orderEntry type="library" exported="" name="freetype-jni" level="project" />
<orderEntry type="library" scope="TEST" name="org.junit.jupiter:junit-jupiter-api:5.7.1" level="project" />
</component>
</module>

View File

@ -12,9 +12,9 @@ open module org.atriasoft.ewol {
exports org.atriasoft.ewol.object; exports org.atriasoft.ewol.object;
exports org.atriasoft.ewol.resource; exports org.atriasoft.ewol.resource;
exports org.atriasoft.ewol.resource.font; exports org.atriasoft.ewol.resource.font;
exports org.atriasoft.ewol.tools; //exports org.atriasoft.ewol.tools;
exports org.atriasoft.ewol.widget; exports org.atriasoft.ewol.widget;
exports org.atriasoft.ewol.widget.meta; //exports org.atriasoft.ewol.widget.meta;
exports org.atriasoft.echrono; exports org.atriasoft.echrono;
exports org.atriasoft.egami; exports org.atriasoft.egami;

View File

@ -0,0 +1,283 @@
package org.atriasoft.etranslate;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
/**
* @brief This is a simple interface to converte application display string in a
* generic current system language
* @note: The current name of language reprenent the file name, then if you want
* to get the machine language in an other than generic passed, juste add
* it. Generic langage char: (all translation might be done in UTF-8 this
* simplify interface) English : "EN" French : "FR" German : "DE" Spanish
* : "SP" Japanese : "JA" Italian : "IT" Korean : "KO" Russian : "RU"
* Portuguese, Brazilian : "PT" Chinese : "ZH"
*/
public class ETranslate {
private static Map<String, Uri> m_listPath = new HashMap<>();
private static String m_major = "etranslate";
private static String m_languageDefault = "EN";
private static String m_language = "";
private static boolean m_translateLoadad = false;
private static Map<String, String> m_translate = new HashMap<>();
private static boolean g_isInit = false;
/**
* @brief Initialize etranslate
* @param[in] _argc Number of argument list
* @param[in] _argv List of arguments
*/
static {
}
/**
* @brief Set the path folder of the translation files
* @param[in] _lib Library name that the path depend
* @param[in] _uri ETK generic uri (DATA:... or /xxx)
* @param[in] _major This path is the major path (The last loaded, the one which
* overload all)
*/
public static void addPath(final String _lib, final Uri _uri) {
addPath(_lib, _uri, false);
}
public static void addPath(final String _lib, final Uri _uri, final boolean _major) {
m_listPath.put(_lib, _uri);
if (_major == true) {
m_major = _lib;
Log.info("Change major translation : '" + m_major + "'");
}
m_translateLoadad = false;
m_translate.clear();
}
/**
* @brief Automatic detection of the system language
*/
public static void autoDetectLanguage() {
if (g_isInit == false) {
Log.error("E-translate system has not been init");
}
Log.verbose("Auto-detect language of system");
String nonameLocalName = "EN";
String userLocalName = "EN";
String globalLocalName = "EN";
/*
* try { nonameLocalName = setlocale(LC_ALL, ""); userLocalName =
* setlocale(LC_MESSAGES, ""); globalLocalName = setlocale(LC_CTYPE, "");
* Log.error(" The default locale is '" + globalLocalName + "'");
* Log.error(" The user's locale is '" + userLocalName + "'");
* Log.error(" A nameless locale is '" + nonameLocalName + "'"); } catch (int
* e) { // TODO: Do it better RuntimeError e) {
* Log.error("Can not get Locals ==> set English ..."); }
*/
Log.error("Can not get Locals ==> set English ...");
String lang = nonameLocalName;
if (lang == "*" || lang == "") {
lang = userLocalName;
}
if (lang == "*" || lang == "") {
lang = globalLocalName;
}
if (lang == "C" || lang == "" || lang.length() < 2) {
lang = "EN";
}
lang = lang.substring(0, 2);
lang = lang.toUpperCase();
Log.info("Select Language : '" + lang + "'");
setLanguage(lang);
}
/**
* @brief Translate a specific text (if not find, it will be retured the same
* text).
* @param[in] _instance Text to translate.
* @return The tranlated text.
*/
public static String get(final String _instance) {
loadTranslation();
Log.verbose("Request translate: '" + _instance + "'");
// find all iterance of '_T{' ... '}'
String out = Pattern.compile("_T\\{.*\\}").matcher(_instance).replaceAll(mr -> {
String data = mr.group();
Log.info("translate : '" + data + "'");
String itTranslate = m_translate.get(data);
if (itTranslate == null) {
Log.debug("Can not find tranlation : '" + _instance + "'");
return data;
}
return itTranslate;
});
return out;
}
/**
* @brief Get the current language loaded
* @return The 2/3 char defining the language
*/
public static String getLanguage() {
return m_language;
}
/**
* @brief Get the current language selected
* @return The 2/3 char defining the language
*/
public static String getLanguageDefault() {
return m_languageDefault;
}
/**
* @brief Get the current paths of the library
* @param[in] _lib Library name that the path depend
* @return Uri value.
*/
public static Uri getPaths(final String _lib) {
return m_listPath.get(_lib);
}
private static void loadTranslation() {
if (m_translateLoadad == true) {
return;
}
Log.debug("Load Translation MAJOR='" + m_major + "' LANG='" + m_language + "' default=" + m_languageDefault);
Log.debug("list path=" + m_listPath.keySet());
// start parse language for Major:
Uri itMajor = m_listPath.get(m_major);
if (itMajor != null) {
Uri uri = itMajor.withPath(itMajor.getPath() + "/" + m_language + ".json");
try {
JsonObject root = (JsonObject) Ejson.parse(uri);
for (Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) {
String val = element.getValue().toJsonString().getValue();
m_translate.put(element.getKey(), val);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
uri = itMajor.withPath(itMajor.getPath() + "/" + m_languageDefault + ".json");
try {
JsonObject root = (JsonObject) Ejson.parse(uri);
for (Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) {
String val = element.getValue().toJsonString().getValue();
m_translate.put(element.getKey(), val);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// start parse language:
for (Map.Entry<String, Uri> it : m_listPath.entrySet()) {
if (it.getKey().contentEquals(m_major)) {
continue;
}
Uri uri = it.getValue().withPath(it.getValue().getPath() + "/" + m_language + ".json");
/*
* TODO ... if (Uri.exist(uri) == false) { continue; }
*/
JsonObject doc;
try {
doc = (JsonObject) Ejson.parse(uri);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
}
for (Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) {
String val = element.getValue().toJsonString().getValue();
m_translate.put(element.getKey(), val);
}
}
// start parse default language:
for (Map.Entry<String, Uri> it : m_listPath.entrySet()) {
if (it.getKey().contentEquals(m_major)) {
continue;
}
Uri uri = it.getValue().withPath(it.getValue().getPath() + "/" + m_languageDefault + ".json");
/*
* TODO ... if (Uri.exist(uri) == false) { continue; }
*/
JsonObject doc;
try {
doc = (JsonObject) Ejson.parse(uri);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
}
for (Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) {
String val = element.getValue().toJsonString().getValue();
m_translate.put(element.getKey(), val);
}
}
m_translateLoadad = true;
}
/**
* @brief Set the language to load data. when no data availlable, we get the
* default language.
* @param[in] _lang Language to load : ("EN" for english, "FR" for french, "DE"
* for German, "SP" for spanish ...)
*/
public static void setLanguage(final String _lang) {
if (m_language == _lang) {
return;
}
m_language = _lang;
m_translateLoadad = false;
m_translate.clear();
if (_lang == "EN") {
Log.info("Change language translation: '" + _lang + "'=English");
} else if (_lang == "FR") {
Log.info("Change language translation: '" + _lang + "'=French");
} else if (_lang == "DE") {
Log.info("Change language translation: '" + _lang + "'=German");
} else if (_lang == "SP") {
Log.info("Change language translation: '" + _lang + "'=Spanish");
} else if (_lang == "JA") {
Log.info("Change language translation: '" + _lang + "'=Japanese");
} else if (_lang == "IT") {
Log.info("Change language translation: '" + _lang + "'=Italian");
} else if (_lang == "KO") {
Log.info("Change language translation: '" + _lang + "'=Korean");
} else if (_lang == "RU") {
Log.info("Change language translation: '" + _lang + "'=Russian");
} else if (_lang == "PT") {
Log.info("Change language translation: '" + _lang + "'=Portuguese, Brazilian");
} else if (_lang == "ZH") {
Log.info("Change language translation: '" + _lang + "'=Chinese");
} else {
Log.info("Change language translation: '" + _lang + "'=Unknow");
}
}
/**
* @brief Set the default language to load data (the default language might
* contain all internal data for the basic application)
* @param[in] _lang Language to load : ("EN" for english, "FR" for french, "DE"
* for German, "SP" for spanish ...)
*/
public static void setLanguageDefault(final String _lang) {
if (m_languageDefault == _lang) {
return;
}
Log.info("Change default language translation : '" + _lang + "'");
m_languageDefault = _lang;
m_translateLoadad = false;
m_translate.clear();
}
private ETranslate() {
}
}

View File

@ -3,15 +3,16 @@ package org.atriasoft.ewol;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
/** @file /**
* @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
public class DrawProperty { //@formatter:off
/* /*
/-. windowsSize /- windowsSize
*--------------------------------------------------* *--------------------------------------------------*
| | | |
| | | |
@ -34,35 +35,33 @@ public class DrawProperty {
/ /
(0,0) (0,0)
*/ */
public Vector2i windowsSize = new Vector2i(0, 0); //!< Windows complete size //@formatter:on
public Vector2i origin = new Vector2i(0, 0); //!< Windows clipping upper widget (can not be <0) public record DrawProperty(
public Vector2i size = new Vector2i(0, 0); //!< Windows clipping upper widget (can not be <0 and >this.windowsSize) Vector2i windowsSize, // !< Windows complete size
Vector2i origin, // !< Windows clipping upper widget (can not be <0)
Vector2i size// !< Windows clipping upper widget (can not be <0 and >this.windowsSize)
) {
public DrawProperty() { public DrawProperty() {
this(Vector2i.ZERO,Vector2i.ZERO,Vector2i.ZERO);
} }
public DrawProperty(final Vector2i windowsSize, final Vector2i origin, final Vector2i size) { public DrawProperty(final Vector2i windowsSize, final Vector2i origin, final Vector2i size) {
super();
this.windowsSize = windowsSize; this.windowsSize = windowsSize;
this.origin = origin; this.origin = origin;
this.size = size; this.size = size;
} }
@Override public DrawProperty withLimit(final Vector2f _origin, final Vector2f _size) {
public DrawProperty clone() { Vector2i tmpSize = this.size.add(this.origin);
return new DrawProperty(this.windowsSize, this.origin, this.size); Vector2i origin = this.origin.max((int) _origin.x(), (int) _origin.y());
} tmpSize = tmpSize.min((int) (_origin.x() + _size.x()), (int) (_origin.y() + _size.y()));
tmpSize = tmpSize.less(origin);
public void limit(final Vector2f _origin, final Vector2f _size) { return new DrawProperty(windowsSize, origin, tmpSize);
this.size.add(this.origin);
this.origin.setMax((int) _origin.x, (int) _origin.y);
this.size.setMin((int) (_origin.x + _size.x), (int) (_origin.y + _size.y));
this.size.less(this.origin);
} }
@Override @Override
public String toString() { public String toString() {
return "DrawProperty [windowsSize=" + this.windowsSize + ", start=" + this.origin + ", stop=" + this.origin.add(this.size) + "]"; return "DrawProperty [windowsSize=" + this.windowsSize + ", start=" + this.origin + ", stop="
+ this.origin.add(this.size) + "]";
} }
} }

View File

@ -11,37 +11,38 @@ import org.atriasoft.etk.math.Vector2f;
* @brief Gravity of the widget property * @brief Gravity of the widget property
*/ */
public enum Gravity { public enum Gravity {
center, //!< gravity is in center center, // !< gravity is in center
top, //!< gravity is in top top, // !< gravity is in top
buttom, //!< gravity is in buttom buttom, // !< gravity is in buttom
right, //!< gravity is in right right, // !< gravity is in right
left, //!< gravity is in left left, // !< gravity is in left
topRight, //!< gravity is in top-right topRight, // !< gravity is in top-right
topLeft, //!< gravity is in top-left topLeft, // !< gravity is in top-left
buttomRight, //!< gravity is in buttom-right buttomRight, // !< gravity is in buttom-right
buttomLeft; //!< gravity is in buttom-left buttomLeft; // !< gravity is in buttom-left
Vector2f gravityGenerateDelta(final Gravity _gravity, final Vector2f _deltas) { public static Vector2f gravityGenerateDelta(final Gravity _gravity, final Vector2f _deltas) {
final Vector2f out = new Vector2f(0.0f, 0.0f); float outX = 0;
if (_deltas.x > 0.0001f) { float outY = 0;
if (_deltas.x() > 0.0001f) {
if (_gravity == left || _gravity == buttomLeft || _gravity == topLeft) { if (_gravity == left || _gravity == buttomLeft || _gravity == topLeft) {
// nothing to do // nothing to do
} else if (_gravity == right || _gravity == buttomRight || _gravity == topRight) { } else if (_gravity == right || _gravity == buttomRight || _gravity == topRight) {
out.x = (int) (_deltas.x); outX = (int) (_deltas.x());
} else { } else {
out.x = (int) (_deltas.x * 0.5f); outX = (int) (_deltas.x() * 0.5f);
} }
} }
if (_deltas.y > 0.0001f) { if (_deltas.y() > 0.0001f) {
if (_gravity == buttom || _gravity == buttomLeft || _gravity == buttomRight) { if (_gravity == buttom || _gravity == buttomLeft || _gravity == buttomRight) {
// nothing to do // nothing to do
} else if (_gravity == top || _gravity == topRight || _gravity == topLeft) { } else if (_gravity == top || _gravity == topRight || _gravity == topLeft) {
out.y = (int) (_deltas.y); outY = (int) (_deltas.y());
} else { } else {
out.y = (int) (_deltas.y * 0.5f); outY = (int) (_deltas.y() * 0.5f);
} }
} }
return out; return new Vector2f(outX, outY);
} }
} }

View File

@ -3,6 +3,7 @@
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
package org.atriasoft.ewol;
/** /**
* @breif Simple class to abstarct the padding porperty. * @breif Simple class to abstarct the padding porperty.
@ -11,7 +12,7 @@ public class Padding {
private float xLeft; private float xLeft;
private float yTop; private float yTop;
private float xRight; private float xRight;
private float yBottom; //!< this represent the 4 padding value Left top right buttom (like css) private float yBottom; // !< this represent the 4 padding value Left top right buttom (like css)
public Padding() { public Padding() {
setValue(); setValue();
@ -45,9 +46,10 @@ public class Padding {
return this; return this;
} }
//! @previous // ! @previous
public Padding addNew(final Padding _v) { public Padding addNew(final Padding _v) {
return new Padding(this.xLeft + _v.xLeft, this.yTop + _v.yTop, this.xRight + _v.xRight, this.yBottom + _v.yBottom); return new Padding(this.xLeft + _v.xLeft, this.yTop + _v.yTop, this.xRight + _v.xRight,
this.yBottom + _v.yBottom);
} }
public void setValue() { public void setValue() {

View File

@ -10,13 +10,13 @@ import org.atriasoft.etk.math.Vector3f;
*/ */
public abstract class Compositing { public abstract class Compositing {
protected Matrix4f matrixApply = Matrix4f.identity(); protected Matrix4f matrixApply = Matrix4f.IDENTITY;;
/** /**
* @brief clear alll tre registered element in the current element * @brief clear alll tre registered element in the current element
*/ */
public void clear() { public void clear() {
this.matrixApply.setIdentity(); this.matrixApply = Matrix4f.IDENTITY;
} }
/** /**
@ -32,7 +32,7 @@ public abstract class Compositing {
* @brief reset to the eye matrix the openGL mouving system * @brief reset to the eye matrix the openGL mouving system
*/ */
public void resetMatrix() { public void resetMatrix() {
this.matrixApply.setIdentity(); this.matrixApply = Matrix4f.IDENTITY;
} }
/** /**
@ -40,7 +40,7 @@ public abstract class Compositing {
* @param[in] _vect The rotation vector to apply at the transformation matrix * @param[in] _vect The rotation vector to apply at the transformation matrix
*/ */
public void rotate(final Vector3f _vect, final float _angle) { public void rotate(final Vector3f _vect, final float _angle) {
this.matrixApply.multiply(Matrix4f.createMatrixRotate(_vect, _angle)); this.matrixApply = this.matrixApply.multiply(Matrix4f.createMatrixRotate(_vect, _angle));
} }
/** /**
@ -48,7 +48,7 @@ public abstract class Compositing {
* @param[in] _vect The scaling vector to apply at the transformation matrix * @param[in] _vect The scaling vector to apply at the transformation matrix
*/ */
public void scale(final Vector3f _vect) { public void scale(final Vector3f _vect) {
this.matrixApply.multiply(Matrix4f.createMatrixScale(_vect)); this.matrixApply = this.matrixApply.multiply(Matrix4f.createMatrixScale(_vect));
} }
/** /**
@ -64,6 +64,6 @@ public abstract class Compositing {
* @param[in] _vect The translation vector to apply at the transformation matrix * @param[in] _vect The translation vector to apply at the transformation matrix
*/ */
public void translate(final Vector3f _vect) { public void translate(final Vector3f _vect) {
this.matrixApply.multiply(Matrix4f.createMatrixTranslate(_vect)); this.matrixApply = this.matrixApply.multiply(Matrix4f.createMatrixTranslate(_vect));
} }
} }

View File

@ -19,7 +19,7 @@ import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualBufferObject; import org.atriasoft.gale.resource.ResourceVirtualBufferObject;
class Drawing extends Compositing { public class CompositingDrawing extends Compositing {
protected static int vboIdCoord = 0; protected static int vboIdCoord = 0;
protected static int vboIdColor = 1; protected static int vboIdColor = 1;
@ -50,7 +50,7 @@ class Drawing extends Compositing {
/** /**
* @brief Basic ructor * @brief Basic ructor
*/ */
public Drawing() { public CompositingDrawing() {
loadProgram(); loadProgram();
for (int iii = 0; iii < 3; iii++) { for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position; this.triangle[iii] = this.position;
@ -58,10 +58,6 @@ class Drawing extends Compositing {
} }
// Create the VBO: // Create the VBO:
this.VBO = ResourceVirtualBufferObject.create(4); this.VBO = ResourceVirtualBufferObject.create(4);
if (this.VBO == null) {
Log.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.VBO.setName("[VBO] of ewol::compositing::Area"); this.VBO.setName("[VBO] of ewol::compositing::Area");
} }
@ -189,8 +185,8 @@ class Drawing extends Compositing {
// push data on the VBO // push data on the VBO
// TODO optimize this with single push when needed // TODO optimize this with single push when needed
this.VBO.setVboData(Drawing.vboIdCoord, this.outTriangles.toArray(Vector3f[]::new)); this.VBO.setVboData(CompositingDrawing.vboIdCoord, this.outTriangles.toArray(Vector3f[]::new));
this.VBO.setVboData(Drawing.vboIdColor, this.outColors.toArray(Color[]::new)); this.VBO.setVboData(CompositingDrawing.vboIdColor, this.outColors.toArray(Color[]::new));
this.VBO.flush(); this.VBO.flush();
if (this.GLprogram == null) { if (this.GLprogram == null) {
@ -198,16 +194,16 @@ class Drawing extends Compositing {
return; return;
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
Matrix4f tmpMatrix = OpenGL.getMatrix().multiplyNew(this.matrixApply); Matrix4f tmpMatrix = OpenGL.getMatrix().multiply(this.matrixApply);
this.GLprogram.use(); this.GLprogram.use();
this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
this.GLprogram.uniformMatrix(this.GLMatrixPosition, Matrix4f.identity()); this.GLprogram.uniformMatrix(this.GLMatrixPosition, Matrix4f.IDENTITY);
// position: // position:
this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, Drawing.vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, CompositingDrawing.vboIdCoord);
// color: // color:
this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, Drawing.vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, CompositingDrawing.vboIdColor);
// Request the draw od the elements : // Request the draw od the elements :
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, this.VBO.bufferSize(Drawing.vboIdCoord)); OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, this.VBO.bufferSize(CompositingDrawing.vboIdCoord));
this.GLprogram.unUse(); this.GLprogram.unUse();
} }

View File

@ -9,6 +9,7 @@ import org.atriasoft.echrono.Clock;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i; import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etranslate.ETranslate;
import org.atriasoft.ewol.event.EntrySystem; import org.atriasoft.ewol.event.EntrySystem;
import org.atriasoft.ewol.internal.Log; import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.ObjectManager; import org.atriasoft.ewol.object.ObjectManager;
@ -38,37 +39,35 @@ public abstract class EwolContext extends Application {
return curentInterface; return curentInterface;
} }
private EwolApplication application; //!< Application handle /**
* @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);
public EwolApplication getApplication() { private EwolApplication application; // !< Application handle
return this.application;
}
public CommandLine getCmd() { private ConfigFont configFont; // !< global font configuration
return Gale.getContext().getCmd();
}
private ConfigFont configFont; //!< global font configuration private final ObjectManager objectManager; // !< Object Manager main instance
public ConfigFont getFontDefault() { private WidgetManager widgetManager; // !< global widget manager
return this.configFont;
}
private final ObjectManager objectManager; //!< Object Manager main instance private final InputManager input;
public ObjectManager getEObjectManager() { private Windows windowsCurrent = null; // !< current displayed windows
return this.objectManager;
}
private WidgetManager widgetManager; //!< global widget manager private final int initStepId = 0;
public WidgetManager getWidgetManager() { private final int initTotalStep = 0;
return this.widgetManager;
}
public ResourceManager getResourcesManager() {
return Gale.getContext().getResourcesManager();
}
public EwolContext(final EwolApplication _application) { public EwolContext(final EwolApplication _application) {
this.application = _application; this.application = _application;
@ -79,21 +78,93 @@ public abstract class EwolContext extends Application {
} }
} }
private final InputManager input; /**
* @brief Redraw all the windows
*/
public void forceRedrawAll() {
if (this.windowsCurrent == null) {
return;
}
final Vector2f size = getSize();
this.windowsCurrent.setSize(new Vector2f((int) size.x(), (int) size.y()));
this.windowsCurrent.onChangeSize();
}
public EwolApplication getApplication() {
return this.application;
}
public CommandLine getCmd() {
return Gale.getContext().getCmd();
}
public ObjectManager getEObjectManager() {
return this.objectManager;
}
public ConfigFont getFontDefault() {
return this.configFont;
}
public ResourceManager getResourcesManager() {
return Gale.getContext().getResourcesManager();
}
public WidgetManager getWidgetManager() {
return this.widgetManager;
}
/**
* @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 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 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 un-lock the pointer properties to move in relative
* instead of absolute
*/
public void inputEventUnGrabPointer() {
this.input.unGrabPointer();
}
@Override
public void onClipboardEvent(final ClipboardList _clipboardId) {
final Widget tmpWidget = this.widgetManager.focusGet();
if (tmpWidget != null) {
tmpWidget.onEventClipboard(_clipboardId);
}
}
@Override @Override
public void onCreate(final Context _context) { public void onCreate(final Context _context) {
Log.info(" == > Ewol system create (BEGIN)"); Log.info(" == > Ewol system create (BEGIN)");
// Add basic ewol translation: // Add basic ewol translation:
//etranslate::addPath("ewol", "DATA:///translate/ewol/?lib=ewol"); ETranslate.addPath("ewol", new Uri("DATA", "translate/ewol/", "ewol"));
//etranslate::autoDetectLanguage(); 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: // parse for help:
for(int iii = 0; iii < _context.getCmd().size() ; ++iii) { for (int iii = 0; iii < _context.getCmd().size(); ++iii) {
if ( _context.getCmd().get(iii) == "-h" if (_context.getCmd().get(iii) == "-h" || _context.getCmd().get(iii) == "--help") {
|| _context.getCmd().get(iii) == "--help") {
Log.print("ewol - help : "); Log.print("ewol - help : ");
Log.print(" xxxxxxxxxxxxx [options]"); Log.print(" xxxxxxxxxxxxx [options]");
Log.print(" -h/--help: Display this help"); Log.print(" -h/--help: Display this help");
@ -108,20 +179,16 @@ public abstract class EwolContext extends Application {
--iii; --iii;
} }
//Log.info("EWOL v:" + ewol::getVersion()); // Log.info("EWOL v:" + ewol::getVersion());
// force a recalculation // force a recalculation
/* /*
requestUpdateSize(){ * requestUpdateSize(){ Context context = gale::getContext();
Context context = gale::getContext(); * context.requestUpdateSize(); } #if
context.requestUpdateSize(); * defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__)
} * forceOrientation(ewol::screenLandscape); #elif
#if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__) * defined(__EWOL_ANDROID_ORIENTATION_PORTRAIT__)
forceOrientation(ewol::screenLandscape); * forceOrientation(ewol::screenPortrait); #else
#elif defined(__EWOL_ANDROID_ORIENTATION_PORTRAIT__) * forceOrientation(ewol::screenAuto); #endif
forceOrientation(ewol::screenPortrait);
#else
forceOrientation(ewol::screenAuto);
#endif
*/ */
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
@ -132,81 +199,6 @@ public abstract class EwolContext extends Application {
Log.info(" == > Ewol system create (END)"); Log.info(" == > Ewol system create (END)");
} }
@Override
public void onStart(final Context _context) {
Log.info(" == > Ewol system start (BEGIN)");
final 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)");
}
@Override
public void onResume(final Context _context) {
Log.info(" == > Ewol system resume (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onResume(this);
Log.info(" == > Ewol system resume (END)");
}
@Override
public void onRegenerateDisplay(final Context _context) {
//Log.info("REGENERATE_DISPLAY");
// check if the user selected a windows
final Windows window = this.windowsCurrent;
if (window == null) {
Log.debug("No windows ...");
return;
}
// Redraw all needed elements
window.onRegenerateDisplay();
if (this.widgetManager.isDrawingNeeded() == true) {
markDrawingIsNeeded();
}
//markDrawingIsNeeded();
}
@Override
public void onDraw(final Context _context) {
//Log.info("DRAW");
// clean internal data...
this.objectManager.cleanInternalRemoved();
// real draw...
final Windows window = this.windowsCurrent;
if (window == null) {
return;
}
window.sysDraw();
}
@Override
public void onPause(final Context _context) {
Log.info(" == > Ewol system pause (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onPause(this);
Log.info(" == > Ewol system pause (END)");
}
@Override
public void onStop(final Context _context) {
Log.info(" == > Ewol system stop (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onStop(this);
Log.info(" == > Ewol system stop (END)");
}
@Override @Override
public void onDestroy(final Context _context) { public void onDestroy(final Context _context) {
Log.info(" == > Ewol system destroy (BEGIN)"); Log.info(" == > Ewol system destroy (BEGIN)");
@ -230,40 +222,21 @@ public abstract class EwolContext extends Application {
} }
@Override @Override
public void onKillDemand(final Context _context) { public void onDraw(final Context _context) {
Log.info(" == > User demand a destroy (BEGIN)"); // Log.info("DRAW");
final EwolApplication appl = this.application; // clean internal data...
if (appl == null) { this.objectManager.cleanInternalRemoved();
exit(0); // real draw...
final Windows window = this.windowsCurrent;
if (window == null) {
return; return;
} }
appl.onKillDemand(this); window.sysDraw();
Log.info(" == > User demand a destroy (END)");
}
public void onPointer(final KeyType _type, final int _pointerID, final Vector2f _pos, final KeyStatus _state) {
switch (_state) {
case move:
//Log.debug("Receive MSG : THREAD_INPUT_MOTION");
this.input.motion(_type, _pointerID, _pos);
break;
case down:
case downRepeate:
//Log.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(_type, _pointerID, true, _pos);
break;
case up:
//Log.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(_type, _pointerID, false, _pos);
break;
default:
Log.debug("Unknow state : " + _state);
break;
}
} }
@Override @Override
public void onKeyboard(final KeySpecial _special, final KeyKeyboard _type, final Character _value, final KeyStatus _state) { public void onKeyboard(final KeySpecial _special, final KeyKeyboard _type, final Character _value,
final KeyStatus _state) {
Log.verbose("event {" + _special + "} " + _type + " " + _value + " " + _state); Log.verbose("event {" + _special + "} " + _type + " " + _value + " " + _state);
// store the keyboard special key status for mouse event... // store the keyboard special key status for mouse event...
this.input.setLastKeyboardSpecial(_special); this.input.setLastKeyboardSpecial(_special);
@ -284,7 +257,8 @@ public abstract class EwolContext extends Application {
return; return;
} }
// check if the widget allow repeating key events. // check if the widget allow repeating key events.
//Log.info("repeating test :" + repeate + " widget=" + tmpWidget.getKeyboardRepeate() + " state=" + isDown); // Log.info("repeating test :" + repeate + " widget=" +
// tmpWidget.getKeyboardRepeate() + " state=" + isDown);
if (repeate == false || (repeate == true && tmpWidget.getKeyboardRepeat() == true)) { if (repeate == false || (repeate == true && tmpWidget.getKeyboardRepeat() == true)) {
// check Widget shortcut // check Widget shortcut
if (tmpWidget.onEventShortCut(_special, _value, _type, isDown) == false) { if (tmpWidget.onEventShortCut(_special, _value, _type, isDown) == false) {
@ -313,11 +287,115 @@ public abstract class EwolContext extends Application {
} }
@Override @Override
public void onClipboardEvent(final ClipboardList _clipboardId) { public void onKillDemand(final Context _context) {
final Widget tmpWidget = this.widgetManager.focusGet(); Log.info(" == > User demand a destroy (BEGIN)");
if (tmpWidget != null) { final EwolApplication appl = this.application;
tmpWidget.onEventClipboard(_clipboardId); if (appl == null) {
exit(0);
return;
} }
appl.onKillDemand(this);
Log.info(" == > User demand a destroy (END)");
}
@Override
public void onPause(final Context _context) {
Log.info(" == > Ewol system pause (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onPause(this);
Log.info(" == > Ewol system pause (END)");
};
public void onPeriod(final Clock _time) {
this.objectManager.timeCall(_time);
}
public void onPointer(final KeyType _type, final int _pointerID, final Vector2f _pos, final KeyStatus _state) {
switch (_state) {
case move:
// Log.debug("Receive MSG : THREAD_INPUT_MOTION");
this.input.motion(_type, _pointerID, _pos);
break;
case down:
case downRepeate:
// Log.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(_type, _pointerID, true, _pos);
break;
case 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 void onRegenerateDisplay(final Context _context) {
// Log.info("REGENERATE_DISPLAY");
// check if the user selected a windows
final Windows 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 void onResize(final Vector2i _size) {
Log.verbose("Resize: " + _size);
forceRedrawAll();
}
@Override
public void onResume(final Context _context) {
Log.info(" == > Ewol system resume (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onResume(this);
Log.info(" == > Ewol system resume (END)");
}
@Override
public void onStart(final Context _context) {
Log.info(" == > Ewol system start (BEGIN)");
final 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)");
}
@Override
public void onStop(final Context _context) {
Log.info(" == > Ewol system stop (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onStop(this);
Log.info(" == > Ewol system stop (END)");
}
/**
* @brief Request a display after call a resize
*/
public void requestUpdateSize() {
final Context context = Gale.getContext();
context.requestUpdateSize();
} }
/** /**
@ -327,7 +405,13 @@ public abstract class EwolContext extends Application {
this.input.newLayerSet(); this.input.newLayerSet();
} }
private Windows windowsCurrent = null; //!< current displayed windows /**
* @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 set the current windows to display : * @brief set the current windows to display :
@ -349,90 +433,4 @@ public abstract class EwolContext extends Application {
// request all the widget redrawing // request all the widget redrawing
forceRedrawAll(); 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 Vector2f size = getSize();
this.windowsCurrent.setSize(new Vector2f((int) size.x(), (int) 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);
}
} }

View File

@ -0,0 +1,21 @@
package org.atriasoft.ewol.event;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
public 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 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;
}
}

View File

@ -5,6 +5,7 @@ import java.lang.ref.WeakReference;
import org.atriasoft.ewol.Ewol; import org.atriasoft.ewol.Ewol;
import org.atriasoft.ewol.context.EwolContext; import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.internal.Log; import org.atriasoft.ewol.internal.Log;
import org.atriasoft.exml.model.XmlElement;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -138,7 +139,9 @@ public class EwolObject {
* @return true : All has been done corectly. * @return true : All has been done corectly.
* @return false : An error occured. * @return false : An error occured.
*/ */
//boolean loadXML( exml::Element _node); protected boolean loadXML(XmlElement _node) {
return true;
}
/** /**
* @brief store properties in this XML node. * @brief store properties in this XML node.
@ -200,7 +203,7 @@ public class EwolObject {
/** /**
* @brief Remove the current parenting. * @brief Remove the current parenting.
*/ */
void removeParent() { public void removeParent() {
this.parent = null; this.parent = null;
} }

View File

@ -18,7 +18,8 @@ import org.atriasoft.gale.resource.Resource;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
/** /**
* @brief simple display of Colored3DObject ==> for DEBUG only Not availlable on ALL platform (like webGL) * @brief simple display of Colored3DObject ==> for DEBUG only Not availlable on
* ALL platform (like webGL)
*/ */
public class RefactorColored3DObject extends Resource { public class RefactorColored3DObject extends Resource {
protected ResourceProgram GLprogram; protected ResourceProgram GLprogram;
@ -30,7 +31,8 @@ public class RefactorColored3DObject extends Resource {
super(); super();
// get the shader resource : // get the shader resource :
this.GLPosition = 0; this.GLPosition = 0;
this.GLprogram = ResourceProgram.create(new Uri("DATA:///simple3D.vert?lib=ewol"), new Uri("DATA:///simple3D.frag?lib=ewol")); this.GLprogram = ResourceProgram.create(new Uri("DATA:///simple3D.vert?lib=ewol"),
new Uri("DATA:///simple3D.frag?lib=ewol"));
if (this.GLprogram != null) { if (this.GLprogram != null) {
this.GLPosition = this.GLprogram.getAttribute("EW_coord3d"); this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
this.GLColor = this.GLprogram.getUniform("EW_color"); this.GLColor = this.GLprogram.getUniform("EW_color");
@ -48,7 +50,8 @@ public class RefactorColored3DObject extends Resource {
draw(_vertices, _color, true, true); draw(_vertices, _color, true, true);
} }
public void draw(final List<Vector3f> _vertices, final Color _color, final boolean _updateDepthBuffer, final boolean _depthtest) { public void draw(final List<Vector3f> _vertices, final Color _color, final boolean _updateDepthBuffer,
final boolean _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -63,7 +66,7 @@ public class RefactorColored3DObject extends Resource {
} }
} }
//Log.debug(" display " + this.coord.size() + " elements" ); // Log.debug(" display " + this.coord.size() + " elements" );
this.GLprogram.use(); this.GLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
@ -71,15 +74,16 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiplyNew(camMatrix); final Matrix4f tmpMatrix = projMatrix.multiplyNew(camMatrix);
this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position : // position :
this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z,unused*/, ResourceProgram.storeDataInFloatBufferVector3f(_vertices), 3); this.GLprogram.sendAttribute(this.GLPosition, 3/* x,y,z,unused */,
ResourceProgram.storeDataInFloatBufferVector3f(_vertices), 3);
// color : // color :
this.GLprogram.uniformColor(this.GLColor, _color); this.GLprogram.uniformColor(this.GLColor, _color);
// Request the draw od the elements: // Request the draw od the elements:
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, _vertices.size()); OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, _vertices.size());
this.GLprogram.unUse(); this.GLprogram.unUse();
// Request the draw od the elements: // Request the draw od the elements:
//glDrawArrays(GL_LINES, 0, vertices.size()); // glDrawArrays(GL_LINES, 0, vertices.size());
//this.GLprogram.UnUse(); // this.GLprogram.UnUse();
if (true == _depthtest) { if (true == _depthtest) {
if (false == _updateDepthBuffer) { if (false == _updateDepthBuffer) {
OpenGL.setDeathMask(true); OpenGL.setDeathMask(true);
@ -93,7 +97,8 @@ public class RefactorColored3DObject extends Resource {
draw(_vertices, _color, _transformationMatrix, true, true); draw(_vertices, _color, _transformationMatrix, true, true);
} }
public void draw(final List<Vector3f> _vertices, final Color _color, final Matrix4f _transformationMatrix, final boolean _updateDepthBuffer, final boolean _depthtest) { public void draw(final List<Vector3f> _vertices, final Color _color, final Matrix4f _transformationMatrix,
final boolean _updateDepthBuffer, final boolean _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -107,7 +112,7 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
//Log.debug(" display " + this.coord.size() + " elements" ); // Log.debug(" display " + this.coord.size() + " elements" );
this.GLprogram.use(); this.GLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
@ -115,7 +120,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiplyNew(camMatrix).multiply(_transformationMatrix); final Matrix4f tmpMatrix = projMatrix.multiplyNew(camMatrix).multiply(_transformationMatrix);
this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position : // position :
this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z*/, ResourceProgram.storeDataInFloatBufferVector3f(_vertices), 3); // TODO : check 4->3 this.GLprogram.sendAttribute(this.GLPosition, 3/* x,y,z */,
ResourceProgram.storeDataInFloatBufferVector3f(_vertices), 3); // TODO : check 4->3
// color : // color :
this.GLprogram.uniformColor(this.GLColor, _color); this.GLprogram.uniformColor(this.GLColor, _color);
// Request the draw od the elements: // Request the draw od the elements:
@ -129,7 +135,8 @@ public class RefactorColored3DObject extends Resource {
} }
} }
public void drawCapsule(final float _radius, final float _size, int _lats, final int _longs, final Matrix4f _transformationMatrix, final Color _tmpColor) { public void drawCapsule(final float _radius, final float _size, int _lats, final int _longs,
final Matrix4f _transformationMatrix, final Color _tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
_lats = _lats / 2 * 2; _lats = _lats / 2 * 2;
@ -225,7 +232,8 @@ public class RefactorColored3DObject extends Resource {
draw(tmpVertices, _tmpColor, _transformationMatrix); draw(tmpVertices, _tmpColor, _transformationMatrix);
} }
public void drawCone(final float _radius, final float _size, final int _lats, final int _longs, final Matrix4f _transformationMatrix, final Color _tmpColor) { public void drawCone(final float _radius, final float _size, final int _lats, final int _longs,
final Matrix4f _transformationMatrix, final Color _tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
// center to border (TOP) // center to border (TOP)
for (int jjj = 0; jjj < _longs; ++jjj) { for (int jjj = 0; jjj < _longs; ++jjj) {
@ -265,52 +273,55 @@ public class RefactorColored3DObject extends Resource {
draw(tmpVertices, _tmpColor, _transformationMatrix); draw(tmpVertices, _tmpColor, _transformationMatrix);
} }
public void drawCubeLine(final Vector3f _min, final Vector3f _max, final Color _color, final Matrix4f _transformationMatrix) { public void drawCubeLine(final Vector3f _min, final Vector3f _max, final Color _color,
final Matrix4f _transformationMatrix) {
drawCubeLine(_min, _max, _color, _transformationMatrix, true, true); drawCubeLine(_min, _max, _color, _transformationMatrix, true, true);
} }
public void drawCubeLine(final Vector3f _min, final Vector3f _max, final Color _color, final Matrix4f _transformationMatrix, final boolean _updateDepthBuffer, final boolean _depthtest) { public void drawCubeLine(final Vector3f _min, final Vector3f _max, final Color _color,
final Matrix4f _transformationMatrix, final boolean _updateDepthBuffer, final boolean _depthtest) {
final List<Vector3f> vertices = new ArrayList<>(); final List<Vector3f> vertices = new ArrayList<>();
vertices.add(new Vector3f(_min.x, _min.y, _min.z)); vertices.add(new Vector3f(_min.x(), _min.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _min.y, _min.z)); vertices.add(new Vector3f(_max.x(), _min.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _min.y, _min.z)); vertices.add(new Vector3f(_max.x(), _min.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _min.y, _max.z)); vertices.add(new Vector3f(_max.x(), _min.y(), _max.z()));
vertices.add(new Vector3f(_max.x, _min.y, _max.z)); vertices.add(new Vector3f(_max.x(), _min.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _min.y, _max.z)); vertices.add(new Vector3f(_min.x(), _min.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _min.y, _max.z)); vertices.add(new Vector3f(_min.x(), _min.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _min.y, _min.z)); vertices.add(new Vector3f(_min.x(), _min.y(), _min.z()));
vertices.add(new Vector3f(_min.x, _max.y, _min.z)); vertices.add(new Vector3f(_min.x(), _max.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _max.y, _min.z)); vertices.add(new Vector3f(_max.x(), _max.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _max.y, _min.z)); vertices.add(new Vector3f(_max.x(), _max.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _max.y, _max.z)); vertices.add(new Vector3f(_max.x(), _max.y(), _max.z()));
vertices.add(new Vector3f(_max.x, _max.y, _max.z)); vertices.add(new Vector3f(_max.x(), _max.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _max.y, _max.z)); vertices.add(new Vector3f(_min.x(), _max.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _max.y, _max.z)); vertices.add(new Vector3f(_min.x(), _max.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _max.y, _min.z)); vertices.add(new Vector3f(_min.x(), _max.y(), _min.z()));
vertices.add(new Vector3f(_min.x, _min.y, _min.z)); vertices.add(new Vector3f(_min.x(), _min.y(), _min.z()));
vertices.add(new Vector3f(_min.x, _max.y, _min.z)); vertices.add(new Vector3f(_min.x(), _max.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _min.y, _min.z)); vertices.add(new Vector3f(_max.x(), _min.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _max.y, _min.z)); vertices.add(new Vector3f(_max.x(), _max.y(), _min.z()));
vertices.add(new Vector3f(_max.x, _min.y, _max.z)); vertices.add(new Vector3f(_max.x(), _min.y(), _max.z()));
vertices.add(new Vector3f(_max.x, _max.y, _max.z)); vertices.add(new Vector3f(_max.x(), _max.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _min.y, _max.z)); vertices.add(new Vector3f(_min.x(), _min.y(), _max.z()));
vertices.add(new Vector3f(_min.x, _max.y, _max.z)); vertices.add(new Vector3f(_min.x(), _max.y(), _max.z()));
drawLine(vertices, _color, _transformationMatrix, _updateDepthBuffer, _depthtest); drawLine(vertices, _color, _transformationMatrix, _updateDepthBuffer, _depthtest);
} }
public void drawCylinder(final float _radius, final float _size, final int _lats, final int _longs, final Matrix4f _transformationMatrix, final Color _tmpColor) { public void drawCylinder(final float _radius, final float _size, final int _lats, final int _longs,
final Matrix4f _transformationMatrix, final Color _tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
// center to border (TOP) // center to border (TOP)
@ -384,7 +395,8 @@ public class RefactorColored3DObject extends Resource {
drawLine(_vertices, _color, _transformationMatrix, true, true); drawLine(_vertices, _color, _transformationMatrix, true, true);
} }
public void drawLine(final List<Vector3f> _vertices, final Color _color, final Matrix4f _transformationMatrix, final boolean _updateDepthBuffer, final boolean _depthtest) { public void drawLine(final List<Vector3f> _vertices, final Color _color, final Matrix4f _transformationMatrix,
final boolean _updateDepthBuffer, final boolean _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -398,7 +410,7 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
//Log.debug(" display " + this.coord.size() + " elements" ); // Log.debug(" display " + this.coord.size() + " elements" );
this.GLprogram.use(); this.GLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
@ -406,7 +418,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiplyNew(camMatrix).multiply(_transformationMatrix); final Matrix4f tmpMatrix = projMatrix.multiplyNew(camMatrix).multiply(_transformationMatrix);
this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position : // position :
this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z*/, ResourceProgram.storeDataInFloatBufferVector3f(_vertices), 3);// TODO : check 4->3 this.GLprogram.sendAttribute(this.GLPosition, 3/* x,y,z */,
ResourceProgram.storeDataInFloatBufferVector3f(_vertices), 3);// TODO : check 4->3
// color : // color :
this.GLprogram.uniformColor(this.GLColor, _color); this.GLprogram.uniformColor(this.GLColor, _color);
// Request the draw od the elements: // Request the draw od the elements:
@ -420,7 +433,8 @@ public class RefactorColored3DObject extends Resource {
} }
} }
public void drawSphere(final float _radius, final int _lats, final int _longs, final Matrix4f _transformationMatrix, final Color _tmpColor) { public void drawSphere(final float _radius, final int _lats, final int _longs, final Matrix4f _transformationMatrix,
final Color _tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
for (int iii = 0; iii <= _lats; ++iii) { for (int iii = 0; iii <= _lats; ++iii) {
final float lat0 = (float) (Math.PI) * (-0.5f + (float) (iii - 1) / _lats); final float lat0 = (float) (Math.PI) * (-0.5f + (float) (iii - 1) / _lats);
@ -458,15 +472,19 @@ public class RefactorColored3DObject extends Resource {
public void drawSquare(final Vector3f _size, final Matrix4f _transformationMatrix, final Color _tmpColor) { public void drawSquare(final Vector3f _size, final Matrix4f _transformationMatrix, final Color _tmpColor) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
final int[] indices = { 0, 1, 2, 3, 2, 1, 4, 0, 6, 6, 0, 2, 5, 1, 4, 4, 1, 0, 7, 3, 1, 7, 1, 5, 5, 4, 7, 7, 4, 6, 7, 2, 3, 7, 6, 2 }; final int[] indices = { 0, 1, 2, 3, 2, 1, 4, 0, 6, 6, 0, 2, 5, 1, 4, 4, 1, 0, 7, 3, 1, 7, 1, 5, 5, 4, 7, 7, 4,
final Vector3f[] vertices = { new Vector3f(_size.x, _size.y, _size.z), new Vector3f(-_size.x, _size.y, _size.z), new Vector3f(_size.x, -_size.y, _size.z), 6, 7, 2, 3, 7, 6, 2 };
new Vector3f(-_size.x, -_size.y, _size.z), new Vector3f(_size.x, _size.y, -_size.z), new Vector3f(-_size.x, _size.y, -_size.z), new Vector3f(_size.x, -_size.y, -_size.z), final Vector3f[] vertices = { new Vector3f(_size.x(), _size.y(), _size.z()),
new Vector3f(-_size.x, -_size.y, -_size.z) }; new Vector3f(-_size.x(), _size.y(), _size.z()), new Vector3f(_size.x(), -_size.y(), _size.z()),
new Vector3f(-_size.x(), -_size.y(), _size.z()), new Vector3f(_size.x(), _size.y(), -_size.z()),
new Vector3f(-_size.x(), _size.y(), -_size.z()), new Vector3f(_size.x(), -_size.y(), -_size.z()),
new Vector3f(-_size.x(), -_size.y(), -_size.z()) };
tmpVertices.clear(); tmpVertices.clear();
for (int iii = 0; iii < 36; iii += 3) { for (int iii = 0; iii < 36; iii += 3) {
// normal calculation : // normal calculation :
//btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]); // btVector3 normal =
//normal.normalize (); // (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]);
// normal.normalize ();
tmpVertices.add(vertices[indices[iii]]); tmpVertices.add(vertices[indices[iii]]);
tmpVertices.add(vertices[indices[iii + 1]]); tmpVertices.add(vertices[indices[iii + 1]]);
tmpVertices.add(vertices[indices[iii + 2]]); tmpVertices.add(vertices[indices[iii + 2]]);
@ -474,20 +492,25 @@ public class RefactorColored3DObject extends Resource {
draw(tmpVertices, _tmpColor, _transformationMatrix); draw(tmpVertices, _tmpColor, _transformationMatrix);
} }
public void drawTriangles(final List<Vector3f> _vertex, final List<Integer> _indice, final Matrix4f _transformationMatrix, final Color _tmpColor) { public void drawTriangles(final List<Vector3f> _vertex, final List<Integer> _indice,
final Matrix4f _transformationMatrix, final Color _tmpColor) {
drawTriangles(_vertex, _indice, _transformationMatrix, _tmpColor, new Vector3f(0.0f, 0.0f, 0.1f)); drawTriangles(_vertex, _indice, _transformationMatrix, _tmpColor, new Vector3f(0.0f, 0.0f, 0.1f));
} }
public void drawTriangles(final List<Vector3f> _vertex, final List<Integer> _indice, final Matrix4f _transformationMatrix, final Color _tmpColor, final Vector3f _offset) { public void drawTriangles(final List<Vector3f> _vertex, final List<Integer> _indice,
final Matrix4f _transformationMatrix, final Color _tmpColor, final Vector3f _offset) {
final List<Vector3f> tmpVertices = new ArrayList<>(); final List<Vector3f> tmpVertices = new ArrayList<>();
for (int iii = 0; iii < _indice.size() / 3; ++iii) { for (int iii = 0; iii < _indice.size() / 3; ++iii) {
tmpVertices.add(_vertex.get(_indice.get(iii * 3 + 0)).addNew(_offset)); tmpVertices.add(_vertex.get(_indice.get(iii * 3 + 0)).add(_offset));
tmpVertices.add(_vertex.get(_indice.get(iii * 3 + 1)).addNew(_offset)); tmpVertices.add(_vertex.get(_indice.get(iii * 3 + 1)).add(_offset));
tmpVertices.add(_vertex.get(_indice.get(iii * 3 + 2)).addNew(_offset)); tmpVertices.add(_vertex.get(_indice.get(iii * 3 + 2)).add(_offset));
//Log.info(" indices " + _indice[iii*3 + 0] + " " + _indice[iii*3 + 1] + " " + _indice[iii*3 + 2]); // Log.info(" indices " + _indice[iii*3 + 0] + " " + _indice[iii*3 + 1] + " " +
//Log.info(" triangle " + _vertex[_indice[iii*3 + 0]] + " " + _vertex[_indice[iii*3 + 1]] + " " + _vertex[_indice[iii*3 + 2]]); // _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); draw(tmpVertices, _tmpColor, _transformationMatrix);
} }
} }

View File

@ -17,11 +17,24 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log; import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
class ListElement {
public String name;
public Color color;
public ListElement(final String name, final Color color) {
super();
this.name = name;
this.color = color;
}
}
/** /**
* @brief ColorFile is a Resource designed to be specific with the theme (for example black, or white or orange ...) * @brief ColorFile is a Resource designed to be specific with the theme (for
* example black, or white or orange ...)
*/ */
public class ResourceColorFile extends Resource { public class ResourceColorFile extends Resource {
private final List<ListElement> list = new ArrayList<>(); //!< List of all color in the file private final List<ListElement> list = new ArrayList<>(); // !< List of all color in the file
private Color errorColor = Color.ORANGE; private Color errorColor = Color.ORANGE;
/** /**
@ -32,7 +45,7 @@ public class ResourceColorFile extends Resource {
super(_uri.get()); super(_uri.get());
Log.debug("CF : load \"" + _uri + "\""); Log.debug("CF : load \"" + _uri + "\"");
reload(); reload();
//Log.debug("List of all color : " + this.list.keySet()); // Log.debug("List of all color : " + this.list.keySet());
} }
@Override @Override
@ -109,8 +122,9 @@ public class ResourceColorFile extends Resource {
continue; continue;
} }
if (color.length() == 0) { if (color.length() == 0) {
put(name, this.errorColor.clone()); put(name, this.errorColor);
} else {} } else {
}
put(name, Color.valueOf(color)); put(name, Color.valueOf(color));
} }
if (findError == true) { if (findError == true) {
@ -135,7 +149,7 @@ public class ResourceColorFile extends Resource {
return iii; return iii;
} }
} }
this.list.add(new ListElement(_paramName, this.errorColor.clone())); this.list.add(new ListElement(_paramName, this.errorColor));
return this.list.size() - 1; return this.list.size() - 1;
} }
@ -147,16 +161,4 @@ public class ResourceColorFile extends Resource {
this.errorColor = _errorColor; this.errorColor = _errorColor;
} }
}
class ListElement {
public String name;
public Color color;
public ListElement(final String name, final Color color) {
super();
this.name = name;
this.color = color;
}
}; };

View File

@ -65,7 +65,8 @@ public class ResourceFontFreeType extends FontBase {
// load Face ... // load Face ...
this.fftFace = library.newFace(this.FileBuffer, 0); this.fftFace = library.newFace(this.FileBuffer, 0);
if (this.fftFace == null) { if (this.fftFace == null) {
Log.error("... the font file could be opened and read, but it appears ... that its font format is unsupported"); Log.error(
"... the font file could be opened and read, but it appears ... that its font format is unsupported");
} else { } else {
// all OK // all OK
Log.debug("load font : \"" + _uri + "\" glyph count = " + this.fftFace.getNumGlyphs()); Log.debug("load font : \"" + _uri + "\" glyph count = " + this.fftFace.getNumGlyphs());
@ -83,14 +84,16 @@ public class ResourceFontFreeType extends FontBase {
} }
@Override @Override
public synchronized boolean drawGlyph(final Image _imageOut, final int _fontSize, final Vector2i _glyphPosition, final GlyphProperty _property, final int _posInImage) { public synchronized boolean drawGlyph(final Image _imageOut, final int _fontSize, final Vector2i _glyphPosition,
final GlyphProperty _property, final int _posInImage) {
if (this.init == false) { if (this.init == false) {
return false; return false;
} }
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
final int fontQuality = 96; final int fontQuality = 96;
// Select size ... // Select size ...
// note tha +6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of
// freetype
boolean error = this.fftFace.setCharSize(_fontSize + 6, _fontSize + 6, fontQuality, fontQuality); boolean error = this.fftFace.setCharSize(_fontSize + 6, _fontSize + 6, fontQuality, fontQuality);
if (error == false) { if (error == false) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
@ -119,16 +122,16 @@ public class ResourceFontFreeType extends FontBase {
switch (_posInImage) { switch (_posInImage) {
default: default:
case 0: case 0:
_imageOut.setA(_glyphPosition.x + iii, _glyphPosition.y + jjj, valueColor); _imageOut.setA(_glyphPosition.x() + iii, _glyphPosition.y() + jjj, valueColor);
break; break;
case 1: case 1:
_imageOut.setR(_glyphPosition.x + iii, _glyphPosition.y + jjj, valueColor); _imageOut.setR(_glyphPosition.x() + iii, _glyphPosition.y() + jjj, valueColor);
break; break;
case 2: case 2:
_imageOut.setG(_glyphPosition.x + iii, _glyphPosition.y + jjj, valueColor); _imageOut.setG(_glyphPosition.x() + iii, _glyphPosition.y() + jjj, valueColor);
break; break;
case 3: case 3:
_imageOut.setB(_glyphPosition.x + iii, _glyphPosition.y + jjj, valueColor); _imageOut.setB(_glyphPosition.x() + iii, _glyphPosition.y() + jjj, valueColor);
break; break;
} }
// real set of color // real set of color
@ -139,14 +142,16 @@ public class ResourceFontFreeType extends FontBase {
} }
@Override @Override
public synchronized boolean drawGlyph(final ImageMono _imageOut, final int _fontSize, final GlyphProperty _property, final int _borderSize) { public synchronized boolean drawGlyph(final ImageMono _imageOut, final int _fontSize, final GlyphProperty _property,
final int _borderSize) {
if (false == this.init) { if (false == this.init) {
return false; return false;
} }
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
final int fontQuality = 96; final int fontQuality = 96;
// Select size ... // Select size ...
// note tha +6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of
// freetype
boolean error = this.fftFace.setCharSize(_fontSize + 6, _fontSize + 6, fontQuality, fontQuality); boolean error = this.fftFace.setCharSize(_fontSize + 6, _fontSize + 6, fontQuality, fontQuality);
if (error == false) { if (error == false) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
@ -162,7 +167,8 @@ public class ResourceFontFreeType extends FontBase {
return false; return false;
} }
// convert to an anti-aliased bitmap // convert to an anti-aliased bitmap
error = slot.renderGlyph(FT_Render_Mode.FT_RENDER_MODE_NORMAL); // TODO : set FT_RENDER_MODE_MONO ==> 1 bit value ==> faster generation ... error = slot.renderGlyph(FT_Render_Mode.FT_RENDER_MODE_NORMAL); // TODO : set FT_RENDER_MODE_MONO ==> 1 bit
// value ==> faster generation ...
if (error == false) { if (error == false) {
Log.error("FT_Render_Glyph"); Log.error("FT_Render_Glyph");
return false; return false;
@ -192,7 +198,8 @@ public class ResourceFontFreeType extends FontBase {
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
final int fontQuality = 96; final int fontQuality = 96;
// Select size ... // Select size ...
// note tha +6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of
// freetype
final boolean error = this.fftFace.setCharSize(fontSize + 6, fontSize + 6, fontQuality, fontQuality); final boolean error = this.fftFace.setCharSize(fontSize + 6, fontSize + 6, fontQuality, fontQuality);
if (error == false) { if (error == false) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
@ -202,11 +209,14 @@ public class ResourceFontFreeType extends FontBase {
for (int iii = 0; iii < listGlyph.size(); iii++) { for (int iii = 0; iii < listGlyph.size(); iii++) {
listGlyph.get(iii).kerningClear(); listGlyph.get(iii).kerningClear();
for (int kkk = 0; kkk < listGlyph.size(); kkk++) { for (int kkk = 0; kkk < listGlyph.size(); kkk++) {
final Kerning kerning = this.fftFace.getKerning(listGlyph.get(kkk).glyphIndex, listGlyph.get(iii).glyphIndex, FT_Kerning_Mode.FT_KERNING_UNFITTED); final Kerning kerning = this.fftFace.getKerning(listGlyph.get(kkk).glyphIndex,
listGlyph.get(iii).glyphIndex, FT_Kerning_Mode.FT_KERNING_UNFITTED);
// add the kerning only if != 0 ... // add the kerning only if != 0 ...
if (kerning.x != 0) { if (kerning.x != 0) {
listGlyph.get(iii).kerningAdd(listGlyph.get(kkk).UVal, kerning.x / 32.0f); listGlyph.get(iii).kerningAdd(listGlyph.get(kkk).UVal, kerning.x / 32.0f);
//Log.debug("Kerning between : '" + (char)listGlyph[iii].this.UVal + "''" + (char)listGlyph[kkk].this.UVal + "' value : " + kerning.x + " => " + (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));
} }
} }
} }
@ -220,7 +230,8 @@ public class ResourceFontFreeType extends FontBase {
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
final int fontQuality = 96; final int fontQuality = 96;
// Select size ... // Select size ...
// note tha +6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of
// freetype
boolean error = this.fftFace.setCharSize(_fontSize + 6, _fontSize + 6, fontQuality, fontQuality); boolean error = this.fftFace.setCharSize(_fontSize + 6, _fontSize + 6, fontQuality, fontQuality);
if (error == false) { if (error == false) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
@ -246,9 +257,11 @@ public class ResourceFontFreeType extends FontBase {
// set properties : // set properties :
_property.glyphIndex = glyph_index; _property.glyphIndex = glyph_index;
final Bitmap bitmap = slot.getBitmap(); final Bitmap bitmap = slot.getBitmap();
_property.sizeTexture.setValue(bitmap.getWidth(), bitmap.getRows()); _property.sizeTexture = new Vector2i(bitmap.getWidth(), bitmap.getRows());
_property.bearing.setValue(slot.getMetrics().getHoriBearingX() >> 6, slot.getMetrics().getHoriBearingY() >> 6); _property.bearing = new Vector2i(slot.getMetrics().getHoriBearingX() >> 6,
_property.advance.setValue(slot.getMetrics().getHoriAdvance() >> 6, slot.getMetrics().getVertAdvance() >> 6); slot.getMetrics().getHoriBearingY() >> 6);
_property.advance = new Vector2i(slot.getMetrics().getHoriAdvance() >> 6,
slot.getMetrics().getVertAdvance() >> 6);
return true; return true;
} }

View File

@ -18,45 +18,37 @@ import org.lwjgl.opengl.GL13;
public class ResourceTexture2 extends Resource { public class ResourceTexture2 extends Resource {
public enum TextureColorMode { public enum TextureColorMode {
rgb, //!< red/green/blue data rgb, // !< red/green/blue data
rgba //!< red/green/blue/alpha data rgba // !< red/green/blue/alpha data
} }
private static int[] textureIdBinding = { GL13.GL_TEXTURE0, GL13.GL_TEXTURE1, GL13.GL_TEXTURE2, GL13.GL_TEXTURE3, GL13.GL_TEXTURE4, GL13.GL_TEXTURE5, GL13.GL_TEXTURE6, GL13.GL_TEXTURE7, private static int[] textureIdBinding = { GL13.GL_TEXTURE0, GL13.GL_TEXTURE1, GL13.GL_TEXTURE2, GL13.GL_TEXTURE3,
GL13.GL_TEXTURE8, GL13.GL_TEXTURE9, GL13.GL_TEXTURE10, GL13.GL_TEXTURE11, GL13.GL_TEXTURE12, GL13.GL_TEXTURE13, GL13.GL_TEXTURE14, GL13.GL_TEXTURE15, GL13.GL_TEXTURE16, GL13.GL_TEXTURE17, GL13.GL_TEXTURE4, GL13.GL_TEXTURE5, GL13.GL_TEXTURE6, GL13.GL_TEXTURE7, GL13.GL_TEXTURE8, GL13.GL_TEXTURE9,
GL13.GL_TEXTURE18, GL13.GL_TEXTURE19, GL13.GL_TEXTURE20, GL13.GL_TEXTURE21, GL13.GL_TEXTURE22, GL13.GL_TEXTURE23, GL13.GL_TEXTURE24, GL13.GL_TEXTURE25, GL13.GL_TEXTURE26, GL13.GL_TEXTURE10, GL13.GL_TEXTURE11, GL13.GL_TEXTURE12, GL13.GL_TEXTURE13, GL13.GL_TEXTURE14,
GL13.GL_TEXTURE27, GL13.GL_TEXTURE28, GL13.GL_TEXTURE29, GL13.GL_TEXTURE30, GL13.GL_TEXTURE31 };; GL13.GL_TEXTURE15, GL13.GL_TEXTURE16, GL13.GL_TEXTURE17, GL13.GL_TEXTURE18, GL13.GL_TEXTURE19,
GL13.GL_TEXTURE20, GL13.GL_TEXTURE21, GL13.GL_TEXTURE22, GL13.GL_TEXTURE23, GL13.GL_TEXTURE24,
GL13.GL_TEXTURE25, GL13.GL_TEXTURE26, GL13.GL_TEXTURE27, GL13.GL_TEXTURE28, GL13.GL_TEXTURE29,
GL13.GL_TEXTURE30, GL13.GL_TEXTURE31 };;
/* /*
public static ResourceTexture2 createFromPng(final Uri uriTexture) { * public static ResourceTexture2 createFromPng(final Uri uriTexture) { return
return createFromPng(uriTexture, 1); * createFromPng(uriTexture, 1); }
} *
* public static ResourceTexture2 createFromPng(final Uri uriTexture, final int
public static ResourceTexture2 createFromPng(final Uri uriTexture, final int textureUnit) { * textureUnit) { ResourceTexture2 resource; Resource resource2; final String
ResourceTexture2 resource; * name = uriTexture.getValue(); if (name.isEmpty() == false && name != "---") {
Resource resource2; * resource2 = getManager().localKeep(name); } else {
final String name = uriTexture.getValue(); * Log.error("Can not create a shader without a filaname"); return null; } if
if (name.isEmpty() == false && name != "---") { * (resource2 != null) { if (resource2 instanceof ResourceTexture2) {
resource2 = getManager().localKeep(name); * resource2.keep(); return (ResourceTexture2) resource2; }
} else { * Log.critical("Request resource file : '" + name +
Log.error("Can not create a shader without a filaname"); * "' With the wrong type (dynamic cast error)"); return null; } resource = new
return null; * ResourceTexture2(uriTexture, textureUnit); final ImageRawData decodedData =
} * ImageLoader.decodePngFile(uriTexture);
if (resource2 != null) { * resource.setTexture(decodedData.getBuffer(), new
if (resource2 instanceof ResourceTexture2) { * Vector2i(decodedData.getWidth(), decodedData.getHeight()),
resource2.keep(); * (decodedData.isHasAlpha() == true ? TextureColorMode.rgba :
return (ResourceTexture2) resource2; * TextureColorMode.rgb), textureUnit); resource.flush(); return resource; }
}
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
return null;
}
resource = new ResourceTexture2(uriTexture, textureUnit);
final ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture);
resource.setTexture(decodedData.getBuffer(), new Vector2i(decodedData.getWidth(), decodedData.getHeight()), (decodedData.isHasAlpha() == true ? TextureColorMode.rgba : TextureColorMode.rgb),
textureUnit);
resource.flush();
return resource;
}
*/ */
/** /**
@ -76,12 +68,13 @@ public class ResourceTexture2 extends Resource {
return val; return val;
} }
protected int texId = -1; //!< openGl textureID. protected int texId = -1; // !< openGl textureID.
// openGl Context properties : // openGl Context properties :
protected Image data = new Image(32, 32); protected Image data = new Image(32, 32);
//! Last loaded size in the system openGL // ! Last loaded size in the system openGL
protected Vector2i lastSize = new Vector2i(1, 1); protected Vector2i lastSize = new Vector2i(1, 1);
//! 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 // ! 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
protected Vector2i realImageSize = new Vector2i(1, 1); protected Vector2i realImageSize = new Vector2i(1, 1);
// internal state of the openGl system. // internal state of the openGl system.
protected boolean loaded = false; protected boolean loaded = false;
@ -93,7 +86,7 @@ public class ResourceTexture2 extends Resource {
// Filter apply at the image when rendering it // Filter apply at the image when rendering it
protected TextureFilter filter = TextureFilter.linear; protected TextureFilter filter = TextureFilter.linear;
//!< Color space of the image. // !< Color space of the image.
private final TextureColorMode dataColorSpace = TextureColorMode.rgba; private final TextureColorMode dataColorSpace = TextureColorMode.rgba;
public ResourceTexture2() { public ResourceTexture2() {
@ -105,17 +98,11 @@ public class ResourceTexture2 extends Resource {
} }
/* /*
public void bindForRendering(final int idTexture) { * public void bindForRendering(final int idTexture) { if (this.loaded == false)
if (this.loaded == false) { * { return; } GL13.glActiveTexture(textureIdBinding[idTexture]);
return; * GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texId); if (this.dataColorSpace
} * == TextureColorMode.rgb) { OpenGL.enable(OpenGL.Flag.flag_cullFace);
GL13.glActiveTexture(textureIdBinding[idTexture]); * OpenGL.enable(OpenGL.Flag.flag_back); } }
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texId);
if (this.dataColorSpace == TextureColorMode.rgb) {
OpenGL.enable(OpenGL.Flag.flag_cullFace);
OpenGL.enable(OpenGL.Flag.flag_back);
}
}
*/ */
public ResourceTexture2(final Uri filename) { public ResourceTexture2(final Uri filename) {
@ -189,17 +176,19 @@ public class ResourceTexture2 extends Resource {
Log.debug("Set a new image in a texture:"); Log.debug("Set a new image in a texture:");
Log.debug(" size=" + _image.getSize()); Log.debug(" size=" + _image.getSize());
this.data = _image; this.data = _image;
this.realImageSize = this.data.getSize().clone(); this.realImageSize = this.data.getSize();
final Vector2i compatibilityHWSize = new Vector2i(Tools.nextP2(this.realImageSize.x), Tools.nextP2(this.realImageSize.y)); final Vector2i compatibilityHWSize = new Vector2i(Tools.nextP2(this.realImageSize.x()),
Tools.nextP2(this.realImageSize.y()));
if (this.realImageSize != compatibilityHWSize) { if (this.realImageSize != compatibilityHWSize) {
Log.verbose("RESIZE Image for HArwareCompatibility:" + this.realImageSize + " => " + compatibilityHWSize); Log.verbose("RESIZE Image for HArwareCompatibility:" + this.realImageSize + " => " + compatibilityHWSize);
this.data.resize(compatibilityHWSize.x, compatibilityHWSize.y); this.data.resize(compatibilityHWSize.x(), compatibilityHWSize.y());
} }
flush(); flush();
}; };
/** /**
* @brief Set the Filter mode to apply at the image when display with a scale (not 1:1 ratio) * @brief Set the Filter mode to apply at the image when display with a scale
* (not 1:1 ratio)
* @param[in] _value Value of the new filter mode * @param[in] _value Value of the new filter mode
*/ */
public void setFilterMode(final TextureFilter _filter) { public void setFilterMode(final TextureFilter _filter) {
@ -207,9 +196,9 @@ public class ResourceTexture2 extends Resource {
} }
// You must set the size here, because it will be set in multiple of pow(2) // You must set the size here, because it will be set in multiple of pow(2)
public synchronized void setImageSize(final Vector2i _newSize) { public synchronized void setImageSize(Vector2i _newSize) {
_newSize.setValue(Tools.nextP2(_newSize.x), Tools.nextP2(_newSize.y)); _newSize = new Vector2i(Tools.nextP2(_newSize.x()), Tools.nextP2(_newSize.y()));
this.data.resize(_newSize.x, _newSize.y); this.data.resize(_newSize.x(), _newSize.y());
}; };
/** /**
@ -234,16 +223,15 @@ public class ResourceTexture2 extends Resource {
public synchronized boolean updateContext() { public synchronized boolean updateContext() {
Log.verbose("updateContext [START]"); Log.verbose("updateContext [START]");
final Steady tic = Steady.now(); final Steady tic = Steady.now();
/* TODO : use unlockable synchronized ... /*
if (lock.tryLock() == false) { * TODO : use unlockable synchronized ... if (lock.tryLock() == false) { //Lock
//Lock error ==> try later ... * error ==> try later ... return false; }
return false;
}
*/ */
final int typeObject = OpenGL.GL_RGBA; final int typeObject = OpenGL.GL_RGBA;
final int sizeObject = OpenGL.GL_UNSIGNED_BYTE; final int sizeObject = OpenGL.GL_UNSIGNED_BYTE;
if (this.loaded == true) { if (this.loaded == true) {
if (this.lastTypeObject != typeObject || this.lastSizeObject != sizeObject || this.lastSize.equals(this.data.getSize()) == false) { if (this.lastTypeObject != typeObject || this.lastSizeObject != sizeObject
|| this.lastSize.equals(this.data.getSize()) == false) {
Log.warning("TEXTURE: Rm [" + getId() + "] texId=" + this.texId); Log.warning("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
OpenGL.glDeleteTextures(this.texId); OpenGL.glDeleteTextures(this.texId);
this.loaded = false; this.loaded = false;
@ -255,9 +243,11 @@ public class ResourceTexture2 extends Resource {
this.lastSize = this.data.getSize(); this.lastSize = this.data.getSize();
this.lastTypeObject = typeObject; this.lastTypeObject = typeObject;
this.lastSizeObject = sizeObject; this.lastSizeObject = sizeObject;
Log.debug("TEXTURE: add [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize() + " OGl_Id=" + this.texId + " type=" + this.data.getClass().getCanonicalName()); Log.debug("TEXTURE: add [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize()
+ " OGl_Id=" + this.texId + " type=" + this.data.getClass().getCanonicalName());
} else { } else {
Log.debug("TEXTURE: update [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize() + " OGl_Id=" + this.texId + " type=" + this.data.getClass().getCanonicalName()); Log.debug("TEXTURE: update [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize()
+ " OGl_Id=" + this.texId + " type=" + this.data.getClass().getCanonicalName());
} }
// in all case we set the texture properties : // in all case we set the texture properties :
// TODO : check error ??? // TODO : check error ???
@ -275,46 +265,29 @@ public class ResourceTexture2 extends Resource {
OpenGL.setTexture2DFilterNearest(); OpenGL.setTexture2DFilterNearest();
} }
} }
//glPixelStorei(GL_UNPACK_ALIGNMENT,1); // glPixelStorei(GL_UNPACK_ALIGNMENT,1);
final Steady toc1 = Steady.now(); final Steady toc1 = Steady.now();
Log.verbose(" BIND ==> " + toc1.less(tic)); Log.verbose(" BIND ==> " + toc1.less(tic));
//egami::store(this.data, String("~/texture_") + etk::toString(getId()) + ".bmp"); // egami::store(this.data, String("~/texture_") + etk::toString(getId()) +
/*if (false) { // ".bmp");
// On some embended target, the texture size must be square of 2: /*
if (this.loaded == false) { * if (false) { // On some embended target, the texture size must be square of
// 1: Create the square 2 texture: * 2: if (this.loaded == false) { // 1: Create the square 2 texture: final int
final int bufferSize = this.data.getGPUSize().x() * this.data.getGPUSize().y() * 8; * bufferSize = this.data.getGPUSize().x() * this.data.getGPUSize().y() * 8;
static List<float> tmpData; * static List<float> tmpData; if (tmpData.size() < bufferSize) {
if (tmpData.size() < bufferSize) { * tmpData.resize(bufferSize, 0.0f); } Log.debug(" CREATE texture ==> " +
tmpData.resize(bufferSize, 0.0f); * this.data.getGPUSize()); // 2 create a new empty texture:
} * OpenGL.glTexImage2D(GL_TEXTURE_2D, // Target 0, // Level typeObject, //
Log.debug(" CREATE texture ==> " + this.data.getGPUSize()); * Format internal this.data.getGPUSize().x(), this.data.getGPUSize().y(), 0, //
// 2 create a new empty texture: * Border typeObject, // format sizeObject, // type tmpData[0] );
OpenGL.glTexImage2D(GL_TEXTURE_2D, // Target *
0, // Level * } //3 Flush all time the data: Steady tic1 = Steady.now();
typeObject, // Format internal * glTexSubImage2D(GL_TEXTURE_2D, // Target 0, // Level 0, // x offset 0, // y
this.data.getGPUSize().x(), * offset this.data.getWidth(), this.data.getHeight(), typeObject, // format
this.data.getGPUSize().y(), * sizeObject, // type (void*)((char*)this.data.getTextureDataPointer()) );
0, // Border * Steady toc2 = Steady.now(); Log.info(" updateContext [STOP] ==> " +
typeObject, // format * toc2.less(tic1)); } else
sizeObject, // type */if (this.loaded == false) {
tmpData[0] );
}
//3 Flush all time the data:
Steady tic1 = Steady.now();
glTexSubImage2D(GL_TEXTURE_2D, // Target
0, // Level
0, // x offset
0, // y offset
this.data.getWidth(),
this.data.getHeight(),
typeObject, // format
sizeObject, // type
(void*)((char*)this.data.getTextureDataPointer()) );
Steady toc2 = Steady.now();
Log.info(" updateContext [STOP] ==> " + toc2.less(tic1));
} else */if (this.loaded == false) {
OpenGL.glTexImage2D(0, // Level OpenGL.glTexImage2D(0, // Level
typeObject, // Format internal typeObject, // Format internal
this.data.getWidth(), this.data.getHeight(), 0, // Border this.data.getWidth(), this.data.getHeight(), 0, // Border
@ -333,12 +306,11 @@ public class ResourceTexture2 extends Resource {
// now the data is loaded // now the data is loaded
this.loaded = true; this.loaded = true;
final Steady toc = Steady.now(); final Steady toc = Steady.now();
//Log.error(" updateContext [STOP] ==> " + (toc - toc1)); // Log.error(" updateContext [STOP] ==> " + (toc - toc1));
return true; return true;
} }
}; };
enum TextureFilter { enum TextureFilter {
nearest, nearest, linear
linear
} }

View File

@ -22,8 +22,10 @@ public class ResourceTextureFile extends ResourceTexture2 {
* @brief keep the resource pointer. * @brief keep the resource pointer.
* @note Never free this pointer by your own... * @note Never free this pointer by your own...
* @param[in] _filename Name of the image file. * @param[in] _filename Name of the image file.
* @param[in] _requested size of the image (usefull when loading .svg to automatic rescale) * @param[in] _requested size of the image (usefull when loading .svg to
* @param[in] _sizeRegister size register in named (When you preaload the images the size write here will be ) * automatic rescale)
* @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. * @return pointer on the resource or null if an error occured.
*/ */
public static ResourceTextureFile create(final Uri _filename) { public static ResourceTextureFile create(final Uri _filename) {
@ -36,30 +38,30 @@ public class ResourceTextureFile extends ResourceTexture2 {
public static ResourceTextureFile create(final Uri _uri, final Vector2i _size, final Vector2i _sizeRegister) { public static ResourceTextureFile create(final Uri _uri, final Vector2i _size, final Vector2i _sizeRegister) {
Log.verbose("KEEP: TextureFile: '" + _uri + "' size=" + _size + " sizeRegister=" + _sizeRegister); Log.verbose("KEEP: TextureFile: '" + _uri + "' size=" + _size + " sizeRegister=" + _sizeRegister);
Vector2i size = _size.clone(); Vector2i size = _size;
if (_uri == null) { if (_uri == null) {
final ResourceTextureFile object = new ResourceTextureFile(); final ResourceTextureFile object = new ResourceTextureFile();
return object; return object;
} }
if (size.x == 0) { if (size.x() == 0) {
size.setX(-1); size = size.withX(-1);
//Log.error("Error Request the image size.x() =0 ???"); // Log.error("Error Request the image size.x() =0 ???");
} }
if (size.y == 0) { if (size.y() == 0) {
size.setY(-1); size = size.withY(-1);
//Log.error("Error Request the image size.y() =0 ???"); // Log.error("Error Request the image size.y() =0 ???");
} }
final Uri tmpFilename = _uri; final Uri tmpFilename = _uri;
if (_uri.getExtention().toLowerCase().contentEquals("svg") == false) { if (_uri.getExtention().toLowerCase().contentEquals("svg") == false) {
size = sizeAuto; size = sizeAuto;
} }
if (size.x > 0 && size.y > 0) { if (size.x() > 0 && size.y() > 0) {
Log.verbose(" == > specific size : " + size); Log.verbose(" == > specific size : " + size);
size.setValue(Tools.nextP2(size.x), Tools.nextP2(size.y)); size = new Vector2i(Tools.nextP2(size.x()), Tools.nextP2(size.y()));
if (_sizeRegister.equals(sizeAuto) == false) { if (_sizeRegister.equals(sizeAuto) == false) {
if (_sizeRegister.equals(sizeDefault) == false) { if (_sizeRegister.equals(sizeDefault) == false) {
//tmpFilename.getQuery().set("x", "" + size.x)); // tmpFilename.getQuery().set("x", "" + size.x));
//tmpFilename.getQuery().set("y", "" + size.y)); // tmpFilename.getQuery().set("y", "" + size.y));
} }
} }
} }

View File

@ -0,0 +1,79 @@
/*
* @author Edouard DUPIN
* @file
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.ewol.tools;
import org.atriasoft.ewol.Ewol;
public class Message {
/**
* @brief Create a simple pop-up message on the screen for application error.
* @param[in] _type Type of the error.
* @param[in] _message message to display (decorated text)
*/
private static void create(Type _type, String _message){
StdPopUp tmpPopUp = new StdPopUp();
switch (_type) {
case Type.info -> tmpPopUp.propertyTitle.set("<bold>_T{Info}</bold>");
case Type.warning -> tmpPopUp.propertyTitle.set("<bold><font color='orange'>_T{Warning}</font></bold>");
case Type.error -> tmpPopUp.propertyTitle.set("<bold><font color='red'>_T{Error}</font></bold>");
case Type.critical -> tmpPopUp.propertyTitle.set("<bold><font colorBg='red'>_T{Critical}</font></bold>");
}
tmpPopUp.propertyComment.set(_message);
tmpPopUp.addButton("_T{close}", true);
tmpPopUp.propertyCloseOutEvent.set(true);
// get windows:
EwolContext context = Ewol.getContext();
Windows windows = context.getWindows();
if (windows == null) {
Log.error("can not get the current windows ... ==> can not display message : " + _message);
return;
}
windows.popUpWidgetPush(tmpPopUp);
}
/**
* @brief Create a simple information message
* @param[in] _message message to display (decorated text)
*/
public static void displayInfo(String _message){
create(Type.info, _message);
}
/**
* @brief Create a simple warning message
* @param[in] _message message to display (decorated text)
*/
public static void displayWarning(String _message) {
create(Type.warning, _message);
}
/**
* @brief Create a simple error message
* @param[in] _message message to display (decorated text)
*/
public static void displayError(String _message) {
create(Type.error,_message);
}
/**
* @brief Create a simple critical message
* @param[in] _message message to display (decorated text)
*/
public static void displayCritical(String _message){
create(Type.critical, _message);
}
private enum Type {
info, //!< information message pop-up
warning, //!< warning message pop-up
error, //!< Error message pop-up
critical //!< Critical message pop-up
}
}

View File

@ -1,65 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp>
#include <ewol/ewol.hpp>
#include <ewol/tools/message.hpp>
#include <ewol/context/Context.hpp>
#include <ewol/widget/Widget.hpp>
#include <ewol/widget/Windows.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/widget/meta/StdPopUp.hpp>
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("<bold>_T{Info}</bold>");
break;
case ewol::tools::message::type::warning:
tmpPopUp.propertyTitle.set("<bold><font color='orange'>_T{Warning}</font></bold>");
break;
case ewol::tools::message::type::error:
tmpPopUp.propertyTitle.set("<bold><font color='red'>_T{Error}</font></bold>");
break;
case ewol::tools::message::type::critical:
tmpPopUp.propertyTitle.set("<bold><font colorBg='red'>_T{Critical}</font></bold>");
break;
}
tmpPopUp.propertyComment.set(_message);
tmpPopUp.addButton("_T{close}", true);
tmpPopUp.propertyCloseOutEvent.set(true);
// get windows:
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);
return;
}
windows.popUpWidgetPush(tmpPopUp);
}
void ewol::tools::message::displayInfo( String _message) {
ewol::tools::message::create(ewol::tools::message::type::info, _message);
}
void ewol::tools::message::displayWarning( String _message) {
ewol::tools::message::create(ewol::tools::message::type::warning, _message);
}
void ewol::tools::message::displayError( String _message) {
ewol::tools::message::create(ewol::tools::message::type::error, _message);
}
void ewol::tools::message::displayCritical( String _message) {
ewol::tools::message::create(ewol::tools::message::type::critical, _message);
}

View File

@ -1,52 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/Widget.hpp>
#include <etk/Color.hpp>
#include <ewol/resource/ColorFile.hpp>
namespace ewol {
namespace tools {
namespace message {
enum class type {
info, //!< information message pop-up
warning, //!< warning message pop-up
error, //!< Error message pop-up
critical //!< Critical message pop-up
};
/**
* @brief Create a simple pop-up message on the screen for application error.
* @param[in] _type Type of the error.
* @param[in] _message message to display (decorated text)
*/
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( String _message);
/**
* @brief Create a simple warning message
* @param[in] _message message to display (decorated text)
*/
void displayWarning( String _message);
/**
* @brief Create a simple error message
* @param[in] _message message to display (decorated text)
*/
void displayError( String _message);
/**
* @brief Create a simple critical message
* @param[in] _message message to display (decorated text)
*/
void displayCritical( String _message);
}
}
}

View File

@ -1,215 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/ewol.hpp>
#include <ewol/widget/Container.hpp>
#include <ewol/widget/Manager.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::widget::Container);
ewol::widget::Container::Container() {
addObjectType("ewol::widget::Container");
// nothing to do ...
}
ewol::widget::Container::~Container() {
subWidgetRemove();
}
Widget ewol::widget::Container::getSubWidget() {
return this.subWidget;
}
void ewol::widget::Container::setSubWidget(Widget _newWidget) {
if (_newWidget == null) {
return;
}
subWidgetRemove();
this.subWidget = _newWidget;
if (this.subWidget != null) {
this.subWidget.setParent(sharedFromThis());
}
markToRedraw();
requestUpdateSize();
}
void ewol::widget::Container::subWidgetReplace( Widget _oldWidget,
Widget _newWidget) {
if (this.subWidget != _oldWidget) {
Log.warning("Request replace with a wrong old widget");
return;
}
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 (this.subWidget != null) {
this.subWidget.removeParent();
this.subWidget.reset();
markToRedraw();
requestUpdateSize();
}
}
void ewol::widget::Container::subWidgetUnLink() {
if (this.subWidget != null) {
this.subWidget.removeParent();
}
this.subWidget.reset();
}
EwolObject ewol::widget::Container::getSubObjectNamed( String _objectName) {
EwolObject tmpObject = Widget::getSubObjectNamed(_objectName);
if (tmpObject != null) {
return tmpObject;
}
if (this.subWidget != null) {
return this.subWidget.getSubObjectNamed(_objectName);
}
return null;
}
void ewol::widget::Container::systemDraw( ewol::DrawProperty _displayProp) {
if (propertyHide.get() == true){
// widget is hidden ...
return;
}
Widget::systemDraw(_displayProp);
if (this.subWidget != null) {
ewol::DrawProperty prop = _displayProp;
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]");
}
}
void ewol::widget::Container::onChangeSize() {
Widget::onChangeSize();
if (*propertyHide == true) {
return;
}
if (this.subWidget == null) {
return;
}
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
Widget::calculateMinMaxSize();
// call sub classes
if (this.subWidget != null) {
this.subWidget.calculateMinMaxSize();
Vector2f min = this.subWidget.getCalculateMinSize();
this.minSize.setMax(min);
}
//Log.error("[" + getId() + "] Result min size : " + this.minSize);
}
void ewol::widget::Container::onRegenerateDisplay() {
if (this.subWidget != null) {
this.subWidget.onRegenerateDisplay();
}
}
Widget ewol::widget::Container::getWidgetAtPos( Vector2f _pos) {
if (propertyHide.get() == false) {
if (this.subWidget != null) {
return this.subWidget.getWidgetAtPos(_pos);
}
}
return null;
};
boolean ewol::widget::Container::loadXML( exml::Element _node) {
if (_node.exist() == false) {
return false;
}
// parse generic properties:
Widget::loadXML(_node);
// remove previous element:
subWidgetRemove();
// parse all the elements:
for ( auto it : _node.nodes) {
exml::Element pNode = it.toElement();
if (pNode.exist() == false) {
// trash here all that is not element
continue;
}
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() + "]" );
continue;
}
if (getSubWidget() != null) {
Log.error("(l " + pNode.getPos() + ") Can only have one subWidget ??? node='" + widgetName + "'" );
continue;
}
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 + "'");
continue;
}
// add widget :
setSubWidget(tmpWidget);
if (tmpWidget.loadXML(pNode) == false) {
EWOL_ERROR ("(l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'");
return false;
}
}
if ( _node.nodes.size() != 0
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget == null) {
Log.warning("Load container with no data inside");
}
return true;
}
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( EwolObject _child) {
if (this.subWidget != _child) {
return;
}
if (this.subWidget == null) {
return;
}
this.subWidget.removeParent();
this.subWidget.reset();
markToRedraw();
}
void ewol::widget::Container::drawWidgetTree(int _level) {
Widget::drawWidgetTree(_level);
_level++;
if (this.subWidget != null) {
this.subWidget.drawWidgetTree(_level);
}
}

View File

@ -1,73 +1,225 @@
import org.atriasoft.etk.math.Vector2b;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.exml.model.XmlNode;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once /*
#include <etk/types.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/Widget.hpp>
namespace ewol {
namespace widget {
class Container;
using Container = ememory::Ptr<ewol::widget::Container>;
using ContainerWeak = ememory::WeakPtr<ewol::widget::Container>;
/**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
* @brief the Cotainer widget is a widget that have an only one subWidget * @brief the Cotainer widget is a widget that have an only one subWidget
*/ */
class Container : public Widget { class Container extends Widget {
protected: protected Widget subWidget = null;
Widget this.subWidget;
protected:
/** /**
* @brief Constructor * @brief Constructor
*/ */
Container(); public Container() {
public: super();
/** }
* @brief Destructor
*/
~Container();
public:
/** /**
* @brief get the main node widget * @brief get the main node widget
* @return the requested pointer on the node * @return the requested pointer on the node
*/ */
Widget getSubWidget(); public Widget getSubWidget(){
return this.subWidget;
}
/** /**
* @brief set the subWidget node widget. * @brief set the subWidget node widget.
* @param[in] _newWidget The widget to add. * @param[in] _newWidget The widget to add.
*/ */
void setSubWidget(Widget _newWidget); public void setSubWidget(Widget _newWidget){
if (_newWidget == null) {
return;
}
subWidgetRemove();
this.subWidget = _newWidget;
if (this.subWidget != null) {
this.subWidget.setParent(this);
}
markToRedraw();
requestUpdateSize();
}
/** /**
* @brief Replace a old subwidget with a new one. * @brief Replace a old subwidget with a new one.
* @param[in] _oldWidget The widget to replace. * @param[in] _oldWidget The widget to replace.
* @param[in] _newWidget The widget to set. * @param[in] _newWidget The widget to set.
*/ */
void subWidgetReplace( Widget _oldWidget, public void subWidgetReplace( Widget _oldWidget,
Widget _newWidget); Widget _newWidget){
if (this.subWidget != _oldWidget) {
Log.warning("Request replace with a wrong old widget");
return;
}
this.subWidget.removeParent();
this.subWidget = _newWidget;
if (this.subWidget != null) {
this.subWidget.setParent(this);
}
markToRedraw();
requestUpdateSize();
}
/** /**
* @brief remove the subWidget node (async). * @brief remove the subWidget node (async).
*/ */
void subWidgetRemove(); public void subWidgetRemove() {
if (this.subWidget != null) {
this.subWidget.removeParent();
this.subWidget = null;
markToRedraw();
requestUpdateSize();
}
}
/** /**
* @brief Unlink the subwidget Node. * @brief Unlink the subwidget Node.
*/ */
void subWidgetUnLink(); public void subWidgetUnLink(){
public: if (this.subWidget != null) {
void systemDraw( ewol::DrawProperty _displayProp) ; this.subWidget.removeParent();
void onRegenerateDisplay() ; }
void onChangeSize() ; this.subWidget = null;
void calculateMinMaxSize() ; }
Widget getWidgetAtPos( Vector2f _pos) ; public void systemDraw( DrawProperty _displayProp){
EwolObject getSubObjectNamed( String _objectName) ; if (propertyHide){
boolean loadXML( exml::Element _node) ; // widget is hidden ...
void setOffset( Vector2f _newVal) ; return;
void requestDestroyFromChild( EwolObject _child) ; }
void drawWidgetTree(int _level=0) ; super.systemDraw(_displayProp);
}; if (this.subWidget != null) {
DrawProperty prop = _displayProp.withLimit(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]");
}
}
public void onRegenerateDisplay() {
if (this.subWidget != null) {
this.subWidget.onRegenerateDisplay();
}
}
public void onChangeSize() {
super.onChangeSize();
if (propertyHide) {
return;
}
if (this.subWidget == null) {
return;
}
Vector2f origin = this.origin.add(this.offset);
Vector2f minSize = this.subWidget.getCalculateMinSize();
Vector2b expand = this.subWidget.getPropertyExpand();
origin = origin.add(Gravity.gravityGenerateDelta(propertyGravity, minSize.less(this.size)));
this.subWidget.setOrigin(origin);
this.subWidget.setSize(this.size);
this.subWidget.onChangeSize();
}
public void calculateMinMaxSize(){
// call main class
super.calculateMinMaxSize();
// call sub classes
if (this.subWidget != null) {
this.subWidget.calculateMinMaxSize();
Vector2f min = this.subWidget.getCalculateMinSize();
this.minSize = Vector2f.max(this.minSize, min);
}
//Log.error("[" + getId() + "] Result min size : " + this.minSize);
}
public Widget getWidgetAtPos( Vector2f _pos) {
if (!propertyHide) {
if (this.subWidget != null) {
return this.subWidget.getWidgetAtPos(_pos);
}
}
return null;
}; };
public EwolObject getSubObjectNamed( String _objectName) {
EwolObject tmpObject = super.getSubObjectNamed(_objectName);
if (tmpObject != null) {
return tmpObject;
}
if (this.subWidget != null) {
return this.subWidget.getSubObjectNamed(_objectName);
}
return null;
}
public boolean loadXML( XmlElement _node) {
if (_node == null) {
return false;
}
// parse generic properties:
super.loadXML(_node);
// remove previous element:
subWidgetRemove();
// parse all the elements:
for (XmlNode it : _node.getNodes()) {
if (!it.isElement()) {
// trash here all that is not element
continue;
}
XmlElement pNode = it.toElement();
String widgetName = pNode.getValue();
Log.verbose("[" + getId() + "] t=" + getClass().getCanonicalName() + " Load node name : '" + widgetName + "'");
if (!getWidgetManager().exist(widgetName)) {
Log.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]" );
continue;
}
if (getSubWidget() != null) {
Log.error("Can only have one subWidget ??? node='" + widgetName + "'" );
continue;
}
Log.debug("try to create subwidget : '" + widgetName + "'");
Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
if (tmpWidget == null) {
Log.error ("Can not create the widget : '" + widgetName + "'");
continue;
}
// add widget :
setSubWidget(tmpWidget);
if (!tmpWidget.loadXML(pNode)) {
Log.error ("can not load widget properties : '" + widgetName + "'");
return false;
}
}
if (_node.getNodes().size() != 0 && this.subWidget == null) {
Log.warning("Load container with no data inside");
}
return true;
}
public void setOffset( Vector2f _newVal) {
if (this.offset.equals(_newVal)) {
return;
}
super.setOffset(_newVal);
// recalculate the new sise and position of sub widget ...
onChangeSize();
}
public void requestDestroyFromChild( EwolObject _child){
if (this.subWidget != _child) {
return;
}
if (this.subWidget == null) {
return;
}
this.subWidget.removeParent();
this.subWidget = null;
markToRedraw();
}
public void drawWidgetTree(int _level) {
super.drawWidgetTree(_level);
_level++;
if (this.subWidget != null) {
this.subWidget.drawWidgetTree(_level);
}
}
}; };

View File

@ -1,342 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/ewol.hpp>
#include <ewol/widget/ContainerN.hpp>
#include <ewol/widget/Manager.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::widget::ContainerN);
ewol::widget::ContainerN::ContainerN() :
propertyLockExpand(this, "lock",
Vector2f(false,false),
"Lock the subwidget expand",
ewol::widget::ContainerN::onChangePropertyLockExpand),
this.subExpend(false,false) {
addObjectType("ewol::widget::ContainerN");
// nothing to do ...
}
ewol::widget::ContainerN::~ContainerN() {
subWidgetRemoveAll();
}
Vector2b ewol::widget::ContainerN::canExpand() {
Vector2b res = propertyExpand.get();
if (propertyLockExpand.x() == false) {
if (this.subExpend.x() == true) {
res.setX(true);
}
}
if (propertyLockExpand.y() == false) {
if (this.subExpend.y() == true) {
res.setY(true);
}
}
//Log.debug("Expend check : user=" + this.userExpand + " lock=" + propertyLockExpand + " sub=" + this.subExpend + " res=" + res);
return res;
}
void ewol::widget::ContainerN::onChangePropertyLockExpand() {
markToRedraw();
requestUpdateSize();
}
void ewol::widget::ContainerN::subWidgetReplace(Widget _oldWidget,
Widget _newWidget) {
boolean haveChange = false;
for (auto it : this.subWidget) {
if (it != _oldWidget) {
continue;
}
it.removeParent();
it.reset();
if (_newWidget != null) {
_newWidget.setParent(sharedFromThis());
}
it = _newWidget;
haveChange = true;
}
if (haveChange == false) {
Log.warning("Request replace with a wrong old widget");
return;
}
markToRedraw();
requestUpdateSize();
}
int ewol::widget::ContainerN::subWidgetAdd(Widget _newWidget) {
if (_newWidget == null) {
Log.error("[" + getId() + "] {" + getObjectType() + "} Try to add An empty Widget ... ");
return -1;
}
_newWidget.setParent(sharedFromThis());
this.subWidget.pushBack(_newWidget);
markToRedraw();
requestUpdateSize();
// added at the last eelement :
return _newWidget.getId();
}
int ewol::widget::ContainerN::subWidgetAddStart(Widget _newWidget) {
if (_newWidget == null) {
Log.error("[" + getId() + "] {" + getObjectType() + "} Try to add start An empty Widget ... ");
return -1;
}
if (_newWidget != null) {
_newWidget.setParent(sharedFromThis());
}
this.subWidget.insert(this.subWidget.begin(), _newWidget);
markToRedraw();
requestUpdateSize();
return _newWidget.getId();
}
void ewol::widget::ContainerN::subWidgetRemove(Widget _newWidget) {
if (_newWidget == null) {
return;
}
int errorControl = this.subWidget.size();
auto it(this.subWidget.begin());
while (it != this.subWidget.end()) {
if (_newWidget == *it) {
(*it).removeParent();
this.subWidget.erase(it);
it = this.subWidget.begin();
markToRedraw();
requestUpdateSize();
} else {
++it;
}
}
}
void ewol::widget::ContainerN::subWidgetUnLink(Widget _newWidget) {
if (_newWidget == null) {
return;
}
auto it(this.subWidget.begin());
while (it != this.subWidget.end()) {
if (_newWidget == *it) {
(*it).removeParent();
(*it).reset();
this.subWidget.erase(it);
it = this.subWidget.begin();
markToRedraw();
requestUpdateSize();
} else {
++it;
}
}
}
void ewol::widget::ContainerN::subWidgetRemoveAll() {
for(auto it : this.subWidget) {
if (it != null) {
it.removeParent();
}
it.reset();
}
this.subWidget.clear();
}
void ewol::widget::ContainerN::subWidgetRemoveAllDelayed() {
subWidgetRemoveAll();
}
EwolObject ewol::widget::ContainerN::getSubObjectNamed( String _objectName) {
EwolObject tmpObject = Widget::getSubObjectNamed(_objectName);
if (tmpObject != null) {
return tmpObject;
}
for (auto it : this.subWidget) {
if (it != null) {
tmpObject = it.getSubObjectNamed(_objectName);
if (tmpObject != null) {
return tmpObject;
}
}
}
return null;
}
void ewol::widget::ContainerN::systemDraw( ewol::DrawProperty _displayProp) {
if (*propertyHide == true){
// widget is hidden ...
return;
}
// local widget draw
Widget::systemDraw(_displayProp);
// subwidget draw
ewol::DrawProperty prop = _displayProp;
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 : this.subWidget) {
if (it == null) {
continue;
}
it.setOrigin(this.origin+this.offset);
it.setSize(this.size);
it.onChangeSize();
}
}
void ewol::widget::ContainerN::calculateMinMaxSize() {
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();
if (true == subExpendProp.x()) {
this.subExpend.setX(true);
}
if (true == subExpendProp.y()) {
this.subExpend.setY(true);
}
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 : " + this.minSize);
}
void ewol::widget::ContainerN::onRegenerateDisplay() {
for (auto it : this.subWidget) {
if (it != null) {
it.onRegenerateDisplay();
}
}
}
Widget ewol::widget::ContainerN::getWidgetAtPos( Vector2f _pos) {
if (*propertyHide == true) {
return null;
}
// for all element in the sizer ...
for (auto it : this.subWidget) {
if (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()) )
{
Widget tmpWidget = it.getWidgetAtPos(_pos);
if (tmpWidget != null) {
return tmpWidget;
}
// stop searching
break;
}
}
}
return null;
};
boolean ewol::widget::ContainerN::loadXML( exml::Element _node) {
if (_node.exist() == false) {
return false;
}
// parse generic properties :
Widget::loadXML(_node);
// remove previous element :
subWidgetRemoveAll();
String tmpAttributeValue = _node.attributes["lock"];
if (tmpAttributeValue.size()!=0) {
propertyLockExpand.set(tmpAttributeValue);
}
boolean invertAdding=false;
tmpAttributeValue = _node.attributes["addmode"];
if(etk::compare_no_case(tmpAttributeValue, "invert")) {
invertAdding=true;
}
// parse all the elements :
for ( auto nodeIt : _node.nodes) {
exml::Element pNode = nodeIt.toElement();
if (pNode.exist() == false) {
// trash here all that is not element
continue;
}
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() << "]" );
continue;
}
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 + "'");
continue;
}
// add sub element :
if (invertAdding == false) {
subWidgetAdd(subWidget);
} else {
subWidgetAddStart(subWidget);
}
if (subWidget.loadXML(pNode) == false) {
Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'");
return false;
}
}
return true;
}
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( EwolObject _child) {
auto it = this.subWidget.begin();
while (it != this.subWidget.end()) {
if (*it == _child) {
if (*it == null) {
this.subWidget.erase(it);
it = this.subWidget.begin();
continue;
}
(*it).removeParent();
(*it).reset();
this.subWidget.erase(it);
it = this.subWidget.begin();
markToRedraw();
continue;
}
++it;
}
}
void ewol::widget::ContainerN::drawWidgetTree(int _level) {
Widget::drawWidgetTree(_level);
_level++;
for (auto it: this.subWidget) {
if (it != null) {
it.drawWidgetTree(_level);
}
}
}

View File

@ -1,70 +1,122 @@
/** @file package org.atriasoft.ewol.widget; /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once
#include <etk/types.hpp> import org.atriasoft.etk.math.Vector2b;
#include <ewol/debug.hpp> import org.atriasoft.ewol.DrawProperty;
#include <ewol/widget/Widget.hpp> import org.atriasoft.ewol.annotation.EwolDescription;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
import org.atriasoft.exml.annotation.XmlProperty;
namespace ewol { import java.util.ArrayList;
namespace widget { import java.util.List;
class ContainerN;
using ContainerN = ememory::Ptr<ewol::widget::ContainerN>; /**
using ContainerNWeak = ememory::WeakPtr<ewol::widget::ContainerN>;
/**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
* @brief the Cotainer widget is a widget that have an only one subWidget * @brief the Cotainer widget is a widget that have an only one subWidget
*/ */
class ContainerN : public Widget { public class ContainerN extends Widget {
public: // properties: @XmlManaged()
eproperty::Value<Vector2b> propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget @XmlProperty()
protected: @XmlName(value = "lock")
List<Widget> this.subWidget; @EwolDescription(value = "Lock the subwidget expand")
protected: protected Vector2b propertyLockExpand = new Vector2b(false,false); //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
protected List<Widget> subWidget = new ArrayList<>();
protected Vector2b subExpend = new Vector2b(false,false); //!< reference of the sub element expention requested.
/** /**
* @brief Constructor * @brief Constructor
*/ */
ContainerN(); protected ContainerN() {}
public:
/**
* @brief Destructor
*/
~ContainerN();
protected:
Vector2b this.subExpend; //!< reference of the sub element expention requested.
// herited function // herited function
Vector2b canExpand() ; public Vector2b canExpand() {
public: Vector2b res = propertyExpand;
if (!propertyLockExpand.x()) {
if (this.subExpend.x()) {
res = res.withX(true);
}
}
if (!propertyLockExpand.y()) {
if (this.subExpend.y()) {
res = res.withY(true);
}
}
//Log.debug("Expend check : user=" + this.userExpand + " lock=" + propertyLockExpand + " sub=" + this.subExpend + " res=" + res);
return res;
}
/** /**
* @brief remove all sub element from the widget. * @brief remove all sub element from the widget.
*/ */
void subWidgetRemoveAll(); public void subWidgetRemoveAll(){
for(Widget it : this.subWidget) {
if (it != null) {
it.removeParent();
}
it = null;
}
this.subWidget.clear();
}
/** /**
* @brief remove all sub element from the widget (delayed to prevent remove in the callbback). * @brief remove all sub element from the widget (delayed to prevent remove in the callbback).
*/ */
void subWidgetRemoveAllDelayed(); public void subWidgetRemoveAllDelayed(){
subWidgetRemoveAll();
}
/** /**
* @brief Replace a old subwidget with a new one. * @brief Replace a old subwidget with a new one.
* @param[in] _oldWidget The widget to replace. * @param[in] _oldWidget The widget to replace.
* @param[in] _newWidget The widget to set. * @param[in] _newWidget The widget to set.
*/ */
void subWidgetReplace(Widget _oldWidget, public void subWidgetReplace(Widget _oldWidget,
Widget _newWidget); Widget _newWidget) {
boolean haveChange = false;
for (Widget it : this.subWidget) {
if (it != _oldWidget) {
continue;
}
it.removeParent();
it.reset();
if (_newWidget != null) {
_newWidget.setParent(this);
}
it = _newWidget;
haveChange = true;
}
if (!haveChange) {
Log.warning("Request replace with a wrong old widget");
return;
}
markToRedraw();
requestUpdateSize();
}
/** /**
* @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * @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 * @param[in] _newWidget the element pointer
* @return the ID of the set element * @return the ID of the set element
*/ */
int subWidgetAdd(Widget _newWidget); public int subWidgetAdd(Widget _newWidget) {
if (_newWidget == null) {
Log.error("[" + getId() + "] {" + getClass().getCanonicalName() + "} Try to add An empty Widget ... ");
return -1;
}
_newWidget.setParent(this);
this.subWidget.add(_newWidget);
markToRedraw();
requestUpdateSize();
// added at the last eelement :
return _newWidget.getId();
}
//! @previous //! @previous
int subWidgetAddBack(Widget _newWidget) { public int subWidgetAddBack(Widget _newWidget) {
return subWidgetAdd(_newWidget); return subWidgetAdd(_newWidget);
}; };
//! @previous //! @previous
int subWidgetAddEnd(Widget _newWidget) { public int subWidgetAddEnd(Widget _newWidget) {
return subWidgetAdd(_newWidget); return subWidgetAdd(_newWidget);
}; };
/** /**
@ -72,34 +124,252 @@ namespace ewol {
* @param[in] _newWidget the element pointer * @param[in] _newWidget the element pointer
* @return the ID of the set element * @return the ID of the set element
*/ */
int subWidgetAddStart(Widget _newWidget); public int subWidgetAddStart(Widget _newWidget) {
if (_newWidget == null) {
Log.error("[" + getId() + "] {" + getClass().getCanonicalName() + "} Try to add start An empty Widget ... ");
return -1;
}
if (_newWidget != null) {
_newWidget.setParent(this);
}
this.subWidget.insert(this.subWidget.begin(), _newWidget);
markToRedraw();
requestUpdateSize();
return _newWidget.getId();
}
//! @previous //! @previous
int subWidgetAddFront(Widget _newWidget) { public int subWidgetAddFront(Widget _newWidget) {
return subWidgetAddStart(_newWidget); return subWidgetAddStart(_newWidget);
}; };
/** /**
* @brief remove definitly a widget from the system and this layer. * @brief remove definitly a widget from the system and this layer.
* @param[in] _newWidget the element pointer. * @param[in] _newWidget the element pointer.
*/ */
void subWidgetRemove(Widget _newWidget); public void subWidgetRemove(Widget _newWidget){
if (_newWidget == null) {
return;
}
int errorControl = this.subWidget.size();
auto it(this.subWidget.begin());
while (it != this.subWidget.end()) {
if (_newWidget == *it) {
(*it).removeParent();
this.subWidget.erase(it);
it = this.subWidget.begin();
markToRedraw();
requestUpdateSize();
} else {
++it;
}
}
}
/** /**
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...) * @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. * @param[in] _newWidget the element pointer.
*/ */
void subWidgetUnLink(Widget _newWidget); public void subWidgetUnLink(Widget _newWidget) {
public: if (_newWidget == null) {
void systemDraw( ewol::DrawProperty _displayProp) ; return;
void onRegenerateDisplay() ; }
void onChangeSize() ; auto it(this.subWidget.begin());
void calculateMinMaxSize() ; while (it != this.subWidget.end()) {
Widget getWidgetAtPos( Vector2f _pos) ; if (_newWidget == *it) {
EwolObject getSubObjectNamed( String _objectName) ; (*it).removeParent();
boolean loadXML( exml::Element _node) ; (*it).reset();
void setOffset( Vector2f _newVal) ; this.subWidget.erase(it);
void requestDestroyFromChild( EwolObject _child) ; it = this.subWidget.begin();
void drawWidgetTree(int _level=0) ; markToRedraw();
protected: requestUpdateSize();
void onChangePropertyLockExpand(); } else {
++it;
}
}
}
public void systemDraw( DrawProperty _displayProp) {
if (propertyHide){
// widget is hidden ...
return;
}
// local widget draw
super.systemDraw(_displayProp);
// subwidget draw
DrawProperty prop = _displayProp;
prop = prop.withLimit(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);
}
}
}
public void onRegenerateDisplay(){
for (Widget it : this.subWidget) {
if (it != null) {
it.onRegenerateDisplay();
}
}
}
public void onChangeSize(){
for (Widget it : this.subWidget) {
if (it == null) {
continue;
}
it.setOrigin(this.origin+this.offset);
it.setSize(this.size);
it.onChangeSize();
}
}
public void calculateMinMaxSize() {
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 (Widget it : this.subWidget) {
if (it != null) {
it.calculateMinMaxSize();
Vector2b subExpendProp = it.canExpand();
if (true == subExpendProp.x()) {
this.subExpend.setX(true);
}
if (true == subExpendProp.y()) {
this.subExpend.setY(true);
}
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 : " + this.minSize);
}
public Widget getWidgetAtPos( Vector2f _pos) {
if (*propertyHide == true) {
return null;
}
// for all element in the sizer ...
for (Widget 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()) )
{
Widget tmpWidget = it.getWidgetAtPos(_pos);
if (tmpWidget != null) {
return tmpWidget;
}
// stop searching
break;
}
}
}
return null;
}; };
};
}; public EwolObject getSubObjectNamed( String _objectName) {
EwolObject tmpObject = Widget::getSubObjectNamed(_objectName);
if (tmpObject != null) {
return tmpObject;
}
for (Widget it : this.subWidget) {
if (it != null) {
tmpObject = it.getSubObjectNamed(_objectName);
if (tmpObject != null) {
return tmpObject;
}
}
}
return null;
}
public boolean loadXML( exml::Element _node) {
if (_node.exist() == false) {
return false;
}
// parse generic properties :
Widget::loadXML(_node);
// remove previous element :
subWidgetRemoveAll();
String tmpAttributeValue = _node.attributes["lock"];
if (tmpAttributeValue.size()!=0) {
propertyLockExpand.set(tmpAttributeValue);
}
boolean invertAdding=false;
tmpAttributeValue = _node.attributes["addmode"];
if(etk::compare_no_case(tmpAttributeValue, "invert")) {
invertAdding=true;
}
// parse all the elements :
for ( auto nodeIt : _node.nodes) {
exml::Element pNode = nodeIt.toElement();
if (pNode.exist() == false) {
// trash here all that is not element
continue;
}
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() << "]" );
continue;
}
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 + "'");
continue;
}
// add sub element :
if (invertAdding == false) {
subWidgetAdd(subWidget);
} else {
subWidgetAddStart(subWidget);
}
if (subWidget.loadXML(pNode) == false) {
Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'");
return false;
}
}
return true;
}
public void setOffset( Vector2f _newVal){
if (this.offset != _newVal) {
Widget::setOffset(_newVal);
// recalculate the new sise and position of sub widget ...
onChangeSize();
}
}
public void requestDestroyFromChild( EwolObject _child) {
auto it = this.subWidget.begin();
while (it != this.subWidget.end()) {
if (*it == _child) {
if (*it == null) {
this.subWidget.erase(it);
it = this.subWidget.begin();
continue;
}
(*it).removeParent();
(*it).reset();
this.subWidget.erase(it);
it = this.subWidget.begin();
markToRedraw();
continue;
}
++it;
}
}
public void drawWidgetTree(int _level) {
super.drawWidgetTree(_level);
_level++;
for (Widget it: this.subWidget) {
if (it != null) {
it.drawWidgetTree(_level);
}
}
}
protected void onChangePropertyLockExpand() {
markToRedraw();
requestUpdateSize();
}
}

View File

@ -3,25 +3,11 @@
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once
#include <etk/types.hpp> /**
#include <ewol/debug.hpp>
#include <ewol/compositing/Text.hpp>
#include <ewol/widget/Widget.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/resource/ColorFile.hpp>
#include <esignal/Signal.hpp>
namespace ewol {
namespace widget {
class Label;
using Label = ememory::Ptr<ewol::widget::Label>;
using LabelWeak = ememory::WeakPtr<ewol::widget::Label>;
/**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
class Label : public Widget { class Label extends Widget {
public: // signals public: // signals
esignal::Signal<> signalPressed; esignal::Signal<> signalPressed;
public: // properties public: // properties
@ -58,7 +44,4 @@ namespace ewol {
void onChangePropertyValue(); void onChangePropertyValue();
void onChangePropertyAutoTranslate(); void onChangePropertyAutoTranslate();
void onChangePropertyFontSize(); void onChangePropertyFontSize();
};
};
}; };

View File

@ -1,97 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/ProgressBar.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <ewol/widget/Manager.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::widget::ProgressBar);
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),
propertyTextColorFg(this, "color-bg",
etk::color::black,
"Background color",
ewol::widget::ProgressBar::onChangePropertyTextColorFg),
propertyTextColorBgOn(this, "color-on",
etk::Color<>(0x00, 0xFF, 0x00, 0xFF),
"Color of the true value",
ewol::widget::ProgressBar::onChangePropertyTextColorBgOn),
propertyTextColorBgOff(this, "color-off",
etk::color::none,
"Color of the false value",
ewol::widget::ProgressBar::onChangePropertyTextColorBgOff) {
addObjectType("ewol::widget::ProgressBar");
}
void ewol::widget::ProgressBar::init() {
Widget::init();
propertyCanFocus.set(true);
}
ewol::widget::ProgressBar::~ProgressBar() {
}
void ewol::widget::ProgressBar::calculateMinMaxSize() {
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() {
this.draw.draw();
}
void ewol::widget::ProgressBar::onRegenerateDisplay() {
if (needRedraw() == false) {
return;
}
// clean the object list ...
this.draw.clear();
this.draw.setColor(propertyTextColorFg);
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 ...
//this.draw.setColor(propertyTextColorFg);
//this.draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
}
void ewol::widget::ProgressBar::onChangePropertyValue() {
markToRedraw();
}
void ewol::widget::ProgressBar::onChangePropertyTextColorFg() {
markToRedraw();
}
void ewol::widget::ProgressBar::onChangePropertyTextColorBgOn() {
markToRedraw();
}
void ewol::widget::ProgressBar::onChangePropertyTextColorBgOff() {
markToRedraw();
}

View File

@ -1,50 +1,127 @@
import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.annotation.EwolDescription;
import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
import org.atriasoft.exml.annotation.XmlProperty;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once class ProgressBar extends Widget {
@XmlManaged()
@XmlProperty()
@XmlName(value = "value")
@EwolDescription(value = "Value of the progress bar [0..1]")
protected float propertyValue = 0;
@XmlManaged()
@XmlProperty()
@XmlName(value = "color-bg")
@EwolDescription(value = "ackground color")
protected Color propertyTextColorFg = Color.BLACK;
@XmlManaged()
@XmlProperty()
@XmlName(value = "color-on")
@EwolDescription(value = "Color of the true value")
protected Color propertyTextColorBgOn = Color.GREEN;
@XmlManaged()
@XmlProperty()
@XmlName(value = "color-off")
@EwolDescription(value = "Color of the false value")
protected Color propertyTextColorBgOff = Color.NONE;
static private final int DOT_RADIUS = 6;
public ProgressBar() {
super();
setPropertyCanFocus(true);
}
#include <etk/types.hpp> private CompositingDrawing draw = new CompositingDrawing(); // basic drawing element
#include <etk/Color.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/Widget.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <ewol/widget/Manager.hpp>
namespace ewol { protected void onDraw() {
namespace widget { this.draw.draw();
class ProgressBar; }
using ProgressBar = ememory::Ptr<ewol::widget::ProgressBar>;
using ProgressBarWeak = ememory::WeakPtr<ewol::widget::ProgressBar>;
/**
* @ingroup ewolWidgetGroup
*/
class ProgressBar : public Widget {
public: // properties
eproperty::Range<float> propertyValue; //!< % used
eproperty::Value<etk::Color<>> propertyTextColorFg; //!< forder bar color
eproperty::Value<etk::Color<>> propertyTextColorBgOn; //!< bar color enable
eproperty::Value<etk::Color<>> propertyTextColorBgOff; //!< bar color disable
protected:
ProgressBar();
void init() ;
public:
DECLARE_WIDGET_FACTORY(ProgressBar, "ProgressBar");
~ProgressBar();
private:
ewol::compositing::Drawing this.draw; // basic drawing element
protected:
void onDraw() ;
public:
void onRegenerateDisplay() ;
void calculateMinMaxSize() ;
protected:
void onChangePropertyValue();
void onChangePropertyTextColorFg();
void onChangePropertyTextColorBgOn();
void onChangePropertyTextColorBgOff();
};
};
};
public void onRegenerateDisplay() {
if (!needRedraw()) {
return;
}
// clean the object list ...
this.draw.clear();
this.draw.setColor(propertyTextColorFg);
int tmpSizeX = (int) (this.size.x() - 10);
int tmpSizeY = (int) (this.size.y() - 10);
int tmpOriginX = 5;
int tmpOriginY = 5;
this.draw.setColor(propertyTextColorBgOn);
this.draw.setPos(new Vector3f(tmpOriginX, tmpOriginY, 0));
this.draw.rectangleWidth(new Vector3f(tmpSizeX * propertyValue, tmpSizeY, 0));
this.draw.setColor(propertyTextColorBgOff);
this.draw.setPos(new Vector3f(tmpOriginX + tmpSizeX * propertyValue, tmpOriginY, 0));
this.draw.rectangleWidth(new Vector3f(tmpSizeX * (1.0f - propertyValue), tmpSizeY, 0));
// TODO : Create a better progress Bar ...
//this.draw.setColor(propertyTextColorFg);
//this.draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
}
public void calculateMinMaxSize() {
Vector2f tmpMin = propertyMinSize.getPixel();
this.minSize = new Vector2f(Math.max(tmpMin.x(), 40.0f),Math.max(tmpMin.y(), DOT_RADIUS * 2.0f) );
markToRedraw();
}
public float getPropertyValue() {
return propertyValue;
}
public void setPropertyValue(float propertyValue) {
if (propertyValue == this.propertyValue) {
return;
}
this.propertyValue = propertyValue;
markToRedraw();
}
public Color getPropertyTextColorFg() {
return propertyTextColorFg;
}
public void setPropertyTextColorFg(Color propertyTextColorFg) {
if (propertyTextColorFg.equals(this.propertyTextColorFg)) {
return;
}
this.propertyTextColorFg = propertyTextColorFg;
markToRedraw();
}
public Color getPropertyTextColorBgOn() {
return propertyTextColorBgOn;
}
public void setPropertyTextColorBgOn(Color propertyTextColorBgOn) {
if (propertyTextColorBgOn.equals(this.propertyTextColorBgOn)) {
return;
}
this.propertyTextColorBgOn = propertyTextColorBgOn;
markToRedraw();
}
public Color getPropertyTextColorBgOff() {
return propertyTextColorBgOff;
}
public void setPropertyTextColorBgOff(Color propertyTextColorBgOff) {
if (propertyTextColorBgOff.equals(this.propertyTextColorBgOff)) {
return;
}
this.propertyTextColorBgOff = propertyTextColorBgOff;
markToRedraw();
}
}

View File

@ -3,66 +3,29 @@
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once /**
#include <etk/types.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/ContainerN.hpp>
#include <ewol/widget/Manager.hpp>
#include <etk/Color.hpp>
#include <ewol/compositing/Drawing.hpp>
namespace ewol {
namespace widget {
class Sizer;
using Sizer = ememory::Ptr<ewol::widget::Sizer>;
using SizerWeak = ememory::WeakPtr<ewol::widget::Sizer>;
/**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
class Sizer : public ewol::widget::ContainerN { public class Sizer extends ContainerN {
public: public enum displayMode {
enum displayMode {
modeVert, //!< Vertical mode modeVert, //!< Vertical mode
modeHori, //!< Horizontal mode modeHori, //!< Horizontal mode
}; };
enum animation { public displayMode propertyMode; //!< Methode to display the widget list (vert/hory ...)
animationNone, //!< No annimation public Dimension propertyBorderSize; //!< Border size needed for all the display
animationTop, //!< element came from the top
animationbuttom, //!< element came from the buttom
animationLeft, //!< element came from the Left
animationRight //!< element came from the right
//animationZoom //!< element came from zooming
};
public: // properties:
eproperty::List<enum displayMode> propertyMode; //!< Methode to display the widget list (vert/hory ...)
eproperty::Value<gale::Dimension> propertyBorderSize; //!< Border size needed for all the display
eproperty::List<enum animation> propertyAnimation; //!< Methode add and remove element (animation)
eproperty::Value<float> propertyAnimationTime; //!< Time in second to generate animation
protected:
/** /**
* @brief Constructor * @brief Constructor
* @param[in] _mode The mode to display the elements * @param[in] _mode The mode to display the elements
*/ */
Sizer(); public Sizer();
public: public void onChangeSize() ;
DECLARE_WIDGET_FACTORY(Sizer, "Sizer"); public void calculateMinMaxSize() ;
/**
* @brief Destructor
*/
~Sizer();
public:
void onChangeSize() ;
void calculateMinMaxSize() ;
// overwrite the set fuction to start annimations ... // overwrite the set fuction to start annimations ...
int subWidgetAdd(Widget _newWidget) ; public int subWidgetAdd(Widget _newWidget) ;
int subWidgetAddStart(Widget _newWidget) ; public int subWidgetAddStart(Widget _newWidget) ;
void subWidgetRemove(Widget _newWidget) ; public void subWidgetRemove(Widget _newWidget) ;
void subWidgetUnLink(Widget _newWidget) ; public void subWidgetUnLink(Widget _newWidget) ;
protected: protected void onChangePropertyMode();
void onChangePropertyMode(); protected void onChangePropertyBorderSize();
void onChangePropertyBorderSize();
};
}
} }

View File

@ -1,50 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/Spacer.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <ewol/widget/Manager.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::widget::Spacer);
ewol::widget::Spacer::Spacer() :
propertyColor(this, "color",
etk::color::none,
"background of the spacer",
ewol::widget::Spacer::onChangePropertyColor) {
addObjectType("ewol::widget::Spacer");
propertyMinSize.setDirectCheck(gale::Dimension(Vector2f(10,10)));
propertyCanFocus.setDirectCheck(true);
}
ewol::widget::Spacer::~Spacer() {
}
void ewol::widget::Spacer::onDraw() {
this.draw.draw();
}
#define BORDER_SIZE_TMP (4)
void ewol::widget::Spacer::onRegenerateDisplay() {
if (false == needRedraw()) {
return;
}
this.draw.clear();
if (propertyColor.a() == 0) {
return;
}
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() {
markToRedraw();
}

View File

@ -1,50 +1,66 @@
package org.atriasoft.ewol.widget;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once
#include <etk/types.hpp> import org.atriasoft.etk.Color;
#include <etk/Color.hpp> import org.atriasoft.etk.math.Vector2f;
#include <ewol/debug.hpp> import org.atriasoft.etk.math.Vector3f;
#include <ewol/widget/Widget.hpp> import org.atriasoft.ewol.annotation.EwolDescription;
#include <ewol/compositing/Drawing.hpp> import org.atriasoft.ewol.compositing.CompositingDrawing;
#include <ewol/widget/Manager.hpp> import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
import org.atriasoft.exml.annotation.XmlProperty;
namespace ewol { /**
namespace widget {
class Spacer;
using Spacer = ememory::Ptr<ewol::widget::Spacer>;
using SpacerWeak = ememory::WeakPtr<ewol::widget::Spacer>;
/**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
class Spacer : public Widget { class Spacer extends Widget {
public: // properties: @XmlManaged()
eproperty::Value<etk::Color<>> propertyColor; //!< Background color @XmlProperty()
protected: @XmlName(value = "color")
@EwolDescription(value = "background of the spacer")
protected Color propertyColor; //!< Background color
/** /**
* @brief Main ructer * @brief Main ructer
*/ */
Spacer(); public Spacer() {
public:
DECLARE_WIDGET_FACTORY(Spacer, "Spacer"); }
/** private CompositingDrawing draw; //!< Compositing drawing element
* @brief Main destructer @Override
*/ public Widget getWidgetAtPos( Vector2f _pos) {
~Spacer();
private:
ewol::compositing::Drawing this.draw; //!< Compositing drawing element
public:
Widget getWidgetAtPos( Vector2f _pos) {
return null; return null;
}; };
void onRegenerateDisplay() ; public void onRegenerateDisplay() {
void onDraw() ; if (!needRedraw()) {
protected: return;
void onChangePropertyColor(); }
}; this.draw.clear();
if (propertyColor.a() == 0) {
return;
}
this.draw.setColor(propertyColor);
this.draw.setPos(Vector3f.ZERO);
this.draw.rectangleWidth(new Vector3f(this.size.x(), this.size.y(),0) );
}
public void onDraw(){
this.draw.draw();
}
public Color getPropertyColor() {
return propertyColor;
}
public void setPropertyTextColorBgOn(Color propertyColor) {
if (propertyColor.equals(this.propertyColor)) {
return;
}
this.propertyColor = propertyColor;
markToRedraw();
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.atriasoft.ewol.internal.Log; import org.atriasoft.ewol.internal.Log;
import org.atriasoft.exml.model.XmlElement;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -56,6 +57,7 @@ public class WidgetManager {
*/ */
public WidgetManager() { public WidgetManager() {
/*
this.creatorList.put("Button", Button.class); this.creatorList.put("Button", Button.class);
this.creatorList.put("ButtonColor", ButtonColor.class); this.creatorList.put("ButtonColor", ButtonColor.class);
this.creatorList.put("Spacer", Spacer.class); this.creatorList.put("Spacer", Spacer.class);
@ -77,6 +79,7 @@ public class WidgetManager {
this.creatorList.put("Composer", Composer.class); this.creatorList.put("Composer", Composer.class);
this.creatorList.put("Select", Select.class); this.creatorList.put("Select", Select.class);
this.creatorList.put("Spin", Spin.class); this.creatorList.put("Spin", Spin.class);
*/
} }
/** /**
@ -120,6 +123,22 @@ public class WidgetManager {
Log.warning("try to create an UnExistant widget : " + nameLower); Log.warning("try to create an UnExistant widget : " + nameLower);
return null; return null;
} }
public Widget create(final String _name, XmlElement node) {
final String nameLower = _name.toLowerCase();
final Class<?> it = this.creatorList.get(nameLower);
if (it != null) {
try {
Widget tmp = (Widget) it.getConstructor().newInstance();
tmp.loadXML(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;
}
/** /**
* @brief Check if an Widget exist * @brief Check if an Widget exist
@ -160,15 +179,11 @@ public class WidgetManager {
focusWidgetCurrent.rmFocus(); focusWidgetCurrent.rmFocus();
focusWidgetCurrent = null; focusWidgetCurrent = null;
} }
if (_newWidget.propertyCanFocus == false) { if (!_newWidget.propertyCanFocus) {
Log.debug("Widget can not have focus, id=" + _newWidget.getId()); Log.debug("Widget can not have focus, id=" + _newWidget.getId());
return; return;
} }
this.focusWidgetCurrent = new WeakReference<>(_newWidget); this.focusWidgetCurrent = new WeakReference<>(_newWidget);
if (_newWidget != null) {
Log.debug("Set focus on WidgetID=" + _newWidget.getId());
_newWidget.setFocus();
}
} }
/** /**
@ -198,7 +213,7 @@ public class WidgetManager {
* @param[in] _newWidget Widget that might get the focus (when nothing else). * @param[in] _newWidget Widget that might get the focus (when nothing else).
*/ */
public void focusSetDefault(final Widget _newWidget) { public void focusSetDefault(final Widget _newWidget) {
if (_newWidget != null && _newWidget.propertyCanFocus == false) { if ((_newWidget != null) && (!_newWidget.propertyCanFocus)) {
Log.verbose("Widget can not have focus, id=" + _newWidget.getId()); Log.verbose("Widget can not have focus, id=" + _newWidget.getId());
return; return;
} }
@ -240,7 +255,7 @@ public class WidgetManager {
* @brief Mark the display to redraw * @brief Mark the display to redraw
*/ */
public void markDrawingIsNeeded() { public void markDrawingIsNeeded() {
if (this.haveRedraw == true) { if (this.haveRedraw) {
return; return;
} }
this.haveRedraw = true; this.haveRedraw = true;