diff --git a/old_widget/Gird.cpp b/old_widget/Gird.cpp deleted file mode 100644 index 6c7e7d2..0000000 --- a/old_widget/Gird.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include -#include -#include - -#include -ETK_DECLARE_TYPE(ewol::widget::Gird); - -ewol::widget::Gird::Gird() : - this.sizeRow(0), - this.tmpWidget(null), - this.gavityButtom(true), - this.borderSize(0,0) { - addObjectType("ewol::widget::Gird"); - requestUpdateSize(); -} - -ewol::widget::Gird::~Gird() { - Log.debug("[" + getId() + "]={" + getObjectType() + "} Gird : destroy"); - subWidgetRemoveAll(); -} - -void ewol::widget::Gird::setBorderSize( Vector2i _newBorderSize) { - this.borderSize = _newBorderSize; - if (this.borderSize.x() < 0) { - Log.error("Try to set a border size <0 on x : " + this.borderSize.x() + " == > restore to 0"); - this.borderSize.setX(0); - } - if (this.borderSize.y() < 0) { - Log.error("Try to set a border size <0 on y : " + this.borderSize.y() + " == > restore to 0"); - this.borderSize.setY(0); - } - markToRedraw(); - requestUpdateSize(); -} - -void ewol::widget::Gird::onChangeSize() { - //Log.debug("Update size"); - this.size -= this.borderSize*2; - - for (int iii=0; iii lastLineID) { - // change of line : - lastLineID = this.subWidget[iii].row; - } - if (this.subWidget[iii].widget != null) { - this.subWidget[iii].widget.calculateMinMaxSize(); - Vector2f tmpSize = this.subWidget[iii].widget.getCalculateMinSize(); - Log.debug(" [" + iii + "] subWidgetMinSize=" + tmpSize); - // for all we get the max size : - this.uniformSizeRow = etk::max((int)tmpSize.y(), this.uniformSizeRow); - // for the colomn size : We set the autamatic value in negative : - if (this.sizeCol[this.subWidget[iii].col] <= 0) { - this.sizeCol[this.subWidget[iii].col] = etk::min(this.sizeCol[this.subWidget[iii].col], (int)-tmpSize.x() ); - } - } - } - - if (this.sizeRow > 0) { - this.uniformSizeRow = this.sizeRow; - } - int tmpSizeWidth = 0; - for (int iii=0; iii it is not the case ==> the herited class must call the \"OnObjectRemove\" function..."); - } - } else { - Log.warning("[" + getId() + "] Must not have null pointer on the subWidget list ..."); - this.subWidget.erase(this.subWidget.begin()+iii); - } - errorControl = this.subWidget.size(); - } - } - // just add the col size: - this.sizeCol.erase(this.sizeCol.end()); - } else { - // just add the col size: - for (int iii=this.sizeCol.size()-1; iii<_colNumber-1 ; iii++) { - this.sizeCol.pushBack(0); - } - } -} - -void ewol::widget::Gird::setColSize(int _colId, int _size) { - if ((long)this.sizeCol.size() > _colId) { - this.sizeCol[_colId] = _size; - } else { - Log.error("Can not set the Colomn size : " + _colId+1 - + " at " + _size + "px we have " - + this.sizeCol.size() + " colomn"); - } -} - -void ewol::widget::Gird::setRowSize(int _size) { - this.sizeRow = _size; -} - -int ewol::widget::Gird::getColSize(int _colId) { - if ((long)this.sizeCol.size() > _colId) { - if (this.sizeCol[_colId] <= 0) { - return 0; - } - return this.sizeCol[_colId]; - } - Log.error("Can not get the Colomn size : " + _colId+1 + " we have "+ this.sizeCol.size() + " colomn"); - return 0; -} - -int ewol::widget::Gird::getRowSize() { - return this.sizeRow; -} - -void ewol::widget::Gird::subWidgetRemoveAll() { - int errorControl = this.subWidget.size(); - this.subWidget.clear(); -} - - -void ewol::widget::Gird::subWidgetAdd(int _colId, int _rowId, Widget _newWidget) { - if (_newWidget == null) { - return; - } - GirdProperties prop; - prop.row = _rowId; - prop.col = _colId; - prop.widget = _newWidget; - - // need to find the correct position : - for (int iii=0; iii prop.row) { - // find a new position; - this.subWidget.insert(this.subWidget.begin()+iii, prop); - return; - } else { - if (this.subWidget[iii].col < prop.col) { - continue; - } else if (this.subWidget[iii].col > prop.col) { - // find a new position; - this.subWidget.insert(this.subWidget.begin()+iii, prop); - return; - } else { - // The element already exist == > replace it ... - this.tmpWidget = this.subWidget[iii].widget; - this.subWidget[iii].widget = _newWidget; - if (this.tmpWidget != null) { - this.tmpWidget.reset(); - if (this.tmpWidget != null) { - Log.critical("[" + getId() + "] Error while replacing a widget ... == > never call when free"); - this.tmpWidget = null; - } - } - } - } - } - // not find == > just adding it ... - this.subWidget.pushBack(prop); -} - -void ewol::widget::Gird::subWidgetRemove(Widget _newWidget) { - for (int iii=0; iii= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { - Widget tmpWidget = it.widget.getWidgetAtPos(_pos); - if (tmpWidget != null) { - return tmpWidget; - } - // stop searching - break; - } - } - return null; -} - diff --git a/old_widget/Gird.java b/old_widget/Gird.java index 5d3da76..b258a62 100644 --- a/old_widget/Gird.java +++ b/old_widget/Gird.java @@ -1,146 +1,420 @@ -/** @file +/* * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ -#pragma once +package org.atriasoft.ewol.widget; -#include -#include -#include -#include -#include +import java.io.File; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; -namespace ewol { - namespace widget { - class Gird; - using Gird = ememory::Ptr; - using GirdWeak = ememory::WeakPtr; - /** - * @ingroup ewolWidgetGroup - */ - class Gird :public Widget { - private: - class GirdProperties { - public: - Widget widget; - int row; - int col; - }; - int this.sizeRow; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ... - int this.uniformSizeRow; - List this.sizeCol; //!< size of all colomn (if set (otherwise 0)) - List this.subWidget; //!< all sub widget are contained in this element - Widget this.tmpWidget; //!< use when replace a widget ... - boolean this.gavityButtom; - protected: - /** - * Constructor - */ - Gird(); - public: - DECLARE_WIDGET_FACTORY(Gird, "Gird"); - /** - * Desstructor - */ - ~Gird(); - /** - * set the number of colomn - * @param colNumber Nuber of colomn - */ - void setColNumber(int _colNumber); - /** - * change a size view of a colomn. - * @param colId Id of the colomn [0..x]. - * @param size size of the colomn. - */ - void setColSize(int _colId, int _size); - /** - * change a size view of a line. - * @param size size of the line. - */ - void setRowSize(int _size); - /** - * get the size view of a colomn. - * @param colId Id of the colomn [0..x]. - * @return The size of the colomn. - */ - int getColSize(int _colId); - /** - * get the size view of the lines. - * @return The size of the lines. - */ - int getRowSize(); - /** - * set the gravity of the widget on the Button (index 0 is on buttom) - */ - void setGravityButtom() { - this.gavityButtom = true; - markToRedraw(); - } - /** - * set the gravity of the widget on the Top (index 0 is on top) - */ - void setGravityTop() { - this.gavityButtom = false; - markToRedraw(); - } - public: - /** - * remove all sub element from the widget. - */ - void subWidgetRemoveAll(); - /** - * add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) - * @param _colId Id of the colomn [0..x]. - * @param _rowId Id of the row [0..y]. - * @param _newWidget the element pointer - */ - void subWidgetAdd(int _colId, int _rowId, Widget _newWidget); - /** - * remove definitly a widget from the system and this Gird. - * @param _newWidget the element pointer. - */ - void subWidgetRemove(Widget _newWidget); - /** - * remove definitly a widget from the system and this Gird. - * @param _colId Id of the colomn [0..x]. - * @param _rowId Id of the row [0..y]. - */ - void subWidgetRemove(int _colId, int _rowId); - /** - * Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). - * @param _newWidget the element pointer. - */ - void subWidgetUnLink(Widget _newWidget); - /** - * Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). - * @param _colId Id of the colomn [0..x]. - * @param _rowId Id of the row [0..y]. - */ - void subWidgetUnLink(int _colId, int _rowId); - private: - // TODO : property - Vector2i this.borderSize; //!< Border size needed for all the display - public: - /** - * set the current border size of the current element: - * @param _newBorderSize The border size to set (0 if not used) - */ - void setBorderSize( Vector2i _newBorderSize); - /** - * get the current border size of the current element: - * @return the border size (0 if not used) - */ - Vector2i getBorderSize() { - return this.borderSize; - }; - public: - void systemDraw( ewol::DrawProperty _displayProp) ; - void onRegenerateDisplay() ; - Widget getWidgetAtPos( Vector2f pos) ; - void onChangeSize() ; - void calculateMinMaxSize() ; +import org.atriasoft.esignal.Signal; +import org.atriasoft.etk.Color; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector2f; +import org.atriasoft.etk.math.Vector2i; +import org.atriasoft.etk.math.Vector3f; +import org.atriasoft.etk.math.Vector3i; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.annotation.EwolSignal; +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.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; +import org.atriasoft.gale.key.KeyStatus; + +/** + * @ingroup ewolWidgetGroup + */ +class Gird extends Widget { + protected class GirdProperties { + public Widget widget; + public int row; + public int col; }; - }; -}; + protected int sizeRow = 0; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ... + protected int uniformSizeRow = 0; + protected List sizeCol = new ArrayList<>(); //!< size of all colomn (if set (otherwise 0)) + protected List subWidget = new ArrayList<>(); //!< all sub widget are contained in this element + protected Widget tmpWidget = null; //!< use when replace a widget ... + protected boolean gavityButtom = true; + /** + * Constructor + */ + public Gird() { + this.borderSize = _newBorderSize; + if (this.borderSize.x() < 0) { + Log.error("Try to set a border size <0 on x : " + this.borderSize.x() + " == > restore to 0"); + this.borderSize.setX(0); + } + if (this.borderSize.y() < 0) { + Log.error("Try to set a border size <0 on y : " + this.borderSize.y() + " == > restore to 0"); + this.borderSize.setY(0); + } + markToRedraw(); + requestUpdateSize(); + } + /** + * set the number of colomn + * @param colNumber Nuber of colomn + */ + public void setColNumber(int _colNumber) { + if ((long)this.sizeCol.size() > _colNumber) { + int errorControl = this.subWidget.size(); + // remove subWidget : + for (long iii=this.subWidget.size(); iii >= 0; iii--) { + if (this.subWidget[iii].col > (_colNumber-1)) { + // out of bounds : must remove it ... + if (this.subWidget[iii].widget != null) { + this.subWidget[iii].widget.reset(); + // 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..."); + } + } else { + Log.warning("[" + getId() + "] Must not have null pointer on the subWidget list ..."); + this.subWidget.erase(this.subWidget.begin()+iii); + } + errorControl = this.subWidget.size(); + } + } + // just add the col size: + this.sizeCol.erase(this.sizeCol.end()); + } else { + // just add the col size: + for (int iii=this.sizeCol.size()-1; iii<_colNumber-1 ; iii++) { + this.sizeCol.pushBack(0); + } + } + } + /** + * change a size view of a colomn. + * @param colId Id of the colomn [0..x]. + * @param size size of the colomn. + */ + public void setColSize(int _colId, int _size) { + if ((long)this.sizeCol.size() > _colId) { + this.sizeCol[_colId] = _size; + } else { + Log.error("Can not set the Colomn size : " + _colId+1 + + " at " + _size + "px we have " + + this.sizeCol.size() + " colomn"); + } + } + + /** + * change a size view of a line. + * @param size size of the line. + */ + public void setRowSize(int _size){ + this.sizeRow = _size; + } + /** + * get the size view of a colomn. + * @param colId Id of the colomn [0..x]. + * @return The size of the colomn. + */ + public int getColSize(int _colId) { + if ((long)this.sizeCol.size() > _colId) { + if (this.sizeCol[_colId] <= 0) { + return 0; + } + return this.sizeCol[_colId]; + } + Log.error("Can not get the Colomn size : " + _colId+1 + " we have "+ this.sizeCol.size() + " colomn"); + return 0; + } + /** + * get the size view of the lines. + * @return The size of the lines. + */ + public int getRowSize(){ + return this.sizeRow; + } + /** + * set the gravity of the widget on the Button (index 0 is on buttom) + */ + public void setGravityButtom() { + this.gavityButtom = true; + markToRedraw(); + } + /** + * set the gravity of the widget on the Top (index 0 is on top) + */ + public void setGravityTop() { + this.gavityButtom = false; + markToRedraw(); + } + /** + * remove all sub element from the widget. + */ + public void subWidgetRemoveAll() { + int errorControl = this.subWidget.size(); + this.subWidget.clear(); + } + /** + * add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) + * @param _colId Id of the colomn [0..x]. + * @param _rowId Id of the row [0..y]. + * @param _newWidget the element pointer + */ + public void subWidgetAdd(int _colId, int _rowId, Widget _newWidget){ + if (_newWidget == null) { + return; + } + GirdProperties prop; + prop.row = _rowId; + prop.col = _colId; + prop.widget = _newWidget; + + // need to find the correct position : + for (int iii=0; iii prop.row) { + // find a new position; + this.subWidget.insert(this.subWidget.begin()+iii, prop); + return; + } else { + if (this.subWidget[iii].col < prop.col) { + continue; + } else if (this.subWidget[iii].col > prop.col) { + // find a new position; + this.subWidget.insert(this.subWidget.begin()+iii, prop); + return; + } else { + // The element already exist == > replace it ... + this.tmpWidget = this.subWidget[iii].widget; + this.subWidget[iii].widget = _newWidget; + if (this.tmpWidget != null) { + this.tmpWidget.reset(); + if (this.tmpWidget != null) { + Log.critical("[" + getId() + "] Error while replacing a widget ... == > never call when free"); + this.tmpWidget = null; + } + } + } + } + } + // not find == > just adding it ... + this.subWidget.pushBack(prop); + } + /** + * remove definitly a widget from the system and this Gird. + * @param _newWidget the element pointer. + */ + public void subWidgetRemove(Widget _newWidget){ + for (int iii=0; iii= _pos.x()) + && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { + Widget tmpWidget = it.widget.getWidgetAtPos(_pos); + if (tmpWidget != null) { + return tmpWidget; + } + // stop searching + break; + } + } + return null; + } + public void onChangeSize() { + //Log.debug("Update size"); + this.size -= this.borderSize*2; + + for (int iii=0; iii lastLineID) { + // change of line : + lastLineID = this.subWidget[iii].row; + } + if (this.subWidget[iii].widget != null) { + this.subWidget[iii].widget.calculateMinMaxSize(); + Vector2f tmpSize = this.subWidget[iii].widget.getCalculateMinSize(); + Log.debug(" [" + iii + "] subWidgetMinSize=" + tmpSize); + // for all we get the max size : + this.uniformSizeRow = etk::max((int)tmpSize.y(), this.uniformSizeRow); + // for the colomn size : We set the autamatic value in negative : + if (this.sizeCol[this.subWidget[iii].col] <= 0) { + this.sizeCol[this.subWidget[iii].col] = etk::min(this.sizeCol[this.subWidget[iii].col], (int)-tmpSize.x() ); + } + } + } + + if (this.sizeRow > 0) { + this.uniformSizeRow = this.sizeRow; + } + int tmpSizeWidth = 0; + for (int iii=0; iii 1.0) { - this.distance = 1.0; - // regenerate n ew display position : - this.displayPos.x = cos(this.angle)*this.distance; - this.displayPos.y = sin(this.angle)*this.distance; - } - markToRedraw(); - if(KeyStatus::down == typeEvent) { - signalEnable.emit(); - } else { - String tmp = String("distance=") + String(this.distance) + String("angle=") + String(this.angle+M_PI/2); - signalMove.emit(this.angle+M_PI/2); - } - //teta += M_PI/2; - //Log.debug("TETA = " + (this.angle*180/M_PI) + " deg distance = " + this.distance); - return true; - } else if( KeyStatus::up == typeEvent) { - if( true == this.lock - LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.distance == 1) { - // nothing to do ... - } else { - this.displayPos.x = 0.0; - this.displayPos.y = 0.0; - this.angle = -0.1; - this.distance = 0; - } - markToRedraw(); - signalDisable.emit(); - return true; - } - return false; - } - */ - return false; -} - - -void ewol::widget::Joystick::ratio(float _newRatio) { - if (_newRatio > 1) { - _newRatio = 1; - } - this.ratio = _newRatio; - Log.info("Set default Joystick ratio at " + this.ratio); -} - - -void ewol::widget::Joystick::background(String _imageNameInData, boolean _display) { - // TODO : check if it existed - this.background = _imageNameInData; - this.displayBackground = _display; - Log.info("Set default Joystick background at " + this.background + " display it=" + this.displayBackground); -} - - -void ewol::widget::Joystick::foreground(String imageNameInData) { - // TODO : check if it existed - this.foreground = imageNameInData; - Log.info("Set default Joystick Foreground at " + this.foreground); -} - - -void ewol::widget::Joystick::getProperty(float distance, float angle) { - distance = this.distance; - angle = this.angle+M_PI/2; -} - - diff --git a/old_widget/Joystick.java b/old_widget/Joystick.java index 94b3881..c85acc9 100644 --- a/old_widget/Joystick.java +++ b/old_widget/Joystick.java @@ -1,90 +1,214 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) +package org.atriasoft.ewol.widget; + +import org.atriasoft.esignal.Connection; +import org.atriasoft.esignal.Signal; +import org.atriasoft.esignal.SignalEmpty; +import org.atriasoft.etk.Color; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector3b; +import org.atriasoft.etk.math.Vector3f; +import org.atriasoft.ewol.Gravity; +import org.atriasoft.ewol.Padding; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.annotation.EwolSignal; +import org.atriasoft.ewol.compositing.GuiShape; +import org.atriasoft.ewol.compositing.GuiShapeMode; +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.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeyStatus; + +/** + * @ingroup ewolWidgetGroup */ -#pragma once - -#include -#include -#include -#include -#include - -// TODO : Rework ==> use property and shaper ... - -namespace ewol { - namespace widget { - class Joystick; - using Joystick = ememory::Ptr; - using JoystickWeak = ememory::WeakPtr; - /** - * @ingroup ewolWidgetGroup - */ - class Joystick :public Widget { - public: - // Event list of properties - esignal::Signal<> signalEnable; - esignal::Signal<> signalDisable; - esignal::Signal signalMove; - public: - enum joystickMode { - modeNormal, - modeArrow, - }; - private: - etk::Color<> this.colorFg; //!< Forground color - etk::Color<> this.colorBg; //!< Background color - Vector2f this.displayPos; //!< direction of the cursor ... - float this.distance; //!< dintance from the center - float this.angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ... - boolean this.lock; //!< flag to mark the lock when the cursor is free when we are outside the circle - enum joystickMode this.displayMode; //!< Type of fonctionnal mode of the joystick - private: - // generic property of the joystick: - boolean this.displayBackground; - String this.background; - String this.foreground; - float this.ratio; - protected: - Joystick(); - public: - DECLARE_WIDGET_FACTORY(Joystick, "Joystick"); - ~Joystick(); - public: - void setLockMode(boolean _lockWhenOut) { - this.lock = _lockWhenOut; - }; - void setDisplayMode(enum joystickMode _newMode) { - this.displayMode = _newMode; - }; - /** - * set the ratio of the widget joystick - * @param _newRatio the new ratio that might be set - */ - void ratio(float _newRatio); - /** - * set the Background of the widget joystick - * @param _imageNameInData the new rbackground that might be set - * @param _display - */ - void background(String _imageNameInData, boolean _display=true); - /** - * set the Foreground of the widget joystick - * @param _imageNameInData the new Foreground that might be set - */ - void foreground(String _imageNameInData); - /** - * get the property of the joystick - * @param _distance distance to the center - * @param _angle angle of the joy - */ - void getProperty(float _distance, float _angle); - - public: - void onRegenerateDisplay() ; - boolean onEventInput( ewol::event::Input _event) ; - }; +class Joystick extends Widget { + private static boolean l_displayBackground(true); + private static String l_background(""); + private static String l_foreground(""); + private static float l_ratio(1.0/7.0); + // Event list of properties + @EwolSignal(name = "enable") + public SignalEmpty signalEnable = new SignalEmpty(); + @EwolSignal(name = "disable") + public SignalEmpty signalDisable = new SignalEmpty(); + @EwolSignal(name = "move") + public Signal signalMove = new Signal<>(); + public enum joystickMode { + modeNormal, + modeArrow, }; -}; + + private Color colorFg = Color.BLUE.withA(0x3F); //!< Forground color + private Color colorBg = Color.BLACK; //!< Background color + private Vector2f displayPos = Vector2f.ZERO; //!< direction of the cursor ... + private float distance = 0.0f; //!< dintance from the center + private float angle = -0.1f; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ... + private boolean lock = false; //!< flag to mark the lock when the cursor is free when we are outside the circle + private enum joystickMode displayMode = joystickMode.modeNormal; //!< Type of fonctionnal mode of the joystick + // generic property of the joystick: + private boolean displayBackground= l_displayBackground; + private String background = l_background; + private String foreground = l_foreground; + private float ratio = l_ratio; + public Joystick() { + + } + public void setLockMode(boolean _lockWhenOut) { + this.lock = _lockWhenOut; + }; + public void setDisplayMode(enum joystickMode _newMode) { + this.displayMode = _newMode; + }; + /** + * set the ratio of the widget joystick + * @param _newRatio the new ratio that might be set + */ + public void ratio(float _newRatio) { + if (_newRatio > 1) { + _newRatio = 1; + } + this.ratio = _newRatio; + Log.info("Set default Joystick ratio at " + this.ratio); + } + /** + * set the Background of the widget joystick + * @param _imageNameInData the new rbackground that might be set + * @param _display + */ + public void background(String _imageNameInData, boolean _display=true) { + // TODO : check if it existed + this.background = _imageNameInData; + this.displayBackground = _display; + Log.info("Set default Joystick background at " + this.background + " display it=" + this.displayBackground); + } + /** + * set the Foreground of the widget joystick + * @param _imageNameInData the new Foreground that might be set + */ + public void foreground(String _imageNameInData) { + // TODO : check if it existed + this.foreground = imageNameInData; + Log.info("Set default Joystick Foreground at " + this.foreground); + } + /** + * get the property of the joystick + * @param _distance distance to the center + * @param _angle angle of the joy + */ + public void getProperty(float _distance, float _angle) { + distance = this.distance; + angle = this.angle+M_PI/2; + } + + public void onRegenerateDisplay() { + if (needRedraw() == true) { + // clean the object list ... + + /* + ewol::OObject2DColored * tmpOObjects = null; + ewol::OObject2DTextured * tmpOOtexBg = null; + ewol::OObject2DTextured * tmpOOtexFg = null; + // set background + if (true == this.displayBackground) { + if (this.background == "") { + tmpOObjects = ne w ewol::OObject2DColored; + tmpOObjects.setColor(this.colorBg); + tmpOObjects.Disc( this.size.x/2, this.size.y/2, this.size.x/2-1); + } else { + tmpOOtexBg = n ew ewol::OObject2DTextured(this.background, this.size.x, this.size.y); + tmpOOtexBg.rectangle(0, 0, this.size.x, this.size.y); + } + } + // set cursor point + float sizeElement = this.size.x*this.ratio; + if (this.foreground == "") { + if (null == tmpOObjects) { + tmpOObjects = ne w ewol::OObject2DColored; + } + tmpOObjects.setColor(this.colorFg); + tmpOObjects.Disc( ((this.displayPos.x+1.0)/2.0)*(this.size.x-2*sizeElement) + sizeElement, + ((this.displayPos.y+1.0)/2.0)*(this.size.y-2*sizeElement) + sizeElement, sizeElement); + } else { + tmpOOtexFg = ne w ewol::OObject2DTextured(this.foreground,sizeElement*2, sizeElement*2); + tmpOOtexFg.rectangle(((this.displayPos.x+1.0)/2.0)*(this.size.x-2*sizeElement), + ((this.displayPos.y+1.0)/2.0)*(this.size.y-2*sizeElement), sizeElement*2, sizeElement*2); + } + // add all needed objects ... + if (null != tmpOObjects) { + addOObject(tmpOObjects); + } + if (null != tmpOOtexBg) { + addOObject(tmpOOtexBg); + } + if (null != tmpOOtexFg) { + addOObject(tmpOOtexFg); + } + */ + } + } + public boolean onEventInput( ewol::event::Input _event) { + /* + if (1 == IdInput) { + if( KeyStatus::down == typeEvent + || KeyStatus::move == typeEvent) { + // get local relative position + Vector2f relativePos = relativePosition(pos); + float sizeElement = this.size.x*this.ratio; + // calculate the position of the cursor... + this.displayPos.x = (relativePos.x-sizeElement)/(this.size.x-sizeElement*2)*2.0 - 1.0; + this.displayPos.y = (relativePos.y-sizeElement)/(this.size.y-sizeElement*2)*2.0 - 1.0; + + // distance : + this.distance = this.displayPos.y*this.displayPos.y + this.displayPos.x * this.displayPos.x; + this.distance = sqrt(this.distance); + // angle : + this.angle = atan(this.displayPos.y/this.displayPos.x); + if (this.displayPos.x < 0) { + this.angle += M_PI; + } + + // clip if needed ... + if (this.distance > 1.0) { + this.distance = 1.0; + // regenerate n ew display position : + this.displayPos.x = cos(this.angle)*this.distance; + this.displayPos.y = sin(this.angle)*this.distance; + } + markToRedraw(); + if(KeyStatus::down == typeEvent) { + signalEnable.emit(); + } else { + String tmp = String("distance=") + String(this.distance) + String("angle=") + String(this.angle+M_PI/2); + signalMove.emit(this.angle+M_PI/2); + } + //teta += M_PI/2; + //Log.debug("TETA = " + (this.angle*180/M_PI) + " deg distance = " + this.distance); + return true; + } else if( KeyStatus::up == typeEvent) { + if( true == this.lock + && this.distance == 1) { + // nothing to do ... + } else { + this.displayPos.x = 0.0; + this.displayPos.y = 0.0; + this.angle = -0.1; + this.distance = 0; + } + markToRedraw(); + signalDisable.emit(); + return true; + } + return false; + } + */ + return false; + } +} diff --git a/old_widget/MainWindows.java b/old_widget/MainWindows.java deleted file mode 100644 index 0736a0b..0000000 --- a/old_widget/MainWindows.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.atriasoft.ewol.widget; - -import org.atriasoft.etk.Dimension3f; -import org.atriasoft.etk.Distance; -import org.atriasoft.etk.math.Vector3b; -import org.atriasoft.etk.math.Vector3f; - -import sample.atriasoft.ewol.BasicWindows; - -public class MainWindows extends BasicWindows { - - public MainWindows() { - setPropertyTitle("Simple Entry test"); - - final Entry simpleEntry = new Entry(); - simpleEntry.setPropertyExpand(Vector3b.TRUE); - simpleEntry.setPropertyFill(Vector3b.TRUE_FALSE_FALSE); - simpleEntry.setPropertyMinSize(new Dimension3f(new Vector3f(200, 15, 10), Distance.PIXEL)); - this.setTestWidget(simpleEntry); - - } -} diff --git a/old_widget/Menu.cpp b/old_widget/Menu.cpp deleted file mode 100644 index 4ba5613..0000000 --- a/old_widget/Menu.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -ETK_DECLARE_TYPE(ewol::widget::Menu); - -ewol::widget::Menu::Menu() : - signalSelect(this, "select", "") { - addObjectType("ewol::widget::Menu"); - this.staticObjectId = 666; - propertyLockExpand.setDirect(Vector2b(true,true)); -} - -ewol::widget::Menu::~Menu() { - clear(); -} - -void ewol::widget::Menu::subWidgetRemoveAll() { - clear(); - ewol::widget::Sizer::subWidgetRemoveAll(); -} - -int ewol::widget::Menu::subWidgetAdd(Widget _newWidget) { - Log.error("Not availlable"); - return -1; -} - -void ewol::widget::Menu::subWidgetRemove(Widget _newWidget) { - Log.error("Not availlable"); -} - -void ewol::widget::Menu::subWidgetUnLink(Widget _newWidget) { - Log.error("Not availlable"); -} - -void ewol::widget::Menu::clear() { - this.listElement.clear(); -} - -int ewol::widget::Menu::addTitle( String _label, - String _image, - String _message) { - return add(-1, _label, _image, _message); -} - -static char* eventButtonPressed = "menu-local-pressed"; - -int ewol::widget::Menu::get( String _label) { - for (auto it : this.listElement) { - if (it.this.label == _label) { - return it.this.localId; - } - } - return -1; -} - -int ewol::widget::Menu::add(int _parent, - String _label, - String _image, - String _message) { - // try to find one already created: - int previous = get(_label); - if (previous != -1) { - return previous; - } - ewol::widget::MenuElement tmpObject; - tmpObject.this.localId = this.staticObjectId++; - tmpObject.this.parentId = _parent; - tmpObject.this.label = _label; - tmpObject.this.image = _image; - tmpObject.this.message = _message; - if (tmpObject.this.parentId == -1) { - ewol::widget::Button myButton = ewol::widget::Button::create(); - if (myButton == null) { - Log.error("Allocation button error"); - return tmpObject.this.localId; - } - if (tmpObject.this.image.size()!=0) { - String composeString ="\n"; - if (etk::end_with(tmpObject.this.image, ".edf") == true) { - composeString+=" \n"; - } else { - composeString+=" \n"; - } - composeString+=" \n"; - composeString+="\n"; - myButton.setSubWidget(ewol::widget::composerGenerateString(composeString)); - } else { - ewol::widget::Label label = ewol::widget::Label::create(); - label.propertyValue.set("" + tmpObject.this.label + ""); - myButton.setSubWidget(label); - } - // add it in the widget list - ewol::widget::Sizer::subWidgetAdd(myButton); - // keep the specific event ... - myButton.signalPressed.connect(sharedFromThis(), ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); - tmpObject.this.widgetPointer = myButton; - } - this.listElement.pushBack(tmpObject); - return tmpObject.this.localId; -} - -void ewol::widget::Menu::remove(int _id) { - Log.todo("NOT remove..."); -} - - -int ewol::widget::Menu::addSpacer(int _parent) { - ewol::widget::MenuElement tmpObject; - tmpObject.this.localId = this.staticObjectId++; - tmpObject.this.parentId = _parent; - tmpObject.this.label = ""; - tmpObject.this.image = ""; - tmpObject.this.message = ""; - if (tmpObject.this.parentId == -1) { - ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); - if (mySpacer == null) { - Log.error("Allocation spacer error"); - return tmpObject.this.localId; - } - mySpacer.propertyExpand.set(Vector2b(true,true)); - mySpacer.propertyFill.set(Vector2b(true,true)); - mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(2,0), gale::distance::pixel)); - mySpacer.propertyMaxSize.set(gale::Dimension(Vector2f(2,10000), gale::distance::pixel)); - mySpacer.propertyColor.set(etk::Color<>(0,0,0,0xFF)); - // add it in the widget list - ewol::widget::Sizer::subWidgetAdd(mySpacer); - } - this.listElement.pushBack(tmpObject); - return tmpObject.this.localId; -} - -void ewol::widget::Menu::onButtonPressed(ewol::widget::ButtonWeak _button) { - ewol::widget::Button caller = _button.lock(); - if (caller == null) { - return; - } - for (auto it : this.listElement) { - if (caller != it.this.widgetPointer.lock()) { - continue; - } - // 2 posible case (have a message or have a child ... - if (it.this.message.size() > 0) { - Log.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 ..."); - tmpContext.destroy(); - } - return; - } - Log.debug("Menu == > load Sub Menu"); - boolean findChild = false; - for (auto it2 : this.listElement) { - if (it.this.localId == it2.this.parentId) { - findChild = true; - break; - } - } - if (false == findChild) { - Log.warning("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"); - return; - } - // get the button widget: - Vector2f newPosition; - Widget eventFromWidget = ememory::dynamicPointerCast(caller); - if (eventFromWidget != null) { - Vector2f tmpOri = eventFromWidget.getOrigin(); - Vector2f tmpSize = eventFromWidget.getSize(); - // calculate the correct position - newPosition.setValue(tmpOri.x() + tmpSize.x()/2, - tmpOri.y() ); - } - tmpContext.setPositionMark(ewol::widget::ContextMenu::markTop, newPosition); - ewol::widget::Sizer mySizer; - ewol::widget::Button myButton; - mySizer = ewol::widget::Sizer::create(); - if (mySizer != null) { - mySizer.propertyMode.set(widget::Sizer::modeVert); - mySizer.propertyLockExpand.set(Vector2f(true,true)); - mySizer.propertyFill.set(Vector2f(true,true)); - // set it in the pop-up-system: - tmpContext.setSubWidget(mySizer); - boolean menuHaveImage = false; - for (auto it2 : this.listElement) { - if (it.this.localId != it2.this.parentId) { - continue; - } - if (it2.this.image.size()!=0) { - menuHaveImage = true; - break; - } - } - for (long iii=this.listElement.size()-1; iii>=0; --iii) { - if (it.this.localId != this.listElement[iii].this.parentId) { - continue; - } - if (this.listElement[iii].this.message == "" LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listElement[iii].this.label == "") { - ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); - if (mySpacer == null) { - Log.error("Allocation spacer error"); - continue; - } - mySpacer.propertyExpand.set(Vector2b(true,true)); - mySpacer.propertyFill.set(Vector2b(true,true)); - mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,2), gale::distance::pixel)); - mySpacer.propertyMaxSize.set(gale::Dimension(Vector2f(10000,2), gale::distance::pixel)); - mySpacer.propertyColor.set(etk::Color<>(0,0,0,0xFF)); - // add it in the widget list - mySizer.subWidgetAdd(mySpacer); - } else { - myButton = ewol::widget::Button::create(); - if (myButton == null) { - Log.error("Allocation Error"); - continue; - } - myButton.propertyExpand.set(Vector2b(true,true)); - myButton.propertyFill.set(Vector2b(true,true)); - // set callback - myButton.signalPressed.connect(sharedFromThis(), ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); - // add it in the widget list - mySizer.subWidgetAdd(myButton); - if (this.listElement[iii].this.image.size() != 0) { - String composeString; - composeString+= " \n"; - if (etk::end_with(this.listElement[iii].this.image, ".edf") == true) { - composeString+=" \n"; - } else { - composeString+=" \n"; - } - composeString+=" \n"; - composeString+=" \n"; - myButton.setSubWidget(ewol::widget::composerGenerateString(composeString)); - } else { - if (menuHaveImage == true) { - myButton.setSubWidget(ewol::widget::composerGenerateString( - String() + - " \n" - " \n" - " \n" - " \n") - ); - } else { - ewol::widget::Label tmpLabel = widget::Label::create(); - if (tmpLabel != null) { - tmpLabel.propertyValue.set(String("") + this.listElement[iii].this.label + "\n"); - tmpLabel.propertyExpand.set(Vector2b(true,false)); - tmpLabel.propertyFill.set(Vector2b(true,true)); - myButton.setSubWidget(tmpLabel); - } - } - } - this.listElement[iii].this.widgetPointer = myButton; - } - } - } - ewol::widget::Windows currentWindows = getWindows(); - if (currentWindows == null) { - Log.error("Can not get the curent Windows..."); - } else { - currentWindows.popUpWidgetPush(tmpContext); - } - return; - } -} - -boolean ewol::widget::Menu::loadXML( exml::Element _node) { - if (_node.exist() == false) { - return false; - } - // parse generic properties: - Widget::loadXML(_node); - // parse all the elements : - for ( auto nodeIt : _node.nodes) { - exml::Element pNode = nodeIt.toElement(); - if (pNode.exist() == false) { - // trash here all that is not element - continue; - } - String widgetName = pNode.getValue(); - Log.info("Get node : " + pNode); - if (widgetName == "elem") { - // - int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]); - for ( auto nodeIt2 : pNode.nodes) { - - exml::Element pNode2 = nodeIt2.toElement(); - if (pNode2.exist() == false) { - // trash here all that is not element - continue; - } - String widgetName2 = pNode2.getValue(); - if (widgetName2 == "elem") { - // - add(idMenu, pNode2.attributes["title"], pNode2.attributes["image"], pNode2.attributes["event"]); - } else if (widgetName2 == "separator") { - addSpacer(idMenu); - } else { - Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode2.getPos() + ") Unknown basic node='" + widgetName2 + "' not in : [elem,separator]" ); - } - } - } else if (widgetName == "separator") { - addSpacer(); - } else { - Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [elem,separator]" ); - } - } - return true; -} diff --git a/old_widget/Menu.java b/old_widget/Menu.java index a121270..b660977 100644 --- a/old_widget/Menu.java +++ b/old_widget/Menu.java @@ -1,55 +1,350 @@ +package org.atriasoft.ewol.widget; + +import org.atriasoft.esignal.Connection; +import org.atriasoft.esignal.Signal; +import org.atriasoft.esignal.SignalEmpty; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector3b; +import org.atriasoft.etk.math.Vector3f; +import org.atriasoft.ewol.Gravity; +import org.atriasoft.ewol.Padding; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.annotation.EwolSignal; +import org.atriasoft.ewol.compositing.GuiShape; +import org.atriasoft.ewol.compositing.GuiShapeMode; +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.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeyStatus; + /** * @ingroup ewolWidgetGroup */ -class Menu:public ewol::widget::Sizer +public class Menu extends Sizer { - public: - esignal::Signal signalSelect; // event on a menu button or ... - protected: - Menu(); - public: - DECLARE_WIDGET_FACTORY(Menu, "Menu"); - ~Menu(); - private: + public class MenuElement { + public MenuElement() { }; + public int localId; + public int parentId; + public WeakReference widgetPointer; + public String label; + public String image; + public String message; + }; + @EwolSignal(name = "select", description = "menu is selected") + public Signal signalSelect; // event on a menu button or ... + public Menu() { + propertyLockExpand = Vector2b(true,true); + } + private void subWidgetRemoveAll(){ + clear(); + ewol::widget::Sizer::subWidgetRemoveAll(); + } + private int subWidgetAdd(Widget _newWidget){ + Log.error("Not availlable"); + return -1; + } - void subWidgetRemoveAll(); + private void subWidgetRemove(Widget _newWidget){ + Log.error("Not availlable"); + } - int subWidgetAdd(Widget _newWidget); + private void subWidgetUnLink(Widget _newWidget){ + Log.error("Not availlable"); + } + protected static final String eventButtonPressed = "menu-local-pressed"; + private boolean loadXML( exml::Element _node) ; + private List listElement; + private int staticObjectId = 666; // unique ID for every element of the menu ... + // TODO: set it as week - void subWidgetRemove(Widget _newWidget); + private ContextMenu widgetContextMenu; + private int get(String _label) { + for (auto it : this.listElement) { + if (it.this.label == _label) { + return it.this.localId; + } + } + return -1; + } - void subWidgetUnLink(Widget _newWidget); + public void clear(){ + this.listElement.clear(); + } - boolean loadXML( exml::Element _node) ; - private: - List this.listElement; - int this.staticObjectId; // unique ID for every element of the menu ... - ewol::widget::ContextMenuWeak this.widgetContextMenu; + public int addTitle( final String _label, final String _image="", String _message = ""){ + return add(-1, _label, _image, _message); + } - int get(String _label); + public int add(final int _parent, final String _label, final String _image="", String _message = "") { + // try to find one already created: + int previous = get(_label); + if (previous != -1) { + return previous; + } + ewol::widget::MenuElement tmpObject; + tmpObject.this.localId = this.staticObjectId++; + tmpObject.this.parentId = _parent; + tmpObject.this.label = _label; + tmpObject.this.image = _image; + tmpObject.this.message = _message; + if (tmpObject.this.parentId == -1) { + ewol::widget::Button myButton = ewol::widget::Button::create(); + if (myButton == null) { + Log.error("Allocation button error"); + return tmpObject.this.localId; + } + if (tmpObject.this.image.size()!=0) { + String composeString ="\n"; + if (etk::end_with(tmpObject.this.image, ".edf") == true) { + composeString+=" \n"; + } else { + composeString+=" \n"; + } + composeString+=" \n"; + composeString+="\n"; + myButton.setSubWidget(ewol::widget::composerGenerateString(composeString)); + } else { + ewol::widget::Label label = ewol::widget::Label::create(); + label.propertyValue.set("" + tmpObject.this.label + ""); + myButton.setSubWidget(label); + } + // add it in the widget list + ewol::widget::Sizer::subWidgetAdd(myButton); + // keep the specific event ... + myButton.signalPressed.connect(sharedFromThis(), ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); + tmpObject.this.widgetPointer = myButton; + } + this.listElement.pushBack(tmpObject); + return tmpObject.this.localId; + } + - public: - void clear(); + public int addSpacer(final int _parent=-1){ + ewol::widget::MenuElement tmpObject; + tmpObject.this.localId = this.staticObjectId++; + tmpObject.this.parentId = _parent; + tmpObject.this.label = ""; + tmpObject.this.image = ""; + tmpObject.this.message = ""; + if (tmpObject.this.parentId == -1) { + ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); + if (mySpacer == null) { + Log.error("Allocation spacer error"); + return tmpObject.this.localId; + } + mySpacer.propertyExpand.set(Vector2b(true,true)); + mySpacer.propertyFill.set(Vector2b(true,true)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(2,0), gale::distance::pixel)); + mySpacer.propertyMaxSize.set(gale::Dimension(Vector2f(2,10000), gale::distance::pixel)); + mySpacer.propertyColor.set(etk::Color<>(0,0,0,0xFF)); + // add it in the widget list + ewol::widget::Sizer::subWidgetAdd(mySpacer); + } + this.listElement.pushBack(tmpObject); + return tmpObject.this.localId; + } - int addTitle( final String _label, final String _image="", String _message = ""); + public void remove(int _id){ + Log.todo("NOT remove..."); + } + + - int add(final int _parent, final String _label, final String _image="", String _message = ""); - - int addSpacer(final int _parent=-1); - - void remove(int _id); - - private: - void onButtonPressed(ewol::widget::ButtonWeak _button); -}; - - ; - - /** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) + private void onButtonPressed(ewol::widget::ButtonWeak _button){ + ewol::widget::Button caller = _button.lock(); + if (caller == null) { + return; + } + for (auto it : this.listElement) { + if (caller != it.this.widgetPointer.lock()) { + continue; + } + // 2 posible case (have a message or have a child ... + if (it.this.message.size() > 0) { + Log.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 ..."); + tmpContext.destroy(); + } + return; + } + Log.debug("Menu == > load Sub Menu"); + boolean findChild = false; + for (auto it2 : this.listElement) { + if (it.this.localId == it2.this.parentId) { + findChild = true; + break; + } + } + if (false == findChild) { + Log.warning("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"); + return; + } + // get the button widget: + Vector2f newPosition; + Widget eventFromWidget = ememory::dynamicPointerCast(caller); + if (eventFromWidget != null) { + Vector2f tmpOri = eventFromWidget.getOrigin(); + Vector2f tmpSize = eventFromWidget.getSize(); + // calculate the correct position + newPosition.setValue(tmpOri.x() + tmpSize.x()/2, + tmpOri.y() ); + } + tmpContext.setPositionMark(ewol::widget::ContextMenu::markTop, newPosition); + ewol::widget::Sizer mySizer; + ewol::widget::Button myButton; + mySizer = ewol::widget::Sizer::create(); + if (mySizer != null) { + mySizer.propertyMode.set(widget::Sizer::modeVert); + mySizer.propertyLockExpand.set(Vector2f(true,true)); + mySizer.propertyFill.set(Vector2f(true,true)); + // set it in the pop-up-system: + tmpContext.setSubWidget(mySizer); + boolean menuHaveImage = false; + for (auto it2 : this.listElement) { + if (it.this.localId != it2.this.parentId) { + continue; + } + if (it2.this.image.size()!=0) { + menuHaveImage = true; + break; + } + } + for (long iii=this.listElement.size()-1; iii>=0; --iii) { + if (it.this.localId != this.listElement[iii].this.parentId) { + continue; + } + if (this.listElement[iii].this.message == "" LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listElement[iii].this.label == "") { + ewol::widget::Spacer mySpacer = ewol::widget::Spacer::create(); + if (mySpacer == null) { + Log.error("Allocation spacer error"); + continue; + } + mySpacer.propertyExpand.set(Vector2b(true,true)); + mySpacer.propertyFill.set(Vector2b(true,true)); + mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(0,2), gale::distance::pixel)); + mySpacer.propertyMaxSize.set(gale::Dimension(Vector2f(10000,2), gale::distance::pixel)); + mySpacer.propertyColor.set(etk::Color<>(0,0,0,0xFF)); + // add it in the widget list + mySizer.subWidgetAdd(mySpacer); + } else { + myButton = ewol::widget::Button::create(); + if (myButton == null) { + Log.error("Allocation Error"); + continue; + } + myButton.propertyExpand.set(Vector2b(true,true)); + myButton.propertyFill.set(Vector2b(true,true)); + // set callback + myButton.signalPressed.connect(sharedFromThis(), ewol::widget::Menu::onButtonPressed, ewol::widget::ButtonWeak(myButton)); + // add it in the widget list + mySizer.subWidgetAdd(myButton); + if (this.listElement[iii].this.image.size() != 0) { + String composeString; + composeString+= " \n"; + if (etk::end_with(this.listElement[iii].this.image, ".edf") == true) { + composeString+=" \n"; + } else { + composeString+=" \n"; + } + composeString+=" \n"; + composeString+=" \n"; + myButton.setSubWidget(ewol::widget::composerGenerateString(composeString)); + } else { + if (menuHaveImage == true) { + myButton.setSubWidget(ewol::widget::composerGenerateString( + String() + + " \n" + " \n" + " \n" + " \n") + ); + } else { + ewol::widget::Label tmpLabel = widget::Label::create(); + if (tmpLabel != null) { + tmpLabel.propertyValue.set(String("") + this.listElement[iii].this.label + "\n"); + tmpLabel.propertyExpand.set(Vector2b(true,false)); + tmpLabel.propertyFill.set(Vector2b(true,true)); + myButton.setSubWidget(tmpLabel); + } + } + } + this.listElement[iii].this.widgetPointer = myButton; + } + } + } + ewol::widget::Windows currentWindows = getWindows(); + if (currentWindows == null) { + Log.error("Can not get the curent Windows..."); + } else { + currentWindows.popUpWidgetPush(tmpContext); + } + return; + } + } + /* + * +boolean ewol::widget::Menu::loadXML( exml::Element _node) { + if (_node.exist() == false) { + return false; + } + // parse generic properties: + Widget::loadXML(_node); + // parse all the elements : + for ( auto nodeIt : _node.nodes) { + exml::Element pNode = nodeIt.toElement(); + if (pNode.exist() == false) { + // trash here all that is not element + continue; + } + String widgetName = pNode.getValue(); + Log.info("Get node : " + pNode); + if (widgetName == "elem") { + // + int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]); + for ( auto nodeIt2 : pNode.nodes) { + + exml::Element pNode2 = nodeIt2.toElement(); + if (pNode2.exist() == false) { + // trash here all that is not element + continue; + } + String widgetName2 = pNode2.getValue(); + if (widgetName2 == "elem") { + // + add(idMenu, pNode2.attributes["title"], pNode2.attributes["image"], pNode2.attributes["event"]); + } else if (widgetName2 == "separator") { + addSpacer(idMenu); + } else { + Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode2.getPos() + ") Unknown basic node='" + widgetName2 + "' not in : [elem,separator]" ); + } + } + } else if (widgetName == "separator") { + addSpacer(); + } else { + Log.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [elem,separator]" ); + } + } + return true; +} */ - class MenuElement { - public MenuElement() { };int this.localId;int this.parentId;WeakReferencethis.widgetPointer;String this.label;String this.image;String this.message; -} \ No newline at end of file +}; + \ No newline at end of file diff --git a/old_widget/Panned.cpp b/old_widget/Panned.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/old_widget/Panned.java b/old_widget/Panned.java deleted file mode 100644 index e69de29..0000000 diff --git a/old_widget/Select.cpp b/old_widget/Select.cpp deleted file mode 100644 index f407be4..0000000 --- a/old_widget/Select.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#include -#include -#include -#include -#include -#include - -#include -ETK_DECLARE_TYPE(ewol::widget::Select); - -ewol::widget::Select::Element::Element(int _value, String _name, boolean _selected): - this.value(_value), - this.name(_name), - this.selected(_selected) { - -} - -ewol::widget::Select::Select() : - signalValue(this, "value", "Select value change"), - propertyValue(this, "value", - -1, - "Value of the Select", - ewol::widget::Select::onChangePropertyValue) { - addObjectType("ewol::widget::Select"); - // the basic parameter: - propertyShape.setDirectCheck(etk::Uri("THEME_GUI:///Select.json?lib=ewol")); - propertySpinMode.setDirect(ewol::widget::spinPosition_noneRight); - propertySpinMode.changeDefault(ewol::widget::spinPosition_noneRight); - propertySpinMode.rename("none-none", "none"); - propertySpinMode.rename("none-right", "right"); - propertySpinMode.rename("left-none", "left"); - propertySpinMode.remove("left-right"); - propertySpinMode.remove("left-left"); - propertySpinMode.remove("right-right"); -} - -ewol::widget::Select::~Select() { - -} - -void ewol::widget::Select::onChangePropertyValue() { - markToRedraw(); - if (this.widgetEntry == null) { - Log.error("Can not acces at entry ..."); - return; - } - for (auto it : this.listElement) { - if (it.this.value == propertyValue.get()) { - if (it.this.selected == false) { - it.this.selected = true; - this.widgetEntry.propertyValue.set(it.this.name); - signalValue.emit(propertyValue.get()); - } - } else { - it.this.selected = false; - } - } -} - -void ewol::widget::Select::optionSelectDefault() { - if (this.widgetEntry == null) { - Log.error("Can not acces at entry ..."); - return; - } - for (auto it : this.listElement) { - if (it.this.selected == true) { - return; - } - } - if (this.listElement.size() == 0) { - this.widgetEntry.propertyValue.set(""); - } - this.widgetEntry.propertyValue.set(this.listElement[0].this.name); -} - -void ewol::widget::Select::optionRemove(int _value) { - for (auto it=this.listElement.begin(); it != this.listElement.end(); ++it) { - if (_value == it.this.value) { - Log.debug("remove element: " + _value); - this.listElement.erase(it); - break; - } - } - optionSelectDefault(); -} - -void ewol::widget::Select::optionClear() { - this.listElement.clear(); - optionSelectDefault(); -} - -void ewol::widget::Select::optionAdd(int _value, String _data) { - for (auto it : this.listElement) { - if (_value == it.this.value) { - Log.debug("replace element: " + _value + " with: '" + _data + "'"); - it.this.name = _data; - } - } - this.listElement.pushBack(ewol::widget::Select::Element(_value, _data, false)); -} - -boolean ewol::widget::Select::loadXML( exml::Element _node) { - if (_node.exist() == false) { - return false; - } - // parse generic properties: - ewol::widget::SpinBase::loadXML(_node); - // remove previous element: - //subWidgetRemove(); - // parse all the elements: - for( auto it : _node.nodes) { - exml::Element pNode = it.toElement(); - if (pNode.exist() == false) { - // trash here all that is not element - continue; - } - if (pNode.getValue() != "option") { - Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + pNode.getValue() + "' not in : [option]" ); - continue; - } - String valId = pNode.attributes["id"]; - String valIsSelected = pNode.attributes["select"]; - String valText = pNode.getText(); - int id = etk::string_to_int(valId); - boolean select = etk::string_to_bool(valIsSelected); - optionAdd(id, valText); - if (select == true) { - propertyValue.set(id); - } - Log.warning("Add option : id='" + valId + "' select='" + valIsSelected + "' text='" + valText + "'"); - } - return true; -} - -void ewol::widget::Select::updateGui() { - ewol::widget::SpinBase::updateGui(); - - if ( this.widgetEntry != null - LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionEntry.isConnected() == false) { - - } - if ( this.widgetButtonUp != null - LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButton.isConnected() == false) { - this.connectionButton = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Select::onCallbackOpenMenu); - } - -} - -void ewol::widget::Select::onCallbackLabelPressed(int _value) { - Log.verbose("User select:" + _value); - propertyValue.set(_value); -} - -void ewol::widget::Select::onCallbackOpenMenu() { - // create a context menu: - ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create(); - if (tmpContext == null) { - Log.error("Allocation Error"); - return; - } - // auto-select mark position: - tmpContext.setPositionMarkAuto(this.origin, this.size); - ewol::widget::Sizer mySizer; - mySizer = ewol::widget::Sizer::create(); - if (mySizer == null) { - Log.error("Allocation Error or sizer"); - return; - } - mySizer.propertyMode.set(widget::Sizer::modeVert); - mySizer.propertyLockExpand.set(Vector2f(true,true)); - mySizer.propertyFill.set(Vector2f(true,true)); - // set it in the pop-up-system: - tmpContext.setSubWidget(mySizer); - for (auto it : this.listElement) { - ewol::widget::Label myLabel = ewol::widget::Label::create(); - if (myLabel == null) { - Log.error("Allocation Error"); - continue; - } - if (it.this.selected == true) { - myLabel.propertyValue.set(String("") + it.this.name + ""); - } else { - myLabel.propertyValue.set(it.this.name); - } - myLabel.propertyExpand.set(Vector2b(true,true)); - myLabel.propertyFill.set(Vector2b(true,true)); - // set callback - myLabel.signalPressed.connect(sharedFromThis(), ewol::widget::Select::onCallbackLabelPressed, it.this.value); - myLabel.signalPressed.connect(tmpContext, ewol::widget::ContextMenu::destroy); - // add it in the widget list - mySizer.subWidgetAddStart(myLabel); - } - ewol::widget::Windows currentWindows = getWindows(); - if (currentWindows == null) { - Log.error("Can not get the curent Windows..."); - } else { - currentWindows.popUpWidgetPush(tmpContext); - } -} - diff --git a/old_widget/Select.java b/old_widget/Select.java index 743a934..6ab6170 100644 --- a/old_widget/Select.java +++ b/old_widget/Select.java @@ -1,16 +1,60 @@ +package org.atriasoft.ewol.widget; + +import org.atriasoft.esignal.Connection; +import org.atriasoft.esignal.Signal; +import org.atriasoft.esignal.SignalEmpty; +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector3b; +import org.atriasoft.etk.math.Vector3f; +import org.atriasoft.ewol.Gravity; +import org.atriasoft.ewol.Padding; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.annotation.EwolSignal; +import org.atriasoft.ewol.compositing.GuiShape; +import org.atriasoft.ewol.compositing.GuiShapeMode; +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.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; +import org.atriasoft.gale.key.KeyKeyboard; +import org.atriasoft.gale.key.KeyStatus; /** * a composed Select is a Select with an inside composed with the specify XML element * ==> this permit to generate standard element simple */ class Select extends SpinBase { + @EwolSignal(name = "value", description = "Select value change") public Signal signalValue = new Signal(); - protected int propertyValue; //!< Current state of the Select. + /* + propertyValue(this, "value", + "Value of the Select", + ewol::widget::Select::onChangePropertyValue) { + */ + protected int propertyValue = -1; //!< Current state of the Select. /** * Constructor * @param _shaperName Shaper file properties */ - public Select(); + public Select() { + setPropertyShape( new Uri("THEME","/shape/Select.json", "ewol")); + + propertySpinMode = SpinPosition.noneRight); + /* + propertySpinMode.changeDefault(ewol::widget::spinPosition_noneRight); + propertySpinMode.rename("none-none", "none"); + propertySpinMode.rename("none-right", "right"); + propertySpinMode.rename("left-none", "left"); + propertySpinMode.remove("left-right"); + propertySpinMode.remove("left-left"); + propertySpinMode.remove("right-right"); + */ + } protected class Element { public: int value; @@ -19,18 +63,168 @@ class Select extends SpinBase { public: // TODO: Remove this: due to the fact my List is not full implemented Element() {} - Element(int _value, String _name, boolean _selected=false); + Element(int _value, String _name, boolean _selected=false) { + this.value = _value; + this.name = _name; + this.selected = _selected; + } }; protected List this.listElement; - public void optionSelectDefault(); - public void optionRemove(int _value); - public void optionClear(); - public void optionAdd(int _value, String _name); - protected boolean loadXML( exml::Element _node) ; - protected void updateGui() ; - protected void onCallbackOpenMenu(); - protected void onCallbackLabelPressed(int _value); + public void optionSelectDefault(){ + if (this.widgetEntry == null) { + Log.error("Can not acces at entry ..."); + return; + } + for (auto it : this.listElement) { + if (it.this.selected == true) { + return; + } + } + if (this.listElement.size() == 0) { + this.widgetEntry.propertyValue.set(""); + } + this.widgetEntry.propertyValue.set(this.listElement[0].this.name); + } + 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); + this.listElement.erase(it); + break; + } + } + optionSelectDefault(); + } + + public void optionClear() { + this.listElement.clear(); + optionSelectDefault(); + } + + public void optionAdd(int _value, String _name) { + for (auto it : this.listElement) { + if (_value == it.this.value) { + Log.debug("replace element: " + _value + " with: '" + _data + "'"); + it.this.name = _data; + } + } + this.listElement.pushBack(ewol::widget::Select::Element(_value, _data, false)); + } + /* + protected boolean loadXML( exml::Element _node){ + if (_node.exist() == false) { + return false; + } + // parse generic properties: + ewol::widget::SpinBase::loadXML(_node); + // remove previous element: + //subWidgetRemove(); + // parse all the elements: + for( auto it : _node.nodes) { + exml::Element pNode = it.toElement(); + if (pNode.exist() == false) { + // trash here all that is not element + continue; + } + if (pNode.getValue() != "option") { + Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + pNode.getValue() + "' not in : [option]" ); + continue; + } + String valId = pNode.attributes["id"]; + String valIsSelected = pNode.attributes["select"]; + String valText = pNode.getText(); + int id = etk::string_to_int(valId); + boolean select = etk::string_to_bool(valIsSelected); + optionAdd(id, valText); + if (select == true) { + propertyValue.set(id); + } + Log.warning("Add option : id='" + valId + "' select='" + valIsSelected + "' text='" + valText + "'"); + } + return true; + } + */ + protected void updateGui() { + ewol::widget::SpinBase::updateGui(); + + if ( this.widgetEntry != null + && this.connectionEntry.isConnected() == false) { + + } + if ( this.widgetButtonUp != null + && this.connectionButton.isConnected() == false) { + this.connectionButton = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Select::onCallbackOpenMenu); + } + + } + protected void onCallbackOpenMenu() { + // create a context menu: + ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create(); + if (tmpContext == null) { + Log.error("Allocation Error"); + return; + } + // auto-select mark position: + tmpContext.setPositionMarkAuto(this.origin, this.size); + ewol::widget::Sizer mySizer; + mySizer = ewol::widget::Sizer::create(); + if (mySizer == null) { + Log.error("Allocation Error or sizer"); + return; + } + mySizer.propertyMode.set(widget::Sizer::modeVert); + mySizer.propertyLockExpand.set(Vector2f(true,true)); + mySizer.propertyFill.set(Vector2f(true,true)); + // set it in the pop-up-system: + tmpContext.setSubWidget(mySizer); + for (auto it : this.listElement) { + ewol::widget::Label myLabel = ewol::widget::Label::create(); + if (myLabel == null) { + Log.error("Allocation Error"); + continue; + } + if (it.this.selected == true) { + myLabel.propertyValue.set(String("") + it.this.name + ""); + } else { + myLabel.propertyValue.set(it.this.name); + } + myLabel.propertyExpand.set(Vector2b(true,true)); + myLabel.propertyFill.set(Vector2b(true,true)); + // set callback + myLabel.signalPressed.connect(sharedFromThis(), ewol::widget::Select::onCallbackLabelPressed, it.this.value); + myLabel.signalPressed.connect(tmpContext, ewol::widget::ContextMenu::destroy); + // add it in the widget list + mySizer.subWidgetAddStart(myLabel); + } + ewol::widget::Windows currentWindows = getWindows(); + if (currentWindows == null) { + Log.error("Can not get the curent Windows..."); + } else { + currentWindows.popUpWidgetPush(tmpContext); + } + } + protected void onCallbackLabelPressed(int _value){ + Log.verbose("User select:" + _value); + propertyValue.set(_value); + } protected esignal::Connection connectionEntry = null; protected esignal::Connection connectionButton = null; - protected void onChangePropertyValue(); + protected void onChangePropertyValue(){ + markToRedraw(); + if (this.widgetEntry == null) { + Log.error("Can not acces at entry ..."); + return; + } + for (auto it : this.listElement) { + if (it.this.value == propertyValue.get()) { + if (it.this.selected == false) { + it.this.selected = true; + this.widgetEntry.propertyValue.set(it.this.name); + signalValue.emit(propertyValue.get()); + } + } else { + it.this.selected = false; + } + } + } } diff --git a/old_widget/Slider.java b/old_widget/Slider.java index 6a2c1c1..dcc0450 100644 --- a/old_widget/Slider.java +++ b/old_widget/Slider.java @@ -35,7 +35,7 @@ namespace ewol { DECLARE_WIDGET_FACTORY(Slider, "Slider"); ~Slider(); public: - // TODO : Rewoek the color in the theme ... + // TODO : Rework the color in the theme ... void setColor(etk::Color<> _newColor) { this.textColorFg = _newColor; }; diff --git a/old_widget/Spin.cpp b/old_widget/Spin.cpp deleted file mode 100644 index b158cac..0000000 --- a/old_widget/Spin.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#include -#include -#include -#include -#include -#include -#include -ETK_DECLARE_TYPE(ewol::widget::Spin); - -ewol::widget::Spin::Spin() : - signalValue(this, "value", - "Spin value change"), - signalValueDouble(this, "valueDouble", - "Spin value change value in 'double'"), - propertyValue(this, "value", - 0, - "Value of the Spin", - ewol::widget::Spin::onChangePropertyValue), - propertyMin(this, "min", - -9999999999, - "Minimum value of the spin", - ewol::widget::Spin::onChangePropertyMin), - propertyMax(this, "max", - 9999999999, - "Maximum value of the spin", - ewol::widget::Spin::onChangePropertyMax), - propertyIncrement(this, "increment", - 1, - "Increment value at each button event or keybord event", - ewol::widget::Spin::onChangePropertyIncrement), - propertyMantis(this, "mantis", - 0, - "fix-point mantis", - ewol::widget::Spin::onChangePropertyMantis) { - addObjectType("ewol::widget::Spin"); - propertyShape.setDirectCheck(etk::Uri("THEME_GUI:///Spin.json?lib=ewol")); -} - -ewol::widget::Spin::~Spin() { - -} - -void ewol::widget::Spin::onChangePropertyValue() { - markToRedraw(); - if (this.widgetEntry == null) { - Log.error("Can not acces at entry ..."); - return; - } - checkValue(*propertyValue); -} - -void ewol::widget::Spin::onChangePropertyMin() { - checkValue(*propertyValue); -} - -void ewol::widget::Spin::onChangePropertyMax() { - checkValue(*propertyValue); -} - -void ewol::widget::Spin::onChangePropertyIncrement() { - -} - -void ewol::widget::Spin::onChangePropertyMantis() { - -} - -void ewol::widget::Spin::updateGui() { - Log.warning("updateGui [START]"); - ewol::widget::SpinBase::updateGui(); - - if ( this.widgetEntry != null - && this.connectionEntry.isConnected() == false) { - - } - if ( this.widgetButtonUp != null - && this.connectionButtonUp.isConnected() == false) { - this.connectionButtonUp = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Spin::onCallbackUp); - } - if ( this.widgetButtonDown != null - && this.connectionButtonDown.isConnected() == false) { - this.connectionButtonDown = this.widgetButtonDown.signalPressed.connect(this, ewol::widget::Spin::onCallbackDown); - } - Log.warning("updateGui [STOP]"); -} - -void ewol::widget::Spin::checkValue(long _value) { - _value = etk::avg(propertyMin.get(), _value, propertyMax.get()); - propertyValue.setDirect(_value); - this.widgetEntry.propertyValue.set(etk::toString(_value)); -} - -void ewol::widget::Spin::onCallbackUp() { - long value = propertyValue.get() + propertyIncrement.get(); - checkValue(value); -} - -void ewol::widget::Spin::onCallbackDown() { - long value = propertyValue.get() - propertyIncrement.get(); - checkValue(value); -} diff --git a/old_widget/Spin.java b/old_widget/Spin.java deleted file mode 100644 index 3817641..0000000 --- a/old_widget/Spin.java +++ /dev/null @@ -1,46 +0,0 @@ - - /** - * a composed Spin is a Spin with an inside composed with the specify XML element - * ==> this permit to generate standard element simple - */ - class Spin : public ewol::widget::SpinBase { - public: - // Event list of properties - esignal::Signal signalValue; - esignal::Signal signalValueDouble; - public: - eproperty::Value propertyValue; //!< Current value of the Spin. - eproperty::Value propertyMin; //!< Minimum value - eproperty::Value propertyMax; //!< Maximum value - eproperty::Value propertyIncrement; //!< Increment value - eproperty::Value propertyMantis; //!< number of value under '.' value - protected: - /** - * Constructor - * @param _mode mode to display the spin - * @param _shaperName Shaper file properties - */ - Spin(); - public: - DECLARE_WIDGET_FACTORY(Spin, "Spin"); - /** - * Destructor - */ - ~Spin(); - protected: - void checkValue(long _value); - void updateGui(); - protected: - void onCallbackUp(); - void onCallbackDown(); - protected: - esignal::Connection this.connectionEntry; - esignal::Connection this.connectionButtonUp; - esignal::Connection this.connectionButtonDown; - protected: - void onChangePropertyValue(); - void onChangePropertyMin(); - void onChangePropertyMax(); - void onChangePropertyIncrement(); - void onChangePropertyMantis(); -} diff --git a/old_widget/TreeView.cpp b/old_widget/TreeView.cpp index 62b0fb3..42c8269 100644 --- a/old_widget/TreeView.cpp +++ b/old_widget/TreeView.cpp @@ -176,11 +176,11 @@ boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2 + " in " + posStart + " . " + (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get()))); if ( _mousePosition.x() >= posStart.x() - LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _mousePosition.x() <= posStart.x()+propertyIconTreeViewSize.get() - LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listSizeY[_pos.y()] - _mousePosition.y() >= posStart.y() - LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.listSizeY[_pos.y()] - _mousePosition.y() <= propertyIconTreeViewSize.get() ) { + && _mousePosition.x() <= posStart.x()+propertyIconTreeViewSize.get() + && this.listSizeY[_pos.y()] - _mousePosition.y() >= posStart.y() + && this.listSizeY[_pos.y()] - _mousePosition.y() <= propertyIconTreeViewSize.get() ) { onItemExpandEvent(_pos); return true; } return false; -} \ No newline at end of file +} diff --git a/old_widget/meta/ColorChooser.cpp b/old_widget/meta/ColorChooser.cpp index a2d1c86..e69de29 100644 --- a/old_widget/meta/ColorChooser.cpp +++ b/old_widget/meta/ColorChooser.cpp @@ -1,153 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -//#include -#include -#include -ETK_DECLARE_TYPE(ewol::widget::ColorChooser); - -extern "C" { - // file browsing ... - #include -} - -ewol::widget::ColorChooser::ColorChooser() : - signalChange(this, "change", ""), - propertyValue(this, "value", - etk::color::white, - "color to select", - ewol::widget::ColorChooser::onChangePropertyValue) { - addObjectType("ewol::widget::ColorChooser"); -} - -void ewol::widget::ColorChooser::init() { - ewol::widget::Sizer::init(); - propertyMode.set(ewol::widget::Sizer::modeVert); - propertyLockExpand.set(Vector2b(true,true)); - this.widgetColorBar = ewol::widget::ColorBar::create(); - this.widgetColorBar.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChange); - this.widgetColorBar.propertyFill.set(Vector2b(true,true)); - subWidgetAdd(this.widgetColorBar); - - etk::Color<> sliderColor; - sliderColor = etk::color::black; - - this.widgetRed = ewol::widget::Slider::create(); - this.widgetRed.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeRed); - this.widgetRed.propertyExpand.set(Vector2b(true,false)); - this.widgetRed.propertyFill.set(Vector2b(true,false)); - this.widgetRed.propertyMinimum.set(0); - this.widgetRed.propertyMaximum.set(255); - sliderColor = etk::Color<>(0xFF, 0x00, 0x00, 0xFF); - this.widgetRed.setColor(sliderColor); - subWidgetAdd(this.widgetRed); - this.widgetGreen = ewol::widget::Slider::create(); - this.widgetGreen.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeGreen); - this.widgetGreen.propertyExpand.set(Vector2b(true,false)); - this.widgetGreen.propertyFill.set(Vector2b(true,false)); - this.widgetGreen.propertyMinimum.set(0); - this.widgetGreen.propertyMaximum.set(255); - sliderColor = etk::Color<>(0x00, 0xFF, 0x00, 0xFF); - this.widgetGreen.setColor(sliderColor); - subWidgetAdd(this.widgetGreen); - this.widgetBlue = ewol::widget::Slider::create(); - this.widgetBlue.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeBlue); - this.widgetBlue.propertyExpand.set(Vector2b(true,false)); - this.widgetBlue.propertyFill.set(Vector2b(true,false)); - this.widgetBlue.propertyMinimum.set(0); - this.widgetBlue.propertyMaximum.set(255); - sliderColor = etk::Color<>(0x00, 0x00, 0xFF, 0xFF); - this.widgetBlue.setColor(sliderColor); - subWidgetAdd(this.widgetBlue); - this.widgetAlpha = ewol::widget::Slider::create(); - this.widgetAlpha.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeAlpha); - this.widgetAlpha.propertyExpand.set(Vector2b(true,false)); - this.widgetAlpha.propertyFill.set(Vector2b(true,false)); - this.widgetAlpha.propertyMinimum.set(0); - this.widgetAlpha.propertyMaximum.set(255); - subWidgetAdd(this.widgetAlpha); -} - - -ewol::widget::ColorChooser::~ColorChooser() { - -} - - -void ewol::widget::ColorChooser::onChangePropertyValue() { - if (this.widgetRed != null) { - this.widgetRed.propertyValue.set(propertyValue.r()); - } - if (this.widgetGreen != null) { - this.widgetGreen.propertyValue.set(propertyValue.g()); - } - if (this.widgetBlue != null) { - this.widgetBlue.propertyValue.set(propertyValue.b()); - } - if (this.widgetAlpha != null) { - this.widgetAlpha.propertyValue.set(propertyValue.a()); - } - if (this.widgetColorBar != null) { - this.widgetColorBar.propertyValue.set(propertyValue); - } -} - -void ewol::widget::ColorChooser::onCallbackColorChangeRed( float _newColor) { - propertyValue.getDirect().setR(_newColor); - if (this.widgetColorBar != null) { - this.widgetColorBar.propertyValue.set(propertyValue); - } - signalChange.emit(propertyValue); -} - -void ewol::widget::ColorChooser::onCallbackColorChangeGreen( float _newColor) { - propertyValue.getDirect().setG(_newColor); - if (this.widgetColorBar != null) { - this.widgetColorBar.propertyValue.set(propertyValue); - } - signalChange.emit(propertyValue); -} - -void ewol::widget::ColorChooser::onCallbackColorChangeBlue( float _newColor) { - propertyValue.getDirect().setB(_newColor); - if (this.widgetColorBar != null) { - this.widgetColorBar.propertyValue.set(propertyValue); - } - signalChange.emit(propertyValue); -} - -void ewol::widget::ColorChooser::onCallbackColorChangeAlpha( float _newColor) { - propertyValue.getDirect().setA(_newColor); - if (this.widgetColorBar != null) { - this.widgetColorBar.propertyValue.set(propertyValue); - } - signalChange.emit(propertyValue); -} - -void ewol::widget::ColorChooser::onCallbackColorChange( etk::Color<> _newColor) { - // == > colorBar has change ... - int tmpAlpha = propertyValue.a(); - propertyValue.getDirect() = _newColor; - propertyValue.getDirect().setA(tmpAlpha); - if (this.widgetRed != null) { - this.widgetRed.propertyValue.set(propertyValue.r()); - } - if (this.widgetGreen != null) { - this.widgetGreen.propertyValue.set(propertyValue.g()); - } - if (this.widgetBlue != null) { - this.widgetBlue.propertyValue.set(propertyValue.b()); - } - if (this.widgetAlpha != null) { - this.widgetAlpha.propertyValue.set(propertyValue.a()); - } - signalChange.emit(propertyValue); -} \ No newline at end of file diff --git a/old_widget/meta/ColorChooser.java b/old_widget/meta/ColorChooser.java index 3e80c39..f3374d3 100644 --- a/old_widget/meta/ColorChooser.java +++ b/old_widget/meta/ColorChooser.java @@ -1,53 +1,164 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) +package org.atriasoft.ewol.widget; + + +import org.atriasoft.etk.Color; +import org.atriasoft.etk.Uri; +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.DrawProperty; +import org.atriasoft.ewol.HighSpeedMode; +import org.atriasoft.ewol.Padding; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.compositing.GuiShape; +import org.atriasoft.ewol.event.EventInput; +import org.atriasoft.ewol.internal.Log; +import org.atriasoft.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; +import org.atriasoft.gale.backend3d.OpenGL; +import org.atriasoft.gale.key.KeyStatus; +import org.atriasoft.gale.key.KeyType; + +/** + * @ingroup ewolWidgetGroup */ -#pragma once +class ColorChooser entends Sizer { + @EwolSignal(name = "change", description = "Update new color") + public Signal signalChange; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ewol { - namespace widget { - class ColorChooser; - using ColorChooser = ememory::Ptr; - using ColorChooserWeak = ememory::WeakPtr; - /** - * @ingroup ewolWidgetGroup - */ - class ColorChooser : public ewol::widget::Sizer { - public: // signals - esignal::Signal> signalChange; - public: - eproperty::Value> propertyValue; - protected: - ColorChooser(); - void init() ; - public: - DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser"); - ~ColorChooser(); - private: - ewol::widget::ColorBar this.widgetColorBar; - ewol::widget::Slider this.widgetRed; - ewol::widget::Slider this.widgetGreen; - ewol::widget::Slider this.widgetBlue; - ewol::widget::Slider this.widgetAlpha; - void onCallbackColorChangeRed( float _newColor); - void onCallbackColorChangeGreen( float _newColor); - void onCallbackColorChangeBlue( float _newColor); - void onCallbackColorChangeAlpha( float _newColor); - void onCallbackColorChange( etk::Color<> _newColor); - protected: - void onChangePropertyValue(); - }; - }; -}; + protected Color propertyValue = Color.WHITE; + @XmlManaged + @XmlAttribute + @XmlName(value = "value") + @EwolDescription(value = "color to select") + public Color getPropertyValue() { + return propertyValue; + } + public void setPropertyValue(Color propertyValue) { + if (this.propertyValue.equals(propertyValue)) { + return; + } + this.propertyValue = propertyValue; + onChangePropertyValue(); + } + + + protected ColorChooser() { + { + ewol::widget::Sizer::init(); + propertyMode.set(ewol::widget::Sizer::modeVert); + propertyLockExpand.set(Vector2b(true,true)); + this.widgetColorBar = ewol::widget::ColorBar::create(); + this.widgetColorBar.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChange); + this.widgetColorBar.propertyFill.set(Vector2b(true,true)); + subWidgetAdd(this.widgetColorBar); + + etk::Color<> sliderColor; + sliderColor = etk::color::black; + + this.widgetRed = ewol::widget::Slider::create(); + this.widgetRed.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeRed); + this.widgetRed.propertyExpand.set(Vector2b(true,false)); + this.widgetRed.propertyFill.set(Vector2b(true,false)); + this.widgetRed.propertyMinimum.set(0); + this.widgetRed.propertyMaximum.set(255); + sliderColor = etk::Color<>(0xFF, 0x00, 0x00, 0xFF); + this.widgetRed.setColor(sliderColor); + subWidgetAdd(this.widgetRed); + this.widgetGreen = ewol::widget::Slider::create(); + this.widgetGreen.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeGreen); + this.widgetGreen.propertyExpand.set(Vector2b(true,false)); + this.widgetGreen.propertyFill.set(Vector2b(true,false)); + this.widgetGreen.propertyMinimum.set(0); + this.widgetGreen.propertyMaximum.set(255); + sliderColor = etk::Color<>(0x00, 0xFF, 0x00, 0xFF); + this.widgetGreen.setColor(sliderColor); + subWidgetAdd(this.widgetGreen); + this.widgetBlue = ewol::widget::Slider::create(); + this.widgetBlue.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeBlue); + this.widgetBlue.propertyExpand.set(Vector2b(true,false)); + this.widgetBlue.propertyFill.set(Vector2b(true,false)); + this.widgetBlue.propertyMinimum.set(0); + this.widgetBlue.propertyMaximum.set(255); + sliderColor = etk::Color<>(0x00, 0x00, 0xFF, 0xFF); + this.widgetBlue.setColor(sliderColor); + subWidgetAdd(this.widgetBlue); + this.widgetAlpha = ewol::widget::Slider::create(); + this.widgetAlpha.signalChange.connect(sharedFromThis(), ewol::widget::ColorChooser::onCallbackColorChangeAlpha); + this.widgetAlpha.propertyExpand.set(Vector2b(true,false)); + this.widgetAlpha.propertyFill.set(Vector2b(true,false)); + this.widgetAlpha.propertyMinimum.set(0); + this.widgetAlpha.propertyMaximum.set(255); + subWidgetAdd(this.widgetAlpha); + } + protected ColorBar widgetColorBar; + protected Slider widgetRed; + protected Slider widgetGreen; + protected Slider widgetBlue; + protected Slider widgetAlpha; + protected static void onCallbackColorChangeRed(ColorChooser self, float _newColor){ + propertyValue.getDirect().setR(_newColor); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); + } + signalChange.emit(propertyValue); + } + protected static void onCallbackColorChangeGreen(ColorChooser self, float _newColor){ + propertyValue.getDirect().setG(_newColor); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); + } + signalChange.emit(propertyValue); + } + protected static void onCallbackColorChangeBlue(ColorChooser self, float _newColor){ + propertyValue.getDirect().setB(_newColor); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); + } + signalChange.emit(propertyValue); + } + protected static void onCallbackColorChangeAlpha(ColorChooser self, float _newColor){ + propertyValue.getDirect().setA(_newColor); + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); + } + signalChange.emit(propertyValue); + } + protected static void onCallbackColorChange(ColorChooser self, etk::Color<> _newColor){ + // == > colorBar has change ... + int tmpAlpha = propertyValue.a(); + propertyValue.getDirect() = _newColor; + propertyValue.getDirect().setA(tmpAlpha); + if (this.widgetRed != null) { + this.widgetRed.propertyValue.set(propertyValue.r()); + } + if (this.widgetGreen != null) { + this.widgetGreen.propertyValue.set(propertyValue.g()); + } + if (this.widgetBlue != null) { + this.widgetBlue.propertyValue.set(propertyValue.b()); + } + if (this.widgetAlpha != null) { + this.widgetAlpha.propertyValue.set(propertyValue.a()); + } + signalChange.emit(propertyValue); + } + protected void onChangePropertyValue(){ + if (this.widgetRed != null) { + this.widgetRed.propertyValue.set(propertyValue.r()); + } + if (this.widgetGreen != null) { + this.widgetGreen.propertyValue.set(propertyValue.g()); + } + if (this.widgetBlue != null) { + this.widgetBlue.propertyValue.set(propertyValue.b()); + } + if (this.widgetAlpha != null) { + this.widgetAlpha.propertyValue.set(propertyValue.a()); + } + if (this.widgetColorBar != null) { + this.widgetColorBar.propertyValue.set(propertyValue); + } +} \ No newline at end of file diff --git a/old_widget/meta/SpinBase.cpp b/old_widget/meta/SpinBase.cpp deleted file mode 100644 index 13df605..0000000 --- a/old_widget/meta/SpinBase.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#include -#include -#include -#include -#include - -#include -ETK_DECLARE_TYPE(ewol::widget::SpinBase); -ETK_DECLARE_TYPE(enum ewol::widget::spinPosition); - -ewol::widget::SpinBase::SpinBase() : - propertyShape(this, "shape", - "", - "shape for the display", - ewol::widget::SpinBase::onChangePropertyShape), - propertySpinMode(this, "spin-mode", - ewol::widget::spinPosition_RightRight, - "The display spin mode", - ewol::widget::SpinBase::onChangePropertySpinMode), - this.confIdEntryShaper(-1), - this.confIdUpShaper(-1), - this.confIdDownShaper(-1), - this.confIdUpData(-1), - this.confIdDownData(-1) { - - addObjectType("ewol::widget::SpinBase"); - propertySpinMode.add(ewol::widget::spinPosition_noneNone, "none-none"); - propertySpinMode.add(ewol::widget::spinPosition_noneRight, "none-right"); - propertySpinMode.add(ewol::widget::spinPosition_leftNone, "left-none"); - propertySpinMode.add(ewol::widget::spinPosition_leftRight, "left-right"); - propertySpinMode.add(ewol::widget::spinPosition_leftLeft, "left-left"); - propertySpinMode.add(ewol::widget::spinPosition_RightRight, "right-right"); - propertyLockExpand.setDirectCheck(Vector2b(true,true)); - propertyGravity.setDirectCheck(gravity_center); -} - -void ewol::widget::SpinBase::init() { - ewol::widget::Sizer::init(); - propertyShape.notifyChange(); - updateGui(); -} - -ewol::widget::SpinBase::~SpinBase() { - -} - -void ewol::widget::SpinBase::onChangePropertySpinMode() { - updateGui(); -} - -void ewol::widget::SpinBase::onChangePropertyShape() { - this.config = ewol::resource::ConfigFile::create(propertyShape); - if (this.config != null) { - this.confIdEntryShaper = this.config.request("entry-shaper"); - this.confIdUpShaper = this.config.request("up-shaper"); - this.confIdDownShaper = this.config.request("down-shaper"); - this.confIdUpData = this.config.request("up-data"); - this.confIdDownData = this.config.request("down-data"); - } - markToRedraw(); -} - - - -void ewol::widget::SpinBase::updateGui() { - subWidgetRemoveAll(); - markToRedraw(); - requestUpdateSize(); - if (this.widgetEntry == null) { - String shaper; - if (this.config != null) { - shaper = this.config.getString(this.confIdEntryShaper); - Log.verbose("shaper entry : " + shaper); - } - this.widgetEntry = ewol::widget::Entry::create("shape", shaper); - if (this.widgetEntry != null) { - this.widgetEntry.propertyExpand.set(Vector2b(true,false)); - this.widgetEntry.propertyFill.set(Vector2b(true,true)); - } - } - if (this.widgetButtonDown == null) { - String shaper; - if (this.config != null) { - shaper = this.config.getString(this.confIdDownShaper); - Log.verbose("shaper button DOWN : " + shaper); - } - this.widgetButtonDown = ewol::widget::Button::create("shape", shaper); - if (this.widgetButtonDown != null) { - this.widgetButtonDown.propertyExpand.set(Vector2b(false,false)); - this.widgetButtonDown.propertyFill.set(Vector2b(true,true)); - String data = this.config.getString(this.confIdDownData); - Widget widget = ewol::widget::composerGenerateString(data); - this.widgetButtonDown.setSubWidget(widget); - } - } - if (this.widgetButtonUp == null) { - String shaper; - if (this.config != null) { - shaper = this.config.getString(this.confIdUpShaper); - Log.verbose("shaper button UP : " + shaper); - } - this.widgetButtonUp = ewol::widget::Button::create("shape", shaper); - if (this.widgetButtonUp != null) { - this.widgetButtonUp.propertyExpand.set(Vector2b(false,false)); - this.widgetButtonUp.propertyFill.set(Vector2b(true,true)); - String data = this.config.getString(this.confIdUpData); - Widget widget = ewol::widget::composerGenerateString(data); - this.widgetButtonUp.setSubWidget(widget); - } - } - switch (propertySpinMode) { - case ewol::widget::spinPosition_noneNone: - subWidgetAdd(this.widgetEntry); - break; - case ewol::widget::spinPosition_noneRight: - subWidgetAdd(this.widgetEntry); - subWidgetAdd(this.widgetButtonUp); - break; - case ewol::widget::spinPosition_leftNone: - subWidgetAdd(this.widgetButtonDown); - subWidgetAdd(this.widgetEntry); - break; - case ewol::widget::spinPosition_leftRight: - subWidgetAdd(this.widgetButtonDown); - subWidgetAdd(this.widgetEntry); - subWidgetAdd(this.widgetButtonUp); - break; - case ewol::widget::spinPosition_leftLeft: - subWidgetAdd(this.widgetButtonDown); - subWidgetAdd(this.widgetButtonUp); - subWidgetAdd(this.widgetEntry); - break; - case ewol::widget::spinPosition_RightRight: - subWidgetAdd(this.widgetEntry); - subWidgetAdd(this.widgetButtonDown); - subWidgetAdd(this.widgetButtonUp); - break; - } -} - -boolean ewol::widget::SpinBase::loadXML( exml::Element _node) { - if (_node.exist() == false) { - return false; - } - // parse generic properties: (we not parse the sizer property, it remove all subwidget) - return Widget::loadXML(_node); -} \ No newline at end of file diff --git a/old_widget/meta/SpinBase.java b/old_widget/meta/SpinBase.java deleted file mode 100644 index 68cf84d..0000000 --- a/old_widget/meta/SpinBase.java +++ /dev/null @@ -1,102 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ewol { - namespace widget { - enum spinPosition { - /** show like: - * *------------------------* - * | | - * *------------------------* - */ - spinPosition_noneNone, - /** show like: - * *--------------------*---* - * | | | - * *--------------------*---* - */ - spinPosition_noneRight, - /** show like: - * *---*--------------------* - * | | | - * *---*--------------------* - */ - spinPosition_leftNone, - /** show like: - * *---*----------------*---* - * | | | | - * *---*----------------*---* - */ - spinPosition_leftRight, - /** show like: - * *---*---*----------------* - * | | | | - * *---*---*----------------* - */ - spinPosition_leftLeft, - /** show like: - * *----------------*---*---* - * | | | | - * *----------------*---*---* - */ - spinPosition_RightRight - }; - class SpinBase; - using SpinBase = ememory::Ptr; - using SpinBaseWeak = ememory::WeakPtr; - /** - * @ingroup ewolWidgetGroup - */ - class SpinBase : public ewol::widget::Sizer { - public: // properties list: - eproperty::Value propertyShape; //!< Shape of the widget - eproperty::List propertySpinMode; //!< How to display the spin base - public: - UN_DECLARE_FACTORY(SpinBase); - protected: - ememory::Ptr this.config; - int this.confIdEntryShaper; - int this.confIdUpShaper; - int this.confIdDownShaper; - int this.confIdUpData; - int this.confIdDownData; - protected: - /** - * Constructor - * @param _mode The mode to display the elements - */ - SpinBase(); - void init() ; - public: - /** - * Destructor - */ - ~SpinBase(); - protected: - ewol::widget::Entry this.widgetEntry; - ewol::widget::Button this.widgetButtonDown; - ewol::widget::Button this.widgetButtonUp; - void updateGui(); - public: - boolean loadXML( exml::Element _node) ; - protected: - void onChangePropertySpinMode(); - void onChangePropertyShape(); - }; - } -} - diff --git a/old_widget/meta/StdPopUp.java b/old_widget/meta/StdPopUp.java index 0b7d651..ba8e17e 100644 --- a/old_widget/meta/StdPopUp.java +++ b/old_widget/meta/StdPopUp.java @@ -1,81 +1,57 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license MPL v2.0 (see license file) - */ -#pragma once -#include -#include -#include -#include -namespace ewol { - namespace widget { - class StdPopUp; - using StdPopUp = ememory::Ptr; - using StdPopUpWeak = ememory::WeakPtr; +/** + * The std pop up widget is a siple message widget to notify user of some simple things, like: + * + * [pre] + * +---------------------------------+---+---+---+ + * | Windows name... | _ | O | X | + * +---------------------------------+---+---+---+ + * | | + * | | + * | | + * | +-------------------+ | + * | | Title: | | + * | | | | + * | | Message to diplay | | + * | | to user | | + * | | | | + * | | Close | | + * | +-------------------+ | + * | | + * | | + * | | + * +---------------------------------------------+ + * [/pre] + */ +class StdPopUp : public ewol::widget::PopUp { + public: // properties: + String propertyTitle; //!< Title of the pop-up + String propertyComment; //!< comment in the pop-up (can be decorated text) + protected: /** - * The std pop up widget is a siple message widget to notify user of some simple things, like: - * - * [pre] - * +---------------------------------+---+---+---+ - * | Windows name... | _ | O | X | - * +---------------------------------+---+---+---+ - * | | - * | | - * | | - * | +-------------------+ | - * | | Title: | | - * | | | | - * | | Message to diplay | | - * | | to user | | - * | | | | - * | | Close | | - * | +-------------------+ | - * | | - * | | - * | | - * +---------------------------------------------+ - * [/pre] + * std-pop-up ructor. */ - class StdPopUp : public ewol::widget::PopUp { - public: // properties: - eproperty::Value propertyTitle; //!< Title of the pop-up - eproperty::Value propertyComment; //!< comment in the pop-up (can be decorated text) - protected: - /** - * std-pop-up ructor. - */ - StdPopUp(); - void init(); - public: - DECLARE_WIDGET_FACTORY(StdPopUp, "StdPopUp"); - /** - * std-pop-up destructor. - */ - ~StdPopUp(); - protected: - ewol::widget::Label this.title; //!< Title Label widget - /** - * property callback when request a change of the title. - */ - void onChangePropertyTitle(); - ewol::widget::Label this.comment; //!< Comment label widget - /** - * property callback when request a change of the Comment. - */ - void onChangePropertyComment(); - protected: - ewol::widget::Sizer this.subBar; //!< subwidget bar containing all the button. - public: - /** - * Add a buttom button. - * @param _text Decorated text to diplay in button. - */ - ewol::widget::Button addButton( String _text, boolean _autoExit=false); - public: - void onCallBackButtonExit(); - }; - } + StdPopUp(); + protected: + ewol::widget::Label this.title; //!< Title Label widget + /** + * property callback when request a change of the title. + */ + void onChangePropertyTitle(); + ewol::widget::Label this.comment; //!< Comment label widget + /** + * property callback when request a change of the Comment. + */ + void onChangePropertyComment(); + protected: + ewol::widget::Sizer subBar; //!< subwidget bar containing all the button. + public: + /** + * Add a buttom button. + * @param _text Decorated text to diplay in button. + */ + Button addButton( String _text, boolean _autoExit=false); + public: + void onCallBackButtonExit(); } diff --git a/resources/resources/ewol/data/ewol-gui-file-chooser.xml b/resources/resources/ewol/data/ewol-gui-file-chooser.xml index c370794..271fba7 100644 --- a/resources/resources/ewol/data/ewol-gui-file-chooser.xml +++ b/resources/resources/ewol/data/ewol-gui-file-chooser.xml @@ -1,18 +1,18 @@ - + - - - + + + - - + + - - - _T{ShowHiddenFiles} + _T{ShowHiddenFiles} - - diff --git a/resources/resources/ewol/theme/shape/Spin.json b/resources/resources/ewol/theme/shape/Spin.json index bc127f2..b34e106 100644 --- a/resources/resources/ewol/theme/shape/Spin.json +++ b/resources/resources/ewol/theme/shape/Spin.json @@ -1,7 +1,7 @@ { - entry-shaper:"THEME_GUI:///SpinEntry.json?lib=ewol", - up-shaper:"THEME_GUI:///SpinUp.json?lib=ewol", - up-data:"", - down-shaper:"THEME_GUI:///SpinDown.json?lib=ewol", - down-data:"", + "entry-shaper":"THEME:shape/SpinEntry.json?lib=ewol", + "up-shaper":"THEME:shape/SpinUp.json?lib=ewol", + "up-data":"", + "down-shaper":"THEME:shape/SpinDown.json?lib=ewol", + "down-data":"", } \ No newline at end of file diff --git a/resources/resources/ewol/theme/shape/SpinDown.json b/resources/resources/ewol/theme/shape/SpinDown.json index 4b8452c..09baba3 100644 --- a/resources/resources/ewol/theme/shape/SpinDown.json +++ b/resources/resources/ewol/theme/shape/SpinDown.json @@ -1,23 +1,20 @@ { - mode:2, - display-outside:false, + "padding-out-left":, + "padding-out-right":0, + "padding-out-top":2, + "padding-out-buttom":2, - padding-out-left:0, - padding-out-right:0, - padding-out-top:1, - padding-out-buttom:1, + "padding-in-left":2, + "padding-in-right":0, + "padding-in-top":2, + "padding-in-buttom":2, - border-left:1, - border-right:0, - border-top:1, - border-buttom:1, + "program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol", + "program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol", - padding-in-left:1, - padding-in-right:1, - padding-in-top:1, - padding-in-buttom:1, + "object-file":"THEME:shape/Button.emf?lib=ewol", - change-time:356, - program:"THEME_GUI:///Button.prog?lib=ewol", - color:"THEME_COLOR:///Button.json?lib=ewol" -} + "palette":"THEME:shape/palette_gui.json?lib=ewol", + + "change-time":200 +} \ No newline at end of file diff --git a/resources/resources/ewol/theme/shape/SpinEntry.json b/resources/resources/ewol/theme/shape/SpinEntry.json index 2c31f26..c69a2eb 100644 --- a/resources/resources/ewol/theme/shape/SpinEntry.json +++ b/resources/resources/ewol/theme/shape/SpinEntry.json @@ -1,23 +1,20 @@ { - mode:2, - display-outside:false, + "padding-out-left":0, + "padding-out-right":0, + "padding-out-top":2, + "padding-out-buttom":2, - padding-out-left:0, - padding-out-right:0, - padding-out-top:1, - padding-out-buttom:1, + "padding-in-left":2, + "padding-in-right":0, + "padding-in-top":2, + "padding-in-buttom":2, - border-left:1, - border-right:0, - border-top:1, - border-buttom:1, + "program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol", + "program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol", - padding-in-left:2, - padding-in-right:2, - padding-in-top:1, - padding-in-buttom:1, + "object-file":"THEME:shape/Entry.emf?lib=ewol", - change-time:356, - program:"THEME_GUI:///Entry.prog?lib=ewol", - color:"THEME_COLOR:///Entry.json?lib=ewol" + "palette":"THEME:shape/palette_gui.json?lib=ewol", + + "change-time":200 } diff --git a/resources/resources/ewol/theme/shape/SpinUp.json b/resources/resources/ewol/theme/shape/SpinUp.json index 0159a01..142535c 100644 --- a/resources/resources/ewol/theme/shape/SpinUp.json +++ b/resources/resources/ewol/theme/shape/SpinUp.json @@ -1,23 +1,20 @@ { - mode:2, - display-outside:false, + "padding-out-left":0, + "padding-out-right":0, + "padding-out-top":2, + "padding-out-buttom":2, - padding-out-left:0, - padding-out-right:0, - padding-out-top:1, - padding-out-buttom:1, + "padding-in-left":2, + "padding-in-right":2, + "padding-in-top":2, + "padding-in-buttom":2, - border-left:1, - border-right:1, - border-top:1, - border-buttom:1, + "program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol", + "program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol", - padding-in-left:1, - padding-in-right:1, - padding-in-top:1, - padding-in-buttom:1, + "object-file":"THEME:shape/Button.emf?lib=ewol", - change-time:356, - program:"THEME_GUI:///Button.prog?lib=ewol", - color:"THEME_COLOR:///Button.json?lib=ewol" + "palette":"THEME:shape/palette_gui.json?lib=ewol", + + "change-time":200 } diff --git a/samples/src/sample/atriasoft/ewol/sampleButton/MainWindows.java b/samples/src/sample/atriasoft/ewol/sampleButton/MainWindows.java index 6750fa1..6a844f6 100644 --- a/samples/src/sample/atriasoft/ewol/sampleButton/MainWindows.java +++ b/samples/src/sample/atriasoft/ewol/sampleButton/MainWindows.java @@ -11,7 +11,7 @@ public class MainWindows extends BasicWindows { public MainWindows() { setPropertyTitle("Simple Button test"); //final Widget data = Composer.composerGenerateString(""); - final Widget data = Composer.composerGenerateString(""); + final Widget data = Composer.composerGenerateString(""); /* final Widget data = Composer.composerGenerateString(""); diff --git a/src/org/atriasoft/ewol/compositing/GuiShape.java b/src/org/atriasoft/ewol/compositing/GuiShape.java index f90469c..64ac014 100644 --- a/src/org/atriasoft/ewol/compositing/GuiShape.java +++ b/src/org/atriasoft/ewol/compositing/GuiShape.java @@ -58,7 +58,7 @@ public class GuiShape extends Compositing { private ResourcePaletteFile palette; private ResourceTexture2 texture; - private ResourceMesh[] mesh = new ResourceMesh[2]; + private final ResourceMesh[] mesh = new ResourceMesh[2]; private Padding sizeObject = Padding.ZERO; private int stateActivate = -1; //!< Activate state of the element private GuiShapeMode stateNew = GuiShapeMode.NORMAL; //!< destination state @@ -120,7 +120,7 @@ public class GuiShape extends Compositing { draw(null, disableDepthTest); } - public void draw(final boolean disableDepthTest, int idMesh) { + public void draw(final boolean disableDepthTest, final int idMesh) { draw(null, disableDepthTest, idMesh); } @@ -128,7 +128,7 @@ public class GuiShape extends Compositing { this.draw(secondaryTexture, disableDepthTest, 0); } - public void draw(final ResourceTexture2 secondaryTexture, final boolean disableDepthTest, int idMesh) { + 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; @@ -149,19 +149,19 @@ public class GuiShape extends Compositing { } OpenGL.enable(Flag.flag_depthTest); // set Matrix : translation/positionMatrix - Matrix4f projMatrix = OpenGL.getMatrix(); - Matrix4f camMatrix = OpenGL.getCameraMatrix(); - Matrix4f tmpMatrix = this.matrixApply.multiply(this.transform); + final Matrix4f projMatrix = OpenGL.getMatrix(); + final Matrix4f camMatrix = OpenGL.getCameraMatrix(); + final Matrix4f tmpMatrix = this.matrixApply.multiply(this.transform); this.oGLprogram.use(); this.mesh[idMesh].bindForRendering(); this.oGLprogram.uniformMatrix(this.oGLMatrixProjection, projMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixTransformation, tmpMatrix); this.oGLprogram.uniformMatrix(this.oGLMatrixView, camMatrix); - Set layers = this.mesh[idMesh].getLayers(); + final Set layers = this.mesh[idMesh].getLayers(); Log.verbose("get layers:" + layers); // Texture: - float imageDelta = (float) 1 / ResourcePaletteFile.getHeight(); + final float imageDelta = (float) 1 / ResourcePaletteFile.getHeight(); float basicValue = this.stateOld.getValue() / ResourcePaletteFile.getHeight(); if (this.stateOld != this.stateNew) { if (this.stateOld == GuiShapeMode.NORMAL) { @@ -314,8 +314,8 @@ public class GuiShape extends Compositing { } protected void loadPalette() { - String paletteFile = this.config.getString(this.confIdPaletteFile); - Uri paletteFileInterface = Uri.valueOf(paletteFile); + 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) { @@ -344,8 +344,8 @@ public class GuiShape extends Compositing { Log.debug("no Shaper set for loading resources ..."); return; } - String basicShaderFileVert = this.config.getString(this.confProgramFileVert); - String basicShaderFileFrag = this.config.getString(this.confProgramFileFrag); + 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)); if (this.oGLprogram != null) { @@ -367,10 +367,10 @@ public class GuiShape extends Compositing { Log.debug("no Shaper set for loading resources ..."); return; } - String objectFile = this.config.getString(this.confObjectFile); + final String objectFile = this.config.getString(this.confObjectFile); if (!objectFile.isEmpty()) { this.mesh[0] = ResourceMesh.create(Uri.valueOf(objectFile)); - List verticesToModify = this.mesh[0].getGeneratedPosition(); + final List verticesToModify = this.mesh[0].getGeneratedPosition(); float top = 0; float bottom = 0; float left = 0; @@ -392,10 +392,10 @@ public class GuiShape extends Compositing { } this.sizeObject = new Padding(Math.abs(left), Math.abs(top), Math.abs(right), Math.abs(bottom)); } - String objectFile2 = this.config.getString(this.confObjectFile2); + final String objectFile2 = this.config.getString(this.confObjectFile2); if (!objectFile2.isEmpty()) { this.mesh[1] = ResourceMesh.create(Uri.valueOf(objectFile2)); - List verticesToModify = this.mesh[1].getGeneratedPosition(); + final List verticesToModify = this.mesh[1].getGeneratedPosition(); float top = 0; float bottom = 0; float left = 0; @@ -444,7 +444,7 @@ public class GuiShape extends Compositing { // check if no new state requested: if (this.nextStatusRequested != GuiShapeMode.NONE && this.stateTransition < 0.5) { // invert sources with destination - GuiShapeMode tmppp = this.stateOld; + final GuiShapeMode tmppp = this.stateOld; this.stateOld = this.stateNew; this.stateNew = tmppp; this.stateTransition = 1.0f - this.stateTransition; @@ -474,7 +474,7 @@ public class GuiShape extends Compositing { // @previous public void setShape(final Vector2f origin, final Vector2f size) { - Padding tmp = getPadding(); + final Padding tmp = getPadding(); setShape(origin, size, origin.add(tmp.left(), tmp.bottom()), size.less(tmp.x(), tmp.y())); } @@ -522,7 +522,7 @@ public class GuiShape extends Compositing { */ 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); - Vector2f halfSize = insideSize.multiply(0.5f); + final Vector2f halfSize = insideSize.multiply(0.5f); this.offsetScaleOutside = new Vector3f(halfSize.x(), halfSize.y(), 1.0f); this.offsetScaleInside = new Vector3f(halfSize.x() + this.sizeObject.x() * 0.25f, halfSize.y() + this.sizeObject.y() * 0.25f, 1.0f); /* @@ -549,12 +549,12 @@ public class GuiShape extends Compositing { // } public void setShape(final Vector3f origin, final Vector3f size) { - Padding tmp = getPadding(); + 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) { - Vector3f halfSize = insideSize.multiply(0.5f); + final Vector3f halfSize = insideSize.multiply(0.5f); this.offsetScaleOutside = halfSize; this.offsetScaleInside = halfSize.add(this.sizeObject.x() * 0.25f, this.sizeObject.y() * 0.25f, 0); /* @@ -579,6 +579,9 @@ public class GuiShape extends Compositing { clear(); unLoadProgram(); this.uri = uri; + loadConfigFile(); + loadUpdateObjectSize(); + loadPalette(); loadProgram(); } diff --git a/src/org/atriasoft/ewol/resource/ResourceConfigFile.java b/src/org/atriasoft/ewol/resource/ResourceConfigFile.java index 3528b4e..e720550 100644 --- a/src/org/atriasoft/ewol/resource/ResourceConfigFile.java +++ b/src/org/atriasoft/ewol/resource/ResourceConfigFile.java @@ -32,14 +32,13 @@ public class ResourceConfigFile extends Resource { * @param name Name of the configuration file. * @return pointer on the resource or null if an error occurred. */ - @SuppressWarnings("preview") public static ResourceConfigFile create(final Uri name) { Resource resource2 = null; if (name != null && !name.isEmpty()) { resource2 = Resource.getManager().localKeep(name); } if (resource2 != null) { - if (resource2 instanceof ResourceConfigFile tmpp) { + if (resource2 instanceof final ResourceConfigFile tmpp) { resource2.keep(); return tmpp; } @@ -110,7 +109,7 @@ public class ResourceConfigFile extends Resource { @Override public synchronized void reload() { // reset all parameters - for (ListElementConfig listElementConfig : this.list) { + for (final ListElementConfig listElementConfig : this.list) { listElementConfig.node = null; } JsonObject out; diff --git a/src/org/atriasoft/ewol/widget/Button.java b/src/org/atriasoft/ewol/widget/Button.java index 6772b71..43de832 100644 --- a/src/org/atriasoft/ewol/widget/Button.java +++ b/src/org/atriasoft/ewol/widget/Button.java @@ -335,6 +335,9 @@ public class Button extends ContainerToggle { this.signalClick.emit(); if (this.propertyToggleMode) { this.setPropertyValue(!this.propertyValue); + } else { + this.setPropertyValue(!this.propertyValue); + this.setPropertyValue(!this.propertyValue); } return true; } diff --git a/src/org/atriasoft/ewol/widget/ContainerToggle.java b/src/org/atriasoft/ewol/widget/ContainerToggle.java index c891f33..5e82a1f 100644 --- a/src/org/atriasoft/ewol/widget/ContainerToggle.java +++ b/src/org/atriasoft/ewol/widget/ContainerToggle.java @@ -157,6 +157,11 @@ public class ContainerToggle extends Widget { onChangeSize(); } + @XmlManaged(value = false) + public void setSubWidget(final Widget newWidget) { + setSubWidget(newWidget, 0); + } + /** * set the subWidget node widget. * @param newWidget The widget to add. diff --git a/src/org/atriasoft/ewol/widget/Spin.java b/src/org/atriasoft/ewol/widget/Spin.java new file mode 100644 index 0000000..924a392 --- /dev/null +++ b/src/org/atriasoft/ewol/widget/Spin.java @@ -0,0 +1,199 @@ +package org.atriasoft.ewol.widget; + +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.annotation.EwolDescription; +import org.atriasoft.ewol.annotation.EwolSignal; +import org.atriasoft.ewol.internal.Log; +import org.atriasoft.ewol.widget.meta.SpinBase; +import org.atriasoft.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; + +/** + * 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 { + // Event list of properties + @EwolSignal(name = "value", description = "Spin updated value (depend of the mantis)") + public Signal signalValue = new Signal<>(); + @EwolSignal(name = "valueDouble", description = "Spin value change value in 'double' (application of the mantis)") + public Signal signalValueDouble = new Signal<>(); + protected long propertyValue = 0; //!< Current value of the Spin. + protected long propertyMin = Long.MIN_VALUE; //!< Minimum value + protected long propertyMax = Long.MAX_VALUE; //!< Maximum value + protected long propertyIncrement = 1; //!< Increment value + protected int propertyMantis = 0; //!< number of value under '.' value + // connection to the elements interface. + protected Connection connectionEntry = new Connection(); + protected Connection connectionButtonUp = new Connection(); + protected Connection connectionButtonDown = new Connection(); + + /** + * Constructor + * @param _mode mode to display the spin + * @param _shaperName Shaper file properties + */ + public Spin() { + 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; + // TODO: manage the mantis ... + this.widgetEntry.setPropertyValue(Long.toString(value)); + this.signalValue.emit(this.propertyValue); + } + + public void connectGui() { + Log.warning("updateGui [START]"); + super.updateGui(); + + if (this.widgetEntry != null && !this.connectionEntry.isConnected()) { + this.connectionEntry = this.widgetEntry.signalModify.connect(this, Spin::onCallbackModify); + // TODO: set a regExp Filter + } + if (this.widgetButtonUp != null && !this.connectionButtonUp.isConnected()) { + this.connectionButtonUp = this.widgetButtonUp.signalValue.connect(this, Spin::onCallbackUp); + } + if (this.widgetButtonDown != null && !this.connectionButtonDown.isConnected()) { + this.connectionButtonDown = this.widgetButtonDown.signalValue.connect(this, Spin::onCallbackDown); + } + checkValue(this.propertyValue); + Log.warning("updateGui [STOP]"); + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "increment") + @EwolDescription(value = "Increment value at each button event or keybord event") + public long getPropertyIncrement() { + return this.propertyIncrement; + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "mantis") + @EwolDescription(value = "fix-point mantis element (number of digit under the .)") + public int getPropertyMantis() { + return this.propertyMantis; + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "max") + @EwolDescription(value = "Maximum value of the spin (depend on mantis)") + public long getPropertyMax() { + return this.propertyMax; + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "min") + @EwolDescription(value = "Minimum value of the spin (depend on mantis)") + public long getPropertyMin() { + return this.propertyMin; + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "value") + @EwolDescription(value = "Value of the Spin") + public long getPropertyValue() { + return this.propertyValue; + } + + protected void onCallbackDown(final Boolean value) { + if (value) { + return; + } + final long data = this.propertyValue - this.propertyIncrement; + checkValue(data); + } + + protected void onCallbackModify(final String value) { + if (value.isEmpty()) { + return; + } + final long value1 = Long.valueOf(value); + checkValue(value1); + } + + protected void onCallbackUp(final Boolean value) { + if (value) { + return; + } + 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 ..."); + return; + } + checkValue(this.propertyValue); + } + + public void setPropertyIncrement(final long propertyIncrement) { + if (this.propertyIncrement == propertyIncrement) { + return; + } + this.propertyIncrement = propertyIncrement; + onChangePropertyIncrement(); + } + + public void setPropertyMantis(final int propertyMantis) { + if (this.propertyMantis == propertyMantis) { + return; + } + this.propertyMantis = propertyMantis; + onChangePropertyMantis(); + } + + public void setPropertyMax(final long propertyMax) { + if (this.propertyMax == propertyMax) { + return; + } + this.propertyMax = propertyMax; + onChangePropertyMax(); + } + + public void setPropertyMin(final long propertyMin) { + if (this.propertyMin == propertyMin) { + return; + } + this.propertyMin = propertyMin; + onChangePropertyMin(); + } + + public void setPropertyValue(final long propertyValue) { + if (this.propertyValue == propertyValue) { + return; + } + this.propertyValue = propertyValue; + onChangePropertyValue(); + } +} diff --git a/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java b/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java index b013e31..0bddffa 100644 --- a/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java +++ b/src/org/atriasoft/ewol/widget/WidgetXmlFactory.java @@ -20,6 +20,7 @@ public class WidgetXmlFactory implements InterfaceXmlFactoryAccess { listWidgetAvaillable.put("ListFileSystem", ListFileSystem.class); listWidgetAvaillable.put("PopUp", PopUp.class); listWidgetAvaillable.put("FileChooser", FileChooser.class); + listWidgetAvaillable.put("Spin", Spin.class); } @Override diff --git a/src/org/atriasoft/ewol/widget/meta/FileChooser.java b/src/org/atriasoft/ewol/widget/meta/FileChooser.java index 5934ecf..81f961a 100644 --- a/src/org/atriasoft/ewol/widget/meta/FileChooser.java +++ b/src/org/atriasoft/ewol/widget/meta/FileChooser.java @@ -91,7 +91,7 @@ public class FileChooser extends Composer { // == > change the file name.get(.get( self.propertyFile = value; // update the selected file in the list : - if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-shooser: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)); } } @@ -102,10 +102,10 @@ public class FileChooser extends Composer { } protected static void onCallbackHidenFileChangeChangeValue(final FileChooser self, final Boolean value) { - if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-shooser: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-shooser:list-folder") instanceof final ListFileSystem tmp) { + if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-chooser:list-folder") instanceof final ListFileSystem tmp) { tmp.setPropertyShowHidden(value); } } @@ -182,30 +182,30 @@ public class FileChooser extends Composer { onChangePropertyLabelValidate(); onChangePropertyLabelCancel(); - if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:show-hiden-file") instanceof final CheckBox tmp) { + if (this.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-shooser:button-validate") instanceof final Button tmp) { + if (this.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-shooser:button-cancel") instanceof final Button tmp) { + if (this.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-shooser:list-folder") instanceof final ListFileSystem tmp) { + if (this.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-shooser:list-files") instanceof final ListFileSystem tmp) { + if (this.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-shooser:entry-file") instanceof final Entry tmp) { + if (this.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-shooser:entry-folder") instanceof final Entry tmp) { + if (this.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-shooser:img-home") instanceof final ImageDisplay tmp) { + if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:img-home") instanceof final ImageDisplay tmp) { tmp.signalPressed.connectAuto(this, FileChooser::onCallbackHomePressed); } // set the default Folder properties: @@ -235,25 +235,25 @@ public class FileChooser extends Composer { } protected void onChangePropertyFile() { - if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-file") instanceof final ListFileSystem tmp) { + if (this.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-shooser:cancel-label") instanceof final Label tmp) { + if (this.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-shooser:title-label") instanceof final Label tmp) { + if (this.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-shooser:validate-label") instanceof final Label tmp) { + if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:validate-label") instanceof final Label tmp) { tmp.setPropertyValue(this.propertyLabelValidate); } } @@ -266,7 +266,7 @@ public class FileChooser extends Composer { @Override public void onGetFocus() { // transfert focus on a specific widget... - if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-folder") instanceof final Entry tmp) { + if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-folder") instanceof final Entry tmp) { tmp.keepFocus(); } } @@ -331,13 +331,13 @@ public class FileChooser extends Composer { } private void updateCurrentFolder() { - if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser: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-shooser: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-shooser:entry-folder") instanceof final Entry tmp) { + if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-chooser:entry-folder") instanceof final Entry tmp) { tmp.setPropertyValue(this.propertyPath); } markToRedraw(); diff --git a/src/org/atriasoft/ewol/widget/meta/SpinBase.java b/src/org/atriasoft/ewol/widget/meta/SpinBase.java new file mode 100644 index 0000000..995bd4f --- /dev/null +++ b/src/org/atriasoft/ewol/widget/meta/SpinBase.java @@ -0,0 +1,182 @@ +package org.atriasoft.ewol.widget.meta; + +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector3b; +import org.atriasoft.ewol.Gravity; +import org.atriasoft.ewol.annotation.EwolDescription; +import org.atriasoft.ewol.internal.Log; +import org.atriasoft.ewol.resource.ResourceConfigFile; +import org.atriasoft.ewol.widget.Button; +import org.atriasoft.ewol.widget.Composer; +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.atriasoft.exml.annotation.XmlAttribute; +import org.atriasoft.exml.annotation.XmlManaged; +import org.atriasoft.exml.annotation.XmlName; + +/** + * @ingroup ewolWidgetGroup + */ +public class SpinBase extends Sizer { + // properties list: + private Uri propertyShape; //!< Shape of the widget + private SpinPosition propertySpinMode = SpinPosition.RIGHT_RIGHT; //!< How to display the spin base + protected ResourceConfigFile config; + protected int confIdEntryShaper = -1; + protected int confIdUpShaper = -1; + 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 + */ + protected SpinBase(final Uri shape) { + setPropertyShape(shape); + /* + propertySpinMode.add(ewol::widget::spinPosition_noneNone, "none-none"); + propertySpinMode.add(ewol::widget::spinPosition_noneRight, "none-right"); + propertySpinMode.add(ewol::widget::spinPosition_leftNone, "left-none"); + propertySpinMode.add(ewol::widget::spinPosition_leftRight, "left-right"); + propertySpinMode.add(ewol::widget::spinPosition_leftLeft, "left-left"); + propertySpinMode.add(ewol::widget::spinPosition_RightRight, "right-right"); + */ + setPropertyGravity(Gravity.CENTER); + updateGui(); + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "shape") + @EwolDescription(value = "shape for the display") + public Uri getPropertyShape() { + return this.propertyShape; + } + + @XmlManaged + @XmlAttribute + @XmlName(value = "spin-mode") + @EwolDescription(value = "The display spin mode") + public SpinPosition getPropertySpinMode() { + return this.propertySpinMode; + } + + protected void onChangePropertyShape() { + this.config = ResourceConfigFile.create(this.propertyShape); + if (this.config != null) { + this.confIdEntryShaper = this.config.request("entry-shaper"); + this.confIdUpShaper = this.config.request("up-shaper"); + this.confIdDownShaper = this.config.request("down-shaper"); + this.confIdUpData = this.config.request("up-data"); + this.confIdDownData = this.config.request("down-data"); + } + markToRedraw(); + } + + protected void onChangePropertySpinMode() { + updateGui(); + } + + public void setPropertyShape(final Uri propertyShape) { + if (this.propertyShape != null && this.propertyShape.equals(propertyShape)) { + return; + } + this.propertyShape = propertyShape; + onChangePropertyShape(); + } + + public void setPropertySpinMode(final SpinPosition propertySpinMode) { + if (this.propertySpinMode == propertySpinMode) { + return; + } + this.propertySpinMode = propertySpinMode; + onChangePropertySpinMode(); + } + + protected void updateGui() { + subWidgetRemoveAll(); + markToRedraw(); + requestUpdateSize(); + if (this.widgetEntry == null) { + this.widgetEntry = new Entry(); + if (this.config != null) { + final String shaper = this.config.getString(this.confIdEntryShaper); + Log.verbose("shaper entry : " + shaper); + if (!shaper.isEmpty()) { + this.widgetEntry.setPropertyConfig(Uri.valueOf(shaper)); + } + } + this.widgetEntry.setPropertyExpand(new Vector3b(true, false, false)); + this.widgetEntry.setPropertyFill(Vector3b.TRUE); + } + if (this.widgetButtonDown == null) { + this.widgetButtonDown = new Button(); + if (this.config != null) { + final String shaper = this.config.getString(this.confIdDownShaper); + Log.verbose("shaper button DOWN : " + shaper); + if (!shaper.isEmpty()) { + this.widgetButtonDown.setPropertyConfig(Uri.valueOf(shaper)); + } + } + this.widgetButtonDown.setPropertyExpand(new Vector3b(false, false, false)); + this.widgetButtonDown.setPropertyFill(Vector3b.TRUE); + final String data = this.config.getString(this.confIdDownData); + final Widget widget = Composer.composerGenerateString(data); + this.widgetButtonDown.setSubWidget(widget, 0); + } + if (this.widgetButtonUp == null) { + this.widgetButtonUp = new Button(); + if (this.config != null) { + final String shaper = this.config.getString(this.confIdUpShaper); + Log.verbose("shaper button UP : " + shaper); + if (!shaper.isEmpty()) { + this.widgetButtonUp.setPropertyConfig(Uri.valueOf(shaper)); + } + } + this.widgetButtonUp.setPropertyExpand(new Vector3b(false, false, false)); + this.widgetButtonUp.setPropertyFill(Vector3b.TRUE); + final String data = this.config.getString(this.confIdUpData); + final Widget widget = Composer.composerGenerateString(data); + this.widgetButtonUp.setSubWidget(widget); + } + switch (this.propertySpinMode) { + case NONE_NONE: + subWidgetAdd(this.widgetEntry); + break; + case NONE_RIGHT: + subWidgetAdd(this.widgetEntry); + subWidgetAdd(this.widgetButtonUp); + break; + case LEFT_NONE: + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetEntry); + break; + case LEFT_RIGHT: + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetEntry); + subWidgetAdd(this.widgetButtonUp); + break; + case LEFT_LEFT: + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetButtonUp); + subWidgetAdd(this.widgetEntry); + break; + case RIGHT_RIGHT: + subWidgetAdd(this.widgetEntry); + subWidgetAdd(this.widgetButtonDown); + subWidgetAdd(this.widgetButtonUp); + break; + default: + break; + } + } + +} diff --git a/src/org/atriasoft/ewol/widget/model/SpinPosition.java b/src/org/atriasoft/ewol/widget/model/SpinPosition.java new file mode 100644 index 0000000..8adde23 --- /dev/null +++ b/src/org/atriasoft/ewol/widget/model/SpinPosition.java @@ -0,0 +1,40 @@ +package org.atriasoft.ewol.widget.model; + +public enum SpinPosition { + /** show like: + * +------------------------+ + * | | + * +------------------------+ + */ + NONE_NONE, + /** show like: + * +--------------------+---+ + * | | | + * +--------------------+---+ + */ + NONE_RIGHT, + /** show like: + * +---+--------------------+ + * | | | + * +---+--------------------+ + */ + LEFT_NONE, + /** show like: + * +---+----------------+---+ + * | | | | + * +---+----------------+---+ + */ + LEFT_RIGHT, + /** show like: + * +---+---+----------------+ + * | | | | + * +---+---+----------------+ + */ + LEFT_LEFT, + /** show like: + * +----------------+---+---+ + * | | | | + * +----------------+---+---+ + */ + RIGHT_RIGHT, +}