[DEV] UPDATE at gale architecture (BAD display)

This commit is contained in:
Edouard DUPIN 2015-08-04 23:24:28 +02:00
parent b569e69297
commit 4325aaecf2
116 changed files with 829 additions and 8388 deletions

View File

@ -1,316 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/Dimension.h>
#include <ewol/debug.h>
#undef __class__
#define __class__ "Dimension"
// TODO : set this in a super class acced in a statin fuction...
// ratio in milimeter :
static bool isInit = false;
static vec2 ratio(9999999,888888);
static vec2 invRatio(1,1);
static ewol::Dimension windowsSize(vec2(9999999,888888), ewol::Dimension::Pixel);
static const float inchToMillimeter = 1.0f/25.4f;
static const float footToMillimeter = 1.0f/304.8f;
static const float meterToMillimeter = 1.0f/1000.0f;
static const float centimeterToMillimeter = 1.0f/10.0f;
static const float kilometerToMillimeter = 1.0f/1000000.0f;
static const float millimeterToInch = 25.4f;
static const float millimeterToFoot = 304.8f;
static const float millimeterToMeter =1000.0f;
static const float millimeterToCentimeter = 10.0f;
static const float millimeterToKilometer = 1000000.0f;
void ewol::Dimension::init() {
if (true == isInit) {
return;
}
ewol::Dimension conversion(vec2(72,72), ewol::Dimension::Inch);
ratio = conversion.getMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(200,200), ewol::Dimension::Pixel);
isInit = true;
}
void ewol::Dimension::unInit() {
isInit = false;
ratio.setValue(9999999,888888);
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(9999999,88888), ewol::Dimension::Pixel);
}
void ewol::Dimension::setPixelRatio(const vec2& _ratio, enum ewol::Dimension::distance _type) {
ewol::Dimension::init();
EWOL_INFO("Set a new screen ratio for the screen : ratio=" << _ratio << " type=" << _type);
ewol::Dimension conversion(_ratio, _type);
EWOL_INFO(" == > " << conversion);
ratio = conversion.getMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
EWOL_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio);
}
void ewol::Dimension::setPixelWindowsSize(const vec2& _size) {
windowsSize = _size;
EWOL_VERBOSE("Set a new Windows property size " << windowsSize << "px");
}
vec2 ewol::Dimension::getWindowsSize(enum ewol::Dimension::distance _type) {
return windowsSize.get(_type);
}
float ewol::Dimension::getWindowsDiag(enum ewol::Dimension::distance _type) {
vec2 size = ewol::Dimension::getWindowsSize(_type);
return size.length();
}
ewol::Dimension::Dimension() :
m_data(0,0),
m_type(ewol::Dimension::Pixel) {
// notinh to do ...
}
ewol::Dimension::Dimension(const vec2& _size, enum ewol::Dimension::distance _type) :
m_data(0,0),
m_type(ewol::Dimension::Pixel) {
set(_size, _type);
}
void ewol::Dimension::set(std::string _config) {
m_data.setValue(0,0);
m_type = ewol::Dimension::Pixel;
enum distance type = ewol::Dimension::Pixel;
if (etk::end_with(_config, "%", false) == true) {
type = ewol::Dimension::Pourcent;
_config.erase(_config.size()-1, 1);
} else if (etk::end_with(_config, "px",false) == true) {
type = ewol::Dimension::Pixel;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "ft",false) == true) {
type = ewol::Dimension::foot;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "in",false) == true) {
type = ewol::Dimension::Inch;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "km",false) == true) {
type = ewol::Dimension::Kilometer;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "mm",false) == true) {
type = ewol::Dimension::Millimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "cm",false) == true) {
type = ewol::Dimension::Centimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "m",false) == true) {
type = ewol::Dimension::Meter;
_config.erase(_config.size()-1, 1);
} else {
EWOL_CRITICAL("Can not parse dimention : \"" << _config << "\"");
return;
}
vec2 tmp = _config;
set(tmp, type);
EWOL_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
}
ewol::Dimension::~Dimension() {
// nothing to do ...
}
ewol::Dimension::operator std::string() const {
std::string str;
str = get(getType());
switch(getType()) {
case ewol::Dimension::Pourcent:
str += "%";
break;
case ewol::Dimension::Pixel:
str += "px";
break;
case ewol::Dimension::Meter:
str += "m";
break;
case ewol::Dimension::Centimeter:
str += "cm";
break;
case ewol::Dimension::Millimeter:
str += "mm";
break;
case ewol::Dimension::Kilometer:
str += "km";
break;
case ewol::Dimension::Inch:
str += "in";
break;
case ewol::Dimension::foot:
str += "ft";
break;
}
return str;
}
vec2 ewol::Dimension::get(enum ewol::Dimension::distance _type) const {
switch(_type) {
case ewol::Dimension::Pourcent:
return getPourcent();
case ewol::Dimension::Pixel:
return getPixel();
case ewol::Dimension::Meter:
return getMeter();
case ewol::Dimension::Centimeter:
return getCentimeter();
case ewol::Dimension::Millimeter:
return getMillimeter();
case ewol::Dimension::Kilometer:
return getKilometer();
case ewol::Dimension::Inch:
return getInch();
case ewol::Dimension::foot:
return getFoot();
}
return vec2(0,0);
}
void ewol::Dimension::set(const vec2& _size, enum ewol::Dimension::distance _type) {
// set min max on input to limit error :
vec2 size(std::avg(0.0f,_size.x(),9999999.0f),
std::avg(0.0f,_size.y(),9999999.0f));
switch(_type) {
case ewol::Dimension::Pourcent: {
vec2 size2(std::avg(0.0f,_size.x(),100.0f),
std::avg(0.0f,_size.y(),100.0f));
m_data = vec2(size2.x()*0.01f, size2.y()*0.01f);
//EWOL_VERBOSE("Set % : " << size2 << " == > " << m_data);
break;
}
case ewol::Dimension::Pixel:
m_data = size;
break;
case ewol::Dimension::Meter:
m_data = vec2(size.x()*meterToMillimeter*ratio.x(), size.y()*meterToMillimeter*ratio.y());
break;
case ewol::Dimension::Centimeter:
m_data = vec2(size.x()*centimeterToMillimeter*ratio.x(), size.y()*centimeterToMillimeter*ratio.y());
break;
case ewol::Dimension::Millimeter:
m_data = vec2(size.x()*ratio.x(), size.y()*ratio.y());
break;
case ewol::Dimension::Kilometer:
m_data = vec2(size.x()*kilometerToMillimeter*ratio.x(), size.y()*kilometerToMillimeter*ratio.y());
break;
case ewol::Dimension::Inch:
m_data = vec2(size.x()*inchToMillimeter*ratio.x(), size.y()*inchToMillimeter*ratio.y());
break;
case ewol::Dimension::foot:
m_data = vec2(size.x()*footToMillimeter*ratio.x(), size.y()*footToMillimeter*ratio.y());
break;
}
m_type = _type;
}
vec2 ewol::Dimension::getPixel() const {
if (m_type!=ewol::Dimension::Pourcent) {
return m_data;
} else {
vec2 windDim = windowsSize.getPixel();
vec2 res = vec2(windDim.x()*m_data.x(), windDim.y()*m_data.y());
//EWOL_DEBUG("Get % : " << m_data << " / " << windDim << " == > " << res);
return res;
}
}
vec2 ewol::Dimension::getPourcent() const {
if (m_type!=ewol::Dimension::Pourcent) {
vec2 windDim = windowsSize.getPixel();
//EWOL_DEBUG(" windows dimention : " /*<< windowsSize*/ << " == > " << windDim << "px"); // ==> infinite loop ...
//printf(" windows dimention : %f,%f", windDim.x(),windDim.y());
//printf(" data : %f,%f", m_data.x(),m_data.y());
return vec2((m_data.x()/windDim.x())*100.0f, (m_data.y()/windDim.y())*100.0f);
}
return vec2(m_data.x()*100.0f, m_data.y()*100.0f);;
}
vec2 ewol::Dimension::getMeter() const {
return ewol::Dimension::getMillimeter()*millimeterToMeter;
}
vec2 ewol::Dimension::getCentimeter() const {
return ewol::Dimension::getMillimeter()*millimeterToCentimeter;
}
vec2 ewol::Dimension::getMillimeter() const {
return ewol::Dimension::getPixel()*invRatio;
}
vec2 ewol::Dimension::getKilometer() const {
return ewol::Dimension::getMillimeter()*millimeterToKilometer;
}
vec2 ewol::Dimension::getInch() const {
return ewol::Dimension::getMillimeter()*millimeterToInch;
}
vec2 ewol::Dimension::getFoot() const {
return ewol::Dimension::getMillimeter()*millimeterToFoot;
}
std::ostream& ewol::operator <<(std::ostream& _os, enum ewol::Dimension::distance _obj) {
switch(_obj) {
case ewol::Dimension::Pourcent:
_os << "%";
break;
case ewol::Dimension::Pixel:
_os << "px";
break;
case ewol::Dimension::Meter:
_os << "m";
break;
case ewol::Dimension::Centimeter:
_os << "cm";
break;
case ewol::Dimension::Millimeter:
_os << "mm";
break;
case ewol::Dimension::Kilometer:
_os << "km";
break;
case ewol::Dimension::Inch:
_os << "in";
break;
case ewol::Dimension::foot:
_os << "ft";
break;
}
return _os;
}
std::ostream& ewol::operator <<(std::ostream& _os, const ewol::Dimension& _obj) {
_os << _obj.get(_obj.getType()) << _obj.getType();
return _os;
}
namespace etk {
template<> std::string to_string<ewol::Dimension>(const ewol::Dimension& _obj) {
return _obj;
}
template<> std::u32string to_u32string<ewol::Dimension>(const ewol::Dimension& _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);
return true;
}
template<> bool from_string<ewol::Dimension>(ewol::Dimension& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
}
};

View File

@ -1,212 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_DIMENSION_H__
#define __EWOL_DIMENSION_H__
#include <etk/types.h>
#include <etk/types.h>
#include <etk/math/Vector2D.h>
namespace ewol {
/**
* @brief in the dimention class we store the data as the more usefull unit (pixel)
* but one case need to be dynamic the %, then when requested in % the register the % value
*/
class Dimension {
public:
enum distance {
Pourcent=0,
Pixel,
Meter,
Centimeter,
Millimeter,
Kilometer,
Inch,
foot,
};
private:
vec2 m_data;
enum distance m_type;
public:
/**
* @brief Constructor (default :0,0 mode pixel)
*/
Dimension();
/**
* @brief Constructor
* @param[in] _size Requested dimention
* @param[in] _type Unit of the Dimention
*/
Dimension(const vec2& _size, enum ewol::Dimension::distance _type=ewol::Dimension::Pixel);
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const std::string& _config) :
m_data(0,0),
m_type(ewol::Dimension::Pixel) {
set(_config);
};
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const char* _config) :
m_data(0,0),
m_type(ewol::Dimension::Pixel) {
set(_config);
};
/**
* @brief Destructor
*/
~Dimension();
/**
* @brief string cast :
*/
operator std::string() const;
/**
* @brief get the current dimention in requested type
* @param[in] _type Type of unit requested.
* @return dimention requested.
*/
vec2 get(enum distance _type) const;
/**
* @brief set the current dimention in requested type
* @param[in] _size Dimention to set
* @param[in] _type Type of unit requested.
*/
void set(const vec2& _size, enum distance _type);
private:
/**
* @brief set the current dimention in requested type
* @param[in] _config dimension configuration.
*/
void set(std::string _config);
public:
/**
* @brief get the current dimention in pixel
* @return dimention in Pixel
*/
vec2 getPixel() const;
/**
* @brief get the current dimention in Pourcent
* @return dimention in Pourcent
*/
vec2 getPourcent() const;
/**
* @brief get the current dimention in Meter
* @return dimention in Meter
*/
vec2 getMeter() const;
/**
* @brief get the current dimention in Centimeter
* @return dimention in Centimeter
*/
vec2 getCentimeter() const;
/**
* @brief get the current dimention in Millimeter
* @return dimention in Millimeter
*/
vec2 getMillimeter() const;
/**
* @brief get the current dimention in Kilometer
* @return dimention in Kilometer
*/
vec2 getKilometer() const;
/**
* @brief get the current dimention in Inch
* @return dimention in Inch
*/
vec2 getInch() const;
/**
* @brief get the current dimention in Foot
* @return dimention in Foot
*/
vec2 getFoot() const;
/*****************************************************
* = assigment
*****************************************************/
const Dimension& operator= (const Dimension& _obj ) {
if (this!=&_obj) {
m_data = _obj.m_data;
m_type = _obj.m_type;
}
return *this;
}
/*****************************************************
* == operator
*****************************************************/
bool operator == (const Dimension& _obj) const {
if( m_data == _obj.m_data
&& m_type == _obj.m_type) {
return true;
}
return false;
}
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const Dimension& _obj) const {
if( m_data != _obj.m_data
|| m_type != _obj.m_type) {
return true;
}
return false;
}
/**
* @breif get the dimension type
* @return the type
*/
enum distance getType() const {
return m_type;
};
public : // Global static access :
/**
* @brief basic init
*/
static void init();
/**
* @brief basic un-init
*/
static void unInit();
/**
* @brief set the Milimeter ratio for calculation
* @param[in] Ratio Milimeter ration for the screen calculation interpolation
* @param[in] type Unit type requested.
* @note: same as @ref setPixelPerInch (internal manage convertion)
*/
static void setPixelRatio(const vec2& _ratio, enum ewol::Dimension::distance _type);
/**
* @brief set the current Windows size
* @param[in] size size of the current windows in pixel.
*/
static void setPixelWindowsSize(const vec2& _size);
/**
* @brief get the Windows size in the request unit
* @param[in] type Unit type requested.
* @return the requested size
*/
static vec2 getWindowsSize(enum ewol::Dimension::distance _type);
/**
* @brief get the Windows diagonal size in the request unit
* @param[in] type Unit type requested.
* @return the requested size
*/
static float getWindowsDiag(enum ewol::Dimension::distance _type);
};
std::ostream& operator <<(std::ostream& _os, enum ewol::Dimension::distance _obj);
std::ostream& operator <<(std::ostream& _os, const ewol::Dimension& _obj);
};
#endif

View File

@ -22,7 +22,7 @@ ewol::compositing::Area::Area(const ivec2& _size) :
m_GLtexture(-1),
m_GLtexID(-1),
m_resource(nullptr) {
m_resource = gale::resource::Texture::create();
m_resource = ewol::resource::Texture::create();
m_resource->setImageSize(_size);
m_resource->flush();
loadProgram();
@ -71,7 +71,7 @@ void ewol::compositing::Area::draw(bool _disableDepthTest) {
// color :
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
}

View File

@ -13,7 +13,8 @@
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <gale/resource/Program.h>
#include <gale/resource/Texture.h>
#include <ewol/resource/Texture.h>
#include <egami/Image.h>
namespace ewol {
namespace compositing {
@ -29,7 +30,7 @@ namespace ewol {
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
std::shared_ptr<gale::resource::Texture> m_resource; //!< texture resources
std::shared_ptr<ewol::resource::Texture> m_resource; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
@ -90,9 +91,11 @@ namespace ewol {
*/
void print(const ivec2& _size);
/*
egami::Image& get() {
return m_resource->get();
};
*/
void flush() {
m_resource->flush();
};

View File

@ -285,7 +285,7 @@ void ewol::compositing::Drawing::loadProgram() {
// remove previous loading ... in case
unLoadProgram();
// oad the new ...
m_GLprogram = ewol::resource::Program::create("DATA:color3.prog");
m_GLprogram = gale::resource::Program::create("DATA:color3.prog");
// get the shader resource :
if (nullptr != m_GLprogram ) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
@ -316,7 +316,7 @@ void ewol::compositing::Drawing::draw(bool _disableDepthTest) {
// color :
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
}

View File

@ -13,7 +13,7 @@
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/resource/Program.h>
#include <gale/resource/Program.h>
namespace ewol {
@ -28,7 +28,7 @@ namespace ewol {
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
private:
std::shared_ptr<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
std::shared_ptr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLMatrixPosition; //!< position matrix

View File

@ -43,9 +43,9 @@ void ewol::compositing::Image::loadProgram() {
m_GLPosition = 0;
m_GLprogram.reset();
if (m_distanceFieldMode == true) {
m_GLprogram = ewol::resource::Program::create("DATA:texturedDF.prog");
m_GLprogram = gale::resource::Program::create("DATA:texturedDF.prog");
} else {
m_GLprogram = ewol::resource::Program::create("DATA:textured3D.prog");
m_GLprogram = gale::resource::Program::create("DATA:textured3D.prog");
}
if (m_GLprogram != nullptr) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
@ -71,9 +71,9 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) {
return;
}
if (_disableDepthTest == true) {
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::disable(gale::openGL::flag_depthTest);
} else {
gale::openGL::enable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::enable(gale::openGL::flag_depthTest);
}
// set Matrix : translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply;
@ -98,7 +98,7 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) {
// color :
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
}

View File

@ -11,7 +11,7 @@
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/resource/Program.h>
#include <gale/resource/Program.h>
#include <ewol/resource/Image.h>
#include <ewol/resource/ImageDF.h>
@ -29,7 +29,7 @@ namespace ewol {
etk::Color<> m_color; //!< The text foreground color
float m_angle; //!< Angle to set at the axes
private:
std::shared_ptr<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
std::shared_ptr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer)

View File

@ -118,7 +118,7 @@ void ewol::compositing::Shaper::loadProgram() {
}
// get the shader resource :
m_GLPosition = 0;
m_GLprogram = ewol::resource::Program::create(tmpFilename);
m_GLprogram = gale::resource::Program::create(tmpFilename);
if (m_GLprogram != nullptr) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord2d");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
@ -202,8 +202,8 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getId());
}
// Request the draw of the elements :
//gale::openGL::drawArrays(GL_TRIANGLES, 0, SHAPER_NB_MAX_VERTEX);
gale::openGL::drawArrays(GL_TRIANGLE_STRIP, 0, m_nbVertexToDisplay);
//gale::openGL::drawArrays(gale::openGL::render_triangle, 0, SHAPER_NB_MAX_VERTEX);
gale::openGL::drawArrays(gale::openGL::render_triangleStrip, 0, m_nbVertexToDisplay);
m_GLprogram->unUse();
}

View File

@ -11,7 +11,7 @@
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/resource/Program.h>
#include <gale/resource/Program.h>
#include <ewol/resource/ConfigFile.h>
#include <ewol/resource/ColorFile.h>
#include <ewol/resource/Image.h>
@ -55,7 +55,7 @@ namespace ewol {
int32_t m_confColorFile; //!< ConfigFile opengGl color file Name
int32_t m_confImageFile; //!< ConfigFile opengGl program Name
// openGL shaders programs:
std::shared_ptr<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
std::shared_ptr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on vec2(X,Y))

View File

@ -11,7 +11,6 @@
#include <ewol/debug.h>
#include <ewol/compositing/Image.h>
#include <ewol/resource/Manager.h>
namespace ewol {
namespace compositing {

View File

@ -44,7 +44,7 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en
return;
}
if (_enableDepthTest == true) {
gale::openGL::enable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::enable(gale::openGL::flag_depthTest);
}
// set Matrix : translation/positionMatrix
mat4 projMatrix = gale::openGL::getMatrix();
@ -63,10 +63,10 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en
// color :
m_GLprogram->sendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
if (_enableDepthTest == true) {
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::disable(gale::openGL::flag_depthTest);
}
}
@ -102,7 +102,7 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) {
// color :
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
}

View File

@ -53,8 +53,8 @@ ewol::compositing::TextBase::~TextBase() {
void ewol::compositing::TextBase::loadProgram(const std::string& _shaderName) {
// get the shader resource :
m_GLPosition = 0;
std::shared_ptr<ewol::resource::Program> old = m_GLprogram;
m_GLprogram = ewol::resource::Program::create(_shaderName);
std::shared_ptr<gale::resource::Program> old = m_GLprogram;
m_GLprogram = gale::resource::Program::create(_shaderName);
if (m_GLprogram != nullptr) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");

View File

@ -77,7 +77,7 @@ namespace ewol {
float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one)
enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...)
protected:
std::shared_ptr<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
std::shared_ptr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer)

View File

@ -55,7 +55,7 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
return;
}
if (_enableDepthTest == true) {
gale::openGL::enable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::enable(gale::openGL::flag_depthTest);
}
// set Matrix : translation/positionMatrix
mat4 projMatrix = gale::openGL::getMatrix();
@ -72,10 +72,10 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
m_GLprogram->sendAttribute(m_GLglyphLevel, m_glyphLevel);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
if (_enableDepthTest == true) {
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::disable(gale::openGL::flag_depthTest);
}
}
@ -110,7 +110,7 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
m_GLprogram->sendAttribute(m_GLglyphLevel, m_glyphLevel);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size());
m_GLprogram->unUse();
}

View File

