[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"?>
<classpath>
<classpathentry kind="src" path="src">
<classpathentry including="**/*.java" kind="src" output="out/maven/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="resources"/>
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
<classpathentry kind="src" output="out/maven/test-classes" path="test/src">
<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"/>
</attributes>
</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="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</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>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-gale">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-exml">
<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"/>
<classpathentry kind="output" path="out/maven/classes"/>
</classpath>

View File

@ -1,41 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>atriasoft-ewol</name>
<name>ewol</name>
<comment></comment>
<projects>
<project>atriasoft-ewol</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<nature>org.python.pydev.pythonNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</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>

View File

@ -14,5 +14,5 @@ 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.export_scene.emf(filepath="/home/heero/dev/WORKSPACE-game/jatria-soft/ewol/resources/resources/ewol/theme/shape/" + elem + ".emf")
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/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/org/atriasoft/ewol/DrawProperty.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/EwolApplication.java',
'src/org/atriasoft/ewol/context/InputManager.java',

View File

@ -65,7 +65,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() {
if (needRedraw() == false) {
return;
}
Log.debug("redraw");
LOGGER.debug("redraw");
this.text.clear();
this.shaper.clear();
@ -144,7 +144,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
}
}
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 (1 == _event.getId()) {
if(KeyStatus::down == _event.getStatus()) {
@ -161,7 +161,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
// create a context menu :
this.widgetContextMenu = ewol::widget::ContextMenu::create();
if (this.widgetContextMenu == null) {
Log.error("Allocation Error");
LOGGER.error("Allocation Error");
return true;
}
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);
ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) {
Log.error("Can not get the curent Windows...");
LOGGER.error("Can not get the curent Windows...");
this.widgetContextMenu.reset();
} else {
currentWindows.popUpWidgetPush(this.widgetContextMenu);

View File

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

View File

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

View File

@ -75,7 +75,7 @@ class Joystick extends Widget {
_newRatio = 1;
}
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
@ -86,7 +86,7 @@ class Joystick extends Widget {
// TODO : check if it existed
this.background = _imageNameInData;
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
@ -95,7 +95,7 @@ class Joystick extends Widget {
public void foreground(String _imageNameInData) {
// TODO : check if it existed
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
@ -189,7 +189,7 @@ class Joystick extends Widget {
signalMove.emit(this.angle+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;
} else if( KeyStatus::up == typeEvent) {
if( true == this.lock

View File

@ -48,16 +48,16 @@ public class Menu extends Sizer
ewol::widget::Sizer::subWidgetRemoveAll();
}
private int subWidgetAdd(Widget _newWidget){
Log.error("Not availlable");
LOGGER.error("Not availlable");
return -1;
}
private void subWidgetRemove(Widget _newWidget){
Log.error("Not availlable");
LOGGER.error("Not availlable");
}
private void subWidgetUnLink(Widget _newWidget){
Log.error("Not availlable");
LOGGER.error("Not availlable");
}
protected static final String eventButtonPressed = "menu-local-pressed";
private boolean loadXML( exml::Element _node) ;
@ -98,7 +98,7 @@ public class Menu extends Sizer
if (tmpObject.this.parentId == -1) {
ewol::widget::Button myButton = ewol::widget::Button::create();
if (myButton == null) {
Log.error("Allocation button error");
LOGGER.error("Allocation button error");
return tmpObject.this.localId;
}
if (tmpObject.this.image.size()!=0) {
@ -137,7 +137,7 @@ public class Menu extends Sizer
if (tmpObject.this.parentId == -1) {
ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) {
Log.error("Allocation spacer error");
LOGGER.error("Allocation spacer error");
return tmpObject.this.localId;
}
mySpacer.propertyExpand.set(Vector2b(true,true));
@ -153,7 +153,7 @@ public class Menu extends Sizer
}
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 ...
if (it.this.message.size() > 0) {
Log.debug("Menu == > generate Event");
LOGGER.debug("Menu == > generate Event");
// Send a multicast event ...
signalSelect.emit(it.this.message);
ewol::widget::ContextMenu tmpContext = this.widgetContextMenu.lock();
if (tmpContext != null) {
Log.debug("Mark the menu to remove ...");
LOGGER.debug("Mark the menu to remove ...");
tmpContext.destroy();
}
return;
}
Log.debug("Menu == > load Sub Menu");
LOGGER.debug("Menu == > load Sub Menu");
boolean findChild = false;
for (auto it2 : this.listElement) {
if (it.this.localId == it2.this.parentId) {
@ -188,14 +188,14 @@ public class Menu extends Sizer
}
}
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;
}
// create a context menu:
ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create();
this.widgetContextMenu = tmpContext;
if (tmpContext == null) {
Log.error("Allocation Error");
LOGGER.error("Allocation Error");
return;
}
// 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 == "") {
ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) {
Log.error("Allocation spacer error");
LOGGER.error("Allocation spacer error");
continue;
}
mySpacer.propertyExpand.set(Vector2b(true,true));
@ -248,7 +248,7 @@ public class Menu extends Sizer
} else {
myButton = ewol::widget::Button::create();
if (myButton == null) {
Log.error("Allocation Error");
LOGGER.error("Allocation Error");
continue;
}
myButton.propertyExpand.set(Vector2b(true,true));
@ -293,7 +293,7 @@ public class Menu extends Sizer
}
ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) {
Log.error("Can not get the curent Windows...");
LOGGER.error("Can not get the curent Windows...");
} else {
currentWindows.popUpWidgetPush(tmpContext);
}
@ -316,7 +316,7 @@ boolean ewol::widget::Menu::loadXML( exml::Element _node) {
continue;
}
String widgetName = pNode.getValue();
Log.info("Get node : " + pNode);
LOGGER.info("Get node : " + pNode);
if (widgetName == "elem") {
// <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"]);
@ -334,13 +334,13 @@ boolean ewol::widget::Menu::loadXML( exml::Element _node) {
} else if (widgetName2 == "separator") {
addSpacer(idMenu);
} 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") {
addSpacer();
} 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;

View File

@ -72,7 +72,7 @@ class Select extends SpinBase {
protected List<ewol::widget::Select::Element> this.listElement;
public void optionSelectDefault(){
if (this.widgetEntry == null) {
Log.error("Can not acces at entry ...");
LOGGER.error("Can not acces at entry ...");
return;
}
for (auto it : this.listElement) {
@ -88,7 +88,7 @@ class Select extends SpinBase {
public void optionRemove(int _value){
for (auto it=this.listElement.begin(); it != this.listElement.end(); ++it) {
if (_value == it.this.value) {
Log.debug("remove element: " + _value);
LOGGER.debug("remove element: " + _value);
this.listElement.erase(it);
break;
}
@ -104,7 +104,7 @@ class Select extends SpinBase {
public void optionAdd(int _value, String _name) {
for (auto it : this.listElement) {
if (_value == it.this.value) {
Log.debug("replace element: " + _value + " with: '" + _data + "'");
LOGGER.debug("replace element: " + _value + " with: '" + _data + "'");
it.this.name = _data;
}
}
@ -127,7 +127,7 @@ class Select extends SpinBase {
continue;
}
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;
}
String valId = pNode.attributes["id"];
@ -139,7 +139,7 @@ class Select extends SpinBase {
if (select == true) {
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;
}
@ -161,7 +161,7 @@ class Select extends SpinBase {
// create a context menu:
ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create();
if (tmpContext == null) {
Log.error("Allocation Error");
LOGGER.error("Allocation Error");
return;
}
// auto-select mark position:
@ -169,7 +169,7 @@ class Select extends SpinBase {
ewol::widget::Sizer mySizer;
mySizer = ewol::widget::Sizer::create();
if (mySizer == null) {
Log.error("Allocation Error or sizer");
LOGGER.error("Allocation Error or sizer");
return;
}
mySizer.propertyMode.set(widget::Sizer::modeVert);
@ -180,7 +180,7 @@ class Select extends SpinBase {
for (auto it : this.listElement) {
ewol::widget::Label myLabel = ewol::widget::Label::create();
if (myLabel == null) {
Log.error("Allocation Error");
LOGGER.error("Allocation Error");
continue;
}
if (it.this.selected == true) {
@ -198,13 +198,13 @@ class Select extends SpinBase {
}
ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) {
Log.error("Can not get the curent Windows...");
LOGGER.error("Can not get the curent Windows...");
} else {
currentWindows.popUpWidgetPush(tmpContext);
}
}
protected void onCallbackLabelPressed(int _value){
Log.verbose("User select:" + _value);
LOGGER.trace("User select:" + _value);
propertyValue.set(_value);
}
protected esignal::Connection connectionEntry = null;
@ -212,7 +212,7 @@ class Select extends SpinBase {
protected void onChangePropertyValue(){
markToRedraw();
if (this.widgetEntry == null) {
Log.error("Can not acces at entry ...");
LOGGER.error("Can not acces at entry ...");
return;
}
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.print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get()));
} else {
Log.error("can not get : " + iconName );
LOGGER.error("can not get : " + iconName );
}
// move right
posStart.setX(posStart.x() + propertyIconTreeViewSize.get());
@ -161,7 +161,7 @@ boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2
if (_pos.x() != 0) {
return false;
}
//Log.info("event: " + _event);
//LOGGER.info("event: " + _event);
Vector2f posStart = Vector2f(0,0);
boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean();
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());
}
// 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
+ " . " + (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get())));
if ( _mousePosition.x() >= posStart.x()

View File

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

View File

@ -44,9 +44,9 @@ void ewol::widget::Parameter::init() {
mySizerVert = ewol::widget::Sizer::create();
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 {
Log.info("add widget");
LOGGER.info("add widget");
mySizerVert.propertyMode.set(widget::Sizer::modeVert);
mySizerVert.propertyLockExpand.set(Vector2b(true,true));
mySizerVert.propertyExpand.set(Vector2b(true,true));
@ -55,14 +55,14 @@ void ewol::widget::Parameter::init() {
mySizerHori = ewol::widget::Sizer::create();
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 {
mySizerHori.propertyMode.set(widget::Sizer::modeHori);
mySizerVert.subWidgetAdd(mySizerHori);
mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error");
LOGGER.error("Can not allocate widget == > display might be in error");
} else {
mySpacer.propertyExpand.set(Vector2b(true,false));
mySizerHori.subWidgetAdd(mySpacer);
@ -70,7 +70,7 @@ void ewol::widget::Parameter::init() {
ewol::widget::Button tmpButton = widget::Button::create();
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 {
tmpButton.setSubWidget(ewol::widget::composerGenerateString(
"<sizer mode='hori'>\n"
@ -83,7 +83,7 @@ void ewol::widget::Parameter::init() {
mySpacer = ewol::widget::Spacer::create();
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 {
mySpacer.propertyExpand.set(Vector2b(false,false));
mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(10,0)));
@ -92,7 +92,7 @@ void ewol::widget::Parameter::init() {
tmpButton = ewol::widget::Button::create();
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 {
tmpButton.setSubWidget(ewol::widget::composerGenerateString(
"<sizer mode='hori'>\n"
@ -106,14 +106,14 @@ void ewol::widget::Parameter::init() {
mySizerHori = ewol::widget::Sizer::create();
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 {
mySizerHori.propertyMode.set(widget::Sizer::modeHori);
mySizerVert.subWidgetAdd(mySizerHori);
this.paramList = ewol::widget::ParameterList::create();
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 {
this.paramList.signalSelect.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackMenuSelected);
@ -123,7 +123,7 @@ void ewol::widget::Parameter::init() {
}
mySpacer = ewol::widget::Spacer::create();
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 {
mySpacer.propertyFill.set(Vector2b(false,true));
mySpacer.propertyMinSize.set(Vector2f(5,5));
@ -133,14 +133,14 @@ void ewol::widget::Parameter::init() {
ewol::widget::Sizer mySizerVert2 = widget::Sizer::create();
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 {
mySizerVert2.propertyMode.set(widget::Sizer::modeVert);
mySizerHori.subWidgetAdd(mySizerVert2);
mySpacer = ewol::widget::Spacer::create();
if (mySpacer == null) {
Log.error("Can not allocate widget == > display might be in error");
LOGGER.error("Can not allocate widget == > display might be in error");
} else {
mySpacer.propertyExpand.set(Vector2b(true,false));
mySpacer.propertyMinSize.set(Vector2f(5,5));
@ -150,7 +150,7 @@ void ewol::widget::Parameter::init() {
this.wSlider = ewol::widget::WSlider::create();
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 {
this.wSlider.propertyTransitionSpeed.set(0.5);
this.wSlider.propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert);
@ -162,7 +162,7 @@ void ewol::widget::Parameter::init() {
mySpacer = ewol::widget::Spacer::create();
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 {
mySpacer.propertyExpand.set(Vector2b(true,false));
mySpacer.propertyMinSize.set(Vector2f(5,5));
@ -172,7 +172,7 @@ void ewol::widget::Parameter::init() {
this.widgetTitle = ewol::widget::Label::create();
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 {
this.widgetTitle.propertyValue.set(propertyLabelTitle);
this.widgetTitle.propertyExpand.set(Vector2b(true,false));
@ -200,11 +200,11 @@ void ewol::widget::Parameter::onCallbackMenuclosed() {
}
void ewol::widget::Parameter::onCallbackParameterSave() {
//ewol::userConfig::Save();
Log.todo("Save Parameter !!! ");
LOGGER.info("[TODO] Save Parameter !!! ");
}
void ewol::widget::Parameter::onCallbackMenuSelected( int _value) {
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);
}
}
@ -216,10 +216,10 @@ void ewol::widget::Parameter::menuAdd(String _label, String _image, Widget _asso
if (_associateWidget != null) {
this.wSlider.subWidgetAdd(_associateWidget);
} else {
Log.debug("Associate an empty widget on it ...");
LOGGER.debug("Associate an empty widget on it ...");
ewol::widget::Label myLabel = widget::Label::create();
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 {
myLabel.propertyValue.set(String("No widget for : ") + _label);
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) {
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;
}
if (_pos < 0 || (int)_pos >= this.listOObject.size() ) {
@ -79,7 +79,7 @@ void ewol::widget::ParameterList::onRegenerateDisplay() {
if (needRedraw() == true) {
// clean the object list ...
clearOObjectList();
//Log.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")");
//LOGGER.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")");
int tmpOriginX = 0;
int tmpOriginY = 0;
@ -195,17 +195,17 @@ boolean ewol::widget::ParameterList::onEventInput( ewol::event::Input _event) {
}
void ewol::widget::ParameterList::onGetFocus() {
Log.debug("Ewol::List get focus");
LOGGER.debug("Ewol::List get focus");
}
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) {
ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, _refId, _image, false);
if (tmpEmement == null) {
Log.error("Can not allocacte menu parameter");
LOGGER.error("Can not allocacte menu parameter");
return;
}
this.list.pushBack(tmpEmement);
@ -219,7 +219,7 @@ void ewol::widget::ParameterList::menuAddGroup(String _label) {
String image = "";
ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, -1, image, true);
if (tmpEmement == null) {
Log.error("Can not allocacte menu parameter");
LOGGER.error("Can not allocacte menu parameter");
return;
}
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) {
if (this.subBar == null) {
Log.error("button-bar does not existed ...");
LOGGER.error("button-bar does not existed ...");
return null;
}
ewol::widget::Button myButton = widget::Button::create();
if (myButton == null) {
Log.error("Can not allocate new button ...");
LOGGER.error("Can not allocate new button ...");
return null;
}
ewol::widget::Label myLabel = ewol::widget::Label::create();
if (myLabel == null) {
Log.error("Can not allocate new label ...");
LOGGER.error("Can not allocate new label ...");
return null;
}
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 {
final Object oldValue = pojo.getValue(widget);
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)));
}
} catch (final AknotException e) {
@ -209,7 +209,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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)));
}
} catch (final AknotException e) {
@ -253,7 +253,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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)));
}
} catch (final AknotException e) {
@ -285,7 +285,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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)));
}
} catch (final AknotException e) {
@ -317,7 +317,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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)));
}
} catch (final AknotException e) {
@ -346,7 +346,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> {
try {
Log.warning("Set new value: {}", valueButton);
LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, (double) valueButton);
} catch (final AknotException e) {
e.printStackTrace();
@ -373,7 +373,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> {
try {
Log.warning("Set new value: {}", valueButton);
LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, (float) valueButton);
} catch (final AknotException e) {
e.printStackTrace();
@ -430,7 +430,7 @@ public class BasicWindows extends Windows {
state = new Gravity(GravityHorizontal.LEFT, GravityVertical.BOTTOM, GravityDepth.CENTER);
}
gravLabel.setPropertyValue(LABEL_GRAVITY + state.toString());
Log.warning("Set new value: {}", state);
LOGGER.warn("Set new value: {}", state);
pojo.setExistingValue(widget, state);
}
} catch (final AknotException e) {
@ -458,7 +458,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> {
try {
Log.warning("Set new value: {}", valueButton);
LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, (int) (long) valueButton);
} catch (final AknotException e) {
@ -486,7 +486,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(spin);
final Connection con = spin.signalValue.connect((valueButton) -> {
try {
Log.warning("Set new value: {}", valueButton);
LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, valueButton);
} catch (final AknotException e) {
e.printStackTrace();
@ -513,7 +513,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(element);
final Connection con = element.signalModify.connect((valueButton) -> {
try {
Log.warning("Set new value: {}", valueButton);
LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, valueButton);
} catch (final AknotException e) {
e.printStackTrace();
@ -540,7 +540,7 @@ public class BasicWindows extends Windows {
this.sizerMenu.subWidgetAdd(element);
final Connection con = element.signalModify.connect((valueButton) -> {
try {
Log.warning("Set new value: {}", valueButton);
LOGGER.warn("Set new value: {}", valueButton);
pojo.setExistingValue(widget, Uri.valueOf(valueButton));
} catch (final AknotException e) {
e.printStackTrace();
@ -574,7 +574,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -638,7 +638,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -670,7 +670,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -714,7 +714,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -746,7 +746,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -782,7 +782,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -865,7 +865,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -897,7 +897,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -929,7 +929,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -973,7 +973,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -1005,7 +1005,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -1037,7 +1037,7 @@ public class BasicWindows extends Windows {
try {
final Object oldValue = pojo.getValue(widget);
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));
}
} catch (final AknotException e) {
@ -1051,40 +1051,40 @@ public class BasicWindows extends Windows {
}
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();
for (final IntrospectionProperty pojo : signals) {
Log.warning(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames()));
Log.warning(" ==> description='{}'", pojo.getDescription());
Log.warning(" ==> type='{}'", pojo.getType());
Log.warning(" ==> sub-type='{}'", pojo.getSubType());
LOGGER.warn(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames()));
LOGGER.warn(" ==> description='{}'", pojo.getDescription());
LOGGER.warn(" ==> type='{}'", pojo.getType());
LOGGER.warn(" ==> sub-type='{}'", pojo.getSubType());
final String eventName = pojo.getNames() != null && pojo.getNames().length != 0 ? pojo.getNames()[0] : pojo.getBeanName();
if (pojo.getSubType() != null && pojo.getType() == Signal.class) {
Log.warning(" ** Signal<{}>", pojo.getSubType());
LOGGER.warn(" ** Signal<{}>", pojo.getSubType());
final Object signalObject = pojo.getValue(widget);
if (signalObject == null) {
Log.error("Signal is not accessible !!!!!!! ");
LOGGER.error("Signal is not accessible !!!!!!! ");
} else {
final String valueNameOfSignal = eventName;
@SuppressWarnings("unchecked")
final Signal<Object> tmp = (Signal<Object>) signalObject;
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) {
Log.warning(" ** SignalEmpty");
LOGGER.warn(" ** SignalEmpty");
final Object signalObject = pojo.getValue(widget);
if (signalObject == null) {
Log.error("Signal is not accessible !!!!!!! ");
LOGGER.error("Signal is not accessible !!!!!!! ");
} else {
final String valueNameOfSignal = eventName;
final SignalEmpty tmp = (SignalEmpty) signalObject;
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 {
Log.warning("Connect all property(ies) on '{}'", widget.getName());
LOGGER.warn("Connect all property(ies) on '{}'", widget.getName());
final List<IntrospectionProperty> atributes = modelPojo.getAttributes();
for (final IntrospectionProperty pojo : atributes) {
Log.warning(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames()));
Log.warning(" ==> description='{}'", pojo.getDescription());
Log.warning(" ==> type='{}'", pojo.getType());
Log.warning(" ==> sub-type='{}'", pojo.getSubType());
LOGGER.warn(" - '{}' otherNames={}", pojo.getBeanName(), Arrays.toString(pojo.getNames()));
LOGGER.warn(" ==> description='{}'", pojo.getDescription());
LOGGER.warn(" ==> type='{}'", pojo.getType());
LOGGER.warn(" ==> sub-type='{}'", pojo.getSubType());
final String propertyName = pojo.getNames() != null && pojo.getNames().length != 0 ? pojo.getNames()[0] : pojo.getBeanName();
if (pojo.getType() == int.class || pojo.getType() == Integer.class) {
addMenuInt(widget, pojo);
@ -1130,13 +1130,13 @@ public class BasicWindows extends Windows {
} else if (pojo.getType() == Dimension2f.class) {
addMenuDimension2f(widget, pojo);
} else if (pojo.getType() == DisplayMode.class) {
Log.error(" ==> plop");
LOGGER.error(" ==> plop");
} else if (pojo.getType() == Uri.class) {
addMenuURI(widget, pojo);
} else if (pojo.getType() == Gravity.class) {
addMenuGravity(widget, pojo);
} else {
Log.error(" ==> property type unknown='{}'", pojo.getType());
LOGGER.error(" ==> property type unknown='{}'", pojo.getType());
}
{
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++) {
String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help");
LOGGER.print(" -h/--help display this help");
System.exit(0);
}
}
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override
public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]");
LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context);
Log.info("Application onCreate: [ END ]");
LOGGER.info("Application onCreate: [ END ]");
}
@Override
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
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
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
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
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 {
private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "ewol-sample";
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);
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LOGGER.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.PRINT);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LOGGER.LIB_NAME, LogLevel.WARNING);
public static void critical(final Exception e, final String data) {
e.printStackTrace();

View File

@ -16,7 +16,7 @@ public class Appl implements EwolApplication {
for (int iii = 0; iii < context.getCmd().size(); iii++) {
String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help");
LOGGER.print(" -h/--help display this help");
System.exit(0);
}
}
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override
public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]");
LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context);
Log.info("Application onCreate: [ END ]");
LOGGER.info("Application onCreate: [ END ]");
}
@Override
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
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
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
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
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++) {
String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help");
LOGGER.print(" -h/--help display this help");
System.exit(0);
}
}
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override
public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]");
LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context);
Log.info("Application onCreate: [ END ]");
LOGGER.info("Application onCreate: [ END ]");
}
@Override
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
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
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
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
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++) {
String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help");
LOGGER.print(" -h/--help display this help");
System.exit(0);
}
}
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override
public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]");
LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context);
Log.info("Application onCreate: [ END ]");
LOGGER.info("Application onCreate: [ END ]");
}
@Override
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
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
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
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
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++) {
final String tmpppp = context.getCmd().get(iii);
if (tmpppp == "-h" || tmpppp == "--help") {
Log.print(" -h/--help display this help");
LOGGER.print(" -h/--help display this help");
System.exit(0);
}
}
@ -39,44 +39,44 @@ public class Appl implements EwolApplication {
@Override
public void onCreate(final EwolContext context) {
Log.info("Application onCreate: [BEGIN]");
LOGGER.info("Application onCreate: [BEGIN]");
localCreate(context);
Log.info("Application onCreate: [ END ]");
LOGGER.info("Application onCreate: [ END ]");
}
@Override
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
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
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
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
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.widget;
exports org.atriasoft.ewol.widget.meta;
requires transitive org.atriasoft.esignal;
requires transitive org.atriasoft.iogami;
requires transitive org.atriasoft.gale;
@ -22,7 +22,6 @@ open module org.atriasoft.ewol {
requires transitive org.atriasoft.esvg;
requires transitive org.atriasoft.exml;
requires transitive org.atriasoft.ejson;
requires transitive org.atriasoft.reggol;
requires org.atriasoft.loader3d;
requires org.atriasoft.egami;
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.JsonObject;
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
@ -21,6 +22,7 @@ import org.atriasoft.ewol.internal.Log;
* Portuguese, Brazilian : "PT" Chinese : "ZH"
*/
public class ETranslate {
private static final Logger LOGGER = LoggerFactory.getLogger(ETranslate.class);
private static boolean globalIsInit = false;
private static String globalLanguage = "";
private static String globalLanguageDefault = "EN";
@ -29,13 +31,6 @@ public class ETranslate {
private static Map<String, String> globalTranslate = new HashMap<>();
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
* @param lib Library name that the path depend
@ -51,7 +46,7 @@ public class ETranslate {
ETranslate.globalListPath.put(lib, uri);
if (major) {
ETranslate.globalMajor = lib;
Log.info("Change major translation : '" + ETranslate.globalMajor + "'");
LOGGER.info("Change major translation : '" + ETranslate.globalMajor + "'");
}
ETranslate.globalTranslateLoadad = false;
ETranslate.globalTranslate.clear();
@ -62,23 +57,23 @@ public class ETranslate {
*/
public static void autoDetectLanguage() {
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 userLocalName = "EN";
final String globalLocalName = "EN";
/*
* try { nonameLocalName = setlocale(LC_ALL, ""); userLocalName =
* setlocale(LC_MESSAGES, ""); globalLocalName = setlocale(LC_CTYPE, "");
* Log.error(" The default locale is '" + globalLocalName + "'");
* Log.error(" The user's locale is '" + userLocalName + "'");
* Log.error(" A nameless locale is '" + nonameLocalName + "'"); } catch (int
* LOGGER.error(" The default locale is '" + globalLocalName + "'");
* LOGGER.error(" The user's locale is '" + userLocalName + "'");
* LOGGER.error(" A nameless locale is '" + nonameLocalName + "'"); } catch (int
* 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;
if (lang.equals("*") || lang.isEmpty()) {
@ -92,7 +87,7 @@ public class ETranslate {
}
lang = lang.substring(0, 2);
lang = lang.toUpperCase();
Log.info("Select Language : '" + lang + "'");
LOGGER.info("Select Language : '" + lang + "'");
ETranslate.setLanguage(lang);
}
@ -104,14 +99,14 @@ public class ETranslate {
*/
public static String get(final String instance) {
ETranslate.loadTranslation();
Log.verbose("Request translate: '" + instance + "'");
LOGGER.trace("Request translate: '" + instance + "'");
// find all iterance of 'T{' ... '}'
final String out = Pattern.compile("_T\\{(.*)\\}").matcher(instance).replaceAll(mr -> {
final String data = mr.group(1);
Log.info("translate : '" + data + "'");
LOGGER.info("translate : '" + data + "'");
final String itTranslate = ETranslate.globalTranslate.get(data);
if (itTranslate == null) {
Log.debug("Can not find tranlation : '" + instance + "'");
LOGGER.debug("Can not find tranlation : '" + instance + "'");
return data;
}
return itTranslate;
@ -148,8 +143,9 @@ public class ETranslate {
if (ETranslate.globalTranslateLoadad) {
return;
}
Log.debug("Load Translation MAJOR='" + ETranslate.globalMajor + "' LANG='" + ETranslate.globalLanguage + "' default=" + ETranslate.globalLanguageDefault);
Log.debug("list path=" + ETranslate.globalListPath.keySet());
LOGGER.debug("Load Translation MAJOR='" + ETranslate.globalMajor + "' LANG='" + ETranslate.globalLanguage
+ "' default=" + ETranslate.globalLanguageDefault);
LOGGER.debug("list path=" + ETranslate.globalListPath.keySet());
// start parse language for Major:
final Uri itMajor = ETranslate.globalListPath.get(ETranslate.globalMajor);
if (itMajor != null) {
@ -158,7 +154,7 @@ public class ETranslate {
final JsonObject root = (JsonObject) Ejson.parse(uri);
for (final Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) {
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);
}
} catch (final Exception e) {
@ -170,7 +166,7 @@ public class ETranslate {
final JsonObject root = (JsonObject) Ejson.parse(uri);
for (final Map.Entry<String, JsonNode> element : root.getNodes().entrySet()) {
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);
}
} catch (final Exception e) {
@ -197,7 +193,7 @@ public class ETranslate {
}
for (final Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) {
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);
}
}
@ -206,7 +202,8 @@ public class ETranslate {
if (it.getKey().contentEquals(ETranslate.globalMajor)) {
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; }
*/
@ -220,7 +217,7 @@ public class ETranslate {
}
for (final Map.Entry<String, JsonNode> element : doc.getNodes().entrySet()) {
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);
}
}
@ -241,27 +238,27 @@ public class ETranslate {
ETranslate.globalTranslateLoadad = false;
ETranslate.globalTranslate.clear();
if (lang.equals("EN")) {
Log.info("Change language translation: '" + lang + "'=English");
LOGGER.info("Change language translation: '" + lang + "'=English");
} else if (lang.equals("FR")) {
Log.info("Change language translation: '" + lang + "'=French");
LOGGER.info("Change language translation: '" + lang + "'=French");
} else if (lang.equals("DE")) {
Log.info("Change language translation: '" + lang + "'=German");
LOGGER.info("Change language translation: '" + lang + "'=German");
} else if (lang.equals("SP")) {
Log.info("Change language translation: '" + lang + "'=Spanish");
LOGGER.info("Change language translation: '" + lang + "'=Spanish");
} else if (lang.equals("JA")) {
Log.info("Change language translation: '" + lang + "'=Japanese");
LOGGER.info("Change language translation: '" + lang + "'=Japanese");
} else if (lang.equals("IT")) {
Log.info("Change language translation: '" + lang + "'=Italian");
LOGGER.info("Change language translation: '" + lang + "'=Italian");
} else if (lang.equals("KO")) {
Log.info("Change language translation: '" + lang + "'=Korean");
LOGGER.info("Change language translation: '" + lang + "'=Korean");
} else if (lang.equals("RU")) {
Log.info("Change language translation: '" + lang + "'=Russian");
LOGGER.info("Change language translation: '" + lang + "'=Russian");
} 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")) {
Log.info("Change language translation: '" + lang + "'=Chinese");
LOGGER.info("Change language translation: '" + lang + "'=Chinese");
} 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)) {
return;
}
Log.info("Change default language translation : '" + lang + "'");
LOGGER.info("Change default language translation : '" + lang + "'");
ETranslate.globalLanguageDefault = lang;
ETranslate.globalTranslateLoadad = false;
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.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingDrawing extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingDrawing.class);
protected static int vboIdColor = 1;
protected static int vboIdCoord = 0;
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 final List<Color> outColors = new ArrayList<>();
private final List<Vector3f> outTriangles = new ArrayList<>();
private Vector3f position = new Vector3f(0, 0, 0); // !< The current position to draw
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 Color[] tricolor = new Color[3]; // !< Register every the associated color foreground
private int triElement = 0; // !< special counter of the single dot generated
//protected ResourceVirtualBufferObject vbo;
protected ResourceVirtualArrayObject vbo;
// internal API for the generation abstraction of triangles
/**
* Basic ructor
@ -64,7 +66,7 @@ public class CompositingDrawing extends Compositing {
// TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of ewol::compositing::Area");
}
/**
* add a point reference at the current position (this is a vertex
* reference at the current position
@ -73,7 +75,7 @@ public class CompositingDrawing extends Compositing {
internalSetColor(this.color);
setPoint(this.position);
}
/**
* draw a 2D circle with the specify rafdius parameter.
* @param radius Distence to the dorder
@ -83,73 +85,73 @@ public class CompositingDrawing extends Compositing {
public void circle(final float radius) {
circle(radius, 0);
}
public void circle(final float radius, final float angleStart) {
circle(radius, angleStart, 2.0f * FMath.PI);
}
public void circle(float radius, final float angleStart, float angleStop) {
resetCount();
if (radius < 0) {
radius *= -1;
}
angleStop = angleStop - angleStart;
int nbOcurence = (int) radius;
if (nbOcurence < 10) {
nbOcurence = 10;
}
// display background :
if (this.colorBg.a() != 0) {
internalSetColor(this.colorBg);
for (int iii = 0; iii < nbOcurence; iii++) {
setPoint(new Vector3f(this.position.x(), this.position.y(), 0));
final float angleOne = angleStart + (angleStop * iii / nbOcurence);
float offsety = FMath.sin(angleOne) * radius;
float offsetx = FMath.cos(angleOne) * radius;
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0));
final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
offsety = FMath.sin(angleTwo) * radius;
offsetx = FMath.cos(angleTwo) * radius;
setPoint(new Vector3f(this.position.x() + offsetx, this.position.y() + offsety, 0));
}
}
// show if we have a border :
if (this.thickness == 0 || this.color.a() == 0) {
return;
}
internalSetColor(this.color);
for (int iii = 0; iii < nbOcurence; iii++) {
final float angleOne = angleStart + (angleStop * iii / nbOcurence);
final float offsetExty = FMath.sin(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 offsetIntx = FMath.cos(angleOne) * (radius - this.thickness / 2);
final float angleTwo = angleStart + (angleStop * (iii + 1) / nbOcurence);
final float offsetExt2y = FMath.sin(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 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() + 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() + offsetInt2x, this.position.y() + offsetInt2y, 0));
setPoint(new Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
}
}
/**
* clear alll tre registered element in the current element
*/
@ -161,35 +163,35 @@ public class CompositingDrawing extends Compositing {
this.vbo.clear();
this.outTriangles.clear();
this.outColors.clear();
// reset temporal variables :
this.position = Vector3f.ZERO;
this.clippingPosStart = Vector3f.ZERO;
this.clippingPosStop = Vector3f.ZERO;
this.clippingEnable = false;
this.color = Color.BLACK;
this.colorBg = Color.NONE;
for (int iii = 0; iii < 3; iii++) {
this.triangle[iii] = this.position;
this.tricolor[iii] = this.color;
}
}
/**
* draw All the refistered text in the current element on openGL
*/
@Override
public void draw(final boolean disableDepthTest) {
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
// set Matrix : translation/positionMatrix
Matrix4f projMatrix = OpenGL.getMatrix();
Matrix4f camMatrix = OpenGL.getCameraMatrix();
final Matrix4f projMatrix = OpenGL.getMatrix();
final Matrix4f camMatrix = OpenGL.getCameraMatrix();
this.oGLprogram.use();
this.vbo.bindForRendering();
this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix);
@ -200,7 +202,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.unBindForRendering();
this.oGLprogram.unUse();
}
@Override
public void flush() {
// push data on the VBO
@ -208,7 +210,7 @@ public class CompositingDrawing extends Compositing {
this.vbo.setColors(this.outColors.toArray(Color[]::new));
this.vbo.setVertexCount(this.outTriangles.size());
}
/**
* 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[2]);
}
/**
* Get the foreground color of the font.
* @return Foreground color.
@ -229,7 +231,7 @@ public class CompositingDrawing extends Compositing {
public Color getColor() {
return this.color;
}
/**
* Get the background color of the font.
* @return Background color.
@ -237,7 +239,7 @@ public class CompositingDrawing extends Compositing {
public Color getColorBg() {
return this.colorBg;
}
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@ -245,7 +247,7 @@ public class CompositingDrawing extends Compositing {
public Vector3f getPos() {
return this.position;
}
/**
* set the Color of the current triangle drawing
* @param color Color to current dots generated
@ -261,7 +263,7 @@ public class CompositingDrawing extends Compositing {
this.tricolor[2] = color;
}
}
/**
* Relative drawing a line (spacial vector)
* @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) {
lineTo(this.position.add(new Vector3f(xxx, yyy, 0)));
}
public void lineRel(final float xxx, final float yyy, final float zzz) {
lineTo(this.position.add(new Vector3f(xxx, yyy, zzz)));
}
public void lineRel(final Vector2f vect) {
lineRel(new Vector3f(vect.x(), vect.y(), 0));
}
public void lineRel(final Vector3f vect) {
lineTo(this.position.add(vect));
}
public void lineTo(final float xxx, final float yyy) {
lineTo(new Vector3f(xxx, yyy, 0));
}
public void lineTo(final float xxx, final float yyy, final float zzz) {
lineTo(new Vector3f(xxx, yyy, zzz));
}
public void lineTo(final Vector2f dest) {
lineTo(new Vector3f(dest.x(), dest.y(), 0));
}
/**
* draw a line to a specific position
* @param dest Position of the end of the line.
@ -301,9 +303,9 @@ public class CompositingDrawing extends Compositing {
public void lineTo(final Vector3f dest) {
resetCount();
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()) {
// Log.warning("Try to draw a line width 0");
// LOGGER.warn("Try to draw a line width 0");
return;
}
// teta = tan-1(oposer/adjacent)
@ -318,20 +320,20 @@ public class CompositingDrawing extends Compositing {
} else if (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 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(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(this.position.x() - offsetx, this.position.y() - offsety, dest.z()));
// update the system position :
this.position = dest;
}
/**
* load the openGL program and get all the ID needed
*/
@ -339,7 +341,8 @@ public class CompositingDrawing extends Compositing {
// remove previous loading ... in case
unLoadProgram();
// 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 :
if (this.oGLprogram != null) {
//this.oGLPosition = this.oGLprogram.getAttribute("in_coord3d");
@ -349,19 +352,19 @@ public class CompositingDrawing extends Compositing {
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
}
}
public void rectangle(final float xxx, final float yyy) {
rectangle(new Vector3f(xxx, yyy, 0));
}
public void rectangle(final float xxx, final float yyy, final float zzz) {
rectangle(new Vector3f(xxx, yyy, zzz));
}
public void rectangle(final Vector2f dest) {
rectangle(new Vector3f(dest.x(), dest.y(), 0));
}
/**
* draw a 2D rectangle to the position requested.
* @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, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyC, 0));
setPoint(new Vector3f(dxB, dyD, 0));
setPoint(new Vector3f(dxA, dyD, 0));
}
public void rectangleWidth(final float xxx, final float yyy) {
rectangleWidth(new Vector3f(xxx, yyy, 0));
}
public void rectangleWidth(final float xxx, final float yyy, final float zzz) {
rectangleWidth(new Vector3f(xxx, yyy, zzz));
}
public void rectangleWidth(final Vector2f size) {
rectangleWidth(new Vector3f(size.x(), size.y(), 0));
}
/**
* draw a 2D rectangle to the requested size.
* @param size size of the rectangle
@ -433,18 +436,18 @@ public class CompositingDrawing extends Compositing {
public void rectangleWidth(final Vector3f size) {
rectangle(this.position.add(size));
}
/**
* in case of some error the count can be reset
*/
private void resetCount() {
this.triElement = 0;
}
public void setClipping(final Vector2f pos, final Vector2f posEnd) {
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)
* @param pos Start position of the clipping
@ -457,7 +460,7 @@ public class CompositingDrawing extends Compositing {
this.clippingPosStart = Vector3f.min(pos, posEnd);
this.clippingEnable = true;
}
/**
* enable/Disable the clipping (without lose the current clipping
* position)
@ -466,11 +469,11 @@ public class CompositingDrawing extends Compositing {
public void setClippingMode(final boolean newMode) {
this.clippingEnable = newMode;
}
public void setClippingWidth(final Vector2f pos, final Vector2f width) {
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)
* @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) {
setClipping(pos, pos.add(width));
}
/**
* set the Color of the current foreground font
* @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) {
this.color = color;
}
/**
* set the background color of the font (for selected Text (not the
* global BG))
@ -496,7 +499,7 @@ public class CompositingDrawing extends Compositing {
public void setColorBg(final Color color) {
this.colorBg = color;
}
/**
* internal add of the specific point
* @param point The requeste dpoint to add
@ -509,19 +512,19 @@ public class CompositingDrawing extends Compositing {
}
this.vbo.flush();
}
public void setPos(final float xxx, final float yyy) {
setPos(new Vector3f(xxx, yyy, 0));
}
public void setPos(final float xxx, final float yyy, final float zzz) {
setPos(new Vector3f(xxx, yyy, zzz));
}
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set position for the next text written
* @param pos Position of the text (in 3D)
@ -529,11 +532,11 @@ public class CompositingDrawing extends Compositing {
public void setPos(final Vector3f pos) {
this.position = pos;
}
public void setRelPos(final float xxx, final float yyy) {
this.position = this.position.add(xxx, yyy, 0);
}
/**
* set relative position for the next text writen
* @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) {
this.position = this.position.add(xxx, yyy, zzz);
}
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos);
}
/**
* Specify the line thickness for the next elements
* @param thickness The thickness disired for the next print
@ -561,12 +564,12 @@ public class CompositingDrawing extends Compositing {
this.thickness *= -1;
}
}
/**
* Un-Load the openGL program and get all the ID needed
*/
private void unLoadProgram() {
this.oGLprogram = null;
}
}

View File

@ -12,25 +12,27 @@ import org.atriasoft.esvg.JoinMode;
import org.atriasoft.etk.Color;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.ResourceTexture2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingGraphicContext extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingGraphicContext.class);
GraphicContext context = new GraphicContext();
private final ResourceTexture2 texture = new ResourceTexture2();
public CompositingGraphicContext() {
}
public Vector2i calculateTextSize(final String data) {
return this.context.calculateTextSize(data);
}
public void circle(final Vector2f position, final float radius) {
this.context.circle(position, radius);
}
/**
* clear alll tre registered element in the current element
*/
@ -41,43 +43,43 @@ public class CompositingGraphicContext extends Compositing {
// reset Buffer :
this.context.clear();
}
/**
* Clear the fill color (disable fill ==> better that set it transparent)
*/
public void clearColorFill() {
this.context.clearColorFill();
}
/**
* Clear the Stroke color (disable stroke)
*/
public void clearColorStroke() {
this.context.clearColorStroke();
}
@Override
public void draw(final boolean disableDepthTest) {
// TODO Auto-generated method stub
}
public void ellipse(final Vector2f center, final Vector2f radius) {
this.context.ellipse(center, radius);
}
@Override
public void flush() {
if (this.texture == null) {
Log.warning("texture is null");
LOGGER.warn("texture is null");
return;
}
ImageByte img = this.context.render();
final ImageByte img = this.context.render();
//IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp222.png"), img);
this.texture.set(img);
this.texture.flush();
}
/**
* Get the fill color.
* @return fill color.
@ -85,7 +87,7 @@ public class CompositingGraphicContext extends Compositing {
public Color getColorFill() {
return this.context.getColorFill();
}
/**
* Get the stroke color.
* @return Stroke color.
@ -93,23 +95,23 @@ public class CompositingGraphicContext extends Compositing {
public Color getColorStroke() {
return this.context.getColorStroke();
}
public CapMode getLineCap() {
return this.context.getLineCap();
}
public JoinMode getLineJoin() {
return this.context.getLineJoin();
}
public float getMiterLimit() {
return this.context.getMiterLimit();
}
public float getOpacity() {
return this.context.getOpacity();
}
/**
* get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size
@ -117,27 +119,27 @@ public class CompositingGraphicContext extends Compositing {
public Vector2i getRealSize() {
return this.texture.get().getSize();
}
public int getRendererId() {
return this.texture.getRendererId();
}
public ResourceTexture2 getResourceTexture() {
return this.texture;
}
public float getStrokeWidth() {
return this.context.getStrokeWidth();
}
public int getTextHeight() {
return this.context.getTextHeight();
}
public float getTextSize() {
return this.context.getTextSize();
}
/**
* 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.
@ -145,60 +147,60 @@ public class CompositingGraphicContext extends Compositing {
public boolean hasSources() {
return true;
}
public void line(final Vector2f origin, final Vector2f destination) {
this.context.line(origin, destination);
}
public void lineRel(final Vector2f origin, final Vector2f relativeDestination) {
this.context.lineRel(origin, relativeDestination);
}
public void pathLine(final Vector2f pos) {
this.context.pathLine(pos);
}
public void pathLineTo(final Vector2f pos) {
this.context.pathLineTo(pos);
}
public void pathMove(final Vector2f pos) {
this.context.pathMove(pos);
}
public void pathMoveTo(final Vector2f pos) {
this.context.pathMoveTo(pos);
}
public void pathStart() {
this.context.pathStart();
}
public void pathStop() {
this.context.pathStop();
}
public void pathStopLinked() {
this.context.pathStopLinked();
}
public void rectangle(final Vector2f position, final Vector2f destination) {
this.context.rectangle(position, destination);
}
public void rectangleRounded(final Vector2f position, final Vector2f destination, final Vector2f ruound) {
this.context.rectangleRounded(position, destination, ruound);
}
public void rectangleRoundedWidth(final Vector2f position, final Vector2f width, final Vector2f ruound) {
this.context.rectangleRoundedWidth(position, width, ruound);
}
public void rectangleWidth(final Vector2f position, final Vector2f width) {
this.context.rectangleWidth(position, width);
}
/**
* set the fill color
* @param color Color to set on fill
@ -207,7 +209,7 @@ public class CompositingGraphicContext extends Compositing {
public void setColorFill(final Color color) {
this.context.setColorFill(color);
}
/**
* set the stroke color
* @param color Color to set on stroke
@ -216,23 +218,23 @@ public class CompositingGraphicContext extends Compositing {
public void setColorStroke(final Color color) {
this.context.setColorStroke(color);
}
public void setLineCap(final CapMode lineCap) {
this.context.setLineCap(lineCap);
}
public void setLineJoin(final JoinMode lineJoin) {
this.context.setLineJoin(lineJoin);
}
public void setMiterLimit(final float miterLimit) {
this.context.setMiterLimit(miterLimit);
}
public void setOpacity(final float opacity) {
this.context.setOpacity(opacity);
}
/**
* Set global size of the Graphic context (output render size)
* @param xxx Width of the image
@ -242,7 +244,7 @@ public class CompositingGraphicContext extends Compositing {
public void setSize(final int xxx, final int yyy) {
this.context.setSize(xxx, yyy);
}
/**
* Set global size of the Graphic contexct (output render size)
* @param vector2i New size of the image
@ -251,17 +253,17 @@ public class CompositingGraphicContext extends Compositing {
public void setSize(final Vector2i size) {
this.context.setSize(size.x(), size.y());
}
public void setStrokeWidth(final float strokeWidth) {
this.context.setStrokeWidth(strokeWidth);
}
public void text(final Vector2f position, final float height, final String data) {
this.context.text(position, height, data);
}
public void text(final Vector2f position, final String 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.Vector2i;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceTexture2;
import org.atriasoft.gale.resource.ResourceTextureFile;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 SIZE_AUTO = 0;
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 Vector3f position = Vector3f.ZERO; //!< The current position to draw
private Vector2i requestSize = new Vector2i(2, 2);
private ResourceTextureFile resource = null; //!< texture resources
private ResourceTexture2 resourceImage = null; //!< texture resources
private ResourceVirtualArrayObject vbo = null;
private Color[] vboDataColors = null;
private Vector3f[] vboDataCoords = null;
private Vector2f[] vboDataCoordsTex = null;
public CompositingImage() {
this(new Uri("DATA", ""), CompositingImage.SIZE_AUTO);
}
/**
* generic ructor
* @param uri URI of the file that might be loaded
@ -59,7 +61,7 @@ public class CompositingImage extends Compositing {
// Create the VBO:
this.vbo = ResourceVirtualArrayObject.createDynamic();
if (this.vbo == null) {
Log.error("can not instanciate VBO ...");
LOGGER.error("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO:
@ -67,7 +69,7 @@ public class CompositingImage extends Compositing {
setSource(uri, size);
loadProgram();
}
/**
* clear alll tre registered element in the current element
*/
@ -82,7 +84,7 @@ public class CompositingImage extends Compositing {
this.color = Color.WHITE;
this.angle = 0;
}
/**
* draw All the registered text in the current element on openGL
* @param disableDepthTest disable the Depth test for display
@ -91,7 +93,7 @@ public class CompositingImage extends Compositing {
public void draw(final boolean disableDepthTest) {
/*
if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
//Log.warning("Nothink to draw...");
//LOGGER.warn("Nothink to draw...");
return;
}
*/
@ -100,10 +102,10 @@ public class CompositingImage extends Compositing {
return;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
//Log.warning("Display image : " + this.VBO.bufferSize(this.vboIdCoord));
//LOGGER.warn("Display image : " + this.VBO.bufferSize(this.vboIdCoord));
if (disableDepthTest) {
OpenGL.disable(OpenGL.Flag.flag_depthTest);
} else {
@ -123,13 +125,13 @@ public class CompositingImage extends Compositing {
} else if (this.resource != null) {
this.resource.bindForRendering(0);
} 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.unBindForRendering();
this.oGLprogram.unUse();
}
@Override
public void flush() {
this.vbo.setPosition(this.vboDataCoords);
@ -138,7 +140,7 @@ public class CompositingImage extends Compositing {
this.vbo.setVertexCount(this.vboDataCoords.length);
this.vbo.flush();
}
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@ -146,7 +148,7 @@ public class CompositingImage extends Compositing {
public Vector3f getPos() {
return this.position;
}
/**
* get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size
@ -160,7 +162,7 @@ public class CompositingImage extends Compositing {
}
return this.resourceImage.getUsableSize();
}
/**
* 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.
@ -168,24 +170,25 @@ public class CompositingImage extends Compositing {
public boolean hasSources() {
return this.resource != null;
}
/**
* load the openGL program and get all the ID needed
*/
private void loadProgram() {
// 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) {
this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation");
this.oGLMatrixProjection = this.oGLprogram.getUniform("in_matrixProjection");
this.oGLMatrixView = this.oGLprogram.getUniform("in_matrixView");
}
}
public void print(final Vector2f size) {
printPart(size, Vector2f.ZERO, Vector2f.ONE);
}
/**
* add a compleate of the image to display with the requested size
* @param size size of the output image
@ -193,7 +196,7 @@ public class CompositingImage extends Compositing {
public void print(final Vector2i size) {
print(new Vector2f(size.x(), size.y()));
}
/**
* add a part of the image to display with the requested size
* @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 sourcePosStart = sourcePosStartIn.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.vboDataCoords = new Vector3f[6];
this.vboDataCoordsTex = new Vector2f[6];
if (this.angle == 0.0f) {
Vector3f point = this.position;
int indexElem = 0;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(this.position.x() + size.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(this.position.x(), this.position.y() + size.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(this.position.x(), this.position.y(), 0);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
return;
}
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);
Vector3f point = Vector3f.ZERO;
Vector2f tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
int indexElem = 0;
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStop.y());
point = new Vector3f(limitedSize.x(), -limitedSize.y(), 0);
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.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStop.x(), sourcePosStart.y());
point = new Vector3f(limitedSize.x(), limitedSize.y(), 0);
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.vboDataColors[indexElem] = this.color;
indexElem++;
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStart.y());
point = new Vector3f(-limitedSize.x(), limitedSize.y(), 0);
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.vboDataColors[indexElem] = this.color;
indexElem++;
tex = new Vector2f(sourcePosStart.x(), sourcePosStop.y());
point = new Vector3f(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotateNew(new Vector3f(0, 0, 1), this.angle).add(center);
this.vboDataCoords[indexElem] = point;
this.vboDataCoordsTex[indexElem] = tex;
this.vboDataColors[indexElem] = this.color;
}
/**
* set a unique rotation of this element (not set in the rotate Generic system)
* @param angleRad Angle to set in radiant.
@ -322,7 +326,7 @@ public class CompositingImage extends Compositing {
public void setAngle(final float angleRad) {
this.angle = angleRad;
}
/**
* set the Color of the current foreground font
* @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) {
this.color = color;
}
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set position for the next text writen
* @param pos Position of the text (in 3D)
@ -342,11 +346,11 @@ public class CompositingImage extends Compositing {
public void setPos(final Vector3f pos) {
this.position = pos;
}
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set relative position for the next text writen
* @param pos ofset apply of the text (in 3D)
@ -354,7 +358,7 @@ public class CompositingImage extends Compositing {
public void setRelPos(final Vector3f pos) {
this.position = this.position.add(pos);
}
public void setSource(final ImageByteRGBA image) {
clear();
this.filename = null;
@ -362,7 +366,7 @@ public class CompositingImage extends Compositing {
this.resourceImage = new ResourceTexture2();
this.resourceImage.set(image);
}
/**
* change the image Source == > can not be done to display 2 images at the same time ...
* @param uri New file of the Image
@ -370,11 +374,11 @@ public class CompositingImage extends Compositing {
public void setSource(final Uri uri) {
setSource(uri, 32);
}
public void setSource(final Uri uri, final int size) {
setSource(uri, new Vector2i(size, size));
}
public void setSource(final Uri uri, final Vector2i size) {
clear();
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.resource = null;
this.resourceImage = null;
final Vector2i tmpSize = new Vector2i(size.x(), size.y());
// note that no image can be loaded...
if (!uri.isEmpty()) {
// link to new one
this.resource = ResourceTextureFile.create(this.filename, tmpSize);
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 (resource != null) {
Log.warning("Retrive previous resource");
LOGGER.warn("Retrive previous resource");
this.resource = resource;
}
if (resourceTex != null) {
Log.warning("Retrive previous resource (image)");
LOGGER.warn("Retrive previous resource (image)");
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.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceTexturedFont;
import org.atriasoft.ewol.resource.font.FontMode;
import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.gale.backend3d.OpenGL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CompositingText extends TextBase {
private static final Logger LOGGER = LoggerFactory.getLogger(CompositingText.class);
protected List<Color> colors = new ArrayList<>();
protected ResourceTexturedFont font; // !< Font resources
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.
protected final boolean forceClimp = true;
protected List<Vector2f> texturePositions = new ArrayList<>();
protected String currentFontName = "";
protected int currentFontSize = -2; // -1 is to perform first initialization
protected int currentFontSizeRequired = -2; // -1 is to perform first initialization
public CompositingText() {
this("");
}
public CompositingText(final String fontName) {
this(fontName, 0);
}
/**
* generic constructor
* @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) {
setFont(fontName, fontSize);
}
@Override
public Vector3f calculateSizeChar(final Character charcode) {
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
@ -59,9 +61,9 @@ public class CompositingText extends TextBase {
final int fontHeigh = (int) getHeight();
if (myGlyphProperty == null) {
if (this.font == null) {
Log.warning("no Glyph... in no font");
LOGGER.warn("no Glyph... in no font");
} 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);
}
@ -70,13 +72,14 @@ public class CompositingText extends TextBase {
if (this.kerning) {
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
this.previousCharcode = charcode;
return outputSize;
}
@Override
public void clear() {
// call upper class
@ -87,22 +90,22 @@ public class CompositingText extends TextBase {
// set the color
this.colors.clear();
}
@Override
public void drawD(final boolean disableDepthTest) {
// draw BG in any case:
this.vectorialDraw.draw(disableDepthTest);
if (this.vbo.getVertexCount() <= 0 || this.font == null) {
// Log.warning("Nothink to draw...");
// LOGGER.warn("Nothink to draw...");
return;
}
if (this.font == null) {
Log.warning("no font...");
LOGGER.warn("no font...");
return;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
// set Matrix : translation/positionMatrix
@ -119,24 +122,24 @@ public class CompositingText extends TextBase {
this.oGLprogram.uniformInt(this.oGLtextHeight, this.font.getOpenGlSize().x());
// Request the draw of the elements:
this.vbo.renderArrays(OpenGL.RenderMode.TRIANGLE);
this.vbo.unBindForRendering();
this.oGLprogram.unUse();
}
@Override
public void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
// draw BG in any case:
this.vectorialDraw.draw();
if (this.vbo.getVertexCount() <= 0 || this.font == null) {
// TODO : set it back ...
// Log.warning("Nothink to draw...");
// LOGGER.warn("Nothink to draw...");
return;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
if (enableDepthTest) {
@ -156,14 +159,14 @@ public class CompositingText extends TextBase {
this.oGLprogram.uniformInt(this.oGLtextHeight, this.font.getOpenGlSize().x());
// Request the draw of the elements:
this.vbo.renderArrays(OpenGL.RenderMode.TRIANGLE);
this.vbo.unBindForRendering();
this.oGLprogram.unUse();
if (enableDepthTest) {
OpenGL.disable(OpenGL.Flag.flag_depthTest);
}
}
@Override
public void flush() {
super.flush();
@ -176,57 +179,57 @@ public class CompositingText extends TextBase {
this.vbo.setVertexCount(this.pointPositions.size());
this.vbo.flush();
}
@Override
public GlyphProperty getGlyphPointer(final Character charcode) {
if (this.font == null) {
Log.warning("no font...");
LOGGER.warn("no font...");
return null;
}
return this.font.getGlyph(charcode, this.mode);
}
@Override
public float getHeight() {
if (this.font == null) {
Log.warning("no font...");
LOGGER.warn("no font...");
return 10.0f;
}
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
return this.font.getHeight(this.mode) * renderRatio;
}
@Override
public float getSize() {
if (this.font == null) {
Log.warning("no font...");
LOGGER.warn("no font...");
return 1.0f;
}
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
return this.font.getFontSize() * renderRatio;
}
@Override
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 :
final GlyphProperty myGlyphProperty = getGlyphPointer(charcode);
if (myGlyphProperty == null) {
Log.error(" font does not really existed ...");
LOGGER.error(" font does not really existed ...");
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...)
final float renderRatio = (float) this.currentFontSizeRequired / (float) this.currentFontSizeRequired;
final int fontSize = (int) (getSize() * renderRatio);
final int fontHeigh = (int) (getHeight() * renderRatio);
// get the kerning offset :
float kerningOffset = 0;
if (this.kerning) {
kerningOffset = myGlyphProperty.kerningGet(this.previousCharcode) * renderRatio;
if (kerningOffset != 0) {
// Log.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.UVal
// LOGGER.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.UVal
// + "' value : " + kerningOffset);
}
}
@ -237,16 +240,18 @@ public class CompositingText extends TextBase {
*/
float dxA = this.position.x() + myGlyphProperty.getTextureRenderOffset().x() * renderRatio + kerningOffset;
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 tuA = myGlyphProperty.texturePosStart.x();
float tuB = tuA + myGlyphProperty.texturePosSize.x();
float tvC = myGlyphProperty.texturePosStart.y();
float tvD = tvC + myGlyphProperty.texturePosSize.y();
// 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 ...
} else {
if (this.clippingEnable) {
@ -307,11 +312,11 @@ public class CompositingText extends TextBase {
final Vector2f texturePos1 = new Vector2f(tuB + this.mode.getValue(), tvC);
final Vector2f texturePos2 = new Vector2f(tuB + this.mode.getValue(), tvD);
final Vector2f texturePos3 = new Vector2f(tuA + this.mode.getValue(), tvD);
// NOTE : Android does not support the Quads elements ...
/*
* Step 1 : ******** ****** **** **
*
*
*/
// set texture coordinates :
this.texturePositions.add(texturePos0);
@ -327,7 +332,7 @@ public class CompositingText extends TextBase {
this.colors.add(this.color);
/*
* Step 2 :
*
*
* ** **** ****** ********
*/
// set texture coordinates :
@ -346,21 +351,22 @@ public class CompositingText extends TextBase {
}
}
// 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);
this.position = this.position.withX(this.position.x() + myGlyphProperty.getAdvenceX() * renderRatio + kerningOffset);
// Log.debug(" 6 print '" + char-code + "' : start=" + this.sizeDisplayStart + "
this.position = this.position
.withX(this.position.x() + myGlyphProperty.getAdvenceX() * renderRatio + kerningOffset);
// LOGGER.debug(" 6 print '" + char-code + "' : start=" + this.sizeDisplayStart + "
// stop=" + this.sizeDisplayStop + " pos=" + this.position);
// Register the previous character
this.previousCharcode = charcode;
}
@Override
public void setFont(final String inputFontName, final int inputFontSize) {
if (inputFontName.equals(this.currentFontName) && inputFontSize == this.currentFontSize) {
return;
}
String fontName = inputFontName;
int fontSize = inputFontSize;
// remove old one
@ -371,7 +377,7 @@ public class CompositingText extends TextBase {
if (fontName.isEmpty()) {
fontName = Configs.getConfigFonts().getName();
}
// if size in under 25, we request upper size:
int sizeRequest = 25;
if (this.forceClimp) {
@ -383,18 +389,18 @@ public class CompositingText extends TextBase {
this.currentFontSize = inputFontSize;
return;
}
clear();
final Uri fontUri = Configs.getConfigFonts().getFontUri(fontName).clone();
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
if (this.forceClimp) {
fontUri.setProperty("FORCE_CLIMP", "true");
}
this.font = ResourceTexturedFont.create(fontUri);
if (this.font == null) {
Log.error("Can not get font resource");
LOGGER.error("Can not get font resource");
this.font = previousFont;
} else {
this.currentFontName = inputFontName;
@ -402,22 +408,22 @@ public class CompositingText extends TextBase {
this.currentFontSizeRequired = sizeRequest;
}
}
@Override
public void setFontMode(final FontMode mode) {
if (this.font != null) {
this.mode = this.font.getWrappingMode(mode);
}
}
@Override
public void setFontName(final String fontName) {
setFont(fontName, this.currentFontSize);
}
@Override
public void setFontSize(final int 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.ewol.Padding;
import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceConfigFile;
import org.atriasoft.gale.backend3d.OpenGL;
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.loader3d.resources.ResourceMesh;
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
@ -28,13 +29,15 @@ import org.atriasoft.loader3d.resources.ResourcePaletteFile;
// TODO : load image
// TODO : Abstaraction between states (call by name and the system greate IDs
public class GuiShape extends Compositing {
private static final Logger LOGGER = LoggerFactory.getLogger(GuiShape.class);
private class SpecificValues {
public Matrix4f transform = Matrix4f.IDENTITY;
public Vector3f offsetScaleInside = Vector3f.ZERO;
public Vector3f offsetScaleOutside = Vector3f.ZERO;
public ResourceMesh mesh = null;
}
private static final int SHAPER_POS_BOTTOM = 3;
private static final int SHAPER_POS_LEFT = 0;
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 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
// External theme configuration:
private ResourceConfigFile config = null; //!< pointer on the config file resources
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 oGLOffsetScaleInside = -1;
private int oGLOffsetScaleOutside = -1;
// openGL shaders programs:
private ResourceProgram oGLprogram = null; //!< pointer on the opengl display program
// For the Image :
@ -69,13 +72,13 @@ public class GuiShape extends Compositing {
private int stateActivate = -1; //!< Activate state of the element
private GuiShapeMode stateNew = GuiShapeMode.NORMAL; //!< destination state
private GuiShapeMode stateOld = GuiShapeMode.NORMAL; //!< previous state
private Uri uri; //!< Name of the configuration of the shaper.
private final SpecificValues[] valueSpecific = new SpecificValues[2];
// dynamic change:
private float stateTransition = 0; //!< working state between 2 states
/**
* @brief generic constructor
* @param _uri URI of the file that might be loaded
@ -92,7 +95,7 @@ public class GuiShape extends Compositing {
loadPalette();
loadProgram();
}
/**
* @brief change the current status in an other
* @param _newStatusId the next new status requested
@ -109,13 +112,13 @@ public class GuiShape extends Compositing {
}
return false;
}
/**
* @brief clear alll tre registered element in the current element
*/
@Override
public void clear() {}
/**
* @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) {
draw(null, disableDepthTest);
}
public void draw(final boolean disableDepthTest, final int idMesh) {
draw(null, disableDepthTest, idMesh);
}
public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest) {
this.draw(secondaryTexture, disableDepthTest, 0);
}
public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest, final int idMesh) {
if (this.config == null) {
// this is a normal case ... the user can choice to have no config basic file ...
return;
}
if (idMesh == 0 && this.valueSpecific[0] == null) {
Log.error("No Object (0) to display ...");
LOGGER.error("No Object (0) to display ...");
return;
} else if (idMesh == 1 && this.valueSpecific[1] == null) {
Log.error("No Object (1) to display ...");
LOGGER.error("No Object (1) to display ...");
return;
} 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;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
OpenGL.enable(Flag.flag_depthTest);
@ -161,9 +165,9 @@ public class GuiShape extends Compositing {
this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, tmpMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix);
final Set<String> layers = this.valueSpecific[idMesh].mesh.getLayers();
Log.verbose("get layers:" + layers);
LOGGER.trace("get layers:" + layers);
// Texture:
final float imageDelta = (float) 1 / 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);
//Log.verbose("plop: " + this.offsetScaleOutside);
//Log.verbose("plop: " + this.offsetScaleInside);
//LOGGER.trace("plop: " + this.offsetScaleOutside);
//LOGGER.trace("plop: " + this.offsetScaleInside);
this.oGLprogram.uniformVector(this.oGLOffsetScaleInside, this.valueSpecific[idMesh].offsetScaleInside);
this.oGLprogram.uniformVector(this.oGLOffsetScaleOutside, this.valueSpecific[idMesh].offsetScaleOutside);
this.texture.bindForRendering(0);
this.valueSpecific[idMesh].mesh.render("palette");
if (secondaryTexture != null) {
this.oGLprogram.uniformFloat(this.oGLPaletteOffset, 0);
secondaryTexture.bindForRendering(0);
this.valueSpecific[idMesh].mesh.render("gui_dynamic_1");
}
// Request the draw of the elements:
this.valueSpecific[idMesh].mesh.render();
this.valueSpecific[idMesh].mesh.unBindForRendering();
this.oGLprogram.unUse();
OpenGL.disable(Flag.flag_depthTest);
}
@Override
public void flush() {
// TODO Auto-generated method stub
}
/**
* @brief get the padding declared by the user in the config file
* @return the padding property
@ -226,7 +231,7 @@ public class GuiShape extends Compositing {
public Padding getBorder() {
return this.sizeObject;
}
/**
* @brief get the current displayed status of the shaper
* @return The Status Id
@ -234,7 +239,7 @@ public class GuiShape extends Compositing {
public GuiShapeMode getCurrentDisplayedStatus() {
return this.stateNew;
}
/**
* @brief get the next displayed status of the shaper
* @return The next status Id (-1 if no status in next)
@ -242,7 +247,7 @@ public class GuiShape extends Compositing {
public GuiShapeMode getNextDisplayedStatus() {
return this.nextStatusRequested;
}
/**
* @brief get the padding declared by the user in the config file
* @return the padding property
@ -250,25 +255,29 @@ public class GuiShape extends Compositing {
public Padding getPadding() {
return getPaddingOut().add(getBorder()).add(getPaddingIn());
}
public Padding getPaddingIn() {
Padding out = Padding.ZERO;
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]),
this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_RIGHT]), this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_BOTTOM]));
out = new Padding(this.config.getNumber(this.confIdPaddingIn[GuiShape.SHAPER_POS_LEFT]),
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;
}
public Padding getPaddingOut() {
Padding out = Padding.ZERO;
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]),
this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_RIGHT]), this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_BOTTOM]));
out = new Padding(this.config.getNumber(this.confIdPaddingOut[GuiShape.SHAPER_POS_LEFT]),
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;
}
/**
* @brief get the shaper file Source
* @return the shapper file name
@ -276,7 +285,7 @@ public class GuiShape extends Compositing {
public Uri getSource() {
return this.uri;
}
/**
* @brief get the current transition status
* @return value of the transition status (0.0f when no activity)
@ -284,7 +293,7 @@ public class GuiShape extends Compositing {
public float getTransitionStatus() {
return this.stateTransition;
}
/**
* @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.
@ -292,10 +301,10 @@ public class GuiShape extends Compositing {
public boolean hasSources() {
return this.oGLprogram != null;
}
private void loadConfigFile() {
if (this.uri.isEmpty()) {
Log.debug("no Shaper set for loading resources ...");
LOGGER.debug("no Shaper set for loading resources ...");
return;
}
this.config = ResourceConfigFile.create(this.uri);
@ -316,14 +325,14 @@ public class GuiShape extends Compositing {
this.confIdPaletteFile = this.config.request("palette");
}
}
protected void loadPalette() {
final String paletteFile = this.config.getString(this.confIdPaletteFile);
final Uri paletteFileInterface = Uri.valueOf(paletteFile);
this.palette = ResourcePaletteFile.create(paletteFileInterface);
this.texture = ResourceTexture2.createNamed("TEXTURE_OF_PALETTE:" + paletteFile);
if (this.texture == null) {
Log.error("can not instanciate Texture ...");
LOGGER.error("can not instanciate Texture ...");
}
// element already called
loadPaletteUpdate();
@ -332,26 +341,27 @@ public class GuiShape extends Compositing {
loadPaletteUpdate();
});
}
protected void loadPaletteUpdate() {
Log.warning("update palet environnement");
LOGGER.warn("update palet environnement");
final ImageByte img = this.palette.getImageByte();
//IOgami.storePNG(new Uri("/home/heero/000000000aaaaplopppp.png"), img);
this.texture.set(img);
}
/**
* load the openGL program and get all the ID needed
*/
private void loadProgram() {
if (this.config == null) {
Log.debug("no Shaper set for loading resources ...");
LOGGER.debug("no Shaper set for loading resources ...");
return;
}
final String basicShaderFileVert = this.config.getString(this.confProgramFileVert);
final String basicShaderFileFrag = this.config.getString(this.confProgramFileFrag);
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) {
this.oGLMatrixTransformation = this.oGLprogram.getUniform("in_matrixTransformation");
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
*/
private void loadUpdateObjectSize() {
if (this.config == null) {
Log.debug("no Shaper set for loading resources ...");
LOGGER.debug("no Shaper set for loading resources ...");
return;
}
final String objectFile = this.config.getString(this.confObjectFile);
@ -385,16 +395,17 @@ public class GuiShape extends Compositing {
float font = 0;
// estimate size of border:
if (verticesToModify == null) {
Log.critical("Element is null : verticesToModify 1");
LOGGER.error("Element is null : verticesToModify 1");
System.exit(-1);
return;
}
for (int iii = 0; iii < verticesToModify.size(); iii++) {
left = Math.min(left, verticesToModify.get(iii).x());
right = Math.max(right, verticesToModify.get(iii).x());
top = Math.min(top, verticesToModify.get(iii).y());
bottom = Math.max(bottom, verticesToModify.get(iii).y());
back = Math.min(back, verticesToModify.get(iii).z());
font = Math.max(font, verticesToModify.get(iii).z());
for (final Vector3f element : verticesToModify) {
left = Math.min(left, element.x());
right = Math.max(right, element.x());
top = Math.min(top, element.y());
bottom = Math.max(bottom, element.y());
back = Math.min(back, element.z());
font = Math.max(font, element.z());
}
this.sizeObject = new Padding(Math.abs(left), Math.abs(top), Math.abs(right), Math.abs(bottom));
} else {
@ -415,23 +426,24 @@ public class GuiShape extends Compositing {
float font = 0;
// estimate size of border:
if (verticesToModify == null) {
Log.critical("Element is null : verticesToModify 2");
LOGGER.error("Element is null : verticesToModify 2");
System.exit(-1);
return;
}
for (int iii = 0; iii < verticesToModify.size(); iii++) {
left = Math.min(left, verticesToModify.get(iii).x());
right = Math.max(right, verticesToModify.get(iii).x());
top = Math.min(top, verticesToModify.get(iii).y());
bottom = Math.max(bottom, verticesToModify.get(iii).y());
back = Math.min(back, verticesToModify.get(iii).z());
font = Math.max(font, verticesToModify.get(iii).z());
for (final Vector3f element : verticesToModify) {
left = Math.min(left, element.x());
right = Math.max(right, element.x());
top = Math.min(top, element.y());
bottom = Math.max(bottom, element.y());
back = Math.min(back, element.z());
font = Math.max(font, element.z());
}
} else {
final int idMesh = 1;
this.valueSpecific[idMesh] = null;
}
}
/**
* @brief Same as the widfget periodic call (this is for change display)
* @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.
*/
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 :
if (this.stateTransition >= 1.0) {
this.stateOld = this.stateNew;
@ -451,7 +464,7 @@ public class GuiShape extends Compositing {
this.stateNew = this.nextStatusRequested;
this.nextStatusRequested = GuiShapeMode.NONE;
this.stateTransition = 0.0f;
Log.verbose(" ##### START ##### ");
LOGGER.trace(" ##### START ##### ");
return true;
}
if (this.stateTransition < 1.0) {
@ -473,11 +486,11 @@ public class GuiShape extends Compositing {
this.stateTransition += event.getTimeDeltaCallSecond() / timeRelativity;
//stateTransition += _event.getDeltaCall();
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;
}
/**
* @brief Set activate state of the element
* @param _status New activate status
@ -485,16 +498,22 @@ public class GuiShape extends Compositing {
public void setActivateState(final int status) {
this.stateActivate = status;
}
public void setShape(final int idMesh, final Vector3f origin, final Vector3f size) {
final Padding tmp = getPadding();
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);
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();
float[] newVertices = new float[verticesToModify.size()*3];
@ -506,25 +525,26 @@ public class GuiShape extends Compositing {
}
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) {
// if (value <= 0.0f) {
// return value - halfsize;
// }
// return value + halfsize;
// }
// @previous
public void setShape(final Vector2f origin, final Vector2f size) {
final Padding tmp = getPadding();
setShape(origin, size, origin.add(tmp.left(), tmp.bottom()), size.less(tmp.x(), tmp.y()));
}
/**
* @brief set the shape property:
*
*
* ********************************************************************************
* * size *
* * *
@ -564,11 +584,16 @@ public class GuiShape extends Compositing {
* @param center Center of the object
* @param size Size of the display
*/
public void setShape(final Vector2f origin, final Vector2f size, final Vector2f insidePos, final Vector2f insideSize) {
//Log.error("Set shape property : origin=" + origin + " size=" + size + " in-pos=" + insidePos + " in-size=" + insideSize);
public void setShape(
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 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();
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.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++) {
if (this.valueSpecific[iii] == null) {
continue;
@ -592,13 +618,17 @@ public class GuiShape extends Compositing {
this.valueSpecific[iii].transform = transform;
}
}
public void setShape(final Vector3f origin, final Vector3f size) {
final Padding tmp = getPadding();
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 offsetScaleOutside = halfSize;
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);
*/
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++) {
if (this.valueSpecific[iii] == null) {
continue;
@ -623,7 +654,7 @@ public class GuiShape extends Compositing {
this.valueSpecific[iii].transform = transform;
}
}
/**
* @brief change the shaper Source
* @param _uri New file of the shaper
@ -637,7 +668,7 @@ public class GuiShape extends Compositing {
loadPalette();
loadProgram();
}
/**
* @brief Change the current state
* @param _newState Current state of the configuration
@ -651,7 +682,7 @@ public class GuiShape extends Compositing {
this.stateActivate = newState;
return true;
}
/**
* @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.util.Dynamic;
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.GlyphProperty;
import org.atriasoft.exml.Exml;
@ -28,8 +27,11 @@ import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.exml.model.XmlNode;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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)
protected AlignMode alignment = AlignMode.DISABLE; // !< Current Alignment mode (justify/left/right ...)
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
// this section is reserved for HTML parsing and display:
public String htmlCurrentLine = ""; // !< current line for HTML display
public List<TextDecoration> htmlDecoration = new ArrayList<>(); // !< current decoration for the HTML display
public TextDecoration htmlDecoTmp = new TextDecoration(); // !< current decoration
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 ResourceVirtualArrayObject vbo = null;
protected CompositingDrawing vectorialDraw = new CompositingDrawing();
/**
* generic constructor
*/
public TextBase() {
this(new Uri("DATA", "text.vert", "ewol"), new Uri("DATA", "text.frag", "ewol"));
}
public TextBase(final Uri vertexShader, final Uri fragmentShader) {
this(vertexShader, fragmentShader, true);
}
public TextBase(final Uri vertexShader, final Uri fragmentShader, final boolean loadProgram) {
if (loadProgram) {
loadProgram(vertexShader, fragmentShader);
@ -90,7 +92,7 @@ public abstract class TextBase extends Compositing {
// TO facilitate some debugs we add a name of the VBO:
this.vbo.setName("[VBO] of super.TextBase");
}
/**
* calculate a theoric charcode size
* @param charcode The Unicode value to calculate dimention.
@ -99,7 +101,7 @@ public abstract class TextBase extends Compositing {
public Vector3f calculateSize(final Character charcode) {
return calculateSizeChar(charcode);
}
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@ -116,10 +118,10 @@ public abstract class TextBase extends Compositing {
}
return outputSize;
}
// ! @previous
public abstract Vector3f calculateSizeChar(Character charcode);
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@ -129,13 +131,13 @@ public abstract class TextBase extends Compositing {
if (text.length() == 0) {
return Vector3f.ZERO;
}
final StringBuilder tmpData = new StringBuilder("<html><body>\n");
tmpData.append(text);
tmpData.append("\n</body></html>\n");
return calculateSizeHTML(tmpData.toString());
}
/**
* calculate a theoric text size
* @param text The string to calculate dimention.
@ -144,29 +146,31 @@ public abstract class TextBase extends Compositing {
public Vector3f calculateSizeHTML(final String text) {
// remove intermediate result
reset();
// Log.debug(" 0 size for=\n" + text);
// LOGGER.debug(" 0 size for=\n" + text);
// disable display system
this.needDisplay = false;
setPos(Vector3f.ZERO);
// same as print without the end display ...
printHTML(text);
//Log.error(" ]]]] position={}", this.position);
//Log.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
//Log.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
//LOGGER.error(" ]]]] position={}", this.position);
//LOGGER.error(" ]]]] sizeDisplayStart={}", this.sizeDisplayStart);
//LOGGER.error(" ]]]] sizeDisplayStop={}", this.sizeDisplayStop);
// get the last elements
this.sizeDisplayStop = Vector3f.max(this.position, this.sizeDisplayStop);
this.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart);
// Log.debug(" 2 Start pos=" + this.sizeDisplayStart);
// Log.debug(" 2 Stop pos=" + this.sizeDisplayStop);
// LOGGER.debug(" 2 Start pos=" + this.sizeDisplayStart);
// LOGGER.debug(" 2 Stop pos=" + this.sizeDisplayStop);
// set back the display system
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
*/
@ -181,14 +185,14 @@ public abstract class TextBase extends Compositing {
// reset temporal variables:
reset();
}
/**
* disable the alignement system
*/
public void disableAlignement() {
this.alignment = AlignMode.DISABLE;
}
/**
* remove the cursor display
*/
@ -196,7 +200,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = -100;
this.cursorPos = -100;
}
/**
* 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) {
drawD(disableDepthTest);
}
// ! @previous
public void draw(final Matrix4f transformationMatrix, final boolean enableDepthTest) {
drawMT(transformationMatrix, enableDepthTest);
}
/**
* draw All the refistered text in the current element on openGL
*/
public abstract void drawD(final boolean disableDepthTest);
// ! @previous
public abstract void drawMT(final Matrix4f transformationMatrix, final boolean enableDepthTest);
/**
* calculate the element number that is the first out the alignment
* 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.
* 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 :
final Character storePrevious = this.previousCharcode;
stop.value = text.length();
space.value = 0;
int lastSpacePosition = start;
int lastSpacefreeSize = 0;
float endPos = this.position.x();
boolean endOfLine = false;
float stopPosition = this.stopTextPos;
if (!this.needDisplay || this.stopTextPos == this.startTextPos) {
stopPosition = this.startTextPos + 3999999999.0f;
}
for (int iii = start; iii < text.length(); iii++) {
final Vector3f tmpSize = calculateSize(text.charAt(iii));
// check overflow :
@ -285,12 +294,12 @@ public abstract class TextBase extends Compositing {
freeSpace.value = lastSpacefreeSize;
return false;
}
@Override
public void flush() {
this.vectorialDraw.flush();
}
/**
* This generate the line return == > it return to the alignment
* 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 :
setPos(new Vector3f(this.startTextPos, this.position.y() - getHeight(), 0));
}
/**
* get the current alignment property
* @return the current alignment type
@ -308,12 +317,12 @@ public abstract class TextBase extends Compositing {
public AlignMode getAlignment() {
return this.alignment;
}
// This is used to draw background selection and other things ...
public CompositingDrawing getDrawing() {
return this.vectorialDraw;
}
/**
* get the current font mode
* @return The font mode applied
@ -321,11 +330,11 @@ public abstract class TextBase extends Compositing {
public FontMode getFontMode() {
return this.mode;
}
public abstract GlyphProperty getGlyphPointer(Character charcode);
public abstract float getHeight();
/**
* get the current display position (sometime needed in the gui control)
* @return the current position.
@ -333,16 +342,17 @@ public abstract class TextBase extends Compositing {
public Vector3f getPos() {
return this.position;
}
public abstract float getSize();
/**
* add a line with the current this.htmlDecoTmp decoration
* @param data The cuurent data to add.
*/
public void htmlAddData(final String data) {
//Log.error("Add data '{}' @pos=", data, this.position);
if (this.htmlCurrentLine.length() > 0 && this.htmlCurrentLine.charAt(this.htmlCurrentLine.length() - 1) != (char) Character.SPACE_SEPARATOR) {
//LOGGER.error("Add data '{}' @pos=", data, this.position);
if (this.htmlCurrentLine.length() > 0
&& this.htmlCurrentLine.charAt(this.htmlCurrentLine.length() - 1) != (char) Character.SPACE_SEPARATOR) {
this.htmlCurrentLine += (char) Character.SPACE_SEPARATOR;
if (this.htmlDecoration.size() > 0) {
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);
}
}
/**
* draw the current line
*/
@ -367,7 +377,7 @@ public abstract class TextBase extends Compositing {
this.htmlCurrentLine = "";
this.htmlDecoration.clear();
}
/**
* 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.oGLtextHeight = this.oGLprogram.getUniform("in_texHeight");
} else {
Log.error("Can not load the program => create previous one...");
LOGGER.error("Can not load the program => create previous one...");
this.oGLprogram = old;
old = null;
}
}
/**
* This parse a tinyXML node (void pointer to permit to hide tiny XML in
* include).
@ -401,21 +411,21 @@ public abstract class TextBase extends Compositing {
}
if (it.isText()) {
htmlAddData(it.getValue());
Log.verbose("XML add : " + it.getValue());
LOGGER.trace("XML add : " + it.getValue());
continue;
}
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;
}
final XmlElement elem = (XmlElement) it;
final String lowercaseValue = elem.getValue().toLowerCase();
if (lowercaseValue.contentEquals("br")) {
htmlFlush();
Log.verbose("XML flush newLine");
LOGGER.trace("XML flush newLine");
forceLineReturn();
} else if (lowercaseValue.contentEquals("font")) {
Log.verbose("XML Font ...");
LOGGER.trace("XML Font ...");
final TextDecoration tmpDeco = this.htmlDecoTmp;
if (elem.existAttribute("color")) {
try {
@ -424,10 +434,10 @@ public abstract class TextBase extends Compositing {
this.htmlDecoTmp = this.htmlDecoTmp.withFG(Color.valueOf(colorValue));
}
} 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();
} 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();
}
}
@ -438,17 +448,17 @@ public abstract class TextBase extends Compositing {
this.htmlDecoTmp = this.htmlDecoTmp.withBG(Color.valueOf(colorValue));
}
} 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();
} 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();
}
}
parseHtmlNode(elem);
this.htmlDecoTmp = tmpDeco;
} else if (lowercaseValue.contentEquals("b") || lowercaseValue.contentEquals("bold")) {
Log.verbose("XML bold ...");
LOGGER.trace("XML bold ...");
final TextDecoration tmpDeco = this.htmlDecoTmp;
if (this.htmlDecoTmp.mode() == FontMode.REGULAR) {
this.htmlDecoTmp = this.htmlDecoTmp.withMode(FontMode.BOLD);
@ -458,7 +468,7 @@ public abstract class TextBase extends Compositing {
parseHtmlNode(elem);
this.htmlDecoTmp = tmpDeco;
} else if (lowercaseValue.contentEquals("i") || lowercaseValue.contentEquals("italic")) {
Log.verbose("XML italic ...");
LOGGER.trace("XML italic ...");
final TextDecoration tmpDeco = this.htmlDecoTmp;
if (this.htmlDecoTmp.mode() == FontMode.REGULAR) {
this.htmlDecoTmp = this.htmlDecoTmp.withMode(FontMode.ITALIC);
@ -468,43 +478,43 @@ public abstract class TextBase extends Compositing {
parseHtmlNode(elem);
this.htmlDecoTmp = tmpDeco;
} else if (lowercaseValue.contentEquals("u") || lowercaseValue.contentEquals("underline")) {
Log.verbose("XML underline ...");
LOGGER.trace("XML underline ...");
parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("p") || lowercaseValue.contentEquals("paragraph")) {
Log.verbose("XML paragraph ...");
LOGGER.trace("XML paragraph ...");
htmlFlush();
this.alignment = AlignMode.LEFT;
forceLineReturn();
parseHtmlNode(elem);
forceLineReturn();
} else if (lowercaseValue.contentEquals("center")) {
Log.verbose("XML center ...");
LOGGER.trace("XML center ...");
htmlFlush();
this.alignment = AlignMode.CENTER;
parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("left")) {
Log.verbose("XML left ...");
LOGGER.trace("XML left ...");
htmlFlush();
this.alignment = AlignMode.LEFT;
parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("right")) {
Log.verbose("XML right ...");
LOGGER.trace("XML right ...");
htmlFlush();
this.alignment = AlignMode.RIGHT;
parseHtmlNode(elem);
} else if (lowercaseValue.contentEquals("justify")) {
Log.verbose("XML justify ...");
LOGGER.trace("XML justify ...");
htmlFlush();
this.alignment = AlignMode.JUSTIFY;
parseHtmlNode(elem);
} 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.
* @param text The string to display.
@ -513,7 +523,7 @@ public abstract class TextBase extends Compositing {
final List<TextDecoration> decorationEmpty = new ArrayList<>();
print(text, decorationEmpty);
}
/**
* display a compleat string in the current element whith specific
* decorations (advence mode).
@ -525,7 +535,7 @@ public abstract class TextBase extends Compositing {
Color tmpFg = this.color;
Color tmpBg = this.colorBg;
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...)
if (this.needDisplay) {
if (0 == this.cursorPos) {
@ -544,7 +554,8 @@ public abstract class TextBase extends Compositing {
}
// if real display : ( not display is for size calculation)
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);
setColorBg(this.colorSelection);
} 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);
} 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);
// special start case at the right of the endpoint :
if (this.stopTextPos < this.position.x()) {
@ -602,13 +613,15 @@ public abstract class TextBase extends Compositing {
case RIGHT:
if (this.needDisplay) {
// 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;
case CENTER:
if (this.needDisplay) {
// 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;
default:
@ -629,7 +642,8 @@ public abstract class TextBase extends Compositing {
setFontMode(decoration.get(iii).mode());
}
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);
setColorBg(this.colorSelection);
} else {
@ -639,7 +653,7 @@ public abstract class TextBase extends Compositing {
}
// special for the justify mode
if (text.charAt(iii) == (char) Character.SPACE_SEPARATOR) {
// Log.debug(" generateString : \" \"");
// LOGGER.debug(" generateString : \" \"");
if (this.needDisplay && this.colorBg.a() != 0) {
this.vectorialDraw.setPos(this.position);
}
@ -648,7 +662,7 @@ public abstract class TextBase extends Compositing {
if (this.needDisplay && this.colorBg.a() != 0) {
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) {
final Vector3f pos = this.position;
this.vectorialDraw.setPos(pos);
@ -687,17 +701,18 @@ public abstract class TextBase extends Compositing {
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
* is availlable if the position is not changed)
* @param charcode Char that might be dispalyed
*/
public abstract void printChar(Character charcode);
/**
* draw a cursor at the specify position
* @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) {
printCursor(isInsertMode, 20.0f);
}
public void printCursor(final boolean isInsertMode, final float cursorSize) {
final int fontHeigh = (int) getHeight();
if (isInsertMode) {
@ -716,11 +731,11 @@ public abstract class TextBase extends Compositing {
this.vectorialDraw.setThickness(0);
}
}
/**
* display a compleat string in the current element with the generic
* decoration specification. (basic html data)
*
*
* [code style=xml] <br/>
* <br/>
* <br/>
@ -739,7 +754,7 @@ public abstract class TextBase extends Compositing {
* <br/>
* <br/>
* <justify> Un exemple de text </justify> [/code]
*
*
* @note This is parsed with tiny xml, then be carfull that the XML is correct,
* and all balises are closed ... otherwite the display can not be done
* @param text The string to display.
@ -749,14 +764,14 @@ public abstract class TextBase extends Compositing {
final StringBuilder tmpData = new StringBuilder("<html>\n<body>\n");
tmpData.append(text);
tmpData.append("\n</body>\n</html>\n");
// Log.debug("plop : " + tmpData);
// LOGGER.debug("plop : " + tmpData);
printHTML(tmpData.toString());
}
/**
* display a compleat string in the current element with the generic
* decoration specification. (basic html data)
*
*
* [code style=xml] <html> <body> <br/>
* <br/>
* <br/>
@ -775,7 +790,7 @@ public abstract class TextBase extends Compositing {
* <br/>
* <br/>
* <justify> Un exemple de text </justify> </body> </html> [/code]
*
*
* @note This is parsed with tiny xml, then be carfull that the XML is correct,
* and all balises are closed ... otherwite the display can not be done
* @param text The string to display.
@ -787,34 +802,34 @@ public abstract class TextBase extends Compositing {
try {
final XmlElement doc = Exml.parse(text);
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);
return;
}
final XmlElement root = (XmlElement) doc.getNode("html");
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;
}
final XmlElement bodyNode = (XmlElement) root.getNode("body");
parseHtmlNode(bodyNode);
htmlFlush();
} 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();
} 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();
} 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();
} 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();
}
}
/**
* clear all the intermediate result detween 2 prints
*/
@ -840,24 +855,24 @@ public abstract class TextBase extends Compositing {
this.needDisplay = true;
this.nbCharDisplayed = 0;
}
@Override
public void rotate(final Vector3f vect, final float angle) {
super.rotate(vect, angle);
this.vectorialDraw.rotate(vect, angle);
}
@Override
public void scale(final Vector3f vect) {
super.scale(vect);
this.vectorialDraw.scale(vect);
}
// ! @previous
public void setClipping(final Vector2f pos, final Vector2f posEnd) {
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)
* @param pos Start position of the clipping
@ -871,7 +886,7 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = true;
this.vectorialDraw.setClipping(this.clippingPosStart, this.clippingPosStop);
}
/**
* enable/Disable the clipping (without lose the current clipping
* position)
@ -882,12 +897,12 @@ public abstract class TextBase extends Compositing {
this.clippingEnable = newMode;
this.vectorialDraw.setClippingMode(this.clippingEnable);
}
// ! @previous
public void setClippingWidth(final Vector2f pos, final Vector2f width) {
setClipping(pos, pos.add(width));
}
/**
* Request a clipping area for the text (next draw only)
* @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) {
setClipping(pos, pos.add(width));
}
/**
* set the Color of the current foreground font
* @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) {
this.color = color;
}
/**
* set the background color of the font (for selected Text (not the
* global BG))
@ -914,7 +929,7 @@ public abstract class TextBase extends Compositing {
this.colorBg = color;
this.vectorialDraw.setColor(color);
}
/**
* change the cursor color
* @param color New color for the Selection
@ -922,7 +937,7 @@ public abstract class TextBase extends Compositing {
public void setCursorColor(final Color color) {
this.colorCursor = color;
}
/**
* set a cursor at a specific position:
* @param cursorPos id of the cursor position
@ -931,7 +946,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = cursorPos;
this.cursorPos = cursorPos;
}
/**
* set a cursor at a specific position with his associated selection:
* @param cursorPos id of the cursor position
@ -941,7 +956,7 @@ public abstract class TextBase extends Compositing {
this.selectionStartPos = selectionStartPos;
this.cursorPos = cursorPos;
}
/**
* set the default background color of the font (when reset, set this
* value ...)
@ -950,7 +965,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorBg(final Color color) {
this.defaultColorBg = color;
}
/**
* set the default Foreground color of the font (when reset, set this
* value ...)
@ -959,7 +974,7 @@ public abstract class TextBase extends Compositing {
public void setDefaultColorFg(final Color color) {
this.defaultColorFg = color;
}
/**
* Specify the font property (this reset the internal element of the
* current text (system requirement)
@ -967,7 +982,7 @@ public abstract class TextBase extends Compositing {
* @param fontSize New font size
*/
public abstract void setFont(final String fontName, final int fontSize);
/**
* enable or disable the bold mode
* @param status The new status for this display property
@ -987,7 +1002,7 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.ITALIC);
}
}
/**
* enable or disable the italic mode
* @param status The new status for this display property
@ -1007,27 +1022,27 @@ public abstract class TextBase extends Compositing {
setFontMode(FontMode.BOLD);
}
}
/**
* Specify the font mode for the next @ref print
* @param mode The font mode requested
*/
public abstract void setFontMode(FontMode mode);
/**
* Specify the font name (this reset the internal element of the current
* text (system requirement)
* @param fontName Current name of the selected font
*/
public abstract void setFontName(final String fontName);
/**
* Specify the font size (this reset the internal element of the current
* text (system requirement)
* @param fontSize New font size
*/
public abstract void setFontSize(final int fontSize);
/**
* set the activation of the Kerning for the display (if it existed)
* @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) {
this.kerning = newMode;
}
// ! @previous
public void setPos(final Vector2f pos) {
setPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set position for the next text writen
* @param pos Position of the text (in 3D)
@ -1048,7 +1063,7 @@ public abstract class TextBase extends Compositing {
public void setPos(final Vector3f pos) {
// check min max for display area
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.sizeDisplayStart = Vector3f.min(this.position, this.sizeDisplayStart);
}
@ -1060,20 +1075,20 @@ public abstract class TextBase extends Compositing {
if (this.nbCharDisplayed == 0) {
this.sizeDisplayStart = this.position;
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 {
//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.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
public void setRelPos(final Vector2f pos) {
setRelPos(new Vector3f(pos.x(), pos.y(), 0));
}
/**
* set relative position for the next text written
* @param pos offset apply of the text (in 3D)
@ -1083,7 +1098,7 @@ public abstract class TextBase extends Compositing {
this.previousCharcode = 0;
this.vectorialDraw.setPos(this.position);
}
/**
* change the selection color
* @param color New color for the Selection
@ -1091,7 +1106,7 @@ public abstract class TextBase extends Compositing {
public void setSelectionColor(final Color color) {
this.colorSelection = color;
}
/**
* This generate the possibility to generate the big text property
* @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) {
setTextAlignment(startTextPos, stopTextPos, AlignMode.DISABLE);
}
public void setTextAlignment(final float startTextPos, final float stopTextPos, final AlignMode alignement) {
this.startTextPos = startTextPos;
this.stopTextPos = stopTextPos + 1;
this.alignment = alignement;
if (this.startTextPos >= this.stopTextPos) {
// 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
public void translate(final Vector3f vect) {
super.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.etranslate.ETranslate;
import org.atriasoft.ewol.event.EntrySystem;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.ObjectManager;
import org.atriasoft.ewol.widget.Widget;
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.KeyType;
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 ...
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.
* @return current reference on the instance.
@ -43,31 +45,32 @@ public class EwolContext extends GaleApplication {
}
return null;
}
private EwolApplication application; // !< Application handle
private final InputManager input;
private final ObjectManager objectManager; // !< Object Manager main instance
private final WidgetManager widgetManager = new WidgetManager(); // !< global widget manager
private Windows windowsCurrent = null; // !< current displayed windows
public EwolContext(final EwolApplication application) {
this.application = application;
this.objectManager = new ObjectManager(this);
this.input = new InputManager(this);
if (this.application == null) {
Log.critical("Can not start context with no Application ==> rtfm ...");
LOGGER.error("Can not start context with no Application ==> rtfm ...");
System.exit(-1);
}
}
/**
* Redraw all the windows
*/
public void forceRedrawAll() {
Log.warning("force redraw on windows:" + this.windowsCurrent);
LOGGER.warn("force redraw on windows:" + this.windowsCurrent);
if (this.windowsCurrent == null) {
return;
}
@ -76,32 +79,32 @@ public class EwolContext extends GaleApplication {
this.windowsCurrent.onChangeSize();
/// Gale.getContext().aaaaaaaaaaaaaa();
}
public void forceRedrawAllAsync() {
Log.verbose("force redraw ALL (ASYNC):");
LOGGER.trace("force redraw ALL (ASYNC):");
GaleContext.getContext().requestUpdateSize();
}
public EwolApplication getApplication() {
return this.application;
}
public CommandLine getCmd() {
return Gale.getContext().getCmd();
}
public ObjectManager getEObjectManager() {
return this.objectManager;
}
public ResourceManager getResourcesManager() {
return Gale.getContext().getResourcesManager();
}
public WidgetManager getWidgetManager() {
return this.widgetManager;
}
/**
* get the current windows that is displayed
* @return the current handle on the windows (can be null)
@ -109,7 +112,7 @@ public class EwolContext extends GaleApplication {
public Windows getWindows() {
return this.windowsCurrent;
}
/**
* This fonction lock the pointer properties to move in relative instead
* of absolute
@ -118,7 +121,7 @@ public class EwolContext extends GaleApplication {
public void inputEventGrabPointer(final Widget widget) {
this.input.grabPointer(widget);
}
/**
* This is to transfert the event from one widget to another one
* @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) {
this.input.transfertEvent(source, destination);
}
/**
* This fonction un-lock the pointer properties to move in relative
* instead of absolute
@ -135,7 +138,7 @@ public class EwolContext extends GaleApplication {
public void inputEventUnGrabPointer() {
this.input.unGrabPointer();
}
@Override
public void onClipboardEvent(final ClipboardList clipboardId) {
final Widget tmpWidget = this.widgetManager.focusGet();
@ -143,29 +146,29 @@ public class EwolContext extends GaleApplication {
tmpWidget.onEventClipboard(clipboardId);
}
}
@Override
public void onCreate(final GaleContext context) {
Log.info(" == > Ewol system create (BEGIN)");
LOGGER.info(" == > Ewol system create (BEGIN)");
// Add basic ewol translation:
ETranslate.addPath("ewol", new Uri("TRANSLATE", "", "ewol"));
ETranslate.autoDetectLanguage();
// parse for help:
for (int iii = 0; iii < context.getCmd().size(); ++iii) {
if (context.getCmd().get(iii).equals("-h") || context.getCmd().get(iii).equals("--help")) {
Log.print("ewol - help : ");
Log.print(" xxxxxxxxxxxxx [options]");
Log.print(" -h/--help: Display this help");
Log.print(" example:");
Log.print(" xxxxxxxxxxxxx --help");
LOGGER.info("ewol - help : ");
LOGGER.info(" xxxxxxxxxxxxx [options]");
LOGGER.info(" -h/--help: Display this help");
LOGGER.info(" example:");
LOGGER.info(" xxxxxxxxxxxxx --help");
// this is a global help system does not remove it
continue;
}
//context.getCmd().remove(iii);
//--iii;
}
// Log.info("EWOL v:" + ewol::getVersion());
// LOGGER.info("EWOL v:" + ewol::getVersion());
// force a recalculation
/*
* requestUpdateSize(){ Context context = gale::getContext();
@ -178,16 +181,16 @@ public class EwolContext extends GaleApplication {
*/
final EwolApplication appl = this.application;
if (appl == null) {
Log.error(" == > Create without application");
LOGGER.error(" == > Create without application");
return;
}
appl.onCreate(this);
Log.info(" == > Ewol system create (END)");
LOGGER.info(" == > Ewol system create (END)");
}
@Override
public void onDestroy(final GaleContext context) {
Log.info(" == > Ewol system destroy (BEGIN)");
LOGGER.info(" == > Ewol system destroy (BEGIN)");
// Remove current windows
this.windowsCurrent = null;
// clean all widget and sub widget with their resources:
@ -200,16 +203,16 @@ public class EwolContext extends GaleApplication {
}
// internal clean elements
this.objectManager.cleanInternalRemoved();
Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
LOGGER.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
this.objectManager.displayListObject();
// now All must be removed !!!
this.objectManager.unInit();
Log.info(" == > Ewol system destroy (END)");
LOGGER.info(" == > Ewol system destroy (END)");
}
@Override
public void onDraw(final GaleContext context) {
//Log.verbose("EWOL DRAW");
//LOGGER.trace("EWOL DRAW");
// clean internal data...
this.objectManager.cleanInternalRemoved();
// real draw...
@ -219,10 +222,14 @@ public class EwolContext extends GaleApplication {
}
window.sysDraw();
}
@Override
public void onKeyboard(final KeySpecial special, final KeyKeyboard type, final Character value, final KeyStatus state) {
Log.verbose("event {" + special + "} " + type + " '" + value + "' " + state);
public void onKeyboard(
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...
this.input.setLastKeyboardSpecial(special);
if (this.windowsCurrent == null) {
@ -242,7 +249,7 @@ public class EwolContext extends GaleApplication {
return;
}
// check if the widget allow repeating key events.
// Log.info("repeating test :" + repeate + " widget=" +
// LOGGER.info("repeating test :" + repeate + " widget=" +
// tmpWidget.getKeyboardRepeate() + " state=" + isDown);
if (!repeate || (repeate && tmpWidget.getKeyboardRepeat())) {
// check Widget shortcut
@ -266,69 +273,74 @@ public class EwolContext extends GaleApplication {
tmpWidget.systemEventEntry(tmpEntryEvent);
}
} else {
Log.debug("remove Repeate key ...");
LOGGER.debug("remove Repeate key ...");
}
}
}
@Override
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;
if (appl == null) {
exit(0);
return;
}
appl.onKillDemand(this);
Log.info(" == > User demand a destroy (END)");
LOGGER.info(" == > User demand a destroy (END)");
}
@Override
public void onPause(final GaleContext context) {
Log.info(" == > Ewol system pause (BEGIN)");
LOGGER.info(" == > Ewol system pause (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onPause(this);
Log.info(" == > Ewol system pause (END)");
LOGGER.info(" == > Ewol system pause (END)");
}
@Override
public void onPeriod(final Clock clock, final long time) {
this.objectManager.timeCall(clock, time);
}
@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);
switch (state) {
case move:
// Log.debug("Receive MSG : THREAD_INPUT_MOTION");
// LOGGER.debug("Receive MSG : THREAD_INPUT_MOTION");
this.input.motion(type, pointerID, pos);
break;
case down:
case downRepeat:
// Log.debug("Receive MSG : THREAD_INPUT_STATE");
// LOGGER.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(type, pointerID, true, pos);
break;
case up:
// Log.debug("Receive MSG : THREAD_INPUT_STATE");
// LOGGER.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(type, pointerID, false, pos);
break;
default:
Log.debug("Unknow state : " + state);
LOGGER.debug("Unknow state : " + state);
break;
}
}
@Override
public void onRegenerateDisplay(final GaleContext context) {
//Log.info("EWOL onRegenerateDisplay /// ");
//LOGGER.info("EWOL onRegenerateDisplay /// ");
// check if the user selected a windows
final Windows window = this.windowsCurrent;
if (window == null) {
Log.error("No windows ...");
LOGGER.error("No windows ...");
return;
}
// Redraw all needed elements
@ -338,52 +350,52 @@ public class EwolContext extends GaleApplication {
}
// markDrawingIsNeeded();
}
@Override
public void onResize(final Vector2f size) {
super.onResize(size);
forceRedrawAll();
}
public void onResize(final Vector2i size) {
Log.verbose("Resize: " + size);
LOGGER.trace("Resize: " + size);
forceRedrawAll();
}
@Override
public void onResume(final GaleContext context) {
Log.info(" == > Ewol system resume (BEGIN)");
LOGGER.info(" == > Ewol system resume (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onResume(this);
Log.info(" == > Ewol system resume (END)");
LOGGER.info(" == > Ewol system resume (END)");
}
@Override
public void onStart(final GaleContext context) {
Log.info(" == > Ewol system start (BEGIN)");
LOGGER.info(" == > Ewol system start (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
// TODO : Request exit of the application .... with error ...
return;
}
appl.onStart(this);
Log.info(" == > Ewol system start (END)");
LOGGER.info(" == > Ewol system start (END)");
}
@Override
public void onStop(final GaleContext context) {
Log.info(" == > Ewol system stop (BEGIN)");
LOGGER.info(" == > Ewol system stop (BEGIN)");
final EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onStop(this);
Log.info(" == > Ewol system stop (END)");
LOGGER.info(" == > Ewol system stop (END)");
}
/**
* Request a display after call a resize
*/
@ -391,14 +403,14 @@ public class EwolContext extends GaleApplication {
final GaleContext context = Gale.getContext();
context.requestUpdateSize();
}
/**
* reset event management for the IO like Input ou Mouse or keyborad
*/
public void resetIOEvent() {
this.input.newLayerSet();
}
/**
* Special for init (main) set the start image when loading data
* @param fileName Name of the image to load
@ -406,13 +418,13 @@ public class EwolContext extends GaleApplication {
public void setInitImage(final Uri fileName) {
// this.initDisplayImageName = fileName;
}
/**
* set the current windows to display :
* @param windows Windows that might be displayed
*/
public void setWindows(final Windows windows) {
Log.info("set New windows");
LOGGER.info("set New windows");
// remove current focus :
this.widgetManager.focusSetDefault(null);
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.Vector3f;
import org.atriasoft.ewol.event.InputSystem;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.Widget;
import org.atriasoft.ewol.widget.Windows;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* internal structure
@ -27,6 +28,7 @@ class InputLimit {
}
class InputManager {
private static final Logger LOGGER = LoggerFactory.getLogger(InputManager.class);
private static final long MILLI_TO_DURATION = 1000000;
private static final long SECONDS_TO_DURATION = 1000000000;
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 InputLimit eventMouseLimit = new InputLimit();
private final InputPoperty[] eventMouseSaved = new InputPoperty[InputManager.MAX_MANAGE_INPUT];
// special grab pointer mode :
private WeakReference<Widget> grabWidget = null; //!< widget that grab the curent pointer.
private KeySpecial specialKey;
public InputManager(final EwolContext context) {
this.context = context;
setDpi(200);
Log.info("Init (start)");
LOGGER.info("Init (start)");
for (int iii = 0; iii < InputManager.MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ...
this.eventInputSaved[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) {
if (eventTable == null) {
return;
}
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() {
this.eventInputLimit.sepatateTime = 300 * InputManager.MILLI_TO_DURATION;
this.eventInputLimit.dpiOffset = this.dpi * 100;
this.eventMouseLimit.sepatateTime = 300 * InputManager.MILLI_TO_DURATION;
this.eventMouseLimit.dpiOffset = (int) (this.dpi * 0.1f);
}
public void cleanElement(final InputPoperty[] eventMouseSaved2, final int idInput) {
if (eventMouseSaved2 == null) {
return;
}
//Log.info("CleanElement[" + idInput + "] = @" + (long)eventTable);
//LOGGER.info("CleanElement[" + idInput + "] = @" + (long)eventTable);
eventMouseSaved2[idInput].clear();
}
/**
* This fonction lock the pointer properties to move in relative instead of absolute
* @param widget The widget that lock the pointer events
@ -94,7 +97,7 @@ class InputManager {
widget.getSize().y/2.0f) );
*/
}
/**
* generate the event on the destinated widget.
* @param type Type of the event that might be sended.
@ -104,12 +107,18 @@ class InputManager {
* @param pos position of the event
* @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 (type == KeyType.mouse || type == KeyType.finger) {
// create the system Event :
// 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 :
return destWidget.systemEventInput(tmpEventSystem);
}
@ -117,7 +126,7 @@ class InputManager {
}
return false;
}
/**
* 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
@ -144,10 +153,10 @@ class InputManager {
}
return realInputId;
}
// note if id<0 == > the it was finger event ...
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) {
// reject pointer == > out of IDs...
return;
@ -158,7 +167,7 @@ class InputManager {
} else if (type == KeyType.finger) {
eventTable = this.eventInputSaved;
} else {
Log.error("Unknown type of event");
LOGGER.error("Unknown type of event");
return;
}
if (pointerID > InputManager.MAX_MANAGE_INPUT || pointerID < 0) {
@ -177,13 +186,17 @@ class InputManager {
} else if (tmpWindows != null) {
tmpWidget = tmpWindows.getWidgetAtPos(new Vector3f(pos.x(), pos.y(), 0));
}
if (eventTable[pointerID].curentWidgetEvent != null && tmpWidget != eventTable[pointerID].curentWidgetEvent.get()
|| (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()))) {
if (eventTable[pointerID].curentWidgetEvent != null
&& tmpWidget != eventTable[pointerID].curentWidgetEvent.get()
|| (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;
//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;
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) {
// set the element inside ...
@ -197,35 +210,41 @@ class InputManager {
eventTable[pointerID].size = tmpWidget.getSize();
}
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;
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;
localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.move, pos);
} else if (eventTable[pointerID].isUsed) {
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].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;
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())
&& (eventTable[pointerID].origin.y() <= pos.y() && (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) >= pos.y())) {
} else if ((eventTable[pointerID].origin.x() <= pos.x()
&& (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) >= pos.x())
&& (eventTable[pointerID].origin.y() <= pos.y()
&& (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) >= pos.y())) {
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;
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;
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 ...
*/
@ -238,23 +257,23 @@ class InputManager {
cleanElement(this.eventMouseSaved, iii);
}
}
public void setDpi(final int newDPI) {
this.dpi = newDPI;
// recalculate the DPI system ...
calculateLimit();
}
public void setLastKeyboardSpecial(final KeySpecial specialKey) {
this.specialKey = specialKey;
}
public void state(final KeyType type, final int pointerID, final boolean isDown, final Vector2f pos) {
if (pointerID >= InputManager.MAX_MANAGE_INPUT) {
// reject pointer == > out of IDs...
return;
}
//Log.debug("event pointerId=" + pointerID);
//LOGGER.debug("event pointerId=" + pointerID);
// convert position in open-GL coordonates ...
InputPoperty[] eventTable = null;
InputLimit localLimit;
@ -265,7 +284,7 @@ class InputManager {
eventTable = this.eventInputSaved;
localLimit = this.eventInputLimit;
} else {
Log.error("Unknown type of event");
LOGGER.error("Unknown type of event");
return;
}
if (pointerID > InputManager.MAX_MANAGE_INPUT || pointerID <= 0) {
@ -275,14 +294,15 @@ class InputManager {
// get the curent time ...
final long currentTime = System.nanoTime();
final Windows tmpWindows = this.context.getWindows();
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) {
// we have an event previously ... check delay between click and offset position
if (currentTime - eventTable[pointerID].lastTimeEvent > localLimit.sepatateTime) {
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);
}
}
@ -290,9 +310,10 @@ class InputManager {
// save start time
eventTable[pointerID].lastTimeEvent = currentTime;
// 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;
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 {
// Mark it used :
eventTable[pointerID].isUsed = true;
@ -312,9 +333,9 @@ class InputManager {
eventTable[pointerID].curentWidgetEvent = new WeakReference<>(tmpWidget);
/*
if (tmpWidget != null) {
Log.debug("Get widget at pos=" + pos + " type: " + tmpWidget.getObjectType());
LOGGER.debug("Get widget at pos=" + pos + " type: " + tmpWidget.getObjectType());
} 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;
}
// 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;
localEventInput(type, tmpWidget, eventTable[pointerID].destinationInputId, KeyStatus.down, pos);
}
} 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();
if (!eventTable[pointerID].isUsed) {
// bad case ... ???
Log.debug("Up event without previous down ... ");
LOGGER.debug("Up event without previous down ... ");
// Mark it un-used :
eventTable[pointerID].isUsed = false;
// revove the widget ...
eventTable[pointerID].curentWidgetEvent = null;
} else if (tmpWidget == null) {
// The widget has been removed:
//Log.debug(" Object Removed ...");
//LOGGER.debug(" Object Removed ...");
// Mark it un-used :
eventTable[pointerID].isUsed = false;
// revove the widget ...
eventTable[pointerID].curentWidgetEvent = null;
} else {
// 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;
// send up event after the single event to prevent multiple widget getting elements
localEventInput(type, tmpWidget, pointerID, KeyStatus.up, pos);
// 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 :
eventTable[pointerID].downStart = pos;
// save start time
@ -369,12 +391,14 @@ class InputManager {
nbClickMax = 5;
}
// 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 :
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;
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) {
eventTable[pointerID].nbClickEvent = 0;
}
@ -391,7 +415,7 @@ class InputManager {
}
}
}
/**
* This is to transfert the event from one widget to another one
* @param source the widget where the event came from
@ -406,28 +430,32 @@ class InputManager {
Widget tmpWidget = this.eventInputSaved[iii].curentWidgetEvent.get();
if (tmpWidget == source) {
// 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);
localEventInput(KeyType.finger, tmpWidget, this.eventInputSaved[iii].destinationInputId, KeyStatus.abort, 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);
// set the new widget ...
this.eventInputSaved[iii].curentWidgetEvent = new WeakReference<>(destination);
// 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);
localEventInput(KeyType.finger, destination, this.eventInputSaved[iii].destinationInputId, KeyStatus.transfer, 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);
}
tmpWidget = this.eventMouseSaved[iii].curentWidgetEvent.get();
if (tmpWidget == source) {
// 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);
localEventInput(KeyType.mouse, tmpWidget, this.eventMouseSaved[iii].destinationInputId, KeyStatus.abort, 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);
// set the new widget ...
this.eventMouseSaved[iii].curentWidgetEvent = new WeakReference<>(destination);
// 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);
localEventInput(KeyType.mouse, destination, this.eventMouseSaved[iii].destinationInputId, KeyStatus.transfer, 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);
}
}
}
/**
* This function un-lock the pointer properties to move in relative instead of absolute
*/
@ -435,7 +463,7 @@ class InputManager {
this.grabWidget = null;
// TODO this.context.grabPointerEvents(false, Vector3f(0,0));
}
}
/**
@ -453,7 +481,7 @@ class InputPoperty {
public Vector3f origin = Vector3f.ZERO;
public Vector2f posEvent = Vector2f.ZERO;
public Vector3f size = Vector3f.MAX_VALUE;
public void clear() {
this.isUsed = false;
this.destinationInputId = 0;
@ -466,6 +494,6 @@ class InputPoperty {
this.isInside = false;
this.nbClickEvent = 0;
this.posEvent = Vector2f.ZERO;
}
}

View File

@ -14,14 +14,20 @@ import java.nio.file.Paths;
import java.util.Collections;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoadPackageStream {
private static final Logger LOGGER = LoggerFactory.getLogger(LoadPackageStream.class);
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);
if (out == null) {
Log.error("Can not load resource: '" + resourceName + "'");
for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources")).toArray(Path[]::new)) {
Log.warning(" - '" + elem + "'");
LOGGER.error("Can not load resource: '" + resourceName + "'");
for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources"))
.toArray(Path[]::new)) {
LOGGER.warn(" - '" + elem + "'");
}
return null;
}
@ -34,7 +40,7 @@ public class LoadPackageStream {
}
return data;
}
public static Stream<Path> getResources(final URL element) {
try {
final URI uri = element.toURI();
@ -66,19 +72,20 @@ public class LoadPackageStream {
return Stream.of();
}
}
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);
if (out == null) {
Log.error("Can not load resource: '" + resourceName + "'");
for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources")).toArray(Path[]::new)) {
Log.warning(" - '" + elem + "'");
LOGGER.error("Can not load resource: '" + resourceName + "'");
for (final Path elem : LoadPackageStream.getResources(LoadPackageStream.class.getResource("/resources"))
.toArray(Path[]::new)) {
LOGGER.warn(" - '" + elem + "'");
}
}
return out;
}
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.ewol.Ewol;
import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.internal.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file
* @author Edouard DUPIN
@ -29,6 +30,7 @@ import org.atriasoft.ewol.internal.Log;
@AknotDefaultAttribute
@AknotIgnoreUnknown
public class EwolObject {
private static final Logger LOGGER = LoggerFactory.getLogger(EwolObject.class);
private static Integer valUID = 0; //!< Static used for the unique ID definition
/**
@ -76,7 +78,7 @@ public class EwolObject {
synchronized (EwolObject.valUID) {
this.uniqueId = EwolObject.valUID++;
}
Log.debug("new Object : [" + this.uniqueId + "]");
LOGGER.debug("new Object : [" + this.uniqueId + "]");
EwolObject.getObjectManager().add(this);
}
@ -85,12 +87,12 @@ public class EwolObject {
* Auto-destroy the object
*/
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) {
final EwolObject parent = this.parent.get();
// TODO : set a signal to do this ...
if (parent != null) {
Log.verbose("Destroy object: Call parrent");
LOGGER.trace("Destroy object: Call parrent");
parent.requestDestroyFromChild(this);
}
}
@ -144,7 +146,7 @@ public class EwolObject {
* @return the requested object or null
*/
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)) {
return this;
}
@ -172,8 +174,10 @@ public class EwolObject {
* @param child Object of the child that want to remove itself
*/
protected void requestDestroyFromChild(final EwolObject child) {
Log.info("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ...");
Log.critical("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)");
LOGGER.info(
"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) {

View File

@ -10,7 +10,8 @@ import java.util.List;
import org.atriasoft.esignal.Signal;
import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file
* @author Edouard DUPIN
@ -19,24 +20,25 @@ import org.atriasoft.ewol.internal.Log;
*/
public class ObjectManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectManager.class);
private final long applWakeUpTime; //!< Time of the application initialize
private final Clock applWakeUpClock; //!< Time of the application initialize
private EwolContext context = null;
private final List<WeakReference<EwolObject>> eObjectList = new ArrayList<>(); // all widget allocated == > all time increment ... never removed ...
private long lastPeriodicCallTime; //!< last call time ...
private Clock lastPeriodicCallClock; //!< last call time ...
public final Signal<EventTime> periodicCall = new Signal<>();
private final List<EwolObject> workerList = new ArrayList<>();
public ObjectManager(final EwolContext context) {
this.context = context;
//periodicCall(this, "periodic", "Call every time system render");
Log.debug(" == > init Object-Manager");
Log.todo("set this back ...");
LOGGER.debug(" == > init Object-Manager");
LOGGER.info("[TODO] set this back ...");
//this.periodicCall.setPeriodic(true);
// set the basic time properties :
this.applWakeUpTime = System.nanoTime();
@ -44,7 +46,7 @@ public class ObjectManager {
this.applWakeUpClock = Clock.systemUTC();
this.lastPeriodicCallClock = this.applWakeUpClock;
}
/**
* 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)
@ -52,17 +54,17 @@ public class ObjectManager {
*/
public synchronized void add(final EwolObject object) {
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));
}
/**
* clean the weak pointer list (remove weakptr that is remoed)
*/
public synchronized void cleanInternalRemoved() {
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();
while (iterator.hasNext()) {
final WeakReference<EwolObject> elem = iterator.next();
@ -71,23 +73,24 @@ public class ObjectManager {
}
}
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.
*/
public synchronized void displayListObject() {
Log.info("List loaded object : ");
LOGGER.info("List loaded object : ");
for (final WeakReference<EwolObject> it : this.eObjectList) {
final EwolObject element = it.get();
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
* @param name Name of the Object
@ -105,7 +108,7 @@ public class ObjectManager {
}
return null;
}
/**
* Get the number of loaded object in the system
* @return number of Object
@ -113,7 +116,7 @@ public class ObjectManager {
public synchronized int getNumberObject() {
return this.eObjectList.size();
}
/**
* retrive an object with his name
* @param name Name of the object
@ -122,26 +125,27 @@ public class ObjectManager {
public synchronized EwolObject getObjectNamed(final String name) {
return get(name);
}
/**
* Call every time we can with the current time
* @param localTime Current system 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;
this.lastPeriodicCallTime = time;
if (this.periodicCall.size() <= 0) {
Log.verbose("Periodic main dunction: Call [ END ] ==> no connection");
LOGGER.trace("Periodic main dunction: Call [ END ] ==> no connection");
return;
}
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);
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
* @return true, have some periodic event...
@ -149,7 +153,7 @@ public class ObjectManager {
public synchronized boolean timeCallHave() {
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
* @param localTime Current system Time.
@ -158,14 +162,14 @@ public class ObjectManager {
this.lastPeriodicCallClock = clock;
this.lastPeriodicCallTime = time;
}
/**
* remove all resources (un-init) out of the destructor (due to the system implementation)
*/
public synchronized void unInit() {
Log.debug(" == > Un-Init Object-Manager");
LOGGER.debug(" == > Un-Init Object-Manager");
if (this.workerList.size() > 0) {
Log.debug(" == > Remove all workers");
LOGGER.debug(" == > Remove all workers");
this.workerList.clear();
}
for (final WeakReference<EwolObject> it : this.eObjectList) {
@ -175,11 +179,11 @@ public class ObjectManager {
}
}
if (this.eObjectList.size() != 0) {
Log.error("Have " + this.eObjectList.size() + " active Object");
LOGGER.error("Have " + this.eObjectList.size() + " active Object");
}
this.eObjectList.clear();
}
/**
* Add a worker on the system list.
* @param worker Worker to add in the list.
@ -187,7 +191,7 @@ public class ObjectManager {
public synchronized void workerAdd(final EwolObject worker) {
this.workerList.add(worker);
}
/**
* Remove a worker on the system 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.math.Matrix4f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.resource.Resource;
import org.atriasoft.gale.resource.ResourceProgram;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* simple display of Colored3DObject ==> for DEBUG only Not availlable on
* ALL platform (like webGL)
*/
public class RefactorColored3DObject extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(RefactorColored3DObject.class);
protected int oGLColor;
protected int oGLMatrix;
protected int oGLPosition;
protected ResourceProgram oGLprogram;
public RefactorColored3DObject() {
// get the shader resource :
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) {
this.oGLPosition = this.oGLprogram.getAttribute("EWcoord3d");
this.oGLColor = this.oGLprogram.getUniform("EWcolor");
this.oGLMatrix = this.oGLprogram.getUniform("EWMatrixTransformation");
}
}
@Override
public void cleanUp() {
// TODO Auto-generated method stub
}
public void draw(final List<Vector3f> vertices, final Color color) {
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) {
return;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
if (depthtest) {
@ -62,8 +69,8 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false);
}
}
// Log.debug(" display " + this.coord.size() + " elements" );
// LOGGER.debug(" display " + this.coord.size() + " elements" );
this.oGLprogram.use();
// set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix();
@ -71,7 +78,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix);
// 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 :
this.oGLprogram.uniformColor(this.oGLColor, color);
// Request the draw od the elements:
@ -83,22 +91,27 @@ public class RefactorColored3DObject extends Resource {
if (depthtest) {
if (!updateDepthBuffer) {
OpenGL.setDeathMask(true);
}
OpenGL.disable(OpenGL.Flag.flag_depthTest);
}
}
public void draw(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix) {
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) {
return;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
if (depthTest) {
@ -107,7 +120,7 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false);
}
}
// Log.debug(" display " + this.coord.size() + " elements" );
// LOGGER.debug(" display " + this.coord.size() + " elements" );
this.oGLprogram.use();
// set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix();
@ -115,7 +128,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix).multiply(transformationMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix);
// 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 :
this.oGLprogram.uniformColor(this.oGLColor, color);
// Request the draw od the elements:
@ -128,29 +142,35 @@ public class RefactorColored3DObject extends Resource {
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<>();
lats = lats / 2 * 2;
// center to border (TOP)
float offset = size * 0.5f;
for (int iii = lats / 2 + 1; iii <= lats; ++iii) {
final float lat0 = (float) (Math.PI) * (-0.5f + (float) (iii - 1) / lats);
final float z0 = (float) (radius * Math.sin(lat0));
final float zr0 = (float) (radius * Math.cos(lat0));
final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats);
final float z1 = (float) (radius * Math.sin(lat1));
final float zr1 = (float) (radius * Math.cos(lat1));
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
float x = (float) Math.cos(lng);
float y = (float) Math.sin(lng);
final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1 + offset);
final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0 + offset);
lng = 2 * (float) (Math.PI) * (jjj) / longs;
x = (float) Math.cos(lng);
y = (float) Math.sin(lng);
@ -159,7 +179,7 @@ public class RefactorColored3DObject extends Resource {
tmpVertices.add(v1);
tmpVertices.add(v2);
tmpVertices.add(v3);
tmpVertices.add(v1);
tmpVertices.add(v3);
tmpVertices.add(v4);
@ -168,24 +188,24 @@ public class RefactorColored3DObject extends Resource {
// Cylinder
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * 0.5f;
float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z);
final Vector3f v2b = new Vector3f(x, y, -z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius);
final Vector3f v3 = new Vector3f(x, y, z);
final Vector3f v3b = new Vector3f(x, y, -z);
tmpVertices.add(v2);
tmpVertices.add(v3);
tmpVertices.add(v3b);
tmpVertices.add(v2);
tmpVertices.add(v3b);
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 z0 = (float) (radius * Math.sin(lat0));
final float zr0 = (float) (radius * Math.cos(lat0));
final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats);
final float z1 = (float) (radius * Math.sin(lat1));
final float zr1 = (float) (radius * Math.cos(lat1));
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
float x = (float) Math.cos(lng);
float y = (float) Math.sin(lng);
final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1 + offset);
final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0 + offset);
lng = 2 * (float) (Math.PI) * (jjj) / longs;
x = (float) Math.cos(lng);
y = (float) Math.sin(lng);
@ -216,7 +236,7 @@ public class RefactorColored3DObject extends Resource {
tmpVertices.add(v1);
tmpVertices.add(v2);
tmpVertices.add(v3);
tmpVertices.add(v1);
tmpVertices.add(v3);
tmpVertices.add(v4);
@ -224,18 +244,24 @@ public class RefactorColored3DObject extends Resource {
}
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<>();
// center to border (TOP)
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, -size / 2);
float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, size / 2);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius);
@ -247,13 +273,13 @@ public class RefactorColored3DObject extends Resource {
// center to border (BOTTOM)
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, size / 2);
float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, size / 2);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius);
@ -264,67 +290,83 @@ public class RefactorColored3DObject extends Resource {
}
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);
}
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<>();
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(), 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(), 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(), 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(), 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(max.x(), min.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(), max.y(), max.z()));
vertices.add(new Vector3f(min.x(), min.y(), max.z()));
vertices.add(new Vector3f(min.x(), max.y(), max.z()));
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<>();
// center to border (TOP)
// center to border (TOP)
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * 0.5f;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, z);
float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius);
@ -336,24 +378,24 @@ public class RefactorColored3DObject extends Resource {
// Cylinder
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * 0.5f;
float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z);
final Vector3f v2b = new Vector3f(x, y, -z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius);
final Vector3f v3 = new Vector3f(x, y, z);
final Vector3f v3b = new Vector3f(x, y, -z);
tmpVertices.add(v2);
tmpVertices.add(v3);
tmpVertices.add(v3b);
tmpVertices.add(v2);
tmpVertices.add(v3b);
tmpVertices.add(v2b);
@ -361,14 +403,14 @@ public class RefactorColored3DObject extends Resource {
// center to border (BOTTOM)
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
final float z = size * -0.5f;
final Vector3f v1 = new Vector3f(0.0f, 0.0f, z);
float x = (float) (Math.cos(lng) * radius);
float y = (float) (Math.sin(lng) * radius);
final Vector3f v2 = new Vector3f(x, y, z);
lng = 2.0f * (float) (Math.PI) * (jjj) / longs;
x = (float) (Math.cos(lng) * radius);
y = (float) (Math.sin(lng) * radius);
@ -379,17 +421,22 @@ public class RefactorColored3DObject extends Resource {
}
draw(tmpVertices, tmpColor, transformationMatrix);
}
public void drawLine(final List<Vector3f> vertices, final Color color, final Matrix4f transformationMatrix) {
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) {
return;
}
if (this.oGLprogram == null) {
Log.error("No shader ...");
LOGGER.error("No shader ...");
return;
}
if (depthTest) {
@ -398,7 +445,7 @@ public class RefactorColored3DObject extends Resource {
OpenGL.setDeathMask(false);
}
}
// Log.debug(" display " + this.coord.size() + " elements" );
// LOGGER.debug(" display " + this.coord.size() + " elements" );
this.oGLprogram.use();
// set Matrix: translation/positionMatrix
final Matrix4f projMatrix = OpenGL.getMatrix();
@ -406,7 +453,8 @@ public class RefactorColored3DObject extends Resource {
final Matrix4f tmpMatrix = projMatrix.multiply(camMatrix).multiply(transformationMatrix);
this.oGLprogram.uniformMatrix(this.oGLMatrix, tmpMatrix);
// 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 :
this.oGLprogram.uniformColor(this.oGLColor, color);
// Request the draw od the elements:
@ -419,35 +467,40 @@ public class RefactorColored3DObject extends Resource {
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<>();
for (int iii = 0; iii <= lats; ++iii) {
final float lat0 = (float) (Math.PI) * (-0.5f + (float) (iii - 1) / lats);
final float z0 = (float) (radius * Math.sin(lat0));
final float zr0 = (float) (radius * Math.cos(lat0));
final float lat1 = (float) (Math.PI) * (-0.5f + (float) (iii) / lats);
final float z1 = (float) (radius * Math.sin(lat1));
final float zr1 = (float) (radius * Math.cos(lat1));
for (int jjj = 0; jjj < longs; ++jjj) {
float lng = 2.0f * (float) (Math.PI) * (jjj - 1) / longs;
float x = (float) Math.cos(lng);
float y = (float) Math.sin(lng);
final Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1);
final Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0);
lng = 2 * (float) (Math.PI) * (jjj) / longs;
x = (float) Math.cos(lng);
y = (float) Math.sin(lng);
final Vector3f v2 = new Vector3f(x * zr1, y * zr1, z1);
final Vector3f v3 = new Vector3f(x * zr0, y * zr0, z0);
tmpVertices.add(v1);
tmpVertices.add(v2);
tmpVertices.add(v3);
tmpVertices.add(v1);
tmpVertices.add(v3);
tmpVertices.add(v4);
@ -455,12 +508,15 @@ public class RefactorColored3DObject extends Resource {
}
draw(tmpVertices, tmpColor, transformationMatrix);
}
public void drawSquare(final Vector3f size, final Matrix4f transformationMatrix, final Color tmpColor) {
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 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()),
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 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()) };
for (int iii = 0; iii < 36; iii += 3) {
// normal calculation :
@ -473,23 +529,32 @@ public class RefactorColored3DObject extends Resource {
}
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));
}
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<>();
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 + 1)).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]);
// 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]]);
}
// Log.info("display " + tmpVertices.size() + " vertices form " +
// LOGGER.info("display " + tmpVertices.size() + " vertices form " +
// indice.size());
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.etk.Color;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class ListElement {
public Color color;
@ -33,18 +34,21 @@ class ListElement {
* example black, or white or orange ...)
*/
public class ResourceColorFile extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceColorFile.class);
public static ResourceColorFile create(final Uri uri) {
Log.verbose("KEEP: ColorFile: " + uri);
ResourceColorFile object = null;
LOGGER.trace("KEEP: ColorFile: " + uri);
final ResourceColorFile object = null;
final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) {
if (object2 instanceof ResourceColorFile) {
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;
}
Log.debug("CREATE: FontFreeType: " + uri);
LOGGER.debug("CREATE: FontFreeType: " + uri);
// need to crate a new one ...
return new ResourceColorFile(uri);
}
@ -59,9 +63,9 @@ public class ResourceColorFile extends Resource {
*/
public ResourceColorFile(final Uri uri) {
super(uri);
Log.debug("CF : load \"" + uri + "\"");
LOGGER.debug("CF : load \"" + uri + "\"");
reload();
// Log.debug("List of all color : " + this.list.keySet());
// LOGGER.debug("List of all color : " + this.list.keySet());
}
@Override
@ -94,8 +98,8 @@ public class ResourceColorFile extends Resource {
}
public synchronized void put(final String name, final Color color) {
for (int iii = 0; iii < this.list.size(); iii++) {
final ListElement elem = this.list.get(iii);
for (final ListElement element : this.list) {
final ListElement elem = element;
if (elem.name.contentEquals(name)) {
elem.color = color;
return;
@ -107,17 +111,17 @@ public class ResourceColorFile extends Resource {
@Override
public synchronized void reload() {
// remove all previous set of value :
for (int iii = 0; iii < this.list.size(); ++iii) {
this.list.get(iii).color = this.errorColor;
for (final ListElement element : this.list) {
element.color = this.errorColor;
}
Log.todo("Mut be implemented ...");
LOGGER.info("[TODO] Mut be implemented ...");
// open and read all json elements:
try {
final JsonObject out = Ejson.parse(Uri.valueOf(this.name)).toJsonObject();
final JsonArray baseArray = out.get("color").toJsonArray();
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);
return;
}
@ -125,15 +129,15 @@ public class ResourceColorFile extends Resource {
for (final JsonNode it : baseArray.getNodes()) {
final JsonObject tmpObj = it.toJsonObject();
if (tmpObj == null) {
Log.error(" can not get object in 'color' : " + it);
LOGGER.error(" can not get object in 'color' : " + it);
findError = true;
continue;
}
final String name = tmpObj.get("name").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) {
Log.error("Drop an empty name");
LOGGER.error("Drop an empty name");
findError = true;
continue;
}
@ -143,11 +147,11 @@ public class ResourceColorFile extends Resource {
put(name, Color.valueOf(color));
}
if (findError) {
Log.error("pb in parsing file:" + this.name);
LOGGER.error("pb in parsing file:" + this.name);
Ejson.display(out);
}
} 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();
}
}

View File

@ -12,8 +12,9 @@ import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.model.JsonObject;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class ListElementConfig {
public final String name;
@ -26,6 +27,8 @@ class ListElementConfig {
}
public class ResourceConfigFile extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceConfigFile.class);
/**
* keep the resource pointer.
* @note Never free this pointer by your own...
@ -42,7 +45,8 @@ public class ResourceConfigFile extends Resource {
resource2.keep();
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;
}
final ResourceConfigFile resource = new ResourceConfigFile(name);
@ -60,7 +64,7 @@ public class ResourceConfigFile extends Resource {
protected ResourceConfigFile(final Uri uri) {
super(uri.toString());
Log.debug("SFP : load '" + uri + "'");
LOGGER.debug("SFP : load '" + uri + "'");
reload();
}

View File

@ -14,20 +14,23 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.FMath;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.gale.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
public class ResourceFontSvg extends Resource {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceFontSvg.class);
public static ResourceFontSvg create(final Uri uri) {
Log.verbose("KEEP: FontFreeType: " + uri);
LOGGER.trace("KEEP: FontFreeType: " + uri);
ResourceFontSvg object = null;
final Resource object2 = Resource.getManager().localKeep(uri);
if (object2 != null) {
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;
}
object = (ResourceFontSvg) object2;
@ -35,7 +38,7 @@ public class ResourceFontSvg extends Resource {
if (object != null) {
return object;
}
Log.debug("CREATE: FontFreeType: " + uri);
LOGGER.debug("CREATE: FontFreeType: " + uri);
// need to crate a new one ...
return new ResourceFontSvg(uri);
}
@ -46,10 +49,11 @@ public class ResourceFontSvg extends Resource {
super(uri);
this.font = EsvgFont.load(uri);
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 {
// all OK
Log.debug("load font : '" + uri + "' glyph count = " + this.font.getNumGlyphs());
LOGGER.debug("load font : '" + uri + "' glyph count = " + this.font.getNumGlyphs());
// display();
}
}
@ -60,15 +64,26 @@ public class ResourceFontSvg extends Resource {
}
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);
}
// 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);
if (weight == null) {
return false;
@ -101,7 +116,11 @@ public class ResourceFontSvg extends Resource {
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);
for (int jjj = 0; jjj < weight.getHeight(); jjj++) {
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.Vector2i;
import org.atriasoft.ewol.Ewol;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.font.FontMode;
import org.atriasoft.ewol.resource.font.GlyphProperty;
import org.atriasoft.gale.resource.Resource;
import org.atriasoft.gale.resource.ResourceTexture2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ResourceTexturedFont extends ResourceTexture2 {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceTexturedFont.class);
public static ResourceTexturedFont create(final Uri fontBaseUri) {
ResourceTexturedFont resource;
Resource resource2;
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;
}
resource2 = Resource.getManager().localKeep("__TEXTURED__>>" + fontBaseUri.toString());
@ -33,7 +36,8 @@ public class ResourceTexturedFont extends ResourceTexture2 {
resource2.keep();
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;
}
resource = new ResourceTexturedFont(fontBaseUri);
@ -60,7 +64,7 @@ public class ResourceTexturedFont extends ResourceTexture2 {
protected ResourceTexturedFont(final Uri fontBaseUri) {
super("__TEXTURED_FONT__>>" + fontBaseUri.toString());
this.forceClimp = "true".equals(fontBaseUri.getProperty("FORCE_CLIMP"));
Log.debug("Load font : '" + fontBaseUri + "'");
LOGGER.debug("Load font : '" + fontBaseUri + "'");
this.font[0] = null;
this.font[1] = null;
@ -94,9 +98,12 @@ public class ResourceTexturedFont extends ResourceTexture2 {
this.size = Integer.parseInt(sizeString);
}
// find all the fonts...
final Uri fontBaseUriBold = new Uri(fontBaseUri.getGroup(), fontBaseUri.getPath().replace(".svg", "Bold.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());
final Uri fontBaseUriBold = new Uri(fontBaseUri.getGroup(), fontBaseUri.getPath().replace(".svg", "Bold.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()) {
this.fileName[FontMode.REGULAR.getValue()] = fontBaseUri;
}
@ -117,7 +124,7 @@ public class ResourceTexturedFont extends ResourceTexture2 {
refMode = FontMode.get(iii);
}
}
Log.debug(" set reference mode : " + refMode);
LOGGER.debug(" set reference mode : " + refMode);
// generate the wrapping on the preventing error
for (int iii = 3; iii >= 0; iii--) {
if (this.fileName[iii] != null) {
@ -129,14 +136,17 @@ public class ResourceTexturedFont extends ResourceTexture2 {
for (int iiiFontId = 0; iiiFontId < 4; iiiFontId++) {
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;
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]);
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++) {
@ -156,15 +166,15 @@ public class ResourceTexturedFont extends ResourceTexture2 {
addGlyph((char) 0);
// by default we set only the first AINSI char available
for (int iii = 0x20; iii < 0x7F; iii++) {
Log.verbose("Add clyph :" + iii);
LOGGER.trace("Add clyph :" + iii);
addGlyph((char) iii);
}
flush();
Log.debug("Wrapping properties : ");
Log.debug(" " + FontMode.REGULAR + " == >" + getWrappingMode(FontMode.REGULAR));
Log.debug(" " + FontMode.ITALIC + " == >" + getWrappingMode(FontMode.ITALIC));
Log.debug(" " + FontMode.BOLD + " == >" + getWrappingMode(FontMode.BOLD));
Log.debug(" " + FontMode.BOLD_ITALIC + " == >" + getWrappingMode(FontMode.BOLD_ITALIC));
LOGGER.debug("Wrapping properties : ");
LOGGER.debug(" " + FontMode.REGULAR + " == >" + getWrappingMode(FontMode.REGULAR));
LOGGER.debug(" " + FontMode.ITALIC + " == >" + getWrappingMode(FontMode.ITALIC));
LOGGER.debug(" " + FontMode.BOLD + " == >" + getWrappingMode(FontMode.BOLD));
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);
if (tmpchar != null && tmpchar.exist()) {
Log.debug("load char : '" + val + "'=" + (int) val);
LOGGER.debug("load char : '" + val + "'=" + (int) val);
hasChange = true;
// change line if needed ...
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.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()) {
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...
for (int kkk = 0; kkk < 4; kkk++) {
// change the coordinate on the element in the texture
for (int jjj = 0; jjj < this.listElement[kkk].size(); ++jjj) {
this.listElement[kkk].get(jjj).texturePosStart = this.listElement[kkk].get(jjj).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));
for (final GlyphProperty element : this.listElement[kkk]) {
element.texturePosStart = element.texturePosStart.multiply(new Vector2f(1.0f, 0.5f));
element.texturePosSize = element.texturePosSize.multiply(new Vector2f(1.0f, 0.5f));
}
}
}
// draw the glyph
this.font[iii].drawGlyph(this.data, this.size, this.lastGlyphPos[iii], tmpchar, iii);
// 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.texturePosSize = new Vector2f((float) tmpchar.sizeTexture.x() / this.data.getSize().x(), (float) tmpchar.sizeTexture.y() / this.data.getSize().y());
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.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 :
if (this.lastRawHeigh[iii] < tmpchar.sizeTexture.y()) {
@ -217,12 +231,12 @@ public class ResourceTexturedFont extends ResourceTexture2 {
// update the Bitmap position drawing :
this.lastGlyphPos[iii] = this.lastGlyphPos[iii].add(new Vector2i(tmpchar.sizeTexture.x() + 1, 0));
} else {
Log.warning("Did not find char : '" + val + "'=" + val);
LOGGER.warn("Did not find char : '" + val + "'=" + val);
}
this.listElement[iii].add(tmpchar);
}
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();
Ewol.getContext().forceRedrawAllAsync();
//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
*/
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]);
final int index = getIndex(charcode, displayMode);
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) {
return this.listElement[displayMode.getValue()].get(0);
}
return this.emptyGlyph;
}
// Log.error(" index=" + index);
// Log.error(" this.UVal=" + this.listElement[displayMode][index].UVal);
// Log.error(" this.glyphIndex=" +
// LOGGER.error(" index=" + index);
// LOGGER.error(" this.UVal=" + this.listElement[displayMode][index].UVal);
// LOGGER.error(" this.glyphIndex=" +
// this.listElement[displayMode][index].glyphIndex);
// Log.error(" this.advance=" + this.listElement[displayMode][index].advance);
// Log.error(" this.bearing=" + this.listElement[displayMode][index].bearing);
// LOGGER.error(" this.advance=" + this.listElement[displayMode][index].advance);
// LOGGER.error(" this.bearing=" + this.listElement[displayMode][index].bearing);
return this.listElement[displayMode.getValue()].get(index);
}
@ -291,12 +305,12 @@ public class ResourceTexturedFont extends ResourceTexture2 {
return charcode - 0x1F;
}
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 + "'");
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()) {
// Log.debug("return " + iii);
// LOGGER.debug("return " + iii);
return charcode;
}
return 0;

View File

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

View File

@ -17,7 +17,6 @@ import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.exml.XmlMapper;
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.key.KeyKeyboard;
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
*/
public class Composer extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Composer.class);
public static Widget composerGenerateFile(final Uri data) {
return composerGenerateFile(data, 0);
}
public static Widget composerGenerateFile(final Uri uri, final long id) {
final byte[] elemData = Uri.getAllData(uri);
if (elemData == null) {
Log.error("Can not read the Stream : {}", uri);
LOGGER.error("Can not read the Stream : {}", uri);
return null;
}
final String dataToParse = new String(elemData);
final Widget tmp = composerGenerateString(dataToParse, id);
if (tmp == null) {
Log.error("Fail to Load data: {}", uri);
LOGGER.error("Fail to Load data: {}", uri);
}
return tmp;
}
public static Widget composerGenerateString(final String data) {
return composerGenerateString(data, 0);
}
public static Widget composerGenerateString(String data, final long id) {
boolean requestComposer = true;
if (!data.startsWith("<Composer>")) {
@ -64,7 +67,7 @@ public class Composer extends Container {
try {
result = mapper.parse(data, Composer.class);//new WidgetXmlFactory());
} catch (final ExmlException | AknotException ex) {
Log.error("Fail to load Data !!! {}", ex.toString());
LOGGER.error("Fail to load Data !!! {}", ex.toString());
ex.printStackTrace();
}
if (result == null) {
@ -75,19 +78,19 @@ public class Composer extends Container {
}
return result.getSubWidget();
}
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
/**
* Constructor
*/
public Composer() {
// nothing to do...
}
@Override
public void calculateMinMaxSize() {
if (this.subWidget != null) {
@ -96,44 +99,44 @@ public class Composer extends Container {
}
super.calculateMinMaxSize();
}
@Override
public void calculateSize() {
if (this.subWidget != null) {
this.subWidget.calculateSize();
return;
}
super.calculateSize();
}
@Override
public Vector3b canExpand() {
if (this.subWidget != null) {
return this.subWidget.canExpand();
}
return super.canExpand();
}
@Override
public Vector3b canExpandIfFree() {
if (this.subWidget != null) {
return this.subWidget.canExpandIfFree();
}
return super.canExpandIfFree();
}
@Override
public Vector3b canFill() {
if (this.subWidget != null) {
return this.subWidget.canFill();
}
return super.canFill();
}
@Override
void changeZoom(final float range) {
if (this.subWidget != null) {
@ -142,7 +145,7 @@ public class Composer extends Container {
}
super.changeZoom(range);
}
@Override
public void checkMaxSize() {
if (this.subWidget != null) {
@ -151,71 +154,71 @@ public class Composer extends Container {
}
super.checkMaxSize();
}
@Override
public void checkMinSize() {
if (this.subWidget != null) {
this.subWidget.checkMinSize();
return;
}
super.checkMinSize();
}
@Override
public Vector3f getCalculateMaxSize() {
if (this.subWidget != null) {
return this.subWidget.getCalculateMaxSize();
}
return super.getCalculateMaxSize();
}
@Override
public Vector3f getCalculateMinSize() {
if (this.subWidget != null) {
return this.subWidget.getCalculateMinSize();
}
return super.getCalculateMinSize();
}
@Override
public Cursor getCursor() {
if (this.subWidget != null) {
return this.subWidget.getCursor();
}
return super.getCursor();
}
@Override
public boolean getGrabStatus() {
if (this.subWidget != null) {
return this.subWidget.getGrabStatus();
}
return super.getGrabStatus();
}
@Override
public boolean getKeyboardRepeat() {
if (this.subWidget != null) {
return this.subWidget.getKeyboardRepeat();
}
return super.getKeyboardRepeat();
}
@Override
public int getMouseLimit() {
if (this.subWidget != null) {
return this.subWidget.getMouseLimit();
}
return super.getMouseLimit();
}
@Override
Vector3f getOffset() {
if (this.subWidget != null) {
@ -223,7 +226,7 @@ public class Composer extends Container {
}
return super.getOffset();
}
@Override
public Vector3f getOrigin() {
if (this.subWidget != null) {
@ -231,79 +234,79 @@ public class Composer extends Container {
}
return super.getOrigin();
}
@Override
public boolean getPropertyCanFocus() {
if (this.subWidget != null) {
return this.subWidget.getPropertyCanFocus();
}
return super.getPropertyCanFocus();
}
@Override
public Vector3b getPropertyExpand() {
if (this.subWidget != null) {
return this.subWidget.getPropertyExpand();
}
return super.getPropertyExpand();
}
@Override
public Vector3b getPropertyExpandIfFree() {
if (this.subWidget != null) {
return this.subWidget.getPropertyExpandIfFree();
}
return super.getPropertyExpandIfFree();
}
@Override
public Vector3b getPropertyFill() {
if (this.subWidget != null) {
return this.subWidget.getPropertyFill();
}
return super.getPropertyFill();
}
@Override
public Gravity getPropertyGravity() {
if (this.subWidget != null) {
return this.subWidget.getPropertyGravity();
}
return super.getPropertyGravity();
}
@Override
public boolean getPropertyHide() {
if (this.subWidget != null) {
return this.subWidget.getPropertyHide();
}
return super.getPropertyHide();
}
@Override
public Dimension3f getPropertyMaxSize() {
if (this.subWidget != null) {
return this.subWidget.getPropertyMaxSize();
}
return super.getPropertyMaxSize();
}
@Override
public Dimension3f getPropertyMinSize() {
if (this.subWidget != null) {
return this.subWidget.getPropertyMinSize();
}
return super.getPropertyMinSize();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "sub-file")
@ -311,16 +314,16 @@ public class Composer extends Container {
public Uri getPropertySubFile() {
return this.propertySubFile;
}
@Override
public Vector3f getSize() {
if (this.subWidget != null) {
return this.subWidget.getSize();
}
return super.getSize();
}
@Override
public EwolObject getSubObjectNamed(final String objectName) {
if (this.subWidget != null) {
@ -328,7 +331,7 @@ public class Composer extends Container {
}
return super.getSubObjectNamed(objectName);
}
@Override
public float getZoom() {
if (this.subWidget != null) {
@ -336,7 +339,7 @@ public class Composer extends Container {
}
return super.getZoom();
}
@Override
public void grabCursor() {
if (this.subWidget != null) {
@ -345,7 +348,7 @@ public class Composer extends Container {
}
super.grabCursor();
}
@Override
public boolean isFocused() {
if (this.subWidget != null) {
@ -353,7 +356,7 @@ public class Composer extends Container {
}
return super.isFocused();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "remove-if-under-remove")
@ -361,7 +364,7 @@ public class Composer extends Container {
public boolean isPropertyRemoveIfUnderRemove() {
return this.propertyRemoveIfUnderRemove;
}
@Override
public void keepFocus() {
if (this.subWidget != null) {
@ -370,7 +373,7 @@ public class Composer extends Container {
}
super.keepFocus();
}
/**
* load a composition with a file
* @param _uri Name of the file
@ -379,7 +382,7 @@ public class Composer extends Container {
* @return false == > some error occured
*/
public boolean loadFromFile(final Uri uri) {
final Widget data = composerGenerateFile(uri, this.getId());
final Widget data = composerGenerateFile(uri, getId());
// check parse is well done.
if (data == null) {
return false;
@ -393,7 +396,7 @@ public class Composer extends Container {
// T O D O: Change this with a throw.a..a
return true;
}
/**
* load a composition with a file
* @param composerXmlString xml to parse directly
@ -402,7 +405,7 @@ public class Composer extends Container {
* @return false == > some error occured
*/
public boolean loadFromString(final String composerXmlString) {
final Widget data = composerGenerateString(composerXmlString, this.getId());
final Widget data = composerGenerateString(composerXmlString, getId());
// check parse is well done.
if (data == null) {
return false;
@ -416,29 +419,29 @@ public class Composer extends Container {
// T O D O: Change this with a throw.a..a
return true;
}
@Override
public void markToRedraw() {
if (this.subWidget != null) {
this.subWidget.calculateMinMaxSize();
return;
}
super.markToRedraw();
}
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()) {
// remove all elements:
subWidgetRemove();
return;
}
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
public void onChangeSize() {
if (this.subWidget != null) {
@ -447,7 +450,7 @@ public class Composer extends Container {
}
super.onChangeSize();
}
@Override
public void onEventClipboard(final ClipboardList clipboardID) {
if (this.subWidget != null) {
@ -456,15 +459,19 @@ public class Composer extends Container {
}
super.onEventClipboard(clipboardID);
}
@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) {
return this.subWidget.onEventShortCut(special, unicodeValue, kbMove, isDown);
}
return super.onEventShortCut(special, unicodeValue, kbMove, isDown);
}
@Override
public void onRegenerateDisplay() {
if (this.subWidget != null) {
@ -473,7 +480,7 @@ public class Composer extends Container {
}
super.onRegenerateDisplay();
}
@Override
public Vector3f relativePosition(final Vector3f pos) {
if (this.subWidget != null) {
@ -481,16 +488,16 @@ public class Composer extends Container {
}
return super.relativePosition(pos);
}
@Override
public void requestDestroyFromChild(final EwolObject child) {
super.requestDestroyFromChild(child);
if (this.propertyRemoveIfUnderRemove) {
Log.debug("Child widget remove ==> auto-remove");
LOGGER.debug("Child widget remove ==> auto-remove");
autoDestroy();
}
}
@Override
public void requestUpdateSize() {
if (this.subWidget != null) {
@ -499,7 +506,7 @@ public class Composer extends Container {
}
super.requestUpdateSize();
}
@Override
public boolean rmFocus() {
if (this.subWidget != null) {
@ -507,7 +514,7 @@ public class Composer extends Container {
}
return super.rmFocus();
}
@Override
public void setCursor(final Cursor newCursor) {
if (this.subWidget != null) {
@ -516,7 +523,7 @@ public class Composer extends Container {
}
super.setCursor(newCursor);
}
@Override
public boolean setFocus() {
if (this.subWidget != null) {
@ -524,7 +531,7 @@ public class Composer extends Container {
}
return super.setFocus();
}
@Override
public void setMouseLimit(final int numberState) {
if (this.subWidget != null) {
@ -533,7 +540,7 @@ public class Composer extends Container {
}
super.setMouseLimit(numberState);
}
@Override
public void setNoMaxSize() {
if (this.subWidget != null) {
@ -542,7 +549,7 @@ public class Composer extends Container {
}
super.setNoMaxSize();
}
@Override
public void setNoMinSize() {
if (this.subWidget != null) {
@ -551,7 +558,7 @@ public class Composer extends Container {
}
super.setNoMinSize();
}
@Override
public void setOffset(final Vector3f newVal) {
if (this.subWidget != null) {
@ -560,7 +567,7 @@ public class Composer extends Container {
}
super.setOffset(newVal);
}
@Override
public void setOrigin(final Vector3f pos) {
if (this.subWidget != null) {
@ -569,7 +576,7 @@ public class Composer extends Container {
}
super.setOrigin(pos);
}
@Override
public void setPropertyCanFocus(final boolean canFocus) {
if (this.subWidget != null) {
@ -578,7 +585,7 @@ public class Composer extends Container {
}
super.setPropertyCanFocus(canFocus);
}
@Override
public void setPropertyExpand(final Vector3b value) {
if (this.subWidget != null) {
@ -587,7 +594,7 @@ public class Composer extends Container {
}
super.setPropertyExpand(value);
}
@Override
public void setPropertyExpandIfFree(final Vector3b value) {
if (this.subWidget != null) {
@ -596,7 +603,7 @@ public class Composer extends Container {
}
super.setPropertyExpandIfFree(value);
}
@Override
public void setPropertyFill(final Vector3b value) {
if (this.subWidget != null) {
@ -605,7 +612,7 @@ public class Composer extends Container {
}
super.setPropertyFill(value);
}
@Override
public void setPropertyGravity(final Gravity gravity) {
if (this.subWidget != null) {
@ -614,7 +621,7 @@ public class Composer extends Container {
}
super.setPropertyGravity(gravity);
}
@Override
public void setPropertyHide(final boolean value) {
if (this.subWidget != null) {
@ -623,7 +630,7 @@ public class Composer extends Container {
}
super.setPropertyHide(value);
}
@Override
public void setPropertyMaxSize(final Dimension3f value) {
if (this.subWidget != null) {
@ -632,7 +639,7 @@ public class Composer extends Container {
}
super.setPropertyMaxSize(value);
}
@Override
public void setPropertyMinSize(final Dimension3f value) {
if (this.subWidget != null) {
@ -641,14 +648,14 @@ public class Composer extends Container {
}
super.setPropertyMinSize(value);
}
public void setPropertyRemoveIfUnderRemove(final boolean propertyRemoveIfUnderRemove) {
if (this.propertyRemoveIfUnderRemove == propertyRemoveIfUnderRemove) {
return;
}
this.propertyRemoveIfUnderRemove = propertyRemoveIfUnderRemove;
}
public void setPropertySubFile(final Uri propertySubFile) {
if (this.propertySubFile.equals(propertySubFile)) {
return;
@ -656,7 +663,7 @@ public class Composer extends Container {
this.propertySubFile = propertySubFile;
onChangePropertySubFile();
}
@Override
public void setSize(final Vector3f value) {
if (this.subWidget != null) {
@ -665,7 +672,7 @@ public class Composer extends Container {
}
super.setSize(value);
}
@Override
public void setZoom(final float newVal) {
if (this.subWidget != null) {
@ -674,7 +681,7 @@ public class Composer extends Container {
}
super.setZoom(newVal);
}
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.subWidget != null) {
@ -683,7 +690,7 @@ public class Composer extends Container {
}
super.systemDraw(displayProp);
}
@Override
public void unGrabCursor() {
if (this.subWidget != null) {
@ -692,5 +699,5 @@ public class Composer extends Container {
}
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.Vector3f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* @ingroup ewolWidgetGroup
* the Cotainer widget is a widget that have an only one subWidget
*/
public class Container extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Container.class);
protected Widget subWidget = null;
/**
* Constructor
*/
public Container() {}
@Override
public void calculateMinMaxSize() {
// call main class
@ -37,9 +39,9 @@ public class Container extends Widget {
final Vector3f min = this.subWidget.getCalculateMinSize();
this.minSize = Vector3f.max(this.minSize, min);
}
Log.warning("[{}] Result min size : {}", getId(), this.minSize);
LOGGER.warn("[{}] Result min size : {}", getId(), this.minSize);
}
@Override
public void drawWidgetTree(int level) {
super.drawWidgetTree(level);
@ -48,7 +50,7 @@ public class Container extends Widget {
this.subWidget.drawWidgetTree(level);
}
}
@Override
public EwolObject getSubObjectNamed(final String objectName) {
final EwolObject tmpObject = super.getSubObjectNamed(objectName);
@ -60,7 +62,7 @@ public class Container extends Widget {
}
return null;
}
/**
* get the main node widget
* @return the requested pointer on the node
@ -72,7 +74,7 @@ public class Container extends Widget {
public Widget getSubWidget() {
return this.subWidget;
}
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
if (!this.propertyHide) {
@ -82,7 +84,7 @@ public class Container extends Widget {
}
return null;
}
// @Override
// public boolean loadXML(final XmlElement node) {
// if (node == null) {
@ -100,34 +102,34 @@ public class Container extends Widget {
// }
// XmlElement pNode = it.toElement();
// 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)) {
// Log.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]");
// LOGGER.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]");
// continue;
// }
// if (getSubWidget() != null) {
// Log.error("Can only have one subWidget ??? node='" + widgetName + "'");
// LOGGER.error("Can only have one subWidget ??? node='" + widgetName + "'");
// continue;
// }
// Log.debug("try to create subwidget : '" + widgetName + "'");
// LOGGER.debug("try to create subwidget : '" + widgetName + "'");
// Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
// if (tmpWidget == null) {
// Log.error("Can not create the widget : '" + widgetName + "'");
// LOGGER.error("Can not create the widget : '" + widgetName + "'");
// continue;
// }
// // add widget :
// setSubWidget(tmpWidget);
// if (!tmpWidget.loadXML(pNode)) {
// Log.error("can not load widget properties : '" + widgetName + "'");
// LOGGER.error("can not load widget properties : '" + widgetName + "'");
// return false;
// }
// }
// if (node.getNodes().size() != 0 && this.subWidget == null) {
// Log.warning("Load container with no data inside");
// LOGGER.warn("Load container with no data inside");
// }
// return true;
// }
@Override
public void onChangeSize() {
super.onChangeSize();
@ -145,14 +147,14 @@ public class Container extends Widget {
this.subWidget.setSize(this.size);
this.subWidget.onChangeSize();
}
@Override
public void onRegenerateDisplay() {
if (this.subWidget != null) {
this.subWidget.systemRegenerateDisplay();
}
}
@Override
public void requestDestroyFromChild(final EwolObject child) {
if (this.subWidget != child) {
@ -165,7 +167,7 @@ public class Container extends Widget {
this.subWidget = null;
markToRedraw();
}
@Override
public void setOffset(final Vector3f newVal) {
if (this.offset.equals(newVal)) {
@ -174,9 +176,9 @@ public class Container extends Widget {
super.setOffset(newVal);
// recalculate the new sise and position of sub widget ...
onChangeSize();
}
/**
* set the subWidget node widget.
* @param newWidget The widget to add.
@ -193,7 +195,7 @@ public class Container extends Widget {
markToRedraw();
requestUpdateSize();
}
/**
* remove the subWidget node (async).
*/
@ -205,7 +207,7 @@ public class Container extends Widget {
requestUpdateSize();
}
}
/**
* Replace a old subwidget with a new one.
* @param oldWidget The widget to replace.
@ -213,7 +215,7 @@ public class Container extends Widget {
*/
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
if (this.subWidget != oldWidget) {
Log.warning("Request replace with a wrong old widget");
LOGGER.warn("Request replace with a wrong old widget");
return;
}
this.subWidget.removeParent();
@ -224,7 +226,7 @@ public class Container extends Widget {
markToRedraw();
requestUpdateSize();
}
/**
* Unlink the subwidget Node.
*/
@ -234,7 +236,7 @@ public class Container extends Widget {
}
this.subWidget = null;
}
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) {
@ -244,10 +246,10 @@ public class Container extends Widget {
super.systemDraw(displayProp);
if (this.subWidget != null) {
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);
} 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.Vector3f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @ingroup ewolWidgetGroup
* the Cotainer widget is a widget that have an only one subWidget
*/
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 subExpend = Vector3b.FALSE; //!< reference of the sub element expention requested.
protected List<Widget> subWidget = new ArrayList<>();
/**
* Constructor
*/
protected ContainerN() {}
@Override
public void calculateMinMaxSize() {
this.subExpend = Vector3b.FALSE;
this.minSize = Vector3f.ZERO;
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) {
if (it != null) {
it.calculateMinMaxSize();
@ -56,9 +58,9 @@ public class ContainerN extends Widget {
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
@Override
public Vector3b canExpand() {
@ -73,10 +75,10 @@ public class ContainerN extends Widget {
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;
}
@Override
public void drawWidgetTree(int level) {
super.drawWidgetTree(level);
@ -87,7 +89,7 @@ public class ContainerN extends Widget {
}
}
}
@AknotManaged
@AknotAttribute
@AknotName(value = "lock")
@ -95,7 +97,7 @@ public class ContainerN extends Widget {
public Vector3b getPropertyLockExpand() {
return this.propertyLockExpand;
}
@Override
public EwolObject getSubObjectNamed(final String objectName) {
EwolObject tmpObject = super.getSubObjectNamed(objectName);
@ -112,14 +114,14 @@ public class ContainerN extends Widget {
}
return null;
}
@AknotManaged
@AknotFactory(value = WidgetXmlFactory.class)
@AknotDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)")
public List<Widget> getSubWidgets() {
return this.subWidget;
}
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
if (this.propertyHide) {
@ -130,7 +132,8 @@ public class ContainerN extends Widget {
if (it != null) {
final Vector3f tmpSize = it.getSize();
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);
if (tmpWidget != null) {
return tmpWidget;
@ -142,7 +145,7 @@ public class ContainerN extends Widget {
}
return null;
}
@Override
public void onChangeSize() {
for (final Widget it : this.subWidget) {
@ -154,7 +157,7 @@ public class ContainerN extends Widget {
it.onChangeSize();
}
}
@Override
public void onRegenerateDisplay() {
for (final Widget it : this.subWidget) {
@ -163,7 +166,7 @@ public class ContainerN extends Widget {
}
}
}
@Override
public void requestDestroyFromChild(final EwolObject child) {
ListIterator<Widget> it = this.subWidget.listIterator();
@ -182,7 +185,7 @@ public class ContainerN extends Widget {
markToRedraw();
}
}
@Override
public void setOffset(final Vector3f newVal) {
if (this.offset != newVal) {
@ -191,7 +194,7 @@ public class ContainerN extends Widget {
onChangeSize();
}
}
public void setPropertyLockExpand(final Vector3b propertyLockExpand) {
if (propertyLockExpand.equals(this.propertyLockExpand)) {
return;
@ -200,10 +203,10 @@ public class ContainerN extends Widget {
markToRedraw();
requestUpdateSize();
}
public void setSubWidgets(final List<Widget> listData) {
// Clean all previous widget
this.subWidgetRemoveAll();
subWidgetRemoveAll();
// add separately all widgets
for (final Widget elem : listData) {
if (elem == null) {
@ -215,7 +218,7 @@ public class ContainerN extends Widget {
markToRedraw();
requestUpdateSize();
}
/**
* 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
@ -223,7 +226,7 @@ public class ContainerN extends Widget {
*/
public int subWidgetAdd(final Widget newWidget) {
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;
}
newWidget.setParent(this);
@ -233,22 +236,22 @@ public class ContainerN extends Widget {
// added at the last eelement :
return newWidget.getId();
}
//! @previous
public int subWidgetAddBack(final Widget newWidget) {
return subWidgetAdd(newWidget);
}
//! @previous
public int subWidgetAddEnd(final Widget newWidget) {
return subWidgetAdd(newWidget);
}
//! @previous
public int subWidgetAddFront(final Widget newWidget) {
return subWidgetAddStart(newWidget);
}
/**
* 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
@ -256,7 +259,8 @@ public class ContainerN extends Widget {
*/
public int subWidgetAddStart(final Widget newWidget) {
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;
}
if (newWidget != null) {
@ -267,7 +271,7 @@ public class ContainerN extends Widget {
requestUpdateSize();
return newWidget.getId();
}
/**
* remove definitly a widget from the system and this layer.
* @param newWidget the element pointer.
@ -277,7 +281,7 @@ public class ContainerN extends Widget {
return;
}
final int errorControl = this.subWidget.size();
final ListIterator<Widget> it = this.subWidget.listIterator();
while (it.hasNext()) {
final Widget elem = it.next();
@ -289,7 +293,7 @@ public class ContainerN extends Widget {
}
}
}
/**
* remove all sub element from the widget.
*/
@ -302,14 +306,14 @@ public class ContainerN extends Widget {
}
this.subWidget.clear();
}
/**
* remove all sub element from the widget (delayed to prevent remove in the callbback).
*/
public void subWidgetRemoveAllDelayed() {
subWidgetRemoveAll();
}
/**
* Replace a old subwidget with a new one.
* @param oldWidget The widget to replace.
@ -331,13 +335,13 @@ public class ContainerN extends Widget {
haveChange = true;
}
if (!haveChange) {
Log.warning("Request replace with a wrong old widget");
LOGGER.warn("Request replace with a wrong old widget");
return;
}
markToRedraw();
requestUpdateSize();
}
/**
* 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.
@ -357,7 +361,7 @@ public class ContainerN extends Widget {
}
}
}
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) {
@ -373,7 +377,7 @@ public class ContainerN extends Widget {
while (it.hasPrevious()) {
final Widget elem = it.previous();
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);
}
}

View File

@ -11,17 +11,19 @@ import org.atriasoft.aknot.annotation.AknotManaged;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* @ingroup ewolWidgetGroup
* the Cotainer widget is a widget that have an only one subWidget
*/
public class ContainerToggle extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerToggle.class);
protected Widget[] subWidget = new Widget[2];
int idWidgetDisplayed = 0; //!< current widget displayed
/**
* Constructor
*/
@ -29,15 +31,15 @@ public class ContainerToggle extends Widget {
this.subWidget[0] = null;
this.subWidget[1] = null;
}
void calculateMinMaxSizePadded(final Padding padding) {
// call main class
this.minSize = Vector3f.ZERO;
// call sub classes
for (int iii = 0; iii < this.subWidget.length; ++iii) {
if (this.subWidget[iii] != null) {
this.subWidget[iii].calculateMinMaxSize();
final Vector3f min = this.subWidget[iii].getCalculateMinSize();
for (final Widget element : this.subWidget) {
if (element != null) {
element.calculateMinMaxSize();
final Vector3f min = element.getCalculateMinSize();
this.minSize = this.minSize.max(min);
}
}
@ -46,9 +48,9 @@ public class ContainerToggle extends Widget {
// verify the min max of the min size ...
checkMinSize();
//markToRedraw();
Log.verbose("[{}] Result min size : {}", getId(), this.minSize);
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
}
@Override
public void drawWidgetTree(int level) {
super.drawWidgetTree(level);
@ -60,7 +62,7 @@ public class ContainerToggle extends Widget {
this.subWidget[1].drawWidgetTree(level);
}
}
@Override
public EwolObject getSubObjectNamed(final String widgetName) {
EwolObject tmpObject = super.getSubObjectNamed(widgetName);
@ -78,14 +80,14 @@ public class ContainerToggle extends Widget {
}
return null;
}
@AknotManaged
@AknotFactory(value = WidgetXmlFactory.class)
@AknotDescription(value = "Request the widget Expand size while free space is detected (does not generate expand in upper widget)")
public Widget[] getSubWidgets() {
return this.subWidget;
}
public Padding onChangeSizePadded(final Padding padding) {
super.onChangeSize();
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()) {
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());
//subElementSize = subElementSize.less(padding.x(), padding.y(), padding.z());
for (int iii = 0; iii < this.subWidget.length; ++iii) {
if (this.subWidget[iii] != null) {
for (final Widget element : this.subWidget) {
if (element != null) {
//final Vector3f origin2 = this.origin.add(this.offset);
//final Vector3f minSize = this.subWidget[iii].getCalculateMinSize();
//Vector2b expand = this.subWidget[iii].propertyExpand.get();
//origin2 = origin2.add(this.propertyGravity.gravityGenerateDelta(minSize.less(localAvaillable)));
this.subWidget[iii].setOrigin(this.origin.add(deltaPadded));
this.subWidget[iii].setSize(subElementSize);
this.subWidget[iii].onChangeSize();
element.setOrigin(this.origin.add(deltaPadded));
element.setSize(subElementSize);
element.onChangeSize();
}
}
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();
return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(), selectableAreaPos.y());
return new Padding(selectableAreaPos.x(), selectableAreaEndPos.y(), selectableAreaEndPos.x(),
selectableAreaPos.y());
}
@Override
public void onRegenerateDisplay() {
if (this.subWidget[this.idWidgetDisplayed] != null) {
this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay();
}
}
@Override
public void requestDestroyFromChild(final EwolObject child) {
if (this.subWidget[0] == child) {
@ -146,7 +151,7 @@ public class ContainerToggle extends Widget {
markToRedraw();
}
}
@Override
public void setOffset(final Vector3f newVal) {
if (this.offset.equals(newVal)) {
@ -156,12 +161,12 @@ public class ContainerToggle extends Widget {
// recalculate the new size and position of sub widget ...
onChangeSize();
}
@AknotManaged(value = false)
public void setSubWidget(final Widget newWidget) {
setSubWidget(newWidget, 0);
}
/**
* set the subWidget node widget.
* @param newWidget The widget to add.
@ -170,29 +175,29 @@ public class ContainerToggle extends Widget {
subWidgetRemove(idWidget);
this.subWidget[idWidget] = newWidget;
if (this.subWidget[idWidget] != null) {
Log.verbose("Add widget : " + idWidget);
LOGGER.trace("Add widget : " + idWidget);
this.subWidget[idWidget].setParent(this);
}
markToRedraw();
requestUpdateSize();
}
public void setSubWidgets(final Widget[] newWidget) {
for (int iii = 0; iii < Math.min(newWidget.length, this.subWidget.length); iii++) {
setSubWidget(newWidget[iii], iii);
}
}
public void subWidgetRemove(final int idWidget) {
if (this.subWidget[idWidget] != null) {
Log.verbose("Remove widget : " + idWidget);
LOGGER.trace("Remove widget : " + idWidget);
this.subWidget[idWidget].removeParent();
this.subWidget[idWidget] = null;
markToRedraw();
requestUpdateSize();
}
}
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
boolean haveChange = false;
for (int iii = 0; iii < this.subWidget.length; ++iii) {
@ -207,21 +212,21 @@ public class ContainerToggle extends Widget {
haveChange = true;
}
if (!haveChange) {
Log.warning("Request replace with a wrong old widget");
LOGGER.warn("Request replace with a wrong old widget");
return;
}
markToRedraw();
requestUpdateSize();
}
public void subWidgetUnLink(final int idWidget) {
if (this.subWidget[idWidget] != null) {
this.subWidget[idWidget].removeParent();
Log.verbose("Unlink widget : " + idWidget);
LOGGER.trace("Unlink widget : " + idWidget);
}
this.subWidget[idWidget] = null;
}
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) {
@ -231,10 +236,10 @@ public class ContainerToggle extends Widget {
super.systemDraw(displayProp);
if (this.subWidget[this.idWidgetDisplayed] != null) {
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);
} 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.compositing.GuiShape;
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!!!!)
*/
public class ContainerWithShape extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(ContainerWithShape.class);
// properties
public Uri propertyShape = null; //!< Compositing theme.
protected GuiShape shape; //!< Compositing theme.
protected ShapeBox shapeProperty = ShapeBox.ZERO;
/**
* Constructor
* @param propertyShape shape file properties
@ -35,7 +37,7 @@ public class ContainerWithShape extends Container {
this.propertyShape = propertyShape;
onChangePropertyShape();
}
@Override
public void calculateMinMaxSize() {
// call main class
@ -47,9 +49,9 @@ public class ContainerWithShape extends Container {
final Padding padding = this.shape.getPadding();
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
@AknotAttribute
@AknotName(value = "shape")
@ -57,7 +59,7 @@ public class ContainerWithShape extends Container {
public Uri getPropertyShape() {
return this.propertyShape;
}
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
final Widget val = super.getWidgetAtPos(pos);
@ -66,7 +68,7 @@ public class ContainerWithShape extends Container {
}
return this;
}
protected void onChangePropertyShape() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyShape);
@ -76,7 +78,7 @@ public class ContainerWithShape extends Container {
markToRedraw();
requestUpdateSize();
}
@Override
public void onChangeSize() {
markToRedraw();
@ -102,21 +104,21 @@ public class ContainerWithShape extends Container {
}
subWidgetSize = subWidgetSize.less(padding.x(), padding.y(), padding.z());
subWidgetSize = subWidgetSize.clipInteger();
// set config to the Sub-widget
Vector3f subWidgetOrigin = this.origin.add(this.size.less(subWidgetSize).multiply(0.5f));
subWidgetOrigin = subWidgetOrigin.clipInteger();
this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize();
}
@Override
protected void onDraw() {
this.shape.draw();
}
@Override
public void onRegenerateDisplay() {
if (needRedraw()) {
@ -140,7 +142,7 @@ public class ContainerWithShape extends Container {
// not sure this is needed...
tmpSizeShaper = tmpSizeShaper.clipInteger();
tmpOriginShaper = tmpOriginShaper.clipInteger();
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper);
}
@ -149,7 +151,7 @@ public class ContainerWithShape extends Container {
this.subWidget.onRegenerateDisplay();
}
}
public void setPropertyShape(final Uri propertyShape) {
if (this.propertyShape.equals(propertyShape)) {
return;
@ -157,7 +159,7 @@ public class ContainerWithShape extends Container {
this.propertyShape = propertyShape;
onChangePropertyShape();
}
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) {
@ -173,5 +175,5 @@ public class ContainerWithShape extends Container {
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.EventInput;
import org.atriasoft.ewol.event.EventTime;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.context.ClipBoard;
import org.atriasoft.gale.context.ClipboardList;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @ingroup ewolWidgetGroup
@ -40,18 +41,20 @@ import org.atriasoft.gale.key.KeyType;
* ~~~~~~~~~~~~~~~~~~~~~~
*/
public class Entry extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Entry.class);
/**
* Periodic call to update grapgic display
* @param _event Time generic 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)) {
self.periodicConnectionHanble.close();
}
self.markToRedraw();
}
/// color property of the text foreground
private int colorIdTextFg;
/// 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 int propertyMaxCharacter = Integer.MAX_VALUE; //!< number max of Character in the list
private boolean propertyPassword = false; //!< Disable display of the content of the entry
/// regular expression value
private String propertyRegex = ".*";
/// Text to display when nothing in in the entry (decorated text...)
private String propertyTextWhenNothing = null;
private String propertyValue = "Test Text..."; //!< string that must be displayed
private Pattern regex = null; //!< regular expression to check content
private GuiShape shape;
@ -92,16 +95,16 @@ public class Entry extends Widget {
@AknotName(value = "enter")
@AknotDescription("The cursor enter inside the button")
public Signal<String> signalEnter = new Signal<>(); //!< Enter key is pressed
@AknotSignal
@AknotName(value = "modify")
@AknotDescription("Entry box value change")
public Signal<String> signalModify = new Signal<>(); //!< data change
// element over:
Vector3f overPositionStart = Vector3f.ZERO;
Vector3f overPositionStop = Vector3f.ZERO;
/**
* Constructor
* @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() {
this.propertyCanFocus = true;
onChangePropertyShaper();
this.regex = Pattern.compile(this.propertyRegex);
if (this.regex == null) {
Log.error("can not parse regex for : " + this.propertyRegex);
LOGGER.error("can not parse regex for : " + this.propertyRegex);
}
markToRedraw();
shortCutAdd("ctrl+w", "clean");
@ -124,7 +127,7 @@ public class Entry extends Widget {
this.shape = new GuiShape(this.propertyConfig);
//TODO this.signalShortcut.connect(this, Entry::onCallbackShortCut);
}
@Override
public void calculateMinMaxSize() {
// call main class
@ -135,26 +138,27 @@ public class Entry extends Widget {
padding = this.shape.getPadding();
}
final int minHeight = (int) this.text.getHeight();//calculateSize('A').y();
Vector3f minimumSizeBase = new Vector3f(20, minHeight, 10);
// add padding :
minimumSizeBase = minimumSizeBase.add(padding.x(), padding.y(), padding.z());
this.minSize = Vector3f.max(this.minSize, minimumSizeBase);
// verify the min max of the min size ...
checkMinSize();
Log.error("min size = " + this.minSize);
LOGGER.error("min size = " + this.minSize);
}
protected void changeStatusIn(final GuiShapeMode newStatusId) {
if (this.shape.changeStatusIn(newStatusId)) {
if (!this.periodicConnectionHanble.isConnected()) {
Log.error("REQUEST: connection on operiodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this, Entry::periodicCall);
LOGGER.error("REQUEST: connection on operiodic call");
this.periodicConnectionHanble = EwolObject.getObjectManager().periodicCall.connect(this,
Entry::periodicCall);
}
markToRedraw();
}
}
/**
* Copy the selected data on the specify clipboard
* @param clipboardID Selected clipboard
@ -174,48 +178,48 @@ public class Entry extends Widget {
final String tmpData = this.propertyValue.substring(pos1, pos2);
ClipBoard.set(clipboardID, tmpData);
}
public Uri getPropertyConfig() {
return this.propertyConfig;
}
public int getPropertyMaxCharacter() {
return this.propertyMaxCharacter;
}
public String getPropertyRegex() {
return this.propertyRegex;
}
public String getPropertyTextWhenNothing() {
return this.propertyTextWhenNothing;
}
public String getPropertyValue() {
return this.propertyValue;
}
public boolean isPropertyPassword() {
return this.propertyPassword;
}
/**
* informe the system thet the text change and the start position change
*/
protected void markToUpdateTextPosition() {
this.needUpdateTextPos = true;
}
private void onCallbackCopy() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
}
private void onCallbackCut() {
copySelectionToClipBoard(ClipboardList.CLIPBOARD_STD);
removeSelected();
this.signalModify.emit(this.propertyValue);
}
private void onCallbackEntryClean() {
this.propertyValue = "";
this.displayStartPosition = 0;
@ -223,11 +227,11 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos;
markToRedraw();
}
private void onCallbackPaste() {
ClipBoard.request(ClipboardList.CLIPBOARD_STD);
}
private void onCallbackSelect(final boolean all) {
if (all) {
this.displayCursorPosSelection = 0;
@ -237,7 +241,7 @@ public class Entry extends Widget {
}
markToRedraw();
}
private void onCallbackShortCut(final String value) {
if (value.equals("clean")) {
onCallbackEntryClean();
@ -246,33 +250,33 @@ public class Entry extends Widget {
} else if (value.equals("copy")) {
onCallbackCopy();
} else if (value.equals("paste")) {
Log.warning("Request past ...");
LOGGER.warn("Request past ...");
onCallbackPaste();
} else if (value.equals("select:all")) {
onCallbackSelect(true);
} else if (value.equals("select:none")) {
onCallbackSelect(false);
} else {
Log.warning("Unknow event from ShortCut : " + value);
LOGGER.warn("Unknow event from ShortCut : " + value);
}
}
protected void onChangePropertyMaxCharacter() {
// TODO : check number of char in the data
}
protected void onChangePropertyPassword() {
markToRedraw();
}
protected void onChangePropertyRegex() {
this.regex = Pattern.compile(this.propertyRegex);
if (this.regex != null) {
Log.error("can not parse regex for : " + this.propertyRegex);
LOGGER.error("can not parse regex for : " + this.propertyRegex);
}
markToRedraw();
}
protected void onChangePropertyShaper() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyConfig);
@ -284,27 +288,27 @@ public class Entry extends Widget {
// this.colorIdCursor = this.shape.requestColor("text-cursor");
// this.colorIdSelection = this.shape.requestColor("text-selection");
}
protected void onChangePropertyTextWhenNothing() {
markToRedraw();
}
protected void onChangePropertyValue() {
String newData = this.propertyValue;
if ((long) newData.length() > 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 ...
setInternalValue(newData);
if (newData == this.propertyValue) {
this.displayCursorPos = this.propertyValue.length();
this.displayCursorPosSelection = this.displayCursorPos;
Log.verbose("Set : '" + newData + "'");
LOGGER.trace("Set : '" + newData + "'");
}
markToRedraw();
}
@Override
protected void onDraw() {
if (this.shape != null) {
@ -312,7 +316,7 @@ public class Entry extends Widget {
}
this.text.draw();
}
@Override
public void onEventClipboard(final ClipboardList clipboardID) {
// remove curent selected data ...
@ -336,10 +340,10 @@ public class Entry extends Widget {
}
this.signalModify.emit(this.propertyValue);
}
@Override
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.status() == KeyStatus.down) {
// remove current selected data ...
@ -368,9 +372,9 @@ public class Entry extends Widget {
this.displayCursorPosSelection = this.displayCursorPos;
}
} 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) {
Log.info("Reject data for entry : '" + event.getChar() + "'");
LOGGER.info("Reject data for entry : '" + event.getChar() + "'");
} else {
final StringBuilder newData = new StringBuilder(this.propertyValue);
newData.insert(this.displayCursorPos, event.getChar());
@ -412,19 +416,20 @@ public class Entry extends Widget {
}
return false;
}
@Override
public boolean onEventInput(final EventInput event) {
final Vector3f absolutePosition = new Vector3f(event.pos().x(), event.pos().y(), 0);
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 (!isFocused()) {
if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL);
} else {
Log.verbose("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()) {
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()) {
changeStatusIn(GuiShapeMode.OVER);
} else {
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()) {
Log.warning("Reject {}", relPos);
if (relPos.x() < this.overPositionStart.x() || relPos.y() < this.overPositionStart.y()
|| relPos.x() > this.overPositionStop.x() || relPos.y() > this.overPositionStop.y()) {
LOGGER.warn("Reject {}", relPos);
return false;
}
if (event.inputId() == 1) {
@ -453,8 +459,10 @@ public class Entry extends Widget {
this.displayCursorPos = iii;
break;
}
if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z') || (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) == '-')) {
if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z')
|| (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;
break;
}
@ -465,8 +473,10 @@ public class Entry extends Widget {
this.displayCursorPosSelection = 0;
break;
}
if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z') || (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) == '-')) {
if (!((this.propertyValue.charAt(iii) >= 'a' && this.propertyValue.charAt(iii) <= 'z')
|| (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;
break;
}
@ -494,7 +504,8 @@ public class Entry extends Widget {
markToRedraw();
}
} 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();
// updatethe cursor position :
updateCursorPosition(absolutePosition);
@ -508,7 +519,7 @@ public class Entry extends Widget {
}
return false;
}
@Override
protected void onGetFocus() {
this.displayCursor = true;
@ -516,7 +527,7 @@ public class Entry extends Widget {
showKeyboard();
markToRedraw();
}
@Override
protected void onLostFocus() {
this.displayCursor = false;
@ -524,13 +535,13 @@ public class Entry extends Widget {
hideKeyboard();
markToRedraw();
}
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
//return;
}
//Log.verbose("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
//LOGGER.trace("Regenerate Display ==> is needed: '" + this.propertyValue + "'");
this.shape.clear();
this.text.clear();
if (this.colorIdTextFg >= 0) {
@ -541,7 +552,7 @@ public class Entry extends Widget {
}
updateTextPosition();
final Padding padding = this.shape.getPadding();
Vector3f tmpSizeShaper = this.minSize;
Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
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 = 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 ...
final int minHeight = (int) this.text.getHeight();
if (tmpSizeText.y() > minHeight) {
tmpOriginText = tmpOriginText.add(0, (tmpSizeText.y() - minHeight) * 0.5f, 0);
@ -572,7 +583,7 @@ public class Entry extends Widget {
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeText = Vector3f.clipInt(tmpSizeText);
tmpOriginText = Vector3f.clipInt(tmpOriginText);
this.text.clear();
//this.text.setSize((int) tmpSizeText.x(), (int) tmpSizeText.y());
this.text.setClippingWidth(tmpOriginText, tmpSizeText);
@ -586,7 +597,7 @@ public class Entry extends Widget {
if (this.propertyPassword) {
Arrays.fill(valueToDisplay, '*');
}
//final Vector2f plop = new Vector2f(tmpOriginText.x() + this.displayStartPosition, tmpOriginText.y());
if (valueToDisplay.length != 0) {
this.text.print(new String(valueToDisplay));
@ -599,9 +610,9 @@ public class Entry extends Widget {
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.text.flush();
this.shape.flush();
}
/**
* remove the selected area
* @note This request a regeneration of the display
@ -629,7 +640,7 @@ public class Entry extends Widget {
this.propertyValue = tmp.toString();
markToRedraw();
}
/**
* internal check the value with RegExp checking
* @param newData The new string to display
@ -640,15 +651,15 @@ public class Entry extends Widget {
if (newData.length() > 0) {
/*
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;
}
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;
}
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;
}
*/
@ -656,7 +667,7 @@ public class Entry extends Widget {
this.propertyValue = newData;
markToRedraw();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "config")
@ -668,7 +679,7 @@ public class Entry extends Widget {
this.propertyConfig = propertyConfig;
onChangePropertyShaper();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "max")
@ -680,7 +691,7 @@ public class Entry extends Widget {
this.propertyMaxCharacter = propertyMaxCharacter;
onChangePropertyMaxCharacter();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "password")
@ -692,7 +703,7 @@ public class Entry extends Widget {
this.propertyPassword = propertyPassword;
onChangePropertyPassword();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "regex")
@ -704,7 +715,7 @@ public class Entry extends Widget {
this.propertyRegex = propertyRegex;
onChangePropertyRegex();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "empty-text")
@ -716,7 +727,7 @@ public class Entry extends Widget {
this.propertyTextWhenNothing = propertyTextWhenNothing;
onChangePropertyTextWhenNothing();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "value")
@ -728,7 +739,7 @@ public class Entry extends Widget {
this.propertyValue = propertyValue;
onChangePropertyValue();
}
/**
* change the cursor position with the curent position requested on the display
* @param pos Absolute position of the event
@ -737,24 +748,24 @@ public class Entry extends Widget {
protected void updateCursorPosition(final Vector3f pos) {
updateCursorPosition(pos, false);
}
protected void updateCursorPosition(final Vector3f pos, final boolean selection/*=false*/) {
final Padding padding = this.shape.getPadding();
final Vector3f relPos = relativePosition(pos).less(this.overPositionStart);
// reject when outside ...
// try to find the new cursor position :
if (this.displayStartPosition > this.propertyValue.length()) {
this.displayStartPosition = this.propertyValue.length();
}
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;
}
String tmpDisplay = this.propertyValue.substring(0, this.displayStartPosition);
final int displayHidenSize = (int) this.text.calculateSize(tmpDisplay).x();
//Log.debug("hidenSize : " + displayHidenSize);
//LOGGER.debug("hidenSize : " + displayHidenSize);
int newCursorPosition = -1;
final int tmpTextOriginX = (int) padding.left();
for (int iii = 0; iii < this.propertyValue.length(); iii++) {
@ -781,7 +792,7 @@ public class Entry extends Widget {
}
markToUpdateTextPosition();
}
/**
* update the display position start == > depending of the position of the Cursor and the size of the Data inside
* @change this.displayStartPosition < == updated
@ -791,7 +802,7 @@ public class Entry extends Widget {
return;
}
final Padding padding = this.shape.getPadding();
int tmpSizeX = (int) this.minSize.x();
if (this.propertyFill.x()) {
tmpSizeX = (int) this.size.x();
@ -808,7 +819,8 @@ public class Entry extends Widget {
} else {
// check if the Cursor is visible at 10px nearest the border :
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) {
// set the cursor on the left
this.displayStartPosition = Math.min(-this.displayCursorPositionPixel + 10, 0);
@ -820,5 +832,5 @@ public class Entry extends Widget {
//this.displayStartPosition = -totalWidth + tmpUserSize;
}
}
}

View File

@ -10,12 +10,15 @@ import java.util.List;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.internal.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @ingroup ewolWidgetGroup
*/
class Gird extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Gird.class);
protected class GirdProperties {
public Widget widget;
public int row;
@ -45,7 +48,7 @@ class Gird extends Widget {
this.sizeCol.set(iii, 0);
}
}
//Log.debug("Update minimum size");
//LOGGER.debug("Update minimum size");
this.minSize = this.propertyMinSize.getPixel();
this.maxSize = this.propertyMaxSize.getPixel();
this.uniformSizeRow = 0;
@ -59,12 +62,13 @@ class Gird extends Widget {
if (this.subWidget.get(iii).widget != null) {
this.subWidget.get(iii).widget.calculateMinMaxSize();
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 :
this.uniformSizeRow = Math.max((int) tmpSize.y(), this.uniformSizeRow);
// for the colomn size : We set the autamatic value in negative :
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;
}
int tmpSizeWidth = 0;
for (int iii = 0; iii < this.sizeCol.size(); iii++) {
tmpSizeWidth += Math.abs(this.sizeCol.get(iii));
for (final Integer element : this.sizeCol) {
tmpSizeWidth += Math.abs(element);
}
Log.debug(" tmpSizeWidth=" + tmpSizeWidth);
Log.debug(" this.uniformSizeRow=" + this.uniformSizeRow);
LOGGER.debug(" tmpSizeWidth=" + tmpSizeWidth);
LOGGER.debug(" this.uniformSizeRow=" + this.uniformSizeRow);
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);
}
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;
}
@ -133,7 +137,8 @@ class Gird extends Widget {
}
final Vector3f tmpSize = it.widget.getSize();
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);
if (tmpWidget != null) {
return tmpWidget;
@ -147,8 +152,9 @@ class Gird extends Widget {
@Override
public void onChangeSize() {
//Log.debug("Update size");
this.size = this.size.less(this.propertyBorderSize.x() * 2, this.propertyBorderSize.y() * 2, this.propertyBorderSize.y() * 2);
//LOGGER.debug("Update size");
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++) {
if (this.subWidget.get(iii).widget != null) {
@ -171,16 +177,19 @@ class Gird extends Widget {
}
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 :
this.subWidget.get(iii).widget.setOrigin(tmpOrigin.clipInteger());
// 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.size = this.size.add(this.propertyBorderSize.multiply(0.5f));
Log.debug("Calculate size : " + this.size);
LOGGER.debug("Calculate size : " + this.size);
markToRedraw();
}
@ -216,11 +225,12 @@ class Gird extends Widget {
this.subWidget.get(iii).widget = null;
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == this.subWidget.size()) {
Log.critical(
"[" + getId() + "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
LOGGER.error("[" + getId()
+ "] 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 {
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);
}
errorControl = this.subWidget.size();
@ -245,7 +255,8 @@ class Gird extends Widget {
if ((long) this.sizeCol.size() > colId) {
this.sizeCol.set(colId, size);
} 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) {
this.propertyBorderSize = propertyBorderSize;
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);
}
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);
}
markToRedraw();
@ -310,19 +321,17 @@ class Gird extends Widget {
// find a new position;
this.subWidget.add(iii, prop);
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 {
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 {
// The element already exist == > replace it ...
this.tmpWidget = this.subWidget.get(iii).widget;
this.subWidget.get(iii).widget = newWidget;
this.tmpWidget = null;
}
// 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 ...
@ -336,7 +345,7 @@ class Gird extends Widget {
*/
public void subWidgetRemove(final int colId, final int rowId) {
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;
}
final int errorControl = this.subWidget.size();
@ -347,7 +356,7 @@ class Gird extends Widget {
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;
}
}
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) {
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;
}
// try to find it ...
@ -389,7 +398,7 @@ class Gird extends Widget {
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.ewol.compositing.CompositingImage;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ImageDisplay extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(ImageDisplay.class);
protected int colorId = -1; //!< Color of the image.
protected ResourceColorFile colorProperty = null; //!< theme color property
protected CompositingImage compositing = new CompositingImage(); //!< compositing element of the image.
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 propertyImageSize = Dimension2f.ZERO; //!< border to add at the image.
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 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 Uri propertySource = null; //!< file name of the image.
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")
@AknotDescription(value = "Image is pressed")
public final SignalEmpty signalPressed = new SignalEmpty();
/**
*
*
*/
public ImageDisplay() {}
@Override
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 imageSize = this.propertyImageSize.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()) {
final Vector2f tmp = imageBoder.add(imageSize);
this.minSize = new Vector3f(tmp.x(), tmp.y(), 0);
this.maxSize = this.minSize;
} else {
final Vector2i imageSizeReal = this.getPropertyMinSize().getPixeli();//.compositing.getRealSize();
Log.verbose(" Real Size = " + imageSizeReal);
final Vector2i imageSizeReal = getPropertyMinSize().getPixeli();//.compositing.getRealSize();
LOGGER.trace(" Real Size = " + imageSizeReal);
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);
Log.verbose(" set max : " + this.minSize + " min1=" + min1);
LOGGER.trace(" set max : " + this.minSize + " min1=" + 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.minSize = Vector3f.min(this.minSize, this.maxSize);
}
this.imageRenderSize = new Vector2f(this.minSize.x(), this.minSize.y());
this.minSize = Vector3f.max(this.minSize, size);
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();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "image-border")
@ -84,7 +88,7 @@ public class ImageDisplay extends Widget {
public Dimension2f getPropertyBorder() {
return this.propertyBorder;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "image-size")
@ -92,7 +96,7 @@ public class ImageDisplay extends Widget {
public Dimension2f getPropertyImageSize() {
return this.propertyImageSize;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "part-start")
@ -100,7 +104,7 @@ public class ImageDisplay extends Widget {
public Vector2f getPropertyPosStart() {
return this.propertyPosStart;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "part-stop")
@ -108,7 +112,7 @@ public class ImageDisplay extends Widget {
public Vector2f getPropertyPosStop() {
return this.propertyPosStop;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "src")
@ -116,7 +120,7 @@ public class ImageDisplay extends Widget {
public Uri getPropertySource() {
return this.propertySource;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "ratio")
@ -124,7 +128,7 @@ public class ImageDisplay extends Widget {
public boolean isPropertyKeepRatio() {
return this.propertyKeepRatio;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "smooth")
@ -132,7 +136,7 @@ public class ImageDisplay extends Widget {
public boolean isPropertySmooth() {
return this.propertySmooth;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "use-theme-color")
@ -140,15 +144,15 @@ public class ImageDisplay extends Widget {
public boolean isPropertyUseThemeColor() {
return this.propertyUseThemeColor;
}
@Override
protected void onDraw() {
this.compositing.draw();
}
@Override
public boolean onEventInput(final EventInput event) {
//Log.debug("Event on BT ...");
//LOGGER.debug("Event on BT ...");
if (event.inputId() == 1) {
if (KeyStatus.pressSingle == event.status()) {
this.signalPressed.emit();
@ -157,7 +161,7 @@ public class ImageDisplay extends Widget {
}
return false;
}
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
@ -174,11 +178,12 @@ public class ImageDisplay extends Widget {
imageBoder = imageBoder.multiply(2.0f);
Vector2f imageRealSize = this.imageRenderSize.less(imageBoder);
final Vector3f imageRealSizeMax = this.size.less(imageBoder.x(), imageBoder.y(), 0);
final Vector2f ratioSizeDisplayRequested = this.propertyPosStop.less(this.propertyPosStart);
//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()) {
imageRealSize = imageRealSize.withX(imageRealSizeMax.x());
delta = delta.withX(0.0f);
@ -188,11 +193,12 @@ public class ImageDisplay extends Widget {
delta = delta.withY(0.0f);
}
origin = origin.add(delta);
if (this.propertyKeepRatio) {
final Vector2i tmpSize = this.compositing.getRealSize();
//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());
final float ratioCurrent = imageRealSize.x() / imageRealSize.y();
if (ratio == ratioCurrent) {
@ -207,7 +213,7 @@ public class ImageDisplay extends Widget {
origin = origin.add(0, (oldY - imageRealSize.y()) * 0.5f, 0);
}
}
// set the somposition properties :
if (this.propertySmooth) {
this.compositing.setPos(origin);
@ -215,23 +221,24 @@ public class ImageDisplay extends Widget {
this.compositing.setPos(Vector3f.clipInt(origin));
}
this.compositing.printPart(imageRealSize, this.propertyPosStart, this.propertyPosStop);
Log.debug("Paint Image at : " + origin + " size=" + imageRealSize);
Log.debug("Paint Image :" + this.propertySource + " realsize=" + this.compositing.getRealSize() + " origin=" + origin + " size=" + imageRealSize);
Log.debug(" start=" + this.propertyPosStart + " stop=" + this.propertyPosStop);
LOGGER.debug("Paint Image at : " + origin + " size=" + imageRealSize);
LOGGER.debug("Paint Image :" + this.propertySource + " realsize=" + this.compositing.getRealSize() + " origin="
+ origin + " size=" + imageRealSize);
LOGGER.debug(" start=" + this.propertyPosStart + " stop=" + this.propertyPosStop);
this.compositing.flush();
}
/**
* set All the configuration of the current image
* @param uri URI of the new image
* @param border New border size to set
*/
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);
setPropertySource(uri);
}
/**
* Set an image with direct elements
* @param image Image to set in the display
@ -242,7 +249,7 @@ public class ImageDisplay extends Widget {
markToRedraw();
requestUpdateSize();
}
public void setPropertyBorder(final Dimension2f propertyBorder) {
if (this.propertyBorder.equals(propertyBorder)) {
return;
@ -251,7 +258,7 @@ public class ImageDisplay extends Widget {
markToRedraw();
requestUpdateSize();
}
public void setPropertyImageSize(final Dimension2f propertyImageSize) {
if (this.propertyImageSize.equals(propertyImageSize)) {
return;
@ -259,10 +266,10 @@ public class ImageDisplay extends Widget {
this.propertyImageSize = propertyImageSize;
markToRedraw();
requestUpdateSize();
Log.verbose("Set sources : " + this.propertySource + " size=" + propertyImageSize);
LOGGER.trace("Set sources : " + this.propertySource + " size=" + propertyImageSize);
this.compositing.setSource(this.propertySource, propertyImageSize.getPixeli());
}
public void setPropertyKeepRatio(final boolean propertyKeepRatio) {
if (this.propertyKeepRatio == propertyKeepRatio) {
return;
@ -271,7 +278,7 @@ public class ImageDisplay extends Widget {
markToRedraw();
requestUpdateSize();
}
public void setPropertyPosStart(final Vector2f propertyPosStart) {
if (this.propertyPosStart.equals(propertyPosStart)) {
return;
@ -280,7 +287,7 @@ public class ImageDisplay extends Widget {
markToRedraw();
requestUpdateSize();
}
public void setPropertyPosStop(final Vector2f propertyPosStop) {
if (this.propertyPosStop.equals(propertyPosStop)) {
return;
@ -289,7 +296,7 @@ public class ImageDisplay extends Widget {
markToRedraw();
requestUpdateSize();
}
public void setPropertySmooth(final boolean propertySmooth) {
if (this.propertySmooth == propertySmooth) {
return;
@ -297,7 +304,7 @@ public class ImageDisplay extends Widget {
this.propertySmooth = propertySmooth;
markToRedraw();
}
public void setPropertySource(final Uri propertySource) {
if (this.propertySource != null && this.propertySource.equals(propertySource)) {
return;
@ -305,10 +312,10 @@ public class ImageDisplay extends Widget {
this.propertySource = propertySource;
markToRedraw();
requestUpdateSize();
Log.verbose("Set sources : " + propertySource + " size=" + this.propertyImageSize);
LOGGER.trace("Set sources : " + propertySource + " size=" + this.propertyImageSize);
this.compositing.setSource(propertySource, this.propertyImageSize.getPixeli());
}
public void setPropertyUseThemeColor(final boolean propertyUseThemeColor) {
if (this.propertyUseThemeColor == propertyUseThemeColor) {
return;

View File

@ -20,11 +20,13 @@ import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.AlignMode;
import org.atriasoft.ewol.compositing.CompositingText;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Label extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(Label.class);
@AknotSignal
@AknotName("pressed")
@AknotDescription("Label is pressed")
@ -33,16 +35,16 @@ public class Label extends Widget {
private int propertyFontSize = 0; //!< default size of the font.
private final CompositingText textCompose = new CompositingText(); //!< Compositing text element.
private String value = "";
protected int colorDefaultBgText = -1; //!< Default Background color of the text
protected int colorDefaultFgText = -1; //!< Default color of the text
protected ResourceColorFile colorProperty; //!< theme color property
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
public Label() {
this("---");
}
public Label(final String label) {
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
if (this.colorProperty != null) {
@ -53,10 +55,10 @@ public class Label extends Widget {
setPropertyCanFocus(false);
setPropertyValue(label);
}
@Override
public void calculateMinMaxSize() {
Log.verbose("calculateMinMaxSize !!! data = '{}'", this.value);
LOGGER.trace("calculateMinMaxSize !!! data = '{}'", this.value);
final Vector3f tmpMax = this.propertyMaxSize.getPixel();
final Vector3f tmpMin = this.propertyMinSize.getPixel();
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} tmpMax : " + tmpMax);
@ -70,33 +72,33 @@ public class Label extends Widget {
this.textCompose.flush();
minSize = minSize.add(2, 2, 0);
//EWOL_DEBUG("[" + getId() + "] {" + getObjectType() + "} minSize : " + minSize);
this.minSize = new Vector3f(FMath.avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x()), //
FMath.avg(tmpMin.y(), 4 + minSize.y(), tmpMax.y()), //
10);
Log.verbose("[{}] Result min size : {}", getId(), this.minSize);
LOGGER.trace("[{}] Result min size : {}", getId(), this.minSize);
}
public int getPropertyFontSize() {
return this.propertyFontSize;
}
public String getPropertyValue() {
return this.propertyValue;
}
public boolean isPropertyAutoTranslate() {
return this.propertyAutoTranslate;
}
@Override
protected void onDraw() {
this.textCompose.draw();
}
@Override
public boolean onEventInput(final EventInput event) {
//Log.debug("Event on Label ...");
//LOGGER.debug("Event on Label ...");
if (event.inputId() == 1) {
if (KeyStatus.pressSingle == event.status()) {
// nothing to do ...
@ -106,7 +108,7 @@ public class Label extends Widget {
}
return false;
}
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
@ -115,25 +117,26 @@ public class Label extends Widget {
this.textCompose.clear();
//final int paddingSize = 2;
final Padding padding = new Padding(2, 2, 2, 2);
final Vector3f tmpMax = this.propertyMaxSize.getPixel();
// to know the size of one line :
final Vector3f minSize = this.textCompose.calculateSize('A');
//minSize.setX(etk::max(minSize.x(), this.minSize.x()));
//minSize.setY(etk::max(minSize.y(), this.minSize.y()));
if (tmpMax.x() <= 999999) {
this.textCompose.setTextAlignment(0, tmpMax.x() - padding.x(), AlignMode.LEFT);
}
final Vector3f curentTextSize = this.textCompose.calculateSizeDecorated(this.value);
//Vector3f localSize = this.minSize.clipInteger();
Vector3f tmpSizeShaper = this.minSize;
// 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));
if (this.propertyFill.x()) {
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
delta = delta.withX(0.0f);
@ -150,19 +153,21 @@ public class Label extends Widget {
}
final Vector3f tmpOriginShaper = delta;
final Vector3f tmpSizeText = tmpSizeShaper.less(padding.x(), padding.y(), padding.z());
tmpTextOrigin = tmpOriginShaper;//tmpTextOrigin.add(paddingSize, 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() - 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());
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);
// clean the element
this.textCompose.reset();
if (this.propertyFontSize != 0) {
@ -173,13 +178,13 @@ public class Label extends Widget {
this.textCompose.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText));
}
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.setClipping(drawClippingPos, drawClippingSize);
this.textCompose.printDecorated(this.value);
this.textCompose.flush();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "auto-translate")
@ -197,7 +202,7 @@ public class Label extends Widget {
markToRedraw();
requestUpdateSize();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "font-size")
@ -210,7 +215,7 @@ public class Label extends Widget {
markToRedraw();
requestUpdateSize();
}
@AknotManaged
@AknotText
@AknotName(value = "value")
@ -228,5 +233,5 @@ public class Label extends Widget {
requestUpdateSize();
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.CompositingText;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.key.KeyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 colorDefaultFgText = -1; //!< Default color of the text
protected ResourceColorFile colorProperty; //!< theme color property
protected boolean propertyAutoTranslate = true; //!< if at true the data is translate automaticaly translate.
protected int propertyFontSize = 0; //!< default size of the font.
protected String propertyValue = ""; //!< decorated text to display.
@AknotSignal
@ -37,7 +39,7 @@ public class LabelOnSVG extends Widget {
public SignalEmpty signalPressed = new SignalEmpty();
protected CompositingText text = new CompositingText(); //!< Compositing text element.
protected String value = "";
public LabelOnSVG() {
this.colorProperty = ResourceColorFile.create(new Uri("THEME", "/color/Label.json", "ewol"));
if (this.colorProperty != null) {
@ -47,7 +49,7 @@ public class LabelOnSVG extends Widget {
setMouseLimit(1);
setPropertyCanFocus(false);
}
/**
* Constructor
* @param newLabel The displayed decorated text.
@ -62,43 +64,45 @@ public class LabelOnSVG extends Widget {
setPropertyCanFocus(false);
setPropertyValue(newLabel);
}
@Override
public void calculateMinMaxSize() {
final Vector3f tmpMax = this.propertyMaxSize.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) {
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);
Log.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()));
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < " + this.minSize + " < " + tmpMax);
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()));
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Result min size : " + tmpMin + " < "
+ this.minSize + " < " + tmpMax);
}
public int getPropertyFontSize() {
return this.propertyFontSize;
}
public String getPropertyValue() {
return this.propertyValue;
}
public boolean isPropertyAutoTranslate() {
return this.propertyAutoTranslate;
}
@Override
protected void onDraw() {
this.text.draw();
}
@Override
public boolean onEventInput(final EventInput event) {
//Log.debug("Event on Label ...");
//LOGGER.debug("Event on Label ...");
if (event.inputId() == 1) {
if (KeyStatus.pressSingle == event.status()) {
// nothing to do ...
@ -108,7 +112,7 @@ public class LabelOnSVG extends Widget {
}
return false;
}
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
@ -116,23 +120,24 @@ public class LabelOnSVG extends Widget {
}
this.text.clear();
final int paddingSize = 2;
final Vector3f tmpMax = this.propertyMaxSize.getPixel();
// to know the size of one line :
final Vector3f minSize = this.text.calculateSize('A');
//minSize.setX(etk::max(minSize.x(), this.minSize.x()));
//minSize.setY(etk::max(minSize.y(), this.minSize.y()));
if (tmpMax.x() <= 999999) {
this.text.setTextAlignment(0, tmpMax.x() - 2 * paddingSize, AlignMode.LEFT);
}
final Vector3f currentTextSize = this.text.calculateSizeDecorated(this.value);
Vector2i localSize = new Vector2i((int) this.minSize.x(), (int) this.minSize.y());
// 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()) {
localSize = localSize.withX((int) this.size.x());
tmpTextOrigin = tmpTextOrigin.withX(0);
@ -143,14 +148,14 @@ public class LabelOnSVG extends Widget {
}
tmpTextOrigin = tmpTextOrigin.add(paddingSize, paddingSize, 0);
localSize = localSize.less(2 * paddingSize, 2 * paddingSize);
tmpTextOrigin = tmpTextOrigin.withY(tmpTextOrigin.y() + (this.minSize.y() - 2 * paddingSize) - minSize.y());
final Vector3f textPos = new Vector3f(tmpTextOrigin.x(), tmpTextOrigin.y(), 0);
final Vector3f drawClippingPos = new Vector3f(paddingSize, paddingSize, -0.5f);
final Vector3f drawClippingSize = new Vector3f((this.size.x() - paddingSize), (this.size.y() - paddingSize), 1);
// clean the element
this.text.reset();
if (this.propertyFontSize != 0) {
@ -161,14 +166,14 @@ public class LabelOnSVG extends Widget {
this.text.setDefaultColorBg(this.colorProperty.get(this.colorDefaultBgText));
}
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.setClipping(drawClippingPos, drawClippingSize);
this.text.printDecorated(this.value);
this.text.flush();
}
@AknotManaged
@AknotAttribute
@AknotName("auto-translate")
@ -186,7 +191,7 @@ public class LabelOnSVG extends Widget {
markToRedraw();
requestUpdateSize();
}
@AknotManaged
@AknotAttribute
@AknotName("font-size")
@ -199,7 +204,7 @@ public class LabelOnSVG extends Widget {
markToRedraw();
requestUpdateSize();
}
@AknotManaged
@AknotAttribute
@AknotName("value")
@ -217,5 +222,5 @@ public class LabelOnSVG extends Widget {
requestUpdateSize();
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.Vector3i;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.ewol.widget.model.ListRole;
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 :
*/
public class ListFileSystem extends WidgetList {
private static final Logger LOGGER = LoggerFactory.getLogger(ListFileSystem.class);
@AknotSignal
@AknotName(value = "file-select")
@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.
@AknotSignal
@AknotName(value = "file-validate")
@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
@AknotSignal
@AknotName(value = "folder-select")
@AknotDescription(value = "A folder has been selected in the List")
public Signal<String> signalFolderSelect = new Signal<>();
@AknotSignal
@AknotName(value = "folder-validate")
@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 propertyShowHidden = true; //!< Display hidden elements
protected String propertyFilter = "^.*$"; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e")
protected ResourceColorFile colorProperty; //!< theme color property.
protected int colorIdText = -1; //!< Color of the text.
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 List<File> list = new ArrayList<>(); //!< List of all element in the File. (they are filtered)
protected int selectedLine; //!< Current Line ID that is selected
public ListFileSystem() {
this.colorProperty = new ResourceColorFile(new Uri("THEME", "/color/ListFileSystem.json", "ewol"));
if (this.colorProperty != null) {
this.colorIdText = this.colorProperty.request("text");
@ -83,19 +85,19 @@ public class ListFileSystem extends WidgetList {
}
setMouseLimit(2);
}
/**
* Clean the list of element.
*/
protected void clearList() {
this.list.clear();
}
@Override
protected Color getBasicBG() {
return this.colorProperty.get(this.colorIdBackground1);
}
@Override
protected Object getData(final ListRole role, final Vector2i pos) {
switch (role) {
@ -114,7 +116,8 @@ public class ListFileSystem extends WidgetList {
}
}
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();
}
}
@ -134,7 +137,7 @@ public class ListFileSystem extends WidgetList {
}
return null;
}
@Override
protected Vector2i getMatrixSize() {
int offset = 0;
@ -147,7 +150,7 @@ public class ListFileSystem extends WidgetList {
}
return new Vector2i(1, this.list.size() + offset);
}
@AknotManaged
@AknotAttribute
@AknotName(value = "select")
@ -155,7 +158,7 @@ public class ListFileSystem extends WidgetList {
public File getPropertyFile() {
return this.propertyFile;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "filter")
@ -163,7 +166,7 @@ public class ListFileSystem extends WidgetList {
public String getPropertyFilter() {
return this.propertyFilter;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "Path")
@ -171,7 +174,7 @@ public class ListFileSystem extends WidgetList {
public String getPropertyPath() {
return this.propertyPath;
}
/**
* Get the current selected file/folder/... in the list
* @return the String of the element selected.
@ -182,7 +185,7 @@ public class ListFileSystem extends WidgetList {
}
return null;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "show-file")
@ -190,7 +193,7 @@ public class ListFileSystem extends WidgetList {
public boolean isPropertyShowFile() {
return this.propertyShowFile;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "show-folder")
@ -198,7 +201,7 @@ public class ListFileSystem extends WidgetList {
public boolean isPropertyShowFolder() {
return this.propertyShowFolder;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "show-hidden")
@ -206,8 +209,12 @@ public class ListFileSystem extends WidgetList {
public boolean isPropertyShowHidden() {
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<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dir))) {
for (final Path path : stream) {
@ -215,18 +222,18 @@ public class ListFileSystem extends WidgetList {
continue;
}
if (Files.isDirectory(path) && showFolder) {
Log.error("Add Directory '{}'", path);
LOGGER.error("Add Directory '{}'", path);
fileList.add(new File(path.toString()));
}
if (!Files.isDirectory(path) && showFiles) {
Log.error("Add File '{}'", path);
LOGGER.error("Add File '{}'", path);
fileList.add(new File(path.toString()));
}
}
}
return fileList;
}
@Override
protected boolean onItemEvent(final EventInput event, final Vector3i pos, final Vector3f mousePosition) {
int offset = 0;
@ -238,7 +245,7 @@ public class ListFileSystem extends WidgetList {
}
}
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 (pos.y() > this.list.size() + offset) {
this.selectedLine = -1;
@ -267,12 +274,10 @@ public class ListFileSystem extends WidgetList {
} else {
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 {
if (event.status() == KeyStatus.pressSingle) {
this.signalFileSelect.emit(this.list.get(this.selectedLine - offset).getPath());
} else {
this.signalFileValidate.emit(this.list.get(this.selectedLine - offset).getPath());
}
this.signalFileValidate.emit(this.list.get(this.selectedLine - offset).getPath());
}
}
// need to regenerate the display of the list :
@ -282,7 +287,7 @@ public class ListFileSystem extends WidgetList {
}
return false;
}
/**
* 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);
final int flags = 0;
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) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -303,7 +309,7 @@ public class ListFileSystem extends WidgetList {
// request a redraw ...
markToRedraw();
}
public void setPropertyFile(final File propertyFile) {
if (this.propertyFile.equals(propertyFile)) {
return;
@ -311,7 +317,7 @@ public class ListFileSystem extends WidgetList {
this.propertyFile = propertyFile;
regenerateView();
}
public void setPropertyFilter(final String propertyFilter) {
if (!this.propertyFilter.equals(propertyFilter)) {
return;
@ -319,7 +325,7 @@ public class ListFileSystem extends WidgetList {
this.propertyFilter = propertyFilter;
regenerateView();
}
public void setPropertyPath(final String propertyPath) {
if (this.propertyPath.equals(propertyPath)) {
return;
@ -327,7 +333,7 @@ public class ListFileSystem extends WidgetList {
this.propertyPath = propertyPath;
regenerateView();
}
public void setPropertyShowFile(final boolean propertyShowFile) {
if (this.propertyShowFile == propertyShowFile) {
return;
@ -335,7 +341,7 @@ public class ListFileSystem extends WidgetList {
this.propertyShowFile = propertyShowFile;
regenerateView();
}
public void setPropertyShowFolder(final boolean propertyShowFolder) {
if (this.propertyShowFolder == propertyShowFolder) {
return;
@ -343,7 +349,7 @@ public class ListFileSystem extends WidgetList {
this.propertyShowFolder = propertyShowFolder;
regenerateView();
}
public void setPropertyShowHidden(final boolean propertyShowHidden) {
if (this.propertyShowHidden == propertyShowHidden) {
return;
@ -351,7 +357,7 @@ public class ListFileSystem extends WidgetList {
this.propertyShowHidden = propertyShowHidden;
regenerateView();
}
/**
* Select a specific file in the File
* @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.compositing.GuiShape;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class Scroll extends Container {
private static final Logger LOGGER = LoggerFactory.getLogger(Scroll.class);
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 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 boolean propertyHover = true; //!< Horizontal shaper name
protected GuiShape shaperH; //!< Compositing theme Horizontal.
protected GuiShape shaperV; //!< Compositing theme Vertical.
protected float pixelScrolling = 20;
protected Vector3f highSpeedStartPos = Vector3f.ZERO;
protected HighSpeedMode highSpeedMode = HighSpeedMode.speedModeDisable;
protected int highSpeedButton = -1;
protected KeyType highSpeedType = KeyType.unknow;
public Scroll() {
/*
// Remove gravity property: (only keep top/buttom)
@ -59,7 +61,7 @@ class Scroll extends Container {
onChangePropertyShapeVert();
onChangePropertyShapeHori();
}
@Override
public void calculateMinMaxSize() {
// Note: No call of container ==> normal case ...
@ -69,7 +71,7 @@ class Scroll extends Container {
this.subWidget.calculateMinMaxSize();
}
}
@AknotManaged
@AknotAttribute
@AknotName(value = "limit")
@ -77,7 +79,7 @@ class Scroll extends Container {
public Vector3f getPropertyLimit() {
return this.propertyLimit;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "shape-hori")
@ -85,7 +87,7 @@ class Scroll extends Container {
public Uri getPropertyShapeHori() {
return this.propertyShapeHori;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "shape-vert")
@ -93,7 +95,7 @@ class Scroll extends Container {
public Uri getPropertyShapeVert() {
return this.propertyShapeVert;
}
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
final Widget tmpWidget = super.getWidgetAtPos(pos);
@ -102,7 +104,7 @@ class Scroll extends Container {
}
return this;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "hover")
@ -110,21 +112,21 @@ class Scroll extends Container {
public boolean isPropertyHover() {
return this.propertyHover;
}
void onChangePropertyLimit() {
markToRedraw();
}
protected void onChangePropertyShapeHori() {
this.shaperH.setSource(this.propertyShapeHori);
markToRedraw();
}
protected void onChangePropertyShapeVert() {
this.shaperV.setSource(this.propertyShapeVert);
markToRedraw();
}
@Override
public void onChangeSize() {
// Note: No call of container ==> normal case ...
@ -140,7 +142,7 @@ class Scroll extends Container {
if (!this.propertyHover) {
basicSize = basicSize.less(SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, SCROLL_BAR_SPACE);
}
Vector3f origin = this.origin.add(this.offset);
Vector3f minSize = this.subWidget.getCalculateMinSize();
final Vector3b expand = this.subWidget.propertyExpand;
@ -161,18 +163,18 @@ class Scroll extends Container {
} else if (this.propertyGravity.y() == GravityVertical.BOTTOM) {
// nothing to do ... origin +=
} else {
Log.error(" Not manage other gravity ...");
LOGGER.error(" Not manage other gravity ...");
}
this.subWidget.setOrigin(origin);
this.subWidget.onChangeSize();
}
@Override
protected void onDraw() {
this.shaperH.draw();
this.shaperV.draw();
}
@Override
public boolean onEventInput(final EventInput event) {
//ewol::event::Input _event = event;
@ -184,9 +186,10 @@ class Scroll extends Container {
scrollOffset = this.subWidget.getOffset();
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());
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) {
// check if selected the scrolling position whth the scrolling bar ...
if (relativePos.x() >= (this.size.x() - SCROLL_BAR_SPACE)) {
@ -194,11 +197,14 @@ class Scroll extends Container {
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
this.highSpeedType = KeyType.mouse;
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;
// 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(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.y())));
scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE)
/ (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();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -209,12 +215,15 @@ class Scroll extends Container {
if (this.size.x() < scrollSize.x() || scrollOffset.x() != 0) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
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.highSpeedButton = 1;
// 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.withY(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x())));
scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE)
/ (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();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -224,10 +233,11 @@ class Scroll extends Container {
}
return false;
} 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()) {
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();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -235,10 +245,11 @@ class Scroll extends Container {
return true;
}
} 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()) {
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();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -282,7 +293,8 @@ class Scroll extends Container {
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) {
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|| FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrooling can start :
// select the direction :
if (relativePos.x() == this.highSpeedStartPos.x()) {
@ -290,7 +302,8 @@ class Scroll extends Container {
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} 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) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} else {
@ -298,21 +311,26 @@ class Scroll extends Container {
}
}
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 {
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();
}
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) {
this.subWidget.setOffset(scrollOffset);
}
return true;
}
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(FMath.avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x() * this.propertyLimit.x())));
scrollOffset = scrollOffset.withX((int) (scrollSize.x() * (relativePos.x() - SCROLL_BAR_SPACE)
/ (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();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -320,8 +338,10 @@ class Scroll extends Container {
return true;
}
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(FMath.avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y() * this.propertyLimit.x())));
scrollOffset = scrollOffset.withY((int) (scrollSize.y() * (relativePos.y() - SCROLL_BAR_SPACE)
/ (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();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -329,46 +349,54 @@ class Scroll extends Container {
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()) {
Log.verbose("event: " + event);
LOGGER.trace("event: " + event);
if (KeyStatus.down == event.status()) {
this.highSpeedMode = HighSpeedMode.speedModeInit;
this.highSpeedType = KeyType.finger;
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;
} else if (KeyStatus.upAfter == event.status()) {
this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow;
Log.verbose("SCROOL == > DISABLE");
LOGGER.trace("SCROOL == > DISABLE");
markToRedraw();
return true;
} else if (this.highSpeedMode == HighSpeedMode.speedModeInit && KeyStatus.move == event.status()) {
// 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 :
// select the direction :
this.highSpeedMode = HighSpeedMode.speedModeEnableFinger;
Log.verbose("SCROOL == > ENABLE");
LOGGER.trace("SCROOL == > ENABLE");
markToRedraw();
}
return true;
}
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);
if (this.propertyLimit.x() != 0.0f) {
scrollOffset = scrollOffset.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())));
scrollOffset = scrollOffset
.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) {
scrollOffset = scrollOffset.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())));
scrollOffset = scrollOffset
.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:
this.highSpeedStartPos = relativePos;
Log.verbose("SCROOL == > MOVE " + scrollOffset);
LOGGER.trace("SCROOL == > MOVE " + scrollOffset);
markToRedraw();
if (this.subWidget != null) {
this.subWidget.setOffset(scrollOffset);
@ -381,14 +409,14 @@ class Scroll extends Container {
} else if (this.highSpeedMode != HighSpeedMode.speedModeDisable && KeyStatus.leave == event.status()) {
this.highSpeedMode = HighSpeedMode.speedModeDisable;
this.highSpeedType = KeyType.unknow;
Log.verbose("SCROOL == > DISABLE");
LOGGER.trace("SCROOL == > DISABLE");
markToRedraw();
return true;
}
}
return false;
}
@Override
public void onRegenerateDisplay() {
if (this.propertyHide) {
@ -416,26 +444,30 @@ class Scroll extends Container {
float originScrollBar = scrollOffset.y() / (scrollSize.y() - this.size.y() * this.propertyLimit.y());
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
originScrollBar *= (this.size.y() - lenScrollBar);
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0), new Vector2f(paddingVert.x(), this.size.y()),
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar), new Vector2f(0, lenScrollBar));
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0),
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) {
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()));
float originScrollBar = scrollOffset.x() / (scrollSize.x() - this.size.x() * this.propertyLimit.x());
originScrollBar = FMath.avg(0.0f, originScrollBar, 1.0f);
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) {
if (propertyHover == this.propertyHover) {
return;
}
this.propertyHover = propertyHover;
}
public void setPropertyLimit(final Vector3f propertyLimit) {
final Vector3f tmp = Vector3f.avg(Vector3f.ZERO, propertyLimit, Vector3f.ONE);
if (tmp.equals(this.propertyLimit)) {
@ -444,7 +476,7 @@ class Scroll extends Container {
this.propertyLimit = propertyLimit;
onChangePropertyLimit();
}
public void setPropertyShapeHori(final Uri value) {
if (this.propertyShapeHori.equals(value)) {
return;
@ -452,7 +484,7 @@ class Scroll extends Container {
this.propertyShapeHori = value;
onChangePropertyShapeHori();
}
public void setPropertyShapeVert(final Uri value) {
if (this.propertyShapeVert.equals(value)) {
return;
@ -460,7 +492,7 @@ class Scroll extends Container {
this.propertyShapeVert = value;
onChangePropertyShapeVert();
}
@Override
public void systemDraw(final DrawProperty displayProp) {
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.Vector3f;
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 {
private static final Logger LOGGER = LoggerFactory.getLogger(Sizer.class);
@AknotCaseSensitive(value = false)
public enum DisplayMode {
HORIZONTAL, //!< Horizontal mode
VERTICAL; //!< Vertical mode
}
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 ...)
/**
* Constructor
*/
public Sizer() {
}
/**
* Constructor
* @param mode The mode to display the elements
@ -41,14 +44,14 @@ public class Sizer extends ContainerN {
public Sizer(final DisplayMode mode) {
this.propertyMode = mode;
}
@Override
public void calculateMinMaxSize() {
Log.verbose("[" + getId() + "] update minimum size");
LOGGER.trace("[" + getId() + "] update minimum size");
this.subExpend = Vector3b.FALSE;
this.minSize = this.propertyMinSize.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) {
if (it == null) {
continue;
@ -61,8 +64,8 @@ public class Sizer extends ContainerN {
this.subExpend = this.subExpend.withY(true);
}
final Vector3f tmpSize = it.getCalculateMinSize();
Log.verbose("[" + getId() + "] NewMinSize=" + tmpSize);
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} Get minSize=" + tmpSize);
LOGGER.trace("[" + getId() + "] NewMinSize=" + tmpSize);
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} Get minSize=" + tmpSize);
if (this.propertyMode == DisplayMode.VERTICAL) {
this.minSize = this.minSize.withY(this.minSize.y() + tmpSize.y());
if (tmpSize.x() > this.minSize.x()) {
@ -76,9 +79,9 @@ public class Sizer extends ContainerN {
}
}
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
@AknotAttribute
@AknotName("border")
@ -86,7 +89,7 @@ public class Sizer extends ContainerN {
public Dimension3f getPropertyBorderSize() {
return this.propertyBorderSize;
}
@AknotManaged
@AknotAttribute
@AknotName("mode")
@ -94,12 +97,13 @@ public class Sizer extends ContainerN {
public DisplayMode getPropertyMode() {
return this.propertyMode;
}
@Override
public void onChangeSize() {
super.onChangeSize();
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));
// -1- calculate min-size and expand requested:
Vector3f minSize = Vector3f.ZERO;
@ -110,9 +114,11 @@ public class Sizer extends ContainerN {
}
final Vector3f tmpSize = it.getCalculateMinSize();
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 {
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();
nbWidgetExpand = nbWidgetExpand.add(expand.x() ? 1 : 0, expand.y() ? 1 : 0, 0);
@ -209,14 +215,16 @@ public class Sizer extends ContainerN {
continue;
}
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);
} else {
if (!it.canExpand().y() && !it.canExpandIfFree().y()) {
continue;
}
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);
}
}
@ -235,13 +243,15 @@ public class Sizer extends ContainerN {
}
final Vector3f size = it.getSize();
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 {
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);
// -8- Calculate the local origin, depending of the gravity:
Vector3f tmpOrigin = this.origin.add(tmpBorderSize).add(this.propertyGravity.gravityGenerateDelta(deltas));
// -9- Set sub widget origin:
@ -252,9 +262,11 @@ public class Sizer extends ContainerN {
Vector3f origin;
final Vector3f size = it.getSize();
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 {
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);
if (this.propertyMode == DisplayMode.VERTICAL) {
@ -272,14 +284,14 @@ public class Sizer extends ContainerN {
}
markToRedraw();
}
public void setPropertyBorderSize(final Dimension3f propertyBorderSize) {
if (this.propertyBorderSize.equals(propertyBorderSize)) {
return;
}
this.propertyBorderSize = propertyBorderSize;
}
public void setPropertyMode(final DisplayMode propertyMode) {
if (this.propertyMode.equals(propertyMode)) {
return;

View File

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

View File

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

View File

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

View File

@ -31,7 +31,6 @@ import org.atriasoft.ewol.event.EventEntry;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.event.EventShortCut;
import org.atriasoft.ewol.event.InputSystem;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.gale.backend3d.OpenGL;
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.KeySpecial;
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:
@ -46,9 +47,10 @@ import org.lwjgl.opengl.GL11;
* :** Can be display at a special position with a special scale
* :** Can get focus
* :** Receive Event (keyboard / mouse / ...)
*
*
*/
public class Widget extends EwolObject {
private static final Logger LOGGER = LoggerFactory.getLogger(Widget.class);
// ----------------------------------------------------------------------------------------------------------------
// -- keyboard event properties Area
// ----------------------------------------------------------------------------------------------------------------
@ -121,7 +123,7 @@ public class Widget extends EwolObject {
protected void calculateMinMaxSizeWidget() {
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();
markToRedraw();
}
@ -194,7 +196,8 @@ public class Widget extends EwolObject {
for (int iii = 0; iii < level; ++iii) {
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());
}
@ -444,7 +447,7 @@ public class Widget extends EwolObject {
* @note INTERNAL EWOL SYSTEM
*/
public void onChangeSize() {
Log.verbose("[" + getId() + "] {" + getClass().getCanonicalName() + "} update size : " + this.size);
LOGGER.trace("[" + getId() + "] {" + getClass().getCanonicalName() + "} update size : " + this.size);
markToRedraw();
}
@ -493,33 +496,43 @@ public class Widget extends EwolObject {
* @return false if the event has not been used.
* @note To prevent some error when you get an event get it if it is down and Up ... ==> like this it could not generate some mistake in the error.
*/
public boolean onEventShortCut(final KeySpecial special, Character unicodeValue, final KeyKeyboard kbMove, final boolean isDown) {
public boolean onEventShortCut(
final KeySpecial special,
Character unicodeValue,
final KeyKeyboard kbMove,
final boolean isDown) {
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...
if (!isDown) {
for (int iii = this.localShortcut.size() - 1; iii >= 0; iii--) {
if (!this.localShortcut.get(iii).isActive) {
continue;
}
if ((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 ((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)) {
// In this case we grap the event in case of an error can occured ...
this.localShortcut.get(iii).isActive = false;
Log.verbose("detect up of a shortcut");
LOGGER.trace("detect up of a shortcut");
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--) {
if (this.localShortcut.get(iii).specialKey().getShift() == special.getShift() && this.localShortcut.get(iii).specialKey().getCtrl() == special.getCtrl()
&& this.localShortcut.get(iii).specialKey().getAlt() == special.getAlt() && 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 (this.localShortcut.get(iii).specialKey().getShift() == special.getShift()
&& this.localShortcut.get(iii).specialKey().getCtrl() == special.getCtrl()
&& this.localShortcut.get(iii).specialKey().getAlt() == special.getAlt()
&& 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) {
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());
}
return true;
@ -545,7 +558,7 @@ public class Widget extends EwolObject {
final Vector3f pixelMax = this.propertyMaxSize.getPixel();
// check minimum maximum compatibility :
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);
}
requestUpdateSize();
@ -587,7 +600,7 @@ public class Widget extends EwolObject {
* @param newCursor selected new cursor.
*/
public void setCursor(final Cursor newCursor) {
Log.debug("Change Cursor in " + newCursor);
LOGGER.debug("Change Cursor in " + newCursor);
this.cursorDisplay = newCursor;
EwolObject.getContext().setCursor(this.cursorDisplay);
}
@ -597,16 +610,17 @@ public class Widget extends EwolObject {
* @return return true if the widget keep the focus
*/
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.hasFocus) {
this.hasFocus = true;
onGetFocus();
}
Log.verbose("set focus (stop) ret true");
LOGGER.trace("set focus (stop) ret true");
return true;
}
Log.verbose("set focus (stop) ret false");
LOGGER.trace("set focus (stop) ret false");
return false;
}
@ -645,7 +659,7 @@ public class Widget extends EwolObject {
* @param newVal offset value.
*/
public void setOffset(final Vector3f newVal) {
Log.info("Set offset: " + newVal);
LOGGER.info("Set offset: " + newVal);
if (this.offset != newVal) {
this.offset = newVal;
markToRedraw();
@ -772,7 +786,7 @@ public class Widget extends EwolObject {
*/
protected void shortCutAdd(final String descriptiveString, final String sendMessage) {
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;
}
String message; //!< data link with the event
@ -918,7 +932,7 @@ public class Widget extends EwolObject {
}
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) {
// widget is hidden ...
return;
@ -935,20 +949,23 @@ public class Widget extends EwolObject {
if (tmpSize.size().x() <= 0 || tmpSize.size().y() <= 0) {
return;
}
//Log.info("setViewport(" + tmpSize.origin() + ", " + tmpSize.size() + ")");
//LOGGER.info("setViewport(" + tmpSize.origin() + ", " + tmpSize.size() + ")");
OpenGL.setViewPort(tmpSize.origin(), tmpSize.size());
// 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);
//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
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));
// Scale if needed (feature not validate)
final Matrix4f tmpScale = Matrix4f.createMatrixScale(this.zoom, this.zoom, 1.0f);
// 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);
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.CompositingText;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.model.ListRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class WidgetList extends WidgetScrolled {
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetList.class);
// drawing capabilities ....
protected List<Compositing> listOObject = new ArrayList<>(); //!< generic element to display...
protected List<Integer> listSizeX = new ArrayList<>(); //!< size of every colomns
protected List<Integer> listSizeY = new ArrayList<>(); //!< size of every rows
protected Map<String, Compositing> compositingElements = new HashMap<>();
// list properties ...
protected int paddingSizeX = 0;
protected int paddingSizeY = 0;
protected int displayStartRaw = 0; //!< Current starting diaplayed raw
protected int displayCurrentNbLine = 0; //!< Number of line in the display
protected int nbVisibleRaw = 0; // set the number of visible raw (calculate don display)
// function call to display the list :
public WidgetList() {
this.paddingSizeX = 2;
this.paddingSizeY = 2;
@ -51,12 +53,12 @@ class WidgetList extends WidgetScrolled {
addComposeElemnent("drawing", new CompositingDrawing());
addComposeElemnent("text", new CompositingText());
}
protected void addComposeElemnent(final String name, final Compositing element) {
this.compositingElements.put(name, element);
//this.listOObject.add(element);
}
/**
* Calculate an element size to estimate the render size.
* @note Does not generate the with the same size.
@ -73,7 +75,7 @@ class WidgetList extends WidgetScrolled {
}
return Vector2f.ZERO;
}
@Override
public void calculateMinMaxSize() {
/*int fontId = getDefaultFontId();
@ -84,18 +86,18 @@ class WidgetList extends WidgetScrolled {
*/
this.minSize = new Vector3f(200, 150, 10);
}
protected void clearComposeElemnent() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
//it.setValue(null);
it.getValue().clear();
}
}
public void clearOObjectList() {
//this.listOObject.clear();
}
/**
* Draw the background
*/
@ -107,7 +109,7 @@ class WidgetList extends WidgetScrolled {
BGOObjects.rectangleWidth(new Vector2f(this.size.x(), this.size.y()));
}
}
/**
* Draw an element in the specific size and position.
* @param pos Position of colomn and Raw of the element.
@ -136,7 +138,7 @@ class WidgetList extends WidgetScrolled {
}
}
}
protected void flushElements() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
it.getValue().flush();
@ -147,15 +149,15 @@ class WidgetList extends WidgetScrolled {
}
}
}
protected Color getBasicBG() {
return new Color(0xFF, 0xFF, 0xFF, 0xFF);
}
protected Compositing getComposeElemnent(final String name) {
return this.compositingElements.get(name);
}
protected Object getData(final ListRole role, final Vector2i pos) {
switch (role) {
case Text:
@ -172,7 +174,7 @@ class WidgetList extends WidgetScrolled {
}
return null;
}
/**
* Get the number of colomn and row availlable in the list
* @return Number of colomn and row
@ -180,7 +182,7 @@ class WidgetList extends WidgetScrolled {
protected Vector2i getMatrixSize() {
return new Vector2i(1, 0);
}
@Override
protected void onDraw() {
for (final Entry<String, Compositing> it : this.compositingElements.entrySet()) {
@ -193,7 +195,7 @@ class WidgetList extends WidgetScrolled {
}
super.onDraw();
}
@Override
public boolean onEventInput(final EventInput event) {
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) {
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
Vector3i pos = Vector3i.ZERO;
float offsetY = 0;
@ -244,7 +247,7 @@ class WidgetList extends WidgetScrolled {
}
return isUsed;
}
/**
* set a raw visible in the main display
* @param _id Id of the raw that might be visible.
@ -252,18 +255,18 @@ class WidgetList extends WidgetScrolled {
//void setRawVisible(int _id);
@Override
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) {
return false;
}
@Override
protected void onLostFocus() {
Log.debug("WidgetList Lost focus");
LOGGER.debug("WidgetList Lost focus");
}
@Override
public void onRegenerateDisplay() {
if (!needRedraw()) {
@ -371,7 +374,7 @@ class WidgetList extends WidgetScrolled {
}
for (int xxx = 0; xxx < matrixSize.x(); ++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) {
// ==> element out of range ==> nothing to display
continue;
@ -380,7 +383,8 @@ class WidgetList extends WidgetScrolled {
// ==> element out of range ==> nothing to display
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
flushElements();
}
protected void removeComposeElemnent() {
this.compositingElements.clear();
}
}

View File

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

View File

@ -14,21 +14,24 @@ import org.atriasoft.ewol.HighSpeedMode;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.key.KeyStatus;
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.
*/
class WidgetScrolled extends Widget {
private static final Logger LOGGER = LoggerFactory.getLogger(WidgetScrolled.class);
public enum ScrollingMode {
scroolModeNormal, //!< No Zoom , can UP and down, left and right
scroolModeCenter, //!< Zoom enable, no move left and right
scroolModeGame, //!< Zoom enable, no move left and right
}
public static final int CALCULATE_SIMULTANEOUS_FINGER = 5;
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
@ -49,7 +52,7 @@ class WidgetScrolled extends Widget {
private final boolean[] fingerPresent = { false, false, false, false, false };
private boolean fingerScoolActivated = false;
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)
* @param _shaperName Shaper name if the scrolled widget.
@ -58,7 +61,7 @@ class WidgetScrolled extends Widget {
onChangePropertyShapeVert();
onChangePropertyShapeHori();
}
@AknotManaged
@AknotAttribute
@AknotName("shape-hori")
@ -66,7 +69,7 @@ class WidgetScrolled extends Widget {
public Uri getPropertyShapeHori() {
return this.propertyShapeHori;
}
@AknotManaged
@AknotAttribute
@AknotName("shape-vert")
@ -74,7 +77,7 @@ class WidgetScrolled extends Widget {
public Uri getPropertyShapeVert() {
return this.propertyShapeVert;
}
/**
* Get the single finger capabilities
* @return true The single finger mode is active
@ -83,7 +86,7 @@ class WidgetScrolled extends Widget {
public boolean getSingleFinger() {
return this.singleFingerMode;
}
protected void onChangePropertyShapeHori() {
if (this.shaperH == null) {
this.shaperH = new GuiShape(this.propertyShapeHori);
@ -92,7 +95,7 @@ class WidgetScrolled extends Widget {
}
markToRedraw();
}
protected void onChangePropertyShapeVert() {
if (this.shaperV == null) {
this.shaperV = new GuiShape(this.propertyShapeVert);
@ -101,23 +104,24 @@ class WidgetScrolled extends Widget {
}
markToRedraw();
}
@Override
protected void onDraw() {
this.shaperH.draw();
this.shaperV.draw();
}
@Override
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));
// Correction due to the open Gl insertion ...
relativePos = relativePos.withY(this.size.y() - relativePos.y());
final Padding paddingV = this.shaperV.getPadding();
final Padding paddingH = this.shaperH.getPadding();
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) {
// check if selected the scrolling position with the scrolling bar ...
if (relativePos.x() >= (this.size.x() - paddingV.x())) {
@ -125,11 +129,14 @@ class WidgetScrolled extends Widget {
this.highSpeedMode = HighSpeedMode.speedModeEnableVertical;
this.highSpeedType = KeyType.mouse;
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;
// 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(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.bottom() * 2)));
this.originScrooled = this.originScrooled.withY(FMath.avg(0.0f, this.originScrooled.y(),
(this.maxSize.y() - this.size.y() * this.limitScrolling.y())));
markToRedraw();
return true;
}
@ -137,12 +144,15 @@ class WidgetScrolled extends Widget {
if (this.size.x() < this.maxSize.x() || this.originScrooled.x() != 0) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
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.highSpeedButton = 1;
// 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(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.left() * 2)));
this.originScrooled = this.originScrooled.withX(FMath.avg(0.0f, this.originScrooled.x(),
(this.maxSize.x() - this.size.x() * this.limitScrolling.x())));
markToRedraw();
return true;
}
@ -156,13 +166,13 @@ class WidgetScrolled extends Widget {
zoom = FMath.avg(0.1f, zoom, 5000.0f);
setZoom(zoom);
*/
} else {
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0 || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
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())));
markToRedraw();
return true;
}
} else if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0
|| this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
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())));
markToRedraw();
return true;
}
} else if (event.inputId() == 5 && event.status() == KeyStatus.up) {
if (event.specialKey().getCtrl()) {
@ -172,27 +182,31 @@ class WidgetScrolled extends Widget {
zoom = FMath.avg(0.1f, zoom, 5000.0f);
setZoom(zoom);
*/
} else {
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0 || this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
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())));
markToRedraw();
return true;
}
} else if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0
|| this.size.y() * this.limitScrolling.y() < this.maxSize.y()) {
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())));
markToRedraw();
return true;
}
} else if (event.inputId() == 11 && event.status() == KeyStatus.up) {
// 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(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();
return true;
}
} else if (event.inputId() == 10 && event.status() == KeyStatus.up) {
// 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(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();
return true;
}
@ -235,7 +249,8 @@ class WidgetScrolled extends Widget {
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) {
if (FMath.abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|| FMath.abs(relativePos.y() - this.highSpeedStartPos.y()) > 10) {
// the scrolling can start :
// select the direction :
if (relativePos.x() == this.highSpeedStartPos.x()) {
@ -243,7 +258,8 @@ class WidgetScrolled extends Widget {
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} 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) {
this.highSpeedMode = HighSpeedMode.speedModeEnableHorizontal;
} else {
@ -251,29 +267,39 @@ class WidgetScrolled extends Widget {
}
}
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 {
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();
}
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;
}
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal && event.status() == KeyStatus.move) {
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())));
if (this.highSpeedMode == HighSpeedMode.speedModeEnableHorizontal
&& event.status() == KeyStatus.move) {
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();
return true;
}
if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical && event.status() == KeyStatus.move) {
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())));
if (this.highSpeedMode == HighSpeedMode.speedModeEnableVertical
&& event.status() == KeyStatus.move) {
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();
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) {
// ***********************
// ** Two finger mode : **
@ -292,18 +318,23 @@ class WidgetScrolled extends Widget {
}
if (this.fingerPresent[0] && this.fingerPresent[1] && !this.fingerScoolActivated) {
this.fingerScoolActivated = true;
Log.verbose("SCROOL == > START pos=" + this.fingerMoveStartPos);
LOGGER.trace("SCROOL == > START pos=" + this.fingerMoveStartPos);
}
if (this.fingerScoolActivated) {
// 1: HighSpeedMode...
// 2: remove all unneeded sub event ... ==> maybe a better methode ...
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.withY(this.originScrooled.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.originScrooled = this.originScrooled.withX(this.originScrooled.x()
- (relativePos.x() - this.fingerMoveStartPos[idTable].x()) * 0.5f);
this.originScrooled = this.originScrooled.withY(this.originScrooled.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());
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
LOGGER.trace("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " "
+ relativePos + " " + this.highSpeedStartPos);
markToRedraw();
}
if (!this.fingerPresent[0] && !this.fingerPresent[1]) {
@ -315,66 +346,72 @@ class WidgetScrolled extends Widget {
}
return true;
}
} else {
// **************************
// ** Single finger mode : **
// **************************
if (event.inputId() == 1) {
Log.verbose("event 1 " + event);
if (event.status() == KeyStatus.down) {
this.highSpeedMode = HighSpeedMode.speedModeInit;
this.highSpeedType = KeyType.finger;
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
Log.verbose("SCROOL == > INIT");
return true;
} 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) {
} else // **************************
// ** Single finger mode : **
// **************************
if (event.inputId() == 1) {
LOGGER.trace("event 1 " + event);
if (event.status() == KeyStatus.down) {
this.highSpeedMode = HighSpeedMode.speedModeInit;
this.highSpeedType = KeyType.finger;
this.highSpeedStartPos = new Vector2f(relativePos.x(), relativePos.y());
LOGGER.trace("SCROOL == > INIT");
return true;
} else if (event.status() == KeyStatus.upAfter) {
this.highSpeedMode = HighSpeedMode.speedModeDisable;
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();
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) {
if (event.type() == KeyType.mouse) {
float tmp1 = this.size.x() / this.maxSize.y();
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);
if (event.inputId() == 4 && event.status() == KeyStatus.up) {
this.zoom -= 0.1;
@ -397,13 +434,13 @@ class WidgetScrolled extends Widget {
}
}
} else if (this.scroollingMode == ScrollingMode.scroolModeGame) {
} else {
Log.error("Scrolling mode unknow ... " + this.scroollingMode);
LOGGER.error("Scrolling mode unknow ... " + this.scroollingMode);
}
return false;
}
@Override
public void onRegenerateDisplay() {
this.shaperH.clear();
@ -417,30 +454,35 @@ class WidgetScrolled extends Widget {
if (this.size.y() < this.maxSize.y() || this.originScrooled.y() != 0) {
float lenScrollBar = this.size.y() * this.size.y() / this.maxSize.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 *= (this.size.y() - lenScrollBar);
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0), new Vector2f(paddingVert.x(), this.size.y()),
new Vector2f(this.size.x() - paddingVert.right(), this.size.y() - originScrollBar - lenScrollBar), new Vector2f(0, lenScrollBar));
this.shaperV.setShape(new Vector2f(this.size.x() - paddingVert.x(), 0),
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) {
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()));
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 *= (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()),
new Vector2f(lenScrollBar, 0));
this.shaperH.setShape(new Vector2f(0, 0), new Vector2f(this.size.x() - paddingVert.x(), paddingHori.y()),
new Vector2f(originScrollBar, paddingHori.bottom()), new Vector2f(lenScrollBar, 0));
}
}
/**
* Reset the scoll of the subWidget
*/
public void resetScrollOrigin() {
this.originScrooled = new Vector2f(0, 0);
}
/**
* Specify the mode of scrolling for this windows
* @param newMode the selected mode for the scrolling...
@ -453,7 +495,7 @@ class WidgetScrolled extends Widget {
this.zoom = 1;
}
}
/**
* 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 ...
@ -462,15 +504,16 @@ class WidgetScrolled extends Widget {
poucentageLimit = FMath.avg(0.1f, poucentageLimit, 1.0f);
this.limitScrolling = new Vector2f(poucentageLimit, poucentageLimit);
}
/**
* 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...
*/
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
* @param localSize new Maximum size
@ -478,7 +521,7 @@ class WidgetScrolled extends Widget {
protected void setMaxSize(final Vector2f localSize) {
this.maxSize = localSize;
}
public void setPropertyShapeHori(final Uri value) {
if (this.propertyShapeHori.equals(value)) {
return;
@ -486,7 +529,7 @@ class WidgetScrolled extends Widget {
this.propertyShapeHori = value;
onChangePropertyShapeHori();
}
public void setPropertyShapeVert(final Uri value) {
if (this.propertyShapeVert.equals(value)) {
return;
@ -494,7 +537,7 @@ class WidgetScrolled extends Widget {
this.propertyShapeVert = value;
onChangePropertyShapeVert();
}
/**
* 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
@ -504,8 +547,11 @@ class WidgetScrolled extends Widget {
protected void setScrollingPositionDynamic(final Vector2f borderWidth, final Vector2f currentPosition) {
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) {
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()));
}
}
/**
* 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
@ -534,7 +580,7 @@ class WidgetScrolled extends Widget {
protected void setScrollingSize(final float nbPixel) {
this.pixelScrolling = nbPixel;
}
/**
* Set the single finger capabilities/
* @param status True if single inger mode, two otherwise/
@ -545,16 +591,18 @@ class WidgetScrolled extends Widget {
}
this.singleFingerMode = status;
}
@Override
public void systemDraw(final DrawProperty displayProp) {
OpenGL.push();
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
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 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);
// set internal matrix system :
OpenGL.setMatrix(tmpMat);
@ -564,8 +612,10 @@ class WidgetScrolled extends Widget {
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
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 tmpTranslate = Matrix4f.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -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 tmpTranslate = Matrix4f
.createMatrixTranslate(new Vector3f(-this.maxSize.x() / 2, -this.maxSize.y() / 2, -1));
final Matrix4f tmpMat = tmpProjection.multiply(tmpTranslate);
// set internal matrix system :
OpenGL.setMatrix(tmpMat);

View File

@ -21,20 +21,22 @@ import org.atriasoft.etk.math.Vector3i;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.compositing.CompositingDrawing;
import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.EwolObject;
import org.atriasoft.ewol.resource.ResourceColorFile;
import org.atriasoft.gale.backend3d.OpenGL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Windows basic interface
*/
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 List<Widget> popUpWidgetList = new ArrayList<>();
@AknotManaged
@AknotAttribute
@AknotName("file-color")
@ -45,20 +47,20 @@ public class Windows extends Widget {
@AknotName("title")
@AknotDescription("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 Widget subWidget;
// internal event at ewol system:
protected CompositingDrawing vectorialDraw = new CompositingDrawing();
protected Windows() {
this.propertyCanFocus = true;
onChangePropertyColor();
}
//!< List of pop-up displayed
@Override
public void drawWidgetTree(int level) {
@ -73,15 +75,15 @@ public class Windows extends Widget {
}
}
}
public Uri getPropertyColorConfiguration() {
return this.propertyColorConfiguration;
}
public String getPropertyTitle() {
return this.propertyTitle;
}
@Override
public EwolObject getSubObjectNamed(final String objectName) {
EwolObject tmpObject = super.getSubObjectNamed(objectName);
@ -107,10 +109,10 @@ public class Windows extends Widget {
// not find ...
return null;
}
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
Log.verbose("Get widget at pos : " + pos);
LOGGER.trace("Get widget at pos : " + pos);
// calculate relative position
final Vector3f relativePos = relativePosition(pos);
// event go directly on the pop-up
@ -124,16 +126,17 @@ public class Windows extends Widget {
// otherwise the event go to this widget ...
return this;
}
protected void onChangePropertyColor() {
this.resourceColor = ResourceColorFile.create(this.propertyColorConfiguration);
if (this.resourceColor != null) {
this.colorBg = this.resourceColor.request("background");
} 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
public void onChangeSize() {
super.onChangeSize();
@ -153,7 +156,7 @@ public class Windows extends Widget {
}
}
}
@Override
public void onRegenerateDisplay() {
if (this.subWidget != null) {
@ -165,7 +168,7 @@ public class Windows extends Widget {
}
}
}
/**
* Get the number of pop-up
* @return Count of pop-up
@ -173,7 +176,7 @@ public class Windows extends Widget {
public int popUpCount() {
return this.popUpWidgetList.size();
}
/**
* Remove the pop-up on top.
*/
@ -183,7 +186,7 @@ public class Windows extends Widget {
}
this.popUpWidgetList.remove(this.popUpWidgetList.size() - 1);
}
/**
* Add a pop-up on the Windows.
* @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) {
if (widget == null) {
// 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;
}
this.popUpWidgetList.add(widget);
@ -203,16 +206,16 @@ public class Windows extends Widget {
// TODO : it is dangerous to access directly to the system ...
EwolObject.getContext().resetIOEvent();
}
//!< main sub-widget of the Windows.
@Override
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();
while (it.hasNext()) {
final Widget elem = it.next();
if (elem == child) {
Log.verbose(" Find it ...");
LOGGER.trace(" Find it ...");
if (elem != null) {
elem.removeParent();
}
@ -222,7 +225,7 @@ public class Windows extends Widget {
}
}
if (this.subWidget == child) {
Log.verbose(" Find it ... 2");
LOGGER.trace(" Find it ... 2");
if (this.subWidget == null) {
return;
}
@ -231,7 +234,7 @@ public class Windows extends Widget {
markToRedraw();
}
}
public void setPropertyColorConfiguration(final Uri propertyColorConfiguration) {
if (this.propertyColorConfiguration.equals(propertyColorConfiguration)) {
return;
@ -239,7 +242,7 @@ public class Windows extends Widget {
this.propertyColorConfiguration = propertyColorConfiguration;
onChangePropertyColor();
}
public void setPropertyTitle(final String propertyTitle) {
if (this.propertyTitle.contentEquals(propertyTitle)) {
return;
@ -249,17 +252,17 @@ public class Windows extends Widget {
if (context.getWindows() == this) {
context.setTitle(propertyTitle);
} else {
Log.info("Set title is delayed ...");
LOGGER.info("Set title is delayed ...");
}
}
/**
* Set the main widget of the application.
* @param widget Widget to set in the windows.
*/
public void setSubWidget(final Widget widget) {
if (this.subWidget != null) {
Log.info("Remove current main windows Widget...");
LOGGER.info("Remove current main windows Widget...");
this.subWidget.removeParent();
this.subWidget = null;
}
@ -270,9 +273,9 @@ public class Windows extends Widget {
// Regenerate the size calculation :
onChangeSize();
}
public void sysDraw() {
//Log.verbose("Draw on " + this.size);
//LOGGER.trace("Draw on " + this.size);
// set the size of the open GL system
OpenGL.setViewPort(Vector3f.ZERO, this.size);
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_depthTest);
OpenGL.disable(OpenGL.Flag.flag_cullFace);
OpenGL.enable(OpenGL.Flag.flag_blend);
//OpenGL.enable(OpenGL.Flag.flag_cullFace);
OpenGL.blendFuncAuto();
// clear the matrix system :
OpenGL.setBasicMatrix(Matrix4f.IDENTITY);
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);
OpenGL.disable(OpenGL.Flag.flag_blend);
}
@Override
public void systemDraw(final DrawProperty displayProp) {
super.systemDraw(displayProp);
@ -308,19 +311,19 @@ public class Windows extends Widget {
OpenGL.clearColor(Color.PURPLE);
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
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
if (this.subWidget != null) {
this.subWidget.systemDraw(displayProp);
//Log.debug("Draw Windows");
//LOGGER.debug("Draw Windows");
}
// second display the pop-up
for (final Widget it : this.popUpWidgetList) {
if (it != null) {
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.SignalEmpty;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.CheckBox;
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.Label;
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 ...
*
*
* 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:
* [code style=c++]
* package org.atriasoft.ewol.widget.meta.FileChooser;
* [/code]
*
*
* The first step is to create the file chooser pop-up : (never in the ructor!!!)
* [code style=c++]
* ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create();
@ -59,9 +60,9 @@ import org.atriasoft.ewol.widget.ListFileSystem;
* }
* tmpWindows.popUpWidgetPush(tmpWidget);
* [/code]
*
*
* Now we just need to wait the the open event message.
*
*
* [code style=c++]
* void ****::onCallbackOpenFile( String _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.
*/
public class FileChooser extends Composer {
private static final Logger LOGGER = LoggerFactory.getLogger(FileChooser.class);
static void onCallbackButtonCancelPressed(final FileChooser self, final Boolean value) {
if (!value) {
return;
@ -82,43 +84,46 @@ public class FileChooser extends Composer {
self.signalCancel.emit();
self.autoDestroy();
}
protected static void onCallbackEntryFileChangeValidate(final FileChooser self, final String value) {
onCallbackListFileValidate(self, value);
}
protected static void onCallbackEntryFileChangeValue(final FileChooser self, final String value) {
// == > change the file name.get(.get(
self.propertyFile = value;
// 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));
}
}
protected static void onCallbackEntryFolderChangeValue(final FileChooser self, final String value) {
// == > change the folder name
// TODO : change the folder, if it exit ...
}
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);
}
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);
}
}
protected static void onCallbackHomePressed(final FileChooser self) {
final String tmpUserFolder = System.getProperty("user.home");
Log.debug("new PATH: '" + tmpUserFolder + "'");
LOGGER.debug("new PATH: '" + tmpUserFolder + "'");
self.propertyPath = tmpUserFolder;
self.propertyFile = "";
self.updateCurrentFolder();
}
protected static void onCallbackListFileSelectChange(final FileChooser self, final String value) {
self.setPropertyFile(value);
/*
@ -127,55 +132,55 @@ public class FileChooser extends Composer {
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
*/
}
protected static void onCallbackListFileValidate(final FileChooser self, final String value) {
// select the file == > generate a validate
self.setPropertyFile(value);
Log.verbose(" generate a fiel opening : '" + self.propertyFile + "'");
LOGGER.trace(" generate a fiel opening : '" + self.propertyFile + "'");
self.signalValidate.emit(value);
self.autoDestroy();
}
protected static void onCallbackListFolderSelectChange(final FileChooser self, final String value) {
// == > this is an internal event ...
Log.debug(" old PATH: '" + self.propertyPath + "' ==> '" + value + "'");
LOGGER.debug(" old PATH: '" + self.propertyPath + "' ==> '" + value + "'");
self.propertyPath = value;
Log.debug("new PATH: '" + self.propertyPath + "'");
LOGGER.debug("new PATH: '" + self.propertyPath + "'");
self.propertyFile = "";
self.updateCurrentFolder();
}
protected static void onCallbackListValidate(final FileChooser self, final Boolean value) {
if (!value) {
return;
}
if (self.propertyFile.isEmpty()) {
Log.warning(" Validate : '" + self.propertyFile + "' ==> error No name ...");
LOGGER.warn(" Validate : '" + self.propertyFile + "' ==> error No name ...");
return;
}
Log.debug(" generate a file opening : '" + self.propertyFile + "'");
LOGGER.debug(" generate a file opening : '" + self.propertyFile + "'");
self.signalValidate.emit(self.propertyFile);
self.autoDestroy();
}
@AknotSignal
@AknotName(value = "cancel")
@AknotDescription(value = "Cancel button is pressed")
public SignalEmpty signalCancel; //!< abort the display of the pop-up or press cancel button
@AknotSignal
@AknotName(value = "validate")
@AknotDescription(value = "Validate button is pressed")
public Signal<String> signalValidate; //!< select file(s)
// properties
public String propertyPath = System.getProperty("user.home"); //!< Current path to explore
public String propertyFile = ""; //!< Selected file
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 propertyLabelCancel = "_T{Cancel}"; //!< Label of cancel/close button of the pop-up (can use translation)
public FileChooser() {
// 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"));
@ -183,88 +188,96 @@ public class FileChooser extends Composer {
onChangePropertyLabelTitle();
onChangePropertyLabelValidate();
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);
}
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);
}
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);
}
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);
}
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.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.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);
}
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);
}
// set the default Folder properties:
updateCurrentFolder();
setPropertyCanFocus(true);
}
public String getPropertyFile() {
return this.propertyFile;
}
public String getPropertyLabelCancel() {
return this.propertyLabelCancel;
}
// callback functions:
public String getPropertyLabelTitle() {
return this.propertyLabelTitle;
}
public String getPropertyLabelValidate() {
return this.propertyLabelValidate;
}
public String getPropertyPath() {
return this.propertyPath;
}
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));
}
}
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);
}
}
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);
}
}
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);
}
}
protected void onChangePropertyPath() {
this.propertyPath = this.propertyPath + "/";
updateCurrentFolder();
}
@Override
public void onGetFocus() {
// transfert focus on a specific widget...
@ -272,7 +285,7 @@ public class FileChooser extends Composer {
tmp.keepFocus();
}
}
@AknotManaged
@AknotAttribute
@AknotName(value = "file")
@ -283,7 +296,7 @@ public class FileChooser extends Composer {
this.propertyFile = propertyFile;
onChangePropertyFile();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "label-cancel")
@ -295,7 +308,7 @@ public class FileChooser extends Composer {
this.propertyLabelCancel = propertyLabelCancel;
onChangePropertyLabelCancel();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "title")
@ -307,7 +320,7 @@ public class FileChooser extends Composer {
this.propertyLabelTitle = propertyLabelTitle;
onChangePropertyLabelTitle();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "label-validate")
@ -319,7 +332,7 @@ public class FileChooser extends Composer {
this.propertyLabelValidate = propertyLabelValidate;
onChangePropertyLabelValidate();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "path")
@ -331,12 +344,14 @@ public class FileChooser extends Composer {
this.propertyPath = propertyPath;
onChangePropertyPath();
}
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);
}
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);
}
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.math.Vector3b;
import org.atriasoft.ewol.Gravity;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.resource.ResourceConfigFile;
import org.atriasoft.ewol.widget.Button;
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.Widget;
import org.atriasoft.ewol.widget.model.SpinPosition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @ingroup ewolWidgetGroup
*/
public class SpinBase extends Sizer {
private static final Logger LOGGER = LoggerFactory.getLogger(SpinBase.class);
// properties list:
private Uri propertyShape; //!< Shape of the widget
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 confIdUpData = -1;
protected int confIdDownData = -1;
protected Entry widgetEntry = null;
protected Button widgetButtonDown = null;
protected Button widgetButtonUp = null;
/**
* Constructor
*/
@ -52,7 +54,7 @@ public class SpinBase extends Sizer {
setPropertyGravity(Gravity.CENTER);
updateGui();
}
@AknotManaged
@AknotAttribute
@AknotName(value = "shape")
@ -60,7 +62,7 @@ public class SpinBase extends Sizer {
public Uri getPropertyShape() {
return this.propertyShape;
}
@AknotManaged
@AknotAttribute
@AknotName(value = "spin-mode")
@ -68,7 +70,7 @@ public class SpinBase extends Sizer {
public SpinPosition getPropertySpinMode() {
return this.propertySpinMode;
}
protected void onChangePropertyShape() {
this.config = ResourceConfigFile.create(this.propertyShape);
if (this.config != null) {
@ -80,11 +82,11 @@ public class SpinBase extends Sizer {
}
markToRedraw();
}
protected void onChangePropertySpinMode() {
updateGui();
}
public void setPropertyShape(final Uri propertyShape) {
if (this.propertyShape != null && this.propertyShape.equals(propertyShape)) {
return;
@ -92,7 +94,7 @@ public class SpinBase extends Sizer {
this.propertyShape = propertyShape;
onChangePropertyShape();
}
public void setPropertySpinMode(final SpinPosition propertySpinMode) {
if (this.propertySpinMode == propertySpinMode) {
return;
@ -100,7 +102,7 @@ public class SpinBase extends Sizer {
this.propertySpinMode = propertySpinMode;
onChangePropertySpinMode();
}
protected void updateGui() {
subWidgetRemoveAll();
markToRedraw();
@ -109,7 +111,7 @@ public class SpinBase extends Sizer {
this.widgetEntry = new Entry();
if (this.config != null) {
final String shaper = this.config.getString(this.confIdEntryShaper);
Log.verbose("shaper entry : " + shaper);
LOGGER.trace("shaper entry : " + shaper);
if (!shaper.isEmpty()) {
this.widgetEntry.setPropertyConfig(Uri.valueOf(shaper));
}
@ -121,7 +123,7 @@ public class SpinBase extends Sizer {
this.widgetButtonDown = new Button();
if (this.config != null) {
final String shaper = this.config.getString(this.confIdDownShaper);
Log.verbose("shaper button DOWN : " + shaper);
LOGGER.trace("shaper button DOWN : " + shaper);
if (!shaper.isEmpty()) {
this.widgetButtonDown.setPropertyConfig(Uri.valueOf(shaper));
}
@ -136,7 +138,7 @@ public class SpinBase extends Sizer {
this.widgetButtonUp = new Button();
if (this.config != null) {
final String shaper = this.config.getString(this.confIdUpShaper);
Log.verbose("shaper button UP : " + shaper);
LOGGER.trace("shaper button UP : " + shaper);
if (!shaper.isEmpty()) {
this.widgetButtonUp.setPropertyConfig(Uri.valueOf(shaper));
}
@ -178,5 +180,5 @@ public class SpinBase extends Sizer {
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;
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.Order;
import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(OrderAnnotation.class)
public class TestBasicLog {
@Test
@Order(1)
public void aaFirstInitialisation() {
List<String> args = new ArrayList<>();
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);
// basic kanva
}
@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();
}
}