[SAMPLE] add basic sample in the repo

This commit is contained in:
Edouard DUPIN 2014-12-04 23:30:36 +01:00
parent 6e571ae742
commit 6e6a9575bf
30 changed files with 1145 additions and 1 deletions

2
external/ege vendored

@ -1 +1 @@
Subproject commit fd45ef5f7766191491cb4f70f6b38a8c898548d7
Subproject commit bc20095852db600eabef6ee13fae38f09c161d87

View File

@ -0,0 +1,57 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <ewol/context/commandLine.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/object/Object.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
// select internal data for font ...
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
}
void unInit(ewol::Context& _context) {
APPL_INFO("==> Un-Init APPL (START)");
// nothing to do ...
APPL_INFO("==> Un-Init APPL (END)");
}
};
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
* @return std IO
*/
int main(int _argc, const char *_argv[]) {
// second possibility
return ewol::run(new MainApplication(), _argc, _argv);
}

View File

@ -0,0 +1,14 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_MAIN_H__
#define __APPL_MAIN_H__
#endif

View File

@ -0,0 +1,32 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <ewol/ewol.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/widget/Label.h>
#undef __class__
#define __class__ "Windows"
appl::Windows::Windows() {
addObjectType("appl::Windows");
}
void appl::Windows::init() {
setTitle("example 001_HelloWord");
std::shared_ptr<ewol::widget::Label> tmpWidget = ewol::widget::Label::create();
if (tmpWidget == nullptr) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
tmpWidget->setLabel("Hello <font color=\"blue\">Word</font>");
tmpWidget->setExpand(bvec2(true,true));
setSubWidget(tmpWidget);
}
}

View File

@ -0,0 +1,25 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_WINDOWS_H__
#define __APPL_WINDOWS_H__
#include <ewol/widget/Windows.h>
namespace appl {
class Windows : public ewol::widget::Windows {
protected:
Windows();
void init();
public:
DECLARE_FACTORY(Windows);
};
};
#endif

View File

@ -0,0 +1,15 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
int32_t appl::getLogId() {
static int32_t g_val = etk::log::registerInstance("example");
return g_val;
}

View File