@ -1,904 +0,0 @@
/**
* @author Edouard DUPIN, Kevin BILLONNEAU
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <jni.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <pthread.h>
#include <mutex>
#include <ewol/debug.h>
#include <ewol/context/Context.h>
#include <ewol/Dimension.h>
/* include auto generated file */
#include <org_ewol_EwolConstants.h>
#include <jvm-basics/jvm-basics.h>
int64_t ewol::getTime() {
struct timeval now;
gettimeofday(&now, nullptr);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
}
// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include
std::mutex g_interfaceMutex;
class AndroidContext : public ewol::Context {
public:
enum application {
appl_unknow,
appl_application,
appl_wallpaper
};
private:
enum application m_javaApplicationType;
// get a resources from the java environement :
JNIEnv* m_JavaVirtualMachinePointer; //!< the JVM
jclass m_javaClassEwol; //!< main activity class (android ...)
jclass m_javaClassEwolCallback;
jobject m_javaObjectEwolCallback;
jmethodID m_javaMethodEwolCallbackStop; //!< Stop function identifier
jmethodID m_javaMethodEwolCallbackEventNotifier; //!< basic methode to call ...
jmethodID m_javaMethodEwolCallbackKeyboardUpdate; //!< basic methode to call ...
jmethodID m_javaMethodEwolCallbackOrientationUpdate;
jmethodID m_javaMethodEwolActivitySetTitle;
jmethodID m_javaMethodEwolActivityOpenURI;
jmethodID m_javaMethodEwolActivitySetClipBoardString;
jmethodID m_javaMethodEwolActivityGetClipBoardString;
jclass m_javaDefaultClassString; //!< default string class
int32_t m_currentHeight;
ewol::key::Special m_guiKeyBoardSpecialKeyMode;//!< special key of the android system :
bool m_clipBoardOwnerStd;
private:
bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) {
_mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign);
if(_mid == nullptr) {
EWOL_ERROR("C->java : Can't find the method " << _name);
/* remove access on the virtual machine : */
m_JavaVirtualMachinePointer = nullptr;
return false;
}
return true;
}
public:
AndroidContext(ewol::context::Application* _application, JNIEnv* _env, jclass _classBase, jobject _objCallback, enum application _typeAPPL) :
ewol::Context(_application),
m_javaApplicationType(_typeAPPL),
m_JavaVirtualMachinePointer(nullptr),
m_javaClassEwol(0),
m_javaClassEwolCallback(0),
m_javaObjectEwolCallback(0),
m_javaMethodEwolCallbackStop(0),
m_javaMethodEwolCallbackEventNotifier(0),
m_javaMethodEwolCallbackKeyboardUpdate(0),
m_javaMethodEwolCallbackOrientationUpdate(0),
m_javaMethodEwolActivitySetTitle(0),
m_javaMethodEwolActivityOpenURI(0),
m_javaMethodEwolActivitySetClipBoardString(0),
m_javaMethodEwolActivityGetClipBoardString(0),
m_javaDefaultClassString(0),
m_currentHeight(0),
m_clipBoardOwnerStd(false) {
EWOL_DEBUG("*******************************************");
if (m_javaApplicationType == appl_application) {
EWOL_DEBUG("** set JVM Pointer (application) **");
} else {
EWOL_DEBUG("** set JVM Pointer (LiveWallpaper) **");
}
EWOL_DEBUG("*******************************************");
m_JavaVirtualMachinePointer = _env;
// get default needed all time elements :
if (nullptr != m_JavaVirtualMachinePointer) {
EWOL_DEBUG("C->java : try load org/ewol/Ewol class");
m_javaClassEwol = m_JavaVirtualMachinePointer->FindClass("org/ewol/Ewol" );
if (m_javaClassEwol == 0) {
EWOL_ERROR("C->java : Can't find org/ewol/Ewol class");
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = nullptr;
return;
}
/* The object field extends Activity and implement EwolCallback */
m_javaClassEwolCallback = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback);
if(m_javaClassEwolCallback == nullptr) {
EWOL_ERROR("C->java : Can't find org/ewol/EwolCallback class");
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = nullptr;
return;
}
bool functionCallbackIsMissing = false;
bool ret= false;
ret = safeInitMethodID(m_javaMethodEwolActivitySetTitle,
m_javaClassEwolCallback,
"titleSet",
"(Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : titleSet");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolActivityOpenURI,
m_javaClassEwolCallback,
"openURI",
"(Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : openURI");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolCallbackStop,
m_javaClassEwolCallback,
"stop",
"()V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : stop");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolCallbackEventNotifier,
m_javaClassEwolCallback,
"eventNotifier",
"([Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : eventNotifier");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolCallbackKeyboardUpdate,
m_javaClassEwolCallback,
"keyboardUpdate",
"(Z)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : keyboardUpdate");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolCallbackOrientationUpdate,
m_javaClassEwolCallback,
"orientationUpdate",
"(I)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : orientationUpdate");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolActivitySetClipBoardString,
m_javaClassEwolCallback,
"setClipBoardString",
"(Ljava/lang/String;)V");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : setClipBoardString");
functionCallbackIsMissing = true;
}
ret = safeInitMethodID(m_javaMethodEwolActivityGetClipBoardString,
m_javaClassEwolCallback,
"getClipBoardString",
"()Ljava/lang/String;");
if (ret == false) {
jvm_basics::checkExceptionJavaVM(_env);
EWOL_ERROR("system can not start without function : getClipBoardString");
functionCallbackIsMissing = true;
}
m_javaObjectEwolCallback = _env->NewGlobalRef(_objCallback);
//javaObjectEwolCallbackAndActivity = objCallback;
if (m_javaObjectEwolCallback == nullptr) {
functionCallbackIsMissing = true;
}
m_javaDefaultClassString = m_JavaVirtualMachinePointer->FindClass("java/lang/String" );
if (m_javaDefaultClassString == 0) {
EWOL_ERROR("C->java : Can't find java/lang/String" );
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = nullptr;
functionCallbackIsMissing = true;
}
if (functionCallbackIsMissing == true) {
EWOL_CRITICAL(" mission one function ==> system can not work withut it...");
}
}
}
~AndroidContext() {
// TODO ...
}
void unInit(JNIEnv* _env) {
_env->DeleteGlobalRef(m_javaObjectEwolCallback);
m_javaObjectEwolCallback = nullptr;
}
int32_t run() {
// might never be called !!!
return -1;
}
void stop() {
EWOL_DEBUG("C->java : send message to the java : STOP REQUESTED");
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackStop);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
// this is to force the local system to think we have the buffer
// TODO : remove this 2 line when code will be writen
m_clipBoardOwnerStd = true;
switch (_clipboardID) {
case ewol::context::clipBoard::clipboardSelection:
// NOTE : Windows does not support the middle button the we do it internaly
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(_clipboardID);
break;
case ewol::context::clipBoard::clipboardStd:
if (false == m_clipBoardOwnerStd) {
// generate a request TO the OS
// TODO : Send the message to the OS "We disire to receive the copy buffer ...
} else {
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(_clipboardID);
}
break;
default:
EWOL_ERROR("Request an unknow ClipBoard ...");
break;
}
}
void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
switch (_clipboardID) {
case ewol::context::clipBoard::clipboardSelection:
// NOTE : nothing to do : Windows deas ot supported Middle button
break;
case ewol::context::clipBoard::clipboardStd:
// Request the clipBoard :
EWOL_DEBUG("C->java : set clipboard");
if (m_javaApplicationType == appl_application) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
jstring data = m_JavaVirtualMachinePointer->NewStringUTF(ewol::context::clipBoard::get(_clipboardID).c_str());
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityGetClipBoardString, data);
m_JavaVirtualMachinePointer->DeleteLocalRef(data);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
} else {
EWOL_ERROR("C->java : can not set clipboard");
}
break;
default:
EWOL_ERROR("Request an unknow ClipBoard ...");
break;
}
}
private:
bool java_attach_current_thread(int *_rstatus) {
EWOL_DEBUG("C->java : call java");
if (jvm_basics::getJavaVM() == nullptr) {
EWOL_ERROR("C->java : JVM not initialised");
m_JavaVirtualMachinePointer = nullptr;
return false;
}
*_rstatus = jvm_basics::getJavaVM()->GetEnv((void **) &m_JavaVirtualMachinePointer, JNI_VERSION_1_6);
if (*_rstatus == JNI_EDETACHED) {
JavaVMAttachArgs lJavaVMAttachArgs;
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
lJavaVMAttachArgs.name = "EwolNativeThread";
lJavaVMAttachArgs.group = nullptr;
int status = jvm_basics::getJavaVM()->AttachCurrentThread(&m_JavaVirtualMachinePointer, &lJavaVMAttachArgs);
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
if (status != JNI_OK) {
EWOL_ERROR("C->java : AttachCurrentThread failed : " << status);
m_JavaVirtualMachinePointer = nullptr;
return false;
}
}
return true;
}
void java_detach_current_thread(int _status) {
if(_status == JNI_EDETACHED) {
jvm_basics::getJavaVM()->DetachCurrentThread();
m_JavaVirtualMachinePointer = nullptr;
}
}
void sendJavaKeyboardUpdate(jboolean _showIt) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackKeyboardUpdate, _showIt);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void keyboardShow() {
sendJavaKeyboardUpdate(JNI_TRUE);
};
void keyboardHide() {
sendJavaKeyboardUpdate(JNI_FALSE);
};
// mode 0 : auto; 1 landscape, 2 portrait
void forceOrientation(enum ewol::orientation _orientation) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
jint param = (jint)_orientation;
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackOrientationUpdate, param);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void setTitle(const std::string& _title) {
EWOL_DEBUG("C->java : send message to the java : \"" << _title << "\"");
if (m_javaApplicationType == appl_application) {
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
jstring title = m_JavaVirtualMachinePointer->NewStringUTF(_title.c_str());
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivitySetTitle, title);
m_JavaVirtualMachinePointer->DeleteLocalRef(title);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
} else {
EWOL_ERROR("C->java : can not set title on appliation that is not real application");
}
}
void openURL(const std::string& _url) {
EWOL_DEBUG("C->java : send message to the java : open URL'" << _url << "'");
int status;
if(!java_attach_current_thread(&status)) {
return;
}
//Call java ...
jstring url = m_JavaVirtualMachinePointer->NewStringUTF(_url.c_str());
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityOpenURI, url);
m_JavaVirtualMachinePointer->DeleteLocalRef(url);
// manage execption :
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
void sendSystemMessage(const char* _dataString) {
EWOL_DEBUG("C->java : send message to the java : \"" << _dataString << "\"");
int status;
if(!java_attach_current_thread(&status)) {
return;
}
EWOL_DEBUG("C->java : 222");
if (nullptr == _dataString) {
EWOL_ERROR("C->java : No data to send ...");
return;
}
EWOL_DEBUG("C->java : 333");
// create the string to the java
jstring jstr = m_JavaVirtualMachinePointer->NewStringUTF(_dataString);
if (jstr == 0) {
EWOL_ERROR("C->java : Out of memory" );
return;
}
EWOL_DEBUG("C->java : 444");
// create argument list
jobjectArray args = m_JavaVirtualMachinePointer->NewObjectArray(1, m_javaDefaultClassString, jstr);
if (args == 0) {
EWOL_ERROR("C->java : Out of memory" );
return;
}
EWOL_DEBUG("C->java : 555");
//Call java ...
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackEventNotifier, args);
EWOL_DEBUG("C->java : 666");
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
}
public:
void OS_SetInputMotion(int _pointerID, const vec2& _pos) {
ewol::Context::OS_SetInputMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) );
}
void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos) {
ewol::Context::OS_SetInputState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) );
}
void OS_SetMouseMotion(int _pointerID, const vec2& _pos) {
ewol::Context::OS_SetMouseMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) );
}
void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos) {
ewol::Context::OS_SetMouseState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) );
}
void ANDROID_SetKeyboard(char32_t _myChar, bool _isDown, bool _isARepeateKey=false) {
OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey);
}
bool ANDROID_systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) {
return systemKeyboradEvent(_key, _down);
}
void ANDROID_SetKeyboardMove(int _move, bool _isDown, bool _isARepeateKey=false) {
// direct wrapping :
enum ewol::key::keyboard move = (enum ewol::key::keyboard)_move;
m_guiKeyBoardSpecialKeyMode.update(move, _isDown);
OS_SetKeyboardMove(m_guiKeyBoardSpecialKeyMode, move, _isDown, _isARepeateKey);
}
void OS_Resize(const vec2& _size) {
m_currentHeight = _size.y();
ewol::Context::OS_Resize(_size);
}
};
static std::vector<AndroidContext*> s_listInstance;
ewol::context::Application* s_applicationInit = NULL;
extern "C" {
/* Call to initialize the graphics state */
void Java_org_ewol_Ewol_EWparamSetArchiveDir(JNIEnv* _env,
jclass _cls,
jint _id,
jint _mode,
jstring _myString) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
//EWOL_CRITICAL(" call with ID : " << _id);
// direct setting of the date in the string system ...
jboolean isCopy;
const char* str = _env->GetStringUTFChars(_myString, &isCopy);
s_listInstance[_id]->setArchiveDir(_mode, str);
if (isCopy == JNI_TRUE) {
// from here str is reset ...
_env->ReleaseStringUTFChars(_myString, str);
str = nullptr;
}
}
// declare main application instance like an application:
int main(int argc, char**argv);
jint Java_org_ewol_Ewol_EWsetJavaVirtualMachineStart(JNIEnv* _env,
jclass _classBase,
jobject _objCallback,
int _typeApplication) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Creating EWOL context **");
EWOL_DEBUG("*******************************************");
AndroidContext* tmpContext = nullptr;
s_applicationInit = NULL;
ewol::context::Application* localApplication = NULL;
// call the basic init of all application (that call us ...)
main(0,NULL);
localApplication = s_applicationInit;
s_applicationInit = NULL;
if (org_ewol_EwolConstants_EWOL_APPL_TYPE_ACTIVITY == _typeApplication) {
tmpContext = new AndroidContext(localApplication, _env, _classBase, _objCallback, AndroidContext::appl_application);
} else if (org_ewol_EwolConstants_EWOL_APPL_TYPE_WALLPAPER == _typeApplication) {
tmpContext = new AndroidContext(localApplication, _env, _classBase, _objCallback, AndroidContext::appl_wallpaper);
} else {
EWOL_CRITICAL(" try to create an instance with no apply type: " << _typeApplication);
return -1;
}
if (nullptr == tmpContext) {
EWOL_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.size()-1));
return -1;
}
// for future case : all time this ...
s_listInstance.push_back(tmpContext);
int32_t newID = s_listInstance.size()-1;
return newID;
}
void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** remove JVM Pointer **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
return;
}
if (nullptr == s_listInstance[_id]) {
EWOL_ERROR("the requested instance _id=" << (int32_t)_id << " is already removed ...");
return;
}
s_listInstance[_id]->unInit(_env);
delete(s_listInstance[_id]);
s_listInstance[_id]=nullptr;
}
void Java_org_ewol_Ewol_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG(" == > Touch Event");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
jvm_basics::checkExceptionJavaVM(_env);
}
void Java_org_ewol_Ewol_EWonCreate(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Create **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
//s_listInstance[_id]->init();
}
void Java_org_ewol_Ewol_EWonStart(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Start **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
//SendSystemMessage(" testmessages ... ");
}
void Java_org_ewol_Ewol_EWonReStart(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Re-Start **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
}
void Java_org_ewol_Ewol_EWonResume(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on resume **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Resume();
}
void Java_org_ewol_Ewol_EWonPause(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on pause **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
// All the openGl has been destroyed ...
s_listInstance[_id]->getResourcesManager().contextHasBeenDestroyed();
s_listInstance[_id]->OS_Suspend();
}
void Java_org_ewol_Ewol_EWonStop(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Stop **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Stop();
}
void Java_org_ewol_Ewol_EWonDestroy(JNIEnv* _env, jobject _thiz, jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Destroy **");
EWOL_DEBUG("*******************************************");
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
//s_listInstance[_id]->UnInit();
}
/* **********************************************************************************************
* ** IO section :
* ********************************************************************************************** */
void Java_org_ewol_Ewol_EWinputEventMotion(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jfloat _x,
jfloat _y) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetInputMotion(_pointerID+1, vec2(_x,_y));
}
void Java_org_ewol_Ewol_EWinputEventState(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jboolean _isUp,
jfloat _x,
jfloat _y) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetInputState(_pointerID+1, _isUp, vec2(_x,_y));
}
void Java_org_ewol_Ewol_EWmouseEventMotion(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jfloat _x,
jfloat _y) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetMouseMotion(_pointerID+1, vec2(_x,_y));
}
void Java_org_ewol_Ewol_EWmouseEventState(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID,
jboolean _isUp,
jfloat _x,
jfloat _y) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_SetMouseState(_pointerID+1, _isUp, vec2(_x,_y));
}
void Java_org_ewol_Ewol_EWunknowEvent(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _pointerID) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
EWOL_DEBUG("Unknown IO event : " << _pointerID << " ???");
}
void Java_org_ewol_Ewol_EWkeyboardEventMove(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _type,
jboolean _isdown) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
EWOL_DEBUG("IO keyboard Move event : \"" << _type << "\" is down=" << _isdown);
s_listInstance[_id]->ANDROID_SetKeyboardMove(_type, _isdown);
}
void Java_org_ewol_Ewol_EWkeyboardEventKey(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _uniChar,
jboolean _isdown) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
EWOL_DEBUG("IO keyboard Key event : \"" << _uniChar << "\" is down=" << _isdown);
s_listInstance[_id]->ANDROID_SetKeyboard(_uniChar, _isdown);
}
void Java_org_ewol_Ewol_EWdisplayPropertyMetrics(JNIEnv* _env,
jobject _thiz,
jint _id,
jfloat _ratioX,
jfloat _ratioY) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
// set the internal system ratio properties ...
ewol::Dimension::setPixelRatio(vec2(_ratioX,_ratioY), ewol::Dimension::Inch);
}
// TODO : set a return true or false if we want to grep this event ...
bool Java_org_ewol_Ewol_EWkeyboardEventKeySystem(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _keyVal,
jboolean _isdown) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return false;
}
switch (_keyVal) {
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_UP:
EWOL_VERBOSE("IO keyboard Key system \"VOLUME_UP\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemVolumeUp, _isdown);
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_DOWN:
EWOL_DEBUG("IO keyboard Key system \"VOLUME_DOWN\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemVolumeDown, _isdown);
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_MENU:
EWOL_DEBUG("IO keyboard Key system \"MENU\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemMenu, _isdown);
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_CAMERA:
EWOL_DEBUG("IO keyboard Key system \"CAMERA\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemCamera, _isdown);
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_HOME:
EWOL_DEBUG("IO keyboard Key system \"HOME\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemHome, _isdown);
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_POWER:
EWOL_DEBUG("IO keyboard Key system \"POWER\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemPower, _isdown);
case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_BACK:
EWOL_DEBUG("IO keyboard Key system \"BACK\" is down=" << _isdown);
return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemBack, _isdown);
default:
EWOL_ERROR("IO keyboard Key system event : \"" << _keyVal << "\" is down=" << _isdown);
break;
}
return false;
}
/* **********************************************************************************************
* ** Renderer section :
* ********************************************************************************************** */
void Java_org_ewol_Ewol_EWrenderInit(JNIEnv* _env,
jobject _thiz,
jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
}
void Java_org_ewol_Ewol_EWrenderResize(JNIEnv* _env,
jobject _thiz,
jint _id,
jint _w,
jint _h) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Resize(vec2(_w, _h));
}
// TODO : Return true or false to not redraw when the under draw has not be done (processing gain of time)
void Java_org_ewol_Ewol_EWrenderDraw(JNIEnv* _env,
jobject _thiz,
jint _id) {
std::unique_lock<std::mutex> lock(g_interfaceMutex);
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
}
s_listInstance[_id]->OS_Draw(true);
}
};
int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) {
s_applicationInit = _application;
return 0;
}

View File

@ -19,11 +19,12 @@
#include <date/date.h>
#include <ewol/ewol.h>
#include <ewol/Dimension.h>
#include <ewol/debug.h>
#include <gale/renderer/openGL/openGL.h>
#include <gale/Dimension.h>
#include <ewol/translate.h>
#include <ewol/openGL/openGL.h>
#include <ewol/object/Object.h>
#include <ewol/object/Manager.h>
#include <ewol/widget/Widget.h>
@ -31,7 +32,6 @@
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <ewol/resource/Manager.h>
@ -58,13 +58,6 @@ ewol::Context& ewol::getContext() {
}
void ewol::Context::setInitImage(const std::string& _fileName) {
//m_initDisplayImageName = _fileName;
}
/**
* @brief set the curent interface.
* @note this lock the main mutex
@ -84,57 +77,11 @@ void ewol::Context::unLockContext() {
}
namespace ewol {
class eSystemMessage {
public:
enum theadMessage {
msgNone,
msgInit,
msgRecalculateSize,
msgResize,
msgHide,
msgShow,
msgInputMotion,
msgInputState,
msgKeyboardKey,
msgKeyboardMove,
msgClipboardArrive
};
public :
// specify the message type
enum theadMessage TypeMessage;
// can not set a union ...
enum ewol::context::clipBoard::clipboardListe clipboardID;
// InputId
enum ewol::key::type inputType;
int32_t inputId;
// generic dimentions
vec2 dimention;
// keyboard events :
bool repeateKey; //!< special flag for the repeating key on the PC interface
bool stateIsDown;
char32_t keyboardChar;
enum ewol::key::keyboard keyboardMove;
ewol::key::Special keyboardSpecial;
eSystemMessage() :
TypeMessage(msgNone),
clipboardID(ewol::context::clipBoard::clipboardStd),
inputType(ewol::key::typeUnknow),
inputId(-1),
dimention(0,0),
repeateKey(false),
stateIsDown(false),
keyboardChar(0),
keyboardMove(ewol::key::keyboardUnknow)
{
}
};
};
void ewol::Context::setInitImage(const std::string& _fileName) {
//m_initDisplayImageName = _fileName;
}
void ewol::Context::inputEventTransfertWidget(std::shared_ptr<ewol::Widget> _source,
@ -151,216 +98,38 @@ void ewol::Context::inputEventUnGrabPointer() {
m_input.unGrabPointer();
}
void ewol::Context::processEvents() {
int32_t nbEvent = 0;
//EWOL_DEBUG(" ******** Event");
ewol::eSystemMessage* data = nullptr;
while (m_msgSystem.count()>0) {
nbEvent++;
if (data != nullptr) {
delete(data);
data = nullptr;
}
m_msgSystem.wait(data);
//EWOL_DEBUG("EVENT");
switch (data->TypeMessage) {
case eSystemMessage::msgInit:
// this is due to the openGL context
/*bool returnVal = */
m_application->init(*this, m_initStepId);
m_initStepId++;
break;
case eSystemMessage::msgRecalculateSize:
forceRedrawAll();
break;
case eSystemMessage::msgResize:
//EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
m_windowsSize = data->dimention;
ewol::Dimension::setPixelWindowsSize(m_windowsSize);
forceRedrawAll();
break;
case eSystemMessage::msgInputMotion:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
m_input.motion(data->inputType, data->inputId, data->dimention);
break;
case eSystemMessage::msgInputState:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
m_input.state(data->inputType, data->inputId, data->stateIsDown, data->dimention);
break;
case eSystemMessage::msgKeyboardKey:
case eSystemMessage::msgKeyboardMove:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
// store the keyboard special key status for mouse event...
m_input.setLastKeyboardSpecial(data->keyboardSpecial);
if (nullptr != m_windowsCurrent) {
if (false == m_windowsCurrent->onEventShortCut(data->keyboardSpecial,
data->keyboardChar,
data->keyboardMove,
data->stateIsDown) ) {
// get the current focused Widget :
std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (nullptr != tmpWidget) {
// check if the widget allow repeating key events.
//EWOL_DEBUG("repeating test :" << data->repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data->stateIsDown);
if( false == data->repeateKey
|| ( true == data->repeateKey
&& true == tmpWidget->getKeyboardRepeate()) ) {
// check Widget shortcut
if (false == tmpWidget->onEventShortCut(data->keyboardSpecial,
data->keyboardChar,
data->keyboardMove,
data->stateIsDown) ) {
// generate the direct event ...
if (data->TypeMessage == eSystemMessage::msgKeyboardKey) {
ewol::event::EntrySystem tmpEntryEvent(ewol::key::keyboardChar,
ewol::key::statusUp,
data->keyboardSpecial,
data->keyboardChar);
if(true == data->stateIsDown) {
tmpEntryEvent.m_event.setStatus(ewol::key::statusDown);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data->keyboardMove << " " << data->stateIsDown);
ewol::event::EntrySystem tmpEntryEvent(data->keyboardMove,
ewol::key::statusUp,
data->keyboardSpecial,
0);
if(true == data->stateIsDown) {
tmpEntryEvent.m_event.setStatus(ewol::key::statusDown);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
}
} else {
EWOL_DEBUG("remove Repeate key ...");
}
}
}
}
}
break;
case eSystemMessage::msgClipboardArrive:
{
std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != nullptr) {
tmpWidget->onEventClipboard(data->clipboardID);
}
}
break;
case eSystemMessage::msgHide:
EWOL_DEBUG("Receive MSG : msgHide");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
//gui_uniqueWindows->SysOnHide();
break;
case eSystemMessage::msgShow:
EWOL_DEBUG("Receive MSG : msgShow");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
//gui_uniqueWindows->SysOnShow();
break;
default:
EWOL_DEBUG("Receive MSG : UNKNOW");
break;
}
}
}
void ewol::Context::setArchiveDir(int _mode, const char* _str) {
switch(_mode) {
case 0:
EWOL_DEBUG("Directory APK : path=" << _str);
etk::setBaseFolderData(_str);
break;
case 1:
EWOL_DEBUG("Directory mode=FILE path=" << _str);
etk::setBaseFolderDataUser(_str);
break;
case 2:
EWOL_DEBUG("Directory mode=CACHE path=" << _str);
etk::setBaseFolderCache(_str);
break;
case 3:
EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << _str);
break;
default:
EWOL_DEBUG("Directory mode=???? path=" << _str);
break;
}
}
ewol::Context::Context(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) :
//m_application(std::make_shared<ewol::context::Application>(_application)),
m_application(_application),
m_objectManager(*this),
m_previousDisplayTime(0),
m_input(*this),
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs))
m_displayFps(true),
#else
m_displayFps(false),
#endif
m_FpsSystemEvent( "Event ", false),
m_FpsSystemContext("Context ", false),
m_FpsSystem( "Draw ", true),
m_FpsFlush( "Flush ", false),
m_windowsCurrent(nullptr),
m_windowsSize(320,480),
m_initStepId(0) {
// set a basic
etk::thread::setName("ewol");
if (m_application == nullptr) {
EWOL_CRITICAL("Can not start context with no Application ==> rtfm ...");
}
m_commandLine.parse(_argc, _argv);
void ewol::Context::onCreate(gale::Context& _context) {
lockContext();
EWOL_INFO(" == > Ewol system init (BEGIN)");
// Add basic ewol translation:
ewol::translate::addPath("ewol", "DATA:translate/ewol/");
ewol::translate::autoDetectLanguage();
// Reset the random system to be sure have real random values...
etk::tool::resetRandom();
// set the curent interface :
lockContext();
// By default we set 2 themes (1 color and 1 shape ...) :
etk::theme::setNameDefault("GUI", "shape/square/");
etk::theme::setNameDefault("COLOR", "color/black/");
// parse the debug level:
for(int32_t iii = 0; iii < m_commandLine.size() ; ++iii) {
if (m_commandLine.get(iii) == "--ewol-fps") {
m_displayFps=true;
} else if ( m_commandLine.get(iii) == "-h"
|| m_commandLine.get(iii) == "--help") {
// parse for help:
for(int32_t iii = 0; iii < _context.getCmd().size() ; ++iii) {
if ( _context.getCmd().get(iii) == "-h"
|| _context.getCmd().get(iii) == "--help") {
EWOL_PRINT("ewol - help : ");
EWOL_PRINT(" " << etk::getApplicationName() << " [options]");
EWOL_PRINT(" --ewol-fps: Display the current fps of the display");
EWOL_PRINT(" -h/--help: Display this help");
EWOL_PRINT(" example:");
EWOL_PRINT(" " << etk::getApplicationName() << " --ewol-fps");
EWOL_PRINT(" " << etk::getApplicationName() << " --help");
// this is a global help system does not remove it
continue;
} else {
continue;
}
m_commandLine.remove(iii);
_context.getCmd().remove(iii);
--iii;
}
//etk::cout.setOutputFile(true);
EWOL_INFO("EWOL v:" << ewol::getVersion());
EWOL_INFO("Build Date: " << date::getYear() << "/" << date::getMonth() << "/" << date::getDay() << " " << date::getHour() << "h" << date::getMinute());
// TODO : remove this ...
etk::initDefaultFolder("ewolApplNoName");
// request the init of the application in the main context of openGL ...
{
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
} else {
data->TypeMessage = eSystemMessage::msgInit;
m_msgSystem.post(data);
}
}
// force a recalculation
/*
requestUpdateSize();
#if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__)
forceOrientation(ewol::screenLandscape);
@ -369,16 +138,74 @@ ewol::Context::Context(ewol::context::Application* _application, int32_t _argc,
#else
forceOrientation(ewol::screenAuto);
#endif
// release the curent interface :
unLockContext();
*/
EWOL_INFO(" == > Ewol system init (END)");
unLockContext();
}
ewol::Context::~Context() {
EWOL_INFO(" == > Ewol system Un-Init (BEGIN)");
// TODO : Clean the message list ...
// set the curent interface :
void ewol::Context::onStart(gale::Context& _context) {
lockContext();
if (m_application == nullptr) {
// TODO : Request exit of the application .... with error ...
unLockContext();
return;
}
for (int32_t iii=0; iii<m_application->getNbStepInit(); ++iii) {
m_application->init(*this, iii);
}
unLockContext();
}
void ewol::Context::onResume(gale::Context& _context) {
lockContext();
unLockContext();
}
void ewol::Context::onRegenerateDisplay(gale::Context& _context) {
lockContext();
EWOL_INFO("REGENERATE_DISPLAY");
// check if the user selected a windows
if (m_windowsCurrent == nullptr) {
EWOL_INFO("No windows ...");
unLockContext();
return;
}
// Redraw all needed elements
m_windowsCurrent->onRegenerateDisplay();
if (m_widgetManager.isDrawingNeeded() == true) {
markDrawingIsNeeded();
}
//markDrawingIsNeeded();
unLockContext();
}
void ewol::Context::onDraw(gale::Context& _context) {
lockContext();
EWOL_INFO("DRAW");
// clean internal data...
m_objectManager.cleanInternalRemoved();
// real draw...
if (m_windowsCurrent == nullptr) {
return;
}
m_windowsCurrent->sysDraw();
unLockContext();
}
void ewol::Context::onPause(gale::Context& _context) {
lockContext();
unLockContext();
}
void ewol::Context::onStop(gale::Context& _context) {
lockContext();
m_application->unInit(*this);
unLockContext();
}
void ewol::Context::onDestroy(gale::Context& _context) {
lockContext();
EWOL_INFO(" == > Ewol system Un-Init (BEGIN)");
// Remove current windows
m_windowsCurrent.reset();
// clean all widget and sub widget with their resources:
@ -386,193 +213,150 @@ ewol::Context::~Context() {
// call application to uninit
m_application->unInit(*this);
m_application.reset();
// clean all messages
m_msgSystem.clean();
// internal clean elements
m_objectManager.cleanInternalRemoved();
m_resourceManager.cleanInternalRemoved();
EWOL_INFO("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
m_objectManager.displayListObject();
// Resource is an lower element as objects ...
m_resourceManager.unInit();
// now All must be removed !!!
m_objectManager.unInit();
// release the curent interface :
unLockContext();
EWOL_INFO(" == > Ewol system Un-Init (END)");
unLockContext();
}
void ewol::Context::requestUpdateSize() {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
void ewol::Context::onPointer(enum gale::key::type _type,
int32_t _pointerID,
const vec2& _pos,
gale::key::status _state) {
lockContext();
switch (_state) {
case gale::key::status_move:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
m_input.motion(_type, _pointerID, _pos);
break;
case gale::key::status_down:
case gale::key::status_downRepeate:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
m_input.state(_type, _pointerID, true, _pos);
break;
case gale::key::status_up:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
m_input.state(_type, _pointerID, false, _pos);
break;
default:
EWOL_DEBUG("Unknow state : " << _state);
break;
}
unLockContext();
}
void ewol::Context::onKeyboard(gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state) {
lockContext();
// store the keyboard special key status for mouse event...
m_input.setLastKeyboardSpecial(_special);
if (m_windowsCurrent == nullptr) {
// No windows ...
unLockContext();
return;
}
data->TypeMessage = eSystemMessage::msgRecalculateSize;
m_msgSystem.post(data);
}
void ewol::Context::OS_Resize(const vec2& _size) {
// TODO : Better in the thread ... == > but generate some init error ...
ewol::Dimension::setPixelWindowsSize(_size);
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
bool repeate = (_state == gale::key::status_downRepeate);
bool isDown = (_state == gale::key::status_downRepeate)
|| (_state == gale::key::status_down);
if (m_windowsCurrent->onEventShortCut(_special,
_value,
_type,
isDown) == true) {
// Keep a shortcut ...
unLockContext();
return;
}
data->TypeMessage = eSystemMessage::msgResize;
data->dimention = _size;
m_msgSystem.post(data);
}
void ewol::Context::OS_Move(const vec2& _pos) {
/*
ewol::eSystemMessage *data = new ewol::eSystemMessage();
data->TypeMessage = eSystemMessage::msgResize;
data->resize.w = w;
data->resize.h = h;
m_msgSystem.Post(data);
*/
}
void ewol::Context::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
// get the current focused Widget :
std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (tmpWidget == nullptr) {
// no Widget ...
unLockContext();
return;
}
data->TypeMessage = eSystemMessage::msgInputMotion;
data->inputType = ewol::key::typeFinger;
data->inputId = _pointerID;
data->dimention = _pos;
m_msgSystem.post(data);
}
void ewol::Context::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
// check if the widget allow repeating key events.
//EWOL_DEBUG("repeating test :" << data->repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data->stateIsDown);
if( repeate == false
|| ( repeate == true
&& tmpWidget->getKeyboardRepeate() == true) ) {
// check Widget shortcut
if (tmpWidget->onEventShortCut(_special,
_value,
_type,
isDown) == false) {
// generate the direct event ...
if (_type == gale::key::keyboard_char) {
ewol::event::EntrySystem tmpEntryEvent(gale::key::keyboard_char,
gale::key::status_up,
_special,
_value);
if(isDown == true) {
tmpEntryEvent.m_event.setStatus(gale::key::status_down);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << _type << " " << _state);
ewol::event::EntrySystem tmpEntryEvent(_type,
gale::key::status_up,
_special,
0);
if(isDown == true) {
tmpEntryEvent.m_event.setStatus(gale::key::status_down);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
}
} else {
EWOL_DEBUG("remove Repeate key ...");
}
}
data->TypeMessage = eSystemMessage::msgInputState;
data->inputType = ewol::key::typeFinger;
data->inputId = _pointerID;
data->stateIsDown = _isDown;
data->dimention = _pos;
m_msgSystem.post(data);
unLockContext();
}
void ewol::Context::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
/*
void ewol::Context::processEvents() {
case eSystemMessage::msgResize:
//EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
m_windowsSize = data->dimention;
ewol::Dimension::setPixelWindowsSize(m_windowsSize);
forceRedrawAll();
break;
*/
void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) {
lockContext();
std::shared_ptr<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != nullptr) {
tmpWidget->onEventClipboard(_clipboardId);
}
data->TypeMessage = eSystemMessage::msgInputMotion;
data->inputType = ewol::key::typeMouse;
data->inputId = _pointerID;
data->dimention = _pos;
m_msgSystem.post(data);
unLockContext();
}
void ewol::Context::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
ewol::Context::Context(ewol::context::Application* _application) :
//m_application(std::make_shared<ewol::context::Application>(_application)),
m_application(_application),
m_objectManager(*this),
m_input(*this),
m_windowsCurrent(nullptr),
m_initStepId(0) {
if (m_application == nullptr) {
EWOL_CRITICAL("Can not start context with no Application ==> rtfm ...");
}
data->TypeMessage = eSystemMessage::msgInputState;
data->inputType = ewol::key::typeMouse;
data->inputId = _pointerID;
data->stateIsDown = _isDown;
data->dimention = _pos;
m_msgSystem.post(data);
}
void ewol::Context::OS_SetKeyboard(ewol::key::Special& _special,
char32_t _myChar,
bool _isDown,
bool _isARepeateKey) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgKeyboardKey;
data->stateIsDown = _isDown;
data->keyboardChar = _myChar;
data->keyboardSpecial = _special;
data->repeateKey = _isARepeateKey;
m_msgSystem.post(data);
}
void ewol::Context::OS_SetKeyboardMove(ewol::key::Special& _special,
enum ewol::key::keyboard _move,
bool _isDown,
bool _isARepeateKey) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgKeyboardMove;
data->stateIsDown = _isDown;
data->keyboardMove = _move;
data->keyboardSpecial = _special;
data->repeateKey = _isARepeateKey;
m_msgSystem.post(data);
}
void ewol::Context::OS_Hide() {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgHide;
m_msgSystem.post(data);
}
void ewol::Context::OS_Show() {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgShow;
m_msgSystem.post(data);
}
void ewol::Context::OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgClipboardArrive;
data->clipboardID = _clipboardID;
m_msgSystem.post(data);
}
void ewol::Context::clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(_clipboardID);
}
void ewol::Context::clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
// nothing to do, data is already copyed in the EWOL clipborad center
ewol::Context::~Context() {
// nothing to do ...
}
#if 0
bool ewol::Context::OS_Draw(bool _displayEveryTime) {
int64_t currentTime = ewol::getTime();
// this is to prevent the multiple display at the a high frequency ...
#if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__Windows))
if(currentTime - m_previousDisplayTime < 1000000/120) {
usleep(1000);
return false;
}
#endif
m_previousDisplayTime = currentTime;
// process the events
@ -596,11 +380,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
}
// call all the widget that neded to do something periodicly
m_objectManager.timeCall(currentTime);
// check if the user selected a windows
if (nullptr != m_windowsCurrent) {
// Redraw all needed elements
m_windowsCurrent->onRegenerateDisplay();
}
if (m_displayFps == true) {
m_FpsSystemEvent.incrementCounter();
m_FpsSystemEvent.toc();
@ -655,12 +435,6 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
// release open GL Context
gale::openGL::unLock();
}
if (m_displayFps == true) {
m_FpsSystemEvent.draw();
m_FpsSystemContext.draw();
m_FpsSystem.draw();
m_FpsFlush.draw();
}
{
// set the curent interface :
lockContext();
@ -677,14 +451,12 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
}
return hasDisplayDone;
}
#endif
void ewol::Context::resetIOEvent() {
m_input.newLayerSet();
}
void ewol::Context::OS_OpenGlContextDestroy() {
m_resourceManager.contextHasBeenDestroyed();
}
void ewol::Context::setWindows(const std::shared_ptr<ewol::widget::Windows>& _windows) {
// remove current focus :
@ -706,9 +478,9 @@ void ewol::Context::forceRedrawAll() {
if (m_windowsCurrent == nullptr) {
return;
}
m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y()));
// TODO: m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y()));
}
/*
void ewol::Context::OS_Stop() {
// set the curent interface :
lockContext();
@ -765,48 +537,9 @@ void ewol::Context::OS_Background() {
// release the curent interface :
unLockContext();
}
*/
void ewol::Context::stop() {
}
void ewol::Context::setSize(const vec2& _size) {
EWOL_INFO("setSize: NOT implemented ...");
};
void ewol::Context::setPos(const vec2& _pos) {
EWOL_INFO("setPos: NOT implemented ...");
}
void ewol::Context::hide() {
EWOL_INFO("hide: NOT implemented ...");
};
void ewol::Context::show() {
EWOL_INFO("show: NOT implemented ...");
}
void ewol::Context::setTitle(const std::string& _title) {
EWOL_INFO("setTitle: NOT implemented ...");
}
void ewol::Context::keyboardShow() {
EWOL_INFO("keyboardShow: NOT implemented ...");
}
void ewol::Context::keyboardHide() {
EWOL_INFO("keyboardHide: NOT implemented ...");
}
bool ewol::Context::systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) {
if (m_windowsCurrent == nullptr) {
return false;
}
lockContext();
bool ret = m_windowsCurrent->onEventHardwareInput(_key, _down);
unLockContext();
return ret;
}

