[FEAT] use Maven a build system root tool

This commit is contained in:
Edouard DUPIN 2024-06-07 09:28:33 +02:00
parent 760fd95b60
commit 730eb4cdfd
71 changed files with 2808 additions and 2506 deletions

View File

@ -1,52 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"> <classpathentry including="**/*.java" kind="src" output="out/maven/classes" path="src">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" path="resources"/> <classpathentry kind="src" output="out/maven/test-classes" path="test/src">
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
<attributes> <attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="atriasoft-ewol/lib"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
</attributes> <attribute name="maven.pomderived" value="true"/>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-esignal"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-gale"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-exml"> <classpathentry kind="output" path="out/maven/classes"/>
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/loader3d">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-ejson">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/>
</classpath> </classpath>

View File

@ -1,41 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>atriasoft-ewol</name> <name>ewol</name>
<comment></comment> <comment></comment>
<projects> <projects>
<project>atriasoft-ewol</project>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures> </natures>
<filteredResources>
<filter>
<id>1646149232192</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription> </projectDescription>

View File

@ -14,5 +14,5 @@ list_elem = [
] ]
for elem in list_elem: for elem in list_elem:
bpy.ops.wm.open_mainfile(filepath="/home/heero/dev/WORKSPACE-game/jatria-soft/ewol/blender_files/" + elem + ".blend") bpy.ops.wm.open_mainfile(filepath="/home/heero/dev/WORKSPACE-game/org.atriasoft/ewol/blender_files/" + elem + ".blend")
bpy.ops.export_scene.emf(filepath="/home/heero/dev/WORKSPACE-game/jatria-soft/ewol/resources/resources/ewol/theme/shape/" + elem + ".emf") bpy.ops.export_scene.emf(filepath="/home/heero/dev/WORKSPACE-game/org.atriasoft/ewol/resources/resources/ewol/theme/shape/" + elem + ".emf")

View File

@ -1,17 +0,0 @@
<?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$/resources" type="java-resource" />
<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" 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

@ -34,7 +34,7 @@ def configure(target, my_module):
'src/module-info.java', 'src/module-info.java',
'src/org/atriasoft/ewol/DrawProperty.java', 'src/org/atriasoft/ewol/DrawProperty.java',
'src/org/atriasoft/ewol/internal/LoadPackageStream.java', 'src/org/atriasoft/ewol/internal/LoadPackageStream.java',
'src/org/atriasoft/ewol/internal/Log.java', 'src/org/atriasoft/ewol/internal/LOGGER.java',
'src/org/atriasoft/ewol/context/EwolContext.java', 'src/org/atriasoft/ewol/context/EwolContext.java',
'src/org/atriasoft/ewol/context/EwolApplication.java', 'src/org/atriasoft/ewol/context/EwolApplication.java',
'src/org/atriasoft/ewol/context/InputManager.java', 'src/org/atriasoft/ewol/context/InputManager.java',

View File

@ -65,7 +65,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() {
if (needRedraw() == false) { if (needRedraw() == false) {
return; return;
} }
Log.debug("redraw"); LOGGER.debug("redraw");
this.text.clear(); this.text.clear();
this.shaper.clear(); this.shaper.clear();
@ -144,7 +144,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
} }
} }
boolean previousPressed = this.buttonPressed; boolean previousPressed = this.buttonPressed;
//Log.debug("Event on BT ... mouse position : " + this.mouseHover); //LOGGER.debug("Event on BT ... mouse position : " + this.mouseHover);
if (true == this.mouseHover) { if (true == this.mouseHover) {
if (1 == _event.getId()) { if (1 == _event.getId()) {
if(KeyStatus::down == _event.getStatus()) { if(KeyStatus::down == _event.getStatus()) {
@ -161,7 +161,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
// create a context menu : // create a context menu :
this.widgetContextMenu = ewol::widget::ContextMenu::create(); this.widgetContextMenu = ewol::widget::ContextMenu::create();
if (this.widgetContextMenu == null) { if (this.widgetContextMenu == null) {
Log.error("Allocation Error"); LOGGER.error("Allocation Error");
return true; return true;
} }
Vector2f tmpPos = this.origin + this.selectableAreaPos + this.selectableAreaSize; Vector2f tmpPos = this.origin + this.selectableAreaPos + this.selectableAreaSize;
@ -175,7 +175,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
myColorChooser.signalChange.connect(sharedFromThis(), ewol::widget::ButtonColor::onCallbackColorChange); myColorChooser.signalChange.connect(sharedFromThis(), ewol::widget::ButtonColor::onCallbackColorChange);
ewol::widget::Windows currentWindows = getWindows(); ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) { if (currentWindows == null) {
Log.error("Can not get the curent Windows..."); LOGGER.error("Can not get the curent Windows...");
this.widgetContextMenu.reset(); this.widgetContextMenu.reset();
} else { } else {
currentWindows.popUpWidgetPush(this.widgetContextMenu); currentWindows.popUpWidgetPush(this.widgetContextMenu);

View File

@ -51,7 +51,7 @@ static etk::Color<> s_listColor[NB_BAND_COLOR+1] = {
void ewol::widget::ColorBar::onChangePropertyValue() { void ewol::widget::ColorBar::onChangePropertyValue() {
propertyValue.getDirect().setA(0xFF); propertyValue.getDirect().setA(0xFF);
// estimate the cursor position: // estimate the cursor position:
Log.todo("Later when really needed ..."); LOGGER.info("[TODO] Later when really needed ...");
} }
void ewol::widget::ColorBar::onDraw() { void ewol::widget::ColorBar::onDraw() {
@ -159,7 +159,7 @@ void ewol::widget::ColorBar::onRegenerateDisplay() {
boolean ewol::widget::ColorBar::onEventInput( ewol::event::Input _event) { boolean ewol::widget::ColorBar::onEventInput( ewol::event::Input _event) {
Vector2f relativePos = relativePosition(_event.getPos()); Vector2f relativePos = relativePosition(_event.getPos());
//Log.debug("Event on BT ..."); //LOGGER.debug("Event on BT ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {
relativePos.setValue( etk::avg(0.0f, this.size.x(),relativePos.x()), relativePos.setValue( etk::avg(0.0f, this.size.x(),relativePos.x()),
etk::avg(0.0f, this.size.y(),relativePos.y()) ); etk::avg(0.0f, this.size.y(),relativePos.y()) );
@ -170,11 +170,11 @@ boolean ewol::widget::ColorBar::onEventInput( ewol::event::Input _event) {
relativePos.y()/this.size.y() ); relativePos.y()/this.size.y() );
markToRedraw(); markToRedraw();
// == > try to estimate color // == > try to estimate color
Log.verbose("event on (" + relativePos.x() + "," + relativePos.y() + ")"); LOGGER.trace("event on (" + relativePos.x() + "," + relativePos.y() + ")");
int bandID = (int)(relativePos.x()/(this.size.x()/6)); int bandID = (int)(relativePos.x()/(this.size.x()/6));
float localPos = relativePos.x() - (this.size.x()/6) * bandID; float localPos = relativePos.x() - (this.size.x()/6) * bandID;
float poroportionnalPos = localPos/(this.size.x()/6); float poroportionnalPos = localPos/(this.size.x()/6);
Log.verbose("bandId=" + bandID + " relative pos=" + localPos); LOGGER.trace("bandId=" + bandID + " relative pos=" + localPos);
etk::Color<> estimateColor = etk::color::white; etk::Color<> estimateColor = etk::color::white;
if (s_listColor[bandID].r() == s_listColor[bandID+1].r()) { if (s_listColor[bandID].r() == s_listColor[bandID+1].r()) {
estimateColor.setR(s_listColor[bandID].r()); estimateColor.setR(s_listColor[bandID].r());

View File

@ -59,7 +59,7 @@ void ewol::widget::ContextMenu::onChangeSize() {
markToRedraw(); markToRedraw();
// pop-up fill all the display : // pop-up fill all the display :
ewol::Padding padding = this.shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
Log.verbose("our origin=" + this.origin + " size=" + this.size); LOGGER.trace("our origin=" + this.origin + " size=" + this.size);
if (this.subWidget == null) { if (this.subWidget == null) {
return; return;
} }
@ -115,7 +115,7 @@ void ewol::widget::ContextMenu::onChangeSize() {
} }
break; break;
} }
Log.verbose(" == > sub origin=" + subWidgetOrigin + " size=" + subWidgetSize); LOGGER.trace(" == > sub origin=" + subWidgetOrigin + " size=" + subWidgetSize);
this.subWidget.setOrigin(subWidgetOrigin); this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize); this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize(); this.subWidget.onChangeSize();
@ -128,7 +128,7 @@ void ewol::widget::ContextMenu::calculateMinMaxSize() {
// add padding of the display // add padding of the display
ewol::Padding padding = this.shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
this.minSize += Vector2f(padding.x(), padding.y()); this.minSize += Vector2f(padding.x(), padding.y());
//Log.debug("CalculateMinSize=>>" + this.minSize); //LOGGER.debug("CalculateMinSize=>>" + this.minSize);
markToRedraw(); markToRedraw();
} }
@ -195,7 +195,7 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() {
default: default:
case markRight: case markRight:
case markLeft: case markLeft:
Log.todo("later"); LOGGER.info("[TODO] later");
break; break;
} }

View File

@ -75,7 +75,7 @@ class Joystick extends Widget {
_newRatio = 1; _newRatio = 1;
} }
this.ratio = _newRatio; this.ratio = _newRatio;
Log.info("Set default Joystick ratio at " + this.ratio); LOGGER.info("Set default Joystick ratio at " + this.ratio);
} }
/** /**
* set the Background of the widget joystick * set the Background of the widget joystick
@ -86,7 +86,7 @@ class Joystick extends Widget {
// TODO : check if it existed // TODO : check if it existed
this.background = _imageNameInData; this.background = _imageNameInData;
this.displayBackground = _display; this.displayBackground = _display;
Log.info("Set default Joystick background at " + this.background + " display it=" + this.displayBackground); LOGGER.info("Set default Joystick background at " + this.background + " display it=" + this.displayBackground);
} }
/** /**
* set the Foreground of the widget joystick * set the Foreground of the widget joystick
@ -95,7 +95,7 @@ class Joystick extends Widget {
public void foreground(String _imageNameInData) { public void foreground(String _imageNameInData) {
// TODO : check if it existed // TODO : check if it existed
this.foreground = imageNameInData; this.foreground = imageNameInData;
Log.info("Set default Joystick Foreground at " + this.foreground); LOGGER.info("Set default Joystick Foreground at " + this.foreground);
} }
/** /**
* get the property of the joystick * get the property of the joystick
@ -189,7 +189,7 @@ class Joystick extends Widget {
signalMove.emit(this.angle+M_PI/2); signalMove.emit(this.angle+M_PI/2);
} }
//teta += M_PI/2; //teta += M_PI/2;
//Log.debug("TETA = " + (this.angle*180/M_PI) + " deg distance = " + this.distance); //LOGGER.debug("TETA = " + (this.angle*180/M_PI) + " deg distance = " + this.distance);
return true; return true;
} else if( KeyStatus::up == typeEvent) { } else if( KeyStatus::up == typeEvent) {
if( true == this.lock if( true == this.lock

View File

@ -48,16 +48,16 @@ public class Menu extends Sizer
ewol::widget::Sizer::subWidgetRemoveAll(); ewol::widget::Sizer::subWidgetRemoveAll();
} }
private int subWidgetAdd(Widget _newWidget){ private int subWidgetAdd(Widget _newWidget){
Log.error("Not availlable"); LOGGER.error("Not availlable");
return -1; return -1;
} }
private void subWidgetRemove(Widget _newWidget){ private void subWidgetRemove(Widget _newWidget){
Log.error("Not availlable"); LOGGER.error("Not availlable");
} }
private void subWidgetUnLink(Widget _newWidget){ private void subWidgetUnLink(Widget _newWidget){
Log.error("Not availlable"); LOGGER.error("Not availlable");
} }
protected static final String eventButtonPressed = "menu-local-pressed"; protected static final String eventButtonPressed = "menu-local-pressed";
private boolean loadXML( exml::Element _node) ; private boolean loadXML( exml::Element _node) ;
@ -98,7 +98,7 @@ public class Menu extends Sizer
if (tmpObject.this.parentId == -1) { if (tmpObject.this.parentId == -1) {
ewol::widget::Button myButton = ewol::widget::Button::create(); ewol::widget::Button myButton = ewol::widget::Button::create();
if (myButton == null) { if (myButton == null) {
Log.error("Allocation button error"); LOGGER.error("Allocation button error");
return tmpObject.this.localId; return tmpObject.this.localId;
} }
if (tmpObject.this.image.size()!=0) { if (tmpObject.this.image.size()!=0) {
@ -137,7 +137,7 @@ public class Menu extends Sizer
if (tmpObject.this.parentId == -1) { if (tmpObject.this.parentId == -1) {
ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Allocation spacer error"); LOGGER.error("Allocation spacer error");
return tmpObject.this.localId; return tmpObject.this.localId;
} }
mySpacer.propertyExpand.set(Vector2b(true,true)); mySpacer.propertyExpand.set(Vector2b(true,true));
@ -153,7 +153,7 @@ public class Menu extends Sizer
} }
public void remove(int _id){ public void remove(int _id){
Log.todo("NOT remove..."); LOGGER.info("[TODO] NOT remove...");
} }
@ -169,17 +169,17 @@ public class Menu extends Sizer
} }
// 2 posible case (have a message or have a child ... // 2 posible case (have a message or have a child ...
if (it.this.message.size() > 0) { if (it.this.message.size() > 0) {
Log.debug("Menu == > generate Event"); LOGGER.debug("Menu == > generate Event");
// Send a multicast event ... // Send a multicast event ...
signalSelect.emit(it.this.message); signalSelect.emit(it.this.message);
ewol::widget::ContextMenu tmpContext = this.widgetContextMenu.lock(); ewol::widget::ContextMenu tmpContext = this.widgetContextMenu.lock();
if (tmpContext != null) { if (tmpContext != null) {
Log.debug("Mark the menu to remove ..."); LOGGER.debug("Mark the menu to remove ...");
tmpContext.destroy(); tmpContext.destroy();
} }
return; return;
} }
Log.debug("Menu == > load Sub Menu"); LOGGER.debug("Menu == > load Sub Menu");
boolean findChild = false; boolean findChild = false;
for (auto it2 : this.listElement) { for (auto it2 : this.listElement) {
if (it.this.localId == it2.this.parentId) { if (it.this.localId == it2.this.parentId) {
@ -188,14 +188,14 @@ public class Menu extends Sizer
} }
} }
if (false == findChild) { if (false == findChild) {
Log.warning("Event on menu element with no child an no event... label=" + it.this.label); LOGGER.warn("Event on menu element with no child an no event... label=" + it.this.label);
return; return;
} }
// create a context menu: // create a context menu:
ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create(); ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create();
this.widgetContextMenu = tmpContext; this.widgetContextMenu = tmpContext;
if (tmpContext == null) { if (tmpContext == null) {
Log.error("Allocation Error"); LOGGER.error("Allocation Error");
return; return;
} }
// get the button widget: // get the button widget:
@ -235,7 +235,7 @@ public class Menu extends Sizer
if (this.listElement[iii].this.message == "" LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listElement[iii].this.label == "") { if (this.listElement[iii].this.message == "" LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listElement[iii].this.label == "") {
ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Allocation spacer error"); LOGGER.error("Allocation spacer error");
continue; continue;
} }
mySpacer.propertyExpand.set(Vector2b(true,true)); mySpacer.propertyExpand.set(Vector2b(true,true));
@ -248,7 +248,7 @@ public class Menu extends Sizer
} else { } else {
myButton = ewol::widget::Button::create(); myButton = ewol::widget::Button::create();
if (myButton == null) { if (myButton == null) {
Log.error("Allocation Error"); LOGGER.error("Allocation Error");
continue; continue;
} }
myButton.propertyExpand.set(Vector2b(true,true)); myButton.propertyExpand.set(Vector2b(true,true));
@ -293,7 +293,7 @@ public class Menu extends Sizer
} }
ewol::widget::Windows currentWindows = getWindows(); ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) { if (currentWindows == null) {
Log.error("Can not get the curent Windows..."); LOGGER.error("Can not get the curent Windows...");
} else { } else {
currentWindows.popUpWidgetPush(tmpContext); currentWindows.popUpWidgetPush(tmpContext);
} }
@ -316,7 +316,7 @@ boolean ewol::widget::Menu::loadXML( exml::Element _node) {
continue; continue;
} }
String widgetName = pNode.getValue(); String widgetName = pNode.getValue();
Log.info("Get node : " + pNode); LOGGER.info("Get node : " + pNode);
if (widgetName == "elem") { if (widgetName == "elem") {
// <elem title="_T{Title of the button}" image="DATA:///List.svg" event="menu:exit"> // <elem title="_T{Title of the button}" image="DATA:///List.svg" event="menu:exit">
int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]); int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]);
@ -334,13 +334,13 @@ boolean ewol::widget::Menu::loadXML( exml::Element _node) {
} else if (widgetName2 == "separator") { } else if (widgetName2 == "separator") {
addSpacer(idMenu); addSpacer(idMenu);
} else { } else {
Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode2.getPos() + ") Unknown basic node='" + widgetName2 + "' not in : [elem,separator]" ); LOGGER.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode2.getPos() + ") Unknown basic node='" + widgetName2 + "' not in : [elem,separator]" );
} }
} }
} else if (widgetName == "separator") { } else if (widgetName == "separator") {
addSpacer(); addSpacer();
} else { } else {
Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [elem,separator]" ); LOGGER.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [elem,separator]" );
} }
} }
return true; return true;

View File

@ -72,7 +72,7 @@ class Select extends SpinBase {
protected List<ewol::widget::Select::Element> this.listElement; protected List<ewol::widget::Select::Element> this.listElement;
public void optionSelectDefault(){ public void optionSelectDefault(){
if (this.widgetEntry == null) { if (this.widgetEntry == null) {
Log.error("Can not acces at entry ..."); LOGGER.error("Can not acces at entry ...");
return; return;
} }
for (auto it : this.listElement) { for (auto it : this.listElement) {
@ -88,7 +88,7 @@ class Select extends SpinBase {
public void optionRemove(int _value){ public void optionRemove(int _value){
for (auto it=this.listElement.begin(); it != this.listElement.end(); ++it) { for (auto it=this.listElement.begin(); it != this.listElement.end(); ++it) {
if (_value == it.this.value) { if (_value == it.this.value) {
Log.debug("remove element: " + _value); LOGGER.debug("remove element: " + _value);
this.listElement.erase(it); this.listElement.erase(it);
break; break;
} }
@ -104,7 +104,7 @@ class Select extends SpinBase {
public void optionAdd(int _value, String _name) { public void optionAdd(int _value, String _name) {
for (auto it : this.listElement) { for (auto it : this.listElement) {
if (_value == it.this.value) { if (_value == it.this.value) {
Log.debug("replace element: " + _value + " with: '" + _data + "'"); LOGGER.debug("replace element: " + _value + " with: '" + _data + "'");
it.this.name = _data; it.this.name = _data;
} }
} }
@ -127,7 +127,7 @@ class Select extends SpinBase {
continue; continue;
} }
if (pNode.getValue() != "option") { if (pNode.getValue() != "option") {
Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + pNode.getValue() + "' not in : [option]" ); LOGGER.error("(l " + pNode.getPos() + ") Unknown basic node='" + pNode.getValue() + "' not in : [option]" );
continue; continue;
} }
String valId = pNode.attributes["id"]; String valId = pNode.attributes["id"];
@ -139,7 +139,7 @@ class Select extends SpinBase {
if (select == true) { if (select == true) {
propertyValue.set(id); propertyValue.set(id);
} }
Log.warning("Add option : id='" + valId + "' select='" + valIsSelected + "' text='" + valText + "'"); LOGGER.warn("Add option : id='" + valId + "' select='" + valIsSelected + "' text='" + valText + "'");
} }
return true; return true;
} }
@ -161,7 +161,7 @@ class Select extends SpinBase {
// create a context menu: // create a context menu:
ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create(); ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create();
if (tmpContext == null) { if (tmpContext == null) {
Log.error("Allocation Error"); LOGGER.error("Allocation Error");
return; return;
} }
// auto-select mark position: // auto-select mark position:
@ -169,7 +169,7 @@ class Select extends SpinBase {
ewol::widget::Sizer mySizer; ewol::widget::Sizer mySizer;
mySizer = ewol::widget::Sizer::create(); mySizer = ewol::widget::Sizer::create();
if (mySizer == null) { if (mySizer == null) {
Log.error("Allocation Error or sizer"); LOGGER.error("Allocation Error or sizer");
return; return;
} }
mySizer.propertyMode.set(widget::Sizer::modeVert); mySizer.propertyMode.set(widget::Sizer::modeVert);
@ -180,7 +180,7 @@ class Select extends SpinBase {
for (auto it : this.listElement) { for (auto it : this.listElement) {
ewol::widget::Label myLabel = ewol::widget::Label::create(); ewol::widget::Label myLabel = ewol::widget::Label::create();
if (myLabel == null) { if (myLabel == null) {
Log.error("Allocation Error"); LOGGER.error("Allocation Error");
continue; continue;
} }
if (it.this.selected == true) { if (it.this.selected == true) {
@ -198,13 +198,13 @@ class Select extends SpinBase {
} }
ewol::widget::Windows currentWindows = getWindows(); ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) { if (currentWindows == null) {
Log.error("Can not get the curent Windows..."); LOGGER.error("Can not get the curent Windows...");
} else { } else {
currentWindows.popUpWidgetPush(tmpContext); currentWindows.popUpWidgetPush(tmpContext);
} }
} }
protected void onCallbackLabelPressed(int _value){ protected void onCallbackLabelPressed(int _value){
Log.verbose("User select:" + _value); LOGGER.trace("User select:" + _value);
propertyValue.set(_value); propertyValue.set(_value);
} }
protected esignal::Connection connectionEntry = null; protected esignal::Connection connectionEntry = null;
@ -212,7 +212,7 @@ class Select extends SpinBase {
protected void onChangePropertyValue(){ protected void onChangePropertyValue(){
markToRedraw(); markToRedraw();
if (this.widgetEntry == null) { if (this.widgetEntry == null) {
Log.error("Can not acces at entry ..."); LOGGER.error("Can not acces at entry ...");
return; return;
} }
for (auto it : this.listElement) { for (auto it : this.listElement) {

View File

@ -124,7 +124,7 @@ void ewol::widget::TreeView::drawElement( Vector2i _pos, Vector2f _start, Vect
tmpImage.setPos(posStart); tmpImage.setPos(posStart);
tmpImage.print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get())); tmpImage.print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get()));
} else { } else {
Log.error("can not get : " + iconName ); LOGGER.error("can not get : " + iconName );
} }
// move right // move right
posStart.setX(posStart.x() + propertyIconTreeViewSize.get()); posStart.setX(posStart.x() + propertyIconTreeViewSize.get());
@ -161,7 +161,7 @@ boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2
if (_pos.x() != 0) { if (_pos.x() != 0) {
return false; return false;
} }
//Log.info("event: " + _event); //LOGGER.info("event: " + _event);
Vector2f posStart = Vector2f(0,0); Vector2f posStart = Vector2f(0,0);
boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean(); boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean();
if (haveChild == false) { if (haveChild == false) {
@ -172,7 +172,7 @@ boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2
posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get()); posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get());
} }
// Inverse the display of Y // Inverse the display of Y
Log.verbose("check: " + Vector2f(_mousePosition.x(), this.listSizeY[_pos.y()] - _mousePosition.y()) LOGGER.trace("check: " + Vector2f(_mousePosition.x(), this.listSizeY[_pos.y()] - _mousePosition.y())
+ " in " + posStart + " in " + posStart
+ " . " + (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get()))); + " . " + (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get())));
if ( _mousePosition.x() >= posStart.x() if ( _mousePosition.x() >= posStart.x()

View File

@ -104,7 +104,7 @@ void ewol::widget::WSlider::onChangeSize() {
void ewol::widget::WSlider::subWidgetSelectSetVectorId(int _id) { void ewol::widget::WSlider::subWidgetSelectSetVectorId(int _id) {
if (_id<0) { if (_id<0) {
Log.error("Can not change to a widget not present : vectID=" + _id); LOGGER.error("Can not change to a widget not present : vectID=" + _id);
return; return;
} }
if (_id != this.windowsDestination) { if (_id != this.windowsDestination) {
@ -143,7 +143,7 @@ void ewol::widget::WSlider::subWidgetSelectSet(int _id) {
void ewol::widget::WSlider::subWidgetSelectSet( Widget _widgetPointer) { void ewol::widget::WSlider::subWidgetSelectSet( Widget _widgetPointer) {
if (_widgetPointer == null) { if (_widgetPointer == null) {
Log.error("Can not change to a widget null"); LOGGER.error("Can not change to a widget null");
return; return;
} }
int iii = 0; int iii = 0;
@ -161,15 +161,15 @@ void ewol::widget::WSlider::subWidgetSelectSet( Widget _widgetPointer) {
} }
iii++; iii++;
} }
Log.error("Can not change to a widget not present"); LOGGER.error("Can not change to a widget not present");
} }
void ewol::widget::WSlider::subWidgetSelectSet( String _widgetName) { void ewol::widget::WSlider::subWidgetSelectSet( String _widgetName) {
if (_widgetName == "") { if (_widgetName == "") {
Log.error("Can not change to a widget with no name (input)"); LOGGER.error("Can not change to a widget with no name (input)");
return; return;
} }
Log.verbose("Select a new sub-widget to dosplay : '" + _widgetName + "'"); LOGGER.trace("Select a new sub-widget to dosplay : '" + _widgetName + "'");
int iii = 0; int iii = 0;
for (auto it : this.subWidget) { for (auto it : this.subWidget) {
if ( it != null if ( it != null
@ -181,10 +181,10 @@ void ewol::widget::WSlider::subWidgetSelectSet( String _widgetName) {
} }
iii++; iii++;
} }
Log.error("Can not change to a widget not present"); LOGGER.error("Can not change to a widget not present");
} }
void ewol::widget::WSlider::periodicCall( ewol::event::Time _event) { void ewol::widget::WSlider::periodicCall( ewol::event::Time _event) {
Log.error("Periodic: " + this.slidingProgress + "/1.0 " + this.windowsSources + " ==> " + this.windowsDestination + " " + _event); LOGGER.error("Periodic: " + this.slidingProgress + "/1.0 " + this.windowsSources + " ==> " + this.windowsDestination + " " + _event);
if (this.slidingProgress >= 1.0) { if (this.slidingProgress >= 1.0) {
this.windowsSources = this.windowsDestination; this.windowsSources = this.windowsDestination;
if( this.windowsRequested != -1 if( this.windowsRequested != -1
@ -230,16 +230,16 @@ void ewol::widget::WSlider::systemDraw( ewol::DrawProperty _displayProp) {
prop.limit(this.origin, this.size); prop.limit(this.origin, this.size);
if (this.windowsDestination == this.windowsSources) { if (this.windowsDestination == this.windowsSources) {
//Log.debug("Draw : " + this.windowsDestination); //LOGGER.debug("Draw : " + this.windowsDestination);
auto it = this.subWidget.begin(); auto it = this.subWidget.begin();
it += this.windowsDestination; it += this.windowsDestination;
if ( it != this.subWidget.end() if ( it != this.subWidget.end()
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) {
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + "o=" + this.origin + " s=" + this.size); //LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + "o=" + this.origin + " s=" + this.size);
(*it).systemDraw(prop); (*it).systemDraw(prop);
} }
} else { } else {
//Log.debug("Draw : " + this.windowsSources + "=>" + this.windowsDestination + "progress=" + ((float)this.slidingProgress/1000.) ); //LOGGER.debug("Draw : " + this.windowsSources + "=>" + this.windowsDestination + "progress=" + ((float)this.slidingProgress/1000.) );
// draw Sources : // draw Sources :
auto it = this.subWidget.begin(); auto it = this.subWidget.begin();
it += this.windowsSources; it += this.windowsSources;
@ -283,7 +283,7 @@ void ewol::widget::WSlider::onRegenerateDisplay() {
void ewol::widget::WSlider::onChangePropertySelectWidget() { void ewol::widget::WSlider::onChangePropertySelectWidget() {
if (propertySelectWidget.get() != "") { if (propertySelectWidget.get() != "") {
Log.error("SELECT new widget: " + propertySelectWidget.get()); LOGGER.error("SELECT new widget: " + propertySelectWidget.get());
subWidgetSelectSet(*propertySelectWidget); subWidgetSelectSet(*propertySelectWidget);
} }
} }

View File

@ -44,9 +44,9 @@ void ewol::widget::Parameter::init() {
mySizerVert = ewol::widget::Sizer::create(); mySizerVert = ewol::widget::Sizer::create();
if (mySizerVert == null) { if (mySizerVert == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
Log.info("add widget"); LOGGER.info("add widget");
mySizerVert.propertyMode.set(widget::Sizer::modeVert); mySizerVert.propertyMode.set(widget::Sizer::modeVert);
mySizerVert.propertyLockExpand.set(Vector2b(true,true)); mySizerVert.propertyLockExpand.set(Vector2b(true,true));
mySizerVert.propertyExpand.set(Vector2b(true,true)); mySizerVert.propertyExpand.set(Vector2b(true,true));
@ -55,14 +55,14 @@ void ewol::widget::Parameter::init() {
mySizerHori = ewol::widget::Sizer::create(); mySizerHori = ewol::widget::Sizer::create();
if (mySizerHori == null) { if (mySizerHori == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySizerHori.propertyMode.set(widget::Sizer::modeHori); mySizerHori.propertyMode.set(widget::Sizer::modeHori);
mySizerVert.subWidgetAdd(mySizerHori); mySizerVert.subWidgetAdd(mySizerHori);
mySpacer = ewol::widget::Spacer::create(); mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySpacer.propertyExpand.set(Vector2b(true,false)); mySpacer.propertyExpand.set(Vector2b(true,false));
mySizerHori.subWidgetAdd(mySpacer); mySizerHori.subWidgetAdd(mySpacer);
@ -70,7 +70,7 @@ void ewol::widget::Parameter::init() {
ewol::widget::Button tmpButton = widget::Button::create(); ewol::widget::Button tmpButton = widget::Button::create();
if (tmpButton == null) { if (tmpButton == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
tmpButton.setSubWidget(ewol::widget::composerGenerateString( tmpButton.setSubWidget(ewol::widget::composerGenerateString(
"<sizer mode='hori'>\n" "<sizer mode='hori'>\n"
@ -83,7 +83,7 @@ void ewol::widget::Parameter::init() {
mySpacer = ewol::widget::Spacer::create(); mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySpacer.propertyExpand.set(Vector2b(false,false)); mySpacer.propertyExpand.set(Vector2b(false,false));
mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(10,0))); mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(10,0)));
@ -92,7 +92,7 @@ void ewol::widget::Parameter::init() {
tmpButton = ewol::widget::Button::create(); tmpButton = ewol::widget::Button::create();
if (tmpButton == null) { if (tmpButton == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
tmpButton.setSubWidget(ewol::widget::composerGenerateString( tmpButton.setSubWidget(ewol::widget::composerGenerateString(
"<sizer mode='hori'>\n" "<sizer mode='hori'>\n"
@ -106,14 +106,14 @@ void ewol::widget::Parameter::init() {
mySizerHori = ewol::widget::Sizer::create(); mySizerHori = ewol::widget::Sizer::create();
if (mySizerHori == null) { if (mySizerHori == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySizerHori.propertyMode.set(widget::Sizer::modeHori); mySizerHori.propertyMode.set(widget::Sizer::modeHori);
mySizerVert.subWidgetAdd(mySizerHori); mySizerVert.subWidgetAdd(mySizerHori);
this.paramList = ewol::widget::ParameterList::create(); this.paramList = ewol::widget::ParameterList::create();
if (this.paramList == null) { if (this.paramList == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
this.paramList.signalSelect.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackMenuSelected); this.paramList.signalSelect.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackMenuSelected);
@ -123,7 +123,7 @@ void ewol::widget::Parameter::init() {
} }
mySpacer = ewol::widget::Spacer::create(); mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySpacer.propertyFill.set(Vector2b(false,true)); mySpacer.propertyFill.set(Vector2b(false,true));
mySpacer.propertyMinSize.set(Vector2f(5,5)); mySpacer.propertyMinSize.set(Vector2f(5,5));
@ -133,14 +133,14 @@ void ewol::widget::Parameter::init() {
ewol::widget::Sizer mySizerVert2 = widget::Sizer::create(); ewol::widget::Sizer mySizerVert2 = widget::Sizer::create();
if (mySizerVert2 == null) { if (mySizerVert2 == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySizerVert2.propertyMode.set(widget::Sizer::modeVert); mySizerVert2.propertyMode.set(widget::Sizer::modeVert);
mySizerHori.subWidgetAdd(mySizerVert2); mySizerHori.subWidgetAdd(mySizerVert2);
mySpacer = ewol::widget::Spacer::create(); mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySpacer.propertyExpand.set(Vector2b(true,false)); mySpacer.propertyExpand.set(Vector2b(true,false));
mySpacer.propertyMinSize.set(Vector2f(5,5)); mySpacer.propertyMinSize.set(Vector2f(5,5));
@ -150,7 +150,7 @@ void ewol::widget::Parameter::init() {
this.wSlider = ewol::widget::WSlider::create(); this.wSlider = ewol::widget::WSlider::create();
if (this.wSlider == null) { if (this.wSlider == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
this.wSlider.propertyTransitionSpeed.set(0.5); this.wSlider.propertyTransitionSpeed.set(0.5);
this.wSlider.propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert); this.wSlider.propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert);
@ -162,7 +162,7 @@ void ewol::widget::Parameter::init() {
mySpacer = ewol::widget::Spacer::create(); mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) { if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
mySpacer.propertyExpand.set(Vector2b(true,false)); mySpacer.propertyExpand.set(Vector2b(true,false));
mySpacer.propertyMinSize.set(Vector2f(5,5)); mySpacer.propertyMinSize.set(Vector2f(5,5));
@ -172,7 +172,7 @@ void ewol::widget::Parameter::init() {
this.widgetTitle = ewol::widget::Label::create(); this.widgetTitle = ewol::widget::Label::create();
if (this.widgetTitle == null) { if (this.widgetTitle == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
this.widgetTitle.propertyValue.set(propertyLabelTitle); this.widgetTitle.propertyValue.set(propertyLabelTitle);
this.widgetTitle.propertyExpand.set(Vector2b(true,false)); this.widgetTitle.propertyExpand.set(Vector2b(true,false));
@ -200,11 +200,11 @@ void ewol::widget::Parameter::onCallbackMenuclosed() {
} }
void ewol::widget::Parameter::onCallbackParameterSave() { void ewol::widget::Parameter::onCallbackParameterSave() {
//ewol::userConfig::Save(); //ewol::userConfig::Save();
Log.todo("Save Parameter !!! "); LOGGER.info("[TODO] Save Parameter !!! ");
} }
void ewol::widget::Parameter::onCallbackMenuSelected( int _value) { void ewol::widget::Parameter::onCallbackMenuSelected( int _value) {
if (this.wSlider != null) { if (this.wSlider != null) {
Log.debug("event on the parameter : Menu-select select ID=" + _value + ""); LOGGER.debug("event on the parameter : Menu-select select ID=" + _value + "");
this.wSlider.subWidgetSelectSet(_value); this.wSlider.subWidgetSelectSet(_value);
} }
} }
@ -216,10 +216,10 @@ void ewol::widget::Parameter::menuAdd(String _label, String _image, Widget _asso
if (_associateWidget != null) { if (_associateWidget != null) {
this.wSlider.subWidgetAdd(_associateWidget); this.wSlider.subWidgetAdd(_associateWidget);
} else { } else {
Log.debug("Associate an empty widget on it ..."); LOGGER.debug("Associate an empty widget on it ...");
ewol::widget::Label myLabel = widget::Label::create(); ewol::widget::Label myLabel = widget::Label::create();
if (myLabel == null) { if (myLabel == null) {
Log.error("Can not allocate widget == > display might be in error"); LOGGER.error("Can not allocate widget == > display might be in error");
} else { } else {
myLabel.propertyValue.set(String("No widget for : ") + _label); myLabel.propertyValue.set(String("No widget for : ") + _label);
myLabel.propertyExpand.set(Vector2b(true,true)); myLabel.propertyExpand.set(Vector2b(true,true));

View File

@ -52,7 +52,7 @@ void ewol::widget::ParameterList::calculateMinMaxSize() {
void ewol::widget::ParameterList::addOObject( ememory::Ptr<ewol::Compositing> _newObject, int _pos) { void ewol::widget::ParameterList::addOObject( ememory::Ptr<ewol::Compositing> _newObject, int _pos) {
if (_newObject == null) { if (_newObject == null) {
Log.error("Try to add an empty object in the Widget generic display system"); LOGGER.error("Try to add an empty object in the Widget generic display system");
return; return;
} }
if (_pos < 0 || (int)_pos >= this.listOObject.size() ) { if (_pos < 0 || (int)_pos >= this.listOObject.size() ) {
@ -79,7 +79,7 @@ void ewol::widget::ParameterList::onRegenerateDisplay() {
if (needRedraw() == true) { if (needRedraw() == true) {
// clean the object list ... // clean the object list ...
clearOObjectList(); clearOObjectList();
//Log.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")"); //LOGGER.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")");
int tmpOriginX = 0; int tmpOriginX = 0;
int tmpOriginY = 0; int tmpOriginY = 0;
@ -195,17 +195,17 @@ boolean ewol::widget::ParameterList::onEventInput( ewol::event::Input _event) {
} }
void ewol::widget::ParameterList::onGetFocus() { void ewol::widget::ParameterList::onGetFocus() {
Log.debug("Ewol::List get focus"); LOGGER.debug("Ewol::List get focus");
} }
void ewol::widget::ParameterList::onLostFocus() { void ewol::widget::ParameterList::onLostFocus() {
Log.debug("Ewol::List Lost focus"); LOGGER.debug("Ewol::List Lost focus");
} }
void ewol::widget::ParameterList::menuAdd(String _label, int _refId, String _image) { void ewol::widget::ParameterList::menuAdd(String _label, int _refId, String _image) {
ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, _refId, _image, false); ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, _refId, _image, false);
if (tmpEmement == null) { if (tmpEmement == null) {
Log.error("Can not allocacte menu parameter"); LOGGER.error("Can not allocacte menu parameter");
return; return;
} }
this.list.pushBack(tmpEmement); this.list.pushBack(tmpEmement);
@ -219,7 +219,7 @@ void ewol::widget::ParameterList::menuAddGroup(String _label) {
String image = ""; String image = "";
ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, -1, image, true); ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, -1, image, true);
if (tmpEmement == null) { if (tmpEmement == null) {
Log.error("Can not allocacte menu parameter"); LOGGER.error("Can not allocacte menu parameter");
return; return;
} }
this.list.pushBack(tmpEmement); this.list.pushBack(tmpEmement);

View File

@ -104,17 +104,17 @@ void ewol::widget::StdPopUp::onChangePropertyComment() {
ewol::widget::Button ewol::widget::StdPopUp::addButton( String _text, boolean _autoExit) { ewol::widget::Button ewol::widget::StdPopUp::addButton( String _text, boolean _autoExit) {
if (this.subBar == null) { if (this.subBar == null) {
Log.error("button-bar does not existed ..."); LOGGER.error("button-bar does not existed ...");
return null; return null;
} }
ewol::widget::Button myButton = widget::Button::create(); ewol::widget::Button myButton = widget::Button::create();
if (myButton == null) { if (myButton == null) {
Log.error("Can not allocate new button ..."); LOGGER.error("Can not allocate new button ...");
return null; return null;
} }
ewol::widget::Label myLabel = ewol::widget::Label::create(); ewol::widget::Label myLabel = ewol::widget::Label::create();
if (myLabel == null) { if (myLabel == null) {
Log.error("Can not allocate new label ..."); LOGGER.error("Can not allocate new label ...");
return null; return null;
} }
myLabel.propertyValue.set(_text); myLabel.propertyValue.set(_text);

153
pom.xml Normal file
View File

@ -0,0 +1,153 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>ewol</artifactId>
<version>0.1.0</version>
<properties>
<maven.compiler.version>3.13.0</maven.compiler.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.dependency.version>3.1.1</maven.dependency.version>
</properties>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>gale</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>io-gami</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>esvg</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>ejson</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>exml</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>esignal</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>loader3d</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test/src</testSourceDirectory>
<directory>${project.basedir}/out/maven/</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
</configuration>
</plugin>
<!-- Create the source bundle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- junit results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Java-doc generation for stand-alone site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</build>
<!-- Generate Java-docs As Part Of Project Reports -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -177,7 +177,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Dimension2f castedValue) { if (oldValue instanceof final Dimension2f castedValue) {
Log.warning("Set new value: {}", castedValue.withSize(castedValue.size().withX(valueButton))); LOGGER.warn("Set new value: {}", castedValue.withSize(castedValue.size().withX(valueButton)));
pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withX(valueButton))); pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withX(valueButton)));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -209,7 +209,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Dimension2f castedValue) { if (oldValue instanceof final Dimension2f castedValue) {
Log.warning("Set new value: {}", castedValue.withSize(castedValue.size().withY(valueButton))); LOGGER.warn("Set new value: {}", castedValue.withSize(castedValue.size().withY(valueButton)));
pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withY(valueButton))); pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withY(valueButton)));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -253,7 +253,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Dimension3f castedValue) { if (oldValue instanceof final Dimension3f castedValue) {
Log.warning("Set new value: {}", castedValue.withSize(castedValue.size().withX(valueButton))); LOGGER.warn("Set new value: {}", castedValue.withSize(castedValue.size().withX(valueButton)));
pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withX(valueButton))); pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withX(valueButton)));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -285,7 +285,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Dimension3f castedValue) { if (oldValue instanceof final Dimension3f castedValue) {
Log.warning("Set new value: {}", castedValue.withSize(castedValue.size().withY(valueButton))); LOGGER.warn("Set new value: {}", castedValue.withSize(castedValue.size().withY(valueButton)));
pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withY(valueButton))); pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withY(valueButton)));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -317,7 +317,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Dimension3f castedValue) { if (oldValue instanceof final Dimension3f castedValue) {
Log.warning("Set new value: {}", castedValue.withSize(castedValue.size().withZ(valueButton))); LOGGER.warn("Set new value: {}", castedValue.withSize(castedValue.size().withZ(valueButton)));
pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withZ(valueButton))); pojo.setExistingValue(widget, castedValue.withSize(castedValue.size().withZ(valueButton)));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -346,7 +346,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin); this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> { final Connection con = spin.signalValue.connect((valueButton) -> {
try { try {
Log.warning("Set new value: {}", valueButton); LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, (double) valueButton); pojo.setExistingValue(widget, (double) valueButton);
} catch (final AknotException e) { } catch (final AknotException e) {
e.printStackTrace(); e.printStackTrace();
@ -373,7 +373,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin); this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> { final Connection con = spin.signalValue.connect((valueButton) -> {
try { try {
Log.warning("Set new value: {}", valueButton); LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, (float) valueButton); pojo.setExistingValue(widget, (float) valueButton);
} catch (final AknotException e) { } catch (final AknotException e) {
e.printStackTrace(); e.printStackTrace();
@ -430,7 +430,7 @@ public class BasicWindows extends Windows {
state = new Gravity(GravityHorizontal.LEFT, GravityVertical.BOTTOM, GravityDepth.CENTER); state = new Gravity(GravityHorizontal.LEFT, GravityVertical.BOTTOM, GravityDepth.CENTER);
} }
gravLabel.setPropertyValue(LABEL_GRAVITY + state.toString()); gravLabel.setPropertyValue(LABEL_GRAVITY + state.toString());
Log.warning("Set new value: {}", state); LOGGER.warn("Set new value: {}", state);
pojo.setExistingValue(widget, state); pojo.setExistingValue(widget, state);
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -458,7 +458,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin); this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> { final Connection con = spin.signalValue.connect((valueButton) -> {
try { try {
Log.warning("Set new value: {}", valueButton); LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, (int) (long) valueButton); pojo.setExistingValue(widget, (int) (long) valueButton);
} catch (final AknotException e) { } catch (final AknotException e) {
@ -486,7 +486,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin); this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> { final Connection con = spin.signalValue.connect((valueButton) -> {
try { try {
Log.warning("Set new value: {}", valueButton); LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, valueButton); pojo.setExistingValue(widget, valueButton);
} catch (final AknotException e) { } catch (final AknotException e) {
e.printStackTrace(); e.printStackTrace();
@ -513,7 +513,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(element); this.sizerMenu.subWidgetAdd(element);
final Connection con = element.signalModify.connect((valueButton) -> { final Connection con = element.signalModify.connect((valueButton) -> {
try { try {
Log.warning("Set new value: {}", valueButton); LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, valueButton); pojo.setExistingValue(widget, valueButton);
} catch (final AknotException e) { } catch (final AknotException e) {
e.printStackTrace(); e.printStackTrace();
@ -540,7 +540,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(element); this.sizerMenu.subWidgetAdd(element);
final Connection con = element.signalModify.connect((valueButton) -> { final Connection con = element.signalModify.connect((valueButton) -> {
try { try {
Log.warning("Set new value: {}", valueButton); LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, Uri.valueOf(valueButton)); pojo.setExistingValue(widget, Uri.valueOf(valueButton));
} catch (final AknotException e) { } catch (final AknotException e) {
e.printStackTrace(); e.printStackTrace();
@ -574,7 +574,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector2b castedValue) { if (oldValue instanceof final Vector2b castedValue) {
Log.warning("Set new value: {}", castedValue.withX(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withX(valueButton));
pojo.setExistingValue(widget, castedValue.withX(valueButton)); pojo.setExistingValue(widget, castedValue.withX(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -638,7 +638,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector2f castedValue) { if (oldValue instanceof final Vector2f castedValue) {
Log.warning("Set new value: {}", castedValue.withX(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withX(valueButton));
pojo.setExistingValue(widget, castedValue.withX(valueButton)); pojo.setExistingValue(widget, castedValue.withX(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -670,7 +670,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector2f castedValue) { if (oldValue instanceof final Vector2f castedValue) {
Log.warning("Set new value: {}", castedValue.withY(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withY(valueButton));
pojo.setExistingValue(widget, castedValue.withY(valueButton)); pojo.setExistingValue(widget, castedValue.withY(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -714,7 +714,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector2i castedValue) { if (oldValue instanceof final Vector2i castedValue) {
Log.warning("Set new value: {}", castedValue.withX((int) (long) valueButton)); LOGGER.warn("Set new value: {}", castedValue.withX((int) (long) valueButton));
pojo.setExistingValue(widget, castedValue.withX((int) (long) valueButton)); pojo.setExistingValue(widget, castedValue.withX((int) (long) valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -746,7 +746,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector2i castedValue) { if (oldValue instanceof final Vector2i castedValue) {
Log.warning("Set new value: {}", castedValue.withY((int) (long) valueButton)); LOGGER.warn("Set new value: {}", castedValue.withY((int) (long) valueButton));
pojo.setExistingValue(widget, castedValue.withY((int) (long) valueButton)); pojo.setExistingValue(widget, castedValue.withY((int) (long) valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -782,7 +782,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3b castedValue) { if (oldValue instanceof final Vector3b castedValue) {
Log.warning("Set new value: {}", castedValue.withX(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withX(valueButton));
pojo.setExistingValue(widget, castedValue.withX(valueButton)); pojo.setExistingValue(widget, castedValue.withX(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -865,7 +865,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3f castedValue) { if (oldValue instanceof final Vector3f castedValue) {
Log.warning("Set new value: {}", castedValue.withX(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withX(valueButton));
pojo.setExistingValue(widget, castedValue.withX(valueButton)); pojo.setExistingValue(widget, castedValue.withX(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -897,7 +897,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3f castedValue) { if (oldValue instanceof final Vector3f castedValue) {
Log.warning("Set new value: {}", castedValue.withY(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withY(valueButton));
pojo.setExistingValue(widget, castedValue.withY(valueButton)); pojo.setExistingValue(widget, castedValue.withY(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -929,7 +929,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3f castedValue) { if (oldValue instanceof final Vector3f castedValue) {
Log.warning("Set new value: {}", castedValue.withZ(valueButton)); LOGGER.warn("Set new value: {}", castedValue.withZ(valueButton));
pojo.setExistingValue(widget, castedValue.withZ(valueButton)); pojo.setExistingValue(widget, castedValue.withZ(valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -973,7 +973,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3i castedValue) { if (oldValue instanceof final Vector3i castedValue) {
Log.warning("Set new value: {}", castedValue.withX((int) (long) valueButton)); LOGGER.warn("Set new value: {}", castedValue.withX((int) (long) valueButton));
pojo.setExistingValue(widget, castedValue.withX((int) (long) valueButton)); pojo.setExistingValue(widget, castedValue.withX((int) (long) valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -1005,7 +1005,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3i castedValue) { if (oldValue instanceof final Vector3i castedValue) {
Log.warning("Set new value: {}", castedValue.withY((int) (long) valueButton)); LOGGER.warn("Set new value: {}", castedValue.withY((int) (long) valueButton));
pojo.setExistingValue(widget, castedValue.withY((int) (long) valueButton)); pojo.setExistingValue(widget, castedValue.withY((int) (long) valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -1037,7 +1037,7 @@ public class BasicWindows extends Windows {
try { try {
final Object oldValue = pojo.getValue(widget); final Object oldValue = pojo.getValue(widget);
if (oldValue instanceof final Vector3i castedValue) { if (oldValue instanceof final Vector3i castedValue) {
Log.warning("Set new value: {}", castedValue.withZ((int) (long) valueButton)); LOGGER.warn("Set new value: {}", castedValue.withZ((int) (long) valueButton));
pojo.setExistingValue(widget, castedValue.withZ((int) (long) valueButton)); pojo.setExistingValue(widget, castedValue.withZ((int) (long) valueButton));
} }
} catch (final AknotException e) { } catch (final AknotException e) {
@ -1051,40 +1051,40 @@ public class BasicWindows extends Windows {
} }
public void connectAllSignals(final Widget widget, final IntrospectionModelComplex modelPojo) throws Exception { public void connectAllSignals(final Widget widget, final IntrospectionModelComplex modelPojo) throws Exception {
Log.warning("Connect all signal(s) on '{}'", widget.getName()); LOGGER.warn("Connect all signal(s) on '{}'", widget.getName());
final List<IntrospectionProperty> signals = modelPojo.getSignals(); final List<IntrospectionProperty> signals = modelPojo.getSignals();
for (final IntrospectionProperty pojo : signals) { for (final IntrospectionProperty pojo : signals) {
Log.warning(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames())); LOGGER.warn(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames()));
Log.warning(" ==> description='{}'", pojo.getDescription()); LOGGER.warn(" ==> description='{}'", pojo.getDescription());
Log.warning(" ==> type='{}'", pojo.getType()); LOGGER.warn(" ==> type='{}'", pojo.getType());
Log.warning(" ==> sub-type='{}'", pojo.getSubType()); LOGGER.warn(" ==> sub-type='{}'", pojo.getSubType());
final String eventName = pojo.getNames() != null && pojo.getNames().length != 0 ? pojo.getNames()[0] : pojo.getBeanName(); final String eventName = pojo.getNames() != null && pojo.getNames().length != 0 ? pojo.getNames()[0] : pojo.getBeanName();
if (pojo.getSubType() != null && pojo.getType() == Signal.class) { if (pojo.getSubType() != null && pojo.getType() == Signal.class) {
Log.warning(" ** Signal<{}>", pojo.getSubType()); LOGGER.warn(" ** Signal<{}>", pojo.getSubType());
final Object signalObject = pojo.getValue(widget); final Object signalObject = pojo.getValue(widget);
if (signalObject == null) { if (signalObject == null) {
Log.error("Signal is not accessible !!!!!!! "); LOGGER.error("Signal is not accessible !!!!!!! ");
} else { } else {
final String valueNameOfSignal = eventName; final String valueNameOfSignal = eventName;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Signal<Object> tmp = (Signal<Object>) signalObject; final Signal<Object> tmp = (Signal<Object>) signalObject;
tmp.connect((object) -> { tmp.connect((object) -> {
Log.print("Get event from '{}' value='{}'", valueNameOfSignal, object); LOGGER.print("Get event from '{}' value='{}'", valueNameOfSignal, object);
}); });
} }
} }
if (pojo.getSubType() == null && pojo.getType() == SignalEmpty.class) { if (pojo.getSubType() == null && pojo.getType() == SignalEmpty.class) {
Log.warning(" ** SignalEmpty"); LOGGER.warn(" ** SignalEmpty");
final Object signalObject = pojo.getValue(widget); final Object signalObject = pojo.getValue(widget);
if (signalObject == null) { if (signalObject == null) {
Log.error("Signal is not accessible !!!!!!! "); LOGGER.error("Signal is not accessible !!!!!!! ");
} else { } else {
final String valueNameOfSignal = eventName; final String valueNameOfSignal = eventName;
final SignalEmpty tmp = (SignalEmpty) signalObject; final SignalEmpty tmp = (SignalEmpty) signalObject;
tmp.connect(() -> { tmp.connect(() -> {
Log.print("Get event from '{}'", valueNameOfSignal); LOGGER.print("Get event from '{}'", valueNameOfSignal);
}); });
} }
@ -1093,13 +1093,13 @@ public class BasicWindows extends Windows {
} }
public void displayAllPropertyWithType(final Widget widget, final IntrospectionModel modelPojo) throws Exception { public void displayAllPropertyWithType(final Widget widget, final IntrospectionModel modelPojo) throws Exception {
Log.warning("Connect all property(ies) on '{}'", widget.getName()); LOGGER.warn("Connect all property(ies) on '{}'", widget.getName());
final List<IntrospectionProperty> atributes = modelPojo.getAttributes(); final List<IntrospectionProperty> atributes = modelPojo.getAttributes();
for (final IntrospectionProperty pojo : atributes) { for (final IntrospectionProperty pojo : atributes) {
Log.warning(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames())); LOGGER.warn(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames()));
Log.warning(" ==> description='{}'", pojo.getDescription()); LOGGER.warn(" ==> description='{}'", pojo.getDescription());
Log.warning(" ==> type='{}'", pojo.getType()); LOGGER.warn(" ==> type='{}'", pojo.getType());
Log.warning(" ==> sub-type='{}'", pojo.getSubType()); LOGGER.warn(" ==> sub-type='{}'", pojo.getSubType());
final String propertyName = pojo.getNames() != null && pojo.getNames().length != 0 ? pojo.getNames()[0] : pojo.getBeanName(); final String propertyName = pojo.getNames() != null && pojo.getNames().length != 0 ? pojo.getNames()[0] : pojo.getBeanName();
if (pojo.getType() == int.class || pojo.getType() == Integer.class) { if (pojo.getType() == int.class || pojo.getType() == Integer.class) {
addMenuInt(widget, pojo); addMenuInt(widget, pojo);
@ -1130,13 +1130,13 @@ public class BasicWindows extends Windows {
} else if (pojo.getType() == Dimension2f.class) { } else if (pojo.getType() == Dimension2f.class) {
addMenuDimension2f(widget, pojo); addMenuDimension2f(widget, pojo);
} else if (pojo.getType() == DisplayMode.class) { } else if (pojo.getType() == DisplayMode.class) {
Log.error(" ==> plop"); LOGGER.error(" ==> plop");
} else if (pojo.getType() == Uri.class) { } else if (pojo.getType() == Uri.class) {
addMenuURI(widget, pojo); addMenuURI(widget, pojo);
} else if (pojo.getType() == Gravity.class) { } else if (pojo.getType() == Gravity.class) {
addMenuGravity(widget, pojo); addMenuGravity(widget, pojo);
} else { } else {
Log.error(" ==> property type unknown='{}'", pojo.getType()); LOGGER.error(" ==> property type unknown='{}'", pojo.getType());
} }
{ {
final Label simpleLabel = new Label("<b>" + propertyName + ":</b>"); final Label simpleLabel = new Label("<b>" + propertyName + ":</b>");

View File

@ -16,7 +16,7 @@ public class Appl implements EwolApplication {
for (int iii = 0; iii < context.getCmd().size(); iii++) { for (int iii = 0; iii < context.getCmd().size(); iii++) {
String tmpppp = context.getCmd().get(iii); String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") { if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help"); LOGGER.print(" -h/--help display this help");
System.exit(0); System.exit(0);
} }
} }
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override @Override
public void onCreate(final EwolContext context) { public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]"); LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context); localCreate(context);
Log.info("Application onCreate: [ END ]"); LOGGER.info("Application onCreate: [ END ]");
} }
@Override @Override
public void onDestroy(final EwolContext context) { public void onDestroy(final EwolContext context) {
Log.info("Application onDestroy: [BEGIN]"); LOGGER.info("Application onDestroy: [BEGIN]");
Log.info("Application onDestroy: [ END ]"); LOGGER.info("Application onDestroy: [ END ]");
} }
@Override @Override
public void onPause(final EwolContext context) { public void onPause(final EwolContext context) {
Log.info("Application onPause: [BEGIN]"); LOGGER.info("Application onPause: [BEGIN]");
Log.info("Application onPause: [ END ]"); LOGGER.info("Application onPause: [ END ]");
} }
@Override @Override
public void onResume(final EwolContext context) { public void onResume(final EwolContext context) {
Log.info("Application onResume: [BEGIN]"); LOGGER.info("Application onResume: [BEGIN]");
Log.info("Application onResume: [ END ]"); LOGGER.info("Application onResume: [ END ]");
} }
@Override @Override
public void onStart(final EwolContext context) { public void onStart(final EwolContext context) {
Log.info("Application onStart: [BEGIN]"); LOGGER.info("Application onStart: [BEGIN]");
Log.info("Application onStart: [ END ]"); LOGGER.info("Application onStart: [ END ]");
} }
@Override @Override
public void onStop(final EwolContext context) { public void onStop(final EwolContext context) {
Log.info("Application onStop: [BEGIN]"); LOGGER.info("Application onStop: [BEGIN]");
Log.info("Application onStop: [ END ]"); LOGGER.info("Application onStop: [ END ]");
} }
} }

View File

@ -6,15 +6,15 @@ import org.atriasoft.reggol.Logger;
public class Log { public class Log {
private static final boolean FORCE_ALL = false; private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "ewol-sample"; private static final String LIB_NAME = "ewol-sample";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME); private static final String LIB_NAME_DRAW = Logger.getDrawableName(LOGGER.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL); private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG); private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR); private static final boolean PRINT_ERROR = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO); private static final boolean PRINT_INFO = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT); private static final boolean PRINT_PRINT = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.PRINT);
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO); private static final boolean PRINT_TODO = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE); private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING); private static final boolean PRINT_WARNING = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.WARNING);
public static void critical(final Exception e, final String data) { public static void critical(final Exception e, final String data) {
e.printStackTrace(); e.printStackTrace();

View File

@ -16,7 +16,7 @@ public class Appl implements EwolApplication {
for (int iii = 0; iii < context.getCmd().size(); iii++) { for (int iii = 0; iii < context.getCmd().size(); iii++) {
String tmpppp = context.getCmd().get(iii); String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") { if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help"); LOGGER.print(" -h/--help display this help");
System.exit(0); System.exit(0);
} }
} }
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override @Override
public void onCreate(final EwolContext context) { public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]"); LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context); localCreate(context);
Log.info("Application onCreate: [ END ]"); LOGGER.info("Application onCreate: [ END ]");
} }
@Override @Override
public void onDestroy(final EwolContext context) { public void onDestroy(final EwolContext context) {
Log.info("Application onDestroy: [BEGIN]"); LOGGER.info("Application onDestroy: [BEGIN]");
Log.info("Application onDestroy: [ END ]"); LOGGER.info("Application onDestroy: [ END ]");
} }
@Override @Override
public void onPause(final EwolContext context) { public void onPause(final EwolContext context) {
Log.info("Application onPause: [BEGIN]"); LOGGER.info("Application onPause: [BEGIN]");
Log.info("Application onPause: [ END ]"); LOGGER.info("Application onPause: [ END ]");
} }
@Override @Override
public void onResume(final EwolContext context) { public void onResume(final EwolContext context) {
Log.info("Application onResume: [BEGIN]"); LOGGER.info("Application onResume: [BEGIN]");
Log.info("Application onResume: [ END ]"); LOGGER.info("Application onResume: [ END ]");
} }
@Override @Override
public void onStart(final EwolContext context) { public void onStart(final EwolContext context) {
Log.info("Application onStart: [BEGIN]"); LOGGER.info("Application onStart: [BEGIN]");
Log.info("Application onStart: [ END ]"); LOGGER.info("Application onStart: [ END ]");
} }
@Override @Override
public void onStop(final EwolContext context) { public void onStop(final EwolContext context) {
Log.info("Application onStop: [BEGIN]"); LOGGER.info("Application onStop: [BEGIN]");
Log.info("Application onStop: [ END ]"); LOGGER.info("Application onStop: [ END ]");
} }
} }

View File

@ -16,7 +16,7 @@ public class Appl implements EwolApplication {
for (int iii = 0; iii < context.getCmd().size(); iii++) { for (int iii = 0; iii < context.getCmd().size(); iii++) {
String tmpppp = context.getCmd().get(iii); String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") { if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help"); LOGGER.print(" -h/--help display this help");
System.exit(0); System.exit(0);
} }
} }
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override @Override
public void onCreate(final EwolContext context) { public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]"); LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context); localCreate(context);
Log.info("Application onCreate: [ END ]"); LOGGER.info("Application onCreate: [ END ]");
} }
@Override @Override
public void onDestroy(final EwolContext context) { public void onDestroy(final EwolContext context) {
Log.info("Application onDestroy: [BEGIN]"); LOGGER.info("Application onDestroy: [BEGIN]");
Log.info("Application onDestroy: [ END ]"); LOGGER.info("Application onDestroy: [ END ]");
} }
@Override @Override
public void onPause(final EwolContext context) { public void onPause(final EwolContext context) {
Log.info("Application onPause: [BEGIN]"); LOGGER.info("Application onPause: [BEGIN]");
Log.info("Application onPause: [ END ]"); LOGGER.info("Application onPause: [ END ]");
} }
@Override @Override
public void onResume(final EwolContext context) { public void onResume(final EwolContext context) {
Log.info("Application onResume: [BEGIN]"); LOGGER.info("Application onResume: [BEGIN]");
Log.info("Application onResume: [ END ]"); LOGGER.info("Application onResume: [ END ]");
} }
@Override @Override
public void onStart(final EwolContext context) { public void onStart(final EwolContext context) {
Log.info("Application onStart: [BEGIN]"); LOGGER.info("Application onStart: [BEGIN]");
Log.info("Application onStart: [ END ]"); LOGGER.info("Application onStart: [ END ]");
} }
@Override @Override
public void onStop(final EwolContext context) { public void onStop(final EwolContext context) {
Log.info("Application onStop: [BEGIN]"); LOGGER.info("Application onStop: [BEGIN]");
Log.info("Application onStop: [ END ]"); LOGGER.info("Application onStop: [ END ]");
} }
} }

View File

@ -16,7 +16,7 @@ public class Appl implements EwolApplication {
for (int iii = 0; iii < context.getCmd().size(); iii++) { for (int iii = 0; iii < context.getCmd().size(); iii++) {
String tmpppp = context.getCmd().get(iii); String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") { if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help"); LOGGER.print(" -h/--help display this help");
System.exit(0); System.exit(0);
} }
} }
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override @Override
public void onCreate(final EwolContext context) { public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]"); LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context); localCreate(context);
Log.info("Application onCreate: [ END ]"); LOGGER.info("Application onCreate: [ END ]");
} }
@Override @Override
public void onDestroy(final EwolContext context) { public void onDestroy(final EwolContext context) {
Log.info("Application onDestroy: [BEGIN]"); LOGGER.info("Application onDestroy: [BEGIN]");
Log.info("Application onDestroy: [ END ]"); LOGGER.info("Application onDestroy: [ END ]");
} }
@Override @Override
public void onPause(final EwolContext context) { public void onPause(final EwolContext context) {
Log.info("Application onPause: [BEGIN]"); LOGGER.info("Application onPause: [BEGIN]");
Log.info("Application onPause: [ END ]"); LOGGER.info("Application onPause: [ END ]");
} }
@Override @Override
public void onResume(final EwolContext context) { public void onResume(final EwolContext context) {
Log.info("Application onResume: [BEGIN]"); LOGGER.info("Application onResume: [BEGIN]");
Log.info("Application onResume: [ END ]"); LOGGER.info("Application onResume: [ END ]");
} }
@Override @Override
public void onStart(final EwolContext context) { public void onStart(final EwolContext context) {
Log.info("Application onStart: [BEGIN]"); LOGGER.info("Application onStart: [BEGIN]");
Log.info("Application onStart: [ END ]"); LOGGER.info("Application onStart: [ END ]");
} }
@Override @Override
public void onStop(final EwolContext context) { public void onStop(final EwolContext context) {
Log.info("Application onStop: [BEGIN]"); LOGGER.info("Application onStop: [BEGIN]");
Log.info("Application onStop: [ END ]"); LOGGER.info("Application onStop: [ END ]");
} }
} }

View File

@ -16,7 +16,7 @@ public class Appl implements EwolApplication {
for (int iii = 0; iii < context.getCmd().size(); iii++) { for (int iii = 0; iii < context.getCmd().size(); iii++) {
final String tmpppp = context.getCmd().get(iii); final String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") { if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help"); LOGGER.print(" -h/--help display this help");
System.exit(0); System.exit(0);
} }
} }
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override @Override
public void onCreate(final EwolContext context) { public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]"); LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context); localCreate(context);
Log.info("Application onCreate: [ END ]"); LOGGER.info("Application onCreate: [ END ]");
} }
@Override @Override
public void onDestroy(final EwolContext context) { public void onDestroy(final EwolContext context) {
Log.info("Application onDestroy: [BEGIN]"); LOGGER.info("Application onDestroy: [BEGIN]");
Log.info("Application onDestroy: [ END ]"); LOGGER.info("Application onDestroy: [ END ]");
} }
@Override @Override
public void onPause(final EwolContext context) { public void onPause(final EwolContext context) {
Log.info("Application onPause: [BEGIN]"); LOGGER.info("Application onPause: [BEGIN]");
Log.info("Application onPause: [ END ]"); LOGGER.info("Application onPause: [ END ]");
} }
@Override @Override
public void onResume(final EwolContext context) { public void onResume(final EwolContext context) {
Log.info("Application onResume: [BEGIN]"); LOGGER.info("Application onResume: [BEGIN]");
Log.info("Application onResume: [ END ]"); LOGGER.info("Application onResume: [ END ]");
} }
@Override @Override
public void onStart(final EwolContext context) { public void onStart(final EwolContext context) {
Log.info("Application onStart: [BEGIN]"); LOGGER.info("Application onStart: [BEGIN]");
Log.info("Application onStart: [ END ]"); LOGGER.info("Application onStart: [ END ]");
} }
@Override @Override
public void onStop(final EwolContext context) { public void onStop(final EwolContext context) {
Log.info("Application onStop: [BEGIN]"); LOGGER.info("Application onStop: [BEGIN]");
Log.info("Application onStop: [ END ]"); LOGGER.info("Application onStop: [ END ]");
} }
} }

View File

@ -14,7 +14,7 @@ open module org.atriasoft.ewol {
//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;
requires transitive org.atriasoft.esignal; requires transitive org.atriasoft.esignal;
requires transitive org.atriasoft.iogami; requires transitive org.atriasoft.iogami;
requires transitive org.atriasoft.gale; requires transitive org.atriasoft.gale;
@ -22,7 +22,6 @@ open module org.atriasoft.ewol {
requires transitive org.atriasoft.esvg; requires transitive org.atriasoft.esvg;
requires transitive org.atriasoft.exml; requires transitive org.atriasoft.exml;
requires transitive org.atriasoft.ejson; requires transitive org.atriasoft.ejson;
requires transitive org.atriasoft.reggol;
requires org.atriasoft.loader3d; requires org.atriasoft.loader3d;
requires org.atriasoft.egami; requires org.atriasoft.egami;
requires java.base; requires java.base;

View File

@ -8,7 +8,8 @@ import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonNode; import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.model.JsonObject; import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* This is a simple interface to converte application display string in a * This is a simple interface to converte application display string in a
@ -21,6 +22,7 @@ import org.atriasoft.ewol.internal.Log;
* Portuguese, Brazilian : "PT" Chinese : "ZH" * Portuguese, Brazilian : "PT" Chinese : "ZH"
*/ */
public class ETranslate { public class ETranslate {
private static final Logger LOGGER = LoggerFactory.getLogger(ETranslate.class);
private static boolean globalIsInit = false; private static boolean globalIsInit = false;
private static String globalLanguage = ""; private static String globalLanguage = "";
private static String globalLanguageDefault = "EN"; private static String globalLanguageDefault = "EN";
@ -29,13 +31,6 @@ public class ETranslate {
private static Map<String, String> globalTranslate = new HashMap<>(); private static Map<String, String> globalTranslate = new HashMap<>();
private static boolean globalTranslateLoadad = false; private static boolean globalTranslateLoadad = false;
/**
* Initialize etranslate
* @param argc Number of argument list
* @param argv List of arguments
*/
static {}
/** /**
* Set the path folder of the translation files * Set the path folder of the translation files
* @param lib Library name that the path depend * @param lib Library name that the path depend
@ -51,7 +46,7 @@ public class ETranslate {
ETranslate.globalListPath.put(lib, uri); ETranslate.globalListPath.put(lib, uri);
if (major) { if (major) {
ETranslate.globalMajor = lib; ETranslate.globalMajor = lib;
Log.info("Change major translation : '" + ETranslate.globalMajor + "'"); LOGGER.info("Change major translation : '" + ETranslate.globalMajor + "'");
} }
ETranslate.globalTranslateLoadad = false; ETranslate.globalTranslateLoadad = false;
ETranslate.globalTranslate.clear(); ETranslate.globalTranslate.clear();
@ -62,23 +57,23 @@ public class ETranslate {
*/ */
public static void autoDetectLanguage() { public static void autoDetectLanguage() {
if (!ETranslate.globalIsInit) { if (!ETranslate.globalIsInit) {
Log.error("E-translate system has not been init"); LOGGER.error("E-translate system has not been init");
} }
Log.verbose("Auto-detect language of system"); LOGGER.trace("Auto-detect language of system");
final String nonameLocalName = "EN"; final String nonameLocalName = "EN";
final String userLocalName = "EN"; final String userLocalName = "EN";
final String globalLocalName = "EN"; final String globalLocalName = "EN";
/* /*
* try { nonameLocalName = setlocale(LC_ALL, ""); userLocalName = * try { nonameLocalName = setlocale(LC_ALL, ""); userLocalName =
* setlocale(LC_MESSAGES, ""); globalLocalName = setlocale(LC_CTYPE, ""); * setlocale(LC_MESSAGES, ""); globalLocalName = setlocale(LC_CTYPE, "");
* Log.error(" The default locale is '" + globalLocalName + "'"); * LOGGER.error(" The default locale is '" + globalLocalName + "'");
* Log.error(" The user's locale is '" + userLocalName + "'"); * LOGGER.error(" The user's locale is '" + userLocalName + "'");
* Log.error(" A nameless locale is '" + nonameLocalName + "'"); } catch (int * LOGGER.error(" A nameless locale is '" + nonameLocalName + "'"); } catch (int
* e) { * e) {
* // TODO Do it better RuntimeError e) { * // TODO Do it better RuntimeError e) {
* Log.error("Can not get Locals ==> set English ..."); } * LOGGER.error("Can not get Locals ==> set English ..."); }
*/ */
Log.error("Can not get Locals ==> set English ..."); LOGGER.error("Can not get Locals ==> set English ...");
String lang = nonameLocalName; String lang = nonameLocalName;
if (lang.equals("*") || lang.isEmpty()) { if (lang.equals("*") || lang.isEmpty()) {
@ -92,7 +87,7 @@ public class ETranslate {
} }
lang = lang.substring(0, 2); lang = lang.substring(0, 2);
lang = lang.toUpperCase(); lang = lang.toUpperCase();
Log.info("Select Language : '" + lang + "'"); LOGGER.info("Select Language : '" + lang + "'");
ETranslate.setLanguage(lang); ETranslate.setLanguage(lang);
} }
@ -104,14 +99,14 @@ public class ETranslate {
*/ */
public static String get(final String instance) { public static String get(final String instance) {
ETranslate.loadTranslation(); ETranslate.loadTranslation();
Log.verbose("Request translate: '" + instance + "'"); LOGGER.trace("Request translate: '" + instance + "'");
// find all iterance of 'T{' ... '}' // find all iterance of 'T{' ... '}'
final String out = Pattern.compile("_T\\{(.*)\\}").matcher(instance).replaceAll(mr -> { final String out = Pattern.compile("_T\\{(.*)\\}").matcher(instance).replaceAll(mr -> {
final String data = mr.group(1); final String data = mr.group(1);
Log.info("translate : '" + data + "'"); LOGGER.info("translate : '" + data + "'");
final String itTranslate = ETranslate.globalTranslate.get(data); final String itTranslate = ETranslate.globalTranslate.get(data);
if (itTranslate == null) { if (itTranslate == null) {
Log.debug("Can not find tranlation : '" + instance + "'"); LOGGER.debug("Can not find tranlation : '" + instance + "'");
return data; return data;
} }
return itTranslate; return itTranslate;
@ -148,8 +143,9 @@ public class ETranslate {
if (ETranslate.globalTranslateLoadad) { if (ETranslate.globalTranslateLoadad) {
return; return;
} }
Log.debug("Load Translation MAJOR='" + ETranslate.globalMajor + "' LANG='" + ETranslate.globalLanguage + "' default=" + ETranslate.globalLanguageDefault); LOGGER.debug("Load Translation MAJOR='" + ETranslate.globalMajor + "' LANG='" + ETranslate.globalLanguage
Log.debug("list path=" + ETranslate.globalListPath.keySet()); + "' default=" + ETranslate.globalLanguageDefault);
LOGGER.debug("list path=" + ETranslate.globalListPath.keySet());
// start parse language for Major: // start parse language for Major:
final Uri itMajor = ETranslate.globalListPath.get(ETranslate.globalMajor); final Uri itMajor = ETranslate.globalListPath.get(ETranslate.globalMajor);
if (itMajor != null) { if (itMajor != null) {
@ -158,7 +154,7 @@ public class ETranslate {
final JsonObject root = (JsonObject) Ejson.parse(uri); final JsonObject root = (JsonObject) Ejson.parse(uri);
for (final Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) { for (final Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) {
final String val = element.getValue().toJsonString().getValue(); final String val = element.getValue().toJsonString().getValue();
//Log.info("Add global translate: '" + element.getKey() + "' => '" + val + "'"); //LOGGER.info("Add global translate: '" + element.getKey() + "' => '" + val + "'");
ETranslate.globalTranslate.put(element.getKey(), val); ETranslate.globalTranslate.put(element.getKey(), val);
} }
} catch (final Exception e) { } catch (final Exception e) {
@ -170,7 +166,7 @@ public class ETranslate {
final JsonObject root = (JsonObject) Ejson.parse(uri); final JsonObject root = (JsonObject) Ejson.parse(uri);
for (final Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) { for (final Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) {
final String val = element.getValue().toJsonString().getValue(); final String val = element.getValue().toJsonString().getValue();
//Log.info("Add global translate: '" + element.getKey() + "' => '" + val + "'"); //LOGGER.info("Add global translate: '" + element.getKey() + "' => '" + val + "'");
ETranslate.globalTranslate.put(element.getKey(), val); ETranslate.globalTranslate.put(element.getKey(), val);
} }
} catch (final Exception e) { } catch (final Exception e) {
@ -197,7 +193,7 @@ public class ETranslate {
} }
for (final Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) { for (final Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) {
final String val = element.getValue().toJsonString().getValue(); final String val = element.getValue().toJsonString().getValue();
//Log.info("Add global translate: '" + element.getKey() + "' => '" + val + "'"); //LOGGER.info("Add global translate: '" + element.getKey() + "' => '" + val + "'");
ETranslate.globalTranslate.put(element.getKey(), val); ETranslate.globalTranslate.put(element.getKey(), val);
} }
} }
@ -206,7 +202,8 @@ public class ETranslate {
if (it.getKey().contentEquals(ETranslate.globalMajor)) { if (it.getKey().contentEquals(ETranslate.globalMajor)) {
continue; continue;
} }
final Uri uri = it.getValue().withPath(it.getValue().getPath() + "/" + ETranslate.globalLanguageDefault + ".json"); final Uri uri = it.getValue()
.withPath(it.getValue().getPath() + "/" + ETranslate.globalLanguageDefault + ".json");
/* /*
* TODO ... if (Uri.exist(uri) == false) { continue; } * TODO ... if (Uri.exist(uri) == false) { continue; }
*/ */
@ -220,7 +217,7 @@ public class ETranslate {
} }
for (final Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) { for (final Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) {
final String val = element.getValue().toJsonString().getValue(); final String val = element.getValue().toJsonString().getValue();
//Log.info("Add global translate: '" + element.getKey() + "' => '" + val + "'"); //LOGGER.info("Add global translate: '" + element.getKey() + "' => '" + val + "'");
ETranslate.globalTranslate.put(element.getKey(), val); ETranslate.globalTranslate.put(element.getKey(), val);
} }
} }
@ -241,27 +238,27 @@ public class ETranslate {
ETranslate.globalTranslateLoadad = false; ETranslate.globalTranslateLoadad = false;
ETranslate.globalTranslate.clear(); ETranslate.globalTranslate.clear();
if (lang.equals("EN")) { if (lang.equals("EN")) {
Log.info("Change language translation: '" + lang + "'=English"); LOGGER.info("Change language translation: '" + lang + "'=English");
} else if (lang.equals("FR")) { } else if (lang.equals("FR")) {
Log.info("Change language translation: '" + lang + "'=French"); LOGGER.info("Change language translation: '" + lang + "'=French");
} else if (lang.equals("DE")) { } else if (lang.equals("DE")) {
Log.info("Change language translation: '" + lang + "'=German"); LOGGER.info("Change language translation: '" + lang + "'=German");
} else if (lang.equals("SP")) { } else if (lang.equals("SP")) {
Log.info("Change language translation: '" + lang + "'=Spanish"); LOGGER.info("Change language translation: '" + lang + "'=Spanish");
} else if (lang.equals("JA")) { } else if (lang.equals("JA")) {
Log.info("Change language translation: '" + lang + "'=Japanese"); LOGGER.info("Change language translation: '" + lang + "'=Japanese");
} else if (lang.equals("IT")) { } else if (lang.equals("IT")) {
Log.info("Change language translation: '" + lang + "'=Italian"); LOGGER.info("Change language translation: '" + lang + "'=Italian");
} else if (lang.equals("KO")) { } else if (lang.equals("KO")) {
Log.info("Change language translation: '" + lang + "'=Korean"); LOGGER.info("Change language translation: '" + lang + "'=Korean");
} else if (lang.equals("RU")) { } else if (lang.equals("RU")) {
Log.info("Change language translation: '" + lang + "'=Russian"); LOGGER.info("Change language translation: '" + lang + "'=Russian");
} else if (lang.equals("PT")) { } else if (lang.equals("PT")) {
Log.info("Change language translation: '" + lang + "'=Portuguese, Brazilian"); LOGGER.info("Change language translation: '" + lang + "'=Portuguese, Brazilian");
} else if (lang.equals("ZH")) { } else if (lang.equals("ZH")) {
Log.info("Change language translation: '" + lang + "'=Chinese"); LOGGER.info("Change language translation: '" + lang + "'=Chinese");
} else { } else {
Log.info("Change language translation: '" + lang + "'=Unknow"); LOGGER.info("Change language translation: '" + lang + "'=Unknow");
} }
} }
@ -275,7 +272,7 @@ public class ETranslate {
if (ETranslate.globalLanguageDefault.equals(lang)) { if (ETranslate.globalLanguageDefault.equals(lang)) {
return; return;
} }
Log.info("Change default language translation : '" + lang + "'"); LOGGER.info("Change default language translation : '" + lang + "'");
ETranslate.globalLanguageDefault = lang; ETranslate.globalLanguageDefault = lang;
ETranslate.globalTranslateLoadad = false; ETranslate.globalTranslateLoadad = false;
ETranslate.globalTranslate.clear(); ETranslate.globalTranslate.clear();

View File

@ -14,13 +14,15 @@ import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject; import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingDrawing extends Compositing { public class CompositingDrawing extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class);
protected static int vboIdColor = 1; protected static int vboIdColor = 1;
protected static int vboIdCoord = 0; protected static int vboIdCoord = 0;
private boolean clippingEnable = false; // !< true if the clipping must be activated private boolean clippingEnable = false; // !< true if the clipping must be activated
@ -36,19 +38,19 @@ public class CompositingDrawing extends Compositing {
private ResourceProgram oGLprogram; // !< pointer on the opengl display program private ResourceProgram oGLprogram; // !< pointer on the opengl display program
private final List<Color> outColors = new ArrayList<>(); private final List<Color> outColors = new ArrayList<>();
private final List<Vector3f> outTriangles = new ArrayList<>(); private final List<Vector3f> outTriangles = new ArrayList<>();
private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw
private float thickness = 0; // !< when drawing line and other things private float thickness = 0; // !< when drawing line and other things
private final Vector3f[] triangle = new Vector3f[3]; // !< Register every system with a combinaison of tiangle private final Vector3f[] triangle = new Vector3f[3]; // !< Register every system with a combinaison of tiangle
private final Color[] tricolor = new Color[3]; // !< Register every the associated color foreground private final Color[] tricolor = new Color[3]; // !< Register every the associated color foreground
private int triElement = 0; // !< special counter of the single dot generated private int triElement = 0; // !< special counter of the single dot generated
//protected ResourceVirtualBufferObject vbo; //protected ResourceVirtualBufferObject vbo;
protected ResourceVirtualArrayObject vbo; protected ResourceVirtualArrayObject vbo;
// internal API for the generation abstraction of triangles // internal API for the generation abstraction of triangles
/** /**
* Basic ructor * Basic ructor
@ -64,7 +66,7 @@ public class CompositingDrawing extends Compositing {
// 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");
} }
/** /**
* add a point reference at the current position (this is a vertex * add a point reference at the current position (this is a vertex
* reference at the current position * reference at the current position
@ -73,7 +75,7 @@ public class CompositingDrawing extends Compositing {
internalSetColor(this.color); internalSetColor(this.color);
setPoint(this.position); setPoint(this.position);
} }
/** /**
* draw a 2D circle with the specify rafdius parameter. * draw a 2D circle with the specify rafdius parameter.
* @param radius Distence to the dorder * @param radius Distence to the dorder
@ -83,73 +85,73 @@ public class CompositingDrawing extends Compositing {
public void circle(final float radius) { public void circle(final float radius) {
circle(radius, 0); circle(radius, 0);
} }
public void circle(final float radius, final float angleStart) { public void circle(final float radius, final float angleStart) {
circle(radius, angleStart, 2.0f * FMath.PI); circle(radius, angleStart, 2.0f * FMath.PI);
} }
public void circle(float radius, final float angleStart, float angleStop) { public void circle(float radius, final float angleStart, float angleStop) {
resetCount(); resetCount();
if (radius < 0) { if (radius < 0) {
radius *= -1; radius *= -1;
} }
angleStop = angleStop - angleStart; angleStop = angleStop - angleStart;
int nbOcurence = (int) radius; int nbOcurence = (int) radius;
if (nbOcurence < 10) { if (nbOcurence < 10) {
nbOcurence = 10; nbOcurence = 10;
} }
// display background : // display background :
if (this.colorBg.a() != 0) { if (this.colorBg.a() != 0) {
internalSetColor(this.colorBg); internalSetColor(this.colorBg);
for (int iii = 0; iii < nbOcurence; iii++) { for (int iii = 0; iii < nbOcurence; iii++) {
setPoint(new Vector3f(this.position.x(), this.position.y(), 0)); setPoint(new Vector3f(this.position.x(), this.position.y(), 0));
final float angleOne = angleStart + (angleStop * iii / nbOcurence); final float angleOne = angleStart + (angleStop * iii / nbOcurence);
float offsety = FMath.sin(angleOne) * radius; float offsety = FMath.sin(angleOne) * radius;
float offsetx = FMath.cos(angleOne) * radius; float offsetx = FMath.cos(angleOne) * radius;
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0)); setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0));
final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence); final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
offsety = FMath.sin(angleTwo) * radius; offsety = FMath.sin(angleTwo) * radius;
offsetx = FMath.cos(angleTwo) * radius; offsetx = FMath.cos(angleTwo) * radius;
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0)); setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0));
} }
} }
// show if we have a border : // show if we have a border :
if (this.thickness == 0 || this.color.a() == 0) { if (this.thickness == 0 || this.color.a() == 0) {
return; return;
} }
internalSetColor(this.color); internalSetColor(this.color);
for (int iii = 0; iii < nbOcurence; iii++) { for (int iii = 0; iii < nbOcurence; iii++) {
final float angleOne = angleStart + (angleStop * iii / nbOcurence); final float angleOne = angleStart + (angleStop * iii / nbOcurence);
final float offsetExty = FMath.sin(angleOne) * (radius + this.thickness / 2); final float offsetExty = FMath.sin(angleOne) * (radius + this.thickness / 2);
final float offsetExtx = FMath.cos(angleOne) * (radius + this.thickness / 2); final float offsetExtx = FMath.cos(angleOne) * (radius + this.thickness / 2);
final float offsetInty = FMath.sin(angleOne) * (radius - this.thickness / 2); final float offsetInty = FMath.sin(angleOne) * (radius - this.thickness / 2);
final float offsetIntx = FMath.cos(angleOne) * (radius - this.thickness / 2); final float offsetIntx = FMath.cos(angleOne) * (radius - this.thickness / 2);
final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence); final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
final float offsetExt2y = FMath.sin(angleTwo) * (radius + this.thickness / 2); final float offsetExt2y = FMath.sin(angleTwo) * (radius + this.thickness / 2);
final float offsetExt2x = FMath.cos(angleTwo) * (radius + this.thickness / 2); final float offsetExt2x = FMath.cos(angleTwo) * (radius + this.thickness / 2);
final float offsetInt2y = FMath.sin(angleTwo) * (radius - this.thickness / 2); final float offsetInt2y = FMath.sin(angleTwo) * (radius - this.thickness / 2);
final float offsetInt2x = FMath.cos(angleTwo) * (radius - this.thickness / 2); final float offsetInt2x = FMath.cos(angleTwo) * (radius - this.thickness / 2);
setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0)); setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
setPoint(new Vector3f(this.position.x() + offsetExtx, this.position.y() + offsetExty, 0)); setPoint(new Vector3f(this.position.x() + offsetExtx, this.position.y() + offsetExty, 0));
setPoint(new Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0)); setPoint(new Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
setPoint(new Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0)); setPoint(new Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
setPoint(new Vector3f(this.position.x() + offsetInt2x, this.position.y() + offsetInt2y, 0)); setPoint(new Vector3f(this.position.x() + offsetInt2x, this.position.y() + offsetInt2y, 0));
setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0)); setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
} }
} }
/** /**
* clear alll tre registered element in the current element * clear alll tre registered element in the current element
*/ */
@ -161,35 +163,35 @@ public class CompositingDrawing extends Compositing {
this.vbo.clear(); this.vbo.clear();
this.outTriangles.clear(); this.outTriangles.clear();
this.outColors.clear(); this.outColors.clear();
// reset temporal variables : // reset temporal variables :
this.position = Vector3f.ZERO; this.position = Vector3f.ZERO;
this.clippingPosStart = Vector3f.ZERO; this.clippingPosStart = Vector3f.ZERO;
this.clippingPosStop = Vector3f.ZERO; this.clippingPosStop = Vector3f.ZERO;
this.clippingEnable = false; this.clippingEnable = false;
this.color = Color.BLACK; this.color = Color.BLACK;
this.colorBg = Color.NONE; this.colorBg = Color.NONE;
for (int iii = 0; iii < 3; iii++) { for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position; this.triangle[iii] = this.position;
this.tricolor[iii] = this.color; this.tricolor[iii] = this.color;
} }
} }
/** /**
* draw All the refistered text in the current element on openGL * draw All the refistered text in the current element on openGL
*/ */
@Override @Override
public void draw(final boolean disableDepthTest) { public void draw(final boolean disableDepthTest) {
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
Matrix4f camMatrix = OpenGL.getCameraMatrix(); final Matrix4f camMatrix = OpenGL.getCameraMatrix();
this.oGLprogram.use(); this.oGLprogram.use();
this.vbo.bindForRendering(); this.vbo.bindForRendering();
this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix);
@ -200,7 +202,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
} }
@Override @Override
public void flush() { public void flush() {
// push data on the VBO // push data on the VBO
@ -208,7 +210,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.setColors(this.outColors.toArray(Color[]::new)); this.vbo.setColors(this.outColors.toArray(Color[]::new));
this.vbo.setVertexCount(this.outTriangles.size()); this.vbo.setVertexCount(this.outTriangles.size());
} }
/** /**
* Lunch the generation of triangle * Lunch the generation of triangle
*/ */
@ -221,7 +223,7 @@ public class CompositingDrawing extends Compositing {
this.outColors.add(this.tricolor[1]); this.outColors.add(this.tricolor[1]);
this.outColors.add(this.tricolor[2]); this.outColors.add(this.tricolor[2]);
} }
/** /**
* Get the foreground color of the font. * Get the foreground color of the font.
* @return Foreground color. * @return Foreground color.
@ -229,7 +231,7 @@ public class CompositingDrawing extends Compositing {
public Color getColor() { public Color getColor() {
return this.color; return this.color;
} }
/** /**
* Get the background color of the font. * Get the background color of the font.
* @return Background color. * @return Background color.
@ -237,7 +239,7 @@ public class CompositingDrawing extends Compositing {
public Color getColorBg() { public Color getColorBg() {
return this.colorBg; return this.colorBg;
} }
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -245,7 +247,7 @@ public class CompositingDrawing extends Compositing {
public Vector3f getPos() { public Vector3f getPos() {
return this.position; return this.position;
} }
/** /**
* set the Color of the current triangle drawing * set the Color of the current triangle drawing
* @param color Color to current dots generated * @param color Color to current dots generated
@ -261,7 +263,7 @@ public class CompositingDrawing extends Compositing {
this.tricolor[2] = color; this.tricolor[2] = color;
} }
} }
/** /**
* Relative drawing a line (spacial vector) * Relative drawing a line (spacial vector)
* @param vect Vector of the curent line. * @param vect Vector of the curent line.
@ -269,31 +271,31 @@ public class CompositingDrawing extends Compositing {
public void lineRel(final float xxx, final float yyy) { public void lineRel(final float xxx, final float yyy) {
lineTo(this.position.add(new Vector3f(xxx, yyy, 0))); lineTo(this.position.add(new Vector3f(xxx, yyy, 0)));
} }
public void lineRel(final float xxx, final float yyy, final float zzz) { public void lineRel(final float xxx, final float yyy, final float zzz) {
lineTo(this.position.add(new Vector3f(xxx, yyy, zzz))); lineTo(this.position.add(new Vector3f(xxx, yyy, zzz)));
} }
public void lineRel(final Vector2f vect) { public void lineRel(final Vector2f vect) {
lineRel(new Vector3f(vect.x(), vect.y(), 0)); lineRel(new Vector3f(vect.x(), vect.y(), 0));
} }
public void lineRel(final Vector3f vect) { public void lineRel(final Vector3f vect) {
lineTo(this.position.add(vect)); lineTo(this.position.add(vect));
} }
public void lineTo(final float xxx, final float yyy) { public void lineTo(final float xxx, final float yyy) {
lineTo(new Vector3f(xxx, yyy, 0)); lineTo(new Vector3f(xxx, yyy, 0));
} }
public void lineTo(final float xxx, final float yyy, final float zzz) { public void lineTo(final float xxx, final float yyy, final float zzz) {
lineTo(new Vector3f(xxx, yyy, zzz)); lineTo(new Vector3f(xxx, yyy, zzz));
} }
public void lineTo(final Vector2f dest) { public void lineTo(final Vector2f dest) {
lineTo(new Vector3f(dest.x(), dest.y(), 0)); lineTo(new Vector3f(dest.x(), dest.y(), 0));
} }
/** /**
* draw a line to a specific position * draw a line to a specific position
* @param dest Position of the end of the line. * @param dest Position of the end of the line.
@ -301,9 +303,9 @@ public class CompositingDrawing extends Compositing {
public void lineTo(final Vector3f dest) { public void lineTo(final Vector3f dest) {
resetCount(); resetCount();
internalSetColor(this.color); internalSetColor(this.color);
// Log.verbose("DrawLine : " + this.position + " to " + dest); // LOGGER.trace("DrawLine : " + this.position + " to " + dest);
if (this.position.x() == dest.x() && this.position.y() == dest.y() && this.position.z() == dest.z()) { if (this.position.x() == dest.x() && this.position.y() == dest.y() && this.position.z() == dest.z()) {
// Log.warning("Try to draw a line width 0"); // LOGGER.warn("Try to draw a line width 0");
return; return;
} }
// teta = tan-1(oposer/adjacent) // teta = tan-1(oposer/adjacent)
@ -318,20 +320,20 @@ public class CompositingDrawing extends Compositing {
} else if (teta > 2 * FMath.PI) { } else if (teta > 2 * FMath.PI) {
teta -= 2 * FMath.PI; teta -= 2 * FMath.PI;
} }
// Log.debug("teta = " + (teta*180/(FMath.PI)) + " deg." ); // LOGGER.debug("teta = " + (teta*180/(FMath.PI)) + " deg." );
final float offsety = FMath.sin(teta - FMath.PI / 2) * (this.thickness / 2); final float offsety = FMath.sin(teta - FMath.PI / 2) * (this.thickness / 2);
final float offsetx = FMath.cos(teta - FMath.PI / 2) * (this.thickness / 2); final float offsetx = FMath.cos(teta - FMath.PI / 2) * (this.thickness / 2);
setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z())); setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z()));
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z())); setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z()));
setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, this.position.z())); setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, this.position.z()));
setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, dest.z())); setPoint(new Vector3f(dest.x() + offsetx, dest.y() + offsety, dest.z()));
setPoint(new Vector3f(dest.x() - offsetx, dest.y() - offsety, dest.z())); setPoint(new Vector3f(dest.x() - offsetx, dest.y() - offsety, dest.z()));
setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, dest.z())); setPoint(new Vector3f(this.position.x() - offsetx, this.position.y() - offsety, dest.z()));
// update the system position : // update the system position :
this.position = dest; this.position = dest;
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
@ -339,7 +341,8 @@ public class CompositingDrawing extends Compositing {
// remove previous loading ... in case // remove previous loading ... in case
unLoadProgram(); unLoadProgram();
// oad the new ... // oad the new ...
this.oGLprogram = ResourceProgram.create(new Uri("DATA", "color3.vert", "ewol"), new Uri("DATA", "color3.frag", "ewol")); this.oGLprogram = ResourceProgram.create(new Uri("DATA", "color3.vert", "ewol"),
new Uri("DATA", "color3.frag", "ewol"));
// get the shader resource : // get the shader resource :
if (this.oGLprogram != null) { if (this.oGLprogram != null) {
//this.oGLPosition = this.oGLprogram.getAttribute("in_coord3d"); //this.oGLPosition = this.oGLprogram.getAttribute("in_coord3d");
@ -349,19 +352,19 @@ public class CompositingDrawing extends Compositing {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView"); this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
} }
} }
public void rectangle(final float xxx, final float yyy) { public void rectangle(final float xxx, final float yyy) {
rectangle(new Vector3f(xxx, yyy, 0)); rectangle(new Vector3f(xxx, yyy, 0));
} }
public void rectangle(final float xxx, final float yyy, final float zzz) { public void rectangle(final float xxx, final float yyy, final float zzz) {
rectangle(new Vector3f(xxx, yyy, zzz)); rectangle(new Vector3f(xxx, yyy, zzz));
} }
public void rectangle(final Vector2f dest) { public void rectangle(final Vector2f dest) {
rectangle(new Vector3f(dest.x(), dest.y(), 0)); rectangle(new Vector3f(dest.x(), dest.y(), 0));
} }
/** /**
* draw a 2D rectangle to the position requested. * draw a 2D rectangle to the position requested.
* @param dest Position the the end of the rectangle * @param dest Position the the end of the rectangle
@ -408,24 +411,24 @@ public class CompositingDrawing extends Compositing {
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
setPoint(new Vector3f(dxA, dyC, 0)); setPoint(new Vector3f(dxA, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0)); setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyD, 0)); setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxA, dyD, 0)); setPoint(new Vector3f(dxA, dyD, 0));
} }
public void rectangleWidth(final float xxx, final float yyy) { public void rectangleWidth(final float xxx, final float yyy) {
rectangleWidth(new Vector3f(xxx, yyy, 0)); rectangleWidth(new Vector3f(xxx, yyy, 0));
} }
public void rectangleWidth(final float xxx, final float yyy, final float zzz) { public void rectangleWidth(final float xxx, final float yyy, final float zzz) {
rectangleWidth(new Vector3f(xxx, yyy, zzz)); rectangleWidth(new Vector3f(xxx, yyy, zzz));
} }
public void rectangleWidth(final Vector2f size) { public void rectangleWidth(final Vector2f size) {
rectangleWidth(new Vector3f(size.x(), size.y(), 0)); rectangleWidth(new Vector3f(size.x(), size.y(), 0));
} }
/** /**
* draw a 2D rectangle to the requested size. * draw a 2D rectangle to the requested size.
* @param size size of the rectangle * @param size size of the rectangle
@ -433,18 +436,18 @@ public class CompositingDrawing extends Compositing {
public void rectangleWidth(final Vector3f size) { public void rectangleWidth(final Vector3f size) {
rectangle(this.position.add(size)); rectangle(this.position.add(size));
} }
/** /**
* in case of some error the count can be reset * in case of some error the count can be reset
*/ */
private void resetCount() { private void resetCount() {
this.triElement = 0; this.triElement = 0;
} }
public void setClipping(final Vector2f pos, final Vector2f posEnd) { public void setClipping(final Vector2f pos, final Vector2f posEnd) {
setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1)); setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1));
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -457,7 +460,7 @@ public class CompositingDrawing extends Compositing {
this.clippingPosStart = Vector3f.min(pos, posEnd); this.clippingPosStart = Vector3f.min(pos, posEnd);
this.clippingEnable = true; this.clippingEnable = true;
} }
/** /**
* enable/Disable the clipping (without lose the current clipping * enable/Disable the clipping (without lose the current clipping
* position) * position)
@ -466,11 +469,11 @@ public class CompositingDrawing extends Compositing {
public void setClippingMode(final boolean newMode) { public void setClippingMode(final boolean newMode) {
this.clippingEnable = newMode; this.clippingEnable = newMode;
} }
public void setClippingWidth(final Vector2f pos, final Vector2f width) { public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClippingWidth(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(width.x(), width.y(), 2)); setClippingWidth(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(width.x(), width.y(), 2));
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -479,7 +482,7 @@ public class CompositingDrawing extends Compositing {
public void setClippingWidth(final Vector3f pos, final Vector3f width) { public void setClippingWidth(final Vector3f pos, final Vector3f width) {
setClipping(pos, pos.add(width)); setClipping(pos, pos.add(width));
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @param color Color to set on foreground (for next print)
@ -487,7 +490,7 @@ public class CompositingDrawing extends Compositing {
public void setColor(final Color color) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
/** /**
* set the background color of the font (for selected Text (not the * set the background color of the font (for selected Text (not the
* global BG)) * global BG))
@ -496,7 +499,7 @@ public class CompositingDrawing extends Compositing {
public void setColorBg(final Color color) { public void setColorBg(final Color color) {
this.colorBg = color; this.colorBg = color;
} }
/** /**
* internal add of the specific point * internal add of the specific point
* @param point The requeste dpoint to add * @param point The requeste dpoint to add
@ -509,19 +512,19 @@ public class CompositingDrawing extends Compositing {
} }
this.vbo.flush(); this.vbo.flush();
} }
public void setPos(final float xxx, final float yyy) { public void setPos(final float xxx, final float yyy) {
setPos(new Vector3f(xxx, yyy, 0)); setPos(new Vector3f(xxx, yyy, 0));
} }
public void setPos(final float xxx, final float yyy, final float zzz) { public void setPos(final float xxx, final float yyy, final float zzz) {
setPos(new Vector3f(xxx, yyy, zzz)); setPos(new Vector3f(xxx, yyy, zzz));
} }
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set position for the next text written * set position for the next text written
* @param pos Position of the text (in 3D) * @param pos Position of the text (in 3D)
@ -529,11 +532,11 @@ public class CompositingDrawing extends Compositing {
public void setPos(final Vector3f pos) { public void setPos(final Vector3f pos) {
this.position = pos; this.position = pos;
} }
public void setRelPos(final float xxx, final float yyy) { public void setRelPos(final float xxx, final float yyy) {
this.position = this.position.add(xxx, yyy, 0); this.position = this.position.add(xxx, yyy, 0);
} }
/** /**
* set relative position for the next text writen * set relative position for the next text writen
* @param pos ofset apply of the text (in 3D) * @param pos ofset apply of the text (in 3D)
@ -541,15 +544,15 @@ public class CompositingDrawing extends Compositing {
public void setRelPos(final float xxx, final float yyy, final float zzz) { public void setRelPos(final float xxx, final float yyy, final float zzz) {
this.position = this.position.add(xxx, yyy, zzz); this.position = this.position.add(xxx, yyy, zzz);
} }
public void setRelPos(final Vector2f pos) { public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0)); setRelPos(new Vector3f(pos.x(), pos.y(), 0));
} }
public void setRelPos(final Vector3f pos) { public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos); this.position = this.position.add(pos);
} }
/** /**
* Specify the line thickness for the next elements * Specify the line thickness for the next elements
* @param thickness The thickness disired for the next print * @param thickness The thickness disired for the next print
@ -561,12 +564,12 @@ public class CompositingDrawing extends Compositing {
this.thickness *= -1; this.thickness *= -1;
} }
} }
/** /**
* Un-Load the openGL program and get all the ID needed * Un-Load the openGL program and get all the ID needed
*/ */
private void unLoadProgram() { private void unLoadProgram() {
this.oGLprogram = null; this.oGLprogram = null;
} }
} }

View File

@ -12,25 +12,27 @@ import org.atriasoft.esvg.JoinMode;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
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.ewol.internal.Log;
import org.atriasoft.gale.resource.ResourceTexture2; import org.atriasoft.gale.resource.ResourceTexture2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingGraphicContext extends Compositing { public class CompositingGraphicContext extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGraphicContext.class);
GraphicContext context = new GraphicContext(); GraphicContext context = new GraphicContext();
private final ResourceTexture2 texture = new ResourceTexture2(); private final ResourceTexture2 texture = new ResourceTexture2();
public CompositingGraphicContext() { public CompositingGraphicContext() {
} }
public Vector2i calculateTextSize(final String data) { public Vector2i calculateTextSize(final String data) {
return this.context.calculateTextSize(data); return this.context.calculateTextSize(data);
} }
public void circle(final Vector2f position, final float radius) { public void circle(final Vector2f position, final float radius) {
this.context.circle(position, radius); this.context.circle(position, radius);
} }
/** /**
* clear alll tre registered element in the current element * clear alll tre registered element in the current element
*/ */
@ -41,43 +43,43 @@ public class CompositingGraphicContext extends Compositing {
// reset Buffer : // reset Buffer :
this.context.clear(); this.context.clear();
} }
/** /**
* Clear the fill color (disable fill ==> better that set it transparent) * Clear the fill color (disable fill ==> better that set it transparent)
*/ */
public void clearColorFill() { public void clearColorFill() {
this.context.clearColorFill(); this.context.clearColorFill();
} }
/** /**
* Clear the Stroke color (disable stroke) * Clear the Stroke color (disable stroke)
*/ */
public void clearColorStroke() { public void clearColorStroke() {
this.context.clearColorStroke(); this.context.clearColorStroke();
} }
@Override @Override
public void draw(final boolean disableDepthTest) { public void draw(final boolean disableDepthTest) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void ellipse(final Vector2f center, final Vector2f radius) { public void ellipse(final Vector2f center, final Vector2f radius) {
this.context.ellipse(center, radius); this.context.ellipse(center, radius);
} }
@Override @Override
public void flush() { public void flush() {
if (this.texture == null) { if (this.texture == null) {
Log.warning("texture is null"); LOGGER.warn("texture is null");
return; return;
} }
ImageByte img = this.context.render(); final ImageByte img = this.context.render();
//IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp222.png"), img); //IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp222.png"), img);
this.texture.set(img); this.texture.set(img);
this.texture.flush(); this.texture.flush();
} }
/** /**
* Get the fill color. * Get the fill color.
* @return fill color. * @return fill color.
@ -85,7 +87,7 @@ public class CompositingGraphicContext extends Compositing {
public Color getColorFill() { public Color getColorFill() {
return this.context.getColorFill(); return this.context.getColorFill();
} }
/** /**
* Get the stroke color. * Get the stroke color.
* @return Stroke color. * @return Stroke color.
@ -93,23 +95,23 @@ public class CompositingGraphicContext extends Compositing {
public Color getColorStroke() { public Color getColorStroke() {
return this.context.getColorStroke(); return this.context.getColorStroke();
} }
public CapMode getLineCap() { public CapMode getLineCap() {
return this.context.getLineCap(); return this.context.getLineCap();
} }
public JoinMode getLineJoin() { public JoinMode getLineJoin() {
return this.context.getLineJoin(); return this.context.getLineJoin();
} }
public float getMiterLimit() { public float getMiterLimit() {
return this.context.getMiterLimit(); return this.context.getMiterLimit();
} }
public float getOpacity() { public float getOpacity() {
return this.context.getOpacity(); return this.context.getOpacity();
} }
/** /**
* get the source image registered size in the file (<0 when multiple size image) * get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size * @return tre image registered size
@ -117,27 +119,27 @@ public class CompositingGraphicContext extends Compositing {
public Vector2i getRealSize() { public Vector2i getRealSize() {
return this.texture.get().getSize(); return this.texture.get().getSize();
} }
public int getRendererId() { public int getRendererId() {
return this.texture.getRendererId(); return this.texture.getRendererId();
} }
public ResourceTexture2 getResourceTexture() { public ResourceTexture2 getResourceTexture() {
return this.texture; return this.texture;
} }
public float getStrokeWidth() { public float getStrokeWidth() {
return this.context.getStrokeWidth(); return this.context.getStrokeWidth();
} }
public int getTextHeight() { public int getTextHeight() {
return this.context.getTextHeight(); return this.context.getTextHeight();
} }
public float getTextSize() { public float getTextSize() {
return this.context.getTextSize(); return this.context.getTextSize();
} }
/** /**
* Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources. * @return the validity od the resources.
@ -145,60 +147,60 @@ public class CompositingGraphicContext extends Compositing {
public boolean hasSources() { public boolean hasSources() {
return true; return true;
} }
public void line(final Vector2f origin, final Vector2f destination) { public void line(final Vector2f origin, final Vector2f destination) {
this.context.line(origin, destination); this.context.line(origin, destination);
} }
public void lineRel(final Vector2f origin, final Vector2f relativeDestination) { public void lineRel(final Vector2f origin, final Vector2f relativeDestination) {
this.context.lineRel(origin, relativeDestination); this.context.lineRel(origin, relativeDestination);
} }
public void pathLine(final Vector2f pos) { public void pathLine(final Vector2f pos) {
this.context.pathLine(pos); this.context.pathLine(pos);
} }
public void pathLineTo(final Vector2f pos) { public void pathLineTo(final Vector2f pos) {
this.context.pathLineTo(pos); this.context.pathLineTo(pos);
} }
public void pathMove(final Vector2f pos) { public void pathMove(final Vector2f pos) {
this.context.pathMove(pos); this.context.pathMove(pos);
} }
public void pathMoveTo(final Vector2f pos) { public void pathMoveTo(final Vector2f pos) {
this.context.pathMoveTo(pos); this.context.pathMoveTo(pos);
} }
public void pathStart() { public void pathStart() {
this.context.pathStart(); this.context.pathStart();
} }
public void pathStop() { public void pathStop() {
this.context.pathStop(); this.context.pathStop();
} }
public void pathStopLinked() { public void pathStopLinked() {
this.context.pathStopLinked(); this.context.pathStopLinked();
} }
public void rectangle(final Vector2f position, final Vector2f destination) { public void rectangle(final Vector2f position, final Vector2f destination) {
this.context.rectangle(position, destination); this.context.rectangle(position, destination);
} }
public void rectangleRounded(final Vector2f position, final Vector2f destination, final Vector2f ruound) { public void rectangleRounded(final Vector2f position, final Vector2f destination, final Vector2f ruound) {
this.context.rectangleRounded(position, destination, ruound); this.context.rectangleRounded(position, destination, ruound);
} }
public void rectangleRoundedWidth(final Vector2f position, final Vector2f width, final Vector2f ruound) { public void rectangleRoundedWidth(final Vector2f position, final Vector2f width, final Vector2f ruound) {
this.context.rectangleRoundedWidth(position, width, ruound); this.context.rectangleRoundedWidth(position, width, ruound);
} }
public void rectangleWidth(final Vector2f position, final Vector2f width) { public void rectangleWidth(final Vector2f position, final Vector2f width) {
this.context.rectangleWidth(position, width); this.context.rectangleWidth(position, width);
} }
/** /**
* set the fill color * set the fill color
* @param color Color to set on fill * @param color Color to set on fill
@ -207,7 +209,7 @@ public class CompositingGraphicContext extends Compositing {
public void setColorFill(final Color color) { public void setColorFill(final Color color) {
this.context.setColorFill(color); this.context.setColorFill(color);
} }
/** /**
* set the stroke color * set the stroke color
* @param color Color to set on stroke * @param color Color to set on stroke
@ -216,23 +218,23 @@ public class CompositingGraphicContext extends Compositing {
public void setColorStroke(final Color color) { public void setColorStroke(final Color color) {
this.context.setColorStroke(color); this.context.setColorStroke(color);
} }
public void setLineCap(final CapMode lineCap) { public void setLineCap(final CapMode lineCap) {
this.context.setLineCap(lineCap); this.context.setLineCap(lineCap);
} }
public void setLineJoin(final JoinMode lineJoin) { public void setLineJoin(final JoinMode lineJoin) {
this.context.setLineJoin(lineJoin); this.context.setLineJoin(lineJoin);
} }
public void setMiterLimit(final float miterLimit) { public void setMiterLimit(final float miterLimit) {
this.context.setMiterLimit(miterLimit); this.context.setMiterLimit(miterLimit);
} }
public void setOpacity(final float opacity) { public void setOpacity(final float opacity) {
this.context.setOpacity(opacity); this.context.setOpacity(opacity);
} }
/** /**
* Set global size of the Graphic context (output render size) * Set global size of the Graphic context (output render size)
* @param xxx Width of the image * @param xxx Width of the image
@ -242,7 +244,7 @@ public class CompositingGraphicContext extends Compositing {
public void setSize(final int xxx, final int yyy) { public void setSize(final int xxx, final int yyy) {
this.context.setSize(xxx, yyy); this.context.setSize(xxx, yyy);
} }
/** /**
* Set global size of the Graphic contexct (output render size) * Set global size of the Graphic contexct (output render size)
* @param vector2i New size of the image * @param vector2i New size of the image
@ -251,17 +253,17 @@ public class CompositingGraphicContext extends Compositing {
public void setSize(final Vector2i size) { public void setSize(final Vector2i size) {
this.context.setSize(size.x(), size.y()); this.context.setSize(size.x(), size.y());
} }
public void setStrokeWidth(final float strokeWidth) { public void setStrokeWidth(final float strokeWidth) {
this.context.setStrokeWidth(strokeWidth); this.context.setStrokeWidth(strokeWidth);
} }
public void text(final Vector2f position, final float height, final String data) { public void text(final Vector2f position, final float height, final String data) {
this.context.text(position, height, data); this.context.text(position, height, data);
} }
public void text(final Vector2f position, final String data) { public void text(final Vector2f position, final String data) {
this.context.text(position, data); this.context.text(position, data);
} }
} }

View File

@ -12,15 +12,17 @@ import org.atriasoft.etk.math.Matrix4f;
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.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode; import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceTexture2; import org.atriasoft.gale.resource.ResourceTexture2;
import org.atriasoft.gale.resource.ResourceTextureFile; import org.atriasoft.gale.resource.ResourceTextureFile;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject; import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingImage extends Compositing { public class CompositingImage extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingImage.class);
public static final int NB_VBO = 3; public static final int NB_VBO = 3;
public static final int SIZE_AUTO = 0; public static final int SIZE_AUTO = 0;
public static final int VBO_ID_COLOR = 2; public static final int VBO_ID_COLOR = 2;
@ -36,19 +38,19 @@ public class CompositingImage extends Compositing {
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
private Vector3f position = Vector3f.ZERO; //!< The current position to draw private Vector3f position = Vector3f.ZERO; //!< The current position to draw
private Vector2i requestSize = new Vector2i(2, 2); private Vector2i requestSize = new Vector2i(2, 2);
private ResourceTextureFile resource = null; //!< texture resources private ResourceTextureFile resource = null; //!< texture resources
private ResourceTexture2 resourceImage = null; //!< texture resources private ResourceTexture2 resourceImage = null; //!< texture resources
private ResourceVirtualArrayObject vbo = null; private ResourceVirtualArrayObject vbo = null;
private Color[] vboDataColors = null; private Color[] vboDataColors = null;
private Vector3f[] vboDataCoords = null; private Vector3f[] vboDataCoords = null;
private Vector2f[] vboDataCoordsTex = null; private Vector2f[] vboDataCoordsTex = null;
public CompositingImage() { public CompositingImage() {
this(new Uri("DATA", ""), CompositingImage.SIZE_AUTO); this(new Uri("DATA", ""), CompositingImage.SIZE_AUTO);
} }
/** /**
* generic ructor * generic ructor
* @param uri URI of the file that might be loaded * @param uri URI of the file that might be loaded
@ -59,7 +61,7 @@ public class CompositingImage extends Compositing {
// Create the VBO: // Create the VBO:
this.vbo = ResourceVirtualArrayObject.createDynamic(); this.vbo = ResourceVirtualArrayObject.createDynamic();
if (this.vbo == null) { if (this.vbo == null) {
Log.error("can not instanciate VBO ..."); LOGGER.error("can not instanciate VBO ...");
return; return;
} }
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
@ -67,7 +69,7 @@ public class CompositingImage extends Compositing {
setSource(uri, size); setSource(uri, size);
loadProgram(); loadProgram();
} }
/** /**
* clear alll tre registered element in the current element * clear alll tre registered element in the current element
*/ */
@ -82,7 +84,7 @@ public class CompositingImage extends Compositing {
this.color = Color.WHITE; this.color = Color.WHITE;
this.angle = 0; this.angle = 0;
} }
/** /**
* draw All the registered text in the current element on openGL * draw All the registered text in the current element on openGL
* @param disableDepthTest disable the Depth test for display * @param disableDepthTest disable the Depth test for display
@ -91,7 +93,7 @@ public class CompositingImage extends Compositing {
public void draw(final boolean disableDepthTest) { public void draw(final boolean disableDepthTest) {
/* /*
if (this.VBO.bufferSize(this.vboIdCoord) <= 0) { if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
//Log.warning("Nothink to draw..."); //LOGGER.warn("Nothink to draw...");
return; return;
} }
*/ */
@ -100,10 +102,10 @@ public class CompositingImage extends Compositing {
return; return;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
//Log.warning("Display image : " + this.VBO.bufferSize(this.vboIdCoord)); //LOGGER.warn("Display image : " + this.VBO.bufferSize(this.vboIdCoord));
if (disableDepthTest) { if (disableDepthTest) {
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
} else { } else {
@ -123,13 +125,13 @@ public class CompositingImage extends Compositing {
} else if (this.resource != null) { } else if (this.resource != null) {
this.resource.bindForRendering(0); this.resource.bindForRendering(0);
} else { } else {
Log.error("FONT type error Request normal and display distance field ..."); LOGGER.error("FONT type error Request normal and display distance field ...");
} }
this.vbo.renderArrays(RenderMode.TRIANGLE); this.vbo.renderArrays(RenderMode.TRIANGLE);
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
} }
@Override @Override
public void flush() { public void flush() {
this.vbo.setPosition(this.vboDataCoords); this.vbo.setPosition(this.vboDataCoords);
@ -138,7 +140,7 @@ public class CompositingImage extends Compositing {
this.vbo.setVertexCount(this.vboDataCoords.length); this.vbo.setVertexCount(this.vboDataCoords.length);
this.vbo.flush(); this.vbo.flush();
} }
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -146,7 +148,7 @@ public class CompositingImage extends Compositing {
public Vector3f getPos() { public Vector3f getPos() {
return this.position; return this.position;
} }
/** /**
* get the source image registered size in the file (<0 when multiple size image) * get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size * @return tre image registered size
@ -160,7 +162,7 @@ public class CompositingImage extends Compositing {
} }
return this.resourceImage.getUsableSize(); return this.resourceImage.getUsableSize();
} }
/** /**
* Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources. * @return the validity od the resources.
@ -168,24 +170,25 @@ public class CompositingImage extends Compositing {
public boolean hasSources() { public boolean hasSources() {
return this.resource != null; return this.resource != null;
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
private void loadProgram() { private void loadProgram() {
// get the shader resource: // get the shader resource:
this.oGLprogram = ResourceProgram.create(new Uri("DATA", "textured3D.vert", "ewol"), new Uri("DATA", "textured3D.frag", "ewol")); this.oGLprogram = ResourceProgram.create(new Uri("DATA", "textured3D.vert", "ewol"),
new Uri("DATA", "textured3D.frag", "ewol"));
if (this.oGLprogram != null) { if (this.oGLprogram != null) {
this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation"); this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation");
this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection"); this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection");
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView"); this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
} }
} }
public void print(final Vector2f size) { public void print(final Vector2f size) {
printPart(size, Vector2f.ZERO, Vector2f.ONE); printPart(size, Vector2f.ZERO, Vector2f.ONE);
} }
/** /**
* add a compleate of the image to display with the requested size * add a compleate of the image to display with the requested size
* @param size size of the output image * @param size size of the output image
@ -193,7 +196,7 @@ public class CompositingImage extends Compositing {
public void print(final Vector2i size) { public void print(final Vector2i size) {
print(new Vector2f(size.x(), size.y())); print(new Vector2f(size.x(), size.y()));
} }
/** /**
* add a part of the image to display with the requested size * add a part of the image to display with the requested size
* @param size size of the output image * @param size size of the output image
@ -209,74 +212,75 @@ public class CompositingImage extends Compositing {
final Vector2f ratio = new Vector2f(usefullSize.x() / openGLSize.x(), usefullSize.y() / openGLSize.y()); final Vector2f ratio = new Vector2f(usefullSize.x() / openGLSize.x(), usefullSize.y() / openGLSize.y());
final Vector2f sourcePosStart = sourcePosStartIn.multiply(ratio); final Vector2f sourcePosStart = sourcePosStartIn.multiply(ratio);
final Vector2f sourcePosStop = sourcePosStopIn.multiply(ratio); final Vector2f sourcePosStop = sourcePosStopIn.multiply(ratio);
Log.verbose(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + sourcePosStart + " stop=" + sourcePosStop); LOGGER.trace(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + sourcePosStart
+ " stop=" + sourcePosStop);
this.vboDataColors = new Color[6]; this.vboDataColors = new Color[6];
this.vboDataCoords = new Vector3f[6]; this.vboDataCoords = new Vector3f[6];
this.vboDataCoordsTex = new Vector2f[6]; this.vboDataCoordsTex = new Vector2f[6];
if (this.angle == 0.0f) { if (this.angle == 0.0f) {
Vector3f point = this.position; Vector3f point = this.position;
int indexElem = 0; int indexElem = 0;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0); point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0); point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0); point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(this.position.x(), this.position.y(), 0); point = new Vector3f(this.position.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
return; return;
} }
final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f); final Vector3f center = this.position.add(new Vector3f(size.x(), size.y(), 0)).divide(2.0f);
final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f); final Vector3f limitedSize = new Vector3f(size.x() * 0.5f, size.y() * 0.5f, 0.0f);
Vector3f point = Vector3f.ZERO; Vector3f point = Vector3f.ZERO;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
int indexElem = 0; int indexElem = 0;
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0); point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0); point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -284,7 +288,7 @@ public class CompositingImage extends Compositing {
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(limitedSize.x(), limitedSize.y(), 0); point = new Vector3f(limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -292,12 +296,12 @@ public class CompositingImage extends Compositing {
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0); point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
@ -305,16 +309,16 @@ public class CompositingImage extends Compositing {
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
indexElem++; indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y()); tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0); point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center); point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point; this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex; this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color; this.vboDataColors[indexElem] = this.color;
} }
/** /**
* set a unique rotation of this element (not set in the rotate Generic system) * set a unique rotation of this element (not set in the rotate Generic system)
* @param angleRad Angle to set in radiant. * @param angleRad Angle to set in radiant.
@ -322,7 +326,7 @@ public class CompositingImage extends Compositing {
public void setAngle(final float angleRad) { public void setAngle(final float angleRad) {
this.angle = angleRad; this.angle = angleRad;
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @param color Color to set on foreground (for next print)
@ -330,11 +334,11 @@ public class CompositingImage extends Compositing {
public void setColor(final Color color) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set position for the next text writen * set position for the next text writen
* @param pos Position of the text (in 3D) * @param pos Position of the text (in 3D)
@ -342,11 +346,11 @@ public class CompositingImage extends Compositing {
public void setPos(final Vector3f pos) { public void setPos(final Vector3f pos) {
this.position = pos; this.position = pos;
} }
public void setRelPos(final Vector2f pos) { public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0)); setRelPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set relative position for the next text writen * set relative position for the next text writen
* @param pos ofset apply of the text (in 3D) * @param pos ofset apply of the text (in 3D)
@ -354,7 +358,7 @@ public class CompositingImage extends Compositing {
public void setRelPos(final Vector3f pos) { public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos); this.position = this.position.add(pos);
} }
public void setSource(final ImageByteRGBA image) { public void setSource(final ImageByteRGBA image) {
clear(); clear();
this.filename = null; this.filename = null;
@ -362,7 +366,7 @@ public class CompositingImage extends Compositing {
this.resourceImage = new ResourceTexture2(); this.resourceImage = new ResourceTexture2();
this.resourceImage.set(image); this.resourceImage.set(image);
} }
/** /**
* change the image Source == > can not be done to display 2 images at the same time ... * change the image Source == > can not be done to display 2 images at the same time ...
* @param uri New file of the Image * @param uri New file of the Image
@ -370,11 +374,11 @@ public class CompositingImage extends Compositing {
public void setSource(final Uri uri) { public void setSource(final Uri uri) {
setSource(uri, 32); setSource(uri, 32);
} }
public void setSource(final Uri uri, final int size) { public void setSource(final Uri uri, final int size) {
setSource(uri, new Vector2i(size, size)); setSource(uri, new Vector2i(size, size));
} }
public void setSource(final Uri uri, final Vector2i size) { public void setSource(final Uri uri, final Vector2i size) {
clear(); clear();
if (this.filename == uri && this.requestSize.x() == size.x() && this.requestSize.y() == size.y()) { if (this.filename == uri && this.requestSize.x() == size.x() && this.requestSize.y() == size.y()) {
@ -387,26 +391,26 @@ public class CompositingImage extends Compositing {
this.requestSize = size; this.requestSize = size;
this.resource = null; this.resource = null;
this.resourceImage = null; this.resourceImage = null;
final Vector2i tmpSize = new Vector2i(size.x(), size.y()); final Vector2i tmpSize = new Vector2i(size.x(), size.y());
// note that no image can be loaded... // note that no image can be loaded...
if (!uri.isEmpty()) { if (!uri.isEmpty()) {
// link to new one // link to new one
this.resource = ResourceTextureFile.create(this.filename, tmpSize); this.resource = ResourceTextureFile.create(this.filename, tmpSize);
if (this.resource == null) { if (this.resource == null) {
Log.error("Can not get Image resource"); LOGGER.error("Can not get Image resource");
} }
} }
if (this.resource == null && this.resourceImage == null) { if (this.resource == null && this.resourceImage == null) {
if (resource != null) { if (resource != null) {
Log.warning("Retrive previous resource"); LOGGER.warn("Retrive previous resource");
this.resource = resource; this.resource = resource;
} }
if (resourceTex != null) { if (resourceTex != null) {
Log.warning("Retrive previous resource (image)"); LOGGER.warn("Retrive previous resource (image)");
this.resourceImage = resourceTex; this.resourceImage = resourceTex;
} }
} }
} }
} }

View File

@ -15,13 +15,15 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceTexturedFont; import org.atriasoft.ewol.resource.ResourceTexturedFont;
import org.atriasoft.ewol.resource.font.FontMode; import org.atriasoft.ewol.resource.font.FontMode;
import org.atriasoft.ewol.resource.font.GlyphProperty; import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingText extends TextBase { public class CompositingText extends TextBase {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingText.class);
protected List<Color> colors = new ArrayList<>(); protected List<Color> colors = new ArrayList<>();
protected ResourceTexturedFont font; // !< Font resources protected ResourceTexturedFont font; // !< Font resources
protected List<Vector3f> pointPositions = new ArrayList<>(); protected List<Vector3f> pointPositions = new ArrayList<>();
@ -29,19 +31,19 @@ public class CompositingText extends TextBase {
// the forceClimp is to generate a forcing of the rendering in small font, this permit to have a correct view of the font, otherwise it will be transparent. // the forceClimp is to generate a forcing of the rendering in small font, this permit to have a correct view of the font, otherwise it will be transparent.
protected final boolean forceClimp = true; protected final boolean forceClimp = true;
protected List<Vector2f> texturePositions = new ArrayList<>(); protected List<Vector2f> texturePositions = new ArrayList<>();
protected String currentFontName = ""; protected String currentFontName = "";
protected int currentFontSize = -2; // -1 is to perform first initialization protected int currentFontSize = -2; // -1 is to perform first initialization
protected int currentFontSizeRequired = -2; // -1 is to perform first initialization protected int currentFontSizeRequired = -2; // -1 is to perform first initialization
public CompositingText() { public CompositingText() {
this(""); this("");
} }
public CompositingText(final String fontName) { public CompositingText(final String fontName) {
this(fontName, 0); this(fontName, 0);
} }
/** /**
* generic constructor * generic constructor
* @param fontName Name of the font that might be loaded * @param fontName Name of the font that might be loaded
@ -50,7 +52,7 @@ public class CompositingText extends TextBase {
public CompositingText(final String fontName, final int fontSize) { public CompositingText(final String fontName, final int fontSize) {
setFont(fontName, fontSize); setFont(fontName, fontSize);
} }
@Override @Override
public Vector3f calculateSizeChar(final Character charcode) { public Vector3f calculateSizeChar(final Character charcode) {
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired; final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
@ -59,9 +61,9 @@ public class CompositingText extends TextBase {
final int fontHeigh = (int) getHeight(); final int fontHeigh = (int) getHeight();
if (myGlyphProperty == null) { if (myGlyphProperty == null) {
if (this.font == null) { if (this.font == null) {
Log.warning("no Glyph... in no font"); LOGGER.warn("no Glyph... in no font");
} else { } else {
Log.warning("no Glyph... in font : " + this.font.getName()); LOGGER.warn("no Glyph... in font : " + this.font.getName());
} }
return new Vector3f(0.2f, fontHeigh, 0); return new Vector3f(0.2f, fontHeigh, 0);
} }
@ -70,13 +72,14 @@ public class CompositingText extends TextBase {
if (this.kerning) { if (this.kerning) {
kerningOffset = myGlyphProperty.kerningGet(this.previousCharcode); kerningOffset = myGlyphProperty.kerningGet(this.previousCharcode);
} }
final Vector3f outputSize = new Vector3f((myGlyphProperty.getAdvenceX() + kerningOffset) * renderRatio, (fontHeigh), 0); final Vector3f outputSize = new Vector3f((myGlyphProperty.getAdvenceX() + kerningOffset) * renderRatio,
(fontHeigh), 0);
// Register the previous character // Register the previous character
this.previousCharcode = charcode; this.previousCharcode = charcode;
return outputSize; return outputSize;
} }
@Override @Override
public void clear() { public void clear() {
// call upper class // call upper class
@ -87,22 +90,22 @@ public class CompositingText extends TextBase {
// set the color // set the color
this.colors.clear(); this.colors.clear();
} }
@Override @Override
public void drawD(final boolean disableDepthTest) { public void drawD(final boolean disableDepthTest) {
// draw BG in any case: // draw BG in any case:
this.vectorialDraw.draw(disableDepthTest); this.vectorialDraw.draw(disableDepthTest);
if (this.vbo.getVertexCount() <= 0 || this.font == null) { if (this.vbo.getVertexCount() <= 0 || this.font == null) {
// Log.warning("Nothink to draw..."); // LOGGER.warn("Nothink to draw...");
return; return;
} }
if (this.font == null) { if (this.font == null) {
Log.warning("no font..."); LOGGER.warn("no font...");
return; return;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
@ -119,24 +122,24 @@ public class CompositingText extends TextBase {
this.oGLprogram.uniformInt(this.oGLtextHeight, this.font.getOpenGlSize().x()); this.oGLprogram.uniformInt(this.oGLtextHeight, this.font.getOpenGlSize().x());
// Request the draw of the elements: // Request the draw of the elements:
this.vbo.renderArrays(OpenGL.RenderMode.TRIANGLE); this.vbo.renderArrays(OpenGL.RenderMode.TRIANGLE);
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
} }
@Override @Override
public void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest) { public void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
// draw BG in any case: // draw BG in any case:
this.vectorialDraw.draw(); this.vectorialDraw.draw();
if (this.vbo.getVertexCount() <= 0 || this.font == null) { if (this.vbo.getVertexCount() <= 0 || this.font == null) {
// TODO : set it back ... // TODO : set it back ...
// Log.warning("Nothink to draw..."); // LOGGER.warn("Nothink to draw...");
return; return;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
if (enableDepthTest) { if (enableDepthTest) {
@ -156,14 +159,14 @@ public class CompositingText extends TextBase {
this.oGLprogram.uniformInt(this.oGLtextHeight, this.font.getOpenGlSize().x()); this.oGLprogram.uniformInt(this.oGLtextHeight, this.font.getOpenGlSize().x());
// Request the draw of the elements: // Request the draw of the elements:
this.vbo.renderArrays(OpenGL.RenderMode.TRIANGLE); this.vbo.renderArrays(OpenGL.RenderMode.TRIANGLE);
this.vbo.unBindForRendering(); this.vbo.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
if (enableDepthTest) { if (enableDepthTest) {
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
} }
} }
@Override @Override
public void flush() { public void flush() {
super.flush(); super.flush();
@ -176,57 +179,57 @@ public class CompositingText extends TextBase {
this.vbo.setVertexCount(this.pointPositions.size()); this.vbo.setVertexCount(this.pointPositions.size());
this.vbo.flush(); this.vbo.flush();
} }
@Override @Override
public GlyphProperty getGlyphPointer(final Character charcode) { public GlyphProperty getGlyphPointer(final Character charcode) {
if (this.font == null) { if (this.font == null) {
Log.warning("no font..."); LOGGER.warn("no font...");
return null; return null;
} }
return this.font.getGlyph(charcode, this.mode); return this.font.getGlyph(charcode, this.mode);
} }
@Override @Override
public float getHeight() { public float getHeight() {
if (this.font == null) { if (this.font == null) {
Log.warning("no font..."); LOGGER.warn("no font...");
return 10.0f; return 10.0f;
} }
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired; final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
return this.font.getHeight(this.mode) * renderRatio; return this.font.getHeight(this.mode) * renderRatio;
} }
@Override @Override
public float getSize() { public float getSize() {
if (this.font == null) { if (this.font == null) {
Log.warning("no font..."); LOGGER.warn("no font...");
return 1.0f; return 1.0f;
} }
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired; final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
return this.font.getFontSize() * renderRatio; return this.font.getFontSize() * renderRatio;
} }
@Override @Override
public void printChar(final Character charcode) { public void printChar(final Character charcode) {
//Log.error("Request printChar : '{}' @pos={}", charcode, this.position); //LOGGER.error("Request printChar : '{}' @pos={}", charcode, this.position);
// get a pointer on the glyph property : // get a pointer on the glyph property :
final GlyphProperty myGlyphProperty = getGlyphPointer(charcode); final GlyphProperty myGlyphProperty = getGlyphPointer(charcode);
if (myGlyphProperty == null) { if (myGlyphProperty == null) {
Log.error(" font does not really existed ..."); LOGGER.error(" font does not really existed ...");
return; return;
} }
// sometime we do net require the correct size to the glyph renderer (due to the fact SVG render is not clear on lower size...) // sometime we do net require the correct size to the glyph renderer (due to the fact SVG render is not clear on lower size...)
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired; final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
final int fontSize = (int) (getSize() * renderRatio); final int fontSize = (int) (getSize() * renderRatio);
final int fontHeigh = (int) (getHeight() * renderRatio); final int fontHeigh = (int) (getHeight() * renderRatio);
// get the kerning offset : // get the kerning offset :
float kerningOffset = 0; float kerningOffset = 0;
if (this.kerning) { if (this.kerning) {
kerningOffset = myGlyphProperty.kerningGet(this.previousCharcode) * renderRatio; kerningOffset = myGlyphProperty.kerningGet(this.previousCharcode) * renderRatio;
if (kerningOffset != 0) { if (kerningOffset != 0) {
// Log.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.UVal // LOGGER.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.UVal
// + "' value : " + kerningOffset); // + "' value : " + kerningOffset);
} }
} }
@ -237,16 +240,18 @@ public class CompositingText extends TextBase {
*/ */
float dxA = this.position.x() + myGlyphProperty.getTextureRenderOffset().x() * renderRatio + kerningOffset; float dxA = this.position.x() + myGlyphProperty.getTextureRenderOffset().x() * renderRatio + kerningOffset;
float dxB = dxA + myGlyphProperty.sizeTexture.x() * renderRatio; float dxB = dxA + myGlyphProperty.sizeTexture.x() * renderRatio;
float dyC = this.position.y() + myGlyphProperty.getTextureRenderOffset().y() * renderRatio + fontHeigh - fontSize; float dyC = this.position.y() + myGlyphProperty.getTextureRenderOffset().y() * renderRatio + fontHeigh
- fontSize;
float dyD = dyC - myGlyphProperty.sizeTexture.y() * renderRatio; float dyD = dyC - myGlyphProperty.sizeTexture.y() * renderRatio;
float tuA = myGlyphProperty.texturePosStart.x(); float tuA = myGlyphProperty.texturePosStart.x();
float tuB = tuA + myGlyphProperty.texturePosSize.x(); float tuB = tuA + myGlyphProperty.texturePosSize.x();
float tvC = myGlyphProperty.texturePosStart.y(); float tvC = myGlyphProperty.texturePosStart.y();
float tvD = tvC + myGlyphProperty.texturePosSize.y(); float tvD = tvC + myGlyphProperty.texturePosSize.y();
// Clipping and drawing area // Clipping and drawing area
if (this.clippingEnable && (dxB < this.clippingPosStart.x() || dxA > this.clippingPosStop.x() || dyC < this.clippingPosStart.y() || dyD > this.clippingPosStop.y())) { if (this.clippingEnable && (dxB < this.clippingPosStart.x() || dxA > this.clippingPosStop.x()
|| dyC < this.clippingPosStart.y() || dyD > this.clippingPosStop.y())) {
// Nothing to display ... // Nothing to display ...
} else { } else {
if (this.clippingEnable) { if (this.clippingEnable) {
@ -307,11 +312,11 @@ public class CompositingText extends TextBase {
final Vector2f texturePos1 = new Vector2f(tuB + this.mode.getValue(), tvC); final Vector2f texturePos1 = new Vector2f(tuB + this.mode.getValue(), tvC);
final Vector2f texturePos2 = new Vector2f(tuB + this.mode.getValue(), tvD); final Vector2f texturePos2 = new Vector2f(tuB + this.mode.getValue(), tvD);
final Vector2f texturePos3 = new Vector2f(tuA + this.mode.getValue(), tvD); final Vector2f texturePos3 = new Vector2f(tuA + this.mode.getValue(), tvD);
// NOTE : Android does not support the Quads elements ... // NOTE : Android does not support the Quads elements ...
/* /*
* Step 1 : ******** ****** **** ** * Step 1 : ******** ****** **** **
* *
*/ */
// set texture coordinates : // set texture coordinates :
this.texturePositions.add(texturePos0); this.texturePositions.add(texturePos0);
@ -327,7 +332,7 @@ public class CompositingText extends TextBase {
this.colors.add(this.color); this.colors.add(this.color);
/* /*
* Step 2 : * Step 2 :
* *
* ** **** ****** ******** * ** **** ****** ********
*/ */
// set texture coordinates : // set texture coordinates :
@ -346,21 +351,22 @@ public class CompositingText extends TextBase {
} }
} }
// move the position : // move the position :
// Log.debug(" 5 pos=" + this.position + " advance=" + myGlyph.advance.x() + " // LOGGER.debug(" 5 pos=" + this.position + " advance=" + myGlyph.advance.x() + "
// kerningOffset=" + kerningOffset); // kerningOffset=" + kerningOffset);
this.position = this.position.withX(this.position.x() + myGlyphProperty.getAdvenceX() * renderRatio + kerningOffset); this.position = this.position
// Log.debug(" 6 print '" + char-code + "' : start=" + this.sizeDisplayStart + " .withX(this.position.x() + myGlyphProperty.getAdvenceX() * renderRatio + kerningOffset);
// LOGGER.debug(" 6 print '" + char-code + "' : start=" + this.sizeDisplayStart + "
// stop=" + this.sizeDisplayStop + " pos=" + this.position); // stop=" + this.sizeDisplayStop + " pos=" + this.position);
// Register the previous character // Register the previous character
this.previousCharcode = charcode; this.previousCharcode = charcode;
} }
@Override @Override
public void setFont(final String inputFontName, final int inputFontSize) { public void setFont(final String inputFontName, final int inputFontSize) {
if (inputFontName.equals(this.currentFontName) && inputFontSize == this.currentFontSize) { if (inputFontName.equals(this.currentFontName) && inputFontSize == this.currentFontSize) {
return; return;
} }
String fontName = inputFontName; String fontName = inputFontName;
int fontSize = inputFontSize; int fontSize = inputFontSize;
// remove old one // remove old one
@ -371,7 +377,7 @@ public class CompositingText extends TextBase {
if (fontName.isEmpty()) { if (fontName.isEmpty()) {
fontName = Configs.getConfigFonts().getName(); fontName = Configs.getConfigFonts().getName();
} }
// if size in under 25, we request upper size: // if size in under 25, we request upper size:
int sizeRequest = 25; int sizeRequest = 25;
if (this.forceClimp) { if (this.forceClimp) {
@ -383,18 +389,18 @@ public class CompositingText extends TextBase {
this.currentFontSize = inputFontSize; this.currentFontSize = inputFontSize;
return; return;
} }
clear(); clear();
final Uri fontUri = Configs.getConfigFonts().getFontUri(fontName).clone(); final Uri fontUri = Configs.getConfigFonts().getFontUri(fontName).clone();
fontUri.setProperty("size", Integer.toString(sizeRequest)); fontUri.setProperty("size", Integer.toString(sizeRequest));
Log.verbose("plop : " + fontName + " size=" + sizeRequest + " result :" + fontName); LOGGER.trace("plop : " + fontName + " size=" + sizeRequest + " result :" + fontName);
// link to new one // link to new one
if (this.forceClimp) { if (this.forceClimp) {
fontUri.setProperty("FORCE_CLIMP", "true"); fontUri.setProperty("FORCE_CLIMP", "true");
} }
this.font = ResourceTexturedFont.create(fontUri); this.font = ResourceTexturedFont.create(fontUri);
if (this.font == null) { if (this.font == null) {
Log.error("Can not get font resource"); LOGGER.error("Can not get font resource");
this.font = previousFont; this.font = previousFont;
} else { } else {
this.currentFontName = inputFontName; this.currentFontName = inputFontName;
@ -402,22 +408,22 @@ public class CompositingText extends TextBase {
this.currentFontSizeRequired = sizeRequest; this.currentFontSizeRequired = sizeRequest;
} }
} }
@Override @Override
public void setFontMode(final FontMode mode) { public void setFontMode(final FontMode mode) {
if (this.font != null) { if (this.font != null) {
this.mode = this.font.getWrappingMode(mode); this.mode = this.font.getWrappingMode(mode);
} }
} }
@Override @Override
public void setFontName(final String fontName) { public void setFontName(final String fontName) {
setFont(fontName, this.currentFontSize); setFont(fontName, this.currentFontSize);
} }
@Override @Override
public void setFontSize(final int fontSize) { public void setFontSize(final int fontSize) {
setFont(this.currentFontName, fontSize); setFont(this.currentFontName, fontSize);
} }
} }

View File

@ -13,7 +13,6 @@ import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.event.EventTime; import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceConfigFile; import org.atriasoft.ewol.resource.ResourceConfigFile;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.Flag; import org.atriasoft.gale.backend3d.OpenGL.Flag;
@ -21,6 +20,8 @@ import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceTexture2; import org.atriasoft.gale.resource.ResourceTexture2;
import org.atriasoft.loader3d.resources.ResourceMesh; import org.atriasoft.loader3d.resources.ResourceMesh;
import org.atriasoft.loader3d.resources.ResourcePaletteFile; import org.atriasoft.loader3d.resources.ResourcePaletteFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @brief the Shaper system is a basic theme configuration for every widget, it corresponds at a background display described by a pool of files * @brief the Shaper system is a basic theme configuration for every widget, it corresponds at a background display described by a pool of files
@ -28,13 +29,15 @@ import org.atriasoft.loader3d.resources.ResourcePaletteFile;
// TODO : load image // TODO : load image
// TODO : Abstaraction between states (call by name and the system greate IDs // TODO : Abstaraction between states (call by name and the system greate IDs
public class GuiShape extends Compositing { public class GuiShape extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(GuiShape.class);
private class SpecificValues { private class SpecificValues {
public Matrix4f transform = Matrix4f.IDENTITY; public Matrix4f transform = Matrix4f.IDENTITY;
public Vector3f offsetScaleInside = Vector3f.ZERO; public Vector3f offsetScaleInside = Vector3f.ZERO;
public Vector3f offsetScaleOutside = Vector3f.ZERO; public Vector3f offsetScaleOutside = Vector3f.ZERO;
public ResourceMesh mesh = null; public ResourceMesh mesh = null;
} }
private static final int SHAPER_POS_BOTTOM = 3; private static final int SHAPER_POS_BOTTOM = 3;
private static final int SHAPER_POS_LEFT = 0; private static final int SHAPER_POS_LEFT = 0;
private static final int SHAPER_POS_RIGHT = 2; private static final int SHAPER_POS_RIGHT = 2;
@ -43,7 +46,7 @@ public class GuiShape extends Compositing {
private int confIdPaletteFile = -1; //!< Palette of the display private int confIdPaletteFile = -1; //!< Palette of the display
private final int[] confIdPaddingIn = new int[4]; //!< Padding in property : X-left X-right Y-top Y-buttom private final int[] confIdPaddingIn = new int[4]; //!< Padding in property : X-left X-right Y-top Y-buttom
private final int[] confIdPaddingOut = new int[4]; //!< Padding out property : X-left X-right Y-top Y-buttom private final int[] confIdPaddingOut = new int[4]; //!< Padding out property : X-left X-right Y-top Y-buttom
// External theme configuration: // External theme configuration:
private ResourceConfigFile config = null; //!< pointer on the config file resources private ResourceConfigFile config = null; //!< pointer on the config file resources
private int confObjectFile = -1; //!< Config Id of the object file to display private int confObjectFile = -1; //!< Config Id of the object file to display
@ -59,7 +62,7 @@ public class GuiShape extends Compositing {
private int oGLPaletteOffset = -1; //!< openGL id on the element (offset for the palet rendering) private int oGLPaletteOffset = -1; //!< openGL id on the element (offset for the palet rendering)
private int oGLOffsetScaleInside = -1; private int oGLOffsetScaleInside = -1;
private int oGLOffsetScaleOutside = -1; private int oGLOffsetScaleOutside = -1;
// openGL shaders programs: // openGL shaders programs:
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
// For the Image : // For the Image :
@ -69,13 +72,13 @@ public class GuiShape extends Compositing {
private int stateActivate = -1; //!< Activate state of the element private int stateActivate = -1; //!< Activate state of the element
private GuiShapeMode stateNew = GuiShapeMode.NORMAL; //!< destination state private GuiShapeMode stateNew = GuiShapeMode.NORMAL; //!< destination state
private GuiShapeMode stateOld = GuiShapeMode.NORMAL; //!< previous state private GuiShapeMode stateOld = GuiShapeMode.NORMAL; //!< previous state
private Uri uri; //!< Name of the configuration of the shaper. private Uri uri; //!< Name of the configuration of the shaper.
private final SpecificValues[] valueSpecific = new SpecificValues[2]; private final SpecificValues[] valueSpecific = new SpecificValues[2];
// dynamic change: // dynamic change:
private float stateTransition = 0; //!< working state between 2 states private float stateTransition = 0; //!< working state between 2 states
/** /**
* @brief generic constructor * @brief generic constructor
* @param _uri URI of the file that might be loaded * @param _uri URI of the file that might be loaded
@ -92,7 +95,7 @@ public class GuiShape extends Compositing {
loadPalette(); loadPalette();
loadProgram(); loadProgram();
} }
/** /**
* @brief change the current status in an other * @brief change the current status in an other
* @param _newStatusId the next new status requested * @param _newStatusId the next new status requested
@ -109,13 +112,13 @@ public class GuiShape extends Compositing {
} }
return false; return false;
} }
/** /**
* @brief clear alll tre registered element in the current element * @brief clear alll tre registered element in the current element
*/ */
@Override @Override
public void clear() {} public void clear() {}
/** /**
* @brief draw All the registered text in the current element on openGL * @brief draw All the registered text in the current element on openGL
*/ */
@ -123,32 +126,33 @@ public class GuiShape extends Compositing {
public void draw(final boolean disableDepthTest) { public void draw(final boolean disableDepthTest) {
draw(null, disableDepthTest); draw(null, disableDepthTest);
} }
public void draw(final boolean disableDepthTest, final int idMesh) { public void draw(final boolean disableDepthTest, final int idMesh) {
draw(null, disableDepthTest, idMesh); draw(null, disableDepthTest, idMesh);
} }
public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest) { public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest) {
this.draw(secondaryTexture, disableDepthTest, 0); this.draw(secondaryTexture, disableDepthTest, 0);
} }
public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest, final int idMesh) { public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest, final int idMesh) {
if (this.config == null) { if (this.config == null) {
// this is a normal case ... the user can choice to have no config basic file ... // this is a normal case ... the user can choice to have no config basic file ...
return; return;
} }
if (idMesh == 0 && this.valueSpecific[0] == null) { if (idMesh == 0 && this.valueSpecific[0] == null) {
Log.error("No Object (0) to display ..."); LOGGER.error("No Object (0) to display ...");
return; return;
} else if (idMesh == 1 && this.valueSpecific[1] == null) { } else if (idMesh == 1 && this.valueSpecific[1] == null) {
Log.error("No Object (1) to display ..."); LOGGER.error("No Object (1) to display ...");
return; return;
} else if (idMesh < 0 && idMesh > 1) { } else if (idMesh < 0 && idMesh > 1) {
Log.critical("No Object (" + idMesh + ") to display [0..1]"); LOGGER.error("No Object (" + idMesh + ") to display [0..1]");
System.exit(-1);
return; return;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
OpenGL.enable(Flag.flag_depthTest); OpenGL.enable(Flag.flag_depthTest);
@ -161,9 +165,9 @@ public class GuiShape extends Compositing {
this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, tmpMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix);
final Set<String> layers = this.valueSpecific[idMesh].mesh.getLayers(); final Set<String> layers = this.valueSpecific[idMesh].mesh.getLayers();
Log.verbose("get layers:" + layers); LOGGER.trace("get layers:" + layers);
// Texture: // Texture:
final float imageDelta = (float) 1 / ResourcePaletteFile.getHeight(); final float imageDelta = (float) 1 / ResourcePaletteFile.getHeight();
float basicValue = this.stateOld.getValue() / ResourcePaletteFile.getHeight(); float basicValue = this.stateOld.getValue() / ResourcePaletteFile.getHeight();
@ -188,37 +192,38 @@ public class GuiShape extends Compositing {
} }
} }
} }
Log.verbose("colorDelta = " + basicValue + " old = " + this.stateOld + "(" + this.stateOld.getValue() * imageDelta + ") new = " + this.stateNew + "(" + this.stateNew.getValue() * imageDelta LOGGER.trace(
+ ")"); "colorDelta = " + basicValue + " old = " + this.stateOld + "(" + this.stateOld.getValue() * imageDelta
+ ") new = " + this.stateNew + "(" + this.stateNew.getValue() * imageDelta + ")");
this.oGLprogram.uniformFloat(this.oGLPaletteOffset, basicValue); this.oGLprogram.uniformFloat(this.oGLPaletteOffset, basicValue);
//Log.verbose("plop: " + this.offsetScaleOutside); //LOGGER.trace("plop: " + this.offsetScaleOutside);
//Log.verbose("plop: " + this.offsetScaleInside); //LOGGER.trace("plop: " + this.offsetScaleInside);
this.oGLprogram.uniformVector(this.oGLOffsetScaleInside, this.valueSpecific[idMesh].offsetScaleInside); this.oGLprogram.uniformVector(this.oGLOffsetScaleInside, this.valueSpecific[idMesh].offsetScaleInside);
this.oGLprogram.uniformVector(this.oGLOffsetScaleOutside, this.valueSpecific[idMesh].offsetScaleOutside); this.oGLprogram.uniformVector(this.oGLOffsetScaleOutside, this.valueSpecific[idMesh].offsetScaleOutside);
this.texture.bindForRendering(0); this.texture.bindForRendering(0);
this.valueSpecific[idMesh].mesh.render("palette"); this.valueSpecific[idMesh].mesh.render("palette");
if (secondaryTexture != null) { if (secondaryTexture != null) {
this.oGLprogram.uniformFloat(this.oGLPaletteOffset, 0); this.oGLprogram.uniformFloat(this.oGLPaletteOffset, 0);
secondaryTexture.bindForRendering(0); secondaryTexture.bindForRendering(0);
this.valueSpecific[idMesh].mesh.render("gui_dynamic_1"); this.valueSpecific[idMesh].mesh.render("gui_dynamic_1");
} }
// Request the draw of the elements: // Request the draw of the elements:
this.valueSpecific[idMesh].mesh.render(); this.valueSpecific[idMesh].mesh.render();
this.valueSpecific[idMesh].mesh.unBindForRendering(); this.valueSpecific[idMesh].mesh.unBindForRendering();
this.oGLprogram.unUse(); this.oGLprogram.unUse();
OpenGL.disable(Flag.flag_depthTest); OpenGL.disable(Flag.flag_depthTest);
} }
@Override @Override
public void flush() { public void flush() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/** /**
* @brief get the padding declared by the user in the config file * @brief get the padding declared by the user in the config file
* @return the padding property * @return the padding property
@ -226,7 +231,7 @@ public class GuiShape extends Compositing {
public Padding getBorder() { public Padding getBorder() {
return this.sizeObject; return this.sizeObject;
} }
/** /**
* @brief get the current displayed status of the shaper * @brief get the current displayed status of the shaper
* @return The Status Id * @return The Status Id
@ -234,7 +239,7 @@ public class GuiShape extends Compositing {
public GuiShapeMode getCurrentDisplayedStatus() { public GuiShapeMode getCurrentDisplayedStatus() {
return this.stateNew; return this.stateNew;
} }
/** /**
* @brief get the next displayed status of the shaper * @brief get the next displayed status of the shaper
* @return The next status Id (-1 if no status in next) * @return The next status Id (-1 if no status in next)
@ -242,7 +247,7 @@ public class GuiShape extends Compositing {
public GuiShapeMode getNextDisplayedStatus() { public GuiShapeMode getNextDisplayedStatus() {
return this.nextStatusRequested; return this.nextStatusRequested;
} }
/** /**
* @brief get the padding declared by the user in the config file * @brief get the padding declared by the user in the config file
* @return the padding property * @return the padding property
@ -250,25 +255,29 @@ public class GuiShape extends Compositing {
public Padding getPadding() { public Padding getPadding() {
return getPaddingOut().add(getBorder()).add(getPaddingIn()); return getPaddingOut().add(getBorder()).add(getPaddingIn());
} }
public Padding getPaddingIn() { public Padding getPaddingIn() {
Padding out = Padding.ZERO; Padding out = Padding.ZERO;
if (this.config != null) { if (this.config != null) {
out = new Padding(this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_LEFT]), this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_TOP]), out = new Padding(this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_LEFT]),
this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_RIGHT]), this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_BOTTOM])); this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_TOP]),
this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_RIGHT]),
this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_BOTTOM]));
} }
return out; return out;
} }
public Padding getPaddingOut() { public Padding getPaddingOut() {
Padding out = Padding.ZERO; Padding out = Padding.ZERO;
if (this.config != null) { if (this.config != null) {
out = new Padding(this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_LEFT]), this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_TOP]), out = new Padding(this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_LEFT]),
this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_RIGHT]), this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_BOTTOM])); this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_TOP]),
this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_RIGHT]),
this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_BOTTOM]));
} }
return out; return out;
} }
/** /**
* @brief get the shaper file Source * @brief get the shaper file Source
* @return the shapper file name * @return the shapper file name
@ -276,7 +285,7 @@ public class GuiShape extends Compositing {
public Uri getSource() { public Uri getSource() {
return this.uri; return this.uri;
} }
/** /**
* @brief get the current transition status * @brief get the current transition status
* @return value of the transition status (0.0f when no activity) * @return value of the transition status (0.0f when no activity)
@ -284,7 +293,7 @@ public class GuiShape extends Compositing {
public float getTransitionStatus() { public float getTransitionStatus() {
return this.stateTransition; return this.stateTransition;
} }
/** /**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources. * @return the validity od the resources.
@ -292,10 +301,10 @@ public class GuiShape extends Compositing {
public boolean hasSources() { public boolean hasSources() {
return this.oGLprogram != null; return this.oGLprogram != null;
} }
private void loadConfigFile() { private void loadConfigFile() {
if (this.uri.isEmpty()) { if (this.uri.isEmpty()) {
Log.debug("no Shaper set for loading resources ..."); LOGGER.debug("no Shaper set for loading resources ...");
return; return;
} }
this.config = ResourceConfigFile.create(this.uri); this.config = ResourceConfigFile.create(this.uri);
@ -316,14 +325,14 @@ public class GuiShape extends Compositing {
this.confIdPaletteFile = this.config.request("palette"); this.confIdPaletteFile = this.config.request("palette");
} }
} }
protected void loadPalette() { protected void loadPalette() {
final String paletteFile = this.config.getString(this.confIdPaletteFile); final String paletteFile = this.config.getString(this.confIdPaletteFile);
final Uri paletteFileInterface = Uri.valueOf(paletteFile); final Uri paletteFileInterface = Uri.valueOf(paletteFile);
this.palette = ResourcePaletteFile.create(paletteFileInterface); this.palette = ResourcePaletteFile.create(paletteFileInterface);
this.texture = ResourceTexture2.createNamed("TEXTURE_OF_PALETTE:" + paletteFile); this.texture = ResourceTexture2.createNamed("TEXTURE_OF_PALETTE:" + paletteFile);
if (this.texture == null) { if (this.texture == null) {
Log.error("can not instanciate Texture ..."); LOGGER.error("can not instanciate Texture ...");
} }
// element already called // element already called
loadPaletteUpdate(); loadPaletteUpdate();
@ -332,26 +341,27 @@ public class GuiShape extends Compositing {
loadPaletteUpdate(); loadPaletteUpdate();
}); });
} }
protected void loadPaletteUpdate() { protected void loadPaletteUpdate() {
Log.warning("update palet environnement"); LOGGER.warn("update palet environnement");
final ImageByte img = this.palette.getImageByte(); final ImageByte img = this.palette.getImageByte();
//IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp.png"), img); //IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp.png"), img);
this.texture.set(img); this.texture.set(img);
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
private void loadProgram() { private void loadProgram() {
if (this.config == null) { if (this.config == null) {
Log.debug("no Shaper set for loading resources ..."); LOGGER.debug("no Shaper set for loading resources ...");
return; return;
} }
final String basicShaderFileVert = this.config.getString(this.confProgramFileVert); final String basicShaderFileVert = this.config.getString(this.confProgramFileVert);
final String basicShaderFileFrag = this.config.getString(this.confProgramFileFrag); final String basicShaderFileFrag = this.config.getString(this.confProgramFileFrag);
if (!basicShaderFileVert.isEmpty() && !basicShaderFileFrag.isEmpty()) { if (!basicShaderFileVert.isEmpty() && !basicShaderFileFrag.isEmpty()) {
this.oGLprogram = ResourceProgram.create(Uri.valueOf(basicShaderFileVert), Uri.valueOf(basicShaderFileFrag)); this.oGLprogram = ResourceProgram.create(Uri.valueOf(basicShaderFileVert),
Uri.valueOf(basicShaderFileFrag));
if (this.oGLprogram != null) { if (this.oGLprogram != null) {
this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation"); this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation");
this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection"); this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection");
@ -362,13 +372,13 @@ public class GuiShape extends Compositing {
} }
} }
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
private void loadUpdateObjectSize() { private void loadUpdateObjectSize() {
if (this.config == null) { if (this.config == null) {
Log.debug("no Shaper set for loading resources ..."); LOGGER.debug("no Shaper set for loading resources ...");
return; return;
} }
final String objectFile = this.config.getString(this.confObjectFile); final String objectFile = this.config.getString(this.confObjectFile);
@ -385,16 +395,17 @@ public class GuiShape extends Compositing {
float font = 0; float font = 0;
// estimate size of border: // estimate size of border:
if (verticesToModify == null) { if (verticesToModify == null) {
Log.critical("Element is null : verticesToModify 1"); LOGGER.error("Element is null : verticesToModify 1");
System.exit(-1);
return; return;
} }
for (int iii = 0; iii < verticesToModify.size(); iii++) { for (final Vector3f element : verticesToModify) {
left = Math.min(left, verticesToModify.get(iii).x()); left = Math.min(left, element.x());
right = Math.max(right, verticesToModify.get(iii).x()); right = Math.max(right, element.x());
top = Math.min(top, verticesToModify.get(iii).y()); top = Math.min(top, element.y());
bottom = Math.max(bottom, verticesToModify.get(iii).y()); bottom = Math.max(bottom, element.y());
back = Math.min(back, verticesToModify.get(iii).z()); back = Math.min(back, element.z());
font = Math.max(font, verticesToModify.get(iii).z()); font = Math.max(font, element.z());
} }
this.sizeObject = new Padding(Math.abs(left), Math.abs(top), Math.abs(right), Math.abs(bottom)); this.sizeObject = new Padding(Math.abs(left), Math.abs(top), Math.abs(right), Math.abs(bottom));
} else { } else {
@ -415,23 +426,24 @@ public class GuiShape extends Compositing {
float font = 0; float font = 0;
// estimate size of border: // estimate size of border:
if (verticesToModify == null) { if (verticesToModify == null) {
Log.critical("Element is null : verticesToModify 2"); LOGGER.error("Element is null : verticesToModify 2");
System.exit(-1);
return; return;
} }
for (int iii = 0; iii < verticesToModify.size(); iii++) { for (final Vector3f element : verticesToModify) {
left = Math.min(left, verticesToModify.get(iii).x()); left = Math.min(left, element.x());
right = Math.max(right, verticesToModify.get(iii).x()); right = Math.max(right, element.x());
top = Math.min(top, verticesToModify.get(iii).y()); top = Math.min(top, element.y());
bottom = Math.max(bottom, verticesToModify.get(iii).y()); bottom = Math.max(bottom, element.y());
back = Math.min(back, verticesToModify.get(iii).z()); back = Math.min(back, element.z());
font = Math.max(font, verticesToModify.get(iii).z()); font = Math.max(font, element.z());
} }
} else { } else {
final int idMesh = 1; final int idMesh = 1;
this.valueSpecific[idMesh] = null; this.valueSpecific[idMesh] = null;
} }
} }
/** /**
* @brief Same as the widfget periodic call (this is for change display) * @brief Same as the widfget periodic call (this is for change display)
* @param event The current time of the call. * @param event The current time of the call.
@ -439,7 +451,8 @@ public class GuiShape extends Compositing {
* @return false No need to request the periodic call. * @return false No need to request the periodic call.
*/ */
public boolean periodicCall(final EventTime event) { public boolean periodicCall(final EventTime event) {
Log.verbose("call=" + event.getTimeDeltaCallSecond() + "s state transition=" + this.stateTransition + " speedTime=" + this.config.getNumber(this.confIdChangeTime)); LOGGER.trace("call=" + event.getTimeDeltaCallSecond() + "s state transition=" + this.stateTransition
+ " speedTime=" + this.config.getNumber(this.confIdChangeTime));
// start : // start :
if (this.stateTransition >= 1.0) { if (this.stateTransition >= 1.0) {
this.stateOld = this.stateNew; this.stateOld = this.stateNew;
@ -451,7 +464,7 @@ public class GuiShape extends Compositing {
this.stateNew = this.nextStatusRequested; this.stateNew = this.nextStatusRequested;
this.nextStatusRequested = GuiShapeMode.NONE; this.nextStatusRequested = GuiShapeMode.NONE;
this.stateTransition = 0.0f; this.stateTransition = 0.0f;
Log.verbose(" ##### START ##### "); LOGGER.trace(" ##### START ##### ");
return true; return true;
} }
if (this.stateTransition < 1.0) { if (this.stateTransition < 1.0) {
@ -473,11 +486,11 @@ public class GuiShape extends Compositing {
this.stateTransition += event.getTimeDeltaCallSecond() / timeRelativity; this.stateTransition += event.getTimeDeltaCallSecond() / timeRelativity;
//stateTransition += _event.getDeltaCall(); //stateTransition += _event.getDeltaCall();
this.stateTransition = FMath.avg(0.0f, this.stateTransition, 1.0f); this.stateTransition = FMath.avg(0.0f, this.stateTransition, 1.0f);
Log.verbose("relative=" + timeRelativity + " Transition : " + this.stateTransition); LOGGER.trace("relative=" + timeRelativity + " Transition : " + this.stateTransition);
} }
return true; return true;
} }
/** /**
* @brief Set activate state of the element * @brief Set activate state of the element
* @param _status New activate status * @param _status New activate status
@ -485,16 +498,22 @@ public class GuiShape extends Compositing {
public void setActivateState(final int status) { public void setActivateState(final int status) {
this.stateActivate = status; this.stateActivate = status;
} }
public void setShape(final int idMesh, final Vector3f origin, final Vector3f size) { public void setShape(final int idMesh, final Vector3f origin, final Vector3f size) {
final Padding tmp = getPadding(); final Padding tmp = getPadding();
setShape(idMesh, origin, size, origin.add(tmp.left(), tmp.bottom(), 0), size.less(tmp.x(), tmp.y(), 0)); setShape(idMesh, origin, size, origin.add(tmp.left(), tmp.bottom(), 0), size.less(tmp.x(), tmp.y(), 0));
} }
public void setShape(final int idMesh, final Vector3f origin, final Vector3f size, final Vector3f insidePos, final Vector3f insideSize) { public void setShape(
final int idMesh,
final Vector3f origin,
final Vector3f size,
final Vector3f insidePos,
final Vector3f insideSize) {
final Vector3f halfSize = insideSize.multiply(0.5f); final Vector3f halfSize = insideSize.multiply(0.5f);
this.valueSpecific[idMesh].offsetScaleOutside = halfSize; this.valueSpecific[idMesh].offsetScaleOutside = halfSize;
this.valueSpecific[idMesh].offsetScaleInside = halfSize.add(this.sizeObject.x() * 0.25f, this.sizeObject.y() * 0.25f, 0); this.valueSpecific[idMesh].offsetScaleInside = halfSize.add(this.sizeObject.x() * 0.25f,
this.sizeObject.y() * 0.25f, 0);
/* /*
List<Vector3f> verticesToModify = this.mesh.getGeneratedPosition(); List<Vector3f> verticesToModify = this.mesh.getGeneratedPosition();
float[] newVertices = new float[verticesToModify.size()*3]; float[] newVertices = new float[verticesToModify.size()*3];
@ -506,25 +525,26 @@ public class GuiShape extends Compositing {
} }
this.mesh.setModifiedPosition(newVertices); this.mesh.setModifiedPosition(newVertices);
*/ */
this.valueSpecific[idMesh].transform = Matrix4f.createMatrixTranslate(new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, origin.z() + size.z() * 0.5f)); this.valueSpecific[idMesh].transform = Matrix4f.createMatrixTranslate(
new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, origin.z() + size.z() * 0.5f));
} }
// private float getUpdatedPos(final float value, final float halfsize) { // private float getUpdatedPos(final float value, final float halfsize) {
// if (value <= 0.0f) { // if (value <= 0.0f) {
// return value - halfsize; // return value - halfsize;
// } // }
// return value + halfsize; // return value + halfsize;
// } // }
// @previous // @previous
public void setShape(final Vector2f origin, final Vector2f size) { public void setShape(final Vector2f origin, final Vector2f size) {
final Padding tmp = getPadding(); final Padding tmp = getPadding();
setShape(origin, size, origin.add(tmp.left(), tmp.bottom()), size.less(tmp.x(), tmp.y())); setShape(origin, size, origin.add(tmp.left(), tmp.bottom()), size.less(tmp.x(), tmp.y()));
} }
/** /**
* @brief set the shape property: * @brief set the shape property:
* *
* ******************************************************************************** * ********************************************************************************
* * size * * * size *
* * * * * *
@ -564,11 +584,16 @@ public class GuiShape extends Compositing {
* @param center Center of the object * @param center Center of the object
* @param size Size of the display * @param size Size of the display
*/ */
public void setShape(final Vector2f origin, final Vector2f size, final Vector2f insidePos, final Vector2f insideSize) { public void setShape(
//Log.error("Set shape property : origin=" + origin + " size=" + size + " in-pos=" + insidePos + " in-size=" + insideSize); final Vector2f origin,
final Vector2f size,
final Vector2f insidePos,
final Vector2f insideSize) {
//LOGGER.error("Set shape property : origin=" + origin + " size=" + size + " in-pos=" + insidePos + " in-size=" + insideSize);
final Vector2f halfSize = insideSize.multiply(0.5f); final Vector2f halfSize = insideSize.multiply(0.5f);
final Vector3f offsetScaleOutside = new Vector3f(halfSize.x(), halfSize.y(), 1.0f); final Vector3f offsetScaleOutside = new Vector3f(halfSize.x(), halfSize.y(), 1.0f);
final Vector3f offsetScaleInside = new Vector3f(halfSize.x() + this.sizeObject.x() * 0.25f, halfSize.y() + this.sizeObject.y() * 0.25f, 1.0f); final Vector3f offsetScaleInside = new Vector3f(halfSize.x() + this.sizeObject.x() * 0.25f,
halfSize.y() + this.sizeObject.y() * 0.25f, 1.0f);
/* /*
List<Vector3f> verticesToModify = this.mesh.getGeneratedPosition(); List<Vector3f> verticesToModify = this.mesh.getGeneratedPosition();
float[] newVertices = new float[verticesToModify.size()*3]; float[] newVertices = new float[verticesToModify.size()*3];
@ -582,7 +607,8 @@ public class GuiShape extends Compositing {
//this.transform = this.transform.multiply(Matrix4f.createMatrixTranslate(new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, 0.0f))); //this.transform = this.transform.multiply(Matrix4f.createMatrixTranslate(new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, 0.0f)));
this.mesh.setModifiedPosition(newVertices); this.mesh.setModifiedPosition(newVertices);
*/ */
final Matrix4f transform = Matrix4f.createMatrixTranslate(new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, 0.0f)); final Matrix4f transform = Matrix4f
.createMatrixTranslate(new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, 0.0f));
for (int iii = 0; iii < 2; iii++) { for (int iii = 0; iii < 2; iii++) {
if (this.valueSpecific[iii] == null) { if (this.valueSpecific[iii] == null) {
continue; continue;
@ -592,13 +618,17 @@ public class GuiShape extends Compositing {
this.valueSpecific[iii].transform = transform; this.valueSpecific[iii].transform = transform;
} }
} }
public void setShape(final Vector3f origin, final Vector3f size) { public void setShape(final Vector3f origin, final Vector3f size) {
final Padding tmp = getPadding(); final Padding tmp = getPadding();
setShape(origin, size, origin.add(tmp.left(), tmp.bottom(), 0), size.less(tmp.x(), tmp.y(), 0)); setShape(origin, size, origin.add(tmp.left(), tmp.bottom(), 0), size.less(tmp.x(), tmp.y(), 0));
} }
public void setShape(final Vector3f origin, final Vector3f size, final Vector3f insidePos, final Vector3f insideSize) { public void setShape(
final Vector3f origin,
final Vector3f size,
final Vector3f insidePos,
final Vector3f insideSize) {
final Vector3f halfSize = insideSize.multiply(0.5f); final Vector3f halfSize = insideSize.multiply(0.5f);
final Vector3f offsetScaleOutside = halfSize; final Vector3f offsetScaleOutside = halfSize;
final Vector3f offsetScaleInside = halfSize.add(this.sizeObject.x() * 0.25f, this.sizeObject.y() * 0.25f, 0); final Vector3f offsetScaleInside = halfSize.add(this.sizeObject.x() * 0.25f, this.sizeObject.y() * 0.25f, 0);
@ -613,7 +643,8 @@ public class GuiShape extends Compositing {
} }
this.mesh.setModifiedPosition(newVertices); this.mesh.setModifiedPosition(newVertices);
*/ */
final Matrix4f transform = Matrix4f.createMatrixTranslate(new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, origin.z() + size.z() * 0.5f)); final Matrix4f transform = Matrix4f.createMatrixTranslate(
new Vector3f(origin.x() + size.x() * 0.5f, origin.y() + size.y() * 0.5f, origin.z() + size.z() * 0.5f));
for (int iii = 0; iii < 2; iii++) { for (int iii = 0; iii < 2; iii++) {
if (this.valueSpecific[iii] == null) { if (this.valueSpecific[iii] == null) {
continue; continue;
@ -623,7 +654,7 @@ public class GuiShape extends Compositing {
this.valueSpecific[iii].transform = transform; this.valueSpecific[iii].transform = transform;
} }
} }
/** /**
* @brief change the shaper Source * @brief change the shaper Source
* @param _uri New file of the shaper * @param _uri New file of the shaper
@ -637,7 +668,7 @@ public class GuiShape extends Compositing {
loadPalette(); loadPalette();
loadProgram(); loadProgram();
} }
/** /**
* @brief Change the current state * @brief Change the current state
* @param _newState Current state of the configuration * @param _newState Current state of the configuration
@ -651,7 +682,7 @@ public class GuiShape extends Compositing {
this.stateActivate = newState; this.stateActivate = newState;
return true; return true;
} }
/** /**
* @brief Un-Load the openGL program and get all the ID needed * @brief Un-Load the openGL program and get all the ID needed
*/ */

View File

@ -16,7 +16,6 @@ import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.util.Dynamic; import org.atriasoft.etk.util.Dynamic;
import org.atriasoft.ewol.compositing.tools.TextDecoration; import org.atriasoft.ewol.compositing.tools.TextDecoration;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.font.FontMode; import org.atriasoft.ewol.resource.font.FontMode;
import org.atriasoft.ewol.resource.font.GlyphProperty; import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.exml.Exml; import org.atriasoft.exml.Exml;
@ -28,8 +27,11 @@ import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.exml.model.XmlNode; import org.atriasoft.exml.model.XmlNode;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject; import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class TextBase extends Compositing { public abstract class TextBase extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(TextBase.class);
// previously this line and the center is perform with this one) // previously this line and the center is perform with this one)
protected AlignMode alignment = AlignMode.DISABLE; // !< Current Alignment mode (justify/left/right ...) protected AlignMode alignment = AlignMode.DISABLE; // !< Current Alignment mode (justify/left/right ...)
protected boolean clippingEnable = false; // !< true if the clipping must be activated protected boolean clippingEnable = false; // !< true if the clipping must be activated
@ -45,7 +47,7 @@ public abstract class TextBase extends Compositing {
protected Color defaultColorFg = Color.BLACK; // !< The text foreground color protected Color defaultColorFg = Color.BLACK; // !< The text foreground color
// this section is reserved for HTML parsing and display: // this section is reserved for HTML parsing and display:
public String htmlCurrentLine = ""; // !< current line for HTML display public String htmlCurrentLine = ""; // !< current line for HTML display
public List<TextDecoration> htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display public List<TextDecoration> htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed protected boolean kerning = true; // !< Kerning enable or disable on the next elements displayed
@ -69,18 +71,18 @@ public abstract class TextBase extends Compositing {
protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word protected float stopTextPos = 0; // !< end of the alignment (when a string is too height it cut at the word
protected ResourceVirtualArrayObject vbo = null; protected ResourceVirtualArrayObject vbo = null;
protected CompositingDrawing vectorialDraw = new CompositingDrawing(); protected CompositingDrawing vectorialDraw = new CompositingDrawing();
/** /**
* generic constructor * generic constructor
*/ */
public TextBase() { public TextBase() {
this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol")); this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol"));
} }
public TextBase(final Uri vertexShader, final Uri fragmentShader) { public TextBase(final Uri vertexShader, final Uri fragmentShader) {
this(vertexShader, fragmentShader, true); this(vertexShader, fragmentShader, true);
} }
public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) { public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) {
if (loadProgram) { if (loadProgram) {
loadProgram(vertexShader, fragmentShader); loadProgram(vertexShader, fragmentShader);
@ -90,7 +92,7 @@ public abstract class TextBase extends Compositing {
// 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 super.TextBase"); this.vbo.setName("[VBO] of super.TextBase");
} }
/** /**
* calculate a theoric charcode size * calculate a theoric charcode size
* @param charcode The Unicode value to calculate dimention. * @param charcode The Unicode value to calculate dimention.
@ -99,7 +101,7 @@ public abstract class TextBase extends Compositing {
public Vector3f calculateSize(final Character charcode) { public Vector3f calculateSize(final Character charcode) {
return calculateSizeChar(charcode); return calculateSizeChar(charcode);
} }
/** /**
* calculate a theoric text size * calculate a theoric text size
* @param text The string to calculate dimention. * @param text The string to calculate dimention.
@ -116,10 +118,10 @@ public abstract class TextBase extends Compositing {
} }
return outputSize; return outputSize;
} }
// ! @previous // ! @previous
public abstract Vector3f calculateSizeChar(Character charcode); public abstract Vector3f calculateSizeChar(Character charcode);
/** /**
* calculate a theoric text size * calculate a theoric text size
* @param text The string to calculate dimention. * @param text The string to calculate dimention.
@ -129,13 +131,13 @@ public abstract class TextBase extends Compositing {
if (text.length() == 0) { if (text.length() == 0) {
return Vector3f.ZERO; return Vector3f.ZERO;
} }
final StringBuilder tmpData = new StringBuilder("<html><body>\n"); final StringBuilder tmpData = new StringBuilder("<html><body>\n");
tmpData.append(text); tmpData.append(text);
tmpData.append("\n</body></html>\n"); tmpData.append("\n</body></html>\n");
return calculateSizeHTML(tmpData.toString()); return calculateSizeHTML(tmpData.toString());
} }
/** /**
* calculate a theoric text size * calculate a theoric text size
* @param text The string to calculate dimention. * @param text The string to calculate dimention.
@ -144,29 +146,31 @@ public abstract class TextBase extends Compositing {
public Vector3f calculateSizeHTML(final String text) { public Vector3f calculateSizeHTML(final String text) {
// remove intermediate result // remove intermediate result
reset(); reset();
// Log.debug(" 0 size for=\n" + text); // LOGGER.debug(" 0 size for=\n" + text);
// disable display system // disable display system
this.needDisplay = false; this.needDisplay = false;
setPos(Vector3f.ZERO); setPos(Vector3f.ZERO);
// same as print without the end display ... // same as print without the end display ...
printHTML(text); printHTML(text);
//Log.error(" ]]]] position={}", this.position); //LOGGER.error(" ]]]] position={}", this.position);
//Log.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart); //LOGGER.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
//Log.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop); //LOGGER.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
// get the last elements // get the last elements
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop); this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart); this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart);
// Log.debug(" 2 Start pos=" + this.sizeDisplayStart); // LOGGER.debug(" 2 Start pos=" + this.sizeDisplayStart);
// Log.debug(" 2 Stop pos=" + this.sizeDisplayStop); // LOGGER.debug(" 2 Stop pos=" + this.sizeDisplayStop);
// set back the display system // set back the display system
this.needDisplay = true; this.needDisplay = true;
return new Vector3f(this.sizeDisplayStop.x() - this.sizeDisplayStart.x(), this.sizeDisplayStop.y() - this.sizeDisplayStart.y(), this.sizeDisplayStop.z() - this.sizeDisplayStart.z()); return new Vector3f(this.sizeDisplayStop.x() - this.sizeDisplayStart.x(),
this.sizeDisplayStop.y() - this.sizeDisplayStart.y(),
this.sizeDisplayStop.z() - this.sizeDisplayStart.z());
} }
/** /**
* clear all the registered element in the current element * clear all the registered element in the current element
*/ */
@ -181,14 +185,14 @@ public abstract class TextBase extends Compositing {
// reset temporal variables: // reset temporal variables:
reset(); reset();
} }
/** /**
* disable the alignement system * disable the alignement system
*/ */
public void disableAlignement() { public void disableAlignement() {
this.alignment = AlignMode.DISABLE; this.alignment = AlignMode.DISABLE;
} }
/** /**
* remove the cursor display * remove the cursor display
*/ */
@ -196,7 +200,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = -100; this.selectionStartPos = -100;
this.cursorPos = -100; this.cursorPos = -100;
} }
/** /**
* draw All the registered text in the current element on openGL * draw All the registered text in the current element on openGL
*/ */
@ -204,20 +208,20 @@ public abstract class TextBase extends Compositing {
public void draw(final boolean disableDepthTest) { public void draw(final boolean disableDepthTest) {
drawD(disableDepthTest); drawD(disableDepthTest);
} }
// ! @previous // ! @previous
public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) { public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
drawMT(transformationMatrix, enableDepthTest); drawMT(transformationMatrix, enableDepthTest);
} }
/** /**
* draw All the refistered text in the current element on openGL * draw All the refistered text in the current element on openGL
*/ */
public abstract void drawD(final boolean disableDepthTest); public abstract void drawD(final boolean disableDepthTest);
// ! @previous // ! @previous
public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest); public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest);
/** /**
* calculate the element number that is the first out the alignment * calculate the element number that is the first out the alignment
* range (start at the specify ID, and use start pos with current one) * range (start at the specify ID, and use start pos with current one)
@ -230,24 +234,29 @@ public abstract class TextBase extends Compositing {
* @return true if the right has free space that can be use for justify. * @return true if the right has free space that can be use for justify.
* false if we find '\n' * false if we find '\n'
*/ */
public boolean extrapolateLastId(final String text, final int start, final Dynamic<Integer> stop, final Dynamic<Integer> space, final Dynamic<Integer> freeSpace) { public boolean extrapolateLastId(
final String text,
final int start,
final Dynamic<Integer> stop,
final Dynamic<Integer> space,
final Dynamic<Integer> freeSpace) {
// store previous : // store previous :
final Character storePrevious = this.previousCharcode; final Character storePrevious = this.previousCharcode;
stop.value = text.length(); stop.value = text.length();
space.value = 0; space.value = 0;
int lastSpacePosition = start; int lastSpacePosition = start;
int lastSpacefreeSize = 0; int lastSpacefreeSize = 0;
float endPos = this.position.x(); float endPos = this.position.x();
boolean endOfLine = false; boolean endOfLine = false;
float stopPosition = this.stopTextPos; float stopPosition = this.stopTextPos;
if (!this.needDisplay || this.stopTextPos == this.startTextPos) { if (!this.needDisplay || this.stopTextPos == this.startTextPos) {
stopPosition = this.startTextPos + 3999999999.0f; stopPosition = this.startTextPos + 3999999999.0f;
} }
for (int iii = start; iii < text.length(); iii++) { for (int iii = start; iii < text.length(); iii++) {
final Vector3f tmpSize = calculateSize(text.charAt(iii)); final Vector3f tmpSize = calculateSize(text.charAt(iii));
// check overflow : // check overflow :
@ -285,12 +294,12 @@ public abstract class TextBase extends Compositing {
freeSpace.value = lastSpacefreeSize; freeSpace.value = lastSpacefreeSize;
return false; return false;
} }
@Override @Override
public void flush() { public void flush() {
this.vectorialDraw.flush(); this.vectorialDraw.flush();
} }
/** /**
* This generate the line return == > it return to the alignment * This generate the line return == > it return to the alignment
* position start and at the correct line position ==> it might be use to * position start and at the correct line position ==> it might be use to
@ -300,7 +309,7 @@ public abstract class TextBase extends Compositing {
// reset position : // reset position :
setPos(new Vector3f(this.startTextPos, this.position.y() - getHeight(), 0)); setPos(new Vector3f(this.startTextPos, this.position.y() - getHeight(), 0));
} }
/** /**
* get the current alignment property * get the current alignment property
* @return the current alignment type * @return the current alignment type
@ -308,12 +317,12 @@ public abstract class TextBase extends Compositing {
public AlignMode getAlignment() { public AlignMode getAlignment() {
return this.alignment; return this.alignment;
} }
// This is used to draw background selection and other things ... // This is used to draw background selection and other things ...
public CompositingDrawing getDrawing() { public CompositingDrawing getDrawing() {
return this.vectorialDraw; return this.vectorialDraw;
} }
/** /**
* get the current font mode * get the current font mode
* @return The font mode applied * @return The font mode applied
@ -321,11 +330,11 @@ public abstract class TextBase extends Compositing {
public FontMode getFontMode() { public FontMode getFontMode() {
return this.mode; return this.mode;
} }
public abstract GlyphProperty getGlyphPointer(Character charcode); public abstract GlyphProperty getGlyphPointer(Character charcode);
public abstract float getHeight(); public abstract float getHeight();
/** /**
* get the current display position (sometime needed in the gui control) * get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
@ -333,16 +342,17 @@ public abstract class TextBase extends Compositing {
public Vector3f getPos() { public Vector3f getPos() {
return this.position; return this.position;
} }
public abstract float getSize(); public abstract float getSize();
/** /**
* add a line with the current this.htmlDecoTmp decoration * add a line with the current this.htmlDecoTmp decoration
* @param data The cuurent data to add. * @param data The cuurent data to add.
*/ */
public void htmlAddData(final String data) { public void htmlAddData(final String data) {
//Log.error("Add data '{}' @pos=", data, this.position); //LOGGER.error("Add data '{}' @pos=", data, this.position);
if (this.htmlCurrentLine.length() > 0 && this.htmlCurrentLine.charAt(this.htmlCurrentLine.length() - 1) != (char) Character.SPACE_SEPARATOR) { if (this.htmlCurrentLine.length() > 0
&& this.htmlCurrentLine.charAt(this.htmlCurrentLine.length() - 1) != (char) Character.SPACE_SEPARATOR) {
this.htmlCurrentLine += (char) Character.SPACE_SEPARATOR; this.htmlCurrentLine += (char) Character.SPACE_SEPARATOR;
if (this.htmlDecoration.size() > 0) { if (this.htmlDecoration.size() > 0) {
final TextDecoration tmp = this.htmlDecoration.get(this.htmlDecoration.size() - 1); final TextDecoration tmp = this.htmlDecoration.get(this.htmlDecoration.size() - 1);
@ -356,7 +366,7 @@ public abstract class TextBase extends Compositing {
this.htmlDecoration.add(this.htmlDecoTmp); this.htmlDecoration.add(this.htmlDecoTmp);
} }
} }
/** /**
* draw the current line * draw the current line
*/ */
@ -367,7 +377,7 @@ public abstract class TextBase extends Compositing {
this.htmlCurrentLine = ""; this.htmlCurrentLine = "";
this.htmlDecoration.clear(); this.htmlDecoration.clear();
} }
/** /**
* load the openGL program and get all the ID needed * load the openGL program and get all the ID needed
*/ */
@ -382,12 +392,12 @@ public abstract class TextBase extends Compositing {
this.oGLtextWidth = this.oGLprogram.getUniform("in_texWidth"); this.oGLtextWidth = this.oGLprogram.getUniform("in_texWidth");
this.oGLtextHeight = this.oGLprogram.getUniform("in_texHeight"); this.oGLtextHeight = this.oGLprogram.getUniform("in_texHeight");
} else { } else {
Log.error("Can not load the program => create previous one..."); LOGGER.error("Can not load the program => create previous one...");
this.oGLprogram = old; this.oGLprogram = old;
old = null; old = null;
} }
} }
/** /**
* This parse a tinyXML node (void pointer to permit to hide tiny XML in * This parse a tinyXML node (void pointer to permit to hide tiny XML in
* include). * include).
@ -401,21 +411,21 @@ public abstract class TextBase extends Compositing {
} }
if (it.isText()) { if (it.isText()) {
htmlAddData(it.getValue()); htmlAddData(it.getValue());
Log.verbose("XML add : " + it.getValue()); LOGGER.trace("XML add : " + it.getValue());
continue; continue;
} }
if (!it.isElement()) { if (!it.isElement()) {
Log.error("node not suported type : " + it.getType() + " val='" + it.getValue() + "'"); LOGGER.error("node not suported type : " + it.getType() + " val='" + it.getValue() + "'");
continue; continue;
} }
final XmlElement elem = (XmlElement) it; final XmlElement elem = (XmlElement) it;
final String lowercaseValue = elem.getValue().toLowerCase(); final String lowercaseValue = elem.getValue().toLowerCase();
if (lowercaseValue.contentEquals("br")) { if (lowercaseValue.contentEquals("br")) {
htmlFlush(); htmlFlush();
Log.verbose("XML flush newLine"); LOGGER.trace("XML flush newLine");
forceLineReturn(); forceLineReturn();
} else if (lowercaseValue.contentEquals("font")) { } else if (lowercaseValue.contentEquals("font")) {
Log.verbose("XML Font ..."); LOGGER.trace("XML Font ...");
final TextDecoration tmpDeco = this.htmlDecoTmp; final TextDecoration tmpDeco = this.htmlDecoTmp;
if (elem.existAttribute("color")) { if (elem.existAttribute("color")) {
try { try {
@ -424,10 +434,10 @@ public abstract class TextBase extends Compositing {
this.htmlDecoTmp = this.htmlDecoTmp.withFG(Color.valueOf(colorValue)); this.htmlDecoTmp = this.htmlDecoTmp.withFG(Color.valueOf(colorValue));
} }
} catch (final ExmlAttributeDoesNotExist e) { } catch (final ExmlAttributeDoesNotExist e) {
Log.error("Can not get attribute 'color' in XML:" + e.getMessage()); LOGGER.error("Can not get attribute 'color' in XML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (final Exception e) { } catch (final Exception e) {
Log.error("Can not parse attribute 'color' in XML:" + e.getMessage()); LOGGER.error("Can not parse attribute 'color' in XML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -438,17 +448,17 @@ public abstract class TextBase extends Compositing {
this.htmlDecoTmp = this.htmlDecoTmp.withBG(Color.valueOf(colorValue)); this.htmlDecoTmp = this.htmlDecoTmp.withBG(Color.valueOf(colorValue));
} }
} catch (final ExmlAttributeDoesNotExist e) { } catch (final ExmlAttributeDoesNotExist e) {
Log.error("Can not get attribute 'colorBg' in XML:" + e.getMessage()); LOGGER.error("Can not get attribute 'colorBg' in XML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (final Exception e) { } catch (final Exception e) {
Log.error("Can not parse attribute 'colorBg' in XML:" + e.getMessage()); LOGGER.error("Can not parse attribute 'colorBg' in XML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
parseHtmlNode(elem); parseHtmlNode(elem);
this.htmlDecoTmp = tmpDeco; this.htmlDecoTmp = tmpDeco;
} else if (lowercaseValue.contentEquals("b") || lowercaseValue.contentEquals("bold")) { } else if (lowercaseValue.contentEquals("b") || lowercaseValue.contentEquals("bold")) {
Log.verbose("XML bold ..."); LOGGER.trace("XML bold ...");
final TextDecoration tmpDeco = this.htmlDecoTmp; final TextDecoration tmpDeco = this.htmlDecoTmp;
if (this.htmlDecoTmp.mode() == FontMode.REGULAR) { if (this.htmlDecoTmp.mode() == FontMode.REGULAR) {
this.htmlDecoTmp = this.htmlDecoTmp.withMode(FontMode.BOLD); this.htmlDecoTmp = this.htmlDecoTmp.withMode(FontMode.BOLD);
@ -458,7 +468,7 @@ public abstract class TextBase extends Compositing {
parseHtmlNode(elem); parseHtmlNode(elem);
this.htmlDecoTmp = tmpDeco; this.htmlDecoTmp = tmpDeco;
} else if (lowercaseValue.contentEquals("i") || lowercaseValue.contentEquals("italic")) { } else if (lowercaseValue.contentEquals("i") || lowercaseValue.contentEquals("italic")) {
Log.verbose("XML italic ..."); LOGGER.trace("XML italic ...");
final TextDecoration tmpDeco = this.htmlDecoTmp; final TextDecoration tmpDeco = this.htmlDecoTmp;
if (this.htmlDecoTmp.mode() == FontMode.REGULAR) { if (this.htmlDecoTmp.mode() == FontMode.REGULAR) {
this.htmlDecoTmp = this.htmlDecoTmp.withMode(FontMode.ITALIC); this.htmlDecoTmp = this.htmlDecoTmp.withMode(FontMode.ITALIC);
@ -468,43 +478,43 @@ public abstract class TextBase extends Compositing {
parseHtmlNode(elem); parseHtmlNode(elem);
this.htmlDecoTmp = tmpDeco; this.htmlDecoTmp = tmpDeco;
} else if (lowercaseValue.contentEquals("u") || lowercaseValue.contentEquals("underline")) { } else if (lowercaseValue.contentEquals("u") || lowercaseValue.contentEquals("underline")) {
Log.verbose("XML underline ..."); LOGGER.trace("XML underline ...");
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("p") || lowercaseValue.contentEquals("paragraph")) { } else if (lowercaseValue.contentEquals("p") || lowercaseValue.contentEquals("paragraph")) {
Log.verbose("XML paragraph ..."); LOGGER.trace("XML paragraph ...");
htmlFlush(); htmlFlush();
this.alignment = AlignMode.LEFT; this.alignment = AlignMode.LEFT;
forceLineReturn(); forceLineReturn();
parseHtmlNode(elem); parseHtmlNode(elem);
forceLineReturn(); forceLineReturn();
} else if (lowercaseValue.contentEquals("center")) { } else if (lowercaseValue.contentEquals("center")) {
Log.verbose("XML center ..."); LOGGER.trace("XML center ...");
htmlFlush(); htmlFlush();
this.alignment = AlignMode.CENTER; this.alignment = AlignMode.CENTER;
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("left")) { } else if (lowercaseValue.contentEquals("left")) {
Log.verbose("XML left ..."); LOGGER.trace("XML left ...");
htmlFlush(); htmlFlush();
this.alignment = AlignMode.LEFT; this.alignment = AlignMode.LEFT;
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("right")) { } else if (lowercaseValue.contentEquals("right")) {
Log.verbose("XML right ..."); LOGGER.trace("XML right ...");
htmlFlush(); htmlFlush();
this.alignment = AlignMode.RIGHT; this.alignment = AlignMode.RIGHT;
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("justify")) { } else if (lowercaseValue.contentEquals("justify")) {
Log.verbose("XML justify ..."); LOGGER.trace("XML justify ...");
htmlFlush(); htmlFlush();
this.alignment = AlignMode.JUSTIFY; this.alignment = AlignMode.JUSTIFY;
parseHtmlNode(elem); parseHtmlNode(elem);
} else { } else {
Log.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'"); LOGGER.error("node not suported type: " + elem.getType() + " val='" + elem.getValue() + "'");
} }
//Log.error("Add data elems... @pos=", this.position); //LOGGER.error("Add data elems... @pos=", this.position);
} }
} }
/** /**
* display a compleat string in the current element. * display a compleat string in the current element.
* @param text The string to display. * @param text The string to display.
@ -513,7 +523,7 @@ public abstract class TextBase extends Compositing {
final List<TextDecoration> decorationEmpty = new ArrayList<>(); final List<TextDecoration> decorationEmpty = new ArrayList<>();
print(text, decorationEmpty); print(text, decorationEmpty);
} }
/** /**
* display a compleat string in the current element whith specific * display a compleat string in the current element whith specific
* decorations (advence mode). * decorations (advence mode).
@ -525,7 +535,7 @@ public abstract class TextBase extends Compositing {
Color tmpFg = this.color; Color tmpFg = this.color;
Color tmpBg = this.colorBg; Color tmpBg = this.colorBg;
if (this.alignment == AlignMode.DISABLE) { if (this.alignment == AlignMode.DISABLE) {
// Log.debug(" 1 print in not aligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); // LOGGER.debug(" 1 print in not aligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position);
// display the cursor if needed (if it is at the start position...) // display the cursor if needed (if it is at the start position...)
if (this.needDisplay) { if (this.needDisplay) {
if (0 == this.cursorPos) { if (0 == this.cursorPos) {
@ -544,7 +554,8 @@ public abstract class TextBase extends Compositing {
} }
// if real display : ( not display is for size calculation) // if real display : ( not display is for size calculation)
if (this.needDisplay) { if (this.needDisplay) {
if ((this.selectionStartPos - 1 < (long) iii && (long) iii <= this.cursorPos - 1) || (this.selectionStartPos - 1 >= (long) iii && (long) iii > this.cursorPos - 1)) { if ((this.selectionStartPos - 1 < (long) iii && (long) iii <= this.cursorPos - 1)
|| (this.selectionStartPos - 1 >= (long) iii && (long) iii > this.cursorPos - 1)) {
setColor(Color.BLACK); setColor(Color.BLACK);
setColorBg(this.colorSelection); setColorBg(this.colorSelection);
} else { } else {
@ -572,10 +583,10 @@ public abstract class TextBase extends Compositing {
} }
} }
} }
// Log.debug(" 2 print in not aligned mode : start=" + this.sizeDisplayStart + // LOGGER.debug(" 2 print in not aligned mode : start=" + this.sizeDisplayStart +
// " stop=" + this.sizeDisplayStop + " pos=" + this.position); // " stop=" + this.sizeDisplayStop + " pos=" + this.position);
} else { } else {
// Log.debug(" 3 print in not aligned mode : start=" + this.sizeDisplayStart + // LOGGER.debug(" 3 print in not aligned mode : start=" + this.sizeDisplayStart +
// " stop=" + this.sizeDisplayStop + " pos=" + this.position); // " stop=" + this.sizeDisplayStop + " pos=" + this.position);
// special start case at the right of the endpoint : // special start case at the right of the endpoint :
if (this.stopTextPos < this.position.x()) { if (this.stopTextPos < this.position.x()) {
@ -602,13 +613,15 @@ public abstract class TextBase extends Compositing {
case RIGHT: case RIGHT:
if (this.needDisplay) { if (this.needDisplay) {
// Move the first char at the right : // Move the first char at the right :
setPos(new Vector3f(this.position.x() + freeSpace.value, this.position.y(), this.position.z())); setPos(new Vector3f(this.position.x() + freeSpace.value, this.position.y(),
this.position.z()));
} }
break; break;
case CENTER: case CENTER:
if (this.needDisplay) { if (this.needDisplay) {
// Move the first char at the right : // Move the first char at the right :
setPos(new Vector3f(this.position.x() + freeSpace.value / 2, this.position.y(), this.position.z())); setPos(new Vector3f(this.position.x() + freeSpace.value / 2, this.position.y(),
this.position.z()));
} }
break; break;
default: default:
@ -629,7 +642,8 @@ public abstract class TextBase extends Compositing {
setFontMode(decoration.get(iii).mode()); setFontMode(decoration.get(iii).mode());
} }
if (this.needDisplay) { if (this.needDisplay) {
if ((this.selectionStartPos - 1 < (long) iii && (long) iii <= this.cursorPos - 1) || (this.selectionStartPos - 1 >= (long) iii && (long) iii > this.cursorPos - 1)) { if ((this.selectionStartPos - 1 < (long) iii && (long) iii <= this.cursorPos - 1)
|| (this.selectionStartPos - 1 >= (long) iii && (long) iii > this.cursorPos - 1)) {
setColor(Color.BLACK); setColor(Color.BLACK);
setColorBg(this.colorSelection); setColorBg(this.colorSelection);
} else { } else {
@ -639,7 +653,7 @@ public abstract class TextBase extends Compositing {
} }
// special for the justify mode // special for the justify mode
if (text.charAt(iii) == (char) Character.SPACE_SEPARATOR) { if (text.charAt(iii) == (char) Character.SPACE_SEPARATOR) {
// Log.debug(" generateString : \" \""); // LOGGER.debug(" generateString : \" \"");
if (this.needDisplay && this.colorBg.a() != 0) { if (this.needDisplay && this.colorBg.a() != 0) {
this.vectorialDraw.setPos(this.position); this.vectorialDraw.setPos(this.position);
} }
@ -648,7 +662,7 @@ public abstract class TextBase extends Compositing {
if (this.needDisplay && this.colorBg.a() != 0) { if (this.needDisplay && this.colorBg.a() != 0) {
this.vectorialDraw.rectangleWidth(new Vector3f(interpolation, fontHeigh, 0.0f)); this.vectorialDraw.rectangleWidth(new Vector3f(interpolation, fontHeigh, 0.0f));
} }
} else // Log.debug(" generateString : \"" + (char)text[iii] + "\""); } else // LOGGER.debug(" generateString : \"" + (char)text[iii] + "\"");
if (this.needDisplay && this.colorBg.a() != 0) { if (this.needDisplay && this.colorBg.a() != 0) {
final Vector3f pos = this.position; final Vector3f pos = this.position;
this.vectorialDraw.setPos(pos); this.vectorialDraw.setPos(pos);
@ -687,17 +701,18 @@ public abstract class TextBase extends Compositing {
currentId = stop.value; currentId = stop.value;
} }
} }
Log.debug(" 4 print in not alligned mode : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position); LOGGER.debug(" 4 print in not alligned mode : start=" + this.sizeDisplayStart + " stop="
+ this.sizeDisplayStop + " pos=" + this.position);
} }
} }
/** /**
* display the current char in the current element (note that the kerning * display the current char in the current element (note that the kerning
* is availlable if the position is not changed) * is availlable if the position is not changed)
* @param charcode Char that might be dispalyed * @param charcode Char that might be dispalyed
*/ */
public abstract void printChar(Character charcode); public abstract void printChar(Character charcode);
/** /**
* draw a cursor at the specify position * draw a cursor at the specify position
* @param isInsertMode True if the insert mode is activated * @param isInsertMode True if the insert mode is activated
@ -705,7 +720,7 @@ public abstract class TextBase extends Compositing {
public void printCursor(final boolean isInsertMode) { public void printCursor(final boolean isInsertMode) {
printCursor(isInsertMode, 20.0f); printCursor(isInsertMode, 20.0f);
} }
public void printCursor(final boolean isInsertMode, final float cursorSize) { public void printCursor(final boolean isInsertMode, final float cursorSize) {
final int fontHeigh = (int) getHeight(); final int fontHeigh = (int) getHeight();
if (isInsertMode) { if (isInsertMode) {
@ -716,11 +731,11 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setThickness(0); this.vectorialDraw.setThickness(0);
} }
} }
/** /**
* display a compleat string in the current element with the generic * display a compleat string in the current element with the generic
* decoration specification. (basic html data) * decoration specification. (basic html data)
* *
* [code style=xml] <br/> * [code style=xml] <br/>
* <br/> * <br/>
* <br/> * <br/>
@ -739,7 +754,7 @@ public abstract class TextBase extends Compositing {
* <br/> * <br/>
* <br/> * <br/>
* <justify> Un exemple de text </justify> [/code] * <justify> Un exemple de text </justify> [/code]
* *
* @note This is parsed with tiny xml, then be carfull that the XML is correct, * @note This is parsed with tiny xml, then be carfull that the XML is correct,
* and all balises are closed ... otherwite the display can not be done * and all balises are closed ... otherwite the display can not be done
* @param text The string to display. * @param text The string to display.
@ -749,14 +764,14 @@ public abstract class TextBase extends Compositing {
final StringBuilder tmpData = new StringBuilder("<html>\n<body>\n"); final StringBuilder tmpData = new StringBuilder("<html>\n<body>\n");
tmpData.append(text); tmpData.append(text);
tmpData.append("\n</body>\n</html>\n"); tmpData.append("\n</body>\n</html>\n");
// Log.debug("plop : " + tmpData); // LOGGER.debug("plop : " + tmpData);
printHTML(tmpData.toString()); printHTML(tmpData.toString());
} }
/** /**
* display a compleat string in the current element with the generic * display a compleat string in the current element with the generic
* decoration specification. (basic html data) * decoration specification. (basic html data)
* *
* [code style=xml] <html> <body> <br/> * [code style=xml] <html> <body> <br/>
* <br/> * <br/>
* <br/> * <br/>
@ -775,7 +790,7 @@ public abstract class TextBase extends Compositing {
* <br/> * <br/>
* <br/> * <br/>
* <justify> Un exemple de text </justify> </body> </html> [/code] * <justify> Un exemple de text </justify> </body> </html> [/code]
* *
* @note This is parsed with tiny xml, then be carfull that the XML is correct, * @note This is parsed with tiny xml, then be carfull that the XML is correct,
* and all balises are closed ... otherwite the display can not be done * and all balises are closed ... otherwite the display can not be done
* @param text The string to display. * @param text The string to display.
@ -787,34 +802,34 @@ public abstract class TextBase extends Compositing {
try { try {
final XmlElement doc = Exml.parse(text); final XmlElement doc = Exml.parse(text);
if (!doc.existNode("html")) { if (!doc.existNode("html")) {
Log.error("can not load XML: main node not find: 'html'"); LOGGER.error("can not load XML: main node not find: 'html'");
Exml.display(doc); Exml.display(doc);
return; return;
} }
final XmlElement root = (XmlElement) doc.getNode("html"); final XmlElement root = (XmlElement) doc.getNode("html");
if (!root.existNode("body")) { if (!root.existNode("body")) {
Log.error("can not load XML: main node not find: 'body'"); LOGGER.error("can not load XML: main node not find: 'body'");
return; return;
} }
final XmlElement bodyNode = (XmlElement) root.getNode("body"); final XmlElement bodyNode = (XmlElement) root.getNode("body");
parseHtmlNode(bodyNode); parseHtmlNode(bodyNode);
htmlFlush(); htmlFlush();
} catch (final ExmlParserErrorMulti e) { } catch (final ExmlParserErrorMulti e) {
Log.error("Can not parse XML data in printHTML:" + e.getMessage()); LOGGER.error("Can not parse XML data in printHTML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (final ExmlBuilderException e) { } catch (final ExmlBuilderException e) {
Log.error("Can not generate XML data in printHTML:" + e.getMessage()); LOGGER.error("Can not generate XML data in printHTML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (final ExmlException e) { } catch (final ExmlException e) {
Log.error("Error in finding node from XML data in printHTML:" + e.getMessage()); LOGGER.error("Error in finding node from XML data in printHTML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} catch (final AknotException e) { } catch (final AknotException e) {
Log.error("Error in parsing pojo data in printHTML:" + e.getMessage()); LOGGER.error("Error in parsing pojo data in printHTML:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* clear all the intermediate result detween 2 prints * clear all the intermediate result detween 2 prints
*/ */
@ -840,24 +855,24 @@ public abstract class TextBase extends Compositing {
this.needDisplay = true; this.needDisplay = true;
this.nbCharDisplayed = 0; this.nbCharDisplayed = 0;
} }
@Override @Override
public void rotate(final Vector3f vect, final float angle) { public void rotate(final Vector3f vect, final float angle) {
super.rotate(vect, angle); super.rotate(vect, angle);
this.vectorialDraw.rotate(vect, angle); this.vectorialDraw.rotate(vect, angle);
} }
@Override @Override
public void scale(final Vector3f vect) { public void scale(final Vector3f vect) {
super.scale(vect); super.scale(vect);
this.vectorialDraw.scale(vect); this.vectorialDraw.scale(vect);
} }
// ! @previous // ! @previous
public void setClipping(final Vector2f pos, final Vector2f posEnd) { public void setClipping(final Vector2f pos, final Vector2f posEnd) {
setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1)); setClipping(new Vector3f(pos.x(), pos.y(), -1), new Vector3f(posEnd.x(), posEnd.y(), 1));
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -871,7 +886,7 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = true; this.clippingEnable = true;
this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop); this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop);
} }
/** /**
* enable/Disable the clipping (without lose the current clipping * enable/Disable the clipping (without lose the current clipping
* position) * position)
@ -882,12 +897,12 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = newMode; this.clippingEnable = newMode;
this.vectorialDraw.setClippingMode(this.clippingEnable); this.vectorialDraw.setClippingMode(this.clippingEnable);
} }
// ! @previous // ! @previous
public void setClippingWidth(final Vector2f pos, final Vector2f width) { public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClipping(pos, pos.add(width)); setClipping(pos, pos.add(width));
} }
/** /**
* Request a clipping area for the text (next draw only) * Request a clipping area for the text (next draw only)
* @param pos Start position of the clipping * @param pos Start position of the clipping
@ -896,7 +911,7 @@ public abstract class TextBase extends Compositing {
public void setClippingWidth(final Vector3f pos, final Vector3f width) { public void setClippingWidth(final Vector3f pos, final Vector3f width) {
setClipping(pos, pos.add(width)); setClipping(pos, pos.add(width));
} }
/** /**
* set the Color of the current foreground font * set the Color of the current foreground font
* @param color Color to set on foreground (for next print) * @param color Color to set on foreground (for next print)
@ -904,7 +919,7 @@ public abstract class TextBase extends Compositing {
public void setColor(final Color color) { public void setColor(final Color color) {
this.color = color; this.color = color;
} }
/** /**
* set the background color of the font (for selected Text (not the * set the background color of the font (for selected Text (not the
* global BG)) * global BG))
@ -914,7 +929,7 @@ public abstract class TextBase extends Compositing {
this.colorBg = color; this.colorBg = color;
this.vectorialDraw.setColor(color); this.vectorialDraw.setColor(color);
} }
/** /**
* change the cursor color * change the cursor color
* @param color New color for the Selection * @param color New color for the Selection
@ -922,7 +937,7 @@ public abstract class TextBase extends Compositing {
public void setCursorColor(final Color color) { public void setCursorColor(final Color color) {
this.colorCursor = color; this.colorCursor = color;
} }
/** /**
* set a cursor at a specific position: * set a cursor at a specific position:
* @param cursorPos id of the cursor position * @param cursorPos id of the cursor position
@ -931,7 +946,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = cursorPos; this.selectionStartPos = cursorPos;
this.cursorPos = cursorPos; this.cursorPos = cursorPos;
} }
/** /**
* set a cursor at a specific position with his associated selection: * set a cursor at a specific position with his associated selection:
* @param cursorPos id of the cursor position * @param cursorPos id of the cursor position
@ -941,7 +956,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = selectionStartPos; this.selectionStartPos = selectionStartPos;
this.cursorPos = cursorPos; this.cursorPos = cursorPos;
} }
/** /**
* set the default background color of the font (when reset, set this * set the default background color of the font (when reset, set this
* value ...) * value ...)
@ -950,7 +965,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorBg(final Color color) { public void setDefaultColorBg(final Color color) {
this.defaultColorBg = color; this.defaultColorBg = color;
} }
/** /**
* set the default Foreground color of the font (when reset, set this * set the default Foreground color of the font (when reset, set this
* value ...) * value ...)
@ -959,7 +974,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorFg(final Color color) { public void setDefaultColorFg(final Color color) {
this.defaultColorFg = color; this.defaultColorFg = color;
} }
/** /**
* Specify the font property (this reset the internal element of the * Specify the font property (this reset the internal element of the
* current text (system requirement) * current text (system requirement)
@ -967,7 +982,7 @@ public abstract class TextBase extends Compositing {
* @param fontSize New font size * @param fontSize New font size
*/ */
public abstract void setFont(final String fontName, final int fontSize); public abstract void setFont(final String fontName, final int fontSize);
/** /**
* enable or disable the bold mode * enable or disable the bold mode
* @param status The new status for this display property * @param status The new status for this display property
@ -987,7 +1002,7 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.ITALIC); setFontMode(FontMode.ITALIC);
} }
} }
/** /**
* enable or disable the italic mode * enable or disable the italic mode
* @param status The new status for this display property * @param status The new status for this display property
@ -1007,27 +1022,27 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.BOLD); setFontMode(FontMode.BOLD);
} }
} }
/** /**
* Specify the font mode for the next @ref print * Specify the font mode for the next @ref print
* @param mode The font mode requested * @param mode The font mode requested
*/ */
public abstract void setFontMode(FontMode mode); public abstract void setFontMode(FontMode mode);
/** /**
* Specify the font name (this reset the internal element of the current * Specify the font name (this reset the internal element of the current
* text (system requirement) * text (system requirement)
* @param fontName Current name of the selected font * @param fontName Current name of the selected font
*/ */
public abstract void setFontName(final String fontName); public abstract void setFontName(final String fontName);
/** /**
* Specify the font size (this reset the internal element of the current * Specify the font size (this reset the internal element of the current
* text (system requirement) * text (system requirement)
* @param fontSize New font size * @param fontSize New font size
*/ */
public abstract void setFontSize(final int fontSize); public abstract void setFontSize(final int fontSize);
/** /**
* set the activation of the Kerning for the display (if it existed) * set the activation of the Kerning for the display (if it existed)
* @param newMode enable/Diasable the kerning on this font. * @param newMode enable/Diasable the kerning on this font.
@ -1035,12 +1050,12 @@ public abstract class TextBase extends Compositing {
public void setKerningMode(final boolean newMode) { public void setKerningMode(final boolean newMode) {
this.kerning = newMode; this.kerning = newMode;
} }
// ! @previous // ! @previous
public void setPos(final Vector2f pos) { public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0)); setPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set position for the next text writen * set position for the next text writen
* @param pos Position of the text (in 3D) * @param pos Position of the text (in 3D)
@ -1048,7 +1063,7 @@ public abstract class TextBase extends Compositing {
public void setPos(final Vector3f pos) { public void setPos(final Vector3f pos) {
// check min max for display area // check min max for display area
if (this.nbCharDisplayed != 0) { if (this.nbCharDisplayed != 0) {
//Log.verbose("update size 1 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); //LOGGER.trace("update size 1 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop); this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart); this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart);
} }
@ -1060,20 +1075,20 @@ public abstract class TextBase extends Compositing {
if (this.nbCharDisplayed == 0) { if (this.nbCharDisplayed == 0) {
this.sizeDisplayStart = this.position; this.sizeDisplayStart = this.position;
this.sizeDisplayStop = this.position.withY(this.sizeDisplayStop.y() + getHeight()); this.sizeDisplayStop = this.position.withY(this.sizeDisplayStop.y() + getHeight());
//Log.verbose("update size 0 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); //LOGGER.trace("update size 0 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
} else { } else {
//Log.verbose("update size 3 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); //LOGGER.trace("update size 3 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop); this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart); this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart);
//Log.verbose("update size 4 " + this.sizeDisplayStart + " " + this.sizeDisplayStop); //LOGGER.trace("update size 4 " + this.sizeDisplayStart + " " + this.sizeDisplayStop);
} }
} }
// ! @previous // ! @previous
public void setRelPos(final Vector2f pos) { public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0)); setRelPos(new Vector3f(pos.x(), pos.y(), 0));
} }
/** /**
* set relative position for the next text written * set relative position for the next text written
* @param pos offset apply of the text (in 3D) * @param pos offset apply of the text (in 3D)
@ -1083,7 +1098,7 @@ public abstract class TextBase extends Compositing {
this.previousCharcode = 0; this.previousCharcode = 0;
this.vectorialDraw.setPos(this.position); this.vectorialDraw.setPos(this.position);
} }
/** /**
* change the selection color * change the selection color
* @param color New color for the Selection * @param color New color for the Selection
@ -1091,7 +1106,7 @@ public abstract class TextBase extends Compositing {
public void setSelectionColor(final Color color) { public void setSelectionColor(final Color color) {
this.colorSelection = color; this.colorSelection = color;
} }
/** /**
* This generate the possibility to generate the big text property * This generate the possibility to generate the big text property
* @param startTextPos The x text start position of the display. * @param startTextPos The x text start position of the display.
@ -1102,21 +1117,21 @@ public abstract class TextBase extends Compositing {
public void setTextAlignment(final float startTextPos, final float stopTextPos) { public void setTextAlignment(final float startTextPos, final float stopTextPos) {
setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE); setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE);
} }
public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) { public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) {
this.startTextPos = startTextPos; this.startTextPos = startTextPos;
this.stopTextPos = stopTextPos + 1; this.stopTextPos = stopTextPos + 1;
this.alignment = alignement; this.alignment = alignement;
if (this.startTextPos >= this.stopTextPos) { if (this.startTextPos >= this.stopTextPos) {
// TODO understand why this flush ... // TODO understand why this flush ...
Log.verbose("Request alignment with Borne position error : " + startTextPos + " => " + stopTextPos); LOGGER.trace("Request alignment with Borne position error : " + startTextPos + " => " + stopTextPos);
} }
} }
@Override @Override
public void translate(final Vector3f vect) { public void translate(final Vector3f vect) {
super.translate(vect); super.translate(vect);
this.vectorialDraw.translate(vect); this.vectorialDraw.translate(vect);
} }
} }

View File

@ -13,7 +13,6 @@ import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etranslate.ETranslate; 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.object.ObjectManager; import org.atriasoft.ewol.object.ObjectManager;
import org.atriasoft.ewol.widget.Widget; import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.ewol.widget.WidgetManager; import org.atriasoft.ewol.widget.WidgetManager;
@ -28,10 +27,13 @@ import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType; import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceManager; import org.atriasoft.gale.resource.ResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Here we herited from the gale application to be agnostic of the OW where we work ... // Here we herited from the gale application to be agnostic of the OW where we work ...
public class EwolContext extends GaleApplication { public class EwolContext extends GaleApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(EwolContext.class);
/** /**
* From everywhere in the program, we can get the context inteface. * From everywhere in the program, we can get the context inteface.
* @return current reference on the instance. * @return current reference on the instance.
@ -43,31 +45,32 @@ public class EwolContext extends GaleApplication {
} }
return null; return null;
} }
private EwolApplication application; // !< Application handle private EwolApplication application; // !< Application handle
private final InputManager input; private final InputManager input;
private final ObjectManager objectManager; // !< Object Manager main instance private final ObjectManager objectManager; // !< Object Manager main instance
private final WidgetManager widgetManager = new WidgetManager(); // !< global widget manager private final WidgetManager widgetManager = new WidgetManager(); // !< global widget manager
private Windows windowsCurrent = null; // !< current displayed windows private Windows windowsCurrent = null; // !< current displayed windows
public EwolContext(final EwolApplication application) { public EwolContext(final EwolApplication application) {
this.application = application; this.application = application;
this.objectManager = new ObjectManager(this); this.objectManager = new ObjectManager(this);
this.input = new InputManager(this); this.input = new InputManager(this);
if (this.application == null) { if (this.application == null) {
Log.critical("Can not start context with no Application ==> rtfm ..."); LOGGER.error("Can not start context with no Application ==> rtfm ...");
System.exit(-1);
} }
} }
/** /**
* Redraw all the windows * Redraw all the windows
*/ */
public void forceRedrawAll() { public void forceRedrawAll() {
Log.warning("force redraw on windows:" + this.windowsCurrent); LOGGER.warn("force redraw on windows:" + this.windowsCurrent);
if (this.windowsCurrent == null) { if (this.windowsCurrent == null) {
return; return;
} }
@ -76,32 +79,32 @@ public class EwolContext extends GaleApplication {
this.windowsCurrent.onChangeSize(); this.windowsCurrent.onChangeSize();
/// Gale.getContext().aaaaaaaaaaaaaa(); /// Gale.getContext().aaaaaaaaaaaaaa();
} }
public void forceRedrawAllAsync() { public void forceRedrawAllAsync() {
Log.verbose("force redraw ALL (ASYNC):"); LOGGER.trace("force redraw ALL (ASYNC):");
GaleContext.getContext().requestUpdateSize(); GaleContext.getContext().requestUpdateSize();
} }
public EwolApplication getApplication() { public EwolApplication getApplication() {
return this.application; return this.application;
} }
public CommandLine getCmd() { public CommandLine getCmd() {
return Gale.getContext().getCmd(); return Gale.getContext().getCmd();
} }
public ObjectManager getEObjectManager() { public ObjectManager getEObjectManager() {
return this.objectManager; return this.objectManager;
} }
public ResourceManager getResourcesManager() { public ResourceManager getResourcesManager() {
return Gale.getContext().getResourcesManager(); return Gale.getContext().getResourcesManager();
} }
public WidgetManager getWidgetManager() { public WidgetManager getWidgetManager() {
return this.widgetManager; return this.widgetManager;
} }
/** /**
* get the current windows that is displayed * get the current windows that is displayed
* @return the current handle on the windows (can be null) * @return the current handle on the windows (can be null)
@ -109,7 +112,7 @@ public class EwolContext extends GaleApplication {
public Windows getWindows() { public Windows getWindows() {
return this.windowsCurrent; return this.windowsCurrent;
} }
/** /**
* This fonction lock the pointer properties to move in relative instead * This fonction lock the pointer properties to move in relative instead
* of absolute * of absolute
@ -118,7 +121,7 @@ public class EwolContext extends GaleApplication {
public void inputEventGrabPointer(final Widget widget) { public void inputEventGrabPointer(final Widget widget) {
this.input.grabPointer(widget); this.input.grabPointer(widget);
} }
/** /**
* This is to transfert the event from one widget to another one * This is to transfert the event from one widget to another one
* @param source the widget where the event came from * @param source the widget where the event came from
@ -127,7 +130,7 @@ public class EwolContext extends GaleApplication {
public void inputEventTransfertWidget(final Widget source, final Widget destination) { public void inputEventTransfertWidget(final Widget source, final Widget destination) {
this.input.transfertEvent(source, destination); this.input.transfertEvent(source, destination);
} }
/** /**
* This fonction un-lock the pointer properties to move in relative * This fonction un-lock the pointer properties to move in relative
* instead of absolute * instead of absolute
@ -135,7 +138,7 @@ public class EwolContext extends GaleApplication {
public void inputEventUnGrabPointer() { public void inputEventUnGrabPointer() {
this.input.unGrabPointer(); this.input.unGrabPointer();
} }
@Override @Override
public void onClipboardEvent(final ClipboardList clipboardId) { public void onClipboardEvent(final ClipboardList clipboardId) {
final Widget tmpWidget = this.widgetManager.focusGet(); final Widget tmpWidget = this.widgetManager.focusGet();
@ -143,29 +146,29 @@ public class EwolContext extends GaleApplication {
tmpWidget.onEventClipboard(clipboardId); tmpWidget.onEventClipboard(clipboardId);
} }
} }
@Override @Override
public void onCreate(final GaleContext context) { public void onCreate(final GaleContext context) {
Log.info(" == > Ewol system create (BEGIN)"); LOGGER.info(" == > Ewol system create (BEGIN)");
// Add basic ewol translation: // Add basic ewol translation:
ETranslate.addPath("ewol", new Uri("TRANSLATE", "", "ewol")); ETranslate.addPath("ewol", new Uri("TRANSLATE", "", "ewol"));
ETranslate.autoDetectLanguage(); ETranslate.autoDetectLanguage();
// 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).equals("-h") || context.getCmd().get(iii).equals("--help")) { if (context.getCmd().get(iii).equals("-h") || context.getCmd().get(iii).equals("--help")) {
Log.print("ewol - help : "); LOGGER.info("ewol - help : ");
Log.print(" xxxxxxxxxxxxx [options]"); LOGGER.info(" xxxxxxxxxxxxx [options]");
Log.print(" -h/--help: Display this help"); LOGGER.info(" -h/--help: Display this help");
Log.print(" example:"); LOGGER.info(" example:");
Log.print(" xxxxxxxxxxxxx --help"); LOGGER.info(" xxxxxxxxxxxxx --help");
// this is a global help system does not remove it // this is a global help system does not remove it
continue; continue;
} }
//context.getCmd().remove(iii); //context.getCmd().remove(iii);
//--iii; //--iii;
} }
// Log.info("EWOL v:" + ewol::getVersion()); // LOGGER.info("EWOL v:" + ewol::getVersion());
// force a recalculation // force a recalculation
/* /*
* requestUpdateSize(){ Context context = gale::getContext(); * requestUpdateSize(){ Context context = gale::getContext();
@ -178,16 +181,16 @@ public class EwolContext extends GaleApplication {
*/ */
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
Log.error(" == > Create without application"); LOGGER.error(" == > Create without application");
return; return;
} }
appl.onCreate(this); appl.onCreate(this);
Log.info(" == > Ewol system create (END)"); LOGGER.info(" == > Ewol system create (END)");
} }
@Override @Override
public void onDestroy(final GaleContext context) { public void onDestroy(final GaleContext context) {
Log.info(" == > Ewol system destroy (BEGIN)"); LOGGER.info(" == > Ewol system destroy (BEGIN)");
// Remove current windows // Remove current windows
this.windowsCurrent = null; this.windowsCurrent = null;
// clean all widget and sub widget with their resources: // clean all widget and sub widget with their resources:
@ -200,16 +203,16 @@ public class EwolContext extends GaleApplication {
} }
// internal clean elements // internal clean elements
this.objectManager.cleanInternalRemoved(); this.objectManager.cleanInternalRemoved();
Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing"); LOGGER.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
this.objectManager.displayListObject(); this.objectManager.displayListObject();
// now All must be removed !!! // now All must be removed !!!
this.objectManager.unInit(); this.objectManager.unInit();
Log.info(" == > Ewol system destroy (END)"); LOGGER.info(" == > Ewol system destroy (END)");
} }
@Override @Override
public void onDraw(final GaleContext context) { public void onDraw(final GaleContext context) {
//Log.verbose("EWOL DRAW"); //LOGGER.trace("EWOL DRAW");
// clean internal data... // clean internal data...
this.objectManager.cleanInternalRemoved(); this.objectManager.cleanInternalRemoved();
// real draw... // real draw...
@ -219,10 +222,14 @@ public class EwolContext extends GaleApplication {
} }
window.sysDraw(); window.sysDraw();
} }
@Override @Override
public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) { public void onKeyboard(
Log.verbose("event {" + special + "} " + type + " '" + value + "' " + state); final KeySpecial special,
final KeyKeyboard type,
final Character value,
final KeyStatus state) {
LOGGER.trace("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);
if (this.windowsCurrent == null) { if (this.windowsCurrent == null) {
@ -242,7 +249,7 @@ public class EwolContext extends GaleApplication {
return; return;
} }
// check if the widget allow repeating key events. // check if the widget allow repeating key events.
// Log.info("repeating test :" + repeate + " widget=" + // LOGGER.info("repeating test :" + repeate + " widget=" +
// tmpWidget.getKeyboardRepeate() + " state=" + isDown); // tmpWidget.getKeyboardRepeate() + " state=" + isDown);
if (!repeate || (repeate && tmpWidget.getKeyboardRepeat())) { if (!repeate || (repeate && tmpWidget.getKeyboardRepeat())) {
// check Widget shortcut // check Widget shortcut
@ -266,69 +273,74 @@ public class EwolContext extends GaleApplication {
tmpWidget.systemEventEntry(tmpEntryEvent); tmpWidget.systemEventEntry(tmpEntryEvent);
} }
} else { } else {
Log.debug("remove Repeate key ..."); LOGGER.debug("remove Repeate key ...");
} }
} }
} }
@Override @Override
public void onKillDemand(final GaleContext context) { public void onKillDemand(final GaleContext context) {
Log.info(" == > User demand a destroy (BEGIN)"); LOGGER.info(" == > User demand a destroy (BEGIN)");
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
exit(0); exit(0);
return; return;
} }
appl.onKillDemand(this); appl.onKillDemand(this);
Log.info(" == > User demand a destroy (END)"); LOGGER.info(" == > User demand a destroy (END)");
} }
@Override @Override
public void onPause(final GaleContext context) { public void onPause(final GaleContext context) {
Log.info(" == > Ewol system pause (BEGIN)"); LOGGER.info(" == > Ewol system pause (BEGIN)");
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
return; return;
} }
appl.onPause(this); appl.onPause(this);
Log.info(" == > Ewol system pause (END)"); LOGGER.info(" == > Ewol system pause (END)");
} }
@Override @Override
public void onPeriod(final Clock clock, final long time) { public void onPeriod(final Clock clock, final long time) {
this.objectManager.timeCall(clock, time); this.objectManager.timeCall(clock, time);
} }
@Override @Override
public void onPointer(final KeySpecial special, final KeyType type, final int pointerID, final Vector2f pos, final KeyStatus state) { public void onPointer(
final KeySpecial special,
final KeyType type,
final int pointerID,
final Vector2f pos,
final KeyStatus state) {
this.input.setLastKeyboardSpecial(special); this.input.setLastKeyboardSpecial(special);
switch (state) { switch (state) {
case move: case move:
// Log.debug("Receive MSG : THREAD_INPUT_MOTION"); // LOGGER.debug("Receive MSG : THREAD_INPUT_MOTION");
this.input.motion(type, pointerID, pos); this.input.motion(type, pointerID, pos);
break; break;
case down: case down:
case downRepeat: case downRepeat:
// Log.debug("Receive MSG : THREAD_INPUT_STATE"); // LOGGER.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(type, pointerID, true, pos); this.input.state(type, pointerID, true, pos);
break; break;
case up: case up:
// Log.debug("Receive MSG : THREAD_INPUT_STATE"); // LOGGER.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(type, pointerID, false, pos); this.input.state(type, pointerID, false, pos);
break; break;
default: default:
Log.debug("Unknow state : " + state); LOGGER.debug("Unknow state : " + state);
break; break;
} }
} }
@Override @Override
public void onRegenerateDisplay(final GaleContext context) { public void onRegenerateDisplay(final GaleContext context) {
//Log.info("EWOL onRegenerateDisplay /// "); //LOGGER.info("EWOL onRegenerateDisplay /// ");
// check if the user selected a windows // check if the user selected a windows
final Windows window = this.windowsCurrent; final Windows window = this.windowsCurrent;
if (window == null) { if (window == null) {
Log.error("No windows ..."); LOGGER.error("No windows ...");
return; return;
} }
// Redraw all needed elements // Redraw all needed elements
@ -338,52 +350,52 @@ public class EwolContext extends GaleApplication {
} }
// markDrawingIsNeeded(); // markDrawingIsNeeded();
} }
@Override @Override
public void onResize(final Vector2f size) { public void onResize(final Vector2f size) {
super.onResize(size); super.onResize(size);
forceRedrawAll(); forceRedrawAll();
} }
public void onResize(final Vector2i size) { public void onResize(final Vector2i size) {
Log.verbose("Resize: " + size); LOGGER.trace("Resize: " + size);
forceRedrawAll(); forceRedrawAll();
} }
@Override @Override
public void onResume(final GaleContext context) { public void onResume(final GaleContext context) {
Log.info(" == > Ewol system resume (BEGIN)"); LOGGER.info(" == > Ewol system resume (BEGIN)");
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
return; return;
} }
appl.onResume(this); appl.onResume(this);
Log.info(" == > Ewol system resume (END)"); LOGGER.info(" == > Ewol system resume (END)");
} }
@Override @Override
public void onStart(final GaleContext context) { public void onStart(final GaleContext context) {
Log.info(" == > Ewol system start (BEGIN)"); LOGGER.info(" == > Ewol system start (BEGIN)");
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
// TODO : Request exit of the application .... with error ... // TODO : Request exit of the application .... with error ...
return; return;
} }
appl.onStart(this); appl.onStart(this);
Log.info(" == > Ewol system start (END)"); LOGGER.info(" == > Ewol system start (END)");
} }
@Override @Override
public void onStop(final GaleContext context) { public void onStop(final GaleContext context) {
Log.info(" == > Ewol system stop (BEGIN)"); LOGGER.info(" == > Ewol system stop (BEGIN)");
final EwolApplication appl = this.application; final EwolApplication appl = this.application;
if (appl == null) { if (appl == null) {
return; return;
} }
appl.onStop(this); appl.onStop(this);
Log.info(" == > Ewol system stop (END)"); LOGGER.info(" == > Ewol system stop (END)");
} }
/** /**
* Request a display after call a resize * Request a display after call a resize
*/ */
@ -391,14 +403,14 @@ public class EwolContext extends GaleApplication {
final GaleContext context = Gale.getContext(); final GaleContext context = Gale.getContext();
context.requestUpdateSize(); context.requestUpdateSize();
} }
/** /**
* reset event management for the IO like Input ou Mouse or keyborad * reset event management for the IO like Input ou Mouse or keyborad
*/ */
public void resetIOEvent() { public void resetIOEvent() {
this.input.newLayerSet(); this.input.newLayerSet();
} }
/** /**
* Special for init (main) set the start image when loading data * Special for init (main) set the start image when loading data
* @param fileName Name of the image to load * @param fileName Name of the image to load
@ -406,13 +418,13 @@ public class EwolContext extends GaleApplication {
public void setInitImage(final Uri fileName) { public void setInitImage(final Uri fileName) {
// this.initDisplayImageName = fileName; // this.initDisplayImageName = fileName;
} }
/** /**
* set the current windows to display : * set the current windows to display :
* @param windows Windows that might be displayed * @param windows Windows that might be displayed
*/ */
public void setWindows(final Windows windows) { public void setWindows(final Windows windows) {
Log.info("set New windows"); LOGGER.info("set New windows");
// remove current focus : // remove current focus :
this.widgetManager.focusSetDefault(null); this.widgetManager.focusSetDefault(null);
this.widgetManager.focusRelease(); this.widgetManager.focusRelease();

View File

@ -11,12 +11,13 @@ import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.event.InputSystem; import org.atriasoft.ewol.event.InputSystem;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.Widget; import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.ewol.widget.Windows; import org.atriasoft.ewol.widget.Windows;
import org.atriasoft.gale.key.KeySpecial; import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType; import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* internal structure * internal structure
@ -27,6 +28,7 @@ class InputLimit {
} }
class InputManager { class InputManager {
private static final Logger LOGGER = LoggerFactory.getLogger(InputManager.class);
private static final long MILLI_TO_DURATION = 1000000; private static final long MILLI_TO_DURATION = 1000000;
private static final long SECONDS_TO_DURATION = 1000000000; private static final long SECONDS_TO_DURATION = 1000000000;
private static final int MAX_MANAGE_INPUT = 15; private static final int MAX_MANAGE_INPUT = 15;
@ -36,49 +38,50 @@ class InputManager {
private final InputPoperty[] eventInputSaved = new InputPoperty[InputManager.MAX_MANAGE_INPUT]; private final InputPoperty[] eventInputSaved = new InputPoperty[InputManager.MAX_MANAGE_INPUT];
private final InputLimit eventMouseLimit = new InputLimit(); private final InputLimit eventMouseLimit = new InputLimit();
private final InputPoperty[] eventMouseSaved = new InputPoperty[InputManager.MAX_MANAGE_INPUT]; private final InputPoperty[] eventMouseSaved = new InputPoperty[InputManager.MAX_MANAGE_INPUT];
// special grab pointer mode : // special grab pointer mode :
private WeakReference<Widget> grabWidget = null; //!< widget that grab the curent pointer. private WeakReference<Widget> grabWidget = null; //!< widget that grab the curent pointer.
private KeySpecial specialKey; private KeySpecial specialKey;
public InputManager(final EwolContext context) { public InputManager(final EwolContext context) {
this.context = context; this.context = context;
setDpi(200); setDpi(200);
Log.info("Init (start)"); LOGGER.info("Init (start)");
for (int iii = 0; iii < InputManager.MAX_MANAGE_INPUT; iii++) { for (int iii = 0; iii < InputManager.MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ... // remove the property of this input ...
this.eventInputSaved[iii] = new InputPoperty(); this.eventInputSaved[iii] = new InputPoperty();
this.eventMouseSaved[iii] = new InputPoperty(); this.eventMouseSaved[iii] = new InputPoperty();
} }
Log.info("Init (end)"); LOGGER.info("Init (end)");
} }
public void abortElement(final InputPoperty[] eventTable, final int idInput, final KeyType type) { public void abortElement(final InputPoperty[] eventTable, final int idInput, final KeyType type) {
if (eventTable == null) { if (eventTable == null) {
return; return;
} }
if (eventTable[idInput].isUsed) { if (eventTable[idInput].isUsed) {
localEventInput(type, eventTable[idInput].curentWidgetEvent.get(), eventTable[idInput].destinationInputId, KeyStatus.abort, eventTable[idInput].posEvent); localEventInput(type, eventTable[idInput].curentWidgetEvent.get(), eventTable[idInput].destinationInputId,
KeyStatus.abort, eventTable[idInput].posEvent);
} }
} }
private void calculateLimit() { private void calculateLimit() {
this.eventInputLimit.sepatateTime = 300 * InputManager.MILLI_TO_DURATION; this.eventInputLimit.sepatateTime = 300 * InputManager.MILLI_TO_DURATION;
this.eventInputLimit.dpiOffset = this.dpi * 100; this.eventInputLimit.dpiOffset = this.dpi * 100;
this.eventMouseLimit.sepatateTime = 300 * InputManager.MILLI_TO_DURATION; this.eventMouseLimit.sepatateTime = 300 * InputManager.MILLI_TO_DURATION;
this.eventMouseLimit.dpiOffset = (int) (this.dpi * 0.1f); this.eventMouseLimit.dpiOffset = (int) (this.dpi * 0.1f);
} }
public void cleanElement(final InputPoperty[] eventMouseSaved2, final int idInput) { public void cleanElement(final InputPoperty[] eventMouseSaved2, final int idInput) {
if (eventMouseSaved2 == null) { if (eventMouseSaved2 == null) {
return; return;
} }
//Log.info("CleanElement[" + idInput + "] = @" + (long)eventTable); //LOGGER.info("CleanElement[" + idInput + "] = @" + (long)eventTable);
eventMouseSaved2[idInput].clear(); eventMouseSaved2[idInput].clear();
} }
/** /**
* This fonction lock the pointer properties to move in relative instead of absolute * This fonction lock the pointer properties to move in relative instead of absolute
* @param widget The widget that lock the pointer events * @param widget The widget that lock the pointer events
@ -94,7 +97,7 @@ class InputManager {
widget.getSize().y/2.0f) ); widget.getSize().y/2.0f) );
*/ */
} }
/** /**
* generate the event on the destinated widget. * generate the event on the destinated widget.
* @param type Type of the event that might be sended. * @param type Type of the event that might be sended.
@ -104,12 +107,18 @@ class InputManager {
* @param pos position of the event * @param pos position of the event
* @return true if event has been greped * @return true if event has been greped
*/ */
public boolean localEventInput(final KeyType type, final Widget destWidget, final int idInput, final KeyStatus status, final Vector2f pos) { public boolean localEventInput(
final KeyType type,
final Widget destWidget,
final int idInput,
final KeyStatus status,
final Vector2f pos) {
if (destWidget != null) { if (destWidget != null) {
if (type == KeyType.mouse || type == KeyType.finger) { if (type == KeyType.mouse || type == KeyType.finger) {
// create the system Event : // create the system Event :
// TODO : set the real ID ... // TODO : set the real ID ...
final InputSystem tmpEventSystem = new InputSystem(type, status, idInput, pos, destWidget, 0, this.specialKey); final InputSystem tmpEventSystem = new InputSystem(type, status, idInput, pos, destWidget, 0,
this.specialKey);
// generate the event : // generate the event :
return destWidget.systemEventInput(tmpEventSystem); return destWidget.systemEventInput(tmpEventSystem);
} }
@ -117,7 +126,7 @@ class InputManager {
} }
return false; return false;
} }
/** /**
* convert the system event id in the correct EWOL id depending of the system management mode * convert the system event id in the correct EWOL id depending of the system management mode
* This function find the next input id unused on the specifiic widget * This function find the next input id unused on the specifiic widget
@ -144,10 +153,10 @@ class InputManager {
} }
return realInputId; return realInputId;
} }
// note if id<0 == > the it was finger event ... // note if id<0 == > the it was finger event ...
public void motion(final KeyType type, final int pointerID, final Vector2f pos) { public void motion(final KeyType type, final int pointerID, final Vector2f pos) {
//Log.debug("motion event : " + type + " " + pointerID + " " + pos); //LOGGER.debug("motion event : " + type + " " + pointerID + " " + pos);
if (InputManager.MAX_MANAGE_INPUT <= pointerID) { if (InputManager.MAX_MANAGE_INPUT <= pointerID) {
// reject pointer == > out of IDs... // reject pointer == > out of IDs...
return; return;
@ -158,7 +167,7 @@ class InputManager {
} else if (type == KeyType.finger) { } else if (type == KeyType.finger) {
eventTable = this.eventInputSaved; eventTable = this.eventInputSaved;
} else { } else {
Log.error("Unknown type of event"); LOGGER.error("Unknown type of event");
return; return;
} }
if (pointerID > InputManager.MAX_MANAGE_INPUT || pointerID < 0) { if (pointerID > InputManager.MAX_MANAGE_INPUT || pointerID < 0) {
@ -177,13 +186,17 @@ class InputManager {
} else if (tmpWindows != null) { } else if (tmpWindows != null) {
tmpWidget = tmpWindows.getWidgetAtPos(new Vector3f(pos.x(), pos.y(), 0)); tmpWidget = tmpWindows.getWidgetAtPos(new Vector3f(pos.x(), pos.y(), 0));
} }
if (eventTable[pointerID].curentWidgetEvent != null && tmpWidget != eventTable[pointerID].curentWidgetEvent.get() if (eventTable[pointerID].curentWidgetEvent != null
|| (eventTable[pointerID].isInside && (eventTable[pointerID].origin.x() > pos.x() || eventTable[pointerID].origin.y() > pos.y() && tmpWidget != eventTable[pointerID].curentWidgetEvent.get()
|| (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) < pos.x() || (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) < pos.y()))) { || (eventTable[pointerID].isInside && (eventTable[pointerID].origin.x() > pos.x()
|| eventTable[pointerID].origin.y() > pos.y()
|| (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) < pos.x()
|| (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) < pos.y()))) {
eventTable[pointerID].isInside = false; eventTable[pointerID].isInside = false;
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [LEAVE] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [LEAVE] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(), eventTable[pointerID].destinationInputId, KeyStatus.leave, pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(),
eventTable[pointerID].destinationInputId, KeyStatus.leave, pos);
} }
if (!eventTable[pointerID].isInside) { if (!eventTable[pointerID].isInside) {
// set the element inside ... // set the element inside ...
@ -197,35 +210,41 @@ class InputManager {
eventTable[pointerID].size = tmpWidget.getSize(); eventTable[pointerID].size = tmpWidget.getSize();
} }
eventTable[pointerID].destinationInputId = 0; eventTable[pointerID].destinationInputId = 0;
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [ENTER] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [ENTER] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.enter, pos); localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.enter, pos);
} }
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [MOVE] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [MOVE] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.move, pos); localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.move, pos);
} else if (eventTable[pointerID].isUsed) { } else if (eventTable[pointerID].isUsed) {
if (eventTable[pointerID].isInside) { if (eventTable[pointerID].isInside) {
if (eventTable[pointerID].origin.x() > pos.x() || eventTable[pointerID].origin.y() > pos.y() || (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) < pos.x() if (eventTable[pointerID].origin.x() > pos.x() || eventTable[pointerID].origin.y() > pos.y()
|| (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) < pos.x()
|| (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) < pos.y()) { || (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) < pos.y()) {
eventTable[pointerID].isInside = false; eventTable[pointerID].isInside = false;
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [LEAVE] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [LEAVE] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(), eventTable[pointerID].destinationInputId, KeyStatus.leave, pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(),
eventTable[pointerID].destinationInputId, KeyStatus.leave, pos);
} }
} else if ((eventTable[pointerID].origin.x() <= pos.x() && (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) >= pos.x()) } else if ((eventTable[pointerID].origin.x() <= pos.x()
&& (eventTable[pointerID].origin.y() <= pos.y() && (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) >= pos.y())) { && (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) >= pos.x())
&& (eventTable[pointerID].origin.y() <= pos.y()
&& (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) >= pos.y())) {
eventTable[pointerID].isInside = true; eventTable[pointerID].isInside = true;
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [ENTER] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [ENTER] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(), eventTable[pointerID].destinationInputId, KeyStatus.enter, pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(),
eventTable[pointerID].destinationInputId, KeyStatus.enter, pos);
} }
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [MOVE] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [MOVE] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(), eventTable[pointerID].destinationInputId, KeyStatus.move, pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(),
eventTable[pointerID].destinationInputId, KeyStatus.move, pos);
} }
} }
/** /**
* a new layer on the windows is set == > might remove all the property of the current element ... * a new layer on the windows is set == > might remove all the property of the current element ...
*/ */
@ -238,23 +257,23 @@ class InputManager {
cleanElement(this.eventMouseSaved, iii); cleanElement(this.eventMouseSaved, iii);
} }
} }
public void setDpi(final int newDPI) { public void setDpi(final int newDPI) {
this.dpi = newDPI; this.dpi = newDPI;
// recalculate the DPI system ... // recalculate the DPI system ...
calculateLimit(); calculateLimit();
} }
public void setLastKeyboardSpecial(final KeySpecial specialKey) { public void setLastKeyboardSpecial(final KeySpecial specialKey) {
this.specialKey = specialKey; this.specialKey = specialKey;
} }
public void state(final KeyType type, final int pointerID, final boolean isDown, final Vector2f pos) { public void state(final KeyType type, final int pointerID, final boolean isDown, final Vector2f pos) {
if (pointerID >= InputManager.MAX_MANAGE_INPUT) { if (pointerID >= InputManager.MAX_MANAGE_INPUT) {
// reject pointer == > out of IDs... // reject pointer == > out of IDs...
return; return;
} }
//Log.debug("event pointerId=" + pointerID); //LOGGER.debug("event pointerId=" + pointerID);
// convert position in open-GL coordonates ... // convert position in open-GL coordonates ...
InputPoperty[] eventTable = null; InputPoperty[] eventTable = null;
InputLimit localLimit; InputLimit localLimit;
@ -265,7 +284,7 @@ class InputManager {
eventTable = this.eventInputSaved; eventTable = this.eventInputSaved;
localLimit = this.eventInputLimit; localLimit = this.eventInputLimit;
} else { } else {
Log.error("Unknown type of event"); LOGGER.error("Unknown type of event");
return; return;
} }
if (pointerID > InputManager.MAX_MANAGE_INPUT || pointerID <= 0) { if (pointerID > InputManager.MAX_MANAGE_INPUT || pointerID <= 0) {
@ -275,14 +294,15 @@ class InputManager {
// get the curent time ... // get the curent time ...
final long currentTime = System.nanoTime(); final long currentTime = System.nanoTime();
final Windows tmpWindows = this.context.getWindows(); final Windows tmpWindows = this.context.getWindows();
if (isDown) { if (isDown) {
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [DOWN] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [DOWN] " + pos);
if (eventTable[pointerID].isUsed) { if (eventTable[pointerID].isUsed) {
// we have an event previously ... check delay between click and offset position // we have an event previously ... check delay between click and offset position
if (currentTime - eventTable[pointerID].lastTimeEvent > localLimit.sepatateTime) { if (currentTime - eventTable[pointerID].lastTimeEvent > localLimit.sepatateTime) {
cleanElement(eventTable, pointerID); cleanElement(eventTable, pointerID);
} else if (FMath.abs(eventTable[pointerID].downStart.x() - pos.x()) >= localLimit.dpiOffset || FMath.abs(eventTable[pointerID].downStart.y() - pos.y()) >= localLimit.dpiOffset) { } else if (FMath.abs(eventTable[pointerID].downStart.x() - pos.x()) >= localLimit.dpiOffset
|| FMath.abs(eventTable[pointerID].downStart.y() - pos.y()) >= localLimit.dpiOffset) {
cleanElement(eventTable, pointerID); cleanElement(eventTable, pointerID);
} }
} }
@ -290,9 +310,10 @@ class InputManager {
// save start time // save start time
eventTable[pointerID].lastTimeEvent = currentTime; eventTable[pointerID].lastTimeEvent = currentTime;
// generate DOWN Event // generate DOWN Event
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [DOWN] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [DOWN] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(), eventTable[pointerID].destinationInputId, KeyStatus.down, pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent.get(),
eventTable[pointerID].destinationInputId, KeyStatus.down, pos);
} else { } else {
// Mark it used : // Mark it used :
eventTable[pointerID].isUsed = true; eventTable[pointerID].isUsed = true;
@ -312,9 +333,9 @@ class InputManager {
eventTable[pointerID].curentWidgetEvent = new WeakReference<>(tmpWidget); eventTable[pointerID].curentWidgetEvent = new WeakReference<>(tmpWidget);
/* /*
if (tmpWidget != null) { if (tmpWidget != null) {
Log.debug("Get widget at pos=" + pos + " type: " + tmpWidget.getObjectType()); LOGGER.debug("Get widget at pos=" + pos + " type: " + tmpWidget.getObjectType());
} else { } else {
Log.debug("Get widget at pos=" + pos + " NO WIDGET"); LOGGER.debug("Get widget at pos=" + pos + " NO WIDGET");
} }
*/ */
} }
@ -330,35 +351,36 @@ class InputManager {
eventTable[pointerID].destinationInputId = -1; eventTable[pointerID].destinationInputId = -1;
} }
// generate DOWN Event // generate DOWN Event
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [DOWN] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [DOWN] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.down, pos); localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.down, pos);
} }
} else { } else {
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [UP] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [UP] " + pos);
final Widget tmpWidget = eventTable[pointerID].curentWidgetEvent.get(); final Widget tmpWidget = eventTable[pointerID].curentWidgetEvent.get();
if (!eventTable[pointerID].isUsed) { if (!eventTable[pointerID].isUsed) {
// bad case ... ??? // bad case ... ???
Log.debug("Up event without previous down ... "); LOGGER.debug("Up event without previous down ... ");
// Mark it un-used : // Mark it un-used :
eventTable[pointerID].isUsed = false; eventTable[pointerID].isUsed = false;
// revove the widget ... // revove the widget ...
eventTable[pointerID].curentWidgetEvent = null; eventTable[pointerID].curentWidgetEvent = null;
} else if (tmpWidget == null) { } else if (tmpWidget == null) {
// The widget has been removed: // The widget has been removed:
//Log.debug(" Object Removed ..."); //LOGGER.debug(" Object Removed ...");
// Mark it un-used : // Mark it un-used :
eventTable[pointerID].isUsed = false; eventTable[pointerID].isUsed = false;
// revove the widget ... // revove the widget ...
eventTable[pointerID].curentWidgetEvent = null; eventTable[pointerID].curentWidgetEvent = null;
} else { } else {
// generate UP Event // generate UP Event
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [UP] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [UP] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
// send up event after the single event to prevent multiple widget getting elements // send up event after the single event to prevent multiple widget getting elements
localEventInput(type, tmpWidget, pointerID, KeyStatus.up, pos); localEventInput(type, tmpWidget, pointerID, KeyStatus.up, pos);
// generate event (single) // generate event (single)
if (FMath.abs(eventTable[pointerID].downStart.x() - pos.x()) < localLimit.dpiOffset && FMath.abs(eventTable[pointerID].downStart.y() - pos.y()) < localLimit.dpiOffset) { if (FMath.abs(eventTable[pointerID].downStart.x() - pos.x()) < localLimit.dpiOffset
&& FMath.abs(eventTable[pointerID].downStart.y() - pos.y()) < localLimit.dpiOffset) {
// Save current position : // Save current position :
eventTable[pointerID].downStart = pos; eventTable[pointerID].downStart = pos;
// save start time // save start time
@ -369,12 +391,14 @@ class InputManager {
nbClickMax = 5; nbClickMax = 5;
} }
// in grab mode the single to quinte event are not generated .... // in grab mode the single to quinte event are not generated ....
if ((this.grabWidget == null || this.grabWidget.get() == null || type != KeyType.mouse) && eventTable[pointerID].nbClickEvent < nbClickMax) { if ((this.grabWidget == null || this.grabWidget.get() == null || type != KeyType.mouse)
&& eventTable[pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE : // generate event SINGLE :
eventTable[pointerID].nbClickEvent++; eventTable[pointerID].nbClickEvent++;
//Log.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [" + eventTable[pointerID].nbClickEvent + "] " + pos); //LOGGER.debug("GUI : Input ID=" + pointerID + " == >" + eventTable[pointerID].destinationInputId + " [" + eventTable[pointerID].nbClickEvent + "] " + pos);
eventTable[pointerID].posEvent = pos; eventTable[pointerID].posEvent = pos;
localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.pressCount(eventTable[pointerID].nbClickEvent), pos); localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId,
KeyStatus.pressCount(eventTable[pointerID].nbClickEvent), pos);
if (eventTable[pointerID].nbClickEvent >= nbClickMax) { if (eventTable[pointerID].nbClickEvent >= nbClickMax) {
eventTable[pointerID].nbClickEvent = 0; eventTable[pointerID].nbClickEvent = 0;
} }
@ -391,7 +415,7 @@ class InputManager {
} }
} }
} }
/** /**
* This is to transfert the event from one widget to another one * This is to transfert the event from one widget to another one
* @param source the widget where the event came from * @param source the widget where the event came from
@ -406,28 +430,32 @@ class InputManager {
Widget tmpWidget = this.eventInputSaved[iii].curentWidgetEvent.get(); Widget tmpWidget = this.eventInputSaved[iii].curentWidgetEvent.get();
if (tmpWidget == source) { if (tmpWidget == source) {
// inform the widget that it does not receive the event now // inform the widget that it does not receive the event now
//Log.debug("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENTINPUTTYPEABORT] " + this.eventInputSaved[iii].posEvent); //LOGGER.debug("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENTINPUTTYPEABORT] " + this.eventInputSaved[iii].posEvent);
localEventInput(KeyType.finger, tmpWidget, this.eventInputSaved[iii].destinationInputId, KeyStatus.abort, this.eventInputSaved[iii].posEvent); localEventInput(KeyType.finger, tmpWidget, this.eventInputSaved[iii].destinationInputId,
KeyStatus.abort, this.eventInputSaved[iii].posEvent);
// set the new widget ... // set the new widget ...
this.eventInputSaved[iii].curentWidgetEvent = new WeakReference<>(destination); this.eventInputSaved[iii].curentWidgetEvent = new WeakReference<>(destination);
// inform the widget that he receive the event property now... // inform the widget that he receive the event property now...
//Log.debug("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENTINPUTTYPETRANSFERT] " + this.eventInputSaved[iii].posEvent); //LOGGER.debug("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENTINPUTTYPETRANSFERT] " + this.eventInputSaved[iii].posEvent);
localEventInput(KeyType.finger, destination, this.eventInputSaved[iii].destinationInputId, KeyStatus.transfer, this.eventInputSaved[iii].posEvent); localEventInput(KeyType.finger, destination, this.eventInputSaved[iii].destinationInputId,
KeyStatus.transfer, this.eventInputSaved[iii].posEvent);
} }
tmpWidget = this.eventMouseSaved[iii].curentWidgetEvent.get(); tmpWidget = this.eventMouseSaved[iii].curentWidgetEvent.get();
if (tmpWidget == source) { if (tmpWidget == source) {
// inform the widget that it does not receive the event now // inform the widget that it does not receive the event now
//Log.debug("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENTINPUTTYPEABORT] " + this.eventMouseSaved[iii].posEvent); //LOGGER.debug("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENTINPUTTYPEABORT] " + this.eventMouseSaved[iii].posEvent);
localEventInput(KeyType.mouse, tmpWidget, this.eventMouseSaved[iii].destinationInputId, KeyStatus.abort, this.eventMouseSaved[iii].posEvent); localEventInput(KeyType.mouse, tmpWidget, this.eventMouseSaved[iii].destinationInputId, KeyStatus.abort,
this.eventMouseSaved[iii].posEvent);
// set the new widget ... // set the new widget ...
this.eventMouseSaved[iii].curentWidgetEvent = new WeakReference<>(destination); this.eventMouseSaved[iii].curentWidgetEvent = new WeakReference<>(destination);
// inform the widget that he receive the event property now... // inform the widget that he receive the event property now...
//Log.debug("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENTINPUTTYPETRANSFERT] " + this.eventMouseSaved[iii].posEvent); //LOGGER.debug("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENTINPUTTYPETRANSFERT] " + this.eventMouseSaved[iii].posEvent);
localEventInput(KeyType.mouse, destination, this.eventMouseSaved[iii].destinationInputId, KeyStatus.transfer, this.eventMouseSaved[iii].posEvent); localEventInput(KeyType.mouse, destination, this.eventMouseSaved[iii].destinationInputId,
KeyStatus.transfer, this.eventMouseSaved[iii].posEvent);
} }
} }
} }
/** /**
* This function un-lock the pointer properties to move in relative instead of absolute * This function un-lock the pointer properties to move in relative instead of absolute
*/ */
@ -435,7 +463,7 @@ class InputManager {
this.grabWidget = null; this.grabWidget = null;
// TODO this.context.grabPointerEvents(false, Vector3f(0,0)); // TODO this.context.grabPointerEvents(false, Vector3f(0,0));
} }
} }
/** /**
@ -453,7 +481,7 @@ class InputPoperty {
public Vector3f origin = Vector3f.ZERO; public Vector3f origin = Vector3f.ZERO;
public Vector2f posEvent = Vector2f.ZERO; public Vector2f posEvent = Vector2f.ZERO;
public Vector3f size = Vector3f.MAX_VALUE; public Vector3f size = Vector3f.MAX_VALUE;
public void clear() { public void clear() {
this.isUsed = false; this.isUsed = false;
this.destinationInputId = 0; this.destinationInputId = 0;
@ -466,6 +494,6 @@ class InputPoperty {
this.isInside = false; this.isInside = false;
this.nbClickEvent = 0; this.nbClickEvent = 0;
this.posEvent = Vector2f.ZERO; this.posEvent = Vector2f.ZERO;
} }
} }

View File

@ -14,14 +14,20 @@ import java.nio.file.Paths;
import java.util.Collections; import java.util.Collections;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoadPackageStream { public class LoadPackageStream {
private static final Logger LOGGER = LoggerFactory.getLogger(LoadPackageStream.class);
public static byte[] getAllData(final String resourceName) { public static byte[] getAllData(final String resourceName) {
Log.verbose("Load resource: '/resources" + resourceName + "'"); LOGGER.trace("Load resource: '/resources" + resourceName + "'");
final InputStream out = LoadPackageStream.class.getResourceAsStream("/resources" + resourceName); final InputStream out = LoadPackageStream.class.getResourceAsStream("/resources" + resourceName);
if (out == null) { if (out == null) {
Log.error("Can not load resource: '" + resourceName + "'"); LOGGER.error("Can not load resource: '" + resourceName + "'");
for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources")).toArray(Path[]::new)) { for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources"))
Log.warning(" - '" + elem + "'"); .toArray(Path[]::new)) {
LOGGER.warn(" - '" + elem + "'");
} }
return null; return null;
} }
@ -34,7 +40,7 @@ public class LoadPackageStream {
} }
return data; return data;
} }
public static Stream<Path> getResources(final URL element) { public static Stream<Path> getResources(final URL element) {
try { try {
final URI uri = element.toURI(); final URI uri = element.toURI();
@ -66,19 +72,20 @@ public class LoadPackageStream {
return Stream.of(); return Stream.of();
} }
} }
public static InputStream getStream(final String resourceName) { public static InputStream getStream(final String resourceName) {
Log.verbose("Load resource: '/resources" + resourceName + "'"); LOGGER.trace("Load resource: '/resources" + resourceName + "'");
final InputStream out = LoadPackageStream.class.getResourceAsStream("/resources" + resourceName); final InputStream out = LoadPackageStream.class.getResourceAsStream("/resources" + resourceName);
if (out == null) { if (out == null) {
Log.error("Can not load resource: '" + resourceName + "'"); LOGGER.error("Can not load resource: '" + resourceName + "'");
for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources")).toArray(Path[]::new)) { for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources"))
Log.warning(" - '" + elem + "'"); .toArray(Path[]::new)) {
LOGGER.warn(" - '" + elem + "'");
} }
} }
return out; return out;
} }
private LoadPackageStream() {} private LoadPackageStream() {}
} }

View File

@ -1,76 +0,0 @@
package org.atriasoft.ewol.internal;
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log {
private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "ewol";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
public static void critical(final Exception e, final String data) {
e.printStackTrace();
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
}
}
public static void critical(final String data, final Object... objects) {
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data, objects);
}
}
public static void debug(final String data, final Object... objects) {
if (PRINT_DEBUG || FORCE_ALL) {
Logger.debug(LIB_NAME_DRAW, data, objects);
}
}
public static void error(final String data, final Object... objects) {
if (PRINT_ERROR || FORCE_ALL) {
Logger.error(LIB_NAME_DRAW, data, objects);
}
}
public static void info(final String data, final Object... objects) {
if (PRINT_INFO || FORCE_ALL) {
Logger.info(LIB_NAME_DRAW, data, objects);
}
}
public static void print(final String data, final Object... objects) {
if (PRINT_PRINT || FORCE_ALL) {
Logger.print(LIB_NAME_DRAW, data, objects);
}
}
public static void todo(final String data, final Object... objects) {
if (PRINT_TODO || FORCE_ALL) {
Logger.todo(LIB_NAME_DRAW, data, objects);
}
}
public static void verbose(final String data, final Object... objects) {
if (PRINT_VERBOSE || FORCE_ALL) {
Logger.verbose(LIB_NAME_DRAW, data, objects);
}
}
public static void warning(final String data, final Object... objects) {
if (PRINT_WARNING || FORCE_ALL) {
Logger.warning(LIB_NAME_DRAW, data, objects);
}
}
private Log() {}
}

View File

@ -12,7 +12,8 @@ import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.aknot.annotation.AknotName; import org.atriasoft.aknot.annotation.AknotName;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -29,6 +30,7 @@ import org.atriasoft.ewol.internal.Log;
@AknotDefaultAttribute @AknotDefaultAttribute
@AknotIgnoreUnknown @AknotIgnoreUnknown
public class EwolObject { public class EwolObject {
private static final Logger LOGGER = LoggerFactory.getLogger(EwolObject.class);
private static Integer valUID = 0; //!< Static used for the unique ID definition private static Integer valUID = 0; //!< Static used for the unique ID definition
/** /**
@ -76,7 +78,7 @@ public class EwolObject {
synchronized (EwolObject.valUID) { synchronized (EwolObject.valUID) {
this.uniqueId = EwolObject.valUID++; this.uniqueId = EwolObject.valUID++;
} }
Log.debug("new Object : [" + this.uniqueId + "]"); LOGGER.debug("new Object : [" + this.uniqueId + "]");
EwolObject.getObjectManager().add(this); EwolObject.getObjectManager().add(this);
} }
@ -85,12 +87,12 @@ public class EwolObject {
* Auto-destroy the object * Auto-destroy the object
*/ */
protected void autoDestroy() { protected void autoDestroy() {
Log.verbose("Destroy object: [" + getId() + "] type:" + this.getClass().getCanonicalName()); LOGGER.trace("Destroy object: [" + getId() + "] type:" + this.getClass().getCanonicalName());
if (this.parent != null) { if (this.parent != null) {
final EwolObject parent = this.parent.get(); final EwolObject parent = this.parent.get();
// TODO : set a signal to do this ... // TODO : set a signal to do this ...
if (parent != null) { if (parent != null) {
Log.verbose("Destroy object: Call parrent"); LOGGER.trace("Destroy object: Call parrent");
parent.requestDestroyFromChild(this); parent.requestDestroyFromChild(this);
} }
} }
@ -144,7 +146,7 @@ public class EwolObject {
* @return the requested object or null * @return the requested object or null
*/ */
public EwolObject getSubObjectNamed(final String objectName) { public EwolObject getSubObjectNamed(final String objectName) {
Log.verbose("check if name : " + objectName + " ?= " + this.name); LOGGER.trace("check if name : " + objectName + " ?= " + this.name);
if (objectName.equals(this.name)) { if (objectName.equals(this.name)) {
return this; return this;
} }
@ -172,8 +174,10 @@ public class EwolObject {
* @param child Object of the child that want to remove itself * @param child Object of the child that want to remove itself
*/ */
protected void requestDestroyFromChild(final EwolObject child) { protected void requestDestroyFromChild(final EwolObject child) {
Log.info("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ..."); LOGGER.info(
Log.critical("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)"); "requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ...");
LOGGER.error("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)");
System.exit(-1);
} }
public void setName(final String name) { public void setName(final String name) {

View File

@ -10,7 +10,8 @@ import java.util.List;
import org.atriasoft.esignal.Signal; import org.atriasoft.esignal.Signal;
import org.atriasoft.ewol.context.EwolContext; import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.event.EventTime; import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -19,24 +20,25 @@ import org.atriasoft.ewol.internal.Log;
*/ */
public class ObjectManager { public class ObjectManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectManager.class);
private final long applWakeUpTime; //!< Time of the application initialize private final long applWakeUpTime; //!< Time of the application initialize
private final Clock applWakeUpClock; //!< Time of the application initialize private final Clock applWakeUpClock; //!< Time of the application initialize
private EwolContext context = null; private EwolContext context = null;
private final List<WeakReference<EwolObject>> eObjectList = new ArrayList<>(); // all widget allocated == > all time increment ... never removed ... private final List<WeakReference<EwolObject>> eObjectList = new ArrayList<>(); // all widget allocated == > all time increment ... never removed ...
private long lastPeriodicCallTime; //!< last call time ... private long lastPeriodicCallTime; //!< last call time ...
private Clock lastPeriodicCallClock; //!< last call time ... private Clock lastPeriodicCallClock; //!< last call time ...
public final Signal<EventTime> periodicCall = new Signal<>(); public final Signal<EventTime> periodicCall = new Signal<>();
private final List<EwolObject> workerList = new ArrayList<>(); private final List<EwolObject> workerList = new ArrayList<>();
public ObjectManager(final EwolContext context) { public ObjectManager(final EwolContext context) {
this.context = context; this.context = context;
//periodicCall(this, "periodic", "Call every time system render"); //periodicCall(this, "periodic", "Call every time system render");
Log.debug(" == > init Object-Manager"); LOGGER.debug(" == > init Object-Manager");
Log.todo("set this back ..."); LOGGER.info("[TODO] set this back ...");
//this.periodicCall.setPeriodic(true); //this.periodicCall.setPeriodic(true);
// set the basic time properties : // set the basic time properties :
this.applWakeUpTime = System.nanoTime(); this.applWakeUpTime = System.nanoTime();
@ -44,7 +46,7 @@ public class ObjectManager {
this.applWakeUpClock = Clock.systemUTC(); this.applWakeUpClock = Clock.systemUTC();
this.lastPeriodicCallClock = this.applWakeUpClock; this.lastPeriodicCallClock = this.applWakeUpClock;
} }
/** /**
* Internal API that used only with Object toi reference itself in the manager. * Internal API that used only with Object toi reference itself in the manager.
* @note The manager remove the object when the refecence Low down 1 (last keeper) * @note The manager remove the object when the refecence Low down 1 (last keeper)
@ -52,17 +54,17 @@ public class ObjectManager {
*/ */
public synchronized void add(final EwolObject object) { public synchronized void add(final EwolObject object) {
if (object == null) { if (object == null) {
Log.error("try to add an inexistant Object in manager"); LOGGER.error("try to add an inexistant Object in manager");
} }
this.eObjectList.add(new WeakReference<>(object)); this.eObjectList.add(new WeakReference<>(object));
} }
/** /**
* clean the weak pointer list (remove weakptr that is remoed) * clean the weak pointer list (remove weakptr that is remoed)
*/ */
public synchronized void cleanInternalRemoved() { public synchronized void cleanInternalRemoved() {
final int nbObject = this.eObjectList.size(); final int nbObject = this.eObjectList.size();
//Log.verbose("Clean Object List (if needed) : " + this.eObjectList.size() + " elements"); //LOGGER.trace("Clean Object List (if needed) : " + this.eObjectList.size() + " elements");
final Iterator<WeakReference<EwolObject>> iterator = this.eObjectList.iterator(); final Iterator<WeakReference<EwolObject>> iterator = this.eObjectList.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
final WeakReference<EwolObject> elem = iterator.next(); final WeakReference<EwolObject> elem = iterator.next();
@ -71,23 +73,24 @@ public class ObjectManager {
} }
} }
if (this.eObjectList.size() != nbObject) { if (this.eObjectList.size() != nbObject) {
Log.verbose(" remove " + (nbObject - this.eObjectList.size()) + " deprecated objects"); LOGGER.trace(" remove " + (nbObject - this.eObjectList.size()) + " deprecated objects");
} }
} }
/** /**
* Display all object Open. * Display all object Open.
*/ */
public synchronized void displayListObject() { public synchronized void displayListObject() {
Log.info("List loaded object : "); LOGGER.info("List loaded object : ");
for (final WeakReference<EwolObject> it : this.eObjectList) { for (final WeakReference<EwolObject> it : this.eObjectList) {
final EwolObject element = it.get(); final EwolObject element = it.get();
if (element != null) { if (element != null) {
Log.info(" [" + element.getId() + "] name='" + element.getName() + "' type=" + element.getClass().getCanonicalName()); LOGGER.info(" [" + element.getId() + "] name='" + element.getName() + "' type="
+ element.getClass().getCanonicalName());
} }
} }
} }
/** /**
* Retrive an Object with his name * Retrive an Object with his name
* @param name Name of the Object * @param name Name of the Object
@ -105,7 +108,7 @@ public class ObjectManager {
} }
return null; return null;
} }
/** /**
* Get the number of loaded object in the system * Get the number of loaded object in the system
* @return number of Object * @return number of Object
@ -113,7 +116,7 @@ public class ObjectManager {
public synchronized int getNumberObject() { public synchronized int getNumberObject() {
return this.eObjectList.size(); return this.eObjectList.size();
} }
/** /**
* retrive an object with his name * retrive an object with his name
* @param name Name of the object * @param name Name of the object
@ -122,26 +125,27 @@ public class ObjectManager {
public synchronized EwolObject getObjectNamed(final String name) { public synchronized EwolObject getObjectNamed(final String name) {
return get(name); return get(name);
} }
/** /**
* Call every time we can with the current time * Call every time we can with the current time
* @param localTime Current system Time. * @param localTime Current system Time.
*/ */
public synchronized void timeCall(final Clock clock, final long time) { public synchronized void timeCall(final Clock clock, final long time) {
Log.verbose("Periodic main function : Call [START]"); LOGGER.trace("Periodic main function : Call [START]");
final long previousTime = this.lastPeriodicCallTime; final long previousTime = this.lastPeriodicCallTime;
this.lastPeriodicCallTime = time; this.lastPeriodicCallTime = time;
if (this.periodicCall.size() <= 0) { if (this.periodicCall.size() <= 0) {
Log.verbose("Periodic main dunction: Call [ END ] ==> no connection"); LOGGER.trace("Periodic main dunction: Call [ END ] ==> no connection");
return; return;
} }
final Duration deltaTime = Duration.ofNanos(time - previousTime); final Duration deltaTime = Duration.ofNanos(time - previousTime);
final EventTime myTime = new EventTime(clock, this.applWakeUpClock, time, this.applWakeUpTime, deltaTime, deltaTime); final EventTime myTime = new EventTime(clock, this.applWakeUpClock, time, this.applWakeUpTime, deltaTime,
deltaTime);
this.periodicCall.emit(myTime); this.periodicCall.emit(myTime);
Log.verbose("Periodic main dunction : Call [END]"); LOGGER.trace("Periodic main dunction : Call [END]");
} }
/** /**
* Check if the Interface have some user that request a periodic call * Check if the Interface have some user that request a periodic call
* @return true, have some periodic event... * @return true, have some periodic event...
@ -149,7 +153,7 @@ public class ObjectManager {
public synchronized boolean timeCallHave() { public synchronized boolean timeCallHave() {
return this.periodicCall.size() > 0; return this.periodicCall.size() > 0;
} }
/** /**
* If the application is suspended The Ewol Object manager does not know it, just call this to update delta call * If the application is suspended The Ewol Object manager does not know it, just call this to update delta call
* @param localTime Current system Time. * @param localTime Current system Time.
@ -158,14 +162,14 @@ public class ObjectManager {
this.lastPeriodicCallClock = clock; this.lastPeriodicCallClock = clock;
this.lastPeriodicCallTime = time; this.lastPeriodicCallTime = time;
} }
/** /**
* remove all resources (un-init) out of the destructor (due to the system implementation) * remove all resources (un-init) out of the destructor (due to the system implementation)
*/ */
public synchronized void unInit() { public synchronized void unInit() {
Log.debug(" == > Un-Init Object-Manager"); LOGGER.debug(" == > Un-Init Object-Manager");
if (this.workerList.size() > 0) { if (this.workerList.size() > 0) {
Log.debug(" == > Remove all workers"); LOGGER.debug(" == > Remove all workers");
this.workerList.clear(); this.workerList.clear();
} }
for (final WeakReference<EwolObject> it : this.eObjectList) { for (final WeakReference<EwolObject> it : this.eObjectList) {
@ -175,11 +179,11 @@ public class ObjectManager {
} }
} }
if (this.eObjectList.size() != 0) { if (this.eObjectList.size() != 0) {
Log.error("Have " + this.eObjectList.size() + " active Object"); LOGGER.error("Have " + this.eObjectList.size() + " active Object");
} }
this.eObjectList.clear(); this.eObjectList.clear();
} }
/** /**
* Add a worker on the system list. * Add a worker on the system list.
* @param worker Worker to add in the list. * @param worker Worker to add in the list.
@ -187,7 +191,7 @@ public class ObjectManager {
public synchronized void workerAdd(final EwolObject worker) { public synchronized void workerAdd(final EwolObject worker) {
this.workerList.add(worker); this.workerList.add(worker);
} }
/** /**
* Remove a worker on the system list. * Remove a worker on the system list.
* @param worker Worker to add in the list. * @param worker Worker to add in the list.
@ -201,5 +205,5 @@ public class ObjectManager {
} }
} }
} }
} }

View File

@ -12,48 +12,55 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f; import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
import org.atriasoft.gale.resource.ResourceProgram; import org.atriasoft.gale.resource.ResourceProgram;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* simple display of Colored3DObject ==> for DEBUG only Not availlable on * simple display of Colored3DObject ==> for DEBUG only Not availlable on
* ALL platform (like webGL) * ALL platform (like webGL)
*/ */
public class RefactorColored3DObject extends Resource { public class RefactorColored3DObject extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(RefactorColored3DObject.class);
protected int oGLColor; protected int oGLColor;
protected int oGLMatrix; protected int oGLMatrix;
protected int oGLPosition; protected int oGLPosition;
protected ResourceProgram oGLprogram; protected ResourceProgram oGLprogram;
public RefactorColored3DObject() { public RefactorColored3DObject() {
// get the shader resource : // get the shader resource :
this.oGLPosition = 0; this.oGLPosition = 0;
this.oGLprogram = ResourceProgram.create(new Uri("DATA", "simple3D.vert", "ewol"), new Uri("DATA", "simple3D.frag", "ewol")); this.oGLprogram = ResourceProgram.create(new Uri("DATA", "simple3D.vert", "ewol"),
new Uri("DATA", "simple3D.frag", "ewol"));
if (this.oGLprogram != null) { if (this.oGLprogram != null) {
this.oGLPosition = this.oGLprogram.getAttribute("EWcoord3d"); this.oGLPosition = this.oGLprogram.getAttribute("EWcoord3d");
this.oGLColor = this.oGLprogram.getUniform("EWcolor"); this.oGLColor = this.oGLprogram.getUniform("EWcolor");
this.oGLMatrix = this.oGLprogram.getUniform("EWMatrixTransformation"); this.oGLMatrix = this.oGLprogram.getUniform("EWMatrixTransformation");
} }
} }
@Override @Override
public void cleanUp() { public void cleanUp() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void draw(final List<Vector3f> vertices, final Color color) { public void draw(final List<Vector3f> vertices, final Color color) {
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;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
if (depthtest) { if (depthtest) {
@ -62,8 +69,8 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
// Log.debug(" display " + this.coord.size() + " elements" ); // LOGGER.debug(" display " + this.coord.size() + " elements" );
this.oGLprogram.use(); this.oGLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
@ -71,7 +78,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix); final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix);
// position : // position :
this.oGLprogram.sendAttribute(this.oGLPosition, 3/* x,y,z,unused */, ResourceProgram.storeDataInFloatBufferVector3f(vertices), 3); this.oGLprogram.sendAttribute(this.oGLPosition, 3/* x,y,z,unused */,
ResourceProgram.storeDataInFloatBufferVector3f(vertices), 3);
// color : // color :
this.oGLprogram.uniformColor(this.oGLColor, color); this.oGLprogram.uniformColor(this.oGLColor, color);
// Request the draw od the elements: // Request the draw od the elements:
@ -83,22 +91,27 @@ public class RefactorColored3DObject extends Resource {
if (depthtest) { if (depthtest) {
if (!updateDepthBuffer) { if (!updateDepthBuffer) {
OpenGL.setDeathMask(true); OpenGL.setDeathMask(true);
} }
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
} }
} }
public void draw(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix) { public void draw(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix) {
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;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
if (depthTest) { if (depthTest) {
@ -107,7 +120,7 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
// Log.debug(" display " + this.coord.size() + " elements" ); // LOGGER.debug(" display " + this.coord.size() + " elements" );
this.oGLprogram.use(); this.oGLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
@ -115,7 +128,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix).multiply(transformationMatrix); final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix).multiply(transformationMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix);
// position : // position :
this.oGLprogram.sendAttribute(this.oGLPosition, 3/* x,y,z */, ResourceProgram.storeDataInFloatBufferVector3f(vertices), 3); // TODO : check 4->3 this.oGLprogram.sendAttribute(this.oGLPosition, 3/* x,y,z */,
ResourceProgram.storeDataInFloatBufferVector3f(vertices), 3); // TODO : check 4->3
// color : // color :
this.oGLprogram.uniformColor(this.oGLColor, color); this.oGLprogram.uniformColor(this.oGLColor, color);
// Request the draw od the elements: // Request the draw od the elements:
@ -128,29 +142,35 @@ public class RefactorColored3DObject extends Resource {
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
} }
} }
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;
// center to border (TOP) // center to border (TOP)
float offset = size * 0.5f; float offset = size * 0.5f;
for (int iii = lats / 2 + 1; iii <= lats; ++iii) { for (int iii = lats / 2 + 1; 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);
final float z0 = (float) (radius * Math.sin(lat0)); final float z0 = (float) (radius * Math.sin(lat0));
final float zr0 = (float) (radius * Math.cos(lat0)); final float zr0 = (float) (radius * Math.cos(lat0));
final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats); final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats);
final float z1 = (float) (radius * Math.sin(lat1)); final float z1 = (float) (radius * Math.sin(lat1));
final float zr1 = (float) (radius * Math.cos(lat1)); final float zr1 = (float) (radius * Math.cos(lat1));
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
float x = (float) Math.cos(lng); float x = (float) Math.cos(lng);
float y = (float) Math.sin(lng); float y = (float) Math.sin(lng);
final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1 + offset); final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1 + offset);
final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0 + offset); final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0 + offset);
lng = 2 * (float) (Math.PI) * (jjj) / longs; lng = 2 * (float) (Math.PI) * (jjj) / longs;
x = (float) Math.cos(lng); x = (float) Math.cos(lng);
y = (float) Math.sin(lng); y = (float) Math.sin(lng);
@ -159,7 +179,7 @@ public class RefactorColored3DObject extends Resource {
tmpVertices.add(v1); tmpVertices.add(v1);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v1); tmpVertices.add(v1);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v4); tmpVertices.add(v4);
@ -168,24 +188,24 @@ public class RefactorColored3DObject extends Resource {
// Cylinder // Cylinder
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * 0.5f; final float z = size * 0.5f;
float x = (float) (Math.cos(lng) * radius); float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius); float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z); final Vector3f v2 = new Vector3f(x, y, z);
final Vector3f v2b = new Vector3f(x, y, -z); final Vector3f v2b = new Vector3f(x, y, -z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs; lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius); x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius); y = (float) (Math.sin(lng) * radius);
final Vector3f v3 = new Vector3f(x, y, z); final Vector3f v3 = new Vector3f(x, y, z);
final Vector3f v3b = new Vector3f(x, y, -z); final Vector3f v3b = new Vector3f(x, y, -z);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v3b); tmpVertices.add(v3b);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3b); tmpVertices.add(v3b);
tmpVertices.add(v2b); tmpVertices.add(v2b);
@ -196,18 +216,18 @@ public class RefactorColored3DObject extends Resource {
final float lat0 = (float) (Math.PI) * (-0.5f + (float) (iii - 1) / lats); final float lat0 = (float) (Math.PI) * (-0.5f + (float) (iii - 1) / lats);
final float z0 = (float) (radius * Math.sin(lat0)); final float z0 = (float) (radius * Math.sin(lat0));
final float zr0 = (float) (radius * Math.cos(lat0)); final float zr0 = (float) (radius * Math.cos(lat0));
final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats); final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats);
final float z1 = (float) (radius * Math.sin(lat1)); final float z1 = (float) (radius * Math.sin(lat1));
final float zr1 = (float) (radius * Math.cos(lat1)); final float zr1 = (float) (radius * Math.cos(lat1));
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
float x = (float) Math.cos(lng); float x = (float) Math.cos(lng);
float y = (float) Math.sin(lng); float y = (float) Math.sin(lng);
final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1 + offset); final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1 + offset);
final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0 + offset); final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0 + offset);
lng = 2 * (float) (Math.PI) * (jjj) / longs; lng = 2 * (float) (Math.PI) * (jjj) / longs;
x = (float) Math.cos(lng); x = (float) Math.cos(lng);
y = (float) Math.sin(lng); y = (float) Math.sin(lng);
@ -216,7 +236,7 @@ public class RefactorColored3DObject extends Resource {
tmpVertices.add(v1); tmpVertices.add(v1);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v1); tmpVertices.add(v1);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v4); tmpVertices.add(v4);
@ -224,18 +244,24 @@ 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) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, -size / 2); final Vector3f v1 = new Vector3f(0.0f, 0.0f, -size / 2);
float x = (float) (Math.cos(lng) * radius); float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius); float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, size / 2); final Vector3f v2 = new Vector3f(x, y, size / 2);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs; lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius); x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius); y = (float) (Math.sin(lng) * radius);
@ -247,13 +273,13 @@ public class RefactorColored3DObject extends Resource {
// center to border (BOTTOM) // center to border (BOTTOM)
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, size / 2); final Vector3f v1 = new Vector3f(0.0f, 0.0f, size / 2);
float x = (float) (Math.cos(lng) * radius); float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius); float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, size / 2); final Vector3f v2 = new Vector3f(x, y, size / 2);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs; lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius); x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius); y = (float) (Math.sin(lng) * radius);
@ -264,67 +290,83 @@ 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)
// center to border (TOP) // center to border (TOP)
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * 0.5f; final float z = size * 0.5f;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, z); final Vector3f v1 = new Vector3f(0.0f, 0.0f, z);
float x = (float) (Math.cos(lng) * radius); float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius); float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z); final Vector3f v2 = new Vector3f(x, y, z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs; lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius); x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius); y = (float) (Math.sin(lng) * radius);
@ -336,24 +378,24 @@ public class RefactorColored3DObject extends Resource {
// Cylinder // Cylinder
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * 0.5f; final float z = size * 0.5f;
float x = (float) (Math.cos(lng) * radius); float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius); float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z); final Vector3f v2 = new Vector3f(x, y, z);
final Vector3f v2b = new Vector3f(x, y, -z); final Vector3f v2b = new Vector3f(x, y, -z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs; lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius); x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius); y = (float) (Math.sin(lng) * radius);
final Vector3f v3 = new Vector3f(x, y, z); final Vector3f v3 = new Vector3f(x, y, z);
final Vector3f v3b = new Vector3f(x, y, -z); final Vector3f v3b = new Vector3f(x, y, -z);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v3b); tmpVertices.add(v3b);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3b); tmpVertices.add(v3b);
tmpVertices.add(v2b); tmpVertices.add(v2b);
@ -361,14 +403,14 @@ public class RefactorColored3DObject extends Resource {
// center to border (BOTTOM) // center to border (BOTTOM)
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * -0.5f; final float z = size * -0.5f;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, z); final Vector3f v1 = new Vector3f(0.0f, 0.0f, z);
float x = (float) (Math.cos(lng) * radius); float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius); float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z); final Vector3f v2 = new Vector3f(x, y, z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs; lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius); x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius); y = (float) (Math.sin(lng) * radius);
@ -379,17 +421,22 @@ public class RefactorColored3DObject extends Resource {
} }
draw(tmpVertices, tmpColor, transformationMatrix); draw(tmpVertices, tmpColor, transformationMatrix);
} }
public void drawLine(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix) { public void drawLine(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix) {
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;
} }
if (this.oGLprogram == null) { if (this.oGLprogram == null) {
Log.error("No shader ..."); LOGGER.error("No shader ...");
return; return;
} }
if (depthTest) { if (depthTest) {
@ -398,7 +445,7 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false); OpenGL.setDeathMask(false);
} }
} }
// Log.debug(" display " + this.coord.size() + " elements" ); // LOGGER.debug(" display " + this.coord.size() + " elements" );
this.oGLprogram.use(); this.oGLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix(); final Matrix4f projMatrix = OpenGL.getMatrix();
@ -406,7 +453,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix).multiply(transformationMatrix); final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix).multiply(transformationMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix);
// position : // position :
this.oGLprogram.sendAttribute(this.oGLPosition, 3/* x,y,z */, ResourceProgram.storeDataInFloatBufferVector3f(vertices), 3);// TODO check 4->3 this.oGLprogram.sendAttribute(this.oGLPosition, 3/* x,y,z */,
ResourceProgram.storeDataInFloatBufferVector3f(vertices), 3);// TODO check 4->3
// color : // color :
this.oGLprogram.uniformColor(this.oGLColor, color); this.oGLprogram.uniformColor(this.oGLColor, color);
// Request the draw od the elements: // Request the draw od the elements:
@ -419,35 +467,40 @@ public class RefactorColored3DObject extends Resource {
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
} }
} }
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);
final float z0 = (float) (radius * Math.sin(lat0)); final float z0 = (float) (radius * Math.sin(lat0));
final float zr0 = (float) (radius * Math.cos(lat0)); final float zr0 = (float) (radius * Math.cos(lat0));
final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats); final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats);
final float z1 = (float) (radius * Math.sin(lat1)); final float z1 = (float) (radius * Math.sin(lat1));
final float zr1 = (float) (radius * Math.cos(lat1)); final float zr1 = (float) (radius * Math.cos(lat1));
for (int jjj = 0; jjj < longs; ++jjj) { for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs; float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
float x = (float) Math.cos(lng); float x = (float) Math.cos(lng);
float y = (float) Math.sin(lng); float y = (float) Math.sin(lng);
final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1); final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1);
final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0); final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0);
lng = 2 * (float) (Math.PI) * (jjj) / longs; lng = 2 * (float) (Math.PI) * (jjj) / longs;
x = (float) Math.cos(lng); x = (float) Math.cos(lng);
y = (float) Math.sin(lng); y = (float) Math.sin(lng);
final Vector3f v2 = new Vector3f(x * zr1, y * zr1, z1); final Vector3f v2 = new Vector3f(x * zr1, y * zr1, z1);
final Vector3f v3 = new Vector3f(x * zr0, y * zr0, z0); final Vector3f v3 = new Vector3f(x * zr0, y * zr0, z0);
tmpVertices.add(v1); tmpVertices.add(v1);
tmpVertices.add(v2); tmpVertices.add(v2);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v1); tmpVertices.add(v1);
tmpVertices.add(v3); tmpVertices.add(v3);
tmpVertices.add(v4); tmpVertices.add(v4);
@ -455,12 +508,15 @@ public class RefactorColored3DObject extends Resource {
} }
draw(tmpVertices, tmpColor, transformationMatrix); draw(tmpVertices, tmpColor, transformationMatrix);
} }
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()) };
for (int iii = 0; iii < 36; iii += 3) { for (int iii = 0; iii < 36; iii += 3) {
// normal calculation : // normal calculation :
@ -473,23 +529,32 @@ 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)).add(offset)); tmpVertices.add(vertex.get(indice.get(iii * 3)).add(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 1)).add(offset)); tmpVertices.add(vertex.get(indice.get(iii * 3 + 1)).add(offset));
tmpVertices.add(vertex.get(indice.get(iii * 3 + 2)).add(offset)); tmpVertices.add(vertex.get(indice.get(iii * 3 + 2)).add(offset));
// Log.info(" indices " + indice[iii*3 + 0] + " " + indice[iii*3 + 1] + " " + // LOGGER.info(" indices " + indice[iii*3 + 0] + " " + indice[iii*3 + 1] + " " +
// indice[iii*3 + 2]); // indice[iii*3 + 2]);
// Log.info(" triangle " + vertex[indice[iii*3 + 0]] + " " + // LOGGER.info(" triangle " + vertex[indice[iii*3 + 0]] + " " +
// vertex[indice[iii*3 + 1]] + " " + vertex[indice[iii*3 + 2]]); // vertex[indice[iii*3 + 1]] + " " + vertex[indice[iii*3 + 2]]);
} }
// Log.info("display " + tmpVertices.size() + " vertices form " + // LOGGER.info("display " + tmpVertices.size() + " vertices form " +
// indice.size()); // indice.size());
draw(tmpVertices, tmpColor, transformationMatrix); draw(tmpVertices, tmpColor, transformationMatrix);
} }

View File

@ -14,8 +14,9 @@ import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.model.JsonObject; import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class ListElement { class ListElement {
public Color color; public Color color;
@ -33,18 +34,21 @@ class ListElement {
* example black, or white or orange ...) * example black, or white or orange ...)
*/ */
public class ResourceColorFile extends Resource { public class ResourceColorFile extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceColorFile.class);
public static ResourceColorFile create(final Uri uri) { public static ResourceColorFile create(final Uri uri) {
Log.verbose("KEEP: ColorFile: " + uri); LOGGER.trace("KEEP: ColorFile: " + uri);
ResourceColorFile object = null; final ResourceColorFile object = null;
final Resource object2 = Resource.getManager().localKeep(uri); final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) { if (object2 != null) {
if (object2 instanceof ResourceColorFile) { if (object2 instanceof ResourceColorFile) {
return (ResourceColorFile) object2; return (ResourceColorFile) object2;
} }
Log.critical("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)"); LOGGER.error("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null; return null;
} }
Log.debug("CREATE: FontFreeType: " + uri); LOGGER.debug("CREATE: FontFreeType: " + uri);
// need to crate a new one ... // need to crate a new one ...
return new ResourceColorFile(uri); return new ResourceColorFile(uri);
} }
@ -59,9 +63,9 @@ public class ResourceColorFile extends Resource {
*/ */
public ResourceColorFile(final Uri uri) { public ResourceColorFile(final Uri uri) {
super(uri); super(uri);
Log.debug("CF : load \"" + uri + "\""); LOGGER.debug("CF : load \"" + uri + "\"");
reload(); reload();
// Log.debug("List of all color : " + this.list.keySet()); // LOGGER.debug("List of all color : " + this.list.keySet());
} }
@Override @Override
@ -94,8 +98,8 @@ public class ResourceColorFile extends Resource {
} }
public synchronized void put(final String name, final Color color) { public synchronized void put(final String name, final Color color) {
for (int iii = 0; iii < this.list.size(); iii++) { for (final ListElement element : this.list) {
final ListElement elem = this.list.get(iii); final ListElement elem = element;
if (elem.name.contentEquals(name)) { if (elem.name.contentEquals(name)) {
elem.color = color; elem.color = color;
return; return;
@ -107,17 +111,17 @@ public class ResourceColorFile extends Resource {
@Override @Override
public synchronized void reload() { public synchronized void reload() {
// remove all previous set of value : // remove all previous set of value :
for (int iii = 0; iii < this.list.size(); ++iii) { for (final ListElement element : this.list) {
this.list.get(iii).color = this.errorColor; element.color = this.errorColor;
} }
Log.todo("Mut be implemented ..."); LOGGER.info("[TODO] Mut be implemented ...");
// open and read all json elements: // open and read all json elements:
try { try {
final JsonObject out = Ejson.parse(Uri.valueOf(this.name)).toJsonObject(); final JsonObject out = Ejson.parse(Uri.valueOf(this.name)).toJsonObject();
final JsonArray baseArray = out.get("color").toJsonArray(); final JsonArray baseArray = out.get("color").toJsonArray();
if (baseArray == null) { if (baseArray == null) {
Log.error("Can not get basic array : 'color' in file:" + this.name); LOGGER.error("Can not get basic array : 'color' in file:" + this.name);
Ejson.display(out); Ejson.display(out);
return; return;
} }
@ -125,15 +129,15 @@ public class ResourceColorFile extends Resource {
for (final JsonNode it : baseArray.getNodes()) { for (final JsonNode it : baseArray.getNodes()) {
final JsonObject tmpObj = it.toJsonObject(); final JsonObject tmpObj = it.toJsonObject();
if (tmpObj == null) { if (tmpObj == null) {
Log.error(" can not get object in 'color' : " + it); LOGGER.error(" can not get object in 'color' : " + it);
findError = true; findError = true;
continue; continue;
} }
final String name = tmpObj.get("name").toJsonString().getValue(); final String name = tmpObj.get("name").toJsonString().getValue();
final String color = tmpObj.get("color").toJsonString().getValue(); final String color = tmpObj.get("color").toJsonString().getValue();
Log.debug("find new color : '" + name + "' color='" + color + "'"); LOGGER.debug("find new color : '" + name + "' color='" + color + "'");
if (name.length() == 0) { if (name.length() == 0) {
Log.error("Drop an empty name"); LOGGER.error("Drop an empty name");
findError = true; findError = true;
continue; continue;
} }
@ -143,11 +147,11 @@ public class ResourceColorFile extends Resource {
put(name, Color.valueOf(color)); put(name, Color.valueOf(color));
} }
if (findError) { if (findError) {
Log.error("pb in parsing file:" + this.name); LOGGER.error("pb in parsing file:" + this.name);
Ejson.display(out); Ejson.display(out);
} }
} catch (final Exception e) { } catch (final Exception e) {
Log.error("chach exception in parsing config file... " + e.getMessage()); LOGGER.error("chach exception in parsing config file... " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -12,8 +12,9 @@ import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonNode; import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.model.JsonObject; import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class ListElementConfig { class ListElementConfig {
public final String name; public final String name;
@ -26,6 +27,8 @@ class ListElementConfig {
} }
public class ResourceConfigFile extends Resource { public class ResourceConfigFile extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceConfigFile.class);
/** /**
* keep the resource pointer. * keep the resource pointer.
* @note Never free this pointer by your own... * @note Never free this pointer by your own...
@ -42,7 +45,8 @@ public class ResourceConfigFile extends Resource {
resource2.keep(); resource2.keep();
return tmpp; return tmpp;
} }
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)"); LOGGER.error("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null; return null;
} }
final ResourceConfigFile resource = new ResourceConfigFile(name); final ResourceConfigFile resource = new ResourceConfigFile(name);
@ -60,7 +64,7 @@ public class ResourceConfigFile extends Resource {
protected ResourceConfigFile(final Uri uri) { protected ResourceConfigFile(final Uri uri) {
super(uri.toString()); super(uri.toString());
Log.debug("SFP : load '" + uri + "'"); LOGGER.debug("SFP : load '" + uri + "'");
reload(); reload();
} }

View File

@ -14,20 +14,23 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath; import org.atriasoft.etk.math.FMath;
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.ewol.internal.Log;
import org.atriasoft.ewol.resource.font.GlyphProperty; import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html // show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
public class ResourceFontSvg extends Resource { public class ResourceFontSvg extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceFontSvg.class);
public static ResourceFontSvg create(final Uri uri) { public static ResourceFontSvg create(final Uri uri) {
Log.verbose("KEEP: FontFreeType: " + uri); LOGGER.trace("KEEP: FontFreeType: " + uri);
ResourceFontSvg object = null; ResourceFontSvg object = null;
final Resource object2 = Resource.getManager().localKeep(uri); final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) { if (object2 != null) {
if (!(object2 instanceof ResourceFontSvg)) { if (!(object2 instanceof ResourceFontSvg)) {
Log.critical("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)"); LOGGER.error("Request resource file : '" + uri + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null; return null;
} }
object = (ResourceFontSvg) object2; object = (ResourceFontSvg) object2;
@ -35,7 +38,7 @@ public class ResourceFontSvg extends Resource {
if (object != null) { if (object != null) {
return object; return object;
} }
Log.debug("CREATE: FontFreeType: " + uri); LOGGER.debug("CREATE: FontFreeType: " + uri);
// need to crate a new one ... // need to crate a new one ...
return new ResourceFontSvg(uri); return new ResourceFontSvg(uri);
} }
@ -46,10 +49,11 @@ public class ResourceFontSvg extends Resource {
super(uri); super(uri);
this.font = EsvgFont.load(uri); this.font = EsvgFont.load(uri);
if (this.font == null) { if (this.font == null) {
Log.error("... the font file could be opened and read, but it appears ... that its font format is unsupported"); LOGGER.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.font.getNumGlyphs()); LOGGER.debug("load font : '" + uri + "' glyph count = " + this.font.getNumGlyphs());
// display(); // display();
} }
} }
@ -60,15 +64,26 @@ public class ResourceFontSvg extends Resource {
} }
public synchronized void display() { public synchronized void display() {
Log.info(" number of glyph = " + this.font.getNumGlyphs()); LOGGER.info(" number of glyph = " + this.font.getNumGlyphs());
} }
public boolean drawGlyph(final ImageByte imageOut, final int fontSize, final Vector2i glyphPosition, final GlyphProperty property, final int posInImage) { public boolean drawGlyph(
final ImageByte imageOut,
final int fontSize,
final Vector2i glyphPosition,
final GlyphProperty property,
final int posInImage) {
return drawGlyph(imageOut, fontSize, glyphPosition, property, posInImage, false); return drawGlyph(imageOut, fontSize, glyphPosition, property, posInImage, false);
} }
// the forceClimp is to generate a forcing of the rendering in small font, this permit to have a correct view of the font, otherwise it will be transparent. // the forceClimp is to generate a forcing of the rendering in small font, this permit to have a correct view of the font, otherwise it will be transparent.
public synchronized boolean drawGlyph(final ImageByte imageOut, final int fontSize, final Vector2i glyphPosition, final GlyphProperty property, final int posInImage, final boolean forceClimp) { public synchronized boolean drawGlyph(
final ImageByte imageOut,
final int fontSize,
final Vector2i glyphPosition,
final GlyphProperty property,
final int posInImage,
final boolean forceClimp) {
final Weight weight = this.font.render(property.glyph.getUnicodeValue(), fontSize); final Weight weight = this.font.render(property.glyph.getUnicodeValue(), fontSize);
if (weight == null) { if (weight == null) {
return false; return false;
@ -101,7 +116,11 @@ public class ResourceFontSvg extends Resource {
return true; return true;
} }
public synchronized boolean drawGlyph(final ImageByteMono imageOut, final int fontSize, final GlyphProperty property, final int borderSize) { public synchronized boolean drawGlyph(
final ImageByteMono imageOut,
final int fontSize,
final GlyphProperty property,
final int borderSize) {
final Weight weight = this.font.render(property.glyph.getUnicodeValue(), fontSize); final Weight weight = this.font.render(property.glyph.getUnicodeValue(), fontSize);
for (int jjj = 0; jjj < weight.getHeight(); jjj++) { for (int jjj = 0; jjj < weight.getHeight(); jjj++) {
for (int iii = 0; iii < weight.getWidth(); iii++) { for (int iii = 0; iii < weight.getWidth(); iii++) {

View File

@ -13,18 +13,21 @@ import org.atriasoft.etk.math.FMath;
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.ewol.Ewol; import org.atriasoft.ewol.Ewol;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.font.FontMode; import org.atriasoft.ewol.resource.font.FontMode;
import org.atriasoft.ewol.resource.font.GlyphProperty; import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
import org.atriasoft.gale.resource.ResourceTexture2; import org.atriasoft.gale.resource.ResourceTexture2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourceTexturedFont extends ResourceTexture2 { public class ResourceTexturedFont extends ResourceTexture2 {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceTexturedFont.class);
public static ResourceTexturedFont create(final Uri fontBaseUri) { public static ResourceTexturedFont create(final Uri fontBaseUri) {
ResourceTexturedFont resource; ResourceTexturedFont resource;
Resource resource2; Resource resource2;
if (fontBaseUri.isEmpty()) { if (fontBaseUri.isEmpty()) {
Log.error("Can not create a Texture Font without a filaname " + fontBaseUri); LOGGER.error("Can not create a Texture Font without a filaname " + fontBaseUri);
return null; return null;
} }
resource2 = Resource.getManager().localKeep("__TEXTURED__>>" + fontBaseUri.toString()); resource2 = Resource.getManager().localKeep("__TEXTURED__>>" + fontBaseUri.toString());
@ -33,7 +36,8 @@ public class ResourceTexturedFont extends ResourceTexture2 {
resource2.keep(); resource2.keep();
return (ResourceTexturedFont) resource2; return (ResourceTexturedFont) resource2;
} }
Log.critical("Request resource fontName : '" + fontBaseUri + "' With the wrong type (dynamic cast error)"); LOGGER.error("Request resource fontName : '" + fontBaseUri + "' With the wrong type (dynamic cast error)");
System.exit(-1);
return null; return null;
} }
resource = new ResourceTexturedFont(fontBaseUri); resource = new ResourceTexturedFont(fontBaseUri);
@ -60,7 +64,7 @@ public class ResourceTexturedFont extends ResourceTexture2 {
protected ResourceTexturedFont(final Uri fontBaseUri) { protected ResourceTexturedFont(final Uri fontBaseUri) {
super("__TEXTURED_FONT__>>" + fontBaseUri.toString()); super("__TEXTURED_FONT__>>" + fontBaseUri.toString());
this.forceClimp = "true".equals(fontBaseUri.getProperty("FORCE_CLIMP")); this.forceClimp = "true".equals(fontBaseUri.getProperty("FORCE_CLIMP"));
Log.debug("Load font : '" + fontBaseUri + "'"); LOGGER.debug("Load font : '" + fontBaseUri + "'");
this.font[0] = null; this.font[0] = null;
this.font[1] = null; this.font[1] = null;
@ -94,9 +98,12 @@ public class ResourceTexturedFont extends ResourceTexture2 {
this.size = Integer.parseInt(sizeString); this.size = Integer.parseInt(sizeString);
} }
// find all the fonts... // find all the fonts...
final Uri fontBaseUriBold = new Uri(fontBaseUri.getGroup(), fontBaseUri.getPath().replace(".svg", "Bold.svg"), fontBaseUri.getproperties()); final Uri fontBaseUriBold = new Uri(fontBaseUri.getGroup(), fontBaseUri.getPath().replace(".svg", "Bold.svg"),
final Uri fontBaseUriOblique = new Uri(fontBaseUri.getGroup(), fontBaseUri.getPath().replace(".svg", "Oblique.svg"), fontBaseUri.getproperties()); fontBaseUri.getproperties());
final Uri fontBaseUriBoldOblique = new Uri(fontBaseUri.getGroup(), fontBaseUri.getPath().replace(".svg", "BoldOblique.svg"), fontBaseUri.getproperties()); final Uri fontBaseUriOblique = new Uri(fontBaseUri.getGroup(),
fontBaseUri.getPath().replace(".svg", "Oblique.svg"), fontBaseUri.getproperties());
final Uri fontBaseUriBoldOblique = new Uri(fontBaseUri.getGroup(),
fontBaseUri.getPath().replace(".svg", "BoldOblique.svg"), fontBaseUri.getproperties());
if (fontBaseUri.exist()) { if (fontBaseUri.exist()) {
this.fileName[FontMode.REGULAR.getValue()] = fontBaseUri; this.fileName[FontMode.REGULAR.getValue()] = fontBaseUri;
} }
@ -117,7 +124,7 @@ public class ResourceTexturedFont extends ResourceTexture2 {
refMode = FontMode.get(iii); refMode = FontMode.get(iii);
} }
} }
Log.debug(" set reference mode : " + refMode); LOGGER.debug(" set reference mode : " + refMode);
// generate the wrapping on the preventing error // generate the wrapping on the preventing error
for (int iii = 3; iii >= 0; iii--) { for (int iii = 3; iii >= 0; iii--) {
if (this.fileName[iii] != null) { if (this.fileName[iii] != null) {
@ -129,14 +136,17 @@ public class ResourceTexturedFont extends ResourceTexture2 {
for (int iiiFontId = 0; iiiFontId < 4; iiiFontId++) { for (int iiiFontId = 0; iiiFontId < 4; iiiFontId++) {
if (this.fileName[iiiFontId] == null) { if (this.fileName[iiiFontId] == null) {
Log.debug("can not load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size); LOGGER.debug("can not load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId]
+ "\" == > size=" + this.size);
this.font[iiiFontId] = null; this.font[iiiFontId] = null;
continue; continue;
} }
Log.debug("Load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size); LOGGER.debug("Load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size="
+ this.size);
this.font[iiiFontId] = ResourceFontSvg.create(this.fileName[iiiFontId]); this.font[iiiFontId] = ResourceFontSvg.create(this.fileName[iiiFontId]);
if (this.font[iiiFontId] == null) { if (this.font[iiiFontId] == null) {
Log.debug("error in loading FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size); LOGGER.debug("error in loading FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId]
+ "\" == > size=" + this.size);
} }
} }
for (int iiiFontId = 0; iiiFontId < 4; iiiFontId++) { for (int iiiFontId = 0; iiiFontId < 4; iiiFontId++) {
@ -156,15 +166,15 @@ public class ResourceTexturedFont extends ResourceTexture2 {
addGlyph((char) 0); addGlyph((char) 0);
// by default we set only the first AINSI char available // by default we set only the first AINSI char available
for (int iii = 0x20; iii < 0x7F; iii++) { for (int iii = 0x20; iii < 0x7F; iii++) {
Log.verbose("Add clyph :" + iii); LOGGER.trace("Add clyph :" + iii);
addGlyph((char) iii); addGlyph((char) iii);
} }
flush(); flush();
Log.debug("Wrapping properties : "); LOGGER.debug("Wrapping properties : ");
Log.debug(" " + FontMode.REGULAR + " == >" + getWrappingMode(FontMode.REGULAR)); LOGGER.debug(" " + FontMode.REGULAR + " == >" + getWrappingMode(FontMode.REGULAR));
Log.debug(" " + FontMode.ITALIC + " == >" + getWrappingMode(FontMode.ITALIC)); LOGGER.debug(" " + FontMode.ITALIC + " == >" + getWrappingMode(FontMode.ITALIC));
Log.debug(" " + FontMode.BOLD + " == >" + getWrappingMode(FontMode.BOLD)); LOGGER.debug(" " + FontMode.BOLD + " == >" + getWrappingMode(FontMode.BOLD));
Log.debug(" " + FontMode.BOLD_ITALIC + " == >" + getWrappingMode(FontMode.BOLD_ITALIC)); LOGGER.debug(" " + FontMode.BOLD_ITALIC + " == >" + getWrappingMode(FontMode.BOLD_ITALIC));
} }
/** /**
@ -183,30 +193,34 @@ public class ResourceTexturedFont extends ResourceTexture2 {
final GlyphProperty tmpchar = this.font[iii].getGlyphProperty(this.size, val); final GlyphProperty tmpchar = this.font[iii].getGlyphProperty(this.size, val);
if (tmpchar != null && tmpchar.exist()) { if (tmpchar != null && tmpchar.exist()) {
Log.debug("load char : '" + val + "'=" + (int) val); LOGGER.debug("load char : '" + val + "'=" + (int) val);
hasChange = true; hasChange = true;
// change line if needed ... // change line if needed ...
if (this.lastGlyphPos[iii].x() + tmpchar.sizeTexture.x() + 3 > this.data.getSize().x()) { if (this.lastGlyphPos[iii].x() + tmpchar.sizeTexture.x() + 3 > this.data.getSize().x()) {
this.lastGlyphPos[iii] = new Vector2i(1, this.lastGlyphPos[iii].y() + this.lastRawHeigh[iii]); this.lastGlyphPos[iii] = new Vector2i(1, this.lastGlyphPos[iii].y() + this.lastRawHeigh[iii]);
this.lastRawHeigh[iii] = 0; this.lastRawHeigh[iii] = 0;
} }
Log.verbose("glyph texture size = " + tmpchar.sizeTexture + "last posY=" + this.lastGlyphPos[iii].y() + " out size=" + this.data.getSize()); LOGGER.trace("glyph texture size = " + tmpchar.sizeTexture + "last posY=" + this.lastGlyphPos[iii].y()
+ " out size=" + this.data.getSize());
while (this.lastGlyphPos[iii].y() + tmpchar.sizeTexture.y() + 3 > this.data.getSize().y()) { while (this.lastGlyphPos[iii].y() + tmpchar.sizeTexture.y() + 3 > this.data.getSize().y()) {
this.data.resize(this.data.getSize().x(), this.data.getSize().y() * 2); this.data.resize(this.data.getSize().x(), this.data.getSize().y() * 2);
// note : need to rework all the layer due to the fact that the texture is used by the 4 type... // note : need to rework all the layer due to the fact that the texture is used by the 4 type...
for (int kkk = 0; kkk < 4; kkk++) { for (int kkk = 0; kkk < 4; kkk++) {
// change the coordinate on the element in the texture // change the coordinate on the element in the texture
for (int jjj = 0; jjj < this.listElement[kkk].size(); ++jjj) { for (final GlyphProperty element : this.listElement[kkk]) {
this.listElement[kkk].get(jjj).texturePosStart = this.listElement[kkk].get(jjj).texturePosStart.multiply(new Vector2f(1.0f, 0.5f)); element.texturePosStart = element.texturePosStart.multiply(new Vector2f(1.0f, 0.5f));
this.listElement[kkk].get(jjj).texturePosSize = this.listElement[kkk].get(jjj).texturePosSize.multiply(new Vector2f(1.0f, 0.5f)); element.texturePosSize = element.texturePosSize.multiply(new Vector2f(1.0f, 0.5f));
} }
} }
} }
// draw the glyph // draw the glyph
this.font[iii].drawGlyph(this.data, this.size, this.lastGlyphPos[iii], tmpchar, iii); this.font[iii].drawGlyph(this.data, this.size, this.lastGlyphPos[iii], tmpchar, iii);
// set video position // set video position
tmpchar.texturePosStart = new Vector2f((float) this.lastGlyphPos[iii].x() / (float) this.data.getSize().x(), (float) this.lastGlyphPos[iii].y() / (float) this.data.getSize().y()); tmpchar.texturePosStart = new Vector2f(
tmpchar.texturePosSize = new Vector2f((float) tmpchar.sizeTexture.x() / this.data.getSize().x(), (float) tmpchar.sizeTexture.y() / this.data.getSize().y()); (float) this.lastGlyphPos[iii].x() / (float) this.data.getSize().x(),
(float) this.lastGlyphPos[iii].y() / (float) this.data.getSize().y());
tmpchar.texturePosSize = new Vector2f((float) tmpchar.sizeTexture.x() / this.data.getSize().x(),
(float) tmpchar.sizeTexture.y() / this.data.getSize().y());
// update the maximum of the line hight : // update the maximum of the line hight :
if (this.lastRawHeigh[iii] < tmpchar.sizeTexture.y()) { if (this.lastRawHeigh[iii] < tmpchar.sizeTexture.y()) {
@ -217,12 +231,12 @@ public class ResourceTexturedFont extends ResourceTexture2 {
// update the Bitmap position drawing : // update the Bitmap position drawing :
this.lastGlyphPos[iii] = this.lastGlyphPos[iii].add(new Vector2i(tmpchar.sizeTexture.x() + 1, 0)); this.lastGlyphPos[iii] = this.lastGlyphPos[iii].add(new Vector2i(tmpchar.sizeTexture.x() + 1, 0));
} else { } else {
Log.warning("Did not find char : '" + val + "'=" + val); LOGGER.warn("Did not find char : '" + val + "'=" + val);
} }
this.listElement[iii].add(tmpchar); this.listElement[iii].add(tmpchar);
} }
if (hasChange) { if (hasChange) {
Log.verbose("All gliph added ====> request a redraw of all the GUI"); LOGGER.trace("All gliph added ====> request a redraw of all the GUI");
flush(); flush();
Ewol.getContext().forceRedrawAllAsync(); Ewol.getContext().forceRedrawAllAsync();
//IOgami.storePNG(new Uri("file", "fileFont.png"), this.data); // ==> for debug test only ... //IOgami.storePNG(new Uri("file", "fileFont.png"), this.data); // ==> for debug test only ...
@ -245,22 +259,22 @@ public class ResourceTexturedFont extends ResourceTexture2 {
* @return The pointer on the glyph == > never null * @return The pointer on the glyph == > never null
*/ */
public synchronized GlyphProperty getGlyph(final Character charcode, final FontMode displayMode) { public synchronized GlyphProperty getGlyph(final Character charcode, final FontMode displayMode) {
// Log.debug("Get glyph property for mode: " + displayMode + " == > wrapping // LOGGER.debug("Get glyph property for mode: " + displayMode + " == > wrapping
// index : " + this.modeWraping[displayMode]); // index : " + this.modeWraping[displayMode]);
final int index = getIndex(charcode, displayMode); final int index = getIndex(charcode, displayMode);
if (index < 0 || index >= this.listElement[displayMode.getValue()].size()) { if (index < 0 || index >= this.listElement[displayMode.getValue()].size()) {
Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" + index); LOGGER.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" + index);
if (this.listElement[displayMode.getValue()].size() > 0) { if (this.listElement[displayMode.getValue()].size() > 0) {
return this.listElement[displayMode.getValue()].get(0); return this.listElement[displayMode.getValue()].get(0);
} }
return this.emptyGlyph; return this.emptyGlyph;
} }
// Log.error(" index=" + index); // LOGGER.error(" index=" + index);
// Log.error(" this.UVal=" + this.listElement[displayMode][index].UVal); // LOGGER.error(" this.UVal=" + this.listElement[displayMode][index].UVal);
// Log.error(" this.glyphIndex=" + // LOGGER.error(" this.glyphIndex=" +
// this.listElement[displayMode][index].glyphIndex); // this.listElement[displayMode][index].glyphIndex);
// Log.error(" this.advance=" + this.listElement[displayMode][index].advance); // LOGGER.error(" this.advance=" + this.listElement[displayMode][index].advance);
// Log.error(" this.bearing=" + this.listElement[displayMode][index].bearing); // LOGGER.error(" this.bearing=" + this.listElement[displayMode][index].bearing);
return this.listElement[displayMode.getValue()].get(index); return this.listElement[displayMode.getValue()].get(index);
} }
@ -291,12 +305,12 @@ public class ResourceTexturedFont extends ResourceTexture2 {
return charcode - 0x1F; return charcode - 0x1F;
} }
for (int iii = 0x80 - 0x20; iii < this.listElement[displayMode.getValue()].size(); iii++) { for (int iii = 0x80 - 0x20; iii < this.listElement[displayMode.getValue()].size(); iii++) {
// Log.debug("search : '" + charcode + "' =?= '" + // LOGGER.debug("search : '" + charcode + "' =?= '" +
// (this.listElement[displayMode])[iii].UVal + "'"); // (this.listElement[displayMode])[iii].UVal + "'");
if (charcode == this.listElement[displayMode.getValue()].get(iii).getUnicodeValue()) { if (charcode == this.listElement[displayMode.getValue()].get(iii).getUnicodeValue()) {
// Log.debug("search : '" + charcode + "'"); // LOGGER.debug("search : '" + charcode + "'");
if (this.listElement[displayMode.getValue()].get(iii).exist()) { if (this.listElement[displayMode.getValue()].get(iii).exist()) {
// Log.debug("return " + iii); // LOGGER.debug("return " + iii);
return charcode; return charcode;
} }
return 0; return 0;

View File

@ -6,9 +6,12 @@
*/ */
package org.atriasoft.ewol.tools; package org.atriasoft.ewol.tools;
import org.atriasoft.ewol.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Message { public class Message {
private static final Logger LOGGER = LoggerFactory.getLogger(Message.class);
private enum Type { private enum Type {
critical, //!< Critical message pop-up, //!< information message pop-up critical, //!< Critical message pop-up, //!< information message pop-up
error, //!< warning message pop-up error, //!< warning message pop-up
@ -22,7 +25,7 @@ public class Message {
* @param message message to display (decorated text) * @param message message to display (decorated text)
*/ */
private static void create(final Type type, final String message) { private static void create(final Type type, final String message) {
Log.todo("Generic message display (simple interface...)"); LOGGER.info("[TODO] Generic message display (simple interface...)");
/* /*
StdPopUp tmpPopUp = new StdPopUp(); StdPopUp tmpPopUp = new StdPopUp();
switch (type) { switch (type) {
@ -38,7 +41,7 @@ public class Message {
EwolContext context = Ewol.getContext(); EwolContext context = Ewol.getContext();
Windows windows = context.getWindows(); Windows windows = context.getWindows();
if (windows == null) { if (windows == null) {
Log.error("can not get the current windows ... ==> can not display message : " + message); LOGGER.error("can not get the current windows ... ==> can not display message : " + message);
return; return;
} }
windows.popUpWidgetPush(tmpPopUp); windows.popUpWidgetPush(tmpPopUp);

View File

@ -19,10 +19,11 @@ import org.atriasoft.ewol.compositing.ShapeBox;
import org.atriasoft.ewol.event.EventEntry; import org.atriasoft.ewol.event.EventEntry;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventTime; import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.key.KeyKeyboard; import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
@ -35,13 +36,15 @@ import org.atriasoft.gale.key.KeyStatus;
* ~~~~~~~~~~~~~~~~~~~~~~ * ~~~~~~~~~~~~~~~~~~~~~~
*/ */
public class Button extends ContainerToggle { public class Button extends ContainerToggle {
private static final Logger LOGGER = LoggerFactory.getLogger(Button.class);
public enum ButtonLock { public enum ButtonLock {
LOCK_NONE, //!< normal status of the button LOCK_NONE, //!< normal status of the button
LOCK_WHEN_PRESSED, //!< When the state is set in pressed, the status stay in this one LOCK_WHEN_PRESSED, //!< When the state is set in pressed, the status stay in this one
LOCK_WHEN_RELEASED, //!< When the state is set in not pressed, the status stay in this one LOCK_WHEN_RELEASED, //!< When the state is set in not pressed, the status stay in this one
LOCK_ACCESS, //!< all event are trashed == > acctivity of the button is disable LOCK_ACCESS, //!< all event are trashed == > acctivity of the button is disable
} }
public static Button createLabelButton(final String label) { public static Button createLabelButton(final String label) {
final Button out = new Button(); final Button out = new Button();
final Label labelWidget = new Label(); final Label labelWidget = new Label();
@ -53,7 +56,7 @@ public class Button extends ContainerToggle {
out.setSubWidget(labelWidget, 0); out.setSubWidget(labelWidget, 0);
return out; return out;
} }
public static Button createToggleLabelButton(final String label0, final String label1) { public static Button createToggleLabelButton(final String label0, final String label1) {
final Button out = new Button(); final Button out = new Button();
{ {
@ -75,31 +78,31 @@ public class Button extends ContainerToggle {
out.setPropertyToggleMode(true); out.setPropertyToggleMode(true);
return out; return out;
} }
/** /**
* Periodic call to update grapgic display * Periodic call to update grapgic display
* @param event Time generic event * @param event Time generic event
*/ */
protected static void periodicCall(final Button self, final EventTime event) { protected static void periodicCall(final Button self, final EventTime event) {
Log.verbose("Periodic call on Entry(" + event + ")"); LOGGER.trace("Periodic call on Entry(" + event + ")");
if (!self.shape.periodicCall(event)) { if (!self.shape.periodicCall(event)) {
self.periodicConnectionHanble.close(); self.periodicConnectionHanble.close();
} }
self.markToRedraw(); self.markToRedraw();
} }
/// Periodic call handle to remove it when needed /// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection(); protected Connection periodicConnectionHanble = new Connection();
private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol"); private Uri propertyConfig = new Uri("THEME", "shape/Button.json", "ewol");
private boolean propertyValue = false; private boolean propertyValue = false;
private ButtonLock propertyLock = ButtonLock.LOCK_NONE; private ButtonLock propertyLock = ButtonLock.LOCK_NONE;
private boolean propertyToggleMode = false; private boolean propertyToggleMode = false;
private boolean propertyEnableSingle = false; private boolean propertyEnableSingle = false;
protected ShapeBox shapeProperty = ShapeBox.ZERO; protected ShapeBox shapeProperty = ShapeBox.ZERO;
private GuiShape shape; private GuiShape shape;
@AknotSignal @AknotSignal
@AknotName(value = "down") @AknotName(value = "down")
@AknotDescription("Button is Down") @AknotDescription("Button is Down")
@ -124,10 +127,10 @@ public class Button extends ContainerToggle {
@AknotName(value = "value") @AknotName(value = "value")
@AknotDescription("The button value change") @AknotDescription("The button value change")
public Signal<Boolean> signalValue = new Signal<>(); public Signal<Boolean> signalValue = new Signal<>();
private boolean buttonPressed = false; private boolean buttonPressed = false;
private boolean mouseHover = false; private boolean mouseHover = false;
/** /**
* Constructor * Constructor
*/ */
@ -137,7 +140,7 @@ public class Button extends ContainerToggle {
// can not support multiple click... // can not support multiple click...
setMouseLimit(1); setMouseLimit(1);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -148,20 +151,21 @@ public class Button extends ContainerToggle {
padding = this.shape.getPadding(); padding = this.shape.getPadding();
} }
calculateMinMaxSizePadded(padding); calculateMinMaxSizePadded(padding);
Log.verbose("[{}] Result min size : {}", getId(), this.minSize); LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
} }
protected void changeStatusIn(final GuiShapeMode newStatusId) { protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) { if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) { if (!this.periodicConnectionHanble.isConnected()) {
//Log.error("REQUEST: connection on periodic call"); //LOGGER.error("REQUEST: connection on periodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this, Button::periodicCall); this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Button::periodicCall);
} }
markToRedraw(); markToRedraw();
} }
} }
void checkStatus() { void checkStatus() {
if (this.buttonPressed) { if (this.buttonPressed) {
changeStatusIn(GuiShapeMode.SELECT); changeStatusIn(GuiShapeMode.SELECT);
@ -176,7 +180,7 @@ public class Button extends ContainerToggle {
} }
changeStatusIn(GuiShapeMode.NONE); changeStatusIn(GuiShapeMode.NONE);
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "config") @AknotName(value = "config")
@ -184,7 +188,7 @@ public class Button extends ContainerToggle {
public Uri getPropertyConfig() { public Uri getPropertyConfig() {
return this.propertyConfig; return this.propertyConfig;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "lock") @AknotName(value = "lock")
@ -192,7 +196,7 @@ public class Button extends ContainerToggle {
public ButtonLock getPropertyLock() { public ButtonLock getPropertyLock() {
return this.propertyLock; return this.propertyLock;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "value") @AknotName(value = "value")
@ -200,7 +204,7 @@ public class Button extends ContainerToggle {
public boolean getPropertyValue() { public boolean getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "enable-single") @AknotName(value = "enable-single")
@ -208,7 +212,7 @@ public class Button extends ContainerToggle {
public boolean isPropertyEnableSingle() { public boolean isPropertyEnableSingle() {
return this.propertyEnableSingle; return this.propertyEnableSingle;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "toggle") @AknotName(value = "toggle")
@ -216,7 +220,7 @@ public class Button extends ContainerToggle {
public boolean isPropertyToggleMode() { public boolean isPropertyToggleMode() {
return this.propertyToggleMode; return this.propertyToggleMode;
} }
void onChangePropertyEnableSingle() { void onChangePropertyEnableSingle() {
if (this.propertyEnableSingle) { if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) { if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
@ -228,7 +232,7 @@ public class Button extends ContainerToggle {
} }
} }
} }
void onChangePropertyLock() { void onChangePropertyLock() {
if (ButtonLock.LOCK_ACCESS == this.propertyLock) { if (ButtonLock.LOCK_ACCESS == this.propertyLock) {
this.buttonPressed = false; this.buttonPressed = false;
@ -237,7 +241,7 @@ public class Button extends ContainerToggle {
checkStatus(); checkStatus();
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyShaper() { protected void onChangePropertyShaper() {
if (this.shape == null) { if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig); this.shape = new GuiShape(this.propertyConfig);
@ -246,18 +250,16 @@ public class Button extends ContainerToggle {
} }
markToRedraw(); markToRedraw();
} }
void onChangePropertyToggleMode() { void onChangePropertyToggleMode() {
this.propertyValue = !this.propertyValue; this.propertyValue = !this.propertyValue;
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
if (!this.propertyToggleMode) { if (!this.propertyToggleMode) {
this.idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} else if (!this.propertyValue) {
this.idWidgetDisplayed = 0;
} else { } else {
if (!this.propertyValue) { this.idWidgetDisplayed = 1;
this.idWidgetDisplayed = 0;
} else {
this.idWidgetDisplayed = 1;
}
} }
if (this.propertyEnableSingle) { if (this.propertyEnableSingle) {
if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) { if (this.idWidgetDisplayed == 0 && this.subWidget[0] == null && this.subWidget[1] != null) {
@ -269,7 +271,7 @@ public class Button extends ContainerToggle {
checkStatus(); checkStatus();
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
if (this.propertyToggleMode) { if (this.propertyToggleMode) {
if (!this.propertyValue) { if (!this.propertyValue) {
@ -288,13 +290,13 @@ public class Button extends ContainerToggle {
checkStatus(); checkStatus();
markToRedraw(); markToRedraw();
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
onChangeSizePadded(padding); onChangeSizePadded(padding);
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
if (this.shape != null) { if (this.shape != null) {
@ -302,21 +304,21 @@ public class Button extends ContainerToggle {
} }
super.onDraw(); super.onDraw();
} }
@Override @Override
protected boolean onEventEntry(final EventEntry event) { protected boolean onEventEntry(final EventEntry event) {
//Log.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //LOGGER.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if (event.type() == KeyKeyboard.CHARACTER && event.status() == KeyStatus.down && event.getChar() == '\r') { if (event.type() == KeyKeyboard.CHARACTER && event.status() == KeyStatus.down && event.getChar() == '\r') {
this.signalEnter.emit(); this.signalEnter.emit();
return true; return true;
} }
return super.onEventEntry(event); return super.onEventEntry(event);
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector3f relPos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0)); final Vector3f relPos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
Log.warning("Event on Input ... " + event + " relPos = " + relPos); LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = this.shapeProperty.isInside(relPos); final boolean over = this.shapeProperty.isInside(relPos);
//filter if outside the element... //filter if outside the element...
if (event.status() == KeyStatus.leave) { if (event.status() == KeyStatus.leave) {
@ -329,7 +331,7 @@ public class Button extends ContainerToggle {
if (KeyStatus.leave == event.status()) { if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL); changeStatusIn(GuiShapeMode.NORMAL);
} else { } else {
Log.verbose("Detect Over : " + this.shapeProperty); LOGGER.trace("Detect Over : " + this.shapeProperty);
if (over) { if (over) {
changeStatusIn(GuiShapeMode.OVER); changeStatusIn(GuiShapeMode.OVER);
} else { } else {
@ -346,10 +348,10 @@ public class Button extends ContainerToggle {
keepFocus(); keepFocus();
this.signalClick.emit(); this.signalClick.emit();
if (this.propertyToggleMode) { if (this.propertyToggleMode) {
this.setPropertyValue(!this.propertyValue); setPropertyValue(!this.propertyValue);
} else { } else {
this.setPropertyValue(!this.propertyValue); setPropertyValue(!this.propertyValue);
this.setPropertyValue(!this.propertyValue); setPropertyValue(!this.propertyValue);
} }
return true; return true;
} }
@ -376,24 +378,24 @@ public class Button extends ContainerToggle {
} }
return false; return false;
} }
@Override @Override
protected void onLostFocus() { protected void onLostFocus() {
this.buttonPressed = false; this.buttonPressed = false;
Log.verbose(this.name + " : Remove Focus ..."); LOGGER.trace(this.name + " : Remove Focus ...");
checkStatus(); checkStatus();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
super.onRegenerateDisplay(); super.onRegenerateDisplay();
if (!needRedraw()) { if (!needRedraw()) {
//return; //return;
} }
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'"); //LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear(); this.shape.clear();
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize; Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize)); Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
@ -408,7 +410,7 @@ public class Button extends ContainerToggle {
tmpSizeShaper = tmpSizeShaper.withZ(this.size.y()); tmpSizeShaper = tmpSizeShaper.withZ(this.size.y());
delta = delta.withZ(0.0f); delta = delta.withZ(0.0f);
} }
Vector3f tmpOriginShaper = delta; Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z()); Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f); //Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
@ -418,13 +420,13 @@ public class Button extends ContainerToggle {
tmpOriginShaper = tmpOriginShaper.clipInteger(); tmpOriginShaper = tmpOriginShaper.clipInteger();
tmpSizeText = tmpSizeText.clipInteger(); tmpSizeText = tmpSizeText.clipInteger();
tmpOriginText = tmpOriginText.clipInteger(); tmpOriginText = tmpOriginText.clipInteger();
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding); this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.shape.flush(); this.shape.flush();
} }
public void setPropertyConfig(final Uri propertyConfig) { public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) { if (this.propertyConfig.equals(propertyConfig)) {
return; return;
@ -432,22 +434,22 @@ public class Button extends ContainerToggle {
this.propertyConfig = propertyConfig; this.propertyConfig = propertyConfig;
onChangePropertyShaper(); onChangePropertyShaper();
} }
public void setPropertyEnableSingle(final boolean propertyEnableSingle) { public void setPropertyEnableSingle(final boolean propertyEnableSingle) {
this.propertyEnableSingle = propertyEnableSingle; this.propertyEnableSingle = propertyEnableSingle;
markToRedraw(); markToRedraw();
} }
public void setPropertyLock(final ButtonLock propertyLock) { public void setPropertyLock(final ButtonLock propertyLock) {
this.propertyLock = propertyLock; this.propertyLock = propertyLock;
markToRedraw(); markToRedraw();
} }
public void setPropertyToggleMode(final boolean propertyToggleMode) { public void setPropertyToggleMode(final boolean propertyToggleMode) {
this.propertyToggleMode = propertyToggleMode; this.propertyToggleMode = propertyToggleMode;
markToRedraw(); markToRedraw();
} }
public void setPropertyValue(final boolean propertyValue) { public void setPropertyValue(final boolean propertyValue) {
if (this.propertyValue == propertyValue) { if (this.propertyValue == propertyValue) {
return; return;
@ -456,5 +458,5 @@ public class Button extends ContainerToggle {
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
onChangePropertyValue(); onChangePropertyValue();
} }
} }

View File

@ -17,7 +17,6 @@ import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Gravity; import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.exml.XmlMapper; import org.atriasoft.exml.XmlMapper;
import org.atriasoft.exml.exception.ExmlException; import org.atriasoft.exml.exception.ExmlException;
@ -25,33 +24,37 @@ import org.atriasoft.gale.context.ClipboardList;
import org.atriasoft.gale.context.Cursor; import org.atriasoft.gale.context.Cursor;
import org.atriasoft.gale.key.KeyKeyboard; import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial; import org.atriasoft.gale.key.KeySpecial;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree * the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree
*/ */
public class Composer extends Container { public class Composer extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Composer.class);
public static Widget composerGenerateFile(final Uri data) { public static Widget composerGenerateFile(final Uri data) {
return composerGenerateFile(data, 0); return composerGenerateFile(data, 0);
} }
public static Widget composerGenerateFile(final Uri uri, final long id) { public static Widget composerGenerateFile(final Uri uri, final long id) {
final byte[] elemData = Uri.getAllData(uri); final byte[] elemData = Uri.getAllData(uri);
if (elemData == null) { if (elemData == null) {
Log.error("Can not read the Stream : {}", uri); LOGGER.error("Can not read the Stream : {}", uri);
return null; return null;
} }
final String dataToParse = new String(elemData); final String dataToParse = new String(elemData);
final Widget tmp = composerGenerateString(dataToParse, id); final Widget tmp = composerGenerateString(dataToParse, id);
if (tmp == null) { if (tmp == null) {
Log.error("Fail to Load data: {}", uri); LOGGER.error("Fail to Load data: {}", uri);
} }
return tmp; return tmp;
} }
public static Widget composerGenerateString(final String data) { public static Widget composerGenerateString(final String data) {
return composerGenerateString(data, 0); return composerGenerateString(data, 0);
} }
public static Widget composerGenerateString(String data, final long id) { public static Widget composerGenerateString(String data, final long id) {
boolean requestComposer = true; boolean requestComposer = true;
if (!data.startsWith("<Composer>")) { if (!data.startsWith("<Composer>")) {
@ -64,7 +67,7 @@ public class Composer extends Container {
try { try {
result = mapper.parse(data, Composer.class);//new WidgetXmlFactory()); result = mapper.parse(data, Composer.class);//new WidgetXmlFactory());
} catch (final ExmlException | AknotException ex) { } catch (final ExmlException | AknotException ex) {
Log.error("Fail to load Data !!! {}", ex.toString()); LOGGER.error("Fail to load Data !!! {}", ex.toString());
ex.printStackTrace(); ex.printStackTrace();
} }
if (result == null) { if (result == null) {
@ -75,19 +78,19 @@ public class Composer extends Container {
} }
return result.getSubWidget(); return result.getSubWidget();
} }
protected boolean propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove protected boolean propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove
protected Uri propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display protected Uri propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display
/** /**
* Constructor * Constructor
*/ */
public Composer() { public Composer() {
// nothing to do... // nothing to do...
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -96,44 +99,44 @@ public class Composer extends Container {
} }
super.calculateMinMaxSize(); super.calculateMinMaxSize();
} }
@Override @Override
public void calculateSize() { public void calculateSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.calculateSize(); this.subWidget.calculateSize();
return; return;
} }
super.calculateSize(); super.calculateSize();
} }
@Override @Override
public Vector3b canExpand() { public Vector3b canExpand() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.canExpand(); return this.subWidget.canExpand();
} }
return super.canExpand(); return super.canExpand();
} }
@Override @Override
public Vector3b canExpandIfFree() { public Vector3b canExpandIfFree() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.canExpandIfFree(); return this.subWidget.canExpandIfFree();
} }
return super.canExpandIfFree(); return super.canExpandIfFree();
} }
@Override @Override
public Vector3b canFill() { public Vector3b canFill() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.canFill(); return this.subWidget.canFill();
} }
return super.canFill(); return super.canFill();
} }
@Override @Override
void changeZoom(final float range) { void changeZoom(final float range) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -142,7 +145,7 @@ public class Composer extends Container {
} }
super.changeZoom(range); super.changeZoom(range);
} }
@Override @Override
public void checkMaxSize() { public void checkMaxSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -151,71 +154,71 @@ public class Composer extends Container {
} }
super.checkMaxSize(); super.checkMaxSize();
} }
@Override @Override
public void checkMinSize() { public void checkMinSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.checkMinSize(); this.subWidget.checkMinSize();
return; return;
} }
super.checkMinSize(); super.checkMinSize();
} }
@Override @Override
public Vector3f getCalculateMaxSize() { public Vector3f getCalculateMaxSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getCalculateMaxSize(); return this.subWidget.getCalculateMaxSize();
} }
return super.getCalculateMaxSize(); return super.getCalculateMaxSize();
} }
@Override @Override
public Vector3f getCalculateMinSize() { public Vector3f getCalculateMinSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getCalculateMinSize(); return this.subWidget.getCalculateMinSize();
} }
return super.getCalculateMinSize(); return super.getCalculateMinSize();
} }
@Override @Override
public Cursor getCursor() { public Cursor getCursor() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getCursor(); return this.subWidget.getCursor();
} }
return super.getCursor(); return super.getCursor();
} }
@Override @Override
public boolean getGrabStatus() { public boolean getGrabStatus() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getGrabStatus(); return this.subWidget.getGrabStatus();
} }
return super.getGrabStatus(); return super.getGrabStatus();
} }
@Override @Override
public boolean getKeyboardRepeat() { public boolean getKeyboardRepeat() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getKeyboardRepeat(); return this.subWidget.getKeyboardRepeat();
} }
return super.getKeyboardRepeat(); return super.getKeyboardRepeat();
} }
@Override @Override
public int getMouseLimit() { public int getMouseLimit() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getMouseLimit(); return this.subWidget.getMouseLimit();
} }
return super.getMouseLimit(); return super.getMouseLimit();
} }
@Override @Override
Vector3f getOffset() { Vector3f getOffset() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -223,7 +226,7 @@ public class Composer extends Container {
} }
return super.getOffset(); return super.getOffset();
} }
@Override @Override
public Vector3f getOrigin() { public Vector3f getOrigin() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -231,79 +234,79 @@ public class Composer extends Container {
} }
return super.getOrigin(); return super.getOrigin();
} }
@Override @Override
public boolean getPropertyCanFocus() { public boolean getPropertyCanFocus() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyCanFocus(); return this.subWidget.getPropertyCanFocus();
} }
return super.getPropertyCanFocus(); return super.getPropertyCanFocus();
} }
@Override @Override
public Vector3b getPropertyExpand() { public Vector3b getPropertyExpand() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyExpand(); return this.subWidget.getPropertyExpand();
} }
return super.getPropertyExpand(); return super.getPropertyExpand();
} }
@Override @Override
public Vector3b getPropertyExpandIfFree() { public Vector3b getPropertyExpandIfFree() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyExpandIfFree(); return this.subWidget.getPropertyExpandIfFree();
} }
return super.getPropertyExpandIfFree(); return super.getPropertyExpandIfFree();
} }
@Override @Override
public Vector3b getPropertyFill() { public Vector3b getPropertyFill() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyFill(); return this.subWidget.getPropertyFill();
} }
return super.getPropertyFill(); return super.getPropertyFill();
} }
@Override @Override
public Gravity getPropertyGravity() { public Gravity getPropertyGravity() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyGravity(); return this.subWidget.getPropertyGravity();
} }
return super.getPropertyGravity(); return super.getPropertyGravity();
} }
@Override @Override
public boolean getPropertyHide() { public boolean getPropertyHide() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyHide(); return this.subWidget.getPropertyHide();
} }
return super.getPropertyHide(); return super.getPropertyHide();
} }
@Override @Override
public Dimension3f getPropertyMaxSize() { public Dimension3f getPropertyMaxSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyMaxSize(); return this.subWidget.getPropertyMaxSize();
} }
return super.getPropertyMaxSize(); return super.getPropertyMaxSize();
} }
@Override @Override
public Dimension3f getPropertyMinSize() { public Dimension3f getPropertyMinSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getPropertyMinSize(); return this.subWidget.getPropertyMinSize();
} }
return super.getPropertyMinSize(); return super.getPropertyMinSize();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "sub-file") @AknotName(value = "sub-file")
@ -311,16 +314,16 @@ public class Composer extends Container {
public Uri getPropertySubFile() { public Uri getPropertySubFile() {
return this.propertySubFile; return this.propertySubFile;
} }
@Override @Override
public Vector3f getSize() { public Vector3f getSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.getSize(); return this.subWidget.getSize();
} }
return super.getSize(); return super.getSize();
} }
@Override @Override
public EwolObject getSubObjectNamed(final String objectName) { public EwolObject getSubObjectNamed(final String objectName) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -328,7 +331,7 @@ public class Composer extends Container {
} }
return super.getSubObjectNamed(objectName); return super.getSubObjectNamed(objectName);
} }
@Override @Override
public float getZoom() { public float getZoom() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -336,7 +339,7 @@ public class Composer extends Container {
} }
return super.getZoom(); return super.getZoom();
} }
@Override @Override
public void grabCursor() { public void grabCursor() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -345,7 +348,7 @@ public class Composer extends Container {
} }
super.grabCursor(); super.grabCursor();
} }
@Override @Override
public boolean isFocused() { public boolean isFocused() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -353,7 +356,7 @@ public class Composer extends Container {
} }
return super.isFocused(); return super.isFocused();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "remove-if-under-remove") @AknotName(value = "remove-if-under-remove")
@ -361,7 +364,7 @@ public class Composer extends Container {
public boolean isPropertyRemoveIfUnderRemove() { public boolean isPropertyRemoveIfUnderRemove() {
return this.propertyRemoveIfUnderRemove; return this.propertyRemoveIfUnderRemove;
} }
@Override @Override
public void keepFocus() { public void keepFocus() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -370,7 +373,7 @@ public class Composer extends Container {
} }
super.keepFocus(); super.keepFocus();
} }
/** /**
* load a composition with a file * load a composition with a file
* @param _uri Name of the file * @param _uri Name of the file
@ -379,7 +382,7 @@ public class Composer extends Container {
* @return false == > some error occured * @return false == > some error occured
*/ */
public boolean loadFromFile(final Uri uri) { public boolean loadFromFile(final Uri uri) {
final Widget data = composerGenerateFile(uri, this.getId()); final Widget data = composerGenerateFile(uri, getId());
// check parse is well done. // check parse is well done.
if (data == null) { if (data == null) {
return false; return false;
@ -393,7 +396,7 @@ public class Composer extends Container {
// T O D O: Change this with a throw.a..a // T O D O: Change this with a throw.a..a
return true; return true;
} }
/** /**
* load a composition with a file * load a composition with a file
* @param composerXmlString xml to parse directly * @param composerXmlString xml to parse directly
@ -402,7 +405,7 @@ public class Composer extends Container {
* @return false == > some error occured * @return false == > some error occured
*/ */
public boolean loadFromString(final String composerXmlString) { public boolean loadFromString(final String composerXmlString) {
final Widget data = composerGenerateString(composerXmlString, this.getId()); final Widget data = composerGenerateString(composerXmlString, getId());
// check parse is well done. // check parse is well done.
if (data == null) { if (data == null) {
return false; return false;
@ -416,29 +419,29 @@ public class Composer extends Container {
// T O D O: Change this with a throw.a..a // T O D O: Change this with a throw.a..a
return true; return true;
} }
@Override @Override
public void markToRedraw() { public void markToRedraw() {
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.calculateMinMaxSize(); this.subWidget.calculateMinMaxSize();
return; return;
} }
super.markToRedraw(); super.markToRedraw();
} }
protected void onChangePropertySubFile() { protected void onChangePropertySubFile() {
Log.info("Load compositing form external file : " + this.propertySubFile); LOGGER.info("Load compositing form external file : " + this.propertySubFile);
if (this.propertySubFile.isEmpty()) { if (this.propertySubFile.isEmpty()) {
// remove all elements: // remove all elements:
subWidgetRemove(); subWidgetRemove();
return; return;
} }
if (!loadFromFile(this.propertySubFile)) { if (!loadFromFile(this.propertySubFile)) {
Log.error("Can not load Player GUI from file ... " + this.propertySubFile); LOGGER.error("Can not load Player GUI from file ... " + this.propertySubFile);
} }
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -447,7 +450,7 @@ public class Composer extends Container {
} }
super.onChangeSize(); super.onChangeSize();
} }
@Override @Override
public void onEventClipboard(final ClipboardList clipboardID) { public void onEventClipboard(final ClipboardList clipboardID) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -456,15 +459,19 @@ public class Composer extends Container {
} }
super.onEventClipboard(clipboardID); super.onEventClipboard(clipboardID);
} }
@Override @Override
public boolean onEventShortCut(final KeySpecial special, final Character unicodeValue, final KeyKeyboard kbMove, final boolean isDown) { public boolean onEventShortCut(
final KeySpecial special,
final Character unicodeValue,
final KeyKeyboard kbMove,
final boolean isDown) {
if (this.subWidget != null) { if (this.subWidget != null) {
return this.subWidget.onEventShortCut(special, unicodeValue, kbMove, isDown); return this.subWidget.onEventShortCut(special, unicodeValue, kbMove, isDown);
} }
return super.onEventShortCut(special, unicodeValue, kbMove, isDown); return super.onEventShortCut(special, unicodeValue, kbMove, isDown);
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -473,7 +480,7 @@ public class Composer extends Container {
} }
super.onRegenerateDisplay(); super.onRegenerateDisplay();
} }
@Override @Override
public Vector3f relativePosition(final Vector3f pos) { public Vector3f relativePosition(final Vector3f pos) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -481,16 +488,16 @@ public class Composer extends Container {
} }
return super.relativePosition(pos); return super.relativePosition(pos);
} }
@Override @Override
public void requestDestroyFromChild(final EwolObject child) { public void requestDestroyFromChild(final EwolObject child) {
super.requestDestroyFromChild(child); super.requestDestroyFromChild(child);
if (this.propertyRemoveIfUnderRemove) { if (this.propertyRemoveIfUnderRemove) {
Log.debug("Child widget remove ==> auto-remove"); LOGGER.debug("Child widget remove ==> auto-remove");
autoDestroy(); autoDestroy();
} }
} }
@Override @Override
public void requestUpdateSize() { public void requestUpdateSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -499,7 +506,7 @@ public class Composer extends Container {
} }
super.requestUpdateSize(); super.requestUpdateSize();
} }
@Override @Override
public boolean rmFocus() { public boolean rmFocus() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -507,7 +514,7 @@ public class Composer extends Container {
} }
return super.rmFocus(); return super.rmFocus();
} }
@Override @Override
public void setCursor(final Cursor newCursor) { public void setCursor(final Cursor newCursor) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -516,7 +523,7 @@ public class Composer extends Container {
} }
super.setCursor(newCursor); super.setCursor(newCursor);
} }
@Override @Override
public boolean setFocus() { public boolean setFocus() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -524,7 +531,7 @@ public class Composer extends Container {
} }
return super.setFocus(); return super.setFocus();
} }
@Override @Override
public void setMouseLimit(final int numberState) { public void setMouseLimit(final int numberState) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -533,7 +540,7 @@ public class Composer extends Container {
} }
super.setMouseLimit(numberState); super.setMouseLimit(numberState);
} }
@Override @Override
public void setNoMaxSize() { public void setNoMaxSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -542,7 +549,7 @@ public class Composer extends Container {
} }
super.setNoMaxSize(); super.setNoMaxSize();
} }
@Override @Override
public void setNoMinSize() { public void setNoMinSize() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -551,7 +558,7 @@ public class Composer extends Container {
} }
super.setNoMinSize(); super.setNoMinSize();
} }
@Override @Override
public void setOffset(final Vector3f newVal) { public void setOffset(final Vector3f newVal) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -560,7 +567,7 @@ public class Composer extends Container {
} }
super.setOffset(newVal); super.setOffset(newVal);
} }
@Override @Override
public void setOrigin(final Vector3f pos) { public void setOrigin(final Vector3f pos) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -569,7 +576,7 @@ public class Composer extends Container {
} }
super.setOrigin(pos); super.setOrigin(pos);
} }
@Override @Override
public void setPropertyCanFocus(final boolean canFocus) { public void setPropertyCanFocus(final boolean canFocus) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -578,7 +585,7 @@ public class Composer extends Container {
} }
super.setPropertyCanFocus(canFocus); super.setPropertyCanFocus(canFocus);
} }
@Override @Override
public void setPropertyExpand(final Vector3b value) { public void setPropertyExpand(final Vector3b value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -587,7 +594,7 @@ public class Composer extends Container {
} }
super.setPropertyExpand(value); super.setPropertyExpand(value);
} }
@Override @Override
public void setPropertyExpandIfFree(final Vector3b value) { public void setPropertyExpandIfFree(final Vector3b value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -596,7 +603,7 @@ public class Composer extends Container {
} }
super.setPropertyExpandIfFree(value); super.setPropertyExpandIfFree(value);
} }
@Override @Override
public void setPropertyFill(final Vector3b value) { public void setPropertyFill(final Vector3b value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -605,7 +612,7 @@ public class Composer extends Container {
} }
super.setPropertyFill(value); super.setPropertyFill(value);
} }
@Override @Override
public void setPropertyGravity(final Gravity gravity) { public void setPropertyGravity(final Gravity gravity) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -614,7 +621,7 @@ public class Composer extends Container {
} }
super.setPropertyGravity(gravity); super.setPropertyGravity(gravity);
} }
@Override @Override
public void setPropertyHide(final boolean value) { public void setPropertyHide(final boolean value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -623,7 +630,7 @@ public class Composer extends Container {
} }
super.setPropertyHide(value); super.setPropertyHide(value);
} }
@Override @Override
public void setPropertyMaxSize(final Dimension3f value) { public void setPropertyMaxSize(final Dimension3f value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -632,7 +639,7 @@ public class Composer extends Container {
} }
super.setPropertyMaxSize(value); super.setPropertyMaxSize(value);
} }
@Override @Override
public void setPropertyMinSize(final Dimension3f value) { public void setPropertyMinSize(final Dimension3f value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -641,14 +648,14 @@ public class Composer extends Container {
} }
super.setPropertyMinSize(value); super.setPropertyMinSize(value);
} }
public void setPropertyRemoveIfUnderRemove(final boolean propertyRemoveIfUnderRemove) { public void setPropertyRemoveIfUnderRemove(final boolean propertyRemoveIfUnderRemove) {
if (this.propertyRemoveIfUnderRemove == propertyRemoveIfUnderRemove) { if (this.propertyRemoveIfUnderRemove == propertyRemoveIfUnderRemove) {
return; return;
} }
this.propertyRemoveIfUnderRemove = propertyRemoveIfUnderRemove; this.propertyRemoveIfUnderRemove = propertyRemoveIfUnderRemove;
} }
public void setPropertySubFile(final Uri propertySubFile) { public void setPropertySubFile(final Uri propertySubFile) {
if (this.propertySubFile.equals(propertySubFile)) { if (this.propertySubFile.equals(propertySubFile)) {
return; return;
@ -656,7 +663,7 @@ public class Composer extends Container {
this.propertySubFile = propertySubFile; this.propertySubFile = propertySubFile;
onChangePropertySubFile(); onChangePropertySubFile();
} }
@Override @Override
public void setSize(final Vector3f value) { public void setSize(final Vector3f value) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -665,7 +672,7 @@ public class Composer extends Container {
} }
super.setSize(value); super.setSize(value);
} }
@Override @Override
public void setZoom(final float newVal) { public void setZoom(final float newVal) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -674,7 +681,7 @@ public class Composer extends Container {
} }
super.setZoom(newVal); super.setZoom(newVal);
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -683,7 +690,7 @@ public class Composer extends Container {
} }
super.systemDraw(displayProp); super.systemDraw(displayProp);
} }
@Override @Override
public void unGrabCursor() { public void unGrabCursor() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -692,5 +699,5 @@ public class Composer extends Container {
} }
super.unGrabCursor(); super.unGrabCursor();
} }
} }

View File

@ -12,21 +12,23 @@ import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.etk.math.Vector3b; import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/* /*
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
* the Cotainer widget is a widget that have an only one subWidget * the Cotainer widget is a widget that have an only one subWidget
*/ */
public class Container extends Widget { public class Container extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Container.class);
protected Widget subWidget = null; protected Widget subWidget = null;
/** /**
* Constructor * Constructor
*/ */
public Container() {} public Container() {}
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -37,9 +39,9 @@ public class Container extends Widget {
final Vector3f min = this.subWidget.getCalculateMinSize(); final Vector3f min = this.subWidget.getCalculateMinSize();
this.minSize = Vector3f.max(this.minSize, min); this.minSize = Vector3f.max(this.minSize, min);
} }
Log.warning("[{}] Result min size : {}", getId(), this.minSize); LOGGER.warn("[{}] Result min size : {}", getId(), this.minSize);
} }
@Override @Override
public void drawWidgetTree(int level) { public void drawWidgetTree(int level) {
super.drawWidgetTree(level); super.drawWidgetTree(level);
@ -48,7 +50,7 @@ public class Container extends Widget {
this.subWidget.drawWidgetTree(level); this.subWidget.drawWidgetTree(level);
} }
} }
@Override @Override
public EwolObject getSubObjectNamed(final String objectName) { public EwolObject getSubObjectNamed(final String objectName) {
final EwolObject tmpObject = super.getSubObjectNamed(objectName); final EwolObject tmpObject = super.getSubObjectNamed(objectName);
@ -60,7 +62,7 @@ public class Container extends Widget {
} }
return null; return null;
} }
/** /**
* get the main node widget * get the main node widget
* @return the requested pointer on the node * @return the requested pointer on the node
@ -72,7 +74,7 @@ public class Container extends Widget {
public Widget getSubWidget() { public Widget getSubWidget() {
return this.subWidget; return this.subWidget;
} }
@Override @Override
public Widget getWidgetAtPos(final Vector3f pos) { public Widget getWidgetAtPos(final Vector3f pos) {
if (!this.propertyHide) { if (!this.propertyHide) {
@ -82,7 +84,7 @@ public class Container extends Widget {
} }
return null; return null;
} }
// @Override // @Override
// public boolean loadXML(final XmlElement node) { // public boolean loadXML(final XmlElement node) {
// if (node == null) { // if (node == null) {
@ -100,34 +102,34 @@ public class Container extends Widget {
// } // }
// XmlElement pNode = it.toElement(); // XmlElement pNode = it.toElement();
// String widgetName = pNode.getValue(); // String widgetName = pNode.getValue();
// Log.verbose("[" + getId() + "] t=" + getClass().getCanonicalName() + " Load node name : '" + widgetName + "'"); // LOGGER.trace("[" + getId() + "] t=" + getClass().getCanonicalName() + " Load node name : '" + widgetName + "'");
// if (!getWidgetManager().exist(widgetName)) { // if (!getWidgetManager().exist(widgetName)) {
// Log.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]"); // LOGGER.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]");
// continue; // continue;
// } // }
// if (getSubWidget() != null) { // if (getSubWidget() != null) {
// Log.error("Can only have one subWidget ??? node='" + widgetName + "'"); // LOGGER.error("Can only have one subWidget ??? node='" + widgetName + "'");
// continue; // continue;
// } // }
// Log.debug("try to create subwidget : '" + widgetName + "'"); // LOGGER.debug("try to create subwidget : '" + widgetName + "'");
// Widget tmpWidget = getWidgetManager().create(widgetName, pNode); // Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
// if (tmpWidget == null) { // if (tmpWidget == null) {
// Log.error("Can not create the widget : '" + widgetName + "'"); // LOGGER.error("Can not create the widget : '" + widgetName + "'");
// continue; // continue;
// } // }
// // add widget : // // add widget :
// setSubWidget(tmpWidget); // setSubWidget(tmpWidget);
// if (!tmpWidget.loadXML(pNode)) { // if (!tmpWidget.loadXML(pNode)) {
// Log.error("can not load widget properties : '" + widgetName + "'"); // LOGGER.error("can not load widget properties : '" + widgetName + "'");
// return false; // return false;
// } // }
// } // }
// if (node.getNodes().size() != 0 && this.subWidget == null) { // if (node.getNodes().size() != 0 && this.subWidget == null) {
// Log.warning("Load container with no data inside"); // LOGGER.warn("Load container with no data inside");
// } // }
// return true; // return true;
// } // }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
super.onChangeSize(); super.onChangeSize();
@ -145,14 +147,14 @@ public class Container extends Widget {
this.subWidget.setSize(this.size); this.subWidget.setSize(this.size);
this.subWidget.onChangeSize(); this.subWidget.onChangeSize();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.systemRegenerateDisplay(); this.subWidget.systemRegenerateDisplay();
} }
} }
@Override @Override
public void requestDestroyFromChild(final EwolObject child) { public void requestDestroyFromChild(final EwolObject child) {
if (this.subWidget != child) { if (this.subWidget != child) {
@ -165,7 +167,7 @@ public class Container extends Widget {
this.subWidget = null; this.subWidget = null;
markToRedraw(); markToRedraw();
} }
@Override @Override
public void setOffset(final Vector3f newVal) { public void setOffset(final Vector3f newVal) {
if (this.offset.equals(newVal)) { if (this.offset.equals(newVal)) {
@ -174,9 +176,9 @@ public class Container extends Widget {
super.setOffset(newVal); super.setOffset(newVal);
// recalculate the new sise and position of sub widget ... // recalculate the new sise and position of sub widget ...
onChangeSize(); onChangeSize();
} }
/** /**
* set the subWidget node widget. * set the subWidget node widget.
* @param newWidget The widget to add. * @param newWidget The widget to add.
@ -193,7 +195,7 @@ public class Container extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
/** /**
* remove the subWidget node (async). * remove the subWidget node (async).
*/ */
@ -205,7 +207,7 @@ public class Container extends Widget {
requestUpdateSize(); requestUpdateSize();
} }
} }
/** /**
* Replace a old subwidget with a new one. * Replace a old subwidget with a new one.
* @param oldWidget The widget to replace. * @param oldWidget The widget to replace.
@ -213,7 +215,7 @@ public class Container extends Widget {
*/ */
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) { public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
if (this.subWidget != oldWidget) { if (this.subWidget != oldWidget) {
Log.warning("Request replace with a wrong old widget"); LOGGER.warn("Request replace with a wrong old widget");
return; return;
} }
this.subWidget.removeParent(); this.subWidget.removeParent();
@ -224,7 +226,7 @@ public class Container extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
/** /**
* Unlink the subwidget Node. * Unlink the subwidget Node.
*/ */
@ -234,7 +236,7 @@ public class Container extends Widget {
} }
this.subWidget = null; this.subWidget = null;
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) { if (this.propertyHide) {
@ -244,10 +246,10 @@ public class Container extends Widget {
super.systemDraw(displayProp); super.systemDraw(displayProp);
if (this.subWidget != null) { if (this.subWidget != null) {
final DrawProperty prop = displayProp.withLimit(this.origin, this.size); final DrawProperty prop = displayProp.withLimit(this.origin, this.size);
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size); //LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
this.subWidget.systemDraw(prop); this.subWidget.systemDraw(prop);
} else { } else {
Log.info("[" + getId() + "] ++++++ : [null]"); LOGGER.info("[" + getId() + "] ++++++ : [null]");
} }
} }
} }

View File

@ -18,30 +18,32 @@ import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.etk.math.Vector3b; import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
* the Cotainer widget is a widget that have an only one subWidget * the Cotainer widget is a widget that have an only one subWidget
*/ */
public class ContainerN extends Widget { public class ContainerN extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerN.class);
protected Vector3b propertyLockExpand = Vector3b.FALSE; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget protected Vector3b propertyLockExpand = Vector3b.FALSE; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
protected Vector3b subExpend = Vector3b.FALSE; //!< reference of the sub element expention requested. protected Vector3b subExpend = Vector3b.FALSE; //!< reference of the sub element expention requested.
protected List<Widget> subWidget = new ArrayList<>(); protected List<Widget> subWidget = new ArrayList<>();
/** /**
* Constructor * Constructor
*/ */
protected ContainerN() {} protected ContainerN() {}
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
this.subExpend = Vector3b.FALSE; this.subExpend = Vector3b.FALSE;
this.minSize = Vector3f.ZERO; this.minSize = Vector3f.ZERO;
this.maxSize = Vector3f.MAX_VALUE; this.maxSize = Vector3f.MAX_VALUE;
//Log.error("[" + getId() + "] {" + getObjectType() + "} set min size : " + this.minSize); //LOGGER.error("[" + getId() + "] {" + getObjectType() + "} set min size : " + this.minSize);
for (final Widget it : this.subWidget) { for (final Widget it : this.subWidget) {
if (it != null) { if (it != null) {
it.calculateMinMaxSize(); it.calculateMinMaxSize();
@ -56,9 +58,9 @@ public class ContainerN extends Widget {
this.minSize = Vector3f.max(tmpSize, this.minSize); this.minSize = Vector3f.max(tmpSize, this.minSize);
} }
} }
Log.warning("[{}] Result min size : {}", getId(), this.minSize); LOGGER.warn("[{}] Result min size : {}", getId(), this.minSize);
} }
// herited function // herited function
@Override @Override
public Vector3b canExpand() { public Vector3b canExpand() {
@ -73,10 +75,10 @@ public class ContainerN extends Widget {
res = res.withY(true); res = res.withY(true);
} }
} }
//Log.debug("Expend check : user=" + this.userExpand + " lock=" + propertyLockExpand + " sub=" + this.subExpend + " res=" + res); //LOGGER.debug("Expend check : user=" + this.userExpand + " lock=" + propertyLockExpand + " sub=" + this.subExpend + " res=" + res);
return res; return res;
} }
@Override @Override
public void drawWidgetTree(int level) { public void drawWidgetTree(int level) {
super.drawWidgetTree(level); super.drawWidgetTree(level);
@ -87,7 +89,7 @@ public class ContainerN extends Widget {
} }
} }
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "lock") @AknotName(value = "lock")
@ -95,7 +97,7 @@ public class ContainerN extends Widget {
public Vector3b getPropertyLockExpand() { public Vector3b getPropertyLockExpand() {
return this.propertyLockExpand; return this.propertyLockExpand;
} }
@Override @Override
public EwolObject getSubObjectNamed(final String objectName) { public EwolObject getSubObjectNamed(final String objectName) {
EwolObject tmpObject = super.getSubObjectNamed(objectName); EwolObject tmpObject = super.getSubObjectNamed(objectName);
@ -112,14 +114,14 @@ public class ContainerN extends Widget {
} }
return null; return null;
} }
@AknotManaged @AknotManaged
@AknotFactory(value = WidgetXmlFactory.class) @AknotFactory(value = WidgetXmlFactory.class)
@AknotDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)") @AknotDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)")
public List<Widget> getSubWidgets() { public List<Widget> getSubWidgets() {
return this.subWidget; return this.subWidget;
} }
@Override @Override
public Widget getWidgetAtPos(final Vector3f pos) { public Widget getWidgetAtPos(final Vector3f pos) {
if (this.propertyHide) { if (this.propertyHide) {
@ -130,7 +132,8 @@ public class ContainerN extends Widget {
if (it != null) { if (it != null) {
final Vector3f tmpSize = it.getSize(); final Vector3f tmpSize = it.getSize();
final Vector3f tmpOrigin = it.getOrigin(); final Vector3f tmpOrigin = it.getOrigin();
if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x()) && (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) { if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x())
&& (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) {
final Widget tmpWidget = it.getWidgetAtPos(pos); final Widget tmpWidget = it.getWidgetAtPos(pos);
if (tmpWidget != null) { if (tmpWidget != null) {
return tmpWidget; return tmpWidget;
@ -142,7 +145,7 @@ public class ContainerN extends Widget {
} }
return null; return null;
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
for (final Widget it : this.subWidget) { for (final Widget it : this.subWidget) {
@ -154,7 +157,7 @@ public class ContainerN extends Widget {
it.onChangeSize(); it.onChangeSize();
} }
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
for (final Widget it : this.subWidget) { for (final Widget it : this.subWidget) {
@ -163,7 +166,7 @@ public class ContainerN extends Widget {
} }
} }
} }
@Override @Override
public void requestDestroyFromChild(final EwolObject child) { public void requestDestroyFromChild(final EwolObject child) {
ListIterator<Widget> it = this.subWidget.listIterator(); ListIterator<Widget> it = this.subWidget.listIterator();
@ -182,7 +185,7 @@ public class ContainerN extends Widget {
markToRedraw(); markToRedraw();
} }
} }
@Override @Override
public void setOffset(final Vector3f newVal) { public void setOffset(final Vector3f newVal) {
if (this.offset != newVal) { if (this.offset != newVal) {
@ -191,7 +194,7 @@ public class ContainerN extends Widget {
onChangeSize(); onChangeSize();
} }
} }
public void setPropertyLockExpand(final Vector3b propertyLockExpand) { public void setPropertyLockExpand(final Vector3b propertyLockExpand) {
if (propertyLockExpand.equals(this.propertyLockExpand)) { if (propertyLockExpand.equals(this.propertyLockExpand)) {
return; return;
@ -200,10 +203,10 @@ public class ContainerN extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setSubWidgets(final List<Widget> listData) { public void setSubWidgets(final List<Widget> listData) {
// Clean all previous widget // Clean all previous widget
this.subWidgetRemoveAll(); subWidgetRemoveAll();
// add separately all widgets // add separately all widgets
for (final Widget elem : listData) { for (final Widget elem : listData) {
if (elem == null) { if (elem == null) {
@ -215,7 +218,7 @@ public class ContainerN extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
/** /**
* add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @param newWidget the element pointer * @param newWidget the element pointer
@ -223,7 +226,7 @@ public class ContainerN extends Widget {
*/ */
public int subWidgetAdd(final Widget newWidget) { public int subWidgetAdd(final Widget newWidget) {
if (newWidget == null) { if (newWidget == null) {
Log.error("[" + getId() + "] {" + getClass().getCanonicalName() + "} Try to add An empty Widget ... "); LOGGER.error("[" + getId() + "] {" + getClass().getCanonicalName() + "} Try to add An empty Widget ... ");
return -1; return -1;
} }
newWidget.setParent(this); newWidget.setParent(this);
@ -233,22 +236,22 @@ public class ContainerN extends Widget {
// added at the last eelement : // added at the last eelement :
return newWidget.getId(); return newWidget.getId();
} }
//! @previous //! @previous
public int subWidgetAddBack(final Widget newWidget) { public int subWidgetAddBack(final Widget newWidget) {
return subWidgetAdd(newWidget); return subWidgetAdd(newWidget);
} }
//! @previous //! @previous
public int subWidgetAddEnd(final Widget newWidget) { public int subWidgetAddEnd(final Widget newWidget) {
return subWidgetAdd(newWidget); return subWidgetAdd(newWidget);
} }
//! @previous //! @previous
public int subWidgetAddFront(final Widget newWidget) { public int subWidgetAddFront(final Widget newWidget) {
return subWidgetAddStart(newWidget); return subWidgetAddStart(newWidget);
} }
/** /**
* add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) * add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @param newWidget the element pointer * @param newWidget the element pointer
@ -256,7 +259,8 @@ public class ContainerN extends Widget {
*/ */
public int subWidgetAddStart(final Widget newWidget) { public int subWidgetAddStart(final Widget newWidget) {
if (newWidget == null) { if (newWidget == null) {
Log.error("[" + getId() + "] {" + getClass().getCanonicalName() + "} Try to add start An empty Widget ... "); LOGGER.error(
"[" + getId() + "] {" + getClass().getCanonicalName() + "} Try to add start An empty Widget ... ");
return -1; return -1;
} }
if (newWidget != null) { if (newWidget != null) {
@ -267,7 +271,7 @@ public class ContainerN extends Widget {
requestUpdateSize(); requestUpdateSize();
return newWidget.getId(); return newWidget.getId();
} }
/** /**
* remove definitly a widget from the system and this layer. * remove definitly a widget from the system and this layer.
* @param newWidget the element pointer. * @param newWidget the element pointer.
@ -277,7 +281,7 @@ public class ContainerN extends Widget {
return; return;
} }
final int errorControl = this.subWidget.size(); final int errorControl = this.subWidget.size();
final ListIterator<Widget> it = this.subWidget.listIterator(); final ListIterator<Widget> it = this.subWidget.listIterator();
while (it.hasNext()) { while (it.hasNext()) {
final Widget elem = it.next(); final Widget elem = it.next();
@ -289,7 +293,7 @@ public class ContainerN extends Widget {
} }
} }
} }
/** /**
* remove all sub element from the widget. * remove all sub element from the widget.
*/ */
@ -302,14 +306,14 @@ public class ContainerN extends Widget {
} }
this.subWidget.clear(); this.subWidget.clear();
} }
/** /**
* remove all sub element from the widget (delayed to prevent remove in the callbback). * remove all sub element from the widget (delayed to prevent remove in the callbback).
*/ */
public void subWidgetRemoveAllDelayed() { public void subWidgetRemoveAllDelayed() {
subWidgetRemoveAll(); subWidgetRemoveAll();
} }
/** /**
* Replace a old subwidget with a new one. * Replace a old subwidget with a new one.
* @param oldWidget The widget to replace. * @param oldWidget The widget to replace.
@ -331,13 +335,13 @@ public class ContainerN extends Widget {
haveChange = true; haveChange = true;
} }
if (!haveChange) { if (!haveChange) {
Log.warning("Request replace with a wrong old widget"); LOGGER.warn("Request replace with a wrong old widget");
return; return;
} }
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
/** /**
* Just unlock the specify widget, this function does not remove it from the system (if you can, do nt use it ...) * Just unlock the specify widget, this function does not remove it from the system (if you can, do nt use it ...)
* @param newWidget the element pointer. * @param newWidget the element pointer.
@ -357,7 +361,7 @@ public class ContainerN extends Widget {
} }
} }
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) { if (this.propertyHide) {
@ -373,7 +377,7 @@ public class ContainerN extends Widget {
while (it.hasPrevious()) { while (it.hasPrevious()) {
final Widget elem = it.previous(); final Widget elem = it.previous();
if (elem != null) { if (elem != null) {
//Log.info(" ***** : [" + (*it).propertyName + "] t=" + (*it).getObjectType() + " o=" + (*it).this.origin + " s=" + (*it).this.size); //LOGGER.info(" ***** : [" + (*it).propertyName + "] t=" + (*it).getObjectType() + " o=" + (*it).this.origin + " s=" + (*it).this.size);
elem.systemDraw(prop); elem.systemDraw(prop);
} }
} }

View File

@ -11,17 +11,19 @@ import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/* /*
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
* the Cotainer widget is a widget that have an only one subWidget * the Cotainer widget is a widget that have an only one subWidget
*/ */
public class ContainerToggle extends Widget { public class ContainerToggle extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerToggle.class);
protected Widget[] subWidget = new Widget[2]; protected Widget[] subWidget = new Widget[2];
int idWidgetDisplayed = 0; //!< current widget displayed int idWidgetDisplayed = 0; //!< current widget displayed
/** /**
* Constructor * Constructor
*/ */
@ -29,15 +31,15 @@ public class ContainerToggle extends Widget {
this.subWidget[0] = null; this.subWidget[0] = null;
this.subWidget[1] = null; this.subWidget[1] = null;
} }
void calculateMinMaxSizePadded(final Padding padding) { void calculateMinMaxSizePadded(final Padding padding) {
// call main class // call main class
this.minSize = Vector3f.ZERO; this.minSize = Vector3f.ZERO;
// call sub classes // call sub classes
for (int iii = 0; iii < this.subWidget.length; ++iii) { for (final Widget element : this.subWidget) {
if (this.subWidget[iii] != null) { if (element != null) {
this.subWidget[iii].calculateMinMaxSize(); element.calculateMinMaxSize();
final Vector3f min = this.subWidget[iii].getCalculateMinSize(); final Vector3f min = element.getCalculateMinSize();
this.minSize = this.minSize.max(min); this.minSize = this.minSize.max(min);
} }
} }
@ -46,9 +48,9 @@ public class ContainerToggle extends Widget {
// verify the min max of the min size ... // verify the min max of the min size ...
checkMinSize(); checkMinSize();
//markToRedraw(); //markToRedraw();
Log.verbose("[{}] Result min size : {}", getId(), this.minSize); LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
} }
@Override @Override
public void drawWidgetTree(int level) { public void drawWidgetTree(int level) {
super.drawWidgetTree(level); super.drawWidgetTree(level);
@ -60,7 +62,7 @@ public class ContainerToggle extends Widget {
this.subWidget[1].drawWidgetTree(level); this.subWidget[1].drawWidgetTree(level);
} }
} }
@Override @Override
public EwolObject getSubObjectNamed(final String widgetName) { public EwolObject getSubObjectNamed(final String widgetName) {
EwolObject tmpObject = super.getSubObjectNamed(widgetName); EwolObject tmpObject = super.getSubObjectNamed(widgetName);
@ -78,14 +80,14 @@ public class ContainerToggle extends Widget {
} }
return null; return null;
} }
@AknotManaged @AknotManaged
@AknotFactory(value = WidgetXmlFactory.class) @AknotFactory(value = WidgetXmlFactory.class)
@AknotDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)") @AknotDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)")
public Widget[] getSubWidgets() { public Widget[] getSubWidgets() {
return this.subWidget; return this.subWidget;
} }
public Padding onChangeSizePadded(final Padding padding) { public Padding onChangeSizePadded(final Padding padding) {
super.onChangeSize(); super.onChangeSize();
final Vector3f localAvaillable = this.size.less(padding.x(), padding.y(), padding.z()); final Vector3f localAvaillable = this.size.less(padding.x(), padding.y(), padding.z());
@ -100,33 +102,36 @@ public class ContainerToggle extends Widget {
if (this.propertyFill.z()) { if (this.propertyFill.z()) {
subElementSize = subElementSize.withZ(this.size.z() - padding.z()); subElementSize = subElementSize.withZ(this.size.z() - padding.z());
} }
final Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(subElementSize.add(padding.x(), padding.y(), padding.z()))); final Vector3f delta = this.propertyGravity
.gravityGenerateDelta(this.size.less(subElementSize.add(padding.x(), padding.y(), padding.z())));
final Vector3f deltaPadded = delta.add(padding.left(), padding.bottom(), padding.back()); final Vector3f deltaPadded = delta.add(padding.left(), padding.bottom(), padding.back());
//subElementSize = subElementSize.less(padding.x(), padding.y(), padding.z()); //subElementSize = subElementSize.less(padding.x(), padding.y(), padding.z());
for (int iii = 0; iii < this.subWidget.length; ++iii) { for (final Widget element : this.subWidget) {
if (this.subWidget[iii] != null) { if (element != null) {
//final Vector3f origin2 = this.origin.add(this.offset); //final Vector3f origin2 = this.origin.add(this.offset);
//final Vector3f minSize = this.subWidget[iii].getCalculateMinSize(); //final Vector3f minSize = this.subWidget[iii].getCalculateMinSize();
//Vector2b expand = this.subWidget[iii].propertyExpand.get(); //Vector2b expand = this.subWidget[iii].propertyExpand.get();
//origin2 = origin2.add(this.propertyGravity.gravityGenerateDelta(minSize.less(localAvaillable))); //origin2 = origin2.add(this.propertyGravity.gravityGenerateDelta(minSize.less(localAvaillable)));
this.subWidget[iii].setOrigin(this.origin.add(deltaPadded)); element.setOrigin(this.origin.add(deltaPadded));
this.subWidget[iii].setSize(subElementSize); element.setSize(subElementSize);
this.subWidget[iii].onChangeSize(); element.onChangeSize();
} }
} }
final Vector3f selectableAreaPos = this.origin.add(delta);//.less(padding.left(), padding.bottom(), padding.back()); final Vector3f selectableAreaPos = this.origin.add(delta);//.less(padding.left(), padding.bottom(), padding.back());
final Vector3f selectableAreaEndPos = this.size.less(selectableAreaPos.add(subElementSize.add(padding.x(), padding.y(), padding.z()))); final Vector3f selectableAreaEndPos = this.size
.less(selectableAreaPos.add(subElementSize.add(padding.x(), padding.y(), padding.z())));
markToRedraw(); markToRedraw();
return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(), selectableAreaPos.y()); return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(),
selectableAreaPos.y());
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (this.subWidget[this.idWidgetDisplayed] != null) { if (this.subWidget[this.idWidgetDisplayed] != null) {
this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay(); this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay();
} }
} }
@Override @Override
public void requestDestroyFromChild(final EwolObject child) { public void requestDestroyFromChild(final EwolObject child) {
if (this.subWidget[0] == child) { if (this.subWidget[0] == child) {
@ -146,7 +151,7 @@ public class ContainerToggle extends Widget {
markToRedraw(); markToRedraw();
} }
} }
@Override @Override
public void setOffset(final Vector3f newVal) { public void setOffset(final Vector3f newVal) {
if (this.offset.equals(newVal)) { if (this.offset.equals(newVal)) {
@ -156,12 +161,12 @@ public class ContainerToggle extends Widget {
// recalculate the new size and position of sub widget ... // recalculate the new size and position of sub widget ...
onChangeSize(); onChangeSize();
} }
@AknotManaged(value = false) @AknotManaged(value = false)
public void setSubWidget(final Widget newWidget) { public void setSubWidget(final Widget newWidget) {
setSubWidget(newWidget, 0); setSubWidget(newWidget, 0);
} }
/** /**
* set the subWidget node widget. * set the subWidget node widget.
* @param newWidget The widget to add. * @param newWidget The widget to add.
@ -170,29 +175,29 @@ public class ContainerToggle extends Widget {
subWidgetRemove(idWidget); subWidgetRemove(idWidget);
this.subWidget[idWidget] = newWidget; this.subWidget[idWidget] = newWidget;
if (this.subWidget[idWidget] != null) { if (this.subWidget[idWidget] != null) {
Log.verbose("Add widget : " + idWidget); LOGGER.trace("Add widget : " + idWidget);
this.subWidget[idWidget].setParent(this); this.subWidget[idWidget].setParent(this);
} }
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setSubWidgets(final Widget[] newWidget) { public void setSubWidgets(final Widget[] newWidget) {
for (int iii = 0; iii < Math.min(newWidget.length, this.subWidget.length); iii++) { for (int iii = 0; iii < Math.min(newWidget.length, this.subWidget.length); iii++) {
setSubWidget(newWidget[iii], iii); setSubWidget(newWidget[iii], iii);
} }
} }
public void subWidgetRemove(final int idWidget) { public void subWidgetRemove(final int idWidget) {
if (this.subWidget[idWidget] != null) { if (this.subWidget[idWidget] != null) {
Log.verbose("Remove widget : " + idWidget); LOGGER.trace("Remove widget : " + idWidget);
this.subWidget[idWidget].removeParent(); this.subWidget[idWidget].removeParent();
this.subWidget[idWidget] = null; this.subWidget[idWidget] = null;
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
} }
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) { public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
boolean haveChange = false; boolean haveChange = false;
for (int iii = 0; iii < this.subWidget.length; ++iii) { for (int iii = 0; iii < this.subWidget.length; ++iii) {
@ -207,21 +212,21 @@ public class ContainerToggle extends Widget {
haveChange = true; haveChange = true;
} }
if (!haveChange) { if (!haveChange) {
Log.warning("Request replace with a wrong old widget"); LOGGER.warn("Request replace with a wrong old widget");
return; return;
} }
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void subWidgetUnLink(final int idWidget) { public void subWidgetUnLink(final int idWidget) {
if (this.subWidget[idWidget] != null) { if (this.subWidget[idWidget] != null) {
this.subWidget[idWidget].removeParent(); this.subWidget[idWidget].removeParent();
Log.verbose("Unlink widget : " + idWidget); LOGGER.trace("Unlink widget : " + idWidget);
} }
this.subWidget[idWidget] = null; this.subWidget[idWidget] = null;
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) { if (this.propertyHide) {
@ -231,10 +236,10 @@ public class ContainerToggle extends Widget {
super.systemDraw(displayProp); super.systemDraw(displayProp);
if (this.subWidget[this.idWidgetDisplayed] != null) { if (this.subWidget[this.idWidgetDisplayed] != null) {
final DrawProperty prop = displayProp.withLimit(this.origin, this.size); final DrawProperty prop = displayProp.withLimit(this.origin, this.size);
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size); //LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
this.subWidget[this.idWidgetDisplayed].systemDraw(prop); this.subWidget[this.idWidgetDisplayed].systemDraw(prop);
} else { } else {
Log.info("[" + getId() + "] ++++++ : [null]"); LOGGER.info("[" + getId() + "] ++++++ : [null]");
} }
} }
} }

View File

@ -15,18 +15,20 @@ import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape; import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.compositing.ShapeBox; import org.atriasoft.ewol.compositing.ShapeBox;
import org.atriasoft.ewol.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Simple Container that have a Shape (not directly instantiate!!!!) * Simple Container that have a Shape (not directly instantiate!!!!)
*/ */
public class ContainerWithShape extends Container { public class ContainerWithShape extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerWithShape.class);
// properties // properties
public Uri propertyShape = null; //!< Compositing theme. public Uri propertyShape = null; //!< Compositing theme.
protected GuiShape shape; //!< Compositing theme. protected GuiShape shape; //!< Compositing theme.
protected ShapeBox shapeProperty = ShapeBox.ZERO; protected ShapeBox shapeProperty = ShapeBox.ZERO;
/** /**
* Constructor * Constructor
* @param propertyShape shape file properties * @param propertyShape shape file properties
@ -35,7 +37,7 @@ public class ContainerWithShape extends Container {
this.propertyShape = propertyShape; this.propertyShape = propertyShape;
onChangePropertyShape(); onChangePropertyShape();
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -47,9 +49,9 @@ public class ContainerWithShape extends Container {
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
this.minSize = Vector3f.max(this.minSize, min.add(padding.x(), padding.y(), padding.z())); this.minSize = Vector3f.max(this.minSize, min.add(padding.x(), padding.y(), padding.z()));
} }
Log.warning("[{}] Result min size : {}", getId(), this.minSize); LOGGER.warn("[{}] Result min size : {}", getId(), this.minSize);
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "shape") @AknotName(value = "shape")
@ -57,7 +59,7 @@ public class ContainerWithShape extends Container {
public Uri getPropertyShape() { public Uri getPropertyShape() {
return this.propertyShape; return this.propertyShape;
} }
@Override @Override
public Widget getWidgetAtPos(final Vector3f pos) { public Widget getWidgetAtPos(final Vector3f pos) {
final Widget val = super.getWidgetAtPos(pos); final Widget val = super.getWidgetAtPos(pos);
@ -66,7 +68,7 @@ public class ContainerWithShape extends Container {
} }
return this; return this;
} }
protected void onChangePropertyShape() { protected void onChangePropertyShape() {
if (this.shape == null) { if (this.shape == null) {
this.shape = new GuiShape(this.propertyShape); this.shape = new GuiShape(this.propertyShape);
@ -76,7 +78,7 @@ public class ContainerWithShape extends Container {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
markToRedraw(); markToRedraw();
@ -102,21 +104,21 @@ public class ContainerWithShape extends Container {
} }
subWidgetSize = subWidgetSize.less(padding.x(), padding.y(), padding.z()); subWidgetSize = subWidgetSize.less(padding.x(), padding.y(), padding.z());
subWidgetSize = subWidgetSize.clipInteger(); subWidgetSize = subWidgetSize.clipInteger();
// set config to the Sub-widget // set config to the Sub-widget
Vector3f subWidgetOrigin = this.origin.add(this.size.less(subWidgetSize).multiply(0.5f)); Vector3f subWidgetOrigin = this.origin.add(this.size.less(subWidgetSize).multiply(0.5f));
subWidgetOrigin = subWidgetOrigin.clipInteger(); subWidgetOrigin = subWidgetOrigin.clipInteger();
this.subWidget.setOrigin(subWidgetOrigin); this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize); this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize(); this.subWidget.onChangeSize();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.shape.draw(); this.shape.draw();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (needRedraw()) { if (needRedraw()) {
@ -140,7 +142,7 @@ public class ContainerWithShape extends Container {
// not sure this is needed... // not sure this is needed...
tmpSizeShaper = tmpSizeShaper.clipInteger(); tmpSizeShaper = tmpSizeShaper.clipInteger();
tmpOriginShaper = tmpOriginShaper.clipInteger(); tmpOriginShaper = tmpOriginShaper.clipInteger();
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding); this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper); this.shape.setShape(tmpOriginShaper, tmpSizeShaper);
} }
@ -149,7 +151,7 @@ public class ContainerWithShape extends Container {
this.subWidget.onRegenerateDisplay(); this.subWidget.onRegenerateDisplay();
} }
} }
public void setPropertyShape(final Uri propertyShape) { public void setPropertyShape(final Uri propertyShape) {
if (this.propertyShape.equals(propertyShape)) { if (this.propertyShape.equals(propertyShape)) {
return; return;
@ -157,7 +159,7 @@ public class ContainerWithShape extends Container {
this.propertyShape = propertyShape; this.propertyShape = propertyShape;
onChangePropertyShape(); onChangePropertyShape();
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) { if (this.propertyHide) {
@ -173,5 +175,5 @@ public class ContainerWithShape extends Container {
this.subWidget.systemDraw(prop); this.subWidget.systemDraw(prop);
} }
} }
} }

View File

@ -21,13 +21,14 @@ import org.atriasoft.ewol.compositing.GuiShapeMode;
import org.atriasoft.ewol.event.EventEntry; import org.atriasoft.ewol.event.EventEntry;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventTime; import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.context.ClipBoard; import org.atriasoft.gale.context.ClipBoard;
import org.atriasoft.gale.context.ClipboardList; import org.atriasoft.gale.context.ClipboardList;
import org.atriasoft.gale.key.KeyKeyboard; import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType; import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
@ -40,18 +41,20 @@ import org.atriasoft.gale.key.KeyType;
* ~~~~~~~~~~~~~~~~~~~~~~ * ~~~~~~~~~~~~~~~~~~~~~~
*/ */
public class Entry extends Widget { public class Entry extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
/** /**
* Periodic call to update grapgic display * Periodic call to update grapgic display
* @param _event Time generic event * @param _event Time generic event
*/ */
protected static void periodicCall(final Entry self, final EventTime event) { protected static void periodicCall(final Entry self, final EventTime event) {
Log.verbose("Periodic call on Entry(" + event + ")"); LOGGER.trace("Periodic call on Entry(" + event + ")");
if (!self.shape.periodicCall(event)) { if (!self.shape.periodicCall(event)) {
self.periodicConnectionHanble.close(); self.periodicConnectionHanble.close();
} }
self.markToRedraw(); self.markToRedraw();
} }
/// color property of the text foreground /// color property of the text foreground
private int colorIdTextFg; private int colorIdTextFg;
/// Cursor must be display only when the widget has the focus /// Cursor must be display only when the widget has the focus
@ -73,13 +76,13 @@ public class Entry extends Widget {
private Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol"); private Uri propertyConfig = new Uri("THEME", "shape/Entry.json", "ewol");
private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list private int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
private boolean propertyPassword = false; //!< Disable display of the content of the entry private boolean propertyPassword = false; //!< Disable display of the content of the entry
/// regular expression value /// regular expression value
private String propertyRegex = ".*"; private String propertyRegex = ".*";
/// Text to display when nothing in in the entry (decorated text...) /// Text to display when nothing in in the entry (decorated text...)
private String propertyTextWhenNothing = null; private String propertyTextWhenNothing = null;
private String propertyValue = "Test Text..."; //!< string that must be displayed private String propertyValue = "Test Text..."; //!< string that must be displayed
private Pattern regex = null; //!< regular expression to check content private Pattern regex = null; //!< regular expression to check content
private GuiShape shape; private GuiShape shape;
@ -92,16 +95,16 @@ public class Entry extends Widget {
@AknotName(value = "enter") @AknotName(value = "enter")
@AknotDescription("The cursor enter inside the button") @AknotDescription("The cursor enter inside the button")
public Signal<String> signalEnter = new Signal<>(); //!< Enter key is pressed public Signal<String> signalEnter = new Signal<>(); //!< Enter key is pressed
@AknotSignal @AknotSignal
@AknotName(value = "modify") @AknotName(value = "modify")
@AknotDescription("Entry box value change") @AknotDescription("Entry box value change")
public Signal<String> signalModify = new Signal<>(); //!< data change public Signal<String> signalModify = new Signal<>(); //!< data change
// element over: // element over:
Vector3f overPositionStart = Vector3f.ZERO; Vector3f overPositionStart = Vector3f.ZERO;
Vector3f overPositionStop = Vector3f.ZERO; Vector3f overPositionStop = Vector3f.ZERO;
/** /**
* Constructor * Constructor
* @param _newData The USting that might be set in the Entry box (no event generation!!) * @param _newData The USting that might be set in the Entry box (no event generation!!)
@ -109,10 +112,10 @@ public class Entry extends Widget {
public Entry() { public Entry() {
this.propertyCanFocus = true; this.propertyCanFocus = true;
onChangePropertyShaper(); onChangePropertyShaper();
this.regex = Pattern.compile(this.propertyRegex); this.regex = Pattern.compile(this.propertyRegex);
if (this.regex == null) { if (this.regex == null) {
Log.error("can not parse regex for : " + this.propertyRegex); LOGGER.error("can not parse regex for : " + this.propertyRegex);
} }
markToRedraw(); markToRedraw();
shortCutAdd("ctrl+w", "clean"); shortCutAdd("ctrl+w", "clean");
@ -124,7 +127,7 @@ public class Entry extends Widget {
this.shape = new GuiShape(this.propertyConfig); this.shape = new GuiShape(this.propertyConfig);
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut); //TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -135,26 +138,27 @@ public class Entry extends Widget {
padding = this.shape.getPadding(); padding = this.shape.getPadding();
} }
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y(); final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
Vector3f minimumSizeBase = new Vector3f(20, minHeight, 10); Vector3f minimumSizeBase = new Vector3f(20, minHeight, 10);
// add padding : // add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z()); minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z());
this.minSize = Vector3f.max(this.minSize, minimumSizeBase); this.minSize = Vector3f.max(this.minSize, minimumSizeBase);
// verify the min max of the min size ... // verify the min max of the min size ...
checkMinSize(); checkMinSize();
Log.error("min size = " + this.minSize); LOGGER.error("min size = " + this.minSize);
} }
protected void changeStatusIn(final GuiShapeMode newStatusId) { protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) { if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) { if (!this.periodicConnectionHanble.isConnected()) {
Log.error("REQUEST: connection on operiodic call"); LOGGER.error("REQUEST: connection on operiodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this, Entry::periodicCall); this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Entry::periodicCall);
} }
markToRedraw(); markToRedraw();
} }
} }
/** /**
* Copy the selected data on the specify clipboard * Copy the selected data on the specify clipboard
* @param clipboardID Selected clipboard * @param clipboardID Selected clipboard
@ -174,48 +178,48 @@ public class Entry extends Widget {
final String tmpData = this.propertyValue.substring(pos1, pos2); final String tmpData = this.propertyValue.substring(pos1, pos2);
ClipBoard.set(clipboardID, tmpData); ClipBoard.set(clipboardID, tmpData);
} }
public Uri getPropertyConfig() { public Uri getPropertyConfig() {
return this.propertyConfig; return this.propertyConfig;
} }
public int getPropertyMaxCharacter() { public int getPropertyMaxCharacter() {
return this.propertyMaxCharacter; return this.propertyMaxCharacter;
} }
public String getPropertyRegex() { public String getPropertyRegex() {
return this.propertyRegex; return this.propertyRegex;
} }
public String getPropertyTextWhenNothing() { public String getPropertyTextWhenNothing() {
return this.propertyTextWhenNothing; return this.propertyTextWhenNothing;
} }
public String getPropertyValue() { public String getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
public boolean isPropertyPassword() { public boolean isPropertyPassword() {
return this.propertyPassword; return this.propertyPassword;
} }
/** /**
* informe the system thet the text change and the start position change * informe the system thet the text change and the start position change
*/ */
protected void markToUpdateTextPosition() { protected void markToUpdateTextPosition() {
this.needUpdateTextPos = true; this.needUpdateTextPos = true;
} }
private void onCallbackCopy() { private void onCallbackCopy() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD); copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
} }
private void onCallbackCut() { private void onCallbackCut() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD); copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
removeSelected(); removeSelected();
this.signalModify.emit(this.propertyValue); this.signalModify.emit(this.propertyValue);
} }
private void onCallbackEntryClean() { private void onCallbackEntryClean() {
this.propertyValue = ""; this.propertyValue = "";
this.displayStartPosition = 0; this.displayStartPosition = 0;
@ -223,11 +227,11 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos; this.displayCursorPosSelection = this.displayCursorPos;
markToRedraw(); markToRedraw();
} }
private void onCallbackPaste() { private void onCallbackPaste() {
ClipBoard.request(ClipboardList.CLIPBOARD_STD); ClipBoard.request(ClipboardList.CLIPBOARD_STD);
} }
private void onCallbackSelect(final boolean all) { private void onCallbackSelect(final boolean all) {
if (all) { if (all) {
this.displayCursorPosSelection = 0; this.displayCursorPosSelection = 0;
@ -237,7 +241,7 @@ public class Entry extends Widget {
} }
markToRedraw(); markToRedraw();
} }
private void onCallbackShortCut(final String value) { private void onCallbackShortCut(final String value) {
if (value.equals("clean")) { if (value.equals("clean")) {
onCallbackEntryClean(); onCallbackEntryClean();
@ -246,33 +250,33 @@ public class Entry extends Widget {
} else if (value.equals("copy")) { } else if (value.equals("copy")) {
onCallbackCopy(); onCallbackCopy();
} else if (value.equals("paste")) { } else if (value.equals("paste")) {
Log.warning("Request past ..."); LOGGER.warn("Request past ...");
onCallbackPaste(); onCallbackPaste();
} else if (value.equals("select:all")) { } else if (value.equals("select:all")) {
onCallbackSelect(true); onCallbackSelect(true);
} else if (value.equals("select:none")) { } else if (value.equals("select:none")) {
onCallbackSelect(false); onCallbackSelect(false);
} else { } else {
Log.warning("Unknow event from ShortCut : " + value); LOGGER.warn("Unknow event from ShortCut : " + value);
} }
} }
protected void onChangePropertyMaxCharacter() { protected void onChangePropertyMaxCharacter() {
// TODO : check number of char in the data // TODO : check number of char in the data
} }
protected void onChangePropertyPassword() { protected void onChangePropertyPassword() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyRegex() { protected void onChangePropertyRegex() {
this.regex = Pattern.compile(this.propertyRegex); this.regex = Pattern.compile(this.propertyRegex);
if (this.regex != null) { if (this.regex != null) {
Log.error("can not parse regex for : " + this.propertyRegex); LOGGER.error("can not parse regex for : " + this.propertyRegex);
} }
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyShaper() { protected void onChangePropertyShaper() {
if (this.shape == null) { if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig); this.shape = new GuiShape(this.propertyConfig);
@ -284,27 +288,27 @@ public class Entry extends Widget {
// this.colorIdCursor = this.shape.requestColor("text-cursor"); // this.colorIdCursor = this.shape.requestColor("text-cursor");
// this.colorIdSelection = this.shape.requestColor("text-selection"); // this.colorIdSelection = this.shape.requestColor("text-selection");
} }
protected void onChangePropertyTextWhenNothing() { protected void onChangePropertyTextWhenNothing() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
String newData = this.propertyValue; String newData = this.propertyValue;
if ((long) newData.length() > this.propertyMaxCharacter) { if ((long) newData.length() > this.propertyMaxCharacter) {
newData = newData.substring(0, this.propertyMaxCharacter); newData = newData.substring(0, this.propertyMaxCharacter);
Log.debug("Limit entry set of data... " + newData); LOGGER.debug("Limit entry set of data... " + newData);
} }
// set the value with the check of the RegExp ... // set the value with the check of the RegExp ...
setInternalValue(newData); setInternalValue(newData);
if (newData == this.propertyValue) { if (newData == this.propertyValue) {
this.displayCursorPos = this.propertyValue.length(); this.displayCursorPos = this.propertyValue.length();
this.displayCursorPosSelection = this.displayCursorPos; this.displayCursorPosSelection = this.displayCursorPos;
Log.verbose("Set : '" + newData + "'"); LOGGER.trace("Set : '" + newData + "'");
} }
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
if (this.shape != null) { if (this.shape != null) {
@ -312,7 +316,7 @@ public class Entry extends Widget {
} }
this.text.draw(); this.text.draw();
} }
@Override @Override
public void onEventClipboard(final ClipboardList clipboardID) { public void onEventClipboard(final ClipboardList clipboardID) {
// remove curent selected data ... // remove curent selected data ...
@ -336,10 +340,10 @@ public class Entry extends Widget {
} }
this.signalModify.emit(this.propertyValue); this.signalModify.emit(this.propertyValue);
} }
@Override @Override
public boolean onEventEntry(final EventEntry event) { public boolean onEventEntry(final EventEntry event) {
Log.verbose("Event on Entry ... " + event); LOGGER.trace("Event on Entry ... " + event);
if (event.type() == KeyKeyboard.CHARACTER) { if (event.type() == KeyKeyboard.CHARACTER) {
if (event.status() == KeyStatus.down) { if (event.status() == KeyStatus.down) {
// remove current selected data ... // remove current selected data ...
@ -368,9 +372,9 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos; this.displayCursorPosSelection = this.displayCursorPos;
} }
} else if (event.getChar() >= 20) { } else if (event.getChar() >= 20) {
Log.error("get data: '" + event.getChar() + "' = '" + event.getChar() + "'"); LOGGER.error("get data: '" + event.getChar() + "' = '" + event.getChar() + "'");
if ((long) this.propertyValue.length() > this.propertyMaxCharacter) { if ((long) this.propertyValue.length() > this.propertyMaxCharacter) {
Log.info("Reject data for entry : '" + event.getChar() + "'"); LOGGER.info("Reject data for entry : '" + event.getChar() + "'");
} else { } else {
final StringBuilder newData = new StringBuilder(this.propertyValue); final StringBuilder newData = new StringBuilder(this.propertyValue);
newData.insert(this.displayCursorPos, event.getChar()); newData.insert(this.displayCursorPos, event.getChar());
@ -412,19 +416,20 @@ public class Entry extends Widget {
} }
return false; return false;
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector3f absolutePosition = new Vector3f(event.pos().x(), event.pos().y(), 0); final Vector3f absolutePosition = new Vector3f(event.pos().x(), event.pos().y(), 0);
final Vector3f relPos = relativePosition(absolutePosition); final Vector3f relPos = relativePosition(absolutePosition);
Log.verbose("Event on Input ... " + event + " relPos = " + relPos); LOGGER.trace("Event on Input ... " + event + " relPos = " + relPos);
if (event.inputId() == 0) { if (event.inputId() == 0) {
if (!isFocused()) { if (!isFocused()) {
if (KeyStatus.leave == event.status()) { if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL); changeStatusIn(GuiShapeMode.NORMAL);
} else { } else {
Log.verbose("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop); LOGGER.trace("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop);
if (relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y()) { if (relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y()
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y()) {
changeStatusIn(GuiShapeMode.OVER); changeStatusIn(GuiShapeMode.OVER);
} else { } else {
changeStatusIn(GuiShapeMode.NORMAL); changeStatusIn(GuiShapeMode.NORMAL);
@ -432,8 +437,9 @@ public class Entry extends Widget {
} }
} }
} }
if (relPos.x() < this.overPositionStart.x() || relPos.y() < this.overPositionStart.y() || relPos.x() > this.overPositionStop.x() || relPos.y() > this.overPositionStop.y()) { if (relPos.x() < this.overPositionStart.x() || relPos.y() < this.overPositionStart.y()
Log.warning("Reject {}", relPos); || relPos.x() > this.overPositionStop.x() || relPos.y() > this.overPositionStop.y()) {
LOGGER.warn("Reject {}", relPos);
return false; return false;
} }
if (event.inputId() == 1) { if (event.inputId() == 1) {
@ -453,8 +459,10 @@ public class Entry extends Widget {
this.displayCursorPos = iii; this.displayCursorPos = iii;
break; break;
} }
if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z') || (this.propertyValue.charAt(iii) >= 'A' && this.propertyValue.charAt(iii) <= 'Z') if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z')
|| (this.propertyValue.charAt(iii) >= '0' && this.propertyValue.charAt(iii) <= '9') || this.propertyValue.charAt(iii) == '_' || this.propertyValue.charAt(iii) == '-')) { || (this.propertyValue.charAt(iii) >= 'A' && this.propertyValue.charAt(iii) <= 'Z')
|| (this.propertyValue.charAt(iii) >= '0' && this.propertyValue.charAt(iii) <= '9')
|| this.propertyValue.charAt(iii) == '_' || this.propertyValue.charAt(iii) == '-')) {
this.displayCursorPos = iii; this.displayCursorPos = iii;
break; break;
} }
@ -465,8 +473,10 @@ public class Entry extends Widget {
this.displayCursorPosSelection = 0; this.displayCursorPosSelection = 0;
break; break;
} }
if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z') || (this.propertyValue.charAt(iii) >= 'A' && this.propertyValue.charAt(iii) <= 'Z') if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z')
|| (this.propertyValue.charAt(iii) >= '0' && this.propertyValue.charAt(iii) <= '9') || this.propertyValue.charAt(iii) == '_' || this.propertyValue.charAt(iii) == '-')) { || (this.propertyValue.charAt(iii) >= 'A' && this.propertyValue.charAt(iii) <= 'Z')
|| (this.propertyValue.charAt(iii) >= '0' && this.propertyValue.charAt(iii) <= '9')
|| this.propertyValue.charAt(iii) == '_' || this.propertyValue.charAt(iii) == '-')) {
this.displayCursorPosSelection = iii + 1; this.displayCursorPosSelection = iii + 1;
break; break;
} }
@ -494,7 +504,8 @@ public class Entry extends Widget {
markToRedraw(); markToRedraw();
} }
} else if (KeyType.mouse == event.type() && event.inputId() == 2) { } else if (KeyType.mouse == event.type() && event.inputId() == 2) {
if (event.status() == KeyStatus.down || event.status() == KeyStatus.move || event.status() == KeyStatus.up) { if (event.status() == KeyStatus.down || event.status() == KeyStatus.move
|| event.status() == KeyStatus.up) {
keepFocus(); keepFocus();
// updatethe cursor position : // updatethe cursor position :
updateCursorPosition(absolutePosition); updateCursorPosition(absolutePosition);
@ -508,7 +519,7 @@ public class Entry extends Widget {
} }
return false; return false;
} }
@Override @Override
protected void onGetFocus() { protected void onGetFocus() {
this.displayCursor = true; this.displayCursor = true;
@ -516,7 +527,7 @@ public class Entry extends Widget {
showKeyboard(); showKeyboard();
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onLostFocus() { protected void onLostFocus() {
this.displayCursor = false; this.displayCursor = false;
@ -524,13 +535,13 @@ public class Entry extends Widget {
hideKeyboard(); hideKeyboard();
markToRedraw(); markToRedraw();
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
//return; //return;
} }
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'"); //LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear(); this.shape.clear();
this.text.clear(); this.text.clear();
if (this.colorIdTextFg >= 0) { if (this.colorIdTextFg >= 0) {
@ -541,7 +552,7 @@ public class Entry extends Widget {
} }
updateTextPosition(); updateTextPosition();
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize; Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize)); Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
@ -562,7 +573,7 @@ public class Entry extends Widget {
Vector3f tmpOriginText = tmpOriginShaper.add(padding.bottom(), padding.left(), padding.back()); //this.size.less(tmpSizeText).multiply(0.5f); Vector3f tmpOriginText = tmpOriginShaper.add(padding.bottom(), padding.left(), padding.back()); //this.size.less(tmpSizeText).multiply(0.5f);
//Vector3f tmpOriginText = new Vector3f(0, this.text.getSize(), 0); //Vector3f tmpOriginText = new Vector3f(0, this.text.getSize(), 0);
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ... // sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
final int minHeight = (int) this.text.getHeight(); final int minHeight = (int) this.text.getHeight();
if (tmpSizeText.y() > minHeight) { if (tmpSizeText.y() > minHeight) {
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f, 0); tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f, 0);
@ -572,7 +583,7 @@ public class Entry extends Widget {
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper); tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeText = Vector3f.clipInt(tmpSizeText); tmpSizeText = Vector3f.clipInt(tmpSizeText);
tmpOriginText = Vector3f.clipInt(tmpOriginText); tmpOriginText = Vector3f.clipInt(tmpOriginText);
this.text.clear(); this.text.clear();
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y()); //this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
this.text.setClippingWidth(tmpOriginText, tmpSizeText); this.text.setClippingWidth(tmpOriginText, tmpSizeText);
@ -586,7 +597,7 @@ public class Entry extends Widget {
if (this.propertyPassword) { if (this.propertyPassword) {
Arrays.fill(valueToDisplay, '*'); Arrays.fill(valueToDisplay, '*');
} }
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y()); //final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
if (valueToDisplay.length != 0) { if (valueToDisplay.length != 0) {
this.text.print(new String(valueToDisplay)); this.text.print(new String(valueToDisplay));
@ -599,9 +610,9 @@ public class Entry extends Widget {
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.text.flush(); this.text.flush();
this.shape.flush(); this.shape.flush();
} }
/** /**
* remove the selected area * remove the selected area
* @note This request a regeneration of the display * @note This request a regeneration of the display
@ -629,7 +640,7 @@ public class Entry extends Widget {
this.propertyValue = tmp.toString(); this.propertyValue = tmp.toString();
markToRedraw(); markToRedraw();
} }
/** /**
* internal check the value with RegExp checking * internal check the value with RegExp checking
* @param newData The new string to display * @param newData The new string to display
@ -640,15 +651,15 @@ public class Entry extends Widget {
if (newData.length() > 0) { if (newData.length() > 0) {
/* /*
if (this.regex.parse(_newData, 0, _newData.size()) == false) { if (this.regex.parse(_newData, 0, _newData.size()) == false) {
Log.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "'" ); LOGGER.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "'" );
return; return;
} }
if (this.regex.start() != 0) { if (this.regex.start() != 0) {
Log.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "' (start position error)" ); LOGGER.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "' (start position error)" );
return; return;
} }
if (this.regex.stop() != _newData.size()) { if (this.regex.stop() != _newData.size()) {
Log.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "' (stop position error)" ); LOGGER.info("The input data does not match with the regExp '" + _newData + "' Regex='" + propertyRegex + "' (stop position error)" );
return; return;
} }
*/ */
@ -656,7 +667,7 @@ public class Entry extends Widget {
this.propertyValue = newData; this.propertyValue = newData;
markToRedraw(); markToRedraw();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "config") @AknotName(value = "config")
@ -668,7 +679,7 @@ public class Entry extends Widget {
this.propertyConfig = propertyConfig; this.propertyConfig = propertyConfig;
onChangePropertyShaper(); onChangePropertyShaper();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "max") @AknotName(value = "max")
@ -680,7 +691,7 @@ public class Entry extends Widget {
this.propertyMaxCharacter = propertyMaxCharacter; this.propertyMaxCharacter = propertyMaxCharacter;
onChangePropertyMaxCharacter(); onChangePropertyMaxCharacter();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "password") @AknotName(value = "password")
@ -692,7 +703,7 @@ public class Entry extends Widget {
this.propertyPassword = propertyPassword; this.propertyPassword = propertyPassword;
onChangePropertyPassword(); onChangePropertyPassword();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "regex") @AknotName(value = "regex")
@ -704,7 +715,7 @@ public class Entry extends Widget {
this.propertyRegex = propertyRegex; this.propertyRegex = propertyRegex;
onChangePropertyRegex(); onChangePropertyRegex();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "empty-text") @AknotName(value = "empty-text")
@ -716,7 +727,7 @@ public class Entry extends Widget {
this.propertyTextWhenNothing = propertyTextWhenNothing; this.propertyTextWhenNothing = propertyTextWhenNothing;
onChangePropertyTextWhenNothing(); onChangePropertyTextWhenNothing();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "value") @AknotName(value = "value")
@ -728,7 +739,7 @@ public class Entry extends Widget {
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
onChangePropertyValue(); onChangePropertyValue();
} }
/** /**
* change the cursor position with the curent position requested on the display * change the cursor position with the curent position requested on the display
* @param pos Absolute position of the event * @param pos Absolute position of the event
@ -737,24 +748,24 @@ public class Entry extends Widget {
protected void updateCursorPosition(final Vector3f pos) { protected void updateCursorPosition(final Vector3f pos) {
updateCursorPosition(pos, false); updateCursorPosition(pos, false);
} }
protected void updateCursorPosition(final Vector3f pos, final boolean selection/*=false*/) { protected void updateCursorPosition(final Vector3f pos, final boolean selection/*=false*/) {
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
final Vector3f relPos = relativePosition(pos).less(this.overPositionStart); final Vector3f relPos = relativePosition(pos).less(this.overPositionStart);
// reject when outside ... // reject when outside ...
// try to find the new cursor position : // try to find the new cursor position :
if (this.displayStartPosition > this.propertyValue.length()) { if (this.displayStartPosition > this.propertyValue.length()) {
this.displayStartPosition = this.propertyValue.length(); this.displayStartPosition = this.propertyValue.length();
} }
if (this.displayStartPosition < 0) { if (this.displayStartPosition < 0) {
Log.error("wring cursor position : " + this.displayStartPosition + "/" + this.propertyValue.length()); LOGGER.error("wring cursor position : " + this.displayStartPosition + "/" + this.propertyValue.length());
this.displayStartPosition = 0; this.displayStartPosition = 0;
} }
String tmpDisplay = this.propertyValue.substring(0, this.displayStartPosition); String tmpDisplay = this.propertyValue.substring(0, this.displayStartPosition);
final int displayHidenSize = (int) this.text.calculateSize(tmpDisplay).x(); final int displayHidenSize = (int) this.text.calculateSize(tmpDisplay).x();
//Log.debug("hidenSize : " + displayHidenSize); //LOGGER.debug("hidenSize : " + displayHidenSize);
int newCursorPosition = -1; int newCursorPosition = -1;
final int tmpTextOriginX = (int) padding.left(); final int tmpTextOriginX = (int) padding.left();
for (int iii = 0; iii < this.propertyValue.length(); iii++) { for (int iii = 0; iii < this.propertyValue.length(); iii++) {
@ -781,7 +792,7 @@ public class Entry extends Widget {
} }
markToUpdateTextPosition(); markToUpdateTextPosition();
} }
/** /**
* update the display position start == > depending of the position of the Cursor and the size of the Data inside * update the display position start == > depending of the position of the Cursor and the size of the Data inside
* @change this.displayStartPosition < == updated * @change this.displayStartPosition < == updated
@ -791,7 +802,7 @@ public class Entry extends Widget {
return; return;
} }
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
int tmpSizeX = (int) this.minSize.x(); int tmpSizeX = (int) this.minSize.x();
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
tmpSizeX = (int) this.size.x(); tmpSizeX = (int) this.size.x();
@ -808,7 +819,8 @@ public class Entry extends Widget {
} else { } else {
// check if the Cursor is visible at 10px nearest the border : // check if the Cursor is visible at 10px nearest the border :
final int tmp1 = this.displayCursorPositionPixel + this.displayStartPosition; final int tmp1 = this.displayCursorPositionPixel + this.displayStartPosition;
Log.debug("cursorPos=" + this.displayCursorPositionPixel + "px maxSize=" + tmpUserSize + "px tmp1=" + tmp1); LOGGER.debug(
"cursorPos=" + this.displayCursorPositionPixel + "px maxSize=" + tmpUserSize + "px tmp1=" + tmp1);
if (tmp1 < 10) { if (tmp1 < 10) {
// set the cursor on the left // set the cursor on the left
this.displayStartPosition = Math.min(-this.displayCursorPositionPixel + 10, 0); this.displayStartPosition = Math.min(-this.displayCursorPositionPixel + 10, 0);
@ -820,5 +832,5 @@ public class Entry extends Widget {
//this.displayStartPosition = -totalWidth + tmpUserSize; //this.displayStartPosition = -totalWidth + tmpUserSize;
} }
} }
} }

View File

@ -10,12 +10,15 @@ import java.util.List;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
class Gird extends Widget { class Gird extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Gird.class);
protected class GirdProperties { protected class GirdProperties {
public Widget widget; public Widget widget;
public int row; public int row;
@ -45,7 +48,7 @@ class Gird extends Widget {
this.sizeCol.set(iii, 0); this.sizeCol.set(iii, 0);
} }
} }
//Log.debug("Update minimum size"); //LOGGER.debug("Update minimum size");
this.minSize = this.propertyMinSize.getPixel(); this.minSize = this.propertyMinSize.getPixel();
this.maxSize = this.propertyMaxSize.getPixel(); this.maxSize = this.propertyMaxSize.getPixel();
this.uniformSizeRow = 0; this.uniformSizeRow = 0;
@ -59,12 +62,13 @@ class Gird extends Widget {
if (this.subWidget.get(iii).widget != null) { if (this.subWidget.get(iii).widget != null) {
this.subWidget.get(iii).widget.calculateMinMaxSize(); this.subWidget.get(iii).widget.calculateMinMaxSize();
final Vector3f tmpSize = this.subWidget.get(iii).widget.getCalculateMinSize(); final Vector3f tmpSize = this.subWidget.get(iii).widget.getCalculateMinSize();
Log.debug(" [" + iii + "] subWidgetMinSize=" + tmpSize); LOGGER.debug(" [" + iii + "] subWidgetMinSize=" + tmpSize);
// for all we get the max size : // for all we get the max size :
this.uniformSizeRow = Math.max((int) tmpSize.y(), this.uniformSizeRow); this.uniformSizeRow = Math.max((int) tmpSize.y(), this.uniformSizeRow);
// for the colomn size : We set the autamatic value in negative : // for the colomn size : We set the autamatic value in negative :
if (this.sizeCol.get(this.subWidget.get(iii).col) <= 0) { if (this.sizeCol.get(this.subWidget.get(iii).col) <= 0) {
this.sizeCol.set(this.subWidget.get(iii).col, Math.min(this.sizeCol.get(this.subWidget.get(iii).col), (int) -tmpSize.x())); this.sizeCol.set(this.subWidget.get(iii).col,
Math.min(this.sizeCol.get(this.subWidget.get(iii).col), (int) -tmpSize.x()));
} }
} }
} }
@ -73,16 +77,16 @@ class Gird extends Widget {
this.uniformSizeRow = this.sizeRow; this.uniformSizeRow = this.sizeRow;
} }
int tmpSizeWidth = 0; int tmpSizeWidth = 0;
for (int iii = 0; iii < this.sizeCol.size(); iii++) { for (final Integer element : this.sizeCol) {
tmpSizeWidth += Math.abs(this.sizeCol.get(iii)); tmpSizeWidth += Math.abs(element);
} }
Log.debug(" tmpSizeWidth=" + tmpSizeWidth); LOGGER.debug(" tmpSizeWidth=" + tmpSizeWidth);
Log.debug(" this.uniformSizeRow=" + this.uniformSizeRow); LOGGER.debug(" this.uniformSizeRow=" + this.uniformSizeRow);
this.minSize = this.minSize.add(tmpSizeWidth, (lastLineID + 1) * this.uniformSizeRow, 0); this.minSize = this.minSize.add(tmpSizeWidth, (lastLineID + 1) * this.uniformSizeRow, 0);
Log.debug("Calculate min size : " + this.minSize); LOGGER.debug("Calculate min size : " + this.minSize);
//Log.debug("Vert Result : expand="+ this.userExpand + " minSize="+ this.minSize); //LOGGER.debug("Vert Result : expand="+ this.userExpand + " minSize="+ this.minSize);
} }
/** /**
@ -105,7 +109,7 @@ class Gird extends Widget {
} }
return this.sizeCol.get(colId); return this.sizeCol.get(colId);
} }
Log.error("Can not get the Colomn size : " + colId + 1 + " we have " + this.sizeCol.size() + " colomn"); LOGGER.error("Can not get the Colomn size : " + colId + 1 + " we have " + this.sizeCol.size() + " colomn");
return 0; return 0;
} }
@ -133,7 +137,8 @@ class Gird extends Widget {
} }
final Vector3f tmpSize = it.widget.getSize(); final Vector3f tmpSize = it.widget.getSize();
final Vector3f tmpOrigin = it.widget.getOrigin(); final Vector3f tmpOrigin = it.widget.getOrigin();
if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x()) && (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) { if ((tmpOrigin.x() <= pos.x() && tmpOrigin.x() + tmpSize.x() >= pos.x())
&& (tmpOrigin.y() <= pos.y() && tmpOrigin.y() + tmpSize.y() >= pos.y())) {
final Widget tmpWidget = it.widget.getWidgetAtPos(pos); final Widget tmpWidget = it.widget.getWidgetAtPos(pos);
if (tmpWidget != null) { if (tmpWidget != null) {
return tmpWidget; return tmpWidget;
@ -147,8 +152,9 @@ class Gird extends Widget {
@Override @Override
public void onChangeSize() { public void onChangeSize() {
//Log.debug("Update size"); //LOGGER.debug("Update size");
this.size = this.size.less(this.propertyBorderSize.x() * 2, this.propertyBorderSize.y() * 2, this.propertyBorderSize.y() * 2); this.size = this.size.less(this.propertyBorderSize.x() * 2, this.propertyBorderSize.y() * 2,
this.propertyBorderSize.y() * 2);
for (int iii = 0; iii < this.subWidget.size(); iii++) { for (int iii = 0; iii < this.subWidget.size(); iii++) {
if (this.subWidget.get(iii).widget != null) { if (this.subWidget.get(iii).widget != null) {
@ -171,16 +177,19 @@ class Gird extends Widget {
} }
tmpOrigin = tmpOrigin.add(tmpSizeWidth, addingPos, 0); tmpOrigin = tmpOrigin.add(tmpSizeWidth, addingPos, 0);
Log.debug(" [{}] set subwidget origin={} size={}", iii, tmpOrigin, new Vector3f(Math.abs(this.sizeCol.get(this.subWidget.get(iii).col)), this.uniformSizeRow, 0)); LOGGER.debug(" [{}] set subwidget origin={} size={}", iii, tmpOrigin,
new Vector3f(Math.abs(this.sizeCol.get(this.subWidget.get(iii).col)), this.uniformSizeRow, 0));
// set the origin : // set the origin :
this.subWidget.get(iii).widget.setOrigin(tmpOrigin.clipInteger()); this.subWidget.get(iii).widget.setOrigin(tmpOrigin.clipInteger());
// all time set all the space . // all time set all the space .
this.subWidget.get(iii).widget.setSize((new Vector3f(Math.abs(this.sizeCol.get(this.subWidget.get(iii).col)), this.uniformSizeRow, 0)).clipInteger()); this.subWidget.get(iii).widget.setSize(
(new Vector3f(Math.abs(this.sizeCol.get(this.subWidget.get(iii).col)), this.uniformSizeRow, 0))
.clipInteger());
this.subWidget.get(iii).widget.onChangeSize(); this.subWidget.get(iii).widget.onChangeSize();
} }
} }
this.size = this.size.add(this.propertyBorderSize.multiply(0.5f)); this.size = this.size.add(this.propertyBorderSize.multiply(0.5f));
Log.debug("Calculate size : " + this.size); LOGGER.debug("Calculate size : " + this.size);
markToRedraw(); markToRedraw();
} }
@ -216,11 +225,12 @@ class Gird extends Widget {
this.subWidget.get(iii).widget = null; this.subWidget.get(iii).widget = null;
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ... // no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == this.subWidget.size()) { if (errorControl == this.subWidget.size()) {
Log.critical( LOGGER.error("[" + getId()
"[" + getId() + "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function..."); + "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
System.exit(-1);
} }
} else { } else {
Log.warning("[" + getId() + "] Must not have null pointer on the subWidget list ..."); LOGGER.warn("[" + getId() + "] Must not have null pointer on the subWidget list ...");
this.subWidget.remove(iii); this.subWidget.remove(iii);
} }
errorControl = this.subWidget.size(); errorControl = this.subWidget.size();
@ -245,7 +255,8 @@ class Gird extends Widget {
if ((long) this.sizeCol.size() > colId) { if ((long) this.sizeCol.size() > colId) {
this.sizeCol.set(colId, size); this.sizeCol.set(colId, size);
} else { } else {
Log.error("Can not set the Colomn size : " + colId + 1 + " at " + size + "px we have " + this.sizeCol.size() + " colomn"); LOGGER.error("Can not set the Colomn size : " + colId + 1 + " at " + size + "px we have "
+ this.sizeCol.size() + " colomn");
} }
} }
@ -268,11 +279,11 @@ class Gird extends Widget {
public void setPropertyBorderSize(final Vector3f propertyBorderSize) { public void setPropertyBorderSize(final Vector3f propertyBorderSize) {
this.propertyBorderSize = propertyBorderSize; this.propertyBorderSize = propertyBorderSize;
if (this.propertyBorderSize.x() < 0) { if (this.propertyBorderSize.x() < 0) {
Log.error("Try to set a border size <0 on x : " + this.propertyBorderSize.x() + " == > restore to 0"); LOGGER.error("Try to set a border size <0 on x : " + this.propertyBorderSize.x() + " == > restore to 0");
this.propertyBorderSize = this.propertyBorderSize.withX(0); this.propertyBorderSize = this.propertyBorderSize.withX(0);
} }
if (this.propertyBorderSize.y() < 0) { if (this.propertyBorderSize.y() < 0) {
Log.error("Try to set a border size <0 on y : " + this.propertyBorderSize.y() + " == > restore to 0"); LOGGER.error("Try to set a border size <0 on y : " + this.propertyBorderSize.y() + " == > restore to 0");
this.propertyBorderSize = this.propertyBorderSize.withY(0); this.propertyBorderSize = this.propertyBorderSize.withY(0);
} }
markToRedraw(); markToRedraw();
@ -310,19 +321,17 @@ class Gird extends Widget {
// find a new position; // find a new position;
this.subWidget.add(iii, prop); this.subWidget.add(iii, prop);
return; return;
} else if (this.subWidget.get(iii).col < prop.col) {
continue;
} else if (this.subWidget.get(iii).col > prop.col) {
// find a new position;
this.subWidget.add(iii, prop);
return;
} else { } else {
if (this.subWidget.get(iii).col < prop.col) { // The element already exist == > replace it ...
continue; this.tmpWidget = this.subWidget.get(iii).widget;
} else if (this.subWidget.get(iii).col > prop.col) { this.subWidget.get(iii).widget = newWidget;
// find a new position; this.tmpWidget = null;
this.subWidget.add(iii, prop);
return;
} else {
// The element already exist == > replace it ...
this.tmpWidget = this.subWidget.get(iii).widget;
this.subWidget.get(iii).widget = newWidget;
this.tmpWidget = null;
}
} }
} }
// not find == > just adding it ... // not find == > just adding it ...
@ -336,7 +345,7 @@ class Gird extends Widget {
*/ */
public void subWidgetRemove(final int colId, final int rowId) { public void subWidgetRemove(final int colId, final int rowId) {
if (colId < 0 || rowId < 0) { if (colId < 0 || rowId < 0) {
Log.warning("[" + getId() + "] try to remove widget with id < 0 col=" + colId + " row=" + rowId); LOGGER.warn("[" + getId() + "] try to remove widget with id < 0 col=" + colId + " row=" + rowId);
return; return;
} }
final int errorControl = this.subWidget.size(); final int errorControl = this.subWidget.size();
@ -347,7 +356,7 @@ class Gird extends Widget {
return; return;
} }
} }
Log.warning("[" + getId() + "] Can not remove unExistant widget"); LOGGER.warn("[" + getId() + "] Can not remove unExistant widget");
} }
/** /**
@ -361,7 +370,7 @@ class Gird extends Widget {
return; return;
} }
} }
Log.warning("[" + getId() + "] Can not remove unExistant widget"); LOGGER.warn("[" + getId() + "] Can not remove unExistant widget");
} }
/** /**
@ -379,7 +388,7 @@ class Gird extends Widget {
*/ */
public void subWidgetUnLink(final int colId, final int rowId) { public void subWidgetUnLink(final int colId, final int rowId) {
if (colId < 0 || rowId < 0) { if (colId < 0 || rowId < 0) {
Log.warning("[" + getId() + "] try to Unlink widget with id < 0 col=" + colId + " row=" + rowId); LOGGER.warn("[" + getId() + "] try to Unlink widget with id < 0 col=" + colId + " row=" + rowId);
return; return;
} }
// try to find it ... // try to find it ...
@ -389,7 +398,7 @@ class Gird extends Widget {
return; return;
} }
} }
Log.warning("[" + getId() + "] Can not unLink unExistant widget"); LOGGER.warn("[" + getId() + "] Can not unLink unExistant widget");
} }
/** /**

View File

@ -19,22 +19,24 @@ import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.compositing.CompositingImage; import org.atriasoft.ewol.compositing.CompositingImage;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ImageDisplay extends Widget { public class ImageDisplay extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(ImageDisplay.class);
protected int colorId = -1; //!< Color of the image. protected int colorId = -1; //!< Color of the image.
protected ResourceColorFile colorProperty = null; //!< theme color property protected ResourceColorFile colorProperty = null; //!< theme color property
protected CompositingImage compositing = new CompositingImage(); //!< compositing element of the image. protected CompositingImage compositing = new CompositingImage(); //!< compositing element of the image.
protected Vector2f imageRenderSize = Vector2f.ZERO; //!< size of the image when we render it protected Vector2f imageRenderSize = Vector2f.ZERO; //!< size of the image when we render it
protected Dimension2f propertyBorder = Dimension2f.ZERO; //!< border to add at the image. protected Dimension2f propertyBorder = Dimension2f.ZERO; //!< border to add at the image.
protected Dimension2f propertyImageSize = Dimension2f.ZERO; //!< border to add at the image. protected Dimension2f propertyImageSize = Dimension2f.ZERO; //!< border to add at the image.
protected boolean propertyKeepRatio = true; //!< keep the image ratio between width and height protected boolean propertyKeepRatio = true; //!< keep the image ratio between width and height
protected Vector2f propertyPosStart = Vector2f.ZERO; //!< position in the image to start the display (when we want not to display all the image) protected Vector2f propertyPosStart = Vector2f.ZERO; //!< position in the image to start the display (when we want not to display all the image)
protected Vector2f propertyPosStop = Vector2f.ONE; //!< position in the image to start the display (when we want not to display all the image) protected Vector2f propertyPosStop = Vector2f.ONE; //!< position in the image to start the display (when we want not to display all the image)
protected boolean propertySmooth = true; //!< display is done in the pixel approximation if false protected boolean propertySmooth = true; //!< display is done in the pixel approximation if false
protected Uri propertySource = null; //!< file name of the image. protected Uri propertySource = null; //!< file name of the image.
protected boolean propertyUseThemeColor = false; //!< Use the themo color management ("THEMECOLOR:///Image.json?lib=ewol") default false protected boolean propertyUseThemeColor = false; //!< Use the themo color management ("THEMECOLOR:///Image.json?lib=ewol") default false
@ -42,41 +44,43 @@ public class ImageDisplay extends Widget {
@AknotName("pressed") @AknotName("pressed")
@AknotDescription(value = "Image is pressed") @AknotDescription(value = "Image is pressed")
public final SignalEmpty signalPressed = new SignalEmpty(); public final SignalEmpty signalPressed = new SignalEmpty();
/** /**
* *
*/ */
public ImageDisplay() {} public ImageDisplay() {}
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
Log.debug("calculate min size: border=" + this.propertyBorder + " size=" + this.propertyImageSize + " min-size=" + this.propertyMinSize); LOGGER.debug("calculate min size: border=" + this.propertyBorder + " size=" + this.propertyImageSize
+ " min-size=" + this.propertyMinSize);
final Vector2f imageBoder = this.propertyBorder.getPixel().multiply(2.0f); final Vector2f imageBoder = this.propertyBorder.getPixel().multiply(2.0f);
final Vector2f imageSize = this.propertyImageSize.getPixel(); final Vector2f imageSize = this.propertyImageSize.getPixel();
final Vector3f size = this.propertyMinSize.getPixel(); final Vector3f size = this.propertyMinSize.getPixel();
Log.debug(" ==> border=" + imageBoder + " size=" + imageSize + " min-size=" + size); LOGGER.debug(" ==> border=" + imageBoder + " size=" + imageSize + " min-size=" + size);
if (!imageSize.isZero()) { if (!imageSize.isZero()) {
final Vector2f tmp = imageBoder.add(imageSize); final Vector2f tmp = imageBoder.add(imageSize);
this.minSize = new Vector3f(tmp.x(), tmp.y(), 0); this.minSize = new Vector3f(tmp.x(), tmp.y(), 0);
this.maxSize = this.minSize; this.maxSize = this.minSize;
} else { } else {
final Vector2i imageSizeReal = this.getPropertyMinSize().getPixeli();//.compositing.getRealSize(); final Vector2i imageSizeReal = getPropertyMinSize().getPixeli();//.compositing.getRealSize();
Log.verbose(" Real Size = " + imageSizeReal); LOGGER.trace(" Real Size = " + imageSizeReal);
final Vector3f min1 = this.propertyMinSize.getPixel().add(imageBoder.x(), imageBoder.y(), 0); final Vector3f min1 = this.propertyMinSize.getPixel().add(imageBoder.x(), imageBoder.y(), 0);
this.minSize = new Vector3f(imageBoder.x() + imageSizeReal.x(), imageBoder.y() + imageSizeReal.y(), 0); this.minSize = new Vector3f(imageBoder.x() + imageSizeReal.x(), imageBoder.y() + imageSizeReal.y(), 0);
Log.verbose(" set max : " + this.minSize + " min1=" + min1); LOGGER.trace(" set max : " + this.minSize + " min1=" + min1);
this.minSize = Vector3f.max(this.minSize, min1); this.minSize = Vector3f.max(this.minSize, min1);
Log.verbose(" result : " + this.minSize); LOGGER.trace(" result : " + this.minSize);
this.maxSize = this.propertyMaxSize.getPixel().add(imageBoder.x(), imageBoder.y(), 0); this.maxSize = this.propertyMaxSize.getPixel().add(imageBoder.x(), imageBoder.y(), 0);
this.minSize = Vector3f.min(this.minSize, this.maxSize); this.minSize = Vector3f.min(this.minSize, this.maxSize);
} }
this.imageRenderSize = new Vector2f(this.minSize.x(), this.minSize.y()); this.imageRenderSize = new Vector2f(this.minSize.x(), this.minSize.y());
this.minSize = Vector3f.max(this.minSize, size); this.minSize = Vector3f.max(this.minSize, size);
this.maxSize = Vector3f.max(this.maxSize, this.minSize); this.maxSize = Vector3f.max(this.maxSize, this.minSize);
Log.debug("set widget min=" + this.minSize + " max=" + this.maxSize + " with real Image size=" + this.imageRenderSize + " img size=" + imageSize + " " + this.propertyImageSize); LOGGER.debug("set widget min=" + this.minSize + " max=" + this.maxSize + " with real Image size="
+ this.imageRenderSize + " img size=" + imageSize + " " + this.propertyImageSize);
markToRedraw(); markToRedraw();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "image-border") @AknotName(value = "image-border")
@ -84,7 +88,7 @@ public class ImageDisplay extends Widget {
public Dimension2f getPropertyBorder() { public Dimension2f getPropertyBorder() {
return this.propertyBorder; return this.propertyBorder;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "image-size") @AknotName(value = "image-size")
@ -92,7 +96,7 @@ public class ImageDisplay extends Widget {
public Dimension2f getPropertyImageSize() { public Dimension2f getPropertyImageSize() {
return this.propertyImageSize; return this.propertyImageSize;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "part-start") @AknotName(value = "part-start")
@ -100,7 +104,7 @@ public class ImageDisplay extends Widget {
public Vector2f getPropertyPosStart() { public Vector2f getPropertyPosStart() {
return this.propertyPosStart; return this.propertyPosStart;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "part-stop") @AknotName(value = "part-stop")
@ -108,7 +112,7 @@ public class ImageDisplay extends Widget {
public Vector2f getPropertyPosStop() { public Vector2f getPropertyPosStop() {
return this.propertyPosStop; return this.propertyPosStop;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "src") @AknotName(value = "src")
@ -116,7 +120,7 @@ public class ImageDisplay extends Widget {
public Uri getPropertySource() { public Uri getPropertySource() {
return this.propertySource; return this.propertySource;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "ratio") @AknotName(value = "ratio")
@ -124,7 +128,7 @@ public class ImageDisplay extends Widget {
public boolean isPropertyKeepRatio() { public boolean isPropertyKeepRatio() {
return this.propertyKeepRatio; return this.propertyKeepRatio;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "smooth") @AknotName(value = "smooth")
@ -132,7 +136,7 @@ public class ImageDisplay extends Widget {
public boolean isPropertySmooth() { public boolean isPropertySmooth() {
return this.propertySmooth; return this.propertySmooth;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "use-theme-color") @AknotName(value = "use-theme-color")
@ -140,15 +144,15 @@ public class ImageDisplay extends Widget {
public boolean isPropertyUseThemeColor() { public boolean isPropertyUseThemeColor() {
return this.propertyUseThemeColor; return this.propertyUseThemeColor;
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.compositing.draw(); this.compositing.draw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
//Log.debug("Event on BT ..."); //LOGGER.debug("Event on BT ...");
if (event.inputId() == 1) { if (event.inputId() == 1) {
if (KeyStatus.pressSingle == event.status()) { if (KeyStatus.pressSingle == event.status()) {
this.signalPressed.emit(); this.signalPressed.emit();
@ -157,7 +161,7 @@ public class ImageDisplay extends Widget {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
@ -174,11 +178,12 @@ public class ImageDisplay extends Widget {
imageBoder = imageBoder.multiply(2.0f); imageBoder = imageBoder.multiply(2.0f);
Vector2f imageRealSize = this.imageRenderSize.less(imageBoder); Vector2f imageRealSize = this.imageRenderSize.less(imageBoder);
final Vector3f imageRealSizeMax = this.size.less(imageBoder.x(), imageBoder.y(), 0); final Vector3f imageRealSizeMax = this.size.less(imageBoder.x(), imageBoder.y(), 0);
final Vector2f ratioSizeDisplayRequested = this.propertyPosStop.less(this.propertyPosStart); final Vector2f ratioSizeDisplayRequested = this.propertyPosStop.less(this.propertyPosStart);
//imageRealSizeMax *= ratioSizeDisplayRequested; //imageRealSizeMax *= ratioSizeDisplayRequested;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.imageRenderSize.x(), this.imageRenderSize.y(), 0)); Vector3f delta = this.propertyGravity
.gravityGenerateDelta(this.size.less(this.imageRenderSize.x(), this.imageRenderSize.y(), 0));
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
imageRealSize = imageRealSize.withX(imageRealSizeMax.x()); imageRealSize = imageRealSize.withX(imageRealSizeMax.x());
delta = delta.withX(0.0f); delta = delta.withX(0.0f);
@ -188,11 +193,12 @@ public class ImageDisplay extends Widget {
delta = delta.withY(0.0f); delta = delta.withY(0.0f);
} }
origin = origin.add(delta); origin = origin.add(delta);
if (this.propertyKeepRatio) { if (this.propertyKeepRatio) {
final Vector2i tmpSize = this.compositing.getRealSize(); final Vector2i tmpSize = this.compositing.getRealSize();
//float ratio = tmpSize.x() / tmpSize.y(); //float ratio = tmpSize.x() / tmpSize.y();
final float ratio = (tmpSize.x() * ratioSizeDisplayRequested.x()) / (tmpSize.y() * ratioSizeDisplayRequested.y()); final float ratio = (tmpSize.x() * ratioSizeDisplayRequested.x())
/ (tmpSize.y() * ratioSizeDisplayRequested.y());
//float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y()); //float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y());
final float ratioCurrent = imageRealSize.x() / imageRealSize.y(); final float ratioCurrent = imageRealSize.x() / imageRealSize.y();
if (ratio == ratioCurrent) { if (ratio == ratioCurrent) {
@ -207,7 +213,7 @@ public class ImageDisplay extends Widget {
origin = origin.add(0, (oldY - imageRealSize.y()) * 0.5f, 0); origin = origin.add(0, (oldY - imageRealSize.y()) * 0.5f, 0);
} }
} }
// set the somposition properties : // set the somposition properties :
if (this.propertySmooth) { if (this.propertySmooth) {
this.compositing.setPos(origin); this.compositing.setPos(origin);
@ -215,23 +221,24 @@ public class ImageDisplay extends Widget {
this.compositing.setPos(Vector3f.clipInt(origin)); this.compositing.setPos(Vector3f.clipInt(origin));
} }
this.compositing.printPart(imageRealSize, this.propertyPosStart, this.propertyPosStop); this.compositing.printPart(imageRealSize, this.propertyPosStart, this.propertyPosStop);
Log.debug("Paint Image at : " + origin + " size=" + imageRealSize); LOGGER.debug("Paint Image at : " + origin + " size=" + imageRealSize);
Log.debug("Paint Image :" + this.propertySource + " realsize=" + this.compositing.getRealSize() + " origin=" + origin + " size=" + imageRealSize); LOGGER.debug("Paint Image :" + this.propertySource + " realsize=" + this.compositing.getRealSize() + " origin="
Log.debug(" start=" + this.propertyPosStart + " stop=" + this.propertyPosStop); + origin + " size=" + imageRealSize);
LOGGER.debug(" start=" + this.propertyPosStart + " stop=" + this.propertyPosStop);
this.compositing.flush(); this.compositing.flush();
} }
/** /**
* set All the configuration of the current image * set All the configuration of the current image
* @param uri URI of the new image * @param uri URI of the new image
* @param border New border size to set * @param border New border size to set
*/ */
public void set(final Uri uri, final Dimension2f border) { public void set(final Uri uri, final Dimension2f border) {
Log.verbose("Set Image : " + uri + " border=" + border); LOGGER.trace("Set Image : " + uri + " border=" + border);
setPropertyBorder(border); setPropertyBorder(border);
setPropertySource(uri); setPropertySource(uri);
} }
/** /**
* Set an image with direct elements * Set an image with direct elements
* @param image Image to set in the display * @param image Image to set in the display
@ -242,7 +249,7 @@ public class ImageDisplay extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setPropertyBorder(final Dimension2f propertyBorder) { public void setPropertyBorder(final Dimension2f propertyBorder) {
if (this.propertyBorder.equals(propertyBorder)) { if (this.propertyBorder.equals(propertyBorder)) {
return; return;
@ -251,7 +258,7 @@ public class ImageDisplay extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setPropertyImageSize(final Dimension2f propertyImageSize) { public void setPropertyImageSize(final Dimension2f propertyImageSize) {
if (this.propertyImageSize.equals(propertyImageSize)) { if (this.propertyImageSize.equals(propertyImageSize)) {
return; return;
@ -259,10 +266,10 @@ public class ImageDisplay extends Widget {
this.propertyImageSize = propertyImageSize; this.propertyImageSize = propertyImageSize;
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
Log.verbose("Set sources : " + this.propertySource + " size=" + propertyImageSize); LOGGER.trace("Set sources : " + this.propertySource + " size=" + propertyImageSize);
this.compositing.setSource(this.propertySource, propertyImageSize.getPixeli()); this.compositing.setSource(this.propertySource, propertyImageSize.getPixeli());
} }
public void setPropertyKeepRatio(final boolean propertyKeepRatio) { public void setPropertyKeepRatio(final boolean propertyKeepRatio) {
if (this.propertyKeepRatio == propertyKeepRatio) { if (this.propertyKeepRatio == propertyKeepRatio) {
return; return;
@ -271,7 +278,7 @@ public class ImageDisplay extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setPropertyPosStart(final Vector2f propertyPosStart) { public void setPropertyPosStart(final Vector2f propertyPosStart) {
if (this.propertyPosStart.equals(propertyPosStart)) { if (this.propertyPosStart.equals(propertyPosStart)) {
return; return;
@ -280,7 +287,7 @@ public class ImageDisplay extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setPropertyPosStop(final Vector2f propertyPosStop) { public void setPropertyPosStop(final Vector2f propertyPosStop) {
if (this.propertyPosStop.equals(propertyPosStop)) { if (this.propertyPosStop.equals(propertyPosStop)) {
return; return;
@ -289,7 +296,7 @@ public class ImageDisplay extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
public void setPropertySmooth(final boolean propertySmooth) { public void setPropertySmooth(final boolean propertySmooth) {
if (this.propertySmooth == propertySmooth) { if (this.propertySmooth == propertySmooth) {
return; return;
@ -297,7 +304,7 @@ public class ImageDisplay extends Widget {
this.propertySmooth = propertySmooth; this.propertySmooth = propertySmooth;
markToRedraw(); markToRedraw();
} }
public void setPropertySource(final Uri propertySource) { public void setPropertySource(final Uri propertySource) {
if (this.propertySource != null && this.propertySource.equals(propertySource)) { if (this.propertySource != null && this.propertySource.equals(propertySource)) {
return; return;
@ -305,10 +312,10 @@ public class ImageDisplay extends Widget {
this.propertySource = propertySource; this.propertySource = propertySource;
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
Log.verbose("Set sources : " + propertySource + " size=" + this.propertyImageSize); LOGGER.trace("Set sources : " + propertySource + " size=" + this.propertyImageSize);
this.compositing.setSource(propertySource, this.propertyImageSize.getPixeli()); this.compositing.setSource(propertySource, this.propertyImageSize.getPixeli());
} }
public void setPropertyUseThemeColor(final boolean propertyUseThemeColor) { public void setPropertyUseThemeColor(final boolean propertyUseThemeColor) {
if (this.propertyUseThemeColor == propertyUseThemeColor) { if (this.propertyUseThemeColor == propertyUseThemeColor) {
return; return;

View File

@ -20,11 +20,13 @@ import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.AlignMode; import org.atriasoft.ewol.compositing.AlignMode;
import org.atriasoft.ewol.compositing.CompositingText; import org.atriasoft.ewol.compositing.CompositingText;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Label extends Widget { public class Label extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Label.class);
@AknotSignal @AknotSignal
@AknotName("pressed") @AknotName("pressed")
@AknotDescription("Label is pressed") @AknotDescription("Label is pressed")
@ -33,16 +35,16 @@ public class Label extends Widget {
private int propertyFontSize = 0; //!< default size of the font. private int propertyFontSize = 0; //!< default size of the font.
private final CompositingText textCompose = new CompositingText(); //!< Compositing text element. private final CompositingText textCompose = new CompositingText(); //!< Compositing text element.
private String value = ""; private String value = "";
protected int colorDefaultBgText = -1; //!< Default Background color of the text protected int colorDefaultBgText = -1; //!< Default Background color of the text
protected int colorDefaultFgText = -1; //!< Default color of the text protected int colorDefaultFgText = -1; //!< Default color of the text
protected ResourceColorFile colorProperty; //!< theme color property protected ResourceColorFile colorProperty; //!< theme color property
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate. protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
public Label() { public Label() {
this("---"); this("---");
} }
public Label(final String label) { public Label(final String label) {
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol")); this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
if (this.colorProperty != null) { if (this.colorProperty != null) {
@ -53,10 +55,10 @@ public class Label extends Widget {
setPropertyCanFocus(false); setPropertyCanFocus(false);
setPropertyValue(label); setPropertyValue(label);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
Log.verbose("calculateMinMaxSize !!! data = '{}'", this.value); LOGGER.trace("calculateMinMaxSize !!! data = '{}'", this.value);
final Vector3f tmpMax = this.propertyMaxSize.getPixel(); final Vector3f tmpMax = this.propertyMaxSize.getPixel();
final Vector3f tmpMin = this.propertyMinSize.getPixel(); final Vector3f tmpMin = this.propertyMinSize.getPixel();
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} tmpMax : " + tmpMax); //EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} tmpMax : " + tmpMax);
@ -70,33 +72,33 @@ public class Label extends Widget {
this.textCompose.flush(); this.textCompose.flush();
minSize = minSize.add(2, 2, 0); minSize = minSize.add(2, 2, 0);
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize); //EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize);
this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), // this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), //
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), // FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), //
10); 10);
Log.verbose("[{}] Result min size : {}", getId(), this.minSize); LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
} }
public int getPropertyFontSize() { public int getPropertyFontSize() {
return this.propertyFontSize; return this.propertyFontSize;
} }
public String getPropertyValue() { public String getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
public boolean isPropertyAutoTranslate() { public boolean isPropertyAutoTranslate() {
return this.propertyAutoTranslate; return this.propertyAutoTranslate;
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.textCompose.draw(); this.textCompose.draw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
//Log.debug("Event on Label ..."); //LOGGER.debug("Event on Label ...");
if (event.inputId() == 1) { if (event.inputId() == 1) {
if (KeyStatus.pressSingle == event.status()) { if (KeyStatus.pressSingle == event.status()) {
// nothing to do ... // nothing to do ...
@ -106,7 +108,7 @@ public class Label extends Widget {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
@ -115,25 +117,26 @@ public class Label extends Widget {
this.textCompose.clear(); this.textCompose.clear();
//final int paddingSize = 2; //final int paddingSize = 2;
final Padding padding = new Padding(2, 2, 2, 2); final Padding padding = new Padding(2, 2, 2, 2);
final Vector3f tmpMax = this.propertyMaxSize.getPixel(); final Vector3f tmpMax = this.propertyMaxSize.getPixel();
// to know the size of one line : // to know the size of one line :
final Vector3f minSize = this.textCompose.calculateSize('A'); final Vector3f minSize = this.textCompose.calculateSize('A');
//minSize.setX(etk::max(minSize.x(), this.minSize.x())); //minSize.setX(etk::max(minSize.x(), this.minSize.x()));
//minSize.setY(etk::max(minSize.y(), this.minSize.y())); //minSize.setY(etk::max(minSize.y(), this.minSize.y()));
if (tmpMax.x() <= 999999) { if (tmpMax.x() <= 999999) {
this.textCompose.setTextAlignment(0, tmpMax.x() - padding.x(), AlignMode.LEFT); this.textCompose.setTextAlignment(0, tmpMax.x() - padding.x(), AlignMode.LEFT);
} }
final Vector3f curentTextSize = this.textCompose.calculateSizeDecorated(this.value); final Vector3f curentTextSize = this.textCompose.calculateSizeDecorated(this.value);
//Vector3f localSize = this.minSize.clipInteger(); //Vector3f localSize = this.minSize.clipInteger();
Vector3f tmpSizeShaper = this.minSize; Vector3f tmpSizeShaper = this.minSize;
// no change for the text origin : // no change for the text origin :
Vector3f tmpTextOrigin = new Vector3f((this.size.x() - minSize.x()) * 0.5f, (this.size.y() - minSize.y()) * 0.5f, 0); Vector3f tmpTextOrigin = new Vector3f((this.size.x() - minSize.x()) * 0.5f,
(this.size.y() - minSize.y()) * 0.5f, 0);
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize)); Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
tmpSizeShaper = tmpSizeShaper.withX(this.size.x()); tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
delta = delta.withX(0.0f); delta = delta.withX(0.0f);
@ -150,19 +153,21 @@ public class Label extends Widget {
} }
final Vector3f tmpOriginShaper = delta; final Vector3f tmpOriginShaper = delta;
final Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z()); final Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
tmpTextOrigin = tmpOriginShaper;//tmpTextOrigin.add(paddingSize, paddingSize, 0); tmpTextOrigin = tmpOriginShaper;//tmpTextOrigin.add(paddingSize, paddingSize, 0);
//localSize = localSize.less(2 * paddingSize, 2 * paddingSize, 0); //localSize = localSize.less(2 * paddingSize, 2 * paddingSize, 0);
//tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y()); //tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + this.minSize.y() - this.textCompose.getHeight() - padding.top());// - this.minSize.y() - paddingSize); tmpTextOrigin = tmpTextOrigin
.withY(tmpTextOrigin.y() + this.minSize.y() - this.textCompose.getHeight() - padding.top());// - this.minSize.y() - paddingSize);
tmpTextOrigin = tmpTextOrigin.withX(tmpTextOrigin.x() + padding.left()); tmpTextOrigin = tmpTextOrigin.withX(tmpTextOrigin.x() + padding.left());
final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0); final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0);
final Vector3f drawClippingPos = tmpOriginShaper.less(new Vector3f(padding.left(), padding.bottom(), padding.back())); final Vector3f drawClippingPos = tmpOriginShaper
.less(new Vector3f(padding.left(), padding.bottom(), padding.back()));
final Vector3f drawClippingSize = tmpOriginShaper.add(tmpSizeShaper); /// new Vector3f((this.size.x() - paddingSize), (this.size.y() - paddingSize), 1); final Vector3f drawClippingSize = tmpOriginShaper.add(tmpSizeShaper); /// new Vector3f((this.size.x() - paddingSize), (this.size.y() - paddingSize), 1);
// clean the element // clean the element
this.textCompose.reset(); this.textCompose.reset();
if (this.propertyFontSize != 0) { if (this.propertyFontSize != 0) {
@ -173,13 +178,13 @@ public class Label extends Widget {
this.textCompose.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText)); this.textCompose.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText));
} }
this.textCompose.setPos(tmpTextOrigin); this.textCompose.setPos(tmpTextOrigin);
Log.verbose("[{}] '{}' display at pos={}, size={}", getId(), this.value, tmpTextOrigin, this.size); LOGGER.trace("[{}] '{}' display at pos={}, size={}", getId(), this.value, tmpTextOrigin, this.size);
this.textCompose.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + tmpSizeText.x(), AlignMode.LEFT); this.textCompose.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + tmpSizeText.x(), AlignMode.LEFT);
this.textCompose.setClipping(drawClippingPos, drawClippingSize); this.textCompose.setClipping(drawClippingPos, drawClippingSize);
this.textCompose.printDecorated(this.value); this.textCompose.printDecorated(this.value);
this.textCompose.flush(); this.textCompose.flush();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "auto-translate") @AknotName(value = "auto-translate")
@ -197,7 +202,7 @@ public class Label extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "font-size") @AknotName(value = "font-size")
@ -210,7 +215,7 @@ public class Label extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@AknotManaged @AknotManaged
@AknotText @AknotText
@AknotName(value = "value") @AknotName(value = "value")
@ -228,5 +233,5 @@ public class Label extends Widget {
requestUpdateSize(); requestUpdateSize();
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
} }
} }

View File

@ -19,16 +19,18 @@ import org.atriasoft.etranslate.ETranslate;
import org.atriasoft.ewol.compositing.AlignMode; import org.atriasoft.ewol.compositing.AlignMode;
import org.atriasoft.ewol.compositing.CompositingText; import org.atriasoft.ewol.compositing.CompositingText;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LabelOnSVG extends Widget { public class LabelOnSVG extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelOnSVG.class);
protected int colorDefaultBgText = -1; //!< Default Background color of the text protected int colorDefaultBgText = -1; //!< Default Background color of the text
protected int colorDefaultFgText = -1; //!< Default color of the text protected int colorDefaultFgText = -1; //!< Default color of the text
protected ResourceColorFile colorProperty; //!< theme color property protected ResourceColorFile colorProperty; //!< theme color property
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate. protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
protected int propertyFontSize = 0; //!< default size of the font. protected int propertyFontSize = 0; //!< default size of the font.
protected String propertyValue = ""; //!< decorated text to display. protected String propertyValue = ""; //!< decorated text to display.
@AknotSignal @AknotSignal
@ -37,7 +39,7 @@ public class LabelOnSVG extends Widget {
public SignalEmpty signalPressed = new SignalEmpty(); public SignalEmpty signalPressed = new SignalEmpty();
protected CompositingText text = new CompositingText(); //!< Compositing text element. protected CompositingText text = new CompositingText(); //!< Compositing text element.
protected String value = ""; protected String value = "";
public LabelOnSVG() { public LabelOnSVG() {
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol")); this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
if (this.colorProperty != null) { if (this.colorProperty != null) {
@ -47,7 +49,7 @@ public class LabelOnSVG extends Widget {
setMouseLimit(1); setMouseLimit(1);
setPropertyCanFocus(false); setPropertyCanFocus(false);
} }
/** /**
* Constructor * Constructor
* @param newLabel The displayed decorated text. * @param newLabel The displayed decorated text.
@ -62,43 +64,45 @@ public class LabelOnSVG extends Widget {
setPropertyCanFocus(false); setPropertyCanFocus(false);
setPropertyValue(newLabel); setPropertyValue(newLabel);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
final Vector3f tmpMax = this.propertyMaxSize.getPixel(); final Vector3f tmpMax = this.propertyMaxSize.getPixel();
final Vector3f tmpMin = this.propertyMinSize.getPixel(); final Vector3f tmpMin = this.propertyMinSize.getPixel();
Log.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} tmpMax : " + tmpMax); LOGGER.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} tmpMax : " + tmpMax);
if (tmpMax.x() <= 999999) { if (tmpMax.x() <= 999999) {
this.text.setTextAlignment(0, tmpMax.x() - 4, AlignMode.LEFT); this.text.setTextAlignment(0, tmpMax.x() - 4, AlignMode.LEFT);
Log.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} force Alignement "); LOGGER.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} force Alignement ");
} }
final Vector3f minSize = this.text.calculateSizeDecorated(this.value); final Vector3f minSize = this.text.calculateSizeDecorated(this.value);
Log.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} minSize : " + minSize); LOGGER.debug("[" + getId() + "] {" + getClass().getCanonicalName() + "} minSize : " + minSize);
this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), FMath.avg(tmpMin.z(), 4 + minSize.z(), tmpMax.z())); this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()),
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < " + this.minSize + " < " + tmpMax); FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), FMath.avg(tmpMin.z(), 4 + minSize.z(), tmpMax.z()));
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < "
+ this.minSize + " < " + tmpMax);
} }
public int getPropertyFontSize() { public int getPropertyFontSize() {
return this.propertyFontSize; return this.propertyFontSize;
} }
public String getPropertyValue() { public String getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
public boolean isPropertyAutoTranslate() { public boolean isPropertyAutoTranslate() {
return this.propertyAutoTranslate; return this.propertyAutoTranslate;
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.text.draw(); this.text.draw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
//Log.debug("Event on Label ..."); //LOGGER.debug("Event on Label ...");
if (event.inputId() == 1) { if (event.inputId() == 1) {
if (KeyStatus.pressSingle == event.status()) { if (KeyStatus.pressSingle == event.status()) {
// nothing to do ... // nothing to do ...
@ -108,7 +112,7 @@ public class LabelOnSVG extends Widget {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
@ -116,23 +120,24 @@ public class LabelOnSVG extends Widget {
} }
this.text.clear(); this.text.clear();
final int paddingSize = 2; final int paddingSize = 2;
final Vector3f tmpMax = this.propertyMaxSize.getPixel(); final Vector3f tmpMax = this.propertyMaxSize.getPixel();
// to know the size of one line : // to know the size of one line :
final Vector3f minSize = this.text.calculateSize('A'); final Vector3f minSize = this.text.calculateSize('A');
//minSize.setX(etk::max(minSize.x(), this.minSize.x())); //minSize.setX(etk::max(minSize.x(), this.minSize.x()));
//minSize.setY(etk::max(minSize.y(), this.minSize.y())); //minSize.setY(etk::max(minSize.y(), this.minSize.y()));
if (tmpMax.x() <= 999999) { if (tmpMax.x() <= 999999) {
this.text.setTextAlignment(0, tmpMax.x() - 2 * paddingSize, AlignMode.LEFT); this.text.setTextAlignment(0, tmpMax.x() - 2 * paddingSize, AlignMode.LEFT);
} }
final Vector3f currentTextSize = this.text.calculateSizeDecorated(this.value); final Vector3f currentTextSize = this.text.calculateSizeDecorated(this.value);
Vector2i localSize = new Vector2i((int) this.minSize.x(), (int) this.minSize.y()); Vector2i localSize = new Vector2i((int) this.minSize.x(), (int) this.minSize.y());
// no change for the text origin : // no change for the text origin :
Vector3f tmpTextOrigin = new Vector3f((this.size.x() - this.minSize.x()) / 2.0f, (this.size.y() - this.minSize.y()) / 2.0f, 0); Vector3f tmpTextOrigin = new Vector3f((this.size.x() - this.minSize.x()) / 2.0f,
(this.size.y() - this.minSize.y()) / 2.0f, 0);
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
localSize = localSize.withX((int) this.size.x()); localSize = localSize.withX((int) this.size.x());
tmpTextOrigin = tmpTextOrigin.withX(0); tmpTextOrigin = tmpTextOrigin.withX(0);
@ -143,14 +148,14 @@ public class LabelOnSVG extends Widget {
} }
tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize, 0); tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize, 0);
localSize = localSize.less(2 * paddingSize, 2 * paddingSize); localSize = localSize.less(2 * paddingSize, 2 * paddingSize);
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y()); tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0); final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0);
final Vector3f drawClippingPos = new Vector3f(paddingSize, paddingSize, -0.5f); final Vector3f drawClippingPos = new Vector3f(paddingSize, paddingSize, -0.5f);
final Vector3f drawClippingSize = new Vector3f((this.size.x() - paddingSize), (this.size.y() - paddingSize), 1); final Vector3f drawClippingSize = new Vector3f((this.size.x() - paddingSize), (this.size.y() - paddingSize), 1);
// clean the element // clean the element
this.text.reset(); this.text.reset();
if (this.propertyFontSize != 0) { if (this.propertyFontSize != 0) {
@ -161,14 +166,14 @@ public class LabelOnSVG extends Widget {
this.text.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText)); this.text.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText));
} }
this.text.setPos(tmpTextOrigin); this.text.setPos(tmpTextOrigin);
Log.verbose("[" + getId() + "] {" + this.value + "} display at pos : " + tmpTextOrigin); LOGGER.trace("[" + getId() + "] {" + this.value + "} display at pos : " + tmpTextOrigin);
this.text.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT); this.text.setTextAlignment(tmpTextOrigin.x(), tmpTextOrigin.x() + localSize.x(), AlignMode.LEFT);
this.text.setClipping(drawClippingPos, drawClippingSize); this.text.setClipping(drawClippingPos, drawClippingSize);
this.text.printDecorated(this.value); this.text.printDecorated(this.value);
this.text.flush(); this.text.flush();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("auto-translate") @AknotName("auto-translate")
@ -186,7 +191,7 @@ public class LabelOnSVG extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("font-size") @AknotName("font-size")
@ -199,7 +204,7 @@ public class LabelOnSVG extends Widget {
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -217,5 +222,5 @@ public class LabelOnSVG extends Widget {
requestUpdateSize(); requestUpdateSize();
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
} }
} }

View File

@ -29,30 +29,32 @@ import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.math.Vector3i; import org.atriasoft.etk.math.Vector3i;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.ewol.widget.model.ListRole; import org.atriasoft.ewol.widget.model.ListRole;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Generic display folder class. This widget display the content of a single folder : * Generic display folder class. This widget display the content of a single folder :
*/ */
public class ListFileSystem extends WidgetList { public class ListFileSystem extends WidgetList {
private static final Logger LOGGER = LoggerFactory.getLogger(ListFileSystem.class);
@AknotSignal @AknotSignal
@AknotName(value = "file-select") @AknotName(value = "file-select")
@AknotDescription(value = "A file has been selected in the List") @AknotDescription(value = "A file has been selected in the List")
public Signal<String> signalFileSelect = new Signal<>(); //!< @event "file-select" Generated when a file is selected. public Signal<String> signalFileSelect = new Signal<>(); //!< @event "file-select" Generated when a file is selected.
@AknotSignal @AknotSignal
@AknotName(value = "file-validate") @AknotName(value = "file-validate")
@AknotDescription(value = "A file has been validated on the list (double clicked or return pressed)") @AknotDescription(value = "A file has been validated on the list (double clicked or return pressed)")
public Signal<String> signalFileValidate = new Signal<>(); //!< @event "file-validate" Generate when the user validate (return) or double click on the element public Signal<String> signalFileValidate = new Signal<>(); //!< @event "file-validate" Generate when the user validate (return) or double click on the element
@AknotSignal @AknotSignal
@AknotName(value = "folder-select") @AknotName(value = "folder-select")
@AknotDescription(value = "A folder has been selected in the List") @AknotDescription(value = "A folder has been selected in the List")
public Signal<String> signalFolderSelect = new Signal<>(); public Signal<String> signalFolderSelect = new Signal<>();
@AknotSignal @AknotSignal
@AknotName(value = "folder-validate") @AknotName(value = "folder-validate")
@AknotDescription(value = "A folder has been validated on the list (double clicked or return pressed)") @AknotDescription(value = "A folder has been validated on the list (double clicked or return pressed)")
@ -63,7 +65,7 @@ public class ListFileSystem extends WidgetList {
protected boolean propertyShowFolder = true; //!< Display the folders elements protected boolean propertyShowFolder = true; //!< Display the folders elements
protected boolean propertyShowHidden = true; //!< Display hidden elements protected boolean propertyShowHidden = true; //!< Display hidden elements
protected String propertyFilter = "^.*$"; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e") protected String propertyFilter = "^.*$"; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e")
protected ResourceColorFile colorProperty; //!< theme color property. protected ResourceColorFile colorProperty; //!< theme color property.
protected int colorIdText = -1; //!< Color of the text. protected int colorIdText = -1; //!< Color of the text.
protected int colorIdBackground1 = -1; //!< Color of the Background. protected int colorIdBackground1 = -1; //!< Color of the Background.
@ -71,9 +73,9 @@ public class ListFileSystem extends WidgetList {
protected int colorIdBackgroundSelected = -1; //!< Color of line selected. protected int colorIdBackgroundSelected = -1; //!< Color of line selected.
protected List<File> list = new ArrayList<>(); //!< List of all element in the File. (they are filtered) protected List<File> list = new ArrayList<>(); //!< List of all element in the File. (they are filtered)
protected int selectedLine; //!< Current Line ID that is selected protected int selectedLine; //!< Current Line ID that is selected
public ListFileSystem() { public ListFileSystem() {
this.colorProperty = new ResourceColorFile(new Uri("THEME", "/color/ListFileSystem.json", "ewol")); this.colorProperty = new ResourceColorFile(new Uri("THEME", "/color/ListFileSystem.json", "ewol"));
if (this.colorProperty != null) { if (this.colorProperty != null) {
this.colorIdText = this.colorProperty.request("text"); this.colorIdText = this.colorProperty.request("text");
@ -83,19 +85,19 @@ public class ListFileSystem extends WidgetList {
} }
setMouseLimit(2); setMouseLimit(2);
} }
/** /**
* Clean the list of element. * Clean the list of element.
*/ */
protected void clearList() { protected void clearList() {
this.list.clear(); this.list.clear();
} }
@Override @Override
protected Color getBasicBG() { protected Color getBasicBG() {
return this.colorProperty.get(this.colorIdBackground1); return this.colorProperty.get(this.colorIdBackground1);
} }
@Override @Override
protected Object getData(final ListRole role, final Vector2i pos) { protected Object getData(final ListRole role, final Vector2i pos) {
switch (role) { switch (role) {
@ -114,7 +116,8 @@ public class ListFileSystem extends WidgetList {
} }
} }
if (pos.y() - offset >= 0 && pos.y() - offset < this.list.size()) { if (pos.y() - offset >= 0 && pos.y() - offset < this.list.size()) {
Log.verbose("get filename for : {}:'{}'", this.list.get(pos.y() - offset), this.list.get(pos.y() - offset).getName()); LOGGER.trace("get filename for : {}:'{}'", this.list.get(pos.y() - offset),
this.list.get(pos.y() - offset).getName());
return this.list.get(pos.y() - offset).getName(); return this.list.get(pos.y() - offset).getName();
} }
} }
@ -134,7 +137,7 @@ public class ListFileSystem extends WidgetList {
} }
return null; return null;
} }
@Override @Override
protected Vector2i getMatrixSize() { protected Vector2i getMatrixSize() {
int offset = 0; int offset = 0;
@ -147,7 +150,7 @@ public class ListFileSystem extends WidgetList {
} }
return new Vector2i(1, this.list.size() + offset); return new Vector2i(1, this.list.size() + offset);
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "select") @AknotName(value = "select")
@ -155,7 +158,7 @@ public class ListFileSystem extends WidgetList {
public File getPropertyFile() { public File getPropertyFile() {
return this.propertyFile; return this.propertyFile;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "filter") @AknotName(value = "filter")
@ -163,7 +166,7 @@ public class ListFileSystem extends WidgetList {
public String getPropertyFilter() { public String getPropertyFilter() {
return this.propertyFilter; return this.propertyFilter;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "Path") @AknotName(value = "Path")
@ -171,7 +174,7 @@ public class ListFileSystem extends WidgetList {
public String getPropertyPath() { public String getPropertyPath() {
return this.propertyPath; return this.propertyPath;
} }
/** /**
* Get the current selected file/folder/... in the list * Get the current selected file/folder/... in the list
* @return the String of the element selected. * @return the String of the element selected.
@ -182,7 +185,7 @@ public class ListFileSystem extends WidgetList {
} }
return null; return null;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "show-file") @AknotName(value = "show-file")
@ -190,7 +193,7 @@ public class ListFileSystem extends WidgetList {
public boolean isPropertyShowFile() { public boolean isPropertyShowFile() {
return this.propertyShowFile; return this.propertyShowFile;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "show-folder") @AknotName(value = "show-folder")
@ -198,7 +201,7 @@ public class ListFileSystem extends WidgetList {
public boolean isPropertyShowFolder() { public boolean isPropertyShowFolder() {
return this.propertyShowFolder; return this.propertyShowFolder;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "show-hidden") @AknotName(value = "show-hidden")
@ -206,8 +209,12 @@ public class ListFileSystem extends WidgetList {
public boolean isPropertyShowHidden() { public boolean isPropertyShowHidden() {
return this.propertyShowHidden; return this.propertyShowHidden;
} }
public List<File> listSelectedFiles(final String dir, final boolean showFiles, final boolean showFolder, final boolean showHidden) throws IOException { public List<File> listSelectedFiles(
final String dir,
final boolean showFiles,
final boolean showFolder,
final boolean showHidden) throws IOException {
final List<File> fileList = new ArrayList<>(); final List<File> fileList = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dir))) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dir))) {
for (final Path path : stream) { for (final Path path : stream) {
@ -215,18 +222,18 @@ public class ListFileSystem extends WidgetList {
continue; continue;
} }
if (Files.isDirectory(path) && showFolder) { if (Files.isDirectory(path) && showFolder) {
Log.error("Add Directory '{}'", path); LOGGER.error("Add Directory '{}'", path);
fileList.add(new File(path.toString())); fileList.add(new File(path.toString()));
} }
if (!Files.isDirectory(path) && showFiles) { if (!Files.isDirectory(path) && showFiles) {
Log.error("Add File '{}'", path); LOGGER.error("Add File '{}'", path);
fileList.add(new File(path.toString())); fileList.add(new File(path.toString()));
} }
} }
} }
return fileList; return fileList;
} }
@Override @Override
protected boolean onItemEvent(final EventInput event, final Vector3i pos, final Vector3f mousePosition) { protected boolean onItemEvent(final EventInput event, final Vector3i pos, final Vector3f mousePosition) {
int offset = 0; int offset = 0;
@ -238,7 +245,7 @@ public class ListFileSystem extends WidgetList {
} }
} }
if (event.status() == KeyStatus.pressSingle || event.status() == KeyStatus.pressDouble) { if (event.status() == KeyStatus.pressSingle || event.status() == KeyStatus.pressDouble) {
Log.verbose("Event on List : IdInput=" + event.inputId() + " _pos=" + pos); LOGGER.trace("Event on List : IdInput=" + event.inputId() + " _pos=" + pos);
if (1 == event.inputId()) { if (1 == event.inputId()) {
if (pos.y() > this.list.size() + offset) { if (pos.y() > this.list.size() + offset) {
this.selectedLine = -1; this.selectedLine = -1;
@ -267,12 +274,10 @@ public class ListFileSystem extends WidgetList {
} else { } else {
this.signalFolderValidate.emit(this.list.get(this.selectedLine - offset).getPath()); this.signalFolderValidate.emit(this.list.get(this.selectedLine - offset).getPath());
} }
} else if (event.status() == KeyStatus.pressSingle) {
this.signalFileSelect.emit(this.list.get(this.selectedLine - offset).getPath());
} else { } else {
if (event.status() == KeyStatus.pressSingle) { this.signalFileValidate.emit(this.list.get(this.selectedLine - offset).getPath());
this.signalFileSelect.emit(this.list.get(this.selectedLine - offset).getPath());
} else {
this.signalFileValidate.emit(this.list.get(this.selectedLine - offset).getPath());
}
} }
} }
// need to regenerate the display of the list : // need to regenerate the display of the list :
@ -282,7 +287,7 @@ public class ListFileSystem extends WidgetList {
} }
return false; return false;
} }
/** /**
* Regenerate the content of the view. this is actually not automation on the system update. * Regenerate the content of the view. this is actually not automation on the system update.
*/ */
@ -293,7 +298,8 @@ public class ListFileSystem extends WidgetList {
this.originScrooled = new Vector2f(0, 0); this.originScrooled = new Vector2f(0, 0);
final int flags = 0; final int flags = 0;
try { try {
this.list = listSelectedFiles(this.propertyPath, this.propertyShowFile, this.propertyShowFolder, this.propertyShowHidden); this.list = listSelectedFiles(this.propertyPath, this.propertyShowFile, this.propertyShowFolder,
this.propertyShowHidden);
} catch (final IOException e) { } catch (final IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -303,7 +309,7 @@ public class ListFileSystem extends WidgetList {
// request a redraw ... // request a redraw ...
markToRedraw(); markToRedraw();
} }
public void setPropertyFile(final File propertyFile) { public void setPropertyFile(final File propertyFile) {
if (this.propertyFile.equals(propertyFile)) { if (this.propertyFile.equals(propertyFile)) {
return; return;
@ -311,7 +317,7 @@ public class ListFileSystem extends WidgetList {
this.propertyFile = propertyFile; this.propertyFile = propertyFile;
regenerateView(); regenerateView();
} }
public void setPropertyFilter(final String propertyFilter) { public void setPropertyFilter(final String propertyFilter) {
if (!this.propertyFilter.equals(propertyFilter)) { if (!this.propertyFilter.equals(propertyFilter)) {
return; return;
@ -319,7 +325,7 @@ public class ListFileSystem extends WidgetList {
this.propertyFilter = propertyFilter; this.propertyFilter = propertyFilter;
regenerateView(); regenerateView();
} }
public void setPropertyPath(final String propertyPath) { public void setPropertyPath(final String propertyPath) {
if (this.propertyPath.equals(propertyPath)) { if (this.propertyPath.equals(propertyPath)) {
return; return;
@ -327,7 +333,7 @@ public class ListFileSystem extends WidgetList {
this.propertyPath = propertyPath; this.propertyPath = propertyPath;
regenerateView(); regenerateView();
} }
public void setPropertyShowFile(final boolean propertyShowFile) { public void setPropertyShowFile(final boolean propertyShowFile) {
if (this.propertyShowFile == propertyShowFile) { if (this.propertyShowFile == propertyShowFile) {
return; return;
@ -335,7 +341,7 @@ public class ListFileSystem extends WidgetList {
this.propertyShowFile = propertyShowFile; this.propertyShowFile = propertyShowFile;
regenerateView(); regenerateView();
} }
public void setPropertyShowFolder(final boolean propertyShowFolder) { public void setPropertyShowFolder(final boolean propertyShowFolder) {
if (this.propertyShowFolder == propertyShowFolder) { if (this.propertyShowFolder == propertyShowFolder) {
return; return;
@ -343,7 +349,7 @@ public class ListFileSystem extends WidgetList {
this.propertyShowFolder = propertyShowFolder; this.propertyShowFolder = propertyShowFolder;
regenerateView(); regenerateView();
} }
public void setPropertyShowHidden(final boolean propertyShowHidden) { public void setPropertyShowHidden(final boolean propertyShowHidden) {
if (this.propertyShowHidden == propertyShowHidden) { if (this.propertyShowHidden == propertyShowHidden) {
return; return;
@ -351,7 +357,7 @@ public class ListFileSystem extends WidgetList {
this.propertyShowHidden = propertyShowHidden; this.propertyShowHidden = propertyShowHidden;
regenerateView(); regenerateView();
} }
/** /**
* Select a specific file in the File * Select a specific file in the File
* @param data File to selected. * @param data File to selected.

View File

@ -20,29 +20,31 @@ import org.atriasoft.ewol.HighSpeedMode;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape; import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType; import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class Scroll extends Container { class Scroll extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Scroll.class);
protected static final int SCROLL_BAR_SPACE = 15; protected static final int SCROLL_BAR_SPACE = 15;
protected Vector3f propertyLimit = new Vector3f(0.15f, 0.5f, 0.0f); //!< Set the limitation of the ratio in the screen protected Vector3f propertyLimit = new Vector3f(0.15f, 0.5f, 0.0f); //!< Set the limitation of the ratio in the screen
protected Uri propertyShapeVert = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Vertical shaper name protected Uri propertyShapeVert = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Vertical shaper name
protected Uri propertyShapeHori = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Horizontal shaper name protected Uri propertyShapeHori = new Uri("THEME_GUI", "WidgetScrolled.json", "ewol"); //!< Horizontal shaper name
protected boolean propertyHover = true; //!< Horizontal shaper name protected boolean propertyHover = true; //!< Horizontal shaper name
protected GuiShape shaperH; //!< Compositing theme Horizontal. protected GuiShape shaperH; //!< Compositing theme Horizontal.
protected GuiShape shaperV; //!< Compositing theme Vertical. protected GuiShape shaperV; //!< Compositing theme Vertical.
protected float pixelScrolling = 20; protected float pixelScrolling = 20;
protected Vector3f highSpeedStartPos = Vector3f.ZERO; protected Vector3f highSpeedStartPos = Vector3f.ZERO;
protected HighSpeedMode highSpeedMode = HighSpeedMode.speedModeDisable; protected HighSpeedMode highSpeedMode = HighSpeedMode.speedModeDisable;
protected int highSpeedButton = -1; protected int highSpeedButton = -1;
protected KeyType highSpeedType = KeyType.unknow; protected KeyType highSpeedType = KeyType.unknow;
public Scroll() { public Scroll() {
/* /*
// Remove gravity property: (only keep top/buttom) // Remove gravity property: (only keep top/buttom)
@ -59,7 +61,7 @@ class Scroll extends Container {
onChangePropertyShapeVert(); onChangePropertyShapeVert();
onChangePropertyShapeHori(); onChangePropertyShapeHori();
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// Note: No call of container ==> normal case ... // Note: No call of container ==> normal case ...
@ -69,7 +71,7 @@ class Scroll extends Container {
this.subWidget.calculateMinMaxSize(); this.subWidget.calculateMinMaxSize();
} }
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "limit") @AknotName(value = "limit")
@ -77,7 +79,7 @@ class Scroll extends Container {
public Vector3f getPropertyLimit() { public Vector3f getPropertyLimit() {
return this.propertyLimit; return this.propertyLimit;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "shape-hori") @AknotName(value = "shape-hori")
@ -85,7 +87,7 @@ class Scroll extends Container {
public Uri getPropertyShapeHori() { public Uri getPropertyShapeHori() {
return this.propertyShapeHori; return this.propertyShapeHori;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "shape-vert") @AknotName(value = "shape-vert")
@ -93,7 +95,7 @@ class Scroll extends Container {
public Uri getPropertyShapeVert() { public Uri getPropertyShapeVert() {
return this.propertyShapeVert; return this.propertyShapeVert;
} }
@Override @Override
public Widget getWidgetAtPos(final Vector3f pos) { public Widget getWidgetAtPos(final Vector3f pos) {
final Widget tmpWidget = super.getWidgetAtPos(pos); final Widget tmpWidget = super.getWidgetAtPos(pos);
@ -102,7 +104,7 @@ class Scroll extends Container {
} }
return this; return this;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "hover") @AknotName(value = "hover")
@ -110,21 +112,21 @@ class Scroll extends Container {
public boolean isPropertyHover() { public boolean isPropertyHover() {
return this.propertyHover; return this.propertyHover;
} }
void onChangePropertyLimit() { void onChangePropertyLimit() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyShapeHori() { protected void onChangePropertyShapeHori() {
this.shaperH.setSource(this.propertyShapeHori); this.shaperH.setSource(this.propertyShapeHori);
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyShapeVert() { protected void onChangePropertyShapeVert() {
this.shaperV.setSource(this.propertyShapeVert); this.shaperV.setSource(this.propertyShapeVert);
markToRedraw(); markToRedraw();
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
// Note: No call of container ==> normal case ... // Note: No call of container ==> normal case ...
@ -140,7 +142,7 @@ class Scroll extends Container {
if (!this.propertyHover) { if (!this.propertyHover) {
basicSize = basicSize.less(SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, SCROLL_BAR_SPACE); basicSize = basicSize.less(SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, SCROLL_BAR_SPACE);
} }
Vector3f origin = this.origin.add(this.offset); Vector3f origin = this.origin.add(this.offset);
Vector3f minSize = this.subWidget.getCalculateMinSize(); Vector3f minSize = this.subWidget.getCalculateMinSize();
final Vector3b expand = this.subWidget.propertyExpand; final Vector3b expand = this.subWidget.propertyExpand;
@ -161,18 +163,18 @@ class Scroll extends Container {
} else if (this.propertyGravity.y() == GravityVertical.BOTTOM) { } else if (this.propertyGravity.y() == GravityVertical.BOTTOM) {
// nothing to do ... origin += // nothing to do ... origin +=
} else { } else {
Log.error(" Not manage other gravity ..."); LOGGER.error(" Not manage other gravity ...");
} }
this.subWidget.setOrigin(origin); this.subWidget.setOrigin(origin);
this.subWidget.onChangeSize(); this.subWidget.onChangeSize();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.shaperH.draw(); this.shaperH.draw();
this.shaperV.draw(); this.shaperV.draw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
//ewol::event::Input _event = event; //ewol::event::Input _event = event;
@ -184,9 +186,10 @@ class Scroll extends Container {
scrollOffset = this.subWidget.getOffset(); scrollOffset = this.subWidget.getOffset();
scrollSize = this.subWidget.getSize(); scrollSize = this.subWidget.getSize();
} }
Log.verbose("Get Event on scroll : " + event); LOGGER.trace("Get Event on scroll : " + event);
relativePos = relativePos.withY(this.size.y() - relativePos.y()); relativePos = relativePos.withY(this.size.y() - relativePos.y());
if (event.type() == KeyType.mouse && (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.mouse)) { if (event.type() == KeyType.mouse
&& (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.mouse)) {
if (event.inputId() == 1 && event.status() == KeyStatus.down) { if (event.inputId() == 1 && event.status() == KeyStatus.down) {
// check if selected the scrolling position whth the scrolling bar ... // check if selected the scrolling position whth the scrolling bar ...
if (relativePos.x() >= (this.size.x() - SCROLL_BAR_SPACE)) { if (relativePos.x() >= (this.size.x() - SCROLL_BAR_SPACE)) {
@ -194,11 +197,14 @@ class Scroll extends Container {
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical; this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
this.highSpeedType = KeyType.mouse; this.highSpeedType = KeyType.mouse;
this.highSpeedStartPos = this.highSpeedStartPos.withX(relativePos.x()); this.highSpeedStartPos = this.highSpeedStartPos.withX(relativePos.x());
this.highSpeedStartPos = this.highSpeedStartPos.withY(scrollOffset.y() / scrollSize.y() * (this.size.y() - SCROLL_BAR_SPACE * 2)); this.highSpeedStartPos = this.highSpeedStartPos
.withY(scrollOffset.y() / scrollSize.y() * (this.size.y() - SCROLL_BAR_SPACE * 2));
this.highSpeedButton = 1; this.highSpeedButton = 1;
// force direct scrolling in this case // force direct scrolling in this case
scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE) / (this.size.y() - SCROLL_BAR_SPACE * 2))); scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE)
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y()))); / (this.size.y() - SCROLL_BAR_SPACE * 2)));
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(),
(scrollSize.y() - this.size.y() * this.propertyLimit.y())));
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -209,12 +215,15 @@ class Scroll extends Container {
if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) { if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal; this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
this.highSpeedType = KeyType.mouse; this.highSpeedType = KeyType.mouse;
this.highSpeedStartPos = this.highSpeedStartPos.withX(scrollOffset.x() / scrollSize.x() * (this.size.x() - SCROLL_BAR_SPACE * 2)); this.highSpeedStartPos = this.highSpeedStartPos
.withX(scrollOffset.x() / scrollSize.x() * (this.size.x() - SCROLL_BAR_SPACE * 2));
this.highSpeedStartPos = this.highSpeedStartPos.withY(relativePos.y()); this.highSpeedStartPos = this.highSpeedStartPos.withY(relativePos.y());
this.highSpeedButton = 1; this.highSpeedButton = 1;
// force direct scrolling in this case // force direct scrolling in this case
scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE) / (this.size.x() - SCROLL_BAR_SPACE * 2))); scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE)
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x()))); / (this.size.x() - SCROLL_BAR_SPACE * 2)));
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.x(),
(scrollSize.x() - this.size.x() * this.propertyLimit.x())));
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -224,10 +233,11 @@ class Scroll extends Container {
} }
return false; return false;
} else if (event.inputId() == 4 && event.status() == KeyStatus.up) { } else if (event.inputId() == 4 && event.status() == KeyStatus.up) {
Log.verbose(" mode UP " + this.size.y() + "<" + scrollSize.y()); LOGGER.trace(" mode UP " + this.size.y() + "<" + scrollSize.y());
if (this.size.y() < scrollSize.y()) { if (this.size.y() < scrollSize.y()) {
scrollOffset = scrollOffset.withY(scrollOffset.y() - this.pixelScrolling); scrollOffset = scrollOffset.withY(scrollOffset.y() - this.pixelScrolling);
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y()))); scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(),
(scrollSize.y() - this.size.y() * this.propertyLimit.y())));
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -235,10 +245,11 @@ class Scroll extends Container {
return true; return true;
} }
} else if (event.inputId() == 5 && event.status() == KeyStatus.up) { } else if (event.inputId() == 5 && event.status() == KeyStatus.up) {
Log.verbose(" mode DOWN " + this.size.y() + "<" + scrollSize.y()); LOGGER.trace(" mode DOWN " + this.size.y() + "<" + scrollSize.y());
if (this.size.y() < scrollSize.y()) { if (this.size.y() < scrollSize.y()) {
scrollOffset = scrollOffset.withY(scrollOffset.y() + this.pixelScrolling); scrollOffset = scrollOffset.withY(scrollOffset.y() + this.pixelScrolling);
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y()))); scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(),
(scrollSize.y() - this.size.y() * this.propertyLimit.y())));
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -282,7 +293,8 @@ class Scroll extends Container {
return true; return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) { } else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
// wait that the cursor move more than 10 px to enable it : // wait that the cursor move more than 10 px to enable it :
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) { if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|| FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrooling can start : // the scrooling can start :
// select the direction : // select the direction :
if (relativePos.x() == this.highSpeedStartPos.x()) { if (relativePos.x() == this.highSpeedStartPos.x()) {
@ -290,7 +302,8 @@ class Scroll extends Container {
} else if (relativePos.y() == this.highSpeedStartPos.y()) { } else if (relativePos.y() == this.highSpeedStartPos.y()) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal; this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} else { } else {
final float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x()); final float coef = (relativePos.y() - this.highSpeedStartPos.y())
/ (relativePos.x() - this.highSpeedStartPos.x());
if (FMath.abs(coef) <= 1) { if (FMath.abs(coef) <= 1) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal; this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} else { } else {
@ -298,21 +311,26 @@ class Scroll extends Container {
} }
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal) {
this.highSpeedStartPos = this.highSpeedStartPos.withX(scrollOffset.x() / scrollSize.x() * (this.size.x() - SCROLL_BAR_SPACE * 2)); this.highSpeedStartPos = this.highSpeedStartPos
.withX(scrollOffset.x() / scrollSize.x() * (this.size.x() - SCROLL_BAR_SPACE * 2));
} else { } else {
this.highSpeedStartPos = this.highSpeedStartPos.withY(scrollOffset.y() / scrollSize.y() * (this.size.y() - SCROLL_BAR_SPACE * 2)); this.highSpeedStartPos = this.highSpeedStartPos
.withY(scrollOffset.y() / scrollSize.y() * (this.size.y() - SCROLL_BAR_SPACE * 2));
} }
markToRedraw(); markToRedraw();
} }
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y()))); scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(),
(scrollSize.y() - this.size.y() * this.propertyLimit.y())));
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
} }
return true; return true;
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal && event.status() == KeyStatus.move) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal && event.status() == KeyStatus.move) {
scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE) / (this.size.x() - SCROLL_BAR_SPACE * 2))); scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE)
scrollOffset = scrollOffset.withX(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x()))); / (this.size.x() - SCROLL_BAR_SPACE * 2)));
scrollOffset = scrollOffset.withX(FMath.avg(0.0f, scrollOffset.x(),
(scrollSize.x() - this.size.x() * this.propertyLimit.x())));
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -320,8 +338,10 @@ class Scroll extends Container {
return true; return true;
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical && event.status() == KeyStatus.move) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical && event.status() == KeyStatus.move) {
scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE) / (this.size.y() - SCROLL_BAR_SPACE * 2))); scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE)
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.x()))); / (this.size.y() - SCROLL_BAR_SPACE * 2)));
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(),
(scrollSize.y() - this.size.y() * this.propertyLimit.x())));
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -329,46 +349,54 @@ class Scroll extends Container {
return true; return true;
} }
} }
} else if (KeyType.finger == event.type() && (KeyType.unknow == this.highSpeedType || KeyType.finger == this.highSpeedType)) { } else if (KeyType.finger == event.type()
&& (KeyType.unknow == this.highSpeedType || KeyType.finger == this.highSpeedType)) {
if (1 == event.inputId()) { if (1 == event.inputId()) {
Log.verbose("event: " + event); LOGGER.trace("event: " + event);
if (KeyStatus.down == event.status()) { if (KeyStatus.down == event.status()) {
this.highSpeedMode = HighSpeedMode.speedModeInit; this.highSpeedMode = HighSpeedMode.speedModeInit;
this.highSpeedType = KeyType.finger; this.highSpeedType = KeyType.finger;
this.highSpeedStartPos = new Vector3f(relativePos.x(), relativePos.y(), 0); this.highSpeedStartPos = new Vector3f(relativePos.x(), relativePos.y(), 0);
Log.verbose("SCROOL == > INIT pos=" + this.highSpeedStartPos + " && curent scrollOffset=" + scrollOffset); LOGGER.trace("SCROOL == > INIT pos=" + this.highSpeedStartPos + " && curent scrollOffset="
+ scrollOffset);
return true; return true;
} else if (KeyStatus.upAfter == event.status()) { } else if (KeyStatus.upAfter == event.status()) {
this.highSpeedMode = HighSpeedMode.speedModeDisable; this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow; this.highSpeedType = KeyType.unknow;
Log.verbose("SCROOL == > DISABLE"); LOGGER.trace("SCROOL == > DISABLE");
markToRedraw(); markToRedraw();
return true; return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && KeyStatus.move == event.status()) { } else if (this.highSpeedMode == HighSpeedMode.speedModeInit && KeyStatus.move == event.status()) {
// wait that the cursor move more than 10 px to enable it : // wait that the cursor move more than 10 px to enable it :
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) { if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|| FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrooling can start : // the scrooling can start :
// select the direction : // select the direction :
this.highSpeedMode = HighSpeedMode.speedModeEnableFinger; this.highSpeedMode = HighSpeedMode.speedModeEnableFinger;
Log.verbose("SCROOL == > ENABLE"); LOGGER.trace("SCROOL == > ENABLE");
markToRedraw(); markToRedraw();
} }
return true; return true;
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && KeyStatus.move == event.status()) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && KeyStatus.move == event.status()) {
Log.verbose("SCROOL == > INIT scrollOffset=" + scrollOffset.y() + " relativePos=" + relativePos.y() + " this.highSpeedStartPos=" + this.highSpeedStartPos.y()); LOGGER.trace("SCROOL == > INIT scrollOffset=" + scrollOffset.y() + " relativePos="
+ relativePos.y() + " this.highSpeedStartPos=" + this.highSpeedStartPos.y());
//scrollOffset.x = (int)(scrollSize.x * x / this.size.x); //scrollOffset.x = (int)(scrollSize.x * x / this.size.x);
if (this.propertyLimit.x() != 0.0f) { if (this.propertyLimit.x() != 0.0f) {
scrollOffset = scrollOffset.withX(scrollOffset.x() + (relativePos.x() - this.highSpeedStartPos.x())); scrollOffset = scrollOffset
scrollOffset = scrollOffset.withX(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x()))); .withX(scrollOffset.x() + (relativePos.x() - this.highSpeedStartPos.x()));
scrollOffset = scrollOffset.withX(FMath.avg(0.0f, scrollOffset.x(),
(scrollSize.x() - this.size.x() * this.propertyLimit.x())));
} }
if (this.propertyLimit.y() != 0.0f) { if (this.propertyLimit.y() != 0.0f) {
scrollOffset = scrollOffset.withY(scrollOffset.y() - (relativePos.y() - this.highSpeedStartPos.y())); scrollOffset = scrollOffset
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y()))); .withY(scrollOffset.y() - (relativePos.y() - this.highSpeedStartPos.y()));
scrollOffset = scrollOffset.withY(FMath.avg(0.0f, scrollOffset.y(),
(scrollSize.y() - this.size.y() * this.propertyLimit.y())));
} }
// update current position: // update current position:
this.highSpeedStartPos = relativePos; this.highSpeedStartPos = relativePos;
Log.verbose("SCROOL == > MOVE " + scrollOffset); LOGGER.trace("SCROOL == > MOVE " + scrollOffset);
markToRedraw(); markToRedraw();
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset); this.subWidget.setOffset(scrollOffset);
@ -381,14 +409,14 @@ class Scroll extends Container {
} else if (this.highSpeedMode != HighSpeedMode.speedModeDisable && KeyStatus.leave == event.status()) { } else if (this.highSpeedMode != HighSpeedMode.speedModeDisable && KeyStatus.leave == event.status()) {
this.highSpeedMode = HighSpeedMode.speedModeDisable; this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow; this.highSpeedType = KeyType.unknow;
Log.verbose("SCROOL == > DISABLE"); LOGGER.trace("SCROOL == > DISABLE");
markToRedraw(); markToRedraw();
return true; return true;
} }
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (this.propertyHide) { if (this.propertyHide) {
@ -416,26 +444,30 @@ class Scroll extends Container {
float originScrollBar = scrollOffset.y() / (scrollSize.y() - this.size.y() * this.propertyLimit.y()); float originScrollBar = scrollOffset.y() / (scrollSize.y() - this.size.y() * this.propertyLimit.y());
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f); originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
originScrollBar *= (this.size.y() - lenScrollBar); originScrollBar *= (this.size.y() - lenScrollBar);
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0), new Vector2f(paddingVert.x(), this.size.y()), this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0),
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar), new Vector2f(0, lenScrollBar)); new Vector2f(paddingVert.x(), this.size.y()),
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar),
new Vector2f(0, lenScrollBar));
} }
if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) { if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) {
float lenScrollBar = (this.size.x() - paddingHori.left()) * (this.size.x() - paddingVert.x()) / scrollSize.x(); float lenScrollBar = (this.size.x() - paddingHori.left()) * (this.size.x() - paddingVert.x())
/ scrollSize.x();
lenScrollBar = FMath.avg(10.0f, lenScrollBar, (this.size.x() - paddingVert.x())); lenScrollBar = FMath.avg(10.0f, lenScrollBar, (this.size.x() - paddingVert.x()));
float originScrollBar = scrollOffset.x() / (scrollSize.x() - this.size.x() * this.propertyLimit.x()); float originScrollBar = scrollOffset.x() / (scrollSize.x() - this.size.x() * this.propertyLimit.x());
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f); originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar); originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar);
this.shaperH.setShape(Vector2f.ZERO, new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()), new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0)); this.shaperH.setShape(Vector2f.ZERO, new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()),
new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0));
} }
} }
public void setPropertyHover(final boolean propertyHover) { public void setPropertyHover(final boolean propertyHover) {
if (propertyHover == this.propertyHover) { if (propertyHover == this.propertyHover) {
return; return;
} }
this.propertyHover = propertyHover; this.propertyHover = propertyHover;
} }
public void setPropertyLimit(final Vector3f propertyLimit) { public void setPropertyLimit(final Vector3f propertyLimit) {
final Vector3f tmp = Vector3f.avg(Vector3f.ZERO, propertyLimit, Vector3f.ONE); final Vector3f tmp = Vector3f.avg(Vector3f.ZERO, propertyLimit, Vector3f.ONE);
if (tmp.equals(this.propertyLimit)) { if (tmp.equals(this.propertyLimit)) {
@ -444,7 +476,7 @@ class Scroll extends Container {
this.propertyLimit = propertyLimit; this.propertyLimit = propertyLimit;
onChangePropertyLimit(); onChangePropertyLimit();
} }
public void setPropertyShapeHori(final Uri value) { public void setPropertyShapeHori(final Uri value) {
if (this.propertyShapeHori.equals(value)) { if (this.propertyShapeHori.equals(value)) {
return; return;
@ -452,7 +484,7 @@ class Scroll extends Container {
this.propertyShapeHori = value; this.propertyShapeHori = value;
onChangePropertyShapeHori(); onChangePropertyShapeHori();
} }
public void setPropertyShapeVert(final Uri value) { public void setPropertyShapeVert(final Uri value) {
if (this.propertyShapeVert.equals(value)) { if (this.propertyShapeVert.equals(value)) {
return; return;
@ -460,7 +492,7 @@ class Scroll extends Container {
this.propertyShapeVert = value; this.propertyShapeVert = value;
onChangePropertyShapeVert(); onChangePropertyShapeVert();
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) { if (this.propertyHide) {

View File

@ -15,25 +15,28 @@ import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector3b; import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.etk.math.Vector3i; import org.atriasoft.etk.math.Vector3i;
import org.atriasoft.ewol.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Sizer extends ContainerN { public class Sizer extends ContainerN {
private static final Logger LOGGER = LoggerFactory.getLogger(Sizer.class);
@AknotCaseSensitive(value = false) @AknotCaseSensitive(value = false)
public enum DisplayMode { public enum DisplayMode {
HORIZONTAL, //!< Horizontal mode HORIZONTAL, //!< Horizontal mode
VERTICAL; //!< Vertical mode VERTICAL; //!< Vertical mode
} }
protected Dimension3f propertyBorderSize = Dimension3f.ZERO; //!< Border size needed for all the display protected Dimension3f propertyBorderSize = Dimension3f.ZERO; //!< Border size needed for all the display
protected DisplayMode propertyMode = DisplayMode.HORIZONTAL; //!< Method to display the widget list (vert/hory ...) protected DisplayMode propertyMode = DisplayMode.HORIZONTAL; //!< Method to display the widget list (vert/hory ...)
/** /**
* Constructor * Constructor
*/ */
public Sizer() { public Sizer() {
} }
/** /**
* Constructor * Constructor
* @param mode The mode to display the elements * @param mode The mode to display the elements
@ -41,14 +44,14 @@ public class Sizer extends ContainerN {
public Sizer(final DisplayMode mode) { public Sizer(final DisplayMode mode) {
this.propertyMode = mode; this.propertyMode = mode;
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
Log.verbose("[" + getId() + "] update minimum size"); LOGGER.trace("[" + getId() + "] update minimum size");
this.subExpend = Vector3b.FALSE; this.subExpend = Vector3b.FALSE;
this.minSize = this.propertyMinSize.getPixel(); this.minSize = this.propertyMinSize.getPixel();
final Vector3f tmpBorderSize = this.propertyBorderSize.getPixel(); final Vector3f tmpBorderSize = this.propertyBorderSize.getPixel();
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} set min size : " + this.minSize); LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} set min size : " + this.minSize);
for (final Widget it : this.subWidget) { for (final Widget it : this.subWidget) {
if (it == null) { if (it == null) {
continue; continue;
@ -61,8 +64,8 @@ public class Sizer extends ContainerN {
this.subExpend = this.subExpend.withY(true); this.subExpend = this.subExpend.withY(true);
} }
final Vector3f tmpSize = it.getCalculateMinSize(); final Vector3f tmpSize = it.getCalculateMinSize();
Log.verbose("[" + getId() + "] NewMinSize=" + tmpSize); LOGGER.trace("[" + getId() + "] NewMinSize=" + tmpSize);
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} Get minSize=" + tmpSize); LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Get minSize=" + tmpSize);
if (this.propertyMode == DisplayMode.VERTICAL) { if (this.propertyMode == DisplayMode.VERTICAL) {
this.minSize = this.minSize.withY(this.minSize.y() + tmpSize.y()); this.minSize = this.minSize.withY(this.minSize.y() + tmpSize.y());
if (tmpSize.x() > this.minSize.x()) { if (tmpSize.x() > this.minSize.x()) {
@ -76,9 +79,9 @@ public class Sizer extends ContainerN {
} }
} }
this.minSize = this.minSize.add(tmpBorderSize.multiply(2)); this.minSize = this.minSize.add(tmpBorderSize.multiply(2));
Log.verbose("[{}] Result min size : {}", getId(), this.minSize); LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("border") @AknotName("border")
@ -86,7 +89,7 @@ public class Sizer extends ContainerN {
public Dimension3f getPropertyBorderSize() { public Dimension3f getPropertyBorderSize() {
return this.propertyBorderSize; return this.propertyBorderSize;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("mode") @AknotName("mode")
@ -94,12 +97,13 @@ public class Sizer extends ContainerN {
public DisplayMode getPropertyMode() { public DisplayMode getPropertyMode() {
return this.propertyMode; return this.propertyMode;
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
super.onChangeSize(); super.onChangeSize();
final Vector3f tmpBorderSize = this.propertyBorderSize.getPixel(); final Vector3f tmpBorderSize = this.propertyBorderSize.getPixel();
Log.verbose("[" + getId() + "] update size : " + this.size + " nbElement : " + this.subWidget.size() + " borderSize=" + tmpBorderSize + " from border=" + this.propertyBorderSize); LOGGER.trace("[" + getId() + "] update size : " + this.size + " nbElement : " + this.subWidget.size()
+ " borderSize=" + tmpBorderSize + " from border=" + this.propertyBorderSize);
final Vector3f localWidgetSize = this.size.less(tmpBorderSize.multiply(2.0f)); final Vector3f localWidgetSize = this.size.less(tmpBorderSize.multiply(2.0f));
// -1- calculate min-size and expand requested: // -1- calculate min-size and expand requested:
Vector3f minSize = Vector3f.ZERO; Vector3f minSize = Vector3f.ZERO;
@ -110,9 +114,11 @@ public class Sizer extends ContainerN {
} }
final Vector3f tmpSize = it.getCalculateMinSize(); final Vector3f tmpSize = it.getCalculateMinSize();
if (this.propertyMode == DisplayMode.VERTICAL) { if (this.propertyMode == DisplayMode.VERTICAL) {
minSize = new Vector3f(Math.max(minSize.x(), tmpSize.x()), minSize.y() + tmpSize.y(), Math.max(minSize.z(), tmpSize.z())); minSize = new Vector3f(Math.max(minSize.x(), tmpSize.x()), minSize.y() + tmpSize.y(),
Math.max(minSize.z(), tmpSize.z()));
} else { } else {
minSize = new Vector3f(minSize.x() + tmpSize.x(), Math.max(minSize.y(), tmpSize.y()), Math.max(minSize.z(), tmpSize.z())); minSize = new Vector3f(minSize.x() + tmpSize.x(), Math.max(minSize.y(), tmpSize.y()),
Math.max(minSize.z(), tmpSize.z()));
} }
final Vector3b expand = it.canExpand(); final Vector3b expand = it.canExpand();
nbWidgetExpand = nbWidgetExpand.add(expand.x() ? 1 : 0, expand.y() ? 1 : 0, 0); nbWidgetExpand = nbWidgetExpand.add(expand.x() ? 1 : 0, expand.y() ? 1 : 0, 0);
@ -209,14 +215,16 @@ public class Sizer extends ContainerN {
continue; continue;
} }
Vector3f tmpSizeMin = it.getSize(); Vector3f tmpSizeMin = it.getSize();
tmpSizeMin = tmpSizeMin.withX(FMath.avg(tmpSizeMin.x(), localWidgetSize.x(), it.getCalculateMaxSize().x())); tmpSizeMin = tmpSizeMin
.withX(FMath.avg(tmpSizeMin.x(), localWidgetSize.x(), it.getCalculateMaxSize().x()));
it.setSize(tmpSizeMin); it.setSize(tmpSizeMin);
} else { } else {
if (!it.canExpand().y() && !it.canExpandIfFree().y()) { if (!it.canExpand().y() && !it.canExpandIfFree().y()) {
continue; continue;
} }
Vector3f tmpSizeMin = it.getSize(); Vector3f tmpSizeMin = it.getSize();
tmpSizeMin = tmpSizeMin.withY(FMath.avg(tmpSizeMin.y(), localWidgetSize.y(), it.getCalculateMaxSize().y())); tmpSizeMin = tmpSizeMin
.withY(FMath.avg(tmpSizeMin.y(), localWidgetSize.y(), it.getCalculateMaxSize().y()));
it.setSize(tmpSizeMin); it.setSize(tmpSizeMin);
} }
} }
@ -235,13 +243,15 @@ public class Sizer extends ContainerN {
} }
final Vector3f size = it.getSize(); final Vector3f size = it.getSize();
if (this.propertyMode == DisplayMode.VERTICAL) { if (this.propertyMode == DisplayMode.VERTICAL) {
underSize = new Vector3f(Math.max(underSize.x(), size.x()), underSize.y() + size.y(), Math.max(underSize.z(), size.z())); underSize = new Vector3f(Math.max(underSize.x(), size.x()), underSize.y() + size.y(),
Math.max(underSize.z(), size.z()));
} else { } else {
underSize = new Vector3f(underSize.x() + size.x(), Math.max(underSize.y(), size.y()), Math.max(underSize.z(), size.z())); underSize = new Vector3f(underSize.x() + size.x(), Math.max(underSize.y(), size.y()),
Math.max(underSize.z(), size.z()));
} }
} }
final Vector3f deltas = localWidgetSize.less(underSize); final Vector3f deltas = localWidgetSize.less(underSize);
// -8- Calculate the local origin, depending of the gravity: // -8- Calculate the local origin, depending of the gravity:
Vector3f tmpOrigin = this.origin.add(tmpBorderSize).add(this.propertyGravity.gravityGenerateDelta(deltas)); Vector3f tmpOrigin = this.origin.add(tmpBorderSize).add(this.propertyGravity.gravityGenerateDelta(deltas));
// -9- Set sub widget origin: // -9- Set sub widget origin:
@ -252,9 +262,11 @@ public class Sizer extends ContainerN {
Vector3f origin; Vector3f origin;
final Vector3f size = it.getSize(); final Vector3f size = it.getSize();
if (this.propertyMode == DisplayMode.VERTICAL) { if (this.propertyMode == DisplayMode.VERTICAL) {
origin = Vector3f.clipInt(tmpOrigin.add(this.offset).add(this.propertyGravity.gravityGenerateDelta(new Vector3f(underSize.x() - size.x(), 0.0f, 0.0f)))); origin = Vector3f.clipInt(tmpOrigin.add(this.offset).add(
this.propertyGravity.gravityGenerateDelta(new Vector3f(underSize.x() - size.x(), 0.0f, 0.0f))));
} else { } else {
origin = Vector3f.clipInt(tmpOrigin.add(this.offset).add(this.propertyGravity.gravityGenerateDelta(new Vector3f(0.0f, underSize.y() - size.y(), 0.0f)))); origin = Vector3f.clipInt(tmpOrigin.add(this.offset).add(
this.propertyGravity.gravityGenerateDelta(new Vector3f(0.0f, underSize.y() - size.y(), 0.0f))));
} }
it.setOrigin(origin); it.setOrigin(origin);
if (this.propertyMode == DisplayMode.VERTICAL) { if (this.propertyMode == DisplayMode.VERTICAL) {
@ -272,14 +284,14 @@ public class Sizer extends ContainerN {
} }
markToRedraw(); markToRedraw();
} }
public void setPropertyBorderSize(final Dimension3f propertyBorderSize) { public void setPropertyBorderSize(final Dimension3f propertyBorderSize) {
if (this.propertyBorderSize.equals(propertyBorderSize)) { if (this.propertyBorderSize.equals(propertyBorderSize)) {
return; return;
} }
this.propertyBorderSize = propertyBorderSize; this.propertyBorderSize = propertyBorderSize;
} }
public void setPropertyMode(final DisplayMode propertyMode) { public void setPropertyMode(final DisplayMode propertyMode) {
if (this.propertyMode.equals(propertyMode)) { if (this.propertyMode.equals(propertyMode)) {
return; return;

View File

@ -15,8 +15,9 @@ import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.compositing.GuiShape; import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -28,9 +29,10 @@ import org.atriasoft.gale.key.KeyStatus;
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
public class Slider extends Widget { public class Slider extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Slider.class);
private Uri propertyConfig = new Uri("THEME", "shape/Slider.json", "ewol"); private Uri propertyConfig = new Uri("THEME", "shape/Slider.json", "ewol");
private Float propertyValue = 0.0f; //!< string that must be displayed private Float propertyValue = 0.0f; //!< string that must be displayed
private GuiShape shape = null; private GuiShape shape = null;
private final GuiShape shapeTop = null; private final GuiShape shapeTop = null;
@ -43,20 +45,20 @@ public class Slider extends Widget {
Vector3f overPositionStop = Vector3f.ZERO; Vector3f overPositionStop = Vector3f.ZERO;
Vector3f overCursorPositionStart = Vector3f.ZERO; Vector3f overCursorPositionStart = Vector3f.ZERO;
Vector3f overCursorPositionStop = Vector3f.ZERO; Vector3f overCursorPositionStop = Vector3f.ZERO;
//@AknotAutoGenerateProperty("minimum", "configuration of the widget") //@AknotAutoGenerateProperty("minimum", "configuration of the widget")
private Float propertyMinimum = 0.0f; private Float propertyMinimum = 0.0f;
private Float propertyMaximum = 10.0f; private Float propertyMaximum = 10.0f;
private Float propertyStep = 0.1f; private Float propertyStep = 0.1f;
private final Color textColorFg = Color.BLACK; //!< Text color private final Color textColorFg = Color.BLACK; //!< Text color
private final Color textColorBg = Color.BLACK.withA(0x3F); //!< Background color private final Color textColorBg = Color.BLACK.withA(0x3F); //!< Background color
CompositingDrawing draw = new CompositingDrawing(); //!< drawing tool. CompositingDrawing draw = new CompositingDrawing(); //!< drawing tool.
public Slider() { public Slider() {
this.propertyCanFocus = true; this.propertyCanFocus = true;
onChangePropertyShaper(); onChangePropertyShaper();
@ -64,7 +66,7 @@ public class Slider extends Widget {
// Limit event at 1: // Limit event at 1:
setMouseLimit(1); setMouseLimit(1);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -75,21 +77,22 @@ public class Slider extends Widget {
padding = this.shape.getPadding(); padding = this.shape.getPadding();
} }
final Vector3i minHeight = Vector3i.VALUE_16; final Vector3i minHeight = Vector3i.VALUE_16;
Vector3f minimumSizeBase = new Vector3f(minHeight.x(), minHeight.y(), minHeight.z()); Vector3f minimumSizeBase = new Vector3f(minHeight.x(), minHeight.y(), minHeight.z());
// add padding : // add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z()); minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z());
this.minSize = Vector3f.max(this.minSize, minimumSizeBase); this.minSize = Vector3f.max(this.minSize, minimumSizeBase);
// verify the min max of the min size ... // verify the min max of the min size ...
checkMinSize(); checkMinSize();
Log.error("min size = " + this.minSize); LOGGER.error("min size = " + this.minSize);
} }
private boolean checkIfOver(final Vector3f relPos) { private boolean checkIfOver(final Vector3f relPos) {
return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y()
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("config") @AknotName("config")
@ -97,7 +100,7 @@ public class Slider extends Widget {
public Uri getPropertyConfig() { public Uri getPropertyConfig() {
return this.propertyConfig; return this.propertyConfig;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("maximum") @AknotName("maximum")
@ -105,7 +108,7 @@ public class Slider extends Widget {
public Float getPropertyMaximum() { public Float getPropertyMaximum() {
return this.propertyMaximum; return this.propertyMaximum;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("minimum") @AknotName("minimum")
@ -113,7 +116,7 @@ public class Slider extends Widget {
public Float getPropertyMinimum() { public Float getPropertyMinimum() {
return this.propertyMinimum; return this.propertyMinimum;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("step") @AknotName("step")
@ -121,7 +124,7 @@ public class Slider extends Widget {
public Float getPropertyStep() { public Float getPropertyStep() {
return this.propertyStep; return this.propertyStep;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -129,7 +132,7 @@ public class Slider extends Widget {
public Float getPropertyValue() { public Float getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
protected void onChangePropertyShaper() { protected void onChangePropertyShaper() {
if (this.shape == null) { if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig); this.shape = new GuiShape(this.propertyConfig);
@ -137,7 +140,7 @@ public class Slider extends Widget {
this.shape.setSource(this.propertyConfig); this.shape.setSource(this.propertyConfig);
} }
} }
@Override @Override
public void onDraw() { public void onDraw() {
if (this.shape != null) { if (this.shape != null) {
@ -146,14 +149,14 @@ public class Slider extends Widget {
// draw slider // draw slider
this.shape.draw(true, 1); this.shape.draw(true, 1);
} }
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector3f positionAbsolute = new Vector3f(event.pos().x(), event.pos().y(), 0); final Vector3f positionAbsolute = new Vector3f(event.pos().x(), event.pos().y(), 0);
final Vector3f relPos = relativePosition(positionAbsolute); final Vector3f relPos = relativePosition(positionAbsolute);
Log.warning("Event on Input ... " + event + " relPos = " + relPos); LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = checkIfOver(relPos); final boolean over = checkIfOver(relPos);
if (event.inputId() != 1) { if (event.inputId() != 1) {
return false; return false;
@ -161,7 +164,8 @@ public class Slider extends Widget {
if (KeyStatus.pressSingle == event.status() && over) { if (KeyStatus.pressSingle == event.status() && over) {
keepFocus(); keepFocus();
// get percent value // get percent value
final float pourcent = (relPos.x() - this.overPositionStart.x()) / (this.overPositionStop.x() - this.overPositionStart.x()); final float pourcent = (relPos.x() - this.overPositionStart.x())
/ (this.overPositionStop.x() - this.overPositionStart.x());
float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum; float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum;
if (this.propertyStep != 0.0f) { if (this.propertyStep != 0.0f) {
value += this.propertyStep * 0.5f; value += this.propertyStep * 0.5f;
@ -172,7 +176,8 @@ public class Slider extends Widget {
if (KeyStatus.down == event.status() && over) { if (KeyStatus.down == event.status() && over) {
keepFocus(); keepFocus();
// get percent value // get percent value
final float pourcent = (relPos.x() - this.overPositionStart.x()) / (this.overPositionStop.x() - this.overPositionStart.x()); final float pourcent = (relPos.x() - this.overPositionStart.x())
/ (this.overPositionStop.x() - this.overPositionStart.x());
float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum; float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum;
if (this.propertyStep != 0.0f) { if (this.propertyStep != 0.0f) {
value += this.propertyStep * 0.5f; value += this.propertyStep * 0.5f;
@ -183,7 +188,8 @@ public class Slider extends Widget {
if (KeyStatus.move == event.status() && over) { if (KeyStatus.move == event.status() && over) {
keepFocus(); keepFocus();
// get percent value // get percent value
final float pourcent = (relPos.x() - this.overPositionStart.x()) / (this.overPositionStop.x() - this.overPositionStart.x()); final float pourcent = (relPos.x() - this.overPositionStart.x())
/ (this.overPositionStop.x() - this.overPositionStart.x());
float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum; float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum;
if (this.propertyStep != 0.0f) { if (this.propertyStep != 0.0f) {
value += this.propertyStep * 0.5f; value += this.propertyStep * 0.5f;
@ -194,7 +200,8 @@ public class Slider extends Widget {
if (KeyStatus.up == event.status() && over) { if (KeyStatus.up == event.status() && over) {
keepFocus(); keepFocus();
// get percent value // get percent value
final float pourcent = (relPos.x() - this.overPositionStart.x()) / (this.overPositionStop.x() - this.overPositionStart.x()); final float pourcent = (relPos.x() - this.overPositionStart.x())
/ (this.overPositionStop.x() - this.overPositionStart.x());
float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum; float value = (this.propertyMaximum - this.propertyMinimum) * pourcent + this.propertyMinimum;
if (this.propertyStep != 0.0f) { if (this.propertyStep != 0.0f) {
value += this.propertyStep * 0.5f; value += this.propertyStep * 0.5f;
@ -204,13 +211,13 @@ public class Slider extends Widget {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
//return; //return;
} }
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'"); //LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear(); this.shape.clear();
//this.gc.clear(); //this.gc.clear();
/* /*
@ -234,7 +241,7 @@ public class Slider extends Widget {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y()); tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
delta = delta.withY(0.0f); delta = delta.withY(0.0f);
} }
Vector3f tmpOriginShaper = delta; Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z()); Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f); //Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
@ -245,7 +252,7 @@ public class Slider extends Widget {
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper); tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeInside = Vector3f.clipInt(tmpSizeInside); tmpSizeInside = Vector3f.clipInt(tmpSizeInside);
tmpOriginInside = Vector3f.clipInt(tmpOriginInside); tmpOriginInside = Vector3f.clipInt(tmpOriginInside);
this.overPositionStart = tmpOriginShaper; this.overPositionStart = tmpOriginShaper;
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper); this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
this.shape.setShape(0, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside); this.shape.setShape(0, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
@ -258,31 +265,32 @@ public class Slider extends Widget {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y()); tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
delta = delta.withY(0.0f); delta = delta.withY(0.0f);
} }
Vector3f tmpOriginShaper = delta; Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z()); Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f); //Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
Vector3f tmpOriginInside = Vector3f.ZERO; Vector3f tmpOriginInside = Vector3f.ZERO;
final float xxx = tmpOriginShaper.x() * 2.0f; final float xxx = tmpOriginShaper.x() * 2.0f;
tmpOriginShaper = tmpOriginShaper.withX(xxx * (this.propertyValue - this.propertyMinimum) / (this.propertyMaximum - this.propertyMinimum)); tmpOriginShaper = tmpOriginShaper.withX(
xxx * (this.propertyValue - this.propertyMinimum) / (this.propertyMaximum - this.propertyMinimum));
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ... // sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
// fix all the position in the int class: // fix all the position in the int class:
tmpSizeShaper = Vector3f.clipInt(tmpSizeShaper); tmpSizeShaper = Vector3f.clipInt(tmpSizeShaper);
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper); tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeInside = Vector3f.clipInt(tmpSizeInside); tmpSizeInside = Vector3f.clipInt(tmpSizeInside);
tmpOriginInside = Vector3f.clipInt(tmpOriginInside); tmpOriginInside = Vector3f.clipInt(tmpOriginInside);
this.overCursorPositionStart = tmpOriginShaper; this.overCursorPositionStart = tmpOriginShaper;
this.overCursorPositionStop = tmpOriginShaper.add(tmpSizeShaper); this.overCursorPositionStop = tmpOriginShaper.add(tmpSizeShaper);
this.shape.setShape(1, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside); this.shape.setShape(1, tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
} }
//this.gc.flush(); //this.gc.flush();
this.shape.flush(); this.shape.flush();
} }
public void setPropertyConfig(final Uri propertyConfig) { public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) { if (this.propertyConfig.equals(propertyConfig)) {
return; return;
@ -290,7 +298,7 @@ public class Slider extends Widget {
this.propertyConfig = propertyConfig; this.propertyConfig = propertyConfig;
onChangePropertyShaper(); onChangePropertyShaper();
} }
public void setPropertyMaximum(final Float propertyMaximum) { public void setPropertyMaximum(final Float propertyMaximum) {
if (this.propertyMaximum == propertyMaximum) { if (this.propertyMaximum == propertyMaximum) {
return; return;
@ -299,7 +307,7 @@ public class Slider extends Widget {
updateValue(this.propertyValue); updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
} }
public void setPropertyMinimum(final Float propertyMinimum) { public void setPropertyMinimum(final Float propertyMinimum) {
if (this.propertyMinimum == propertyMinimum) { if (this.propertyMinimum == propertyMinimum) {
return; return;
@ -308,7 +316,7 @@ public class Slider extends Widget {
updateValue(this.propertyValue); updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
} }
public void setPropertyStep(final Float propertyStep) { public void setPropertyStep(final Float propertyStep) {
if (this.propertyStep == propertyStep) { if (this.propertyStep == propertyStep) {
return; return;
@ -317,7 +325,7 @@ public class Slider extends Widget {
updateValue(this.propertyValue); updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
} }
public void setPropertyValue(final Float propertyValue) { public void setPropertyValue(final Float propertyValue) {
if (this.propertyValue == propertyValue) { if (this.propertyValue == propertyValue) {
return; return;
@ -326,7 +334,7 @@ public class Slider extends Widget {
updateValue(this.propertyValue); updateValue(this.propertyValue);
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
} }
protected void updateValue(float newValue) { protected void updateValue(float newValue) {
newValue = FMath.max(FMath.min(newValue, this.propertyMaximum), this.propertyMinimum); newValue = FMath.max(FMath.min(newValue, this.propertyMaximum), this.propertyMinimum);
if (this.propertyStep == 0.0f) { if (this.propertyStep == 0.0f) {

View File

@ -9,14 +9,16 @@ import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.Signal; import org.atriasoft.esignal.Signal;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath; import org.atriasoft.etk.math.FMath;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.meta.SpinBase; import org.atriasoft.ewol.widget.meta.SpinBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* a composed Spin is a Spin with an inside composed with the specify XML element * a composed Spin is a Spin with an inside composed with the specify XML element
* ==> this permit to generate standard element simple * ==> this permit to generate standard element simple
*/ */
public class Spin extends SpinBase { public class Spin extends SpinBase {
private static final Logger LOGGER = LoggerFactory.getLogger(Spin.class);
// Event list of properties // Event list of properties
@AknotSignal @AknotSignal
@AknotName("value") @AknotName("value")
@ -35,7 +37,7 @@ public class Spin extends SpinBase {
protected Connection connectionEntry = new Connection(); protected Connection connectionEntry = new Connection();
protected Connection connectionButtonUp = new Connection(); protected Connection connectionButtonUp = new Connection();
protected Connection connectionButtonDown = new Connection(); protected Connection connectionButtonDown = new Connection();
/** /**
* Constructor * Constructor
* @param _mode mode to display the spin * @param _mode mode to display the spin
@ -45,16 +47,16 @@ public class Spin extends SpinBase {
super(new Uri("THEME", "shape/Spin.json", "ewol")); super(new Uri("THEME", "shape/Spin.json", "ewol"));
connectGui(); connectGui();
} }
public void checkValue(long value) { public void checkValue(long value) {
value = FMath.clamp(this.propertyMin, value, this.propertyMax); value = FMath.clamp(this.propertyMin, value, this.propertyMax);
this.propertyValue = value; this.propertyValue = value;
this.widgetEntry.setPropertyValue(Long.toString(value)); this.widgetEntry.setPropertyValue(Long.toString(value));
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
} }
public void connectGui() { public void connectGui() {
Log.warning("updateGui [START]"); LOGGER.warn("updateGui [START]");
super.updateGui(); super.updateGui();
if (this.widgetEntry != null && !this.connectionEntry.isConnected()) { if (this.widgetEntry != null && !this.connectionEntry.isConnected()) {
this.connectionEntry = this.widgetEntry.signalModify.connect(this, Spin::onCallbackModify); this.connectionEntry = this.widgetEntry.signalModify.connect(this, Spin::onCallbackModify);
@ -66,9 +68,9 @@ public class Spin extends SpinBase {
this.connectionButtonDown = this.widgetButtonDown.signalValue.connect(this, Spin::onCallbackDown); this.connectionButtonDown = this.widgetButtonDown.signalValue.connect(this, Spin::onCallbackDown);
} }
checkValue(this.propertyValue); checkValue(this.propertyValue);
Log.warning("updateGui [STOP]"); LOGGER.warn("updateGui [STOP]");
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("increment") @AknotName("increment")
@ -76,7 +78,7 @@ public class Spin extends SpinBase {
public long getPropertyIncrement() { public long getPropertyIncrement() {
return this.propertyIncrement; return this.propertyIncrement;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("mantis") @AknotName("mantis")
@ -84,7 +86,7 @@ public class Spin extends SpinBase {
public int getPropertyMantis() { public int getPropertyMantis() {
return this.propertyMantis; return this.propertyMantis;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "max") @AknotName(value = "max")
@ -92,7 +94,7 @@ public class Spin extends SpinBase {
public long getPropertyMax() { public long getPropertyMax() {
return this.propertyMax; return this.propertyMax;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("min") @AknotName("min")
@ -100,7 +102,7 @@ public class Spin extends SpinBase {
public long getPropertyMin() { public long getPropertyMin() {
return this.propertyMin; return this.propertyMin;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -108,7 +110,7 @@ public class Spin extends SpinBase {
public long getPropertyValue() { public long getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
protected void onCallbackDown(final Boolean value) { protected void onCallbackDown(final Boolean value) {
if (value) { if (value) {
return; return;
@ -116,7 +118,7 @@ public class Spin extends SpinBase {
final long data = this.propertyValue - this.propertyIncrement; final long data = this.propertyValue - this.propertyIncrement;
checkValue(data); checkValue(data);
} }
protected void onCallbackModify(final String value) { protected void onCallbackModify(final String value) {
if (value.isEmpty()) { if (value.isEmpty()) {
return; return;
@ -124,7 +126,7 @@ public class Spin extends SpinBase {
final long value1 = Long.valueOf(value); final long value1 = Long.valueOf(value);
checkValue(value1); checkValue(value1);
} }
protected void onCallbackUp(final Boolean value) { protected void onCallbackUp(final Boolean value) {
if (value) { if (value) {
return; return;
@ -132,32 +134,32 @@ public class Spin extends SpinBase {
final long data = this.propertyValue + this.propertyIncrement; final long data = this.propertyValue + this.propertyIncrement;
checkValue(data); checkValue(data);
} }
protected void onChangePropertyIncrement() { protected void onChangePropertyIncrement() {
} }
protected void onChangePropertyMantis() { protected void onChangePropertyMantis() {
} }
protected void onChangePropertyMax() { protected void onChangePropertyMax() {
checkValue(this.propertyValue); checkValue(this.propertyValue);
} }
protected void onChangePropertyMin() { protected void onChangePropertyMin() {
checkValue(this.propertyValue); checkValue(this.propertyValue);
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
markToRedraw(); markToRedraw();
if (this.widgetEntry == null) { if (this.widgetEntry == null) {
Log.error("Can not acces at entry ..."); LOGGER.error("Can not acces at entry ...");
return; return;
} }
checkValue(this.propertyValue); checkValue(this.propertyValue);
} }
public void setPropertyIncrement(final long propertyIncrement) { public void setPropertyIncrement(final long propertyIncrement) {
if (this.propertyIncrement == propertyIncrement) { if (this.propertyIncrement == propertyIncrement) {
return; return;
@ -165,7 +167,7 @@ public class Spin extends SpinBase {
this.propertyIncrement = propertyIncrement; this.propertyIncrement = propertyIncrement;
onChangePropertyIncrement(); onChangePropertyIncrement();
} }
public void setPropertyMantis(final int propertyMantis) { public void setPropertyMantis(final int propertyMantis) {
if (this.propertyMantis == propertyMantis) { if (this.propertyMantis == propertyMantis) {
return; return;
@ -173,7 +175,7 @@ public class Spin extends SpinBase {
this.propertyMantis = propertyMantis; this.propertyMantis = propertyMantis;
onChangePropertyMantis(); onChangePropertyMantis();
} }
public void setPropertyMax(final long propertyMax) { public void setPropertyMax(final long propertyMax) {
if (this.propertyMax == propertyMax) { if (this.propertyMax == propertyMax) {
return; return;
@ -181,7 +183,7 @@ public class Spin extends SpinBase {
this.propertyMax = propertyMax; this.propertyMax = propertyMax;
onChangePropertyMax(); onChangePropertyMax();
} }
public void setPropertyMin(final long propertyMin) { public void setPropertyMin(final long propertyMin) {
if (this.propertyMin == propertyMin) { if (this.propertyMin == propertyMin) {
return; return;
@ -189,7 +191,7 @@ public class Spin extends SpinBase {
this.propertyMin = propertyMin; this.propertyMin = propertyMin;
onChangePropertyMin(); onChangePropertyMin();
} }
public void setPropertyValue(final long propertyValue) { public void setPropertyValue(final long propertyValue) {
if (this.propertyValue == propertyValue) { if (this.propertyValue == propertyValue) {
return; return;

View File

@ -16,9 +16,10 @@ import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.compositing.GuiShapeMode; import org.atriasoft.ewol.compositing.GuiShapeMode;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventTime; import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
@ -40,28 +41,30 @@ public Signal<Boolean> signalValue;
public Uri> propertyShape; //!< shape of the widget public Uri> propertyShape; //!< shape of the widget
*/ */
public class Tick extends Widget { public class Tick extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Tick.class);
/** /**
* Periodic call to update grapgic display * Periodic call to update grapgic display
* @param _event Time generic event * @param _event Time generic event
*/ */
protected static void periodicCall(final Tick self, final EventTime event) { protected static void periodicCall(final Tick self, final EventTime event) {
Log.verbose("Periodic call on Entry(" + event + ")"); LOGGER.trace("Periodic call on Entry(" + event + ")");
if (!self.shape.periodicCall(event)) { if (!self.shape.periodicCall(event)) {
//Log.error("end periodic call"); //LOGGER.error("end periodic call");
self.periodicConnectionHanble.close(); self.periodicConnectionHanble.close();
} }
self.markToRedraw(); self.markToRedraw();
} }
/// color property of the text foreground /// color property of the text foreground
private int colorIdTextFg; private int colorIdTextFg;
/// text display this.text /// text display this.text
//private final CompositingGraphicContext gc = new CompositingGraphicContext(); //private final CompositingGraphicContext gc = new CompositingGraphicContext();
/// Periodic call handle to remove it when needed /// Periodic call handle to remove it when needed
protected Connection periodicConnectionHanble = new Connection(); protected Connection periodicConnectionHanble = new Connection();
private Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol"); private Uri propertyConfig = new Uri("THEME", "shape/Tick.json", "ewol");
private Boolean propertyValue = false; //!< string that must be displayed private Boolean propertyValue = false; //!< string that must be displayed
private GuiShape shape; private GuiShape shape;
@AknotSignal @AknotSignal
@ -83,9 +86,9 @@ public class Tick extends Widget {
// element over: // element over:
Vector3f overPositionStart = Vector3f.ZERO; Vector3f overPositionStart = Vector3f.ZERO;
Vector3f overPositionStop = Vector3f.ZERO; Vector3f overPositionStop = Vector3f.ZERO;
private boolean isDown; private boolean isDown;
/** /**
* Constuctor * Constuctor
*/ */
@ -96,7 +99,7 @@ public class Tick extends Widget {
// can not support multiple click... // can not support multiple click...
setMouseLimit(1); setMouseLimit(1);
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
// call main class // call main class
@ -107,30 +110,32 @@ public class Tick extends Widget {
padding = this.shape.getPadding(); padding = this.shape.getPadding();
} }
final Vector3i minHeight = Vector3i.VALUE_16; final Vector3i minHeight = Vector3i.VALUE_16;
Vector3f minimumSizeBase = new Vector3f(minHeight.x(), minHeight.y(), minHeight.z()); Vector3f minimumSizeBase = new Vector3f(minHeight.x(), minHeight.y(), minHeight.z());
// add padding : // add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z()); minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z());
this.minSize = Vector3f.max(this.minSize, minimumSizeBase); this.minSize = Vector3f.max(this.minSize, minimumSizeBase);
// verify the min max of the min size ... // verify the min max of the min size ...
checkMinSize(); checkMinSize();
Log.error("min size = " + this.minSize); LOGGER.error("min size = " + this.minSize);
} }
protected void changeStatusIn(final GuiShapeMode newStatusId) { protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) { if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) { if (!this.periodicConnectionHanble.isConnected()) {
//Log.error("REQUEST: connection on periodic call"); //LOGGER.error("REQUEST: connection on periodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this, Tick::periodicCall); this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Tick::periodicCall);
} }
markToRedraw(); markToRedraw();
} }
} }
private boolean checkIfOver(final Vector3f relPos) { private boolean checkIfOver(final Vector3f relPos) {
return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y() && relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y(); return relPos.x() > this.overPositionStart.x() && relPos.y() > this.overPositionStart.y()
&& relPos.x() < this.overPositionStop.x() && relPos.y() < this.overPositionStop.y();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("config") @AknotName("config")
@ -138,7 +143,7 @@ public class Tick extends Widget {
public Uri getPropertyConfig() { public Uri getPropertyConfig() {
return this.propertyConfig; return this.propertyConfig;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("value") @AknotName("value")
@ -146,7 +151,7 @@ public class Tick extends Widget {
public Boolean getPropertyValue() { public Boolean getPropertyValue() {
return this.propertyValue; return this.propertyValue;
} }
protected void onChangePropertyShaper() { protected void onChangePropertyShaper() {
if (this.shape == null) { if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig); this.shape = new GuiShape(this.propertyConfig);
@ -154,28 +159,28 @@ public class Tick extends Widget {
this.shape.setSource(this.propertyConfig); this.shape.setSource(this.propertyConfig);
} }
} }
protected void onChangePropertyTextWhenNothing() { protected void onChangePropertyTextWhenNothing() {
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyValue() { protected void onChangePropertyValue() {
//Boolean newData = this.propertyValue; //Boolean newData = this.propertyValue;
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
if (this.shape != null) { if (this.shape != null) {
this.shape.draw(true, this.propertyValue ? 0 : 1); this.shape.draw(true, this.propertyValue ? 0 : 1);
} }
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
final Vector3f positionAbsolute = new Vector3f(event.pos().x(), event.pos().y(), 0); final Vector3f positionAbsolute = new Vector3f(event.pos().x(), event.pos().y(), 0);
final Vector3f relPos = relativePosition(positionAbsolute); final Vector3f relPos = relativePosition(positionAbsolute);
Log.warning("Event on Input ... " + event + " relPos = " + relPos); LOGGER.warn("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = checkIfOver(relPos); final boolean over = checkIfOver(relPos);
//filter if outside the element... //filter if outside the element...
if (event.status() == KeyStatus.leave) { if (event.status() == KeyStatus.leave) {
@ -188,7 +193,7 @@ public class Tick extends Widget {
if (KeyStatus.leave == event.status()) { if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL); changeStatusIn(GuiShapeMode.NORMAL);
} else { } else {
Log.verbose("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop); LOGGER.trace("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop);
if (over) { if (over) {
changeStatusIn(GuiShapeMode.OVER); changeStatusIn(GuiShapeMode.OVER);
} else { } else {
@ -230,13 +235,13 @@ public class Tick extends Widget {
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
//return; //return;
} }
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'"); //LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear(); this.shape.clear();
//this.gc.clear(); //this.gc.clear();
if (this.colorIdTextFg >= 0) { if (this.colorIdTextFg >= 0) {
@ -246,7 +251,7 @@ public class Tick extends Widget {
//this.text.setSelectionColor(this.shape.getColor(this.colorIdSelection)); //this.text.setSelectionColor(this.shape.getColor(this.colorIdSelection));
} }
final Padding padding = this.shape.getPadding(); final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize; Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize)); Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) { if (this.propertyFill.x()) {
@ -257,7 +262,7 @@ public class Tick extends Widget {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y()); tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
delta = delta.withY(0.0f); delta = delta.withY(0.0f);
} }
Vector3f tmpOriginShaper = delta; Vector3f tmpOriginShaper = delta;
Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z()); Vector3f tmpSizeInside = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f); //Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
@ -274,10 +279,10 @@ public class Tick extends Widget {
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper); tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeInside = Vector3f.clipInt(tmpSizeInside); tmpSizeInside = Vector3f.clipInt(tmpSizeInside);
tmpOriginInside = Vector3f.clipInt(tmpOriginInside); tmpOriginInside = Vector3f.clipInt(tmpOriginInside);
//this.gc.clear(); //this.gc.clear();
//this.gc.setSize((int)tmpSizeText.x(), (int)tmpSizeText.y()); //this.gc.setSize((int)tmpSizeText.x(), (int)tmpSizeText.y());
//this.gc.setColorFill(Color.BLACK); //this.gc.setColorFill(Color.BLACK);
//this.gc.setColorStroke(Color.NONE); //this.gc.setColorStroke(Color.NONE);
//this.gc.setStrokeWidth(1); //this.gc.setStrokeWidth(1);
@ -287,9 +292,9 @@ public class Tick extends Widget {
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside); this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginInside, tmpSizeInside);
//this.gc.flush(); //this.gc.flush();
this.shape.flush(); this.shape.flush();
} }
/** /**
* internal check the value with RegExp checking * internal check the value with RegExp checking
* @param newData The new string to display * @param newData The new string to display
@ -298,7 +303,7 @@ public class Tick extends Widget {
this.propertyValue = newData; this.propertyValue = newData;
markToRedraw(); markToRedraw();
} }
public void setPropertyConfig(final Uri propertyConfig) { public void setPropertyConfig(final Uri propertyConfig) {
if (this.propertyConfig.equals(propertyConfig)) { if (this.propertyConfig.equals(propertyConfig)) {
return; return;
@ -306,7 +311,7 @@ public class Tick extends Widget {
this.propertyConfig = propertyConfig; this.propertyConfig = propertyConfig;
onChangePropertyShaper(); onChangePropertyShaper();
} }
public void setPropertyValue(final Boolean propertyValue) { public void setPropertyValue(final Boolean propertyValue) {
if (this.propertyValue.equals(propertyValue)) { if (this.propertyValue.equals(propertyValue)) {
return; return;
@ -315,5 +320,5 @@ public class Tick extends Widget {
this.signalValue.emit(this.propertyValue); this.signalValue.emit(this.propertyValue);
onChangePropertyValue(); onChangePropertyValue();
} }
} }

View File

@ -31,7 +31,6 @@ import org.atriasoft.ewol.event.EventEntry;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventShortCut; import org.atriasoft.ewol.event.EventShortCut;
import org.atriasoft.ewol.event.InputSystem; import org.atriasoft.ewol.event.InputSystem;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.context.ClipboardList; import org.atriasoft.gale.context.ClipboardList;
@ -39,6 +38,8 @@ import org.atriasoft.gale.context.Cursor;
import org.atriasoft.gale.key.KeyKeyboard; import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial; import org.atriasoft.gale.key.KeySpecial;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Widget class is the main widget interface, it has so me generic properties: * Widget class is the main widget interface, it has so me generic properties:
@ -46,9 +47,10 @@ import org.lwjgl.opengl.GL11;
* :** Can be display at a special position with a special scale * :** Can be display at a special position with a special scale
* :** Can get focus * :** Can get focus
* :** Receive Event (keyboard / mouse / ...) * :** Receive Event (keyboard / mouse / ...)
* *
*/ */
public class Widget extends EwolObject { public class Widget extends EwolObject {
private static final Logger LOGGER = LoggerFactory.getLogger(Widget.class);
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- keyboard event properties Area // -- keyboard event properties Area
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
@ -121,7 +123,7 @@ public class Widget extends EwolObject {
protected void calculateMinMaxSizeWidget() { protected void calculateMinMaxSizeWidget() {
this.minSize = this.propertyMinSize.getPixel(); this.minSize = this.propertyMinSize.getPixel();
//Log.error("[" + getId() + "] convert in min size : " + propertyMinSize + " out=" + this.minSize); //LOGGER.error("[" + getId() + "] convert in min size : " + propertyMinSize + " out=" + this.minSize);
this.maxSize = this.propertyMaxSize.getPixel(); this.maxSize = this.propertyMaxSize.getPixel();
markToRedraw(); markToRedraw();
} }
@ -194,7 +196,8 @@ public class Widget extends EwolObject {
for (int iii = 0; iii < level; ++iii) { for (int iii = 0; iii < level; ++iii) {
space.append(" "); space.append(" ");
} }
Log.print(space.append("[").append(getId()).append("] name='").append(this.name).append("' type=").append(getClass().getCanonicalName()).append(" o=").append(this.origin).append(" s=") LOGGER.info(space.append("[").append(getId()).append("] name='").append(this.name).append("' type=")
.append(getClass().getCanonicalName()).append(" o=").append(this.origin).append(" s=")
.append(this.size).append(" hide=").append(this.propertyHide).toString()); .append(this.size).append(" hide=").append(this.propertyHide).toString());
} }
@ -444,7 +447,7 @@ public class Widget extends EwolObject {
* @note INTERNAL EWOL SYSTEM * @note INTERNAL EWOL SYSTEM
*/ */
public void onChangeSize() { public void onChangeSize() {
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} update size : " + this.size); LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} update size : " + this.size);
markToRedraw(); markToRedraw();
} }
@ -493,33 +496,43 @@ public class Widget extends EwolObject {
* @return false if the event has not been used. * @return false if the event has not been used.
* @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some mistake in the error. * @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some mistake in the error.
*/ */
public boolean onEventShortCut(final KeySpecial special, Character unicodeValue, final KeyKeyboard kbMove, final boolean isDown) { public boolean onEventShortCut(
final KeySpecial special,
Character unicodeValue,
final KeyKeyboard kbMove,
final boolean isDown) {
unicodeValue = Character.toLowerCase(unicodeValue); unicodeValue = Character.toLowerCase(unicodeValue);
//Log.verbose("check shortcut...." + special + " " + unicodeValue + " " + kbMove + " " + (isDown ? "DOWN" : "UP") + " nb shortcut:" + this.localShortcut.size()); //LOGGER.trace("check shortcut...." + special + " " + unicodeValue + " " + kbMove + " " + (isDown ? "DOWN" : "UP") + " nb shortcut:" + this.localShortcut.size());
// Remove the up event of the shortcut... // Remove the up event of the shortcut...
if (!isDown) { if (!isDown) {
for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) { for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) {
if (!this.localShortcut.get(iii).isActive) { if (!this.localShortcut.get(iii).isActive) {
continue; continue;
} }
if ((this.localShortcut.get(iii).keyboardMoveValue() == KeyKeyboard.UNKNOWN && this.localShortcut.get(iii).unicodeValue() == unicodeValue) if ((this.localShortcut.get(iii).keyboardMoveValue() == KeyKeyboard.UNKNOWN
|| (this.localShortcut.get(iii).keyboardMoveValue() == kbMove && this.localShortcut.get(iii).unicodeValue() == 0)) { && this.localShortcut.get(iii).unicodeValue() == unicodeValue)
|| (this.localShortcut.get(iii).keyboardMoveValue() == kbMove
&& this.localShortcut.get(iii).unicodeValue() == 0)) {
// In this case we grap the event in case of an error can occured ... // In this case we grap the event in case of an error can occured ...
this.localShortcut.get(iii).isActive = false; this.localShortcut.get(iii).isActive = false;
Log.verbose("detect up of a shortcut"); LOGGER.trace("detect up of a shortcut");
return true; return true;
} }
} }
} }
//Log.info("Try to indexOf generic shortcut ..."); //LOGGER.info("Try to indexOf generic shortcut ...");
for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) { for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) {
if (this.localShortcut.get(iii).specialKey().getShift() == special.getShift() && this.localShortcut.get(iii).specialKey().getCtrl() == special.getCtrl() if (this.localShortcut.get(iii).specialKey().getShift() == special.getShift()
&& this.localShortcut.get(iii).specialKey().getAlt() == special.getAlt() && this.localShortcut.get(iii).specialKey().getMeta() == special.getMeta() && this.localShortcut.get(iii).specialKey().getCtrl() == special.getCtrl()
&& ((this.localShortcut.get(iii).keyboardMoveValue() == KeyKeyboard.UNKNOWN && this.localShortcut.get(iii).unicodeValue() == unicodeValue) && this.localShortcut.get(iii).specialKey().getAlt() == special.getAlt()
|| (this.localShortcut.get(iii).keyboardMoveValue() == kbMove && this.localShortcut.get(iii).unicodeValue() == 0))) { && this.localShortcut.get(iii).specialKey().getMeta() == special.getMeta()
&& ((this.localShortcut.get(iii).keyboardMoveValue() == KeyKeyboard.UNKNOWN
&& this.localShortcut.get(iii).unicodeValue() == unicodeValue)
|| (this.localShortcut.get(iii).keyboardMoveValue() == kbMove
&& this.localShortcut.get(iii).unicodeValue() == 0))) {
if (isDown) { if (isDown) {
this.localShortcut.get(iii).isActive = true; this.localShortcut.get(iii).isActive = true;
Log.verbose("Generate shortCut: " + this.localShortcut.get(iii).message()); LOGGER.trace("Generate shortCut: " + this.localShortcut.get(iii).message());
this.signalShortcut.emit(this.localShortcut.get(iii).message()); this.signalShortcut.emit(this.localShortcut.get(iii).message());
} }
return true; return true;
@ -545,7 +558,7 @@ public class Widget extends EwolObject {
final Vector3f pixelMax = this.propertyMaxSize.getPixel(); final Vector3f pixelMax = this.propertyMaxSize.getPixel();
// check minimum maximum compatibility : // check minimum maximum compatibility :
if (pixelMin.x() > pixelMax.x() || pixelMin.y() > pixelMax.y()) { if (pixelMin.x() > pixelMax.x() || pixelMin.y() > pixelMax.y()) {
Log.error("Can not set a 'min size' > 'max size' reset to maximum ..."); LOGGER.error("Can not set a 'min size' > 'max size' reset to maximum ...");
this.propertyMaxSize = new Dimension3f(Vector3f.MAX_VALUE, Distance.PIXEL); this.propertyMaxSize = new Dimension3f(Vector3f.MAX_VALUE, Distance.PIXEL);
} }
requestUpdateSize(); requestUpdateSize();
@ -587,7 +600,7 @@ public class Widget extends EwolObject {
* @param newCursor selected new cursor. * @param newCursor selected new cursor.
*/ */
public void setCursor(final Cursor newCursor) { public void setCursor(final Cursor newCursor) {
Log.debug("Change Cursor in " + newCursor); LOGGER.debug("Change Cursor in " + newCursor);
this.cursorDisplay = newCursor; this.cursorDisplay = newCursor;
EwolObject.getContext().setCursor(this.cursorDisplay); EwolObject.getContext().setCursor(this.cursorDisplay);
} }
@ -597,16 +610,17 @@ public class Widget extends EwolObject {
* @return return true if the widget keep the focus * @return return true if the widget keep the focus
*/ */
public boolean setFocus() { public boolean setFocus() {
Log.verbose("set focus (start) *propertyCanFocus=" + this.propertyCanFocus + " this.hasFocus=" + this.hasFocus); LOGGER.trace(
"set focus (start) *propertyCanFocus=" + this.propertyCanFocus + " this.hasFocus=" + this.hasFocus);
if (this.propertyCanFocus) { if (this.propertyCanFocus) {
if (!this.hasFocus) { if (!this.hasFocus) {
this.hasFocus = true; this.hasFocus = true;
onGetFocus(); onGetFocus();
} }
Log.verbose("set focus (stop) ret true"); LOGGER.trace("set focus (stop) ret true");
return true; return true;
} }
Log.verbose("set focus (stop) ret false"); LOGGER.trace("set focus (stop) ret false");
return false; return false;
} }
@ -645,7 +659,7 @@ public class Widget extends EwolObject {
* @param newVal offset value. * @param newVal offset value.
*/ */
public void setOffset(final Vector3f newVal) { public void setOffset(final Vector3f newVal) {
Log.info("Set offset: " + newVal); LOGGER.info("Set offset: " + newVal);
if (this.offset != newVal) { if (this.offset != newVal) {
this.offset = newVal; this.offset = newVal;
markToRedraw(); markToRedraw();
@ -772,7 +786,7 @@ public class Widget extends EwolObject {
*/ */
protected void shortCutAdd(final String descriptiveString, final String sendMessage) { protected void shortCutAdd(final String descriptiveString, final String sendMessage) {
if (descriptiveString.length() == 0) { if (descriptiveString.length() == 0) {
Log.error("try to add shortcut with no descriptive string ..."); LOGGER.error("try to add shortcut with no descriptive string ...");
return; return;
} }
String message; //!< data link with the event String message; //!< data link with the event
@ -918,7 +932,7 @@ public class Widget extends EwolObject {
} }
protected void systemDrawWidget(final DrawProperty displayProp) { protected void systemDrawWidget(final DrawProperty displayProp) {
//Log.info("[" + getId() + "] Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" << this.size << " hide=" << propertyHide); //LOGGER.info("[" + getId() + "] Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" << this.size << " hide=" << propertyHide);
if (this.propertyHide) { if (this.propertyHide) {
// widget is hidden ... // widget is hidden ...
return; return;
@ -935,20 +949,23 @@ public class Widget extends EwolObject {
if (tmpSize.size().x() <= 0 || tmpSize.size().y() <= 0) { if (tmpSize.size().x() <= 0 || tmpSize.size().y() <= 0) {
return; return;
} }
//Log.info("setViewport(" + tmpSize.origin() + ", " + tmpSize.size() + ")"); //LOGGER.info("setViewport(" + tmpSize.origin() + ", " + tmpSize.size() + ")");
OpenGL.setViewPort(tmpSize.origin(), tmpSize.size()); OpenGL.setViewPort(tmpSize.origin(), tmpSize.size());
// special case, when origin < display origin, we need to cut the display : // special case, when origin < display origin, we need to cut the display :
Vector2i downOffset = new Vector2i((int) (this.origin.x() - tmpSize.origin().x()), (int) (this.origin.y() - tmpSize.origin().y())); Vector2i downOffset = new Vector2i((int) (this.origin.x() - tmpSize.origin().x()),
(int) (this.origin.y() - tmpSize.origin().y()));
downOffset = Vector2i.min(downOffset, Vector2i.ZERO); downOffset = Vector2i.min(downOffset, Vector2i.ZERO);
//Log.info("translate : (" + (new Vector3f(-tmpSize.size().x() / 2 + this.offset.x() + downOffset.x(), -tmpSize.size().y() / 2 + this.offset.y() + downOffset.y(), -1.0f)).clipInteger()); //LOGGER.info("translate : (" + (new Vector3f(-tmpSize.size().x() / 2 + this.offset.x() + downOffset.x(), -tmpSize.size().y() / 2 + this.offset.y() + downOffset.y(), -1.0f)).clipInteger());
// translate the display to have a Gui 0,0 position on the Left button angle // translate the display to have a Gui 0,0 position on the Left button angle
final Matrix4f tmpTranslate = Matrix4f final Matrix4f tmpTranslate = Matrix4f
.createMatrixTranslate((new Vector3f(-tmpSize.size().x() / 2 + this.offset.x() + downOffset.x(), -tmpSize.size().y() / 2 + this.offset.y() + downOffset.y(), -1.0f)).clipInteger()); .createMatrixTranslate((new Vector3f(-tmpSize.size().x() / 2 + this.offset.x() + downOffset.x(),
-tmpSize.size().y() / 2 + this.offset.y() + downOffset.y(), -1.0f)).clipInteger());
//final Matrix4f tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 1.0f)); //final Matrix4f tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(0, 0, 1.0f));
// Scale if needed (feature not validate) // Scale if needed (feature not validate)
final Matrix4f tmpScale = Matrix4f.createMatrixScale(this.zoom, this.zoom, 1.0f); final Matrix4f tmpScale = Matrix4f.createMatrixScale(this.zoom, this.zoom, 1.0f);
// create orthogonal projection for GUI ==> simple to manage staking // create orthogonal projection for GUI ==> simple to manage staking
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-tmpSize.size().x() / 2, tmpSize.size().x() / 2, -tmpSize.size().y() / 2, tmpSize.size().y() / 2, -500, 500); final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-tmpSize.size().x() / 2, tmpSize.size().x() / 2,
-tmpSize.size().y() / 2, tmpSize.size().y() / 2, -500, 500);
//Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate); //Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate);
OpenGL.push(); OpenGL.push();

View File

@ -20,28 +20,30 @@ import org.atriasoft.ewol.compositing.Compositing;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.compositing.CompositingText; import org.atriasoft.ewol.compositing.CompositingText;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.model.ListRole; import org.atriasoft.ewol.widget.model.ListRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class WidgetList extends WidgetScrolled { class WidgetList extends WidgetScrolled {
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetList.class);
// drawing capabilities .... // drawing capabilities ....
protected List<Compositing> listOObject = new ArrayList<>(); //!< generic element to display... protected List<Compositing> listOObject = new ArrayList<>(); //!< generic element to display...
protected List<Integer> listSizeX = new ArrayList<>(); //!< size of every colomns protected List<Integer> listSizeX = new ArrayList<>(); //!< size of every colomns
protected List<Integer> listSizeY = new ArrayList<>(); //!< size of every rows protected List<Integer> listSizeY = new ArrayList<>(); //!< size of every rows
protected Map<String, Compositing> compositingElements = new HashMap<>(); protected Map<String, Compositing> compositingElements = new HashMap<>();
// list properties ... // list properties ...
protected int paddingSizeX = 0; protected int paddingSizeX = 0;
protected int paddingSizeY = 0; protected int paddingSizeY = 0;
protected int displayStartRaw = 0; //!< Current starting diaplayed raw protected int displayStartRaw = 0; //!< Current starting diaplayed raw
protected int displayCurrentNbLine = 0; //!< Number of line in the display protected int displayCurrentNbLine = 0; //!< Number of line in the display
protected int nbVisibleRaw = 0; // set the number of visible raw (calculate don display) protected int nbVisibleRaw = 0; // set the number of visible raw (calculate don display)
// function call to display the list : // function call to display the list :
public WidgetList() { public WidgetList() {
this.paddingSizeX = 2; this.paddingSizeX = 2;
this.paddingSizeY = 2; this.paddingSizeY = 2;
@ -51,12 +53,12 @@ class WidgetList extends WidgetScrolled {
addComposeElemnent("drawing", new CompositingDrawing()); addComposeElemnent("drawing", new CompositingDrawing());
addComposeElemnent("text", new CompositingText()); addComposeElemnent("text", new CompositingText());
} }
protected void addComposeElemnent(final String name, final Compositing element) { protected void addComposeElemnent(final String name, final Compositing element) {
this.compositingElements.put(name, element); this.compositingElements.put(name, element);
//this.listOObject.add(element); //this.listOObject.add(element);
} }
/** /**
* Calculate an element size to estimate the render size. * Calculate an element size to estimate the render size.
* @note Does not generate the with the same size. * @note Does not generate the with the same size.
@ -73,7 +75,7 @@ class WidgetList extends WidgetScrolled {
} }
return Vector2f.ZERO; return Vector2f.ZERO;
} }
@Override @Override
public void calculateMinMaxSize() { public void calculateMinMaxSize() {
/*int fontId = getDefaultFontId(); /*int fontId = getDefaultFontId();
@ -84,18 +86,18 @@ class WidgetList extends WidgetScrolled {
*/ */
this.minSize = new Vector3f(200, 150, 10); this.minSize = new Vector3f(200, 150, 10);
} }
protected void clearComposeElemnent() { protected void clearComposeElemnent() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) { for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
//it.setValue(null); //it.setValue(null);
it.getValue().clear(); it.getValue().clear();
} }
} }
public void clearOObjectList() { public void clearOObjectList() {
//this.listOObject.clear(); //this.listOObject.clear();
} }
/** /**
* Draw the background * Draw the background
*/ */
@ -107,7 +109,7 @@ class WidgetList extends WidgetScrolled {
BGOObjects.rectangleWidth(new Vector2f(this.size.x(), this.size.y())); BGOObjects.rectangleWidth(new Vector2f(this.size.x(), this.size.y()));
} }
} }
/** /**
* Draw an element in the specific size and position. * Draw an element in the specific size and position.
* @param pos Position of colomn and Raw of the element. * @param pos Position of colomn and Raw of the element.
@ -136,7 +138,7 @@ class WidgetList extends WidgetScrolled {
} }
} }
} }
protected void flushElements() { protected void flushElements() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) { for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
it.getValue().flush(); it.getValue().flush();
@ -147,15 +149,15 @@ class WidgetList extends WidgetScrolled {
} }
} }
} }
protected Color getBasicBG() { protected Color getBasicBG() {
return new Color(0xFF, 0xFF, 0xFF, 0xFF); return new Color(0xFF, 0xFF, 0xFF, 0xFF);
} }
protected Compositing getComposeElemnent(final String name) { protected Compositing getComposeElemnent(final String name) {
return this.compositingElements.get(name); return this.compositingElements.get(name);
} }
protected Object getData(final ListRole role, final Vector2i pos) { protected Object getData(final ListRole role, final Vector2i pos) {
switch (role) { switch (role) {
case Text: case Text:
@ -172,7 +174,7 @@ class WidgetList extends WidgetScrolled {
} }
return null; return null;
} }
/** /**
* Get the number of colomn and row availlable in the list * Get the number of colomn and row availlable in the list
* @return Number of colomn and row * @return Number of colomn and row
@ -180,7 +182,7 @@ class WidgetList extends WidgetScrolled {
protected Vector2i getMatrixSize() { protected Vector2i getMatrixSize() {
return new Vector2i(1, 0); return new Vector2i(1, 0);
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) { for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
@ -193,7 +195,7 @@ class WidgetList extends WidgetScrolled {
} }
super.onDraw(); super.onDraw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
Vector3f relativePos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0)); Vector3f relativePos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
@ -205,7 +207,8 @@ class WidgetList extends WidgetScrolled {
if (this.listSizeY.size() == 0) { if (this.listSizeY.size() == 0) {
return false; return false;
} }
relativePos = new Vector3f(relativePos.x() + this.originScrooled.x(), this.size.y() - relativePos.y() + this.originScrooled.y(), 0); relativePos = new Vector3f(relativePos.x() + this.originScrooled.x(),
this.size.y() - relativePos.y() + this.originScrooled.y(), 0);
// Find the colomn and the row // Find the colomn and the row
Vector3i pos = Vector3i.ZERO; Vector3i pos = Vector3i.ZERO;
float offsetY = 0; float offsetY = 0;
@ -244,7 +247,7 @@ class WidgetList extends WidgetScrolled {
} }
return isUsed; return isUsed;
} }
/** /**
* set a raw visible in the main display * set a raw visible in the main display
* @param _id Id of the raw that might be visible. * @param _id Id of the raw that might be visible.
@ -252,18 +255,18 @@ class WidgetList extends WidgetScrolled {
//void setRawVisible(int _id); //void setRawVisible(int _id);
@Override @Override
protected void onGetFocus() { protected void onGetFocus() {
Log.debug("WidgetList get focus"); LOGGER.debug("WidgetList get focus");
} }
protected boolean onItemEvent(final EventInput event, final Vector3i pos, final Vector3f mousePosition) { protected boolean onItemEvent(final EventInput event, final Vector3i pos, final Vector3f mousePosition) {
return false; return false;
} }
@Override @Override
protected void onLostFocus() { protected void onLostFocus() {
Log.debug("WidgetList Lost focus"); LOGGER.debug("WidgetList Lost focus");
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (!needRedraw()) { if (!needRedraw()) {
@ -371,7 +374,7 @@ class WidgetList extends WidgetScrolled {
} }
for (int xxx = 0; xxx < matrixSize.x(); ++xxx) { for (int xxx = 0; xxx < matrixSize.x(); ++xxx) {
final float startXposition = -this.originScrooled.x() + listStartPosX.get(xxx); final float startXposition = -this.originScrooled.x() + listStartPosX.get(xxx);
//Log.error("display start: " + startXposition); //LOGGER.error("display start: " + startXposition);
if (startXposition + this.listSizeX.get(xxx) < 0) { if (startXposition + this.listSizeX.get(xxx) < 0) {
// ==> element out of range ==> nothing to display // ==> element out of range ==> nothing to display
continue; continue;
@ -380,7 +383,8 @@ class WidgetList extends WidgetScrolled {
// ==> element out of range ==> nothing to display // ==> element out of range ==> nothing to display
break; break;
} }
drawElement(new Vector2i(xxx, yyy), new Vector2f(startXposition, startYposition), new Vector2f(this.listSizeX.get(xxx), this.listSizeY.get(yyy))); drawElement(new Vector2i(xxx, yyy), new Vector2f(startXposition, startYposition),
new Vector2f(this.listSizeX.get(xxx), this.listSizeY.get(yyy)));
} }
} }
// ------------------------------------------------------- // -------------------------------------------------------
@ -390,9 +394,9 @@ class WidgetList extends WidgetScrolled {
// flush all compositing drawing // flush all compositing drawing
flushElements(); flushElements();
} }
protected void removeComposeElemnent() { protected void removeComposeElemnent() {
this.compositingElements.clear(); this.compositingElements.clear();
} }
} }

View File

@ -2,8 +2,9 @@ package org.atriasoft.ewol.widget;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.exml.model.XmlElement; import org.atriasoft.exml.model.XmlElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -12,7 +13,8 @@ import org.atriasoft.exml.model.XmlElement;
*/ */
public class WidgetManager { public class WidgetManager {
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetManager.class);
// --------------------------------------------- // ---------------------------------------------
// -- Factory area // -- Factory area
// --------------------------------------------- // ---------------------------------------------
@ -21,14 +23,14 @@ public class WidgetManager {
// -- Focus area // -- Focus area
// --------------------------------------------- // ---------------------------------------------
private WeakReference<Widget> focusWidgetDefault; //!< default focus when no current focus is set private WeakReference<Widget> focusWidgetDefault; //!< default focus when no current focus is set
private Runnable funcRedrawNeeded = null; private Runnable funcRedrawNeeded = null;
// --------------------------------------------- // ---------------------------------------------
// -- Something change area (TODO maybe set it in the windows) // -- Something change area (TODO maybe set it in the windows)
// --------------------------------------------- // ---------------------------------------------
private boolean haveRedraw = true; //!< something request a redraw private boolean haveRedraw = true; //!< something request a redraw
/** /**
* Create a widget with his name. * Create a widget with his name.
* @param name Name of the widget to create. * @param name Name of the widget to create.
@ -48,11 +50,11 @@ public class WidgetManager {
return null; return null;
} }
} }
Log.warning("try to create an UnExistant widget : " + nameLower); LOGGER.warn("try to create an UnExistant widget : " + nameLower);
return null; return null;
} }
*/ */
public WidgetManager() { public WidgetManager() {
/* /*
this.creatorList.put("Button", Button.class); this.creatorList.put("Button", Button.class);
@ -78,7 +80,7 @@ public class WidgetManager {
this.creatorList.put("Spin", Spin.class); this.creatorList.put("Spin", Spin.class);
*/ */
} }
/** /**
* @throws Exception * @throws Exception
* add a factory of a specific widget. * add a factory of a specific widget.
@ -93,13 +95,13 @@ public class WidgetManager {
// final String nameLower = name.toLowerCase(); // final String nameLower = name.toLowerCase();
// final Class<?> it = WidgetXmlFactory.creatorList.get(nameLower); // final Class<?> it = WidgetXmlFactory.creatorList.get(nameLower);
// if (it != null) { // if (it != null) {
// Log.warning("Replace Creator of a specify widget : " + nameLower); // LOGGER.warn("Replace Creator of a specify widget : " + nameLower);
// return; // return;
// } // }
// this.creatorList.put(nameLower, klass); // this.creatorList.put(nameLower, klass);
// // TODO check constructors ... // // TODO check constructors ...
} }
/** /**
* Create a widget with his name. * Create a widget with his name.
* @param name Name of the widget to create. * @param name Name of the widget to create.
@ -117,10 +119,10 @@ public class WidgetManager {
// return null; // return null;
// } // }
// } // }
Log.warning("try to create an UnExistant widget : " + nameLower); LOGGER.warn("try to create an UnExistant widget : " + nameLower);
return null; return null;
} }
public Widget create(final String name, final XmlElement node) { public Widget create(final String name, final XmlElement node) {
final String nameLower = name.toLowerCase(); final String nameLower = name.toLowerCase();
// final Class<?> it = this.creatorList.get(nameLower); // final Class<?> it = this.creatorList.get(nameLower);
@ -134,10 +136,10 @@ public class WidgetManager {
// return null; // return null;
// } // }
// } // }
Log.warning("try to create an UnExistant widget : " + nameLower); LOGGER.warn("try to create an UnExistant widget : " + nameLower);
return null; return null;
} }
/** /**
* Check if an Widget exist * Check if an Widget exist
* @param name Name of the widget to check. * @param name Name of the widget to check.
@ -148,7 +150,7 @@ public class WidgetManager {
// return this.creatorList.get(name.toLowerCase()) != null; // return this.creatorList.get(name.toLowerCase()) != null;
return false; return false;
} }
/** /**
* Get the current Focused widget. * Get the current Focused widget.
* @return The pointer on the current focused element. * @return The pointer on the current focused element.
@ -156,7 +158,7 @@ public class WidgetManager {
public Widget focusGet() { public Widget focusGet() {
return this.focusWidgetCurrent.get(); return this.focusWidgetCurrent.get();
} }
/** /**
* Request a focus on a specify widget. * Request a focus on a specify widget.
* @param newWidget Widget that might get the focus. * @param newWidget Widget that might get the focus.
@ -166,7 +168,7 @@ public class WidgetManager {
// nothing to do ... // nothing to do ...
return; return;
} }
Log.debug("focusKeep=" + newWidget.getId()); LOGGER.debug("focusKeep=" + newWidget.getId());
//elog::displayBacktrace(); //elog::displayBacktrace();
Widget focusWidgetCurrent = this.focusWidgetCurrent.get(); Widget focusWidgetCurrent = this.focusWidgetCurrent.get();
if (newWidget == focusWidgetCurrent) { if (newWidget == focusWidgetCurrent) {
@ -174,21 +176,21 @@ public class WidgetManager {
return; return;
} }
if (focusWidgetCurrent != null) { if (focusWidgetCurrent != null) {
Log.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId()); LOGGER.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId());
focusWidgetCurrent.rmFocus(); focusWidgetCurrent.rmFocus();
focusWidgetCurrent = null; focusWidgetCurrent = null;
} }
if (!newWidget.propertyCanFocus) { if (!newWidget.propertyCanFocus) {
Log.debug("Widget can not have focus, id=" + newWidget.getId()); LOGGER.debug("Widget can not have focus, id=" + newWidget.getId());
return; return;
} }
this.focusWidgetCurrent = new WeakReference<>(newWidget); this.focusWidgetCurrent = new WeakReference<>(newWidget);
if (newWidget != null) { if (newWidget != null) {
Log.debug("Set focus on WidgetID=" + newWidget.getId()); LOGGER.debug("Set focus on WidgetID=" + newWidget.getId());
newWidget.setFocus(); newWidget.setFocus();
} }
} }
/** /**
* Release the current focus (back on default if possible). * Release the current focus (back on default if possible).
*/ */
@ -200,24 +202,24 @@ public class WidgetManager {
return; return;
} }
if (focusWidgetCurrent != null) { if (focusWidgetCurrent != null) {
Log.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId()); LOGGER.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId());
focusWidgetCurrent.rmFocus(); focusWidgetCurrent.rmFocus();
} }
this.focusWidgetCurrent = this.focusWidgetDefault; this.focusWidgetCurrent = this.focusWidgetDefault;
focusWidgetCurrent = this.focusWidgetCurrent.get(); focusWidgetCurrent = this.focusWidgetCurrent.get();
if (focusWidgetCurrent != null) { if (focusWidgetCurrent != null) {
Log.debug("Set focus on WidgetID=" + focusWidgetCurrent.getId()); LOGGER.debug("Set focus on WidgetID=" + focusWidgetCurrent.getId());
focusWidgetCurrent.setFocus(); focusWidgetCurrent.setFocus();
} }
} }
/** /**
* Set the default focus when none selected. * Set the default focus when none selected.
* @param newWidget Widget that might get the focus (when nothing else). * @param 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)) { if ((newWidget != null) && (!newWidget.propertyCanFocus)) {
Log.verbose("Widget can not have focus, id=" + newWidget.getId()); LOGGER.trace("Widget can not have focus, id=" + newWidget.getId());
return; return;
} }
Widget focusWidgetDefault = null; Widget focusWidgetDefault = null;
@ -230,18 +232,18 @@ public class WidgetManager {
} }
if (focusWidgetDefault == focusWidgetCurrent) { if (focusWidgetDefault == focusWidgetCurrent) {
if (focusWidgetCurrent != null) { if (focusWidgetCurrent != null) {
Log.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId()); LOGGER.debug("Rm focus on WidgetID=" + focusWidgetCurrent.getId());
focusWidgetCurrent.rmFocus(); focusWidgetCurrent.rmFocus();
} }
this.focusWidgetCurrent = new WeakReference<>(newWidget); this.focusWidgetCurrent = new WeakReference<>(newWidget);
if (newWidget != null) { if (newWidget != null) {
Log.debug("Set focus on WidgetID=" + newWidget.getId()); LOGGER.debug("Set focus on WidgetID=" + newWidget.getId());
newWidget.setFocus(); newWidget.setFocus();
} }
} }
this.focusWidgetDefault = new WeakReference<>(newWidget); this.focusWidgetDefault = new WeakReference<>(newWidget);
} }
/** /**
* Check if a redraw has been requested (set the local value back at false) * Check if a redraw has been requested (set the local value back at false)
* @return true if something to be redraw * @return true if something to be redraw
@ -251,7 +253,7 @@ public class WidgetManager {
this.haveRedraw = false; this.haveRedraw = false;
return tmp; return tmp;
} }
/** /**
* Get the list of all Widget that can be created. * Get the list of all Widget that can be created.
* @return Separate with ',' string list. * @return Separate with ',' string list.
@ -260,7 +262,7 @@ public class WidgetManager {
//return this.creatorList.keySet().toString(); //return this.creatorList.keySet().toString();
return ""; return "";
} }
/** /**
* Mark the display to redraw * Mark the display to redraw
*/ */
@ -273,7 +275,7 @@ public class WidgetManager {
this.funcRedrawNeeded.run(); this.funcRedrawNeeded.run();
} }
} }
/** /**
* Set a callback when we need redraw the display (need by MacOs) * Set a callback when we need redraw the display (need by MacOs)
* @param func function to call * @param func function to call
@ -281,5 +283,5 @@ public class WidgetManager {
public void setCallbackonRedrawNeeded(final Runnable func) { public void setCallbackonRedrawNeeded(final Runnable func) {
this.funcRedrawNeeded = func; this.funcRedrawNeeded = func;
} }
} }

View File

@ -14,21 +14,24 @@ import org.atriasoft.ewol.HighSpeedMode;
import org.atriasoft.ewol.Padding; import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape; import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.event.EventInput; import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.key.KeyStatus; import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType; import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Widget to integrate a scrool bar in a widget. This is not a stadalone widget. * Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
*/ */
class WidgetScrolled extends Widget { class WidgetScrolled extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetScrolled.class);
public enum ScrollingMode { public enum ScrollingMode {
scroolModeNormal, //!< No Zoom , can UP and down, left and right scroolModeNormal, //!< No Zoom , can UP and down, left and right
scroolModeCenter, //!< Zoom enable, no move left and right scroolModeCenter, //!< Zoom enable, no move left and right
scroolModeGame, //!< Zoom enable, no move left and right scroolModeGame, //!< Zoom enable, no move left and right
} }
public static final int CALCULATE_SIMULTANEOUS_FINGER = 5; public static final int CALCULATE_SIMULTANEOUS_FINGER = 5;
protected Uri propertyShapeVert = new Uri("THEME", "shape/WidgetScrolled.json", "ewol"); //!< Vertical shaper name protected Uri propertyShapeVert = new Uri("THEME", "shape/WidgetScrolled.json", "ewol"); //!< Vertical shaper name
protected Uri propertyShapeHori = new Uri("THEME", "shape/WidgetScrolled.json", "ewol"); //!< Horizontal shaper name protected Uri propertyShapeHori = new Uri("THEME", "shape/WidgetScrolled.json", "ewol"); //!< Horizontal shaper name
@ -49,7 +52,7 @@ class WidgetScrolled extends Widget {
private final boolean[] fingerPresent = { false, false, false, false, false }; private final boolean[] fingerPresent = { false, false, false, false, false };
private boolean fingerScoolActivated = false; private boolean fingerScoolActivated = false;
private final Vector2f[] fingerMoveStartPos = new Vector2f[CALCULATE_SIMULTANEOUS_FINGER]; private final Vector2f[] fingerMoveStartPos = new Vector2f[CALCULATE_SIMULTANEOUS_FINGER];
/** /**
* Scroll Widget main constructor to be inherited from an other widget (this is not a stand-alone widget) * Scroll Widget main constructor to be inherited from an other widget (this is not a stand-alone widget)
* @param _shaperName Shaper name if the scrolled widget. * @param _shaperName Shaper name if the scrolled widget.
@ -58,7 +61,7 @@ class WidgetScrolled extends Widget {
onChangePropertyShapeVert(); onChangePropertyShapeVert();
onChangePropertyShapeHori(); onChangePropertyShapeHori();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("shape-hori") @AknotName("shape-hori")
@ -66,7 +69,7 @@ class WidgetScrolled extends Widget {
public Uri getPropertyShapeHori() { public Uri getPropertyShapeHori() {
return this.propertyShapeHori; return this.propertyShapeHori;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("shape-vert") @AknotName("shape-vert")
@ -74,7 +77,7 @@ class WidgetScrolled extends Widget {
public Uri getPropertyShapeVert() { public Uri getPropertyShapeVert() {
return this.propertyShapeVert; return this.propertyShapeVert;
} }
/** /**
* Get the single finger capabilities * Get the single finger capabilities
* @return true The single finger mode is active * @return true The single finger mode is active
@ -83,7 +86,7 @@ class WidgetScrolled extends Widget {
public boolean getSingleFinger() { public boolean getSingleFinger() {
return this.singleFingerMode; return this.singleFingerMode;
} }
protected void onChangePropertyShapeHori() { protected void onChangePropertyShapeHori() {
if (this.shaperH == null) { if (this.shaperH == null) {
this.shaperH = new GuiShape(this.propertyShapeHori); this.shaperH = new GuiShape(this.propertyShapeHori);
@ -92,7 +95,7 @@ class WidgetScrolled extends Widget {
} }
markToRedraw(); markToRedraw();
} }
protected void onChangePropertyShapeVert() { protected void onChangePropertyShapeVert() {
if (this.shaperV == null) { if (this.shaperV == null) {
this.shaperV = new GuiShape(this.propertyShapeVert); this.shaperV = new GuiShape(this.propertyShapeVert);
@ -101,23 +104,24 @@ class WidgetScrolled extends Widget {
} }
markToRedraw(); markToRedraw();
} }
@Override @Override
protected void onDraw() { protected void onDraw() {
this.shaperH.draw(); this.shaperH.draw();
this.shaperV.draw(); this.shaperV.draw();
} }
@Override @Override
public boolean onEventInput(final EventInput event) { public boolean onEventInput(final EventInput event) {
Log.verbose("event XXX {}", event); LOGGER.trace("event XXX {}", event);
Vector3f relativePos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0.0f)); Vector3f relativePos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0.0f));
// Correction due to the open Gl insertion ... // Correction due to the open Gl insertion ...
relativePos = relativePos.withY(this.size.y() - relativePos.y()); relativePos = relativePos.withY(this.size.y() - relativePos.y());
final Padding paddingV = this.shaperV.getPadding(); final Padding paddingV = this.shaperV.getPadding();
final Padding paddingH = this.shaperH.getPadding(); final Padding paddingH = this.shaperH.getPadding();
if (this.scroollingMode == ScrollingMode.scroolModeNormal) { if (this.scroollingMode == ScrollingMode.scroolModeNormal) {
if (event.type() == KeyType.mouse && (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.mouse)) { if (event.type() == KeyType.mouse
&& (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.mouse)) {
if (event.inputId() == 1 && event.status() == KeyStatus.down) { if (event.inputId() == 1 && event.status() == KeyStatus.down) {
// check if selected the scrolling position with the scrolling bar ... // check if selected the scrolling position with the scrolling bar ...
if (relativePos.x() >= (this.size.x() - paddingV.x())) { if (relativePos.x() >= (this.size.x() - paddingV.x())) {
@ -125,11 +129,14 @@ class WidgetScrolled extends Widget {
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical; this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
this.highSpeedType = KeyType.mouse; this.highSpeedType = KeyType.mouse;
this.highSpeedStartPos = this.highSpeedStartPos.withX(relativePos.x()); this.highSpeedStartPos = this.highSpeedStartPos.withX(relativePos.x());
this.highSpeedStartPos = this.highSpeedStartPos.withY(this.originScrooled.y() / this.maxSize.y() * (this.size.y() - paddingV.y())); this.highSpeedStartPos = this.highSpeedStartPos
.withY(this.originScrooled.y() / this.maxSize.y() * (this.size.y() - paddingV.y()));
this.highSpeedButton = 1; this.highSpeedButton = 1;
// force direct scrolling in this case // force direct scrolling in this case
this.originScrooled = this.originScrooled.withY((int) (this.maxSize.y() * (relativePos.y() - paddingV.bottom()) / (this.size.y() - paddingV.bottom() * 2))); this.originScrooled = this.originScrooled.withY((int) (this.maxSize.y()
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y()))); * (relativePos.y() - paddingV.bottom()) / (this.size.y() - paddingV.bottom() * 2)));
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
(this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
markToRedraw(); markToRedraw();
return true; return true;
} }
@ -137,12 +144,15 @@ class WidgetScrolled extends Widget {
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) { if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal; this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
this.highSpeedType = KeyType.mouse; this.highSpeedType = KeyType.mouse;
this.highSpeedStartPos = this.highSpeedStartPos.withX(this.originScrooled.x() / this.maxSize.x() * (this.size.x() - paddingH.x())); this.highSpeedStartPos = this.highSpeedStartPos
.withX(this.originScrooled.x() / this.maxSize.x() * (this.size.x() - paddingH.x()));
this.highSpeedStartPos = this.highSpeedStartPos.withY(relativePos.y()); this.highSpeedStartPos = this.highSpeedStartPos.withY(relativePos.y());
this.highSpeedButton = 1; this.highSpeedButton = 1;
// force direct scrolling in this case // force direct scrolling in this case
this.originScrooled = this.originScrooled.withX((int) (this.maxSize.x() * (relativePos.x() - paddingH.left()) / (this.size.x() - paddingH.left() * 2))); this.originScrooled = this.originScrooled.withX((int) (this.maxSize.x()
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x()))); * (relativePos.x() - paddingH.left()) / (this.size.x() - paddingH.left() * 2)));
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
markToRedraw(); markToRedraw();
return true; return true;
} }
@ -156,13 +166,13 @@ class WidgetScrolled extends Widget {
zoom = FMath.avg(0.1f, zoom, 5000.0f); zoom = FMath.avg(0.1f, zoom, 5000.0f);
setZoom(zoom); setZoom(zoom);
*/ */
} else { } else if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0 || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) { || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - this.pixelScrolling); this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - this.pixelScrolling);
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y()))); this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
markToRedraw(); (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
return true; markToRedraw();
} return true;
} }
} else if (event.inputId() == 5 && event.status() == KeyStatus.up) { } else if (event.inputId() == 5 && event.status() == KeyStatus.up) {
if (event.specialKey().getCtrl()) { if (event.specialKey().getCtrl()) {
@ -172,27 +182,31 @@ class WidgetScrolled extends Widget {
zoom = FMath.avg(0.1f, zoom, 5000.0f); zoom = FMath.avg(0.1f, zoom, 5000.0f);
setZoom(zoom); setZoom(zoom);
*/ */
} else { } else if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0 || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) { || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() + this.pixelScrolling); this.originScrooled = this.originScrooled.withY(this.originScrooled.y() + this.pixelScrolling);
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y()))); this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
markToRedraw(); (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
return true; markToRedraw();
} return true;
} }
} else if (event.inputId() == 11 && event.status() == KeyStatus.up) { } else if (event.inputId() == 11 && event.status() == KeyStatus.up) {
// Scrool Left // Scrool Left
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0 || this.size.x() * this.limitScrolling.x() < this.maxSize.x()) { if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0
|| this.size.x() * this.limitScrolling.x() < this.maxSize.x()) {
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - this.pixelScrolling); this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - this.pixelScrolling);
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x()))); this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
markToRedraw(); markToRedraw();
return true; return true;
} }
} else if (event.inputId() == 10 && event.status() == KeyStatus.up) { } else if (event.inputId() == 10 && event.status() == KeyStatus.up) {
// Scrool Right // Scrool Right
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0 || this.size.x() * this.limitScrolling.x() < this.maxSize.x()) { if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0
|| this.size.x() * this.limitScrolling.x() < this.maxSize.x()) {
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() + this.pixelScrolling); this.originScrooled = this.originScrooled.withX(this.originScrooled.x() + this.pixelScrolling);
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x()))); this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
markToRedraw(); markToRedraw();
return true; return true;
} }
@ -235,7 +249,8 @@ class WidgetScrolled extends Widget {
return true; return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) { } else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
// wait that the cursor move more than 10 px to enable it : // wait that the cursor move more than 10 px to enable it :
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) { if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|| FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrolling can start : // the scrolling can start :
// select the direction : // select the direction :
if (relativePos.x() == this.highSpeedStartPos.x()) { if (relativePos.x() == this.highSpeedStartPos.x()) {
@ -243,7 +258,8 @@ class WidgetScrolled extends Widget {
} else if (relativePos.y() == this.highSpeedStartPos.y()) { } else if (relativePos.y() == this.highSpeedStartPos.y()) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal; this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} else { } else {
final float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x()); final float coef = (relativePos.y() - this.highSpeedStartPos.y())
/ (relativePos.x() - this.highSpeedStartPos.x());
if (FMath.abs(coef) <= 1) { if (FMath.abs(coef) <= 1) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal; this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} else { } else {
@ -251,29 +267,39 @@ class WidgetScrolled extends Widget {
} }
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal) {
this.highSpeedStartPos = this.highSpeedStartPos.withX(this.originScrooled.x() / this.maxSize.x() * (this.size.x() - paddingV.x())); this.highSpeedStartPos = this.highSpeedStartPos.withX(
this.originScrooled.x() / this.maxSize.x() * (this.size.x() - paddingV.x()));
} else { } else {
this.highSpeedStartPos = this.highSpeedStartPos.withY(this.originScrooled.y() / this.maxSize.y() * (this.size.y() - paddingV.y())); this.highSpeedStartPos = this.highSpeedStartPos.withY(
this.originScrooled.y() / this.maxSize.y() * (this.size.y() - paddingV.y()));
} }
markToRedraw(); markToRedraw();
} }
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y()))); this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
(this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
return true; return true;
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal && event.status() == KeyStatus.move) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal
this.originScrooled = this.originScrooled.withX((int) (this.maxSize.x() * (relativePos.x() - paddingH.left()) / (this.size.x() - paddingH.x()))); && event.status() == KeyStatus.move) {
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x()))); this.originScrooled = this.originScrooled.withX((int) (this.maxSize.x()
* (relativePos.x() - paddingH.left()) / (this.size.x() - paddingH.x())));
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
markToRedraw(); markToRedraw();
return true; return true;
} }
if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical && event.status() == KeyStatus.move) { if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical
this.originScrooled = this.originScrooled.withY((int) (this.maxSize.y() * (relativePos.y() - paddingV.bottom()) / (this.size.y() - paddingV.y()))); && event.status() == KeyStatus.move) {
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y()))); this.originScrooled = this.originScrooled.withY((int) (this.maxSize.y()
* (relativePos.y() - paddingV.bottom()) / (this.size.y() - paddingV.y())));
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
(this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
markToRedraw(); markToRedraw();
return true; return true;
} }
} }
} else if (event.type() == KeyType.finger && (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.finger)) { } else if (event.type() == KeyType.finger
&& (this.highSpeedType == KeyType.unknow || this.highSpeedType == KeyType.finger)) {
if (!this.singleFingerMode) { if (!this.singleFingerMode) {
// *********************** // ***********************
// ** Two finger mode : ** // ** Two finger mode : **
@ -292,18 +318,23 @@ class WidgetScrolled extends Widget {
} }
if (this.fingerPresent[0] && this.fingerPresent[1] && !this.fingerScoolActivated) { if (this.fingerPresent[0] && this.fingerPresent[1] && !this.fingerScoolActivated) {
this.fingerScoolActivated = true; this.fingerScoolActivated = true;
Log.verbose("SCROOL == > START pos=" + this.fingerMoveStartPos); LOGGER.trace("SCROOL == > START pos=" + this.fingerMoveStartPos);
} }
if (this.fingerScoolActivated) { if (this.fingerScoolActivated) {
// 1: HighSpeedMode... // 1: HighSpeedMode...
// 2: remove all unneeded sub event ... ==> maybe a better methode ... // 2: remove all unneeded sub event ... ==> maybe a better methode ...
if (event.status() == KeyStatus.move) { if (event.status() == KeyStatus.move) {
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - (relativePos.x() - this.fingerMoveStartPos[idTable].x()) * 0.5f); this.originScrooled = this.originScrooled.withX(this.originScrooled.x()
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - (relativePos.y() - this.fingerMoveStartPos[idTable].y()) * 0.5f); - (relativePos.x() - this.fingerMoveStartPos[idTable].x()) * 0.5f);
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x()))); this.originScrooled = this.originScrooled.withY(this.originScrooled.y()
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y()))); - (relativePos.y() - this.fingerMoveStartPos[idTable].y()) * 0.5f);
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
(this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
this.fingerMoveStartPos[idTable] = new Vector2f(relativePos.x(), relativePos.y()); this.fingerMoveStartPos[idTable] = new Vector2f(relativePos.x(), relativePos.y());
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos); LOGGER.trace("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " "
+ relativePos + " " + this.highSpeedStartPos);
markToRedraw(); markToRedraw();
} }
if (!this.fingerPresent[0] && !this.fingerPresent[1]) { if (!this.fingerPresent[0] && !this.fingerPresent[1]) {
@ -315,66 +346,72 @@ class WidgetScrolled extends Widget {
} }
return true; return true;
} }
} else { } else // **************************
// ************************** // ** Single finger mode : **
// ** Single finger mode : ** // **************************
// ************************** if (event.inputId() == 1) {
if (event.inputId() == 1) { LOGGER.trace("event 1 " + event);
Log.verbose("event 1 " + event); if (event.status() == KeyStatus.down) {
if (event.status() == KeyStatus.down) { this.highSpeedMode = HighSpeedMode.speedModeInit;
this.highSpeedMode = HighSpeedMode.speedModeInit; this.highSpeedType = KeyType.finger;
this.highSpeedType = KeyType.finger; this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y()); LOGGER.trace("SCROOL == > INIT");
Log.verbose("SCROOL == > INIT"); return true;
return true; } else if (event.status() == KeyStatus.upAfter) {
} else if (event.status() == KeyStatus.upAfter) {
this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow;
Log.verbose("SCROOL == > DISABLE");
markToRedraw();
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
// wait that the cursor move more than 10 px to enable it :
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10 || FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrooling can start :
// select the direction :
this.highSpeedMode = HighSpeedMode.speedModeEnableFinger;
Log.debug("SCROOL == > ENABLE");
markToRedraw();
}
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.pressSingle) {
// Keep all event in the range of moving
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.pressDouble) {
// Keep all event in the range of moving
return true;
}
if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.move) {
//this.originScrooled.x = (int)(this.maxSize.x * x / this.size.x);
this.originScrooled = this.originScrooled.withX(this.originScrooled.x() - (relativePos.x() - this.highSpeedStartPos.x()));
this.originScrooled = this.originScrooled.withY(this.originScrooled.y() - (relativePos.y() - this.highSpeedStartPos.y()));
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
markToRedraw();
return true;
}
} else if (this.highSpeedMode == HighSpeedMode.speedModeDisable && event.status() == KeyStatus.leave) {
this.highSpeedMode = HighSpeedMode.speedModeDisable; this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow; this.highSpeedType = KeyType.unknow;
Log.verbose("SCROOL == > DISABLE"); LOGGER.trace("SCROOL == > DISABLE");
markToRedraw();
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && event.status() == KeyStatus.move) {
// wait that the cursor move more than 10 px to enable it :
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|| FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrooling can start :
// select the direction :
this.highSpeedMode = HighSpeedMode.speedModeEnableFinger;
LOGGER.debug("SCROOL == > ENABLE");
markToRedraw();
}
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger
&& event.status() == KeyStatus.pressSingle) {
// Keep all event in the range of moving
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger
&& event.status() == KeyStatus.pressDouble) {
// Keep all event in the range of moving
return true;
}
if (this.highSpeedMode == HighSpeedMode.speedModeEnableFinger && event.status() == KeyStatus.move) {
//this.originScrooled.x = (int)(this.maxSize.x * x / this.size.x);
this.originScrooled = this.originScrooled
.withX(this.originScrooled.x() - (relativePos.x() - this.highSpeedStartPos.x()));
this.originScrooled = this.originScrooled
.withY(this.originScrooled.y() - (relativePos.y() - this.highSpeedStartPos.y()));
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
(this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
LOGGER.trace("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos
+ " " + this.highSpeedStartPos);
markToRedraw(); markToRedraw();
return true; return true;
} }
} else if (this.highSpeedMode == HighSpeedMode.speedModeDisable && event.status() == KeyStatus.leave) {
this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow;
LOGGER.trace("SCROOL == > DISABLE");
markToRedraw();
return true;
} }
} }
} else if (this.scroollingMode == ScrollingMode.scroolModeCenter) { } else if (this.scroollingMode == ScrollingMode.scroolModeCenter) {
if (event.type() == KeyType.mouse) { if (event.type() == KeyType.mouse) {
float tmp1 = this.size.x() / this.maxSize.y(); float tmp1 = this.size.x() / this.maxSize.y();
final float tmp2 = this.size.y() / this.maxSize.x(); final float tmp2 = this.size.y() / this.maxSize.x();
//Log.info(" elements Zoom : " + tmp1 + " " + tmp2); //LOGGER.info(" elements Zoom : " + tmp1 + " " + tmp2);
tmp1 = FMath.min(tmp1, tmp2); tmp1 = FMath.min(tmp1, tmp2);
if (event.inputId() == 4 && event.status() == KeyStatus.up) { if (event.inputId() == 4 && event.status() == KeyStatus.up) {
this.zoom -= 0.1; this.zoom -= 0.1;
@ -397,13 +434,13 @@ class WidgetScrolled extends Widget {
} }
} }
} else if (this.scroollingMode == ScrollingMode.scroolModeGame) { } else if (this.scroollingMode == ScrollingMode.scroolModeGame) {
} else { } else {
Log.error("Scrolling mode unknow ... " + this.scroollingMode); LOGGER.error("Scrolling mode unknow ... " + this.scroollingMode);
} }
return false; return false;
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
this.shaperH.clear(); this.shaperH.clear();
@ -417,30 +454,35 @@ class WidgetScrolled extends Widget {
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0) { if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0) {
float lenScrollBar = this.size.y() * this.size.y() / this.maxSize.y(); float lenScrollBar = this.size.y() * this.size.y() / this.maxSize.y();
lenScrollBar = FMath.avg(10.0f, lenScrollBar, this.size.y()); lenScrollBar = FMath.avg(10.0f, lenScrollBar, this.size.y());
float originScrollBar = this.originScrooled.y() / (this.maxSize.y() - this.size.y() * this.limitScrolling.y()); float originScrollBar = this.originScrooled.y()
/ (this.maxSize.y() - this.size.y() * this.limitScrolling.y());
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f); originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
originScrollBar *= (this.size.y() - lenScrollBar); originScrollBar *= (this.size.y() - lenScrollBar);
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0), new Vector2f(paddingVert.x(), this.size.y()), this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0),
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar), new Vector2f(0, lenScrollBar)); new Vector2f(paddingVert.x(), this.size.y()),
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar),
new Vector2f(0, lenScrollBar));
} }
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) { if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) {
float lenScrollBar = (this.size.x() - paddingHori.left()) * (this.size.x() - paddingVert.x()) / this.maxSize.x(); float lenScrollBar = (this.size.x() - paddingHori.left()) * (this.size.x() - paddingVert.x())
/ this.maxSize.x();
lenScrollBar = FMath.avg(10.0f, lenScrollBar, (this.size.x() - paddingVert.x())); lenScrollBar = FMath.avg(10.0f, lenScrollBar, (this.size.x() - paddingVert.x()));
float originScrollBar = this.originScrooled.x() / (this.maxSize.x() - this.size.x() * this.limitScrolling.x()); float originScrollBar = this.originScrooled.x()
/ (this.maxSize.x() - this.size.x() * this.limitScrolling.x());
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f); originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar); originScrollBar *= (this.size.x() - paddingHori.right() - lenScrollBar);
this.shaperH.setShape(new Vector2f(0, 0), new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()), new Vector2f(originScrollBar, paddingHori.bottom()), this.shaperH.setShape(new Vector2f(0, 0), new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()),
new Vector2f(lenScrollBar, 0)); new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0));
} }
} }
/** /**
* Reset the scoll of the subWidget * Reset the scoll of the subWidget
*/ */
public void resetScrollOrigin() { public void resetScrollOrigin() {
this.originScrooled = new Vector2f(0, 0); this.originScrooled = new Vector2f(0, 0);
} }
/** /**
* Specify the mode of scrolling for this windows * Specify the mode of scrolling for this windows
* @param newMode the selected mode for the scrolling... * @param newMode the selected mode for the scrolling...
@ -453,7 +495,7 @@ class WidgetScrolled extends Widget {
this.zoom = 1; this.zoom = 1;
} }
} }
/** /**
* set the scrolling limit when arriving at he end of the widget * set the scrolling limit when arriving at he end of the widget
* @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ... * @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
@ -462,15 +504,16 @@ class WidgetScrolled extends Widget {
poucentageLimit = FMath.avg(0.1f, poucentageLimit, 1.0f); poucentageLimit = FMath.avg(0.1f, poucentageLimit, 1.0f);
this.limitScrolling = new Vector2f(poucentageLimit, poucentageLimit); this.limitScrolling = new Vector2f(poucentageLimit, poucentageLimit);
} }
/** /**
* set the scrolling limit when arriving at he end of the widget * set the scrolling limit when arriving at he end of the widget
* @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific... * @param poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
*/ */
protected void setLimitScrolling(final Vector2f poucentageLimit) { protected void setLimitScrolling(final Vector2f poucentageLimit) {
this.limitScrolling = new Vector2f(FMath.avg(0.1f, poucentageLimit.x(), 1.0f), FMath.avg(0.1f, poucentageLimit.y(), 1.0f)); this.limitScrolling = new Vector2f(FMath.avg(0.1f, poucentageLimit.x(), 1.0f),
FMath.avg(0.1f, poucentageLimit.y(), 1.0f));
} }
/** /**
* set the specific mawimum size of the widget * set the specific mawimum size of the widget
* @param localSize new Maximum size * @param localSize new Maximum size
@ -478,7 +521,7 @@ class WidgetScrolled extends Widget {
protected void setMaxSize(final Vector2f localSize) { protected void setMaxSize(final Vector2f localSize) {
this.maxSize = localSize; this.maxSize = localSize;
} }
public void setPropertyShapeHori(final Uri value) { public void setPropertyShapeHori(final Uri value) {
if (this.propertyShapeHori.equals(value)) { if (this.propertyShapeHori.equals(value)) {
return; return;
@ -486,7 +529,7 @@ class WidgetScrolled extends Widget {
this.propertyShapeHori = value; this.propertyShapeHori = value;
onChangePropertyShapeHori(); onChangePropertyShapeHori();
} }
public void setPropertyShapeVert(final Uri value) { public void setPropertyShapeVert(final Uri value) {
if (this.propertyShapeVert.equals(value)) { if (this.propertyShapeVert.equals(value)) {
return; return;
@ -494,7 +537,7 @@ class WidgetScrolled extends Widget {
this.propertyShapeVert = value; this.propertyShapeVert = value;
onChangePropertyShapeVert(); onChangePropertyShapeVert();
} }
/** /**
* Request a specific position for the scrolling of the current windows. * Request a specific position for the scrolling of the current windows.
* @param borderWidth size of the border that requested the element might not to be * @param borderWidth size of the border that requested the element might not to be
@ -504,8 +547,11 @@ class WidgetScrolled extends Widget {
protected void setScrollingPositionDynamic(final Vector2f borderWidth, final Vector2f currentPosition) { protected void setScrollingPositionDynamic(final Vector2f borderWidth, final Vector2f currentPosition) {
setScrollingPositionDynamic(borderWidth, currentPosition, false); setScrollingPositionDynamic(borderWidth, currentPosition, false);
} }
protected void setScrollingPositionDynamic(Vector2f borderWidth, final Vector2f currentPosition, final boolean center) { protected void setScrollingPositionDynamic(
Vector2f borderWidth,
final Vector2f currentPosition,
final boolean center) {
if (center) { if (center) {
borderWidth = new Vector2f(this.size.x() / 2 - borderWidth.x(), this.size.y() / 2 - borderWidth.y()); borderWidth = new Vector2f(this.size.x() / 2 - borderWidth.x(), this.size.y() / 2 - borderWidth.y());
} }
@ -526,7 +572,7 @@ class WidgetScrolled extends Widget {
this.originScrooled = this.originScrooled.withY(FMath.max(0.0f, this.originScrooled.y())); this.originScrooled = this.originScrooled.withY(FMath.max(0.0f, this.originScrooled.y()));
} }
} }
/** /**
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled * For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
* @param nbPixel number of pixel scrolling * @param nbPixel number of pixel scrolling
@ -534,7 +580,7 @@ class WidgetScrolled extends Widget {
protected void setScrollingSize(final float nbPixel) { protected void setScrollingSize(final float nbPixel) {
this.pixelScrolling = nbPixel; this.pixelScrolling = nbPixel;
} }
/** /**
* Set the single finger capabilities/ * Set the single finger capabilities/
* @param status True if single inger mode, two otherwise/ * @param status True if single inger mode, two otherwise/
@ -545,16 +591,18 @@ class WidgetScrolled extends Widget {
} }
this.singleFingerMode = status; this.singleFingerMode = status;
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
OpenGL.push(); OpenGL.push();
if (this.scroollingMode == ScrollingMode.scroolModeCenter) { if (this.scroollingMode == ScrollingMode.scroolModeCenter) {
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
OpenGL.setViewPort(this.origin, this.size); OpenGL.setViewPort(this.origin, this.size);
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-this.size.x() / 2, this.size.x() / 2, -this.size.y() / 2, this.size.y() / 2, -1, 1); final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-this.size.x() / 2, this.size.x() / 2,
-this.size.y() / 2, this.size.y() / 2, -1, 1);
final Matrix4f tmpScale = Matrix4f.createMatrixScale(new Vector3f(this.zoom, this.zoom, 1)); final Matrix4f tmpScale = Matrix4f.createMatrixScale(new Vector3f(this.zoom, this.zoom, 1));
final Matrix4f tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1)); final Matrix4f tmpTranslate = Matrix4f
.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1));
final Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate); final Matrix4f tmpMat = tmpProjection.multiply(tmpScale).multiply(tmpTranslate);
// set internal matrix system : // set internal matrix system :
OpenGL.setMatrix(tmpMat); OpenGL.setMatrix(tmpMat);
@ -564,8 +612,10 @@ class WidgetScrolled extends Widget {
if (this.scroollingMode == ScrollingMode.scroolModeGame) { if (this.scroollingMode == ScrollingMode.scroolModeGame) {
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
OpenGL.setViewPort(this.origin, this.size); OpenGL.setViewPort(this.origin, this.size);
final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-this.size.x() / 2, this.size.x() / 2, -this.size.y() / 2, this.size.y() / 2, -1, 1); final Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-this.size.x() / 2, this.size.x() / 2,
final Matrix4f tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1)); -this.size.y() / 2, this.size.y() / 2, -1, 1);
final Matrix4f tmpTranslate = Matrix4f
.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1));
final Matrix4f tmpMat = tmpProjection.multiply(tmpTranslate); final Matrix4f tmpMat = tmpProjection.multiply(tmpTranslate);
// set internal matrix system : // set internal matrix system :
OpenGL.setMatrix(tmpMat); OpenGL.setMatrix(tmpMat);

View File

@ -21,20 +21,22 @@ import org.atriasoft.etk.math.Vector3i;
import org.atriasoft.ewol.DrawProperty; import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.compositing.CompositingDrawing; import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.context.EwolContext; import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject; import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.ewol.resource.ResourceColorFile; import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.backend3d.OpenGL; import org.atriasoft.gale.backend3d.OpenGL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Windows basic interface * Windows basic interface
*/ */
public class Windows extends Widget { public class Windows extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Windows.class);
protected int colorBg = -1; //!< Default background color of the windows protected int colorBg = -1; //!< Default background color of the windows
protected List<Widget> popUpWidgetList = new ArrayList<>(); protected List<Widget> popUpWidgetList = new ArrayList<>();
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName("file-color") @AknotName("file-color")
@ -45,20 +47,20 @@ public class Windows extends Widget {
@AknotName("title") @AknotName("title")
@AknotDescription("Title of the windows") @AknotDescription("Title of the windows")
public String propertyTitle = "No title"; //!< Current title of the windows public String propertyTitle = "No title"; //!< Current title of the windows
protected ResourceColorFile resourceColor = null; //!< theme color property (name of file in @ref propertyColorConfiguration) protected ResourceColorFile resourceColor = null; //!< theme color property (name of file in @ref propertyColorConfiguration)
protected Widget subWidget; protected Widget subWidget;
// internal event at ewol system: // internal event at ewol system:
protected CompositingDrawing vectorialDraw = new CompositingDrawing(); protected CompositingDrawing vectorialDraw = new CompositingDrawing();
protected Windows() { protected Windows() {
this.propertyCanFocus = true; this.propertyCanFocus = true;
onChangePropertyColor(); onChangePropertyColor();
} }
//!< List of pop-up displayed //!< List of pop-up displayed
@Override @Override
public void drawWidgetTree(int level) { public void drawWidgetTree(int level) {
@ -73,15 +75,15 @@ public class Windows extends Widget {
} }
} }
} }
public Uri getPropertyColorConfiguration() { public Uri getPropertyColorConfiguration() {
return this.propertyColorConfiguration; return this.propertyColorConfiguration;
} }
public String getPropertyTitle() { public String getPropertyTitle() {
return this.propertyTitle; return this.propertyTitle;
} }
@Override @Override
public EwolObject getSubObjectNamed(final String objectName) { public EwolObject getSubObjectNamed(final String objectName) {
EwolObject tmpObject = super.getSubObjectNamed(objectName); EwolObject tmpObject = super.getSubObjectNamed(objectName);
@ -107,10 +109,10 @@ public class Windows extends Widget {
// not find ... // not find ...
return null; return null;
} }
@Override @Override
public Widget getWidgetAtPos(final Vector3f pos) { public Widget getWidgetAtPos(final Vector3f pos) {
Log.verbose("Get widget at pos : " + pos); LOGGER.trace("Get widget at pos : " + pos);
// calculate relative position // calculate relative position
final Vector3f relativePos = relativePosition(pos); final Vector3f relativePos = relativePosition(pos);
// event go directly on the pop-up // event go directly on the pop-up
@ -124,16 +126,17 @@ public class Windows extends Widget {
// otherwise the event go to this widget ... // otherwise the event go to this widget ...
return this; return this;
} }
protected void onChangePropertyColor() { protected void onChangePropertyColor() {
this.resourceColor = ResourceColorFile.create(this.propertyColorConfiguration); this.resourceColor = ResourceColorFile.create(this.propertyColorConfiguration);
if (this.resourceColor != null) { if (this.resourceColor != null) {
this.colorBg = this.resourceColor.request("background"); this.colorBg = this.resourceColor.request("background");
} else { } else {
Log.warning("Can not open the default color configuration file for the windows: " + this.propertyColorConfiguration); LOGGER.warn("Can not open the default color configuration file for the windows: "
+ this.propertyColorConfiguration);
} }
} }
@Override @Override
public void onChangeSize() { public void onChangeSize() {
super.onChangeSize(); super.onChangeSize();
@ -153,7 +156,7 @@ public class Windows extends Widget {
} }
} }
} }
@Override @Override
public void onRegenerateDisplay() { public void onRegenerateDisplay() {
if (this.subWidget != null) { if (this.subWidget != null) {
@ -165,7 +168,7 @@ public class Windows extends Widget {
} }
} }
} }
/** /**
* Get the number of pop-up * Get the number of pop-up
* @return Count of pop-up * @return Count of pop-up
@ -173,7 +176,7 @@ public class Windows extends Widget {
public int popUpCount() { public int popUpCount() {
return this.popUpWidgetList.size(); return this.popUpWidgetList.size();
} }
/** /**
* Remove the pop-up on top. * Remove the pop-up on top.
*/ */
@ -183,7 +186,7 @@ public class Windows extends Widget {
} }
this.popUpWidgetList.remove(this.popUpWidgetList.size() - 1); this.popUpWidgetList.remove(this.popUpWidgetList.size() - 1);
} }
/** /**
* Add a pop-up on the Windows. * Add a pop-up on the Windows.
* @param widget Widget to set on top of the pop-up. * @param widget Widget to set on top of the pop-up.
@ -191,7 +194,7 @@ public class Windows extends Widget {
public void popUpWidgetPush(final Widget widget) { public void popUpWidgetPush(final Widget widget) {
if (widget == null) { if (widget == null) {
// nothing to do an error appear : // nothing to do an error appear :
Log.error("can not set widget pop-up (null pointer)"); LOGGER.error("can not set widget pop-up (null pointer)");
return; return;
} }
this.popUpWidgetList.add(widget); this.popUpWidgetList.add(widget);
@ -203,16 +206,16 @@ public class Windows extends Widget {
// TODO : it is dangerous to access directly to the system ... // TODO : it is dangerous to access directly to the system ...
EwolObject.getContext().resetIOEvent(); EwolObject.getContext().resetIOEvent();
} }
//!< main sub-widget of the Windows. //!< main sub-widget of the Windows.
@Override @Override
public void requestDestroyFromChild(final EwolObject child) { public void requestDestroyFromChild(final EwolObject child) {
Log.verbose("A child has been removed"); LOGGER.trace("A child has been removed");
ListIterator<Widget> it = this.popUpWidgetList.listIterator(); ListIterator<Widget> it = this.popUpWidgetList.listIterator();
while (it.hasNext()) { while (it.hasNext()) {
final Widget elem = it.next(); final Widget elem = it.next();
if (elem == child) { if (elem == child) {
Log.verbose(" Find it ..."); LOGGER.trace(" Find it ...");
if (elem != null) { if (elem != null) {
elem.removeParent(); elem.removeParent();
} }
@ -222,7 +225,7 @@ public class Windows extends Widget {
} }
} }
if (this.subWidget == child) { if (this.subWidget == child) {
Log.verbose(" Find it ... 2"); LOGGER.trace(" Find it ... 2");
if (this.subWidget == null) { if (this.subWidget == null) {
return; return;
} }
@ -231,7 +234,7 @@ public class Windows extends Widget {
markToRedraw(); markToRedraw();
} }
} }
public void setPropertyColorConfiguration(final Uri propertyColorConfiguration) { public void setPropertyColorConfiguration(final Uri propertyColorConfiguration) {
if (this.propertyColorConfiguration.equals(propertyColorConfiguration)) { if (this.propertyColorConfiguration.equals(propertyColorConfiguration)) {
return; return;
@ -239,7 +242,7 @@ public class Windows extends Widget {
this.propertyColorConfiguration = propertyColorConfiguration; this.propertyColorConfiguration = propertyColorConfiguration;
onChangePropertyColor(); onChangePropertyColor();
} }
public void setPropertyTitle(final String propertyTitle) { public void setPropertyTitle(final String propertyTitle) {
if (this.propertyTitle.contentEquals(propertyTitle)) { if (this.propertyTitle.contentEquals(propertyTitle)) {
return; return;
@ -249,17 +252,17 @@ public class Windows extends Widget {
if (context.getWindows() == this) { if (context.getWindows() == this) {
context.setTitle(propertyTitle); context.setTitle(propertyTitle);
} else { } else {
Log.info("Set title is delayed ..."); LOGGER.info("Set title is delayed ...");
} }
} }
/** /**
* Set the main widget of the application. * Set the main widget of the application.
* @param widget Widget to set in the windows. * @param widget Widget to set in the windows.
*/ */
public void setSubWidget(final Widget widget) { public void setSubWidget(final Widget widget) {
if (this.subWidget != null) { if (this.subWidget != null) {
Log.info("Remove current main windows Widget..."); LOGGER.info("Remove current main windows Widget...");
this.subWidget.removeParent(); this.subWidget.removeParent();
this.subWidget = null; this.subWidget = null;
} }
@ -270,9 +273,9 @@ public class Windows extends Widget {
// Regenerate the size calculation : // Regenerate the size calculation :
onChangeSize(); onChangeSize();
} }
public void sysDraw() { public void sysDraw() {
//Log.verbose("Draw on " + this.size); //LOGGER.trace("Draw on " + this.size);
// set the size of the open GL system // set the size of the open GL system
OpenGL.setViewPort(Vector3f.ZERO, this.size); OpenGL.setViewPort(Vector3f.ZERO, this.size);
OpenGL.disable(OpenGL.Flag.flag_dither); OpenGL.disable(OpenGL.Flag.flag_dither);
@ -283,11 +286,11 @@ public class Windows extends Widget {
OpenGL.disable(OpenGL.Flag.flag_texture2D); OpenGL.disable(OpenGL.Flag.flag_texture2D);
OpenGL.disable(OpenGL.Flag.flag_depthTest); OpenGL.disable(OpenGL.Flag.flag_depthTest);
OpenGL.disable(OpenGL.Flag.flag_cullFace); OpenGL.disable(OpenGL.Flag.flag_cullFace);
OpenGL.enable(OpenGL.Flag.flag_blend); OpenGL.enable(OpenGL.Flag.flag_blend);
//OpenGL.enable(OpenGL.Flag.flag_cullFace); //OpenGL.enable(OpenGL.Flag.flag_cullFace);
OpenGL.blendFuncAuto(); OpenGL.blendFuncAuto();
// clear the matrix system : // clear the matrix system :
OpenGL.setBasicMatrix(Matrix4f.IDENTITY); OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
final Vector3i tmpSize = new Vector3i((int) this.size.x(), (int) this.size.y(), (int) this.size.z()); final Vector3i tmpSize = new Vector3i((int) this.size.x(), (int) this.size.y(), (int) this.size.z());
@ -295,7 +298,7 @@ public class Windows extends Widget {
systemDraw(displayProp); systemDraw(displayProp);
OpenGL.disable(OpenGL.Flag.flag_blend); OpenGL.disable(OpenGL.Flag.flag_blend);
} }
@Override @Override
public void systemDraw(final DrawProperty displayProp) { public void systemDraw(final DrawProperty displayProp) {
super.systemDraw(displayProp); super.systemDraw(displayProp);
@ -308,19 +311,19 @@ public class Windows extends Widget {
OpenGL.clearColor(Color.PURPLE); OpenGL.clearColor(Color.PURPLE);
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer); OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer); OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
//Log.warning(" WINDOWS draw on " + this.currentDrawId); //LOGGER.warn(" WINDOWS draw on " + this.currentDrawId);
// first display the windows on the display // first display the windows on the display
if (this.subWidget != null) { if (this.subWidget != null) {
this.subWidget.systemDraw(displayProp); this.subWidget.systemDraw(displayProp);
//Log.debug("Draw Windows"); //LOGGER.debug("Draw Windows");
} }
// second display the pop-up // second display the pop-up
for (final Widget it : this.popUpWidgetList) { for (final Widget it : this.popUpWidgetList) {
if (it != null) { if (it != null) {
it.systemDraw(displayProp); it.systemDraw(displayProp);
//Log.debug("Draw Pop-up"); //LOGGER.debug("Draw Pop-up");
} }
} }
} }

View File

@ -15,7 +15,6 @@ import org.atriasoft.aknot.annotation.AknotSignal;
import org.atriasoft.esignal.Signal; import org.atriasoft.esignal.Signal;
import org.atriasoft.esignal.SignalEmpty; import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.Button; import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.CheckBox; import org.atriasoft.ewol.widget.CheckBox;
import org.atriasoft.ewol.widget.Composer; import org.atriasoft.ewol.widget.Composer;
@ -23,17 +22,19 @@ import org.atriasoft.ewol.widget.Entry;
import org.atriasoft.ewol.widget.ImageDisplay; import org.atriasoft.ewol.widget.ImageDisplay;
import org.atriasoft.ewol.widget.Label; import org.atriasoft.ewol.widget.Label;
import org.atriasoft.ewol.widget.ListFileSystem; import org.atriasoft.ewol.widget.ListFileSystem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* File Chooser is a simple selector of file for opening, saving, and what you want ... * File Chooser is a simple selector of file for opening, saving, and what you want ...
* *
* As all other pop-up methode ( wost case we can have) the creating is simple , but event back is not all the time simple: * As all other pop-up methode ( wost case we can have) the creating is simple , but event back is not all the time simple:
* *
* Fist global static declaration and inclusion: * Fist global static declaration and inclusion:
* [code style=c++] * [code style=c++]
* package org.atriasoft.ewol.widget.meta.FileChooser; * package org.atriasoft.ewol.widget.meta.FileChooser;
* [/code] * [/code]
* *
* The first step is to create the file chooser pop-up : (never in the ructor!!!) * The first step is to create the file chooser pop-up : (never in the ructor!!!)
* [code style=c++] * [code style=c++]
* ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create(); * ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create();
@ -59,9 +60,9 @@ import org.atriasoft.ewol.widget.ListFileSystem;
* } * }
* tmpWindows.popUpWidgetPush(tmpWidget); * tmpWindows.popUpWidgetPush(tmpWidget);
* [/code] * [/code]
* *
* Now we just need to wait the the open event message. * Now we just need to wait the the open event message.
* *
* [code style=c++] * [code style=c++]
* void ****::onCallbackOpenFile( String _value) { * void ****::onCallbackOpenFile( String _value) {
* APPL_INFO("Request open file : '" + _value + "'"); * APPL_INFO("Request open file : '" + _value + "'");
@ -73,7 +74,8 @@ import org.atriasoft.ewol.widget.ListFileSystem;
* This is the best example of a Meta-widget. * This is the best example of a Meta-widget.
*/ */
public class FileChooser extends Composer { public class FileChooser extends Composer {
private static final Logger LOGGER = LoggerFactory.getLogger(FileChooser.class);
static void onCallbackButtonCancelPressed(final FileChooser self, final Boolean value) { static void onCallbackButtonCancelPressed(final FileChooser self, final Boolean value) {
if (!value) { if (!value) {
return; return;
@ -82,43 +84,46 @@ public class FileChooser extends Composer {
self.signalCancel.emit(); self.signalCancel.emit();
self.autoDestroy(); self.autoDestroy();
} }
protected static void onCallbackEntryFileChangeValidate(final FileChooser self, final String value) { protected static void onCallbackEntryFileChangeValidate(final FileChooser self, final String value) {
onCallbackListFileValidate(self, value); onCallbackListFileValidate(self, value);
} }
protected static void onCallbackEntryFileChangeValue(final FileChooser self, final String value) { protected static void onCallbackEntryFileChangeValue(final FileChooser self, final String value) {
// == > change the file name.get(.get( // == > change the file name.get(.get(
self.propertyFile = value; self.propertyFile = value;
// update the selected file in the list : // update the selected file in the list :
if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) { if (self.getSubObjectNamed(
"[" + Long.toString(self.getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) {
tmp.setPropertyFile(new File(self.propertyFile)); tmp.setPropertyFile(new File(self.propertyFile));
} }
} }
protected static void onCallbackEntryFolderChangeValue(final FileChooser self, final String value) { protected static void onCallbackEntryFolderChangeValue(final FileChooser self, final String value) {
// == > change the folder name // == > change the folder name
// TODO : change the folder, if it exit ... // TODO : change the folder, if it exit ...
} }
protected static void onCallbackHidenFileChangeChangeValue(final FileChooser self, final Boolean value) { protected static void onCallbackHidenFileChangeChangeValue(final FileChooser self, final Boolean value) {
if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) { if (self.getSubObjectNamed(
"[" + Long.toString(self.getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) {
tmp.setPropertyShowHidden(value); tmp.setPropertyShowHidden(value);
} }
if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) { if (self.getSubObjectNamed(
"[" + Long.toString(self.getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) {
tmp.setPropertyShowHidden(value); tmp.setPropertyShowHidden(value);
} }
} }
protected static void onCallbackHomePressed(final FileChooser self) { protected static void onCallbackHomePressed(final FileChooser self) {
final String tmpUserFolder = System.getProperty("user.home"); final String tmpUserFolder = System.getProperty("user.home");
Log.debug("new PATH: '" + tmpUserFolder + "'"); LOGGER.debug("new PATH: '" + tmpUserFolder + "'");
self.propertyPath = tmpUserFolder; self.propertyPath = tmpUserFolder;
self.propertyFile = ""; self.propertyFile = "";
self.updateCurrentFolder(); self.updateCurrentFolder();
} }
protected static void onCallbackListFileSelectChange(final FileChooser self, final String value) { protected static void onCallbackListFileSelectChange(final FileChooser self, final String value) {
self.setPropertyFile(value); self.setPropertyFile(value);
/* /*
@ -127,55 +132,55 @@ public class FileChooser extends Composer {
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
*/ */
} }
protected static void onCallbackListFileValidate(final FileChooser self, final String value) { protected static void onCallbackListFileValidate(final FileChooser self, final String value) {
// select the file == > generate a validate // select the file == > generate a validate
self.setPropertyFile(value); self.setPropertyFile(value);
Log.verbose(" generate a fiel opening : '" + self.propertyFile + "'"); LOGGER.trace(" generate a fiel opening : '" + self.propertyFile + "'");
self.signalValidate.emit(value); self.signalValidate.emit(value);
self.autoDestroy(); self.autoDestroy();
} }
protected static void onCallbackListFolderSelectChange(final FileChooser self, final String value) { protected static void onCallbackListFolderSelectChange(final FileChooser self, final String value) {
// == > this is an internal event ... // == > this is an internal event ...
Log.debug(" old PATH: '" + self.propertyPath + "' ==> '" + value + "'"); LOGGER.debug(" old PATH: '" + self.propertyPath + "' ==> '" + value + "'");
self.propertyPath = value; self.propertyPath = value;
Log.debug("new PATH: '" + self.propertyPath + "'"); LOGGER.debug("new PATH: '" + self.propertyPath + "'");
self.propertyFile = ""; self.propertyFile = "";
self.updateCurrentFolder(); self.updateCurrentFolder();
} }
protected static void onCallbackListValidate(final FileChooser self, final Boolean value) { protected static void onCallbackListValidate(final FileChooser self, final Boolean value) {
if (!value) { if (!value) {
return; return;
} }
if (self.propertyFile.isEmpty()) { if (self.propertyFile.isEmpty()) {
Log.warning(" Validate : '" + self.propertyFile + "' ==> error No name ..."); LOGGER.warn(" Validate : '" + self.propertyFile + "' ==> error No name ...");
return; return;
} }
Log.debug(" generate a file opening : '" + self.propertyFile + "'"); LOGGER.debug(" generate a file opening : '" + self.propertyFile + "'");
self.signalValidate.emit(self.propertyFile); self.signalValidate.emit(self.propertyFile);
self.autoDestroy(); self.autoDestroy();
} }
@AknotSignal @AknotSignal
@AknotName(value = "cancel") @AknotName(value = "cancel")
@AknotDescription(value = "Cancel button is pressed") @AknotDescription(value = "Cancel button is pressed")
public SignalEmpty signalCancel; //!< abort the display of the pop-up or press cancel button public SignalEmpty signalCancel; //!< abort the display of the pop-up or press cancel button
@AknotSignal @AknotSignal
@AknotName(value = "validate") @AknotName(value = "validate")
@AknotDescription(value = "Validate button is pressed") @AknotDescription(value = "Validate button is pressed")
public Signal<String> signalValidate; //!< select file(s) public Signal<String> signalValidate; //!< select file(s)
// properties // properties
public String propertyPath = System.getProperty("user.home"); //!< Current path to explore public String propertyPath = System.getProperty("user.home"); //!< Current path to explore
public String propertyFile = ""; //!< Selected file public String propertyFile = ""; //!< Selected file
public String propertyLabelTitle = "_T{FileChooser}"; //!< Label of the pop-up (can use translation) public String propertyLabelTitle = "_T{FileChooser}"; //!< Label of the pop-up (can use translation)
public String propertyLabelValidate = "_T{Validate}"; //!< Label of validate button of the pop-up (can use translation) public String propertyLabelValidate = "_T{Validate}"; //!< Label of validate button of the pop-up (can use translation)
public String propertyLabelCancel = "_T{Cancel}"; //!< Label of cancel/close button of the pop-up (can use translation) public String propertyLabelCancel = "_T{Cancel}"; //!< Label of cancel/close button of the pop-up (can use translation)
public FileChooser() { public FileChooser() {
// Load file with replacing the "{ID}" with the local ID of the widget ==> obtain unique ID // Load file with replacing the "{ID}" with the local ID of the widget ==> obtain unique ID
loadFromFile(new Uri("DATA", "ewol-gui-file-chooser.xml", "ewol")); loadFromFile(new Uri("DATA", "ewol-gui-file-chooser.xml", "ewol"));
@ -183,88 +188,96 @@ public class FileChooser extends Composer {
onChangePropertyLabelTitle(); onChangePropertyLabelTitle();
onChangePropertyLabelValidate(); onChangePropertyLabelValidate();
onChangePropertyLabelCancel(); onChangePropertyLabelCancel();
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:show-hiden-file") instanceof final CheckBox tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:show-hiden-file") instanceof final CheckBox tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackHidenFileChangeChangeValue); tmp.signalValue.connectAuto(this, FileChooser::onCallbackHidenFileChangeChangeValue);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:button-validate") instanceof final Button tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:button-validate") instanceof final Button tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackListValidate); tmp.signalValue.connectAuto(this, FileChooser::onCallbackListValidate);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:button-cancel") instanceof final Button tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:button-cancel") instanceof final Button tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackButtonCancelPressed); tmp.signalValue.connectAuto(this, FileChooser::onCallbackButtonCancelPressed);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) {
tmp.signalFolderValidate.connectAuto(this, FileChooser::onCallbackListFolderSelectChange); tmp.signalFolderValidate.connectAuto(this, FileChooser::onCallbackListFolderSelectChange);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) {
tmp.signalFileSelect.connectAuto(this, FileChooser::onCallbackListFileSelectChange); tmp.signalFileSelect.connectAuto(this, FileChooser::onCallbackListFileSelectChange);
tmp.signalFileValidate.connectAuto(this, FileChooser::onCallbackListFileValidate); tmp.signalFileValidate.connectAuto(this, FileChooser::onCallbackListFileValidate);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-file") instanceof final Entry tmp) { if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-file") instanceof final Entry tmp) {
tmp.signalModify.connectAuto(this, FileChooser::onCallbackEntryFileChangeValue); tmp.signalModify.connectAuto(this, FileChooser::onCallbackEntryFileChangeValue);
tmp.signalEnter.connectAuto(this, FileChooser::onCallbackEntryFileChangeValidate); tmp.signalEnter.connectAuto(this, FileChooser::onCallbackEntryFileChangeValidate);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-folder") instanceof final Entry tmp) { if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-folder") instanceof final Entry tmp) {
tmp.signalModify.connectAuto(this, FileChooser::onCallbackEntryFolderChangeValue); tmp.signalModify.connectAuto(this, FileChooser::onCallbackEntryFolderChangeValue);
} }
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:img-home") instanceof final ImageDisplay tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:img-home") instanceof final ImageDisplay tmp) {
tmp.signalPressed.connectAuto(this, FileChooser::onCallbackHomePressed); tmp.signalPressed.connectAuto(this, FileChooser::onCallbackHomePressed);
} }
// set the default Folder properties: // set the default Folder properties:
updateCurrentFolder(); updateCurrentFolder();
setPropertyCanFocus(true); setPropertyCanFocus(true);
} }
public String getPropertyFile() { public String getPropertyFile() {
return this.propertyFile; return this.propertyFile;
} }
public String getPropertyLabelCancel() { public String getPropertyLabelCancel() {
return this.propertyLabelCancel; return this.propertyLabelCancel;
} }
// callback functions: // callback functions:
public String getPropertyLabelTitle() { public String getPropertyLabelTitle() {
return this.propertyLabelTitle; return this.propertyLabelTitle;
} }
public String getPropertyLabelValidate() { public String getPropertyLabelValidate() {
return this.propertyLabelValidate; return this.propertyLabelValidate;
} }
public String getPropertyPath() { public String getPropertyPath() {
return this.propertyPath; return this.propertyPath;
} }
protected void onChangePropertyFile() { protected void onChangePropertyFile() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-file") instanceof final ListFileSystem tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:entry-file") instanceof final ListFileSystem tmp) {
tmp.setPropertyFile(new File(this.propertyFile)); tmp.setPropertyFile(new File(this.propertyFile));
} }
} }
protected void onChangePropertyLabelCancel() { protected void onChangePropertyLabelCancel() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:cancel-label") instanceof final Label tmp) { if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:cancel-label") instanceof final Label tmp) {
tmp.setPropertyValue(this.propertyLabelCancel); tmp.setPropertyValue(this.propertyLabelCancel);
} }
} }
protected void onChangePropertyLabelTitle() { protected void onChangePropertyLabelTitle() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:title-label") instanceof final Label tmp) { if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:title-label") instanceof final Label tmp) {
tmp.setPropertyValue(this.propertyLabelTitle); tmp.setPropertyValue(this.propertyLabelTitle);
} }
} }
protected void onChangePropertyLabelValidate() { protected void onChangePropertyLabelValidate() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:validate-label") instanceof final Label tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:validate-label") instanceof final Label tmp) {
tmp.setPropertyValue(this.propertyLabelValidate); tmp.setPropertyValue(this.propertyLabelValidate);
} }
} }
protected void onChangePropertyPath() { protected void onChangePropertyPath() {
this.propertyPath = this.propertyPath + "/"; this.propertyPath = this.propertyPath + "/";
updateCurrentFolder(); updateCurrentFolder();
} }
@Override @Override
public void onGetFocus() { public void onGetFocus() {
// transfert focus on a specific widget... // transfert focus on a specific widget...
@ -272,7 +285,7 @@ public class FileChooser extends Composer {
tmp.keepFocus(); tmp.keepFocus();
} }
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "file") @AknotName(value = "file")
@ -283,7 +296,7 @@ public class FileChooser extends Composer {
this.propertyFile = propertyFile; this.propertyFile = propertyFile;
onChangePropertyFile(); onChangePropertyFile();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "label-cancel") @AknotName(value = "label-cancel")
@ -295,7 +308,7 @@ public class FileChooser extends Composer {
this.propertyLabelCancel = propertyLabelCancel; this.propertyLabelCancel = propertyLabelCancel;
onChangePropertyLabelCancel(); onChangePropertyLabelCancel();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "title") @AknotName(value = "title")
@ -307,7 +320,7 @@ public class FileChooser extends Composer {
this.propertyLabelTitle = propertyLabelTitle; this.propertyLabelTitle = propertyLabelTitle;
onChangePropertyLabelTitle(); onChangePropertyLabelTitle();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "label-validate") @AknotName(value = "label-validate")
@ -319,7 +332,7 @@ public class FileChooser extends Composer {
this.propertyLabelValidate = propertyLabelValidate; this.propertyLabelValidate = propertyLabelValidate;
onChangePropertyLabelValidate(); onChangePropertyLabelValidate();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "path") @AknotName(value = "path")
@ -331,12 +344,14 @@ public class FileChooser extends Composer {
this.propertyPath = propertyPath; this.propertyPath = propertyPath;
onChangePropertyPath(); onChangePropertyPath();
} }
private void updateCurrentFolder() { private void updateCurrentFolder() {
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:list-files") instanceof final ListFileSystem tmp) {
tmp.setPropertyPath(this.propertyPath); tmp.setPropertyPath(this.propertyPath);
} }
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) { if (getSubObjectNamed(
"[" + Long.toString(getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) {
tmp.setPropertyPath(this.propertyPath); tmp.setPropertyPath(this.propertyPath);
} }
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-folder") instanceof final Entry tmp) { if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-folder") instanceof final Entry tmp) {

View File

@ -7,7 +7,6 @@ import org.atriasoft.aknot.annotation.AknotName;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector3b; import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.ewol.Gravity; import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceConfigFile; import org.atriasoft.ewol.resource.ResourceConfigFile;
import org.atriasoft.ewol.widget.Button; import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.Composer; import org.atriasoft.ewol.widget.Composer;
@ -15,11 +14,14 @@ import org.atriasoft.ewol.widget.Entry;
import org.atriasoft.ewol.widget.Sizer; import org.atriasoft.ewol.widget.Sizer;
import org.atriasoft.ewol.widget.Widget; import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.ewol.widget.model.SpinPosition; import org.atriasoft.ewol.widget.model.SpinPosition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
public class SpinBase extends Sizer { public class SpinBase extends Sizer {
private static final Logger LOGGER = LoggerFactory.getLogger(SpinBase.class);
// properties list: // properties list:
private Uri propertyShape; //!< Shape of the widget private Uri propertyShape; //!< Shape of the widget
private SpinPosition propertySpinMode = SpinPosition.RIGHT_RIGHT; //!< How to display the spin base private SpinPosition propertySpinMode = SpinPosition.RIGHT_RIGHT; //!< How to display the spin base
@ -29,13 +31,13 @@ public class SpinBase extends Sizer {
protected int confIdDownShaper = -1; protected int confIdDownShaper = -1;
protected int confIdUpData = -1; protected int confIdUpData = -1;
protected int confIdDownData = -1; protected int confIdDownData = -1;
protected Entry widgetEntry = null; protected Entry widgetEntry = null;
protected Button widgetButtonDown = null; protected Button widgetButtonDown = null;
protected Button widgetButtonUp = null; protected Button widgetButtonUp = null;
/** /**
* Constructor * Constructor
*/ */
@ -52,7 +54,7 @@ public class SpinBase extends Sizer {
setPropertyGravity(Gravity.CENTER); setPropertyGravity(Gravity.CENTER);
updateGui(); updateGui();
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "shape") @AknotName(value = "shape")
@ -60,7 +62,7 @@ public class SpinBase extends Sizer {
public Uri getPropertyShape() { public Uri getPropertyShape() {
return this.propertyShape; return this.propertyShape;
} }
@AknotManaged @AknotManaged
@AknotAttribute @AknotAttribute
@AknotName(value = "spin-mode") @AknotName(value = "spin-mode")
@ -68,7 +70,7 @@ public class SpinBase extends Sizer {
public SpinPosition getPropertySpinMode() { public SpinPosition getPropertySpinMode() {
return this.propertySpinMode; return this.propertySpinMode;
} }
protected void onChangePropertyShape() { protected void onChangePropertyShape() {
this.config = ResourceConfigFile.create(this.propertyShape); this.config = ResourceConfigFile.create(this.propertyShape);
if (this.config != null) { if (this.config != null) {
@ -80,11 +82,11 @@ public class SpinBase extends Sizer {
} }
markToRedraw(); markToRedraw();
} }
protected void onChangePropertySpinMode() { protected void onChangePropertySpinMode() {
updateGui(); updateGui();
} }
public void setPropertyShape(final Uri propertyShape) { public void setPropertyShape(final Uri propertyShape) {
if (this.propertyShape != null && this.propertyShape.equals(propertyShape)) { if (this.propertyShape != null && this.propertyShape.equals(propertyShape)) {
return; return;
@ -92,7 +94,7 @@ public class SpinBase extends Sizer {
this.propertyShape = propertyShape; this.propertyShape = propertyShape;
onChangePropertyShape(); onChangePropertyShape();
} }
public void setPropertySpinMode(final SpinPosition propertySpinMode) { public void setPropertySpinMode(final SpinPosition propertySpinMode) {
if (this.propertySpinMode == propertySpinMode) { if (this.propertySpinMode == propertySpinMode) {
return; return;
@ -100,7 +102,7 @@ public class SpinBase extends Sizer {
this.propertySpinMode = propertySpinMode; this.propertySpinMode = propertySpinMode;
onChangePropertySpinMode(); onChangePropertySpinMode();
} }
protected void updateGui() { protected void updateGui() {
subWidgetRemoveAll(); subWidgetRemoveAll();
markToRedraw(); markToRedraw();
@ -109,7 +111,7 @@ public class SpinBase extends Sizer {
this.widgetEntry = new Entry(); this.widgetEntry = new Entry();
if (this.config != null) { if (this.config != null) {
final String shaper = this.config.getString(this.confIdEntryShaper); final String shaper = this.config.getString(this.confIdEntryShaper);
Log.verbose("shaper entry : " + shaper); LOGGER.trace("shaper entry : " + shaper);
if (!shaper.isEmpty()) { if (!shaper.isEmpty()) {
this.widgetEntry.setPropertyConfig(Uri.valueOf(shaper)); this.widgetEntry.setPropertyConfig(Uri.valueOf(shaper));
} }
@ -121,7 +123,7 @@ public class SpinBase extends Sizer {
this.widgetButtonDown = new Button(); this.widgetButtonDown = new Button();
if (this.config != null) { if (this.config != null) {
final String shaper = this.config.getString(this.confIdDownShaper); final String shaper = this.config.getString(this.confIdDownShaper);
Log.verbose("shaper button DOWN : " + shaper); LOGGER.trace("shaper button DOWN : " + shaper);
if (!shaper.isEmpty()) { if (!shaper.isEmpty()) {
this.widgetButtonDown.setPropertyConfig(Uri.valueOf(shaper)); this.widgetButtonDown.setPropertyConfig(Uri.valueOf(shaper));
} }
@ -136,7 +138,7 @@ public class SpinBase extends Sizer {
this.widgetButtonUp = new Button(); this.widgetButtonUp = new Button();
if (this.config != null) { if (this.config != null) {
final String shaper = this.config.getString(this.confIdUpShaper); final String shaper = this.config.getString(this.confIdUpShaper);
Log.verbose("shaper button UP : " + shaper); LOGGER.trace("shaper button UP : " + shaper);
if (!shaper.isEmpty()) { if (!shaper.isEmpty()) {
this.widgetButtonUp.setPropertyConfig(Uri.valueOf(shaper)); this.widgetButtonUp.setPropertyConfig(Uri.valueOf(shaper));
} }
@ -178,5 +180,5 @@ public class SpinBase extends Sizer {
break; break;
} }
} }
} }

View File

@ -1,59 +0,0 @@
package test.atriasoft.ewol;
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log {
private static final String LIB_NAME = "etk-test";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
private Log() {}
public static void print(String data) {
if (PRINT_PRINT)
Logger.print(LIB_NAME_DRAW, data);
}
public static void critical(String data) {
if (PRINT_CRITICAL)
Logger.critical(LIB_NAME_DRAW, data);
}
public static void error(String data) {
if (PRINT_ERROR)
Logger.error(LIB_NAME_DRAW, data);
}
public static void warning(String data) {
if (PRINT_WARNING)
Logger.warning(LIB_NAME_DRAW, data);
}
public static void info(String data) {
if (PRINT_INFO)
Logger.info(LIB_NAME_DRAW, data);
}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
public static void verbose(String data) {
if (PRINT_VERBOSE)
Logger.verbose(LIB_NAME_DRAW, data);
}
public static void todo(String data) {
if (PRINT_TODO)
Logger.todo(LIB_NAME_DRAW, data);
}
}

View File

@ -1,18 +0,0 @@
package test.atriasoft.ewol;
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log2 {
private static final String LIB_NAME = "etk-test-2";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private Log2() {}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
}

View File

@ -8,96 +8,19 @@
******************************************************************************/ ******************************************************************************/
package test.atriasoft.ewol; package test.atriasoft.ewol;
import java.util.ArrayList;
import java.util.List;
import org.atriasoft.reggol.Logger;
import org.junit.Test;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.Test; //import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(OrderAnnotation.class) @TestMethodOrder(OrderAnnotation.class)
public class TestBasicLog { public class TestBasicLog {
@Test @Test
@Order(1) @Order(1)
public void aaFirstInitialisation() { public void aaFirstInitialisation() {
List<String> args = new ArrayList<>(); // basic kanva
args.add("--log-level=999");
args.add("--log-level=1");
args.add("--log-no-color");
args.add("--log-color");
args.add("--log-lib=sc-log-test+6");
args.add("--log-lib=sc-log-test/6");
args.add("--log-lib=sc-log-test:6");
args.add("--log-lib=sc-log-test:verbose");
args.add("--log-lib=sc-log-test2+3");
args.add("--log-lib=sc-log-test");
args.add("--log-with-stupid-parameter=sdkfjsqdlkf");
args.add("--help");
Logger.init(args);
} }
@Test
@Order(2)
public void bbSecondInitialisation() {
List<String> args = new ArrayList<>();
Logger.init(args);
}
@Test
@Order(3)
public void ccBasicLogCall() {
Log.print("Simple print");
Log.todo("Simple todo");
Log.error("Simple error");
Log.warning("Simple warning");
Log.info("Simple info");
Log.debug("Simple debug");
Log.verbose("Simple verbose");
}
// TODO REFACTO REMOVE this and set it in the Test of the logger.
public static String getAAAAAAA(int dfsdf) {
int hhh = 0;
for (int kkk = 0; kkk < dfsdf; kkk++)
for (int iii = 0; iii < 10000; iii++)
for (int jjj = 0; jjj < 100000; jjj++)
for (int lll = 0; lll < 100000; lll++)
hhh++;
return "kkk" + hhh;
}
public static void testLog() {
Log.print("test direct [START]");
// test de 10 secondes contre 0.0?? second quand le niveau n'est pas assez grand ...
long timeStart = System.currentTimeMillis();
for (int iii = 0; iii < 100000000; iii++)
Log2.debug("test direct");
long timeStop = System.currentTimeMillis();
Log.print("test direct [END] : " + timeStart + " to " + timeStop + " ==> delta=" + (timeStop - timeStart));
Log.print("test concat [START]");
// C'est très long dans les 2 cas ...
timeStart = System.currentTimeMillis();
for (int iii = 0; iii < 6; iii++)
Log2.debug("test concat: non fonctionnel, il applelle le get a chaque log ... " + getAAAAAAA(iii));
timeStop = System.currentTimeMillis();
Log.print("test concat [END] : " + timeStart + " to " + timeStop + " ==> delta=" + (timeStop - timeStart));
}
@Test
@Order(4)
public void ddTestSimpleLog() {
testLog();
}
@Test
@Order(4)
public void eeUsage() {
Logger.usage();
}
} }