[DEV] add pop-up with correct model

This commit is contained in:
Edouard DUPIN 2022-04-26 22:25:18 +02:00
parent f8f872f5aa
commit f02987f8bf
21 changed files with 423 additions and 600 deletions

View File

@ -1,179 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/PopUp.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/object/Manager.hpp>
#include <ewol/ewol.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::widget::PopUp);
static char* annimationIncrease = "increase";
ewol::widget::PopUp::PopUp() :
propertyShape(this, "shaper",
etk::Uri("THEME_GUI:///PopUp.json?lib=ewol"),
"The shaper properties",
ewol::widget::PopUp::onChangePropertyShape),
propertyLockExpand(this, "lock",
Vector2b(true,true),
"Lock expand contamination",
ewol::widget::PopUp::onChangePropertyLockExpand),
propertyCloseOutEvent(this, "out-click-remove",
false,
"Remove the widget if the use click outside") {
addObjectType("ewol::widget::PopUp");
}
void ewol::widget::PopUp::init() {
ewol::widget::Container::init();
propertyFill.set(Vector2b(false,false));
propertyShape.notifyChange();
propertyMinSize.set(gale::Dimension(Vector2f(80,80),gale::distance::pourcent));
propertyExpand.set(Vector2b(false, false));
}
ewol::widget::PopUp::~PopUp() {
}
void ewol::widget::PopUp::onChangeSize() {
markToRedraw();
if (this.subWidget == null) {
return;
}
ewol::Padding padding = this.shaper.getPadding();
Vector2f subWidgetSize = this.subWidget.getCalculateMinSize();
if (this.subWidget.canExpand().x() == true) {
if (propertyLockExpand.x() == true) {
subWidgetSize.setX(this.minSize.x());
} else {
subWidgetSize.setX(this.size.x()-padding.xLeft());
}
}
if (this.subWidget.canExpand().y() == true) {
if (propertyLockExpand.y() == true) {
subWidgetSize.setY(this.minSize.y());
} else {
subWidgetSize.setY(this.size.y()-padding.yButtom());
}
}
// limit the size of the element :
//subWidgetSize.setMin(this.minSize);
// posiition at a int pos :
subWidgetSize = Vector2fClipInt32(subWidgetSize);
// set config to the Sub-widget
Vector2f subWidgetOrigin = this.origin + (this.size-subWidgetSize)/2.0f;
subWidgetOrigin = Vector2fClipInt32(subWidgetOrigin);
this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize();
}
void ewol::widget::PopUp::systemDraw( ewol::DrawProperty _displayProp) {
if (*propertyHide == true){
// widget is hidden ...
return;
}
Widget::systemDraw(_displayProp);
if (this.subWidget == null) {
return;
}
if( this.shaper.getNextDisplayedStatus() == -1
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.shaper.getTransitionStatus() >= 1.0) {
ewol::DrawProperty prop = _displayProp;
prop.limit(this.origin, this.size);
this.subWidget.systemDraw(prop);
}
}
void ewol::widget::PopUp::onDraw() {
this.shaper.draw();
}
void ewol::widget::PopUp::onRegenerateDisplay() {
if (needRedraw() == true) {
this.shaper.clear();
ewol::Padding padding = this.shaper.getPadding();
Vector2f tmpSize(0,0);
Vector2b expand = canExpand();
Vector2b fill = canFill();
if (fill.x() == true) {
tmpSize.setX(this.size.x()-padding.x());
}
if (fill.y() == true) {
tmpSize.setY(this.size.y()-padding.y());
}
if (this.subWidget != null) {
Vector2f tmpSize = this.subWidget.getSize();
}
tmpSize.setMax(this.minSize);
Vector2f tmpOrigin = (this.size-tmpSize)/2.0f;
this.shaper.setShape(Vector2f(0,0),
Vector2fClipInt32(this.size),
Vector2fClipInt32(tmpOrigin-Vector2f(padding.xLeft(), padding.yButtom())),
Vector2fClipInt32(tmpSize + Vector2f(padding.x(), padding.y())));
}
// SUBwIDGET GENERATION ...
if (this.subWidget != null) {
this.subWidget.onRegenerateDisplay();
}
}
Widget ewol::widget::PopUp::getWidgetAtPos( Vector2f _pos) {
Widget val = ewol::widget::Container::getWidgetAtPos(_pos);
if (val != null) {
return val;
}
return ememory::dynamicPointerCast<Widget>(sharedFromThis());
}
void ewol::widget::PopUp::onChangePropertyShape() {
this.shaper.setSource(*propertyShape);
markToRedraw();
requestUpdateSize();
}
void ewol::widget::PopUp::onChangePropertyLockExpand() {
markToRedraw();
requestUpdateSize();
}
boolean ewol::widget::PopUp::onEventInput( ewol::event::Input _event) {
if (_event.getId() == 0) {
return false;
}
if (_event.getStatus() == KeyStatus::move) {
return false;
}
if (*propertyCloseOutEvent == true) {
return false;
}
ewol::Padding padding = this.shaper.getPadding();
Vector2f tmpSize(0,0);
if (this.subWidget != null) {
Vector2f tmpSize = this.subWidget.getSize();
}
tmpSize.setMax(this.minSize);
Vector2f tmpOrigin = (this.size-tmpSize)/2.0f;
tmpOrigin -= Vector2f(padding.xLeft(), padding.yButtom());
tmpSize += Vector2f(padding.x(), padding.y());
Vector2f pos = relativePosition(_event.getPos());
if( pos.x() < tmpOrigin.x()
|| pos.y() < tmpOrigin.y()
|| pos.x() > tmpOrigin.x()+tmpSize.x()
|| pos.y() > tmpOrigin.y()+tmpSize.y() ) {
autoDestroy();
return true;
}
return false;
}