View File

@ -9,48 +9,34 @@
#ifndef __EWOL_CONTEXT_H__
#define __EWOL_CONTEXT_H__
#include <etk/os/Fifo.h>
#include <gale/key/key.h>
#include <gale/Application.h>
#include <gale/context/Context.h>
#include <gale/context/clipBoard.h>
#include <gale/context/commandLine.h>
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/key/key.h>
#include <ewol/object/Manager.h>
#include <ewol/resource/Manager.h>
#include <ewol/widget/Manager.h>
#include <ewol/widget/Windows.h>
#include <ewol/context/Application.h>
#include <ewol/context/clipBoard.h>
#include <ewol/context/ConfigFont.h>
#include <ewol/context/commandLine.h>
#include <ewol/context/InputManager.h>
#include <ewol/context/Fps.h>
#include <memory>
namespace ewol {
/**
* @not-in-doc
*/
class eSystemMessage;
/**
* @not-in-doc
*/
enum orientation{
screenAuto = 0,
screenLandscape,
screenPortrait
};
class Context/* : private ewol::object::RemoveEvent */{
// Here we hereted from the gale application to be agnostic of the OW where we work ...
class Context : public gale::Application {
private:
std::shared_ptr<ewol::context::Application> m_application; //!< Application handle
public:
std::shared_ptr<ewol::context::Application> getApplication() {
return m_application;
}
private:
ewol::context::CommandLine m_commandLine; //!< Start command line information
public:
ewol::context::CommandLine& getCmd() {
return m_commandLine;
gale::context::CommandLine& getCmd() {
return gale::getContext().getCmd();
};
private:
ewol::context::ConfigFont m_configFont; //!< global font configuration
@ -70,15 +56,15 @@ namespace ewol {
ewol::widget::Manager& getWidgetManager() {
return m_widgetManager;
};
private:
ewol::resource::Manager m_resourceManager; //!< global resources Manager
public:
ewol::resource::Manager& getResourcesManager() {
return m_resourceManager;
gale::resource::Manager& getResourcesManager() {
return gale::getContext().getResourcesManager();
};
public:
Context(ewol::context::Application* _application, int32_t _argc=0, const char* _argv[]=nullptr);
Context(ewol::context::Application* _application);
virtual ~Context();
private:
ewol::context::InputManager m_input;
protected:
/**
* @brief set the curent interface.
@ -90,72 +76,31 @@ namespace ewol {
* @note this un-lock the main mutex
*/
void unLockContext();
private:
int64_t m_previousDisplayTime; // this is to limit framerate ... in case...
ewol::context::InputManager m_input;
etk::Fifo<ewol::eSystemMessage*> m_msgSystem;
bool m_displayFps;
ewol::context::Fps m_FpsSystemEvent;
ewol::context::Fps m_FpsSystemContext;
ewol::context::Fps m_FpsSystem;
ewol::context::Fps m_FpsFlush;
/**
* @brief Processing all the event arrived ... (commoly called in draw function)
*/
void processEvents();
public:
virtual void setArchiveDir(int _mode, const char* _str);
public: // herited function:
virtual void onCreate(gale::Context& _context);
virtual void onStart(gale::Context& _context);
virtual void onResume(gale::Context& _context);
virtual void onRegenerateDisplay(gale::Context& _context);
virtual void onDraw(gale::Context& _context);
virtual void onPause(gale::Context& _context);
virtual void onStop(gale::Context& _context);
virtual void onDestroy(gale::Context& _context);
virtual void onPointer(enum gale::key::type _type,
int32_t _pointerID,
const vec2& _pos,
gale::key::status _state);
virtual void onKeyboard(gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state);
virtual void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId);
virtual void OS_SetInputMotion(int _pointerID, const vec2& _pos);
virtual void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos);
virtual void OS_SetMouseMotion(int _pointerID, const vec2& _pos);
virtual void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos);
virtual void OS_SetKeyboard(ewol::key::Special& _special,
char32_t _myChar,
bool _isDown,
bool _isARepeateKey=false);
virtual void OS_SetKeyboardMove(ewol::key::Special& _special,
enum ewol::key::keyboard _move,
bool _isDown,
bool _isARepeateKey=false);
/**
* @brief The current context is suspended
*/
virtual void OS_Suspend();
/**
* @brief The current context is resumed
*/
virtual void OS_Resume();
/**
* @brief The current context is set in foreground (framerate is maximum speed)
*/
virtual void OS_Foreground();
/**
* @brief The current context is set in background (framerate is slowing down (max fps)/5 # 4fps)
*/
virtual void OS_Background();
void requestUpdateSize();
// return true if a flush is needed
bool OS_Draw(bool _displayEveryTime);
public:
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
void resetIOEvent();
/**
* @brief The OS inform that the openGL constext has been destroy == > use to automaticly reload the texture and other thinks ...
*/
void OS_OpenGlContextDestroy();
/**
* @brief The OS Inform that the Window has been killed
*/
void OS_Stop();
/**
* @brief The application request that the Window will be killed
*/
@ -173,52 +118,7 @@ namespace ewol {
* @return the current handle on the windows (can be null)
*/
std::shared_ptr<ewol::widget::Windows> getWindows();
private:
vec2 m_windowsSize; //!< current size of the system
public:
/**
* @brief get the current windows size
* @return the current size ...
*/
const vec2& getSize() {
return m_windowsSize;
};
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
virtual void OS_Resize(const vec2& _size);
/**
* @brief The application request a change of his curent size.
* @param[in] _size new Requested size of the windows.
*/
virtual void setSize(const vec2& _size);
/**
* @brief The OS inform that the current windows has change his position.
* @param[in] _pos New position of the Windows.
*/
void OS_Move(const vec2& _pos);
/**
* @brief The Application request that the current windows will change his position.
* @param[in] _pos New position of the Windows requested.
*/
virtual void setPos(const vec2& _pos);
/**
* @brief The OS inform that the Windows is now Hidden.
*/
void OS_Hide();
/**
* @brief The Application request that the Windows will be Hidden.
*/
virtual void hide();
/**
* @brief The OS inform that the Windows is now visible.
*/
void OS_Show();
/**
* @brief The Application request that the Windows will be visible.
*/
virtual void show();
/**
* @brief Redraw all the windows
*/
@ -240,16 +140,7 @@ namespace ewol {
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/
void inputEventUnGrabPointer();
/**
* @brief display the virtal keyboard (for touch system only)
*/
virtual void keyboardShow();
/**
* @brief Hide the virtal keyboard (for touch system only)
*/
virtual void keyboardHide();
#if 0
/**
* @brief Inform the Gui that we want to have a copy of the clipboard
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
@ -265,16 +156,9 @@ namespace ewol {
* @param[in] Id of the clipboard
*/
void OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief set the new title of the windows
* @param[in] title New desired title
*/
virtual void setTitle(const std::string& _title);
/**
* @brief Open an URL on an eternal brother.
* @param[in] _url URL to open.
*/
virtual void openURL(const std::string& _url) { };
#endif
#if 0
/**
* @brief force the screen orientation (availlable on portable elements ...
* @param[in] _orientation Selected orientation.
@ -286,25 +170,14 @@ namespace ewol {
* @param[in] _forcedPosition the position where the mouse might be reset at every events ...
*/
virtual void grabPointerEvents(bool _isGrabbed, const vec2& _forcedPosition) { };
/**
* @brief set the cursor display type.
* @param[in] _newCursor selected new cursor.
*/
virtual void setCursor(enum ewol::context::cursorDisplay _newCursor) { };
/**
* @brief set the Icon of the program
* @param[in] _inputFile new filename icon of the curent program.
*/
virtual void setIcon(const std::string& _inputFile) { };
/**
* @brief get the curent time in micro-second
* @note : must be implemented in all system OS implementation
* @return The curent time of the process
*/
static int64_t getTime();
private:
// TODO : set user argument here ....
#endif
public:
/**
* @brief This is the only one things the User might done in his main();
@ -329,13 +202,15 @@ namespace ewol {
*/
void setInitImage(const std::string& _fileName);
protected:
# if 0
/**
* @brief HARDWARE keyboard event from the system
* @param[in] _key event type
* @param[in] _status Up or down status
* @return Keep the event or not
*/
virtual bool systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down);
virtual bool systemKeyboradEvent(enum gale:key::keyboardSystem _key, bool _down);
#endif
};
/**
* @brief From everyware in the program, we can get the context inteface.

View File

@ -1,141 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_FPS_H__
#define __EWOL_FPS_H__
namespace ewol {
namespace context {
/**
* @brief This class is designed to count the number of frame per second in the main renderer system
* @not-in-doc
*/
class Fps {
// display every second ...
#define DISPLAY_PERIODE_US (1000000)
private:
int64_t startTime;
int64_t nbCallTime;
int64_t nbDisplayTime;
int64_t min;
int64_t avg;
int64_t max;
int64_t min_idle;
int64_t avg_idle;
int64_t max_idle;
int64_t ticTime;
bool display;
bool drwingDone;
const char * m_displayName;
bool m_displayFPS;
public:
/**
* @brief Constructor
*/
Fps(const char * displayName, bool displayFPS) {
startTime = -1;
nbCallTime = 0;
nbDisplayTime = 0;
min = 99999999999999LL;
avg = 0;
max = 0;
min_idle = 99999999999999LL;
avg_idle = 0;
max_idle = 0;
ticTime = 0;
display = false;
drwingDone = false;
m_displayName = displayName;
m_displayFPS = displayFPS;
}
/**
* @brief Destructor
*/
~Fps() {
}
/**
* @brief this might be call every time a diplay start
*/
void tic() {
int64_t currentTime = ewol::getTime();
ticTime = currentTime;
nbCallTime++;
if (startTime<0) {
startTime = currentTime;
}
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
if ( (currentTime - startTime) > DISPLAY_PERIODE_US) {
display = true;
}
}
/**
* @brief this might be call every time a diplay stop, it do the display every second
* @param[in] displayTime display curent time of the frame.
*/
void toc(bool displayTime = false) {
int64_t currentTime = ewol::getTime();
int64_t processTimeLocal = (currentTime - ticTime);
if (displayTime == true) {
EWOL_PRINT(m_displayName << " : processTime : " << (float)((float)processTimeLocal / 1000.0) << "ms ");
}
if (drwingDone) {
min = std::min(min, processTimeLocal);
max = std::max(max, processTimeLocal);
avg += processTimeLocal;
drwingDone = false;
} else {
min_idle = std::min(min_idle, processTimeLocal);
max_idle = std::max(max_idle, processTimeLocal);
avg_idle += processTimeLocal;
}
}
/**
* @brief this might be call when a display is really done
*/
void incrementCounter() {
nbDisplayTime++;
drwingDone = true;
}
/**
* @brief draw debug display ...
*/
void draw() {
if (true == display) {
if (nbDisplayTime>0) {
EWOL_PRINT(m_displayName << " : Active : "
<< (float)((float)min / 1000.0) << "ms "
<< (float)((float)avg / (float)nbDisplayTime / 1000.0) << "ms "
<< (float)((float)max / 1000.0) << "ms ");
}
if (nbCallTime-nbDisplayTime>0) {
EWOL_PRINT(m_displayName << " : idle : "
<< (float)((float)min_idle / 1000.0) << "ms "
<< (float)((float)avg_idle / (float)(nbCallTime-nbDisplayTime) / 1000.0) << "ms "
<< (float)((float)max_idle / 1000.0) << "ms ");
}
if (true == m_displayFPS) {
EWOL_PRINT("FPS : " << nbDisplayTime << "/" << nbCallTime << "fps");
}
max = 0;
min = 99999999999999LL;
avg = 0;
max_idle = 0;
min_idle = 99999999999999LL;
avg_idle = 0;
nbCallTime = 0;
nbDisplayTime = 0;
startTime = -1;
display = false;
}
}
};
};
};
#endif

View File

@ -1,20 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <UIKit/UIKit.h>
@class OpenglView;
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *window;
OpenglView *glView;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet OpenglView *glView;
@end

View File

@ -1,97 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <UIKit/UIKit.h>
#include "ewol/context/IOs/Interface.h"
#import <ewol/context/IOs/OpenglView.h>
#import <ewol/context/IOs/AppDelegate.h>
#include <ewol/context/IOs/Context.h>
#include <ewol/debug.h>
@implementation AppDelegate
@synthesize window;
@synthesize glView;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height);
CGSize currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
//screenBounds.size.width *= screenScale;
//screenBounds.size.height *= screenScale;
NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height);
window = [[UIWindow alloc] initWithFrame:screenBounds];
window.contentMode = UIViewContentModeRedraw;
glView = [[OpenglView alloc] initWithFrame:window.bounds];
glView.contentMode = UIViewContentModeRedraw;
[window addSubview:glView];
[window makeKeyAndVisible];
// Create interface of ewol here ....
NSLog(@"CREATE EWOL interface creation\n");
IOs::createInterface();
IOs::resize(currentSize.width, currentSize.height);
IOs::start();
}
/*
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
*/
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
EWOL_INFO("move windows in applicationWillResignActive");
[glView speedSlow];
IOs::background();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
EWOL_INFO("move windows in applicationDidEnterBackground");
[glView stopDisplayLink];
IOs::suspend();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
EWOL_INFO("move windows in applicationWillEnterForeground");
IOs::resume();
[glView startDisplayLink];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
EWOL_INFO("move windows in applicationDidBecomeActive");
[glView speedNormal];
IOs::foreground();
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Create interface of ewol here ....
EWOL_INFO("move windows in applicationWillTerminate");
IOs::stop();
IOs::releaseInterface();
}
/*
- (void)dealloc {
[window release];
[glView release];
[super dealloc];
}
*/
@end

View File

@ -1,273 +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/ewol.h>
#include <ewol/key/key.h>
#include <ewol/context/commandLine.h>
#include <etk/types.h>
#include <etk/os/FSNode.h>
#include <ewol/widget/Manager.h>
#include <ewol/resource/Manager.h>
#include <ewol/context/Context.h>
#include <ewol/context/IOs/Interface.h>
#include <ewol/context/IOs/Context.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/times.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <etk/etk.h>
int64_t ewol::getTime() {
struct timespec now;
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
now.tv_sec = mts.tv_sec;
now.tv_nsec = mts.tv_nsec;
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
}
#undef __class__
#define __class__ "MacOSInterface"
class MacOSInterface : public ewol::Context {
private:
ewol::key::Special m_guiKeyBoardMode;
public:
MacOSInterface(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) :
ewol::Context(_application, _argc, _argv) {
// nothing to do ...
}
int32_t Run() {
return 0;
}
virtual void stop() {
mm_exit();
}
public:
//interface MacOS :
bool MAC_Draw(bool _displayEveryTime) {
return OS_Draw(_displayEveryTime);
}
void MAC_Resize(float _x, float _y) {
OS_Resize(vec2(_x,_y));
}
void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) {
OS_SetMouseState(_id, _isDown, vec2(_x, _y));
}
void MAC_SetMouseMotion(int32_t _id, float _x, float _y) {
OS_SetMouseMotion(_id, vec2(_x, _y));
}
void MAC_SetInputState(int32_t _id, bool _isDown, float _x, float _y) {
OS_SetInputState(_id, _isDown, vec2(_x, _y));
}
void MAC_SetInputMotion(int32_t _id, float _x, float _y) {
OS_SetInputMotion(_id, vec2(_x, _y));
}
void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (_unichar == u32char::Delete) {
_unichar = u32char::Suppress;
} else if (_unichar == u32char::Suppress) {
_unichar = u32char::Delete;
}
if (_unichar == u32char::CarrierReturn) {
_unichar = u32char::Return;
}
//EWOL_DEBUG("key: " << _unichar << " up=" << !_isDown);
if (_unichar <= 4) {
enum ewol::key::keyboard move;
switch(_unichar) {
case 0:
move = ewol::key::keyboardUp;
break;
case 1:
move = ewol::key::keyboardDown;
break;
case 2:
move = ewol::key::keyboardLeft;
break;
case 3:
move = ewol::key::keyboardRight;
break;
}
OS_SetKeyboardMove(_keyboardMode, move, !_isDown, _isAReapeateKey);
} else {
OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey);
}
}
void MAC_SetKeyboardMove(ewol::key::Special& _special,
enum ewol::key::keyboard _move,
bool _isDown) {
OS_SetKeyboardMove(_special, _move, _isDown);
}
void openURL(const std::string& _url) {
mm_openURL(_url.c_str());
}
};
MacOSInterface* interface = nullptr;
bool IOs::draw(bool _displayEveryTime) {
if (interface == nullptr) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void IOs::resize(float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_Resize(_x, _y);
}
void IOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void IOs::setMouseMotion(int32_t _id, float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
void IOs::setInputState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_SetInputState(_id, _isDown, _x, _y);
}
void IOs::setInputMotion(int32_t _id, float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_SetInputMotion(_id, _x, _y);
}
void IOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
}
void IOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown);
}
void IOs::start() {
if (interface == nullptr) {
return;
}
//interface->OS_Start();
}
void IOs::resume() {
if (interface == nullptr) {
return;
}
interface->OS_Resume();
}
void IOs::suspend() {
if (interface == nullptr) {
return;
}
interface->OS_Suspend();
}
void IOs::stop() {
if (interface == nullptr) {
return;
}
interface->OS_Stop();
}
void IOs::background() {
if (interface == nullptr) {
return;
}
interface->OS_Background();
}
void IOs::foreground() {
if (interface == nullptr) {
return;
}
interface->OS_Foreground();
}
static int l_argc = 0;
static const char **l_argv = nullptr;
static ewol::context::Application* l_application;
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) {
l_argc = _argc;
l_argv = _argv;
l_application = _application;
return mm_main(_argc, _argv);
}
// Creat and relaese ewol::Context interface:
void IOs::createInterface() {
etk::init(l_argc, l_argv);
EWOL_INFO("Create new interface");
interface = new MacOSInterface(l_application, l_argc, l_argv);
l_application = nullptr;
if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return;
}
}
void IOs::releaseInterface() {
if (interface != nullptr) {
EWOL_INFO("Remove interface");
}
delete(interface);
interface = nullptr;
}

View File

@ -1,40 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __MAC_OS_CONTEXT_H__
#define __MAC_OS_CONTEXT_H__
#include <ewol/key/key.h>
namespace IOs {
// Create and relaese ewol::Context interface:
void createInterface();
void releaseInterface();
// return true if a flush is needed
bool draw(bool _displayEveryTime);
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
void resize(float _x, float _y);
void setMouseState(int32_t _id, bool _isDown, float _x, float _y);
void setMouseMotion(int32_t _id, float _x, float _y);
void setInputState(int32_t _id, bool _isDown, float _x, float _y);
void setInputMotion(int32_t _id, float _x, float _y);
void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown);
void start();
void stop();
void foreground();
void background();
void resume();
void suspend();
};
#endif

View File