@ -0,0 +1,52 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_DEBUG_H__
#define __APPL_DEBUG_H__
#include <etk/log.h>
namespace appl {
int32_t getLogId();
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define APPL_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(appl::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(appl::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data)
#ifdef DEBUG
#define APPL_INFO(data) APPL_BASE(4, data)
#define APPL_DEBUG(data) APPL_BASE(5, data)
#define APPL_VERBOSE(data) APPL_BASE(6, data)
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
#else
#define APPL_INFO(data) do { } while(false)
#define APPL_DEBUG(data) do { } while(false)
#define APPL_VERBOSE(data) do { } while(false)
#define APPL_TODO(data) do { } while(false)
#endif
#define APPL_ASSERT(cond,data) \
do { \
if (!(cond)) { \
APPL_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif

View File

@ -0,0 +1,32 @@
#!/usr/bin/python
import lutinModule as module
import lutinTools as tools
# optionnal : Describe in the "lutin.py --help"
def get_desc():
return "Tutorial 001 : Hello Word"
# Module creation instance (not optionnal)
def create(target):
# module name is '001_HelloWord' and type binary.
myModule = module.Module(__file__, '001_HelloWord', 'BINARY')
# add the file to compile:
myModule.add_src_file([
'appl/Main.cpp',
'appl/debug.cpp',
'appl/Windows.cpp',
])
# add Library dependency name
myModule.add_module_depend(['ewol'])
# add application C flags
myModule.compile_flags_CC([
"-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""])
# Add current include Path
myModule.add_path(tools.get_current_path(__file__))
# return the created module
return myModule

View File

@ -0,0 +1,57 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <ewol/context/commandLine.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/object/Object.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <appl/widget/VectorDisplay.h>
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
// select internal data for font ...
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
appl::widget::VectorDisplay::createManagerWidget(_context.getWidgetManager());
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
}
void unInit(ewol::Context& _context) {
APPL_INFO("==> Un-Init APPL (START)");
// nothing to do...
APPL_INFO("==> Un-Init APPL (END)");
}
};
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
* @return std IO
*/
int main(int _argc, const char *_argv[]) {
// second possibility
return ewol::run(new MainApplication(), _argc, _argv);
}

View File

@ -0,0 +1,14 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_MAIN_H__
#define __APPL_MAIN_H__
#endif

View File

@ -0,0 +1,74 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <ewol/ewol.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Button.h>
#include <appl/widget/VectorDisplay.h>
#include <etk/tool.h>
#undef __class__
#define __class__ "Windows"
static const char* const g_eventChangeValues = "appl-change-value";
static const char* const g_eventAutoMode = "appl-change-auto";
appl::Windows::Windows() :
m_composer(NULL) {
addObjectType("appl::Windows");
}
void appl::Windows::init() {
setTitle("example 001_HelloWord");
std::string composition = std::string("");
composition += "<sizer mode='vert'>\n";
composition += " <sizer mode='hori'>\n";
composition += " <button name='bt-change'>\n";
composition += " <label>\n";
composition += " Change Data ...\n";
composition += " </label>\n";
composition += " </button>\n";
composition += " <button name='bt-auto'>\n";
composition += " <label>\n";
composition += " Auto generate\n";
composition += " </label>\n";
composition += " </button>\n";
composition += " </sizer>\n";
composition += " <VectorDisplay name='displayer' expand='true' fill='true'/>\n";
composition += "</sizer>\n";
m_composer = ewol::widget::Composer::create(ewol::widget::Composer::String, composition);
if (m_composer == NULL) {
APPL_CRITICAL(" An error occured ... in the windows creatrion ...");
return;
}
setSubWidget(m_composer);
subBind(ewol::widget::Button, "bt-change", signalPressed, shared_from_this(), &appl::Windows::onCallbackChangeValues);
subBind(ewol::widget::Button, "bt-auto", signalPressed, shared_from_this(), &appl::Windows::onCallbackAutoMode);
}
void appl::Windows::onCallbackChangeValues() {
std::vector<float> tmp;
for (int32_t iii=0; iii<2048; ++iii) {
tmp.push_back(etk::tool::frand(-1.0, 1.0));
}
std::shared_ptr<appl::widget::VectorDisplay> tmpDisp = std::dynamic_pointer_cast<appl::widget::VectorDisplay>(getSubObjectNamed("displayer"));
if (tmpDisp != NULL) {
tmpDisp->setValue(tmp);
}
}
void appl::Windows::onCallbackAutoMode() {
std::shared_ptr<appl::widget::VectorDisplay> tmpDisp = std::dynamic_pointer_cast<appl::widget::VectorDisplay>(getSubObjectNamed("displayer"));
if (tmpDisp != NULL) {
tmpDisp->ToggleAuto();
}
}

View File

@ -0,0 +1,31 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_WINDOWS_H__
#define __APPL_WINDOWS_H__
#include <ewol/widget/Windows.h>
#include <ewol/widget/Composer.h>
namespace appl {
class Windows : public ewol::widget::Windows {
private:
std::shared_ptr<ewol::widget::Composer> m_composer;
protected:
Windows();
void init();
public:
DECLARE_FACTORY(Windows);
public: // callback functions
void onCallbackChangeValues();
void onCallbackAutoMode();
};
};
#endif

View File

@ -0,0 +1,15 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <appl/debug.h>
int32_t appl::getLogId() {
static int32_t g_val = etk::log::registerInstance("example");
return g_val;
}

View File

@ -0,0 +1,52 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_DEBUG_H__
#define __APPL_DEBUG_H__
#include <etk/log.h>
namespace appl {
int32_t getLogId();
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define APPL_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(appl::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(appl::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data)
#ifdef DEBUG
#define APPL_INFO(data) APPL_BASE(4, data)
#define APPL_DEBUG(data) APPL_BASE(5, data)
#define APPL_VERBOSE(data) APPL_BASE(6, data)
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
#else
#define APPL_INFO(data) do { } while(false)
#define APPL_DEBUG(data) do { } while(false)
#define APPL_VERBOSE(data) do { } while(false)
#define APPL_TODO(data) do { } while(false)
#endif
#define APPL_ASSERT(cond,data) \
do { \
if (!(cond)) { \
APPL_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif

View File

@ -0,0 +1,92 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <appl/debug.h>
#include <appl/widget/VectorDisplay.h>
#include <etk/tool.h>
#undef __class__
#define __class__ "VectorDisplay"
appl::widget::VectorDisplay::VectorDisplay() :
m_autoDisplay(false),
m_minVal(-1.0f),
m_maxVal(1.0f) {
addObjectType("appl::widget::VectorDisplay");
}
void appl::widget::VectorDisplay::init() {
ewol::Widget::init();
markToRedraw();
}
appl::widget::VectorDisplay::~VectorDisplay() {
}
void appl::widget::VectorDisplay::setValue(const std::vector<float>& _data) {
m_data = _data;
markToRedraw();
}
void appl::widget::VectorDisplay::ToggleAuto() {
if (m_autoDisplay == false) {
periodicCallEnable();
m_autoDisplay = true;
} else {
periodicCallDisable();
m_autoDisplay = false;
}
}
void appl::widget::VectorDisplay::onDraw() {
m_draw.draw();
}
void appl::widget::VectorDisplay::onRegenerateDisplay() {
//!< Check if we really need to redraw the display, if not needed, we redraw the previous data ...
if (needRedraw() == false) {
return;
}
// remove previous data
m_draw.clear();
// set background
m_draw.setColor(etk::color::black);
m_draw.setPos(vec2(0,0));
m_draw.rectangleWidth(m_size);
if (m_data.size() == 0) {
return;
}
// set all the line:
m_draw.setColor(etk::color::white);
m_draw.setThickness(1);
float origin = m_size.y()*0.5f;
float ratioY = m_size.y() / (m_maxVal - m_minVal);
float stepX = m_size.x() / (float)m_data.size();
m_draw.setPos(vec2(0, origin + ratioY*m_data[0]));
float baseX = 0;
for (size_t iii=1; iii<m_data.size(); ++iii) {
m_draw.lineTo(vec2((float)iii*stepX, origin + ratioY*m_data[iii]));
}
}
void appl::widget::VectorDisplay::periodicCall(const ewol::event::Time& _event) {
for (size_t iii=0; iii<std::max(m_data.size()/200.0f, 50.0f); ++iii) {
if (m_data.size() > 50) {
m_data.erase(m_data.begin());
}
m_data.push_back(etk::tool::frand(m_minVal, m_maxVal));
}
markToRedraw();
}

View File

@ -0,0 +1,48 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_WIDGET_VECTOR_DISPLAY_H__
#define __APPL_WIDGET_VECTOR_DISPLAY_H__
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/Manager.h>
namespace appl {
namespace widget {
class VectorDisplay : public ewol::Widget {
private:
ewol::compositing::Drawing m_draw; //!< drawing instance
protected:
//! @brief constructor
VectorDisplay();
void init();
public:
DECLARE_WIDGET_FACTORY(VectorDisplay, "VectorDisplay");
//! @brief destructor
virtual ~VectorDisplay();
private:
std::vector<float> m_data; //!< data that might be displayed
public:
void setValue(const std::vector<float>& _data);
private:
bool m_autoDisplay;
public:
void ToggleAuto();
private:
float m_minVal; //!< display minimum value
float m_maxVal; //!< display maximum value
public: // herited function
virtual void onDraw();
virtual void onRegenerateDisplay();
virtual void periodicCall(const ewol::event::Time& _event);
};
};
};
#endif

View File

@ -0,0 +1,34 @@
#!/usr/bin/python
import lutinModule as module
import lutinTools as tools
# optionnal : Describe in the "lutin.py --help"
def get_desc():
return "Tutorial 0XX : Create custom Widget"
# Module creation instance (not optionnal)
def create(target):
# module name is '001_HelloWord' and type binary.
myModule = module.Module(__file__, '0XX_customwidget', 'BINARY')
# add the file to compile:
myModule.add_src_file([
'appl/Main.cpp',
'appl/debug.cpp',
'appl/Windows.cpp',
'appl/widget/VectorDisplay.cpp',
])
# add Library dependency name
myModule.add_module_depend(['ewol'])
# add application C flags
myModule.compile_flags_CC([
"-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""])
# Add current include Path
myModule.add_path(tools.get_current_path(__file__))
# return the created module
return myModule

52
sample/README.md Normal file
View File

@ -0,0 +1,52 @@
Ewol Samples
============
Ewol sample are a FREE software for learn use of ewol.
Instructions
============
download the software :
git clone git://github.com/HeeroYui/ewol.git
cd ewol
git submodule init
git submodule update
Compile software and install : (build all binary and libs)
ewol/build/lutin.py -j4
Dependency packages
===================
sudo apt-get install g++ libgl1-mesa-dev zlib1g-dev libasound2-dev
# if you want to compile with clang :
sudo apt-get install clang
# For andoid compilation (jdk 7 does not work...)
sudo apt-get install javacc openjdk-6-jdk
# if you want to compile for windows :
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-mingw-w64
# on 64 bits processor for compatibility
sudo apt-get install ia32-libs
sudo apt-get install g++-multilib libc6-dev-i386
License (APACHE v2.0)
=====================
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.

BIN
sample/data/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -0,0 +1,57 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <ewol/context/commandLine.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/object/Object.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
class MainApplication : public ewol::context::Application {
public:
bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
// select internal data for font ...
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
}
void unInit(ewol::Context& _context) {
APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)");
// nothing to do ...
APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)");
}
};
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
* @return std IO
*/
int main(int _argc, const char *_argv[]) {
// second possibility
return ewol::run(new MainApplication(), _argc, _argv);
}

View File

@ -0,0 +1,14 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_MAIN_H__
#define __APPL_MAIN_H__
#endif

View File

@ -0,0 +1,116 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/WidgetDisplay.h>
#include <appl/debug.h>
#include <etk/tool.h>
#undef __class__
#define __class__ "WidgetDisplay"
appl::WidgetDisplay::WidgetDisplay() {
addObjectType("appl::WidgetDisplay");
}
void appl::WidgetDisplay::init() {
ewol::Widget::init();
m_compositing.setSource("DATA:SnowFlake.svg", ivec2(128,128));
setCanHaveFocus(true);
periodicCallEnable();
for (int32_t iii=0; iii<250 ; ++iii) {
m_elements.push_back(appl::WidgetDisplay::Element());
}
}
appl::WidgetDisplay::~WidgetDisplay() {
}
void appl::WidgetDisplay::onDraw() {
m_compositing.draw();
}
appl::WidgetDisplay::Element::Element() {
regenerate(vec2(1024,2048));
m_lifeTime = etk::tool::frand(-4,4);
m_life = m_lifeTime;
}
void appl::WidgetDisplay::Element::regenerate(const vec2& _size) {
float sizeDisplay=etk::tool::frand(10,64);
m_position = vec2(etk::tool::frand(0,_size.x()),
etk::tool::frand(_size.y(),_size.y()+64));
m_size = vec2(sizeDisplay,sizeDisplay);
m_angle = etk::tool::frand(-3.1415952f,3.1415952f);
m_lifeTime = etk::tool::frand(1,10);
m_life = m_lifeTime;
m_lifeTime += 4;
m_angleAdd = etk::tool::frand(-0.05f,0.05f);
m_downSpeed = etk::tool::frand(0.5f,3.f);
}
void appl::WidgetDisplay::Element::move(float _deltaTime) {
m_lifeTime -= _deltaTime;
m_position -= vec2(0, m_downSpeed);
m_angle += m_angleAdd;
}
void appl::WidgetDisplay::onRegenerateDisplay() {
if (needRedraw() == false) {
return;
}
// remove data of the previous composition :
m_compositing.clear();
for (int32_t iii=0; iii<m_elements.size() ; ++iii) {
if (m_elements[iii].m_lifeTime < 0.0f) {
int32_t color = 0xFF*(1.0f+0.25*m_elements[iii].m_lifeTime);
m_compositing.setColor(etk::Color<>(0xFF, 0xFF, 0xFF, color));
} else if (m_elements[iii].m_lifeTime > m_elements[iii].m_life) {
int32_t color = 0xFF*(1.0f-0.25*(m_elements[iii].m_lifeTime - m_elements[iii].m_life));
m_compositing.setColor(etk::Color<>(0xFF, 0xFF, 0xFF, color));
} else {
m_compositing.setColor(etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF));
}
//3d7dab
m_compositing.setPos(m_elements[iii].m_position);
m_compositing.setAngle(m_elements[iii].m_angle);
m_compositing.print(m_elements[iii].m_size);
}
}
void appl::WidgetDisplay::periodicCall(const ewol::event::Time& _event) {
float curentDelta=_event.getDeltaCall();
// set the somposition properties :
for (int32_t iii=0; iii<m_elements.size() ; ++iii) {
m_elements[iii].move(curentDelta);
if( m_elements[iii].m_lifeTime < -4.0f
|| m_elements[iii].m_position.y() < -m_elements[iii].m_size.y()*1.4f) {
// change properties
m_elements[iii].regenerate(m_size);
}
}
markToRedraw();
}
bool appl::WidgetDisplay::onEventInput(const ewol::event::Input& _event) {
//EWOL_DEBUG("Input event : " << _event);
vec2 relPos = relativePosition(_event.getPos());
if (_event.getType() == ewol::key::typeFinger) {
keepFocus();
if (1 == _event.getId()) {
APPL_DEBUG("Touch event ... ");
}
}
return false;
}

View File

@ -0,0 +1,49 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_WIDGET_DISPLAY_H__
#define __APPL_WIDGET_DISPLAY_H__
#include <draw/Color.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Image.h>
namespace appl {
class WidgetDisplay : public ewol::Widget {
private:
class Element {
public:
Element();
vec2 m_position;
vec2 m_size;
float m_angle;
float m_lifeTime;
float m_life;
float m_angleAdd;
float m_downSpeed;
void regenerate(const vec2& _size);
void move(float _deltaTime);
};
protected:
WidgetDisplay();
void init();
public:
DECLARE_FACTORY(WidgetDisplay);
virtual ~WidgetDisplay();
ewol::compositing::Image m_compositing;
std::vector<Element> m_elements;
public: // Derived function
void onRegenerateDisplay();
virtual void periodicCall(const ewol::event::Time& _event);
virtual bool onEventInput(const ewol::event::Input& _event);
virtual void onDraw();
};
};
#endif

View File

@ -0,0 +1,39 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <ewol/ewol.h>
#include <appl/debug.h>
#include <appl/WidgetDisplay.h>
#include <appl/Windows.h>
#undef __class__
#define __class__ "Windows"
appl::Windows::Windows() {
addObjectType("appl::Windows");
}
void appl::Windows::init() {
ewol::widget::Windows::init();
setTitle("example Wallpaper");
std::shared_ptr<appl::WidgetDisplay> tmpWidget = appl::WidgetDisplay::create();
if (tmpWidget == nullptr) {
APPL_ERROR("Can not allocate widget ==> display might be in error");
} else {
setSubWidget(tmpWidget);
tmpWidget->setExpand(bvec2(true,true));
tmpWidget->setFill(bvec2(true,true));
}
setBackgroundColor(etk::Color<float>(0,0,0,0));
}
appl::Windows::~Windows() {
}

View File

@ -0,0 +1,27 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_WINDOWS_H__
#define __APPL_WINDOWS_H__
#include <appl/WidgetDisplay.h>
#include <ewol/widget/Windows.h>
namespace appl {
class Windows : public ewol::widget::Windows {
protected:
Windows();
void init();
public:
DECLARE_FACTORY(Windows);
virtual ~Windows();
};
};
#endif

View File

@ -0,0 +1,15 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
int32_t appl::getLogId() {
static int32_t g_val = etk::log::registerInstance("example");
return g_val;
}

View File

@ -0,0 +1,52 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __APPL_DEBUG_H__
#define __APPL_DEBUG_H__
#include <etk/log.h>
namespace appl {
int32_t getLogId();
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define APPL_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(appl::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(appl::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data)
#ifdef DEBUG
#define APPL_INFO(data) APPL_BASE(4, data)
#define APPL_DEBUG(data) APPL_BASE(5, data)
#define APPL_VERBOSE(data) APPL_BASE(6, data)
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
#else
#define APPL_INFO(data) do { } while(false)
#define APPL_DEBUG(data) do { } while(false)
#define APPL_VERBOSE(data) do { } while(false)
#define APPL_TODO(data) do { } while(false)
#endif
#define APPL_ASSERT(cond,data) \
do { \
if (!(cond)) { \
APPL_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif

View File

@ -0,0 +1,5 @@
<?xml encoding="UTF-8"?>
<svg width="397" height="411">
<path d="M 183.3125,43.09375 L 183.3125,83.8125 L 152.71875,66.125 L 137.1875,92.9375 L 183.3125,119.65625 L 183.3125,179.75 L 131.5,149.8125 L 131.40625,96.28125 L 100.40625,96.34375 L 100.46875,131.90625 L 65.09375,111.46875 L 49.59375,138.3125 L 84.875,158.6875 L 54.25,176.3125 L 69.6875,203.1875 L 115.90625,176.59375 L 167.90625,206.625 L 116.09375,236.53125 L 69.6875,209.84375 L 54.25,236.71875 L 85.0625,254.46875 L 49.6875,274.875 L 65.1875,301.71875 L 100.46875,281.34375 L 100.40625,316.6875 L 131.40625,316.75 L 131.5,263.4375 L 183.5,233.4375 L 183.5,293.25 L 137.1875,320.09375 L 152.71875,346.90625 L 183.5,329.09375 L 183.5,369.9375 L 214.5,369.9375 L 214.5,329.21875 L 245.09375,346.90625 L 260.625,320.09375 L 214.5,293.375 L 214.5,233.28125 L 266.3125,263.21875 L 266.40625,316.75 L 297.40625,316.6875 L 297.34375,281.125 L 332.71875,301.5625 L 348.21875,274.71875 L 312.9375,254.34375 L 343.5625,236.71875 L 328.125,209.84375 L 281.9375,236.4375 L 229.90625,206.40625 L 281.75,176.46875 L 328.125,203.1875 L 343.5625,176.3125 L 312.75,158.5625 L 348.125,138.15625 L 332.625,111.3125 L 297.34375,131.6875 L 297.40625,96.34375 L 266.40625,96.28125 L 266.3125,149.59375 L 214.3125,179.59375 L 214.3125,119.78125 L 260.625,92.9375 L 245.09375,66.125 L 214.3125,83.9375 L 214.3125,43.09375 L 183.3125,43.09375 z"
style="fill:#fff;fill-opacity:1;stroke:none"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,61 @@
#!/usr/bin/python
import lutinModule as module
import lutinTools as tools
import datetime
def get_desc():
return "Tutorial xxx example wallpaper"
def create(target):
# module name is 'edn' and type binary.
myModule = module.Module(__file__, 'examplewallpaper', 'PACKAGE')
# add the file to compile:
myModule.add_src_file([
'appl/Main.cpp',
'appl/debug.cpp',
'appl/WidgetDisplay.cpp',
'appl/Windows.cpp',
])
myModule.add_module_depend(['ewol'])
myModule.compile_flags_CC([
"-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""])
myModule.copy_folder('data/SnowFlake.svg','')
myModule.add_path(tools.get_current_path(__file__))
now = datetime.datetime.now()
versionID=str(now.year-2013)+"."+str(now.month)+"."+str(now.day)
# set the package properties :
myModule.pkg_set("VERSION", versionID)
myModule.pkg_set("COMPAGNY_TYPE", "org")
myModule.pkg_set("COMPAGNY_NAME", "EWOL")
myModule.pkg_set("MAINTAINER", ["Mr DUPIN Edouard <yui.heero@gmail.com>"])
myModule.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.png")
myModule.pkg_set("SECTION", "example")
myModule.pkg_set("PRIORITY", "extra")
myModule.pkg_set("DESCRIPTION", "EWOL example for Wallpaper on Android")
myModule.pkg_set("NAME", "ewol Wallpaper ewample")
myModule.pkg_set("ANDROID_APPL_TYPE", "WALLPAPER")
#for the exemple :
myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", "testpattern", "Select test pattern", "Choose which test pattern to display", \
[ ["key","value display"],\
["key2","value display 2"]\
] \
])
myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", "movement", "Motion", "Apply movement to test pattern", ["Moving test pattern", "Still test pattern"]])
# add the currrent module at the
return myModule

13
sample/license.txt Normal file
View File

@ -0,0 +1,13 @@
Copyright ewol samples 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.