View File

@ -1,58 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/Widget.hpp>
#include <ewol/widget/Container.hpp>
#include <ewol/compositing/Drawing.hpp>
#include <ewol/compositing/Shaper.hpp>
#include <ewol/widget/Manager.hpp>
namespace ewol {
namespace widget {
class PopUp;
using PopUp = ememory::Ptr<ewol::widget::PopUp>;
using PopUpWeak = ememory::WeakPtr<ewol::widget::PopUp>;
/**
* @ingroup ewolWidgetGroup
*/
class PopUp : public ewol::widget::Container {
public: // properties
eproperty::Value<etk::Uri> propertyShape; //!< Compositing theme.
eproperty::Value<Vector2b> propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
eproperty::Value<bool> propertyCloseOutEvent; //!< ratio progression of a sliding
protected:
/**
* Constructor
* @param _shaperName Shaper file properties
*/
PopUp();
void init() ;
public:
DECLARE_WIDGET_FACTORY(PopUp, "PopUp");
/**
* Destructor
*/
~PopUp();
protected:
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
protected:
void onDraw() ;
public:
void systemDraw( ewol::DrawProperty _displayProp) ;
void onRegenerateDisplay() ;
void onChangeSize() ;
boolean onEventInput( ewol::event::Input _event) ;
Widget getWidgetAtPos( Vector2f _pos) ;
protected:
void onChangePropertyShape();
void onChangePropertyLockExpand();
};
};
};

View File

@ -1,4 +1,4 @@
<Composer>
<PopUp>
<Sizer mode="VERTICAL" lock="true" fill="true" expand="true">
<Label name="[{ID}]file-shooser:title-label">_T{Title}</Label>
<Sizer mode="HORIZONTAL">
@ -45,4 +45,4 @@
</Button >
</Sizer >
</Sizer>
</Composer>
</PopUp>

View File