@ -1,24 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_MM_INTERFACE_H__
#define __EWOL_MM_INTERFACE_H__
#ifdef __cplusplus
extern "C" {
#endif
int mm_main(int _argc, const char *_argv[]);
void mm_exit();
void mm_openURL(const char *_url);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,31 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <UIKit/UIKit.h>
#import <ewol/context/IOs/AppDelegate.h>
//#import "AppDelegate.h"
int mm_main(int argc, const char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, (char**)argv, nil, NSStringFromClass([AppDelegate class]));
}
// return no error
return 0;
}
void mm_exit(void) {
[[NSThread mainThread] cancel];
}
void mm_openURL(const char *_url) {
NSString* url = [[NSString alloc] initWithUTF8String:_url];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

View File

@ -1,41 +0,0 @@
//
// EAGLView.h
// OpenGLBasics
//
// Created by Charlie Key on 6/24/09.
//
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
/*
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
The view content is basically an EAGL surface you render your OpenGL scene into.
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
@interface OpenglView : UIView {
@private
CAEAGLLayer* _eaglLayer;
EAGLContext *_context;
GLuint _colorRenderBuffer;
GLuint _depthRenderBuffer;
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
GLuint viewRenderbuffer, viewFramebuffer;
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
GLuint depthRenderbuffer;
CGSize m_currentSize;
CADisplayLink* displayLink; //!< link to start and stop display of the view...
int deltaDisplay;
int displayCounter;
}
- (void)stopDisplayLink;
- (void)startDisplayLink;
- (void)speedSlow;
- (void)speedNormal;
@end

View File

@ -1,281 +0,0 @@
//
// EAGLView.m
// OpenGLBasics
//
// Created by Charlie Key on 6/24/09.
//
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#include <ewol/context/IOs/Context.h>
#include <ewol/Dimension.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#import "OpenglView.h"
#include <ewol/debug.h>
@interface OpenglView ()
@end
@implementation OpenglView
// You must implement this method (it does not work without it)
+ (Class)layerClass {
return [CAEAGLLayer class];
}
- (NSString *) platform {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char*)malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
}
- (NSString *) platformString {
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return @"Verizon iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G";
if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G";
if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch 5G";
if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)";
if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini (GSM)";
if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (GSM)";
if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (GSM)";
if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)";
if ([platform isEqualToString:@"iPad4,4"]) return @"iPad mini 2G (WiFi)";
if ([platform isEqualToString:@"iPad4,5"]) return @"iPad mini 2G (Cellular)";
if ([platform isEqualToString:@"i386"]) return @"Simulator";
if ([platform isEqualToString:@"x86_64"]) return @"Simulator";
return platform;
}
- (float)getScreenPPP {
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return 326.0f; //@"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return 326.0f; //@"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return 326.0f; //@"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return 326.0f; //@"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return 326.0f; //@"Verizon iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"]) return 326.0f; //@"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"]) return 326.0f; //@"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return 326.0f; //@"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return 326.0f; //@"iPhone 5c (GSM)";
if ([platform isEqualToString:@"iPhone5,4"]) return 326.0f; //@"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,1"]) return 326.0f; //@"iPhone 5s (GSM)";
if ([platform isEqualToString:@"iPhone6,2"]) return 326.0f; //@"iPhone 5s (GSM+CDMA)";
if ([platform isEqualToString:@"iPod1,1"]) return 326.0f; //@"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return 326.0f; //@"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return 326.0f; //@"iPod Touch 3G";
if ([platform isEqualToString:@"iPod4,1"]) return 326.0f; //@"iPod Touch 4G";
if ([platform isEqualToString:@"iPod5,1"]) return 326.0f; //@"iPod Touch 5G";
if ([platform isEqualToString:@"iPad1,1"]) return 264.0f; //@"iPad";
if ([platform isEqualToString:@"iPad2,1"]) return 264.0f; //@"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return 264.0f; //@"iPad 2 (GSM)";
if ([platform isEqualToString:@"iPad2,3"]) return 264.0f; //@"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return 264.0f; //@"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,5"]) return 163.0f; //@"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"]) return 163.0f; //@"iPad Mini (GSM)";
if ([platform isEqualToString:@"iPad2,7"]) return 163.0f; //@"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"]) return 264.0f; //@"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"]) return 264.0f; //@"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"]) return 264.0f; //@"iPad 3 (GSM)";
if ([platform isEqualToString:@"iPad3,4"]) return 264.0f; //@"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return 264.0f; //@"iPad 4 (GSM)";
if ([platform isEqualToString:@"iPad3,6"]) return 264.0f; //@"iPad 4 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad4,1"]) return 264.0f; //@"iPad Air (WiFi)";
if ([platform isEqualToString:@"iPad4,2"]) return 264.0f; //@"iPad Air (Cellular)";
if ([platform isEqualToString:@"iPad4,4"]) return 326.0f; //@"iPad mini 2G (WiFi)";
if ([platform isEqualToString:@"iPad4,5"]) return 326.0f; //@"iPad mini 2G (Cellular)";
if ([platform isEqualToString:@"i386"]) return 200.0f; //@"Simulator";
if ([platform isEqualToString:@"x86_64"]) return 326.0f; //@"Simulator";
return 326.0f;
}
- (void)setNeedsDisplay {
EWOL_INFO("**** setNeedsDisplay:" << vec2(self.frame.size.width, self.frame.size.height));
// TODO : SIZE change ...
}
- (void)configureAspectRatio {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
m_currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
//self.frame.size = m_currentSize;
EWOL_INFO("**** screen size:" << vec2(m_currentSize.width, m_currentSize.height));
float ratio = [self getScreenPPP];
EWOL_INFO("**** pixel ratio: " << ratio);
ewol::Dimension::setPixelRatio(vec2(1.0f/ratio, 1.0f/ratio), ewol::Dimension::Inch);
IOs::resize(m_currentSize.width, m_currentSize.height);
CGRect localBounds = [self bounds];
EWOL_INFO("**** localBounds:" << vec2(localBounds.size.width, localBounds.size.height));
}
- (void)setupLayer {
_eaglLayer = (CAEAGLLayer*) self.layer;
CGFloat screenScale = [[UIScreen mainScreen] scale];
_eaglLayer.contentsScale = screenScale;
_eaglLayer.opaque = YES;
}
- (void)setupContext {
EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES2;
_context = [[EAGLContext alloc] initWithAPI:api];
if (!_context) {
NSLog(@"Failed to initialize OpenGLES 2.0 context");
exit(1);
}
if (![EAGLContext setCurrentContext:_context]) {
NSLog(@"Failed to set current OpenGL context");
exit(1);
}
}
- (void)setupRenderBuffer {
glGenRenderbuffers(1, &_colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer);
[_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:_eaglLayer];
}
- (void)setupDepthBuffer {
glGenRenderbuffers(1, &_depthRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBuffer);
CGFloat screenScale = [[UIScreen mainScreen] scale];
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, self.frame.size.width*screenScale, self.frame.size.height*screenScale);
}
- (void)setupFrameBuffer {
GLuint framebuffer;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderBuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBuffer);
}
- (void)render:(CADisplayLink*)displayLink {
displayCounter++;
if (displayCounter >= deltaDisplay) {
displayCounter = 0;
IOs::draw(true);
[_context presentRenderbuffer:GL_RENDERBUFFER];
}
}
- (void)speedSlow {
deltaDisplay = 5;
}
- (void)speedNormal {
deltaDisplay = 1;
}
- (void)startDisplayLink {
if (displayLink != NULL) {
return;
}
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
- (void)stopDisplayLink {
if (displayLink == NULL) {
return;
}
[displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
displayLink = NULL;
}
- (id)initWithFrame:(CGRect)frame {
deltaDisplay = 1;
displayCounter = 0;
NSLog(@"INIT with size : %fx%f, %fx%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
self = [super initWithFrame:frame];
self.contentScaleFactor = 1.0f;
// TODO : Enable multi touch ==> but this generate many sub errors ... 3 touch can be appear in 1 event ...
//self.multipleTouchEnabled = YES;
if (self) {
[self configureAspectRatio];
[self setupLayer];
[self setupContext];
[self setupDepthBuffer];
[self setupRenderBuffer];
[self setupFrameBuffer];
[self startDisplayLink];
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
EWOL_DEBUG(touches.count << " touchesBegan: " << positionEvent);
IOs::setInputState(1, true, positionEvent.x(), positionEvent.y());
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
EWOL_DEBUG(touches.count << " touchesEnded: " << positionEvent);
IOs::setInputState(1, false, positionEvent.x(), positionEvent.y());
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
CGRect localBounds = [self bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale);
EWOL_DEBUG(touches.count << " touchesMoved: " << positionEvent);
IOs::setInputMotion(1, positionEvent.x(), positionEvent.y());
}
- (void)layoutSubviews {
[EAGLContext setCurrentContext:_context];
}
- (void)dealloc {
if ([EAGLContext currentContext] == _context) {
[EAGLContext setCurrentContext:nil];
}
}
@end

View File

@ -41,13 +41,13 @@ void ewol::context::InputManager::setDpi(int32_t newDPI) {
calculateLimit();
}
bool ewol::context::InputManager::localEventInput(enum ewol::key::type _type,
bool ewol::context::InputManager::localEventInput(enum gale::key::type _type,
std::shared_ptr<ewol::Widget> _destWidget,
int32_t _IdInput,
enum ewol::key::status _status,
enum gale::key::status _status,
vec2 _pos) {
if (nullptr != _destWidget) {
if (_type == ewol::key::typeMouse || _type == ewol::key::typeFinger) {
if (_type == gale::key::type_mouse || _type == gale::key::type_finger) {
// create the system Event :
ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, m_specialKey); // TODO : set the real ID ...
// generate the event :
@ -61,7 +61,7 @@ bool ewol::context::InputManager::localEventInput(enum ewol::key::type _type,
void ewol::context::InputManager::abortElement(InputPoperty *_eventTable,
int32_t _idInput,
enum ewol::key::type _type) {
enum gale::key::type _type) {
if (nullptr == _eventTable) {
return;
}
@ -69,7 +69,7 @@ void ewol::context::InputManager::abortElement(InputPoperty *_eventTable,
localEventInput(_type,
_eventTable[_idInput].curentWidgetEvent.lock(),
_eventTable[_idInput].destinationInputId,
ewol::key::statusAbort,
gale::key::status_abort,
_eventTable[_idInput].posEvent);
}
}
@ -104,23 +104,23 @@ void ewol::context::InputManager::transfertEvent(std::shared_ptr<ewol::Widget> _
if (tmpWidget == _source) {
// inform the widget that it does not receive the event now
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventInputSaved[iii].posEvent);
localEventInput(ewol::key::typeFinger, tmpWidget, m_eventInputSaved[iii].destinationInputId, ewol::key::statusAbort, m_eventInputSaved[iii].posEvent);
localEventInput(gale::key::type_finger, tmpWidget, m_eventInputSaved[iii].destinationInputId, gale::key::status_abort, m_eventInputSaved[iii].posEvent);
// set the new widget ...
m_eventInputSaved[iii].curentWidgetEvent = _destination;
// inform the widget that he receive the event property now...
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventInputSaved[iii].posEvent);
localEventInput(ewol::key::typeFinger, _destination, m_eventInputSaved[iii].destinationInputId, ewol::key::statusTransfert, m_eventInputSaved[iii].posEvent);
localEventInput(gale::key::type_finger, _destination, m_eventInputSaved[iii].destinationInputId, gale::key::status_transfert, m_eventInputSaved[iii].posEvent);
}
tmpWidget = m_eventMouseSaved[iii].curentWidgetEvent.lock();
if (tmpWidget == _source) {
// inform the widget that it does not receive the event now
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventMouseSaved[iii].posEvent);
localEventInput(ewol::key::typeMouse, tmpWidget, m_eventMouseSaved[iii].destinationInputId, ewol::key::statusAbort, m_eventMouseSaved[iii].posEvent);
localEventInput(gale::key::type_mouse, tmpWidget, m_eventMouseSaved[iii].destinationInputId, gale::key::status_abort, m_eventMouseSaved[iii].posEvent);
// set the new widget ...
m_eventMouseSaved[iii].curentWidgetEvent = _destination;
// inform the widget that he receive the event property now...
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventMouseSaved[iii].posEvent);
localEventInput(ewol::key::typeMouse, _destination, m_eventMouseSaved[iii].destinationInputId, ewol::key::statusTransfert, m_eventMouseSaved[iii].posEvent);
localEventInput(gale::key::type_mouse, _destination, m_eventMouseSaved[iii].destinationInputId, gale::key::status_transfert, m_eventMouseSaved[iii].posEvent);
}
}
}
@ -130,22 +130,24 @@ void ewol::context::InputManager::grabPointer(std::shared_ptr<ewol::Widget> _wid
return;
}
m_grabWidget = _widget;
/* TODO :
m_context.grabPointerEvents(true, _widget->getOrigin()
+ ivec2(_widget->getSize().x()/2.0f,
_widget->getSize().y()/2.0f) );
*/
}
void ewol::context::InputManager::unGrabPointer() {
m_grabWidget.reset();
m_context.grabPointerEvents(false, vec2(0,0));
// TODO: m_context.grabPointerEvents(false, vec2(0,0));
}
void ewol::context::InputManager::newLayerSet() {
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ...
abortElement(m_eventInputSaved, iii, ewol::key::typeFinger);
abortElement(m_eventInputSaved, iii, gale::key::type_finger);
cleanElement(m_eventInputSaved, iii);
abortElement(m_eventMouseSaved, iii, ewol::key::typeMouse);
abortElement(m_eventMouseSaved, iii, gale::key::type_mouse);
cleanElement(m_eventMouseSaved, iii);
}
}
@ -168,10 +170,10 @@ ewol::context::InputManager::~InputManager() {
EWOL_INFO("Un-Init (end)");
}
int32_t ewol::context::InputManager::localGetDestinationId(enum ewol::key::type _type,
int32_t ewol::context::InputManager::localGetDestinationId(enum gale::key::type _type,
std::shared_ptr<ewol::Widget> _destWidget,
int32_t _realInputId) {
if (_type == ewol::key::typeFinger) {
if (_type == gale::key::type_finger) {
int32_t lastMinimum = 0;
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (true == m_eventInputSaved[iii].isUsed) {
@ -189,7 +191,7 @@ int32_t ewol::context::InputManager::localGetDestinationId(enum ewol::key::type
}
// note if id<0 == > the it was finger event ...
void ewol::context::InputManager::motion(enum ewol::key::type _type,
void ewol::context::InputManager::motion(enum gale::key::type _type,
int _pointerID,
vec2 _pos) {
EVENT_DEBUG("motion event : " << _type << " " << _pointerID << " " << _pos);
@ -198,9 +200,9 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
return;
}
InputPoperty *eventTable = nullptr;
if (_type == ewol::key::typeMouse) {
if (_type == gale::key::type_mouse) {
eventTable = m_eventMouseSaved;
} else if (_type == ewol::key::typeFinger) {
} else if (_type == gale::key::type_finger) {
eventTable = m_eventInputSaved;
} else {
EWOL_ERROR("Unknown type of event");
@ -213,7 +215,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
}
std::shared_ptr<ewol::widget::Windows> tmpWindows = m_context.getWindows();
// special case for the mouse event 0 that represent the hover event of the system :
if (_type == ewol::key::typeMouse && _pointerID == 0) {
if (_type == gale::key::type_mouse && _pointerID == 0) {
// this event is all time on the good widget ... and manage the enter and leave ...
// NOTE : the "layer widget" force us to get the widget at the specific position all the time :
std::shared_ptr<ewol::Widget> tmpWidget;
@ -237,7 +239,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId,
ewol::key::statusLeave,
gale::key::status_leave,
_pos);
}
if (eventTable[_pointerID].isInside == false) {
@ -259,7 +261,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
localEventInput(_type,
tmpWidget,
eventTable[_pointerID].destinationInputId,
ewol::key::statusEnter,
gale::key::status_enter,
_pos);
}
EVENT_DEBUG("GUI : Input ID=" << _pointerID
@ -269,7 +271,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
localEventInput(_type,
tmpWidget,
eventTable[_pointerID].destinationInputId,
ewol::key::statusMove,
gale::key::status_move,
_pos);
} else if (true == eventTable[_pointerID].isUsed) {
if (true == eventTable[_pointerID].isInside) {
@ -285,7 +287,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId,
ewol::key::statusLeave,
gale::key::status_leave,
_pos);
}
} else {
@ -301,7 +303,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId,
ewol::key::statusEnter,
gale::key::status_enter,
_pos);
}
}
@ -312,12 +314,12 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId,
ewol::key::statusMove,
gale::key::status_move,
_pos);
}
}
void ewol::context::InputManager::state(enum ewol::key::type _type,
void ewol::context::InputManager::state(enum gale::key::type _type,
int _pointerID,
bool _isDown,
vec2 _pos)
@ -330,10 +332,10 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
// convert position in open-GL coordonates ...
InputPoperty *eventTable = nullptr;
InputLimit localLimit;
if (_type == ewol::key::typeMouse) {
if (_type == gale::key::type_mouse) {
eventTable = m_eventMouseSaved;
localLimit = m_eventMouseLimit;
} else if (_type == ewol::key::typeFinger) {
} else if (_type == gale::key::type_finger) {
eventTable = m_eventInputSaved;
localLimit = m_eventInputLimit;
} else {
@ -373,7 +375,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId,
ewol::key::statusDown,
gale::key::status_down,
_pos);
} else {
// Mark it used :
@ -388,7 +390,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
// get destination widget :
if(nullptr != tmpWindows) {
if ( tmpWidget != nullptr
&& _type == ewol::key::typeMouse) {
&& _type == gale::key::type_mouse) {
eventTable[_pointerID].curentWidgetEvent = tmpWidget;
} else {
eventTable[_pointerID].curentWidgetEvent = tmpWindows->getWidgetAtPos(_pos);
@ -412,7 +414,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
localEventInput(_type,
tmpWidget,
eventTable[_pointerID].destinationInputId,
ewol::key::statusDown,
gale::key::status_down,
_pos);
}
} else {
@ -437,7 +439,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
localEventInput(_type,
tmpWidget,
_pointerID,
ewol::key::statusUp,
gale::key::status_up,
_pos);
// generate event (single)
if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset
@ -455,7 +457,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
}
// in grab mode the single to quinte event are not generated ....
if( ( m_grabWidget.lock() == nullptr
|| _type != ewol::key::typeMouse )
|| _type != gale::key::type_mouse )
&& eventTable[_pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE :
eventTable[_pointerID].nbClickEvent++;
@ -466,7 +468,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
localEventInput(_type,
tmpWidget,
eventTable[_pointerID].destinationInputId,
(enum ewol::key::status)(ewol::key::statusSingle + eventTable[_pointerID].nbClickEvent-1),
(enum gale::key::status)(gale::key::status_single + eventTable[_pointerID].nbClickEvent-1),
_pos);
if( eventTable[_pointerID].nbClickEvent >= nbClickMax) {
eventTable[_pointerID].nbClickEvent = 0;
@ -479,10 +481,10 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
localEventInput(_type,
tmpWidget,
_pointerID,
ewol::key::statusUpAfter,
gale::key::status_upAfter,
_pos);
// specific for tuch event
if (_type == ewol::key::typeFinger) {
if (_type == gale::key::type_finger) {
cleanElement(eventTable, _pointerID);
}
}

View File

@ -55,7 +55,7 @@ namespace ewol {
void calculateLimit();
InputPoperty m_eventInputSaved[MAX_MANAGE_INPUT];
InputPoperty m_eventMouseSaved[MAX_MANAGE_INPUT];
void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum ewol::key::type _type);
void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum gale::key::type _type);
void cleanElement(InputPoperty* _eventTable, int32_t _idInput);
/**
* @brief generate the event on the destinated widget.
@ -66,10 +66,10 @@ namespace ewol {
* @param[in] _pos position of the event
* @return true if event has been greped
*/
bool localEventInput(enum ewol::key::type _type,
bool localEventInput(enum gale::key::type _type,
std::shared_ptr<ewol::Widget> _destWidget,
int32_t _IdInput,
enum ewol::key::status _typeEvent,
enum gale::key::status _typeEvent,
vec2 _pos);
/**
* @brief convert the system event id in the correct EWOL id depending of the system management mode
@ -80,7 +80,7 @@ namespace ewol {
* @param[in] _realInputId system Id
* @return the ewol input id
*/
int32_t localGetDestinationId(enum ewol::key::type _type,
int32_t localGetDestinationId(enum gale::key::type _type,
std::shared_ptr<ewol::Widget> _destWidget,
int32_t _realInputId);
private:
@ -91,8 +91,8 @@ namespace ewol {
void setDpi(int32_t _newDPI);
// note if id<0 == > the it was finger event ...
void motion(enum ewol::key::type _type, int _pointerID, vec2 _pos );
void state(enum ewol::key::type _type, int _pointerID, bool _isDown, vec2 _pos);
void motion(enum gale::key::type _type, int _pointerID, vec2 _pos );
void state(enum gale::key::type _type, int _pointerID, bool _isDown, vec2 _pos);
public:
/**
* @brief a new layer on the windows is set == > might remove all the property of the current element ...
@ -114,9 +114,9 @@ namespace ewol {
*/
void unGrabPointer();
private:
ewol::key::Special m_specialKey;
gale::key::Special m_specialKey;
public:
void setLastKeyboardSpecial(const ewol::key::Special& _specialKey) {
void setLastKeyboardSpecial(const gale::key::Special& _specialKey) {
m_specialKey = _specialKey;
}
};

View File

@ -1,16 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
@interface MacOsAppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
- (void)sendEvent:(NSEvent *)event;
- (void)applicationWillResignActive:(MacOsAppDelegate *)application;
@end

View File

@ -1,76 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <ewol/context/MacOs/AppDelegate.h>
#import <ewol/context/MacOs/OpenglView.h>
#include <ewol/debug.h>
@implementation MacOsAppDelegate
@synthesize window=_window;
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] frame]];
return YES;
}
- (void)applicationWillResignActive:(MacOsAppDelegate *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
EWOL_INFO("move windows in applicationWillResignActive");
}
- (void)applicationDidEnterBackground:(MacOsAppDelegate *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
EWOL_INFO("move windows in applicationDidEnterBackground");
}
- (void)applicationWillEnterForeground:(MacOsAppDelegate *)application {
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
EWOL_INFO("move windows in applicationWillEnterForeground");
}
- (void)applicationDidBecomeActive:(MacOsAppDelegate *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
EWOL_INFO("move windows in applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(MacOsAppDelegate *)application {
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
EWOL_INFO("move windows in applicationWillTerminate");
}
- (void)dealloc {
[_window release];
[super dealloc];
}
- (void)sendEvent:(NSEvent *)event {
EWOL_WARNING(" EVENT ... ");
}
@end

View File

@ -1,30 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __MAC_OS_CONTEXT_H__
#define __MAC_OS_CONTEXT_H__
#include <ewol/key/key.h>
namespace MacOs {
// return true if a flush is needed
bool draw(bool _displayEveryTime);
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
void resize(float _x, float _y);
void setMouseState(int32_t _id, bool _isDown, float _x, float _y);
void setMouseMotion(int32_t _id, float _x, float _y);
void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey);
void stopRequested();
void setRedrawCallback(const std::function<void()>& _func);
};
#endif

View File

@ -1,246 +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/ewol.h>
#include <ewol/key/key.h>
#include <ewol/context/commandLine.h>
#include <ewol/context/clipBoard.h>
#include <etk/types.h>
#include <etk/os/FSNode.h>
#include <ewol/widget/Manager.h>
#include <ewol/resource/Manager.h>
#include <ewol/context/Context.h>
#include <ewol/context/MacOs/Interface.h>
#include <ewol/context/MacOs/Context.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/times.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <etk/etk.h>
#import <Cocoa/Cocoa.h>
int64_t ewol::getTime() {
struct timespec now;
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
now.tv_sec = mts.tv_sec;
now.tv_nsec = mts.tv_nsec;
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
}
#undef __class__
#define __class__ "MacOSInterface"
class MacOSInterface : public ewol::Context {
private:
ewol::key::Special m_guiKeyBoardMode;
public:
MacOSInterface(ewol::context::Application* _application, int _argc, const char* _argv[]) :
ewol::Context(_application, _argc, _argv) {
mm_main(_argc, _argv);
}
int32_t Run() {
return mm_run();
}
public:
//interface MacOS :
bool MAC_Draw(bool _displayEveryTime) {
return OS_Draw(_displayEveryTime);
}
void MAC_Resize(float _x, float _y) {
OS_Resize(vec2(_x,_y));
}
void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) {
OS_SetMouseState(_id, _isDown, vec2(_x, _y));
}
void MAC_SetMouseMotion(int32_t _id, float _x, float _y) {
OS_SetMouseMotion(_id, vec2(_x, _y));
}
void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (char32_t(_unichar) == u32char::Delete) {
_unichar = u32char::Suppress;
} else if (char32_t(_unichar) == u32char::Suppress) {
_unichar = u32char::Delete;
}
if (char32_t(_unichar) == u32char::CarrierReturn) {
_unichar = u32char::Return;
}
//EWOL_DEBUG("key: " << _unichar << " up=" << !_isDown);
if (_unichar <= 4) {
enum ewol::key::keyboard move;
switch(_unichar) {
case 0:
move = ewol::key::keyboardUp;
break;
case 1:
move = ewol::key::keyboardDown;
break;
case 2:
move = ewol::key::keyboardLeft;
break;
case 3:
move = ewol::key::keyboardRight;
break;
}
OS_SetKeyboardMove(_keyboardMode, move, !_isDown, _isAReapeateKey);
} else {
OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey);
}
}
void MAC_SetKeyboardMove(ewol::key::Special& _special,
enum ewol::key::keyboard _move,
bool _isDown,
bool _isAReapeateKey) {
OS_SetKeyboardMove(_special, _move, _isDown, _isAReapeateKey);
}
void openURL(const std::string& _url) {
std::string req = "open " + _url;
system(req.c_str());
}
void MAC_Stop() {
OS_Stop();
}
void stop() {
mm_stopApplication();
}
void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
if (_clipboardID == ewol::context::clipBoard::clipboardStd) {
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
NSString* myString = [myPasteboard stringForType:NSPasteboardTypeString];
std::string val([myString UTF8String]);
ewol::context::clipBoard::setSystem(_clipboardID, val);
if (val.size() != 0) {
OS_ClipBoardArrive(_clipboardID);
}
} else {
ewol::Context::clipBoardGet(_clipboardID);
}
}
void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
if (_clipboardID == ewol::context::clipBoard::clipboardStd) {
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
[myPasteboard clearContents];
//EWOL_ERROR(" copy: " << ewol::context::clipBoard::get(_clipboardID));
NSString *text = [[NSString alloc] initWithUTF8String:ewol::context::clipBoard::get(_clipboardID).c_str()];
BOOL err = [myPasteboard setString:text forType:NSPasteboardTypeString];
if (err == FALSE) {
EWOL_ERROR("copy to clipboard can not be done ...");
}
} else {
ewol::Context::clipBoardSet(_clipboardID);
}
}
};
MacOSInterface* interface = nullptr;
bool MacOs::draw(bool _displayEveryTime) {
if (interface == nullptr) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void MacOs::resize(float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_Resize(_x, _y);
}
void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void MacOs::setMouseMotion(int32_t _id, float _x, float _y) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
void MacOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
}
void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown, _isAReapeateKey);
}
void MacOs::stopRequested() {
if (interface == nullptr) {
return;
}
interface->MAC_Stop();
}
void MacOs::setRedrawCallback(const std::function<void()>& _func) {
if (interface == nullptr) {
return;
}
interface->getWidgetManager().setCallbackonRedrawNeeded(_func);
}
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int ewol::run(ewol::context::Application* _application, int _argc, const char* _argv[]) {
etk::init(_argc, _argv);
interface = new MacOSInterface(_application, _argc, _argv);
if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2;
}
int32_t retValue = interface->Run();
EWOL_INFO("Stop running");
delete(interface);
interface = nullptr;
return retValue;
}

View File

@ -1,24 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_MM_INTERFACE_H__
#define __EWOL_MM_INTERFACE_H__
#ifdef __cplusplus
extern "C" {
#endif
int mm_main(int _argc, const char* _argv[]);
int mm_run();
void mm_stopApplication();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,104 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include "Context.h"
#import <Cocoa/Cocoa.h>
#include "ewol/context/MacOs/Interface.h"
#import <ewol/context/MacOs/OpenglView.h>
#import <ewol/context/MacOs/Windows.h>
#import <ewol/context/MacOs/AppDelegate.h>
#import <ewol/debug.h>
id window = nil;
void callbackSomeThingToDo() {
//EWOL_CRITICAL("ksdjlkqjsdlfkjsqdlkfjslqkdjflqksjdf");
[window UpdateScreenRequested];
}
int mm_main(int _argc, const char* _argv[]) {
[NSAutoreleasePool new];
[NSApplication sharedApplication];
// set the quit policy and all stadard for Mac
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// ---------------------------------------------------------------
// -- basic menu bar creation :
// ---------------------------------------------------------------
// set the basic menu bar (stadard on Mac OSX)
id menubar = [[NSMenu new] autorelease];
//add an item
id appMenuItem = [[NSMenuItem new] autorelease];
// add the item to the menu bar:
[menubar addItem:appMenuItem];
// set the main menu in the menu bar ...
[NSApp setMainMenu:menubar];
id appMenu = [[NSMenu new] autorelease];
id appName = [[NSProcessInfo processInfo] processName];
// create the label to qui the application :
id quitTitle = [@"Quit " stringByAppendingString:appName];
// create the item to quit the appllication with META+q at shortCut
id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle
action:@selector(stop:) keyEquivalent:@"q"] autorelease];
// add the item to the menu:
[appMenu addItem:quitMenuItem];
// set the application menu to the main app menu ...
[appMenuItem setSubmenu:appMenu];
// ---------------------------------------------------------------
// -- basic windows creation :
// ---------------------------------------------------------------
// create a windows of size 800/600
window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
autorelease];
[window setAcceptsMouseMovedEvents:YES];
//id window = [ [MacOsAppDelegate alloc] autorelease];
// set the windows at a specific position :
[window cascadeTopLeftFromPoint:NSMakePoint(50,50)];
// set the windows resizable
[window setStyleMask:[window styleMask] | NSResizableWindowMask];
// oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask];
// set the title
[window setTitle:appName];
[window setAcceptsMouseMovedEvents:YES];
// ???
[window makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
NSRect window_frame = [window frame];
OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
NSTrackingArea *track = [[NSTrackingArea alloc] initWithRect:window_frame options: NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder | NSTrackingActiveInKeyWindow
owner:window userInfo:nil];
[view addTrackingArea:track];
[window setContentView:view];
[view setAutoresizesSubviews:YES];
return 0;
}
int mm_run(void) {
//MacOs::setRedrawCallback(std::bind(callbackSomeThingToDo));
[NSApp run];
EWOL_DEBUG("END of application");
// return no error
return 0;
}
void mm_stopApplication() {
EWOL_DEBUG("NSApp terminate start.");
[window closeRequestEwol];
[NSApp stop:nil];
EWOL_DEBUG("NSApp terminate done");
}

View File

@ -1,21 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
NSTimer* _refreshTimer;
bool _redraw;
}
- (void)prepareOpenGL;
- (void)drawRect:(NSRect) bounds;
- (void)UpdateScreenRequested;
@end

View File

@ -1,70 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <ewol/context/MacOs/OpenglView.h>
#include <OpenGL/gl.h>
#include <ewol/context/MacOS/Context.h>
#include <ewol/debug.h>
#include <ewol/Dimension.h>
@implementation OpenGLView
- (void) prepareOpenGL {
EWOL_INFO("prepare");
GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
// set system dpi size :
NSScreen *screen = [NSScreen mainScreen];
NSDictionary *description = [screen deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
ewol::Dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
ewol::Dimension::Millimeter);
_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ;
_redraw = true;
}
- (void)UpdateScreenRequested {
_redraw = true;
}
-(void) drawRect: (NSRect) bounds {
if ( ! _refreshTimer ) {
_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ;
EWOL_WARNING("create timer ... ");
}
MacOs::draw(false);
}
/**
* Service the animation timer.
*/
- (void) animationTimerFired: (NSTimer *) timer {
if (_redraw == true) {
//_redraw = false;
[self setNeedsDisplay:YES];
//EWOL_WARNING("view refresh ..." );
}
}
-(void)reshape {
EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
// window resize; width and height are in pixel coordinates
// but they are floats
float width = [self frame].size.width;
float height = [self frame].size.height;
MacOs::resize(width,height);
}
@end

View File

@ -1,39 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
#import <ewol/context/MacOs/OpenglView.h>
@interface EwolMainWindows : NSWindow {
OpenGLView* _view;
}
+ (id)alloc;
- (id)init;
+ (void)dealloc;
+ (void)performClose:(id)sender;
// All mouse events:
- (void)mouseDown:(NSEvent *) event;
- (void)mouseDragged:(NSEvent *) event;
- (void)mouseUp:(NSEvent *)event;
- (void)mouseMoved:(NSEvent *)event;
- (void)mouseEntered:(NSEvent *)event;
- (void)mouseExited:(NSEvent *)event;
- (void)rightMouseDown:(NSEvent *)event;
- (void)rightMouseDragged:(NSEvent *)event;
- (void)rightMouseUp:(NSEvent *)event;
- (void)otherMouseDown:(NSEvent *)event;
- (void)otherMouseDragged:(NSEvent *)event;
- (void)otherMouseUp:(NSEvent *)event;
// keyboard eevnts:
- (void)keyDown:(NSEvent *)theEvent;
- (void)flagsChanged:(NSEvent *)theEvent;
- (void)closeRequestEwol;
- (void)UpdateScreenRequested;
@end

View File

