Compare commits
69 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
df65afb204 | ||
![]() |
163e2e17ea | ||
![]() |
3bbe3afe23 | ||
![]() |
29ef90c1a3 | ||
![]() |
55664d759e | ||
![]() |
ec4b1a1875 | ||
![]() |
0fe0fa6629 | ||
![]() |
a81778e4aa | ||
![]() |
9472ddc46b | ||
![]() |
adef08ac95 | ||
![]() |
fe423be3d9 | ||
![]() |
847bcb14f4 | ||
![]() |
2743abe410 | ||
![]() |
6c4ac572b6 | ||
f4224792c0 | |||
ba8f348af9 | |||
730eb4cdfd | |||
760fd95b60 | |||
757b5c78e7 | |||
95c92bce01 | |||
f4bd09a363 | |||
9a5d925206 | |||
d016e87df0 | |||
599db5aefa | |||
4df776a15c | |||
2e0a24f1c3 | |||
f02987f8bf | |||
f8f872f5aa | |||
a8003d993b | |||
b75a5b383d | |||
ce3e31743d | |||
bdfa14d2e6 | |||
e26dd68b5e | |||
ef1aa054ad | |||
2bbe3f3f03 | |||
93d6f70765 | |||
066d067a41 | |||
457f81f1f2 | |||
f29254547d | |||
3e233e5bdf | |||
1f315d1afd | |||
a374caf9ba | |||
7bccb092d1 | |||
62a72a30c9 | |||
7c0a5eefcc | |||
47bc71af75 | |||
ea7c800947 | |||
26e1cc24a2 | |||
4f16dc25fb | |||
a851ede714 | |||
7393095de5 | |||
f595e4cfd0 | |||
8128f19f7b | |||
9ee9354568 | |||
fc43bfa599 | |||
3ebc16ce80 | |||
5378312ab7 | |||
72109971d4 | |||
e802c14182 | |||
cfc2082d02 | |||
04ce3868d5 | |||
3d262b8b82 | |||
ff07d48196 | |||
b5722fe8e1 | |||
2f11ebe2c5 | |||
20d06b66df | |||
3d3f7c3274 | |||
1c300cf50a | |||
943c19c1b2 |
69
.classpath
69
.classpath
@ -1,67 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/testResources">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="atriasoft-ewol/lib"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
|
||||
<classpathentry kind="src" output="target/classes" path="src/main">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-io-gami">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-ejson">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-etk">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-gale">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-exml">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-esvg">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/loader3d">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="out/eclipse/classes"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
42
.gitignore
vendored
42
.gitignore
vendored
@ -1,11 +1,28 @@
|
||||
/bin/
|
||||
/Operator/
|
||||
/DrawerProperties/
|
||||
*.pdfd
|
||||
*.dbc
|
||||
SchedulerConfig.txt
|
||||
scenicView.properties
|
||||
ScenariumConfig.txt
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*.class
|
||||
*~
|
||||
*.bck
|
||||
@ -15,3 +32,12 @@ build.number
|
||||
/.settings/
|
||||
/junit/
|
||||
/target/
|
||||
/__pycache__/
|
||||
|
||||
|
||||
*.pdfd
|
||||
*.dbc
|
||||
SchedulerConfig.txt
|
||||
scenicView.properties
|
||||
ScenariumConfig.txt
|
||||
*.blend*
|
||||
|
7
.project
7
.project
@ -1,9 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>atriasoft-ewol</name>
|
||||
<name>ewol</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>atriasoft-ewol</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
@ -12,13 +11,13 @@
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
18
blender_files/exportEmf.py
Normal file
18
blender_files/exportEmf.py
Normal file
@ -0,0 +1,18 @@
|
||||
import bpy
|
||||
|
||||
##To export manualy a emf... (for test ...)
|
||||
# blender --background -P ./exportEmf.py
|
||||
|
||||
|
||||
|
||||
list_elem = [
|
||||
"Entry",
|
||||
"Tick",
|
||||
"ScrollBar",
|
||||
"Button",
|
||||
"Slider"
|
||||
]
|
||||
|
||||
for elem in list_elem:
|
||||
bpy.ops.wm.open_mainfile(filepath="/home/heero/dev/WORKSPACE-game/org.atriasoft/ewol/blender_files/" + elem + ".blend")
|
||||
bpy.ops.export_scene.emf(filepath="/home/heero/dev/WORKSPACE-game/org.atriasoft/ewol/resources/resources/ewol/theme/shape/" + elem + ".emf")
|
17
ewol.iml
17
ewol.iml
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="gale" exported="" />
|
||||
<orderEntry type="module" module-name="ejson" exported="" />
|
||||
<orderEntry type="module" module-name="exml" exported="" />
|
||||
<orderEntry type="library" name="freetype-jni" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="org.junit.jupiter:junit-jupiter-api:5.7.1" level="project" />
|
||||
</component>
|
||||
</module>
|
109
lutin_org-atriasoft-ewol.py
Normal file
109
lutin_org-atriasoft-ewol.py
Normal file
@ -0,0 +1,109 @@
|
||||
#!/usr/bin/python
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
import realog.debug as debug
|
||||
import lutin.image as image
|
||||
import os
|
||||
import lutin.multiprocess as lutinMultiprocess
|
||||
|
||||
|
||||
def get_type():
|
||||
return "LIBRARY_DYNAMIC"
|
||||
|
||||
def get_desc():
|
||||
return "Ewol Tool Kit"
|
||||
|
||||
def get_licence():
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "org"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
#def get_maintainer():
|
||||
# return "authors.txt"
|
||||
|
||||
#def get_version():
|
||||
# return "version.txt"
|
||||
|
||||
def configure(target, my_module):
|
||||
|
||||
my_module.add_src_file([
|
||||
'src/module-info.java',
|
||||
'src/org/atriasoft/ewol/DrawProperty.java',
|
||||
'src/org/atriasoft/ewol/internal/LoadPackageStream.java',
|
||||
'src/org/atriasoft/ewol/internal/LOGGER.java',
|
||||
'src/org/atriasoft/ewol/context/EwolContext.java',
|
||||
'src/org/atriasoft/ewol/context/EwolApplication.java',
|
||||
'src/org/atriasoft/ewol/context/InputManager.java',
|
||||
'src/org/atriasoft/ewol/Padding.java',
|
||||
'src/org/atriasoft/ewol/annotation/EwolDescription.java',
|
||||
'src/org/atriasoft/ewol/annotation/EwolAnnotation.java',
|
||||
'src/org/atriasoft/ewol/annotation/EwolSignal.java',
|
||||
'src/org/atriasoft/ewol/resource/RefactorColored3DObject.java',
|
||||
'src/org/atriasoft/ewol/resource/font/FontMode.java',
|
||||
'src/org/atriasoft/ewol/resource/font/GlyphProperty.java',
|
||||
'src/org/atriasoft/ewol/resource/ResourceTexturedFont.java',
|
||||
'src/org/atriasoft/ewol/resource/ResourceFontSvg.java',
|
||||
'src/org/atriasoft/ewol/resource/ResourceColorFile.java',
|
||||
'src/org/atriasoft/ewol/resource/ResourceConfigFile.java',
|
||||
'src/org/atriasoft/ewol/event/EntrySystem.java',
|
||||
'src/org/atriasoft/ewol/event/EventInput.java',
|
||||
'src/org/atriasoft/ewol/event/InputSystem.java',
|
||||
'src/org/atriasoft/ewol/event/EventShortCut.java',
|
||||
'src/org/atriasoft/ewol/event/EventEntry.java',
|
||||
'src/org/atriasoft/ewol/event/EventTime.java',
|
||||
'src/org/atriasoft/ewol/widget/Windows.java',
|
||||
'src/org/atriasoft/ewol/widget/Entry.java',
|
||||
'src/org/atriasoft/ewol/widget/ImageDisplay.java',
|
||||
'src/org/atriasoft/ewol/widget/WidgetManager.java',
|
||||
'src/org/atriasoft/ewol/widget/Label.java',
|
||||
'src/org/atriasoft/ewol/widget/ProgressBar.java',
|
||||
'src/org/atriasoft/ewol/widget/Widget.java',
|
||||
'src/org/atriasoft/ewol/widget/Container.java',
|
||||
'src/org/atriasoft/ewol/widget/Spacer.java',
|
||||
'src/org/atriasoft/ewol/widget/Sizer.java',
|
||||
'src/org/atriasoft/ewol/widget/Button.java',
|
||||
'src/org/atriasoft/ewol/widget/ContainerN.java',
|
||||
'src/org/atriasoft/ewol/Gravity.java',
|
||||
'src/org/atriasoft/ewol/tools/Message.java',
|
||||
'src/org/atriasoft/ewol/Ewol.java',
|
||||
'src/org/atriasoft/ewol/object/Worker.java',
|
||||
'src/org/atriasoft/ewol/object/EwolObject.java',
|
||||
'src/org/atriasoft/ewol/object/ObjectManager.java',
|
||||
'src/org/atriasoft/ewol/compositing/CompositingGraphicContext.java',
|
||||
'src/org/atriasoft/ewol/compositing/AlignMode.java',
|
||||
'src/org/atriasoft/ewol/compositing/CompositingText.java',
|
||||
'src/org/atriasoft/ewol/compositing/CompositingDrawing.java',
|
||||
'src/org/atriasoft/ewol/compositing/Compositing.java',
|
||||
'src/org/atriasoft/ewol/compositing/CompositingImage.java',
|
||||
'src/org/atriasoft/ewol/compositing/tools/TextDecoration.java',
|
||||
'src/org/atriasoft/ewol/compositing/TextBase.java',
|
||||
'src/org/atriasoft/ewol/compositing/GuiShapeMode.java',
|
||||
'src/org/atriasoft/ewol/compositing/GuiShape.java',
|
||||
'src/org/atriasoft/etranslate/ETranslate.java',
|
||||
])
|
||||
my_module.add_path('src/', type='java')
|
||||
|
||||
my_module.add_depend([
|
||||
'org-atriasoft-gale',
|
||||
'org-atriasoft-iogami',
|
||||
'org-atriasoft-esvg',
|
||||
'org-atriasoft-ejson',
|
||||
'org-atriasoft-exml',
|
||||
'org-atriasoft-esignal',
|
||||
'org-atriasoft-loader3d',
|
||||
])
|
||||
|
||||
#my_module.add_path([
|
||||
# 'lib/spotbugs-annotations-4.2.2.jar'
|
||||
# ],
|
||||
# type='java',
|
||||
# export=True
|
||||
#);
|
||||
my_module.add_flag('java', "RELEASE_15_PREVIEW");
|
||||
|
||||
return True
|
||||
|
@ -1,288 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/object/Manager.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Button);
|
||||
ETK_DECLARE_TYPE(ewol::widget::Button::buttonLock);
|
||||
// DEFINE for the shader display system:
|
||||
static int STATUS_UP(0);
|
||||
static int STATUS_HOVER(2);
|
||||
static int STATUS_PRESSED(1);
|
||||
static int STATUS_DOWN(3);
|
||||
|
||||
ewol::widget::Button::Button() :
|
||||
signalPressed(this, "pressed", "Button is pressed"),
|
||||
signalDown(this, "down", "Button is DOWN"),
|
||||
signalUp(this, "up", "Button is UP"),
|
||||
signalEnter(this, "enter", "The cursor enter inside the button"),
|
||||
signalLeave(this, "leave", "the cursor leave the button"),
|
||||
signalValue(this, "value", "button value change"),
|
||||
propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "The display name for config file", ewol::widget::Button::onChangePropertyShape),
|
||||
propertyValue(this, "value", false, "Value of the Button", ewol::widget::Button::onChangePropertyValue),
|
||||
propertyLock(this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder", ewol::widget::Button::onChangePropertyLock),
|
||||
propertyToggleMode(this, "toggle", false, "The Button can toogle", ewol::widget::Button::onChangePropertyToggleMode),
|
||||
propertyEnableSingle(this, "enable-single", false, "If one element set in the Button ==> display only set", ewol::widget::Button::onChangePropertyEnableSingle),
|
||||
this.mouseHover(false),
|
||||
this.buttonPressed(false),
|
||||
this.selectableAreaPos(0,0),
|
||||
this.selectableAreaSize(0,0) {
|
||||
addObjectType("ewol::widget::Button");
|
||||
|
||||
// set property list:
|
||||
propertyLock.add(lockNone, "none");
|
||||
propertyLock.add(lockWhenPressed, "pressed");
|
||||
propertyLock.add(lockWhenReleased, "released");
|
||||
propertyLock.add(lockAccess, "access");
|
||||
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
|
||||
// shaper satatus update:
|
||||
CheckStatus();
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
}
|
||||
|
||||
void ewol::widget::Button::init() {
|
||||
ewol::widget::Container2::init();
|
||||
propertyShape.notifyChange();
|
||||
}
|
||||
|
||||
ewol::widget::Button::~Button() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangeSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
ewol::Padding ret = onChangeSizePadded(padding);
|
||||
//Log.debug(" configuring : origin=" + origin + " size=" + subElementSize + "");
|
||||
this.selectableAreaPos = Vector2f(ret.xLeft(), ret.yButtom());
|
||||
this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop()));
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Button::calculateMinMaxSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
calculateMinMaxSizePadded(padding);
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onDraw() {
|
||||
// draw the shaaper (if needed indeed)
|
||||
this.shaper.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onRegenerateDisplay() {
|
||||
ewol::widget::Container2::onRegenerateDisplay();
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
this.shaper.setShape(Vector2f(0,0),
|
||||
this.size,
|
||||
Vector2fClipInt32(this.selectableAreaPos+Vector2f(padding.xLeft(),padding.yButtom()) ),
|
||||
Vector2fClipInt32(this.selectableAreaSize-Vector2f(padding.x(),padding.y()) ) );
|
||||
//Log.error("pos=" + this.origin + " size=" + this.size);
|
||||
}
|
||||
|
||||
boolean ewol::widget::Button::onEventInput( ewol::event::Input _event) {
|
||||
Log.verbose("Event on BT : " + _event);
|
||||
// disable event in the lock access mode :
|
||||
if(ewol::widget::Button::lockAccess == *propertyLock) {
|
||||
return false;
|
||||
}
|
||||
if( _event.getStatus() == KeyStatus::leave
|
||||
|| _event.getStatus() == KeyStatus::abort) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
// prevent error from ouside the button
|
||||
if( relativePos.x() < this.selectableAreaPos.x()
|
||||
|| relativePos.y() < this.selectableAreaPos.y()
|
||||
|| relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|
||||
|| relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
this.mouseHover = true;
|
||||
}
|
||||
}
|
||||
Log.verbose("Event on BT ... mouse hover : " + this.mouseHover);
|
||||
if (this.mouseHover == true) {
|
||||
if (_event.getId() == 1) {
|
||||
if(_event.getStatus() == KeyStatus::down) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalDown);
|
||||
signalDown.emit();
|
||||
this.buttonPressed = true;
|
||||
markToRedraw();
|
||||
}
|
||||
if(_event.getStatus() == KeyStatus::up) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalUp);
|
||||
signalUp.emit();
|
||||
this.buttonPressed = false;
|
||||
markToRedraw();
|
||||
}
|
||||
if(_event.getStatus() == KeyStatus::pressSingle) {
|
||||
if ( ( *propertyValue == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenPressed)
|
||||
|| ( *propertyValue == false
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenReleased) ) {
|
||||
// nothing to do : Lock mode ...
|
||||
// user might set himself the new correct value with @ref setValue(xxx)
|
||||
} else {
|
||||
// inverse value :
|
||||
propertyValue.set((*propertyValue)?false:true);
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalPressed);
|
||||
signalPressed.emit();
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue );
|
||||
signalValue.emit(*propertyValue);
|
||||
if( *propertyToggleMode == false
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyValue == true) {
|
||||
propertyValue.set(false);
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue);
|
||||
signalValue.emit(*propertyValue);
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckStatus();
|
||||
return this.mouseHover;
|
||||
}
|
||||
|
||||
|
||||
boolean ewol::widget::Button::onEventEntry( ewol::event::Entry _event) {
|
||||
//Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data));
|
||||
if( _event.getType() == KeyKeyboard::character
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') {
|
||||
signalEnter.emit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onLostFocus() {
|
||||
this.buttonPressed = false;
|
||||
Log.verbose(propertyName.get() + " : Remove Focus ...");
|
||||
CheckStatus();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::CheckStatus() {
|
||||
if (this.buttonPressed == true) {
|
||||
changeStatusIn(STATUS_PRESSED);
|
||||
return;
|
||||
}
|
||||
if (this.mouseHover == true) {
|
||||
changeStatusIn(STATUS_HOVER);
|
||||
return;
|
||||
}
|
||||
if (*propertyValue == true) {
|
||||
changeStatusIn(STATUS_DOWN);
|
||||
}
|
||||
changeStatusIn(STATUS_UP);
|
||||
}
|
||||
|
||||
void ewol::widget::Button::changeStatusIn(int _newStatusId) {
|
||||
if (this.shaper.changeStatusIn(_newStatusId) == true) {
|
||||
this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::Button::periodicCall);
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Button::periodicCall( ewol::event::Time _event) {
|
||||
if (this.shaper.periodicCall(_event) == false) {
|
||||
this.PCH.disconnect();
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyShape() {
|
||||
this.shaper.setSource(*propertyShape);
|
||||
markToRedraw();
|
||||
}
|
||||
void ewol::widget::Button::onChangePropertyValue() {
|
||||
if (*propertyToggleMode == true) {
|
||||
if (*propertyValue == false) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else {
|
||||
this.idWidgetDisplayed = 1;
|
||||
}
|
||||
}
|
||||
if (*propertyEnableSingle == true) {
|
||||
if ( this.idWidgetDisplayed == 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
|
||||
this.idWidgetDisplayed = 1;
|
||||
} else if ( this.idWidgetDisplayed == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
}
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyLock() {
|
||||
if(ewol::widget::Button::lockAccess == *propertyLock) {
|
||||
this.buttonPressed = false;
|
||||
this.mouseHover = false;
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyToggleMode() {
|
||||
if (*propertyValue == true) {
|
||||
propertyValue.setDirect(false);
|
||||
// TODO : change display and send event ...
|
||||
}
|
||||
if (*propertyToggleMode == false) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else {
|
||||
if (*propertyValue == false) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else {
|
||||
this.idWidgetDisplayed = 1;
|
||||
}
|
||||
}
|
||||
if (*propertyEnableSingle == true) {
|
||||
if ( this.idWidgetDisplayed == 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
|
||||
this.idWidgetDisplayed = 1;
|
||||
} else if ( this.idWidgetDisplayed == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
}
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Button::onChangePropertyEnableSingle() {
|
||||
if (*propertyEnableSingle == true) {
|
||||
if ( this.idWidgetDisplayed == 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
|
||||
this.idWidgetDisplayed = 1;
|
||||
} else if ( this.idWidgetDisplayed == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
} else if ( this.subWidget[0] == null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null) {
|
||||
this.idWidgetDisplayed = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,107 +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/compositing/Text.hpp>
|
||||
#include <ewol/compositing/Image.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
#include <ewol/widget/Container2.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Button;
|
||||
using Button = ememory::Ptr<ewol::widget::Button>;
|
||||
using ButtonWeak = ememory::WeakPtr<ewol::widget::Button>;
|
||||
/**
|
||||
* a composed button is a button with an inside composed with the specify XML element
|
||||
* ==> this permit to generate standard element simple
|
||||
*/
|
||||
class Button : public ewol::widget::Container2 {
|
||||
public:
|
||||
enum buttonLock{
|
||||
lockNone, //!< normal status of the button
|
||||
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
||||
lockWhenReleased, //!< When the state is set in not pressed, the status stay in this one
|
||||
lockAccess, //!< all event are trashed == > acctivity of the button is disable
|
||||
};
|
||||
public: // Event list
|
||||
esignal::Signal<> signalPressed;
|
||||
esignal::Signal<> signalDown;
|
||||
esignal::Signal<> signalUp;
|
||||
esignal::Signal<> signalEnter;
|
||||
esignal::Signal<> signalLeave;
|
||||
esignal::Signal<bool> signalValue;
|
||||
public: // propertie list
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< shaper name property
|
||||
eproperty::Value<bool> propertyValue; //!< Current state of the button.
|
||||
eproperty::List<enum buttonLock> propertyLock; //!< Current lock state of the button.
|
||||
eproperty::Value<bool> propertyToggleMode; //!< The button is able to toggle.
|
||||
eproperty::Value<bool> propertyEnableSingle; //!< When a single subwidget is set display all time it.
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
* @param _shaperName Shaper file properties
|
||||
*/
|
||||
Button();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Button, "Button");
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Button();
|
||||
private:
|
||||
boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
|
||||
boolean this.buttonPressed; //!< Flag to know if the button is curently pressed.
|
||||
// hover area :
|
||||
Vector2f this.selectableAreaPos; //!< Start position of the events
|
||||
Vector2f this.selectableAreaSize; //!< size of the event positions
|
||||
private:
|
||||
/**
|
||||
* internal system to change the property of the current status
|
||||
* @param _newStatusId new state
|
||||
*/
|
||||
void changeStatusIn(int _newStatusId);
|
||||
/**
|
||||
* update the status with the internal satte of the button ...
|
||||
*/
|
||||
void CheckStatus();
|
||||
protected: // Derived function
|
||||
void onDraw() ;
|
||||
public:
|
||||
void calculateMinMaxSize() ;
|
||||
void onChangeSize() ;
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
boolean onEventEntry( ewol::event::Entry _event) ;
|
||||
void onDetectPresenceToggleWidget() {
|
||||
propertyToggleMode.set(true);
|
||||
}
|
||||
protected:
|
||||
esignal::Connection this.PCH; //!< Periodic Call Handle to remove it when needed
|
||||
/**
|
||||
* Periodic call to update grapgic display
|
||||
* @param _event Time generic event
|
||||
*/
|
||||
void periodicCall( ewol::event::Time _event);
|
||||
void onLostFocus() ;
|
||||
protected:
|
||||
void onChangePropertyShape();
|
||||
void onChangePropertyValue();
|
||||
void onChangePropertyLock();
|
||||
void onChangePropertyToggleMode();
|
||||
void onChangePropertyEnableSingle();
|
||||
};
|
||||
};
|
||||
};
|
@ -65,7 +65,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() {
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
Log.debug("redraw");
|
||||
LOGGER.debug("redraw");
|
||||
this.text.clear();
|
||||
this.shaper.clear();
|
||||
|
||||
@ -144,7 +144,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
|
||||
}
|
||||
}
|
||||
boolean previousPressed = this.buttonPressed;
|
||||
//Log.debug("Event on BT ... mouse position : " + this.mouseHover);
|
||||
//LOGGER.debug("Event on BT ... mouse position : " + this.mouseHover);
|
||||
if (true == this.mouseHover) {
|
||||
if (1 == _event.getId()) {
|
||||
if(KeyStatus::down == _event.getStatus()) {
|
||||
@ -161,7 +161,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
|
||||
// create a context menu :
|
||||
this.widgetContextMenu = ewol::widget::ContextMenu::create();
|
||||
if (this.widgetContextMenu == null) {
|
||||
Log.error("Allocation Error");
|
||||
LOGGER.error("Allocation Error");
|
||||
return true;
|
||||
}
|
||||
Vector2f tmpPos = this.origin + this.selectableAreaPos + this.selectableAreaSize;
|
||||
@ -175,7 +175,7 @@ boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
|
||||
myColorChooser.signalChange.connect(sharedFromThis(), ewol::widget::ButtonColor::onCallbackColorChange);
|
||||
ewol::widget::Windows currentWindows = getWindows();
|
||||
if (currentWindows == null) {
|
||||
Log.error("Can not get the curent Windows...");
|
||||
LOGGER.error("Can not get the curent Windows...");
|
||||
this.widgetContextMenu.reset();
|
||||
} else {
|
||||
currentWindows.popUpWidgetPush(this.widgetContextMenu);
|
||||
|
@ -1,216 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/CheckBox.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/object/Manager.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::CheckBox);
|
||||
|
||||
// DEFINE for the shader display system :
|
||||
#define STATUS_UP (0)
|
||||
#define STATUS_HOVER (2)
|
||||
#define STATUS_PRESSED (1)
|
||||
#define STATUS_SELECTED (2)
|
||||
|
||||
ewol::widget::CheckBox::CheckBox() :
|
||||
signalPressed(this, "pressed", "CheckBox is pressed"),
|
||||
signalDown(this, "down", "CheckBox is DOWN"),
|
||||
signalUp(this, "up", "CheckBox is UP"),
|
||||
signalEnter(this, "enter", "The cursor enter inside the CheckBox"),
|
||||
signalValue(this, "value", "CheckBox value change"),
|
||||
propertyValue(this, "value",
|
||||
false,
|
||||
"Basic value of the widget",
|
||||
ewol::widget::CheckBox::onChangePropertyValue),
|
||||
propertyShape(this, "shape",
|
||||
etk::Uri("THEME_GUI:///CheckBox.json?lib=ewol"),
|
||||
"The display name for config file",
|
||||
ewol::widget::CheckBox::onChangePropertyShape),
|
||||
this.mouseHover(false),
|
||||
this.buttonPressed(false),
|
||||
this.selectableAreaPos(0,0),
|
||||
this.selectableAreaSize(0,0),
|
||||
this.shaperIdSize(-1),
|
||||
this.shaperIdSizeInsize(-1) {
|
||||
addObjectType("ewol::widget::CheckBox");
|
||||
// shaper satatus update:
|
||||
CheckStatus();
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::CheckBox::init() {
|
||||
ewol::widget::Container2::init();
|
||||
propertyShape.notifyChange();
|
||||
}
|
||||
|
||||
ewol::widget::CheckBox::~CheckBox() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onChangeSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
|
||||
padding.setXLeft(padding.xLeft()*2.0f + boxSize);
|
||||
ewol::Padding ret = onChangeSizePadded(padding);
|
||||
Log.debug(" configuring : padding=" + padding + " boxSize=" + boxSize + "");
|
||||
this.selectableAreaPos = Vector2f(ret.xLeft()/*-boxSize*/, ret.yButtom());
|
||||
this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop()));
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::calculateMinMaxSize() {
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
|
||||
padding.setXLeft(padding.xLeft()*2.0f + boxSize);
|
||||
calculateMinMaxSizePadded(padding);
|
||||
if (this.minSize.y() < padding.y()+boxSize) {
|
||||
this.minSize.setY(padding.y()+boxSize);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onDraw() {
|
||||
// draw the shaaper (if needed indeed)
|
||||
this.shaper.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onRegenerateDisplay() {
|
||||
ewol::widget::Container2::onRegenerateDisplay();
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
|
||||
float boxInside = this.shaper.getConfigNumber(this.shaperIdSizeInsize);
|
||||
this.shaper.clear();
|
||||
Log.debug(" configuring : boxSize=" + boxSize + " boxInside=" + boxInside + "");
|
||||
Vector2f origin(this.selectableAreaPos + Vector2f(0, (this.selectableAreaSize.y() - (boxSize+padding.y()))*0.5f));
|
||||
Vector2f size = Vector2f(boxSize+padding.x(), boxSize+padding.y());
|
||||
|
||||
Vector2f origin2 = this.selectableAreaPos + Vector2f((boxSize-boxInside)*0.5f, (this.selectableAreaSize.y() - (boxInside+padding.y()))*0.5f);
|
||||
Vector2f size2 = Vector2f(boxInside+padding.x(), boxInside+padding.y());
|
||||
this.shaper.setShape(Vector2fClipInt32(origin),
|
||||
Vector2fClipInt32(size),
|
||||
Vector2fClipInt32(origin2+Vector2f(padding.xLeft(),padding.yButtom()) ),
|
||||
Vector2fClipInt32(size2-Vector2f(padding.x(),padding.y()) ));
|
||||
}
|
||||
|
||||
boolean ewol::widget::CheckBox::onEventInput( ewol::event::Input _event) {
|
||||
Log.verbose("Event on BT : " + _event);
|
||||
|
||||
boolean previousHoverState = this.mouseHover;
|
||||
if( KeyStatus::leave == _event.getStatus()
|
||||
|| KeyStatus::abort == _event.getStatus()) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
// prevent error from ouside the button
|
||||
if( relativePos.x() < this.selectableAreaPos.x()
|
||||
|| relativePos.y() < this.selectableAreaPos.y()
|
||||
|| relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|
||||
|| relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
|
||||
this.mouseHover = false;
|
||||
this.buttonPressed = false;
|
||||
} else {
|
||||
this.mouseHover = true;
|
||||
}
|
||||
}
|
||||
boolean previousPressed = this.buttonPressed;
|
||||
Log.verbose("Event on BT ... mouse hover : " + this.mouseHover);
|
||||
if (this.mouseHover == true) {
|
||||
if (_event.getId() == 1) {
|
||||
if(KeyStatus::down == _event.getStatus()) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalDown);
|
||||
signalDown.emit();
|
||||
this.buttonPressed = true;
|
||||
markToRedraw();
|
||||
}
|
||||
if(KeyStatus::up == _event.getStatus()) {
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalUp);
|
||||
signalUp.emit();
|
||||
this.buttonPressed = false;
|
||||
markToRedraw();
|
||||
}
|
||||
if(KeyStatus::pressSingle == _event.getStatus()) {
|
||||
// inverse value :
|
||||
propertyValue.set((*propertyValue)?false:true);
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalPressed);
|
||||
signalPressed.emit();
|
||||
Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + propertyValue );
|
||||
signalValue.emit(*propertyValue);
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
if( this.mouseHover != previousHoverState
|
||||
|| this.buttonPressed != previousPressed) {
|
||||
CheckStatus();
|
||||
}
|
||||
return this.mouseHover;
|
||||
}
|
||||
|
||||
|
||||
boolean ewol::widget::CheckBox::onEventEntry( ewol::event::Entry _event) {
|
||||
//Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data));
|
||||
if( _event.getType() == KeyKeyboard::character
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') {
|
||||
signalEnter.emit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::CheckStatus() {
|
||||
if (this.shaper.setState(*propertyValue==true?1:0) == true) {
|
||||
markToRedraw();
|
||||
}
|
||||
if (this.buttonPressed == true) {
|
||||
changeStatusIn(STATUS_PRESSED);
|
||||
return;
|
||||
}
|
||||
if (this.mouseHover == true) {
|
||||
changeStatusIn(STATUS_HOVER);
|
||||
return;
|
||||
}
|
||||
changeStatusIn(STATUS_UP);
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::changeStatusIn(int _newStatusId) {
|
||||
if (this.shaper.changeStatusIn(_newStatusId) == true) {
|
||||
this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::CheckBox::periodicCall);
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::CheckBox::periodicCall( ewol::event::Time _event) {
|
||||
if (this.shaper.periodicCall(_event) == false) {
|
||||
this.PCH.disconnect();
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onChangePropertyShape() {
|
||||
this.shaper.setSource(*propertyShape);
|
||||
this.shaperIdSize = this.shaper.requestConfig("box-size");
|
||||
this.shaperIdSizeInsize = this.shaper.requestConfig("box-inside");
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onChangePropertyValue() {
|
||||
if (*propertyValue == false) {
|
||||
this.idWidgetDisplayed = convertId(0);
|
||||
} else {
|
||||
this.idWidgetDisplayed = convertId(1);
|
||||
}
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
this.shaper.setActivateState(*propertyValue==true?1:0);
|
||||
}
|
@ -1,85 +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/compositing/Shaper.hpp>
|
||||
#include <ewol/widget/Container2.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class CheckBox;
|
||||
using CheckBox = ememory::Ptr<ewol::widget::CheckBox>;
|
||||
using CheckBoxWeak = ememory::WeakPtr<ewol::widget::CheckBox>;
|
||||
class CheckBox : public ewol::widget::Container2 {
|
||||
public: // Event list
|
||||
esignal::Signal<> signalPressed;
|
||||
esignal::Signal<> signalDown;
|
||||
esignal::Signal<> signalUp;
|
||||
esignal::Signal<> signalEnter;
|
||||
esignal::Signal<bool> signalValue;
|
||||
public: // propertie list
|
||||
eproperty::Value<bool> propertyValue; //!< Current state of the checkbox.
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< shape of the widget
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
|
||||
boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
|
||||
boolean this.buttonPressed; //!< Flag to know if the button is curently pressed.
|
||||
// hover area :
|
||||
Vector2f this.selectableAreaPos; //!< Start position of the events
|
||||
Vector2f this.selectableAreaSize; //!< size of the event positions
|
||||
// shaper ids:
|
||||
int this.shaperIdSize;
|
||||
int this.shaperIdSizeInsize;
|
||||
protected:
|
||||
/**
|
||||
* Main checkbox ructor
|
||||
* @param _shaperName Shaper file properties
|
||||
*/
|
||||
CheckBox();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(CheckBox, "CheckBox");
|
||||
/**
|
||||
* main destructor.
|
||||
*/
|
||||
~CheckBox();
|
||||
protected:
|
||||
/**
|
||||
* internal system to change the property of the current status
|
||||
* @param _newStatusId new state
|
||||
*/
|
||||
void changeStatusIn(int _newStatusId);
|
||||
/**
|
||||
* update the status with the internal satte of the button ...
|
||||
*/
|
||||
void CheckStatus();
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void calculateMinMaxSize() ;
|
||||
void onChangeSize() ;
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
boolean onEventEntry( ewol::event::Entry _event) ;
|
||||
protected:
|
||||
esignal::Connection this.PCH; //!< Periodic call handle to remove it when needed
|
||||
/**
|
||||
* Periodic call to update grapgic display
|
||||
* @param _event Time generic event
|
||||
*/
|
||||
void periodicCall( ewol::event::Time _event);
|
||||
protected:
|
||||
void onChangePropertyShape();
|
||||
void onChangePropertyValue();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ static etk::Color<> s_listColor[NB_BAND_COLOR+1] = {
|
||||
void ewol::widget::ColorBar::onChangePropertyValue() {
|
||||
propertyValue.getDirect().setA(0xFF);
|
||||
// estimate the cursor position:
|
||||
Log.todo("Later when really needed ...");
|
||||
LOGGER.info("[TODO] Later when really needed ...");
|
||||
}
|
||||
|
||||
void ewol::widget::ColorBar::onDraw() {
|
||||
@ -159,7 +159,7 @@ void ewol::widget::ColorBar::onRegenerateDisplay() {
|
||||
|
||||
boolean ewol::widget::ColorBar::onEventInput( ewol::event::Input _event) {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
//Log.debug("Event on BT ...");
|
||||
//LOGGER.debug("Event on BT ...");
|
||||
if (1 == _event.getId()) {
|
||||
relativePos.setValue( etk::avg(0.0f, this.size.x(),relativePos.x()),
|
||||
etk::avg(0.0f, this.size.y(),relativePos.y()) );
|
||||
@ -170,11 +170,11 @@ boolean ewol::widget::ColorBar::onEventInput( ewol::event::Input _event) {
|
||||
relativePos.y()/this.size.y() );
|
||||
markToRedraw();
|
||||
// == > try to estimate color
|
||||
Log.verbose("event on (" + relativePos.x() + "," + relativePos.y() + ")");
|
||||
LOGGER.trace("event on (" + relativePos.x() + "," + relativePos.y() + ")");
|
||||
int bandID = (int)(relativePos.x()/(this.size.x()/6));
|
||||
float localPos = relativePos.x() - (this.size.x()/6) * bandID;
|
||||
float poroportionnalPos = localPos/(this.size.x()/6);
|
||||
Log.verbose("bandId=" + bandID + " relative pos=" + localPos);
|
||||
LOGGER.trace("bandId=" + bandID + " relative pos=" + localPos);
|
||||
etk::Color<> estimateColor = etk::color::white;
|
||||
if (s_listColor[bandID].r() == s_listColor[bandID+1].r()) {
|
||||
estimateColor.setR(s_listColor[bandID].r());
|
||||
|
@ -1,162 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Composer);
|
||||
|
||||
ewol::widget::Composer::Composer() :
|
||||
propertyRemoveIfUnderRemove(this, "remove-if-under-remove", true, "Demand the remove iof the widget if the subObject demand a remove"),
|
||||
propertySubFile(this, "sub-file", "", "compose with a subXML file", ewol::widget::Composer::onChangePropertySubFile) {
|
||||
addObjectType("ewol::widget::Composer");
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
Widget ewol::widget::composerGenerateFile( etk::Uri _uri, ulong _id) {
|
||||
String tmpData;
|
||||
if (etk::uri::readAll(_uri, tmpData) == false) {
|
||||
Log.error("Can not read the file: " + _uri);
|
||||
return null;
|
||||
}
|
||||
return ewol::widget::composerGenerateString(tmpData, _id);
|
||||
}
|
||||
|
||||
Widget ewol::widget::composerGenerateString( String _data, ulong _id) {
|
||||
ewol::widget::Manager widgetManager = ewol::getContext().getWidgetManager();
|
||||
if (_data == "") {
|
||||
return null;
|
||||
}
|
||||
exml::Document doc;
|
||||
String tmpData = _data;
|
||||
// replace all elements:
|
||||
if (_id != 0) {
|
||||
tmpData.replace("{ID}", etk::toString(_id));
|
||||
}
|
||||
if (doc.parse(tmpData) == false) {
|
||||
Log.error(" can not load file XML string...");
|
||||
return null;
|
||||
}
|
||||
exml::Element root = doc.toElement();
|
||||
if (root.nodes.size() == 0) {
|
||||
Log.error(" (l ?) No node in the XML file/string.");
|
||||
return null;
|
||||
}
|
||||
if (root.nodes.size() > 1) {
|
||||
Log.warning(" (l ?) More than 1 node in the XML file/string. (JUST parse the first)");
|
||||
}
|
||||
exml::Element pNode = root.nodes[0].toElement();
|
||||
if (pNode.exist() == false) {
|
||||
Log.error(" (l ?) No node in the XML file/string. {2}");
|
||||
return null;
|
||||
}
|
||||
String widgetName = pNode.getValue();
|
||||
if (widgetManager.exist(widgetName) == false) {
|
||||
Log.error("(l " + pNode.getPos() + ") Unknown basic node='" + widgetName + "' not in : [" + widgetManager.list() + "]" );
|
||||
return null;
|
||||
}
|
||||
Log.debug("try to create subwidget : '" + widgetName + "'");
|
||||
Widget tmpWidget = widgetManager.create(widgetName);
|
||||
if (tmpWidget == null) {
|
||||
EWOL_ERROR ("(l " + pNode.getPos() + ") Can not create the widget : '" + widgetName + "'");
|
||||
return null;
|
||||
}
|
||||
if (tmpWidget.loadXML(pNode) == false) {
|
||||
EWOL_ERROR ("(l " + pNode.getPos() + ") can not load widget properties : '" + widgetName + "'");
|
||||
}
|
||||
return tmpWidget;
|
||||
}
|
||||
|
||||
ewol::widget::Composer::~Composer() {
|
||||
|
||||
}
|
||||
|
||||
boolean ewol::widget::Composer::loadFromFile( etk::Uri _uri, ulong _id) {
|
||||
String tmpData;
|
||||
if (etk::uri::readAll(_uri, tmpData) == false) {
|
||||
Log.error("Can not read the file: " + _uri);
|
||||
return false;
|
||||
}
|
||||
return loadFromString(tmpData, _id);
|
||||
}
|
||||
|
||||
boolean ewol::widget::Composer::loadFromString( String _composerXmlString, ulong _id) {
|
||||
exml::Document doc;
|
||||
String tmpData = _composerXmlString;
|
||||
// replace all elements:
|
||||
if (_id != 0) {
|
||||
tmpData.replace("{ID}", etk::toString(_id));
|
||||
}
|
||||
if (doc.parse(tmpData) == false) {
|
||||
Log.error(" can not load file XML string...");
|
||||
return false;
|
||||
}
|
||||
exml::Element root = doc.nodes["composer"];
|
||||
if (root.exist() == false) {
|
||||
// Maybe a multiple node XML for internal config:
|
||||
root = doc.toElement();
|
||||
if (root.exist() == false) {
|
||||
Log.error("[" + getId() + "] {" + getObjectType() + "} (l ?) main node not find: 'composer' ...");
|
||||
return false;
|
||||
}
|
||||
if (root.nodes.size() == 0) {
|
||||
Log.error("[" + getId() + "] {" + getObjectType() + "} (l ?) no node in the Container XML element.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// call upper class to parse his elements ...
|
||||
ewol::widget::Container::loadXML(root);
|
||||
if (this.subWidget == null) {
|
||||
Log.warning("Load data from composer and have no under Widget after loading");
|
||||
if (_composerXmlString.size() != 0) {
|
||||
Log.error("Error Loading XML data : " + _composerXmlString);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
requestUpdateSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::widget::Composer::requestDestroyFromChild( EwolObject _child) {
|
||||
ewol::widget::Container::requestDestroyFromChild(_child);
|
||||
if (*propertyRemoveIfUnderRemove == true) {
|
||||
Log.debug("Child widget remove ==> auto-remove");
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Composer::onChangePropertySubFile() {
|
||||
Log.info("Load compositing form external file : " + propertySubFile);
|
||||
if (*propertySubFile == "") {
|
||||
// remove all elements:
|
||||
subWidgetRemove();
|
||||
return;
|
||||
}
|
||||
if (loadFromFile(*propertySubFile, getId()) == false) {
|
||||
Log.error("Can not load Player GUI from file ... " + propertySubFile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean ewol::widget::Composer::loadXML( exml::Element _node) {
|
||||
//Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load XML (start)");
|
||||
if (_node.exist() == false) {
|
||||
return false;
|
||||
}
|
||||
// parse generic properties:
|
||||
Widget::loadXML(_node);
|
||||
// parse all the elements:
|
||||
if (_node.nodes.size() != 0) {
|
||||
Log.error("a composer Node Can not have Sub-element in XML ==> must be done in an external file and load it with attribute: 'sub-file'");
|
||||
}
|
||||
//drawWidgetTree();
|
||||
//Log.verbose("[" + getId() + "] t=" + getObjectType() + " Load XML (stop)");
|
||||
return true;
|
||||
}
|
@ -1,63 +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/Container.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Composer;
|
||||
using Composer = ememory::Ptr<ewol::widget::Composer>;
|
||||
using ComposerWeak = ememory::WeakPtr<ewol::widget::Composer>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
* the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree
|
||||
*/
|
||||
class Composer : public ewol::widget::Container {
|
||||
public:
|
||||
eproperty::Value<bool> propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove
|
||||
eproperty::Value<etk::Uri> propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Composer();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Composer, "Composer");
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Composer();
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param _uri Name of the file
|
||||
* @param _id Unique ID that is used in replacing the balise "{ID}" inside the File (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
boolean loadFromFile( etk::Uri _uri, ulong _id=0);
|
||||
/**
|
||||
* load a composition with a file
|
||||
* @param _composerXmlString xml to parse directly
|
||||
* @param _id Unique ID that is used in replacing the balise "{ID}" inside the String (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
boolean loadFromString( String _composerXmlString, ulong _id=0);
|
||||
private:
|
||||
void requestDestroyFromChild( EwolObject _child) ;
|
||||
public:
|
||||
boolean loadXML( exml::Element _node) ;
|
||||
protected:
|
||||
void onChangePropertySubFile();
|
||||
};
|
||||
Widget composerGenerateString( String _data = "", ulong _id=0);
|
||||
Widget composerGenerateFile( etk::Uri _uri = "", ulong _id=0);
|
||||
};
|
||||
};
|
@ -22,240 +22,6 @@ ewol::widget::Container2::~Container2() {
|
||||
subWidgetRemoveToggle();
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::setSubWidget(Widget _newWidget, int _idWidget) {
|
||||
subWidgetRemove(_idWidget);
|
||||
this.subWidget[_idWidget] = _newWidget;
|
||||
if (this.subWidget[_idWidget] != null) {
|
||||
Log.verbose("Add widget : " + _idWidget);
|
||||
this.subWidget[_idWidget].setParent(sharedFromThis());
|
||||
}
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::subWidgetReplace( Widget _oldWidget,
|
||||
Widget _newWidget) {
|
||||
boolean haveChange = false;
|
||||
for (int iii=0; iii<2; ++iii) {
|
||||
if (this.subWidget[iii] != _oldWidget) {
|
||||
continue;
|
||||
}
|
||||
this.subWidget[iii].removeParent();
|
||||
this.subWidget[iii].reset();
|
||||
this.subWidget[iii] = _newWidget;
|
||||
if (this.subWidget[iii] != null) {
|
||||
this.subWidget[iii].setParent(sharedFromThis());
|
||||
}
|
||||
haveChange = true;
|
||||
}
|
||||
if (haveChange == false) {
|
||||
Log.warning("Request replace with a wrong old widget");
|
||||
return;
|
||||
}
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Container2::subWidgetRemove(int _idWidget) {
|
||||
if (this.subWidget[_idWidget] != null) {
|
||||
Log.verbose("Remove widget : " + _idWidget);
|
||||
this.subWidget[_idWidget].removeParent();
|
||||
this.subWidget[_idWidget].reset();
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::subWidgetUnLink(int _idWidget) {
|
||||
if (this.subWidget[_idWidget] != null) {
|
||||
this.subWidget[_idWidget].removeParent();
|
||||
Log.verbose("Unlink widget : " + _idWidget);
|
||||
}
|
||||
this.subWidget[_idWidget].reset();
|
||||
}
|
||||
|
||||
EwolObject ewol::widget::Container2::getSubObjectNamed( String _widgetName) {
|
||||
EwolObject tmpObject = Widget::getSubObjectNamed(_widgetName);
|
||||
if (tmpObject != null) {
|
||||
return tmpObject;
|
||||
}
|
||||
if (this.subWidget[0] != null) {
|
||||
tmpObject = this.subWidget[0].getSubObjectNamed(_widgetName);
|
||||
if (tmpObject != null) {
|
||||
return tmpObject;
|
||||
}
|
||||
}
|
||||
if (this.subWidget[1] != null) {
|
||||
return this.subWidget[1].getSubObjectNamed(_widgetName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
if (propertyHide.get() == true){
|
||||
// widget is hidden ...
|
||||
return;
|
||||
}
|
||||
Widget::systemDraw(_displayProp);
|
||||
if (this.subWidget[this.idWidgetDisplayed] != null) {
|
||||
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + " o=" + this.origin + " s=" + this.size);
|
||||
this.subWidget[this.idWidgetDisplayed].systemDraw(_displayProp);
|
||||
}
|
||||
}
|
||||
|
||||
ewol::Padding ewol::widget::Container2::onChangeSizePadded( ewol::Padding _padding) {
|
||||
Widget::onChangeSize();
|
||||
Vector2f localAvaillable = this.size - Vector2f(_padding.x(), _padding.y());
|
||||
// Checkin the filling properties == > for the subElements:
|
||||
Vector2f subElementSize = this.minSize;
|
||||
if (propertyFill.x() == true) {
|
||||
subElementSize.setX(this.size.x());
|
||||
}
|
||||
if (propertyFill.y() == true) {
|
||||
subElementSize.setY(this.size.y());
|
||||
}
|
||||
Vector2f delta = ewol::gravityGenerateDelta(propertyGravity, this.size - subElementSize);
|
||||
Vector2f origin = delta + Vector2f(_padding.xLeft(), _padding.yButtom());
|
||||
subElementSize -= Vector2f(_padding.x(), _padding.y());
|
||||
for (int iii = 0; iii < 2; ++iii) {
|
||||
if (this.subWidget[iii] != null) {
|
||||
Vector2f origin2 = origin+this.offset;
|
||||
Vector2f minSize = this.subWidget[iii].getCalculateMinSize();
|
||||
//Vector2b expand = this.subWidget[iii].propertyExpand.get();
|
||||
origin2 += ewol::gravityGenerateDelta(propertyGravity, minSize - localAvaillable);
|
||||
this.subWidget[iii].setOrigin(this.origin + origin);
|
||||
this.subWidget[iii].setSize(subElementSize);
|
||||
this.subWidget[iii].onChangeSize();
|
||||
}
|
||||
}
|
||||
Vector2f selectableAreaPos = origin-Vector2f(_padding.xLeft(), _padding.yButtom());
|
||||
Vector2f selectableAreaEndPos = this.size - (selectableAreaPos + subElementSize + Vector2f(_padding.x(), _padding.y()));
|
||||
markToRedraw();
|
||||
return ewol::Padding(selectableAreaPos.x(),
|
||||
selectableAreaEndPos.y(),
|
||||
selectableAreaEndPos.x(),
|
||||
selectableAreaPos.y());
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::calculateMinMaxSizePadded( ewol::Padding _padding) {
|
||||
// call main class
|
||||
this.minSize = Vector2f(0,0);
|
||||
// call sub classes
|
||||
for (int iii = 0; iii < 2; ++iii) {
|
||||
if (this.subWidget[iii] != null) {
|
||||
this.subWidget[iii].calculateMinMaxSize();
|
||||
Vector2f min = this.subWidget[iii].getCalculateMinSize();
|
||||
this.minSize.setMax(min);
|
||||
}
|
||||
}
|
||||
// add padding :
|
||||
this.minSize += Vector2f(_padding.x(), _padding.y());
|
||||
// verify the min max of the min size ...
|
||||
checkMinSize();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::onRegenerateDisplay() {
|
||||
if (this.subWidget[this.idWidgetDisplayed] != null) {
|
||||
this.subWidget[this.idWidgetDisplayed].onRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
/*
|
||||
Widget ewol::widget::Container2::getWidgetAtPos( Vector2f _pos) {
|
||||
if (isHide() == false) {
|
||||
if (this.subWidget[this.idWidgetDisplayed] != null) {
|
||||
return this.subWidget[this.idWidgetDisplayed].getWidgetAtPos(_pos);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
boolean ewol::widget::Container2::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;
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::setOffset( Vector2f _newVal) {
|
||||
if (this.offset != _newVal) {
|
||||
Widget::setOffset(_newVal);
|
||||
// recalculate the new sise and position of sub widget ...
|
||||
calculateSize();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::requestDestroyFromChild( EwolObject _child) {
|
||||
if (this.subWidget[0] == _child) {
|
||||
if (this.subWidget[0] == null) {
|
||||
return;
|
||||
}
|
||||
this.subWidget[0].removeParent();
|
||||
this.subWidget[0].reset();
|
||||
markToRedraw();
|
||||
}
|
||||
if (this.subWidget[1] == _child) {
|
||||
if (this.subWidget[1] == null) {
|
||||
return;
|
||||
}
|
||||
this.subWidget[1].removeParent();
|
||||
this.subWidget[1].reset();
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Container2::drawWidgetTree(int _level) {
|
||||
Widget::drawWidgetTree(_level);
|
||||
_level++;
|
||||
if (this.subWidget[0] != null) {
|
||||
this.subWidget[0].drawWidgetTree(_level);
|
||||
}
|
||||
if (this.subWidget[1] != null) {
|
||||
this.subWidget[1].drawWidgetTree(_level);
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void ewol::widget::ContextMenu::onChangeSize() {
|
||||
markToRedraw();
|
||||
// pop-up fill all the display :
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
Log.verbose("our origin=" + this.origin + " size=" + this.size);
|
||||
LOGGER.trace("our origin=" + this.origin + " size=" + this.size);
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
@ -115,7 +115,7 @@ void ewol::widget::ContextMenu::onChangeSize() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
Log.verbose(" == > sub origin=" + subWidgetOrigin + " size=" + subWidgetSize);
|
||||
LOGGER.trace(" == > sub origin=" + subWidgetOrigin + " size=" + subWidgetSize);
|
||||
this.subWidget.setOrigin(subWidgetOrigin);
|
||||
this.subWidget.setSize(subWidgetSize);
|
||||
this.subWidget.onChangeSize();
|
||||
@ -128,7 +128,7 @@ void ewol::widget::ContextMenu::calculateMinMaxSize() {
|
||||
// add padding of the display
|
||||
ewol::Padding padding = this.shaper.getPadding();
|
||||
this.minSize += Vector2f(padding.x(), padding.y());
|
||||
//Log.debug("CalculateMinSize=>>" + this.minSize);
|
||||
//LOGGER.debug("CalculateMinSize=>>" + this.minSize);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() {
|
||||
default:
|
||||
case markRight:
|
||||
case markLeft:
|
||||
Log.todo("later");
|
||||
LOGGER.info("[TODO] later");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,70 +1,45 @@
|
||||
/** @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 <etk/Color.hpp>
|
||||
#include <ewol/debug.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 ContextMenu;
|
||||
using ContextMenu = ememory::Ptr<ewol::widget::ContextMenu>;
|
||||
using ContextMenuWeak = ememory::WeakPtr<ewol::widget::ContextMenu>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class ContextMenu : public ewol::widget::Container {
|
||||
public:
|
||||
enum markPosition {
|
||||
markTop,
|
||||
markRight,
|
||||
markButtom,
|
||||
markLeft,
|
||||
markNone
|
||||
};
|
||||
public: // properties
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< shape of the widget.
|
||||
eproperty::Value<Vector2f> propertyArrowPos;
|
||||
eproperty::List<enum markPosition> propertyArrawBorder;
|
||||
protected:
|
||||
ContextMenu();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(ContextMenu, "ContextMenu");
|
||||
~ContextMenu();
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
|
||||
|
||||
// TODO : Use shaper for the arraw ...
|
||||
ewol::compositing::Drawing this.compositing;
|
||||
etk::Color<> this.colorBorder; // use shaper ID
|
||||
|
||||
|
||||
float this.offset;
|
||||
public:
|
||||
void setPositionMarkAuto( Vector2f _origin, Vector2f _size);
|
||||
void setPositionMark(enum markPosition _position, Vector2f _arrowPos);
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void onChangeSize() ;
|
||||
void calculateMinMaxSize() ;
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
protected:
|
||||
void onChangePropertyArrowPos();
|
||||
void onChangePropertyArrawBorder();
|
||||
void onChangePropertyShape();
|
||||
class ContextMenu extends Container {
|
||||
public:
|
||||
enum markPosition {
|
||||
markTop,
|
||||
markRight,
|
||||
markButtom,
|
||||
markLeft,
|
||||
markNone
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
public: // properties
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< shape of the widget.
|
||||
eproperty::Value<Vector2f> propertyArrowPos;
|
||||
eproperty::List<enum markPosition> propertyArrawBorder;
|
||||
protected:
|
||||
ContextMenu();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(ContextMenu, "ContextMenu");
|
||||
~ContextMenu();
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaper; //!< Compositing theme.
|
||||
|
||||
// TODO : Use shaper for the arraw ...
|
||||
ewol::compositing::Drawing this.compositing;
|
||||
etk::Color<> this.colorBorder; // use shaper ID
|
||||
|
||||
|
||||
float this.offset;
|
||||
public:
|
||||
void setPositionMarkAuto( Vector2f _origin, Vector2f _size);
|
||||
void setPositionMark(enum markPosition _position, Vector2f _arrowPos);
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void onChangeSize() ;
|
||||
void calculateMinMaxSize() ;
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
protected:
|
||||
void onChangePropertyArrowPos();
|
||||
void onChangePropertyArrawBorder();
|
||||
void onChangePropertyShape();
|
||||
};
|
@ -1,330 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Gird.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
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<this.subWidget.size(); iii++) {
|
||||
if (this.subWidget[iii].widget != null) {
|
||||
//calculate the origin :
|
||||
Vector2f tmpOrigin = this.origin + this.borderSize;
|
||||
if (false == this.gavityButtom) {
|
||||
tmpOrigin += Vector2f(0, this.size.y()-this.borderSize.y());
|
||||
}
|
||||
|
||||
int tmpSizeWidth = 0;
|
||||
for (int jjj=0; jjj<this.subWidget[iii].col; jjj++ ){
|
||||
tmpSizeWidth += abs(this.sizeCol[jjj]);
|
||||
}
|
||||
// adding Y origin :
|
||||
int addingPos = 0;
|
||||
if (true == this.gavityButtom) {
|
||||
addingPos = (this.subWidget[iii].row)*this.uniformSizeRow;
|
||||
} else {
|
||||
addingPos = -(this.subWidget[iii].row+1)*this.uniformSizeRow;
|
||||
}
|
||||
tmpOrigin += Vector2f(tmpSizeWidth, addingPos);
|
||||
|
||||
Log.debug(" [" + iii + "] set subwidget origin=" +tmpOrigin + " size=" + Vector2i(abs(this.sizeCol[this.subWidget[iii].col]), this.uniformSizeRow) );
|
||||
// set the origin :
|
||||
this.subWidget[iii].widget.setOrigin(Vector2fClipInt32(tmpOrigin));
|
||||
// all time set oll the space .
|
||||
this.subWidget[iii].widget.setSize(Vector2fClipInt32(Vector2f(abs(this.sizeCol[this.subWidget[iii].col]), this.uniformSizeRow)));
|
||||
this.subWidget[iii].widget.onChangeSize();
|
||||
}
|
||||
}
|
||||
this.size += this.borderSize*2;
|
||||
Log.debug("Calculate size : " + this.size);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::calculateMinMaxSize() {
|
||||
for (int iii=0; iii<this.sizeCol.size(); iii++ ){
|
||||
if (this.sizeCol[iii] <= 0) {
|
||||
this.sizeCol[iii] = 0;
|
||||
}
|
||||
}
|
||||
//Log.debug("Update minimum size");
|
||||
this.minSize = propertyMinSize.getPixel();
|
||||
this.maxSize = propertyMaxSize.getPixel();
|
||||
this.uniformSizeRow = 0;
|
||||
this.minSize += this.borderSize*2;
|
||||
int lastLineID = 0;
|
||||
for (int iii=0; iii<this.subWidget.size(); iii++) {
|
||||
if (this.subWidget[iii].row > 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<this.sizeCol.size(); iii++ ){
|
||||
tmpSizeWidth += abs(this.sizeCol[iii]);
|
||||
}
|
||||
Log.debug(" tmpSizeWidth=" + tmpSizeWidth);
|
||||
Log.debug(" this.uniformSizeRow=" + this.uniformSizeRow);
|
||||
this.minSize += Vector2i(tmpSizeWidth, (lastLineID+1)*this.uniformSizeRow);
|
||||
|
||||
Log.debug("Calculate min size : " + this.minSize);
|
||||
|
||||
//Log.debug("Vert Result : expand="+ this.userExpand + " minSize="+ this.minSize);
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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<this.subWidget.size(); iii++) {
|
||||
if (this.subWidget[iii].row < prop.row) {
|
||||
continue;
|
||||
} else if (this.subWidget[iii].row > 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<this.subWidget.size(); iii++) {
|
||||
if (_newWidget == this.subWidget[iii].widget) {
|
||||
this.subWidget.erase(this.subWidget.begin()+iii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Log.warning("[" + getId() + "] Can not remove unExistant widget");
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::subWidgetRemove(int _colId, int _rowId) {
|
||||
if ( _colId < 0
|
||||
|| _rowId < 0) {
|
||||
Log.warning("[" + getId() + "] try to remove widget with id < 0 col=" + _colId + " row=" + _rowId);
|
||||
return;
|
||||
}
|
||||
int errorControl = this.subWidget.size();
|
||||
// try to find it ...
|
||||
for (int iii=0; iii<this.subWidget.size(); iii++) {
|
||||
if( this.subWidget[iii].row == _rowId
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[iii].col == _colId) {
|
||||
this.subWidget.erase(this.subWidget.begin()+iii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Log.warning("[" + getId() + "] Can not remove unExistant widget");
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::subWidgetUnLink(Widget _newWidget) {
|
||||
if (_newWidget == null) {
|
||||
return;
|
||||
}
|
||||
for (int iii=0; iii<this.subWidget.size(); iii++) {
|
||||
if (_newWidget == this.subWidget[iii].widget) {
|
||||
this.subWidget.erase(this.subWidget.begin()+iii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::subWidgetUnLink(int _colId, int _rowId) {
|
||||
if ( _colId < 0
|
||||
|| _rowId < 0) {
|
||||
Log.warning("[" + getId() + "] try to Unlink widget with id < 0 col=" + _colId + " row=" + _rowId);
|
||||
return;
|
||||
}
|
||||
// try to find it ...
|
||||
for (int iii=0; iii<this.subWidget.size(); iii++) {
|
||||
if( this.subWidget[iii].row == _rowId
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[iii].col == _colId) {
|
||||
this.subWidget.erase(this.subWidget.begin()+iii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Log.warning("[" + getId() + "] Can not unLink unExistant widget");
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
Widget::systemDraw(_displayProp);
|
||||
for (auto it : this.subWidget) {
|
||||
if (it.widget != null) {
|
||||
it.widget.systemDraw(_displayProp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Gird::onRegenerateDisplay() {
|
||||
for (auto it : this.subWidget) {
|
||||
if (it.widget != null) {
|
||||
it.widget.onRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget ewol::widget::Gird::getWidgetAtPos( Vector2f _pos) {
|
||||
if (*propertyHide == true) {
|
||||
return null;
|
||||
}
|
||||
// for all element in the sizer ...
|
||||
for (auto it : this.subWidget) {
|
||||
if (it.widget == null) {
|
||||
continue;
|
||||
}
|
||||
Vector2f tmpSize = it.widget.getSize();
|
||||
Vector2f tmpOrigin = it.widget.getOrigin();
|
||||
if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x())
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) {
|
||||
Widget tmpWidget = it.widget.getWidgetAtPos(_pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
// stop searching
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,146 +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 <etk/Vector.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Gird;
|
||||
using Gird = ememory::Ptr<ewol::widget::Gird>;
|
||||
using GirdWeak = ememory::WeakPtr<ewol::widget::Gird>;
|
||||
/**
|
||||
* @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<int> this.sizeCol; //!< size of all colomn (if set (otherwise 0))
|
||||
List<GirdProperties> 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() ;
|
||||
};
|
||||
};
|
||||
};
|
@ -1,190 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Joystick.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <ewol/compositing/Image.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Joystick);
|
||||
|
||||
static boolean l_displayBackground(true);
|
||||
static String l_background("");
|
||||
static String l_foreground("");
|
||||
static float l_ratio(1.0/7.0);
|
||||
|
||||
ewol::widget::Joystick::Joystick() :
|
||||
signalEnable(this, "enable", ""),
|
||||
signalDisable(this, "disable", ""),
|
||||
signalMove(this, "move", "") {
|
||||
addObjectType("ewol::widget::Joystick");
|
||||
// by default the joy does not lock when free out
|
||||
this.lock = false;
|
||||
this.displayMode = modeNormal;
|
||||
|
||||
this.colorFg = etk::color::blue;
|
||||
|
||||
this.colorBg = etk::color::black;
|
||||
this.colorBg.setA(0x3F);
|
||||
|
||||
this.displayPos.setValue(0,0);
|
||||
this.distance = 0.0;
|
||||
this.angle = -0.1;
|
||||
|
||||
// set the generic parameters:
|
||||
this.displayBackground = l_displayBackground;
|
||||
this.background = l_background;
|
||||
this.foreground = l_foreground;
|
||||
this.ratio = l_ratio;
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
}
|
||||
|
||||
ewol::widget::Joystick::~Joystick() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::Joystick::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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Sine Function: sin(teta) = Opposite / Hypotenuse
|
||||
Cosine Function: cos(teta) = Adjacent / Hypotenuse
|
||||
Tangent Function: tan(teta) = Opposite / Adjacent
|
||||
*/
|
||||
boolean ewol::widget::Joystick::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
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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 <etk/types.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
// TODO : Rework ==> use property and shaper ...
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Joystick;
|
||||
using Joystick = ememory::Ptr<ewol::widget::Joystick>;
|
||||
using JoystickWeak = ememory::WeakPtr<ewol::widget::Joystick>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class Joystick :public Widget {
|
||||
public:
|
||||
// Event list of properties
|
||||
esignal::Signal<> signalEnable;
|
||||
esignal::Signal<> signalDisable;
|
||||
esignal::Signal<Vector2f> 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<Vector2f> 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;
|
||||
LOGGER.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;
|
||||
LOGGER.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;
|
||||
LOGGER.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;
|
||||
//LOGGER.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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Layer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Layer);
|
||||
|
||||
ewol::widget::Layer::Layer() {
|
||||
addObjectType("ewol::widget::Layer");
|
||||
}
|
||||
|
||||
ewol::widget::Layer::~Layer() {
|
||||
Log.debug("[" + getId() + "] Layer : destroy");
|
||||
}
|
||||
|
||||
Widget ewol::widget::Layer::getWidgetAtPos( Vector2f _pos) {
|
||||
if (*propertyHide == true) {
|
||||
return null;
|
||||
}
|
||||
// for all element in the sizer ...
|
||||
for (auto it : this.subWidget) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
Vector2f tmpSize = it.getSize();
|
||||
Vector2f tmpOrigin = it.getOrigin();
|
||||
if( (tmpOrigin.x() <= _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpOrigin.x() + tmpSize.x() >= _pos.x())
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) {
|
||||
Widget tmpWidget = it.getWidgetAtPos(_pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
// parse the next layer ...
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
@ -1,38 +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/ContainerN.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Layer;
|
||||
using Layer = ememory::Ptr<ewol::widget::Layer>;
|
||||
using LayerWeak = ememory::WeakPtr<ewol::widget::Layer>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class Layer : public ewol::widget::ContainerN {
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Layer();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Layer, "Layer");
|
||||
/**
|
||||
* Desstructor
|
||||
*/
|
||||
~Layer();
|
||||
public:
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,332 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/List.hpp>
|
||||
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/compositing/Text.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::List);
|
||||
|
||||
ewol::widget::List::List() {
|
||||
addObjectType("ewol::widget::List");
|
||||
this.paddingSizeX = 2;
|
||||
#ifdef __TARGET_OS__Android
|
||||
this.paddingSizeY = 10;
|
||||
#else
|
||||
this.paddingSizeY = 2;
|
||||
#endif
|
||||
this.nbVisibleRaw = 0;
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
this.limitScrolling = Vector2f(1, 0.5);
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::List::init() {
|
||||
ewol::widget::WidgetScrolled::init();
|
||||
addComposeElemnent("drawing", ememory::make<ewol::compositing::Drawing>());
|
||||
addComposeElemnent("text", ememory::make<ewol::compositing::Text>());
|
||||
}
|
||||
|
||||
|
||||
ewol::widget::List::~List() {
|
||||
}
|
||||
|
||||
void ewol::widget::List::addComposeElemnent( String _name, ememory::Ptr<ewol::Compositing> _element) {
|
||||
this.compositingElements.set(_name, _element);
|
||||
this.listOObject.pushBack(_element);
|
||||
}
|
||||
|
||||
void ewol::widget::List::clearComposeElemnent() {
|
||||
for (auto it: this.compositingElements) {
|
||||
it.second.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::List::removeComposeElemnent() {
|
||||
this.compositingElements.clear();
|
||||
}
|
||||
|
||||
ememory::Ptr<ewol::Compositing> ewol::widget::List::getComposeElemnent( String _name) {
|
||||
return this.compositingElements[_name];
|
||||
}
|
||||
/*
|
||||
void ewol::widget::List::setRawVisible(int _id) {
|
||||
Log.debug("Set Raw visible : " + _id);
|
||||
if (_id<0) {
|
||||
return;
|
||||
}
|
||||
if (_id == this.displayStartRaw) {
|
||||
// nothing to do ...
|
||||
return;
|
||||
}
|
||||
if (_id < this.displayStartRaw) {
|
||||
this.displayStartRaw = _id-2;
|
||||
} else {
|
||||
if (this.displayStartRaw + this.nbVisibleRaw < _id) {
|
||||
this.displayStartRaw = _id - this.nbVisibleRaw + 2;
|
||||
}
|
||||
}
|
||||
Vector2i matrixSize = getMatrixSize();
|
||||
if (this.displayStartRaw > matrixSize.y()) {
|
||||
this.displayStartRaw = matrixSize.y()-2;
|
||||
}
|
||||
if (this.displayStartRaw<0) {
|
||||
this.displayStartRaw = 0;
|
||||
}
|
||||
Log.debug("Set start raw : " + this.displayStartRaw);
|
||||
markToRedraw();
|
||||
}
|
||||
*/
|
||||
|
||||
void ewol::widget::List::calculateMinMaxSize() {
|
||||
/*int fontId = getDefaultFontId();
|
||||
int minWidth = ewol::getWidth(fontId, this.label);
|
||||
int minHeight = ewol::getHeight(fontId);
|
||||
this.minSize.x = 3+minWidth;
|
||||
this.minSize.y = 3+minHeight;
|
||||
*/
|
||||
this.minSize.setValue(200, 150);
|
||||
}
|
||||
|
||||
void ewol::widget::List::onDraw() {
|
||||
for (int iii=0; iii<this.listOObject.size(); iii++) {
|
||||
if (this.listOObject[iii] != null) {
|
||||
this.listOObject[iii].draw();
|
||||
}
|
||||
}
|
||||
WidgetScrolled::onDraw();
|
||||
}
|
||||
|
||||
void ewol::widget::List::onRegenerateDisplay() {
|
||||
if (needRedraw() == true) {
|
||||
// clean the object list ...
|
||||
clearComposeElemnent();
|
||||
// -------------------------------------------------------
|
||||
// -- Calculate the size of each element
|
||||
// -------------------------------------------------------
|
||||
Vector2i matrixSize = getMatrixSize();
|
||||
this.listSizeX.clear();
|
||||
this.listSizeX.resize(matrixSize.x(), 0);
|
||||
this.listSizeY.clear();
|
||||
this.listSizeY.resize(matrixSize.y(), 0);
|
||||
for (int_t yyy=0; yyy<matrixSize.y(); ++yyy) {
|
||||
for (int_t xxx=0; xxx<matrixSize.x(); ++xxx) {
|
||||
Vector2i pos(xxx, yyy);
|
||||
Vector2f elementSize = calculateElementSize(pos);
|
||||
if (elementSize.x() > this.listSizeX[xxx]) {
|
||||
this.listSizeX[xxx] = elementSize.x();
|
||||
}
|
||||
if (elementSize.y() > this.listSizeY[yyy]) {
|
||||
this.listSizeY[yyy] = elementSize.y();
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------
|
||||
// -- Fill property applyence
|
||||
// -------------------------------------------------------
|
||||
if (propertyFill.x() == true) {
|
||||
int fullSize = 0;
|
||||
for (auto size: this.listSizeX) {
|
||||
fullSize += size;
|
||||
}
|
||||
if (fullSize < this.size.x() ) {
|
||||
// need to expand all elements:
|
||||
int residualAdd = (this.size.x() - fullSize) / matrixSize.x();
|
||||
if (residualAdd != 0) {
|
||||
for (auto size: this.listSizeX) {
|
||||
size += residualAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (propertyFill.y() == true) {
|
||||
int fullSize = 0;
|
||||
for (auto size: this.listSizeY) {
|
||||
fullSize += size;
|
||||
}
|
||||
if (fullSize < this.size.y() ) {
|
||||
// need to expand all elements:
|
||||
int residualAdd = (this.size.y() - fullSize) / matrixSize.y();
|
||||
if (residualAdd != 0) {
|
||||
for (auto size: this.listSizeY) {
|
||||
size += residualAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
// -------------------------------------------------------
|
||||
// -- Calculate the start position size of each element
|
||||
// -------------------------------------------------------
|
||||
List<int> listStartPosX;
|
||||
List<int> listStartPosY;
|
||||
int lastPositionX = 0;
|
||||
for (auto size: this.listSizeX) {
|
||||
listStartPosX.pushBack(lastPositionX);
|
||||
lastPositionX += size;
|
||||
}
|
||||
int lastPositionY = 0;
|
||||
for (auto size: this.listSizeY) {
|
||||
lastPositionY += size;
|
||||
listStartPosY.pushBack(lastPositionY);
|
||||
}
|
||||
// -------------------------------------------------------
|
||||
// -- Update the scroolBar
|
||||
// -------------------------------------------------------
|
||||
this.maxSize = Vector2i(lastPositionX, lastPositionY);
|
||||
// -------------------------------------------------------
|
||||
// -- Clean the background
|
||||
// -------------------------------------------------------
|
||||
drawBackground();
|
||||
// -------------------------------------------------------
|
||||
// -- Draw each element
|
||||
// -------------------------------------------------------
|
||||
for (int_t yyy=0; yyy<matrixSize.y(); ++yyy) {
|
||||
float startYposition = this.size.y() + this.originScrooled.y() - listStartPosY[yyy];
|
||||
if (startYposition + this.listSizeY[yyy] < 0) {
|
||||
// ==> element out of range ==> nothing to display
|
||||
break;
|
||||
}
|
||||
if (startYposition > this.size.y()) {
|
||||
// ==> element out of range ==> nothing to display
|
||||
continue;
|
||||
}
|
||||
for (int_t xxx=0; xxx<matrixSize.x(); ++xxx) {
|
||||
float startXposition = -this.originScrooled.x() + listStartPosX[xxx];
|
||||
//Log.error("display start: " + startXposition);
|
||||
if (startXposition + this.listSizeX[xxx] < 0) {
|
||||
// ==> element out of range ==> nothing to display
|
||||
continue;
|
||||
}
|
||||
if (startXposition > this.size.x()) {
|
||||
// ==> element out of range ==> nothing to display
|
||||
break;
|
||||
}
|
||||
drawElement(Vector2i(xxx, yyy),
|
||||
Vector2f(startXposition, startYposition),
|
||||
Vector2f(this.listSizeX[xxx], this.listSizeY[yyy]));
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------
|
||||
// -- Draw Scrooling widget
|
||||
// -------------------------------------------------------
|
||||
WidgetScrolled::onRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
Vector2i ewol::widget::List::getMatrixSize() {
|
||||
return Vector2i(1,0);
|
||||
}
|
||||
|
||||
Vector2f ewol::widget::List::calculateElementSize( Vector2i _pos) {
|
||||
auto tmpText = ememory::staticPointerCast<ewol::compositing::Text>(getComposeElemnent("text"));
|
||||
String myTextToWrite = getData(ListRole::Text, _pos).getSafeString();
|
||||
Vector3f textSize = tmpText.calculateSize(myTextToWrite);
|
||||
Vector2i count = getMatrixSize();
|
||||
return Vector2f(textSize.x(),
|
||||
textSize.y() + this.paddingSizeY*3
|
||||
);
|
||||
}
|
||||
|
||||
void ewol::widget::List::drawBackground() {
|
||||
auto BGOObjects = ememory::staticPointerCast<ewol::compositing::Drawing>(getComposeElemnent("drawing"));
|
||||
if (BGOObjects != null) {
|
||||
etk::Color<> basicBG = getBasicBG();
|
||||
BGOObjects.setColor(basicBG);
|
||||
BGOObjects.setPos(Vector3f(0, 0, 0) );
|
||||
BGOObjects.rectangleWidth(this.size);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::List::drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) {
|
||||
String myTextToWrite = getData(ListRole::Text, _pos).getSafeString();
|
||||
etk::Color<> fg = getData(ListRole::FgColor, _pos).getSafeColor();
|
||||
auto backgroundVariant = getData(ListRole::BgColor, _pos);
|
||||
if (backgroundVariant.isColor() == true) {
|
||||
etk::Color<> bg = backgroundVariant.getColor();
|
||||
auto BGOObjects = ememory::staticPointerCast<ewol::compositing::Drawing>(getComposeElemnent("drawing"));
|
||||
if (BGOObjects != null) {
|
||||
BGOObjects.setColor(bg);
|
||||
BGOObjects.setPos(Vector3f(_start.x(), _start.y(), 0) );
|
||||
BGOObjects.rectangleWidth(_size);
|
||||
}
|
||||
}
|
||||
if (myTextToWrite != "") {
|
||||
auto tmpText = ememory::staticPointerCast<ewol::compositing::Text>(getComposeElemnent("text"));
|
||||
if (tmpText != null) {
|
||||
int displayPositionY = _start.y() + this.paddingSizeY;
|
||||
tmpText.setColor(fg);
|
||||
tmpText.setPos(Vector3f(_start.x() + this.paddingSizeX, displayPositionY, 0) );
|
||||
tmpText.print(myTextToWrite);;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean ewol::widget::List::onEventInput( ewol::event::Input _event) {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
if (WidgetScrolled::onEventInput(_event) == true) {
|
||||
keepFocus();
|
||||
// nothing to do ... done on upper widet ...
|
||||
return true;
|
||||
}
|
||||
if (this.listSizeY.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
relativePos = Vector2f(relativePos.x(),this.size.y() - relativePos.y()) + this.originScrooled;
|
||||
// Find the colomn and the row
|
||||
Vector2i pos{0,0};
|
||||
float_t offsetY = 0;
|
||||
for (int iii=0; iii<this.listSizeY.size()-1; iii++) {
|
||||
int previous = offsetY;
|
||||
offsetY += this.listSizeY[iii];
|
||||
if ( relativePos.y() < offsetY
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.y() >= previous ) {
|
||||
pos.setY(iii);
|
||||
offsetY = previous;
|
||||
break;
|
||||
}
|
||||
if ( iii == this.listSizeY.size()-2
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.y() >= offsetY ) {
|
||||
pos.setY(iii+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
float_t offsetX = 0;
|
||||
for (int iii=0; iii<this.listSizeX.size()-1; iii++) {
|
||||
int previous = offsetX;
|
||||
offsetX += this.listSizeX[iii];
|
||||
if ( relativePos.x() < offsetX
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.x() >= previous ) {
|
||||
pos.setX(iii);
|
||||
offsetX = previous;
|
||||
break;
|
||||
}
|
||||
if ( iii == this.listSizeX.size()-2
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM relativePos.x() >= offsetX ) {
|
||||
pos.setX(iii+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Vector2f posInternalMouse = relativePos - Vector2f(offsetX, offsetY);
|
||||
boolean isUsed = onItemEvent(_event, pos, posInternalMouse);
|
||||
if (isUsed == true) {
|
||||
// TODO : this generate bugs ... I did not understand why ..
|
||||
//WidgetManager::focusKeep(this);
|
||||
}
|
||||
return isUsed;
|
||||
}
|
||||
|
||||
void ewol::widget::List::onGetFocus() {
|
||||
Log.debug("Ewol::List get focus");
|
||||
}
|
||||
|
||||
void ewol::widget::List::onLostFocus() {
|
||||
Log.debug("Ewol::List Lost focus");
|
||||
}
|
@ -1,130 +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 <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/WidgetScrolled.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <fluorine/Variant.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class List;
|
||||
using List = ememory::Ptr<ewol::widget::List>;
|
||||
using ListWeak = ememory::WeakPtr<ewol::widget::List>;
|
||||
|
||||
enum ListRole {
|
||||
Text = 11234, // string
|
||||
IsSelected, // bool
|
||||
IsExpand, // bool
|
||||
Icon, // string
|
||||
ChildCount, // uint_t
|
||||
HaveChild, // bool
|
||||
ParentId, // uint_t
|
||||
BgColor, // color
|
||||
FgColor, // color
|
||||
DistanceToRoot, // uint_t
|
||||
// Every other role must be set here:
|
||||
EndOfEwolRole
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class List : public ewol::widget::WidgetScrolled {
|
||||
protected:
|
||||
List();
|
||||
void init() ;
|
||||
public:
|
||||
~List();
|
||||
void calculateMinMaxSize() ;
|
||||
// drawing capabilities ....
|
||||
protected:
|
||||
List<ememory::Ptr<ewol::Compositing>> this.listOObject; //!< generic element to display...
|
||||
List<int> this.listSizeX; //!< size of every colomns
|
||||
List<int> this.listSizeY; //!< size of every rows
|
||||
protected:
|
||||
etk::Map<String, ememory::Ptr<ewol::Compositing>> this.compositingElements;
|
||||
void addComposeElemnent( String _name, ememory::Ptr<ewol::Compositing> _element);
|
||||
void clearComposeElemnent();
|
||||
void removeComposeElemnent();
|
||||
ememory::Ptr<ewol::Compositing> getComposeElemnent( String _name);
|
||||
public:
|
||||
void clearOObjectList();
|
||||
// list properties ...
|
||||
protected:
|
||||
int this.paddingSizeX;
|
||||
int this.paddingSizeY;
|
||||
int this.displayStartRaw; //!< Current starting diaplayed raw
|
||||
int this.displayCurrentNbLine; //!< Number of line in the display
|
||||
int this.nbVisibleRaw; // set the number of visible raw (calculate don display)
|
||||
protected:
|
||||
// function call to display the list :
|
||||
etk::Color<> getBasicBG() {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of colomn and row availlable in the list
|
||||
* @return Number of colomn and row
|
||||
*/
|
||||
Vector2i getMatrixSize() ;
|
||||
|
||||
fluorine::Variant getData(int _role, Vector2i _pos) {
|
||||
switch (_role) {
|
||||
case ListRole::Text:
|
||||
return "";
|
||||
case ListRole::FgColor:
|
||||
return etk::Color<>(0x00, 0x00, 0x00, 0xFF);
|
||||
case ListRole::BgColor:
|
||||
if (_pos.y() % 2 == 0) {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
return etk::Color<>(0x7F, 0x7F, 0x7F, 0xFF);
|
||||
}
|
||||
return fluorine::Variant();
|
||||
};
|
||||
/**
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
Vector2f calculateElementSize( Vector2i _pos);
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size);
|
||||
/**
|
||||
* Draw the background
|
||||
*/
|
||||
void drawBackground();
|
||||
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* set a raw visible in the main display
|
||||
* @param _id Id of the raw that might be visible.
|
||||
*/
|
||||
//void setRawVisible(int _id);
|
||||
protected:
|
||||
void onGetFocus() ;
|
||||
void onLostFocus() ;
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,256 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/ListFileSystem.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
#include <etk/algorithm.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::ListFileSystem);
|
||||
|
||||
ewol::widget::ListFileSystem::ListFileSystem() :
|
||||
signalFileSelect(this, "file-select", ""),
|
||||
signalFileValidate(this, "file-validate", ""),
|
||||
signalFolderSelect(this, "folder-select", ""),
|
||||
signalFolderValidate(this, "folder-validate", ""),
|
||||
propertyPath(this, "path",
|
||||
etk::Path("/"),
|
||||
"Path to display",
|
||||
ewol::widget::ListFileSystem::onChangePropertyPath),
|
||||
propertyFile(this, "select",
|
||||
etk::Path(),
|
||||
"selection af a specific file",
|
||||
ewol::widget::ListFileSystem::onChangePropertyFile),
|
||||
propertyShowFile(this, "show-file",
|
||||
true,
|
||||
"display files",
|
||||
ewol::widget::ListFileSystem::onChangePropertyShowFile),
|
||||
propertyShowFolder(this, "show-folder",
|
||||
true,
|
||||
"display folders",
|
||||
ewol::widget::ListFileSystem::onChangePropertyShowFolder),
|
||||
propertyShowHidden(this, "show-hidden",
|
||||
true,
|
||||
"Show the hidden element (file, folder, ...)",
|
||||
ewol::widget::ListFileSystem::onChangePropertyShowHidden),
|
||||
propertyFilter(this, "filter",
|
||||
"",
|
||||
"regex to filter files ...",
|
||||
ewol::widget::ListFileSystem::onChangePropertyFilter),
|
||||
this.selectedLine(-1) {
|
||||
addObjectType("ewol::widget::ListFileSystem");
|
||||
#if defined(__TARGET_OS__Windows)
|
||||
propertyPath.setDirectCheck("c:/");
|
||||
#endif
|
||||
this.colorProperty = ewol::resource::ColorFile::create("THEME_COLOR:///ListFileSystem.json?lib=ewol");
|
||||
if (this.colorProperty != null) {
|
||||
this.colorIdText = this.colorProperty.request("text");
|
||||
this.colorIdBackground1 = this.colorProperty.request("background1");
|
||||
this.colorIdBackground2 = this.colorProperty.request("background2");
|
||||
this.colorIdBackgroundSelected = this.colorProperty.request("selected");
|
||||
}
|
||||
setMouseLimit(2);
|
||||
}
|
||||
|
||||
ewol::widget::ListFileSystem::~ListFileSystem() {
|
||||
clearList();
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::clearList() {
|
||||
this.list.clear();
|
||||
}
|
||||
|
||||
etk::Color<> ewol::widget::ListFileSystem::getBasicBG() {
|
||||
return this.colorProperty.get(this.colorIdBackground1);
|
||||
}
|
||||
|
||||
static boolean localSort( etk::Path _left, etk::Path _right) {
|
||||
return _left.getString().toUpper() <= _right.getString().toUpper();
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::regenerateView() {
|
||||
clearList();
|
||||
this.selectedLine = -1;
|
||||
this.list.clear();
|
||||
this.originScrooled.setValue(0,0);
|
||||
uint flags = 0;
|
||||
if (*propertyShowHidden == true) {
|
||||
flags |= etk::path::LIST_HIDDEN;
|
||||
}
|
||||
if (*propertyShowFolder == true) {
|
||||
flags |= etk::path::LIST_FOLDER;
|
||||
}
|
||||
if (*propertyShowFile == true) {
|
||||
flags |= etk::path::LIST_FILE;
|
||||
}
|
||||
this.list = etk::path::list(*propertyPath, flags);
|
||||
Log.error("Lsit of element: " + this.list.size() );
|
||||
// Sort the list:
|
||||
etk::algorithm::quickSort(this.list, localSort);
|
||||
// request a redraw ...
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
etk::Path ewol::widget::ListFileSystem::getSelect() {
|
||||
String tmpVal = "";
|
||||
if (this.selectedLine >= 0) {
|
||||
tmpVal = this.list[this.selectedLine].getFileName();
|
||||
}
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
// select the specific file
|
||||
void ewol::widget::ListFileSystem::setSelect( etk::Path _data) {
|
||||
// remove selected line
|
||||
this.selectedLine = -1;
|
||||
// search the coresponding file :
|
||||
for (int iii=0; iii<this.list.size(); ++iii) {
|
||||
if (this.list[iii] == _data) {
|
||||
// we find the line :
|
||||
this.selectedLine = iii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
Vector2i ewol::widget::ListFileSystem::getMatrixSize() {
|
||||
int offset = 0;
|
||||
if (*propertyShowFolder == true) {
|
||||
if (propertyPath.get() == "/") {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
}
|
||||
return Vector2i(1, this.list.size() + offset);
|
||||
}
|
||||
|
||||
fluorine::Variant ewol::widget::ListFileSystem::getData(int _role, Vector2i _pos) {
|
||||
switch (_role) {
|
||||
case ListRole::Text:
|
||||
{
|
||||
int offset = 0;
|
||||
if (*propertyShowFolder == true) {
|
||||
if (*propertyPath == "/") {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
if (_pos.y() == 0) {
|
||||
return ".";
|
||||
} else if ( _pos.y() == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM propertyPath.get() != "/") {
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
if( _pos.y()-offset >= 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _pos.y()-offset < (int)this.list.size()) {
|
||||
Log.verbose("get filename for : '" + this.list[_pos.y()-offset] + ":'" + this.list[_pos.y()-offset].getFileName() + "'");
|
||||
return this.list[_pos.y()-offset].getFileName();
|
||||
}
|
||||
}
|
||||
return "+<ERROR>>>";
|
||||
case ListRole::FgColor:
|
||||
return this.colorProperty.get(this.colorIdText);
|
||||
case ListRole::BgColor:
|
||||
if (this.selectedLine == _pos.y()) {
|
||||
return this.colorProperty.get(this.colorIdBackgroundSelected);
|
||||
}
|
||||
if (_pos.y() % 2) {
|
||||
return this.colorProperty.get(this.colorIdBackground1);
|
||||
}
|
||||
return this.colorProperty.get(this.colorIdBackground2);
|
||||
}
|
||||
return fluorine::Variant();
|
||||
}
|
||||
|
||||
boolean ewol::widget::ListFileSystem::onItemEvent( ewol::event::Input _event,
|
||||
Vector2i _pos,
|
||||
Vector2f _mousePosition) {
|
||||
int offset = 0;
|
||||
if (*propertyShowFolder == true) {
|
||||
if (*propertyPath == "/") {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
}
|
||||
if ( _event.getStatus() == KeyStatus::pressSingle
|
||||
|| _event.getStatus() == KeyStatus::pressDouble) {
|
||||
Log.verbose("Event on List : IdInput=" + _event.getId() + " _pos=" + _pos );
|
||||
if (1 == _event.getId()) {
|
||||
if (_pos.y() > (int)this.list.size()+offset ) {
|
||||
this.selectedLine = -1;
|
||||
} else {
|
||||
this.selectedLine = _pos.y();
|
||||
}
|
||||
if( *propertyShowFolder == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.selectedLine == 0) {
|
||||
// "." folder
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
signalFolderSelect.emit(*propertyPath);
|
||||
} else {
|
||||
signalFolderValidate.emit(*propertyPath);
|
||||
}
|
||||
} else if ( *propertyShowFolder == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.selectedLine == 1) {
|
||||
// ".." folder
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
signalFolderSelect.emit(propertyPath.getParent());
|
||||
} else {
|
||||
signalFolderValidate.emit(propertyPath.getParent());
|
||||
}
|
||||
} else if( this.selectedLine-offset >= 0
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.selectedLine-offset < (int)this.list.size() ) {
|
||||
// generate event extern:
|
||||
if(etk::path::isDirectory(this.list[this.selectedLine-offset])) {
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
signalFolderSelect.emit(this.list[this.selectedLine-offset]);
|
||||
} else {
|
||||
signalFolderValidate.emit(this.list[this.selectedLine-offset]);
|
||||
}
|
||||
} else {
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
signalFileSelect.emit(this.list[this.selectedLine-offset]);
|
||||
} else {
|
||||
signalFileValidate.emit(this.list[this.selectedLine-offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// need to regenerate the display of the list :
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::onChangePropertyPath() {
|
||||
Log.warning("Change Path: " + *propertyPath + " selected File=" + *propertyFile);;
|
||||
regenerateView();
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::onChangePropertyFile() {
|
||||
setSelect(propertyFile);
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::onChangePropertyShowFile() {
|
||||
regenerateView();
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::onChangePropertyShowFolder() {
|
||||
regenerateView();
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::onChangePropertyShowHidden() {
|
||||
regenerateView();
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::onChangePropertyFilter() {
|
||||
regenerateView();
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/resource/ColorFile.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class ListFileSystem;
|
||||
using ListFileSystem = ememory::Ptr<ewol::widget::ListFileSystem>;
|
||||
using ListFileSystemWeak = ememory::WeakPtr<ewol::widget::ListFileSystem>;
|
||||
/**
|
||||
* Generic display folder class. This widget display the content of a single folder :
|
||||
*/
|
||||
class ListFileSystem : public ewol::widget::List {
|
||||
public: // signals
|
||||
esignal::Signal<etk::Path> signalFileSelect; //!< @event "file-select" Generated when a file is selected.
|
||||
esignal::Signal<etk::Path> signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
||||
esignal::Signal<etk::Path> signalFolderSelect;
|
||||
esignal::Signal<etk::Path> signalFolderValidate;
|
||||
public: // properties
|
||||
eproperty::Value<etk::Path> propertyPath; //!< Current folder that display point on.
|
||||
eproperty::Value<etk::Path> propertyFile; //!< current selected file
|
||||
eproperty::Value<bool> propertyShowFile; //!< Show files elements
|
||||
eproperty::Value<bool> propertyShowFolder; //!< Display the folders elements
|
||||
eproperty::Value<bool> propertyShowHidden; //!< Display hidden elements
|
||||
eproperty::Value<String> propertyFilter; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e")
|
||||
protected:
|
||||
ListFileSystem();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(ListFileSystem, "ListFileSystem");
|
||||
~ListFileSystem();
|
||||
protected:
|
||||
ememory::Ptr<ewol::resource::ColorFile> this.colorProperty; //!< theme color property.
|
||||
int this.colorIdText; //!< Color of the text.
|
||||
int this.colorIdBackground1; //!< Color of the Background.
|
||||
int this.colorIdBackground2; //!< Color of the Background 2.
|
||||
int this.colorIdBackgroundSelected; //!< Color of line selected.
|
||||
protected:
|
||||
etk::Color<> getBasicBG() ;
|
||||
Vector2i getMatrixSize() ;
|
||||
fluorine::Variant getData(int _role, Vector2i _pos) ;
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ;
|
||||
protected:
|
||||
List<etk::Path> this.list; //!< List of all element in the path. (they are filtered)
|
||||
/**
|
||||
* Clean the list of element.
|
||||
*/
|
||||
void clearList();
|
||||
/**
|
||||
* Regenerate the content of the view. this is actually not automation on the system update.
|
||||
*/
|
||||
void regenerateView();
|
||||
protected:
|
||||
int this.selectedLine; //!< Current Line ID that is selected
|
||||
public:
|
||||
/**
|
||||
* Select a specific file in the path
|
||||
* @param _data File to selested.
|
||||
*/
|
||||
void setSelect( etk::Path _data);
|
||||
/**
|
||||
* Get the current selected file/folder/... in the list
|
||||
* @return the String of the element selected.
|
||||
*/
|
||||
etk::Path getSelect() ;
|
||||
protected:
|
||||
void onChangePropertyPath();
|
||||
void onChangePropertyFile();
|
||||
void onChangePropertyShowFile();
|
||||
void onChangePropertyShowFolder();
|
||||
void onChangePropertyShowHidden();
|
||||
void onChangePropertyFilter();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,330 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/widget/Menu.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/ContextMenu.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <ewol/widget/Spacer.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
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 ="<sizer mode='hori' expand='true,false' fill='true,true'>\n";
|
||||
if (etk::end_with(tmpObject.this.image, ".edf") == true) {
|
||||
composeString+=" <image src='" + tmpObject.this.image + "' size='8,8mm' distance-field='true'/>\n";
|
||||
} else {
|
||||
composeString+=" <image src='" + tmpObject.this.image + "' size='8,8mm'/>\n";
|
||||
}
|
||||
composeString+=" <label><left>" + tmpObject.this.label + "</left></label>\n";
|
||||
composeString+="</sizer>\n";
|
||||
myButton.setSubWidget(ewol::widget::composerGenerateString(composeString));
|
||||
} else {
|
||||
ewol::widget::Label label = ewol::widget::Label::create();
|
||||
label.propertyValue.set("<left>" + tmpObject.this.label + "</left>");
|
||||
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<Widget>(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+= " <sizer mode='hori' expand='true,false' fill='true,true' lock='true'>\n";
|
||||
if (etk::end_with(this.listElement[iii].this.image, ".edf") == true) {
|
||||
composeString+=" <image src='" + this.listElement[iii].this.image + "' size='8,8mm' distance-field='true'/>\n";
|
||||
} else {
|
||||
composeString+=" <image src='" + this.listElement[iii].this.image + "' size='8,8mm'/>\n";
|
||||
}
|
||||
composeString+=" <label exand='true,true' fill='true,true'><left>" + this.listElement[iii].this.label + "</left></label>\n";
|
||||
composeString+=" </sizer>\n";
|
||||
myButton.setSubWidget(ewol::widget::composerGenerateString(composeString));
|
||||
} else {
|
||||
if (menuHaveImage == true) {
|
||||
myButton.setSubWidget(ewol::widget::composerGenerateString(
|
||||
String() +
|
||||
" <sizer mode='hori' expand='true,false' fill='true,true' lock='true'>\n"
|
||||
" <spacer min-size='8,0mm'/>\n"
|
||||
" <label exand='true,true' fill='true,true'><![CDATA[<left>" + this.listElement[iii].this.label + "</left>]]></label>\n"
|
||||
" </sizer>\n")
|
||||
);
|
||||
} else {
|
||||
ewol::widget::Label tmpLabel = widget::Label::create();
|
||||
if (tmpLabel != null) {
|
||||
tmpLabel.propertyValue.set(String("<left>") + this.listElement[iii].this.label + "</left>\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") {
|
||||
// <elem title="_T{Title of the button}" image="DATA:///List.svg" event="menu:exit">
|
||||
int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]);
|
||||
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") {
|
||||
// <elem title="_T{Title of the button}" image="DATA:///List.svg" event="menu:exit">
|
||||
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;
|
||||
}
|
@ -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<String> 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<Widget> widgetPointer;
|
||||
public String label;
|
||||
public String image;
|
||||
public String message;
|
||||
};
|
||||
@EwolSignal(name = "select", description = "menu is selected")
|
||||
public Signal<String> 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){
|
||||
LOGGER.error("Not availlable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void subWidgetRemoveAll();
|
||||
private void subWidgetRemove(Widget _newWidget){
|
||||
LOGGER.error("Not availlable");
|
||||
}
|
||||
|
||||
int subWidgetAdd(Widget _newWidget);
|
||||
private void subWidgetUnLink(Widget _newWidget){
|
||||
LOGGER.error("Not availlable");
|
||||
}
|
||||
protected static final String eventButtonPressed = "menu-local-pressed";
|
||||
private boolean loadXML( exml::Element _node) ;
|
||||
private List<MenuElement> 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<ewol::widget::MenuElement> 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) {
|
||||
LOGGER.error("Allocation button error");
|
||||
return tmpObject.this.localId;
|
||||
}
|
||||
if (tmpObject.this.image.size()!=0) {
|
||||
String composeString ="<sizer mode='HORIZONTAL' expand='true,false' fill='true,true'>\n";
|
||||
if (etk::end_with(tmpObject.this.image, ".edf") == true) {
|
||||
composeString+=" <image src='" + tmpObject.this.image + "' size='8,8mm' distance-field='true'/>\n";
|
||||
} else {
|
||||
composeString+=" <image src='" + tmpObject.this.image + "' size='8,8mm'/>\n";
|
||||
}
|
||||
composeString+=" <label><left>" + tmpObject.this.label + "</left></label>\n";
|
||||
composeString+="</sizer>\n";
|
||||
myButton.setSubWidget(ewol::widget::composerGenerateString(composeString));
|
||||
} else {
|
||||
ewol::widget::Label label = ewol::widget::Label::create();
|
||||
label.propertyValue.set("<left>" + tmpObject.this.label + "</left>");
|
||||
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) {
|
||||
LOGGER.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){
|
||||
LOGGER.info("[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) {
|
||||
LOGGER.debug("Menu == > generate Event");
|
||||
// Send a multicast event ...
|
||||
signalSelect.emit(it.this.message);
|
||||
ewol::widget::ContextMenu tmpContext = this.widgetContextMenu.lock();
|
||||
if (tmpContext != null) {
|
||||
LOGGER.debug("Mark the menu to remove ...");
|
||||
tmpContext.destroy();
|
||||
}
|
||||
return;
|
||||
}
|
||||
LOGGER.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) {
|
||||
LOGGER.warn("Event on menu element with no child an no event... label=" + it.this.label);
|
||||
return;
|
||||
}
|
||||
// create a context menu:
|
||||
ewol::widget::ContextMenu tmpContext = ewol::widget::ContextMenu::create();
|
||||
this.widgetContextMenu = tmpContext;
|
||||
if (tmpContext == null) {
|
||||
LOGGER.error("Allocation Error");
|
||||
return;
|
||||
}
|
||||
// get the button widget:
|
||||
Vector2f newPosition;
|
||||
Widget eventFromWidget = ememory::dynamicPointerCast<Widget>(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) {
|
||||
LOGGER.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) {
|
||||
LOGGER.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+= " <sizer mode='hori' expand='true,false' fill='true,true' lock='true'>\n";
|
||||
if (etk::end_with(this.listElement[iii].this.image, ".edf") == true) {
|
||||
composeString+=" <image src='" + this.listElement[iii].this.image + "' size='8,8mm' distance-field='true'/>\n";
|
||||
} else {
|
||||
composeString+=" <image src='" + this.listElement[iii].this.image + "' size='8,8mm'/>\n";
|
||||
}
|
||||
composeString+=" <label exand='true,true' fill='true,true'><left>" + this.listElement[iii].this.label + "</left></label>\n";
|
||||
composeString+=" </sizer>\n";
|
||||
myButton.setSubWidget(ewol::widget::composerGenerateString(composeString));
|
||||
} else {
|
||||
if (menuHaveImage == true) {
|
||||
myButton.setSubWidget(ewol::widget::composerGenerateString(
|
||||
String() +
|
||||
" <sizer mode='hori' expand='true,false' fill='true,true' lock='true'>\n"
|
||||
" <spacer min-size='8,0mm'/>\n"
|
||||
" <label exand='true,true' fill='true,true'><![CDATA[<left>" + this.listElement[iii].this.label + "</left>]]></label>\n"
|
||||
" </sizer>\n")
|
||||
);
|
||||
} else {
|
||||
ewol::widget::Label tmpLabel = widget::Label::create();
|
||||
if (tmpLabel != null) {
|
||||
tmpLabel.propertyValue.set(String("<left>") + this.listElement[iii].this.label + "</left>\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) {
|
||||
LOGGER.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();
|
||||
LOGGER.info("Get node : " + pNode);
|
||||
if (widgetName == "elem") {
|
||||
// <elem title="_T{Title of the button}" image="DATA:///List.svg" event="menu:exit">
|
||||
int idMenu = addTitle(pNode.attributes["title"], pNode.attributes["image"], pNode.attributes["event"]);
|
||||
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") {
|
||||
// <elem title="_T{Title of the button}" image="DATA:///List.svg" event="menu:exit">
|
||||
add(idMenu, pNode2.attributes["title"], pNode2.attributes["image"], pNode2.attributes["event"]);
|
||||
} else if (widgetName2 == "separator") {
|
||||
addSpacer(idMenu);
|
||||
} else {
|
||||
LOGGER.error("[" + getId() + "] {" + getObjectType() + "} (l " + pNode2.getPos() + ") Unknown basic node='" + widgetName2 + "' not in : [elem,separator]" );
|
||||
}
|
||||
}
|
||||
} else if (widgetName == "separator") {
|
||||
addSpacer();
|
||||
} else {
|
||||
LOGGER.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;WeakReference<Widget>this.widgetPointer;String this.label;String this.image;String this.message;
|
||||
}
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,444 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Scroll.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Scroll);
|
||||
|
||||
ewol::widget::Scroll::Scroll() :
|
||||
propertyLimit(this, "limit",
|
||||
Vector2f(0.15,0.5), Vector2f(0.0,0.0), Vector2f(1.0,1.0),
|
||||
"Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end",
|
||||
ewol::widget::Scroll::onChangePropertyLimit),
|
||||
propertyShapeVert(this, "shape-vert",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the vertical display",
|
||||
ewol::widget::Scroll::onChangePropertyShapeVert),
|
||||
propertyShapeHori(this, "shape-hori",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the horizonal display",
|
||||
ewol::widget::Scroll::onChangePropertyShapeHori),
|
||||
propertyHover(this, "hover",
|
||||
true,
|
||||
"the display bar are hover the subWidget"),
|
||||
this.pixelScrolling(20),
|
||||
this.highSpeedStartPos(0,0),
|
||||
this.highSpeedMode(speedModeDisable),
|
||||
this.highSpeedButton(-1),
|
||||
this.highSpeedType(KeyType::unknow) {
|
||||
addObjectType("ewol::widget::Scroll");
|
||||
// Remove gravity property: (only keep top/buttom)
|
||||
propertyGravity.remove("center");
|
||||
propertyGravity.remove("top-left");
|
||||
//propertyGravity.remove("top");
|
||||
propertyGravity.remove("top-right");
|
||||
propertyGravity.remove("right");
|
||||
propertyGravity.remove("buttom-right");
|
||||
//propertyGravity.remove("buttom");
|
||||
propertyGravity.remove("buttom-left");
|
||||
propertyGravity.remove("left");
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::init() {
|
||||
ewol::widget::Container::init();
|
||||
propertyShapeVert.notifyChange();
|
||||
propertyShapeHori.notifyChange();
|
||||
}
|
||||
|
||||
|
||||
ewol::widget::Scroll::~Scroll() {
|
||||
|
||||
}
|
||||
// TODO : create a config for this ...
|
||||
#define SCROLL_BAR_SPACE (15)
|
||||
|
||||
// note: The widget will expand has possible and will control itself the display property
|
||||
void ewol::widget::Scroll::onChangeSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
Widget::onChangeSize();
|
||||
if (*propertyHide == true) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget == null) {
|
||||
return;
|
||||
}
|
||||
// remove the bar if hover
|
||||
Vector2f basicSize = this.size;
|
||||
if (*propertyHover == false) {
|
||||
basicSize -= Vector2f(SCROLL_BAR_SPACE,SCROLL_BAR_SPACE);
|
||||
}
|
||||
|
||||
|
||||
Vector2f origin = this.origin+this.offset;
|
||||
Vector2f minSize = this.subWidget.getCalculateMinSize();
|
||||
Vector2b expand = this.subWidget.propertyExpand.get();
|
||||
//The gravity is not set on the sub element ==> special use of the widget
|
||||
//origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - this.size);
|
||||
if ( expand.x() == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM minSize.x() < basicSize.x()) {
|
||||
minSize.setX(basicSize.x());
|
||||
}
|
||||
if ( expand.y() == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM minSize.y() < basicSize.y()) {
|
||||
minSize.setY(basicSize.y());
|
||||
}
|
||||
this.subWidget.setSize(minSize);
|
||||
if (*propertyGravity == ewol::gravity_top) {
|
||||
origin += Vector2f(0.0f, basicSize.y()-minSize.y());
|
||||
if (*propertyHover == false) {
|
||||
origin += Vector2f(0,SCROLL_BAR_SPACE);
|
||||
}
|
||||
} else if (*propertyGravity == ewol::gravity_buttom) {
|
||||
// nothing to do ... origin +=
|
||||
} else {
|
||||
Log.error(" Not manage other gravity ...");
|
||||
}
|
||||
this.subWidget.setOrigin(origin);
|
||||
this.subWidget.onChangeSize();
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::calculateMinMaxSize() {
|
||||
// Note: No call of container ==> normal case ...
|
||||
Widget::calculateMinMaxSize();
|
||||
// call sub classes
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.calculateMinMaxSize();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
if (*propertyHide == true) {
|
||||
return;
|
||||
}
|
||||
if (this.subWidget != null) {
|
||||
ewol::DrawProperty prop = _displayProp;
|
||||
prop.limit(this.origin, this.size);
|
||||
this.subWidget.systemDraw(prop);
|
||||
}
|
||||
Widget::systemDraw(_displayProp);
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onDraw() {
|
||||
this.shaperH.draw();
|
||||
this.shaperV.draw();
|
||||
/*
|
||||
ewol::compositing::Drawing draw;
|
||||
draw.setPos(Vector2f(10,10));
|
||||
draw.setColor(etk::color::orange);
|
||||
draw.rectangleWidth(Vector2f(25,25));
|
||||
draw.setPos(this.size - Vector2f(35,35));
|
||||
draw.setColor(etk::color::green);
|
||||
draw.rectangleWidth(Vector2f(25,25));
|
||||
draw.draw();
|
||||
*/
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onRegenerateDisplay() {
|
||||
if (*propertyHide == true) {
|
||||
return;
|
||||
}
|
||||
// call upper class
|
||||
ewol::widget::Container::onRegenerateDisplay();
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
// clear all previous display
|
||||
this.shaperH.clear();
|
||||
this.shaperV.clear();
|
||||
ewol::Padding paddingVert = this.shaperV.getPadding();
|
||||
ewol::Padding paddingHori = this.shaperH.getPadding();
|
||||
Vector2f scrollOffset(0,0);
|
||||
Vector2f scrollSize(0,0);
|
||||
if (this.subWidget != null) {
|
||||
scrollOffset = this.subWidget.getOffset();
|
||||
scrollSize = this.subWidget.getSize();
|
||||
}
|
||||
if( this.size.y() < scrollSize.y()
|
||||
|| scrollOffset.y() != 0) {
|
||||
float lenScrollBar = this.size.y()*this.size.y() / scrollSize.y();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, this.size.y());
|
||||
float originScrollBar = scrollOffset.y() / (scrollSize.y()-this.size.y()*propertyLimit.y());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y()-lenScrollBar);
|
||||
this.shaperV.setShape(Vector2f(this.size.x() - paddingVert.x(), 0),
|
||||
Vector2f(paddingVert.x(), this.size.y()),
|
||||
Vector2f(this.size.x() - paddingVert.xRight(), this.size.y() - originScrollBar - lenScrollBar),
|
||||
Vector2f(0, lenScrollBar));
|
||||
}
|
||||
if( this.size.x() < scrollSize.x()
|
||||
|| scrollOffset.x() != 0) {
|
||||
float lenScrollBar = (this.size.x()-paddingHori.xLeft())*(this.size.x()-paddingVert.x()) / scrollSize.x();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, (this.size.x()-paddingVert.x()));
|
||||
float originScrollBar = scrollOffset.x() / (scrollSize.x()-this.size.x()*propertyLimit.x());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x()-paddingHori.xRight()-lenScrollBar);
|
||||
this.shaperH.setShape(Vector2f(0, 0),
|
||||
Vector2f(this.size.x()-paddingVert.x(), paddingHori.y()),
|
||||
Vector2f(originScrollBar, paddingHori.yButtom()),
|
||||
Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
boolean ewol::widget::Scroll::onEventInput( ewol::event::Input _event) {
|
||||
//ewol::event::Input _event = event;
|
||||
//_event.setType(KeyType::finger);
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
Vector2f scrollOffset(0,0);
|
||||
Vector2f scrollSize(0,0);
|
||||
if (this.subWidget != null) {
|
||||
scrollOffset = this.subWidget.getOffset();
|
||||
scrollSize = this.subWidget.getSize();
|
||||
}
|
||||
Log.verbose("Get Event on scroll : " + _event);
|
||||
relativePos.setY(this.size.y() - relativePos.y());
|
||||
if( _event.getType() == KeyType::mouse
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow
|
||||
|| this.highSpeedType == KeyType::mouse) ) {
|
||||
if( _event.getId() == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down) {
|
||||
// check if selected the scrolling position whth the scrolling bar ...
|
||||
if (relativePos.x() >= (this.size.x()-SCROLL_BAR_SPACE)) {
|
||||
if( this.size.y() < scrollSize.y()
|
||||
|| scrollOffset.y() != 0) {
|
||||
this.highSpeedMode = speedModeEnableVertical;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(relativePos.x());
|
||||
this.highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (this.size.y()-SCROLL_BAR_SPACE*2));
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
scrollOffset.setY((int)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (this.size.y()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (relativePos.y() >= (this.size.y()-SCROLL_BAR_SPACE)) {
|
||||
if( this.size.x() < scrollSize.x()
|
||||
|| scrollOffset.x()!=0) {
|
||||
this.highSpeedMode = speedModeEnableHorizontal;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (this.size.x()-SCROLL_BAR_SPACE*2));
|
||||
this.highSpeedStartPos.setY(relativePos.y());
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
scrollOffset.setX((int)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (this.size.x()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if( _event.getId() == 4
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
Log.verbose(" mode UP " + this.size.y() + "<" + scrollSize.y());
|
||||
if(this.size.y() < scrollSize.y()) {
|
||||
scrollOffset.setY(scrollOffset.y()-this.pixelScrolling);
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if( _event.getId() == 5
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
Log.verbose(" mode DOWN " + this.size.y() + "<" + scrollSize.y());
|
||||
if(this.size.y() < scrollSize.y()) {
|
||||
scrollOffset.setY(scrollOffset.y()+this.pixelScrolling);
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}else if (_event.getId() == 2) {
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.highSpeedMode = speedModeInit;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
this.highSpeedButton = 2;
|
||||
// not really use... == > just keep some informations
|
||||
return false;
|
||||
}
|
||||
} else if( this.highSpeedMode != speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if ( _event.getId() == this.highSpeedButton
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.highSpeedMode != speedModeDisable) {
|
||||
if (_event.getStatus() == KeyStatus::up) {
|
||||
if (this.highSpeedMode == speedModeInit) {
|
||||
// TODO : generate back the down event ...
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
return false;
|
||||
} else {
|
||||
this.highSpeedMode = speedModeGrepEndEvent;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (this.highSpeedMode == speedModeGrepEndEvent) {
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
this.highSpeedButton = -1;
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if( this.highSpeedMode == speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
if (relativePos.x() == this.highSpeedStartPos.x()) {
|
||||
this.highSpeedMode = speedModeEnableVertical;
|
||||
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
|
||||
this.highSpeedMode = speedModeEnableHorizontal;
|
||||
} else {
|
||||
float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x());
|
||||
if (etk::abs(coef) <= 1 ) {
|
||||
this.highSpeedMode = speedModeEnableHorizontal;
|
||||
} else {
|
||||
this.highSpeedMode = speedModeEnableVertical;
|
||||
}
|
||||
}
|
||||
if (this.highSpeedMode == speedModeEnableHorizontal) {
|
||||
this.highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (this.size.x()-SCROLL_BAR_SPACE*2));
|
||||
} else {
|
||||
this.highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (this.size.y()-SCROLL_BAR_SPACE*2));
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if( this.highSpeedMode == speedModeEnableHorizontal
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
scrollOffset.setX((int)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (this.size.x()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x() )));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if( this.highSpeedMode == speedModeEnableVertical
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
scrollOffset.setY((int)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (this.size.y()-SCROLL_BAR_SPACE*2)));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.x())));
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if( KeyType::finger == _event.getType()
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( KeyType::unknow == this.highSpeedType
|
||||
|| KeyType::finger == this.highSpeedType ) ) {
|
||||
if (1 == _event.getId()) {
|
||||
Log.verbose("event: " + _event);
|
||||
if (KeyStatus::down == _event.getStatus()) {
|
||||
this.highSpeedMode = speedModeInit;
|
||||
this.highSpeedType = KeyType::finger;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > INIT pos=" + this.highSpeedStartPos + " LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM curent scrollOffset=" + scrollOffset);
|
||||
return true;
|
||||
} else if (KeyStatus::upAfter == _event.getStatus()) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::move == _event.getStatus()) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
this.highSpeedMode = speedModeEnableFinger;
|
||||
Log.verbose("SCROOL == > ENABLE");
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ( this.highSpeedMode == speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::move == _event.getStatus()) {
|
||||
Log.verbose("SCROOL == > INIT scrollOffset=" + scrollOffset.y() + " relativePos=" + relativePos.y() + " this.highSpeedStartPos=" + this.highSpeedStartPos.y());
|
||||
//scrollOffset.x = (int)(scrollSize.x * x / this.size.x);
|
||||
if (propertyLimit.x() != 0.0f) {
|
||||
scrollOffset.setX(scrollOffset.x() + (relativePos.x() - this.highSpeedStartPos.x()));
|
||||
scrollOffset.setX(etk::avg(0.0f, scrollOffset.x(), (scrollSize.x() - this.size.x()*propertyLimit.x())));
|
||||
}
|
||||
if (propertyLimit.y() != 0.0f) {
|
||||
scrollOffset.setY(scrollOffset.y() - (relativePos.y() - this.highSpeedStartPos.y()));
|
||||
scrollOffset.setY(etk::avg(0.0f, scrollOffset.y(), (scrollSize.y() - this.size.y()*propertyLimit.y())));
|
||||
}
|
||||
// update current position:
|
||||
this.highSpeedStartPos = relativePos;
|
||||
Log.verbose("SCROOL == > MOVE " + scrollOffset);
|
||||
markToRedraw();
|
||||
if (this.subWidget != null) {
|
||||
this.subWidget.setOffset(scrollOffset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.highSpeedMode == speedModeEnableFinger) {
|
||||
return true;
|
||||
}
|
||||
} else if ( this.highSpeedMode != speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM KeyStatus::leave == _event.getStatus()) {
|
||||
this.highSpeedMode = speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Widget ewol::widget::Scroll::getWidgetAtPos( Vector2f _pos) {
|
||||
Widget tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos);
|
||||
if (tmpWidget != null) {
|
||||
return tmpWidget;
|
||||
}
|
||||
return ememory::dynamicPointerCast<Widget>(sharedFromThis());;
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onChangePropertyLimit() {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onChangePropertyShapeVert() {
|
||||
this.shaperV.setSource(propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Scroll::onChangePropertyShapeHori() {
|
||||
this.shaperH.setSource(propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
@ -1,66 +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/Container.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Scroll;
|
||||
using Scroll = ememory::Ptr<ewol::widget::Scroll>;
|
||||
using ScrollWeak = ememory::WeakPtr<ewol::widget::Scroll>;
|
||||
class Scroll : public ewol::widget::Container {
|
||||
public: // properties
|
||||
eproperty::Range<Vector2f> propertyLimit; //!< Set the limitation of the ratio in the sreen
|
||||
eproperty::Value<etk::Uri> propertyShapeVert; //!< Vertical shaper name
|
||||
eproperty::Value<etk::Uri> propertyShapeHori; //!< Horizontal shaper name
|
||||
eproperty::Value<bool> propertyHover; //!< Horizontal shaper name
|
||||
public:
|
||||
enum highSpeedMode {
|
||||
speedModeDisable,
|
||||
speedModeInit,
|
||||
speedModeEnableFinger, // Specific for touchpad
|
||||
speedModeEnableHorizontal, // Specific for mouse
|
||||
speedModeEnableVertical, // Specific for mouse
|
||||
speedModeGrepEndEvent
|
||||
};
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal.
|
||||
ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical.
|
||||
private:
|
||||
float this.pixelScrolling;
|
||||
Vector2f this.highSpeedStartPos;
|
||||
enum highSpeedMode this.highSpeedMode;
|
||||
int this.highSpeedButton;
|
||||
KeyType this.highSpeedType;
|
||||
protected:
|
||||
Scroll();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Scroll, "Scroll");
|
||||
~Scroll();
|
||||
public:
|
||||
void onChangeSize() ;
|
||||
void calculateMinMaxSize() ;
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void systemDraw( ewol::DrawProperty _displayProp) ;
|
||||
Widget getWidgetAtPos( Vector2f _pos) ;
|
||||
protected:
|
||||
void onDraw() ;
|
||||
protected:
|
||||
void onChangePropertyLimit();
|
||||
void onChangePropertyShapeVert();
|
||||
void onChangePropertyShapeHori();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,205 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Select.hpp>
|
||||
#include <ewol/widget/ContextMenu.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
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("<b>") + it.this.name + "</b>");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +1,230 @@
|
||||
/** @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.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
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/widget/meta/SpinBase.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Select;
|
||||
using Select = ememory::Ptr<ewol::widget::Select>;
|
||||
using SelectWeak = ememory::WeakPtr<ewol::widget::Select>;
|
||||
class Select extends SpinBase {
|
||||
@EwolSignal(name = "value", description = "Select value change")
|
||||
public Signal<int> signalValue = new Signal<int>();
|
||||
/*
|
||||
propertyValue(this, "value",
|
||||
"Value of the Select",
|
||||
ewol::widget::Select::onChangePropertyValue) {
|
||||
*/
|
||||
protected int propertyValue = -1; //!< Current state of the Select.
|
||||
/**
|
||||
* a composed Select is a Select with an inside composed with the specify XML element
|
||||
* ==> this permit to generate standard element simple
|
||||
* Constructor
|
||||
* @param _shaperName Shaper file properties
|
||||
*/
|
||||
class Select : public ewol::widget::SpinBase {
|
||||
public: // signals
|
||||
esignal::Signal<int> signalValue;
|
||||
public: // properties
|
||||
eproperty::Value<int> propertyValue; //!< Current state of the Select.
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
* @param _shaperName Shaper file properties
|
||||
*/
|
||||
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:
|
||||
DECLARE_WIDGET_FACTORY(Select, "Select");
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Select();
|
||||
protected:
|
||||
class Element {
|
||||
public:
|
||||
int this.value;
|
||||
String this.name;
|
||||
boolean this.selected;
|
||||
public:
|
||||
// TODO: Remove this: due to the fact my List is not full implemented
|
||||
Element() {}
|
||||
Element(int _value, String _name, boolean _selected=false);
|
||||
};
|
||||
List<ewol::widget::Select::Element> this.listElement;
|
||||
int value;
|
||||
String name;
|
||||
boolean selected;
|
||||
public:
|
||||
void optionSelectDefault();
|
||||
void optionRemove(int _value);
|
||||
void optionClear();
|
||||
void optionAdd(int _value, String _name);
|
||||
protected:
|
||||
boolean loadXML( exml::Element _node) ;
|
||||
void updateGui() ;
|
||||
protected:
|
||||
void onCallbackOpenMenu();
|
||||
void onCallbackLabelPressed(int _value);
|
||||
protected:
|
||||
esignal::Connection this.connectionEntry;
|
||||
esignal::Connection this.connectionButton;
|
||||
protected:
|
||||
void onChangePropertyValue();
|
||||
// TODO: Remove this: due to the fact my List is not full implemented
|
||||
Element() {}
|
||||
Element(int _value, String _name, boolean _selected=false) {
|
||||
this.value = _value;
|
||||
this.name = _name;
|
||||
this.selected = _selected;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
protected List<ewol::widget::Select::Element> this.listElement;
|
||||
public void optionSelectDefault(){
|
||||
if (this.widgetEntry == null) {
|
||||
LOGGER.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) {
|
||||
LOGGER.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) {
|
||||
LOGGER.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") {
|
||||
LOGGER.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);
|
||||
}
|
||||
LOGGER.warn("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) {
|
||||
LOGGER.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) {
|
||||
LOGGER.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) {
|
||||
LOGGER.error("Allocation Error");
|
||||
continue;
|
||||
}
|
||||
if (it.this.selected == true) {
|
||||
myLabel.propertyValue.set(String("<b>") + it.this.name + "</b>");
|
||||
} 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) {
|
||||
LOGGER.error("Can not get the curent Windows...");
|
||||
} else {
|
||||
currentWindows.popUpWidgetPush(tmpContext);
|
||||
}
|
||||
}
|
||||
protected void onCallbackLabelPressed(int _value){
|
||||
LOGGER.trace("User select:" + _value);
|
||||
propertyValue.set(_value);
|
||||
}
|
||||
protected esignal::Connection connectionEntry = null;
|
||||
protected esignal::Connection connectionButton = null;
|
||||
protected void onChangePropertyValue(){
|
||||
markToRedraw();
|
||||
if (this.widgetEntry == null) {
|
||||
LOGGER.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,134 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::Slider);
|
||||
|
||||
int dotRadius = 6;
|
||||
|
||||
ewol::widget::Slider::Slider() :
|
||||
signalChange(this, "change", ""),
|
||||
propertyValue(this, "value",
|
||||
0.0f,
|
||||
"Value of the Slider",
|
||||
ewol::widget::Slider::onChangePropertyValue),
|
||||
propertyMinimum(this, "min",
|
||||
0.0f,
|
||||
"Minium value",
|
||||
ewol::widget::Slider::onChangePropertyMinimum),
|
||||
propertyMaximum(this, "max",
|
||||
10.0f,
|
||||
"Maximum value",
|
||||
ewol::widget::Slider::onChangePropertyMaximum),
|
||||
propertyStep(this, "step",
|
||||
1.0f,
|
||||
"Step size",
|
||||
ewol::widget::Slider::onChangePropertyStep) {
|
||||
addObjectType("ewol::widget::Slider");
|
||||
|
||||
this.textColorFg = etk::color::black;
|
||||
|
||||
this.textColorBg = etk::color::black;
|
||||
this.textColorBg.setA(0x3F);
|
||||
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
}
|
||||
|
||||
ewol::widget::Slider::~Slider() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::calculateMinMaxSize() {
|
||||
Vector2f minTmp = propertyMinSize.getPixel();
|
||||
this.minSize.setValue(etk::max(minTmp.x(), 40.0f),
|
||||
etk::max(minTmp.y(), dotRadius*2.0f) );
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::onDraw() {
|
||||
this.draw.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::onRegenerateDisplay() {
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
// clean the object list ...
|
||||
this.draw.clear();
|
||||
this.draw.setColor(this.textColorFg);
|
||||
// draw a line :
|
||||
this.draw.setThickness(1);
|
||||
this.draw.setPos(Vector3f(dotRadius, this.size.y()/2, 0) );
|
||||
this.draw.lineTo(Vector3f(this.size.x()-dotRadius, this.size.y()/2, 0) );
|
||||
this.draw.setThickness(0);
|
||||
|
||||
etk::Color<> borderDot = this.textColorFg;
|
||||
borderDot.setA(borderDot.a()/2);
|
||||
this.draw.setPos(Vector3f(4+((propertyValue-propertyMinimum)/(propertyMaximum-propertyMinimum))*(this.size.x()-2*dotRadius), this.size.y()/2, 0) );
|
||||
this.draw.setColorBg(borderDot);
|
||||
this.draw.circle(dotRadius);
|
||||
this.draw.setColorBg(this.textColorFg);
|
||||
this.draw.circle(dotRadius/1.6);
|
||||
}
|
||||
|
||||
boolean ewol::widget::Slider::onEventInput( ewol::event::Input _event) {
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
//Log.debug("Event on Slider ..." + _event);
|
||||
if (1 == _event.getId()) {
|
||||
if( KeyStatus::pressSingle == _event.getStatus()
|
||||
|| KeyStatus::move == _event.getStatus()) {
|
||||
// get the new position :
|
||||
Log.verbose("Event on Slider (" + relativePos.x() + "," + relativePos.y() + ")");
|
||||
float oldValue = *propertyValue;
|
||||
updateValue(*propertyMinimum + (float)(relativePos.x() - dotRadius) / (this.size.x()-2*dotRadius) * (*propertyMaximum-*propertyMinimum));
|
||||
if (oldValue != *propertyValue) {
|
||||
Log.verbose(" new value : " + *propertyValue + " in [" + *propertyMinimum + ".." + *propertyMaximum + "]");
|
||||
signalChange.emit(*propertyValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::updateValue(float _newValue) {
|
||||
_newValue = etk::max(etk::min(_newValue, *propertyMaximum), *propertyMinimum);
|
||||
if (*propertyStep == 0.0f) {
|
||||
propertyValue.setDirect(_newValue);
|
||||
} else {
|
||||
float basicVal = (long)(_newValue / *propertyStep);
|
||||
propertyValue.setDirect(basicVal * *propertyStep);
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Slider::onChangePropertyValue() {
|
||||
updateValue(*propertyValue);
|
||||
return;
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::onChangePropertyMinimum() {
|
||||
updateValue(*propertyValue);
|
||||
return;
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::onChangePropertyMaximum() {
|
||||
updateValue(*propertyValue);
|
||||
return;
|
||||
}
|
||||
|
||||
void ewol::widget::Slider::onChangePropertyStep() {
|
||||
updateValue(*propertyValue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,60 +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 <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Slider;
|
||||
using Slider = ememory::Ptr<ewol::widget::Slider>;
|
||||
using SliderWeak = ememory::WeakPtr<ewol::widget::Slider>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class Slider : public Widget {
|
||||
public: // signals
|
||||
esignal::Signal<float> signalChange;
|
||||
public:
|
||||
//eproperty::Value<String> propertyShape; //!< name of the shape used
|
||||
eproperty::Value<float> propertyValue; //!< current value of the Slider
|
||||
eproperty::Value<float> propertyMinimum; //!< minimum value of the slider
|
||||
eproperty::Value<float> propertyMaximum; //!< maximum value of the slider
|
||||
eproperty::Value<float> propertyStep; //!< step of every iteration of the slider (increment/precision)
|
||||
protected:
|
||||
Slider();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(Slider, "Slider");
|
||||
~Slider();
|
||||
public:
|
||||
// TODO : Rewoek the color in the theme ...
|
||||
void setColor(etk::Color<> _newColor) {
|
||||
this.textColorFg = _newColor;
|
||||
};
|
||||
protected:
|
||||
ewol::compositing::Drawing this.draw; //!< drawing tool.
|
||||
etk::Color<> this.textColorFg; //!< Text color
|
||||
etk::Color<> this.textColorBg; //!< Background color
|
||||
void updateValue(float _newValue);
|
||||
public: // Derived function
|
||||
void onDraw() ;
|
||||
void calculateMinMaxSize() ;
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
protected:
|
||||
void onChangePropertyValue();
|
||||
void onChangePropertyMinimum();
|
||||
void onChangePropertyMaximum();
|
||||
void onChangePropertyStep();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,106 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Spin.hpp>
|
||||
#include <ewol/widget/ContextMenu.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
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
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionEntry.isConnected() == false) {
|
||||
|
||||
}
|
||||
if ( this.widgetButtonUp != null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.connectionButtonUp.isConnected() == false) {
|
||||
this.connectionButtonUp = this.widgetButtonUp.signalPressed.connect(this, ewol::widget::Spin::onCallbackUp);
|
||||
}
|
||||
if ( this.widgetButtonDown != null
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM 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);
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/widget/meta/SpinBase.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class Spin;
|
||||
using Spin = ememory::Ptr<ewol::widget::Spin>;
|
||||
using SpinWeak = ememory::WeakPtr<ewol::widget::Spin>;
|
||||
/**
|
||||
* 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<long> signalValue;
|
||||
esignal::Signal<double> signalValueDouble;
|
||||
public:
|
||||
eproperty::Value<long> propertyValue; //!< Current value of the Spin.
|
||||
eproperty::Value<long> propertyMin; //!< Minimum value
|
||||
eproperty::Value<long> propertyMax; //!< Maximum value
|
||||
eproperty::Value<long> propertyIncrement; //!< Increment value
|
||||
eproperty::Value<int8_t> 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();
|
||||
};
|
||||
};
|
||||
};
|
@ -124,7 +124,7 @@ void ewol::widget::TreeView::drawElement( Vector2i _pos, Vector2f _start, Vect
|
||||
tmpImage.setPos(posStart);
|
||||
tmpImage.print(Vector2f(propertyIconTreeViewSize.get(), propertyIconTreeViewSize.get()));
|
||||
} else {
|
||||
Log.error("can not get : " + iconName );
|
||||
LOGGER.error("can not get : " + iconName );
|
||||
}
|
||||
// move right
|
||||
posStart.setX(posStart.x() + propertyIconTreeViewSize.get());
|
||||
@ -161,7 +161,7 @@ boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2
|
||||
if (_pos.x() != 0) {
|
||||
return false;
|
||||
}
|
||||
//Log.info("event: " + _event);
|
||||
//LOGGER.info("event: " + _event);
|
||||
Vector2f posStart = Vector2f(0,0);
|
||||
boolean haveChild = getData(ListRole::HaveChild, _pos).getSafeBoolean();
|
||||
if (haveChild == false) {
|
||||
@ -172,15 +172,15 @@ boolean ewol::widget::TreeView::onItemEvent( ewol::event::Input _event, Vector2
|
||||
posStart.setX(posStart.x() + value.getSafeNumber() * propertyOffsetTreeView.get());
|
||||
}
|
||||
// Inverse the display of Y
|
||||
Log.verbose("check: " + Vector2f(_mousePosition.x(), this.listSizeY[_pos.y()] - _mousePosition.y())
|
||||
LOGGER.trace("check: " + Vector2f(_mousePosition.x(), this.listSizeY[_pos.y()] - _mousePosition.y())
|
||||
+ " in " + posStart
|
||||
+ " . " + (posStart+Vector2f(propertyIconTreeViewSize.get(),propertyIconTreeViewSize.get())));
|
||||
if ( _mousePosition.x() >= posStart.x()
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +1,36 @@
|
||||
/** @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 <etk/Color.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <fluorine/Variant.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class TreeView;
|
||||
using TreeView = ememory::Ptr<ewol::widget::TreeView>;
|
||||
using TreeViewWeak = ememory::WeakPtr<ewol::widget::TreeView>;
|
||||
|
||||
class TreeView extends WidgetList {
|
||||
public: // signals
|
||||
public: // properties
|
||||
eproperty::Value<float> propertyOffsetTreeView; //!< indentation betwwen every new element.
|
||||
eproperty::Value<float> propertyIconTreeViewSize; //!< Size of the icon.
|
||||
eproperty::Value<bool> propertyTextIsDecorated; //!< Size of the icon.
|
||||
protected:
|
||||
TreeView();
|
||||
void init() ;
|
||||
public:
|
||||
~TreeView();
|
||||
protected:
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
class TreeView : public ewol::widget::List {
|
||||
public: // signals
|
||||
public: // properties
|
||||
eproperty::Value<float> propertyOffsetTreeView; //!< indentation betwwen every new element.
|
||||
eproperty::Value<float> propertyIconTreeViewSize; //!< Size of the icon.
|
||||
eproperty::Value<bool> propertyTextIsDecorated; //!< Size of the icon.
|
||||
protected:
|
||||
TreeView();
|
||||
void init() ;
|
||||
public:
|
||||
~TreeView();
|
||||
protected:
|
||||
/**
|
||||
* Calculate an element size to extimate the render size.
|
||||
* @note Does not generate the with the same size.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
Vector2f calculateElementSize( Vector2i _pos) ;
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) ;
|
||||
protected:
|
||||
void onChangePropertyOffsetTreeView();
|
||||
void onChangePropertyTextDecorated();
|
||||
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ;
|
||||
void onItemExpandEvent( Vector2i _pos) { };
|
||||
};
|
||||
};
|
||||
};
|
||||
Vector2f calculateElementSize( Vector2i _pos) ;
|
||||
/**
|
||||
* Draw an element in the specific size and position.
|
||||
* @param _pos Position of colomn and Raw of the element.
|
||||
* @param _start Start display position.
|
||||
* @param _size Render raw size
|
||||
* @return The estimate size of the element.
|
||||
*/
|
||||
void drawElement( Vector2i _pos, Vector2f _start, Vector2f _size) ;
|
||||
protected:
|
||||
void onChangePropertyOffsetTreeView();
|
||||
void onChangePropertyTextDecorated();
|
||||
|
||||
boolean onItemEvent( ewol::event::Input _event, Vector2i _pos, Vector2f _mousePosition) ;
|
||||
void onItemExpandEvent( Vector2i _pos) { };
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ void ewol::widget::WSlider::onChangeSize() {
|
||||
|
||||
void ewol::widget::WSlider::subWidgetSelectSetVectorId(int _id) {
|
||||
if (_id<0) {
|
||||
Log.error("Can not change to a widget not present : vectID=" + _id);
|
||||
LOGGER.error("Can not change to a widget not present : vectID=" + _id);
|
||||
return;
|
||||
}
|
||||
if (_id != this.windowsDestination) {
|
||||
@ -143,7 +143,7 @@ void ewol::widget::WSlider::subWidgetSelectSet(int _id) {
|
||||
|
||||
void ewol::widget::WSlider::subWidgetSelectSet( Widget _widgetPointer) {
|
||||
if (_widgetPointer == null) {
|
||||
Log.error("Can not change to a widget null");
|
||||
LOGGER.error("Can not change to a widget null");
|
||||
return;
|
||||
}
|
||||
int iii = 0;
|
||||
@ -161,15 +161,15 @@ void ewol::widget::WSlider::subWidgetSelectSet( Widget _widgetPointer) {
|
||||
}
|
||||
iii++;
|
||||
}
|
||||
Log.error("Can not change to a widget not present");
|
||||
LOGGER.error("Can not change to a widget not present");
|
||||
}
|
||||
|
||||
void ewol::widget::WSlider::subWidgetSelectSet( String _widgetName) {
|
||||
if (_widgetName == "") {
|
||||
Log.error("Can not change to a widget with no name (input)");
|
||||
LOGGER.error("Can not change to a widget with no name (input)");
|
||||
return;
|
||||
}
|
||||
Log.verbose("Select a new sub-widget to dosplay : '" + _widgetName + "'");
|
||||
LOGGER.trace("Select a new sub-widget to dosplay : '" + _widgetName + "'");
|
||||
int iii = 0;
|
||||
for (auto it : this.subWidget) {
|
||||
if ( it != null
|
||||
@ -181,10 +181,10 @@ void ewol::widget::WSlider::subWidgetSelectSet( String _widgetName) {
|
||||
}
|
||||
iii++;
|
||||
}
|
||||
Log.error("Can not change to a widget not present");
|
||||
LOGGER.error("Can not change to a widget not present");
|
||||
}
|
||||
void ewol::widget::WSlider::periodicCall( ewol::event::Time _event) {
|
||||
Log.error("Periodic: " + this.slidingProgress + "/1.0 " + this.windowsSources + " ==> " + this.windowsDestination + " " + _event);
|
||||
LOGGER.error("Periodic: " + this.slidingProgress + "/1.0 " + this.windowsSources + " ==> " + this.windowsDestination + " " + _event);
|
||||
if (this.slidingProgress >= 1.0) {
|
||||
this.windowsSources = this.windowsDestination;
|
||||
if( this.windowsRequested != -1
|
||||
@ -230,16 +230,16 @@ void ewol::widget::WSlider::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
prop.limit(this.origin, this.size);
|
||||
|
||||
if (this.windowsDestination == this.windowsSources) {
|
||||
//Log.debug("Draw : " + this.windowsDestination);
|
||||
//LOGGER.debug("Draw : " + this.windowsDestination);
|
||||
auto it = this.subWidget.begin();
|
||||
it += this.windowsDestination;
|
||||
if ( it != this.subWidget.end()
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *it != null) {
|
||||
//Log.info("Draw : [" + propertyName + "] t=" + getObjectType() + "o=" + this.origin + " s=" + this.size);
|
||||
//LOGGER.info("Draw : [" + propertyName + "] t=" + getObjectType() + "o=" + this.origin + " s=" + this.size);
|
||||
(*it).systemDraw(prop);
|
||||
}
|
||||
} else {
|
||||
//Log.debug("Draw : " + this.windowsSources + "=>" + this.windowsDestination + "progress=" + ((float)this.slidingProgress/1000.) );
|
||||
//LOGGER.debug("Draw : " + this.windowsSources + "=>" + this.windowsDestination + "progress=" + ((float)this.slidingProgress/1000.) );
|
||||
// draw Sources :
|
||||
auto it = this.subWidget.begin();
|
||||
it += this.windowsSources;
|
||||
@ -283,7 +283,7 @@ void ewol::widget::WSlider::onRegenerateDisplay() {
|
||||
|
||||
void ewol::widget::WSlider::onChangePropertySelectWidget() {
|
||||
if (propertySelectWidget.get() != "") {
|
||||
Log.error("SELECT new widget: " + propertySelectWidget.get());
|
||||
LOGGER.error("SELECT new widget: " + propertySelectWidget.get());
|
||||
subWidgetSelectSet(*propertySelectWidget);
|
||||
}
|
||||
}
|
||||
|
@ -1,501 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/WidgetScrolled.hpp>
|
||||
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <gale/renderer/openGL/openGL.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::WidgetScrolled);
|
||||
|
||||
ewol::widget::WidgetScrolled::WidgetScrolled() :
|
||||
propertyShapeVert(this, "shape-vert",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the vertical display",
|
||||
ewol::widget::WidgetScrolled::onChangePropertyShapeVert),
|
||||
propertyShapeHori(this, "shape-hori",
|
||||
etk::Uri("THEME_GUI:///WidgetScrolled.json?lib=ewol"),
|
||||
"shape for the horizonal display",
|
||||
ewol::widget::WidgetScrolled::onChangePropertyShapeHori),
|
||||
this.shaperH(),
|
||||
this.shaperV(),
|
||||
this.singleFingerMode(true) {
|
||||
addObjectType("ewol::widget::WidgetScrolled");
|
||||
this.originScrooled.setValue(0,0);
|
||||
this.pixelScrolling = 20;
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.scroollingMode = scroolModeNormal;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
this.highSpeedButton = -1;
|
||||
this.limitScrolling = Vector2f(0.5f, 0.5f);
|
||||
|
||||
this.fingerScoolActivated = false;
|
||||
for (int iii = 0; iii < CALCULATE_SIMULTANEOUS_FINGER; ++iii) {
|
||||
this.fingerPresent[iii] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::init() {
|
||||
Widget::init();
|
||||
propertyShapeVert.notifyChange();
|
||||
propertyShapeHori.notifyChange();
|
||||
}
|
||||
|
||||
ewol::widget::WidgetScrolled::~WidgetScrolled() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::onRegenerateDisplay() {
|
||||
this.shaperH.clear();
|
||||
this.shaperV.clear();
|
||||
if (this.scroollingMode == scroolModeGame) {
|
||||
// nothing to do ...
|
||||
return;
|
||||
}
|
||||
ewol::Padding paddingVert = this.shaperV.getPadding();
|
||||
ewol::Padding paddingHori = this.shaperH.getPadding();
|
||||
if( this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y()!=0) {
|
||||
float lenScrollBar = this.size.y()*this.size.y() / this.maxSize.y();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, this.size.y());
|
||||
float originScrollBar = this.originScrooled.y() / (this.maxSize.y()-this.size.y()*this.limitScrolling.y());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.y()-lenScrollBar);
|
||||
this.shaperV.setShape(Vector2f(this.size.x() - paddingVert.x(), 0),
|
||||
Vector2f(paddingVert.x(), this.size.y()),
|
||||
Vector2f(this.size.x() - paddingVert.xRight(), this.size.y() - originScrollBar - lenScrollBar),
|
||||
Vector2f(0, lenScrollBar));
|
||||
}
|
||||
if( this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0) {
|
||||
float lenScrollBar = (this.size.x()-paddingHori.xLeft())*(this.size.x()-paddingVert.x()) / this.maxSize.x();
|
||||
lenScrollBar = etk::avg(10.0f, lenScrollBar, (this.size.x()-paddingVert.x()));
|
||||
float originScrollBar = this.originScrooled.x() / (this.maxSize.x()-this.size.x()*this.limitScrolling.x());
|
||||
originScrollBar = etk::avg(0.0f, originScrollBar, 1.0f);
|
||||
originScrollBar *= (this.size.x()-paddingHori.xRight()-lenScrollBar);
|
||||
this.shaperH.setShape(Vector2f(0, 0),
|
||||
Vector2f(this.size.x()-paddingVert.x(), paddingHori.y()),
|
||||
Vector2f(originScrollBar, paddingHori.yButtom()),
|
||||
Vector2f(lenScrollBar, 0));
|
||||
}
|
||||
}
|
||||
|
||||
boolean ewol::widget::WidgetScrolled::onEventInput( ewol::event::Input _event) {
|
||||
Log.verbose("event XXX " + _event);
|
||||
Vector2f relativePos = relativePosition(_event.getPos());
|
||||
// corection due to the open Gl invertion ...
|
||||
relativePos.setY(this.size.y() - relativePos.y());
|
||||
ewol::Padding paddingV = this.shaperV.getPadding();
|
||||
ewol::Padding paddingH = this.shaperH.getPadding();
|
||||
if (this.scroollingMode == scroolModeNormal) {
|
||||
if ( _event.getType() == KeyType::mouse
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow
|
||||
|| this.highSpeedType == KeyType::mouse) ) {
|
||||
if ( _event.getId() == 1
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down) {
|
||||
// check if selected the scrolling position whth the scrolling bar ...
|
||||
if (relativePos.x() >= (this.size.x()-paddingV.x())) {
|
||||
if( this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y() != 0) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(relativePos.x());
|
||||
this.highSpeedStartPos.setY(this.originScrooled.y() / this.maxSize.y() * (this.size.y()-paddingV.yButtom()*2));
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
this.originScrooled.setY((int)(this.maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (this.size.y()-paddingV.yButtom()*2)));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (relativePos.y() >= (this.size.y()-paddingH.y())) {
|
||||
if( this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setX(this.originScrooled.x() / this.maxSize.x() * (this.size.x()-paddingH.xLeft()*2));
|
||||
this.highSpeedStartPos.setY(relativePos.y());
|
||||
this.highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
this.originScrooled.setX((int)(this.maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (this.size.x()-paddingH.xLeft()*2)));
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if ( _event.getId() == 4
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
if (true == _event.getSpecialKey().getCtrl()) {
|
||||
changeZoom(1);
|
||||
/*
|
||||
float zoom = getZoom()*1.1;
|
||||
zoom = etk::avg(0.1f, zoom, 5000.0f);
|
||||
setZoom(zoom);
|
||||
*/
|
||||
} else {
|
||||
if(this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y() != 0
|
||||
|| this.size.y()*this.limitScrolling.y() < this.maxSize.y() ) {
|
||||
this.originScrooled.setY(this.originScrooled.y()-this.pixelScrolling);
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( _event.getId() == 5
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
if (true == _event.getSpecialKey().getCtrl()) {
|
||||
changeZoom(-1);
|
||||
/*
|
||||
float zoom = getZoom()*0.9;
|
||||
zoom = etk::avg(0.1f, zoom, 5000.0f);
|
||||
setZoom(zoom);
|
||||
*/
|
||||
} else {
|
||||
if(this.size.y() < this.maxSize.y()
|
||||
|| this.originScrooled.y()!=0
|
||||
|| this.size.y()*this.limitScrolling.y() < this.maxSize.y() ) {
|
||||
this.originScrooled.setY(this.originScrooled.y()+this.pixelScrolling);
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( _event.getId() == 11
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
// Scrool Left
|
||||
if(this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0
|
||||
|| this.size.x()*this.limitScrolling.x() < this.maxSize.x() ) {
|
||||
this.originScrooled.setX(this.originScrooled.x()-this.pixelScrolling);
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if ( _event.getId() == 10
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
// Scrool Right
|
||||
if(this.size.x() < this.maxSize.x()
|
||||
|| this.originScrooled.x()!=0
|
||||
|| this.size.x()*this.limitScrolling.x() < this.maxSize.x() ) {
|
||||
this.originScrooled.setX(this.originScrooled.x()+this.pixelScrolling);
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}else if (_event.getId() == 2) {
|
||||
/*
|
||||
if (true == ewol::isSetCtrl()) {
|
||||
if (KeyStatus::down == typeEvent) {
|
||||
float zoom = 1.0;
|
||||
setZoom(zoom);
|
||||
}
|
||||
} else */{
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeInit;
|
||||
this.highSpeedType = KeyType::mouse;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
this.highSpeedButton = 2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( this.highSpeedMode != ewol::widget::Scroll::speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if ( _event.getId() == this.highSpeedButton
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.highSpeedMode != ewol::widget::Scroll::speedModeDisable) {
|
||||
if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
return false;
|
||||
} else if (this.highSpeedMode == ewol::widget::Scroll::speedModeGrepEndEvent) {
|
||||
if (_event.getStatus() == KeyStatus::pressSingle) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
this.highSpeedButton = -1;
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if (_event.getStatus() == KeyStatus::up) {
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
if (relativePos.x() == this.highSpeedStartPos.x()) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||
} else if (relativePos.y() == this.highSpeedStartPos.y()) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||
} else {
|
||||
float coef = (relativePos.y() - this.highSpeedStartPos.y()) / (relativePos.x() - this.highSpeedStartPos.x());
|
||||
if (etk::abs(coef) <= 1 ) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
|
||||
} else {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
|
||||
}
|
||||
}
|
||||
if (this.highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal) {
|
||||
this.highSpeedStartPos.setX(this.originScrooled.x() / this.maxSize.x() * (this.size.x()-paddingV.x()));
|
||||
} else {
|
||||
this.highSpeedStartPos.setY(this.originScrooled.y() / this.maxSize.y() * (this.size.y()-paddingV.y()));
|
||||
}
|
||||
markToRedraw();
|
||||
}
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
return true;
|
||||
}
|
||||
if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
this.originScrooled.setX((int)(this.maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (this.size.x()-paddingH.x())));
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableVertical
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
this.originScrooled.setY((int)(this.maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (this.size.y()-paddingV.y())));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if ( _event.getType() == KeyType::finger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( this.highSpeedType == KeyType::unknow
|
||||
|| this.highSpeedType == KeyType::finger) ) {
|
||||
if (this.singleFingerMode == false) {
|
||||
// ***********************
|
||||
// ** Two finger mode : **
|
||||
// ***********************
|
||||
if (_event.getId() >= 3) {
|
||||
return false;
|
||||
}
|
||||
int idTable = _event.getId()-1;
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.fingerPresent[idTable] = true;
|
||||
} else if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
this.fingerPresent[idTable] = false;
|
||||
}
|
||||
if (this.fingerScoolActivated == false) {
|
||||
this.fingerMoveStartPos[idTable] = relativePos;
|
||||
}
|
||||
if ( this.fingerPresent[0] == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerPresent[1] == true
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerScoolActivated == false) {
|
||||
this.fingerScoolActivated = true;
|
||||
Log.verbose("SCROOL == > START pos=" + this.fingerMoveStartPos);
|
||||
}
|
||||
if (this.fingerScoolActivated == true) {
|
||||
// 1: scroll...
|
||||
// 2: remove all unneeded sub event ... ==> maybe a better methode ...
|
||||
if (_event.getStatus() == KeyStatus::move) {
|
||||
this.originScrooled.setX(this.originScrooled.x() - (relativePos.x() - this.fingerMoveStartPos[idTable].x())*0.5f);
|
||||
this.originScrooled.setY(this.originScrooled.y() - (relativePos.y() - this.fingerMoveStartPos[idTable].y())*0.5f);
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
this.fingerMoveStartPos[idTable] = relativePos;
|
||||
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
|
||||
markToRedraw();
|
||||
}
|
||||
if ( this.fingerPresent[0] == false
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.fingerPresent[1] == false) {
|
||||
if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
// TODO : Reset event ...
|
||||
this.fingerScoolActivated = false;
|
||||
_event.reset();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// **************************
|
||||
// ** Single finger mode : **
|
||||
// **************************
|
||||
if (_event.getId() == 1) {
|
||||
Log.verbose("event 1 " + _event);
|
||||
if (_event.getStatus() == KeyStatus::down) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeInit;
|
||||
this.highSpeedType = KeyType::finger;
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > INIT");
|
||||
return true;
|
||||
} else if (_event.getStatus() == KeyStatus::upAfter) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeInit
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
// wait that the cursor move more than 10 px to enable it :
|
||||
if( etk::abs(relativePos.x() - this.highSpeedStartPos.x()) > 10
|
||||
|| etk::abs(relativePos.y() - this.highSpeedStartPos.y()) > 10 ) {
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger;
|
||||
Log.debug("SCROOL == > ENABLE");
|
||||
markToRedraw();
|
||||
}
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressSingle) {
|
||||
// Keep all event in the range of moving
|
||||
return true;
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::pressDouble) {
|
||||
// Keep all event in the range of moving
|
||||
return true;
|
||||
} if ( this.highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::move) {
|
||||
//this.originScrooled.x = (int)(this.maxSize.x * x / this.size.x);
|
||||
this.originScrooled.setX(this.originScrooled.x() - (relativePos.x() - this.highSpeedStartPos.x()));
|
||||
this.originScrooled.setY(this.originScrooled.y() - (relativePos.y() - this.highSpeedStartPos.y()));
|
||||
this.originScrooled.setX(etk::avg(0.0f, this.originScrooled.x(), (this.maxSize.x() - this.size.x()*this.limitScrolling.x())));
|
||||
this.originScrooled.setY(etk::avg(0.0f, this.originScrooled.y(), (this.maxSize.y() - this.size.y()*this.limitScrolling.y())));
|
||||
this.highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
Log.verbose("SCROOL == > MOVE this.originScrooled=" + this.originScrooled + " " + relativePos + " " + this.highSpeedStartPos);
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if ( this.highSpeedMode == ewol::widget::Scroll::speedModeDisable
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::leave) {
|
||||
this.highSpeedMode = ewol::widget::Scroll::speedModeDisable;
|
||||
this.highSpeedType = KeyType::unknow;
|
||||
Log.verbose("SCROOL == > DISABLE");
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == scroolModeCenter) {
|
||||
if (_event.getType() == KeyType::mouse) {
|
||||
float tmp1=this.size.x() / this.maxSize.y();
|
||||
float tmp2=this.size.y() / this.maxSize.x();
|
||||
//Log.info(" elements Zoom : " + tmp1 + " " + tmp2);
|
||||
tmp1 = etk::min(tmp1, tmp2);
|
||||
if ( _event.getId() == 4
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
this.zoom -= 0.1;
|
||||
if (tmp1 < 1.0) {
|
||||
this.zoom = etk::max(tmp1, this.zoom);
|
||||
} else {
|
||||
this.zoom = etk::max(1.0f, this.zoom);
|
||||
}
|
||||
markToRedraw();
|
||||
return true;
|
||||
} else if ( _event.getId() == 5
|
||||
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::up) {
|
||||
this.zoom += 0.1;
|
||||
if (tmp1 > 1.0) {
|
||||
this.zoom = etk::min(tmp1, this.zoom);
|
||||
} else {
|
||||
this.zoom = etk::min(1.0f, this.zoom);
|
||||
}
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (this.scroollingMode == scroolModeGame) {
|
||||
|
||||
} else {
|
||||
Log.error("Scrolling mode unknow ... " + this.scroollingMode );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::WidgetScrolled::onDraw() {
|
||||
this.shaperH.draw();
|
||||
this.shaperV.draw();
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::systemDraw( ewol::DrawProperty _displayProp) {
|
||||
gale::openGL::push();
|
||||
if (this.scroollingMode == scroolModeCenter) {
|
||||
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
|
||||
gale::openGL::setViewPort(this.origin, this.size);
|
||||
Matrix4f tmpProjection = etk::matOrtho(-this.size.x()/2, this.size.x()/2, -this.size.y()/2, this.size.y()/2, -1, 1);
|
||||
Matrix4f tmpScale = etk::matScale(Vector3f(this.zoom, this.zoom, 1.0) );
|
||||
Matrix4f tmpTranslate = etk::matTranslate(Vector3f(-this.maxSize.x()/2, -this.maxSize.y()/2, -1.0) );
|
||||
Matrix4f tmpMat = tmpProjection * tmpScale * tmpTranslate;
|
||||
// set internal matrix system :
|
||||
gale::openGL::setMatrix(tmpMat);
|
||||
// Call the widget drawing methode
|
||||
onDraw();
|
||||
} if (this.scroollingMode == scroolModeGame) {
|
||||
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
|
||||
gale::openGL::setViewPort(this.origin, this.size);
|
||||
Matrix4f tmpProjection = etk::matOrtho(-this.size.x()/2, this.size.x()/2, -this.size.y()/2, this.size.y()/2, -1, 1);
|
||||
Matrix4f tmpTranslate = etk::matTranslate(Vector3f( -this.maxSize.x()/2, -this.maxSize.y()/2, -1.0) );
|
||||
Matrix4f tmpMat = tmpProjection * tmpTranslate;
|
||||
// set internal matrix system :
|
||||
gale::openGL::setMatrix(tmpMat);
|
||||
// Call the widget drawing methode
|
||||
onDraw();
|
||||
} else {
|
||||
Widget::systemDraw(_displayProp);
|
||||
}
|
||||
gale::openGL::pop();
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center) {
|
||||
if (true == _center) {
|
||||
_borderWidth.setValue(this.size.x() / 2 - _borderWidth.x(),
|
||||
this.size.y() / 2 - _borderWidth.y() );
|
||||
}
|
||||
// check scrooling in X
|
||||
if (_currentPosition.x() < (this.originScrooled.x() + _borderWidth.x()) ) {
|
||||
this.originScrooled.setX(_currentPosition.x() - _borderWidth.x());
|
||||
this.originScrooled.setX(etk::max(0.0f, this.originScrooled.x()));
|
||||
} else if (_currentPosition.x() > (this.originScrooled.x()+this.size.x()-2*_borderWidth.x()) ) {
|
||||
this.originScrooled.setX(_currentPosition.x() - this.size.x() + 2*_borderWidth.x());
|
||||
this.originScrooled.setX(etk::max(0.0f, this.originScrooled.x()));
|
||||
}
|
||||
// check scrooling in Y
|
||||
if (_currentPosition.y() < (this.originScrooled.y() + _borderWidth.y()) ) {
|
||||
this.originScrooled.setY(_currentPosition.y() - _borderWidth.y());
|
||||
this.originScrooled.setY(etk::max(0.0f, this.originScrooled.y()));
|
||||
} else if (_currentPosition.y() > (this.originScrooled.y()+this.size.y()-2*_borderWidth.y()) ) {
|
||||
this.originScrooled.setY(_currentPosition.y() - this.size.y() + 2*_borderWidth.y());
|
||||
this.originScrooled.setY(etk::max(0.0f, this.originScrooled.y()));
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::scroolingMode(enum scrollingMode _newMode) {
|
||||
this.scroollingMode = _newMode;
|
||||
if (this.scroollingMode == scroolModeGame) {
|
||||
// set the scene maximum size :
|
||||
this.maxSize.setValue(etk::max(this.size.x(), this.size.y()),
|
||||
this.maxSize.x());
|
||||
this.zoom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::setSingleFinger(boolean _status) {
|
||||
if (this.singleFingerMode == _status) {
|
||||
return;
|
||||
}
|
||||
this.singleFingerMode = _status;
|
||||
}
|
||||
|
||||
void ewol::widget::WidgetScrolled::onChangePropertyShapeVert() {
|
||||
this.shaperV.setSource(propertyShapeVert);
|
||||
markToRedraw();
|
||||
}
|
||||
void ewol::widget::WidgetScrolled::onChangePropertyShapeHori() {
|
||||
this.shaperH.setSource(propertyShapeHori);
|
||||
markToRedraw();
|
||||
}
|
||||
|
@ -1,142 +1,107 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
|
||||
/**
|
||||
* Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/widget/Scroll.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
|
||||
#define CALCULATE_SIMULTANEOUS_FINGER (5)
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class WidgetScrolled;
|
||||
using WidgetScrolled = ememory::Ptr<ewol::widget::WidgetScrolled>;
|
||||
using WidgetScrolledWeak = ememory::WeakPtr<ewol::widget::WidgetScrolled>;
|
||||
class WidgetScrolled extends Widget {
|
||||
public static final int CALCULATE_SIMULTANEOUS_FINGER = 5;
|
||||
protected etk::Uri propertyShapeVert; //!< Vertical shaper name
|
||||
protected etk::Uri propertyShapeHori; //!< Horizontal shaper name
|
||||
public enum scrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
};
|
||||
private ewol::compositing::Shaper shaperH; //!< Compositing theme Horizontal.
|
||||
private ewol::compositing::Shaper shaperV; //!< Compositing theme Vertical.
|
||||
protected Vector2f originScrooled = Vector2f.ZERO; //!< pixel distance from the origin of the display (Bottum left)
|
||||
protected Vector2f maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
protected Vector2f limitScrolling = Vector2f.ZERO; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
// Mouse section :
|
||||
private enum scrollingMode scroollingMode = scrollingMode.scroolModeNormal; //!< mode of management of the scrooling
|
||||
private float pixelScrolling = 20;
|
||||
private Vector2f highSpeedStartPos;
|
||||
private enum Scroll::highSpeedMode highSpeedMode = Scroll::speedModeDisable;
|
||||
private int highSpeedButton = -1;
|
||||
private KeyType highSpeedType = KeyType.unknow;
|
||||
// finger section:
|
||||
private boolean singleFingerMode = true; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select...
|
||||
public
|
||||
/**
|
||||
* Widget to integrate a scrool bar in a widget. This is not a stadalone widget.
|
||||
* Set the single finger capabilities/
|
||||
* @param _status True if single inger mode, two otherwise/
|
||||
*/
|
||||
class WidgetScrolled : public Widget {
|
||||
public: // properties:
|
||||
eproperty::Value<etk::Uri> propertyShapeVert; //!< Vertical shaper name
|
||||
eproperty::Value<etk::Uri> propertyShapeHori; //!< Horizontal shaper name
|
||||
// TODO : All property
|
||||
public:
|
||||
enum scrollingMode {
|
||||
scroolModeNormal, //!< No Zoom , can UP and down, left and right
|
||||
scroolModeCenter, //!< Zoom enable, no move left and right
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
};
|
||||
private:
|
||||
ewol::compositing::Shaper this.shaperH; //!< Compositing theme Horizontal.
|
||||
ewol::compositing::Shaper this.shaperV; //!< Compositing theme Vertical.
|
||||
protected:
|
||||
Vector2f this.originScrooled; //!< pixel distance from the origin of the display (Bottum left)
|
||||
Vector2f this.maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
Vector2f this.limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
private: // Mouse section :
|
||||
enum scrollingMode this.scroollingMode; //!< mode of management of the scrooling
|
||||
float this.pixelScrolling;
|
||||
Vector2f this.highSpeedStartPos;
|
||||
enum Scroll::highSpeedMode this.highSpeedMode;
|
||||
int this.highSpeedButton;
|
||||
KeyType this.highSpeedType;
|
||||
private: // finger section:
|
||||
boolean this.singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select...
|
||||
public:
|
||||
/**
|
||||
* Set the single finger capabilities/
|
||||
* @param _status True if single inger mode, two otherwise/
|
||||
*/
|
||||
void setSingleFinger(boolean _status);
|
||||
/**
|
||||
* Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
* @return false The To finger mode is active
|
||||
*/
|
||||
boolean getSingleFinger() {
|
||||
return this.singleFingerMode;
|
||||
}
|
||||
/**
|
||||
* Reset the scoll of the subWidget
|
||||
*/
|
||||
void resetScrollOrigin() {
|
||||
this.originScrooled = Vector2f(0,0);
|
||||
}
|
||||
private:
|
||||
boolean this.fingerPresent[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
boolean this.fingerScoolActivated;
|
||||
Vector2f this.fingerMoveStartPos[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
protected:
|
||||
/**
|
||||
* Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
* @param _shaperName Shaper name if the scrolled widget.
|
||||
*/
|
||||
WidgetScrolled();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(WidgetScrolled, "WidgetScrolled");
|
||||
/**
|
||||
* Scroll widget destructor.
|
||||
*/
|
||||
~WidgetScrolled();
|
||||
protected:
|
||||
void onDraw() ;
|
||||
public:
|
||||
void onRegenerateDisplay() ;
|
||||
boolean onEventInput( ewol::event::Input _event) ;
|
||||
void systemDraw( ewol::DrawProperty _displayProp) ;
|
||||
protected:
|
||||
/**
|
||||
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param _nbPixel number of pixel scrolling
|
||||
*/
|
||||
void setScrollingSize(float _nbPixel) {
|
||||
this.pixelScrolling = _nbPixel;
|
||||
};
|
||||
/**
|
||||
* Specify the mode of scrolling for this windows
|
||||
* @param _newMode the selected mode for the scrolling...
|
||||
*/
|
||||
void scroolingMode(enum scrollingMode _newMode);
|
||||
/**
|
||||
* set the specific mawimum size of the widget
|
||||
* @param _localSize new Maximum size
|
||||
*/
|
||||
void setMaxSize( Vector2f _localSize) {
|
||||
this.maxSize = _localSize;
|
||||
};
|
||||
/**
|
||||
* Request a specific position for the scrolling of the current windows.
|
||||
* @param _borderWidth size of the border that requested the element might not to be
|
||||
* @param _currentPosition Position that is requested to view
|
||||
* @param _center True if the position might be at the center of the widget
|
||||
*/
|
||||
void setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center = false);
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
void setLimitScrolling(float _poucentageLimit) {
|
||||
_poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f);
|
||||
this.limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit);
|
||||
};
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
*/
|
||||
void setLimitScrolling( Vector2f _poucentageLimit) {
|
||||
this.limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f));
|
||||
};
|
||||
protected:
|
||||
void onChangePropertyShapeVert();
|
||||
void onChangePropertyShapeHori();
|
||||
};
|
||||
void setSingleFinger(boolean _status);
|
||||
/**
|
||||
* Get the single finger capabilities
|
||||
* @return true The single finger mode is active
|
||||
* @return false The To finger mode is active
|
||||
*/
|
||||
boolean getSingleFinger() {
|
||||
return this.singleFingerMode;
|
||||
}
|
||||
/**
|
||||
* Reset the scoll of the subWidget
|
||||
*/
|
||||
void resetScrollOrigin() {
|
||||
this.originScrooled = Vector2f(0,0);
|
||||
}
|
||||
private boolean fingerPresent[] = {false, false, false, false, false};
|
||||
private boolean fingerScoolActivated = false;
|
||||
private Vector2f fingerMoveStartPos[] = new Vector2f[CALCULATE_SIMULTANEOUS_FINGER];
|
||||
/**
|
||||
* Scroll Widget main ructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
* @param _shaperName Shaper name if the scrolled widget.
|
||||
*/
|
||||
public WidgetScrolled() {
|
||||
onChangePropertyShapeVert();
|
||||
onChangePropertyShapeHori();
|
||||
}
|
||||
protected void onDraw() ;
|
||||
public void onRegenerateDisplay() ;
|
||||
public boolean onEventInput( ewol::event::Input _event) ;
|
||||
public void systemDraw( ewol::DrawProperty _displayProp) ;
|
||||
/**
|
||||
* For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled
|
||||
* @param _nbPixel number of pixel scrolling
|
||||
*/
|
||||
protected void setScrollingSize(float _nbPixel) {
|
||||
this.pixelScrolling = _nbPixel;
|
||||
};
|
||||
/**
|
||||
* Specify the mode of scrolling for this windows
|
||||
* @param _newMode the selected mode for the scrolling...
|
||||
*/
|
||||
protected void scroolingMode(enum scrollingMode _newMode);
|
||||
/**
|
||||
* set the specific mawimum size of the widget
|
||||
* @param _localSize new Maximum size
|
||||
*/
|
||||
protected void setMaxSize( Vector2f _localSize) {
|
||||
this.maxSize = _localSize;
|
||||
};
|
||||
/**
|
||||
* Request a specific position for the scrolling of the current windows.
|
||||
* @param _borderWidth size of the border that requested the element might not to be
|
||||
* @param _currentPosition Position that is requested to view
|
||||
* @param _center True if the position might be at the center of the widget
|
||||
*/
|
||||
protected void setScrollingPositionDynamic(Vector2f _borderWidth, Vector2f _currentPosition, boolean _center = false);
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
protected void setLimitScrolling(float _poucentageLimit) {
|
||||
_poucentageLimit = etk::avg(0.1f, _poucentageLimit,1.0f);
|
||||
this.limitScrolling = Vector2f(_poucentageLimit, _poucentageLimit);
|
||||
};
|
||||
/**
|
||||
* set the scrolling limit when arriving at he end of the widget
|
||||
* @param _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end for axis specific...
|
||||
*/
|
||||
protected void setLimitScrolling( Vector2f _poucentageLimit) {
|
||||
this.limitScrolling = Vector2f(etk::avg(0.1f, _poucentageLimit.x(),1.0f), etk::avg(0.1f, _poucentageLimit.y(),1.0f));
|
||||
};
|
||||
protected void onChangePropertyShapeVert();
|
||||
protected void onChangePropertyShapeHori();
|
||||
}
|
||||
|
||||
|
@ -1,153 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/widget/meta/ColorChooser.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/widget/Spacer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
//#include <etk/Vector.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::ColorChooser);
|
||||
|
||||
extern "C" {
|
||||
// file browsing ...
|
||||
#include <dirent.h>
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@ -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<Color> signalChange;
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/PopUp.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/ColorBar.hpp>
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class ColorChooser;
|
||||
using ColorChooser = ememory::Ptr<ewol::widget::ColorChooser>;
|
||||
using ColorChooserWeak = ememory::WeakPtr<ewol::widget::ColorChooser>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class ColorChooser : public ewol::widget::Sizer {
|
||||
public: // signals
|
||||
esignal::Signal<etk::Color<>> signalChange;
|
||||
public:
|
||||
eproperty::Value<etk::Color<>> 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;
|
||||
@AKManaged
|
||||
@XmlAttribute
|
||||
@AKName(value = "value")
|
||||
@AknotDescription(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);
|
||||
}
|
||||
}
|
@ -1,197 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <ewol/widget/meta/FileChooser.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/CheckBox.hpp>
|
||||
#include <ewol/widget/ListFileSystem.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Spacer.hpp>
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
//#include <etk/Vector.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
|
||||
extern "C" {
|
||||
// file browsing ...
|
||||
#include <dirent.h>
|
||||
}
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::FileChooser);
|
||||
|
||||
ewol::widget::FileChooser::FileChooser() :
|
||||
signalCancel(this, "cancel", ""),
|
||||
signalValidate(this, "validate", ""),
|
||||
propertyPath(this, "path",
|
||||
etk::path::getHomePath(),
|
||||
"",
|
||||
ewol::widget::FileChooser::onChangePropertyPath),
|
||||
propertyFile(this, "file",
|
||||
"",
|
||||
"",
|
||||
ewol::widget::FileChooser::onChangePropertyFile),
|
||||
propertyLabelTitle(this, "title",
|
||||
"_T{FileChooser}",
|
||||
"",
|
||||
ewol::widget::FileChooser::onChangePropertyLabelTitle),
|
||||
propertyLabelValidate(this, "label-validate",
|
||||
"_T{Validate}",
|
||||
"",
|
||||
ewol::widget::FileChooser::onChangePropertyLabelValidate),
|
||||
propertyLabelCancel(this, "label-cancel",
|
||||
"_T{Cancel}",
|
||||
"",
|
||||
ewol::widget::FileChooser::onChangePropertyLabelCancel) {
|
||||
addObjectType("ewol::widget::FileChooser");
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::init() {
|
||||
ewol::widget::Composer::init();
|
||||
// Load file with replacing the "{ID}" with the local ID of the widget ==> obtain unique ID
|
||||
loadFromFile("DATA:///ewol-gui-file-chooser.xml?lib=ewol", getId());
|
||||
// Basic replacement of labels
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:title-label", "value", propertyLabelTitle);
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:validate-label", "value", propertyLabelValidate);
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel);
|
||||
|
||||
subBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:show-hiden-file", signalValue, sharedFromThis(), ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue);
|
||||
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-validate", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackListValidate);
|
||||
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-cancel", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackButtonCancelPressed);
|
||||
subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-folder", signalFolderValidate, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFolderSelectChange);
|
||||
subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileSelect, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFileSelectChange);
|
||||
subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileValidate, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFileValidate);
|
||||
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalModify, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFileChangeValue);
|
||||
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalEnter, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFileChangeValidate);
|
||||
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalModify, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFolderChangeValue);
|
||||
//composerBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalEnter, sharedFromThis(), ewol::widget::FileChooser::);
|
||||
subBind(ewol::widget::Image, "[" + etk::toString(getId()) + "]file-shooser:img-home", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackHomePressed);
|
||||
// set the default Folder properties:
|
||||
updateCurrentFolder();
|
||||
propertyCanFocus.set(true);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onGetFocus() {
|
||||
// transfert focus on a specific widget...
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-file", "focus", "true");
|
||||
}
|
||||
|
||||
ewol::widget::FileChooser::~FileChooser() {
|
||||
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onChangePropertyPath() {
|
||||
propertyPath.getDirect() = *propertyPath + "/";
|
||||
updateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onChangePropertyFile() {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-file", "value", propertyFile.getFileName());
|
||||
//updateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onChangePropertyLabelTitle() {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:title-label", "value", propertyLabelTitle);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onChangePropertyLabelValidate() {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:validate-label", "value", propertyLabelValidate);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onChangePropertyLabelCancel() {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue( String _value) {
|
||||
// == > change the folder name
|
||||
// TODO : change the folder, if it exit ...
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackEntryFileChangeValue( String _value) {
|
||||
// == > change the file name.get(.get(
|
||||
propertyFile.setDirect(_value);
|
||||
// update the selected file in the list :
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "select", propertyFile.getString());
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackButtonCancelPressed() {
|
||||
// == > Auto remove ...
|
||||
signalCancel.emit();
|
||||
autoDestroy();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue( bool _value) {
|
||||
if (_value == true) {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "show-hidden", "true");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "show-hidden", "true");
|
||||
} else {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "show-hidden", "false");
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "show-hidden", "false");
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListFolderSelectChange( etk::Path _value) {
|
||||
// == > this is an internal event ...
|
||||
Log.debug(" old PATH: '" + *propertyPath + "' ==> '" + _value + "'");
|
||||
propertyPath.setDirect(_value);
|
||||
Log.debug("new PATH: '" + *propertyPath + "'");
|
||||
propertyFile.setDirect("");
|
||||
updateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListFileSelectChange( etk::Path _value) {
|
||||
propertyFile.set(_value);
|
||||
/*
|
||||
String tmpFileCompleatName = this.folder;
|
||||
tmpFileCompleatName += this.file;
|
||||
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
|
||||
*/
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListFileValidate( etk::Path _value) {
|
||||
// select the file == > generate a validate
|
||||
propertyFile.set(_value);
|
||||
Log.verbose(" generate a fiel opening : '" + propertyFile + "'");
|
||||
signalValidate.emit(_value);
|
||||
autoDestroy();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackEntryFileChangeValidate( String _value) {
|
||||
onCallbackListFileValidate(_value);
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackListValidate() {
|
||||
if (propertyFile.get() == "") {
|
||||
Log.warning(" Validate : '" + *propertyFile + "' ==> error No name ...");
|
||||
return;
|
||||
}
|
||||
Log.debug(" generate a file opening : '" + *propertyFile + "'");
|
||||
signalValidate.emit(*propertyFile);
|
||||
autoDestroy();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::onCallbackHomePressed() {
|
||||
etk::Path tmpUserFolder = etk::path::getHomePath();
|
||||
Log.debug("new PATH: '" + tmpUserFolder + "'");
|
||||
|
||||
propertyPath.setDirect(tmpUserFolder);
|
||||
propertyFile.setDirect("");
|
||||
updateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::widget::FileChooser::updateCurrentFolder() {
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "path", propertyPath.getString());
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "path", propertyPath.getString());
|
||||
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-folder", "value", propertyPath.getString());
|
||||
markToRedraw();
|
||||
}
|
@ -1,106 +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/Composer.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class FileChooser;
|
||||
using FileChooser = ememory::Ptr<ewol::widget::FileChooser>;
|
||||
using FileChooserWeak = ememory::WeakPtr<ewol::widget::FileChooser>;
|
||||
/**
|
||||
* File Chooser is a simple selector of file for opening, saving, and what you want ...
|
||||
*
|
||||
* As all other pop-up methode ( wost case we can have) the creating is simple , but event back is not all the time simple:
|
||||
*
|
||||
* Fist global static declaration and inclusion:
|
||||
* [code style=c++]
|
||||
* #include <ewol/widget/meta/FileChooser.hpp>
|
||||
* [/code]
|
||||
*
|
||||
* The first step is to create the file chooser pop-up : (never in the ructor!!!)
|
||||
* [code style=c++]
|
||||
* ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create();
|
||||
* if (tmpWidget == null) {
|
||||
* APPL_ERROR("Can not open File chooser !!! ");
|
||||
* return -1;
|
||||
* }
|
||||
* // register on the Validate event:
|
||||
* tmpWidget.signalValidate.connect(sharedFromThis(), ****::onCallbackOpenFile);
|
||||
* // no need of this event watching ...
|
||||
* tmpWidget.signalCancel.connect(sharedFromThis(), ****::onCallbackClosePopUp);
|
||||
* // set the title:
|
||||
* tmpWidget.propertyLabelTitle.set("Open files ...");
|
||||
* // Set the validate Label:
|
||||
* tmpWidget.propertyLabelValidate.set("Open");
|
||||
* // simply set a folder (by default this is the home folder)
|
||||
* //tmpWidget.propertyPath.set("/home/me");
|
||||
* // add the widget as windows pop-up ...
|
||||
* ewol::widget::Windows tmpWindows = getWindows();
|
||||
* if (tmpWindows == null) {
|
||||
* APPL_ERROR("Can not get the current windows !!! ");
|
||||
* return -1;
|
||||
* }
|
||||
* tmpWindows.popUpWidgetPush(tmpWidget);
|
||||
* [/code]
|
||||
*
|
||||
* Now we just need to wait the the open event message.
|
||||
*
|
||||
* [code style=c++]
|
||||
* void ****::onCallbackOpenFile( String _value) {
|
||||
* APPL_INFO("Request open file : '" + _value + "'");
|
||||
* }
|
||||
* void ****::onCallbackClosePopUp() {
|
||||
* APPL_INFO("The File chooser has been closed");
|
||||
* }
|
||||
* [/code]
|
||||
* This is the best example of a Meta-widget.
|
||||
*/
|
||||
class FileChooser : public ewol::widget::Composer {
|
||||
public: // signals
|
||||
esignal::Signal<> signalCancel; //!< abort the display of the pop-up or press cancel button
|
||||
esignal::Signal<etk::Path> signalValidate; //!< select file(s)
|
||||
public: // properties
|
||||
eproperty::Value<etk::Path> propertyPath; //!< Current path to explore
|
||||
eproperty::Value<etk::Path> propertyFile; //!< Selected file
|
||||
eproperty::Value<String> propertyLabelTitle; //!< Label of the pop-up (can use translation)
|
||||
eproperty::Value<String> propertyLabelValidate; //!< Label of validate button of the pop-up (can use translation)
|
||||
eproperty::Value<String> propertyLabelCancel; //!< Label of cancel/close button of the pop-up (can use translation)
|
||||
protected:
|
||||
FileChooser();
|
||||
void init() ;
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(FileChooser, "FileChooser");
|
||||
~FileChooser();
|
||||
private:
|
||||
void updateCurrentFolder();
|
||||
public:
|
||||
void onGetFocus() ;
|
||||
private:
|
||||
// callback functions:
|
||||
void onCallbackEntryFolderChangeValue( String _value);
|
||||
void onCallbackEntryFileChangeValue( String _value);
|
||||
void onCallbackEntryFileChangeValidate( String _value);
|
||||
void onCallbackButtonCancelPressed();
|
||||
void onCallbackHidenFileChangeChangeValue( bool _value);
|
||||
void onCallbackListFolderSelectChange( etk::Path _value);
|
||||
void onCallbackListFileSelectChange( etk::Path _value);
|
||||
void onCallbackListFileValidate( etk::Path _value);
|
||||
void onCallbackListValidate();
|
||||
void onCallbackHomePressed();
|
||||
protected:
|
||||
void onChangePropertyPath();
|
||||
void onChangePropertyFile();
|
||||
void onChangePropertyLabelTitle();
|
||||
void onChangePropertyLabelValidate();
|
||||
void onChangePropertyLabelCancel();
|
||||
};
|
||||
};
|
||||
};
|
@ -44,9 +44,9 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
mySizerVert = ewol::widget::Sizer::create();
|
||||
if (mySizerVert == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
Log.info("add widget");
|
||||
LOGGER.info("add widget");
|
||||
mySizerVert.propertyMode.set(widget::Sizer::modeVert);
|
||||
mySizerVert.propertyLockExpand.set(Vector2b(true,true));
|
||||
mySizerVert.propertyExpand.set(Vector2b(true,true));
|
||||
@ -55,14 +55,14 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
mySizerHori = ewol::widget::Sizer::create();
|
||||
if (mySizerHori == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySizerHori.propertyMode.set(widget::Sizer::modeHori);
|
||||
mySizerVert.subWidgetAdd(mySizerHori);
|
||||
|
||||
mySpacer = ewol::widget::Spacer::create();
|
||||
if (mySpacer == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySpacer.propertyExpand.set(Vector2b(true,false));
|
||||
mySizerHori.subWidgetAdd(mySpacer);
|
||||
@ -70,7 +70,7 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
ewol::widget::Button tmpButton = widget::Button::create();
|
||||
if (tmpButton == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
tmpButton.setSubWidget(ewol::widget::composerGenerateString(
|
||||
"<sizer mode='hori'>\n"
|
||||
@ -83,7 +83,7 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
mySpacer = ewol::widget::Spacer::create();
|
||||
if (mySpacer == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySpacer.propertyExpand.set(Vector2b(false,false));
|
||||
mySpacer.propertyMinSize.set(gale::Dimension(Vector2f(10,0)));
|
||||
@ -92,7 +92,7 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
tmpButton = ewol::widget::Button::create();
|
||||
if (tmpButton == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
tmpButton.setSubWidget(ewol::widget::composerGenerateString(
|
||||
"<sizer mode='hori'>\n"
|
||||
@ -106,14 +106,14 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
mySizerHori = ewol::widget::Sizer::create();
|
||||
if (mySizerHori == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySizerHori.propertyMode.set(widget::Sizer::modeHori);
|
||||
mySizerVert.subWidgetAdd(mySizerHori);
|
||||
|
||||
this.paramList = ewol::widget::ParameterList::create();
|
||||
if (this.paramList == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
|
||||
this.paramList.signalSelect.connect(sharedFromThis(), ewol::widget::Parameter::onCallbackMenuSelected);
|
||||
@ -123,7 +123,7 @@ void ewol::widget::Parameter::init() {
|
||||
}
|
||||
mySpacer = ewol::widget::Spacer::create();
|
||||
if (mySpacer == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySpacer.propertyFill.set(Vector2b(false,true));
|
||||
mySpacer.propertyMinSize.set(Vector2f(5,5));
|
||||
@ -133,14 +133,14 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
ewol::widget::Sizer mySizerVert2 = widget::Sizer::create();
|
||||
if (mySizerVert2 == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySizerVert2.propertyMode.set(widget::Sizer::modeVert);
|
||||
mySizerHori.subWidgetAdd(mySizerVert2);
|
||||
|
||||
mySpacer = ewol::widget::Spacer::create();
|
||||
if (mySpacer == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySpacer.propertyExpand.set(Vector2b(true,false));
|
||||
mySpacer.propertyMinSize.set(Vector2f(5,5));
|
||||
@ -150,7 +150,7 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
this.wSlider = ewol::widget::WSlider::create();
|
||||
if (this.wSlider == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
this.wSlider.propertyTransitionSpeed.set(0.5);
|
||||
this.wSlider.propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert);
|
||||
@ -162,7 +162,7 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
mySpacer = ewol::widget::Spacer::create();
|
||||
if (mySpacer == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
mySpacer.propertyExpand.set(Vector2b(true,false));
|
||||
mySpacer.propertyMinSize.set(Vector2f(5,5));
|
||||
@ -172,7 +172,7 @@ void ewol::widget::Parameter::init() {
|
||||
|
||||
this.widgetTitle = ewol::widget::Label::create();
|
||||
if (this.widgetTitle == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
this.widgetTitle.propertyValue.set(propertyLabelTitle);
|
||||
this.widgetTitle.propertyExpand.set(Vector2b(true,false));
|
||||
@ -200,11 +200,11 @@ void ewol::widget::Parameter::onCallbackMenuclosed() {
|
||||
}
|
||||
void ewol::widget::Parameter::onCallbackParameterSave() {
|
||||
//ewol::userConfig::Save();
|
||||
Log.todo("Save Parameter !!! ");
|
||||
LOGGER.info("[TODO] Save Parameter !!! ");
|
||||
}
|
||||
void ewol::widget::Parameter::onCallbackMenuSelected( int _value) {
|
||||
if (this.wSlider != null) {
|
||||
Log.debug("event on the parameter : Menu-select select ID=" + _value + "");
|
||||
LOGGER.debug("event on the parameter : Menu-select select ID=" + _value + "");
|
||||
this.wSlider.subWidgetSelectSet(_value);
|
||||
}
|
||||
}
|
||||
@ -216,10 +216,10 @@ void ewol::widget::Parameter::menuAdd(String _label, String _image, Widget _asso
|
||||
if (_associateWidget != null) {
|
||||
this.wSlider.subWidgetAdd(_associateWidget);
|
||||
} else {
|
||||
Log.debug("Associate an empty widget on it ...");
|
||||
LOGGER.debug("Associate an empty widget on it ...");
|
||||
ewol::widget::Label myLabel = widget::Label::create();
|
||||
if (myLabel == null) {
|
||||
Log.error("Can not allocate widget == > display might be in error");
|
||||
LOGGER.error("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
myLabel.propertyValue.set(String("No widget for : ") + _label);
|
||||
myLabel.propertyExpand.set(Vector2b(true,true));
|
||||
|
@ -52,7 +52,7 @@ void ewol::widget::ParameterList::calculateMinMaxSize() {
|
||||
|
||||
void ewol::widget::ParameterList::addOObject( ememory::Ptr<ewol::Compositing> _newObject, int _pos) {
|
||||
if (_newObject == null) {
|
||||
Log.error("Try to add an empty object in the Widget generic display system");
|
||||
LOGGER.error("Try to add an empty object in the Widget generic display system");
|
||||
return;
|
||||
}
|
||||
if (_pos < 0 || (int)_pos >= this.listOObject.size() ) {
|
||||
@ -79,7 +79,7 @@ void ewol::widget::ParameterList::onRegenerateDisplay() {
|
||||
if (needRedraw() == true) {
|
||||
// clean the object list ...
|
||||
clearOObjectList();
|
||||
//Log.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")");
|
||||
//LOGGER.debug("OnRegenerateDisplay(" + this.size.x + "," + this.size.y + ")");
|
||||
|
||||
int tmpOriginX = 0;
|
||||
int tmpOriginY = 0;
|
||||
@ -195,17 +195,17 @@ boolean ewol::widget::ParameterList::onEventInput( ewol::event::Input _event) {
|
||||
}
|
||||
|
||||
void ewol::widget::ParameterList::onGetFocus() {
|
||||
Log.debug("Ewol::List get focus");
|
||||
LOGGER.debug("Ewol::List get focus");
|
||||
}
|
||||
|
||||
void ewol::widget::ParameterList::onLostFocus() {
|
||||
Log.debug("Ewol::List Lost focus");
|
||||
LOGGER.debug("Ewol::List Lost focus");
|
||||
}
|
||||
|
||||
void ewol::widget::ParameterList::menuAdd(String _label, int _refId, String _image) {
|
||||
ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, _refId, _image, false);
|
||||
if (tmpEmement == null) {
|
||||
Log.error("Can not allocacte menu parameter");
|
||||
LOGGER.error("Can not allocacte menu parameter");
|
||||
return;
|
||||
}
|
||||
this.list.pushBack(tmpEmement);
|
||||
@ -219,7 +219,7 @@ void ewol::widget::ParameterList::menuAddGroup(String _label) {
|
||||
String image = "";
|
||||
ememory::Ptr<ewol::widget::elementPL> tmpEmement = ememory::make<widget::elementPL>(_label, -1, image, true);
|
||||
if (tmpEmement == null) {
|
||||
Log.error("Can not allocacte menu parameter");
|
||||
LOGGER.error("Can not allocacte menu parameter");
|
||||
return;
|
||||
}
|
||||
this.list.pushBack(tmpEmement);
|
||||
|
@ -1,152 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/meta/SpinBase.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
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);
|
||||
}
|
@ -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 <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/ContainerN.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
|
||||
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<ewol::widget::SpinBase>;
|
||||
using SpinBaseWeak = ememory::WeakPtr<ewol::widget::SpinBase>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class SpinBase : public ewol::widget::Sizer {
|
||||
public: // properties list:
|
||||
eproperty::Value<etk::Uri> propertyShape; //!< Shape of the widget
|
||||
eproperty::List<enum ewol::widget::spinPosition> propertySpinMode; //!< How to display the spin base
|
||||
public:
|
||||
UN_DECLARE_FACTORY(SpinBase);
|
||||
protected:
|
||||
ememory::Ptr<ewol::resource::ConfigFile> 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();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -104,17 +104,17 @@ void ewol::widget::StdPopUp::onChangePropertyComment() {
|
||||
|
||||
ewol::widget::Button ewol::widget::StdPopUp::addButton( String _text, boolean _autoExit) {
|
||||
if (this.subBar == null) {
|
||||
Log.error("button-bar does not existed ...");
|
||||
LOGGER.error("button-bar does not existed ...");
|
||||
return null;
|
||||
}
|
||||
ewol::widget::Button myButton = widget::Button::create();
|
||||
if (myButton == null) {
|
||||
Log.error("Can not allocate new button ...");
|
||||
LOGGER.error("Can not allocate new button ...");
|
||||
return null;
|
||||
}
|
||||
ewol::widget::Label myLabel = ewol::widget::Label::create();
|
||||
if (myLabel == null) {
|
||||
Log.error("Can not allocate new label ...");
|
||||
LOGGER.error("Can not allocate new label ...");
|
||||
return null;
|
||||
}
|
||||
myLabel.propertyValue.set(_text);
|
||||
|
@ -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 <ewol/widget/PopUp.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class StdPopUp;
|
||||
using StdPopUp = ememory::Ptr<ewol::widget::StdPopUp>;
|
||||
using StdPopUpWeak = ememory::WeakPtr<ewol::widget::StdPopUp>;
|
||||
/**
|
||||
* 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<String> propertyTitle; //!< Title of the pop-up
|
||||
eproperty::Value<String> 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();
|
||||
}
|
||||
|
||||
|
170
pom.xml
Normal file
170
pom.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>ewol</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Mozilla Public License 2.0</name>
|
||||
<url>https://opensource.org/licenses/MPL-2.0</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dev1</id>
|
||||
<name>Edouard DUPIN</name>
|
||||
<email>edouard.dupin@proton.me</email>
|
||||
<roles>
|
||||
<role>Lead Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>gale</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>io-gami</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>esvg</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>ejson</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>exml</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>esignal</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>loader3d</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.1.0-alpha1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>src/main</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<testSourceDirectory>src/test</testSourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${basedir}/src/testResources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.14.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Create the source bundle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- junit results -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>fully.qualified.MainClass</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Java-doc generation for stand-alone site -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<show>private</show>
|
||||
<nohelp>true</nohelp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Generate Java-docs As Part Of Project Reports -->
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
@ -1,50 +0,0 @@
|
||||
<popup>
|
||||
<sizer mode="vert" lock="true" fill="true" expand="true">
|
||||
<sizer mode="hori">
|
||||
<checkbox name="[{ID}]file-shooser:show-hiden-file">
|
||||
<label>_T{ShowHiddenFiles}</label>
|
||||
</checkbox>
|
||||
<spacer expand="true,false"/>
|
||||
<button name="[{ID}]file-shooser:button-validate">
|
||||
<sizer mode="hori">
|
||||
<image src="THEME_GUI:///Load.svg?lib=ewol" fill="true" size="7,7mm"/>
|
||||
<label name="[{ID}]file-shooser:validate-label">_T{Validate}</label>
|
||||
</sizer>
|
||||
</button>
|
||||
<button name="[{ID}]file-shooser:button-cancel">
|
||||
<sizer mode="hori">
|
||||
<image src="THEME_GUI:///Remove.svg?lib=ewol" fill="true" size="7,7mm"/>
|
||||
<label name="[{ID}]file-shooser:cancel-label">_T{Cancel}</label>
|
||||
</sizer>
|
||||
</button>
|
||||
</sizer>
|
||||
<sizer mode="hori">
|
||||
<spacer min-size="2,2mm"/>
|
||||
<ListFileSystem name="[{ID}]file-shooser:list-folder"
|
||||
min-size="20,0%"
|
||||
expand="false,true"
|
||||
show-hidden="false"
|
||||
show-file="false"
|
||||
show-folder="true"
|
||||
show-temporary="false"/>
|
||||
<spacer min-size="2,2mm"/>
|
||||
<ListFileSystem name="[{ID}]file-shooser:list-files"
|
||||
expand="true,true"
|
||||
show-hidden="false"
|
||||
show-file="true"
|
||||
show-folder="false"
|
||||
show-temporary="false"/>
|
||||
<spacer min-size="2,2mm"/>
|
||||
</sizer>
|
||||
<sizer mode="hori">
|
||||
<image name="[{ID}]file-shooser:img-file" src="THEME_GUI:///File.svg?lib=ewol" expand="false" size="8,8mm"/>
|
||||
<entry name="[{ID}]file-shooser:entry-file" expand="true,false" fill="true,false"/>
|
||||
</sizer>
|
||||
<sizer mode="hori">
|
||||
<image name="[{ID}]file-shooser:img-folder" src="THEME_GUI:///Folder.svg?lib=ewol" expand="false" size="8,8mm"/>
|
||||
<entry name="[{ID}]file-shooser:entry-folder" expand="true,false" fill="true,false"/>
|
||||
<image name="[{ID}]file-shooser:img-home" src="THEME_GUI:///Home.svg?lib=ewol" expand="false" size="8,8mm"/>
|
||||
</sizer>
|
||||
<label name="[{ID}]file-shooser:title-label">_T{Title}</label>
|
||||
</sizer>
|
||||
</popup>
|
@ -1,21 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
// Input :
|
||||
attribute vec3 in_coord3d;
|
||||
attribute vec2 in_texture2d;
|
||||
attribute vec4 in_color;
|
||||
uniform mat4 in_MatrixTransformation;
|
||||
|
||||
// output :
|
||||
varying vec4 io_color;
|
||||
varying vec2 io_texcoord;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = in_MatrixTransformation * vec4(in_coord3d, 1.0);
|
||||
// set texture output coord
|
||||
io_texcoord = in_texture2d;
|
||||
// set output color :
|
||||
io_color = in_color;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
// transmit from the vertex shader
|
||||
varying vec2 v_propPos;
|
||||
varying vec4 v_colorTansition;
|
||||
uniform vec4 EW_border;
|
||||
uniform vec4 EW_background;
|
||||
|
||||
|
||||
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 = EW_background;
|
||||
} else {
|
||||
gl_FragColor = EW_border;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
padding-out-left:1,
|
||||
padding-out-right:1,
|
||||
padding-out-top:1,
|
||||
padding-out-buttom:1,
|
||||
|
||||
border-left:1,
|
||||
border-right:1,
|
||||
border-top:1,
|
||||
border-buttom:1,
|
||||
|
||||
padding-in-left:1,
|
||||
padding-in-right:1,
|
||||
padding-in-top:1,
|
||||
padding-in-buttom:1,
|
||||
|
||||
object-file:"THEME:///Button.obj?lib=ewol",
|
||||
object-size:"1,1,1"
|
||||
}
|
@ -1,52 +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_foreground;
|
||||
uniform vec4 EW_foregroundHover;
|
||||
uniform vec4 EW_foregroundSelected;
|
||||
uniform vec4 EW_foregroundPressed;
|
||||
|
||||
// output :
|
||||
varying vec2 v_propPos;
|
||||
varying vec4 v_colorTansition;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
// transmit position of the curent element (intermolated ...)
|
||||
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;
|
||||
}
|
||||
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
v_colorTansition = colorOld * (1.0 - EW_status.transition)
|
||||
+ colorNew * EW_status.transition;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
{
|
||||
mode:2,
|
||||
display-outside:false,
|
||||
|
||||
padding-out-left:1,
|
||||
padding-out-right:1,
|
||||
padding-out-top:1,
|
||||
padding-out-buttom:1,
|
||||
|
||||
border-left:1,
|
||||
border-right:1,
|
||||
border-top:1,
|
||||
border-buttom:1,
|
||||
|
||||
padding-in-left:1,
|
||||
padding-in-right:1,
|
||||
padding-in-top:1,
|
||||
padding-in-buttom:1,
|
||||
|
||||
box-size:20,
|
||||
box-inside:12,
|
||||
change-time:356,
|
||||
program:"THEME_GUI:///CheckBox.prog?lib=ewol",
|
||||
color:"THEME_COLOR:///CheckBox.json?lib=ewol"
|
||||
}
|
@ -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;
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
EMF(STRING)
|
||||
# Blender v2.92.0 EMF File: 'Entry.blend'
|
@ -1,25 +0,0 @@
|
||||
{
|
||||
# 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 "inside" the object in piuxel ==> prevent bad display
|
||||
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",
|
||||
|
||||
# Object to render (with modification)
|
||||
object-file:"THEME:shape/Entry.obj?lib=ewol",
|
||||
|
||||
# Theme Image (pallete)
|
||||
image-palette:"THEME:shape/GuiPaletteColor.png?lib=ewol",
|
||||
# read mode: 'nearest', 'linear'
|
||||
image-palette-load-mode: "nearest",
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
# Blender MTL File: 'Entry.blend'
|
||||
# Material Count: 2
|
||||
|
||||
newmtl TextArea
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd empty_area.png
|
||||
|
||||
newmtl center
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.450000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd GuiPaletteColor.png
|
@ -1,99 +0,0 @@
|
||||
# Blender v2.92.0 OBJ File: 'Entry.blend'
|
||||
# www.blender.org
|
||||
mtllib Entry.mtl
|
||||
o Cube
|
||||
v 20.042355 20.042355 -7.751226
|
||||
v 20.042355 -20.042355 -7.751226
|
||||
v 20.042355 20.042355 4.633502
|
||||
v 20.042355 -20.042355 4.633502
|
||||
v -20.042355 20.042355 -7.751226
|
||||
v -20.042355 -20.042355 -7.751226
|
||||
v -20.042355 20.042355 4.633502
|
||||
v -20.042355 -20.042355 4.633502
|
||||
v 10.127714 10.127714 7.726907
|
||||
v 10.127714 -10.127714 7.726907
|
||||
v -10.127714 10.127714 7.726907
|
||||
v -10.127714 -10.127714 7.726907
|
||||
v -10.127714 -10.127714 9.146553
|
||||
v -10.127714 10.127714 9.146553
|
||||
v 10.127714 10.127714 9.146553
|
||||
v 10.127714 -10.127714 9.146553
|
||||
vt 0.174907 0.947863
|
||||
vt 0.131613 0.991157
|
||||
vt 0.132843 0.945402
|
||||
vt 0.074219 0.995849
|
||||
vt 0.120606 0.943115
|
||||
vt 0.121582 0.993408
|
||||
vt 0.178368 0.944941
|
||||
vt 0.137534 0.984544
|
||||
vt 0.142456 0.948632
|
||||
vt 0.171985 0.949093
|
||||
vt 0.136074 0.991157
|
||||
vt 0.137304 0.950323
|
||||
vt 0.174677 0.949093
|
||||
vt 0.135074 0.992387
|
||||
vt 0.136304 0.949093
|
||||
vt 0.112927 0.992387
|
||||
vt 0.078245 0.948093
|
||||
vt 0.073324 0.991157
|
||||
vt 0.101769 0.970961
|
||||
vt 0.080974 0.959440
|
||||
vt 0.102023 0.957458
|
||||
vt 0.111927 0.985005
|
||||
vt 0.078476 0.953015
|
||||
vt 0.082167 0.983774
|
||||
vt 0.137534 0.988235
|
||||
vt 0.177138 0.947863
|
||||
vt 0.135074 0.947862
|
||||
vt 0.013265 0.951784
|
||||
vt 0.051868 0.992387
|
||||
vt 0.013034 0.993618
|
||||
vt 0.178598 0.993618
|
||||
vt 0.074219 0.944092
|
||||
vt 0.178368 0.988235
|
||||
vt 0.173216 0.991157
|
||||
vt 0.175907 0.989926
|
||||
vt 0.111696 0.944402
|
||||
vt 0.080720 0.975385
|
||||
vt 0.113157 0.949323
|
||||
vt 0.172446 0.988465
|
||||
vt 0.054098 0.951784
|
||||
vt 0.000100 0.000100
|
||||
vt 0.999900 0.999900
|
||||
vt 0.000100 0.999900
|
||||
vt 0.999900 0.000100
|
||||
vn 0.0000 1.0000 0.0000
|
||||
vn -0.2978 0.0000 0.9546
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn 0.0000 -0.2978 0.9546
|
||||
vn 0.0000 0.2978 0.9546
|
||||
vn 0.2978 0.0000 0.9546
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
usemtl center
|
||||
s off
|
||||
f 5/1/1 3/2/1 1/3/1
|
||||
f 8/4/2 11/5/2 7/6/2
|
||||
f 7/7/3 6/8/3 8/9/3
|
||||
f 2/10/4 8/11/4 6/12/4
|
||||
f 1/13/5 4/14/5 2/15/5
|
||||
f 4/16/6 12/17/6 8/18/6
|
||||
f 7/19/7 9/20/7 3/21/7
|
||||
f 3/22/8 10/23/8 4/24/8
|
||||
f 6/25/9 1/26/9 2/27/9
|
||||
f 10/28/10 11/29/10 12/30/10
|
||||
f 5/1/1 7/31/1 3/2/1
|
||||
f 8/4/2 12/32/2 11/5/2
|
||||
f 7/7/3 5/33/3 6/8/3
|
||||
f 2/10/4 4/34/4 8/11/4
|
||||
f 1/13/5 3/35/5 4/14/5
|
||||
f 4/16/6 10/36/6 12/17/6
|
||||
f 7/19/7 11/37/7 9/20/7
|
||||
f 3/22/8 9/38/8 10/23/8
|
||||
f 6/25/9 5/39/9 1/26/9
|
||||
f 10/28/10 9/40/10 11/29/10
|
||||
usemtl TextArea
|
||||
f 15/41/10 13/42/10 16/43/10
|
||||
f 15/41/10 14/44/10 13/42/10
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
mode:2,
|
||||
display-outside:false,
|
||||
|
||||
padding-out-left:2,
|
||||
padding-out-right:2,
|
||||
padding-out-top:2,
|
||||
padding-out-buttom:2,
|
||||
|
||||
border-left:3,
|
||||
border-right:3,
|
||||
border-top:3,
|
||||
border-buttom:3,
|
||||
|
||||
padding-in-left:2,
|
||||
padding-in-right:2,
|
||||
padding-in-top:2,
|
||||
padding-in-buttom:2,
|
||||
|
||||
change-time:356,
|
||||
program:"THEME_GUI:///PopUp.prog?lib=ewol",
|
||||
color:"THEME_COLOR:///PopUp.json?lib=ewol"
|
||||
}
|
@ -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;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
entry-shaper:"THEME_GUI:///SpinEntry.json?lib=ewol",
|
||||
up-shaper:"THEME_GUI:///SpinUp.json?lib=ewol",
|
||||
up-data:"<label>+</label>",
|
||||
down-shaper:"THEME_GUI:///SpinDown.json?lib=ewol",
|
||||
down-data:"<label>-</label>",
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
mode:2,
|
||||
display-outside:false,
|
||||
|
||||
padding-out-left:0,
|
||||
padding-out-right:0,
|
||||
padding-out-top:1,
|
||||
padding-out-buttom:1,
|
||||
|
||||
border-left:1,
|
||||
border-right:0,
|
||||
border-top:1,
|
||||
border-buttom:1,
|
||||
|
||||
padding-in-left:1,
|
||||
padding-in-right:1,
|
||||
padding-in-top:1,
|
||||
padding-in-buttom:1,
|
||||
|
||||
change-time:356,
|
||||
program:"THEME_GUI:///Button.prog?lib=ewol",
|
||||
color:"THEME_COLOR:///Button.json?lib=ewol"
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
mode:2,
|
||||
display-outside:false,
|
||||
|
||||
padding-out-left:0,
|
||||
padding-out-right:0,
|
||||
padding-out-top:1,
|
||||
padding-out-buttom:1,
|
||||
|
||||
border-left:1,
|
||||
border-right:0,
|
||||
border-top:1,
|
||||
border-buttom:1,
|
||||
|
||||
padding-in-left:2,
|
||||
padding-in-right:2,
|
||||
padding-in-top:1,
|
||||
padding-in-buttom:1,
|
||||
|
||||
change-time:356,
|
||||
program:"THEME_GUI:///Entry.prog?lib=ewol",
|
||||
color:"THEME_COLOR:///Entry.json?lib=ewol"
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
mode:2,
|
||||
display-outside:false,
|
||||
|
||||
padding-out-left:0,
|
||||
padding-out-right:0,
|
||||
padding-out-top:1,
|
||||
padding-out-buttom:1,
|
||||
|
||||
border-left:1,
|
||||
border-right:1,
|
||||
border-top:1,
|
||||
border-buttom:1,
|
||||
|
||||
padding-in-left:1,
|
||||
padding-in-right:1,
|
||||
padding-in-top:1,
|
||||
padding-in-buttom:1,
|
||||
|
||||
change-time:356,
|
||||
program:"THEME_GUI:///Button.prog?lib=ewol",
|
||||
color:"THEME_COLOR:///Button.json?lib=ewol"
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
mode:2,
|
||||
display-outside:true,
|
||||
|
||||
padding-out-left:1,
|
||||
padding-out-right:1,
|
||||
padding-out-top:1,
|
||||
padding-out-buttom:1,
|
||||
|
||||
border-left:1,
|
||||
border-right:1,
|
||||
border-top:1,
|
||||
border-buttom:1,
|
||||
|
||||
padding-in-left:3,
|
||||
padding-in-right:3,
|
||||
padding-in-top:3,
|
||||
padding-in-buttom:3,
|
||||
|
||||
change-time:200,
|
||||
program:"THEME_GUI:///WidgetScrolled.prog?lib=ewol",
|
||||
color:"THEME_COLOR:///WidgetScrolled.json?lib=ewol"
|
||||
}
|
@ -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;
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -1,15 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-ewol">
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
4
samples/.gitignore
vendored
4
samples/.gitignore
vendored
@ -1 +1,5 @@
|
||||
|
||||
/__pycache__/
|
||||
/bin/
|
||||
/out/
|
||||
/target/
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>atriasoft-ewol-samples</name>
|
||||
<name>ewol-sample</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
@ -10,8 +10,14 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
8
samples/.settings/org.eclipse.jdt.core.prefs
Normal file
8
samples/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
||||
org.eclipse.jdt.core.compiler.compliance=21
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=21
|
4
samples/.settings/org.eclipse.m2e.core.prefs
Normal file
4
samples/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
147
samples/pom.xml
Normal file
147
samples/pom.xml
Normal file
@ -0,0 +1,147 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>ewol-sample</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Mozilla Public License 2.0</name>
|
||||
<url>https://opensource.org/licenses/MPL-2.0</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>dev1</id>
|
||||
<name>Edouard DUPIN</name>
|
||||
<email>edouard.dupin@proton.me</email>
|
||||
<roles>
|
||||
<role>Lead Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>gitea</id>
|
||||
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>ewol</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
<!-- Loopback of logger JDK logging API to SLF4J -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>2.0.9</version>
|
||||
</dependency>
|
||||
<!-- generic logger of SLF4J to console (in color) -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.4.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.12.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
<artifactId>janino</artifactId>
|
||||
<version>3.1.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.14.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Create the source bundle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>4.0.0-beta-1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- junit results -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>fully.qualified.MainClass</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Java-doc generation for stand-alone site -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<show>private</show>
|
||||
<nohelp>true</nohelp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Generate Java-docs As Part Of Project Reports -->
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
@ -1,4 +1,6 @@
|
||||
module sample.atriasoft.ewol {
|
||||
//exports sample.atriasoft.ewol.simpleWindowsWithImage;
|
||||
requires org.atriasoft.ewol;
|
||||
requires org.atriasoft.etk;
|
||||
requires org.atriasoft.esignal;
|
||||
}
|
83
samples/src/main/sample/atriasoft/ewol/Appl.java
Normal file
83
samples/src/main/sample/atriasoft/ewol/Appl.java
Normal file
@ -0,0 +1,83 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import org.atriasoft.etk.Configs;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.context.EwolApplication;
|
||||
import org.atriasoft.ewol.context.EwolContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Appl implements EwolApplication {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Appl.class);
|
||||
|
||||
// ! [ewol_sample_HW_main_application]
|
||||
private void localCreate(final EwolContext context) {
|
||||
// ! [ewol_sample_HW_main_parse_arguments]
|
||||
// parse all the argument of the application
|
||||
for (var iii = 0; iii < context.getCmd().size(); iii++) {
|
||||
final var tmpppp = context.getCmd().get(iii);
|
||||
if (tmpppp == "-h" || tmpppp == "--help") {
|
||||
LOGGER.info(" -h/--help display this help");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
// ! [ewol_sample_HW_main_parse_arguments]
|
||||
// ! [ewol_sample_HW_main_set_windows_size]
|
||||
// TODO : Remove this: Move if in the windows properties
|
||||
context.setSize(new Vector2f(800, 600));
|
||||
// ! [ewol_sample_HW_main_set_windows_size]
|
||||
// ! [ewol_sample_HW_main_set_font_property]
|
||||
// select font preference of der with a basic application size
|
||||
Configs.getConfigFonts().set("FreeSherif", 12);
|
||||
// ! [ewol_sample_HW_main_set_font_property]
|
||||
// ! [ewol_sample_HW_main_set_windows]
|
||||
// Create the windows
|
||||
final var basicWindows = new BasicWindows();
|
||||
// configure the ewol context to use the new windows
|
||||
context.setWindows(basicWindows);
|
||||
// ! [ewol_sample_HW_main_set_windows]
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final EwolContext context) {
|
||||
LOGGER.info("Application onCreate: [BEGIN]");
|
||||
localCreate(context);
|
||||
LOGGER.info("Application onCreate: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(final EwolContext context) {
|
||||
LOGGER.info("Application onDestroy: [BEGIN]");
|
||||
|
||||
LOGGER.info("Application onDestroy: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(final EwolContext context) {
|
||||
LOGGER.info("Application onPause: [BEGIN]");
|
||||
|
||||
LOGGER.info("Application onPause: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(final EwolContext context) {
|
||||
LOGGER.info("Application onResume: [BEGIN]");
|
||||
|
||||
LOGGER.info("Application onResume: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(final EwolContext context) {
|
||||
LOGGER.info("Application onStart: [BEGIN]");
|
||||
|
||||
LOGGER.info("Application onStart: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(final EwolContext context) {
|
||||
LOGGER.info("Application onStop: [BEGIN]");
|
||||
|
||||
LOGGER.info("Application onStop: [ END ]");
|
||||
}
|
||||
|
||||
}
|
112
samples/src/main/sample/atriasoft/ewol/BasicWindows.java
Normal file
112
samples/src/main/sample/atriasoft/ewol/BasicWindows.java
Normal file
@ -0,0 +1,112 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.Distance;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.widget.Button;
|
||||
import org.atriasoft.ewol.widget.Container;
|
||||
import org.atriasoft.ewol.widget.Label;
|
||||
import org.atriasoft.ewol.widget.Sizer;
|
||||
import org.atriasoft.ewol.widget.Sizer.DisplayMode;
|
||||
import org.atriasoft.ewol.widget.Windows;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BasicWindows extends Windows {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BasicWindows.class);
|
||||
|
||||
private int index = -1;
|
||||
private final List<TestWidgetInterface> testedElement = new ArrayList<>();
|
||||
private Container container = null;
|
||||
private Label title = null;
|
||||
|
||||
public static void staticRequestNext(final BasicWindows self) {
|
||||
self.requestNext();
|
||||
}
|
||||
|
||||
public static void staticRequestPrevious(final BasicWindows self) {
|
||||
self.requestPrevious();
|
||||
}
|
||||
|
||||
public void requestNext() {
|
||||
LOGGER.info("Request Next");
|
||||
this.index++;
|
||||
if (this.index >= this.testedElement.size()) {
|
||||
this.index = 0;
|
||||
}
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
public void requestPrevious() {
|
||||
LOGGER.info("Request Previous");
|
||||
this.index--;
|
||||
if (this.index < 0) {
|
||||
this.index = this.testedElement.size() - 1;
|
||||
}
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
public void updateDisplay() {
|
||||
final var test = this.testedElement.get(this.index);
|
||||
final var titlegenerated = "<b>[" + (this.index + 1) + "/" + this.testedElement.size() + "] " + test.getTitle()
|
||||
+ "</b>";
|
||||
this.title.setPropertyValue(titlegenerated);
|
||||
setPropertyTitle(titlegenerated);
|
||||
this.container.setSubWidget(new ModelWidget(test));
|
||||
}
|
||||
|
||||
public BasicWindows() {
|
||||
|
||||
final var sizerMain = new Sizer(DisplayMode.VERTICAL);
|
||||
sizerMain.setPropertyExpand(Vector2b.TRUE);
|
||||
sizerMain.setPropertyFill(Vector2b.TRUE);
|
||||
setSubWidget(sizerMain);
|
||||
|
||||
final var menu = new Sizer(DisplayMode.HORIZONTAL);
|
||||
menu.setPropertyExpand(Vector2b.TRUE_FALSE);
|
||||
menu.setPropertyExpandIfFree(Vector2b.TRUE_FALSE);
|
||||
menu.setPropertyFill(Vector2b.TRUE);
|
||||
menu.setPropertyLockExpand(Vector2b.TRUE);
|
||||
menu.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 3), Distance.CENTIMETER));
|
||||
sizerMain.subWidgetAdd(menu);
|
||||
|
||||
this.container = new Container();
|
||||
this.container.setPropertyExpand(Vector2b.TRUE);
|
||||
this.container.setPropertyFill(Vector2b.TRUE);
|
||||
sizerMain.subWidgetAdd(this.container);
|
||||
|
||||
final var next = Button.createLabelButton("<< Previous");
|
||||
next.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
||||
menu.subWidgetAdd(next);
|
||||
next.signalClick.connectAuto(this, BasicWindows::staticRequestNext);
|
||||
|
||||
this.title = new Label("unknown");
|
||||
this.title.setPropertyFill(Vector2b.FALSE);
|
||||
this.title.setPropertyExpand(Vector2b.TRUE);
|
||||
menu.subWidgetAdd(this.title);
|
||||
|
||||
final var previous = Button.createLabelButton("Next >>");
|
||||
previous.setPropertyMaxSize(new Dimension2f(new Vector2f(9999, 2), Distance.CENTIMETER));
|
||||
menu.subWidgetAdd(previous);
|
||||
previous.signalClick.connectAuto(this, BasicWindows::staticRequestPrevious);
|
||||
|
||||
this.container.setPropertyExpand(Vector2b.TRUE);
|
||||
this.container.setPropertyFill(Vector2b.TRUE);
|
||||
this.container.setPropertyExpandIfFree(Vector2b.TRUE);
|
||||
|
||||
this.testedElement.add(new TestWidgetSlider());
|
||||
this.testedElement.add(new TestWidgetEntry());
|
||||
this.testedElement.add(new TestWidgetBox());
|
||||
this.testedElement.add(new TestWidgetButton());
|
||||
this.testedElement.add(new TestWidgetButtonToggle());
|
||||
this.testedElement.add(new TestWidgetCheckBox());
|
||||
this.testedElement.add(new TestWidgetImage());
|
||||
this.testedElement.add(new TestWidgetLabel());
|
||||
requestNext();
|
||||
|
||||
}
|
||||
}
|
@ -4,17 +4,20 @@ import org.atriasoft.etk.Configs;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.context.EwolApplication;
|
||||
import org.atriasoft.ewol.context.EwolContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Appl implements EwolApplication {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Appl.class);
|
||||
|
||||
//! [ewol_sample_HW_main_application]
|
||||
private void localCreate(final EwolContext context) {
|
||||
//! [ewol_sample_HW_main_parse_arguments]
|
||||
// parse all the argument of the application
|
||||
for (int iii = 0; iii < context.getCmd().size(); iii++) {
|
||||
String tmpppp = context.getCmd().get(iii);
|
||||
final String tmpppp = context.getCmd().get(iii);
|
||||
if (tmpppp == "-h" || tmpppp == "--help") {
|
||||
Log.print(" -h/--help display this help");
|
||||
LOGGER.info(" -h/--help display this help");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@ -29,7 +32,7 @@ public class Appl implements EwolApplication {
|
||||
//! [ewol_sample_HW_main_set_font_property]
|
||||
//! [ewol_sample_HW_main_set_windows]
|
||||
// Create the windows
|
||||
MainWindows basicWindows = new MainWindows();
|
||||
final MainWindows basicWindows = new MainWindows();
|
||||
// configure the ewol context to use the new windows
|
||||
context.setWindows(basicWindows);
|
||||
//! [ewol_sample_HW_main_set_windows]
|
||||
@ -37,44 +40,44 @@ public class Appl implements EwolApplication {
|
||||
|
||||
@Override
|
||||
public void onCreate(final EwolContext context) {
|
||||
Log.info("Application onCreate: [BEGIN]");
|
||||
LOGGER.info("Application onCreate: [BEGIN]");
|
||||
localCreate(context);
|
||||
Log.info("Application onCreate: [ END ]");
|
||||
LOGGER.info("Application onCreate: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(final EwolContext context) {
|
||||
Log.info("Application onDestroy: [BEGIN]");
|
||||
LOGGER.info("Application onDestroy: [BEGIN]");
|
||||
|
||||
Log.info("Application onDestroy: [ END ]");
|
||||
LOGGER.info("Application onDestroy: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(final EwolContext context) {
|
||||
Log.info("Application onPause: [BEGIN]");
|
||||
LOGGER.info("Application onPause: [BEGIN]");
|
||||
|
||||
Log.info("Application onPause: [ END ]");
|
||||
LOGGER.info("Application onPause: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(final EwolContext context) {
|
||||
Log.info("Application onResume: [BEGIN]");
|
||||
LOGGER.info("Application onResume: [BEGIN]");
|
||||
|
||||
Log.info("Application onResume: [ END ]");
|
||||
LOGGER.info("Application onResume: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(final EwolContext context) {
|
||||
Log.info("Application onStart: [BEGIN]");
|
||||
LOGGER.info("Application onStart: [BEGIN]");
|
||||
|
||||
Log.info("Application onStart: [ END ]");
|
||||
LOGGER.info("Application onStart: [ END ]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop(final EwolContext context) {
|
||||
Log.info("Application onStop: [BEGIN]");
|
||||
LOGGER.info("Application onStop: [BEGIN]");
|
||||
|
||||
Log.info("Application onStop: [ END ]");
|
||||
LOGGER.info("Application onStop: [ END ]");
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package sample.atriasoft.ewol.ComplexWindiows1;
|
||||
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.Distance;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
@ -16,55 +16,55 @@ public class MainWindows extends Windows {
|
||||
//! [ewol_sample_HW_windows_title]
|
||||
setPropertyTitle("Simple sample test");
|
||||
//EwolObject.getContext().getFontDefault().setName("FreeSans");
|
||||
Sizer sizerMain = new Sizer(DisplayMode.modeVert);
|
||||
sizerMain.setPropertyExpand(new Vector2b(true, true));
|
||||
sizerMain.setPropertyFill(new Vector2b(true, true));
|
||||
Sizer sizerMain = new Sizer(DisplayMode.VERTICAL);
|
||||
sizerMain.setPropertyExpand(Vector2b.TRUE);
|
||||
sizerMain.setPropertyFill(Vector2b.TRUE);
|
||||
setSubWidget(sizerMain);
|
||||
|
||||
Sizer sizerHori1 = new Sizer(DisplayMode.modeHori);
|
||||
sizerHori1.setPropertyExpand(new Vector2b(true, true));
|
||||
sizerHori1.setPropertyFill(new Vector2b(true, true));
|
||||
Sizer sizerHori1 = new Sizer(DisplayMode.HORIZONTAL);
|
||||
sizerHori1.setPropertyExpand(Vector2b.TRUE);
|
||||
sizerHori1.setPropertyFill(Vector2b.TRUE);
|
||||
sizerMain.subWidgetAdd(sizerHori1);
|
||||
|
||||
Sizer sizerHori2 = new Sizer(DisplayMode.modeHori);
|
||||
sizerHori2.setPropertyExpand(new Vector2b(true, true));
|
||||
sizerHori2.setPropertyFill(new Vector2b(true, true));
|
||||
Sizer sizerHori2 = new Sizer(DisplayMode.HORIZONTAL);
|
||||
sizerHori2.setPropertyExpand(Vector2b.TRUE);
|
||||
sizerHori2.setPropertyFill(Vector2b.TRUE);
|
||||
sizerMain.subWidgetAdd(sizerHori2);
|
||||
|
||||
{
|
||||
Spacer simpleSpacer = new Spacer();
|
||||
simpleSpacer.setPropertyMinSize(new Dimension(new Vector2f(100, 100), Distance.PIXEL));
|
||||
simpleSpacer.setPropertyMinSize(new Dimension2f(new Vector2f(100, 100), Distance.PIXEL));
|
||||
simpleSpacer.setPropertyColor(Color.ALICE_BLUE);
|
||||
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyFill(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyExpand(Vector2b.TRUE);
|
||||
simpleSpacer.setPropertyFill(Vector2b.TRUE);
|
||||
sizerHori1.subWidgetAdd(simpleSpacer);
|
||||
}
|
||||
{
|
||||
Spacer simpleSpacer = new Spacer();
|
||||
simpleSpacer.setPropertyColor(Color.DARK_GREEN);
|
||||
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyFill(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyExpand(Vector2b.TRUE);
|
||||
simpleSpacer.setPropertyFill(Vector2b.TRUE);
|
||||
sizerHori1.subWidgetAdd(simpleSpacer);
|
||||
}
|
||||
{
|
||||
Spacer simpleSpacer = new Spacer();
|
||||
simpleSpacer.setPropertyColor(Color.CHOCOLATE);
|
||||
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyFill(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyExpand(Vector2b.TRUE);
|
||||
simpleSpacer.setPropertyFill(Vector2b.TRUE);
|
||||
sizerHori1.subWidgetAdd(simpleSpacer);
|
||||
}
|
||||
{
|
||||
Spacer simpleSpacer = new Spacer();
|
||||
simpleSpacer.setPropertyColor(Color.GREEN_YELLOW);
|
||||
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyFill(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyExpand(Vector2b.TRUE);
|
||||
simpleSpacer.setPropertyFill(Vector2b.TRUE);
|
||||
sizerHori2.subWidgetAdd(simpleSpacer);
|
||||
}
|
||||
{
|
||||
Spacer simpleSpacer = new Spacer();
|
||||
simpleSpacer.setPropertyColor(Color.PINK);
|
||||
simpleSpacer.setPropertyExpand(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyFill(new Vector2b(true, true));
|
||||
simpleSpacer.setPropertyExpand(Vector2b.TRUE);
|
||||
simpleSpacer.setPropertyFill(Vector2b.TRUE);
|
||||
sizerHori2.subWidgetAdd(simpleSpacer);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import org.atriasoft.etk.Uri;
|
||||
import org.atriasoft.ewol.Ewol;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
|
||||
public class MainApplicaitionStarter {
|
||||
public static void main(final String[] args) {
|
||||
// Loop-back of logger JDK logging API to SLF4J
|
||||
LogManager.getLogManager().reset();
|
||||
SLF4JBridgeHandler.install();
|
||||
Ewol.init();
|
||||
Uri.setApplication(MainApplicaitionStarter.class, "test-ewol/");
|
||||
Ewol.run(new Appl(), args);
|
||||
}
|
||||
|
||||
private MainApplicaitionStarter() {}
|
||||
}
|
1560
samples/src/main/sample/atriasoft/ewol/ModelWidget.java
Normal file
1560
samples/src/main/sample/atriasoft/ewol/ModelWidget.java
Normal file
File diff suppressed because it is too large
Load Diff
40
samples/src/main/sample/atriasoft/ewol/TestWidgetBox.java
Normal file
40
samples/src/main/sample/atriasoft/ewol/TestWidgetBox.java
Normal file
@ -0,0 +1,40 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import org.atriasoft.etk.Color;
|
||||
import org.atriasoft.etk.Dimension2f;
|
||||
import org.atriasoft.etk.DimensionBorderRadius;
|
||||
import org.atriasoft.etk.DimensionInsets;
|
||||
import org.atriasoft.etk.math.Vector2b;
|
||||
import org.atriasoft.etk.math.Vector2f;
|
||||
import org.atriasoft.ewol.widget.Box;
|
||||
import org.atriasoft.ewol.widget.Widget;
|
||||
|
||||
public class TestWidgetBox implements TestWidgetInterface {
|
||||
@Override
|
||||
public Widget getWidget() {
|
||||
final var innerWidget = new Box();
|
||||
// this.testWidget.setPropertySource(new Uri("DATA", "mireA.png"));
|
||||
innerWidget.setPropertyExpand(Vector2b.FALSE);
|
||||
innerWidget.setPropertyExpandIfFree(Vector2b.TRUE);
|
||||
innerWidget.setPropertyFill(Vector2b.TRUE);
|
||||
innerWidget.setPropertyColor(Color.PINK);
|
||||
innerWidget.setPropertyMinSize(new Dimension2f(new Vector2f(50, 80)));
|
||||
|
||||
final var testWidget = new Box(innerWidget);
|
||||
testWidget.setPropertyExpand(Vector2b.FALSE);
|
||||
testWidget.setPropertyFill(Vector2b.FALSE);
|
||||
testWidget.setPropertyBorderWidth(new DimensionInsets(10));
|
||||
testWidget.setPropertyBorderRadius(new DimensionBorderRadius(25));
|
||||
testWidget.setPropertyBorderColor(Color.BLACK);
|
||||
testWidget.setPropertyColor(Color.GREEN_YELLOW);
|
||||
testWidget.setPropertyPadding(new DimensionInsets(15, 15));
|
||||
testWidget.setPropertyMargin(new DimensionInsets(25, 25));
|
||||
|
||||
return testWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Simple CheckBox";
|
||||
}
|
||||
}
|
17
samples/src/main/sample/atriasoft/ewol/TestWidgetButton.java
Normal file
17
samples/src/main/sample/atriasoft/ewol/TestWidgetButton.java
Normal file
@ -0,0 +1,17 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import org.atriasoft.ewol.widget.Button;
|
||||
import org.atriasoft.ewol.widget.Widget;
|
||||
|
||||
public class TestWidgetButton implements TestWidgetInterface {
|
||||
|
||||
@Override
|
||||
public Widget getWidget() {
|
||||
return Button.createLabelButton("A simple Label");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Simple CheckBox";
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package sample.atriasoft.ewol;
|
||||
|
||||
import org.atriasoft.ewol.widget.Composer;
|
||||
import org.atriasoft.ewol.widget.Widget;
|
||||
|
||||
public class TestWidgetButtonToggle implements TestWidgetInterface {
|
||||
|
||||
@Override
|
||||
public Widget getWidget() {
|
||||
return Composer.composerGenerateString("""
|
||||
<Button name='My name is Bob' toggle='true' fill='true,false' expand='true'>
|
||||
<Label>hello, how are you</Label>
|
||||
<Label>You <br/>Click - Me <b>!?<!--kjlkjlkjlkj-->d</b></Label>
|
||||
</Button>
|
||||
""");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Simple Button toggle";
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user