@ -0,0 +1,71 @@
EMF(STRING)
# Blender v3.1.2 EMF File: 'PopUp.blend'
Mesh:PopUp_Cube
Vertex:16
20.042355 19.982376 -7.860689|20.042355 -20.102333 -7.862826|20.042355 19.981716 4.524041|20.042355 -20.102993 4.521903|-20.042355 19.982376 -7.860689|-20.042355 -20.102333 -7.862826|-20.042355 19.981716 4.524041|-20.042355 -20.102993 4.521903|10.127714 10.066911 7.616918|10.127714 -10.188519 7.615837|-10.127714 10.066911 7.616918|-10.127714 -10.188519 7.615837|-10.199120 -10.192897 -7.028094|-10.199120 10.181330 -7.027014|10.199120 10.181330 -7.027014|10.199120 -10.192897 -7.028094|
UV-mapping:
0.074219 0.995849|0.120606 0.943115|0.121582 0.993408|0.112927 0.992387|0.078245 0.948093|0.073324 0.991157|0.101769 0.970961|0.080974 0.959440|0.102023 0.957458|0.111927 0.985005|0.078476 0.953015|0.082167 0.983774|0.074219 0.944092|0.111696 0.944402|0.080720 0.975385|0.113157 0.949323|0.174907 0.947863|0.131613 0.991157|0.132843 0.945402|0.178368 0.944941|0.137534 0.984544|0.142456 0.948632|0.171985 0.949093|0.136074 0.991157|0.137304 0.950323|0.174677 0.949093|0.135074 0.992387|0.136304 0.949093|0.178598 0.993618|0.178368 0.988235|0.173216 0.991157|0.175907 0.989926|0.013265 0.951784|0.051868 0.992387|0.013034 0.993618|0.054098 0.951784|0.137534 0.988235|0.177138 0.947863|0.135074 0.947862|0.172446 0.988465|
Normal(face):28
-0.297843 -0.000051 0.954615|0.000000 -0.297894 0.954599|0.000000 0.297792 0.954631|0.297843 -0.000051 0.954615|0.000000 1.000000 0.000053|-1.000000 0.000000 0.000000|0.000000 -1.000000 -0.000053|1.000000 -0.000000 -0.000000|-0.999988 0.000000 -0.004876|0.000000 -0.999969 -0.007813|0.999988 0.000000 -0.004876|0.000000 1.000000 -0.000299|0.000000 -0.000053 1.000000|0.000000 0.000053 -1.000000|
Face:28
palette:gui_border_1
7/0/0 10/1/0 6/2/0| 3/3/1 11/4/1 7/5/1| 6/6/2 8/7/2 2/8/2| 2/9/3 9/10/3 3/11/3| 7/0/0 11/12/0 10/1/0| 3/3/1 9/13/1 11/4/1| 6/6/2 10/14/2 8/7/2| 2/9/3 8/15/3 9/10/3|
palette:gui_border_2
4/16/4 2/17/4 0/18/4| 6/19/5 5/20/5 7/21/5| 1/22/6 7/23/6 5/24/6| 0/25/7 3/26/7 1/27/7| 4/16/4 6/28/4 2/17/4| 6/19/5 4/29/5 5/20/5| 1/22/6 3/30/6 7/23/6| 0/25/7 2/31/7 3/26/7|
palette:gui_border_inside
8/7/8 15/32/8 9/10/8| 13/33/9 8/7/9 10/14/9| 10/14/10 12/34/10 13/33/10| 15/32/11 11/4/11 9/10/11| 8/7/8 14/35/8 15/32/8| 13/33/9 14/35/9 8/7/9| 10/14/10 11/4/10 12/34/10| 15/32/11 12/34/11 11/4/11|
palette:gui_center
15/32/12 13/33/12 12/34/12| 15/32/12 14/35/12 13/33/12|
palette:gui_back
5/36/13 0/37/13 1/38/13| 5/36/13 4/39/13 0/37/13|
# Just for information:
Palettes:gui_back
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.000000 0.005632
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_border_1
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.002615 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_border_2
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.800000 0.170495
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_border_inside
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.003877 0.001682 0.147314
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2
# Just for information:
Palettes:gui_center
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.438544 0.438544 0.438544
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
vNi 1.450000
d 1.000000
illum 2

View File

@ -1,27 +0,0 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_border;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
varying vec2 v_propPos;
void main(void) {
// prevent origin moving ...
gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0);
if( v_propPos.x == 1.0
&& v_propPos.y == 1.0) {
gl_FragColor = EW_foreground;
} else if ( v_propPos.x == 0.0
|| v_propPos.y == 0.0) {
gl_FragColor = EW_background;
} else {
gl_FragColor = EW_border;
}
}

View File

@ -1,23 +1,30 @@
{
mode:2,
display-outside:false,
# padding "outside" the object in pixel ==> prevent bad display
"padding-out-left":2,
"padding-out-right":2,
"padding-out-top":2,
"padding-out-buttom":2,
padding-out-left:2,
padding-out-right:2,
padding-out-top:2,
padding-out-buttom:2,
# border description
"border-left":3,
"border-right":3,
"border-top":3,
"border-buttom":3,
border-left:3,
border-right:3,
border-top:3,
border-buttom:3,
# padding "inside" the object in pixel ==> prevent bad display
"padding-in-left":2,
"padding-in-right":2,
"padding-in-top":2,
"padding-in-buttom":2,
padding-in-left:2,
padding-in-right:2,
padding-in-top:2,
padding-in-buttom:2,
# render program:
"program-vert":"THEME:shape/aaRenderShape.vert?lib=ewol",
"program-frag":"THEME:shape/aaRenderShape.frag?lib=ewol",
change-time:356,
program:"THEME_GUI:///PopUp.prog?lib=ewol",
color:"THEME_COLOR:///PopUp.json?lib=ewol"
# Object to render (with modification)
"object-file":"THEME:shape/PopUp.emf?lib=ewol",
"palette":"THEME:shape/palette_gui.json?lib=ewol",
"change-time":200
}

View File

@ -1,17 +0,0 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// Input :
attribute vec2 EW_coord2d;
attribute vec2 EW_widgetPropertyPos;
uniform mat4 EW_MatrixTransformation;
// output :
varying vec2 v_propPos;
void main(void) {
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
v_propPos = EW_widgetPropertyPos;
}

View File