@ -1,443 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <ewol/context/MacOs/Windows.h>
#include <ewol/context/MacOS/Context.h>
#include <ewol/key/key.h>
#include <ewol/debug.h>
@implementation EwolMainWindows
+ (id)alloc {
id windowsID = [super alloc];
EWOL_DEBUG("ALLOCATE ...");
return windowsID;
}
- (id)init {
id windowsID = [super init];
//[NSApp setDelegate: self];
EWOL_DEBUG("INIT ...");
// set the windows at a specific position :
[windowsID cascadeTopLeftFromPoint:NSMakePoint(50,50)];
EWOL_DEBUG("ALLOCATE ...");
// set the windows resizable
[windowsID setStyleMask:[windowsID styleMask] | NSResizableWindowMask];
EWOL_DEBUG("ALLOCATE ...");
// oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask];
// set the title
id appName = [[NSProcessInfo processInfo] processName];
EWOL_DEBUG("ALLOCATE ...");
[windowsID setTitle:appName];
EWOL_DEBUG("ALLOCATE ...");
[windowsID setAcceptsMouseMovedEvents:YES];
EWOL_DEBUG("ALLOCATE ...");
// ???
[windowsID makeKeyAndOrderFront:nil];
EWOL_DEBUG("ALLOCATE ...");
[NSApp activateIgnoringOtherApps:YES];
EWOL_DEBUG("ALLOCATE ...");
NSRect window_frame = [windowsID frame];
EWOL_DEBUG("ALLOCATE ...");
_view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
EWOL_DEBUG("ALLOCATE ...");
[windowsID setContentView:_view];
EWOL_DEBUG("ALLOCATE ...");
[_view setAutoresizesSubviews:YES];
EWOL_DEBUG("ALLOCATE ...");
// Override point for customization after application launch.
//[window addSubview:view];
//[window addChildWindow:view];
//[window makeKeyAndVisible];
//[windowsID setDelegate:view];
EWOL_DEBUG("ALLOCATE ...");
return windowsID;
}
+ (void)dealloc {
EWOL_ERROR("FREE ...");
//[_window release];
[super dealloc];
}
+ (void)performClose:(id)sender {
EWOL_ERROR("perform close ...");
}
static ewol::key::Special guiKeyBoardMode;
-(void)localKeyEvent:(NSEvent*)theEvent isDown:(bool)_isDown {
bool thisIsAReapeateKey = false;
if ([theEvent isARepeat]) {
thisIsAReapeateKey = true;
}
NSString *str = [theEvent charactersIgnoringModifiers];
// TODO : set if for every char in the string !!!
unichar c = [str characterAtIndex:0];
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
bool find = true;
enum ewol::key::keyboard keyInput;
switch (c) {
case 63232: keyInput = ewol::key::keyboardUp; break;
case 63233: keyInput = ewol::key::keyboardDown; break;
case 63234: keyInput = ewol::key::keyboardLeft; break;
case 63235: keyInput = ewol::key::keyboardRight; break;
case 63276: keyInput = ewol::key::keyboardPageUp; break;
case 63277: keyInput = ewol::key::keyboardPageDown; break;
case 63273: keyInput = ewol::key::keyboardStart; break;
case 63275: keyInput = ewol::key::keyboardEnd; break;
/*
case 78: keyInput = ewol::key::keyboardStopDefil; break;
case 127: keyInput = ewol::key::keyboardWait; break;
*/
case 63302:
find = false;
keyInput = ewol::key::keyboardInsert;
if(_isDown == false) {
if (true == guiKeyBoardMode.getInsert()) {
guiKeyBoardMode.setInsert(false);
} else {
guiKeyBoardMode.setInsert(true);
}
}
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, true, thisIsAReapeateKey);
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << !_isDown);
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, false, thisIsAReapeateKey);
break;
//case 84: keyInput = ewol::key::keyboardCenter; break; // Keypad
case 63236: keyInput = ewol::key::keyboardF1; break;
case 63237: keyInput = ewol::key::keyboardF2; break;
case 63238: keyInput = ewol::key::keyboardF3; break;
case 63239: keyInput = ewol::key::keyboardF4; break;
case 63240: keyInput = ewol::key::keyboardF5; break;
case 63241: keyInput = ewol::key::keyboardF6; break;
case 63242: keyInput = ewol::key::keyboardF7; break;
case 63243: keyInput = ewol::key::keyboardF8; break;
case 63244: keyInput = ewol::key::keyboardF9; break;
case 63245: keyInput = ewol::key::keyboardF10; break;
case 63246: keyInput = ewol::key::keyboardF11; break;
case 63247: keyInput = ewol::key::keyboardF12; break;
case 63272: // Suppress
find = false;
MacOs::setKeyboard(guiKeyBoardMode, u32char::Delete, _isDown, thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, u32char::Delete, !_isDown, thisIsAReapeateKey);
}
break;
default:
find = false;
{
if (guiKeyBoardMode.getAlt() == true) {
// special keyboard transcription ...
str = [theEvent characters];
c = [str characterAtIndex:0];
}
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
MacOs::setKeyboard(guiKeyBoardMode, c, _isDown, thisIsAReapeateKey);
if (true==thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, c, !_isDown, thisIsAReapeateKey);
}
}
break;
}
if (find == true) {
EWOL_VERBOSE("eventKey Move type : " << keyInput );
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, _isDown, thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, !_isDown, thisIsAReapeateKey);
}
}
}
- (void)keyDown:(NSEvent *)theEvent {
[self localKeyEvent:theEvent isDown:true];
}
- (void)keyUp:(NSEvent *)theEvent {
[self localKeyEvent:theEvent isDown:false];
}
- (void)flagsChanged:(NSEvent *)theEvent {
if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) {
EWOL_VERBOSE("NSAlphaShiftKeyMask");
if (guiKeyBoardMode.getCapsLock() == false) {
guiKeyBoardMode.setCapsLock(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, true, false);
}
} else {
if (guiKeyBoardMode.getCapsLock() == true) {
guiKeyBoardMode.setCapsLock(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, false, false);
}
}
if (([theEvent modifierFlags] & NSShiftKeyMask) != 0) {
EWOL_VERBOSE("NSShiftKeyMask");
if (guiKeyBoardMode.getShift() == false) {
guiKeyBoardMode.setShift(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, true, false);
}
} else {
if (guiKeyBoardMode.getShift() == true) {
guiKeyBoardMode.setShift(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, false, false);
}
}
if (([theEvent modifierFlags] & NSControlKeyMask) != 0) {
//EWOL_VERBOSE("NSControlKeyMask");
if (guiKeyBoardMode.getCtrl() == false) {
EWOL_VERBOSE("NSControlKeyMask DOWN");
guiKeyBoardMode.setCtrl(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, true, false);
}
} else {
if (guiKeyBoardMode.getCtrl() == true) {
EWOL_VERBOSE("NSControlKeyMask UP");
guiKeyBoardMode.setCtrl(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, false, false);
}
}
if (([theEvent modifierFlags] & NSAlternateKeyMask) != 0) {
EWOL_VERBOSE("NSAlternateKeyMask");
if (guiKeyBoardMode.getAlt() == false) {
guiKeyBoardMode.setAlt(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, true, false);
}
} else {
if (guiKeyBoardMode.getAlt() == true) {
guiKeyBoardMode.setAlt(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, false, false);
}
}
if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) {
EWOL_VERBOSE("NSCommandKeyMask");
if (guiKeyBoardMode.getMeta() == false) {
guiKeyBoardMode.setMeta(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, true, false);
}
} else {
if (guiKeyBoardMode.getMeta() == true) {
guiKeyBoardMode.setMeta(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, false, false);
}
}
if (([theEvent modifierFlags] & NSNumericPadKeyMask) != 0) {
EWOL_VERBOSE("NSNumericPadKeyMask");
if (guiKeyBoardMode.getNumLock() == false) {
guiKeyBoardMode.setNumLock(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, true, false);
}
} else {
if (guiKeyBoardMode.getNumLock() == true) {
guiKeyBoardMode.setNumLock(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, false, false);
}
}
if (([theEvent modifierFlags] & NSHelpKeyMask) != 0) {
EWOL_VERBOSE("NSHelpKeyMask");
}
if (([theEvent modifierFlags] & NSFunctionKeyMask) != 0) {
EWOL_VERBOSE("NSFunctionKeyMask");
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, true, false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, false, false);
}
EWOL_VERBOSE("EVENT : " << int32_t([theEvent modifierFlags]));
}
// this generate all the event entry availlable ==> like a big keep focus ...
- (BOOL)acceptsFirstResponder {
return YES;
}
- (BOOL)becomeFirstResponder {
return YES;
}
-(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("mouseMoved : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(0, point.x, point.y);
}
-(void)mouseEntered:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseEntered : " << (float)point.x << " " << (float)point.y);
}
-(void)mouseExited:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y);
}
-(void)mouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("mouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(1, true, point.x, point.y);
}
-(void)mouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("mouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(1, point.x, point.y);
}
-(void)mouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("mouseUp : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(1, false, point.x, point.y);
}
-(void)rightMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("rightMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(3, true, point.x, point.y);
}
-(void)rightMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("rightMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(3, point.x, point.y);
}
-(void)rightMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("rightMouseUp : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(3, false, point.x, point.y);
}
-(void)otherMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
EWOL_VERBOSE("otherMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(btNumber, true, point.x, point.y);
}
-(void)otherMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
EWOL_VERBOSE("otherMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(btNumber, point.x, point.y);
}
-(void)otherMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
EWOL_VERBOSE("otherMouseUp: id=" << btNumber );
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
EWOL_VERBOSE("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber );
MacOs::setMouseState(btNumber, false, point.x, point.y);
}
- (void)scrollWheel:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("scrollWheel : " << (float)point.x << " " << (float)point.y << " delta(" << (float)([event deltaX]) << "," << (float)([event deltaY]) << ")");
float deltaY = [event deltaY];
int32_t idEvent = 4;
if (deltaY < 0) {
idEvent = 5;
}
if (fabs(deltaY) < 0.1f) {
return;
}
for (float iii=fabs(deltaY) ; iii>=0.0f ; iii-=1.0f) {
MacOs::setMouseState(idEvent, true , point.x, point.y);
MacOs::setMouseState(idEvent, false, point.x, point.y);
}
}
- (void)closeRequestEwol {
EWOL_VERBOSE("closeRequestEwol: BEGIN");
[super close];
EWOL_VERBOSE("closeRequestEwol: END");
}
- (void)close {
EWOL_VERBOSE("close:");
MacOs::stopRequested();
}
- (void)UpdateScreenRequested {
[_view UpdateScreenRequested];
}
@end

View File

@ -1,503 +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/ewol.h>
#include <etk/types.h>
#include <etk/os/FSNode.h>
#include <etk/math/Vector2D.h>
#include <etk/math/Vector3D.h>
#include <ewol/widget/Manager.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/Image.h>
#include <ewol/context/Context.h>
#include <ewol/openGL/openGL.h>
#include <sys/time.h>
#include <windows.h>
#include <windowsx.h>
#include <etk/etk.h>
int64_t ewol::getTime() {
struct timeval now;
gettimeofday(&now, nullptr);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
}
#undef __class__
#define __class__ "ContextWindows"
class WindowsContext : public ewol::Context {
private:
int32_t m_currentHeight = 0;
bool m_inputIsPressed[MAX_MANAGE_INPUT];
ewol::key::Special m_guiKeyBoardMode;
bool m_run = true;
bool m_clipBoardOwnerStd = false;
public:
WindowsContext(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) :
ewol::Context(_application, _argc, _argv) {
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; ++iii) {
m_inputIsPressed[iii] = false;
}
}
~WindowsContext() {
}
int32_t run() {
HINSTANCE hInstance = 0;
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
// register window class
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( nullptr, IDI_APPLICATION );
wc.hCursor = LoadCursor( nullptr, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = nullptr;
wc.lpszClassName = "EwolMainWindows";
RegisterClass( &wc );
// create main window
hWnd = CreateWindow( "EwolMainWindows", "Ewol ... TODO Title",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE | WS_SIZEBOX,
0, 0, 800, 600,
nullptr, nullptr, hInstance, nullptr);
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int title_size = GetSystemMetrics(SM_CYCAPTION);
m_currentHeight = 600-2*border_thickness -title_size;
OS_Resize(vec2(800-2*border_thickness, m_currentHeight));
// enable openGL for the window
enableOpenGL( hWnd, &hDC, &hRC );
// program main loop
while(true == m_run) {
// check for messages
if ( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE )) {
// handle or dispatch messages
if ( msg.message == WM_QUIT ) {
m_run = false;
} else {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
} else {
OS_Draw(true);
SwapBuffers( hDC );
}
}
// shutdown openGL
disableOpenGL( hWnd, hDC, hRC );
// destroy the window explicitly
DestroyWindow( hWnd );
return msg.wParam;
}
void Stop() {
m_run = false;
// To exit program ...
PostQuitMessage(0);
}
void setSize(const vec2& _size) {
float border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
float title_size = GetSystemMetrics(SM_CYCAPTION);
vec2 newSize(_size.x() + border_thickness*2.0f,
_size.y() + border_thickness*2.0f + title_size);
//m_currentHeight = size.y;
// TODO : Later
}
void ClipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
// this is to force the local system to think we have the buffer
// TODO : remove this 2 line when code will be writen
m_clipBoardOwnerStd = true;
switch (_clipboardID) {
case ewol::context::clipBoard::clipboardSelection:
// NOTE : Windows does not support the middle button the we do it internaly
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(ewol::context::clipBoard::clipboardSelection);
break;
case ewol::context::clipBoard::clipboardStd:
if (false == m_clipBoardOwnerStd) {
// generate a request TO the OS
// TODO : Send the message to the OS "We disire to receive the copy buffer ...
} else {
// just transmit an event , we have the data in the system
OS_ClipBoardArrive(ewol::context::clipBoard::clipboardStd);
}
break;
default:
EWOL_ERROR("Request an unknow ClipBoard ...");
break;
}
}
void ClipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
switch (_clipboardID) {
case ewol::context::clipBoard::clipboardSelection:
// NOTE : nothing to do : Windows deas ot supported Middle button
break;
case ewol::context::clipBoard::clipboardStd:
// Request the clipBoard :
if (false == m_clipBoardOwnerStd) {
// TODO : Inform the OS that we have the current buffer of copy ...
m_clipBoardOwnerStd = true;
}
break;
default:
EWOL_ERROR("Request an unknow ClipBoard ...");
break;
}
}
// enable openGL
void enableOpenGL(HWND _hWnd, HDC* _hDC, HGLRC* _hRC) {
// get the device context (DC)
*_hDC = GetDC( _hWnd );
PIXELFORMATDESCRIPTOR pfd;
// set the pixel format for the DC
ZeroMemory(&pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
int format = ChoosePixelFormat( *_hDC, &pfd );
SetPixelFormat( *_hDC, format, &pfd );
// create and enable the render context(RC)
*_hRC = wglCreateContext( *_hDC );
wglMakeCurrent( *_hDC, *_hRC );
}
// disable openGL
void disableOpenGL(HWND _hWnd, HDC _hDC, HGLRC _hRC) {
wglMakeCurrent( nullptr, NULL );
wglDeleteContext( _hRC );
ReleaseDC( _hWnd, _hDC );
}
// Window Procedure
static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) {
// TODO : set this function really work...
// TODO : return classPointer->WndProcReal(_hWnd, _message, _wParam, _lParam);
return 0;
}
LRESULT CALLBACK WndProcReal(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) {
bool buttonIsDown = true;
int32_t mouseButtonId = 0;
ivec2 pos;
// to know all _message : http://wiki.winehq.org/List_Of_Windows__messages
switch (_message) {
/* **************************************************************************
* Gui event
* **************************************************************************/
case WM_CREATE:
EWOL_DEBUG("WM_CREATE");
return 0;
case WM_CLOSE:
EWOL_DEBUG("WM_CLOSE");
PostQuitMessage( 0 );
return 0;
case WM_DESTROY:
EWOL_DEBUG("WM_DESTROY");
return 0;
case WM_MOVE:
EWOL_DEBUG("WM_MOVE");
return 0;
case WM_SIZE:
EWOL_DEBUG("WM_SIZE");
return 0;
/*
case WM_GETMINMAXINFO:
{
MINMAXINFO* tmpVal = (MINMAXINFO*)lParam;
EWOL_DEBUG("WM_GETMINMAXINFO : ");
EWOL_DEBUG(" ptMaxSize : " << tmpVal->ptMaxSize.x << "," << tmpVal->ptMaxSize.y << ")");
EWOL_DEBUG(" ptMaxPosition : " << tmpVal->ptMaxPosition.x << "," << tmpVal->ptMaxPosition.y << ")");
EWOL_DEBUG(" ptMinTrackSize : " << tmpVal->ptMinTrackSize.x << "," << tmpVal->ptMinTrackSize.y << ")");
EWOL_DEBUG(" ptMaxTrackSize : " << tmpVal->ptMaxTrackSize.x << "," << tmpVal->ptMaxTrackSize.y << ")");
}
return 0;
*/
case WM_WINDOWPOSCHANGING: {
WINDOWPOS* tmpVal = (WINDOWPOS*)_lParam;
if (nullptr != tmpVal) {
//EWOL_DEBUG("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")");
// in windows system, we need to remove the size of the border elements :
int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
int title_size = GetSystemMetrics(SM_CYCAPTION);
m_currentHeight = tmpVal->cy - 2*border_thickness - title_size;
OS_Resize(vec2(tmpVal->cx-2*border_thickness, m_currentHeight));
}
return 0;
}
// these message are not parse by us ...
case WM_SETCURSOR: // Call the windows if we want the mouse event :
case WM_NCHITTEST: // inform the application the position of the mouse is moving
return DefWindowProc( _hWnd, _message, _wParam, _lParam );
/* **************************************************************************
* Keyboard management
* **************************************************************************/
case WM_KEYUP:
buttonIsDown = false;
case WM_KEYDOWN: {
char32_t tmpChar = 0;
enum ewol::key::keyboard keyInput;
switch (_wParam) {
//case 80: // keypad
case VK_UP: keyInput = ewol::key::keyboardUp; break;
//case 83: // keypad
case VK_LEFT: keyInput = ewol::key::keyboardLeft; break;
//case 85: // keypad
case VK_RIGHT: keyInput = ewol::key::keyboardRight; break;
//case 88: // keypad
case VK_DOWN: keyInput = ewol::key::keyboardDown; break;
//case 81: // keypad
case VK_PRIOR: keyInput = ewol::key::keyboardPageUp; break;
//case 89: // keypad
case VK_NEXT: keyInput = ewol::key::keyboardPageDown; break;
//case 79: // keypad
case VK_HOME: keyInput = ewol::key::keyboardStart; break;
//case 87: // keypad
case VK_END: keyInput = ewol::key::keyboardEnd; break;
//case VK_: keyInput = ewol::key::keyboardStopDefil; break;
case VK_PAUSE: keyInput = ewol::key::keyboardWait; break;
//case 90: // keypad
case VK_INSERT:
keyInput = ewol::key::keyboardInsert;
m_guiKeyBoardMode.setInsert(buttonIsDown);
break;
case VK_F1: keyInput = ewol::key::keyboardF1; break;
case VK_F2: keyInput = ewol::key::keyboardF2; break;
case VK_F3: keyInput = ewol::key::keyboardF3; break;
case VK_F4: keyInput = ewol::key::keyboardF4; break;
case VK_F5: keyInput = ewol::key::keyboardF5; break;
case VK_F6: keyInput = ewol::key::keyboardF6; break;
case VK_F7: keyInput = ewol::key::keyboardF7; break;
case VK_F8: keyInput = ewol::key::keyboardF8; break;
case VK_F9: keyInput = ewol::key::keyboardF9; break;
case VK_F10: keyInput = ewol::key::keyboardF10; break;
case VK_F11: keyInput = ewol::key::keyboardF11; break;
case VK_F12:
case VK_F13:
case VK_F14:
case VK_F15:
case VK_F16:
case VK_F17:
case VK_F18:
case VK_F19:
case VK_F20:
case VK_F21:
case VK_F22:
case VK_F23:
case VK_F24: keyInput = ewol::key::keyboardF12; break;
case VK_CAPITAL:
keyInput = ewol::key::keyboardCapLock;
m_guiKeyBoardMode.setCapsLock(buttonIsDown);
break;
case VK_SHIFT:
case VK_LSHIFT:
keyInput = ewol::key::keyboardShiftLeft;
m_guiKeyBoardMode.setShift(buttonIsDown);
break;
case VK_RSHIFT:
keyInput = ewol::key::keyboardShiftRight;
m_guiKeyBoardMode.setShift(buttonIsDown);
break;
case VK_CONTROL:
case VK_LCONTROL:
keyInput = ewol::key::keyboardCtrlLeft;
m_guiKeyBoardMode.setCtrl(buttonIsDown);
break;
case VK_RCONTROL:
keyInput = ewol::key::keyboardCtrlRight;
m_guiKeyBoardMode.setCtrl(buttonIsDown);
break;
case VK_LWIN:
keyInput = ewol::key::keyboardMetaLeft;
m_guiKeyBoardMode.setMeta(buttonIsDown);
break;
case VK_RWIN:
keyInput = ewol::key::keyboardMetaRight;
m_guiKeyBoardMode.setMeta(buttonIsDown);
break;
case VK_MENU:
case VK_LMENU:
keyInput = ewol::key::keyboardAlt;
m_guiKeyBoardMode.setAlt(buttonIsDown);
break;
case VK_RMENU:
keyInput = ewol::key::keyboardAltGr;
m_guiKeyBoardMode.setAltGr(buttonIsDown);
break;
//case : keyInput = ewol::key::keyboardContextMenu; break;
case VK_NUMLOCK:
keyInput = ewol::key::keyboardNumLock;
m_guiKeyBoardMode.setNumLock(buttonIsDown);
break;
case VK_BACK: // DEL
tmpChar = 0x08;
break;
// TODO : Really strang, need to understand why ...
case 46: // Suppr
tmpChar = 0x7F;
break;
case VK_TAB: // special case for TAB
tmpChar = 0x09;
break;
case VK_RETURN: // special case for TAB
tmpChar = '\n';
break;
default:
{
BYTE kbd[256];
GetKeyboardState(kbd);
const int BUFFER_LENGTH = 8; //Length of the buffer
WCHAR chars[BUFFER_LENGTH];
ToUnicode(_wParam, _lParam, kbd, chars,BUFFER_LENGTH,0);
tmpChar = utf8::convertChar32((char*)chars);
}
break;
}
EWOL_DEBUG("kjhkjhkjhkjhkj = " << _wParam);
if (tmpChar == 0) {
//EWOL_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) );
OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, buttonIsDown);
} else {
OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, buttonIsDown);
}
return 0;
}
/* **************************************************************************
* Mouse management
* **************************************************************************/
case WM_LBUTTONUP:
buttonIsDown = false;
case WM_LBUTTONDOWN:
mouseButtonId = 1;
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
m_inputIsPressed[mouseButtonId] = buttonIsDown;
OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y()));
return 0;
case WM_MBUTTONUP:
buttonIsDown = false;
case WM_MBUTTONDOWN:
mouseButtonId = 2;
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
m_inputIsPressed[mouseButtonId] = buttonIsDown;
OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y()));
return 0;
case WM_RBUTTONUP:
buttonIsDown = false;
case WM_RBUTTONDOWN:
mouseButtonId = 3;
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
m_inputIsPressed[mouseButtonId] = buttonIsDown;
OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y()));
return 0;
case WM_MOUSEWHEEL:
if (_wParam & 0x200000) {
EWOL_DEBUG("event SCROOL UP");
mouseButtonId = 4;
} else {
EWOL_DEBUG("event SCROOL DOWN");
mouseButtonId = 5;
}
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
OS_SetMouseState(mouseButtonId, true, vec2(pos.x(),pos.y()));
OS_SetMouseState(mouseButtonId, false, vec2(pos.x(),pos.y()));
return 0;
case WM_MOUSEHOVER:
case WM_MOUSEMOVE:
pos.setValue(GET_X_LPARAM(_lParam),
m_currentHeight-GET_Y_LPARAM(_lParam));
for (int32_t iii=0; iii<MAX_MANAGE_INPUT ; iii++) {
if (true == m_inputIsPressed[iii]) {
EWOL_VERBOSE("Windows event: bt=" << iii << " " << _message << " = \"WM_MOUSEMOVE\" " << pos );
OS_SetMouseMotion(iii, vec2(pos.x(),pos.y()));
return 0;
}
}
EWOL_VERBOSE("Windows event: bt=" << 0 << " " << _message << " = \"WM_MOUSEMOVE\" " << pos );
OS_SetMouseMotion(0, vec2(pos.x(),pos.y()));
return 0;
default:
EWOL_DEBUG("event ..." << _message );
return DefWindowProc( _hWnd, _message, _wParam, _lParam );
}
}
};
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
GLenum err = glewInit();
if (GLEW_OK != err) {
// Problem: glewInit failed, something is seriously wrong.
EWOL_ERROR("Error:" << glewGetErrorString(err));
}
if (!glewIsSupported("GL_VERSION_2_0")) {
EWOL_ERROR("OpenGL 2.0 not available");
//return 1;
}
WindowsContext* localInterface = new WindowsContext(_application, _argc, _argv);
if (localInterface == nullptr) {
EWOL_CRITICAL("Can not create the 'Windows' interface ... MEMORY allocation error");
return -2;
}
int32_t retValue = localInterface->run();
delete(localInterface);
localInterface = nullptr;
return retValue;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/context/clipBoard.h>
#include <ewol/context/Context.h>
#undef __class__
#define __class__ "ClipBoard"
/*
note: copy id data :
0 : copy standard
[1..9] : copy internal
10 : middle button
*/
//!< Local copy of the clipboards
static std::string myCopy[ewol::context::clipBoard::clipboardCount];
static const char* clipboardDescriptionString[ewol::context::clipBoard::clipboardCount+1] = {
"clipboard0",
"clipboard1",
"clipboard2",
"clipboard3",
"clipboard4",
"clipboard5",
"clipboard6",
"clipboard7",
"clipboard8",
"clipboard9",
"clipboardStd",
"clipboardSelection",
"clipboardCount"
};
std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::context::clipBoard::clipboardListe _obj) {
if (_obj >= 0 && _obj <ewol::context::clipBoard::clipboardCount) {
_os << clipboardDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}
void ewol::context::clipBoard::init() {
EWOL_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<ewol::context::clipBoard::clipboardCount; i++) {
myCopy[i].clear();
}
}
void ewol::context::clipBoard::unInit() {
EWOL_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<ewol::context::clipBoard::clipboardCount; i++) {
myCopy[i].clear();
}
}
void ewol::context::clipBoard::set(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data) {
// check if ID is correct
if(0 == _data.size()) {
EWOL_INFO("request a copy of nothing");
return;
} else
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return;
}
ewol::context::clipBoard::setSystem(_clipboardID, _data);
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
ewol::getContext().clipBoardSet(_clipboardID);
}
}
void ewol::context::clipBoard::request(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return;
}
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
ewol::getContext().clipBoardGet(_clipboardID);
} else {
// generate an event on the main thread ...
ewol::getContext().OS_ClipBoardArrive(_clipboardID);
}
}
void ewol::context::clipBoard::setSystem(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data) {
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return;
}
// Copy datas ...
myCopy[_clipboardID] = _data;
}
const std::string& ewol::context::clipBoard::get(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
static const std::string emptyString("");
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return emptyString;
}
// Copy datas ...
return myCopy[_clipboardID];
}

View File

