Update version tag : 0.9.3
This commit is contained in:
commit
be0b31f905
2
build
2
build
@ -1 +1 @@
|
|||||||
Subproject commit dd46d2d7b4100fd518cabe4de2468868d22a1adb
|
Subproject commit b1cbee3b4b65bacad8abbbbdc99cdf9e472b76e4
|
@ -5,7 +5,7 @@ __________________________________________________
|
|||||||
=== Overview:===
|
=== Overview:===
|
||||||
EWOL is an OpenGL library for creating graphical user interfaces.
|
EWOL is an OpenGL library for creating graphical user interfaces.
|
||||||
It works on many UNIX-like platforms, Windows, and OS X and some mobile platforms Android, iOs(soon).
|
It works on many UNIX-like platforms, Windows, and OS X and some mobile platforms Android, iOs(soon).
|
||||||
EWOL is released under the BSD 3 clauses license (BSD v3), which allows for very flexible licensing of client applications.
|
EWOL is released under the APACHE-2 license, which allows for very flexible licensing of client applications.
|
||||||
EWOL has a C++ architecture that allows for maximum flexibility.
|
EWOL has a C++ architecture that allows for maximum flexibility.
|
||||||
|
|
||||||
The main idea of EWOL is to create a complete abstraction of the platforms.
|
The main idea of EWOL is to create a complete abstraction of the platforms.
|
||||||
@ -21,7 +21,7 @@ To use ewol you need to know only C++ language. It could be usefull to know:
|
|||||||
One of the important point to know in this framwork is some of absurd things came from the multiple architecture type.
|
One of the important point to know in this framwork is some of absurd things came from the multiple architecture type.
|
||||||
|
|
||||||
I will Explain the main points:
|
I will Explain the main points:
|
||||||
:** IOs does [b]NOT[/b] simply support the shared object sub lib, this force ewol to be BSD, and depend on some sub-library with small license restriction.
|
:** IOs does [b]NOT[/b] simply support the shared object sub lib, this force ewol to be APACHE-2, and depend on some sub-library with small license restriction.
|
||||||
:** Android have a JAVA main, then the application main will not be used with this platform
|
:** Android have a JAVA main, then the application main will not be used with this platform
|
||||||
:** Android event (keyboard, mouse, touch-screen and ...) will arrive in asynchron mode ==> need to be resynchronyse in one thread
|
:** Android event (keyboard, mouse, touch-screen and ...) will arrive in asynchron mode ==> need to be resynchronyse in one thread
|
||||||
:** Only one graphyc framework is availlable on all platform. This is OpenGL
|
:** Only one graphyc framework is availlable on all platform. This is OpenGL
|
||||||
|
36
doc/faq.bb
Normal file
36
doc/faq.bb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
=?= FAQ =?=
|
||||||
|
|
||||||
|
== What is ewol licence ==
|
||||||
|
|
||||||
|
This is really simple : APACHE-2 :
|
||||||
|
|
||||||
|
Copyright ewol Edouard DUPIN
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
[[http://www.apache.org/licenses/LICENSE-2.0]]
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
== Why we use "DECLARE_FACTORY" Macro ? ==
|
||||||
|
|
||||||
|
For some reason!!! But everything might be clear:
|
||||||
|
:** In ewol we masively use std::shared_ptr<xxx> (I have create my own but it is not "standard" (I like when we use genecic system)).
|
||||||
|
:** The main class : [class[ewol::Object]] herited from [i]std::enable_shared_from_this<Object>[/i] to permit to access at his own [i]std::shared_ptr[/i].
|
||||||
|
:** Acces At his own [i]std::shared_ptr[/i] is not allowed in the class contructor/destructor.
|
||||||
|
:** Many time for meta-widget we need to propagate our [i]std::shared_ptr[/i] in child.
|
||||||
|
|
||||||
|
Then for all these reasons, I have create a simple MACRO that create a static template funtion that create the object and just after
|
||||||
|
creation call the init(...) function to permit to create a complex widget or others with some writing convinience.
|
||||||
|
|
||||||
|
|
||||||
|
|
38
doc/index.bb
38
doc/index.bb
@ -7,10 +7,10 @@ EWOL, or Edn Widget OpenGl Layer, is a multi-platform library for creating graph
|
|||||||
===Where can I use it?===
|
===Where can I use it?===
|
||||||
Everywhere! EWOL is cross-platform devolopped to support bases OS:
|
Everywhere! EWOL is cross-platform devolopped to support bases OS:
|
||||||
: ** Linux (X11) (mouse)
|
: ** Linux (X11) (mouse)
|
||||||
: ** Windows (mouse)
|
: ** Windows (mouse) (not compile anymore ==> TODO)
|
||||||
: ** MacOs (mouse)
|
: ** MacOs (mouse)
|
||||||
: ** Android (mouse + touch)
|
: ** Android (mouse + touch)
|
||||||
: ** IOs (in-progress)
|
: ** IOs (touch)
|
||||||
|
|
||||||
===What languages are supported?===
|
===What languages are supported?===
|
||||||
EWOL is written in C++ and is not (for now) supported for other languages.
|
EWOL is written in C++ and is not (for now) supported for other languages.
|
||||||
@ -23,7 +23,7 @@ That allow you to use it for every program you want, including those developing
|
|||||||
[note]The static support is important for some platform like IOs, and this limit the external library use at some license like :
|
[note]The static support is important for some platform like IOs, and this limit the external library use at some license like :
|
||||||
:** BSD*
|
:** BSD*
|
||||||
:** MIT
|
:** MIT
|
||||||
:** APPACHE
|
:** APPACHE-2
|
||||||
:** PNG
|
:** PNG
|
||||||
:** ZLIB
|
:** ZLIB
|
||||||
This exclude the classical extern library with licence:
|
This exclude the classical extern library with licence:
|
||||||
@ -31,33 +31,37 @@ This exclude the classical extern library with licence:
|
|||||||
:** GPL
|
:** GPL
|
||||||
[/note]
|
[/note]
|
||||||
|
|
||||||
==== License (BSD) ====
|
==== License (APACHE 2) ====
|
||||||
Redistribution and use in source and binary forms, with or without
|
Copyright ewol Edouard DUPIN
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
|
|
||||||
:** Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
:** Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
you may not use this file except in compliance with the License.
|
||||||
:** The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
[[http://www.apache.org/licenses/LICENSE-2.0]]
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
==== Sub library: ====
|
==== Sub library: ====
|
||||||
===== License: =====
|
===== License: =====
|
||||||
:** [b][lib[etk | e-tk]][/b] : BSD 3 clauses
|
:** [b][lib[etk | e-tk]][/b] : APACHE-2
|
||||||
::** [b][lib[linearmath | Linear-Math]][/b] : z-lib (subset of bullet lib)
|
::** [b][lib[linearmath | Linear-Math]][/b] : z-lib (subset of bullet lib)
|
||||||
::** [b][lib[earchive | e-Archive]][/b] : BSD 3 clauses
|
::** [b][lib[earchive | e-Archive]][/b] : APACHE-2
|
||||||
:::** [b][lib[z | Z lib]][/b] : z-lib
|
:::** [b][lib[z | Z lib]][/b] : z-lib
|
||||||
:** [b][lib[egami | e-gami]][/b] : BSD 3 clauses
|
:** [b][lib[egami | e-gami]][/b] : APACHE-2
|
||||||
::** [b][lib[esvg | e-svg]][/b] : BSD 3 clauses
|
::** [b][lib[esvg | e-svg]][/b] : APACHE-2
|
||||||
:::** [b][lib[agg | AGG]][/b] : BSD-like
|
:::** [b][lib[agg | AGG]][/b] : BSD-like
|
||||||
::** [b][lib[png | libPNG]][/b] : PNG
|
::** [b][lib[png | libPNG]][/b] : PNG
|
||||||
:** [b][lib[portaudio | portaudio]][/b] : MIT
|
:** [b][lib[portaudio | portaudio]][/b] : MIT
|
||||||
:** [b][lib[ogg | ogg]][/b] : BSD-like
|
:** [b][lib[ogg | ogg]][/b] : BSD-like
|
||||||
:** [b][lib[freetype | Free-Type]][/b] : BSD-like
|
:** [b][lib[freetype | Free-Type]][/b] : BSD-like
|
||||||
:** [b][lib[ejson | e-json]][/b] : BSD 3 clauses
|
:** [b][lib[ejson | e-json]][/b] : APACHE-2
|
||||||
:** [b][lib[exml | e-xml]][/b] : BSD 3 clauses
|
:** [b][lib[exml | e-xml]][/b] : APACHE-2
|
||||||
|
|
||||||
|
|
||||||
==== Description : ====
|
==== Description : ====
|
||||||
|
@ -48,7 +48,7 @@ Compile software in debug for the curent platform :
|
|||||||
|
|
||||||
You can specify the platform with:
|
You can specify the platform with:
|
||||||
[code style=shell]
|
[code style=shell]
|
||||||
./ewol/build/lutin.py -mdebug -tAndroid
|
./ewol/build/lutin.py -tAndroid -mdebug
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
It coud be usefull to disable the package generation in local debug :
|
It coud be usefull to disable the package generation in local debug :
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
=?= Tutorial 1: Hello Word =?=
|
|
||||||
__________________________________________________
|
|
||||||
[left][tutorial[000_Build | Previous: Download & Build]][/left] [right][tutorial[010_ObjectModel | Next: Object model]][/right]
|
|
||||||
|
|
||||||
=== Objectif ===
|
=== Objectif ===
|
||||||
:** Understand basis of ewol
|
:** Understand basis of ewol
|
||||||
@ -12,12 +9,15 @@ __________________________________________________
|
|||||||
|
|
||||||
A generic Ewol application is manage by creating an [class[ewol::context::Application]] that is the basis of your application.
|
A generic Ewol application is manage by creating an [class[ewol::context::Application]] that is the basis of your application.
|
||||||
|
|
||||||
Due to the fact the ewol librairy is a multi-platform framework, then you need to think all you will do with only one
|
Due to the fact the ewol library is a multi-platform framework, you will have many contraint like:
|
||||||
application and only one windows displayable at the same time.
|
:** One application at the same time
|
||||||
|
:** One Windows displayable at the time
|
||||||
|
:** Not a big CPU ...
|
||||||
|
|
||||||
Then we will create the application:
|
Then we will create the application:
|
||||||
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
|
namespace appl {
|
||||||
class MainApplication : public ewol::context::Application {
|
class MainApplication : public ewol::context::Application {
|
||||||
public:
|
public:
|
||||||
bool init(ewol::Context& _context, size_t _initId) {
|
bool init(ewol::Context& _context, size_t _initId) {
|
||||||
@ -32,42 +32,47 @@ Then we will create the application:
|
|||||||
APPL_INFO("==> Un-Init APPL (END)");
|
APPL_INFO("==> Un-Init APPL (END)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
};
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
The input [class[ewol::Context]] is the main system context.
|
The input [class[ewol::Context]] is the main system context.
|
||||||
|
|
||||||
[note]
|
[note]
|
||||||
It is important to know that the system can call your application in parallele, the basic exemple of this is the Wallpaper on Android.
|
It is important to know that the system can create your application multiple times, the basic exemple of this is the Wallpaper on Android.
|
||||||
|
|
||||||
What is done:
|
What is done:
|
||||||
** When selected, it create an intance and when it is apply Android create a new instance and remove the previous one...
|
** When we select the wallpaper it create a new application (to show an example)
|
||||||
|
** When applying your choice, it create the real one an remove the previous one.
|
||||||
[/note]
|
[/note]
|
||||||
|
|
||||||
In all program we need to have a main()
|
In all program we need to have a main()
|
||||||
|
|
||||||
To be portable on Android, that have a java main the User might the Wrapper call the generic main() (please do not add other things in this main).
|
To be portable on Android, the "main" in the java might call your main through the Android wrapper.
|
||||||
|
|
||||||
|
To simplify compabilities between platform it is recommanded to not add other things in the application main:
|
||||||
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
// only one things to do :
|
// only one things to do :
|
||||||
return ewol::run(new MainApplication(), _argc, _argv);
|
return ewol::run(new appl::MainApplication(), _argc, _argv);
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
|
||||||
==== Some configuration are needed ====
|
==== Some configuration are needed ====
|
||||||
|
|
||||||
In your application you can use many configuration,
|
In your application you can use many configuration, it is really better to set all your configuration dynamic.
|
||||||
none of them are set in static for compilation and interface reason,
|
With this basic condiction will simplify the interface of the library if you would have many different application
|
||||||
then you will to set it on dynamic.
|
(never forger the compilator garbage collector is really very efficient).
|
||||||
|
|
||||||
|
|
||||||
Select fonts:
|
|
||||||
|
[b]Select fonts:[/b]
|
||||||
|
|
||||||
This can be a problem when you design an application for some other operating system (OS),
|
This can be a problem when you design an application for some other operating system (OS),
|
||||||
They do not have the same default font.
|
They do not have the same default font.
|
||||||
|
|
||||||
And we select an order to search the font names and the system basic size.
|
We select an order to search the font names and the system basic size.
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
// Use External font depending on the system (for specific application, it is better to provide fonts)
|
// Use External font depending on the system (for specific application, it is better to provide fonts)
|
||||||
_context.getFontDefault().setUseExternal(true);
|
_context.getFontDefault().setUseExternal(true);
|
||||||
@ -80,7 +85,7 @@ And we select an order to search the font names and the system basic size.
|
|||||||
|
|
||||||
Create the main Windows:
|
Create the main Windows:
|
||||||
|
|
||||||
For this point we will create a class that herited form the basic windows class:
|
For this point we will create a class that herited form the basic [class[ewol::wiget::Windows]] class:
|
||||||
|
|
||||||
[b]Windows.h[/b]
|
[b]Windows.h[/b]
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
@ -91,14 +96,19 @@ For this point we will create a class that herited form the basic windows class:
|
|||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
class Windows : public ewol::widget::Windows {
|
class Windows : public ewol::widget::Windows {
|
||||||
public:
|
protected:
|
||||||
Windows(void);
|
Windows(void);
|
||||||
|
init()
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(Windows);
|
||||||
virtual ~Windows(void) {};
|
virtual ~Windows(void) {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
See [tutorial[010_ObjectModel | Next: Object model]] to understand why this structure is so complex.
|
||||||
|
|
||||||
[b]Windows.cpp[/b]
|
[b]Windows.cpp[/b]
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
#include <ewol/ewol.h>
|
#include <ewol/ewol.h>
|
||||||
@ -110,8 +120,13 @@ For this point we will create a class that herited form the basic windows class:
|
|||||||
#define __class__ "Windows"
|
#define __class__ "Windows"
|
||||||
|
|
||||||
appl::Windows::Windows(void) {
|
appl::Windows::Windows(void) {
|
||||||
|
// To simplify log (if you have a better solution, I am aware)
|
||||||
|
addObjectType("appl::Windows");
|
||||||
|
}
|
||||||
|
appl::Windows::init(void) {
|
||||||
|
ewol::widget::Windows::init();
|
||||||
setTitle("example 001_HelloWord");
|
setTitle("example 001_HelloWord");
|
||||||
ewol::object::Shared<ewol::widget::Label> tmpWidget = new ewol::widget::Label();
|
std::shared_ptr<ewol::widget::Label> tmpWidget = ewol::widget::Label::create();
|
||||||
if (NULL == tmpWidget) {
|
if (NULL == tmpWidget) {
|
||||||
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||||
} else {
|
} else {
|
||||||
@ -122,6 +137,11 @@ For this point we will create a class that herited form the basic windows class:
|
|||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
The init function can not be virtual due to his polymorphic status, then we need to call parrent init
|
||||||
|
[code style=c++]
|
||||||
|
ewol::widget::Windows::init();
|
||||||
|
[/code]
|
||||||
|
|
||||||
The fist basic property to set is the Title:
|
The fist basic property to set is the Title:
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
setTitle("example 001_HelloWord");
|
setTitle("example 001_HelloWord");
|
||||||
@ -130,14 +150,17 @@ The fist basic property to set is the Title:
|
|||||||
After we simple create a [class[widget::Label]] in the main windows constructor.
|
After we simple create a [class[widget::Label]] in the main windows constructor.
|
||||||
And we set the widget property (label).
|
And we set the widget property (label).
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
ewol::object::Shared<ewol::widget::Label> tmpWidget = ewol::object::makeShared(new ewol::widget::Label());
|
std::shared_ptr<ewol::widget::Label> tmpWidget = ewol::widget::Label::create();
|
||||||
tmpWidget->setLabel("Hello <font color=\"blue\">Word</font>");
|
tmpWidget->setLabel("Hello <font color='blue'>Word</font>");
|
||||||
tmpWidget->setExpand(bvec2(true,true));
|
tmpWidget->setExpand(bvec2(true,true));
|
||||||
[/code]
|
[/code]
|
||||||
We can se in this example that the label have some other property like the font color.
|
We can see in this example that the label have some other property like the font color.
|
||||||
|
|
||||||
|
|
||||||
The label can have decorated text based on the html generic writing but it is composed with really simple set of balise.
|
The label can have decorated text based on the html generic writing but it is composed with really simple set of balise.
|
||||||
I will take a really long time to create a real html parser, the the availlable property is:
|
I will take a really long time to create a real html parser.
|
||||||
|
|
||||||
|
The availlable property is:
|
||||||
:** [b]<br/>[/b] : New line
|
:** [b]<br/>[/b] : New line
|
||||||
:** [b]<font color="#FF0000\"> ... </font>[/b] : change the font color.
|
:** [b]<font color="#FF0000\"> ... </font>[/b] : change the font color.
|
||||||
:** [b]<center> ... </center>[/b] : center the text.
|
:** [b]<center> ... </center>[/b] : center the text.
|
||||||
@ -156,6 +179,7 @@ The last step is to add the widget on the windows :
|
|||||||
[code style=c++]
|
[code style=c++]
|
||||||
setSubWidget(tmpWidget);
|
setSubWidget(tmpWidget);
|
||||||
[/code]
|
[/code]
|
||||||
|
When we call this function, it use the shard_from_this() function that create an exception if we are in constructor
|
||||||
|
|
||||||
|
|
||||||
==== Configure Ewol to have display the windows ====
|
==== Configure Ewol to have display the windows ====
|
||||||
@ -164,10 +188,12 @@ At this point we have created the basic windows.
|
|||||||
But the system does not know it.
|
But the system does not know it.
|
||||||
Then we create windows and set it in the main contect main (in the MainApplication::init()):
|
Then we create windows and set it in the main contect main (in the MainApplication::init()):
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
ewol::object::Shared<ewol::Windows> basicWindows = ewol::object::makeShared(new appl::Windows());
|
std::shared_ptr<ewol::Windows> basicWindows = appl::Windows::create());
|
||||||
// create the specific windows
|
// create the specific windows
|
||||||
_context.setWindows(basicWindows);
|
_context.setWindows(basicWindows);
|
||||||
[/code]
|
[/code]
|
||||||
|
Her we call the create function that is created by the DECLARE_FACTORY macro
|
||||||
|
|
||||||
|
|
||||||
Then the init fuction is :
|
Then the init fuction is :
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
@ -177,7 +203,7 @@ bool MainApplication::init(ewol::Context& _context, size_t _initId) {
|
|||||||
_context.getFontDefault().setUseExternal(true);
|
_context.getFontDefault().setUseExternal(true);
|
||||||
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
|
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
|
||||||
|
|
||||||
ewol::Windows* basicWindows = new appl::Windows();
|
std::shared_ptr<ewol::Windows> basicWindows = appl::Windows::create();
|
||||||
// create the specific windows
|
// create the specific windows
|
||||||
_context.setWindows(basicWindows);
|
_context.setWindows(basicWindows);
|
||||||
APPL_INFO("==> Init APPL (END)");
|
APPL_INFO("==> Init APPL (END)");
|
||||||
@ -245,9 +271,9 @@ I do not explain again the lutin file, for next tutorial, show example sources .
|
|||||||
|
|
||||||
=== Build your application ===
|
=== Build your application ===
|
||||||
|
|
||||||
go to your workspace folder and launch
|
Go to your workspace folder and launch
|
||||||
[code style=shell]
|
[code style=shell]
|
||||||
./ewol/build/lutin.py -C -mdebug -p 001_HelloWord
|
./ewol/build/lutin.py -C -mdebug 001_HelloWord
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
Your program example will build correctly...
|
Your program example will build correctly...
|
||||||
@ -259,13 +285,14 @@ Launch it :
|
|||||||
|
|
||||||
The [b]-l6[/b] is used to specify the Log level of the application display (this log is synchronous)
|
The [b]-l6[/b] is used to specify the Log level of the application display (this log is synchronous)
|
||||||
|
|
||||||
|
|
||||||
The output compile in a separate folder depending on the compilation tool (gcc or clang)
|
The output compile in a separate folder depending on the compilation tool (gcc or clang)
|
||||||
|
|
||||||
|
|
||||||
It create a complete final tree in the ./out/Linux/debug/staging/gcc/001_HelloWord/ folder
|
It create a complete final tree in the ./out/Linux/debug/staging/gcc/001_HelloWord/ folder
|
||||||
|
|
||||||
The final folder contain the package generated
|
|
||||||
|
|
||||||
tree of the output
|
The final folder contain the package generated:
|
||||||
:** out
|
:** out
|
||||||
::** MacOs
|
::** MacOs
|
||||||
::** Android
|
::** Android
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
=?= Tutorial 2: Object Model =?=
|
|
||||||
__________________________________________________
|
|
||||||
[left][tutorial[001_HelloWord | Previous: Hello Word]][/left] [right][tutorial[011_ObjectConfig | Next: Object config]][/right]
|
|
||||||
|
|
||||||
=== Objectif ===
|
=== Objectif ===
|
||||||
:** Understand ewol basic [class[ewol::Object]]
|
:** Understand ewol basic [class[ewol::Object]]
|
||||||
:** Use [class[ewol::Object]] correctly
|
:** Use [class[ewol::Object]] correctly
|
||||||
|
|
||||||
== Basis of the Object ==
|
== Basis of the ewol::Object ==
|
||||||
|
|
||||||
An object in Ewol is a simple class : [class[ewol::Object]] This object is the basis of all element in the ewol system.
|
An object in Ewol is a simple class : [class[ewol::Object]] This object is the basis of all element in the ewol system.
|
||||||
This is designed to manage basis element of complexe structure:
|
This is designed to manage many common things:
|
||||||
|
|
||||||
:** Unique ID
|
:** Unique ID
|
||||||
:** Name
|
:** Name
|
||||||
:** Configuration (decriptive naming of parameters)
|
:** Parameters
|
||||||
:** Event generation and receving
|
:** Signal generation
|
||||||
:** Xml configuration
|
:** Xml configuration
|
||||||
:** Delayed removing
|
:** Removing
|
||||||
|
:** Perodic calling
|
||||||
|
|
||||||
[note]
|
[note]
|
||||||
Please do not compare with the gObject basic class...
|
Please do not compare with the gObject basic class...
|
||||||
@ -25,130 +23,86 @@ Please do not compare with the gObject basic class...
|
|||||||
|
|
||||||
== Create an Object: ==
|
== Create an Object: ==
|
||||||
|
|
||||||
In theory you can use a simple new on an object, but you need to remove the refcounting of this one by yoursef ... really awfull.
|
Creating an object is really simple:
|
||||||
|
|
||||||
It is really better to use the ewol::object::Shared<> declaration to auto manage it. (same as std::shared_ptr)
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
ewol::object::Shared<widget::Label> tmpObject = ewol::object::makeShared(new widget::Label());
|
std::shared_ptr<ewol::Button> tmpButon = ewol::Button::create();
|
||||||
if (tmpObject == NULL) {
|
APPL_INFO("We just create a button widget with unique ID=" << tmpButon->getId() << " name='" << tmpButon->getName() << "'");
|
||||||
APPL_ERROR("An error occured");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
The object register itself on the object manager, now it will have a specific Id and no name
|
Note that all object created are std::shared_ptr.
|
||||||
|
|
||||||
Force the set of the name :
|
|
||||||
|
Set the name of the object:
|
||||||
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
tmpObject->setName("my widget name");
|
tmpButon->setName("my widget name");
|
||||||
APPL_INFO("We just create an Object with ID=" << tmpObject->getId() << " name='" << tmpObject->getName() << "'");
|
APPL_INFO("We just create an Object with ID=" << tmpButon->getId() << " name='" << tmpButon->getName() << "'");
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
|
||||||
== Remove an Object: ==
|
== Remove an Object: ==
|
||||||
|
|
||||||
This is important to note that many element can have a reference on the Object.
|
Simply use the function:
|
||||||
|
|
||||||
Then we need to use the fuction:
|
|
||||||
[b]removeObject()[/b] to remove the Object, This will notify avery object in the system that this
|
|
||||||
specific object has been removed.
|
|
||||||
|
|
||||||
|
|
||||||
Then to remove an object call:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
tmpObject->removeObject();
|
tmpButon->destroy();
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
On every object we can have an herited function: [b]virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject);[/b]
|
This function request his parrent to remove the std::shared_ptr it keep on it.
|
||||||
|
And when all std::shared_ptr is removed the object will be really removed.
|
||||||
|
|
||||||
|
At his point we can think an object is allive all the time someone keep a reference on it, then when you are not a parrent of the object, do not keep a std::shared_ptr but a std::weak_ptr.
|
||||||
We need to implement this fuction to be notify an object is removed:
|
|
||||||
[code style=c++]
|
|
||||||
void namespeceName::ClassName::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) {
|
|
||||||
// Never forget to call upper Object (otherwise many object will keep theire reference)
|
|
||||||
upperClass::onObjectRemove(_removeObject);
|
|
||||||
if (_removeObject == m_object) {
|
|
||||||
m_object.reset();
|
|
||||||
markToRedraw(); // set only for graphical object ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
[note]
|
[note]
|
||||||
If you have well follow the idea, you will never declare an object in local, just use shared pointer on them.
|
If some Object is not removed when you close the application, the system inform you with displaying all object already alive.
|
||||||
[/note]
|
[/note]
|
||||||
|
|
||||||
[note]
|
|
||||||
For some case it could be interesting to see the [class[ewol::object::Owner<T>]] class that provide an automatic auto remove of object.
|
|
||||||
|
|
||||||
See [class[ewol::widget::Container]] for an example.
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
|
|
||||||
=== Particularity ===
|
|
||||||
|
|
||||||
An object can remove itself, just use the function:
|
|
||||||
[code style=c++]
|
|
||||||
autoDestroy();
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
|
|
||||||
== Retrieve an Object: ==
|
== Retrieve an Object: ==
|
||||||
|
|
||||||
In Ewol this is possible to get a object with his name.
|
In Ewol this is possible to get a object with his name.
|
||||||
This is really simple.
|
|
||||||
|
|
||||||
=== In an Object ===
|
=== Find a global Object (ouside an Object) ===
|
||||||
|
|
||||||
Call a simple function define in the Object:
|
|
||||||
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
#include <ewol/object/Manager.h>
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
ewol::object::Shared<ewol::Object> tmpObject = getObjectManager().get("name of the object");
|
|
||||||
if (tmpObject == NULL) {
|
|
||||||
APPL_ERROR("The Object does not exist");
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
=== Not in an Object ===
|
|
||||||
|
|
||||||
In this case, we need to get the context manager and after the object manager:
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
#include <ewol/object/Manager.h>
|
|
||||||
#include <ewol/context/Context.h>
|
#include <ewol/context/Context.h>
|
||||||
|
|
||||||
...
|
std::shared_ptr<ewol::Object> tmpObject = ewol::getContext().getEObjectManager().getObjectNamed("obj Name");
|
||||||
|
|
||||||
ewol::object::Shared<ewol::Object> tmpObject = ewol::getContext().getObjectManager().get("name of the object");
|
|
||||||
if (tmpObject == NULL) {
|
if (tmpObject == NULL) {
|
||||||
APPL_ERROR("The Object does not exist");
|
APPL_ERROR("The Object does not exist");
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
=== Casting your object ===
|
=== Find a global Object (inside an Object) ===
|
||||||
|
|
||||||
|
[code style=c++]
|
||||||
|
std::shared_ptr<ewol::Object> tmpObject = getObjectNamed("obj Name");
|
||||||
|
if (tmpObject == NULL) {
|
||||||
|
APPL_ERROR("The Object does not exist");
|
||||||
|
}
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
=== Find a sub-object ===
|
||||||
|
|
||||||
|
[code style=c++]
|
||||||
|
std::shared_ptr<ewol::Object> tmpObject = getSubObjectNamed("obj Name");
|
||||||
|
if (tmpObject == NULL) {
|
||||||
|
APPL_ERROR("The Object does not exist");
|
||||||
|
}
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
=== retriving your object type ===
|
||||||
|
|
||||||
It could be really interesting to retrive your own instance:
|
It could be really interesting to retrive your own instance:
|
||||||
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
ewol::object::Shared<ewol::Object> tmpObject ...;
|
std::shared_ptr<ewol::Object> tmpObject ...;
|
||||||
|
|
||||||
ewol::object::Shared<appl::MyOwnObject> myObject = ewol::dynamic_pointer_cast<appl::MyOwnObject>(tmpObject);
|
std::shared_ptr<appl::MyOwnObject> myObject = std::dynamic_pointer_cast<appl::MyOwnObject>(tmpObject);
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
== conclusion ==
|
== conclusion ==
|
||||||
|
|
||||||
If you follow these rules, you will not have memory leek and no segmentation fault on the ewol system.
|
TODO ...
|
||||||
|
|
||||||
[note]
|
|
||||||
To be sure that the name is unique, just add the current creator object Id in the name.
|
|
||||||
|
|
||||||
See [class[ewol::widget::FileChooser]] class for an example.
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,153 +1,98 @@
|
|||||||
=?= Tutorial 3: Object Config =?=
|
|
||||||
__________________________________________________
|
|
||||||
[left][tutorial[010_ObjectModel | Previous: Object model]][/left] [right][tutorial[012_ObjectMessage | Next: Object message]][/right]
|
|
||||||
|
|
||||||
=== Objectif ===
|
=== Objectif ===
|
||||||
:** Understand ewol::Object configuration parameter
|
:** Understand ewol::Object configuration parameter
|
||||||
:** Create an configurable object
|
:** Create an configurable object
|
||||||
|
|
||||||
== Use of Configuration ==
|
== Configuration using ==
|
||||||
|
|
||||||
Configuration are parameters to set some property on an object,
|
All [class[ewol::Object]] have a configuration of parameters (the object name is a parameter), Then we need to set get and use xml to update parameters.
|
||||||
this is a really generic use in many system,
|
|
||||||
this is the reason why we implement one.
|
|
||||||
|
|
||||||
|
=== Set a Parameter ===
|
||||||
|
|
||||||
This is a generic interface to set and get parameter,
|
[note]
|
||||||
when you did not really know it,
|
Using getter and setter is really better, and faster.
|
||||||
but it generate many convertion to string search and many other things...
|
[/note]
|
||||||
|
|
||||||
If you know the object just interact with it with his own accessors (faster ond conpilation check).
|
==== With a string configuration ====
|
||||||
|
|
||||||
|
|
||||||
=== Set config ===
|
|
||||||
|
|
||||||
When you have the pointer on the object:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
if (tmpObject->setConfig("name", "new name of object") == false) {
|
if (tmpObject->parameterSet("name", "new name of object") == false) {
|
||||||
APPL_ERROR("Can not set object property");
|
APPL_ERROR("Can not set object parameter");
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
A second methode is to request the name with his direct config name:
|
==== whith the object name ====
|
||||||
[code style=c++]
|
|
||||||
// to be sure that the name exist:
|
|
||||||
if (tmpObject->setConfig(ewol::Object::configName, "new name of object") == false) {
|
|
||||||
APPL_ERROR("Can not set object property");
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
The only aventage here is to have an automatic update on the name of the parameter.
|
|
||||||
|
|
||||||
It is possible to configure an object whitout knowing his name:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
// in an ewol::Object only ...
|
if (parameterSetOnWidgetNamed("objectName", "value", "16.2") == false) {
|
||||||
if (setConfigNamed("object name", "ewol::Object::configName, "new name of object") == false) {
|
APPL_ERROR("Can not set object parameter");
|
||||||
APPL_ERROR("Can not set object property");
|
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
=== Get Parameter ===
|
||||||
|
|
||||||
=== Get config ===
|
|
||||||
|
|
||||||
Direct get the configuration:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
std::string val = tmpObject->getConfig("name");
|
std::string val = tmpObject->parameterGet("name");
|
||||||
APPL_INFO("Get Object property : name='" << val << "'");
|
APPL_INFO("Get Object property : name='" << val << "'");
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
Get with his direct definition name:
|
|
||||||
[code style=c++]
|
|
||||||
std::string val = tmpObject->getConfig(ewol::Object::configName);
|
|
||||||
APPL_INFO("Get Object property : " << ewol::Object::configName << "'" << val << "'");
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
|
|
||||||
== Implement configuration ==
|
== Implement configuration ==
|
||||||
|
|
||||||
=== Declare config ===
|
|
||||||
|
|
||||||
In the header file:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
#include <ewol/object/Object.h>
|
#include <ewol/object/Object.h>
|
||||||
namespace appl {
|
namespace appl {
|
||||||
class MyObj : public ewol::Object {
|
class MyObj : public ewol::Object {
|
||||||
public:
|
protected:
|
||||||
// Config list of properties
|
|
||||||
static const char* const configValue;
|
|
||||||
public:
|
|
||||||
//! @brief Constructor
|
//! @brief Constructor
|
||||||
MyObj(void);
|
MyObj(void) :
|
||||||
|
m_value(*this, "value", false, "Value of the parameter (descrition string)") {
|
||||||
|
// nothing to do..
|
||||||
|
}
|
||||||
|
void init() {
|
||||||
|
ewol::Object::init();
|
||||||
|
}
|
||||||
|
public:
|
||||||
//! @brief Destructor
|
//! @brief Destructor
|
||||||
virtual ~MyObj(void);
|
virtual ~MyObj(void) { }
|
||||||
|
DECLARE_FACTORY(MyObj);
|
||||||
private:
|
private:
|
||||||
bool m_value; //!< Internal Object value
|
ewol::object::Param<bool> m_value; //!< Internal Object value
|
||||||
public:
|
public:
|
||||||
//! @brief Setter
|
//! @brief Setter
|
||||||
void setValue(bool _val) {
|
void setValue(bool _val) {
|
||||||
m_value = _val;
|
m_value.set(_val);
|
||||||
}
|
}
|
||||||
//! @brief Getter
|
//! @brief Getter
|
||||||
bool getValue(void) const {
|
bool getValue() const {
|
||||||
return m_value;
|
return m_value.get();
|
||||||
}
|
}
|
||||||
public: // herited function:
|
public: // herited function:
|
||||||
bool onSetConfig(const ewol::object::Config& _conf);
|
void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer) {
|
||||||
|
if (_paramPointer == m_value) {
|
||||||
|
APPL_DEBUG("The internal value has change, new value is : '" << m_value.get() << "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
[note]
|
In the contructor we need to add:
|
||||||
By convention declare config started with "configXXXXXX"
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
In the source file:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
// Declare the configuration Name:
|
m_value(*this, "value", false, "Value of the parameter (descrition string)")
|
||||||
const char* const appl::MyObj::configValue = "value";
|
|
||||||
|
|
||||||
appl::MyObj::MyObj(void) {
|
|
||||||
// declare the configuration on this object:
|
|
||||||
registerConfig(configValue, "bool", NULL, "object configuration description");
|
|
||||||
// Note : This API is not compleately define ...
|
|
||||||
}
|
|
||||||
appl::MyObj::~MyObj(void) {
|
|
||||||
// nothing to do ...
|
|
||||||
}
|
|
||||||
[/code]
|
[/code]
|
||||||
Now an extern Object can register configure these parameter, otherwise, they will be rejected!!!
|
:** [b]'*this':[/b] Reference the main class to call it chen value change.
|
||||||
|
:** [b]"value":[/b] Is the name of the parameter.
|
||||||
|
:** [b]false:[/b] The default value.
|
||||||
|
:** [b]"....."[/b] Description of the parameter (optionnal).
|
||||||
|
|
||||||
|
|
||||||
=== Get and Set config ===
|
The function [b]onParameterChangeValue[/b] is called only the parameter change (no historic has been registered)
|
||||||
|
|
||||||
You can see in these implementation that we not compare the string but just the pointer.
|
The last point is that the m_value.get() is an inline fuction then it take no more CPU cycle to access the value than normal variable.
|
||||||
The ewol::Object convert the string in the correct pointer to be faster in many case.
|
|
||||||
|
|
||||||
==== Set configuration ====
|
Some other parameter are availlable :
|
||||||
|
:** ewol::object::Param<T> Basic parameter.
|
||||||
|
:** ewol::object::ParamRange<T> For numeric parameter that range value are check befor setting new value.
|
||||||
|
:** ewol::object::ParamList<T> For List of parameter values.
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
bool appl::MyObj::onSetConfig(const ewol::object::Config& _conf) {
|
|
||||||
APPL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config : " << _conf);
|
|
||||||
if (_conf.getConfig() == configValue) {
|
|
||||||
setValue(std::stob(_conf.getData()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
==== Get configuration ====
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
bool appl::MyObj::onGetConfig(const char* _config, std::string& _result) const {
|
|
||||||
if (_config == configValue) {
|
|
||||||
_result = std::to_string(getValue());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
== Conclusion ==
|
|
||||||
|
|
||||||
Now you can choice the methode you want in your application to implement your basic configuration feature.
|
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
=?= Tutorial 4: Object Message =?=
|
|
||||||
__________________________________________________
|
|
||||||
[left][tutorial[011_ObjectConfig | Previous: Object config]][/left] [right][tutorial[020_FileAccess | Next: File Access]][/right]
|
|
||||||
|
|
||||||
=== Objectif ===
|
=== Objectif ===
|
||||||
:** Understand ewol::Object Messaging system
|
:** Understand ewol::Object Messaging system
|
||||||
@ -8,123 +5,164 @@ __________________________________________________
|
|||||||
|
|
||||||
== Message system ==
|
== Message system ==
|
||||||
|
|
||||||
The message system is a simple message sending between Object.
|
Message system is based on generic std::funtion and std::bind methode:
|
||||||
This is composed with a pointer (const char* const) that represent the mesage ID (pointer, then unique)
|
|
||||||
and a value (std::string)
|
|
||||||
|
|
||||||
The message are broadcast or multicast on object watcher.
|
It permit to an object to generate some [b]'signals'[/b].
|
||||||
|
|
||||||
== Receive Message from other object ==
|
All signal are synchronous
|
||||||
|
|
||||||
=== Register on message ===
|
|
||||||
|
|
||||||
We will se an example on the widget : [class[ewol::widget::Button]]
|
== Receive signals from other object ==
|
||||||
|
|
||||||
By default the messageID is the event generated, But to overwrite this message Id just create a new one:
|
[todo]
|
||||||
|
Link with the signal name
|
||||||
|
[/todo]
|
||||||
|
|
||||||
|
Register on the 'up' and 'value' signal of a button:
|
||||||
|
|
||||||
|
Button header :
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
// on the global on the file or in private class member:
|
...
|
||||||
static const char* const g_backMessage = "local-event-button-pressed";
|
public:
|
||||||
static const char* const g_backMessageValue = "local-event-button-value";
|
ewol::object::Signal<void> signalDown;
|
||||||
static const char* const g_backMessageDataOverWritte = "local-event-button-data";
|
ewol::object::Signal<void> signalUp;
|
||||||
|
...
|
||||||
|
ewol::object::Signal<bool> signalValue;
|
||||||
|
...
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
=== simple signal connection: ===
|
||||||
Register with his name:
|
|
||||||
[code style=c++]
|
|
||||||
registerOnEvent(this, "pressed", g_backMessage);
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
Register with his direct name:
|
|
||||||
[code style=c++]
|
|
||||||
registerOnEvent(this, ewol::widget::Button::eventValue, g_backMessageValue);
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
It is possible to overwrote the data send by the Object :
|
|
||||||
[code style=c++]
|
|
||||||
registerOnEvent(this, ewol::widget::Button::eventPressed, g_backMessageDataOverWritte, "Data we want to receive");
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
|
|
||||||
=== Receive message ===
|
|
||||||
|
|
||||||
To receive message from other widget, just implement this function:
|
|
||||||
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
void appl::ObjectName::onReceiveMessage(const ewol::object::Message& _msg) {
|
#include <ewol/widget/Button.h>
|
||||||
APPL_INFO("Receive Event : " << _msg);
|
namespace appl {
|
||||||
if (_msg.getMessage() == g_backMessage) {
|
class MyObj : public ewol::Object {
|
||||||
// process here
|
private:
|
||||||
return;
|
std::shared_ptr<ewol::widget::Button> m_button;
|
||||||
}
|
protected:
|
||||||
if (_msg.getMessage() == g_backMessageValue) {
|
//! @brief Constructor
|
||||||
APPL_INFO("message value: '" << _msg.getData() << "'");
|
MyObj(void) {
|
||||||
return;
|
// nothing to do..
|
||||||
}
|
}
|
||||||
if (_msg.getMessage() == g_backMessageDataOverWritte) {
|
void init() {
|
||||||
APPL_INFO("Overwrite message data: '" << _msg.getData() << "'");
|
ewol::Object::init();
|
||||||
return;
|
m_button = ewol::widget::Button::Create();
|
||||||
|
if (m_button == nullptr) {
|
||||||
|
APPL_ERROR("Can not create button...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// We connect signals here :
|
||||||
|
m_button->signalUp.bind(shared_from_this(), &appl::MyObj::onCallbackUp);
|
||||||
|
m_button->signalValue.bind(shared_from_this(), &appl::MyObj::onCallbackValue);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
//! @brief Destructor
|
||||||
|
virtual ~MyObj(void) { }
|
||||||
|
DECLARE_FACTORY(MyObj);
|
||||||
|
private:
|
||||||
|
void onCallbackUp() {
|
||||||
|
APPL_INFO("button pressed: UP);
|
||||||
|
}
|
||||||
|
void onCallbackValue(const bool& _value) {
|
||||||
|
APPL_INFO("button value: " << _value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
|
|
||||||
== Declare Extern Message ==
|
=== Advenced signal connection: ===
|
||||||
|
|
||||||
=== Declare Message ===
|
Here we will see how to connect an advance function on a signal
|
||||||
|
|
||||||
In the header file:
|
|
||||||
[code style=c++]
|
[code style=c++]
|
||||||
#include <ewol/object/Object.h>
|
#include <ewol/object/Object.h>
|
||||||
|
#include <ewol/widget/Button.h>
|
||||||
|
namespace appl {
|
||||||
|
class MyObj : public ewol::Object {
|
||||||
|
private:
|
||||||
|
std::shared_ptr<ewol::widget::Button> m_button;
|
||||||
|
protected:
|
||||||
|
//! @brief Constructor
|
||||||
|
MyObj(void) {
|
||||||
|
// nothing to do..
|
||||||
|
}
|
||||||
|
void init() {
|
||||||
|
ewol::Object::init();
|
||||||
|
m_button = ewol::widget::Button::Create();
|
||||||
|
if (m_button == nullptr) {
|
||||||
|
APPL_ERROR("Can not create button...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// We connect signals here :
|
||||||
|
m_button->signalUp.register(shared_from_this(), std::bind(&appl::MyObj::onCallbackUp, this, std::string("tmpVariableToSend")));
|
||||||
|
m_button->signalValue.register(shared_from_this(), std::bind(&appl::MyObj::onCallbackValue, this));
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
//! @brief Destructor
|
||||||
|
virtual ~MyObj(void) { }
|
||||||
|
DECLARE_FACTORY(MyObj);
|
||||||
|
private:
|
||||||
|
void onCallbackUp(const std::string& _value) {
|
||||||
|
APPL_INFO("button pressed: UP inputMessage: " << _value);
|
||||||
|
}
|
||||||
|
void onCallbackValue() {
|
||||||
|
APPL_INFO("button value: " << _value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
=== Connect to a signal with a named widget ===
|
||||||
|
|
||||||
|
TODO: documentation :
|
||||||
|
:** subBind(_type, _name, _event, _obj, _func)
|
||||||
|
:** globalBind(_type, _name, _event, _obj, _func)
|
||||||
|
:** externSubBind(_object, _type, _name, _event, _obj, _func)
|
||||||
|
|
||||||
|
|
||||||
|
== Declare Signal ==
|
||||||
|
|
||||||
|
=== source ===
|
||||||
|
|
||||||
|
[code style=c++]
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
#include <ewol/widget/Button.h>
|
||||||
namespace appl {
|
namespace appl {
|
||||||
class MyObj : public ewol::Object {
|
class MyObj : public ewol::Object {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
ewol::object::Signal<void> signalEmpty;
|
||||||
static const char* const eventValue;
|
ewol::object::Signal<bool> signalBoolean;
|
||||||
public:
|
ewol::object::Signal<std::string> signalString;
|
||||||
|
protected:
|
||||||
//! @brief Constructor
|
//! @brief Constructor
|
||||||
MyObj(void);
|
MyObj(void) :
|
||||||
|
signalEmpty(*this, "empty"),
|
||||||
|
signalBoolean(*this, "boolean"),
|
||||||
|
signalString(*this, "string") {
|
||||||
|
// nothing to do..
|
||||||
|
}
|
||||||
|
void init() {
|
||||||
|
ewol::Object::init();
|
||||||
|
}
|
||||||
|
public:
|
||||||
//! @brief Destructor
|
//! @brief Destructor
|
||||||
virtual ~MyObj(void);
|
virtual ~MyObj(void) { }
|
||||||
|
DECLARE_FACTORY(MyObj);
|
||||||
|
private:
|
||||||
|
void process() {
|
||||||
|
signalEmpty.emit();
|
||||||
|
signalBoolean.emit(false);
|
||||||
|
signalString.emit("plop... plop");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
[note]
|
|
||||||
By convention declare events started with "eventXXXXXX"
|
|
||||||
[/note]
|
|
||||||
|
|
||||||
In the source file:
|
|
||||||
[code style=c++]
|
|
||||||
// Declare the configuration Name:
|
|
||||||
const char* const appl::MyObj::eventValue = "value";
|
|
||||||
|
|
||||||
appl::MyObj::MyObj(void) {
|
|
||||||
// declare Event generated on this object:
|
|
||||||
addEventId(eventValue);
|
|
||||||
}
|
|
||||||
appl::MyObj::~MyObj(void) {
|
|
||||||
// nothing to do ...
|
|
||||||
}
|
|
||||||
[/code]
|
|
||||||
Now an extern Object can register event on this object, otherwise, they will be rejected!!!
|
|
||||||
|
|
||||||
|
|
||||||
=== Generate Message ===
|
|
||||||
|
|
||||||
Now we have register object message, We need to have generated it, This is really simple :
|
|
||||||
|
|
||||||
[code style=c++]
|
|
||||||
// with no data:
|
|
||||||
generateEventId(eventValue);
|
|
||||||
// With a custom data:
|
|
||||||
generateEventId(eventValue, "My sring custom data ...");
|
|
||||||
[/code]
|
|
||||||
|
|
||||||
|
|
||||||
== Conclusion ==
|
== Conclusion ==
|
||||||
|
|
||||||
You will now able to generate event between objects...
|
You will now able to reise signals between objects...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
=?= Tutorial 5: File Access =?=
|
|
||||||
__________________________________________________
|
|
||||||
[left][tutorial[012_ObjectMessage | Previous: Object message]][/left] [right][tutorial[021_Resources | Next: Resources management]][/right]
|
|
||||||
|
|
||||||
=== Objectif ===
|
=== Objectif ===
|
||||||
:** Understand why we wrap interface on file system
|
:** Understand why we wrap interface on file system
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
=== Objectifs ===
|
||||||
|
:** Understand What is a resource
|
||||||
|
:** Use resources
|
||||||
|
|
||||||
|
=== What is a resource: ===
|
||||||
|
|
||||||
|
A resource is an usique element that can be used by manny element like:
|
||||||
|
:** An image (special resolution)
|
||||||
|
:** A configuration file
|
||||||
|
:** An application manager (special case)
|
||||||
|
:** A sound file
|
||||||
|
:** ...
|
||||||
|
|
||||||
|
A resource have an other objective, form some platform, the graphic interface can be stopped, then we need to reload texture in the graphic inteface...
|
||||||
|
Then the texture is an other graphic interface.
|
||||||
|
|
||||||
|
=== Get a resource: ===
|
||||||
|
|
||||||
|
For this example we will load a configuration file:
|
||||||
|
[code style=c++]
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
#include <ewol/resource/ConfigFile.h>
|
||||||
|
namespace appl {
|
||||||
|
class MyObj : public ewol::Object {
|
||||||
|
private:
|
||||||
|
std::shared_ptr<ewol::resource::ConfigFile> m_config;
|
||||||
|
int32_t m_configValId;
|
||||||
|
protected:
|
||||||
|
//! @brief Constructor
|
||||||
|
MyObj(void) :
|
||||||
|
m_configValId(-1) {
|
||||||
|
// nothing to do..
|
||||||
|
}
|
||||||
|
void init() {
|
||||||
|
ewol::Object::init();
|
||||||
|
m_config = ewol::resource::ConfigFile::create("DATA:ExapleConfig.json");
|
||||||
|
m_configValId = m_config->request("exampleConfigName");
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
//! @brief Destructor
|
||||||
|
virtual ~MyObj(void) { }
|
||||||
|
DECLARE_FACTORY(MyObj);
|
||||||
|
public:
|
||||||
|
void process() {
|
||||||
|
double value = m_config->getNumber(m_configValId);
|
||||||
|
APPL_DEBUG("example value : " << value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
|
||||||
|
=== Create a new resource: ===
|
||||||
|
|
||||||
|
A resource is a generic [class[ewol::Resource]] that hrited form a generic [class[ewol::Object]], simply change the FACTORY macro in :
|
||||||
|
:** DECLARE_RESOURCE_FACTORY(className) To declare a resource with no name (unique for every creation)
|
||||||
|
:** DECLARE_RESOURCE_NAMED_FACTORY(className) To create a resource that have a specific name. When created, we will find the previous resource with the specify name in the fanctory.
|
||||||
|
:** DECLARE_RESOURCE_SINGLE_FACTORY(className,uniqueName) This is to have a unique resource for all the application (name is specify in the Macro)
|
||||||
|
|
||||||
|
we have now some specific interface to compleate (if needed):
|
||||||
|
|
||||||
|
==== The Resource Level ====
|
||||||
|
|
||||||
|
The resources can be reloaded, then we need to reaload in the good order (level [0 .. 5])
|
||||||
|
|
||||||
|
The resources are loaded fron 0 to 5.
|
||||||
|
|
||||||
|
Then for basic resource :
|
||||||
|
|
||||||
|
[code style=c++]
|
||||||
|
#include <ewol/object/Resource.h>
|
||||||
|
namespace appl {
|
||||||
|
class MyResource : public ewol::Resource {
|
||||||
|
protected:
|
||||||
|
//! @brief Constructor
|
||||||
|
MyResource() :
|
||||||
|
m_configValId(-1) {
|
||||||
|
m_resourceLevel = 4;
|
||||||
|
addObjectType("ewol::MyResource");
|
||||||
|
}
|
||||||
|
void init(const std::& _name) {
|
||||||
|
ewol::Resource::init(_name);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
//! @brief Destructor
|
||||||
|
virtual ~MyResource(void) { }
|
||||||
|
DECLARE_RESOURCE_NAMED_FACTORY(MyResource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
Now we need to implement somme functions:
|
||||||
|
|
||||||
|
To send data on the hardware (openGL):
|
||||||
|
[code style=c++]
|
||||||
|
void updateContext();
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
To remove data from the the hardware (openGL):
|
||||||
|
[code style=c++]
|
||||||
|
void removeContext();
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
When loose hardware (juste update internal state):
|
||||||
|
[code style=c++]
|
||||||
|
void removeContextToLate();
|
||||||
|
[/code]
|
||||||
|
|
||||||
|
When user request to reload all resources (can be usefull when using file type : THEME:GUI:xxx)
|
||||||
|
[code style=c++]
|
||||||
|
void reload();
|
||||||
|
[/code]
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
=== Objectif ===
|
||||||
|
:** What is a Widget
|
||||||
|
:** Simply create a complex Gui
|
||||||
|
|
||||||
|
=== What is a Widget ===
|
||||||
|
|
||||||
|
A widget is a simple entity of a graphical Object. It herited of every [class[ewol::Object]] class with many graphical interface to draw a complex gui.
|
||||||
|
|
||||||
|
We can consider some widget:
|
||||||
|
:** Windows: Main gui interface to display the unique "windows".
|
||||||
|
:** Simple widget: all widget that display somthing.
|
||||||
|
:** Meta widget: Widget composed with some wodget.
|
||||||
|
|
||||||
|
=== Simple load of a widget: ===
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=== Create an interface with a XML form: ===
|
||||||
|
|
||||||
|
|
||||||
|
=== Create in C++ the interface: ===
|
||||||
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
|||||||
=?=Create a custum widget=?=
|
|
||||||
|
|
||||||
To create a custum widget, this is as simple as complex.
|
To create a custum widget, this is as simple as complex.
|
||||||
The first things to do is to choice a methode to display you widget:
|
The first things to do is to choice a methode to display you widget:
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
== Declare object in XML ==
|
== Declare object in XML ==
|
||||||
|
|
||||||
Object can be declared in some XML, (like gui decription), then we need to declare the Object in the system recognition.
|
Object can be declared in some XML, (like gui decription), then we need to declare the Object in the system recognition.
|
||||||
|
@ -299,19 +299,18 @@ std::ostream& ewol::operator <<(std::ostream& _os, const ewol::Dimension& _obj)
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
template<> std::string etk::to_string<ewol::Dimension>(const ewol::Dimension& _obj) {
|
template<> std::string to_string<ewol::Dimension>(const ewol::Dimension& _obj) {
|
||||||
return _obj;
|
return _obj;
|
||||||
}
|
}
|
||||||
template<> std::u32string etk::to_u32string<ewol::Dimension>(const ewol::Dimension& _obj) {
|
template<> std::u32string to_u32string<ewol::Dimension>(const ewol::Dimension& _obj) {
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
}
|
}
|
||||||
|
template<> bool from_string<ewol::Dimension>(ewol::Dimension& _variableRet, const std::string& _value) {
|
||||||
|
_variableRet = ewol::Dimension(_value);
|
||||||
template<> bool etk::from_string<ewol::Dimension>(ewol::Dimension& _variableRet, const std::string& _value) {
|
return true;
|
||||||
_variableRet = ewol::Dimension(_value);
|
}
|
||||||
return true;
|
template<> bool from_string<ewol::Dimension>(ewol::Dimension& _variableRet, const std::u32string& _value) {
|
||||||
}
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
template<> bool etk::from_string<ewol::Dimension>(ewol::Dimension& _variableRet, const std::u32string& _value) {
|
}
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
};
|
||||||
}
|
|
||||||
|
@ -623,20 +623,19 @@ const etk::Color<float>& ewol::compositing::Shaper::getColor(int32_t _id) {
|
|||||||
return m_colorProperty->get(_id);
|
return m_colorProperty->get(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) {
|
||||||
|
return _obj.getSource();
|
||||||
|
}
|
||||||
|
template<> std::u32string to_u32string<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) {
|
||||||
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
template<> bool from_string<ewol::compositing::Shaper>(ewol::compositing::Shaper& _variableRet, const std::string& _value) {
|
||||||
|
_variableRet.setSource(_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
template<> bool from_string<ewol::compositing::Shaper>(ewol::compositing::Shaper& _variableRet, const std::u32string& _value) {
|
||||||
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template<> std::string etk::to_string<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) {
|
|
||||||
return _obj.getSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> std::u32string etk::to_u32string<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) {
|
|
||||||
return etk::to_u32string(etk::to_string(_obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> bool etk::from_string<ewol::compositing::Shaper>(ewol::compositing::Shaper& _variableRet, const std::string& _value) {
|
|
||||||
_variableRet.setSource(_value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
template<> bool etk::from_string<ewol::compositing::Shaper>(ewol::compositing::Shaper& _variableRet, const std::u32string& _value) {
|
|
||||||
return from_string(_variableRet, etk::to_string(_value));
|
|
||||||
}
|
|
@ -23,7 +23,6 @@
|
|||||||
#include <ewol/context/commandLine.h>
|
#include <ewol/context/commandLine.h>
|
||||||
#include <ewol/context/InputManager.h>
|
#include <ewol/context/InputManager.h>
|
||||||
#include <ewol/context/Fps.h>
|
#include <ewol/context/Fps.h>
|
||||||
#include <ewol/object/RemoveEvent.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#define __EWOL_SYSTEM_INPUT_H__
|
#define __EWOL_SYSTEM_INPUT_H__
|
||||||
|
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/object/RemoveEvent.h>
|
|
||||||
|
|
||||||
#define MAX_MANAGE_INPUT (15)
|
#define MAX_MANAGE_INPUT (15)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
std::ostream& ewol::event::operator <<(std::ostream& _os, const ewol::event::Input& _obj) {
|
std::ostream& ewol::event::operator <<(std::ostream& _os, const ewol::event::Input& _obj) {
|
||||||
_os << "{type=" << _obj.getType();
|
_os << "{type=" << _obj.getType();
|
||||||
_os << " status=" << _obj.getStatus();
|
_os << " status=" << _obj.getStatus();
|
||||||
_os << " id=" << _obj.getId();
|
_os << " id=" << etk::to_string(_obj.getId());
|
||||||
_os << " pos=" << _obj.getPos();
|
_os << " pos=" << _obj.getPos();
|
||||||
_os << "}";
|
_os << "}";
|
||||||
return _os;
|
return _os;
|
||||||
|
@ -53,7 +53,6 @@ void ewol::object::Manager::unInit() {
|
|||||||
if (m_eObjectList.size() != 0) {
|
if (m_eObjectList.size() != 0) {
|
||||||
EWOL_ERROR("Have " << m_eObjectList.size() << " active Object");
|
EWOL_ERROR("Have " << m_eObjectList.size() << " active Object");
|
||||||
}
|
}
|
||||||
m_multiCast.clear();
|
|
||||||
m_eObjectList.clear();
|
m_eObjectList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,19 +100,6 @@ std::shared_ptr<ewol::Object> ewol::object::Manager::get(const std::string& _nam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::object::Manager::add(ewol::object::RemoveEvent* _class) {
|
|
||||||
m_removeEventList.push_back(_class);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::object::Manager::rm(ewol::object::RemoveEvent* _class) {
|
|
||||||
for (size_t iii=0; iii<m_removeEventList.size(); ++iii) {
|
|
||||||
if (m_removeEventList[iii] == _class) {
|
|
||||||
m_removeEventList.erase(m_removeEventList.begin() + iii);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<ewol::Object> ewol::object::Manager::getObjectNamed(const std::string& _name) {
|
std::shared_ptr<ewol::Object> ewol::object::Manager::getObjectNamed(const std::string& _name) {
|
||||||
return ewol::object::Manager::get(_name);
|
return ewol::object::Manager::get(_name);
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,12 @@
|
|||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <ewol/object/Object.h>
|
#include <ewol/object/Object.h>
|
||||||
#include <ewol/object/MultiCast.h>
|
|
||||||
#include <ewol/object/RemoveEvent.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class Context;
|
class Context;
|
||||||
namespace object {
|
namespace object {
|
||||||
class Manager {
|
class Manager {
|
||||||
private:
|
private:
|
||||||
std::vector<ewol::object::RemoveEvent*> m_removeEventList;
|
|
||||||
std::vector<std::weak_ptr<ewol::Object>> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
std::vector<std::weak_ptr<ewol::Object>> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
||||||
Context& m_context;
|
Context& m_context;
|
||||||
public:
|
public:
|
||||||
@ -47,15 +44,6 @@ namespace ewol {
|
|||||||
void cleanInternalRemoved();
|
void cleanInternalRemoved();
|
||||||
|
|
||||||
std::shared_ptr<ewol::Object> get(const std::string& _name);
|
std::shared_ptr<ewol::Object> get(const std::string& _name);
|
||||||
private:
|
|
||||||
ewol::object::MultiCast m_multiCast; //!< muticast manager
|
|
||||||
public:
|
|
||||||
ewol::object::MultiCast& multiCast() {
|
|
||||||
return m_multiCast;
|
|
||||||
};
|
|
||||||
|
|
||||||
void add(ewol::object::RemoveEvent* _class);
|
|
||||||
void rm(ewol::object::RemoveEvent* _class);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "object/Message"
|
|
||||||
|
|
||||||
std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::Message& _obj) {
|
|
||||||
_os << "{";
|
|
||||||
if (nullptr != _obj.getMessage()) {
|
|
||||||
_os << "msg=\"" << _obj.getMessage() << "\"";
|
|
||||||
} else {
|
|
||||||
_os << "msg={nullptr}";
|
|
||||||
}
|
|
||||||
_os << " data=\"" << _obj.getData() << "\"}";
|
|
||||||
return _os;
|
|
||||||
}
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EWOL_OBJECT_MESSAGE_H__
|
|
||||||
#define __EWOL_OBJECT_MESSAGE_H__
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
namespace object {
|
|
||||||
class Message {
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ewol::Object> m_callerObject; //!< Caller class.
|
|
||||||
const char* m_event; //!< Event pointer == > unique Id define by the system ...
|
|
||||||
std::string m_data; //!< compositing additionnal message Value.
|
|
||||||
public:
|
|
||||||
Message(const std::shared_ptr<ewol::Object>& _caller,
|
|
||||||
const char* _message,
|
|
||||||
const std::string& _data) :
|
|
||||||
m_callerObject(_caller),
|
|
||||||
m_event(_message),
|
|
||||||
m_data(_data) {
|
|
||||||
|
|
||||||
};
|
|
||||||
void setCaller(const std::shared_ptr<ewol::Object>& _caller) {
|
|
||||||
m_callerObject = _caller;
|
|
||||||
};
|
|
||||||
inline std::shared_ptr<ewol::Object> getCaller() const {
|
|
||||||
return m_callerObject;
|
|
||||||
};
|
|
||||||
void setMessage(const char* _message) {
|
|
||||||
m_event = _message;
|
|
||||||
};
|
|
||||||
inline const char* getMessage() const {
|
|
||||||
return m_event;
|
|
||||||
};
|
|
||||||
void setData(const std::string& _data) {
|
|
||||||
m_data = _data;
|
|
||||||
};
|
|
||||||
inline const std::string& getData() const {
|
|
||||||
return m_data;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
std::ostream& operator <<(std::ostream& _os, const ewol::object::Message& _obj);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
|
||||||
#include <ewol/object/MultiCast.h>
|
|
||||||
#include <ewol/context/Context.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "object::MultiCast"
|
|
||||||
|
|
||||||
ewol::object::MultiCast::MultiCast() {
|
|
||||||
EWOL_INFO("EObject message Multi-Cast");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ewol::object::MultiCast::~MultiCast() {
|
|
||||||
EWOL_INFO("EObject message Multi-Cast");
|
|
||||||
m_messageList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::object::MultiCast::clear() {
|
|
||||||
EWOL_INFO("EObject message Multi-Cast");
|
|
||||||
m_messageList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::object::MultiCast::add(const std::shared_ptr<ewol::Object>& _object, const char* const _message) {
|
|
||||||
if (_object == nullptr) {
|
|
||||||
EWOL_ERROR("Add with nullptr object");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_message == nullptr) {
|
|
||||||
EWOL_ERROR("Add with nullptr Message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_messageList.push_back(MessageList(_message, _object));
|
|
||||||
EWOL_DEBUG("SendMulticast ADD listener :" << _object->getId() << " on \"" << _message << "\"" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ewol::object::MultiCast::rm(const std::shared_ptr<ewol::Object>& _object) {
|
|
||||||
if (_object == nullptr) {
|
|
||||||
EWOL_ERROR("Rm with nullptr object");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// send the message at all registered widget ...
|
|
||||||
auto it(m_messageList.begin());
|
|
||||||
while (it != m_messageList.end()) {
|
|
||||||
std::shared_ptr<ewol::Object> obj = it->m_object.lock();
|
|
||||||
if(obj == _object) {
|
|
||||||
EWOL_DEBUG("SendMulticast RM listener :" << _object->getId());
|
|
||||||
m_messageList.erase(it);
|
|
||||||
it = m_messageList.begin();
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::object::MultiCast::send(const std::shared_ptr<ewol::Object>& _object, const char* const _message, const std::string& _data) {
|
|
||||||
EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to:");
|
|
||||||
// send the message at all registered widget ...
|
|
||||||
for (auto &it : m_messageList) {
|
|
||||||
std::shared_ptr<ewol::Object> obj = it.m_object.lock();
|
|
||||||
if( it.m_message == _message
|
|
||||||
&& obj != _object) {
|
|
||||||
if (obj != nullptr) {
|
|
||||||
EWOL_VERBOSE(" id = " << obj->getId() << " type=" << obj->getObjectType());
|
|
||||||
// generate event ... (create message before ...
|
|
||||||
ewol::object::Message tmpMsg(_object, it.m_message, _data);
|
|
||||||
obj->onReceiveMessage(tmpMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EWOL_OBJECT_MULTICAST_H__
|
|
||||||
#define __EWOL_OBJECT_MULTICAST_H__
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <exml/exml.h>
|
|
||||||
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
namespace object {
|
|
||||||
class MultiCast {
|
|
||||||
private:
|
|
||||||
class MessageList {
|
|
||||||
public:
|
|
||||||
MessageList(const char* _message=nullptr, std::shared_ptr<ewol::Object> _object=nullptr) :
|
|
||||||
m_message(_message), m_object(_object) {
|
|
||||||
|
|
||||||
}
|
|
||||||
const char* m_message;
|
|
||||||
std::weak_ptr<ewol::Object> m_object;
|
|
||||||
};
|
|
||||||
std::vector<MessageList> m_messageList; //!< List of all message ...
|
|
||||||
public:
|
|
||||||
MultiCast();
|
|
||||||
virtual ~MultiCast();
|
|
||||||
void clear();
|
|
||||||
void anonymousSend(const char* const _messageId, const std::string& _data) {
|
|
||||||
send(nullptr, _messageId, _data);
|
|
||||||
};
|
|
||||||
void send(const std::shared_ptr<ewol::Object>& _object, const char* const _message, const std::string& _data);
|
|
||||||
void rm(const std::shared_ptr<ewol::Object>& _object);
|
|
||||||
void add(const std::shared_ptr<ewol::Object>& _object, const char* const _message);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -10,7 +10,6 @@
|
|||||||
#include <ewol/object/Manager.h>
|
#include <ewol/object/Manager.h>
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/context/Context.h>
|
#include <ewol/context/Context.h>
|
||||||
#include <ewol/object/MultiCast.h>
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Object"
|
#define __class__ "Object"
|
||||||
@ -57,15 +56,13 @@ ewol::Object::Object() :
|
|||||||
|
|
||||||
ewol::Object::~Object() {
|
ewol::Object::~Object() {
|
||||||
EWOL_DEBUG("delete Object : [" << m_uniqueId << "] : " << getTypeDescription());
|
EWOL_DEBUG("delete Object : [" << m_uniqueId << "] : " << getTypeDescription());
|
||||||
m_externEvent.clear();
|
|
||||||
m_availlableEventId.clear();
|
|
||||||
m_uniqueId = -1;
|
m_uniqueId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Object::init() {
|
void ewol::Object::init() {
|
||||||
getObjectManager().add(shared_from_this());
|
getObjectManager().add(shared_from_this());
|
||||||
parameterDisplay();
|
//parameterDisplay();
|
||||||
m_objectHasBeenInit = true;
|
m_objectHasBeenInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,161 +106,6 @@ bool ewol::Object::isTypeCompatible(const std::string& _type) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::Object::addEventId(const char * _generateEventId) {
|
|
||||||
for (auto &it : m_availlableEventId) {
|
|
||||||
if (std::string(it) == _generateEventId) {
|
|
||||||
EWOL_WARNING("Event already existed : '" << it << "' == '" << _generateEventId << "'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_generateEventId != nullptr) {
|
|
||||||
m_availlableEventId.push_back(_generateEventId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::Object::generateEventId(const char * _generateEventId, const std::string& _data) {
|
|
||||||
if (m_objectHasBeenInit == false) {
|
|
||||||
EWOL_WARNING("try to generate an event inside a constructor");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t nbObject = getObjectManager().getNumberObject();
|
|
||||||
EWOL_VERBOSE("try send message '" << _generateEventId << "'");
|
|
||||||
// for every element registered ...
|
|
||||||
for (auto &it : m_externEvent) {
|
|
||||||
// if we find the event ...
|
|
||||||
if (it.localEventId != _generateEventId) {
|
|
||||||
EWOL_VERBOSE(" wrong event '" << it.localEventId << "' != '" << _generateEventId << "'");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::shared_ptr<ewol::Object> destObject = it.destObject.lock();
|
|
||||||
if (destObject == nullptr) {
|
|
||||||
EWOL_VERBOSE(" nullptr dest");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (it.overloadData.size() <= 0){
|
|
||||||
ewol::object::Message tmpMsg(shared_from_this(), it.destEventId, _data);
|
|
||||||
EWOL_VERBOSE("send message " << tmpMsg);
|
|
||||||
destObject->onReceiveMessage(tmpMsg);
|
|
||||||
} else {
|
|
||||||
// set the user requested data ...
|
|
||||||
ewol::object::Message tmpMsg(shared_from_this(), it.destEventId, it.overloadData);
|
|
||||||
EWOL_VERBOSE("send message " << tmpMsg);
|
|
||||||
destObject->onReceiveMessage(tmpMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nbObject > getObjectManager().getNumberObject()) {
|
|
||||||
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->removObject() which is asynchronous");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::Object::sendMultiCast(const char* const _messageId, const std::string& _data) {
|
|
||||||
if (m_objectHasBeenInit == false) {
|
|
||||||
EWOL_WARNING("try to generate an multicast event inside a constructor");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int32_t nbObject = getObjectManager().getNumberObject();
|
|
||||||
getMultiCast().send(shared_from_this(), _messageId, _data);
|
|
||||||
if (nbObject > getObjectManager().getNumberObject()) {
|
|
||||||
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->removObject() which is asynchronous");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::Object::registerMultiCast(const char* const _messageId) {
|
|
||||||
if (m_objectHasBeenInit == false) {
|
|
||||||
EWOL_ERROR("Try to Register multicast inside a constructor (move it in the init function)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getMultiCast().add(shared_from_this(), _messageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::Object::registerOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated,
|
|
||||||
const std::string& _overloadData) {
|
|
||||||
if (nullptr == _destinationObject) {
|
|
||||||
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (nullptr == _eventId) {
|
|
||||||
EWOL_ERROR("Input ERROR nullptr pointer Event Id...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( _eventId[0] == '*'
|
|
||||||
&& _eventId[1] == '\0') {
|
|
||||||
EWOL_VERBOSE("Register on all event ...");
|
|
||||||
for(auto &it : m_availlableEventId) {
|
|
||||||
ewol::object::EventExtGen tmpEvent;
|
|
||||||
tmpEvent.localEventId = it;
|
|
||||||
tmpEvent.destObject = _destinationObject;
|
|
||||||
tmpEvent.overloadData = _overloadData;
|
|
||||||
if (nullptr != _eventIdgenerated) {
|
|
||||||
tmpEvent.destEventId = _eventIdgenerated;
|
|
||||||
} else {
|
|
||||||
tmpEvent.destEventId = it;
|
|
||||||
}
|
|
||||||
m_externEvent.push_back(tmpEvent);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// check if event existed :
|
|
||||||
bool findIt = false;
|
|
||||||
for(auto &it : m_availlableEventId) {
|
|
||||||
if (it == _eventId) {
|
|
||||||
findIt = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (false == findIt) {
|
|
||||||
EWOL_VERBOSE("Try to register with a NON direct string name");
|
|
||||||
for(auto &it : m_availlableEventId) {
|
|
||||||
if (0 == strncmp(it, _eventId, 1024)) {
|
|
||||||
findIt = true;
|
|
||||||
_eventId = it;
|
|
||||||
EWOL_VERBOSE("find event ID : '" << _eventId << "' ==> '" << _eventIdgenerated << "'");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (false == findIt) {
|
|
||||||
EWOL_ERROR("Can not register event on this Type=" << getObjectType() << " event=\"" << _eventId << "\" == > unknow event");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ewol::object::EventExtGen tmpEvent;
|
|
||||||
tmpEvent.localEventId = _eventId;
|
|
||||||
tmpEvent.destObject = _destinationObject;
|
|
||||||
tmpEvent.overloadData = _overloadData;
|
|
||||||
if (nullptr != _eventIdgenerated) {
|
|
||||||
tmpEvent.destEventId = _eventIdgenerated;
|
|
||||||
} else {
|
|
||||||
tmpEvent.destEventId = _eventId;
|
|
||||||
}
|
|
||||||
m_externEvent.push_back(tmpEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::Object::unRegisterOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const char * _eventId) {
|
|
||||||
if (_destinationObject == nullptr) {
|
|
||||||
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// check if event existed :
|
|
||||||
auto it(m_externEvent.begin());
|
|
||||||
while(it != m_externEvent.end()) {
|
|
||||||
std::shared_ptr<ewol::Object> obj = it->destObject.lock();
|
|
||||||
if (obj == nullptr) {
|
|
||||||
m_externEvent.erase(it);
|
|
||||||
it = m_externEvent.begin();
|
|
||||||
} else if ( obj == _destinationObject
|
|
||||||
&& it->localEventId == _eventId) {
|
|
||||||
m_externEvent.erase(it);
|
|
||||||
it = m_externEvent.begin();
|
|
||||||
EWOL_INFO("[" << getId() << "] Remove extern event : to object id=" << _destinationObject->getId() << " event=" << _eventId);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ewol::Object::loadXML(exml::Element* _node) {
|
bool ewol::Object::loadXML(exml::Element* _node) {
|
||||||
if (nullptr == _node) {
|
if (nullptr == _node) {
|
||||||
return false;
|
return false;
|
||||||
@ -306,28 +148,17 @@ ewol::object::Manager& ewol::Object::getObjectManager() const {
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::object::MultiCast& ewol::Object::getMultiCast() const {
|
|
||||||
return ewol::getContext().getEObjectManager().multiCast();
|
|
||||||
}
|
|
||||||
|
|
||||||
ewol::Context& ewol::Object::getContext() const {
|
ewol::Context& ewol::Object::getContext() const {
|
||||||
return ewol::getContext();
|
return ewol::getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::Object::registerOnObjectEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const std::string& _objectName,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated,
|
|
||||||
const std::string& _overloadData) {
|
|
||||||
std::shared_ptr<ewol::Object> tmpObject = getObjectManager().getObjectNamed(_objectName);
|
|
||||||
if (nullptr != tmpObject) {
|
|
||||||
EWOL_DEBUG("Find widget named : '" << _objectName << "' register event='" << _eventId << "'");
|
|
||||||
tmpObject->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData);
|
|
||||||
} else {
|
|
||||||
EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Can not register event : \"" << _eventId << "\" the object named=\"" << _objectName << "\" does not exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<ewol::Object> ewol::Object::getObjectNamed(const std::string& _objectName) const {
|
std::shared_ptr<ewol::Object> ewol::Object::getObjectNamed(const std::string& _objectName) const {
|
||||||
return getObjectManager().getObjectNamed(_objectName);
|
return getObjectManager().getObjectNamed(_objectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ewol::Object> ewol::Object::getSubObjectNamed(const std::string& _objectName) {
|
||||||
|
if (_objectName == m_name.get()) {
|
||||||
|
return shared_from_this();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#ifndef __EWOL_OBJECT_H__
|
#ifndef __EWOL_OBJECT_H__
|
||||||
#define __EWOL_OBJECT_H__
|
#define __EWOL_OBJECT_H__
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <exml/exml.h>
|
#include <exml/exml.h>
|
||||||
@ -21,16 +20,16 @@ namespace ewol {
|
|||||||
class Object;
|
class Object;
|
||||||
namespace object {
|
namespace object {
|
||||||
class Manager;
|
class Manager;
|
||||||
class MultiCast;
|
|
||||||
};
|
};
|
||||||
class Context;
|
class Context;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <ewol/object/Message.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/object/ParameterList.h>
|
#include <ewol/object/ParameterList.h>
|
||||||
#include <ewol/object/Param.h>
|
#include <ewol/object/Param.h>
|
||||||
#include <ewol/object/ParamRange.h>
|
#include <ewol/object/ParamRange.h>
|
||||||
#include <ewol/object/ParamList.h>
|
#include <ewol/object/ParamList.h>
|
||||||
|
#include <ewol/object/SignalList.h>
|
||||||
|
|
||||||
#define DECLARE_FACTORY(className) \
|
#define DECLARE_FACTORY(className) \
|
||||||
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
|
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
|
||||||
@ -47,24 +46,13 @@ namespace ewol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace object {
|
|
||||||
/**
|
|
||||||
* local class for event generation
|
|
||||||
* @not-in-doc
|
|
||||||
*/
|
|
||||||
class EventExtGen {
|
|
||||||
public:
|
|
||||||
const char* localEventId; //!< local event Id generation
|
|
||||||
std::weak_ptr<ewol::Object> destObject; //!< destination widget that might be call
|
|
||||||
const char* destEventId; //!< generated event ID on the distant widget
|
|
||||||
std::string overloadData; //!< sometimes the user prefer to receive some specific data on an event (instead of the one sed by the widget)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Basic message classes for ewol system
|
* @brief Basic message classes for ewol system
|
||||||
* this class mermit at every Object to communicate between them.
|
* this class mermit at every Object to communicate between them.
|
||||||
*/
|
*/
|
||||||
class Object : public std::enable_shared_from_this<Object>, public ewol::object::ParameterList {
|
class Object : public std::enable_shared_from_this<Object>,
|
||||||
|
public ewol::object::ParameterList,
|
||||||
|
public ewol::object::SignalList {
|
||||||
private:
|
private:
|
||||||
static size_t m_valUID; //!< Static used for the unique ID definition
|
static size_t m_valUID; //!< Static used for the unique ID definition
|
||||||
private:
|
private:
|
||||||
@ -75,6 +63,7 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
Object();
|
Object();
|
||||||
void init();
|
void init();
|
||||||
|
//! @previous
|
||||||
void init(const std::string& _name);
|
void init(const std::string& _name);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -148,58 +137,8 @@ namespace ewol {
|
|||||||
int32_t getId(){
|
int32_t getId(){
|
||||||
return m_uniqueId;
|
return m_uniqueId;
|
||||||
};
|
};
|
||||||
private:
|
|
||||||
std::vector<object::EventExtGen> m_externEvent; //!< Generic list of event generation for output link
|
|
||||||
std::vector<const char*> m_availlableEventId; //!< List of all event availlable for this widget
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief add a specific event Id in the list to prevent wrong link on a Object
|
|
||||||
* @param[in] _generateEventId event Id to add
|
|
||||||
*/
|
|
||||||
void addEventId(const char * _generateEventId);
|
|
||||||
/**
|
|
||||||
* @brief generate event on all registered Object
|
|
||||||
* @param[in] _generateEventId event Id that is curetly generated
|
|
||||||
* @param[in] _data data associated with the event
|
|
||||||
*/
|
|
||||||
void generateEventId(const char * _generateEventId, const std::string& _data = "");
|
|
||||||
/**
|
|
||||||
* @brief generate Multicast event on all Object requested the event
|
|
||||||
* @param[in] _messageId Event Id that is generated
|
|
||||||
* @param[in] _data String that is send at all the destinations
|
|
||||||
*/
|
|
||||||
void sendMultiCast(const char* const _messageId, const std::string& _data = "");
|
|
||||||
/**
|
|
||||||
* @brief Register of the arrival of a Multicast message
|
|
||||||
* @param[in] _messageId Event Id waiting for...
|
|
||||||
*/
|
|
||||||
void registerMultiCast(const char* const _messageId);
|
|
||||||
public:
|
public:
|
||||||
/**
|
// TODO : Rework the position on this function ... This is a convignent function ...
|
||||||
* @brief Register an Object over an other to get event on the second...
|
|
||||||
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
|
|
||||||
* @param[in] _eventId Event generate inside the object (note : "*" event register on all event generated )
|
|
||||||
* @param[in] _eventIdgenerated event generated when call the distant Object.onReceiveMessage(...)
|
|
||||||
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
|
|
||||||
*/
|
|
||||||
void registerOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated = nullptr,
|
|
||||||
const std::string& _overloadData = "");
|
|
||||||
/**
|
|
||||||
* @brief Un-Register an Object over an other.
|
|
||||||
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
|
|
||||||
* @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object)
|
|
||||||
*/
|
|
||||||
void unRegisterOnEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const char * _eventId = nullptr);
|
|
||||||
/**
|
|
||||||
* @brief Receive a message from an other Object with a specific eventId and data
|
|
||||||
* @param[in] _msg Message handle
|
|
||||||
*/
|
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg) { };
|
|
||||||
public:
|
|
||||||
// TODO : Rework the position on this function ...
|
|
||||||
bool parameterSetOnWidgetNamed(const std::string& _objectName, const std::string& _config, const std::string& _value);
|
bool parameterSetOnWidgetNamed(const std::string& _objectName, const std::string& _config, const std::string& _value);
|
||||||
protected:
|
protected:
|
||||||
ewol::object::Param<std::string> m_name; //!< name of the element ...
|
ewol::object::Param<std::string> m_name; //!< name of the element ...
|
||||||
@ -239,11 +178,6 @@ namespace ewol {
|
|||||||
* @return the requested object manager.
|
* @return the requested object manager.
|
||||||
*/
|
*/
|
||||||
ewol::object::Manager& getObjectManager() const;
|
ewol::object::Manager& getObjectManager() const;
|
||||||
/**
|
|
||||||
* @breif get the current Object Message Multicast manager.
|
|
||||||
* @return the requested object manager.
|
|
||||||
*/
|
|
||||||
ewol::object::MultiCast& getMultiCast() const;
|
|
||||||
/**
|
/**
|
||||||
* @brief get the curent the system inteface.
|
* @brief get the curent the system inteface.
|
||||||
* @return current reference on the instance.
|
* @return current reference on the instance.
|
||||||
@ -267,30 +201,70 @@ namespace ewol {
|
|||||||
bool getStatusResource() const {
|
bool getStatusResource() const {
|
||||||
return m_isResource;
|
return m_isResource;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @brief Register an Event an named widget. @see registerOnEvent
|
|
||||||
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
|
|
||||||
* @param[in] _objectName Name of the object.
|
|
||||||
* @param[in] _eventId Event generate inside the object.
|
|
||||||
* @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...)
|
|
||||||
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
|
|
||||||
* @note : To used when NOT herited from this object.
|
|
||||||
*/
|
|
||||||
void registerOnObjectEvent(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const std::string& _objectName,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated = nullptr,
|
|
||||||
const std::string& _overloadData="");
|
|
||||||
/**
|
/**
|
||||||
* @brief Retrive an object with his name (in the global list)
|
* @brief Retrive an object with his name (in the global list)
|
||||||
* @param[in] _name Name of the object
|
* @param[in] _name Name of the object
|
||||||
* @return the requested object or nullptr
|
* @return the requested object or nullptr
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<ewol::Object> getObjectNamed(const std::string& _objectName) const;
|
std::shared_ptr<ewol::Object> getObjectNamed(const std::string& _objectName) const;
|
||||||
|
/**
|
||||||
|
* @brief Retrive an object with his name (in the global list)
|
||||||
|
* @param[in] _name Name of the object
|
||||||
|
* @return the requested object or nullptr
|
||||||
|
*/
|
||||||
|
virtual std::shared_ptr<ewol::Object> getSubObjectNamed(const std::string& _objectName);
|
||||||
|
protected:
|
||||||
|
// TODO : Create a template ...
|
||||||
|
/**
|
||||||
|
* @brief link on an signal in the subwiget with his name
|
||||||
|
*/
|
||||||
|
#define subBind(_type, _name, _event, _obj, _func) do {\
|
||||||
|
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(getSubObjectNamed(_name)); \
|
||||||
|
if (myObject != nullptr) { \
|
||||||
|
myObject->_event.bind(_obj, _func); \
|
||||||
|
} else { \
|
||||||
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
/*
|
||||||
|
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)()) {
|
||||||
|
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
||||||
|
if (obj2 == nullptr) {
|
||||||
|
EWOL_ERROR("Can not bind signal ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get())));
|
||||||
|
}
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief link on an signal in the global object list with his name
|
||||||
|
*/
|
||||||
|
#define globalBind(_type, _name, _event, _obj, _func) do {\
|
||||||
|
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \
|
||||||
|
if (myObject != nullptr) { \
|
||||||
|
myObject->_event.bind(_obj, _func); \
|
||||||
|
} else { \
|
||||||
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief link on an signal in the subWidget of an object with his name
|
||||||
|
*/
|
||||||
|
#define externSubBind(_object, _type, _name, _event, _obj, _func) do {\
|
||||||
|
std::shared_ptr<_type> myObject = std::dynamic_pointer_cast<_type>(_object->getObjectNamed(_name)); \
|
||||||
|
if (myObject != nullptr) { \
|
||||||
|
myObject->_event.bind(_obj, _func); \
|
||||||
|
} else { \
|
||||||
|
EWOL_ERROR("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
//#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ namespace ewol {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename MY_TYPE> std::ostream& operator <<(std::ostream& _os, const ewol::object::Param<MY_TYPE>& _obj) {
|
template<typename MY_TYPE, bool isEventReceiving=false> std::ostream& operator <<(std::ostream& _os, const ewol::object::Param<MY_TYPE, isEventReceiving>& _obj) {
|
||||||
_os << _obj.get();
|
_os << _obj.get();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/object/RemoveEvent.h>
|
|
||||||
#include <ewol/context/Context.h>
|
|
||||||
|
|
||||||
ewol::object::RemoveEvent::RemoveEvent() {
|
|
||||||
EWOL_TODO("ewol::object::RemoveEvent::RemoveEvent()");
|
|
||||||
/*
|
|
||||||
Context& tmp = ewol::getContext();
|
|
||||||
ewol::object::Manager& manager = tmp.getEObjectManager();
|
|
||||||
manager.add(this);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
ewol::object::RemoveEvent::~RemoveEvent() {
|
|
||||||
EWOL_TODO("ewol::object::RemoveEvent::~RemoveEvent()");
|
|
||||||
/*
|
|
||||||
Context& tmp = ewol::getContext();
|
|
||||||
ewol::object::Manager& manager = tmp.getEObjectManager();
|
|
||||||
manager.rm(this);
|
|
||||||
*/
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license APACHE v2.0 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EWOL_OBJECT_REMOVE_EVENT_H__
|
|
||||||
#define __EWOL_OBJECT_REMOVE_EVENT_H__
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <ewol/object/Object.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
namespace object {
|
|
||||||
class RemoveEvent {
|
|
||||||
public:
|
|
||||||
RemoveEvent();
|
|
||||||
virtual ~RemoveEvent();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
191
sources/ewol/object/Signal.h
Normal file
191
sources/ewol/object/Signal.h
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
|
||||||
|
#ifndef __EWOL_SIGNAL_H__
|
||||||
|
#define __EWOL_SIGNAL_H__
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <ewol/object/ParameterList.h>
|
||||||
|
#include <ewol/object/SignalBase.h>
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
|
||||||
|
namespace ewol {
|
||||||
|
namespace object {
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "object::Signal<T>"
|
||||||
|
template<typename T> class Signal : public SignalBase {
|
||||||
|
private:
|
||||||
|
std::vector<std::pair<std::weak_ptr<ewol::Object>,
|
||||||
|
std::function<void(const T&)>>> m_callerList;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _objectLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the parameter.
|
||||||
|
* @param[in] _defaultValue Default value of the parameter.
|
||||||
|
* @param[in] _min Minumum value.
|
||||||
|
* @param[in] _max Maximum value.
|
||||||
|
* @param[in] _description description of the parameter.
|
||||||
|
*/
|
||||||
|
Signal(ewol::object::SignalList& _objectLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "") :
|
||||||
|
SignalBase(_objectLink, _name, _description) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Signal() { };
|
||||||
|
/**
|
||||||
|
* @brief Bind a callback function to the current signal (generic methis (simplest))
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func Link on the fuction that might be called (inside a class)
|
||||||
|
* @example signalXXXX.bind(shared_from_this(), &ClassName::onCallbackXXX);
|
||||||
|
*/
|
||||||
|
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)(const T&)) {
|
||||||
|
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
||||||
|
if (obj2 == nullptr) {
|
||||||
|
EWOL_ERROR("Can not bind signal ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get(), std::placeholders::_1)));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Advanced binding a callback function to the current signal.
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func functor to call (do it yourself)
|
||||||
|
* @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1));
|
||||||
|
*/
|
||||||
|
void connect(std::shared_ptr<ewol::Object> _obj, std::function<void(const T&)> _function ) {
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), _function));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief remove link on the signal.
|
||||||
|
* @param[in] _obj shared pointer on the removing object
|
||||||
|
*/
|
||||||
|
void release(std::shared_ptr<ewol::Object> _obj) {
|
||||||
|
for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
m_callerList.erase(it);
|
||||||
|
it = m_callerList.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Generate a signal on all interface listening.
|
||||||
|
* @param[in] _data data to emit
|
||||||
|
*/
|
||||||
|
void emit(const T& _data) {
|
||||||
|
for (auto &it : m_callerList) {
|
||||||
|
std::shared_ptr<ewol::Object> destObject = it.first.lock();
|
||||||
|
if (destObject == nullptr) {
|
||||||
|
// TODO : Remove instance ...
|
||||||
|
EWOL_VERBOSE(" nullptr dest");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
ewol::Object* srcObject = dynamic_cast<ewol::Object*>(&m_objectLink);
|
||||||
|
if (srcObject != nullptr) {
|
||||||
|
EWOL_DEBUG("emit signal : " << srcObject->getObjectType() << " '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " data='" << etk::to_string(_data) << "'");
|
||||||
|
} else {
|
||||||
|
EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " data='" << etk::to_string(_data) << "'");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
it.second(_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "object::Signal<void>"
|
||||||
|
template<> class Signal<void> : public SignalBase {
|
||||||
|
private:
|
||||||
|
std::vector<std::pair<std::weak_ptr<ewol::Object>, std::function<void()>>> m_callerList;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _objectLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the parameter.
|
||||||
|
* @param[in] _defaultValue Default value of the parameter.
|
||||||
|
* @param[in] _min Minumum value.
|
||||||
|
* @param[in] _max Maximum value.
|
||||||
|
* @param[in] _description description of the parameter.
|
||||||
|
*/
|
||||||
|
Signal(ewol::object::SignalList& _objectLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "") :
|
||||||
|
SignalBase(_objectLink, _name, _description) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Signal() { };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bind a callback function to the current signal (generic methis (simplest))
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func Link on the fuction that might be called (inside a class)
|
||||||
|
* @example signalXXXX.connect(shared_from_this(), &ClassName::onCallbackXXX);
|
||||||
|
*/
|
||||||
|
template<class TYPE> void bind(std::shared_ptr<ewol::Object> _obj, void (TYPE::*_func)()) {
|
||||||
|
std::shared_ptr<TYPE> obj2 = std::dynamic_pointer_cast<TYPE>(_obj);
|
||||||
|
if (obj2 == nullptr) {
|
||||||
|
EWOL_ERROR("Can not bind signal ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), std::bind(_func, obj2.get())));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Advanced binding a callback function to the current signal.
|
||||||
|
* @param[in] _obj Shared pointer on the caller object
|
||||||
|
* @param[in] _func functor to call (do it yourself)
|
||||||
|
* @example signalXXXX.connect(shared_from_this(), std::bind(&ClassName::onCallbackXXX, this, std::placeholders::_1));
|
||||||
|
*/
|
||||||
|
void connect(std::shared_ptr<ewol::Object> _obj, std::function<void()> _function ) {
|
||||||
|
m_callerList.push_back(std::make_pair(std::weak_ptr<ewol::Object>(_obj), _function));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief remove link on the signal.
|
||||||
|
* @param[in] _obj shared pointer on the removing object
|
||||||
|
*/
|
||||||
|
void release(std::shared_ptr<ewol::Object> _obj) {
|
||||||
|
for (auto it(m_callerList.begin()) ; it != m_callerList.end(); ++it) {
|
||||||
|
if (it->first.lock() == _obj) {
|
||||||
|
m_callerList.erase(it);
|
||||||
|
it = m_callerList.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void emit() {
|
||||||
|
for (auto &it : m_callerList) {
|
||||||
|
std::shared_ptr<ewol::Object> destObject = it.first.lock();
|
||||||
|
if (destObject == nullptr) {
|
||||||
|
// TODO : Remove instance ...
|
||||||
|
EWOL_VERBOSE(" nullptr dest");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
ewol::Object* srcObject = dynamic_cast<ewol::Object*>(&m_objectLink);
|
||||||
|
if (srcObject != nullptr) {
|
||||||
|
EWOL_DEBUG("emit signal : " << srcObject->getObjectType() << " '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " BANG!!!");
|
||||||
|
} else {
|
||||||
|
EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " BANG!!!");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
it.second();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ nullptr
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#endif
|
29
sources/ewol/object/SignalBase.cpp
Normal file
29
sources/ewol/object/SignalBase.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <ewol/debug.h>
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
#include <ewol/object/SignalList.h>
|
||||||
|
#include <ewol/object/SignalBase.h>
|
||||||
|
|
||||||
|
ewol::object::SignalBase::SignalBase(ewol::object::SignalList& _objectLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description) :
|
||||||
|
m_objectLink(_objectLink),
|
||||||
|
m_name(_name),
|
||||||
|
m_description(_description) {
|
||||||
|
// add a reference on the current signal ...
|
||||||
|
m_objectLink.signalAdd(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::SignalBase& _obj) {
|
||||||
|
_os << _obj.getName();
|
||||||
|
return _os;
|
||||||
|
}
|
||||||
|
|
50
sources/ewol/object/SignalBase.h
Normal file
50
sources/ewol/object/SignalBase.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EWOL_SIGNAL_BASE_H__
|
||||||
|
#define __EWOL_SIGNAL_BASE_H__
|
||||||
|
|
||||||
|
#include <ewol/object/SignalList.h>
|
||||||
|
#include <ewol/object/SignalBase.h>
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace ewol {
|
||||||
|
namespace object {
|
||||||
|
class SignalBase {
|
||||||
|
protected:
|
||||||
|
ewol::object::SignalList& m_objectLink;
|
||||||
|
std::string m_name;
|
||||||
|
std::string m_description;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _objectLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the parameter.
|
||||||
|
* @param[in] _description description of the parameter.
|
||||||
|
*/
|
||||||
|
SignalBase(ewol::object::SignalList& _objectLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "");
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~SignalBase() { };
|
||||||
|
|
||||||
|
const std::string& getName() const {
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
const std::string& getDescription() const {
|
||||||
|
return m_description;
|
||||||
|
}
|
||||||
|
virtual void release(std::shared_ptr<ewol::Object> _obj) = 0;
|
||||||
|
};
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const SignalBase& _obj);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#endif
|
54
sources/ewol/object/SignalList.cpp
Normal file
54
sources/ewol/object/SignalList.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <ewol/debug.h>
|
||||||
|
#include <ewol/object/Object.h>
|
||||||
|
#include <ewol/object/SignalList.h>
|
||||||
|
#include <ewol/object/SignalBase.h>
|
||||||
|
#include <ewol/context/Context.h>
|
||||||
|
|
||||||
|
ewol::object::SignalList::SignalList() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ewol::object::SignalList::~SignalList() {
|
||||||
|
m_list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// note this pointer is not allocated and not free at the end of the class
|
||||||
|
void ewol::object::SignalList::signalAdd(SignalBase* _pointerOnSignal) {
|
||||||
|
if (_pointerOnSignal == nullptr) {
|
||||||
|
EWOL_ERROR("Try to link a nullptr parameters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_list.push_back(_pointerOnSignal);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> ewol::object::SignalList::signalGetAll() const {
|
||||||
|
std::vector<std::string> out;
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if(it != nullptr) {
|
||||||
|
out.push_back(it->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::object::SignalList::unBindAll(const std::shared_ptr<ewol::Object>& _object) {
|
||||||
|
if (_object == nullptr) {
|
||||||
|
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->release(_object);
|
||||||
|
}
|
||||||
|
}
|
52
sources/ewol/object/SignalList.h
Normal file
52
sources/ewol/object/SignalList.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __EWOL_SIGNAL_LIST_H__
|
||||||
|
#define __EWOL_SIGNAL_LIST_H__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace ewol {
|
||||||
|
namespace object {
|
||||||
|
class SignalBase;
|
||||||
|
class SignalList {
|
||||||
|
friend class ewol::object::SignalBase; // to register parameter in the list.
|
||||||
|
private:
|
||||||
|
std::vector<ewol::object::SignalBase*> m_list; //!< list of availlable Parameters
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Constructor.
|
||||||
|
*/
|
||||||
|
SignalList();
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~SignalList();
|
||||||
|
/**
|
||||||
|
* @brief Register a parameter class pointer in the List of parameters
|
||||||
|
* @note This class does not destroy the parameter pointer!!!
|
||||||
|
* @param[in] pointerOnParameter Pointer on the parameter that might be added.
|
||||||
|
*/
|
||||||
|
void signalAdd(SignalBase* _pointerOnParameter);
|
||||||
|
/**
|
||||||
|
* @brief Get All the signal list:
|
||||||
|
* @return vector on all the signals names
|
||||||
|
*/
|
||||||
|
std::vector<std::string> signalGetAll() const;
|
||||||
|
/**
|
||||||
|
* @brief Remove binding on all event class.
|
||||||
|
* @param[in] _object Object to unlink.
|
||||||
|
*/
|
||||||
|
void unBindAll(const std::shared_ptr<ewol::Object>& _object);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -14,7 +14,6 @@
|
|||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/resource/Resource.h>
|
#include <ewol/resource/Resource.h>
|
||||||
#include <ewol/object/RemoveEvent.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace resource {
|
namespace resource {
|
||||||
|
@ -90,31 +90,69 @@ namespace ewol {
|
|||||||
namespace resource {
|
namespace resource {
|
||||||
class Manager;
|
class Manager;
|
||||||
};
|
};
|
||||||
// class resources is pure virtual
|
/**
|
||||||
|
* @brief A Resource is a generic interface to have an instance that have things that can be used by many people, ad have some hardware dependency.
|
||||||
|
* For example of resources :
|
||||||
|
* :** Shaders: openGL display interface.
|
||||||
|
* :** Texture: openGL imega interface.
|
||||||
|
* :** Font: Single file interface to store many glyphe ==> reduce the number of parallele loaded files.
|
||||||
|
* :** ConfigFile: simple widget configuration files
|
||||||
|
* :** ...
|
||||||
|
*/
|
||||||
class Resource : public ewol::Object {
|
class Resource : public ewol::Object {
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief generic protected contructor (use factory to create this class)
|
||||||
|
*/
|
||||||
Resource() :
|
Resource() :
|
||||||
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
|
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
|
||||||
addObjectType("ewol::Resource");
|
addObjectType("ewol::Resource");
|
||||||
setStatusResource(true);
|
setStatusResource(true);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @brief Initialisation of the class and previous classes.
|
||||||
|
* @param[in] _name Name of the resource.
|
||||||
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
//! @previous
|
||||||
void init(const std::string& _name);
|
void init(const std::string& _name);
|
||||||
public:
|
public:
|
||||||
|
//! geenric destructor
|
||||||
virtual ~Resource() {
|
virtual ~Resource() {
|
||||||
|
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
uint8_t m_resourceLevel; //!< Level of the resource ==> for updata priority [0..5] 0 must be update first.
|
uint8_t m_resourceLevel; //!< Level of the resource ==> for update priority [0..5] 0 must be update first.
|
||||||
public:
|
public:
|
||||||
uint8_t getResourceLevel() {
|
/**
|
||||||
|
* @brief Get the current resource level;
|
||||||
|
* @return value in [0..5]
|
||||||
|
*/
|
||||||
|
uint8_t getResourceLevel() {
|
||||||
return m_resourceLevel;
|
return m_resourceLevel;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @brief Call when need to send data on the harware (openGL)
|
||||||
|
* @note This is done asynchronously with the create of the Resource.
|
||||||
|
*/
|
||||||
virtual void updateContext();
|
virtual void updateContext();
|
||||||
|
/**
|
||||||
|
* @brief The current OpenGl context is removing ==> remove yout own system data
|
||||||
|
*/
|
||||||
virtual void removeContext();
|
virtual void removeContext();
|
||||||
|
/**
|
||||||
|
* @brief The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android).
|
||||||
|
* Juste update your internal state
|
||||||
|
*/
|
||||||
virtual void removeContextToLate();
|
virtual void removeContextToLate();
|
||||||
|
/**
|
||||||
|
* @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ...
|
||||||
|
*/
|
||||||
virtual void reload();
|
virtual void reload();
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief Get the current resource Manager
|
||||||
|
*/
|
||||||
static ewol::resource::Manager& getManager();
|
static ewol::resource::Manager& getManager();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -14,14 +14,6 @@
|
|||||||
#define __class__ "Button"
|
#define __class__ "Button"
|
||||||
|
|
||||||
|
|
||||||
const char* const ewol::widget::Button::eventPressed = "pressed";
|
|
||||||
const char* const ewol::widget::Button::eventDown = "down";
|
|
||||||
const char* const ewol::widget::Button::eventUp = "up";
|
|
||||||
const char* const ewol::widget::Button::eventEnter = "enter";
|
|
||||||
const char* const ewol::widget::Button::eventLeave = "leave";
|
|
||||||
const char* const ewol::widget::Button::eventValue = "value";
|
|
||||||
|
|
||||||
|
|
||||||
// DEFINE for the shader display system :
|
// DEFINE for the shader display system :
|
||||||
#define STATUS_UP (0)
|
#define STATUS_UP (0)
|
||||||
#define STATUS_HOVER (2)
|
#define STATUS_HOVER (2)
|
||||||
@ -29,6 +21,12 @@ const char* const ewol::widget::Button::eventValue = "value";
|
|||||||
#define STATUS_DOWN (3)
|
#define STATUS_DOWN (3)
|
||||||
|
|
||||||
ewol::widget::Button::Button() :
|
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"),
|
||||||
m_shaper(*this, "shaper", "The display name for config file"),
|
m_shaper(*this, "shaper", "The display name for config file"),
|
||||||
m_value(*this, "value", false, "Value of the Button"),
|
m_value(*this, "value", false, "Value of the Button"),
|
||||||
m_lock(*this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder"),
|
m_lock(*this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder"),
|
||||||
@ -39,13 +37,6 @@ ewol::widget::Button::Button() :
|
|||||||
m_selectableAreaPos(0,0),
|
m_selectableAreaPos(0,0),
|
||||||
m_selectableAreaSize(0,0) {
|
m_selectableAreaSize(0,0) {
|
||||||
addObjectType("ewol::widget::Button");
|
addObjectType("ewol::widget::Button");
|
||||||
// add basic Event generated :
|
|
||||||
addEventId(eventPressed);
|
|
||||||
addEventId(eventDown);
|
|
||||||
addEventId(eventUp);
|
|
||||||
addEventId(eventEnter);
|
|
||||||
addEventId(eventLeave);
|
|
||||||
addEventId(eventValue);
|
|
||||||
|
|
||||||
// set property list:
|
// set property list:
|
||||||
m_lock.add(lockNone, "none");
|
m_lock.add(lockNone, "none");
|
||||||
@ -130,36 +121,36 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
|
|||||||
if (true == m_mouseHover) {
|
if (true == m_mouseHover) {
|
||||||
if (1 == _event.getId()) {
|
if (1 == _event.getId()) {
|
||||||
if(ewol::key::statusDown == _event.getStatus()) {
|
if(ewol::key::statusDown == _event.getStatus()) {
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventDown);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalDown);
|
||||||
generateEventId(eventDown);
|
signalDown.emit();
|
||||||
m_buttonPressed = true;
|
m_buttonPressed = true;
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
if(ewol::key::statusUp == _event.getStatus()) {
|
if(ewol::key::statusUp == _event.getStatus()) {
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventUp);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalUp);
|
||||||
generateEventId(eventUp);
|
signalUp.emit();
|
||||||
m_buttonPressed = false;
|
m_buttonPressed = false;
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
if(ewol::key::statusSingle == _event.getStatus()) {
|
if(ewol::key::statusSingle == _event.getStatus()) {
|
||||||
if( ( m_value == true
|
if( ( m_value.get() == true
|
||||||
&& ewol::widget::Button::lockWhenPressed == m_lock)
|
&& ewol::widget::Button::lockWhenPressed == m_lock)
|
||||||
|| ( m_value == false
|
|| ( m_value.get() == false
|
||||||
&& ewol::widget::Button::lockWhenReleased == m_lock) ) {
|
&& ewol::widget::Button::lockWhenReleased == m_lock) ) {
|
||||||
// nothing to do : Lock mode ...
|
// nothing to do : Lock mode ...
|
||||||
// user might set himself the new correct value with @ref setValue(xxx)
|
// user might set himself the new correct value with @ref setValue(xxx)
|
||||||
} else {
|
} else {
|
||||||
// inverse value :
|
// inverse value :
|
||||||
setValue((m_value)?false:true);
|
setValue((m_value.get())?false:true);
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventPressed);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed);
|
||||||
generateEventId(eventPressed);
|
signalPressed.emit();
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventValue << " val=" << m_value );
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value );
|
||||||
generateEventId(eventValue, etk::to_string(m_value.get()));
|
signalValue.emit(m_value.get());
|
||||||
if( false == m_toggleMode
|
if( m_toggleMode.get() == false
|
||||||
&& true == m_value) {
|
&& m_value.get() == true) {
|
||||||
setValue(false);
|
setValue(false);
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << ewol::widget::Button::eventValue << " val=" << m_value);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value);
|
||||||
generateEventId(eventValue, etk::to_string(m_value.get()));
|
signalValue.emit(m_value.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
@ -176,7 +167,7 @@ bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) {
|
|||||||
if( _event.getType() == ewol::key::keyboardChar
|
if( _event.getType() == ewol::key::keyboardChar
|
||||||
&& _event.getStatus() == ewol::key::statusDown
|
&& _event.getStatus() == ewol::key::statusDown
|
||||||
&& _event.getChar() == '\r') {
|
&& _event.getChar() == '\r') {
|
||||||
generateEventId(eventEnter);
|
signalEnter.emit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -225,7 +216,7 @@ void ewol::widget::Button::onParameterChangeValue(const ewol::object::ParameterR
|
|||||||
markToRedraw();
|
markToRedraw();
|
||||||
} else if (_paramPointer == m_value) {
|
} else if (_paramPointer == m_value) {
|
||||||
if (m_toggleMode == true) {
|
if (m_toggleMode == true) {
|
||||||
if (m_value == false) {
|
if (m_value.get() == false) {
|
||||||
m_idWidgetDisplayed = 0;
|
m_idWidgetDisplayed = 0;
|
||||||
} else {
|
} else {
|
||||||
m_idWidgetDisplayed = 1;
|
m_idWidgetDisplayed = 1;
|
||||||
@ -252,20 +243,20 @@ void ewol::widget::Button::onParameterChangeValue(const ewol::object::ParameterR
|
|||||||
CheckStatus();
|
CheckStatus();
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
} else if (_paramPointer == m_toggleMode) {
|
} else if (_paramPointer == m_toggleMode) {
|
||||||
if (m_value == true) {
|
if (m_value.get() == true) {
|
||||||
m_value = false;
|
m_value.get() = false;
|
||||||
// TODO : change display and send event ...
|
// TODO : change display and send event ...
|
||||||
}
|
}
|
||||||
if (m_toggleMode == false) {
|
if (m_toggleMode.get() == false) {
|
||||||
m_idWidgetDisplayed = 0;
|
m_idWidgetDisplayed = 0;
|
||||||
} else {
|
} else {
|
||||||
if (m_value == false) {
|
if (m_value.get() == false) {
|
||||||
m_idWidgetDisplayed = 0;
|
m_idWidgetDisplayed = 0;
|
||||||
} else {
|
} else {
|
||||||
m_idWidgetDisplayed = 1;
|
m_idWidgetDisplayed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_enableSingle == true) {
|
if (m_enableSingle.get() == true) {
|
||||||
if ( m_idWidgetDisplayed == 0
|
if ( m_idWidgetDisplayed == 0
|
||||||
&& m_subWidget[0] == nullptr
|
&& m_subWidget[0] == nullptr
|
||||||
&& m_subWidget[1] != nullptr) {
|
&& m_subWidget[1] != nullptr) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <ewol/compositing/Shaper.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Container2.h>
|
#include <ewol/widget/Container2.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -29,12 +30,12 @@ namespace ewol {
|
|||||||
class Button : public ewol::widget::Container2 {
|
class Button : public ewol::widget::Container2 {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char* const eventPressed;
|
ewol::object::Signal<void> signalPressed;
|
||||||
static const char* const eventDown;
|
ewol::object::Signal<void> signalDown;
|
||||||
static const char* const eventUp;
|
ewol::object::Signal<void> signalUp;
|
||||||
static const char* const eventEnter;
|
ewol::object::Signal<void> signalEnter;
|
||||||
static const char* const eventLeave;
|
ewol::object::Signal<void> signalLeave;
|
||||||
static const char* const eventValue;
|
ewol::object::Signal<bool> signalValue;
|
||||||
enum buttonLock{
|
enum buttonLock{
|
||||||
lockNone, //!< normal status of the button
|
lockNone, //!< normal status of the button
|
||||||
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
#include <ewol/widget/Windows.h>
|
#include <ewol/widget/Windows.h>
|
||||||
#include <ewol/ewol.h>
|
#include <ewol/ewol.h>
|
||||||
|
|
||||||
const char * const ewol::widget::ButtonColor::eventChange = "change";
|
|
||||||
|
|
||||||
|
|
||||||
// DEFINE for the shader display system :
|
// DEFINE for the shader display system :
|
||||||
#define STATUS_UP (0)
|
#define STATUS_UP (0)
|
||||||
#define STATUS_HOVER (2)
|
#define STATUS_HOVER (2)
|
||||||
@ -31,10 +28,10 @@ const char * const ewol::widget::ButtonColor::eventChange = "change";
|
|||||||
static const char* const eventColorHasChange = "ewol-widget-ButtonColor-colorChange";
|
static const char* const eventColorHasChange = "ewol-widget-ButtonColor-colorChange";
|
||||||
|
|
||||||
ewol::widget::ButtonColor::ButtonColor() :
|
ewol::widget::ButtonColor::ButtonColor() :
|
||||||
|
signalChange(*this, "change", "Button color change value"),
|
||||||
m_textColorFg(etk::color::black),
|
m_textColorFg(etk::color::black),
|
||||||
m_widgetContextMenu(nullptr) {
|
m_widgetContextMenu(nullptr) {
|
||||||
addObjectType("ewol::widget::ButtonColor");
|
addObjectType("ewol::widget::ButtonColor");
|
||||||
addEventId(eventChange);
|
|
||||||
changeStatusIn(STATUS_UP);
|
changeStatusIn(STATUS_UP);
|
||||||
setCanHaveFocus(true);
|
setCanHaveFocus(true);
|
||||||
// Limit event at 1:
|
// Limit event at 1:
|
||||||
@ -185,7 +182,7 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
|
|||||||
myColorChooser->setColor(m_textColorFg);
|
myColorChooser->setColor(m_textColorFg);
|
||||||
// set it in the pop-up-system :
|
// set it in the pop-up-system :
|
||||||
m_widgetContextMenu->setSubWidget(myColorChooser);
|
m_widgetContextMenu->setSubWidget(myColorChooser);
|
||||||
myColorChooser->registerOnEvent(shared_from_this(), "change", eventColorHasChange);
|
myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange);
|
||||||
std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows();
|
std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows();
|
||||||
if (currentWindows == nullptr) {
|
if (currentWindows == nullptr) {
|
||||||
EWOL_ERROR("Can not get the curent Windows...");
|
EWOL_ERROR("Can not get the curent Windows...");
|
||||||
@ -212,9 +209,13 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
|
|||||||
return m_mouseHover;
|
return m_mouseHover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color) {
|
||||||
|
setValue(_color);
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::widget::ButtonColor::setValue(etk::Color<> _color) {
|
void ewol::widget::ButtonColor::setValue(const etk::Color<>& _color) {
|
||||||
m_textColorFg = _color;
|
m_textColorFg = _color;
|
||||||
|
signalChange.emit(m_textColorFg);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,17 +223,6 @@ etk::Color<> ewol::widget::ButtonColor::getValue() {
|
|||||||
return m_textColorFg;
|
return m_textColorFg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::widget::ButtonColor::onReceiveMessage(const ewol::object::Message& _msg) {
|
|
||||||
EWOL_INFO("Receive MSG : " << _msg.getData());
|
|
||||||
if (_msg.getMessage() == eventColorHasChange) {
|
|
||||||
m_textColorFg = _msg.getData();
|
|
||||||
generateEventId(eventChange, _msg.getData());
|
|
||||||
markToRedraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
|
void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
|
||||||
if (true == m_shaper.changeStatusIn(_newStatusId) ) {
|
if (true == m_shaper.changeStatusIn(_newStatusId) ) {
|
||||||
periodicCallEnable();
|
periodicCallEnable();
|
||||||
@ -240,8 +230,6 @@ void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) {
|
void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) {
|
||||||
if (false == m_shaper.periodicCall(_event) ) {
|
if (false == m_shaper.periodicCall(_event) ) {
|
||||||
periodicCallDisable();
|
periodicCallDisable();
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
#include <ewol/compositing/Shaper.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
class ButtonColor : public ewol::Widget {
|
class ButtonColor : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventChange;
|
ewol::object::Signal<etk::Color<>> signalChange;
|
||||||
private:
|
private:
|
||||||
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
|
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
|
||||||
ewol::compositing::Text m_text; //!< Compositing Test display.
|
ewol::compositing::Text m_text; //!< Compositing Test display.
|
||||||
@ -62,14 +63,13 @@ namespace ewol {
|
|||||||
* @brief Specify the current color.
|
* @brief Specify the current color.
|
||||||
* @param[in] _color The new display color.
|
* @param[in] _color The new display color.
|
||||||
*/
|
*/
|
||||||
void setValue(etk::Color<> _color);
|
void setValue(const etk::Color<>& _color);
|
||||||
protected: // Derived function
|
protected: // Derived function
|
||||||
virtual void onDraw();
|
virtual void onDraw();
|
||||||
public: // Derived function
|
public: // Derived function
|
||||||
virtual void calculateMinMaxSize();
|
virtual void calculateMinMaxSize();
|
||||||
virtual void onRegenerateDisplay();
|
virtual void onRegenerateDisplay();
|
||||||
virtual bool onEventInput(const ewol::event::Input& _event);
|
virtual bool onEventInput(const ewol::event::Input& _event);
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief internal system to change the property of the current status
|
* @brief internal system to change the property of the current status
|
||||||
@ -78,6 +78,8 @@ namespace ewol {
|
|||||||
void changeStatusIn(int32_t _newStatusId);
|
void changeStatusIn(int32_t _newStatusId);
|
||||||
// Derived function
|
// Derived function
|
||||||
virtual void periodicCall(const ewol::event::Time& _event);
|
virtual void periodicCall(const ewol::event::Time& _event);
|
||||||
|
// Callback function:
|
||||||
|
void onCallbackColorChange(const etk::Color<>& _color);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
#include <ewol/widget/CheckBox.h>
|
#include <ewol/widget/CheckBox.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
|
||||||
const char* const ewol::widget::CheckBox::eventPressed = "pressed";
|
|
||||||
const char* const ewol::widget::CheckBox::eventDown = "down";
|
|
||||||
const char* const ewol::widget::CheckBox::eventUp = "up";
|
|
||||||
const char* const ewol::widget::CheckBox::eventEnter = "enter";
|
|
||||||
const char* const ewol::widget::CheckBox::eventValue = "value";
|
|
||||||
|
|
||||||
|
|
||||||
// DEFINE for the shader display system :
|
// DEFINE for the shader display system :
|
||||||
#define STATUS_UP (0)
|
#define STATUS_UP (0)
|
||||||
#define STATUS_HOVER (2)
|
#define STATUS_HOVER (2)
|
||||||
@ -26,6 +19,11 @@ const char* const ewol::widget::CheckBox::eventValue = "value";
|
|||||||
|
|
||||||
|
|
||||||
ewol::widget::CheckBox::CheckBox() :
|
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"),
|
||||||
m_shaper(*this, "shaper", "The display name for config file"),
|
m_shaper(*this, "shaper", "The display name for config file"),
|
||||||
m_mouseHover(false),
|
m_mouseHover(false),
|
||||||
m_buttonPressed(false),
|
m_buttonPressed(false),
|
||||||
@ -35,12 +33,6 @@ ewol::widget::CheckBox::CheckBox() :
|
|||||||
m_shaperIdSizeInsize(-1),
|
m_shaperIdSizeInsize(-1),
|
||||||
m_value(*this, "value", false, "Basic value of the widget") {
|
m_value(*this, "value", false, "Basic value of the widget") {
|
||||||
addObjectType("ewol::widget::CheckBox");
|
addObjectType("ewol::widget::CheckBox");
|
||||||
// add basic Event generated :
|
|
||||||
addEventId(eventPressed);
|
|
||||||
addEventId(eventDown);
|
|
||||||
addEventId(eventUp);
|
|
||||||
addEventId(eventEnter);
|
|
||||||
addEventId(eventValue);
|
|
||||||
|
|
||||||
m_shaperIdSize = m_shaper->requestConfig("box-size");
|
m_shaperIdSize = m_shaper->requestConfig("box-size");
|
||||||
m_shaperIdSizeInsize = m_shaper->requestConfig("box-inside");
|
m_shaperIdSizeInsize = m_shaper->requestConfig("box-inside");
|
||||||
@ -135,24 +127,24 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) {
|
|||||||
if (true == m_mouseHover) {
|
if (true == m_mouseHover) {
|
||||||
if (1 == _event.getId()) {
|
if (1 == _event.getId()) {
|
||||||
if(ewol::key::statusDown == _event.getStatus()) {
|
if(ewol::key::statusDown == _event.getStatus()) {
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventDown);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalDown);
|
||||||
generateEventId(eventDown);
|
signalDown.emit();
|
||||||
m_buttonPressed = true;
|
m_buttonPressed = true;
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
if(ewol::key::statusUp == _event.getStatus()) {
|
if(ewol::key::statusUp == _event.getStatus()) {
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventUp);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalUp);
|
||||||
generateEventId(eventUp);
|
signalUp.emit();
|
||||||
m_buttonPressed = false;
|
m_buttonPressed = false;
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
if(ewol::key::statusSingle == _event.getStatus()) {
|
if(ewol::key::statusSingle == _event.getStatus()) {
|
||||||
// inverse value :
|
// inverse value :
|
||||||
setValue((m_value)?false:true);
|
setValue((m_value)?false:true);
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventPressed);
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed);
|
||||||
generateEventId(eventPressed);
|
signalPressed.emit();
|
||||||
EWOL_VERBOSE(getName() << " : Generate event : " << eventValue << " val=" << m_value );
|
EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value );
|
||||||
generateEventId(eventValue, etk::to_string(m_value.get()));
|
signalValue.emit(m_value.get());
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +162,7 @@ bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) {
|
|||||||
if( _event.getType() == ewol::key::keyboardChar
|
if( _event.getType() == ewol::key::keyboardChar
|
||||||
&& _event.getStatus() == ewol::key::statusDown
|
&& _event.getStatus() == ewol::key::statusDown
|
||||||
&& _event.getChar() == '\r') {
|
&& _event.getChar() == '\r') {
|
||||||
generateEventId(eventEnter);
|
signalEnter.emit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -208,7 +200,7 @@ void ewol::widget::CheckBox::onParameterChangeValue(const ewol::object::Paramete
|
|||||||
if (_paramPointer == m_shaper) {
|
if (_paramPointer == m_shaper) {
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
} else if (_paramPointer == m_value) {
|
} else if (_paramPointer == m_value) {
|
||||||
if (m_value == false) {
|
if (m_value.get() == false) {
|
||||||
m_idWidgetDisplayed = convertId(0);
|
m_idWidgetDisplayed = convertId(0);
|
||||||
} else {
|
} else {
|
||||||
m_idWidgetDisplayed = convertId(1);
|
m_idWidgetDisplayed = convertId(1);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <ewol/compositing/Shaper.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Container2.h>
|
#include <ewol/widget/Container2.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -21,11 +22,11 @@ namespace ewol {
|
|||||||
class CheckBox : public ewol::widget::Container2 {
|
class CheckBox : public ewol::widget::Container2 {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char* const eventPressed;
|
ewol::object::Signal<void> signalPressed;
|
||||||
static const char* const eventDown;
|
ewol::object::Signal<void> signalDown;
|
||||||
static const char* const eventUp;
|
ewol::object::Signal<void> signalUp;
|
||||||
static const char* const eventEnter;
|
ewol::object::Signal<void> signalEnter;
|
||||||
static const char* const eventValue;
|
ewol::object::Signal<bool> signalValue;
|
||||||
private:
|
private:
|
||||||
ewol::object::Param<ewol::compositing::Shaper> m_shaper; //!< Compositing theme.
|
ewol::object::Param<ewol::compositing::Shaper> m_shaper; //!< Compositing theme.
|
||||||
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
|
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
|
||||||
|
@ -13,16 +13,12 @@
|
|||||||
|
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
|
|
||||||
const char * const ewol::widget::ColorBar::eventChange = "change";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ColorBar"
|
#define __class__ "ColorBar"
|
||||||
|
|
||||||
ewol::widget::ColorBar::ColorBar() {
|
ewol::widget::ColorBar::ColorBar() :
|
||||||
|
signalChange(*this, "change", "Color value change") {
|
||||||
addObjectType("ewol::widget::ColorBar");
|
addObjectType("ewol::widget::ColorBar");
|
||||||
addEventId(eventChange);
|
|
||||||
m_currentUserPos.setValue(0,0);
|
m_currentUserPos.setValue(0,0);
|
||||||
m_currentColor = etk::color::black;
|
m_currentColor = etk::color::black;
|
||||||
setCanHaveFocus(true);
|
setCanHaveFocus(true);
|
||||||
@ -224,7 +220,7 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) {
|
|||||||
}
|
}
|
||||||
if(m_currentColor != estimateColor) {
|
if(m_currentColor != estimateColor) {
|
||||||
m_currentColor = estimateColor;
|
m_currentColor = estimateColor;
|
||||||
generateEventId(eventChange);
|
signalChange.emit(m_currentColor);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/compositing/Drawing.h>
|
#include <ewol/compositing/Drawing.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -21,7 +22,7 @@ namespace ewol {
|
|||||||
class ColorBar : public ewol::Widget {
|
class ColorBar : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventChange;
|
ewol::object::Signal<etk::Color<>> signalChange;
|
||||||
protected:
|
protected:
|
||||||
ColorBar();
|
ColorBar();
|
||||||
void init();
|
void init();
|
||||||
|
@ -88,25 +88,3 @@ bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlStrin
|
|||||||
requestUpdateSize();
|
requestUpdateSize();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::widget::Composer::registerOnEventNameWidget(const std::string& _subWidgetName,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated,
|
|
||||||
const std::string& _overloadData) {
|
|
||||||
registerOnEventNameWidget(shared_from_this(), _subWidgetName, _eventId, _eventIdgenerated, _overloadData);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::widget::Composer::registerOnEventNameWidget(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const std::string& _subWidgetName,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated,
|
|
||||||
const std::string& _overloadData) {
|
|
||||||
std::shared_ptr<ewol::Widget> tmpWidget = getWidgetNamed(_subWidgetName);
|
|
||||||
if (tmpWidget != nullptr) {
|
|
||||||
EWOL_DEBUG("Find widget named : \"" << _subWidgetName << "\" register event=\"" << _eventId << "\"");
|
|
||||||
tmpWidget->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData);
|
|
||||||
} else {
|
|
||||||
EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Can not register event : \"" << _eventId << "\" the widget named=\"" << _subWidgetName << "\" does not exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -57,34 +57,6 @@ namespace ewol {
|
|||||||
* @return false == > some error occured
|
* @return false == > some error occured
|
||||||
*/
|
*/
|
||||||
bool loadFromString(const std::string& _composerXmlString);
|
bool loadFromString(const std::string& _composerXmlString);
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief Register an Event an named widget. @see registerOnEvent
|
|
||||||
* @param[in] _subWidgetName Name of the subWidget.
|
|
||||||
* @param[in] _eventId Event generate inside the object.
|
|
||||||
* @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...)
|
|
||||||
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
|
|
||||||
* @note : To used when herited from this object.
|
|
||||||
*/
|
|
||||||
void registerOnEventNameWidget(const std::string& _subWidgetName,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated = nullptr,
|
|
||||||
const std::string& _overloadData="");
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Register an Event an named widget. @see registerOnEvent
|
|
||||||
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
|
|
||||||
* @param[in] _subWidgetName Name of the subWidget.
|
|
||||||
* @param[in] _eventId Event generate inside the object.
|
|
||||||
* @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...)
|
|
||||||
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
|
|
||||||
* @note : To used when NOT herited from this object.
|
|
||||||
*/
|
|
||||||
void registerOnEventNameWidget(const std::shared_ptr<ewol::Object>& _destinationObject,
|
|
||||||
const std::string& _subWidgetName,
|
|
||||||
const char * _eventId,
|
|
||||||
const char * _eventIdgenerated = nullptr,
|
|
||||||
const std::string& _overloadData="");
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -64,13 +64,13 @@ void ewol::widget::Container::subWidgetUnLink() {
|
|||||||
m_subWidget.reset();
|
m_subWidget.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ewol::Widget> ewol::widget::Container::getWidgetNamed(const std::string& _widgetName) {
|
std::shared_ptr<ewol::Object> ewol::widget::Container::getSubObjectNamed(const std::string& _objectName) {
|
||||||
std::shared_ptr<ewol::Widget> tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
|
std::shared_ptr<ewol::Object> tmpObject = ewol::Widget::getSubObjectNamed(_objectName);
|
||||||
if (nullptr!=tmpUpperWidget) {
|
if (nullptr!=tmpObject) {
|
||||||
return tmpUpperWidget;
|
return tmpObject;
|
||||||
}
|
}
|
||||||
if (nullptr != m_subWidget) {
|
if (nullptr != m_subWidget) {
|
||||||
return m_subWidget->getWidgetNamed(_widgetName);
|
return m_subWidget->getSubObjectNamed(_objectName);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace ewol {
|
|||||||
virtual void calculateSize(const vec2& _availlable);
|
virtual void calculateSize(const vec2& _availlable);
|
||||||
virtual void calculateMinMaxSize();
|
virtual void calculateMinMaxSize();
|
||||||
virtual std::shared_ptr<ewol::Widget> getWidgetAtPos(const vec2& _pos);
|
virtual std::shared_ptr<ewol::Widget> getWidgetAtPos(const vec2& _pos);
|
||||||
virtual std::shared_ptr<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
|
virtual std::shared_ptr<ewol::Object> getSubObjectNamed(const std::string& _objectName);
|
||||||
virtual bool loadXML(exml::Element* _node);
|
virtual bool loadXML(exml::Element* _node);
|
||||||
virtual void setOffset(const vec2& _newVal);
|
virtual void setOffset(const vec2& _newVal);
|
||||||
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
||||||
|
@ -63,16 +63,19 @@ void ewol::widget::Container2::subWidgetUnLink(int32_t _idWidget) {
|
|||||||
m_subWidget[_idWidget].reset();
|
m_subWidget[_idWidget].reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ewol::Widget> ewol::widget::Container2::getWidgetNamed(const std::string& _widgetName) {
|
std::shared_ptr<ewol::Object> ewol::widget::Container2::getSubObjectNamed(const std::string& _widgetName) {
|
||||||
std::shared_ptr<ewol::Widget> tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
|
std::shared_ptr<ewol::Object> tmpObject = ewol::Widget::getSubObjectNamed(_widgetName);
|
||||||
if (tmpUpperWidget != nullptr) {
|
if (tmpObject != nullptr) {
|
||||||
return tmpUpperWidget;
|
return tmpObject;
|
||||||
}
|
}
|
||||||
if (m_subWidget[0] != nullptr) {
|
if (m_subWidget[0] != nullptr) {
|
||||||
return m_subWidget[0]->getWidgetNamed(_widgetName);
|
tmpObject = m_subWidget[0]->getSubObjectNamed(_widgetName);
|
||||||
|
if (tmpObject != nullptr) {
|
||||||
|
return tmpObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_subWidget[1] != nullptr) {
|
if (m_subWidget[1] != nullptr) {
|
||||||
return m_subWidget[1]->getWidgetNamed(_widgetName);
|
return m_subWidget[1]->getSubObjectNamed(_widgetName);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace ewol {
|
|||||||
calculateMinMaxSizePadded();
|
calculateMinMaxSizePadded();
|
||||||
}
|
}
|
||||||
//virtual std::shared_ptr<ewol::Widget> getWidgetAtPos(const vec2& _pos);
|
//virtual std::shared_ptr<ewol::Widget> getWidgetAtPos(const vec2& _pos);
|
||||||
virtual std::shared_ptr<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
|
virtual std::shared_ptr<ewol::Object> getSubObjectNamed(const std::string& _objectName);
|
||||||
virtual bool loadXML(exml::Element* _node);
|
virtual bool loadXML(exml::Element* _node);
|
||||||
virtual void setOffset(const vec2& _newVal);
|
virtual void setOffset(const vec2& _newVal);
|
||||||
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
||||||
|
@ -138,16 +138,16 @@ void ewol::widget::ContainerN::subWidgetRemoveAllDelayed() {
|
|||||||
subWidgetRemoveAll();
|
subWidgetRemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ewol::Widget> ewol::widget::ContainerN::getWidgetNamed(const std::string& _widgetName) {
|
std::shared_ptr<ewol::Object> ewol::widget::ContainerN::getSubObjectNamed(const std::string& _objectName) {
|
||||||
std::shared_ptr<ewol::Widget> tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
|
std::shared_ptr<ewol::Object> tmpObject = ewol::Widget::getSubObjectNamed(_objectName);
|
||||||
if (tmpUpperWidget != nullptr) {
|
if (tmpObject != nullptr) {
|
||||||
return tmpUpperWidget;
|
return tmpObject;
|
||||||
}
|
}
|
||||||
for (auto &it : m_subWidget) {
|
for (auto &it : m_subWidget) {
|
||||||
if (it != nullptr) {
|
if (it != nullptr) {
|
||||||
std::shared_ptr<ewol::Widget> tmpWidget = it->getWidgetNamed(_widgetName);
|
tmpObject = it->getSubObjectNamed(_objectName);
|
||||||
if (tmpWidget != nullptr) {
|
if (tmpObject != nullptr) {
|
||||||
return tmpWidget;
|
return tmpObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace ewol {
|
|||||||
virtual void calculateSize(const vec2& _availlable);
|
virtual void calculateSize(const vec2& _availlable);
|
||||||
virtual void calculateMinMaxSize();
|
virtual void calculateMinMaxSize();
|
||||||
virtual std::shared_ptr<ewol::Widget> getWidgetAtPos(const vec2& _pos);
|
virtual std::shared_ptr<ewol::Widget> getWidgetAtPos(const vec2& _pos);
|
||||||
virtual std::shared_ptr<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
|
virtual std::shared_ptr<ewol::Object> getSubObjectNamed(const std::string& _objectName);
|
||||||
virtual bool loadXML(exml::Element* _node);
|
virtual bool loadXML(exml::Element* _node);
|
||||||
virtual void setOffset(const vec2& _newVal);
|
virtual void setOffset(const vec2& _newVal);
|
||||||
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
||||||
|
@ -13,14 +13,6 @@
|
|||||||
#include <ewol/context/Context.h>
|
#include <ewol/context/Context.h>
|
||||||
#include <ewol/Padding.h>
|
#include <ewol/Padding.h>
|
||||||
|
|
||||||
|
|
||||||
const char * const ewolEventEntryCut = "ewol-widget-entry-event-internal-cut";
|
|
||||||
const char * const ewolEventEntryCopy = "ewol-widget-entry-event-internal-copy";
|
|
||||||
const char * const ewolEventEntryPaste = "ewol-widget-entry-event-internal-paste";
|
|
||||||
const char * const ewolEventEntryClean = "ewol-widget-entry-event-internal-clean";
|
|
||||||
const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-select";
|
|
||||||
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Entry"
|
#define __class__ "Entry"
|
||||||
|
|
||||||
@ -29,11 +21,10 @@ const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-sele
|
|||||||
#define STATUS_HOVER (1)
|
#define STATUS_HOVER (1)
|
||||||
#define STATUS_SELECTED (2)
|
#define STATUS_SELECTED (2)
|
||||||
|
|
||||||
const char * const ewol::widget::Entry::eventClick = "click";
|
|
||||||
const char * const ewol::widget::Entry::eventEnter = "enter";
|
|
||||||
const char * const ewol::widget::Entry::eventModify = "modify";
|
|
||||||
|
|
||||||
ewol::widget::Entry::Entry() :
|
ewol::widget::Entry::Entry() :
|
||||||
|
signalClick(*this, "click", "the user Click on the Entry box"),
|
||||||
|
signalEnter(*this, "enter", "The cursor enter inside the button"),
|
||||||
|
signalModify(*this, "modify", "Entry box value change"),
|
||||||
m_shaper(*this, "shaper", "Shaper to display the background"),
|
m_shaper(*this, "shaper", "Shaper to display the background"),
|
||||||
m_data(*this, "value", "", "Value display in the entry (decorated text)"),
|
m_data(*this, "value", "", "Value display in the entry (decorated text)"),
|
||||||
m_maxCharacter(*this, "max", 0x7FFFFFFF, 0, 0x7FFFFFFF, "Maximum cgar that can be set on the Entry"),
|
m_maxCharacter(*this, "max", 0x7FFFFFFF, 0, 0x7FFFFFFF, "Maximum cgar that can be set on the Entry"),
|
||||||
@ -45,25 +36,24 @@ ewol::widget::Entry::Entry() :
|
|||||||
m_displayCursorPosSelection(0),
|
m_displayCursorPosSelection(0),
|
||||||
m_textWhenNothing(*this, "emptytext", "", "Text that is displayed when the Entry is empty (decorated text)") {
|
m_textWhenNothing(*this, "emptytext", "", "Text that is displayed when the Entry is empty (decorated text)") {
|
||||||
addObjectType("ewol::widget::Entry");
|
addObjectType("ewol::widget::Entry");
|
||||||
setCanHaveFocus(true);
|
|
||||||
addEventId(eventClick);
|
|
||||||
addEventId(eventEnter);
|
|
||||||
addEventId(eventModify);
|
|
||||||
shortCutAdd("ctrl+w", ewolEventEntryClean);
|
|
||||||
shortCutAdd("ctrl+x", ewolEventEntryCut);
|
|
||||||
shortCutAdd("ctrl+c", ewolEventEntryCopy);
|
|
||||||
shortCutAdd("ctrl+v", ewolEventEntryPaste);
|
|
||||||
shortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
|
||||||
shortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
|
||||||
m_regExp.setString(".*");
|
|
||||||
markToRedraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::widget::Entry::init(const std::string& _newData) {
|
void ewol::widget::Entry::init(const std::string& _newData) {
|
||||||
ewol::Widget::init();
|
ewol::Widget::init();
|
||||||
m_data.set(_newData);
|
m_data.set(_newData);
|
||||||
m_shaper.setString("THEME:GUI:Entry.json");
|
m_shaper.setString("THEME:GUI:Entry.json");
|
||||||
|
setCanHaveFocus(true);
|
||||||
|
m_regExp.setString(".*");
|
||||||
|
m_regExp.get().setMaximize(true);
|
||||||
|
markToRedraw();
|
||||||
|
|
||||||
|
shortCutAdd("ctrl+w", "clean");
|
||||||
|
shortCutAdd("ctrl+x", "cut");
|
||||||
|
shortCutAdd("ctrl+c", "copy");
|
||||||
|
shortCutAdd("ctrl+v", "paste");
|
||||||
|
shortCutAdd("ctrl+a", "select:all");
|
||||||
|
shortCutAdd("ctrl+shift+a", "select:none");
|
||||||
|
signalShortcut.bind(shared_from_this(), &ewol::widget::Entry::onCallbackShortCut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,6 +61,24 @@ ewol::widget::Entry::~Entry() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::widget::Entry::onCallbackShortCut(const std::string& _value) {
|
||||||
|
if (_value == "clean") {
|
||||||
|
onCallbackEntryClean();
|
||||||
|
} else if (_value == "cut") {
|
||||||
|
onCallbackCut();
|
||||||
|
} else if (_value == "copy") {
|
||||||
|
onCallbackCopy();
|
||||||
|
} else if (_value == "paste") {
|
||||||
|
onCallbackPaste();
|
||||||
|
} else if (_value == "select:all") {
|
||||||
|
onCallbackSelect(true);
|
||||||
|
} else if (_value == "select:none") {
|
||||||
|
onCallbackSelect(false);
|
||||||
|
} else {
|
||||||
|
EWOL_WARNING("Unknow event from ShortCut : " << _value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::widget::Entry::calculateMinMaxSize() {
|
void ewol::widget::Entry::calculateMinMaxSize() {
|
||||||
// call main class
|
// call main class
|
||||||
ewol::Widget::calculateMinMaxSize();
|
ewol::Widget::calculateMinMaxSize();
|
||||||
@ -244,7 +252,7 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) {
|
|||||||
if (1 == _event.getId()) {
|
if (1 == _event.getId()) {
|
||||||
if (ewol::key::statusSingle == _event.getStatus()) {
|
if (ewol::key::statusSingle == _event.getStatus()) {
|
||||||
keepFocus();
|
keepFocus();
|
||||||
generateEventId(eventClick);
|
signalClick.emit();
|
||||||
//nothing to do ...
|
//nothing to do ...
|
||||||
return true;
|
return true;
|
||||||
} else if (ewol::key::statusDouble == _event.getStatus()) {
|
} else if (ewol::key::statusDouble == _event.getStatus()) {
|
||||||
@ -335,13 +343,11 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) {
|
|||||||
bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) {
|
bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) {
|
||||||
if (_event.getType() == ewol::key::keyboardChar) {
|
if (_event.getType() == ewol::key::keyboardChar) {
|
||||||
if(_event.getStatus() == ewol::key::statusDown) {
|
if(_event.getStatus() == ewol::key::statusDown) {
|
||||||
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
|
|
||||||
//return GenEventInputExternal(eventEnter, -1, -1);
|
|
||||||
// remove curent selected data ...
|
// remove curent selected data ...
|
||||||
removeSelected();
|
removeSelected();
|
||||||
if( _event.getChar() == '\n'
|
if( _event.getChar() == '\n'
|
||||||
|| _event.getChar() == '\r') {
|
|| _event.getChar() == '\r') {
|
||||||
generateEventId(eventEnter, m_data);
|
signalEnter.emit(m_data);
|
||||||
return true;
|
return true;
|
||||||
} else if (_event.getChar() == 0x7F) {
|
} else if (_event.getChar() == 0x7F) {
|
||||||
// SUPPR :
|
// SUPPR :
|
||||||
@ -371,7 +377,7 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
generateEventId(eventModify, m_data);
|
signalModify.emit(m_data);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -408,7 +414,7 @@ void ewol::widget::Entry::setInternalValue(const std::string& _newData) {
|
|||||||
std::string previous = m_data;
|
std::string previous = m_data;
|
||||||
// check the RegExp :
|
// check the RegExp :
|
||||||
if (_newData.size()>0) {
|
if (_newData.size()>0) {
|
||||||
if (false == m_regExp->processOneElement(_newData,0,_newData.size()) ) {
|
if (false == m_regExp->parse(_newData,0,_newData.size()) ) {
|
||||||
EWOL_INFO("the input data does not match with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp->getRegExp() << "\" start=" << m_regExp->start() << " stop=" << m_regExp->stop() );
|
EWOL_INFO("the input data does not match with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp->getRegExp() << "\" start=" << m_regExp->start() << " stop=" << m_regExp->stop() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -443,35 +449,39 @@ void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipbo
|
|||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
generateEventId(eventModify, m_data);
|
signalModify.emit(m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::widget::Entry::onCallbackEntryClean() {
|
||||||
|
m_data = "";
|
||||||
|
m_displayStartPosition = 0;
|
||||||
|
m_displayCursorPos = 0;
|
||||||
|
m_displayCursorPosSelection = m_displayCursorPos;
|
||||||
|
markToRedraw();
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::widget::Entry::onReceiveMessage(const ewol::object::Message& _msg) {
|
void ewol::widget::Entry::onCallbackCut() {
|
||||||
ewol::Widget::onReceiveMessage(_msg);
|
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
|
||||||
if(_msg.getMessage() == ewolEventEntryClean) {
|
removeSelected();
|
||||||
m_data = "";
|
signalModify.emit(m_data);
|
||||||
m_displayStartPosition = 0;
|
}
|
||||||
m_displayCursorPos = 0;
|
|
||||||
|
void ewol::widget::Entry::onCallbackCopy() {
|
||||||
|
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::widget::Entry::onCallbackPaste() {
|
||||||
|
ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::widget::Entry::onCallbackSelect(bool _all) {
|
||||||
|
if(_all == true) {
|
||||||
|
m_displayCursorPosSelection = 0;
|
||||||
|
m_displayCursorPos = m_data->size();
|
||||||
|
} else {
|
||||||
m_displayCursorPosSelection = m_displayCursorPos;
|
m_displayCursorPosSelection = m_displayCursorPos;
|
||||||
markToRedraw();
|
|
||||||
} else if(_msg.getMessage() == ewolEventEntryCut) {
|
|
||||||
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
|
|
||||||
removeSelected();
|
|
||||||
generateEventId(eventModify, m_data);
|
|
||||||
} else if(_msg.getMessage() == ewolEventEntryCopy) {
|
|
||||||
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
|
|
||||||
} else if(_msg.getMessage() == ewolEventEntryPaste) {
|
|
||||||
ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd);
|
|
||||||
} else if(_msg.getMessage() == ewolEventEntrySelect) {
|
|
||||||
if(_msg.getData() == "ALL") {
|
|
||||||
m_displayCursorPosSelection = 0;
|
|
||||||
m_displayCursorPos = m_data->size();
|
|
||||||
} else {
|
|
||||||
m_displayCursorPosSelection = m_displayCursorPos;
|
|
||||||
}
|
|
||||||
markToRedraw();
|
|
||||||
}
|
}
|
||||||
|
markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Entry::markToUpdateTextPosition() {
|
void ewol::widget::Entry::markToUpdateTextPosition() {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -33,10 +34,9 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class Entry : public ewol::Widget {
|
class Entry : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
ewol::object::Signal<void> signalClick; //!< bang on click the entry box
|
||||||
static const char * const eventClick;
|
ewol::object::Signal<std::string> signalEnter; //!< Enter key is pressed
|
||||||
static const char * const eventEnter;
|
ewol::object::Signal<std::string> signalModify; //!< data change
|
||||||
static const char * const eventModify; // return in the data the new string inside it ...
|
|
||||||
private:
|
private:
|
||||||
ewol::object::Param<ewol::compositing::Shaper> m_shaper;
|
ewol::object::Param<ewol::compositing::Shaper> m_shaper;
|
||||||
int32_t m_colorIdTextFg; //!< color property of the text foreground
|
int32_t m_colorIdTextFg; //!< color property of the text foreground
|
||||||
@ -166,7 +166,6 @@ namespace ewol {
|
|||||||
virtual void onRegenerateDisplay();
|
virtual void onRegenerateDisplay();
|
||||||
virtual bool onEventInput(const ewol::event::Input& _event);
|
virtual bool onEventInput(const ewol::event::Input& _event);
|
||||||
virtual bool onEventEntry(const ewol::event::Entry& _event);
|
virtual bool onEventEntry(const ewol::event::Entry& _event);
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
|
||||||
virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID);
|
virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID);
|
||||||
virtual void calculateMinMaxSize();
|
virtual void calculateMinMaxSize();
|
||||||
protected: // Derived function
|
protected: // Derived function
|
||||||
@ -176,6 +175,13 @@ namespace ewol {
|
|||||||
virtual void changeStatusIn(int32_t _newStatusId);
|
virtual void changeStatusIn(int32_t _newStatusId);
|
||||||
virtual void periodicCall(const ewol::event::Time& _event);
|
virtual void periodicCall(const ewol::event::Time& _event);
|
||||||
virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer);
|
virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer);
|
||||||
|
private: // callback functions
|
||||||
|
void onCallbackShortCut(const std::string& _value);
|
||||||
|
void onCallbackEntryClean();
|
||||||
|
void onCallbackCut();
|
||||||
|
void onCallbackCopy();
|
||||||
|
void onCallbackPaste();
|
||||||
|
void onCallbackSelect(bool _all);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Image"
|
#define __class__ "Image"
|
||||||
|
|
||||||
const char * const ewol::widget::Image::eventPressed = "pressed";
|
|
||||||
|
|
||||||
ewol::widget::Image::Image() :
|
ewol::widget::Image::Image() :
|
||||||
|
signalPressed(*this, "pressed", "Image is pressed"),
|
||||||
m_colorProperty(nullptr),
|
m_colorProperty(nullptr),
|
||||||
m_colorId(-1),
|
m_colorId(-1),
|
||||||
m_fileName(*this, "src", "", "Image source path"),
|
m_fileName(*this, "src", "", "Image source path"),
|
||||||
@ -29,7 +28,6 @@ ewol::widget::Image::Image() :
|
|||||||
m_posStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"),
|
m_posStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"),
|
||||||
m_distanceFieldMode(*this, "distance-field", false, "Distance field mode") {
|
m_distanceFieldMode(*this, "distance-field", false, "Distance field mode") {
|
||||||
addObjectType("ewol::widget::Image");
|
addObjectType("ewol::widget::Image");
|
||||||
addEventId(eventPressed);
|
|
||||||
m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Image.json");
|
m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Image.json");
|
||||||
if (m_colorProperty != nullptr) {
|
if (m_colorProperty != nullptr) {
|
||||||
m_colorId = m_colorProperty->request("foreground");
|
m_colorId = m_colorProperty->request("foreground");
|
||||||
@ -135,7 +133,7 @@ bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) {
|
|||||||
//EWOL_DEBUG("Event on BT ...");
|
//EWOL_DEBUG("Event on BT ...");
|
||||||
if (1 == _event.getId()) {
|
if (1 == _event.getId()) {
|
||||||
if(ewol::key::statusSingle == _event.getStatus()) {
|
if(ewol::key::statusSingle == _event.getStatus()) {
|
||||||
generateEventId(eventPressed);
|
signalPressed.emit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <ewol/compositing/Image.h>
|
#include <ewol/compositing/Image.h>
|
||||||
#include <ewol/resource/ColorFile.h>
|
#include <ewol/resource/ColorFile.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -25,7 +26,7 @@ namespace ewol {
|
|||||||
class Image :public ewol::Widget {
|
class Image :public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventPressed;
|
ewol::object::Signal<void> signalPressed;
|
||||||
protected:
|
protected:
|
||||||
ewol::compositing::Image m_compositing; //!< compositing element of the image.
|
ewol::compositing::Image m_compositing; //!< compositing element of the image.
|
||||||
std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
|
std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
#include <ewol/compositing/Image.h>
|
#include <ewol/compositing/Image.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
|
||||||
const char * const ewol::widget::Joystick::eventEnable = "enable";
|
|
||||||
const char * const ewol::widget::Joystick::eventDisable = "disable";
|
|
||||||
const char * const ewol::widget::Joystick::eventMove = "move";
|
|
||||||
|
|
||||||
static bool l_displayBackground(true);
|
static bool l_displayBackground(true);
|
||||||
static std::string l_background("");
|
static std::string l_background("");
|
||||||
static std::string l_foreground("");
|
static std::string l_foreground("");
|
||||||
@ -24,11 +20,11 @@ static float l_ratio(1.0/7.0);
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Joystick"
|
#define __class__ "Joystick"
|
||||||
|
|
||||||
ewol::widget::Joystick::Joystick() {
|
ewol::widget::Joystick::Joystick() :
|
||||||
|
signalEnable(*this, "enable"),
|
||||||
|
signalDisable(*this, "disable"),
|
||||||
|
signalMove(*this, "move") {
|
||||||
addObjectType("ewol::widget::Joystick");
|
addObjectType("ewol::widget::Joystick");
|
||||||
addEventId(eventEnable);
|
|
||||||
addEventId(eventDisable);
|
|
||||||
addEventId(eventMove);
|
|
||||||
// by default the joy does not lock when free out
|
// by default the joy does not lock when free out
|
||||||
m_lock = false;
|
m_lock = false;
|
||||||
m_displayMode = modeNormal;
|
m_displayMode = modeNormal;
|
||||||
@ -148,10 +144,10 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
|
|||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
if(ewol::key::statusDown == typeEvent) {
|
if(ewol::key::statusDown == typeEvent) {
|
||||||
generateEventId(eventEnable);
|
signalEnable.emit();
|
||||||
} else {
|
} else {
|
||||||
std::string tmp = std::string("distance=") + std::string(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2);
|
std::string tmp = std::string("distance=") + std::string(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2);
|
||||||
generateEventId(eventMove, tmp);
|
signalMove.emit(m_angle+M_PI/2);
|
||||||
}
|
}
|
||||||
//teta += M_PI/2;
|
//teta += M_PI/2;
|
||||||
//EWOL_DEBUG("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance);
|
//EWOL_DEBUG("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance);
|
||||||
@ -167,7 +163,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
|
|||||||
m_distance = 0;
|
m_distance = 0;
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
generateEventId(eventDisable);
|
signalDisable.emit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <draw/Color.h>
|
#include <draw/Color.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -23,9 +24,9 @@ namespace ewol {
|
|||||||
class Joystick :public ewol::Widget {
|
class Joystick :public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventEnable;
|
ewol::object::Signal<void> signalEnable;
|
||||||
static const char * const eventDisable;
|
ewol::object::Signal<void> signalDisable;
|
||||||
static const char * const eventMove;
|
ewol::object::Signal<vec2> signalMove;
|
||||||
public:
|
public:
|
||||||
enum joystickMode {
|
enum joystickMode {
|
||||||
modeNormal,
|
modeNormal,
|
||||||
@ -34,7 +35,7 @@ namespace ewol {
|
|||||||
private:
|
private:
|
||||||
draw::Color m_colorFg; //!< Forground color
|
draw::Color m_colorFg; //!< Forground color
|
||||||
draw::Color m_colorBg; //!< Background color
|
draw::Color m_colorBg; //!< Background color
|
||||||
vec2 m_displayPos; //!< direction of the cursor ...
|
vec2 m_displayPos; //!< direction of the cursor ...
|
||||||
float m_distance; //!< dintance from the center
|
float m_distance; //!< dintance from the center
|
||||||
float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ...
|
float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ...
|
||||||
bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle
|
bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Label"
|
#define __class__ "Label"
|
||||||
|
|
||||||
const char * const ewol::widget::Label::eventPressed = "pressed";
|
|
||||||
|
|
||||||
// TODO : Remove the label name in the constructor ...
|
// TODO : Remove the label name in the constructor ...
|
||||||
ewol::widget::Label::Label() :
|
ewol::widget::Label::Label() :
|
||||||
|
signalPressed(*this, "pressed"),
|
||||||
m_label(*this, "value", U"", "displayed value string"),
|
m_label(*this, "value", U"", "displayed value string"),
|
||||||
m_colorProperty(nullptr),
|
m_colorProperty(nullptr),
|
||||||
m_colorDefaultFgText(-1),
|
m_colorDefaultFgText(-1),
|
||||||
@ -29,7 +28,6 @@ ewol::widget::Label::Label() :
|
|||||||
m_colorDefaultFgText = m_colorProperty->request("foreground");
|
m_colorDefaultFgText = m_colorProperty->request("foreground");
|
||||||
m_colorDefaultBgText = m_colorProperty->request("background");
|
m_colorDefaultBgText = m_colorProperty->request("background");
|
||||||
}
|
}
|
||||||
addEventId(eventPressed);
|
|
||||||
setCanHaveFocus(false);
|
setCanHaveFocus(false);
|
||||||
setMouseLimit(1);
|
setMouseLimit(1);
|
||||||
}
|
}
|
||||||
@ -126,7 +124,7 @@ bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) {
|
|||||||
if (1 == _event.getId()) {
|
if (1 == _event.getId()) {
|
||||||
if (ewol::key::statusSingle == _event.getStatus()) {
|
if (ewol::key::statusSingle == _event.getStatus()) {
|
||||||
// nothing to do ...
|
// nothing to do ...
|
||||||
generateEventId(eventPressed);
|
signalPressed.emit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
#include <ewol/resource/ColorFile.h>
|
#include <ewol/resource/ColorFile.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -24,7 +25,7 @@ namespace ewol {
|
|||||||
class Label : public ewol::Widget {
|
class Label : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventPressed;
|
ewol::object::Signal<void> signalPressed;
|
||||||
private:
|
private:
|
||||||
ewol::compositing::Text m_text; //!< Compositing text element.
|
ewol::compositing::Text m_text; //!< Compositing text element.
|
||||||
ewol::object::Param<std::u32string> m_label; //!< decorated text to display.
|
ewol::object::Param<std::u32string> m_label; //!< decorated text to display.
|
||||||
|
@ -15,13 +15,11 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ListFileSystem"
|
#define __class__ "ListFileSystem"
|
||||||
|
|
||||||
const char * const ewol::widget::ListFileSystem::eventFileSelect = "file-select";
|
|
||||||
const char * const ewol::widget::ListFileSystem::eventFileValidate = "file-validate";
|
|
||||||
const char * const ewol::widget::ListFileSystem::eventFolderSelect = "folder-select";
|
|
||||||
const char * const ewol::widget::ListFileSystem::eventFolderValidate = "folder-validate";
|
|
||||||
|
|
||||||
|
|
||||||
ewol::widget::ListFileSystem::ListFileSystem() :
|
ewol::widget::ListFileSystem::ListFileSystem() :
|
||||||
|
signalFileSelect(*this, "file-select"),
|
||||||
|
signalFileValidate(*this, "file-validate"),
|
||||||
|
signalFolderSelect(*this, "folder-select"),
|
||||||
|
signalFolderValidate(*this, "folder-validate"),
|
||||||
m_selectedLine(-1),
|
m_selectedLine(-1),
|
||||||
m_folder(*this, "path", "/", "Path to display"),
|
m_folder(*this, "path", "/", "Path to display"),
|
||||||
m_selectFile(*this, "select", "", "selection af a specific file"),
|
m_selectFile(*this, "select", "", "selection af a specific file"),
|
||||||
@ -40,11 +38,6 @@ ewol::widget::ListFileSystem::ListFileSystem() :
|
|||||||
m_colorIdBackground2 = m_colorProperty->request("background2");
|
m_colorIdBackground2 = m_colorProperty->request("background2");
|
||||||
m_colorIdBackgroundSelected = m_colorProperty->request("selected");
|
m_colorIdBackgroundSelected = m_colorProperty->request("selected");
|
||||||
}
|
}
|
||||||
addEventId(eventFileSelect);
|
|
||||||
addEventId(eventFileValidate);
|
|
||||||
addEventId(eventFolderSelect);
|
|
||||||
addEventId(eventFolderValidate);
|
|
||||||
|
|
||||||
setMouseLimit(1);
|
setMouseLimit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -180,7 +173,7 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_typeEvent == ewol::key::statusSingle) {
|
if (_typeEvent == ewol::key::statusSingle) {
|
||||||
EWOL_DEBUG("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
|
EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
|
||||||
if (1 == _IdInput) {
|
if (1 == _IdInput) {
|
||||||
int32_t previousRaw = m_selectedLine;
|
int32_t previousRaw = m_selectedLine;
|
||||||
if (_raw > (int32_t)m_list.size()+offset ) {
|
if (_raw > (int32_t)m_list.size()+offset ) {
|
||||||
@ -192,21 +185,21 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
|
|||||||
if( m_showFolder == true
|
if( m_showFolder == true
|
||||||
&& m_selectedLine == 0) {
|
&& m_selectedLine == 0) {
|
||||||
// "." folder
|
// "." folder
|
||||||
generateEventId(eventFolderSelect, ".");
|
signalFolderSelect.emit(".");
|
||||||
} else if ( m_showFolder == true
|
} else if ( m_showFolder == true
|
||||||
&& m_selectedLine == 1) {
|
&& m_selectedLine == 1) {
|
||||||
// ".." folder
|
// ".." folder
|
||||||
generateEventId(eventFolderSelect, "..");
|
signalFolderSelect.emit("..");
|
||||||
} else if( m_selectedLine-offset >= 0
|
} else if( m_selectedLine-offset >= 0
|
||||||
&& m_selectedLine-offset < (int32_t)m_list.size()
|
&& m_selectedLine-offset < (int32_t)m_list.size()
|
||||||
&& nullptr != m_list[m_selectedLine-offset] ) {
|
&& nullptr != m_list[m_selectedLine-offset] ) {
|
||||||
// generate event extern :
|
// generate event extern :
|
||||||
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
||||||
case etk::FSN_FILE :
|
case etk::FSN_FILE :
|
||||||
generateEventId(eventFileSelect, m_list[m_selectedLine-offset]->getNameFile());
|
signalFileSelect.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||||
break;
|
break;
|
||||||
case etk::FSN_FOLDER :
|
case etk::FSN_FOLDER :
|
||||||
generateEventId(eventFolderSelect, m_list[m_selectedLine-offset]->getNameFile());
|
signalFolderSelect.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
EWOL_ERROR("Can not generate event on an unknow type");
|
EWOL_ERROR("Can not generate event on an unknow type");
|
||||||
@ -217,21 +210,20 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
|
|||||||
if( m_showFolder == true
|
if( m_showFolder == true
|
||||||
&& m_selectedLine == 0) {
|
&& m_selectedLine == 0) {
|
||||||
// "." folder
|
// "." folder
|
||||||
generateEventId(eventFolderValidate, ".");
|
signalFolderValidate.emit(".");
|
||||||
} else if ( m_showFolder == true
|
} else if ( m_showFolder == true
|
||||||
&& m_selectedLine == 1) {
|
&& m_selectedLine == 1) {
|
||||||
// ".." folder
|
// ".." folder
|
||||||
generateEventId(eventFolderValidate, "..");
|
signalFolderValidate.emit("..");
|
||||||
} else if( m_selectedLine-offset >= 0
|
} else if( m_selectedLine-offset >= 0
|
||||||
&& m_selectedLine-offset < (int32_t)m_list.size()
|
&& m_selectedLine-offset < (int32_t)m_list.size()
|
||||||
&& nullptr != m_list[m_selectedLine-offset] ) {
|
&& nullptr != m_list[m_selectedLine-offset] ) {
|
||||||
switch(m_list[m_selectedLine-offset]->getNodeType())
|
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
||||||
{
|
|
||||||
case etk::FSN_FILE :
|
case etk::FSN_FILE :
|
||||||
generateEventId(eventFileValidate, m_list[m_selectedLine-offset]->getNameFile());
|
signalFileValidate.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||||
break;
|
break;
|
||||||
case etk::FSN_FOLDER :
|
case etk::FSN_FOLDER :
|
||||||
generateEventId(eventFolderValidate, m_list[m_selectedLine-offset]->getNameFile());
|
signalFolderValidate.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
EWOL_ERROR("Can not generate event on an unknow type");
|
EWOL_ERROR("Can not generate event on an unknow type");
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <ewol/widget/List.h>
|
#include <ewol/widget/List.h>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.h>
|
||||||
#include <ewol/resource/ColorFile.h>
|
#include <ewol/resource/ColorFile.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -21,10 +22,10 @@ namespace ewol {
|
|||||||
class ListFileSystem : public ewol::widget::List {
|
class ListFileSystem : public ewol::widget::List {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventFileSelect; //!< @event "file-select" Generated when a file is selected.
|
ewol::object::Signal<std::string> signalFileSelect; //!< @event "file-select" Generated when a file is selected.
|
||||||
static const char * const eventFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
ewol::object::Signal<std::string> signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
||||||
static const char * const eventFolderSelect;
|
ewol::object::Signal<std::string> signalFolderSelect;
|
||||||
static const char * const eventFolderValidate;
|
ewol::object::Signal<std::string> signalFolderValidate;
|
||||||
protected:
|
protected:
|
||||||
ListFileSystem();
|
ListFileSystem();
|
||||||
void init();
|
void init();
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <etk/Hash.h>
|
#include <etk/Hash.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/object/RemoveEvent.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Menu"
|
#define __class__ "Menu"
|
||||||
|
|
||||||
ewol::widget::Menu::Menu() {
|
ewol::widget::Menu::Menu() :
|
||||||
|
signalSelect(*this, "select") {
|
||||||
addObjectType("ewol::widget::Menu");
|
addObjectType("ewol::widget::Menu");
|
||||||
m_staticId = 0;
|
m_staticId = 666;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Menu::init() {
|
void ewol::widget::Menu::init() {
|
||||||
@ -53,24 +54,37 @@ void ewol::widget::Menu::clear() {
|
|||||||
m_listElement.clear();
|
m_listElement.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::widget::Menu::addTitle(std::string _label,
|
int32_t ewol::widget::Menu::addTitle(const std::string& _label,
|
||||||
std::string _image,
|
const std::string& _image,
|
||||||
const char * _generateEvent,
|
const std::string& _message) {
|
||||||
const std::string _message) {
|
return add(-1, _label, _image, _message);
|
||||||
return add(-1, _label, _image, _generateEvent, _message);
|
}
|
||||||
|
|
||||||
|
static const char* eventButtonPressed = "menu-local-pressed";
|
||||||
|
|
||||||
|
int32_t ewol::widget::Menu::get(const std::string& _label) {
|
||||||
|
for (auto &it : m_listElement) {
|
||||||
|
if (it.m_label == _label) {
|
||||||
|
return it.m_localId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::widget::Menu::add(int32_t _parent,
|
int32_t ewol::widget::Menu::add(int32_t _parent,
|
||||||
std::string _label,
|
const std::string& _label,
|
||||||
std::string _image,
|
const std::string& _image,
|
||||||
const char *_generateEvent,
|
const std::string& _message) {
|
||||||
const std::string _message) {
|
// try to find one already created :
|
||||||
|
int32_t previous = get(_label);
|
||||||
|
if (previous != -1) {
|
||||||
|
return previous;
|
||||||
|
}
|
||||||
ewol::widget::MenuElement tmpObject;
|
ewol::widget::MenuElement tmpObject;
|
||||||
tmpObject.m_localId = m_staticId++;
|
tmpObject.m_localId = m_staticId++;
|
||||||
tmpObject.m_parentId = _parent;
|
tmpObject.m_parentId = _parent;
|
||||||
tmpObject.m_label = std::string("<left>") + _label + "</left>";
|
tmpObject.m_label = _label;
|
||||||
tmpObject.m_image = _image;
|
tmpObject.m_image = _image;
|
||||||
tmpObject.m_generateEvent = _generateEvent;
|
|
||||||
tmpObject.m_message = _message;
|
tmpObject.m_message = _message;
|
||||||
if (-1 == tmpObject.m_parentId) {
|
if (-1 == tmpObject.m_parentId) {
|
||||||
std::shared_ptr<ewol::widget::Button> myButton = ewol::widget::Button::create();
|
std::shared_ptr<ewol::widget::Button> myButton = ewol::widget::Button::create();
|
||||||
@ -85,155 +99,156 @@ int32_t ewol::widget::Menu::add(int32_t _parent,
|
|||||||
} else {
|
} else {
|
||||||
composeString+=" <image src=\"" + tmpObject.m_image + "\" size=\"8,8mm\"/>\n";
|
composeString+=" <image src=\"" + tmpObject.m_image + "\" size=\"8,8mm\"/>\n";
|
||||||
}
|
}
|
||||||
composeString+=" <label>" + tmpObject.m_label + "</label>\n";
|
composeString+=" <label><left>" + tmpObject.m_label + "</left></label>\n";
|
||||||
composeString+="</sizer>\n";
|
composeString+="</sizer>\n";
|
||||||
myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString));
|
myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString));
|
||||||
} else {
|
} else {
|
||||||
myButton->setSubWidget(ewol::widget::Label::create(tmpObject.m_label) );
|
myButton->setSubWidget(ewol::widget::Label::create("<left>" + tmpObject.m_label + "</left>") );
|
||||||
}
|
}
|
||||||
|
|
||||||
// add it in the widget list
|
// add it in the widget list
|
||||||
ewol::widget::Sizer::subWidgetAdd(myButton);
|
ewol::widget::Sizer::subWidgetAdd(myButton);
|
||||||
// keep the specific event ...
|
// keep the specific event ...
|
||||||
myButton->registerOnEvent(shared_from_this(), ewol::widget::Button::eventPressed, widget::Button::eventPressed);
|
myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr<ewol::widget::Button>(myButton)));
|
||||||
tmpObject.m_widgetPointer = myButton;
|
tmpObject.m_widgetPointer = myButton;
|
||||||
}
|
}
|
||||||
m_listElement.push_back(tmpObject);
|
m_listElement.push_back(tmpObject);
|
||||||
return tmpObject.m_localId;
|
return tmpObject.m_localId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Menu::addSpacer() {
|
void ewol::widget::Menu::remove(int32_t _id) {
|
||||||
EWOL_TODO("NOT now...");
|
EWOL_TODO("NOT remove...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) {
|
int32_t ewol::widget::Menu::addSpacer() {
|
||||||
/*
|
EWOL_TODO("NOT addSpacer...");
|
||||||
if (true == ewol::sizer::onReceiveMessage(_msg) {
|
return -1;
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
void ewol::widget::Menu::onButtonPressed(std::weak_ptr<ewol::widget::Button> _button) {
|
||||||
|
std::shared_ptr<ewol::widget::Button> caller = _button.lock();
|
||||||
|
if (caller == nullptr) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
*/
|
for (auto &it : m_listElement) {
|
||||||
EWOL_ERROR(" receive message : " << _msg);
|
if (caller == it.m_widgetPointer.lock()) {
|
||||||
if (_msg.getMessage() == ewol::widget::Button::eventPressed) {
|
// 2 posible case (have a message or have a child ...
|
||||||
for (auto &it : m_listElement) {
|
if (it.m_message.size() > 0) {
|
||||||
if (_msg.getCaller() == it.m_widgetPointer.lock()) {
|
EWOL_DEBUG("Menu == > generate Event");
|
||||||
// 2 posible case (have a message or have a child ...
|
// Send a multicast event ...
|
||||||
if (it.m_generateEvent != nullptr) {
|
signalSelect.emit(it.m_message);
|
||||||
EWOL_DEBUG("Menu == > generate Event");
|
std::shared_ptr<ewol::widget::ContextMenu> tmpContext = m_widgetContextMenu.lock();
|
||||||
// Send a multicast event ...
|
if (tmpContext != nullptr) {
|
||||||
sendMultiCast(it.m_generateEvent, it.m_message);
|
EWOL_DEBUG("Mark the menu to remove ...");
|
||||||
std::shared_ptr<ewol::widget::ContextMenu> tmpContext = m_widgetContextMenu.lock();
|
tmpContext->destroy();
|
||||||
if (tmpContext != nullptr) {
|
|
||||||
EWOL_DEBUG("Mark the menu to remove ...");
|
|
||||||
tmpContext->destroy();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else{
|
|
||||||
EWOL_DEBUG("Menu == > load Sub Menu");
|
|
||||||
bool findChild = false;
|
|
||||||
for (auto &it2 : m_listElement) {
|
|
||||||
if (it.m_localId == it2.m_parentId) {
|
|
||||||
findChild = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (false == findChild) {
|
|
||||||
EWOL_WARNING("Event on menu element with no child an no event... label=" << it.m_label);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// create a context menu :
|
|
||||||
std::shared_ptr<ewol::widget::ContextMenu> tmpContext = ewol::widget::ContextMenu::create();
|
|
||||||
m_widgetContextMenu = tmpContext;
|
|
||||||
if (tmpContext == nullptr) {
|
|
||||||
EWOL_ERROR("Allocation Error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// get the button widget :
|
|
||||||
vec2 newPosition;
|
|
||||||
std::shared_ptr<ewol::Widget> eventFromWidget = std::dynamic_pointer_cast<ewol::Widget>(_msg.getCaller());
|
|
||||||
if (eventFromWidget != nullptr) {
|
|
||||||
vec2 tmpOri = eventFromWidget->getOrigin();
|
|
||||||
vec2 tmpSize = eventFromWidget->getSize();
|
|
||||||
// calculate the correct position
|
|
||||||
newPosition.setValue(tmpOri.x() + tmpSize.x()/2,
|
|
||||||
tmpOri.y() );
|
|
||||||
}
|
|
||||||
tmpContext->setPositionMark(ewol::widget::ContextMenu::markTop, newPosition );
|
|
||||||
|
|
||||||
std::shared_ptr<ewol::widget::Sizer> mySizer;
|
|
||||||
std::shared_ptr<ewol::widget::Button> myButton;
|
|
||||||
|
|
||||||
mySizer = ewol::widget::Sizer::create(widget::Sizer::modeVert);
|
|
||||||
if (nullptr != mySizer) {
|
|
||||||
mySizer->lockExpand(vec2(true,true));
|
|
||||||
// set it in the pop-up-system :
|
|
||||||
tmpContext->setSubWidget(mySizer);
|
|
||||||
|
|
||||||
bool menuHaveImage = false;
|
|
||||||
for (auto &it2 : m_listElement) {
|
|
||||||
if (it.m_localId == it2.m_parentId) {
|
|
||||||
if (it2.m_image.size()!=0) {
|
|
||||||
menuHaveImage = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto it2=m_listElement.rbegin(); it2!=m_listElement.rend() ; ++it2) {
|
|
||||||
if (it.m_localId == it2->m_parentId) {
|
|
||||||
myButton = ewol::widget::Button::create();
|
|
||||||
if (myButton == nullptr) {
|
|
||||||
EWOL_ERROR("Allocation Error");
|
|
||||||
} else {
|
|
||||||
if (it2->m_image.size()!=0) {
|
|
||||||
std::string composeString = "<composer expand=\"true,false\" fill=\"true,true\">\n";
|
|
||||||
composeString+= " <sizer mode=\"hori\" expand=\"true,false\" fill=\"true,true\" lock=\"true\">\n";
|
|
||||||
if (etk::end_with(it2->m_image, ".edf") == true) {
|
|
||||||
composeString+=" <image src=\"" + it2->m_image + "\" size=\"8,8mm\" distance-field='true'/>\n";
|
|
||||||
} else {
|
|
||||||
composeString+=" <image src=\"" + it2->m_image + "\" size=\"8,8mm\"/>\n";
|
|
||||||
}
|
|
||||||
composeString+=" <label exand=\"true,true\" fill=\"true,true\">" + it2->m_label + "</label>\n";
|
|
||||||
composeString+=" </sizer>\n";
|
|
||||||
composeString+="</composer>\n";
|
|
||||||
myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString));
|
|
||||||
} else {
|
|
||||||
if (true == menuHaveImage) {
|
|
||||||
myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String,
|
|
||||||
std::string("<composer expand=\"true,false\" fill=\"true,true\">\n") +
|
|
||||||
" <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[" + it2->m_label + "]]></label>\n"
|
|
||||||
" </sizer>\n"
|
|
||||||
"</composer>\n"));
|
|
||||||
} else {
|
|
||||||
std::shared_ptr<ewol::widget::Label> tmpLabel = widget::Label::create(std::string("<left>") + it2->m_label + "</left>\n");
|
|
||||||
if (tmpLabel != nullptr) {
|
|
||||||
tmpLabel->setExpand(bvec2(true,false));
|
|
||||||
tmpLabel->setFill(bvec2(true,true));
|
|
||||||
myButton->setSubWidget(tmpLabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// set the image if one is present ...
|
|
||||||
myButton->registerOnEvent(shared_from_this(), ewol::widget::Button::eventPressed, widget::Button::eventPressed);
|
|
||||||
myButton->setExpand(bvec2(true,false));
|
|
||||||
myButton->setFill(bvec2(true,false));
|
|
||||||
// add it in the widget list
|
|
||||||
mySizer->subWidgetAdd(myButton);
|
|
||||||
it2->m_widgetPointer = myButton;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows();
|
|
||||||
if (currentWindows == nullptr) {
|
|
||||||
EWOL_ERROR("Can not get the curent Windows...");
|
|
||||||
} else {
|
|
||||||
currentWindows->popUpWidgetPush(tmpContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else{
|
||||||
|
EWOL_DEBUG("Menu == > load Sub Menu");
|
||||||
|
bool findChild = false;
|
||||||
|
for (auto &it2 : m_listElement) {
|
||||||
|
if (it.m_localId == it2.m_parentId) {
|
||||||
|
findChild = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false == findChild) {
|
||||||
|
EWOL_WARNING("Event on menu element with no child an no event... label=" << it.m_label);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// create a context menu :
|
||||||
|
std::shared_ptr<ewol::widget::ContextMenu> tmpContext = ewol::widget::ContextMenu::create();
|
||||||
|
m_widgetContextMenu = tmpContext;
|
||||||
|
if (tmpContext == nullptr) {
|
||||||
|
EWOL_ERROR("Allocation Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// get the button widget :
|
||||||
|
vec2 newPosition;
|
||||||
|
std::shared_ptr<ewol::Widget> eventFromWidget = std::dynamic_pointer_cast<ewol::Widget>(caller);
|
||||||
|
if (eventFromWidget != nullptr) {
|
||||||
|
vec2 tmpOri = eventFromWidget->getOrigin();
|
||||||
|
vec2 tmpSize = eventFromWidget->getSize();
|
||||||
|
// calculate the correct position
|
||||||
|
newPosition.setValue(tmpOri.x() + tmpSize.x()/2,
|
||||||
|
tmpOri.y() );
|
||||||
|
}
|
||||||
|
tmpContext->setPositionMark(ewol::widget::ContextMenu::markTop, newPosition );
|
||||||
|
|
||||||
|
std::shared_ptr<ewol::widget::Sizer> mySizer;
|
||||||
|
std::shared_ptr<ewol::widget::Button> myButton;
|
||||||
|
|
||||||
|
mySizer = ewol::widget::Sizer::create(widget::Sizer::modeVert);
|
||||||
|
if (nullptr != mySizer) {
|
||||||
|
mySizer->lockExpand(vec2(true,true));
|
||||||
|
// set it in the pop-up-system :
|
||||||
|
tmpContext->setSubWidget(mySizer);
|
||||||
|
|
||||||
|
bool menuHaveImage = false;
|
||||||
|
for (auto &it2 : m_listElement) {
|
||||||
|
if (it.m_localId == it2.m_parentId) {
|
||||||
|
if (it2.m_image.size()!=0) {
|
||||||
|
menuHaveImage = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto it2=m_listElement.rbegin(); it2!=m_listElement.rend() ; ++it2) {
|
||||||
|
if (it.m_localId == it2->m_parentId) {
|
||||||
|
myButton = ewol::widget::Button::create();
|
||||||
|
if (myButton == nullptr) {
|
||||||
|
EWOL_ERROR("Allocation Error");
|
||||||
|
} else {
|
||||||
|
if (it2->m_image.size()!=0) {
|
||||||
|
std::string composeString = "<composer expand=\"true,false\" fill=\"true,true\">\n";
|
||||||
|
composeString+= " <sizer mode=\"hori\" expand=\"true,false\" fill=\"true,true\" lock=\"true\">\n";
|
||||||
|
if (etk::end_with(it2->m_image, ".edf") == true) {
|
||||||
|
composeString+=" <image src=\"" + it2->m_image + "\" size=\"8,8mm\" distance-field='true'/>\n";
|
||||||
|
} else {
|
||||||
|
composeString+=" <image src=\"" + it2->m_image + "\" size=\"8,8mm\"/>\n";
|
||||||
|
}
|
||||||
|
composeString+=" <label exand=\"true,true\" fill=\"true,true\"><left>" + it2->m_label + "</left></label>\n";
|
||||||
|
composeString+=" </sizer>\n";
|
||||||
|
composeString+="</composer>\n";
|
||||||
|
myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, composeString));
|
||||||
|
} else {
|
||||||
|
if (true == menuHaveImage) {
|
||||||
|
myButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String,
|
||||||
|
std::string("<composer expand=\"true,false\" fill=\"true,true\">\n") +
|
||||||
|
" <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>" + it2->m_label + "</left>]]></label>\n"
|
||||||
|
" </sizer>\n"
|
||||||
|
"</composer>\n"));
|
||||||
|
} else {
|
||||||
|
std::shared_ptr<ewol::widget::Label> tmpLabel = widget::Label::create(std::string("<left>") + it2->m_label + "</left>\n");
|
||||||
|
if (tmpLabel != nullptr) {
|
||||||
|
tmpLabel->setExpand(bvec2(true,false));
|
||||||
|
tmpLabel->setFill(bvec2(true,true));
|
||||||
|
myButton->setSubWidget(tmpLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set the image if one is present ...
|
||||||
|
//myButton->registerOnEvent(shared_from_this(), "pressed", eventButtonPressed);
|
||||||
|
myButton->signalPressed.connect(shared_from_this(), std::bind(&ewol::widget::Menu::onButtonPressed, this, std::weak_ptr<ewol::widget::Button>(myButton)));
|
||||||
|
myButton->setExpand(bvec2(true,false));
|
||||||
|
myButton->setFill(bvec2(true,false));
|
||||||
|
// add it in the widget list
|
||||||
|
mySizer->subWidgetAdd(myButton);
|
||||||
|
it2->m_widgetPointer = myButton;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows();
|
||||||
|
if (currentWindows == nullptr) {
|
||||||
|
EWOL_ERROR("Can not get the curent Windows...");
|
||||||
|
} else {
|
||||||
|
currentWindows->popUpWidgetPush(tmpContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
|
#include <ewol/widget/Button.h>
|
||||||
#include <ewol/widget/Sizer.h>
|
#include <ewol/widget/Sizer.h>
|
||||||
#include <ewol/widget/ContextMenu.h>
|
#include <ewol/widget/ContextMenu.h>
|
||||||
|
|
||||||
@ -26,13 +27,14 @@ namespace ewol {
|
|||||||
std::weak_ptr<ewol::Widget> m_widgetPointer;
|
std::weak_ptr<ewol::Widget> m_widgetPointer;
|
||||||
std::string m_label;
|
std::string m_label;
|
||||||
std::string m_image;
|
std::string m_image;
|
||||||
const char* m_generateEvent;
|
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @ingroup ewolWidgetGroup
|
* @ingroup ewolWidgetGroup
|
||||||
*/
|
*/
|
||||||
class Menu :public ewol::widget::Sizer {
|
class Menu :public ewol::widget::Sizer {
|
||||||
|
public:
|
||||||
|
ewol::object::Signal<std::string> signalSelect; // event on a menu button or ...
|
||||||
protected:
|
protected:
|
||||||
Menu();
|
Menu();
|
||||||
void init();
|
void init();
|
||||||
@ -48,13 +50,15 @@ namespace ewol {
|
|||||||
std::vector<ewol::widget::MenuElement> m_listElement;
|
std::vector<ewol::widget::MenuElement> m_listElement;
|
||||||
int32_t m_staticId; // unique ID for every element of the menu ...
|
int32_t m_staticId; // unique ID for every element of the menu ...
|
||||||
std::weak_ptr<ewol::widget::ContextMenu> m_widgetContextMenu;
|
std::weak_ptr<ewol::widget::ContextMenu> m_widgetContextMenu;
|
||||||
|
int32_t get(const std::string& _label);
|
||||||
public:
|
public:
|
||||||
void clear();
|
void clear();
|
||||||
int32_t addTitle(std::string _label, std::string _image="", const char * _generateEvent = nullptr, const std::string _message = "");
|
int32_t addTitle(const std::string& _label, const std::string& _image="", const std::string& _message = "");
|
||||||
int32_t add(int32_t _parent, std::string _label, std::string _image="", const char * _generateEvent = nullptr, const std::string _message = "");
|
int32_t add(int32_t _parent, const std::string& _label, const std::string& _image="", const std::string& _message = "");
|
||||||
void addSpacer();
|
int32_t addSpacer();
|
||||||
// Derived function
|
void remove(int32_t _id);
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
private:
|
||||||
|
void onButtonPressed(std::weak_ptr<ewol::widget::Button> _button);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -10,16 +10,14 @@
|
|||||||
|
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
|
||||||
const char * const ewol::widget::Slider::eventChange = "change";
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Slider"
|
#define __class__ "Slider"
|
||||||
|
|
||||||
const int32_t dotRadius = 6;
|
const int32_t dotRadius = 6;
|
||||||
|
|
||||||
ewol::widget::Slider::Slider() {
|
ewol::widget::Slider::Slider() :
|
||||||
|
signalChange(*this, "change") {
|
||||||
addObjectType("ewol::widget::Slider");
|
addObjectType("ewol::widget::Slider");
|
||||||
addEventId(eventChange);
|
|
||||||
|
|
||||||
m_value = 0;
|
m_value = 0;
|
||||||
m_min = 0;
|
m_min = 0;
|
||||||
@ -109,7 +107,7 @@ bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) {
|
|||||||
m_value = std::max(std::min(m_value, m_max), m_min);
|
m_value = std::max(std::min(m_value, m_max), m_min);
|
||||||
if (oldValue != m_value) {
|
if (oldValue != m_value) {
|
||||||
EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
|
EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
|
||||||
generateEventId(eventChange, etk::to_string(m_value));
|
signalChange.emit(m_value);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
#include <ewol/compositing/Drawing.h>
|
#include <ewol/compositing/Drawing.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -23,7 +24,7 @@ namespace ewol {
|
|||||||
class Slider : public ewol::Widget {
|
class Slider : public ewol::Widget {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventChange;
|
ewol::object::Signal<int32_t> signalChange;
|
||||||
protected:
|
protected:
|
||||||
Slider();
|
Slider();
|
||||||
void init();
|
void init();
|
||||||
|
@ -23,11 +23,9 @@ std::ostream& operator <<(std::ostream& _os, const enum ewol::widget::WSlider::s
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "WSlider"
|
#define __class__ "WSlider"
|
||||||
|
|
||||||
// Event list of properties
|
|
||||||
const char* const ewol::widget::WSlider::eventStartSlide = "ewol-widget-wslider-event-start-slide";
|
|
||||||
const char* const ewol::widget::WSlider::eventStopSlide = "ewol-widget-wslider-event-stop-slide";
|
|
||||||
|
|
||||||
ewol::widget::WSlider::WSlider() :
|
ewol::widget::WSlider::WSlider() :
|
||||||
|
signalStartSlide(*this, "start"),
|
||||||
|
signalStopSlide(*this, "stop"),
|
||||||
m_windowsSources(0),
|
m_windowsSources(0),
|
||||||
m_windowsDestination(0),
|
m_windowsDestination(0),
|
||||||
m_windowsRequested(-1),
|
m_windowsRequested(-1),
|
||||||
@ -36,8 +34,6 @@ ewol::widget::WSlider::WSlider() :
|
|||||||
m_transitionSpeed(*this, "speed", 1.0f, 0.0f, 200.0f, "Transition speed of the slider"),
|
m_transitionSpeed(*this, "speed", 1.0f, 0.0f, 200.0f, "Transition speed of the slider"),
|
||||||
m_transitionSlide(*this, "mode", sladingTransitionHori, "Transition mode of the slider") {
|
m_transitionSlide(*this, "mode", sladingTransitionHori, "Transition mode of the slider") {
|
||||||
addObjectType("ewol::widget::WSlider");
|
addObjectType("ewol::widget::WSlider");
|
||||||
addEventId(eventStartSlide);
|
|
||||||
addEventId(eventStopSlide);
|
|
||||||
m_transitionSlide.add(sladingTransitionVert, "vert");
|
m_transitionSlide.add(sladingTransitionVert, "vert");
|
||||||
m_transitionSlide.add(sladingTransitionHori, "hori");
|
m_transitionSlide.add(sladingTransitionHori, "hori");
|
||||||
}
|
}
|
||||||
@ -105,7 +101,7 @@ void ewol::widget::WSlider::subWidgetSelectSetVectorId(int32_t _id) {
|
|||||||
}
|
}
|
||||||
if (_id != m_windowsDestination) {
|
if (_id != m_windowsDestination) {
|
||||||
m_windowsRequested = _id;
|
m_windowsRequested = _id;
|
||||||
generateEventId(eventStartSlide);
|
signalStartSlide.emit();
|
||||||
periodicCallEnable();
|
periodicCallEnable();
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
@ -189,7 +185,7 @@ void ewol::widget::WSlider::periodicCall(const ewol::event::Time& _event) {
|
|||||||
} else {
|
} else {
|
||||||
// end of periodic :
|
// end of periodic :
|
||||||
periodicCallDisable();
|
periodicCallDisable();
|
||||||
generateEventId(eventStopSlide);
|
signalStopSlide.emit();
|
||||||
}
|
}
|
||||||
m_windowsRequested = -1;
|
m_windowsRequested = -1;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/ContainerN.h>
|
#include <ewol/widget/ContainerN.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -22,8 +23,8 @@ namespace ewol {
|
|||||||
class WSlider :public ewol::widget::ContainerN {
|
class WSlider :public ewol::widget::ContainerN {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char* const eventStartSlide;
|
ewol::object::Signal<void> signalStartSlide;
|
||||||
static const char* const eventStopSlide;
|
ewol::object::Signal<void> signalStopSlide;
|
||||||
enum sladingMode {
|
enum sladingMode {
|
||||||
sladingTransitionVert,
|
sladingTransitionVert,
|
||||||
sladingTransitionHori,
|
sladingTransitionHori,
|
||||||
|
@ -86,11 +86,6 @@ std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::gravity _obj
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Widget"
|
#define __class__ "Widget"
|
||||||
|
|
||||||
// event generated :
|
|
||||||
const char* const ewol::Widget::eventAnnimationStart = "annimation-start";
|
|
||||||
const char* const ewol::Widget::eventAnnimationRatio = "annimation-ratio";
|
|
||||||
const char* const ewol::Widget::eventAnnimationStop = "annimation-stop";
|
|
||||||
|
|
||||||
ewol::Widget::Widget() :
|
ewol::Widget::Widget() :
|
||||||
m_size(10,10),
|
m_size(10,10),
|
||||||
m_minSize(0,0),
|
m_minSize(0,0),
|
||||||
@ -110,9 +105,13 @@ ewol::Widget::Widget() :
|
|||||||
m_allowRepeateKeyboardEvent(true),
|
m_allowRepeateKeyboardEvent(true),
|
||||||
m_periodicCallDeltaTime(-1),
|
m_periodicCallDeltaTime(-1),
|
||||||
m_periodicCallTime(0),
|
m_periodicCallTime(0),
|
||||||
|
signalShortcut(*this, "shortcut"),
|
||||||
m_needRegenerateDisplay(true),
|
m_needRegenerateDisplay(true),
|
||||||
m_grabCursor(false),
|
m_grabCursor(false),
|
||||||
m_cursorDisplay(ewol::context::cursorArrow),
|
m_cursorDisplay(ewol::context::cursorArrow),
|
||||||
|
signalAnnimationStart(*this, "annimation-start"),
|
||||||
|
signalAnnimationRatio(*this, "annimation-ratio"),
|
||||||
|
signalAnnimationStop(*this, "annimation-stop"),
|
||||||
m_annimationMode(annimationModeDisable),
|
m_annimationMode(annimationModeDisable),
|
||||||
m_annimationratio(0.0f),
|
m_annimationratio(0.0f),
|
||||||
m_annimationTypeStart(*this, "annimation-start-type", 0, "Annimation type, when adding/show a widget"),
|
m_annimationTypeStart(*this, "annimation-start-type", 0, "Annimation type, when adding/show a widget"),
|
||||||
@ -133,10 +132,6 @@ ewol::Widget::Widget() :
|
|||||||
m_gravity.add(ewol::gravityLeft, "left");
|
m_gravity.add(ewol::gravityLeft, "left");
|
||||||
m_annimationTypeStart.add(0, "none");
|
m_annimationTypeStart.add(0, "none");
|
||||||
m_annimationTypeStop.add(0, "none");
|
m_annimationTypeStop.add(0, "none");
|
||||||
|
|
||||||
addEventId(eventAnnimationStart);
|
|
||||||
addEventId(eventAnnimationRatio);
|
|
||||||
addEventId(eventAnnimationStop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::Widget::init() {
|
void ewol::Widget::init() {
|
||||||
@ -431,12 +426,8 @@ const bvec2& ewol::Widget::canFill() {
|
|||||||
// -- Shortcut : management of the shortcut
|
// -- Shortcut : management of the shortcut
|
||||||
// ----------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void ewol::Widget::shortCutAdd(const char * _descriptiveString,
|
void ewol::Widget::shortCutAdd(const std::string& _descriptiveString, const std::string& _message) {
|
||||||
const char * _generateEventId,
|
if (_descriptiveString.size() == 0) {
|
||||||
std::string _data,
|
|
||||||
bool _broadcast) {
|
|
||||||
if ( _descriptiveString == nullptr
|
|
||||||
|| strlen(_descriptiveString) == 0) {
|
|
||||||
EWOL_ERROR("try to add shortcut with no descriptive string ...");
|
EWOL_ERROR("try to add shortcut with no descriptive string ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -445,94 +436,105 @@ void ewol::Widget::shortCutAdd(const char * _descriptiveString,
|
|||||||
EWOL_ERROR("allocation error ... Memory error ...");
|
EWOL_ERROR("allocation error ... Memory error ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmpElement->broadcastEvent = _broadcast;
|
if (_message.size() == 0) {
|
||||||
tmpElement->generateEventId = _generateEventId;
|
tmpElement->message = _descriptiveString;
|
||||||
tmpElement->eventData = _data;
|
} else {
|
||||||
|
tmpElement->message = _message;
|
||||||
|
}
|
||||||
// parsing of the string :
|
// parsing of the string :
|
||||||
//"ctrl+shift+alt+meta+s"
|
//"ctrl+shift+alt+meta+s"
|
||||||
const char * tmp = strstr(_descriptiveString, "ctrl");
|
if(_descriptiveString.find("ctrl") != std::string::npos) {
|
||||||
if(nullptr != tmp) {
|
|
||||||
tmpElement->specialKey.setCtrl(true);
|
tmpElement->specialKey.setCtrl(true);
|
||||||
}
|
}
|
||||||
tmp = strstr(_descriptiveString, "shift");
|
if(_descriptiveString.find("shift") != std::string::npos) {
|
||||||
if(nullptr != tmp) {
|
|
||||||
tmpElement->specialKey.setShift(true);
|
tmpElement->specialKey.setShift(true);
|
||||||
}
|
}
|
||||||
tmp = strstr(_descriptiveString, "alt");
|
if(_descriptiveString.find("alt") != std::string::npos) {
|
||||||
if(nullptr != tmp) {
|
|
||||||
tmpElement->specialKey.setAlt(true);
|
tmpElement->specialKey.setAlt(true);
|
||||||
}
|
}
|
||||||
tmp = strstr(_descriptiveString, "meta");
|
if(_descriptiveString.find("meta") != std::string::npos) {
|
||||||
if(nullptr != tmp) {
|
|
||||||
tmpElement->specialKey.setMeta(true);
|
tmpElement->specialKey.setMeta(true);
|
||||||
}
|
}
|
||||||
if(nullptr != strstr(_descriptiveString, "F12") ) {
|
if(_descriptiveString.find("F12") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF12;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF12;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F11") ) {
|
} else if(_descriptiveString.find("F11") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF11;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF11;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F10") ) {
|
} else if(_descriptiveString.find("F10") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF10;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF10;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F9") ) {
|
} else if(_descriptiveString.find("F9") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF9;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF9;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F8") ) {
|
} else if(_descriptiveString.find("F8") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF8;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF8;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F7") ) {
|
} else if(_descriptiveString.find("F7") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF7;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF7;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F6") ) {
|
} else if(_descriptiveString.find("F6") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF6;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF6;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F5") ) {
|
} else if(_descriptiveString.find("F5") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF5;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF5;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F4") ) {
|
} else if(_descriptiveString.find("F4") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF4;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF4;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F3") ) {
|
} else if(_descriptiveString.find("F3") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF3;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF3;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F2") ) {
|
} else if(_descriptiveString.find("F2") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF2;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF2;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "F1") ) {
|
} else if(_descriptiveString.find("F1") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardF1;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardF1;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "LEFT") ) {
|
} else if(_descriptiveString.find("LEFT") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardLeft;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardLeft;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "RIGHT") ) {
|
} else if(_descriptiveString.find("RIGHT") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardRight;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardRight;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "UP") ) {
|
} else if(_descriptiveString.find("UP") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardUp;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardUp;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "DOWN") ) {
|
} else if(_descriptiveString.find("DOWN") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardDown;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardDown;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "PAGE_UP") ) {
|
} else if(_descriptiveString.find("PAGE_UP") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardPageUp;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardPageUp;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "PAGE_DOWN") ) {
|
} else if(_descriptiveString.find("PAGE_DOWN") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardPageDown;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardPageDown;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "START") ) {
|
} else if(_descriptiveString.find("START") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardStart;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardStart;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "END") ) {
|
} else if(_descriptiveString.find("END") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardEnd;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardEnd;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "PRINT") ) {
|
} else if(_descriptiveString.find("PRINT") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardPrint;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardPrint;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "ARRET_DEFIL") ) {
|
} else if(_descriptiveString.find("ARRET_DEFIL") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardStopDefil;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardStopDefil;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "WAIT") ) {
|
} else if(_descriptiveString.find("WAIT") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardWait;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardWait;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "INSERT") ) {
|
} else if(_descriptiveString.find("INSERT") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardInsert;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardInsert;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "CAPLOCK") ) {
|
} else if(_descriptiveString.find("CAPLOCK") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardCapLock;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardCapLock;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "CONTEXT_MENU") ) {
|
} else if(_descriptiveString.find("CONTEXT_MENU") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardContextMenu;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardContextMenu;
|
||||||
} else if(nullptr != strstr(_descriptiveString, "NUM_LOCK") ) {
|
} else if(_descriptiveString.find("NUM_LOCK") != std::string::npos) {
|
||||||
tmpElement->keyboardMoveValue = ewol::key::keyboardNumLock;
|
tmpElement->keyboardMoveValue = ewol::key::keyboardNumLock;
|
||||||
} else {
|
} else {
|
||||||
tmpElement->unicodeValue = _descriptiveString[strlen(_descriptiveString) -1];
|
tmpElement->unicodeValue = _descriptiveString[_descriptiveString.size() -1];
|
||||||
}
|
}
|
||||||
// add it on the List ...
|
// add it on the List ...
|
||||||
m_localShortcut.push_back(tmpElement);
|
m_localShortcut.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::Widget::shortCutClean() {
|
void ewol::Widget::shortCutRemove(const std::string& _message) {
|
||||||
for (size_t iii=0; iii<m_localShortcut.size(); iii++) {
|
auto it(m_localShortcut.begin());
|
||||||
if (nullptr != m_localShortcut[iii]) {
|
while(it != m_localShortcut.end()) {
|
||||||
delete(m_localShortcut[iii]);
|
if ( *it != nullptr
|
||||||
m_localShortcut[iii]=nullptr;
|
&& (*it)->message != _message) {
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
delete(*it);
|
||||||
|
*it = nullptr;
|
||||||
|
m_localShortcut.erase(it);
|
||||||
|
it = m_localShortcut.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::Widget::shortCutClean() {
|
||||||
|
for (auto &it : m_localShortcut) {
|
||||||
|
delete(it);
|
||||||
|
it = nullptr;
|
||||||
}
|
}
|
||||||
m_localShortcut.clear();
|
m_localShortcut.clear();
|
||||||
}
|
}
|
||||||
@ -557,14 +559,8 @@ bool ewol::Widget::onEventShortCut(ewol::key::Special& _special,
|
|||||||
&& m_localShortcut[iii]->unicodeValue == 0)
|
&& m_localShortcut[iii]->unicodeValue == 0)
|
||||||
) ) {
|
) ) {
|
||||||
if (_isDown) {
|
if (_isDown) {
|
||||||
if (true == m_localShortcut[iii]->broadcastEvent) {
|
signalShortcut.emit(m_localShortcut[iii]->message);
|
||||||
// send message at all the widget (exepted this one)
|
}
|
||||||
sendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
|
|
||||||
}
|
|
||||||
// send message direct to the current widget (in every case, really useful for some generic windows shortcut)
|
|
||||||
ewol::object::Message tmpMsg(shared_from_this(), m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
|
|
||||||
onReceiveMessage(tmpMsg);
|
|
||||||
} // no else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -602,20 +598,11 @@ enum ewol::context::cursorDisplay ewol::Widget::getCursor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::Widget::loadXML(exml::Element* _node) {
|
bool ewol::Widget::loadXML(exml::Element* _node) {
|
||||||
// Call EObject basic parser
|
ewol::Object::loadXML(_node);
|
||||||
ewol::Object::loadXML(_node); // note : load standard parameters (attribute in XML)
|
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ewol::Widget> ewol::Widget::getWidgetNamed(const std::string& _widgetName) {
|
|
||||||
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} compare : " << getName() << " == " << _widgetName );
|
|
||||||
if (getName() == _widgetName) {
|
|
||||||
return std::dynamic_pointer_cast<ewol::Widget>(shared_from_this());
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) {
|
bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) {
|
||||||
std::shared_ptr<ewol::Widget> up = std::dynamic_pointer_cast<ewol::Widget>(m_parent.lock());
|
std::shared_ptr<ewol::Widget> up = std::dynamic_pointer_cast<ewol::Widget>(m_parent.lock());
|
||||||
if (up != nullptr) {
|
if (up != nullptr) {
|
||||||
|
@ -31,6 +31,7 @@ namespace ewol {
|
|||||||
#include <ewol/event/Entry.h>
|
#include <ewol/event/Entry.h>
|
||||||
#include <ewol/event/Time.h>
|
#include <ewol/event/Time.h>
|
||||||
#include <ewol/translate.h>
|
#include <ewol/translate.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
#define ULTIMATE_MAX_SIZE (99999999)
|
#define ULTIMATE_MAX_SIZE (99999999)
|
||||||
|
|
||||||
@ -99,16 +100,12 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class EventShortCut {
|
class EventShortCut {
|
||||||
public:
|
public:
|
||||||
bool broadcastEvent; //!< if it is true, then the message is sent to all the system
|
std::string message; //!< data link with the event
|
||||||
const char* generateEventId; //!< Local generated event
|
|
||||||
std::string eventData; //!< data link with the event
|
|
||||||
ewol::key::Special specialKey; //!< special board key
|
ewol::key::Special specialKey; //!< special board key
|
||||||
char32_t unicodeValue; //!< 0 if not used
|
char32_t unicodeValue; //!< 0 if not used
|
||||||
enum ewol::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used
|
enum ewol::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used
|
||||||
EventShortCut() {
|
EventShortCut() {
|
||||||
broadcastEvent = false;
|
message = "";
|
||||||
generateEventId = nullptr;
|
|
||||||
eventData = "";
|
|
||||||
unicodeValue = 0;
|
unicodeValue = 0;
|
||||||
keyboardMoveValue = ewol::key::keyboardUnknow;
|
keyboardMoveValue = ewol::key::keyboardUnknow;
|
||||||
};
|
};
|
||||||
@ -531,12 +528,6 @@ namespace ewol {
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* @brief get the widget if it have this name or one of the subwidget with the same name
|
|
||||||
* @param[in] _widgetName name of the widget
|
|
||||||
* @return the requested pointer on the node (or nullptr pointer)
|
|
||||||
*/
|
|
||||||
virtual std::shared_ptr<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
|
|
||||||
|
|
||||||
// event section:
|
// event section:
|
||||||
public:
|
public:
|
||||||
@ -590,23 +581,27 @@ namespace ewol {
|
|||||||
// ----------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
// -- Shortcut : management of the shortcut
|
// -- Shortcut : management of the shortcut
|
||||||
// ----------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
public:
|
||||||
|
ewol::object::Signal<std::string> signalShortcut; //!< signal handle of the message
|
||||||
private:
|
private:
|
||||||
std::vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget
|
std::vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief add a specific shortcut with his description
|
* @brief add a specific shortcut with his description
|
||||||
* @param[in] _descriptiveString Description string of the shortcut
|
* @param[in] _descriptiveString Description string of the shortcut
|
||||||
* @param[in] _generateEventId Event generic of the element
|
* @param[in] _message massage to generate (or shortcut name)
|
||||||
* @param[in] _data Associate data wit the event
|
|
||||||
*/
|
*/
|
||||||
virtual void shortCutAdd(const char * _descriptiveString,
|
virtual void shortCutAdd(const std::string& _descriptiveString,
|
||||||
const char * _generateEventId,
|
const std::string& _message="");
|
||||||
std::string _data="",
|
|
||||||
bool _broadcast=false);
|
|
||||||
/**
|
/**
|
||||||
* @brief remove all curent shortCut
|
* @brief remove all curent shortCut
|
||||||
*/
|
*/
|
||||||
virtual void shortCutClean();
|
virtual void shortCutClean();
|
||||||
|
/**
|
||||||
|
* @brief remove a specific shortCut whith his event name
|
||||||
|
* @param[in] _message renerated event name
|
||||||
|
*/
|
||||||
|
virtual void shortCutRemove(const std::string& _message);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref onEventKb).
|
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref onEventKb).
|
||||||
@ -713,9 +708,9 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
// event generated :
|
// event generated :
|
||||||
static const char* const eventAnnimationStart; //!< event when start annimation
|
ewol::object::Signal<void> signalAnnimationStart; //!< event when start annimation
|
||||||
static const char* const eventAnnimationRatio; //!< event when % of annimation change (integer)
|
ewol::object::Signal<float> signalAnnimationRatio; //!< event when % of annimation change (integer)
|
||||||
static const char* const eventAnnimationStop; //!< event when stop annimation
|
ewol::object::Signal<void> signalAnnimationStop; //!< event when stop annimation
|
||||||
protected:
|
protected:
|
||||||
enum annimationMode {
|
enum annimationMode {
|
||||||
annimationModeEnableAdd,
|
annimationModeEnableAdd,
|
||||||
|
@ -22,24 +22,19 @@ extern "C" {
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ColorChooser"
|
#define __class__ "ColorChooser"
|
||||||
|
|
||||||
|
|
||||||
const char * const ewol::widget::ColorChooser::eventChange = "change";
|
|
||||||
|
|
||||||
|
|
||||||
static const char * const eventColorBarHasChange = "event-color-bar-has-change";
|
static const char * const eventColorBarHasChange = "event-color-bar-has-change";
|
||||||
static const char * const eventColorSpecificHasChange = "event-color-specific-has-change";
|
|
||||||
|
|
||||||
|
|
||||||
ewol::widget::ColorChooser::ColorChooser() {
|
ewol::widget::ColorChooser::ColorChooser() :
|
||||||
|
signalChange(*this, "change") {
|
||||||
addObjectType("ewol::widget::ColorChooser");
|
addObjectType("ewol::widget::ColorChooser");
|
||||||
addEventId(eventChange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::ColorChooser::init() {
|
void ewol::widget::ColorChooser::init() {
|
||||||
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
|
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
|
||||||
lockExpand(bvec2(true,true));
|
lockExpand(bvec2(true,true));
|
||||||
m_widgetColorBar = ewol::widget::ColorBar::create();
|
m_widgetColorBar = ewol::widget::ColorBar::create();
|
||||||
m_widgetColorBar->registerOnEvent(shared_from_this(), "change", eventColorBarHasChange);
|
m_widgetColorBar->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChange);
|
||||||
m_widgetColorBar->setFill(bvec2(true,true));
|
m_widgetColorBar->setFill(bvec2(true,true));
|
||||||
subWidgetAdd(m_widgetColorBar);
|
subWidgetAdd(m_widgetColorBar);
|
||||||
|
|
||||||
@ -47,7 +42,7 @@ void ewol::widget::ColorChooser::init() {
|
|||||||
sliderColor = etk::color::black;
|
sliderColor = etk::color::black;
|
||||||
|
|
||||||
m_widgetRed = ewol::widget::Slider::create();
|
m_widgetRed = ewol::widget::Slider::create();
|
||||||
m_widgetRed->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange);
|
m_widgetRed->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeRed);
|
||||||
m_widgetRed->setExpand(bvec2(true,false));
|
m_widgetRed->setExpand(bvec2(true,false));
|
||||||
m_widgetRed->setFill(bvec2(true,false));
|
m_widgetRed->setFill(bvec2(true,false));
|
||||||
m_widgetRed->setMin(0);
|
m_widgetRed->setMin(0);
|
||||||
@ -56,7 +51,7 @@ void ewol::widget::ColorChooser::init() {
|
|||||||
m_widgetRed->setColor(sliderColor);
|
m_widgetRed->setColor(sliderColor);
|
||||||
subWidgetAdd(m_widgetRed);
|
subWidgetAdd(m_widgetRed);
|
||||||
m_widgetGreen = ewol::widget::Slider::create();
|
m_widgetGreen = ewol::widget::Slider::create();
|
||||||
m_widgetGreen->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange);
|
m_widgetGreen->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeGreen);
|
||||||
m_widgetGreen->setExpand(bvec2(true,false));
|
m_widgetGreen->setExpand(bvec2(true,false));
|
||||||
m_widgetGreen->setFill(bvec2(true,false));
|
m_widgetGreen->setFill(bvec2(true,false));
|
||||||
m_widgetGreen->setMin(0);
|
m_widgetGreen->setMin(0);
|
||||||
@ -65,7 +60,7 @@ void ewol::widget::ColorChooser::init() {
|
|||||||
m_widgetGreen->setMax(255);
|
m_widgetGreen->setMax(255);
|
||||||
subWidgetAdd(m_widgetGreen);
|
subWidgetAdd(m_widgetGreen);
|
||||||
m_widgetBlue = ewol::widget::Slider::create();
|
m_widgetBlue = ewol::widget::Slider::create();
|
||||||
m_widgetBlue->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange);
|
m_widgetBlue->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeBlue);
|
||||||
m_widgetBlue->setExpand(bvec2(true,false));
|
m_widgetBlue->setExpand(bvec2(true,false));
|
||||||
m_widgetBlue->setFill(bvec2(true,false));
|
m_widgetBlue->setFill(bvec2(true,false));
|
||||||
m_widgetBlue->setMin(0);
|
m_widgetBlue->setMin(0);
|
||||||
@ -74,7 +69,7 @@ void ewol::widget::ColorChooser::init() {
|
|||||||
m_widgetBlue->setMax(255);
|
m_widgetBlue->setMax(255);
|
||||||
subWidgetAdd(m_widgetBlue);
|
subWidgetAdd(m_widgetBlue);
|
||||||
m_widgetAlpha = ewol::widget::Slider::create();
|
m_widgetAlpha = ewol::widget::Slider::create();
|
||||||
m_widgetAlpha->registerOnEvent(shared_from_this(), "change", eventColorSpecificHasChange);
|
m_widgetAlpha->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeAlpha);
|
||||||
m_widgetAlpha->setExpand(bvec2(true,false));
|
m_widgetAlpha->setExpand(bvec2(true,false));
|
||||||
m_widgetAlpha->setFill(bvec2(true,false));
|
m_widgetAlpha->setFill(bvec2(true,false));
|
||||||
m_widgetAlpha->setMin(0);
|
m_widgetAlpha->setMin(0);
|
||||||
@ -114,51 +109,51 @@ etk::Color<> ewol::widget::ColorChooser::getColor() {
|
|||||||
return m_currentColor;
|
return m_currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::widget::ColorChooser::onCallbackColorChangeRed(const int32_t& _newColor) {
|
||||||
void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _msg) {
|
m_currentColor.setR(_newColor);
|
||||||
if (nullptr == _msg.getCaller()) {
|
if (nullptr != m_widgetColorBar) {
|
||||||
return;
|
m_widgetColorBar->setCurrentColor(m_currentColor);
|
||||||
}
|
}
|
||||||
//EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" == > data=\"" << data << "\"" );
|
signalChange.emit(m_currentColor);
|
||||||
if (eventColorBarHasChange == _msg.getMessage()) {
|
}
|
||||||
// == > colorBar has change ...
|
void ewol::widget::ColorChooser::onCallbackColorChangeGreen(const int32_t& _newColor) {
|
||||||
uint8_t tmpAlpha = m_currentColor.a();
|
m_currentColor.setG(_newColor);
|
||||||
// the colorbar has no notion of the alpha == > keep it ...
|
if (nullptr != m_widgetColorBar) {
|
||||||
if (nullptr != m_widgetColorBar) {
|
m_widgetColorBar->setCurrentColor(m_currentColor);
|
||||||
m_currentColor = m_widgetColorBar->getCurrentColor();
|
|
||||||
}
|
|
||||||
m_currentColor.setA(tmpAlpha);
|
|
||||||
if (nullptr != m_widgetRed) {
|
|
||||||
m_widgetRed->setValue(m_currentColor.r());
|
|
||||||
}
|
|
||||||
if (nullptr != m_widgetGreen) {
|
|
||||||
m_widgetGreen->setValue(m_currentColor.g());
|
|
||||||
}
|
|
||||||
if (nullptr != m_widgetBlue) {
|
|
||||||
m_widgetBlue->setValue(m_currentColor.b());
|
|
||||||
}
|
|
||||||
if (nullptr != m_widgetAlpha) {
|
|
||||||
m_widgetAlpha->setValue(m_currentColor.a());
|
|
||||||
}
|
|
||||||
generateEventId(eventChange, m_currentColor.getString());
|
|
||||||
} else if (eventColorSpecificHasChange == _msg.getMessage()) {
|
|
||||||
// Slider has changes his color == > get the one change ...
|
|
||||||
if (_msg.getCaller() == m_widgetRed) {
|
|
||||||
m_currentColor.setR(m_widgetRed->getValue());
|
|
||||||
}
|
|
||||||
if (_msg.getCaller() == m_widgetGreen) {
|
|
||||||
m_currentColor.setG(m_widgetGreen->getValue());
|
|
||||||
}
|
|
||||||
if (_msg.getCaller() == m_widgetBlue) {
|
|
||||||
m_currentColor.setB(m_widgetBlue->getValue());
|
|
||||||
}
|
|
||||||
if (_msg.getCaller() == m_widgetAlpha) {
|
|
||||||
m_currentColor.setA(m_widgetAlpha->getValue());
|
|
||||||
}
|
|
||||||
if (nullptr != m_widgetColorBar) {
|
|
||||||
m_widgetColorBar->setCurrentColor(m_currentColor);
|
|
||||||
}
|
|
||||||
generateEventId(eventChange, m_currentColor.getString());
|
|
||||||
}
|
}
|
||||||
};
|
signalChange.emit(m_currentColor);
|
||||||
|
}
|
||||||
|
void ewol::widget::ColorChooser::onCallbackColorChangeBlue(const int32_t& _newColor) {
|
||||||
|
m_currentColor.setB(_newColor);
|
||||||
|
if (nullptr != m_widgetColorBar) {
|
||||||
|
m_widgetColorBar->setCurrentColor(m_currentColor);
|
||||||
|
}
|
||||||
|
signalChange.emit(m_currentColor);
|
||||||
|
}
|
||||||
|
void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const int32_t& _newColor) {
|
||||||
|
m_currentColor.setA(_newColor);
|
||||||
|
if (nullptr != m_widgetColorBar) {
|
||||||
|
m_widgetColorBar->setCurrentColor(m_currentColor);
|
||||||
|
}
|
||||||
|
signalChange.emit(m_currentColor);
|
||||||
|
}
|
||||||
|
void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) {
|
||||||
|
m_currentColor = _newColor;
|
||||||
|
// == > colorBar has change ...
|
||||||
|
uint8_t tmpAlpha = m_currentColor.a();
|
||||||
|
m_currentColor = _newColor;
|
||||||
|
m_currentColor.setA(tmpAlpha);
|
||||||
|
if (nullptr != m_widgetRed) {
|
||||||
|
m_widgetRed->setValue(m_currentColor.r());
|
||||||
|
}
|
||||||
|
if (nullptr != m_widgetGreen) {
|
||||||
|
m_widgetGreen->setValue(m_currentColor.g());
|
||||||
|
}
|
||||||
|
if (nullptr != m_widgetBlue) {
|
||||||
|
m_widgetBlue->setValue(m_currentColor.b());
|
||||||
|
}
|
||||||
|
if (nullptr != m_widgetAlpha) {
|
||||||
|
m_widgetAlpha->setValue(m_currentColor.a());
|
||||||
|
}
|
||||||
|
signalChange.emit(m_currentColor);
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
#include <ewol/widget/Sizer.h>
|
#include <ewol/widget/Sizer.h>
|
||||||
#include <ewol/widget/ColorBar.h>
|
#include <ewol/widget/ColorBar.h>
|
||||||
#include <ewol/widget/Slider.h>
|
#include <ewol/widget/Slider.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -27,15 +28,13 @@ namespace ewol {
|
|||||||
class ColorChooser : public ewol::widget::Sizer {
|
class ColorChooser : public ewol::widget::Sizer {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventChange;
|
ewol::object::Signal<etk::Color<>> signalChange;
|
||||||
protected:
|
protected:
|
||||||
ColorChooser();
|
ColorChooser();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser");
|
DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser");
|
||||||
virtual ~ColorChooser();
|
virtual ~ColorChooser();
|
||||||
public: // Derived function
|
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
|
||||||
public:
|
public:
|
||||||
void setColor(etk::Color<> _newColor);
|
void setColor(etk::Color<> _newColor);
|
||||||
etk::Color<> getColor();
|
etk::Color<> getColor();
|
||||||
@ -46,6 +45,11 @@ namespace ewol {
|
|||||||
std::shared_ptr<ewol::widget::Slider> m_widgetBlue;
|
std::shared_ptr<ewol::widget::Slider> m_widgetBlue;
|
||||||
std::shared_ptr<ewol::widget::Slider> m_widgetAlpha;
|
std::shared_ptr<ewol::widget::Slider> m_widgetAlpha;
|
||||||
etk::Color<> m_currentColor;
|
etk::Color<> m_currentColor;
|
||||||
|
void onCallbackColorChangeRed(const int32_t& _newColor);
|
||||||
|
void onCallbackColorChangeGreen(const int32_t& _newColor);
|
||||||
|
void onCallbackColorChangeBlue(const int32_t& _newColor);
|
||||||
|
void onCallbackColorChangeAlpha(const int32_t& _newColor);
|
||||||
|
void onCallbackColorChange(const etk::Color<>& _newColor);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#include <ewol/widget/meta/FileChooser.h>
|
#include <ewol/widget/meta/FileChooser.h>
|
||||||
#include <ewol/widget/Sizer.h>
|
#include <ewol/widget/Sizer.h>
|
||||||
#include <ewol/widget/List.h>
|
#include <ewol/widget/List.h>
|
||||||
|
#include <ewol/widget/Button.h>
|
||||||
|
#include <ewol/widget/CheckBox.h>
|
||||||
|
#include <ewol/widget/ListFileSystem.h>
|
||||||
|
#include <ewol/widget/Entry.h>
|
||||||
#include <ewol/widget/Spacer.h>
|
#include <ewol/widget/Spacer.h>
|
||||||
#include <ewol/widget/Image.h>
|
#include <ewol/widget/Image.h>
|
||||||
#include <ewol/widget/Composer.h>
|
#include <ewol/widget/Composer.h>
|
||||||
@ -29,25 +33,10 @@ extern "C" {
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "FileChooser"
|
#define __class__ "FileChooser"
|
||||||
|
|
||||||
|
ewol::widget::FileChooser::FileChooser() :
|
||||||
const char * const ewol::widget::FileChooser::eventCancel = "cancel";
|
signalCancel(*this, "cancel"),
|
||||||
const char * const ewol::widget::FileChooser::eventValidate = "validate";
|
signalValidate(*this, "validate") {
|
||||||
|
|
||||||
static const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files";
|
|
||||||
static const char * const ewolEventFileChooserEntryFolder = "ewol-event-file-chooser-modify-entry-folder";
|
|
||||||
static const char * const ewolEventFileChooserEntryFolderEnter = "ewol-event-file-chooser-modify-entry-folder-enter";
|
|
||||||
static const char * const ewolEventFileChooserEntryFile = "ewol-event-file-chooser-modify-entry-file";
|
|
||||||
static const char * const ewolEventFileChooserEntryFileEnter = "ewol-event-file-chooser-modify-entry-file-enter";
|
|
||||||
static const char * const ewolEventFileChooserListFolder = "ewol-event-file-chooser-modify-list-folder";
|
|
||||||
static const char * const ewolEventFileChooserListFile = "ewol-event-file-chooser-modify-list-file";
|
|
||||||
static const char * const ewolEventFileChooserListFileValidate = "ewol-event-file-chooser-modify-list-file-validate";
|
|
||||||
static const char * const ewolEventFileChooserHome = "ewol-event-file-chooser-home";
|
|
||||||
|
|
||||||
|
|
||||||
ewol::widget::FileChooser::FileChooser() {
|
|
||||||
addObjectType("ewol::widget::FileChooser");
|
addObjectType("ewol::widget::FileChooser");
|
||||||
addEventId(eventCancel);
|
|
||||||
addEventId(eventValidate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::FileChooser::init() {
|
void ewol::widget::FileChooser::init() {
|
||||||
@ -106,17 +95,17 @@ void ewol::widget::FileChooser::init() {
|
|||||||
+ " </sizer>\n"
|
+ " </sizer>\n"
|
||||||
+ "</popup>";
|
+ "</popup>";
|
||||||
loadFromString(myDescription);
|
loadFromString(myDescription);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", "value", ewolEventFileChooserHidenFileChange);
|
subBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", signalValue, shared_from_this(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-validate", "pressed", eventValidate);
|
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-validate", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackListValidate);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:button-cancel", "pressed", eventCancel);
|
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-cancel", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "folder-validate", ewolEventFileChooserListFolder);
|
subBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-folder", signalFolderValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFolderSelectChange);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-select", ewolEventFileChooserListFile);
|
subBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileSelect, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileSelectChange);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:list-files", "file-validate", ewolEventFileChooserListFileValidate);
|
subBind(ewol::widget::ListFileSystem, "[" + etk::to_string(getId()) + "]file-shooser:list-files", signalFileValidate, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "modify", ewolEventFileChooserEntryFile);
|
subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFileChangeValue);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "enter", ewolEventFileChooserEntryFileEnter);
|
subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-file", signalEnter, shared_from_this(), &ewol::widget::FileChooser::onCallbackListFileValidate);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "modify", ewolEventFileChooserEntryFolder);
|
subBind(ewol::widget::Entry, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalModify, shared_from_this(), &ewol::widget::FileChooser::onCallbackEntryFolderChangeValue);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "enter", ewolEventFileChooserEntryFolderEnter);
|
//composerBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:entry-folder", signalEnter, shared_from_this(), &ewol::widget::FileChooser::);
|
||||||
registerOnEventNameWidget("[" + etk::to_string(getId()) + "]file-shooser:img-home", "pressed", ewolEventFileChooserHome);
|
subBind(ewol::widget::Image, "[" + etk::to_string(getId()) + "]file-shooser:img-home", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackHomePressed);
|
||||||
// set the default Folder properties:
|
// set the default Folder properties:
|
||||||
updateCurrentFolder();
|
updateCurrentFolder();
|
||||||
setCanHaveFocus(true);
|
setCanHaveFocus(true);
|
||||||
@ -153,62 +142,81 @@ void ewol::widget::FileChooser::setFileName(const std::string& _filename) {
|
|||||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "value", _filename);
|
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "value", _filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::FileChooser::onReceiveMessage(const ewol::object::Message& _msg) {
|
|
||||||
EWOL_INFO("Receive Event from the LIST ... : " << _msg);
|
void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue(const std::string& _value) {
|
||||||
if (_msg.getMessage() == ewolEventFileChooserEntryFolder) {
|
// == > change the folder name
|
||||||
// == > change the folder name
|
// TODO : change the folder, if it exit ...
|
||||||
// TODO : change the folder, if it exit ...
|
}
|
||||||
} else if (_msg.getMessage() == ewolEventFileChooserEntryFile) {
|
|
||||||
// == > change the file name
|
void ewol::widget::FileChooser::onCallbackEntryFileChangeValue(const std::string& _value) {
|
||||||
m_file = _msg.getData();
|
// == > change the file name
|
||||||
// update the selected file in the list :
|
m_file = _value;
|
||||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file);
|
// update the selected file in the list :
|
||||||
} else if (eventCancel == _msg.getMessage()) {
|
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file);
|
||||||
// == > Auto remove ...
|
}
|
||||||
generateEventId(_msg.getMessage());
|
|
||||||
autoDestroy();
|
void ewol::widget::FileChooser::onCallbackButtonCancelPressed() {
|
||||||
} else if (_msg.getMessage() == ewolEventFileChooserHidenFileChange) {
|
// == > Auto remove ...
|
||||||
if (_msg.getData() == "true") {
|
signalCancel.emit();
|
||||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "true");
|
autoDestroy();
|
||||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "true");
|
}
|
||||||
} else {
|
|
||||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "false");
|
void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue(const bool& _value) {
|
||||||
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "false");
|
if (_value == true) {
|
||||||
}
|
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "true");
|
||||||
} else if (_msg.getMessage() == ewolEventFileChooserListFolder) {
|
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "true");
|
||||||
// == > this is an internal event ...
|
} else {
|
||||||
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _msg.getData() << "\"");
|
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "show-hidden", "false");
|
||||||
m_folder = m_folder + _msg.getData();
|
parameterSetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "show-hidden", "false");
|
||||||
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
|
|
||||||
m_folder = etk::simplifyPath(m_folder);
|
|
||||||
setFileName("");
|
|
||||||
updateCurrentFolder();
|
|
||||||
} else if (_msg.getMessage() == ewolEventFileChooserListFile) {
|
|
||||||
setFileName(_msg.getData());
|
|
||||||
std::string tmpFileCompleatName = m_folder;
|
|
||||||
tmpFileCompleatName += m_file;
|
|
||||||
generateEventId(_msg.getMessage(), tmpFileCompleatName);
|
|
||||||
} else if( _msg.getMessage() == ewolEventFileChooserListFileValidate
|
|
||||||
|| (_msg.getMessage() == eventValidate && m_file != "" )
|
|
||||||
|| (_msg.getMessage() == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) {
|
|
||||||
// select the file == > generate a validate
|
|
||||||
if (_msg.getData() != "") {
|
|
||||||
setFileName(_msg.getData());
|
|
||||||
}
|
|
||||||
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\"");
|
|
||||||
generateEventId(eventValidate, getCompleateFileName());
|
|
||||||
autoDestroy();
|
|
||||||
} else if(_msg.getMessage() == ewolEventFileChooserHome) {
|
|
||||||
std::string tmpUserFolder = etk::getUserHomeFolder();
|
|
||||||
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");
|
|
||||||
|
|
||||||
m_folder = etk::simplifyPath(tmpUserFolder);
|
|
||||||
|
|
||||||
setFileName("");
|
|
||||||
updateCurrentFolder();
|
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
};
|
|
||||||
|
void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const std::string& _value) {
|
||||||
|
// == > this is an internal event ...
|
||||||
|
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _value << "\"");
|
||||||
|
m_folder = m_folder + _value;
|
||||||
|
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
|
||||||
|
m_folder = etk::simplifyPath(m_folder);
|
||||||
|
setFileName("");
|
||||||
|
updateCurrentFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) {
|
||||||
|
setFileName(_value);
|
||||||
|
/*
|
||||||
|
std::string tmpFileCompleatName = m_folder;
|
||||||
|
tmpFileCompleatName += m_file;
|
||||||
|
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) {
|
||||||
|
// select the file == > generate a validate
|
||||||
|
setFileName(_value);
|
||||||
|
EWOL_VERBOSE(" generate a fiel opening : '" << m_folder << "' / '" << m_file << "'");
|
||||||
|
signalValidate.emit(getCompleateFileName());
|
||||||
|
autoDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::widget::FileChooser::onCallbackListValidate() {
|
||||||
|
if (m_file == "" ) {
|
||||||
|
EWOL_WARNING(" Validate : '" << m_folder << "' / '" << m_file << "' ==> error No name ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EWOL_DEBUG(" generate a file opening : '" << m_folder << "' / '" << m_file << "'");
|
||||||
|
signalValidate.emit(getCompleateFileName());
|
||||||
|
autoDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::widget::FileChooser::onCallbackHomePressed() {
|
||||||
|
std::string tmpUserFolder = etk::getUserHomeFolder();
|
||||||
|
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");
|
||||||
|
|
||||||
|
m_folder = etk::simplifyPath(tmpUserFolder);
|
||||||
|
|
||||||
|
setFileName("");
|
||||||
|
updateCurrentFolder();
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::widget::FileChooser::updateCurrentFolder() {
|
void ewol::widget::FileChooser::updateCurrentFolder() {
|
||||||
if (m_folder != "" ) {
|
if (m_folder != "" ) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Composer.h>
|
#include <ewol/widget/Composer.h>
|
||||||
|
#include <ewol/object/Signal.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
@ -23,21 +24,19 @@ namespace ewol {
|
|||||||
* Fist global static declaration and inclusion:
|
* Fist global static declaration and inclusion:
|
||||||
* [code style=c++]
|
* [code style=c++]
|
||||||
* #include <ewol/widget/meta/FileChooser.h>
|
* #include <ewol/widget/meta/FileChooser.h>
|
||||||
* static const char* const g_eventOpenFile = "appl-local-event-open-file";
|
|
||||||
* static const char* const g_eventClosePopUp = "appl-local-event-close-pop-up";
|
|
||||||
* [/code]
|
* [/code]
|
||||||
*
|
*
|
||||||
* The first step is to create the file chooser pop-up :
|
* The first step is to create the file chooser pop-up : (never in the constructor!!!)
|
||||||
* [code style=c++]
|
* [code style=c++]
|
||||||
* std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::object::makeShared(new ewol::Widget::FileChooser());
|
* std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::Widget::FileChooser::create();
|
||||||
* if (tmpWidget == nullptr) {
|
* if (tmpWidget == nullptr) {
|
||||||
* APPL_ERROR("Can not open File chooser !!! ");
|
* APPL_ERROR("Can not open File chooser !!! ");
|
||||||
* return -1;
|
* return -1;
|
||||||
* }
|
* }
|
||||||
* // register on the Validate event:
|
* // register on the Validate event:
|
||||||
* tmpWidget->registerOnEvent(this, "validate", g_eventOpenFile);
|
* tmpWidget->signalValidate.bind(shared_from_this(), &****::onCallbackOpenFile);
|
||||||
* // no need of this event watching ...
|
* // no need of this event watching ...
|
||||||
* tmpWidget->registerOnEvent(this, "cancel", g_eventClosePopUp);
|
* tmpWidget->signalCancel.bind(shared_from_this(), &****::onCallbackClosePopUp);
|
||||||
* // set the title:
|
* // set the title:
|
||||||
* tmpWidget->setTitle("Open files ...");
|
* tmpWidget->setTitle("Open files ...");
|
||||||
* // Set the validate Label:
|
* // Set the validate Label:
|
||||||
@ -45,7 +44,7 @@ namespace ewol {
|
|||||||
* // simply set a folder (by default this is the home folder)
|
* // simply set a folder (by default this is the home folder)
|
||||||
* //tmpWidget->setFolder("/home/me");
|
* //tmpWidget->setFolder("/home/me");
|
||||||
* // add the widget as windows pop-up ...
|
* // add the widget as windows pop-up ...
|
||||||
* ewol::widget::Windows* tmpWindows = getWindows();
|
* std::shared_ptr<ewol::widget::Windows> tmpWindows = getWindows();
|
||||||
* if (tmpWindows == nullptr) {
|
* if (tmpWindows == nullptr) {
|
||||||
* APPL_ERROR("Can not get the current windows !!! ");
|
* APPL_ERROR("Can not get the current windows !!! ");
|
||||||
* return -1;
|
* return -1;
|
||||||
@ -56,17 +55,11 @@ namespace ewol {
|
|||||||
* Now we just need to wait the the open event message.
|
* Now we just need to wait the the open event message.
|
||||||
*
|
*
|
||||||
* [code style=c++]
|
* [code style=c++]
|
||||||
* void ********::onReceiveMessage(const ewol::object::Message& _msg) {
|
* void ****::onCallbackOpenFile(const std::string& _value) {
|
||||||
* APPL_DEBUG("Receive Message: " << _msg );
|
* APPL_INFO("Request open file : '" << _value << "'");
|
||||||
* if (_msg.getMessage() == g_eventOpenFile) {
|
* }
|
||||||
* APPL_INFO("Request open file : '" << _msg.getData() << "'");
|
* void ****::onCallbackClosePopUp() {
|
||||||
* return;
|
* APPL_INFO("The File chooser has been closed");
|
||||||
* }
|
|
||||||
* if (_msg.getMessage() == g_eventClosePopUp) {
|
|
||||||
* APPL_INFO("The File chooser has been closed");
|
|
||||||
* // generaly nothing to do ...
|
|
||||||
* return;
|
|
||||||
* }
|
|
||||||
* }
|
* }
|
||||||
* [/code]
|
* [/code]
|
||||||
* This is the best example of a Meta-widget.
|
* This is the best example of a Meta-widget.
|
||||||
@ -74,8 +67,8 @@ namespace ewol {
|
|||||||
class FileChooser : public ewol::widget::Composer {
|
class FileChooser : public ewol::widget::Composer {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char* const eventCancel;
|
ewol::object::Signal<void> signalCancel;
|
||||||
static const char* const eventValidate;
|
ewol::object::Signal<std::string> signalValidate;
|
||||||
protected:
|
protected:
|
||||||
FileChooser();
|
FileChooser();
|
||||||
void init();
|
void init();
|
||||||
@ -94,8 +87,18 @@ namespace ewol {
|
|||||||
std::string getCompleateFileName();
|
std::string getCompleateFileName();
|
||||||
void updateCurrentFolder();
|
void updateCurrentFolder();
|
||||||
public: // Derived function
|
public: // Derived function
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
|
||||||
virtual void onGetFocus();
|
virtual void onGetFocus();
|
||||||
|
private:
|
||||||
|
// callback functions:
|
||||||
|
void onCallbackEntryFolderChangeValue(const std::string& _value);
|
||||||
|
void onCallbackEntryFileChangeValue(const std::string& _value);
|
||||||
|
void onCallbackButtonCancelPressed();
|
||||||
|
void onCallbackHidenFileChangeChangeValue(const bool& _value);
|
||||||
|
void onCallbackListFolderSelectChange(const std::string& _value);
|
||||||
|
void onCallbackListFileSelectChange(const std::string& _value);
|
||||||
|
void onCallbackListFileValidate(const std::string& _value);
|
||||||
|
void onCallbackListValidate();
|
||||||
|
void onCallbackHomePressed();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -21,18 +21,12 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Parameter"
|
#define __class__ "Parameter"
|
||||||
|
|
||||||
const char * const ewol::widget::Parameter::eventClose = "close";
|
|
||||||
|
|
||||||
static const char * const ewolEventParameterValidate = "ewol-event-parameter-validate";
|
|
||||||
static const char * const ewolEventParameterSave = "ewol-event-parameter-save";
|
|
||||||
static const char * const l_eventMenuSelected = "local-event-menu-selected";
|
|
||||||
|
|
||||||
ewol::widget::Parameter::Parameter() :
|
ewol::widget::Parameter::Parameter() :
|
||||||
|
signalClose(*this, "close"),
|
||||||
m_currentIdList(0),
|
m_currentIdList(0),
|
||||||
m_widgetTitle(),
|
m_widgetTitle(),
|
||||||
m_paramList() {
|
m_paramList() {
|
||||||
addObjectType("ewol::widget::Parameter");
|
addObjectType("ewol::widget::Parameter");
|
||||||
addEventId(eventClose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Parameter::init() {
|
void ewol::widget::Parameter::init() {
|
||||||
@ -82,7 +76,7 @@ void ewol::widget::Parameter::init() {
|
|||||||
" <label>Save</label>\n"
|
" <label>Save</label>\n"
|
||||||
" </sizer>\n"
|
" </sizer>\n"
|
||||||
"</composer>\n"));
|
"</composer>\n"));
|
||||||
tmpButton->registerOnEvent(shared_from_this(), "pressed", ewolEventParameterSave);
|
tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackParameterSave);
|
||||||
mySizerHori->subWidgetAdd(tmpButton);
|
mySizerHori->subWidgetAdd(tmpButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +100,7 @@ void ewol::widget::Parameter::init() {
|
|||||||
" <label>Close</label>\n"
|
" <label>Close</label>\n"
|
||||||
" </sizer>\n"
|
" </sizer>\n"
|
||||||
"</composer>\n"));
|
"</composer>\n"));
|
||||||
tmpButton->registerOnEvent(shared_from_this(), "pressed", eventClose);
|
tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuclosed);
|
||||||
mySizerHori->subWidgetAdd(tmpButton);
|
mySizerHori->subWidgetAdd(tmpButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +116,7 @@ void ewol::widget::Parameter::init() {
|
|||||||
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
EWOL_ERROR("Can not allocate widget == > display might be in error");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
m_paramList->registerOnEvent(shared_from_this(), "select", l_eventMenuSelected);
|
m_paramList->signalSelect.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuSelected);
|
||||||
m_paramList->setFill(bvec2(false,true));
|
m_paramList->setFill(bvec2(false,true));
|
||||||
m_paramList->setExpand(bvec2(false,true));
|
m_paramList->setExpand(bvec2(false,true));
|
||||||
mySizerHori->subWidgetAdd(m_paramList);
|
mySizerHori->subWidgetAdd(m_paramList);
|
||||||
@ -197,26 +191,21 @@ void ewol::widget::Parameter::setTitle(std::string _label) {
|
|||||||
m_widgetTitle->setLabel(_label);
|
m_widgetTitle->setLabel(_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Parameter::onReceiveMessage(const ewol::object::Message& _msg) {
|
void ewol::widget::Parameter::onCallbackMenuclosed() {
|
||||||
ewol::widget::PopUp::onReceiveMessage(_msg);
|
// inform that the parameter windows is closed
|
||||||
EWOL_DEBUG("event on the parameter : " << _msg);
|
signalClose.emit();
|
||||||
if (_msg.getMessage() == eventClose) {
|
// close this widget ...
|
||||||
// inform that the parameter windows is closed
|
autoDestroy();
|
||||||
generateEventId(eventClose);
|
}
|
||||||
// close this widget ...
|
void ewol::widget::Parameter::onCallbackParameterSave() {
|
||||||
autoDestroy();
|
//ewol::userConfig::Save();
|
||||||
} else if (_msg.getMessage() == ewolEventParameterSave) {
|
EWOL_TODO("Save Parameter !!! ");
|
||||||
//ewol::userConfig::Save();
|
}
|
||||||
EWOL_TODO("Save Parameter !!! ");
|
void ewol::widget::Parameter::onCallbackMenuSelected(const int32_t& _value) {
|
||||||
} else if (_msg.getMessage() == l_eventMenuSelected) {
|
if (m_wSlider != nullptr) {
|
||||||
if (nullptr != m_wSlider) {
|
EWOL_DEBUG("event on the parameter : Menu-select select ID=" << _value << "");
|
||||||
int32_t value = 0;
|
m_wSlider->subWidgetSelectSet(_value);
|
||||||
sscanf(_msg.getData().c_str(), "%d", &value);
|
|
||||||
EWOL_DEBUG("event on the parameter : " << _msg.getMessage() << " select ID=" << value << "");
|
|
||||||
m_wSlider->subWidgetSelectSet(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget) {
|
void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget) {
|
||||||
|
@ -29,15 +29,13 @@ namespace ewol {
|
|||||||
class Parameter : public ewol::widget::PopUp {
|
class Parameter : public ewol::widget::PopUp {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventClose;
|
ewol::object::Signal<void> signalClose;
|
||||||
protected:
|
protected:
|
||||||
Parameter();
|
Parameter();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
DECLARE_WIDGET_FACTORY(Parameter, "Parameter");
|
DECLARE_WIDGET_FACTORY(Parameter, "Parameter");
|
||||||
virtual ~Parameter();
|
virtual ~Parameter();
|
||||||
public: // Derived function
|
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
|
||||||
public:
|
public:
|
||||||
void setTitle(std::string _label);
|
void setTitle(std::string _label);
|
||||||
void menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget);
|
void menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget);
|
||||||
@ -49,6 +47,10 @@ namespace ewol {
|
|||||||
std::shared_ptr<ewol::widget::Label> m_widgetTitle;
|
std::shared_ptr<ewol::widget::Label> m_widgetTitle;
|
||||||
std::shared_ptr<ewol::widget::ParameterList> m_paramList;
|
std::shared_ptr<ewol::widget::ParameterList> m_paramList;
|
||||||
std::shared_ptr<ewol::widget::WSlider> m_wSlider;
|
std::shared_ptr<ewol::widget::WSlider> m_wSlider;
|
||||||
|
private: //callback functions:
|
||||||
|
void onCallbackMenuclosed();
|
||||||
|
void onCallbackParameterSave();
|
||||||
|
void onCallbackMenuSelected(const int32_t& _value);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -15,15 +15,13 @@
|
|||||||
#include <ewol/compositing/Text.h>
|
#include <ewol/compositing/Text.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
|
||||||
const char * const ewol::widget::ParameterList::eventSelect = "select";
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "List"
|
#define __class__ "List"
|
||||||
|
|
||||||
|
|
||||||
ewol::widget::ParameterList::ParameterList() {
|
ewol::widget::ParameterList::ParameterList() :
|
||||||
|
signalSelect(*this, "select") {
|
||||||
addObjectType("ewol::widget::ParameterList");
|
addObjectType("ewol::widget::ParameterList");
|
||||||
addEventId(eventSelect);
|
|
||||||
|
|
||||||
m_idSelected = -1;
|
m_idSelected = -1;
|
||||||
m_paddingSizeX = 2;
|
m_paddingSizeX = 2;
|
||||||
@ -192,7 +190,7 @@ bool ewol::widget::ParameterList::onEventInput(const ewol::event::Input& _event)
|
|||||||
if (rawID >= 0 && (size_t)rawID < m_list.size()) {
|
if (rawID >= 0 && (size_t)rawID < m_list.size()) {
|
||||||
if (m_list[rawID]!=nullptr) {
|
if (m_list[rawID]!=nullptr) {
|
||||||
if (m_list[rawID]->m_refId >= 0) {
|
if (m_list[rawID]->m_refId >= 0) {
|
||||||
generateEventId(eventSelect, etk::to_string(m_list[rawID]->m_refId));
|
signalSelect.emit(m_list[rawID]->m_refId);
|
||||||
m_idSelected = rawID;
|
m_idSelected = rawID;
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,7 +39,7 @@ namespace ewol {
|
|||||||
class ParameterList :public ewol::widget::WidgetScrolled {
|
class ParameterList :public ewol::widget::WidgetScrolled {
|
||||||
public:
|
public:
|
||||||
// Event list of properties
|
// Event list of properties
|
||||||
static const char * const eventSelect;
|
ewol::object::Signal<int32_t> signalSelect;
|
||||||
private:
|
private:
|
||||||
int32_t m_idSelected;
|
int32_t m_idSelected;
|
||||||
std::vector<ewol::widget::elementPL *> m_list;
|
std::vector<ewol::widget::elementPL *> m_list;
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol::StdPopUp"
|
#define __class__ "ewol::StdPopUp"
|
||||||
|
|
||||||
static const char * const eventButtonExit = "ewol-event-pop-up-exit-button";
|
|
||||||
|
|
||||||
ewol::widget::StdPopUp::StdPopUp() :
|
ewol::widget::StdPopUp::StdPopUp() :
|
||||||
m_title(nullptr),
|
m_title(nullptr),
|
||||||
m_comment(nullptr),
|
m_comment(nullptr),
|
||||||
@ -107,17 +105,13 @@ std::shared_ptr<ewol::widget::Button> ewol::widget::StdPopUp::addButton(const st
|
|||||||
}
|
}
|
||||||
myButton->setSubWidget(ewol::widget::Label::create(_text));
|
myButton->setSubWidget(ewol::widget::Label::create(_text));
|
||||||
if(_autoExit == true) {
|
if(_autoExit == true) {
|
||||||
myButton->registerOnEvent(shared_from_this(), ewol::widget::Button::eventPressed, eventButtonExit);
|
myButton->signalPressed.bind(shared_from_this(), &ewol::widget::StdPopUp::onCallBackButtonExit);
|
||||||
}
|
}
|
||||||
m_subBar->subWidgetAdd(myButton);
|
m_subBar->subWidgetAdd(myButton);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return myButton;
|
return myButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::StdPopUp::onReceiveMessage(const ewol::object::Message& _msg) {
|
void ewol::widget::StdPopUp::onCallBackButtonExit() {
|
||||||
// call parent:
|
autoDestroy();
|
||||||
ewol::widget::PopUp::onReceiveMessage(_msg);
|
|
||||||
if (_msg.getMessage() == eventButtonExit) {
|
|
||||||
autoDestroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ namespace ewol {
|
|||||||
* @param[in] _text Decorated text to diplay in button.
|
* @param[in] _text Decorated text to diplay in button.
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<ewol::widget::Button> addButton(const std::string& _text, bool _autoExit=false);
|
std::shared_ptr<ewol::widget::Button> addButton(const std::string& _text, bool _autoExit=false);
|
||||||
public: // Derived function
|
public: // callback function
|
||||||
virtual void onReceiveMessage(const ewol::object::Message& _msg);
|
void onCallBackButtonExit();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -89,15 +89,12 @@ def create(target):
|
|||||||
# object :
|
# object :
|
||||||
myModule.add_src_file([
|
myModule.add_src_file([
|
||||||
'ewol/object/Manager.cpp',
|
'ewol/object/Manager.cpp',
|
||||||
'ewol/object/Message.cpp',
|
|
||||||
'ewol/object/MultiCast.cpp',
|
|
||||||
'ewol/object/Object.cpp',
|
'ewol/object/Object.cpp',
|
||||||
'ewol/object/RemoveEvent.cpp',
|
|
||||||
'ewol/object/Parameter.cpp',
|
'ewol/object/Parameter.cpp',
|
||||||
'ewol/object/ParameterList.cpp',
|
'ewol/object/ParameterList.cpp',
|
||||||
'ewol/object/ParamList.cpp',
|
'ewol/object/ParamList.cpp',
|
||||||
'ewol/object/Param.cpp',
|
'ewol/object/SignalList.cpp',
|
||||||
'ewol/object/ParamRange.cpp'
|
'ewol/object/SignalBase.cpp'
|
||||||
])
|
])
|
||||||
|
|
||||||
# OpenGL interface :
|
# OpenGL interface :
|
||||||
|
@ -1 +1 @@
|
|||||||
0.9.2
|
0.9.3
|
Loading…
x
Reference in New Issue
Block a user