@ -1,28 +0,0 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
varying vec2 v_propPos;
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
varying vec4 v_colorInside;
void main(void) {
// prevent origin moving ...
gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0);
if( v_propPos.x == 1.0
&& v_propPos.y == 1.0) {
gl_FragColor = v_colorTansition;
} else if ( v_propPos.x == 0.0
|| v_propPos.y == 0.0) {
gl_FragColor = v_colorBackground;
} else {
gl_FragColor = v_colorBorder;
}
}

View File

@ -1,71 +0,0 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct widgetStateProperty {
int activate;
int stateOld;
int stateNew;
float transition;
};
uniform widgetStateProperty EW_status;
// Input :
attribute vec2 EW_coord2d;
attribute vec2 EW_widgetPropertyPos;
uniform mat4 EW_MatrixTransformation;
uniform vec4 EW_border;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_foregroundHover;
uniform vec4 EW_foregroundSelected;
uniform vec4 EW_foregroundPressed;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec2 v_propPos;
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
varying vec4 v_colorInside;
void main(void) {
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
// transmit position of the curent element (intermolated ...)
v_position = EW_coord2d;
v_propPos = EW_widgetPropertyPos;
vec4 colorOld = EW_foreground;
if(EW_status.stateOld == 1) {
colorOld = EW_foregroundPressed;
} else if(EW_status.stateOld == 2) {
colorOld = EW_foregroundHover;
} else if(EW_status.stateOld == 3) {
colorOld = EW_foregroundSelected;
}
vec4 colorNew = EW_foreground;
if(EW_status.stateNew == 1) {
colorNew = EW_foregroundPressed;
} else if(EW_status.stateNew == 2) {
colorNew = EW_foregroundHover;
} else if(EW_status.stateNew == 3) {
colorNew = EW_foregroundSelected;
}
v_colorInside = EW_foreground;
if (EW_status.activate == 1) {
v_colorInside = EW_foregroundSelected;
}
// note : int() is needed for the OpenGL ES platform
v_colorTansition = colorOld * (1.0 - EW_status.transition)
+ colorNew * EW_status.transition;
// for test ... TODO : Remove
if (EW_status.activate == 1) {
v_colorTansition = EW_foregroundSelected;
}
v_colorBorder = EW_border;
v_colorBackground = EW_background;
}

View File

@ -1,25 +0,0 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
varying vec2 v_propPos;
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
void main(void) {
// prevent origin moving ...
gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0);
if( v_propPos.x == 1.0
&& v_propPos.y == 1.0) {
gl_FragColor = v_colorTansition;
} else if ( v_propPos.x == 0.0
|| v_propPos.y == 0.0) {
gl_FragColor = v_colorBackground;
} else {
gl_FragColor = v_colorBorder;
}
}

View File

@ -1,50 +0,0 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct widgetStateProperty {
int stateOld;
int stateNew;
float transition;
};
uniform widgetStateProperty EW_status;
// Input :
attribute vec2 EW_coord2d;
attribute vec2 EW_widgetPropertyPos;
uniform mat4 EW_MatrixTransformation;
uniform vec4 EW_border;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_foregroundPressed;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec2 v_propPos;
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
void main(void) {
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
// transmit position of the curent element (intermolated ...)
v_position = EW_coord2d;
v_propPos = EW_widgetPropertyPos;
vec4 colorOld = EW_foreground;
if(EW_status.stateOld == 1) {
colorOld = EW_foregroundPressed;
}
vec4 colorNew = EW_foreground;
if(EW_status.stateNew == 1) {
colorNew = EW_foregroundPressed;
}
// note : int() is needed for the OpenGL ES platform
v_colorTansition = colorOld * (1.0 - EW_status.transition)
+ colorNew * EW_status.transition;
v_colorBorder = EW_border;
v_colorBackground = EW_background;
}

View File

@ -0,0 +1,47 @@
package org.atriasoft.ewol.compositing;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.Padding;
public record ShapeBox(
Vector3f outOrigin,
Vector3f outSize,
Vector3f inOrigin,
Vector3f inSize) {
public static final ShapeBox ZERO = new ShapeBox(Vector3f.ZERO, Vector3f.ZERO, Vector3f.ZERO, Vector3f.ZERO);
@Override
public String toString() {
final StringBuilder out = new StringBuilder();
out.append("{");
out.append(this.outOrigin);
out.append("->");
out.append(this.outOrigin.add(this.outSize));
out.append(" / ");
out.append(this.inOrigin);
out.append("->");
out.append(this.inOrigin.add(this.inSize));
out.append("}");
return out.toString();
}
public ShapeBox(final Vector3f outOrigin, final Vector3f outSize, final Vector3f inOrigin, final Vector3f inSize) {
this.outOrigin = outOrigin;
this.outSize = outSize;
this.inOrigin = inOrigin;
this.inSize = inSize;
}
public ShapeBox(final Vector3f outOrigin, final Vector3f outSize, final Padding padding) {
this(outOrigin, outSize, outOrigin.add(padding.left(), padding.bottom(), padding.back()), outSize.less(padding.x(), padding.y(), padding.z()));
}
public boolean isInside(final Vector3f value) {
return value.x() > this.outOrigin.x() //
&& value.y() > this.outOrigin.y() //
&& value.x() < this.outOrigin.x() + this.outSize.x() //
&& value.y() < this.outOrigin.y() + this.outSize.y();
}
}