@ -1,84 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_CLIPBOARD_H__
#define __EWOL_CLIPBOARD_H__
#include <ewol/debug.h>
// TODO : Remove this ... ==> set it in the context ....
namespace ewol {
namespace context {
namespace clipBoard {
enum clipboardListe {
clipboard0, //!< internal clipboard 0
clipboard1, //!< internal clipboard 1
clipboard2, //!< internal clipboard 2
clipboard3, //!< internal clipboard 3
clipboard4, //!< internal clipboard 4
clipboard5, //!< internal clipboard 5
clipboard6, //!< internal clipboard 6
clipboard7, //!< internal clipboard 7
clipboard8, //!< internal clipboard 8
clipboard9, //!< internal clipboard 9
clipboardStd, //!< External clipboard represent the Copy/Cut/Past buffer
clipboardSelection, //!< External or internal clipboard depending on the OS, represent the middle button
clipboardCount, //!< Total number of clipboard
};
/**
* @brief set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change
* @param[in] _clipboardID Select the specific ID of the clipboard
* @param[in] _data The string that might be send to the clipboard
*/
void set(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data);
/**
* @brief Call system to request the current clipboard.
* @note Due to some system that manage the clipboard request asynchronous (like X11) and ewol managing the system with only one thread,
* we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the
* notification of the arrival of this buffer id
* @param[in] _clipboardID the needed clipboard ID
*/
void request(enum ewol::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief set the ewol internal buffer (no notification at the GUI). This fuction might be use by the
* Gui abstraction to set the buffer we receive. The end user must not use it.
* @param[in] _clipboardID selected clipboard ID
* @param[in] _data new buffer data
*/
void setSystem(enum ewol::context::clipBoard::clipboardListe _clipboardID,const std::string& _data);
/**
* @brief get the ewol internal buffer of the curent clipboard. The end user can use it when he receive the event in
* the widget : @ref onEventClipboard == > we can nothe this function is the only one which permit it.
* @note if we call this fuction withoutcallin @ref ewol::context::clipBoard::Request, we only get the previous clipboard
* @param[in] _clipboardID selected clipboard ID
* @return the requested buffer
*/
const std::string& get(enum ewol::context::clipBoard::clipboardListe _clipboardID);
// internal section
/**
* @brief initialize the clipboard system (done by ewol)
*/
void init();
/**
* @brief Un-Initialize the clipboard system (done by ewol)
*/
void unInit();
};
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
std::ostream& operator <<(std::ostream& _os, const enum ewol::context::clipBoard::clipboardListe _obj);
};
#endif

View File

@ -1,40 +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/context/commandLine.h>
#include <vector>
void ewol::context::CommandLine::parse(int32_t _argc, const char* _argv[]) {
for (int32_t i=1 ; i<_argc; i++) {
EWOL_INFO("commandLine : \"" << _argv[i] << "\"" );
m_listArgs.push_back(_argv[i]);
}
}
int32_t ewol::context::CommandLine::size() {
return m_listArgs.size();
}
const std::string& ewol::context::CommandLine::get(int32_t _id) {
static const std::string errorArg("");
if ( _id < 0
&& _id >= (int64_t)m_listArgs.size()) {
return errorArg;
}
return m_listArgs[_id];
}
void ewol::context::CommandLine::add(const std::string& _newElement) {
m_listArgs.push_back(_newElement);
}
void ewol::context::CommandLine::remove(int32_t _id) {
m_listArgs.erase(m_listArgs.begin()+_id);
}

View File

@ -1,48 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_COMMAND_LINE_H__
#define __EWOL_COMMAND_LINE_H__
#include <ewol/debug.h>
namespace ewol {
namespace context {
class CommandLine {
private:
std::vector<std::string> m_listArgs; //!< list of all argument parsed
public:
/**
* @brief Parse the command line parameters
*/
void parse(int32_t _argc, const char* _argv[]);
/**
* @brief get the number of element in the Command line
* @return the number of element
*/
int32_t size();
/**
* @brief get an element with a specific ID
* @return _id The cmdLine Id element
*/
const std::string& get(int32_t _id);
/**
* @brief add one element at the Command line
* @param[in] _newElement String in the input that might be added.
*/
void add(const std::string& _newElement);
/**
* @brief remove an element
* @param[in] _id Id of the element
*/
void remove(int32_t _id);
};
};
};
#endif

View File

@ -1,45 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/context/cursor.h>
static const char* cursorDescriptionString[ewol::context::cursorCount+1] = {
"cursorArrow",
"cursorLeftArrow",
"cursorInfo",
"cursorDestroy",
"cursorHelp",
"cursorCycle",
"cursorSpray",
"cursorWait",
"cursorText",
"cursorCrossHair",
"cursorSlideUpDown",
"cursorSlideLeftRight",
"cursorResizeUp",
"cursorResizeDown",
"cursorResizeLeft",
"cursorResizeRight",
"cursorCornerTopLeft",
"cursorCornerTopRight",
"cursorCornerButtomLeft",
"cursorCornerButtomRight",
"cursorNone",
"cursorCount"
};
std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::context::cursorDisplay _obj) {
if (_obj >= 0 && _obj <ewol::context::cursorCount) {
_os << cursorDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}

View File

@ -1,50 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_CURSOR_H__
#define __EWOL_CURSOR_H__
#include <ewol/debug.h>
namespace ewol {
namespace context {
enum cursorDisplay {
cursorArrow, // this is the normal arrow ...
cursorLeftArrow,
cursorInfo,
cursorDestroy,
cursorHelp,
cursorCycle,
cursorSpray,
cursorWait,
cursorText,
cursorCrossHair,
cursorSlideUpDown, //!< change the position (slide) vertical
cursorSlideLeftRight, //!< change the position (slide) horizontal
cursorResizeUp,
cursorResizeDown,
cursorResizeLeft,
cursorResizeRight,
cursorCornerTopLeft,
cursorCornerTopRight,
cursorCornerButtomLeft,
cursorCornerButtomRight,
cursorNone,
// just for the count:
cursorCount
};
};
/**
* @brief Debug operator To display the curent element in a Human readable information
*/
std::ostream& operator <<(std::ostream& _os, const enum ewol::context::cursorDisplay _obj);
};
#endif

View File

@ -1,494 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
/*
notes :
sudo edn /etc/udev/rules.d/framebuffer.rules
KERNEL == "fb0", OWNER="root", MODE="0660"
sudo usermod -a -G video username
sudo usermod -a -G tty username
sudo fbset -i
sudo chmod o+wr /dev/fb0
http://mail.directfb.org/pipermail/directfb-users/2010-February/002115.html
on X11 :
http://stackoverflow.com/questions/521957/how-to-develop-a-directfb-app-without-leaving-x-11-environment
$ sudo apt-get install libdirectfb-extra # for Debian and Ubuntu, anyhow
$ cat ~/.directfbrc
system=x11
force-windowed
*/
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/key.h>
#include <ewol/config.h>
#include <ewol/commandLine.h>
#include <etk/types.h>
#include <etk/unicode.h>
#include <ewol/widget/Manager.h>
#include <ewol/renderer/ResourceManager.h>
#include <ewol/renderer/eSystem.h>
#include <ewol/openGL/openGL.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <directfb.h>
#include <directfbgl.h>
int64_t guiInterface::getTime() {
struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
// Error to get the time ...
now.tv_sec = time(nullptr);
now.tv_nsec = 0;
}
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
}
#undef __class__
#define __class__ "guiInterface"
static ewol::SpecialKey guiKeyBoardMode;
bool inputIsPressed[20];
bool m_run = true;
bool m_grabAllEvent = false;
// the super interface
IDirectFB *dfb = nullptr;
// the primary surface (surface of primary layer)
IDirectFBSurface *primary = nullptr;
// the GL context
IDirectFBGL *primary_gl = nullptr;
// event buffer
IDirectFBEventBuffer *events = nullptr;
static int screen_width =800;
static int screen_height = 600;
/**
* @brief set the new title of the windows
* @param title New desired title
* @return ---
*/
void guiInterface::setTitle(std::string& title) {
// TODO : ...
}
void guiInterface::setIcon(std::string inputFile) {
// TODO : ...
}
void DirectFB_Init(int argc, const char *argv[]) {
EWOL_INFO("DirectFB init (START)");
DFBResult err;
DFBSurfaceDescription dsc;
EWOL_INFO("call DirectFBInit");
int argc2 = 1;
err = DirectFBInit(&argc2, (char***)&argv);
if (DFB_OK!=err) {
EWOL_ERROR("DirectFBInit");
DirectFBErrorFatal("DirectFBInit", err);
exit(-1);
}
EWOL_INFO("call DirectFBCreate");
// create the super interface
err = DirectFBCreate(&dfb);
if (DFB_OK!=err) {
EWOL_ERROR("DirectFBCreate");
DirectFBErrorFatal("DirectFBCreate", err);
exit(-1);
}
EWOL_INFO("call setCooperativeLevel");
// set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer
dfb->setCooperativeLevel(dfb, DFSCL_FULLSCREEN);
//dfb->setCooperativeLevel(dfb, DFSCL_NORMAL);
// get the primary surface, i.e. the surface of the primary layer we have exclusive access to
dsc.flags = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS);// | DSDESC_PIXELFORMAT);
//dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_DEPTH); // DSCAPS_SHARED
dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_GL);// | DSCAPS_FLIPPING);
//dsc.caps = (DFBSurfaceCapabilities) (DSCAPS_SUBSURFACE | DSCAPS_VIDEOONLY | DSCAPS_PREMULTIPLIED | DSCAPS_FLIPPING);
dsc.pixelformat = DSPF_ARGB;
dsc.width = 600;
dsc.height = 400;
EWOL_INFO("call CreateSurface");
err = dfb->CreateSurface(dfb, &dsc, &primary);
if (DFB_OK!=err) {
EWOL_ERROR("dfb->CreateSurface");
DirectFBErrorFatal("dfb->CreateSurface", err);
exit(-1);
}
primary->setBlittingFlags(primary, DSBLIT_BLEND_ALPHACHANNEL);
primary->setPorterDuff( primary, DSPD_ADD );
primary->setDstBlendFunction(primary, DSBF_SRCALPHA);
primary->setDrawingFlags(primary, DSDRAW_BLEND);
primary->Blit(primary, primary, nullptr, 0, 0);
EWOL_INFO("call getSize");
// get the size of the surface and fill it
err = primary->getSize(primary, &screen_width, &screen_height);
if (DFB_OK!=err) {
EWOL_ERROR("primary->getSize");
DirectFBErrorFatal("primary->getSize", err);
exit(-1);
}
EWOL_INFO("call CreateInputEventBuffer");
// create an event buffer for all devices with these caps
err = dfb->CreateInputEventBuffer(dfb, (DFBInputDeviceCapabilities)(DICAPS_KEYS | DICAPS_AXES), DFB_FALSE, &events);
if (DFB_OK!=err) {
EWOL_ERROR("dfb->CreateInputEventBuffer");
DirectFBErrorFatal("CreateInputEventBuffer", err);
exit(-1);
}
EWOL_INFO("call Flip");
primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
// NOTE : we need to force it on X11 display ...
EWOL_INFO("call getGL");
// get the GL context
err = primary->getGL(primary, &primary_gl);
if (DFB_OK!=err) {
EWOL_ERROR("primary->getGL");
DirectFBErrorFatal("GetGL", err);
exit(-1);
}
EWOL_INFO("DirectFB init (STOP)");
}
void DirectFB_UnInit() {
// release our interfaces to shutdown DirectFB
primary_gl->release(primary_gl);
primary->release(primary);
events->release(events);
dfb->release(dfb);
}
void DirectFB_Run() {
EWOL_INFO("X11 configure windows size : (" << screen_height << "," << screen_width << ")");
eSystem::Resize(screen_width, screen_height);
DFBResult err;
int32_t position = 0;
while (true == m_run) {
DFBInputEvent evt;
unsigned long t;
/*
primary->setColor (primary, 0x00, 0x00, 0x00, 0xFF);
primary->FillRectangle(primary, 0, 0, screen_width, screen_height);
primary->setColor (primary, 0xFF, (uint8_t)position, 0x00, 0xFF);
primary->FillRectangle(primary, position, position, 300, 300);
primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
position++;
if (position>600) {
position = 0;
}
*/
if(true == m_run) {
err = primary_gl->Lock(primary_gl);
if (DFB_OK!=err) {
EWOL_ERROR("primary_gl->Lock");
DirectFBErrorFatal("primary_gl->Lock", err);
}
// TODO : set at false
bool hasDisplay = eSystem::draw(true);
if (true == hasDisplay) {
glFinish();
}
err = primary_gl->Unlock(primary_gl);
if (DFB_OK!=err) {
EWOL_ERROR("primary_gl->Unlock");
DirectFBErrorFatal("primary_gl->Unlock", err);
}
primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
}
while (events->getEvent(events, DFB_EVENT(&evt)) == DFB_OK) {
switch (evt.type) {
default:
case DIET_UNKNOWN: /* unknown event */
EWOL_DEBUG("event unknown type : " << evt.type << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " ...");
break;
case DIET_KEYPRESS: /* a key is been pressed */
case DIET_KEYRELEASE: /* a key is been released */
{
bool isPressed = (evt.type == DIET_KEYPRESS);
//EWOL_DEBUG("event KeyBoard isPressed : " << isPressed << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " ...");
if( 1 <= evt.key_symbol && evt.key_symbol <= 0x7F ) {
eSystem::setKeyboard(guiKeyBoardMode, evt.key_symbol, isPressed, false);
} else {
EWOL_DEBUG("event KeyBoard isPressed : " << isPressed << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " == > not managed key");
}
}
break;
case DIET_AXISMOTION: /* mouse/joystick movement */
{
/*
if (evt.flags & DIEF_AXISREL) {
switch (evt.axis) {
case DIAI_X:
//view_roty += evt.axisrel / 2.0;
break;
case DIAI_Y:
//view_rotx += evt.axisrel / 2.0;
break;
case DIAI_Z:
//view_rotz += evt.axisrel / 2.0;
break;
default:
;
}
}
*/
EWOL_DEBUG("event mouse motion flag" << (char)evt.flags << " axis=" << evt.axis << " value=" << evt.axisrel);
}
break;
case DIET_BUTTONPRESS: /* a (mouse) button is been pressed */
case DIET_BUTTONRELEASE: /* a (mouse) button is been released */
{
bool isPressed = (evt.type == DIET_KEYPRESS);
EWOL_DEBUG("event mouse event pressed=" << isPressed << " flag" << (char)evt.flags << " axis=" << evt.axis << " value=" << evt.axisrel);
}
break;
/*
case DIET_KEYPRESS:
switch (evt.key_symbol) {
case DIKS_ESCAPE:
m_run = false;
break;
case DIKS_CURSOR_UP:
//inc_rotx = 5.0;
break;
case DIKS_CURSOR_DOWN:
//inc_rotx = -5.0;
break;
case DIKS_CURSOR_LEFT:
//inc_roty = 5.0;
break;
case DIKS_CURSOR_RIGHT:
//inc_roty = -5.0;
break;
case DIKS_PAGE_UP:
//inc_rotz = 5.0;
break;
case DIKS_PAGE_DOWN:
//inc_rotz = -5.0;
break;
default:
;
}
break;
case DIET_KEYRELEASE:
switch (evt.key_symbol) {
case DIKS_CURSOR_UP:
//inc_rotx = 0;
break;
case DIKS_CURSOR_DOWN:
//inc_rotx = 0;
break;
case DIKS_CURSOR_LEFT:
//inc_roty = 0;
break;
case DIKS_CURSOR_RIGHT:
//inc_roty = 0;
break;
case DIKS_PAGE_UP:
//inc_rotz = 0;
break;
case DIKS_PAGE_DOWN:
//inc_rotz = 0;
break;
default:
;
}
break;
case DIET_AXISMOTION:
if (evt.flags & DIEF_AXISREL) {
switch (evt.axis) {
case DIAI_X:
//view_roty += evt.axisrel / 2.0;
break;
case DIAI_Y:
//view_rotx += evt.axisrel / 2.0;
break;
case DIAI_Z:
//view_rotz += evt.axisrel / 2.0;
break;
default:
;
}
}
break;
default:
;
*/
}
}
}
// Note : if we not stop like this the system break ...
exit(-1);
};
// -------------------------------------------------------------------------
// ClipBoard AREA :
// -------------------------------------------------------------------------
void guiInterface::ClipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
// TODO : ...
}
void guiInterface::ClipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
// TODO : ...
}
#undef __class__
#define __class__ "guiInterface"
void guiInterface::Stop() {
EWOL_INFO("X11-API: Stop");
m_run = false;
}
void guiInterface::KeyboardShow() {
// nothing to do : No keyboard on computer ...
}
void guiInterface::KeyboardHide() {
// nothing to do : No keyboard on computer ...
}
void guiInterface::changeSize(ivec2 _size) {
// TODO : ...
}
void guiInterface::changePos(ivec2 _pos) {
// TODO : ...
}
void guiInterface::getAbsPos(ivec2& _pos) {
// TODO : ...
}
void guiInterface::setCursor(enum ewol::cursorDisplay _newCursor) {
// TODO : ...
}
void guiInterface::GrabPointerEvents(bool _isGrabbed, vec2 _forcedPosition) {
// TODO : ...
}
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int guiInterface::main(int argc, const char *argv[]) {
EWOL_INFO("Main (START)");
for (int32_t iii=0; iii<NB_MAX_INPUT; iii++) {
inputIsPressed[iii] = false;
}
m_grabAllEvent = false;
// start X11 thread ...
DirectFB_Init(argc, argv);
//start the basic thread :
eSystem::init();
// Run ...
DirectFB_Run();
// UnInit:
DirectFB_UnInit();
// close X11 :
guiInterface::Stop();
// uninit ALL :
eSystem::UnInit();
EWOL_INFO("Main (STOP)");
return 0;
}
void guiInterface::forceOrientation(enum ewol::orientation _orientation) {
// nothing to do ...
}
/*
static void init(int argc, char *argv[]) {
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
for (i=1; i<argc; i++)
{
if (strcmp(argv[i],"-info") == 0)
{
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
else if (strcmp(argv[i],"-exit") == 0)
{
autoexit = 30;
printf("Auto Exit after %i seconds.\n", autoexit );
}
}
// make the gears
gear1 = gear(1.0, 4.0, 1.0, 20, 0.7, red);
gear2 = gear(0.5, 2.0, 2.0, 10, 0.7, green);
gear3 = gear(1.3, 2.0, 0.5, 10, 0.7, blue);
}
*/

View File