View File

@ -88,11 +88,13 @@ public class EwolObject {
*/
protected void autoDestroy() {
Log.verbose("Destroy object: [" + getId() + "] type:" + this.getClass().getCanonicalName());
final EwolObject parent = this.parent.get();
// TODO : set a signal to do this ...
if (parent != null) {
Log.verbose("Destroy object: Call parrent");
parent.requestDestroyFromChild(this);
if (this.parent != null) {
final EwolObject parent = this.parent.get();
// TODO : set a signal to do this ...
if (parent != null) {
Log.verbose("Destroy object: Call parrent");
parent.requestDestroyFromChild(this);
}
}
//if no parent ==> noting to do ...
this.destroy = true;

View File

@ -12,6 +12,7 @@ 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;
@ -96,6 +97,7 @@ public class Button extends ContainerToggle {
private boolean propertyToggleMode = false;
private boolean propertyEnableSingle = false;
protected ShapeBox shapeProperty = ShapeBox.ZERO;
private GuiShape shape;
@EwolSignal(name = "down", description = "Button is Down")
@ -111,10 +113,6 @@ public class Button extends ContainerToggle {
@EwolSignal(name = "value", description = "The button value change")
public Signal<Boolean> signalValue = new Signal<>();
// element over:
Vector3f overPositionStart = Vector3f.ZERO;
Vector3f overPositionStop = Vector3f.ZERO;
private boolean buttonPressed = false;
private boolean mouseHover = false;
@ -152,13 +150,6 @@ public class Button extends ContainerToggle {
}
private boolean checkIfOver(final Vector3f relPos) {
return relPos.x() > this.overPositionStart.x() //
&& relPos.y() > this.overPositionStart.y() //
&& relPos.x() < this.overPositionStop.x() //
&& relPos.y() < this.overPositionStop.y();
}
void checkStatus() {
if (this.buttonPressed) {
changeStatusIn(GuiShapeMode.SELECT);
@ -314,7 +305,7 @@ public class Button extends ContainerToggle {
public boolean onEventInput(final EventInput event) {
final Vector3f relPos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
Log.warning("Event on Input ... " + event + " relPos = " + relPos);
final boolean over = checkIfOver(relPos);
final boolean over = this.shapeProperty.isInside(relPos);
//filter if outside the element...
if (event.status() == KeyStatus.leave) {
changeStatusIn(GuiShapeMode.NORMAL);
@ -326,7 +317,7 @@ public class Button extends ContainerToggle {
if (KeyStatus.leave == event.status()) {
changeStatusIn(GuiShapeMode.NORMAL);
} else {
Log.verbose("Detect Over : " + this.overPositionStart + " -> " + this.overPositionStop);
Log.verbose("Detect Over : " + this.shapeProperty);
if (over) {
changeStatusIn(GuiShapeMode.OVER);
} else {
@ -408,13 +399,12 @@ public class Button extends ContainerToggle {
//Vector3f tmpOriginText = this.size.less(tmpSizeText).multiply(0.5f);
Vector3f tmpOriginText = new Vector3f(0, 0, 0);
// not sure this is needed...
tmpSizeShaper = Vector3f.clipInt(tmpSizeShaper);
tmpOriginShaper = Vector3f.clipInt(tmpOriginShaper);
tmpSizeText = Vector3f.clipInt(tmpSizeText);
tmpOriginText = Vector3f.clipInt(tmpOriginText);
tmpSizeShaper = tmpSizeShaper.clipInteger();
tmpOriginShaper = tmpOriginShaper.clipInteger();
tmpSizeText = tmpSizeText.clipInteger();
tmpOriginText = tmpOriginText.clipInteger();
this.overPositionStart = tmpOriginShaper;
this.overPositionStop = tmpOriginShaper.add(tmpSizeShaper);
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText);
this.shape.flush();

View File

@ -30,56 +30,11 @@ public class ContainerToggle extends Widget {
this.subWidget[1] = null;
}
// @Override
// public boolean loadXML(final XmlElement node) {
// if (node == null) {
// return false;
// }
// // parse generic properties:
// super.loadXML(node);
// // remove previous element:
// subWidgetRemove();
// // parse all the elements:
// for (XmlNode it : node.getNodes()) {
// if (!it.isElement()) {
// // trash here all that is not element
// continue;
// }
// XmlElement pNode = it.toElement();
// String widgetName = pNode.getValue();
// Log.verbose("[" + getId() + "] t=" + getClass().getCanonicalName() + " Load node name : '" + widgetName + "'");
// if (!getWidgetManager().exist(widgetName)) {
// Log.error("Unknown basic node='" + widgetName + "' not in : [" + getWidgetManager().list() + "]");
// continue;
// }
// if (getSubWidget() != null) {
// Log.error("Can only have one subWidget ??? node='" + widgetName + "'");
// continue;
// }
// Log.debug("try to create subwidget : '" + widgetName + "'");
// Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
// if (tmpWidget == null) {
// Log.error("Can not create the widget : '" + widgetName + "'");
// continue;
// }
// // add widget :
// setSubWidget(tmpWidget);
// if (!tmpWidget.loadXML(pNode)) {
// Log.error("can not load widget properties : '" + widgetName + "'");
// return false;
// }
// }
// if (node.getNodes().size() != 0 && this.subWidget == null) {
// Log.warning("Load container with no data inside");
// }
// return true;
// }
void calculateMinMaxSizePadded(final Padding padding) {
// call main class
this.minSize = Vector3f.ZERO;
// call sub classes
for (int iii = 0; iii < 2; ++iii) {
for (int iii = 0; iii < this.subWidget.length; ++iii) {
if (this.subWidget[iii] != null) {
this.subWidget[iii].calculateMinMaxSize();
final Vector3f min = this.subWidget[iii].getCalculateMinSize();
@ -148,7 +103,7 @@ public class ContainerToggle extends Widget {
final Vector3f delta = this.propertyGravity.gravityGenerateDelta(this.size.less(subElementSize.add(padding.x(), padding.y(), padding.z())));
final Vector3f deltaPadded = delta.add(padding.left(), padding.bottom(), padding.back());
//subElementSize = subElementSize.less(padding.x(), padding.y(), padding.z());
for (int iii = 0; iii < 2; ++iii) {
for (int iii = 0; iii < this.subWidget.length; ++iii) {
if (this.subWidget[iii] != null) {
//final Vector3f origin2 = this.origin.add(this.offset);
//final Vector3f minSize = this.subWidget[iii].getCalculateMinSize();
@ -171,56 +126,6 @@ public class ContainerToggle extends Widget {
this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay();
}
}
/*
boolean loadXML( exml::Element _node) {
if (_node.exist() == false) {
return false;
}
// parse generic properties :
Widget::loadXML(_node);
// remove previous element :
subWidgetRemove();
Log.verbose("Create en element 2 ... with nodes.size()=" + _node.nodes.size());
// parse all the elements:
for( auto it : _node.nodes) {
Log.verbose(" node: " + it);
exml::Element pNode = it.toElement();
if (pNode.exist() == false) {
// trash here all that is not element
continue;
}
String widgetName = pNode.getValue();
if (getWidgetManager().exist(widgetName) == false) {
Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in: [" + getWidgetManager().list() + "]" );
continue;
}
boolean toogleMode=false;
if (getSubWidget() != null) {
toogleMode=true;
if (getSubWidgetToggle() != null) {
Log.error("(l " + pNode.getPos() + ") Can only have one subWidget ??? node='" + widgetName + "'" );
continue;
}
}
Log.debug("try to create subwidget : '" + widgetName + "'");
Widget tmpWidget = getWidgetManager().create(widgetName, pNode);
if (tmpWidget == null) {
EWOL_ERROR ("(l " + pNode.getPos() + ") Can not create the widget: '" + widgetName + "'");
continue;
}
// add widget :
if (toogleMode == false) {
setSubWidget(tmpWidget);
} else {
setSubWidgetToggle(tmpWidget);
}
if (tmpWidget.loadXML(pNode) == false) {
EWOL_ERROR ("(l "+pNode.getPos()+") can not load widget properties: '" + widgetName + "'");
return false;
}
}
return true;
}*/
@Override
public void requestDestroyFromChild(final EwolObject child) {
@ -268,7 +173,7 @@ public class ContainerToggle extends Widget {
}
public void setSubWidgets(final Widget[] newWidget) {
for (int iii = 0; iii < Math.min(newWidget.length, 2); iii++) {
for (int iii = 0; iii < Math.min(newWidget.length, this.subWidget.length); iii++) {
setSubWidget(newWidget[iii], iii);
}
}
@ -285,7 +190,7 @@ public class ContainerToggle extends Widget {
public void subWidgetReplace(final Widget oldWidget, final Widget newWidget) {
boolean haveChange = false;
for (int iii = 0; iii < 2; ++iii) {
for (int iii = 0; iii < this.subWidget.length; ++iii) {
if (this.subWidget[iii] != oldWidget) {
continue;
}

View File

@ -0,0 +1,177 @@
/** @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.Uri;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.DrawProperty;
import org.atriasoft.ewol.Padding;
import org.atriasoft.ewol.annotation.EwolDescription;
import org.atriasoft.ewol.compositing.GuiShape;
import org.atriasoft.ewol.compositing.ShapeBox;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.exml.annotation.XmlAttribute;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
/**
* Simple Container that have a Shape (not directly instantiate!!!!)
*/
public class ContainerWithShape extends Container {
// properties
public Uri propertyShape = null; //!< Compositing theme.
protected GuiShape shape; //!< Compositing theme.
protected ShapeBox shapeProperty = ShapeBox.ZERO;
/**
* Constructor
* @param propertyShape shape file properties
*/
public ContainerWithShape(final Uri propertyShape) {
this.propertyShape = propertyShape;
onChangePropertyShape();
}
@Override
public void calculateMinMaxSize() {
// call main class
calculateMinMaxSizeWidget();
// call sub classes
if (this.subWidget != null) {
this.subWidget.calculateMinMaxSize();
final Vector3f min = this.subWidget.getCalculateMinSize();
final Padding padding = this.shape.getPadding();
this.minSize = Vector3f.max(this.minSize, min.add(padding.x(), padding.y(), padding.z()));
}
Log.warning("[{}] Result min size : {}", getId(), this.minSize);
}
@XmlManaged
@XmlAttribute
@XmlName(value = "shape")
@EwolDescription(value = "The uri one the shape for the Pop-up")
public Uri getPropertyShape() {
return this.propertyShape;
}
@Override
public Widget getWidgetAtPos(final Vector3f pos) {
final Widget val = super.getWidgetAtPos(pos);
if (val != null) {
return val;
}
return this;
}
protected void onChangePropertyShape() {
if (this.shape == null) {
this.shape = new GuiShape(this.propertyShape);
} else {
this.shape.setSource(this.propertyShape);
}
markToRedraw();
requestUpdateSize();
}
@Override
public void onChangeSize() {
markToRedraw();
if (this.subWidget == null) {
return;
}
final Padding padding = this.shape.getPadding();
Vector3f subWidgetSize = this.subWidget.getCalculateMinSize();
if (this.subWidget.canExpand().x() && this.propertyFill.x()) {
subWidgetSize = subWidgetSize.withX(this.size.x());
} else {
subWidgetSize = subWidgetSize.withX(this.minSize.x());
}
if (this.subWidget.canExpand().y() && this.propertyFill.y()) {
subWidgetSize = subWidgetSize.withY(this.size.y());
} else {
subWidgetSize = subWidgetSize.withY(this.minSize.y());
}
if (this.subWidget.canExpand().z() && this.propertyFill.z()) {
subWidgetSize = subWidgetSize.withZ(this.size.z());
} else {
subWidgetSize = subWidgetSize.withZ(this.minSize.z());
}
subWidgetSize = subWidgetSize.less(padding.x(), padding.y(), padding.z());
subWidgetSize = subWidgetSize.clipInteger();
// set config to the Sub-widget
Vector3f subWidgetOrigin = this.origin.add(this.size.less(subWidgetSize).multiply(0.5f));
subWidgetOrigin = subWidgetOrigin.clipInteger();
this.subWidget.setOrigin(subWidgetOrigin);
this.subWidget.setSize(subWidgetSize);
this.subWidget.onChangeSize();
}
@Override
protected void onDraw() {
this.shape.draw();
}
@Override
public void onRegenerateDisplay() {
if (needRedraw()) {
this.shape.clear();
final Padding padding = this.shape.getPadding();
final Vector3f tmpSize = Vector3f.ZERO;
Vector3f tmpSizeShaper = this.minSize;
Vector3f tmpOriginShaper = this.propertyGravity.gravityGenerateDelta(this.size.less(this.minSize));
if (this.propertyFill.x()) {
tmpSizeShaper = tmpSizeShaper.withX(this.size.x());
tmpOriginShaper = tmpOriginShaper.withX(0.0f);
}
if (this.propertyFill.y()) {
tmpSizeShaper = tmpSizeShaper.withY(this.size.y());
tmpOriginShaper = tmpOriginShaper.withY(0.0f);
}
if (this.propertyFill.z()) {
tmpSizeShaper = tmpSizeShaper.withZ(this.size.y());
tmpOriginShaper = tmpOriginShaper.withZ(0.0f);
}
// not sure this is needed...
tmpSizeShaper = tmpSizeShaper.clipInteger();
tmpOriginShaper = tmpOriginShaper.clipInteger();
this.shapeProperty = new ShapeBox(tmpOriginShaper, tmpSizeShaper, padding);
this.shape.setShape(tmpOriginShaper, tmpSizeShaper);
}
// SubWidget generation ...
if (this.subWidget != null) {
this.subWidget.onRegenerateDisplay();
}
}
public void setPropertyShape(final Uri propertyShape) {
if (this.propertyShape.equals(propertyShape)) {
return;
}
this.propertyShape = propertyShape;
onChangePropertyShape();
}
@Override
public void systemDraw(final DrawProperty displayProp) {
if (this.propertyHide) {
// widget is hidden ...
return;
}
systemDrawWidget(displayProp);
if (this.subWidget == null) {
return;
}
if (true) { //this.shape.getNextDisplayedStatus() == GuiShapeMode.NONE && this.shape.getTransitionStatus() >= 1.0) {
final DrawProperty prop = displayProp.withLimit(this.origin, this.size);
this.subWidget.systemDraw(prop);
}
}
}

View File

@ -0,0 +1,71 @@
/** @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.Dimension3f;
import org.atriasoft.etk.Distance;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector3b;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.ewol.annotation.EwolDescription;
import org.atriasoft.ewol.event.EventInput;
import org.atriasoft.exml.annotation.XmlAttribute;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
import org.atriasoft.gale.key.KeyStatus;
/**
* Pop-up Display a sub element in a field inside the whole size (id set in pup-up windows)
*/
public class PopUp extends ContainerWithShape {
// properties
public boolean propertyCloseOutEvent = false; //!< ratio progression of a sliding
/**
* Constructor
*/
public PopUp() {
super(new Uri("THEME", "shape/PopUp.json", "ewol"));
this.propertyMinSize = new Dimension3f(new Vector3f(80, 80, 20), Distance.POURCENT);
this.propertyExpand = Vector3b.FALSE;
}
@XmlManaged
@XmlAttribute
@XmlName(value = "out-click-remove")
@EwolDescription(value = "Remove the widget if the use click outside")
public boolean isPropertyCloseOutEvent() {
return this.propertyCloseOutEvent;
}
@Override
public boolean onEventInput(final EventInput event) {
if (this.propertyCloseOutEvent) {
return false;
}
if (event.inputId() == 0) {
return false;
}
if (event.status() == KeyStatus.move) {
return false;
}
final Vector3f pos = relativePosition(new Vector3f(event.pos().x(), event.pos().y(), 0));
if (!this.shapeProperty.isInside(pos)) {
autoDestroy();
return true;
}
return false;
}
public void setPropertyCloseOutEvent(final boolean propertyCloseOutEvent) {
if (this.propertyCloseOutEvent == propertyCloseOutEvent) {
return;
}
this.propertyCloseOutEvent = propertyCloseOutEvent;
}
}

View File

@ -26,8 +26,7 @@ public class Sizer extends ContainerN {
}
protected Dimension3f propertyBorderSize = Dimension3f.ZERO; //!< Border size needed for all the display
protected DisplayMode propertyMode = DisplayMode.HORIZONTAL; //!< Methode to display the widget list (vert/hory ...)
protected DisplayMode propertyMode = DisplayMode.HORIZONTAL; //!< Method to display the widget list (vert/hory ...)
/**
* Constructor

View File

@ -20,7 +20,7 @@ public class Spacer extends Widget {
@XmlAttribute
@XmlName(value = "color")
@EwolDescription(value = "background of the spacer")
protected Color propertyColor = Color.GREEN; //!< Background color
protected Color propertyColor = Color.NONE; //!< Background color
/**
* Main ructer

View File

@ -115,6 +115,10 @@ public class Widget extends EwolObject {
* @note : INTERNAL EWOL SYSTEM
*/
public void calculateMinMaxSize() {
calculateMinMaxSizeWidget();
}
protected void calculateMinMaxSizeWidget() {
this.minSize = this.propertyMinSize.getPixel();
//Log.error("[" + getId() + "] convert in min size : " + propertyMinSize + " out=" + this.minSize);
this.maxSize = this.propertyMaxSize.getPixel();
@ -909,6 +913,10 @@ public class Widget extends EwolObject {
(0,0)
*/
public void systemDraw(final DrawProperty displayProp) {
systemDrawWidget(displayProp);
}
protected void systemDrawWidget(final DrawProperty displayProp) {
//Log.info("[" + getId() + "] Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" << this.size << " hide=" << propertyHide);
if (this.propertyHide) {
// widget is hidden ...

View File

@ -17,6 +17,7 @@ public class WidgetXmlFactory implements InterfaceXmlFactoryAccess {
listWidgetAvaillable.put("Tick", Tick.class);
listWidgetAvaillable.put("CheckBox", CheckBox.class);
listWidgetAvaillable.put("ListFileSystem", ListFileSystem.class);
listWidgetAvaillable.put("PopUp", PopUp.class);
}
@Override