@ -14,7 +14,7 @@
std::ostream& ewol::event::operator <<(std::ostream& _os, const ewol::event::Entry& _obj) {
_os << "{type=" << _obj.getType();
_os << " status=" << _obj.getStatus();
if (_obj.getType() == ewol::key::keyboardChar) {
if (_obj.getType() == gale::key::keyboard_char) {
_os << " char=" << _obj.getChar();
}
_os << "}";

View File

@ -10,20 +10,20 @@
#define __EWOL_EVENT_ENTRY_H__
#include <etk/types.h>
#include <ewol/key/key.h>
#include <gale/key/key.h>
namespace ewol {
namespace event {
class Entry {
private:
enum ewol::key::keyboard m_type; //!< type of hardware event
enum ewol::key::status m_status; //!< status of hardware event
ewol::key::Special m_specialKey; //!< input key status (prevent change in time..)
enum gale::key::keyboard m_type; //!< type of hardware event
enum gale::key::status m_status; //!< status of hardware event
gale::key::Special m_specialKey; //!< input key status (prevent change in time..)
char32_t m_unicodeData; //!< Unicode data (in some case)
public:
Entry(enum ewol::key::keyboard _type,
enum ewol::key::status _status,
ewol::key::Special _specialKey,
Entry(enum gale::key::keyboard _type,
enum gale::key::status _status,
gale::key::Special _specialKey,
char32_t _char) :
m_type(_type),
m_status(_status),
@ -31,22 +31,22 @@ namespace ewol {
m_unicodeData(_char) {
};
void setType(enum ewol::key::keyboard _type) {
void setType(enum gale::key::keyboard _type) {
m_type = _type;
};
inline const enum ewol::key::keyboard& getType() const {
inline const enum gale::key::keyboard& getType() const {
return m_type;
};
void setStatus(enum ewol::key::status _status) {
void setStatus(enum gale::key::status _status) {
m_status = _status;
};
inline const enum ewol::key::status& getStatus() const {
inline const enum gale::key::status& getStatus() const {
return m_status;
};
void setSpecialKey(const ewol::key::Special& _specialKey) {
void setSpecialKey(const gale::key::Special& _specialKey) {
m_specialKey = _specialKey;
};
inline const ewol::key::Special& getSpecialKey() const {
inline const gale::key::Special& getSpecialKey() const {
return m_specialKey;
};
void setChar(char32_t _char) {
@ -60,9 +60,9 @@ namespace ewol {
class EntrySystem {
public:
EntrySystem(enum ewol::key::keyboard _type,
enum ewol::key::status _status,
ewol::key::Special _specialKey,
EntrySystem(enum gale::key::keyboard _type,
enum gale::key::status _status,
gale::key::Special _specialKey,
char32_t _char) :
m_event(_type, _status, _specialKey, _char) {

View File

@ -15,17 +15,17 @@ namespace ewol {
namespace event {
class Input {
private:
enum ewol::key::type m_type;
enum ewol::key::status m_status;
enum gale::key::type m_type;
enum gale::key::status m_status;
uint8_t m_inputId;
vec2 m_pos;
ewol::key::Special m_specialKey; //!< input key status (prevent change in time..)
gale::key::Special m_specialKey; //!< input key status (prevent change in time..)
public:
Input(enum ewol::key::type _type,
enum ewol::key::status _status,
Input(enum gale::key::type _type,
enum gale::key::status _status,
uint8_t _id,
const vec2& _pos,
ewol::key::Special _specialKey):
gale::key::Special _specialKey):
m_type(_type),
m_status(_status),
m_inputId(_id),
@ -33,16 +33,16 @@ namespace ewol {
m_specialKey(_specialKey) {
};
void setType(enum ewol::key::type _type) {
void setType(enum gale::key::type _type) {
m_type = _type;
};
inline const enum ewol::key::type& getType() const {
inline const enum gale::key::type& getType() const {
return m_type;
};
void setStatus(enum ewol::key::status _status) {
void setStatus(enum gale::key::status _status) {
m_status = _status;
};
inline const enum ewol::key::status& getStatus() const {
inline const enum gale::key::status& getStatus() const {
return m_status;
};
void setId(uint8_t _id) {
@ -57,10 +57,10 @@ namespace ewol {
inline const vec2& getPos() const {
return m_pos;
};
void setSpecialKey(const ewol::key::Special& _specialKey) {
void setSpecialKey(const gale::key::Special& _specialKey) {
m_specialKey = _specialKey;
};
inline const ewol::key::Special& getSpecialKey() const {
inline const gale::key::Special& getSpecialKey() const {
return m_specialKey;
};
/**
@ -74,13 +74,13 @@ namespace ewol {
class InputSystem {
public:
InputSystem(enum ewol::key::type _type,
enum ewol::key::status _status,
InputSystem(enum gale::key::type _type,
enum gale::key::status _status,
uint8_t _id,
const vec2& _pos,
std::shared_ptr<ewol::Widget> _dest,
int32_t _realIdEvent,
ewol::key::Special _specialKey) :
gale::key::Special _specialKey) :
m_event(_type, _status, _id, _pos, _specialKey),
m_dest(_dest),
m_realIdEvent(_realIdEvent) { };

View File

@ -9,10 +9,11 @@
#include <ewol/ewol.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <gale/gale.h>
#include <ewol/context/commandLine.h>
#include <gale/context/commandLine.h>
#include <etk/os/FSNode.h>
#include <ewol/Dimension.h>
#include <gale/Dimension.h>
#include <date/date.h>
#undef __class__
@ -48,4 +49,14 @@ std::string ewol::getBoardType() {
std::string ewol::getVersion() {
return EWOL_VERSION;
}
int64_t ewol::getTime() {
return gale::getTime();
}
int32_t ewol::run(ewol::context::Application* _application,
int32_t _argc,
const char* _argv[]) {
return gale::run(new ewol::Context(_application), _argc, _argv);
}

View File

@ -36,16 +36,19 @@ namespace ewol {
* @return The current time
* @note is implemented by the OS implementation cf renderer/X11/...
*/
// TODO : Remove ...
int64_t getTime();
/**
* @brief get compilation mode (release/debug)
* @return the string of the mode of commpilation
*/
// TODO : Remove ...
std::string getCompilationMode();
/**
* @brief get the board type (Android/Linux/MacOs/...)
* @return the string of the mode of commpilation
*/
// TODO : Remove ...
std::string getBoardType();
};

View File

@ -1,214 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/key/Special.h>
#define EWOL_FLAG_KEY_CAPS_LOCK 0x00000001
#define EWOL_FLAG_KEY_SHIFT 0x00000002
#define EWOL_FLAG_KEY_CTRL 0x00000004
#define EWOL_FLAG_KEY_META 0x00000008
#define EWOL_FLAG_KEY_ALT 0x00000010
#define EWOL_FLAG_KEY_ALTGR 0x00000020
#define EWOL_FLAG_KEY_NUM_LOCK 0x00000040
#define EWOL_FLAG_KEY_INSERT 0x00000080
// TODO : Update to support the Left and right of some key ...
ewol::key::Special::Special() :
m_value(0) {
}
void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
switch (_move) {
case keyboardInsert:
setInsert(_isDown);
break;
case keyboardCapLock:
setCapsLock(_isDown);
break;
case keyboardShiftLeft:
case keyboardShiftRight:
setShift(_isDown);
break;
case keyboardCtrlLeft:
case keyboardCtrlRight:
setCtrl(_isDown);
break;
case keyboardMetaLeft:
case keyboardMetaRight:
setMeta(_isDown);
break;
case keyboardAlt:
setAlt(_isDown);
break;
case keyboardAltGr:
setAltGr(_isDown);
break;
case keyboardNumLock:
setNumLock(_isDown);
break;
default:
break;
}
}
bool ewol::key::Special::getCapsLock() const {
if ((m_value & EWOL_FLAG_KEY_CAPS_LOCK) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setCapsLock(bool _value) {
if ((m_value & EWOL_FLAG_KEY_CAPS_LOCK) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_CAPS_LOCK;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_CAPS_LOCK;
}
}
}
bool ewol::key::Special::getShift() const {
if ((m_value & EWOL_FLAG_KEY_SHIFT) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setShift(bool _value) {
if ((m_value & EWOL_FLAG_KEY_SHIFT) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_SHIFT;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_SHIFT;
}
}
}
bool ewol::key::Special::getCtrl() const {
if ((m_value & EWOL_FLAG_KEY_CTRL) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setCtrl(bool _value) {
if ((m_value & EWOL_FLAG_KEY_CTRL) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_CTRL;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_CTRL;
}
}
}
bool ewol::key::Special::getMeta() const {
if ((m_value & EWOL_FLAG_KEY_META) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setMeta(bool _value) {
if ((m_value & EWOL_FLAG_KEY_META) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_META;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_META;
}
}
}
bool ewol::key::Special::getAlt() const {
if ((m_value & EWOL_FLAG_KEY_ALT) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setAlt(bool _value) {
if ((m_value & EWOL_FLAG_KEY_ALT) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_ALT;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_ALT;
}
}
}
bool ewol::key::Special::getAltGr() const {
if ((m_value & EWOL_FLAG_KEY_ALTGR) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setAltGr(bool _value) {
if ((m_value & EWOL_FLAG_KEY_ALTGR) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_ALTGR;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_ALTGR;
}
}
}
bool ewol::key::Special::getNumLock() const {
if ((m_value & EWOL_FLAG_KEY_NUM_LOCK) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setNumLock(bool _value) {
if ((m_value & EWOL_FLAG_KEY_NUM_LOCK) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_NUM_LOCK;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_NUM_LOCK;
}
}
}
bool ewol::key::Special::getInsert() const {
if ((m_value & EWOL_FLAG_KEY_INSERT) != 0) {
return true;
}
return false;
}
void ewol::key::Special::setInsert(bool _value) {
if ((m_value & EWOL_FLAG_KEY_INSERT) != 0) {
if (_value == false) {
m_value -= EWOL_FLAG_KEY_INSERT;
}
} else {
if (_value == true) {
m_value += EWOL_FLAG_KEY_INSERT;
}
}
}
std::ostream& ewol::key::operator <<(std::ostream& _os, const ewol::key::Special _obj) {
_os << " capLock=" << _obj.getCapsLock();
_os << " shift=" << _obj.getShift();
_os << " ctrl=" << _obj.getCtrl();
_os << " meta=" << _obj.getMeta();
_os << " alt=" << _obj.getAlt();
_os << " altGr=" << _obj.getAltGr();
_os << " verNum=" << _obj.getNumLock();
_os << " insert=" << _obj.getInsert();
return _os;
}

View File

@ -1,121 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_KEY_SPECIAL_H__
#define __EWOL_KEY_SPECIAL_H__
#include <ewol/debug.h>
#include <ewol/key/keyboard.h>
namespace ewol {
namespace key {
/**
* @brief This class consider generic special keyborad key (insert, control, shift ...)
*/
class Special {
private:
uint32_t m_value;
public:
/**
* @brief Main constructor
*/
Special();
/**
* @brief get the current CapLock Status
* @return The CapLock value
*/
bool getCapsLock() const;
/**
* @brief set the current CapLock Status
* @param[in] _value The new CapLock value
*/
void setCapsLock(bool _value);
/**
* @brief Get the current Shift key status
* @return The Shift value
*/
bool getShift() const;
/**
* @brief Set the current Shift key status
* @param[in] _value The new Shift value
*/
void setShift(bool _value);
/**
* @brief Get the Current Control key status
* @return The Control value
*/
bool getCtrl() const;
/**
* @brief Set the Current Control key status
* @param[in] _value The new Control value
*/
void setCtrl(bool _value);
/**
* @brief Get the current Meta key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
bool getMeta() const;
/**
* @brief Set the current Meta key status (also named windows or apple key)
* @param[in] _value The new Meta value (name Windows key, apple key, command key ...)
*/
void setMeta(bool _value);
/**
* @brief Get the current Alt key status
* @return The Alt value
*/
bool getAlt() const;
/**
* @brief Set the current Alt key status
* @param[in] _value The new Alt value
*/
void setAlt(bool _value);
/**
* @brief Get the current Alt-Gr key status
* @return The Alt-gr value (does not exist on MacOs)
*/
bool getAltGr() const;
/**
* @brief Set the current Alt-Gr key status
* @param[in] _value The new Alt-gr value (does not exist on MacOs)
*/
void setAltGr(bool _value);
/**
* @brief Get the current Ver-num key status
* @return The Numerical Lock value
*/
bool getNumLock() const;
/**
* @brief Set the current Ver-num key status
* @param[in] _value The new Numerical Lock value
*/
void setNumLock(bool _value);
/**
* @brief Get the current Intert key status
* @return The Insert value
*/
bool getInsert() const;
/**
* @brief Set the current Intert key status
* @param[in] _value The new Insert value
*/
void setInsert(bool _value);
/**
* @brief Update the internal value with the input moving key.
* @param[in] _move Moving key.
* @param[in] _isFown The Key is pressed or not.
*/
void update(enum ewol::key::keyboard _move, bool _isDown);
};
std::ostream& operator <<(std::ostream& _os, const ewol::key::Special _obj);
};
};
#endif

View File

@ -1,19 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_KEY_H__
#define __EWOL_KEY_H__
#include <ewol/key/keyboard.h>
#include <ewol/key/Special.h>
#include <ewol/key/status.h>
#include <ewol/key/type.h>
#endif

View File

@ -1,80 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/key/keyboard.h>
static const char* keyboardDescriptionString[ewol::key::keyboardCount+1] = {
"keyboardUnknow",
"keyboardChar",
"keyboardLeft",
"keyboardRight",
"keyboardUp",
"keyboardDown",
"keyboardPageUp",
"keyboardPageDown",
"keyboardStart",
"keyboardEnd",
"keyboardPrint",
"keyboardStopDefil",
"keyboardWait",
"keyboardInsert",
"keyboardF1",
"keyboardF2",
"keyboardF3",
"keyboardF4",
"keyboardF5",
"keyboardF6",
"keyboardF7",
"keyboardF8",
"keyboardF9",
"keyboardF10",
"keyboardF11",
"keyboardF12",
"keyboardCapLock",
"keyboardShiftLeft",
"keyboardShiftRight",
"keyboardCtrlLeft",
"keyboardCtrlRight",
"keyboardMetaLeft",
"keyboardMetaRight",
"keyboardAlt",
"keyboardAltGr",
"keyboardContextMenu",
"keyboardNumLock",
"keyboardCount"
};
std::ostream& ewol::key::operator <<(std::ostream& _os, const enum ewol::key::keyboard _obj) {
if (_obj >= 0 && _obj <ewol::key::keyboardCount) {
_os << keyboardDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}
static const char* keyboardSystemDescriptionString[ewol::key::keyboardSystemCount+1] = {
"keyboardSystemUnknow",
"keyboardSystemVolumeUp",
"keyboardSystemVolumeDown",
"keyboardSystemMenu",
"keyboardSystemCamera",
"keyboardSystemHome",
"keyboardSystemPower",
"keyboardSystemBack",
"keyboardSystemCount"
};
std::ostream& ewol::key::operator <<(std::ostream& _os, const enum ewol::key::keyboardSystem _obj) {
if (_obj >= 0 && _obj <ewol::key::keyboardSystemCount) {
_os << keyboardSystemDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}

View File

@ -1,84 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_KEY_KEYBOARD_H__
#define __EWOL_KEY_KEYBOARD_H__
#include <ewol/debug.h>
namespace ewol {
namespace key {
/**
* @brief Keybord event or joystick event
* @warning If you modify Id of these element check the java interface file of constant : EwolConstant.java
*/
enum keyboard {
keyboardUnknow = 0, //!< Unknown keyboard key
keyboardChar, //!< Char input is arrived ...
keyboardLeft, //!< Left key <--
keyboardRight, //!< Right key -->
keyboardUp, //!< Up key ^
keyboardDown, //!< Down key \/
keyboardPageUp, //!< Page Up key
keyboardPageDown, //!< page down key
keyboardStart, //!< Start key
keyboardEnd, //!< End key
keyboardPrint, //!< print screen key.
keyboardStopDefil, //!< Stop display key.
keyboardWait, //!< Wait key.
keyboardInsert, //!< insert key.
keyboardF1, //!< F1 key.
keyboardF2, //!< F2 key.
keyboardF3, //!< F3 key.
keyboardF4, //!< F4 key.
keyboardF5, //!< F5 key.
keyboardF6, //!< F6 key.
keyboardF7, //!< F7 key.
keyboardF8, //!< F8 key.
keyboardF9, //!< F9 key.
keyboardF10, //!< F10 key.
keyboardF11, //!< F11 key.
keyboardF12, //!< F12 key.
keyboardCapLock, //!< Capital Letter Lock key.
keyboardShiftLeft, //!< Shift left key.
keyboardShiftRight, //!< Shift right key.
keyboardCtrlLeft, //!< Control left key.
keyboardCtrlRight, //!< Control right key.
keyboardMetaLeft, //!< Meta left key (apple key or windows key).
keyboardMetaRight, //!< Meta right key (apple key or windows key).
keyboardAlt, //!< Alt key.
keyboardAltGr, //!< Alt ground key.
keyboardContextMenu, //!< Contextual menu key.
keyboardNumLock, //!< Numerical Lock key.
keyboardCount //!< number of posible key
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
std::ostream& operator <<(std::ostream& _os, const enum ewol::key::keyboard _obj);
enum keyboardSystem {
keyboardSystemUnknow = 0, //!< Unknown keyboard system key
keyboardSystemVolumeUp, //!< Hardware volume UP key
keyboardSystemVolumeDown, //!< Hardware volume DOWN key
keyboardSystemMenu, //!< Hardware Menu key
keyboardSystemCamera, //!< Hardware Camera key
keyboardSystemHome, //!< Hardware Home key
keyboardSystemPower, //!< Hardware Power key
keyboardSystemBack, //!< Hardware Back key
keyboardSystemCount //!< number of posible System key
};
std::ostream& operator <<(std::ostream& _os, const enum ewol::key::keyboardSystem _obj);
};
};
#endif

View File

@ -1,38 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/key/status.h>
static const char* statusDescriptionString[ewol::key::statusCount+1] = {
"statusUnknow",
"statusDown",
"statusMove",
"statusSingle",
"statusDouble",
"statusTriple",
"statusQuad",
"statusQuinte",
"statusUp",
"statusUpAfter",
"statusEnter",
"statusLeave",
"statusAbort",
"statusTransfert",
"statusCount"
};
std::ostream& ewol::key::operator <<(std::ostream& _os, const enum ewol::key::status _obj) {
if (_obj >= 0 && _obj <ewol::key::statusCount) {
_os << statusDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}

View File

@ -1,47 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_KEY_STATUS_H__
#define __EWOL_KEY_STATUS_H__
#include <ewol/debug.h>
namespace ewol {
namespace key {
/**
* @brief Keybord event or joyestick event
*/
enum status {
statusUnknow = 0,
statusDown, // availlable on Keyboard too
statusMove,
statusSingle,
statusDouble,
statusTriple,
statusQuad,
statusQuinte,
statusUp, // availlable on Keyboard too
statusUpAfter, // mouse input & finger input this appear after the single event (depending on some case...)
statusEnter,
statusLeave,
statusAbort, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has lost the events)
statusTransfert, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event)
statusCount, // number max of imput possible
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
std::ostream& operator <<(std::ostream& _os, const enum ewol::key::status _obj);
};
};
#endif

View File

@ -1,28 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/key/type.h>
static const char* typeDescriptionString[ewol::key::typeCount+1] = {
"typeUnknow",
"typeMouse",
"typeFinger",
"typeStylet",
"typeCount"
};
std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::key::type _obj) {
if (_obj >= 0 && _obj < ewol::key::typeCount) {
_os << typeDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}

View File

@ -1,37 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_KEY_TYPE_H__
#define __EWOL_KEY_TYPE_H__
#include <ewol/debug.h>
namespace ewol {
namespace key {
/**
* @brief type of input : Note that the keyboard is not prevent due to the fact that data is too different
*/
enum type {
typeUnknow = 0, //!< Unknow input Type
typeMouse, //!< Mouse type
typeFinger, //!< Finger type
typeStylet, //!< Stylet type
typeCount //!< number of types
};
};
/**
* @brief Debug operator To display the curent element in a Human redeable information
*/
std::ostream& operator <<(std::ostream& _os, const enum ewol::key::type _obj);
};
#endif

View File

@ -9,7 +9,6 @@
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <ewol/resource/ColorFile.h>
#include <ewol/resource/Manager.h>
#include <ejson/ejson.h>
#include <stdexcept>
@ -18,13 +17,13 @@
ewol::resource::ColorFile::ColorFile() :
ewol::Resource(),
gale::Resource(),
m_errorColor(etk::color::orange) {
addObjectType("ewol::ColorFile");
addResourceType("ewol::ColorFile");
}
void ewol::resource::ColorFile::init(const std::string& _filename) {
ewol::Resource::init(_filename);
gale::Resource::init(_filename);
EWOL_DEBUG("CF : load \"" << _filename << "\"");
reload();
EWOL_DEBUG("List of all color : " << m_list.getKeys());

View File

@ -13,14 +13,14 @@
#include <etk/Color.h>
#include <etk/Hash.h>
#include <ewol/debug.h>
#include <ewol/resource/Resource.h>
#include <gale/resource/Resource.h>
namespace ewol {
namespace resource {
/**
* @brief ColorFile is a Resource designed to be specific with the theme (for example black, or white or orange ...)
*/
class ColorFile : public ewol::Resource {
class ColorFile : public gale::Resource {
private:
etk::Hash<etk::Color<float> > m_list; //!< List of all color in the file
etk::Color<float> m_errorColor; //!< Error returned color

View File

@ -8,7 +8,8 @@
#include <ewol/debug.h>
#include <ewol/resource/Colored3DObject.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <gale/renderer/openGL/openGL-include.h>
#undef __class__
#define __class__ "resource::Colored3DObject"
@ -16,11 +17,11 @@
ewol::resource::Colored3DObject::Colored3DObject() :
m_GLprogram(nullptr) {
addObjectType("ewol::Colored3DObject");
addResourceType("ewol::Colored3DObject");
}
void ewol::resource::Colored3DObject::init() {
ewol::Resource::init();
gale::Resource::init();
// get the shader resource :
m_GLPosition = 0;
m_GLprogram = gale::resource::Program::create("DATA:simple3D.prog");
@ -48,7 +49,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
return;
}
if (true == _depthtest) {
gale::openGL::enable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::enable(gale::openGL::flag_depthTest);
if (false == _updateDepthBuffer) {
glDepthMask(GL_FALSE);
}
@ -65,7 +66,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
// color :
m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, _vertices.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, _vertices.size());
m_GLprogram->unUse();
// Request the draw od the elements :
//glDrawArrays(GL_LINES, 0, vertices.size());
@ -74,7 +75,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
if (false == _updateDepthBuffer) {
glDepthMask(GL_TRUE);
}
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::disable(gale::openGL::flag_depthTest);
}
}
@ -91,7 +92,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
return;
}
if (true == _depthtest) {
gale::openGL::enable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::enable(gale::openGL::flag_depthTest);
if (false == _updateDepthBuffer) {
glDepthMask(GL_FALSE);
}
@ -108,13 +109,13 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
// color :
m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_TRIANGLES, 0, _vertices.size());
gale::openGL::drawArrays(gale::openGL::render_triangle, 0, _vertices.size());
m_GLprogram->unUse();
if (true == _depthtest) {
if (false == _updateDepthBuffer) {
glDepthMask(GL_TRUE);
}
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::disable(gale::openGL::flag_depthTest);
}
}
@ -131,7 +132,7 @@ void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
return;
}
if (true == _depthtest) {
gale::openGL::enable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::enable(gale::openGL::flag_depthTest);
if (false == _updateDepthBuffer) {
glDepthMask(GL_FALSE);
}
@ -148,13 +149,13 @@ void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
// color :
m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color);
// Request the draw od the elements :
gale::openGL::drawArrays(GL_LINES, 0, _vertices.size());
gale::openGL::drawArrays(gale::openGL::render_line, 0, _vertices.size());
m_GLprogram->unUse();
if (true == _depthtest) {
if (false == _updateDepthBuffer) {
glDepthMask(GL_TRUE);
}
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
gale::openGL::disable(gale::openGL::flag_depthTest);
}
}

View File

@ -10,13 +10,13 @@
#define __COLORED_3D_OBJECT_H__
#include <etk/types.h>
#include <ewol/resource/Resource.h>
#include <gale/resource/Resource.h>
#include <ewol/resource/Image.h>
#include <gale/resource/Program.h>
namespace ewol {
namespace resource {
class Colored3DObject : public ewol::Resource {
class Colored3DObject : public gale::Resource {
protected:
std::shared_ptr<gale::resource::Program> m_GLprogram;
int32_t m_GLPosition;

View File

@ -9,7 +9,7 @@
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <ewol/resource/ConfigFile.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ejson/ejson.h>
#include <ejson/Number.h>
#include <ejson/String.h>
@ -20,12 +20,12 @@
ewol::resource::ConfigFile::ConfigFile() :
ewol::Resource() {
addObjectType("ewol::ConfigFile");
gale::Resource() {
addResourceType("ewol::ConfigFile");
}
void ewol::resource::ConfigFile::init(const std::string& _filename) {
ewol::Resource::init(_filename);
gale::Resource::init(_filename);
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
reload();
}

View File

@ -13,11 +13,11 @@
#include <etk/Hash.h>
#include <ewol/debug.h>
#include <ejson/ejson.h>
#include <ewol/resource/Resource.h>
#include <gale/resource/Resource.h>
namespace ewol {
namespace resource {
class ConfigFile : public ewol::Resource {
class ConfigFile : public gale::Resource {
private:
ejson::Document m_doc;
etk::Hash<std::shared_ptr<ejson::Value>> m_list;

View File

@ -10,7 +10,7 @@
#include <etk/os/FSNode.h>
#include <egami/egami.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ewol/resource/font/FontBase.h>
#include <ewol/resource/TexturedFont.h>
@ -28,7 +28,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() :
ewol::resource::Texture(),
m_borderSize(10),
m_textureBorderSize(0,0) {
addObjectType("ewol::resource::DistanceFieldFont");
addResourceType("ewol::resource::DistanceFieldFont");
m_font = nullptr;
m_lastGlyphPos.setValue(1,1);
m_lastRawHeigh = 0;

View File

@ -11,7 +11,6 @@
#include <ewol/resource/font/FontBase.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/Resource.h>
#include <ewol/resource/TexturedFont.h>
namespace ewol {

View File

@ -11,12 +11,12 @@
#include <etk/os/FSNode.h>
#include <ewol/openGL/openGL.h>
#include <gale/renderer/openGL/openGL.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/FontFreeType.h>
#include <ewol/resource/font/FontBase.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#undef __class__
#define __class__ "resource::FontFreeType"
@ -53,7 +53,7 @@ void ewol::resource::freeTypeUnInit() {
}
ewol::resource::FontFreeType::FontFreeType() {
addObjectType("ewol::FontFreeType");
addResourceType("ewol::FontFreeType");
m_init = false;
m_FileBuffer = nullptr;
m_FileSize = 0;

View File

@ -9,7 +9,7 @@
#include <etk/types.h>
#include <egami/egami.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ewol/resource/Image.h>
#include <ewol/resource/Texture.h>
@ -18,7 +18,7 @@
#define __class__ "resource::TextureFile"
ewol::resource::TextureFile::TextureFile() {
addObjectType("ewol::resource::Image");
addResourceType("ewol::resource::Image");
}
@ -104,21 +104,21 @@ std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
std::shared_ptr<ewol::resource::TextureFile> object = nullptr;
std::shared_ptr<ewol::Resource> object2 = getManager().localKeep(TmpFilename);
if (nullptr != object2) {
std::shared_ptr<gale::Resource> object2 = getManager().localKeep(TmpFilename);
if (object2 != nullptr) {
object = std::dynamic_pointer_cast<ewol::resource::TextureFile>(object2);
if (nullptr == object) {
if (object == nullptr) {
EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)");
return nullptr;
}
}
if (nullptr != object) {
if (object != nullptr) {
return object;
}
EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size);
// need to crate a new one ...
object = std::shared_ptr<ewol::resource::TextureFile>(new ewol::resource::TextureFile());
if (nullptr == object) {
if (object == nullptr) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return nullptr;
}

View File

@ -13,7 +13,6 @@
#include <etk/types.h>
#include <egami/Image.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/Resource.h>
namespace ewol {
namespace resource {

View File

@ -9,7 +9,7 @@
#include <etk/types.h>
#include <egami/egami.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ewol/resource/ImageDF.h>
#include <ewol/resource/Texture.h>
#include <edtaa3/edtaa3func.h>
@ -19,7 +19,7 @@
#define __class__ "resource::TextureFile"
ewol::resource::ImageDF::ImageDF() {
addObjectType("ewol::resource::ImageDF");
addResourceType("ewol::resource::ImageDF");
}
@ -193,7 +193,7 @@ std::shared_ptr<ewol::resource::ImageDF> ewol::resource::ImageDF::create(const s
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
std::shared_ptr<ewol::resource::ImageDF> object = nullptr;
std::shared_ptr<ewol::Resource> object2 = getManager().localKeep("DF__" + TmpFilename);
std::shared_ptr<gale::Resource> object2 = getManager().localKeep("DF__" + TmpFilename);
if (nullptr != object2) {
object = std::dynamic_pointer_cast<ewol::resource::ImageDF>(object2);
if (nullptr == object) {

View File

@ -14,7 +14,6 @@
#include <egami/Image.h>
#include <egami/ImageMono.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/Resource.h>
namespace ewol {
namespace resource {

View File

@ -1,193 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resource/Manager.h>
#include <ewol/resource/FontFreeType.h>
#include <ewol/ewol.h>
#include <ewol/openGL/openGL.h>
#include <ewol/context/Context.h>
ewol::resource::Manager::Manager() :
m_contextHasBeenRemoved(true) {
// nothing to do ...
}
ewol::resource::Manager::~Manager() {
bool hasError = false;
if (m_resourceListToUpdate.size()!=0) {
EWOL_ERROR("Must not have anymore resources to update !!!");
hasError = true;
}
// TODO : Remove unneeded elements
if (m_resourceList.size()!=0) {
EWOL_ERROR("Must not have anymore resources !!!");
hasError = true;
}
if (true == hasError) {
EWOL_ERROR("Check if the function UnInit has been called !!!");
}
}
void ewol::resource::Manager::unInit() {
display();
m_resourceListToUpdate.clear();
// remove all resources ...
auto it(m_resourceList.begin());
while(it != m_resourceList.end()) {
std::shared_ptr<ewol::Resource> tmpRessource = (*it).lock();
if (tmpRessource != nullptr) {
EWOL_WARNING("Find a resource that is not removed : [" << tmpRessource->getId() << "]"
<< "=\"" << tmpRessource->getName() << "\" "
<< tmpRessource.use_count() << " elements");
}
m_resourceList.erase(it);
it = m_resourceList.begin();
}
m_resourceList.clear();
}
void ewol::resource::Manager::display() {
EWOL_INFO("Resources loaded : ");
// remove all resources ...
for (auto &it : m_resourceList) {
std::shared_ptr<ewol::Resource> tmpRessource = it.lock();
if (tmpRessource != nullptr) {
EWOL_INFO(" [" << tmpRessource->getId() << "]"
<< tmpRessource->getObjectType()
<< "=\"" << tmpRessource->getName() << "\" "
<< tmpRessource.use_count() << " elements");
}
}
EWOL_INFO("Resources ---");
}
void ewol::resource::Manager::reLoadResources() {
EWOL_INFO("------------- Resources re-loaded -------------");
// remove all resources ...
if (m_resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
EWOL_INFO(" Reload level : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (auto &it : m_resourceList) {
std::shared_ptr<ewol::Resource> tmpRessource = it.lock();
if(tmpRessource != nullptr) {
if (jjj == tmpRessource->getResourceLevel()) {
tmpRessource->reload();
EWOL_INFO(" [" << tmpRessource->getId() << "]="<< tmpRessource->getObjectType());
}
}
}
}
}
// TODO : UNderstand why it is set here ...
//ewol::requestUpdateSize();
EWOL_INFO("------------- Resources -------------");
}
void ewol::resource::Manager::update(const std::shared_ptr<ewol::Resource>& _object) {
// chek if not added before
for (auto &it : m_resourceListToUpdate) {
if ( it != nullptr
&& it == _object) {
// just prevent some double add ...
return;
}
}
// add it ...
m_resourceListToUpdate.push_back(_object);
}
// Specific to load or update the data in the openGl context == > system use only
void ewol::resource::Manager::updateContext() {
if (m_contextHasBeenRemoved == true) {
// need to update all ...
m_contextHasBeenRemoved = false;
if (m_resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
EWOL_INFO(" updateContext level (D) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (auto &it : m_resourceList) {
std::shared_ptr<ewol::Resource> tmpRessource = it.lock();
if( tmpRessource != nullptr
&& jjj == tmpRessource->getResourceLevel()) {
//EWOL_DEBUG("Update context named : " << l_resourceList[iii]->getName());
tmpRessource->updateContext();
}
}
}
}
} else {
if (m_resourceListToUpdate.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
EWOL_INFO(" updateContext level (U) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (auto &it : m_resourceListToUpdate) {
if ( it != nullptr
&& jjj == it->getResourceLevel()) {
it->updateContext();
}
}
}
}
}
// Clean the update list
m_resourceListToUpdate.clear();
}
// in this case, it is really too late ...
void ewol::resource::Manager::contextHasBeenDestroyed() {
for (auto &it : m_resourceList) {
std::shared_ptr<ewol::Resource> tmpRessource = it.lock();
if (tmpRessource != nullptr) {
tmpRessource->removeContextToLate();
}
}
// no context preent ...
m_contextHasBeenRemoved = true;
}
// internal generic keeper ...
std::shared_ptr<ewol::Resource> ewol::resource::Manager::localKeep(const std::string& _filename) {
EWOL_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources");
for (auto &it : m_resourceList) {
std::shared_ptr<ewol::Resource> tmpRessource = it.lock();
if (tmpRessource != nullptr) {
if (tmpRessource->getName() == _filename) {
return tmpRessource;
}
}
}
return nullptr;
}
// internal generic keeper ...
void ewol::resource::Manager::localAdd(const std::shared_ptr<ewol::Resource>& _object) {
//Add ... find empty slot
for (auto &it : m_resourceList) {
std::shared_ptr<ewol::Resource> tmpRessource = it.lock();
if (tmpRessource == nullptr) {
it = _object;
return;
}
}
// add at the end if no slot is free
m_resourceList.push_back(_object);
}
// in case of error ...
void ewol::resource::Manager::cleanInternalRemoved() {
//EWOL_INFO("remove object in Manager");
updateContext();
for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) {
if ((*it).expired() == true) {
m_resourceList.erase(it);
it = m_resourceList.begin();
}
}
}

View File

@ -1,72 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __RESOURCES_MANAGER_H__
#define __RESOURCES_MANAGER_H__
#include <list>
#include <vector>
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resource/Resource.h>
namespace ewol {
namespace resource {
class Manager{
private:
std::list<std::weak_ptr<ewol::Resource>> m_resourceList;
std::vector<std::shared_ptr<ewol::Resource>> m_resourceListToUpdate;
bool m_contextHasBeenRemoved;
public:
/**
* @brief initialize the internal variable
*/
Manager();
/**
* @brief Uninitiamize the resource manager, free all resources previously requested
* @note when not free == > generate warning, because the segfault can appear after...
*/
virtual ~Manager();
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
void unInit();
/**
* @brief display in the log all the resources loaded ...
*/
void display();
/**
* @brief Reload all resources from files, and send there in openGL card if needed.
* @note If file is reference at THEME:XXX:filename if the Theme change the file will reload the newOne
*/
void reLoadResources();
/**
* @brief Call by the system to send all the needed data on the graphic card chen they change ...
* @param[in] _object The resources that might be updated
*/
void update(const std::shared_ptr<ewol::Resource>& _object);
/**
* @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other ....
*/
void updateContext();
/**
* @brief This is to inform the resources manager that we have no more openGl context ...
*/
void contextHasBeenDestroyed();
public:
// internal API to extent eResources in extern Soft
std::shared_ptr<ewol::Resource> localKeep(const std::string& _filename);
void localAdd(const std::shared_ptr<ewol::Resource>& _object);
virtual void cleanInternalRemoved();
};
};
};
#endif

View File

@ -1,42 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resource/Resource.h>
#include <ewol/resource/Manager.h>
#include <ewol/ewol.h>
#include <ewol/context/Context.h>
void ewol::Resource::init() {
ewol::Object::init();
}
void ewol::Resource::init(const std::string& _name) {
ewol::Object::init(_name);
}
void ewol::Resource::updateContext() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)");
}
void ewol::Resource::removeContext() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)");
}
void ewol::Resource::removeContextToLate() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)");
}
void ewol::Resource::reload() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)");
}
ewol::resource::Manager& ewol::Resource::getManager() {
return ewol::getContext().getResourcesManager();
}

View File

@ -1,166 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __RESOURCES_H__
#define __RESOURCES_H__
#include <etk/types.h>
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/object/Object.h>
#define MAX_RESOURCE_LEVEL (5)
#define DECLARE_RESOURCE_FACTORY(className) \
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
std::shared_ptr<className> object(new className()); \
if (object == nullptr) { \
EWOL_ERROR("Factory resource error"); \
return nullptr; \
} \
object->init(std::forward<T>(all)... ); \
if (object->objectHasBeenCorectlyInit() == false) { \
EWOL_CRITICAL("Object Is not correctly init : " << #className ); \
} \
getManager().localAdd(object); \
return object; \
}
#define DECLARE_RESOURCE_NAMED_FACTORY(className) \
template<typename ... T> static std::shared_ptr<className> create(const std::string& _name, T&& ... all ) { \
std::shared_ptr<className> object; \
std::shared_ptr<ewol::Resource> object2; \
if (_name != "" && _name != "---") { \
object2 = getManager().localKeep(_name); \
} \
if (object2 != nullptr) { \
object = std::dynamic_pointer_cast<className>(object2); \
if (object == nullptr) { \
EWOL_CRITICAL("Request resource file : '" << _name << "' With the wrong type (dynamic cast error)"); \
return nullptr; \
} \
} \
if (object != nullptr) { \
return object; \
} \
object = std::shared_ptr<className>(new className()); \
if (object == nullptr) { \
EWOL_ERROR("allocation error of a resource : " << _name); \
return nullptr; \
} \
object->init(_name, std::forward<T>(all)... ); \
if (object->objectHasBeenCorectlyInit() == false) { \
EWOL_CRITICAL("Object Is not correctly init : " << #className ); \
} \
getManager().localAdd(object); \
return object; \
}
#define DECLARE_RESOURCE_SINGLE_FACTORY(className,uniqueName) \
template<typename ... T> static std::shared_ptr<className> create(T&& ... all ) { \
std::shared_ptr<className> object; \
std::shared_ptr<ewol::Resource> object2 = getManager().localKeep(uniqueName); \
if (object2 != nullptr) { \
object = std::dynamic_pointer_cast<className>(object2); \
if (object == nullptr) { \
EWOL_CRITICAL("Request resource file : '" << uniqueName << "' With the wrong type (dynamic cast error)"); \
return nullptr; \
} \
} \
if (object != nullptr) { \
return object; \
} \
object = std::shared_ptr<className>(new className()); \
if (object == nullptr) { \
EWOL_ERROR("allocation error of a resource : " << uniqueName); \
return nullptr; \
} \
object->init(uniqueName, std::forward<T>(all)... ); \
if (object->objectHasBeenCorectlyInit() == false) { \
EWOL_CRITICAL("Object Is not correctly init : " << #className ); \
} \
getManager().localAdd(object); \
return object; \
}
namespace ewol {
namespace resource {
class Manager;
};
/**
* @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 {
protected:
/**
* @brief generic protected contructor (use factory to create this class)
*/
Resource() :
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
/**
* @brief Initialisation of the class and previous classes.
* @param[in] _name Name of the resource.
*/
void init();
//! @previous
void init(const std::string& _name);
public:
//! geenric destructor
virtual ~Resource() {
};
protected:
uint8_t m_resourceLevel; //!< Level of the resource ==> for update priority [0..5] 0 must be update first.
public:
/**
* @brief Get the current resource level;
* @return value in [0..5]
*/
uint8_t getResourceLevel() {
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();
/**
* @brief The current OpenGl context is removing ==> remove yout own system data
*/
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();
/**
* @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ...
*/
virtual void reload();
protected:
/**
* @brief Get the current resource Manager
*/
static ewol::resource::Manager& getManager();
};
};
#include <ewol/resource/Manager.h>
#endif

108
ewol/resource/Texture.cpp Normal file
View File

@ -0,0 +1,108 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <gale/renderer/openGL/openGL.h>
#include <gale/renderer/openGL/openGL-include.h>
#include <gale/resource/Manager.h>
#include <ewol/resource/Texture.h>
#undef __class__
#define __class__ "resource::Texture"
/**
* @brief get the next power 2 if the input
* @param[in] value Value that we want the next power of 2
* @return result value
*/
static int32_t nextP2(int32_t _value) {
int32_t val=1;
for (int32_t iii=1; iii<31; iii++) {
if (_value <= val) {
return val;
}
val *=2;
}
EWOL_CRITICAL("impossible CASE....");
return val;
}
void ewol::resource::Texture::init(const std::string& _filename) {
gale::Resource::init(_filename);
}
void ewol::resource::Texture::init() {
gale::Resource::init();
}
ewol::resource::Texture::Texture() {
addResourceType("ewol::compositing::Texture");
m_loaded = false;
m_texId = 0;
m_endPointSize.setValue(1.0,1.0);
}
ewol::resource::Texture::~Texture() {
removeContext();
}
void ewol::resource::Texture::updateContext() {
if (false == m_loaded) {
// Request a new texture at openGl :
glGenTextures(1, &m_texId);
}
// in all case we set the texture properties :
// TODO : check error ???
glBindTexture(GL_TEXTURE_2D, m_texId);
// TODO : Check error ???
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
//--- mode nearest
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//--- Mode linear
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" <<m_texId);
glTexImage2D(GL_TEXTURE_2D, // Target
0, // Level
GL_RGBA, // Format internal
m_data.getWidth(),
m_data.getHeight(),
0, // Border
GL_RGBA, // format
GL_UNSIGNED_BYTE, // type
m_data.getTextureDataPointer() );
// now the data is loaded
m_loaded = true;
}
void ewol::resource::Texture::removeContext() {
if (true == m_loaded) {
// Request remove texture ...
EWOL_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
glDeleteTextures(1, &m_texId);
m_loaded = false;
}
}
void ewol::resource::Texture::removeContextToLate() {
m_loaded = false;
m_texId=0;
}
void ewol::resource::Texture::flush() {
// request to the manager to be call at the next update ...
getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this()));
}
void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
m_data.resize(_newSize);
}

52
ewol/resource/Texture.h Normal file
View File

@ -0,0 +1,52 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#ifndef __EWOL_TEXTURE_H__
#define __EWOL_TEXTURE_H__
#include <etk/types.h>
#include <ewol/debug.h>
#include <egami/Image.h>
#include <gale/resource/Texture.h>
namespace ewol {
namespace resource {
class Texture : public gale::resource::Texture {
protected:
// openGl Context propoerties :
egami::Image m_data;
// some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0
vec2 m_endPointSize;
// internal state of the openGl system :
bool m_loaded;
// Public API:
protected:
void init(const std::string& _filename);
void init();
Texture();
public:
DECLARE_RESOURCE_FACTORY(Texture);
virtual ~Texture();
public:
// you must set the size here, because it will be set in multiple of pow(2)
void setImageSize(ivec2 newSize);
// get the reference on this image to draw nomething on it ...
inline egami::Image& get() {
return m_data;
};
// flush the data to send it at the openGl system
void flush();
void updateContext();
void removeContext();
void removeContextToLate();
};
};
};
#endif

View File

@ -10,7 +10,7 @@
#include <etk/os/FSNode.h>
#include <egami/egami.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ewol/resource/font/FontBase.h>
#include <ewol/resource/TexturedFont.h>
@ -43,7 +43,7 @@ std::ostream& ewol::operator <<(std::ostream& _os, enum ewol::font::mode _obj) {
#define __class__ "resource::TexturedFont"
ewol::resource::TexturedFont::TexturedFont() {
addObjectType("ewol::resource::TexturedFont");
addResourceType("ewol::resource::TexturedFont");
}
void ewol::resource::TexturedFont::init(const std::string& _fontName) {

View File

@ -11,7 +11,6 @@
#include <ewol/resource/font/FontBase.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/Resource.h>
namespace ewol {
namespace font {

View File

@ -14,19 +14,19 @@
#include <egami/Image.h>
#include <egami/ImageMono.h>
#include <ewol/resource/Texture.h>
#include <ewol/resource/Resource.h>
#include <gale/resource/Resource.h>
#include <ewol/resource/font/GlyphProperty.h>
namespace ewol {
namespace resource {
class FontBase : public ewol::Resource {
class FontBase : public gale::Resource {
public:
FontBase() {
addObjectType("ewol::FontFreeType");
addResourceType("ewol::FontFreeType");
}
void init(const std::string& _fontName) {
ewol::Resource::init(_fontName);
gale::Resource::init(_fontName);
};
virtual ~FontBase() { };

View File

@ -101,8 +101,8 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
if(ewol::widget::Button::lockAccess == m_lock) {
return false;
}
if( ewol::key::statusLeave == _event.getStatus()
|| ewol::key::statusAbort == _event.getStatus()) {
if( gale::key::status_leave == _event.getStatus()
|| gale::key::status_abort == _event.getStatus()) {
m_mouseHover = false;
m_buttonPressed = false;
} else {
@ -121,19 +121,19 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
EWOL_VERBOSE("Event on BT ... mouse hover : " << m_mouseHover);
if (true == m_mouseHover) {
if (1 == _event.getId()) {
if(ewol::key::statusDown == _event.getStatus()) {
if(gale::key::status_down == _event.getStatus()) {
EWOL_VERBOSE(getName() << " : Generate event : " << signalDown);
signalDown.emit();
m_buttonPressed = true;
markToRedraw();
}
if(ewol::key::statusUp == _event.getStatus()) {
if(gale::key::status_up == _event.getStatus()) {
EWOL_VERBOSE(getName() << " : Generate event : " << signalUp);
signalUp.emit();
m_buttonPressed = false;
markToRedraw();
}
if(ewol::key::statusSingle == _event.getStatus()) {
if(gale::key::status_single == _event.getStatus()) {
if( ( m_value.get() == true
&& ewol::widget::Button::lockWhenPressed == m_lock)
|| ( m_value.get() == false
@ -165,8 +165,8 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( _event.getType() == ewol::key::keyboardChar
&& _event.getStatus() == ewol::key::statusDown
if( _event.getType() == gale::key::keyboard_char
&& _event.getStatus() == gale::key::status_down
&& _event.getChar() == '\r') {
signalEnter.emit();
return true;

View File

@ -137,7 +137,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() {
bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
bool previousHoverState = m_mouseHover;
if(ewol::key::statusLeave == _event.getStatus()) {
if(gale::key::status_leave == _event.getStatus()) {
m_mouseHover = false;
m_buttonPressed = false;
} else {
@ -157,15 +157,15 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
//EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover);
if (true == m_mouseHover) {
if (1 == _event.getId()) {
if(ewol::key::statusDown == _event.getStatus()) {
if(gale::key::status_down == _event.getStatus()) {
m_buttonPressed = true;
markToRedraw();
}
if(ewol::key::statusUp == _event.getStatus()) {
if(gale::key::status_up == _event.getStatus()) {
m_buttonPressed = false;
markToRedraw();
}
if(ewol::key::statusSingle == _event.getStatus()) {
if(gale::key::status_single == _event.getStatus()) {
m_buttonPressed = false;
m_mouseHover = false;
// create a context menu :

View File

@ -105,8 +105,8 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) {
EWOL_VERBOSE("Event on BT : " << _event);
bool previousHoverState = m_mouseHover;
if( ewol::key::statusLeave == _event.getStatus()
|| ewol::key::statusAbort == _event.getStatus()) {
if( gale::key::status_leave == _event.getStatus()
|| gale::key::status_abort == _event.getStatus()) {
m_mouseHover = false;
m_buttonPressed = false;
} else {
@ -126,19 +126,19 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) {
EWOL_VERBOSE("Event on BT ... mouse hover : " << m_mouseHover);
if (true == m_mouseHover) {
if (1 == _event.getId()) {
if(ewol::key::statusDown == _event.getStatus()) {
if(gale::key::status_down == _event.getStatus()) {
EWOL_VERBOSE(getName() << " : Generate event : " << signalDown);
signalDown.emit();
m_buttonPressed = true;
markToRedraw();
}
if(ewol::key::statusUp == _event.getStatus()) {
if(gale::key::status_up == _event.getStatus()) {
EWOL_VERBOSE(getName() << " : Generate event : " << signalUp);
signalUp.emit();
m_buttonPressed = false;
markToRedraw();
}
if(ewol::key::statusSingle == _event.getStatus()) {
if(gale::key::status_single == _event.getStatus()) {
// inverse value :
setValue((m_value)?false:true);
EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed);
@ -159,8 +159,8 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) {
bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( _event.getType() == ewol::key::keyboardChar
&& _event.getStatus() == ewol::key::statusDown
if( _event.getType() == gale::key::keyboard_char
&& _event.getStatus() == gale::key::status_down
&& _event.getChar() == '\r') {
signalEnter.emit();
return true;

View File

@ -170,8 +170,8 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) {
if (1 == _event.getId()) {
relativePos.setValue( std::avg(0.0f, m_size.x(),relativePos.x()),
std::avg(0.0f, m_size.y(),relativePos.y()) );
if( ewol::key::statusSingle == _event.getStatus()
|| ewol::key::statusMove == _event.getStatus()) {
if( gale::key::status_single == _event.getStatus()
|| gale::key::status_move == _event.getStatus()) {
// nothing to do ...
m_currentUserPos.setValue( relativePos.x()/m_size.x(),
relativePos.y()/m_size.y() );

View File

@ -204,12 +204,12 @@ bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) {
if (nullptr != ewol::widget::Container::getWidgetAtPos(_event.getPos())) {
return false;
}
if( _event.getStatus() == ewol::key::statusDown
|| _event.getStatus() == ewol::key::statusMove
|| _event.getStatus() == ewol::key::statusSingle
|| _event.getStatus() == ewol::key::statusUp
|| _event.getStatus() == ewol::key::statusEnter
|| _event.getStatus() == ewol::key::statusLeave ) {
if( _event.getStatus() == gale::key::status_down
|| _event.getStatus() == gale::key::status_move
|| _event.getStatus() == gale::key::status_single
|| _event.getStatus() == gale::key::status_up
|| _event.getStatus() == gale::key::status_enter
|| _event.getStatus() == gale::key::status_leave ) {
// Auto-remove ...
autoDestroy();
return true;

View File

@ -234,7 +234,7 @@ void ewol::widget::Entry::removeSelected() {
}
void ewol::widget::Entry::copySelectionToClipBoard(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
void ewol::widget::Entry::copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID) {
if (m_displayCursorPosSelection == m_displayCursorPos) {
// nothing to cut ...
return;
@ -247,19 +247,19 @@ void ewol::widget::Entry::copySelectionToClipBoard(enum ewol::context::clipBoard
}
// Copy
std::string tmpData = std::string(m_data, pos1, pos2);
ewol::context::clipBoard::set(_clipboardID, tmpData);
gale::context::clipBoard::set(_clipboardID, tmpData);
}
bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) {
//EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput);
if (1 == _event.getId()) {
if (ewol::key::statusSingle == _event.getStatus()) {
if (gale::key::status_single == _event.getStatus()) {
keepFocus();
signalClick.emit();
//nothing to do ...
return true;
} else if (ewol::key::statusDouble == _event.getStatus()) {
} else if (gale::key::status_double == _event.getStatus()) {
keepFocus();
// select word
m_displayCursorPosSelection = m_displayCursorPos-1;
@ -302,42 +302,42 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) {
}
}
// Copy to clipboard Middle ...
copySelectionToClipBoard(ewol::context::clipBoard::clipboardSelection);
copySelectionToClipBoard(gale::context::clipBoard::clipboardSelection);
markToRedraw();
} else if (ewol::key::statusTriple == _event.getStatus()) {
} else if (gale::key::status_triple == _event.getStatus()) {
keepFocus();
m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data->size();
} else if (ewol::key::statusDown == _event.getStatus()) {
} else if (gale::key::status_down == _event.getStatus()) {
keepFocus();
updateCursorPosition(_event.getPos());
markToRedraw();
} else if (ewol::key::statusMove == _event.getStatus()) {
} else if (gale::key::status_move == _event.getStatus()) {
keepFocus();
updateCursorPosition(_event.getPos(), true);
markToRedraw();
} else if (ewol::key::statusUp == _event.getStatus()) {
} else if (gale::key::status_up == _event.getStatus()) {
keepFocus();
updateCursorPosition(_event.getPos(), true);
// Copy to clipboard Middle ...
copySelectionToClipBoard(ewol::context::clipBoard::clipboardSelection);
copySelectionToClipBoard(gale::context::clipBoard::clipboardSelection);
markToRedraw();
}
}
else if( ewol::key::typeMouse == _event.getType()
else if( gale::key::type_mouse == _event.getType()
&& _event.getId() == 2) {
if( _event.getStatus() == ewol::key::statusDown
|| _event.getStatus() == ewol::key::statusMove
|| _event.getStatus() == ewol::key::statusUp) {
if( _event.getStatus() == gale::key::status_down
|| _event.getStatus() == gale::key::status_move
|| _event.getStatus() == gale::key::status_up) {
keepFocus();
// updatethe cursor position :
updateCursorPosition(_event.getPos());
}
// Paste current selection only when up button
if (_event.getStatus() == ewol::key::statusUp) {
if (_event.getStatus() == gale::key::status_up) {
keepFocus();
// middle button => past data...
ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardSelection);
gale::context::clipBoard::request(gale::context::clipBoard::clipboardSelection);
}
}
return false;
@ -345,8 +345,8 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) {
bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) {
if (_event.getType() == ewol::key::keyboardChar) {
if(_event.getStatus() == ewol::key::statusDown) {
if (_event.getType() == gale::key::keyboard_char) {
if(_event.getStatus() == gale::key::status_down) {
// remove curent selected data ...
removeSelected();
if( _event.getChar() == '\n'
@ -387,19 +387,19 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) {
}
return false;
} else {
if(_event.getStatus() == ewol::key::statusDown) {
if(_event.getStatus() == gale::key::status_down) {
switch (_event.getType())
{
case ewol::key::keyboardLeft:
case gale::key::keyboard_left:
m_displayCursorPos--;
break;
case ewol::key::keyboardRight:
case gale::key::keyboard_right:
m_displayCursorPos++;
break;
case ewol::key::keyboardStart:
case gale::key::keyboard_start:
m_displayCursorPos = 0;
break;
case ewol::key::keyboardEnd:
case gale::key::keyboard_end:
m_displayCursorPos = m_data->size();
break;
default:
@ -437,7 +437,7 @@ void ewol::widget::Entry::setInternalValue(const std::string& _newData) {
markToRedraw();
}
void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
void ewol::widget::Entry::onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID) {
// remove curent selected data ...
removeSelected();
// get current selection / Copy :
@ -469,17 +469,17 @@ void ewol::widget::Entry::onCallbackEntryClean() {
}
void ewol::widget::Entry::onCallbackCut() {
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
copySelectionToClipBoard(gale::context::clipBoard::clipboardStd);
removeSelected();
signalModify.emit(m_data);
}
void ewol::widget::Entry::onCallbackCopy() {
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
copySelectionToClipBoard(gale::context::clipBoard::clipboardStd);
}
void ewol::widget::Entry::onCallbackPaste() {
ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd);
gale::context::clipBoard::request(gale::context::clipBoard::clipboardStd);
}
void ewol::widget::Entry::onCallbackSelect(bool _all) {

View File

@ -140,7 +140,7 @@ namespace ewol {
* @brief Copy the selected data on the specify clipboard
* @param[in] _clipboardID Selected clipboard
*/
virtual void copySelectionToClipBoard(enum ewol::context::clipBoard::clipboardListe _clipboardID);
virtual void copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID);
/**
* @brief remove the selected area
* @note This request a regeneration of the display
@ -167,7 +167,7 @@ namespace ewol {
virtual void onRegenerateDisplay();
virtual bool onEventInput(const ewol::event::Input& _event);
virtual bool onEventEntry(const ewol::event::Entry& _event);
virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID);
virtual void onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID);
virtual void calculateMinMaxSize();
protected: // Derived function
virtual void onDraw();

View File

@ -34,7 +34,7 @@ ewol::widget::Image::Image() :
}
}
void ewol::widget::Image::init(const std::string& _file, const ewol::Dimension& _border) {
void ewol::widget::Image::init(const std::string& _file, const gale::Dimension& _border) {
ewol::Widget::init();
set(_file, _border);
}
@ -44,7 +44,7 @@ ewol::widget::Image::~Image() {
}
void ewol::widget::Image::set(const std::string& _file, const ewol::Dimension& _border) {
void ewol::widget::Image::set(const std::string& _file, const gale::Dimension& _border) {
EWOL_VERBOSE("Set Image : " << _file << " border=" << _border);
m_border.set(_border);
m_fileName.set(_file);
@ -132,7 +132,7 @@ void ewol::widget::Image::calculateMinMaxSize() {
bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) {
//EWOL_DEBUG("Event on BT ...");
if (_event.getId() == 1) {
if(ewol::key::statusSingle == _event.getStatus()) {
if(gale::key::status_single == _event.getStatus()) {
signalPressed.emit();
return true;
}

View File

@ -37,7 +37,7 @@ namespace ewol {
*/
Image();
void init(const std::string& _file="",
const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
const gale::Dimension& _border=gale::Dimension(vec2(0,0),gale::Dimension::Millimeter));
public:
DECLARE_WIDGET_FACTORY(Image, "Image");
/**
@ -49,7 +49,7 @@ namespace ewol {
* @param[in] _file Filaneme of the new image
* @param[in] _border New border size to set
*/
void set(const std::string& _file, const ewol::Dimension& _border);
void set(const std::string& _file, const gale::Dimension& _border);
protected:
ewol::parameter::Value<std::string> m_fileName; //!< file name of the image.
public:
@ -68,33 +68,33 @@ namespace ewol {
return m_fileName;
};
protected:
ewol::parameter::Value<ewol::Dimension> m_border; //!< border to add at the image.
ewol::parameter::Value<gale::Dimension> m_border; //!< border to add at the image.
public:
/**
* @brief set tge Border size around the image
* @param[in] _border New border size to set
*/
void setBorder(const ewol::Dimension& _border);
void setBorder(const gale::Dimension& _border);
/**
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getBorder() const {
const gale::Dimension& getBorder() const {
return m_border;
};
protected:
ewol::parameter::Value<ewol::Dimension> m_imageSize; //!< border to add at the image.
ewol::parameter::Value<gale::Dimension> m_imageSize; //!< border to add at the image.
public:
/**
* @brief set tge Border size around the image
* @param[in] _size New border size to set
*/
void setImageSize(const ewol::Dimension& _size);
void setImageSize(const gale::Dimension& _size);
/**
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getImageSize() const {
const gale::Dimension& getImageSize() const {
return m_imageSize;
};
protected:

View File

@ -117,8 +117,8 @@ Tangent Function: tan(teta) = Opposite / Adjacent
bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
/*
if (1 == IdInput) {
if( ewol::key::statusDown == typeEvent
|| ewol::key::statusMove == typeEvent) {
if( gale::key::status_down == typeEvent
|| gale::key::status_move == typeEvent) {
// get local relative position
vec2 relativePos = relativePosition(pos);
float sizeElement = m_size.x*m_ratio;
@ -143,7 +143,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
m_displayPos.y = sin(m_angle)*m_distance;
}
markToRedraw();
if(ewol::key::statusDown == typeEvent) {
if(gale::key::status_down == typeEvent) {
signalEnable.emit();
} else {
std::string tmp = std::string("distance=") + std::string(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2);
@ -152,7 +152,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
//teta += M_PI/2;
//EWOL_DEBUG("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance);
return true;
} else if( ewol::key::statusUp == typeEvent) {
} else if( gale::key::status_up == typeEvent) {
if( true == m_lock
&& m_distance == 1) {
// nothing to do ...

View File

@ -122,7 +122,7 @@ void ewol::widget::Label::onRegenerateDisplay() {
bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) {
//EWOL_DEBUG("Event on Label ...");
if (1 == _event.getId()) {
if (ewol::key::statusSingle == _event.getStatus()) {
if (gale::key::status_single == _event.getStatus()) {
// nothing to do ...
signalPressed.emit();
return true;

View File

@ -68,7 +68,7 @@ namespace ewol {
}
return false;
};
virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) {
virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) {
return false;
}
/**

View File

@ -159,7 +159,7 @@ bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std
bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
enum ewol::key::status _typeEvent,
enum gale::key::status _typeEvent,
int32_t _colomn,
int32_t _raw,
float _x,
@ -172,7 +172,7 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
offset = 2;
}
}
if (_typeEvent == ewol::key::statusSingle) {
if (_typeEvent == gale::key::status_single) {
EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
if (1 == _IdInput) {
int32_t previousRaw = m_selectedLine;

View File

@ -44,7 +44,7 @@ namespace ewol {
virtual bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
virtual uint32_t getNuberOfRaw();
virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
protected:
std::vector<etk::FSNode *> m_list; //!< List of all element in the path. (they are filtered)
/**

View File

@ -29,7 +29,7 @@ ewol::widget::PopUp::PopUp() :
void ewol::widget::PopUp::init(const std::string& _shaperName) {
ewol::widget::Container::init();
m_shaper.setString(_shaperName);
setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
setMinSize(gale::Dimension(vec2(80,80),gale::Dimension::Pourcent));
m_userExpand.set(bvec2(false, false));
}
ewol::widget::PopUp::~PopUp() {

View File

@ -20,7 +20,7 @@ ewol::widget::Scroll::Scroll() :
m_highSpeedStartPos(0,0),
m_highSpeedMode(speedModeDisable),
m_highSpeedButton(-1),
m_highSpeedType(ewol::key::typeUnknow) {
m_highSpeedType(gale::key::type_unknow) {
addObjectType("ewol::widget::Scroll");
}
@ -113,7 +113,7 @@ void ewol::widget::Scroll::onRegenerateDisplay() {
bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
//ewol::event::Input _event = event;
//_event.setType(ewol::key::typeFinger);
//_event.setType(gale::key::type_finger);
vec2 relativePos = relativePosition(_event.getPos());
vec2 scrollOffset(0,0);
vec2 scrollSize(0,0);
@ -123,17 +123,17 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
}
EWOL_VERBOSE("Get Event on scroll : " << _event);
relativePos.setY(m_size.y() - relativePos.y());
if( _event.getType() == ewol::key::typeMouse
&& ( ewol::key::typeUnknow == m_highSpeedType
|| ewol::key::typeMouse == m_highSpeedType ) ) {
if( _event.getType() == gale::key::type_mouse
&& ( gale::key::type_unknow == m_highSpeedType
|| gale::key::type_mouse == m_highSpeedType ) ) {
if( _event.getId() == 1
&& _event.getStatus() == ewol::key::statusDown) {
&& _event.getStatus() == gale::key::status_down) {
// check if selected the scrolling position whth the scrolling bar ...
if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) {
if( m_size.y() < scrollSize.y()
|| scrollOffset.y() != 0) {
m_highSpeedMode = speedModeEnableVertical;
m_highSpeedType = ewol::key::typeMouse;
m_highSpeedType = gale::key::type_mouse;
m_highSpeedStartPos.setX(relativePos.x());
m_highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (m_size.y()-SCROLL_BAR_SPACE*2));
m_highSpeedButton = 1;
@ -150,7 +150,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
if( m_size.x() < scrollSize.x()
|| scrollOffset.x()!=0) {
m_highSpeedMode = speedModeEnableHorizontal;
m_highSpeedType = ewol::key::typeMouse;
m_highSpeedType = gale::key::type_mouse;
m_highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (m_size.x()-SCROLL_BAR_SPACE*2));
m_highSpeedStartPos.setY(relativePos.y());
m_highSpeedButton = 1;
@ -166,7 +166,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
}
return false;
} else if( _event.getId() == 4
&& _event.getStatus() == ewol::key::statusUp) {
&& _event.getStatus() == gale::key::status_up) {
if(m_size.y() < scrollSize.y()) {
scrollOffset.setY(scrollOffset.y()-m_pixelScrolling);
scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y())));
@ -177,7 +177,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
} else if( _event.getId() == 5
&& _event.getStatus() == ewol::key::statusUp) {
&& _event.getStatus() == gale::key::status_up) {
if(m_size.y() < scrollSize.y()) {
scrollOffset.setY(scrollOffset.y()+m_pixelScrolling);
scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y())));
@ -188,28 +188,28 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
}else if (_event.getId() == 2) {
if (_event.getStatus() == ewol::key::statusDown) {
if (_event.getStatus() == gale::key::status_down) {
m_highSpeedMode = speedModeInit;
m_highSpeedType = ewol::key::typeMouse;
m_highSpeedType = gale::key::type_mouse;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
m_highSpeedButton = 2;
// not really use... == > just keep some informations
return false;
}
} else if( m_highSpeedMode != speedModeDisable
&& _event.getStatus() == ewol::key::statusLeave) {
&& _event.getStatus() == gale::key::status_leave) {
m_highSpeedMode = speedModeDisable;
m_highSpeedType = ewol::key::typeUnknow;
m_highSpeedType = gale::key::type_unknow;
markToRedraw();
return true;
}
if ( _event.getId() == m_highSpeedButton
&& m_highSpeedMode != speedModeDisable) {
if (_event.getStatus() == ewol::key::statusUp) {
if (_event.getStatus() == gale::key::status_up) {
if (m_highSpeedMode == speedModeInit) {
// TODO : generate back the down event ...
m_highSpeedMode = speedModeDisable;
m_highSpeedType = ewol::key::typeUnknow;
m_highSpeedType = gale::key::type_unknow;
return false;
} else {
m_highSpeedMode = speedModeGrepEndEvent;
@ -217,15 +217,15 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
} else if (m_highSpeedMode == speedModeGrepEndEvent) {
if (_event.getStatus() == ewol::key::statusSingle) {
if (_event.getStatus() == gale::key::status_single) {
m_highSpeedMode = speedModeDisable;
m_highSpeedType = ewol::key::typeUnknow;
m_highSpeedType = gale::key::type_unknow;
m_highSpeedButton = -1;
markToRedraw();
}
return true;
} else if( m_highSpeedMode == speedModeInit
&& _event.getStatus() == ewol::key::statusMove) {
&& _event.getStatus() == gale::key::status_move) {
// wait that the cursor move more than 10 px to enable it :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
@ -257,7 +257,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
if( m_highSpeedMode == speedModeEnableHorizontal
&& _event.getStatus() == ewol::key::statusMove) {
&& _event.getStatus() == gale::key::status_move) {
scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2)));
scrollOffset.setX(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit->x() )));
markToRedraw();
@ -267,7 +267,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
if( m_highSpeedMode == speedModeEnableVertical
&& _event.getStatus() == ewol::key::statusMove) {
&& _event.getStatus() == gale::key::status_move) {
scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2)));
scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->x())));
markToRedraw();
@ -277,25 +277,25 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
}
} else if( ewol::key::typeFinger == _event.getType()
&& ( ewol::key::typeUnknow == m_highSpeedType
|| ewol::key::typeFinger == m_highSpeedType ) ) {
} else if( gale::key::type_finger == _event.getType()
&& ( gale::key::type_unknow == m_highSpeedType
|| gale::key::type_finger == m_highSpeedType ) ) {
if (1 == _event.getId()) {
EWOL_VERBOSE("event: " << _event);
if (ewol::key::statusDown == _event.getStatus()) {
if (gale::key::status_down == _event.getStatus()) {
m_highSpeedMode = speedModeInit;
m_highSpeedType = ewol::key::typeFinger;
m_highSpeedType = gale::key::type_finger;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
EWOL_VERBOSE("SCROOL == > INIT pos=" << m_highSpeedStartPos << " && curent scrollOffset=" << scrollOffset);
return true;
} else if (ewol::key::statusUpAfter == _event.getStatus()) {
} else if (gale::key::status_upAfter == _event.getStatus()) {
m_highSpeedMode = speedModeDisable;
m_highSpeedType = ewol::key::typeUnknow;
m_highSpeedType = gale::key::type_unknow;
EWOL_VERBOSE("SCROOL == > DISABLE");
markToRedraw();
return true;
} else if ( m_highSpeedMode == speedModeInit
&& ewol::key::statusMove == _event.getStatus()) {
&& gale::key::status_move == _event.getStatus()) {
// wait that the cursor move more than 10 px to enable it :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
@ -308,7 +308,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
if ( m_highSpeedMode == speedModeEnableFinger
&& ewol::key::statusMove == _event.getStatus()) {
&& gale::key::status_move == _event.getStatus()) {
EWOL_VERBOSE("SCROOL == > INIT scrollOffset=" << scrollOffset.y() << " relativePos=" << relativePos.y() << " m_highSpeedStartPos=" << m_highSpeedStartPos.y());
//scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x);
if (m_limit->x() != 0.0f) {
@ -332,9 +332,9 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
return true;
}
} else if ( m_highSpeedMode != speedModeDisable
&& ewol::key::statusLeave == _event.getStatus()) {
&& gale::key::status_leave == _event.getStatus()) {
m_highSpeedMode = speedModeDisable;
m_highSpeedType = ewol::key::typeUnknow;
m_highSpeedType = gale::key::type_unknow;
EWOL_VERBOSE("SCROOL == > DISABLE");
markToRedraw();
return true;

Some files were not shown because too many files have changed in this diff Show More