[DEV] code style '_' & '{' at end of line

This commit is contained in:
Edouard DUPIN 2013-10-08 22:32:40 +02:00
parent 7254b172e8
commit b63e6d33b2
174 changed files with 3133 additions and 4516 deletions

View File

@ -1,120 +0,0 @@
#!/bin/bash
replaceSed.sh "==" " == "
replaceSed.sh "==" " == "
replaceSed.sh "==" " == "
replaceSed.sh " == " " == "
replaceSed.sh " == " " == "
replaceSed.sh " == " " == "
replaceSed.sh " == " " == "
replaceSed.sh "\.PushBack(" ".pushBack("
replaceSed.sh "->PushBack(" "->pushBack("
replaceSed.sh " PushBack" " pushBack"
replaceSed.sh "\tPushBack" "\tpushBack"
replaceSed.sh "::PushBack" "::pushBack"
replaceSed.sh "\.PopBack(" ".popBack("
replaceSed.sh "->PopBack(" "->popBack("
replaceSed.sh " PopBack" " popBack"
replaceSed.sh "\tPopBack" "\tpopBack"
replaceSed.sh "::PopBack" "::popBack"
replaceSed.sh "\.Size" ".size"
replaceSed.sh "->Size" "->size"
replaceSed.sh " Size" " size"
replaceSed.sh "\tSize" "\tsize"
replaceSed.sh "::Size" "::size"
replaceSed.sh "\.Clear()" ".clear()"
replaceSed.sh "->Clear()" "->clear()"
replaceSed.sh " Clear" " clear"
replaceSed.sh "\tClear" "\tclear"
replaceSed.sh "::Clear" "::clear"
replaceSed.sh "\.To" ".to"
replaceSed.sh "->To" "->to"
replaceSed.sh " To" " to"
replaceSed.sh "\tTo" "\tto"
replaceSed.sh "::To" "::to"
replaceSed.sh "\.Is" ".is"
replaceSed.sh "->Is" "->is"
replaceSed.sh " Is" " is"
replaceSed.sh "\tIs" "\tis"
replaceSed.sh "::Is" "::is"
replaceSed.sh "\.Exist()" ".exist()"
replaceSed.sh "->Exist()" "->exist()"
replaceSed.sh " Exist" " exist"
replaceSed.sh "\tExist" "\texist"
replaceSed.sh "::Exist" "::exist"
replaceSed.sh "\.Add" ".add"
replaceSed.sh "->Add" "->add"
replaceSed.sh " Add" " add"
replaceSed.sh "\tAdd" "\tadd"
replaceSed.sh "::Add" "::add"
replaceSed.sh "\.Get" ".get"
replaceSed.sh "->Get" "->get"
replaceSed.sh " Get" " get"
replaceSed.sh "\tGet" "\tget"
replaceSed.sh "::Get" "::get"
replaceSed.sh "\.Set" ".set"
replaceSed.sh "->Set" "->set"
replaceSed.sh " Set" " set"
replaceSed.sh "\tSet" "\tset"
replaceSed.sh "::Set" "::set"
replaceSed.sh "\.Insert" ".insert"
replaceSed.sh "->Insert" "->insert"
replaceSed.sh " Insert" " insert"
replaceSed.sh "\tInsert" "\tinsert"
replaceSed.sh "::Insert" "::insert"
replaceSed.sh "\.Parse" ".parse"
replaceSed.sh "->Parse" "->parse"
replaceSed.sh " Parse" " parse"
replaceSed.sh "\tParse" "\tparse"
replaceSed.sh "::Parse" "::parse"
replaceSed.sh "\.Generate" ".generate"
replaceSed.sh "->Generate" "->generate"
replaceSed.sh " Generate" " generate"
replaceSed.sh "\tGenerate" "\tgenerate"
replaceSed.sh "::Generate" "::generate"
replaceSed.sh "\.Transfert" ".transfert"
replaceSed.sh "->Transfert" "->transfert"
replaceSed.sh " Transfert" " transfert"
replaceSed.sh "\tTransfert" "\ttransfert"
replaceSed.sh "::Transfert" "::transfert"
replaceSed.sh "\.Duplicate" ".duplicate"
replaceSed.sh "->Duplicate" "->duplicate"
replaceSed.sh " Duplicate" " duplicate"
replaceSed.sh "\tDuplicate" "\tduplicate"
replaceSed.sh "::Duplicate" "::duplicate"
replaceSed.sh "\.Draw" ".draw"
replaceSed.sh "->Draw" "->draw"
replaceSed.sh " Draw" " draw"
replaceSed.sh "\tDraw" "\tdraw"
replaceSed.sh "::Draw" "::draw"
replaceSed.sh "\.Check" ".check"
replaceSed.sh "->Check" "->check"
replaceSed.sh " Check" " check"
replaceSed.sh "\tCheck" "\tcheck"
replaceSed.sh "::Check" "::check"
replaceSed.sh "\.Count" ".count"
replaceSed.sh "->Count" "->count"
replaceSed.sh " Count" " count"
replaceSed.sh "\tCount" "\tcount"
replaceSed.sh "::Count" "::count"

View File

@ -1,16 +0,0 @@
#!/bin/bash
listFiles=" `find . -name "*.cpp"` "
listFiles+=" `find . -name "*.c"` "
listFiles+=" `find . -name "*.h"` "
#listFiles+=" `find . -name "*.mk"` "
echo "Replace : \"$1\" ==> \"$2\""
for iii in $listFiles
do
echo "* File : "$iii
sed -i "s|$1|$2|" $iii
done

View File

@ -17,19 +17,16 @@ import android.util.Log;
public class Ewol { public class Ewol {
private int instanceID = -1; // local and private instance ID private int instanceID = -1; // local and private instance ID
public <T extends EwolCallback> Ewol(T activityInstance, int typeApplication) public <T extends EwolCallback> Ewol(T activityInstance, int typeApplication) {
{
instanceID = -1; instanceID = -1;
instanceID = EWsetJavaVirtualMachineStart(activityInstance, typeApplication); instanceID = EWsetJavaVirtualMachineStart(activityInstance, typeApplication);
Log.d("Ewol", "new : " + instanceID); Log.d("Ewol", "new : " + instanceID);
} }
public void setJavaVirtualMachineStop() public void setJavaVirtualMachineStop() {
{
EWsetJavaVirtualMachineStop(instanceID); EWsetJavaVirtualMachineStop(instanceID);
} }
public void paramSetArchiveDir(int mode, String myString) public void paramSetArchiveDir(int mode, String myString) {
{
EWparamSetArchiveDir(instanceID, mode, myString); EWparamSetArchiveDir(instanceID, mode, myString);
} }
@ -42,65 +39,52 @@ public class Ewol {
public void onStop() { EWonStop(instanceID); } public void onStop() { EWonStop(instanceID); }
public void onDestroy() { EWonDestroy(instanceID); } public void onDestroy() { EWonDestroy(instanceID); }
// set display properties : // set display properties :
public void displayPropertyMetrics(float ratioX, float ratioY) public void displayPropertyMetrics(float ratioX, float ratioY) {
{
EWdisplayPropertyMetrics(instanceID, ratioX, ratioY); EWdisplayPropertyMetrics(instanceID, ratioX, ratioY);
} }
// IO native function : // IO native function :
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same) // Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
public void inputEventMotion(int pointerID, float x, float y) public void inputEventMotion(int pointerID, float x, float y) {
{
EWinputEventMotion(instanceID, pointerID, x, y); EWinputEventMotion(instanceID, pointerID, x, y);
} }
public void inputEventState(int pointerID, boolean isDown, float x, float y) public void inputEventState(int pointerID, boolean isDown, float x, float y) {
{
EWinputEventState(instanceID, pointerID, isDown, x, y); EWinputEventState(instanceID, pointerID, isDown, x, y);
} }
// Specific for the type of input : TOOL_TYPE_MOUSE // Specific for the type of input : TOOL_TYPE_MOUSE
public void mouseEventMotion(int pointerID, float x, float y) public void mouseEventMotion(int pointerID, float x, float y) {
{
EWmouseEventMotion(instanceID, pointerID, x, y); EWmouseEventMotion(instanceID, pointerID, x, y);
} }
public void mouseEventState(int pointerID, boolean isDown, float x, float y) public void mouseEventState(int pointerID, boolean isDown, float x, float y) {
{
EWmouseEventState(instanceID, pointerID, isDown, x, y); EWmouseEventState(instanceID, pointerID, isDown, x, y);
} }
// other unknow event ... // other unknow event ...
public void unknowEvent(int eventID) public void unknowEvent(int eventID) {
{
EWunknowEvent(instanceID, eventID); EWunknowEvent(instanceID, eventID);
} }
public void keyboardEventMove(int type, boolean isDown) public void keyboardEventMove(int type, boolean isDown) {
{
EWkeyboardEventMove(instanceID, type, isDown); EWkeyboardEventMove(instanceID, type, isDown);
} }
public void keyboardEventKey(int uniChar, boolean isDown) public void keyboardEventKey(int uniChar, boolean isDown) {
{
EWkeyboardEventKey(instanceID, uniChar, isDown); EWkeyboardEventKey(instanceID, uniChar, isDown);
} }
// Audio section ... // Audio section ...
public void audioPlayback(short[] bufferData, int frames, int nbChannels) public void audioPlayback(short[] bufferData, int frames, int nbChannels) {
{
EWaudioPlayback(instanceID, bufferData, frames, nbChannels); EWaudioPlayback(instanceID, bufferData, frames, nbChannels);
} }
public void keyboardEventKeySystem(int keyVal, boolean isDown) public void keyboardEventKeySystem(int keyVal, boolean isDown) {
{
EWkeyboardEventKeySystem(instanceID, keyVal, isDown); EWkeyboardEventKeySystem(instanceID, keyVal, isDown);
} }
// renderer Event : // renderer Event :
public void renderInit() public void renderInit() {
{
EWrenderInit(instanceID); EWrenderInit(instanceID);
} }
public void renderResize(int w, int h) public void renderResize(int w, int h) {
{
EWrenderResize(instanceID, w, h); EWrenderResize(instanceID, w, h);
} }
public void renderDraw() public void renderDraw() {
{
EWrenderDraw(instanceID); EWrenderDraw(instanceID);
} }

View File

@ -54,8 +54,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
static { static {
System.loadLibrary("ewol"); System.loadLibrary("ewol");
} }
public EwolActivity() public EwolActivity() {
{
// set the java evironement in the C sources : // set the java evironement in the C sources :
EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY); EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY);
} }
@ -78,8 +77,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
EWOL.paramSetArchiveDir(0, apkFilePath); EWOL.paramSetArchiveDir(0, apkFilePath);
} }
@Override protected void onCreate(Bundle savedInstanceState) @Override protected void onCreate(Bundle savedInstanceState) {
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Load the application directory // Load the application directory
@ -114,22 +112,19 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
setContentView(mGLView); setContentView(mGLView);
} }
@Override protected void onStart() @Override protected void onStart() {
{
super.onStart(); super.onStart();
// call C // call C
EWOL.onStart(); EWOL.onStart();
} }
@Override protected void onRestart() @Override protected void onRestart() {
{
super.onRestart(); super.onRestart();
// call C // call C
EWOL.onReStart(); EWOL.onReStart();
} }
@Override protected void onResume() @Override protected void onResume() {
{
super.onResume(); super.onResume();
mGLView.onResume(); mGLView.onResume();
mAudioThread = new Thread(mStreams); mAudioThread = new Thread(mStreams);
@ -140,8 +135,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
EWOL.onResume(); EWOL.onResume();
} }
@Override protected void onPause() @Override protected void onPause() {
{
super.onPause(); super.onPause();
mGLView.onPause(); mGLView.onPause();
if (mAudioThread != null) { if (mAudioThread != null) {
@ -156,14 +150,12 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
EWOL.onPause(); EWOL.onPause();
} }
@Override protected void onStop() @Override protected void onStop() {
{
super.onStop(); super.onStop();
// call C // call C
EWOL.onStop(); EWOL.onStop();
} }
@Override protected void onDestroy() @Override protected void onDestroy() {
{
super.onDestroy(); super.onDestroy();
// call C // call C
EWOL.onDestroy(); EWOL.onDestroy();
@ -171,19 +163,16 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
EWOL.setJavaVirtualMachineStop(); EWOL.setJavaVirtualMachineStop();
} }
@Override protected void finalize() throws Throwable @Override protected void finalize() throws Throwable {
{
super.finalize(); super.finalize();
// cleanup your object here // cleanup your object here
} }
public void onConfigurationChanged(Configuration newConfig) public void onConfigurationChanged(Configuration newConfig) {
{
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
} }
public void keyboardUpdate(boolean show) public void keyboardUpdate(boolean show) {
{
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if(show) { if(show) {
//EWOL.touchEvent(); //EWOL.touchEvent();
@ -194,13 +183,11 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
} }
} }
public void eventNotifier(String[] args) public void eventNotifier(String[] args) {
{
// TODO : ... // TODO : ...
} }
public void orientationUpdate(int screenMode) public void orientationUpdate(int screenMode) {
{
if (screenMode == EWOL_ORIENTATION_LANDSCAPE) { if (screenMode == EWOL_ORIENTATION_LANDSCAPE) {
//Force landscape //Force landscape
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
@ -213,13 +200,11 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
} }
} }
public void titleSet(String value) public void titleSet(String value) {
{
setTitle(value); setTitle(value);
} }
public void stop() public void stop() {
{
// end application is requested ... // end application is requested ...
finish(); finish();
} }

View File

@ -28,13 +28,11 @@ public class EwolAudioTask implements Runnable, EwolConstants
private Ewol EWOL; private Ewol EWOL;
// constructor : // constructor :
public EwolAudioTask(Ewol ewolInstance) public EwolAudioTask(Ewol ewolInstance) {
{
EWOL = ewolInstance; EWOL = ewolInstance;
} }
public void run() public void run() {
{
if(m_musicTrack != null) { if(m_musicTrack != null) {
return; return;
} }
@ -67,22 +65,19 @@ public class EwolAudioTask implements Runnable, EwolConstants
m_musicTrack.flush(); m_musicTrack.flush();
m_musicTrack.stop(); m_musicTrack.stop();
} }
public void Pause() public void Pause() {
{
if(m_musicTrack == null) { if(m_musicTrack == null) {
return; return;
} }
m_musicTrack.pause(); m_musicTrack.pause();
} }
public void Resume() public void Resume() {
{
if(m_musicTrack == null) { if(m_musicTrack == null) {
return; return;
} }
m_musicTrack.play(); m_musicTrack.play();
} }
public void AutoStop() public void AutoStop() {
{
if(m_musicTrack == null) { if(m_musicTrack == null) {
return; return;
} }

View File

@ -27,8 +27,7 @@ public class EwolRendererGL implements GLSurfaceView.Renderer
{ {
private Ewol EWOL; private Ewol EWOL;
public EwolRendererGL(Ewol ewolInstance) public EwolRendererGL(Ewol ewolInstance) {
{
EWOL = ewolInstance; EWOL = ewolInstance;
} }
public void onSurfaceCreated(GL10 gl, EGLConfig config) { public void onSurfaceCreated(GL10 gl, EGLConfig config) {

View File

@ -216,8 +216,7 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
return true; return true;
} }
private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown) private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown) {
{
int actionDone = event.getAction(); int actionDone = event.getAction();
switch(keyCode) switch(keyCode)
{ {
@ -287,13 +286,11 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
return false; return false;
} }
public boolean onKeyDown(int keyCode, KeyEvent event) public boolean onKeyDown(int keyCode, KeyEvent event) {
{
return keyboardEvent(keyCode, event, true); return keyboardEvent(keyCode, event, true);
} }
public boolean onKeyUp(int keyCode, KeyEvent event) public boolean onKeyUp(int keyCode, KeyEvent event) {
{
return keyboardEvent(keyCode, event, false); return keyboardEvent(keyCode, event, false);
} }

View File

@ -50,8 +50,7 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
EWOL.paramSetArchiveDir(0, apkFilePath); EWOL.paramSetArchiveDir(0, apkFilePath);
} }
@Override public Engine onCreateEngine() @Override public Engine onCreateEngine() {
{
// set the java evironement in the C sources : // set the java evironement in the C sources :
EWOL = new Ewol(this, EWOL_APPL_TYPE_WALLPAPER); EWOL = new Ewol(this, EWOL_APPL_TYPE_WALLPAPER);
@ -76,32 +75,24 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
return mGLView; return mGLView;
} }
public class GLEngine extends Engine {
public class GLEngine extends Engine
{
private Ewol EWOL; private Ewol EWOL;
public GLEngine(Ewol ewolInstance) public GLEngine(Ewol ewolInstance) {
{
EWOL = ewolInstance; EWOL = ewolInstance;
} }
class WallpaperGLSurfaceView extends EwolSurfaceViewGL class WallpaperGLSurfaceView extends EwolSurfaceViewGL
{ {
private static final String TAG = "WallpaperGLSurfaceView"; private static final String TAG = "WallpaperGLSurfaceView";
WallpaperGLSurfaceView(Context context, Ewol ewolInstance) WallpaperGLSurfaceView(Context context, Ewol ewolInstance) {
{
super(context, ewolInstance); super(context, ewolInstance);
Log.d(TAG, "WallpaperGLSurfaceView(" + context + ")"); Log.d(TAG, "WallpaperGLSurfaceView(" + context + ")");
} }
@Override @Override public SurfaceHolder getHolder() {
public SurfaceHolder getHolder()
{
Log.d(TAG, "getHolder(): returning " + getSurfaceHolder()); Log.d(TAG, "getHolder(): returning " + getSurfaceHolder());
return getSurfaceHolder(); return getSurfaceHolder();
} }
public void onDestroy() public void onDestroy() {
{
Log.d(TAG, "onDestroy()"); Log.d(TAG, "onDestroy()");
super.onDetachedFromWindow(); super.onDetachedFromWindow();
} }
@ -110,8 +101,7 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
private static final String TAG = "GLEngine"; private static final String TAG = "GLEngine";
private WallpaperGLSurfaceView glSurfaceView; private WallpaperGLSurfaceView glSurfaceView;
@Override public void onCreate(SurfaceHolder surfaceHolder) @Override public void onCreate(SurfaceHolder surfaceHolder) {
{
Log.d(TAG, "onCreate(" + surfaceHolder + ")"); Log.d(TAG, "onCreate(" + surfaceHolder + ")");
super.onCreate(surfaceHolder); super.onCreate(surfaceHolder);
@ -135,13 +125,11 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
} }
@Override public void onTouchEvent(MotionEvent event) @Override public void onTouchEvent(MotionEvent event) {
{
glSurfaceView.onTouchEvent(event); glSurfaceView.onTouchEvent(event);
} }
@Override public void onVisibilityChanged(boolean visible) @Override public void onVisibilityChanged(boolean visible) {
{
Log.d(TAG, "onVisibilityChanged(" + visible + ")"); Log.d(TAG, "onVisibilityChanged(" + visible + ")");
super.onVisibilityChanged(visible); super.onVisibilityChanged(visible);
if (true==visible) { if (true==visible) {
@ -155,8 +143,7 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
} }
} }
@Override public void onDestroy() @Override public void onDestroy() {
{
Log.d(TAG, "onDestroy()"); Log.d(TAG, "onDestroy()");
super.onDestroy(); super.onDestroy();
// call C // call C
@ -165,46 +152,40 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
glSurfaceView.onDestroy(); glSurfaceView.onDestroy();
} }
protected void setPreserveEGLContextOnPause(boolean preserve) protected void setPreserveEGLContextOnPause(boolean preserve) {
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Log.d(TAG, "setPreserveEGLContextOnPause(" + preserve + ")"); Log.d(TAG, "setPreserveEGLContextOnPause(" + preserve + ")");
glSurfaceView.setPreserveEGLContextOnPause(preserve); glSurfaceView.setPreserveEGLContextOnPause(preserve);
} }
} }
protected void setEGLContextClientVersion(int version) protected void setEGLContextClientVersion(int version) {
{
Log.d(TAG, "setEGLContextClientVersion(" + version + ")"); Log.d(TAG, "setEGLContextClientVersion(" + version + ")");
glSurfaceView.setEGLContextClientVersion(version); glSurfaceView.setEGLContextClientVersion(version);
} }
} }
public void keyboardUpdate(boolean show) public void keyboardUpdate(boolean show) {
{
// never display keyboard on wallpaer... // never display keyboard on wallpaer...
Log.d("EwolCallback", "KEABOARD UPDATE is not implemented ..."); Log.d("EwolCallback", "KEABOARD UPDATE is not implemented ...");
} }
public void eventNotifier(String[] args) public void eventNotifier(String[] args) {
{
// just for the test ... // just for the test ...
Log.d("EwolCallback", "EVENT NOTIFIER is not implemented ..."); Log.d("EwolCallback", "EVENT NOTIFIER is not implemented ...");
} }
public void orientationUpdate(int screenMode) public void orientationUpdate(int screenMode) {
{
Log.d("EwolCallback", "SET ORIENTATION is not implemented ..."); Log.d("EwolCallback", "SET ORIENTATION is not implemented ...");
} }
public void titleSet(String value) public void titleSet(String value) {
{
// no title in the wallpaper ... // no title in the wallpaper ...
Log.d("EwolCallback", "SET TITLE is not implemented ..."); Log.d("EwolCallback", "SET TITLE is not implemented ...");
} }
public void stop()
{ public void stop() {
Log.d("EwolCallback", "STOP is not implemented ..."); Log.d("EwolCallback", "STOP is not implemented ...");
} }
} }

View File

@ -31,8 +31,7 @@ static const float millimeterToCentimeter = 10.0f;
static const float millimeterToKilometer = 1000000.0f; static const float millimeterToKilometer = 1000000.0f;
void ewol::dimension::init(void) void ewol::dimension::init(void) {
{
if (true == isInit) { if (true == isInit) {
return; return;
} }
@ -43,16 +42,14 @@ void ewol::dimension::init(void)
isInit = true; isInit = true;
} }
void ewol::dimension::unInit(void) void ewol::dimension::unInit(void) {
{
isInit = false; isInit = false;
ratio.setValue(9999999,888888); ratio.setValue(9999999,888888);
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y()); invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(9999999,88888), ewol::Dimension::Pixel); windowsSize.set(vec2(9999999,88888), ewol::Dimension::Pixel);
} }
void ewol::dimension::setPixelRatio(const vec2& _ratio, ewol::Dimension::distance_te _type) void ewol::dimension::setPixelRatio(const vec2& _ratio, ewol::Dimension::distance_te _type) {
{
ewol::dimension::init(); ewol::dimension::init();
EWOL_INFO("Set a new screen ratio for the screen : ratio=" << _ratio << " type=" << _type); EWOL_INFO("Set a new screen ratio for the screen : ratio=" << _ratio << " type=" << _type);
ewol::Dimension conversion(_ratio, _type); ewol::Dimension conversion(_ratio, _type);
@ -62,43 +59,33 @@ void ewol::dimension::setPixelRatio(const vec2& _ratio, ewol::Dimension::distanc
EWOL_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio); EWOL_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio);
} }
void ewol::dimension::setPixelWindowsSize(const vec2& _size) void ewol::dimension::setPixelWindowsSize(const vec2& _size) {
{
windowsSize = _size; windowsSize = _size;
EWOL_VERBOSE("Set a new Windows property size " << windowsSize << "px"); EWOL_VERBOSE("Set a new Windows property size " << windowsSize << "px");
} }
vec2 ewol::dimension::getWindowsSize(ewol::Dimension::distance_te _type) vec2 ewol::dimension::getWindowsSize(ewol::Dimension::distance_te _type) {
{
return windowsSize.get(_type); return windowsSize.get(_type);
} }
float ewol::dimension::getWindowsDiag(ewol::Dimension::distance_te _type) float ewol::dimension::getWindowsDiag(ewol::Dimension::distance_te _type) {
{
vec2 size = ewol::dimension::getWindowsSize(_type); vec2 size = ewol::dimension::getWindowsSize(_type);
return size.length(); return size.length();
} }
ewol::Dimension::Dimension(void) : ewol::Dimension::Dimension(void) :
m_data(0,0), m_data(0,0),
m_type(ewol::Dimension::Pixel) m_type(ewol::Dimension::Pixel) {
{
// notinh to do ... // notinh to do ...
} }
ewol::Dimension::Dimension(const vec2& _size, ewol::Dimension::distance_te _type) : ewol::Dimension::Dimension(const vec2& _size, ewol::Dimension::distance_te _type) :
m_data(0,0), m_data(0,0),
m_type(ewol::Dimension::Pixel) m_type(ewol::Dimension::Pixel) {
{
set(_size, _type); set(_size, _type);
} }
void ewol::Dimension::set(etk::UString _config) void ewol::Dimension::set(etk::UString _config) {
{
m_data.setValue(0,0); m_data.setValue(0,0);
m_type = ewol::Dimension::Pixel; m_type = ewol::Dimension::Pixel;
distance_te type = ewol::Dimension::Pixel; distance_te type = ewol::Dimension::Pixel;
@ -135,13 +122,11 @@ void ewol::Dimension::set(etk::UString _config)
EWOL_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this ); EWOL_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
} }
ewol::Dimension::~Dimension(void) ewol::Dimension::~Dimension(void) {
{
// nothing to do ... // nothing to do ...
} }
ewol::Dimension::operator etk::UString(void) const ewol::Dimension::operator etk::UString(void) const {
{
etk::UString str; etk::UString str;
str = get(getType()); str = get(getType());
@ -174,8 +159,7 @@ ewol::Dimension::operator etk::UString(void) const
return str; return str;
} }
vec2 ewol::Dimension::get(ewol::Dimension::distance_te _type) const vec2 ewol::Dimension::get(ewol::Dimension::distance_te _type) const {
{
switch(_type) { switch(_type) {
case ewol::Dimension::Pourcent: case ewol::Dimension::Pourcent:
return getPourcent(); return getPourcent();
@ -196,20 +180,18 @@ vec2 ewol::Dimension::get(ewol::Dimension::distance_te _type) const
} }
} }
void ewol::Dimension::set(const vec2& _size, ewol::Dimension::distance_te _type) void ewol::Dimension::set(const vec2& _size, ewol::Dimension::distance_te _type) {
{
// set min max on input to limit error : // set min max on input to limit error :
vec2 size(etk_avg(0.0f,_size.x(),9999999.0f), vec2 size(etk_avg(0.0f,_size.x(),9999999.0f),
etk_avg(0.0f,_size.y(),9999999.0f)); etk_avg(0.0f,_size.y(),9999999.0f));
switch(_type) { switch(_type) {
case ewol::Dimension::Pourcent: case ewol::Dimension::Pourcent: {
{ vec2 size2(etk_avg(0.0f,_size.x(),100.0f),
vec2 size2(etk_avg(0.0f,_size.x(),100.0f), etk_avg(0.0f,_size.y(),100.0f));
etk_avg(0.0f,_size.y(),100.0f)); m_data = vec2(size2.x()*0.01f, size2.y()*0.01f);
m_data = vec2(size2.x()*0.01f, size2.y()*0.01f); //EWOL_VERBOSE("Set % : " << size2 << " == > " << m_data);
//EWOL_VERBOSE("Set % : " << size2 << " == > " << m_data);
}
break; break;
}
case ewol::Dimension::Pixel: case ewol::Dimension::Pixel:
m_data = size; m_data = size;
break; break;
@ -235,8 +217,7 @@ void ewol::Dimension::set(const vec2& _size, ewol::Dimension::distance_te _type)
m_type = _type; m_type = _type;
} }
vec2 ewol::Dimension::getPixel(void) const vec2 ewol::Dimension::getPixel(void) const {
{
if (m_type!=ewol::Dimension::Pourcent) { if (m_type!=ewol::Dimension::Pourcent) {
return m_data; return m_data;
} else { } else {
@ -247,8 +228,7 @@ vec2 ewol::Dimension::getPixel(void) const
} }
} }
vec2 ewol::Dimension::getPourcent(void) const vec2 ewol::Dimension::getPourcent(void) const {
{
if (m_type!=ewol::Dimension::Pourcent) { if (m_type!=ewol::Dimension::Pourcent) {
vec2 windDim = windowsSize.getPixel(); vec2 windDim = windowsSize.getPixel();
//EWOL_DEBUG(" windows dimention : " /*<< windowsSize*/ << " == > " << windDim << "px"); // ==> infinite loop ... //EWOL_DEBUG(" windows dimention : " /*<< windowsSize*/ << " == > " << windDim << "px"); // ==> infinite loop ...
@ -259,38 +239,31 @@ vec2 ewol::Dimension::getPourcent(void) const
return vec2(m_data.x()*100.0f, m_data.y()*100.0f);; return vec2(m_data.x()*100.0f, m_data.y()*100.0f);;
} }
vec2 ewol::Dimension::getMeter(void) const vec2 ewol::Dimension::getMeter(void) const {
{
return ewol::Dimension::getMillimeter()*millimeterToMeter; return ewol::Dimension::getMillimeter()*millimeterToMeter;
} }
vec2 ewol::Dimension::getCentimeter(void) const vec2 ewol::Dimension::getCentimeter(void) const {
{
return ewol::Dimension::getMillimeter()*millimeterToCentimeter; return ewol::Dimension::getMillimeter()*millimeterToCentimeter;
} }
vec2 ewol::Dimension::getMillimeter(void) const vec2 ewol::Dimension::getMillimeter(void) const {
{
return ewol::Dimension::getPixel()*invRatio; return ewol::Dimension::getPixel()*invRatio;
} }
vec2 ewol::Dimension::getKilometer(void) const vec2 ewol::Dimension::getKilometer(void) const {
{
return ewol::Dimension::getMillimeter()*millimeterToKilometer; return ewol::Dimension::getMillimeter()*millimeterToKilometer;
} }
vec2 ewol::Dimension::getInch(void) const vec2 ewol::Dimension::getInch(void) const {
{
return ewol::Dimension::getMillimeter()*millimeterToInch; return ewol::Dimension::getMillimeter()*millimeterToInch;
} }
vec2 ewol::Dimension::getFoot(void) const vec2 ewol::Dimension::getFoot(void) const {
{
return ewol::Dimension::getMillimeter()*millimeterToFoot; return ewol::Dimension::getMillimeter()*millimeterToFoot;
} }
etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::Dimension::distance_te& obj) etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::Dimension::distance_te& obj) {
{
switch(obj) { switch(obj) {
case ewol::Dimension::Pourcent: case ewol::Dimension::Pourcent:
os << "%"; os << "%";
@ -320,8 +293,7 @@ etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::Dimension::distance_te
return os; return os;
} }
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Dimension& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Dimension& _obj) {
{
_os << _obj.get(_obj.getType()) << _obj.getType(); _os << _obj.get(_obj.getType()) << _obj.getType();
return _os; return _os;
} }

View File

@ -13,14 +13,12 @@
#include <etk/UString.h> #include <etk/UString.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
namespace ewol namespace ewol {
{
/** /**
* @brief in the dimention class we store the data as the more usefull unit (pixel) * @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 * but one case need to be dynamic the %, then when requested in % the register the % value
*/ */
class Dimension class Dimension {
{
public: public:
typedef enum { typedef enum {
Pourcent=0, Pourcent=0,
@ -165,8 +163,7 @@ namespace ewol
etk::CCout& operator <<(etk::CCout& _os, const ewol::Dimension::distance_te& _obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::Dimension::distance_te& _obj);
etk::CCout& operator <<(etk::CCout& _os, const ewol::Dimension& _obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::Dimension& _obj);
namespace dimension namespace dimension {
{
/** /**
* @brief basic init * @brief basic init

View File

@ -10,48 +10,43 @@
#include <ewol/debug.h> #include <ewol/debug.h>
ewol::Light::Light(void) : ewol::Light::Light(void) :
m_direction(0,0,0), m_direction(0,0,0),
m_halfplane(0,0,0), m_halfplane(0,0,0),
m_ambientColor(0,0,0,0), m_ambientColor(0,0,0,0),
m_diffuseColor(0,0,0,0), m_diffuseColor(0,0,0,0),
m_specularColor(0,0,0,0), m_specularColor(0,0,0,0),
m_GL_direction(0), m_GL_direction(0),
m_GL_halfplane(0), m_GL_halfplane(0),
m_GL_ambientColor(0), m_GL_ambientColor(0),
m_GL_diffuseColor(0), m_GL_diffuseColor(0),
m_GL_specularColor(0) m_GL_specularColor(0) {
{
// nothing to do else ... // nothing to do else ...
} }
ewol::Light::~Light(void) ewol::Light::~Light(void) {
{
} }
void ewol::Light::link(ewol::Program* prog, const etk::UString& baseName) void ewol::Light::link(ewol::Program* _prog, const etk::UString& _baseName) {
{ if (NULL == _prog) {
if (NULL == prog) {
return; return;
} }
m_GL_direction = prog->getUniform(baseName+".direction"); m_GL_direction = _prog->getUniform(_baseName+".direction");
m_GL_halfplane = prog->getUniform(baseName+".halfplane"); m_GL_halfplane = _prog->getUniform(_baseName+".halfplane");
m_GL_ambientColor = prog->getUniform(baseName+".ambientColor"); m_GL_ambientColor = _prog->getUniform(_baseName+".ambientColor");
m_GL_diffuseColor = prog->getUniform(baseName+".diffuseColor"); m_GL_diffuseColor = _prog->getUniform(_baseName+".diffuseColor");
m_GL_specularColor = prog->getUniform(baseName+".specularColor"); m_GL_specularColor = _prog->getUniform(_baseName+".specularColor");
} }
void ewol::Light::draw(ewol::Program* prog) void ewol::Light::draw(ewol::Program* _prog) {
{ _prog->uniform3(m_GL_direction, m_direction);
prog->uniform3(m_GL_direction, m_direction); _prog->uniform3(m_GL_halfplane, m_halfplane);
prog->uniform3(m_GL_halfplane, m_halfplane); _prog->uniform4(m_GL_ambientColor, m_ambientColor);
prog->uniform4(m_GL_ambientColor, m_ambientColor); _prog->uniform4(m_GL_diffuseColor, m_diffuseColor);
prog->uniform4(m_GL_diffuseColor, m_diffuseColor); _prog->uniform4(m_GL_specularColor, m_specularColor);
prog->uniform4(m_GL_specularColor, m_specularColor);
} }
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Light& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Light& _obj) {
{
_os << "light:{"; _os << "light:{";
_os << "dir=" << _obj.m_direction; _os << "dir=" << _obj.m_direction;
_os << " halfplan=" << _obj.m_halfplane; _os << " halfplan=" << _obj.m_halfplane;

View File

@ -14,10 +14,8 @@
#include <etk/math/Vector4D.h> #include <etk/math/Vector4D.h>
#include <ewol/resources/Program.h> #include <ewol/resources/Program.h>
namespace ewol namespace ewol {
{ class Light {
class Light
{
private: private:
// values // values
vec3 m_direction; vec3 m_direction;
@ -35,8 +33,8 @@ namespace ewol
public: public:
Light(void); Light(void);
~Light(void); ~Light(void);
void link(ewol::Program* prog, const etk::UString& baseName); void link(ewol::Program* _prog, const etk::UString& _baseName);
void draw(ewol::Program* prog); void draw(ewol::Program* _prog);
void setDirection(const vec3& val) { void setDirection(const vec3& val) {
m_direction = val; m_direction = val;
} }
@ -56,7 +54,6 @@ namespace ewol
friend etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj); friend etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj);
}; };
etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::Light& _obj);
}; };

View File

@ -11,18 +11,16 @@
#include <ewol/debug.h> #include <ewol/debug.h>
ewol::MaterialGlId::MaterialGlId(void) : ewol::MaterialGlId::MaterialGlId(void) :
m_GL_ambientFactor(0), m_GL_ambientFactor(0),
m_GL_diffuseFactor(0), m_GL_diffuseFactor(0),
m_GL_specularFactor(0), m_GL_specularFactor(0),
m_GL_shininess(0), m_GL_shininess(0),
m_GL_texture0(0) m_GL_texture0(0) {
{
// nothing to do else ... // nothing to do else ...
} }
void ewol::MaterialGlId::link(ewol::Program* _prog, const etk::UString& _baseName) void ewol::MaterialGlId::link(ewol::Program* _prog, const etk::UString& _baseName) {
{
if (NULL == _prog) { if (NULL == _prog) {
return; return;
} }
@ -34,23 +32,20 @@ void ewol::MaterialGlId::link(ewol::Program* _prog, const etk::UString& _baseNam
} }
ewol::Material::Material(void) : ewol::Material::Material(void) :
m_ambientFactor(1,1,1,1), m_ambientFactor(1,1,1,1),
m_diffuseFactor(0,0,0,1), m_diffuseFactor(0,0,0,1),
m_specularFactor(0,0,0,1), m_specularFactor(0,0,0,1),
m_shininess(1), m_shininess(1),
m_texture0(NULL) m_texture0(NULL) {
{
// nothing to do else ... // nothing to do else ...
} }
ewol::Material::~Material(void) ewol::Material::~Material(void) {
{
if(NULL!=m_texture0) { if(NULL!=m_texture0) {
ewol::TextureFile::release(m_texture0); ewol::TextureFile::release(m_texture0);
} }
} }
void ewol::Material::draw(ewol::Program* _prog, const MaterialGlId& _glID) void ewol::Material::draw(ewol::Program* _prog, const MaterialGlId& _glID) {
{
_prog->uniform4(_glID.m_GL_ambientFactor, m_ambientFactor); _prog->uniform4(_glID.m_GL_ambientFactor, m_ambientFactor);
_prog->uniform4(_glID.m_GL_diffuseFactor, m_diffuseFactor); _prog->uniform4(_glID.m_GL_diffuseFactor, m_diffuseFactor);
_prog->uniform4(_glID.m_GL_specularFactor, m_specularFactor); _prog->uniform4(_glID.m_GL_specularFactor, m_specularFactor);
@ -60,8 +55,7 @@ void ewol::Material::draw(ewol::Program* _prog, const MaterialGlId& _glID)
} }
} }
void ewol::Material::setTexture0(const etk::UString& _filename) void ewol::Material::setTexture0(const etk::UString& _filename) {
{
ivec2 tmpSize(256, 256); ivec2 tmpSize(256, 256);
// prevent overloard error : // prevent overloard error :
ewol::TextureFile* tmpCopy = m_texture0; ewol::TextureFile* tmpCopy = m_texture0;

View File

@ -15,10 +15,8 @@
#include <ewol/resources/Program.h> #include <ewol/resources/Program.h>
#include <ewol/resources/Image.h> #include <ewol/resources/Image.h>
namespace ewol namespace ewol {
{ class MaterialGlId {
class MaterialGlId
{
public: public:
// GL index // GL index
int32_t m_GL_ambientFactor; int32_t m_GL_ambientFactor;
@ -29,8 +27,7 @@ namespace ewol
MaterialGlId(void); MaterialGlId(void);
void link(ewol::Program* _prog, const etk::UString& _baseName); void link(ewol::Program* _prog, const etk::UString& _baseName);
}; };
class Material class Material {
{
private: private:
// values // values
vec4 m_ambientFactor; vec4 m_ambientFactor;

View File

@ -13,7 +13,7 @@
#include <ewol/renderer/eContext.h> #include <ewol/renderer/eContext.h>
#undef __class__ #undef __class__
#define __class__ "ClipBoard" #define __class__ "ClipBoard"
/* /*
@ -25,7 +25,6 @@ note: la copy dans le :
//!< Local copy of the clipboards //!< Local copy of the clipboards
static etk::UString mesCopy[ewol::clipBoard::clipboardCount]; static etk::UString mesCopy[ewol::clipBoard::clipboardCount];
static const char* clipboardDescriptionString[ewol::clipBoard::clipboardCount+1] = { static const char* clipboardDescriptionString[ewol::clipBoard::clipboardCount+1] = {
"clipboard0", "clipboard0",
"clipboard1", "clipboard1",
@ -42,8 +41,7 @@ static const char* clipboardDescriptionString[ewol::clipBoard::clipboardCount+1]
"clipboardCount" "clipboardCount"
}; };
etk::CCout& ewol::clipBoard::operator <<(etk::CCout& _os, const ewol::clipBoard::clipboardListe_te _obj) etk::CCout& ewol::clipBoard::operator <<(etk::CCout& _os, const ewol::clipBoard::clipboardListe_te _obj) {
{
if (_obj >= 0 && _obj <ewol::clipBoard::clipboardCount) { if (_obj >= 0 && _obj <ewol::clipBoard::clipboardCount) {
_os << clipboardDescriptionString[_obj]; _os << clipboardDescriptionString[_obj];
} else { } else {
@ -53,8 +51,7 @@ etk::CCout& ewol::clipBoard::operator <<(etk::CCout& _os, const ewol::clipBoard:
} }
void ewol::clipBoard::init(void) void ewol::clipBoard::init(void) {
{
EWOL_INFO("Initialyse ClipBoards"); EWOL_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<ewol::clipBoard::clipboardCount; i++) { for(int32_t i=0; i<ewol::clipBoard::clipboardCount; i++) {
mesCopy[i].clear(); mesCopy[i].clear();
@ -62,8 +59,7 @@ void ewol::clipBoard::init(void)
} }
void ewol::clipBoard::unInit(void) void ewol::clipBoard::unInit(void) {
{
EWOL_INFO("Initialyse ClipBoards"); EWOL_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<ewol::clipBoard::clipboardCount; i++) { for(int32_t i=0; i<ewol::clipBoard::clipboardCount; i++) {
mesCopy[i].clear(); mesCopy[i].clear();
@ -71,8 +67,7 @@ void ewol::clipBoard::unInit(void)
} }
void ewol::clipBoard::set(ewol::clipBoard::clipboardListe_te _clipboardID, const etk::UString& _data) void ewol::clipBoard::set(ewol::clipBoard::clipboardListe_te _clipboardID, const etk::UString& _data) {
{
// check if ID is correct // check if ID is correct
if(0 == _data.size()) { if(0 == _data.size()) {
EWOL_INFO("request a copy of nothing"); EWOL_INFO("request a copy of nothing");
@ -94,8 +89,7 @@ void ewol::clipBoard::set(ewol::clipBoard::clipboardListe_te _clipboardID, const
} }
void ewol::clipBoard::request(ewol::clipBoard::clipboardListe_te _clipboardID) void ewol::clipBoard::request(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
if(_clipboardID >= ewol::clipBoard::clipboardCount) { if(_clipboardID >= ewol::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error"); EWOL_WARNING("request ClickBoard id error");
return; return;
@ -113,8 +107,7 @@ void ewol::clipBoard::request(ewol::clipBoard::clipboardListe_te _clipboardID)
} }
void ewol::clipBoard::setSystem(ewol::clipBoard::clipboardListe_te _clipboardID, const etk::UString& _data) void ewol::clipBoard::setSystem(ewol::clipBoard::clipboardListe_te _clipboardID, const etk::UString& _data) {
{
if(_clipboardID >= ewol::clipBoard::clipboardCount) { if(_clipboardID >= ewol::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error"); EWOL_WARNING("request ClickBoard id error");
return; return;
@ -124,8 +117,7 @@ void ewol::clipBoard::setSystem(ewol::clipBoard::clipboardListe_te _clipboardID,
} }
const etk::UString& ewol::clipBoard::get(ewol::clipBoard::clipboardListe_te _clipboardID) const etk::UString& ewol::clipBoard::get(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
static const etk::UString emptyString(""); static const etk::UString emptyString("");
if(_clipboardID >= ewol::clipBoard::clipboardCount) { if(_clipboardID >= ewol::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error"); EWOL_WARNING("request ClickBoard id error");

View File

@ -10,8 +10,7 @@
#include <ewol/commandLine.h> #include <ewol/commandLine.h>
#include <etk/Vector.h> #include <etk/Vector.h>
void ewol::CommandLine::parse(int32_t _argc, const char* _argv[]) void ewol::CommandLine::parse(int32_t _argc, const char* _argv[]) {
{
for( int32_t i=1 ; i<_argc; i++) { for( int32_t i=1 ; i<_argc; i++) {
EWOL_INFO("commandLine : \"" << _argv[i] << "\"" ); EWOL_INFO("commandLine : \"" << _argv[i] << "\"" );
m_listArgs.pushBack(_argv[i]); m_listArgs.pushBack(_argv[i]);
@ -20,13 +19,11 @@ void ewol::CommandLine::parse(int32_t _argc, const char* _argv[])
esize_t ewol::CommandLine::size(void) esize_t ewol::CommandLine::size(void) {
{
return m_listArgs.size(); return m_listArgs.size();
} }
const etk::UString& ewol::CommandLine::get(int32_t _id) const etk::UString& ewol::CommandLine::get(int32_t _id) {
{
static const etk::UString errorArg(""); static const etk::UString errorArg("");
if (_id<0 && _id >= m_listArgs.size()) { if (_id<0 && _id >= m_listArgs.size()) {
return errorArg; return errorArg;
@ -34,13 +31,11 @@ const etk::UString& ewol::CommandLine::get(int32_t _id)
return m_listArgs[_id]; return m_listArgs[_id];
} }
void ewol::CommandLine::add(const etk::UString& _newElement) void ewol::CommandLine::add(const etk::UString& _newElement) {
{
m_listArgs.pushBack(_newElement); m_listArgs.pushBack(_newElement);
} }
void ewol::CommandLine::remove(esize_t _id) void ewol::CommandLine::remove(esize_t _id) {
{
m_listArgs.remove(_id); m_listArgs.remove(_id);
} }

View File

@ -12,10 +12,8 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/UString.h>
namespace ewol namespace ewol {
{ class CommandLine {
class CommandLine
{
private: private:
etk::Vector<etk::UString> m_listArgs; //!< list of all argument parsed etk::Vector<etk::UString> m_listArgs; //!< list of all argument parsed
public: public:

View File

@ -13,30 +13,27 @@
#define __class__ "ewol::Area" #define __class__ "ewol::Area"
ewol::Area::Area(const ivec2& _size) : ewol::Area::Area(const ivec2& _size) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_color(etk::color::white), m_color(etk::color::white),
m_GLprogram(NULL), m_GLprogram(NULL),
m_GLPosition(-1), m_GLPosition(-1),
m_GLMatrix(-1), m_GLMatrix(-1),
m_GLColor(-1), m_GLColor(-1),
m_GLtexture(-1), m_GLtexture(-1),
m_GLtexID(-1), m_GLtexID(-1),
m_resource(NULL) m_resource(NULL) {
{
m_resource = ewol::Texture::keep(); m_resource = ewol::Texture::keep();
m_resource->setImageSize(_size); m_resource->setImageSize(_size);
m_resource->flush(); m_resource->flush();
loadProgram(); loadProgram();
} }
ewol::Area::~Area(void) ewol::Area::~Area(void) {
{
ewol::Texture::release(m_resource); ewol::Texture::release(m_resource);
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Area::loadProgram(void) void ewol::Area::loadProgram(void) {
{
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:textured3D.prog"); m_GLprogram = ewol::Program::keep("DATA:textured3D.prog");
@ -49,8 +46,7 @@ void ewol::Area::loadProgram(void)
} }
} }
void ewol::Area::draw(bool _disableDepthTest) void ewol::Area::draw(bool _disableDepthTest) {
{
if (m_coord.size() <= 0) { if (m_coord.size() <= 0) {
//EWOL_WARNING("Nothink to draw..."); //EWOL_WARNING("Nothink to draw...");
return; return;
@ -80,8 +76,7 @@ void ewol::Area::draw(bool _disableDepthTest)
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Area::clear(void) void ewol::Area::clear(void) {
{
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
@ -92,18 +87,15 @@ void ewol::Area::clear(void)
m_position = vec3(0.0, 0.0, 0.0); m_position = vec3(0.0, 0.0, 0.0);
} }
void ewol::Area::print(const ivec2& _size) void ewol::Area::print(const ivec2& _size) {
{
vec3 point(0,0,0); vec3 point(0,0,0);
vec2 tex(0,1); vec2 tex(0,1);
point.setX(m_position.x()); point.setX(m_position.x());
point.setY(m_position.y()); point.setY(m_position.y());
m_coord.pushBack(point); m_coord.pushBack(point);
m_coordTex.pushBack(tex); m_coordTex.pushBack(tex);
m_coordColor.pushBack(m_color); m_coordColor.pushBack(m_color);
tex.setValue(1,1); tex.setValue(1,1);
point.setX(m_position.x() + _size.x()); point.setX(m_position.x() + _size.x());
point.setY(m_position.y()); point.setY(m_position.y());
@ -111,7 +103,6 @@ void ewol::Area::print(const ivec2& _size)
m_coordTex.pushBack(tex); m_coordTex.pushBack(tex);
m_coordColor.pushBack(m_color); m_coordColor.pushBack(m_color);
tex.setValue(1,0); tex.setValue(1,0);
point.setX(m_position.x() + _size.x()); point.setX(m_position.x() + _size.x());
point.setY(m_position.y() + _size.y()); point.setY(m_position.y() + _size.y());

View File

@ -13,49 +13,41 @@
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compositing.h>
ewol::Compositing::Compositing(void) ewol::Compositing::Compositing(void) {
{
// nothing to do // nothing to do
} }
ewol::Compositing::~Compositing(void) ewol::Compositing::~Compositing(void) {
{
// nothing to do // nothing to do
} }
void ewol::Compositing::resetMatrix(void) void ewol::Compositing::resetMatrix(void) {
{
m_matrixApply.identity(); m_matrixApply.identity();
} }
void ewol::Compositing::translate(const vec3& _vect) void ewol::Compositing::translate(const vec3& _vect) {
{
m_matrixApply *= etk::matTranslate(_vect); m_matrixApply *= etk::matTranslate(_vect);
} }
void ewol::Compositing::rotate(const vec3& _vect, float _angle) void ewol::Compositing::rotate(const vec3& _vect, float _angle) {
{
m_matrixApply *= etk::matRotate(_vect, _angle); m_matrixApply *= etk::matRotate(_vect, _angle);
} }
void ewol::Compositing::scale(const vec3& _vect) void ewol::Compositing::scale(const vec3& _vect) {
{
m_matrixApply *= etk::matScale(_vect); m_matrixApply *= etk::matScale(_vect);
} }
void ewol::Compositing::clear(void) void ewol::Compositing::clear(void) {
{
m_matrixApply.identity(); m_matrixApply.identity();
} }
void ewol::Compositing::setMatrix(const mat4& _mat) void ewol::Compositing::setMatrix(const mat4& _mat) {
{
m_matrixApply = _mat; m_matrixApply = _mat;
} }

View File

@ -218,19 +218,18 @@ static void SutherlandHodgman(etk::Vector<vec2 > & input, etk::Vector<vec2 > & o
#endif #endif
ewol::Drawing::Drawing(void) : ewol::Drawing::Drawing(void) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), m_clippingPosStop(0.0, 0.0, 0.0),
m_clippingEnable(false), m_clippingEnable(false),
m_color(etk::color::black), m_color(etk::color::black),
m_colorBg(etk::color::none), m_colorBg(etk::color::none),
m_GLprogram(NULL), m_GLprogram(NULL),
m_GLPosition(-1), m_GLPosition(-1),
m_GLMatrix(-1), m_GLMatrix(-1),
m_GLColor(-1), m_GLColor(-1),
m_thickness(0.0), m_thickness(0.0),
m_triElement(0) m_triElement(0) {
{
loadProgram(); loadProgram();
for (int32_t iii=0; iii<3; iii++) { for (int32_t iii=0; iii<3; iii++) {
m_triangle[iii] = m_position; m_triangle[iii] = m_position;
@ -238,15 +237,11 @@ ewol::Drawing::Drawing(void) :
} }
} }
ewol::Drawing::~Drawing(void) {
ewol::Drawing::~Drawing(void)
{
unLoadProgram(); unLoadProgram();
} }
void ewol::Drawing::generateTriangle(void) {
void ewol::Drawing::generateTriangle(void)
{
m_triElement = 0; m_triElement = 0;
m_coord.pushBack(m_triangle[0]); m_coord.pushBack(m_triangle[0]);
@ -257,8 +252,7 @@ void ewol::Drawing::generateTriangle(void)
m_coordColor.pushBack(m_tricolor[2]); m_coordColor.pushBack(m_tricolor[2]);
} }
void ewol::Drawing::internalSetColor(const etk::Color<>& _color) void ewol::Drawing::internalSetColor(const etk::Color<>& _color) {
{
if (m_triElement < 1) { if (m_triElement < 1) {
m_tricolor[0] = _color; m_tricolor[0] = _color;
} }
@ -270,9 +264,7 @@ void ewol::Drawing::internalSetColor(const etk::Color<>& _color)
} }
} }
void ewol::Drawing::setPoint(const vec3& _point) {
void ewol::Drawing::setPoint(const vec3& _point)
{
m_triangle[m_triElement] = _point; m_triangle[m_triElement] = _point;
m_triElement++; m_triElement++;
if (m_triElement >= 3) { if (m_triElement >= 3) {
@ -280,19 +272,15 @@ void ewol::Drawing::setPoint(const vec3& _point)
} }
} }
void ewol::Drawing::resetCount(void) {
void ewol::Drawing::resetCount(void)
{
m_triElement = 0; m_triElement = 0;
} }
void ewol::Drawing::unLoadProgram(void) void ewol::Drawing::unLoadProgram(void) {
{
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Drawing::loadProgram(void) void ewol::Drawing::loadProgram(void) {
{
// remove previous loading ... in case // remove previous loading ... in case
unLoadProgram(); unLoadProgram();
// oad the new ... // oad the new ...
@ -305,8 +293,7 @@ void ewol::Drawing::loadProgram(void)
} }
} }
void ewol::Drawing::draw(bool _disableDepthTest) void ewol::Drawing::draw(bool _disableDepthTest) {
{
if (m_coord.size() <= 0) { if (m_coord.size() <= 0) {
// TODO : a remÚtre ... // TODO : a remÚtre ...
//EWOL_WARNING("Nothink to draw..."); //EWOL_WARNING("Nothink to draw...");
@ -329,8 +316,7 @@ void ewol::Drawing::draw(bool _disableDepthTest)
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Drawing::clear(void) void ewol::Drawing::clear(void) {
{
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
@ -352,8 +338,7 @@ void ewol::Drawing::clear(void)
} }
} }
void ewol::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd) void ewol::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd) {
{
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); m_clippingPosStart.setX(_pos.x());
@ -379,9 +364,7 @@ void ewol::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd)
m_clippingEnable = true; m_clippingEnable = true;
} }
void ewol::Drawing::setThickness(float _thickness) {
void ewol::Drawing::setThickness(float _thickness)
{
m_thickness = _thickness; m_thickness = _thickness;
// thickness must be positive // thickness must be positive
if (m_thickness < 0) { if (m_thickness < 0) {
@ -389,14 +372,12 @@ void ewol::Drawing::setThickness(float _thickness)
} }
} }
void ewol::Drawing::addVertex(void) void ewol::Drawing::addVertex(void) {
{
internalSetColor(m_color); internalSetColor(m_color);
setPoint(m_position); setPoint(m_position);
} }
void ewol::Drawing::lineTo(const vec3& _dest) void ewol::Drawing::lineTo(const vec3& _dest) {
{
resetCount(); resetCount();
internalSetColor(m_color); internalSetColor(m_color);
EWOL_VERBOSE("DrawLine : " << m_position << " to " << _dest); EWOL_VERBOSE("DrawLine : " << m_position << " to " << _dest);
@ -419,7 +400,6 @@ void ewol::Drawing::lineTo(const vec3& _dest)
//EWOL_DEBUG("teta = " << (teta*180/(M_PI)) << " deg." ); //EWOL_DEBUG("teta = " << (teta*180/(M_PI)) << " deg." );
float offsety = sin(teta-M_PI/2) * (m_thickness/2); float offsety = sin(teta-M_PI/2) * (m_thickness/2);
float offsetx = cos(teta-M_PI/2) * (m_thickness/2); float offsetx = cos(teta-M_PI/2) * (m_thickness/2);
setPoint(vec3(m_position.x() - offsetx, m_position.y() - offsety, m_position.z()) ); setPoint(vec3(m_position.x() - offsetx, m_position.y() - offsety, m_position.z()) );
setPoint(vec3(m_position.x() + offsetx, m_position.y() + offsety, m_position.z()) ); setPoint(vec3(m_position.x() + offsetx, m_position.y() + offsety, m_position.z()) );
setPoint(vec3(_dest.x() + offsetx, _dest.y() + offsety, m_position.z()) ); setPoint(vec3(_dest.x() + offsetx, _dest.y() + offsety, m_position.z()) );
@ -431,8 +411,7 @@ void ewol::Drawing::lineTo(const vec3& _dest)
m_position = _dest; m_position = _dest;
} }
void ewol::Drawing::rectangle(const vec3& _dest) void ewol::Drawing::rectangle(const vec3& _dest) {
{
resetCount(); resetCount();
internalSetColor(m_color); internalSetColor(m_color);
/* Bitmap position /* Bitmap position
@ -485,13 +464,11 @@ void ewol::Drawing::rectangle(const vec3& _dest)
setPoint(vec3(dxA, dyD, 0) ); setPoint(vec3(dxA, dyD, 0) );
} }
void ewol::Drawing::cube(const vec3& _dest) void ewol::Drawing::cube(const vec3& _dest) {
{
} }
void ewol::Drawing::circle(float _radius, float _angleStart, float _angleStop) void ewol::Drawing::circle(float _radius, float _angleStart, float _angleStop) {
{
resetCount(); resetCount();
if (_radius<0) { if (_radius<0) {

View File

@ -16,10 +16,8 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol namespace ewol {
{ class Drawing : public ewol::Compositing {
class Drawing : public ewol::Compositing
{
private: private:
vec3 m_position; //!< The current position to draw vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position vec3 m_clippingPosStart; //!< Clipping start position

View File

@ -13,32 +13,29 @@
#define __class__ "ewol::Image" #define __class__ "ewol::Image"
ewol::Image::Image(const etk::UString& _imageName) : ewol::Image::Image(const etk::UString& _imageName) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), m_clippingPosStop(0.0, 0.0, 0.0),
m_clippingEnable(false), m_clippingEnable(false),
m_color(etk::color::white), m_color(etk::color::white),
m_angle(0.0), m_angle(0.0),
m_GLprogram(NULL), m_GLprogram(NULL),
m_GLPosition(-1), m_GLPosition(-1),
m_GLMatrix(-1), m_GLMatrix(-1),
m_GLColor(-1), m_GLColor(-1),
m_GLtexture(-1), m_GLtexture(-1),
m_GLtexID(-1), m_GLtexID(-1),
m_resource(NULL) m_resource(NULL) {
{
setSource(_imageName); setSource(_imageName);
loadProgram(); loadProgram();
} }
ewol::Image::~Image(void) ewol::Image::~Image(void) {
{
ewol::TextureFile::release(m_resource); ewol::TextureFile::release(m_resource);
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Image::loadProgram(void) void ewol::Image::loadProgram(void) {
{
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:textured3D.prog"); m_GLprogram = ewol::Program::keep("DATA:textured3D.prog");
@ -51,8 +48,7 @@ void ewol::Image::loadProgram(void)
} }
} }
void ewol::Image::draw(bool _disableDepthTest) void ewol::Image::draw(bool _disableDepthTest) {
{
if (m_coord.size() <= 0) { if (m_coord.size() <= 0) {
//EWOL_WARNING("Nothink to draw..."); //EWOL_WARNING("Nothink to draw...");
return; return;
@ -87,8 +83,7 @@ void ewol::Image::draw(bool _disableDepthTest)
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Image::clear(void) void ewol::Image::clear(void) {
{
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
@ -104,8 +99,7 @@ void ewol::Image::clear(void)
m_angle = 0.0; m_angle = 0.0;
} }
void ewol::Image::setClipping(const vec3& _pos, vec3 _posEnd) void ewol::Image::setClipping(const vec3& _pos, vec3 _posEnd) {
{
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); m_clippingPosStart.setX(_pos.x());
@ -131,20 +125,17 @@ void ewol::Image::setClipping(const vec3& _pos, vec3 _posEnd)
m_clippingEnable = true; m_clippingEnable = true;
} }
void ewol::Image::setAngle(float _angle) void ewol::Image::setAngle(float _angle) {
{
m_angle = _angle; m_angle = _angle;
} }
void ewol::Image::print(const vec2& _size) void ewol::Image::print(const vec2& _size) {
{
printPart(_size, vec2(0,0), vec2(1,1)); printPart(_size, vec2(0,0), vec2(1,1));
} }
void ewol::Image::printPart(const vec2& _size, void ewol::Image::printPart(const vec2& _size,
const vec2& _sourcePosStart, const vec2& _sourcePosStart,
const vec2& _sourcePosStop) const vec2& _sourcePosStop) {
{
if (m_angle == 0.0f) { if (m_angle == 0.0f) {
vec3 point = m_position; vec3 point = m_position;
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y()); vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
@ -235,8 +226,7 @@ void ewol::Image::printPart(const vec2& _size,
m_coordColor.pushBack(m_color); m_coordColor.pushBack(m_color);
} }
void ewol::Image::setSource(const etk::UString& _newFile, const vec2& _size) void ewol::Image::setSource(const etk::UString& _newFile, const vec2& _size) {
{
clear(); clear();
// remove old one // remove old one
ewol::TextureFile::release(m_resource); ewol::TextureFile::release(m_resource);
@ -251,14 +241,12 @@ void ewol::Image::setSource(const etk::UString& _newFile, const vec2& _size)
} }
} }
bool ewol::Image::hasSources(void) bool ewol::Image::hasSources(void) {
{
return m_resource!=NULL; return m_resource!=NULL;
} }
vec2 ewol::Image::getRealSize(void) vec2 ewol::Image::getRealSize(void) {
{
if (NULL == m_resource) { if (NULL == m_resource) {
return vec2(0,0); return vec2(0,0);
} }

View File

@ -13,10 +13,8 @@
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compositing.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol namespace ewol {
{ class Image : public ewol::Compositing {
class Image : public ewol::Compositing
{
private: private:
vec3 m_position; //!< The current position to draw vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position vec3 m_clippingPosStart; //!< Clipping start position

View File

@ -13,10 +13,8 @@
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compositing.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol namespace ewol {
{ class Mesh : public ewol::Compositing {
class Mesh : public ewol::Compositing
{
protected: protected:
public: public:

View File

@ -14,49 +14,45 @@
#define __class__ "ewol::Shaper" #define __class__ "ewol::Shaper"
ewol::Shaper::Shaper(const etk::UString& _shaperName) : ewol::Shaper::Shaper(const etk::UString& _shaperName) :
m_name(_shaperName), m_name(_shaperName),
m_config(NULL), m_config(NULL),
m_confIdPaddingX(-1), m_confIdPaddingX(-1),
m_confIdPaddingY(-1), m_confIdPaddingY(-1),
m_confIdChangeTime(-1), m_confIdChangeTime(-1),
m_confProgramFile(-1), m_confProgramFile(-1),
m_GLprogram(NULL), m_GLprogram(NULL),
m_GLPosition(-1), m_GLPosition(-1),
m_GLMatrix(-1), m_GLMatrix(-1),
m_GLPropertySize(-1), m_GLPropertySize(-1),
m_GLPropertyInsidePos(-1), m_GLPropertyInsidePos(-1),
m_GLPropertyInsideSize(-1), m_GLPropertyInsideSize(-1),
m_GLStateOld(-1), m_GLStateOld(-1),
m_GLStateNew(-1), m_GLStateNew(-1),
m_GLStateTransition(-1), m_GLStateTransition(-1),
m_resourceTexture(NULL), m_resourceTexture(NULL),
m_nextStatusRequested(-1), m_nextStatusRequested(-1),
m_propertyOrigin(0,0), m_propertyOrigin(0,0),
m_propertySize(0,0), m_propertySize(0,0),
m_propertyInsidePosition(0,0), m_propertyInsidePosition(0,0),
m_propertyInsideSize(0,0), m_propertyInsideSize(0,0),
m_stateOld(0), m_stateOld(0),
m_stateNew(0), m_stateNew(0),
m_stateTransition(1.0) m_stateTransition(1.0) {
{
loadProgram(); loadProgram();
updateVertex(); updateVertex();
} }
ewol::Shaper::~Shaper(void) ewol::Shaper::~Shaper(void) {
{
unLoadProgram(); unLoadProgram();
} }
void ewol::Shaper::unLoadProgram(void) void ewol::Shaper::unLoadProgram(void) {
{
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
ewol::TextureFile::release(m_resourceTexture); ewol::TextureFile::release(m_resourceTexture);
ewol::ConfigFile::release(m_config); ewol::ConfigFile::release(m_config);
} }
void ewol::Shaper::loadProgram(void) void ewol::Shaper::loadProgram(void) {
{
if (m_name == "") { if (m_name == "") {
EWOL_DEBUG("no Shaper set for loading resources ..."); EWOL_DEBUG("no Shaper set for loading resources ...");
return; return;
@ -102,9 +98,7 @@ void ewol::Shaper::loadProgram(void)
} }
} }
void ewol::Shaper::draw(bool _disableDepthTest) {
void ewol::Shaper::draw(bool _disableDepthTest)
{
if (m_config == NULL) { if (m_config == NULL) {
// this is a normale case ... the user can choice to have no config basic file ... // this is a normale case ... the user can choice to have no config basic file ...
return; return;
@ -138,13 +132,11 @@ void ewol::Shaper::draw(bool _disableDepthTest)
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Shaper::clear(void) void ewol::Shaper::clear(void) {
{
// nothing to do ... // nothing to do ...
} }
bool ewol::Shaper::changeStatusIn(int32_t _newStatusId) bool ewol::Shaper::changeStatusIn(int32_t _newStatusId) {
{
if (_newStatusId != m_stateNew) { if (_newStatusId != m_stateNew) {
m_nextStatusRequested = _newStatusId; m_nextStatusRequested = _newStatusId;
return true; return true;
@ -156,8 +148,7 @@ bool ewol::Shaper::changeStatusIn(int32_t _newStatusId)
return false; return false;
} }
bool ewol::Shaper::periodicCall(const ewol::EventTime& _event) bool ewol::Shaper::periodicCall(const ewol::EventTime& _event) {
{
//EWOL_DEBUG("call=" << _event); //EWOL_DEBUG("call=" << _event);
// start : // start :
if (m_stateTransition >= 1.0) { if (m_stateTransition >= 1.0) {
@ -195,9 +186,7 @@ bool ewol::Shaper::periodicCall(const ewol::EventTime& _event)
return true; return true;
} }
void ewol::Shaper::updateVertex(void) {
void ewol::Shaper::updateVertex(void)
{
// set coord == > must be a static VBO ... // set coord == > must be a static VBO ...
m_coord[0].setValue( m_propertyOrigin.x(), m_coord[0].setValue( m_propertyOrigin.x(),
m_propertyOrigin.y()+m_propertySize.y()); m_propertyOrigin.y()+m_propertySize.y());
@ -214,36 +203,29 @@ void ewol::Shaper::updateVertex(void)
m_propertyOrigin.y()+m_propertySize.y()); m_propertyOrigin.y()+m_propertySize.y());
} }
void ewol::Shaper::setOrigin(const vec2& _newOri) void ewol::Shaper::setOrigin(const vec2& _newOri) {
{
if (m_propertyOrigin != _newOri) { if (m_propertyOrigin != _newOri) {
m_propertyOrigin = _newOri; m_propertyOrigin = _newOri;
updateVertex(); updateVertex();
} }
} }
void ewol::Shaper::setSize(const vec2& _newSize) void ewol::Shaper::setSize(const vec2& _newSize) {
{
if (m_propertySize != _newSize) { if (m_propertySize != _newSize) {
m_propertySize = _newSize; m_propertySize = _newSize;
updateVertex(); updateVertex();
} }
} }
void ewol::Shaper::setInsideSize(const vec2& _newInsideSize) void ewol::Shaper::setInsideSize(const vec2& _newInsideSize) {
{
m_propertyInsideSize = _newInsideSize; m_propertyInsideSize = _newInsideSize;
} }
void ewol::Shaper::setInsidePos(const vec2& _newInsidePos) void ewol::Shaper::setInsidePos(const vec2& _newInsidePos) {
{
m_propertyInsidePosition = _newInsidePos; m_propertyInsidePosition = _newInsidePos;
} }
vec2 ewol::Shaper::getPadding(void) {
vec2 ewol::Shaper::getPadding(void)
{
vec2 padding(0,0); vec2 padding(0,0);
if (m_config!=NULL) { if (m_config!=NULL) {
padding.setValue(m_config->getFloat(m_confIdPaddingX), padding.setValue(m_config->getFloat(m_confIdPaddingX),
@ -252,17 +234,14 @@ vec2 ewol::Shaper::getPadding(void)
return padding; return padding;
} }
void ewol::Shaper::setSource(const etk::UString& _newFile) {
void ewol::Shaper::setSource(const etk::UString& _newFile)
{
clear(); clear();
unLoadProgram(); unLoadProgram();
m_name = _newFile; m_name = _newFile;
loadProgram(); loadProgram();
} }
bool ewol::Shaper::hasSources(void) bool ewol::Shaper::hasSources(void) {
{
return m_GLprogram!=NULL; return m_GLprogram!=NULL;
} }

View File

@ -14,15 +14,13 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <ewol/renderer/EventTime.h> #include <ewol/renderer/EventTime.h>
namespace ewol namespace ewol {
{
/** /**
* @brief the Shaper system is a basic theme configuration for every widget, it corespond at a background display described by a pool of files * @brief the Shaper system is a basic theme configuration for every widget, it corespond at a background display described by a pool of files
*/ */
// TODO : load image // TODO : load image
// TODO : Abstaraction between states (call by name and the system greate IDs // TODO : Abstaraction between states (call by name and the system greate IDs
class Shaper : public ewol::Compositing class Shaper : public ewol::Compositing {
{
private: private:
etk::UString m_name; //!< Name of the configuration of the shaper. etk::UString m_name; //!< Name of the configuration of the shaper.
// External theme config: // External theme config:

View File

@ -10,13 +10,12 @@
#include <ewol/compositing/Sprite.h> #include <ewol/compositing/Sprite.h>
#undef __class__ #undef __class__
#define __class__ "ewol::Sprite" #define __class__ "ewol::Sprite"
ewol::Sprite::Sprite(const etk::UString& _imageName, const ivec2& _nbSprite) : ewol::Sprite::Sprite(const etk::UString& _imageName, const ivec2& _nbSprite) :
ewol::Image(_imageName), ewol::Image(_imageName),
m_nbSprite(_nbSprite), m_nbSprite(_nbSprite),
m_unitarySpriteSize(0,0) m_unitarySpriteSize(0,0) {
{
/* /*
vec2 imageSize = getRealSize(); vec2 imageSize = getRealSize();
m_unitarySpriteSize.setValue(imageSize.x()/(float)m_nbSprite.x(), m_unitarySpriteSize.setValue(imageSize.x()/(float)m_nbSprite.x(),
@ -24,12 +23,10 @@ ewol::Sprite::Sprite(const etk::UString& _imageName, const ivec2& _nbSprite) :
*/ */
m_unitarySpriteSize.setValue(1.0/(float)m_nbSprite.x(), m_unitarySpriteSize.setValue(1.0/(float)m_nbSprite.x(),
1.0/(float)m_nbSprite.y()); 1.0/(float)m_nbSprite.y());
} }
void ewol::Sprite::printSprite(const ivec2& _spriteID, const vec3& _size) void ewol::Sprite::printSprite(const ivec2& _spriteID, const vec3& _size) {
{
if( _spriteID.x()<0 if( _spriteID.x()<0
|| _spriteID.y()<0 || _spriteID.y()<0
|| _spriteID.x() >= m_nbSprite.x() || _spriteID.x() >= m_nbSprite.x()

View File

@ -13,10 +13,8 @@
#include <ewol/compositing/Image.h> #include <ewol/compositing/Image.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol namespace ewol {
{ class Sprite : public ewol::Image {
class Sprite : public ewol::Image
{
protected: protected:
ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal
vec2 m_unitarySpriteSize; //!< size of a unique sprite vec2 m_unitarySpriteSize; //!< size of a unique sprite

View File

@ -15,44 +15,41 @@
ewol::Text::Text(const etk::UString& _fontName, int32_t _fontSize) : ewol::Text::Text(const etk::UString& _fontName, int32_t _fontSize) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), m_clippingPosStop(0.0, 0.0, 0.0),
m_clippingEnable(false), m_clippingEnable(false),
m_color(etk::color::black), m_color(etk::color::black),
m_colorBg(etk::color::none), m_colorBg(etk::color::none),
m_colorCursor(etk::color::black), m_colorCursor(etk::color::black),
m_colorSelection(etk::color::olive), m_colorSelection(etk::color::olive),
m_mode(ewol::font::Regular), m_mode(ewol::font::Regular),
m_kerning(true), m_kerning(true),
m_distanceField(false), m_distanceField(false),
m_previousCharcode(0), m_previousCharcode(0),
m_startTextpos(0), m_startTextpos(0),
m_stopTextPos(0), m_stopTextPos(0),
m_alignement(ewol::Text::alignDisable), m_alignement(ewol::Text::alignDisable),
m_GLprogram(NULL), m_GLprogram(NULL),
m_GLPosition(-1), m_GLPosition(-1),
m_GLMatrix(-1), m_GLMatrix(-1),
m_GLColor(-1), m_GLColor(-1),
m_GLtexture(-1), m_GLtexture(-1),
m_GLtexID(-1), m_GLtexID(-1),
m_selectionStartPos(-100), m_selectionStartPos(-100),
m_cursorPos(-100), m_cursorPos(-100),
m_font(NULL) m_font(NULL) {
{
setFont(_fontName, _fontSize); setFont(_fontName, _fontSize);
loadProgram(); loadProgram();
} }
ewol::Text::~Text(void) ewol::Text::~Text(void) {
{
ewol::TexturedFont::release(m_font); ewol::TexturedFont::release(m_font);
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Text::loadProgram(void) void ewol::Text::loadProgram(void) {
{
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:text.prog"); m_GLprogram = ewol::Program::keep("DATA:text.prog");
@ -65,8 +62,7 @@ void ewol::Text::loadProgram(void)
} }
} }
void ewol::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest) void ewol::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest) {
{
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); m_vectorialDraw.draw();
@ -110,8 +106,7 @@ void ewol::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest)
} }
void ewol::Text::draw(bool _disableDepthTest) void ewol::Text::draw(bool _disableDepthTest) {
{
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); m_vectorialDraw.draw();
@ -145,29 +140,22 @@ void ewol::Text::draw(bool _disableDepthTest)
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Text::translate(const vec3& _vect) void ewol::Text::translate(const vec3& _vect) {
{
ewol::Compositing::translate(_vect); ewol::Compositing::translate(_vect);
m_vectorialDraw.translate(_vect); m_vectorialDraw.translate(_vect);
} }
void ewol::Text::rotate(const vec3& _vect, float _angle) {
void ewol::Text::rotate(const vec3& _vect, float _angle)
{
ewol::Compositing::rotate(_vect, _angle); ewol::Compositing::rotate(_vect, _angle);
m_vectorialDraw.rotate(_vect, _angle); m_vectorialDraw.rotate(_vect, _angle);
} }
void ewol::Text::scale(const vec3& _vect) {
void ewol::Text::scale(const vec3& _vect)
{
ewol::Compositing::scale(_vect); ewol::Compositing::scale(_vect);
m_vectorialDraw.scale(_vect); m_vectorialDraw.scale(_vect);
} }
void ewol::Text::clear(void) {
void ewol::Text::clear(void)
{
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// remove sub draw system // remove sub draw system
@ -180,8 +168,7 @@ void ewol::Text::clear(void)
reset(); reset();
} }
void ewol::Text::reset(void) void ewol::Text::reset(void) {
{
m_position = vec3(0,0,0); m_position = vec3(0,0,0);
m_clippingPosStart = vec3(0,0,0); m_clippingPosStart = vec3(0,0,0);
m_clippingPosStop = vec3(0,0,0); m_clippingPosStop = vec3(0,0,0);
@ -204,8 +191,7 @@ void ewol::Text::reset(void)
m_nbCharDisplayed = 0; m_nbCharDisplayed = 0;
} }
void ewol::Text::setPos(const vec3& _pos) void ewol::Text::setPos(const vec3& _pos) {
{
// check min max for display area // check min max for display area
if (m_nbCharDisplayed != 0) { if (m_nbCharDisplayed != 0) {
EWOL_VERBOSE("update size 1 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); EWOL_VERBOSE("update size 1 " << m_sizeDisplayStart << " " << m_sizeDisplayStop);
@ -235,22 +221,18 @@ void ewol::Text::setPos(const vec3& _pos)
} }
} }
void ewol::Text::setRelPos(const vec3& _pos) {
void ewol::Text::setRelPos(const vec3& _pos)
{
m_position += _pos; m_position += _pos;
m_previousCharcode = 0; m_previousCharcode = 0;
m_vectorialDraw.setPos(m_position); m_vectorialDraw.setPos(m_position);
} }
void ewol::Text::setColorBg(const etk::Color<>& _color) void ewol::Text::setColorBg(const etk::Color<>& _color) {
{
m_colorBg = _color; m_colorBg = _color;
m_vectorialDraw.setColor(_color); m_vectorialDraw.setColor(_color);
} }
void ewol::Text::setClipping(const vec3& _pos, const vec3& _posEnd) void ewol::Text::setClipping(const vec3& _pos, const vec3& _posEnd) {
{
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); m_clippingPosStart.setX(_pos.x());
@ -277,16 +259,12 @@ void ewol::Text::setClipping(const vec3& _pos, const vec3& _posEnd)
//m_vectorialDraw.setClipping(m_clippingPosStart, m_clippingPosStop); //m_vectorialDraw.setClipping(m_clippingPosStart, m_clippingPosStop);
} }
void ewol::Text::setClippingMode(bool _newMode) {
void ewol::Text::setClippingMode(bool _newMode)
{
m_clippingEnable = _newMode; m_clippingEnable = _newMode;
//m_vectorialDraw.setClippingMode(m_clippingEnable); //m_vectorialDraw.setClippingMode(m_clippingEnable);
} }
void ewol::Text::setFontSize(int32_t _fontSize) {
void ewol::Text::setFontSize(int32_t _fontSize)
{
// get old size // get old size
etk::UString fontName = ""; etk::UString fontName = "";
if (NULL != m_font) { if (NULL != m_font) {
@ -295,9 +273,7 @@ void ewol::Text::setFontSize(int32_t _fontSize)
setFont(fontName, _fontSize); setFont(fontName, _fontSize);
} }
void ewol::Text::setFontName(const etk::UString& _fontName) {
void ewol::Text::setFontName(const etk::UString& _fontName)
{
// get old size // get old size
int32_t fontSize = -1; int32_t fontSize = -1;
if (NULL != m_font) { if (NULL != m_font) {
@ -306,9 +282,7 @@ void ewol::Text::setFontName(const etk::UString& _fontName)
setFont(_fontName, fontSize); setFont(_fontName, fontSize);
} }
void ewol::Text::setFont(etk::UString _fontName, int32_t _fontSize) {
void ewol::Text::setFont(etk::UString _fontName, int32_t _fontSize)
{
clear(); clear();
// remove old one // remove old one
ewol::TexturedFont * previousFont = m_font; ewol::TexturedFont * previousFont = m_font;
@ -330,23 +304,17 @@ void ewol::Text::setFont(etk::UString _fontName, int32_t _fontSize)
} }
} }
void ewol::Text::setFontMode(ewol::font::mode_te _mode) {
void ewol::Text::setFontMode(ewol::font::mode_te _mode)
{
if (NULL!=m_font) { if (NULL!=m_font) {
m_mode = m_font->getWrappingMode(_mode); m_mode = m_font->getWrappingMode(_mode);
} }
} }
ewol::font::mode_te ewol::Text::getFontMode(void) {
ewol::font::mode_te ewol::Text::getFontMode(void)
{
return m_mode; return m_mode;
} }
void ewol::Text::setFontBold(bool _status) {
void ewol::Text::setFontBold(bool _status)
{
if (true == _status) { if (true == _status) {
// enable // enable
if (m_mode == ewol::font::Regular) { if (m_mode == ewol::font::Regular) {
@ -364,8 +332,7 @@ void ewol::Text::setFontBold(bool _status)
} }
} }
void ewol::Text::setFontItalic(bool _status) void ewol::Text::setFontItalic(bool _status) {
{
if (true == _status) { if (true == _status) {
// enable // enable
if (m_mode == ewol::font::Regular) { if (m_mode == ewol::font::Regular) {
@ -383,29 +350,21 @@ void ewol::Text::setFontItalic(bool _status)
} }
} }
void ewol::Text::setKerningMode(bool _newMode) {
void ewol::Text::setKerningMode(bool _newMode)
{
m_kerning = _newMode; m_kerning = _newMode;
} }
void ewol::Text::setDistanceFieldMode(bool _newMode) {
void ewol::Text::setDistanceFieldMode(bool _newMode)
{
m_distanceField = _newMode; m_distanceField = _newMode;
EWOL_TODO("The Distance field mode is not availlable for now ..."); EWOL_TODO("The Distance field mode is not availlable for now ...");
} }
void ewol::Text::print(const etk::UString& _text) {
void ewol::Text::print(const etk::UString& _text)
{
etk::Vector<TextDecoration> decorationEmpty; etk::Vector<TextDecoration> decorationEmpty;
print(_text, decorationEmpty); print(_text, decorationEmpty);
} }
void ewol::Text::parseHtmlNode(exml::Element* _element) {
void ewol::Text::parseHtmlNode(exml::Element* _element)
{
// get the static real pointer // get the static real pointer
if (NULL == _element) { if (NULL == _element) {
EWOL_ERROR( "Error Input node does not existed ..."); EWOL_ERROR( "Error Input node does not existed ...");
@ -501,8 +460,7 @@ void ewol::Text::parseHtmlNode(exml::Element* _element)
} }
} }
void ewol::Text::printDecorated(const etk::UString& _text) void ewol::Text::printDecorated(const etk::UString& _text) {
{
etk::UString tmpData("<html>\n<body>\n"); etk::UString tmpData("<html>\n<body>\n");
tmpData+=_text; tmpData+=_text;
tmpData+="\n</body>\n</html>\n"; tmpData+="\n</body>\n</html>\n";
@ -510,8 +468,7 @@ void ewol::Text::printDecorated(const etk::UString& _text)
printHTML(tmpData); printHTML(tmpData);
} }
void ewol::Text::printHTML(const etk::UString& _text) void ewol::Text::printHTML(const etk::UString& _text) {
{
exml::Document doc; exml::Document doc;
// reset parameter : // reset parameter :
@ -539,8 +496,7 @@ void ewol::Text::printHTML(const etk::UString& _text)
htmlFlush(); htmlFlush();
} }
void ewol::Text::print(const etk::UString& _text, const etk::Vector<TextDecoration>& _decoration) void ewol::Text::print(const etk::UString& _text, const etk::Vector<TextDecoration>& _decoration) {
{
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return; return;
@ -732,8 +688,7 @@ void ewol::Text::print(const etk::UString& _text, const etk::Vector<TextDecorati
} }
void ewol::Text::print(const etk::UniChar& _charcode) void ewol::Text::print(const etk::UniChar& _charcode) {
{
if (NULL == m_font) { if (NULL == m_font) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return; return;
@ -904,15 +859,12 @@ void ewol::Text::print(const etk::UniChar& _charcode)
return; return;
} }
void ewol::Text::forceLineReturn(void) void ewol::Text::forceLineReturn(void) {
{
// reset position : // reset position :
setPos(vec3(m_startTextpos, m_position.y() - m_font->getHeight(m_mode), 0) ); setPos(vec3(m_startTextpos, m_position.y() - m_font->getHeight(m_mode), 0) );
} }
void ewol::Text::setTextAlignement(float _startTextpos, float _stopTextPos, ewol::Text::aligneMode_te _alignement) {
void ewol::Text::setTextAlignement(float _startTextpos, float _stopTextPos, ewol::Text::aligneMode_te _alignement)
{
m_startTextpos = _startTextpos; m_startTextpos = _startTextpos;
m_stopTextPos = _stopTextPos+1; m_stopTextPos = _stopTextPos+1;
m_alignement = _alignement; m_alignement = _alignement;
@ -921,21 +873,15 @@ void ewol::Text::setTextAlignement(float _startTextpos, float _stopTextPos, ewol
} }
} }
ewol::Text::aligneMode_te ewol::Text::getAlignement(void) {
ewol::Text::aligneMode_te ewol::Text::getAlignement(void)
{
return m_alignement; return m_alignement;
} }
void ewol::Text::disableAlignement(void) {
void ewol::Text::disableAlignement(void)
{
m_alignement = ewol::Text::alignDisable; m_alignement = ewol::Text::alignDisable;
} }
vec3 ewol::Text::calculateSizeHTML(const etk::UString& _text) {
vec3 ewol::Text::calculateSizeHTML(const etk::UString& _text)
{
// remove intermediate result // remove intermediate result
reset(); reset();
//EWOL_DEBUG(" 0 size for=\n" << text); //EWOL_DEBUG(" 0 size for=\n" << text);
@ -966,8 +912,7 @@ vec3 ewol::Text::calculateSizeHTML(const etk::UString& _text)
m_sizeDisplayStop.z()-m_sizeDisplayStart.z()); m_sizeDisplayStop.z()-m_sizeDisplayStart.z());
} }
vec3 ewol::Text::calculateSizeDecorated(const etk::UString& _text) vec3 ewol::Text::calculateSizeDecorated(const etk::UString& _text) {
{
if (_text.size() == 0) { if (_text.size() == 0) {
return vec3(0,0,0); return vec3(0,0,0);
} }
@ -978,8 +923,7 @@ vec3 ewol::Text::calculateSizeDecorated(const etk::UString& _text)
return tmpVal; return tmpVal;
} }
vec3 ewol::Text::calculateSize(const etk::UString& _text) vec3 ewol::Text::calculateSize(const etk::UString& _text) {
{
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return vec3(0,0,0); return vec3(0,0,0);
@ -995,8 +939,7 @@ vec3 ewol::Text::calculateSize(const etk::UString& _text)
return outputSize; return outputSize;
} }
vec3 ewol::Text::calculateSize(const etk::UniChar& _charcode) vec3 ewol::Text::calculateSize(const etk::UniChar& _charcode) {
{
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return vec3(0,0,0); return vec3(0,0,0);
@ -1020,8 +963,7 @@ vec3 ewol::Text::calculateSize(const etk::UniChar& _charcode)
} }
void ewol::Text::printCursor(bool _isInsertMode) void ewol::Text::printCursor(bool _isInsertMode) {
{
int32_t fontHeigh = m_font->getHeight(m_mode); int32_t fontHeigh = m_font->getHeight(m_mode);
if (true == _isInsertMode) { if (true == _isInsertMode) {
m_vectorialDraw.rectangleWidth(vec3(20, fontHeigh, 0) ); m_vectorialDraw.rectangleWidth(vec3(20, fontHeigh, 0) );
@ -1033,8 +975,11 @@ void ewol::Text::printCursor(bool _isInsertMode)
} }
bool ewol::Text::extrapolateLastId(const etk::UString& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace) bool ewol::Text::extrapolateLastId(const etk::UString& _text,
{ const int32_t _start,
int32_t& _stop,
int32_t& _space,
int32_t& _freeSpace) {
// store previous : // store previous :
etk::UniChar storePrevious = m_previousCharcode; etk::UniChar storePrevious = m_previousCharcode;
@ -1093,8 +1038,7 @@ bool ewol::Text::extrapolateLastId(const etk::UString& _text, const int32_t _sta
} }
} }
void ewol::Text::htmlAddData(const etk::UString& _data) void ewol::Text::htmlAddData(const etk::UString& _data) {
{
if( m_htmlCurrrentLine.size()>0 if( m_htmlCurrrentLine.size()>0
&& m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') { && m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') {
m_htmlCurrrentLine+=" "; m_htmlCurrrentLine+=" ";
@ -1111,9 +1055,7 @@ void ewol::Text::htmlAddData(const etk::UString& _data)
} }
} }
void ewol::Text::htmlFlush(void) {
void ewol::Text::htmlFlush(void)
{
if (m_htmlCurrrentLine.size()>0) { if (m_htmlCurrrentLine.size()>0) {
print(m_htmlCurrrentLine, m_htmlDecoration); print(m_htmlCurrrentLine, m_htmlDecoration);
} }
@ -1121,31 +1063,25 @@ void ewol::Text::htmlFlush(void)
m_htmlDecoration.clear(); m_htmlDecoration.clear();
} }
void ewol::Text::disableCursor(void) {
void ewol::Text::disableCursor(void)
{
m_selectionStartPos = -100; m_selectionStartPos = -100;
m_cursorPos = -100; m_cursorPos = -100;
} }
void ewol::Text::setCursorPos(int32_t _cursorPos) void ewol::Text::setCursorPos(int32_t _cursorPos) {
{
m_selectionStartPos = _cursorPos; m_selectionStartPos = _cursorPos;
m_cursorPos = _cursorPos; m_cursorPos = _cursorPos;
} }
void ewol::Text::setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos) void ewol::Text::setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos) {
{
m_selectionStartPos = _selectionStartPos; m_selectionStartPos = _selectionStartPos;
m_cursorPos = _cursorPos; m_cursorPos = _cursorPos;
} }
void ewol::Text::setSelectionColor(const etk::Color<>& _color) void ewol::Text::setSelectionColor(const etk::Color<>& _color) {
{
m_colorSelection = _color; m_colorSelection = _color;
} }
void ewol::Text::setCursorColor(const etk::Color<>& _color) void ewol::Text::setCursorColor(const etk::Color<>& _color) {
{
m_colorCursor = _color; m_colorCursor = _color;
} }

View File

@ -17,19 +17,16 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <exml/exml.h> #include <exml/exml.h>
namespace ewol namespace ewol {
{
/** /**
* @brief This class represent the specific display for every char in the string ... * @brief This class represent the specific display for every char in the string ...
*/ */
class TextDecoration class TextDecoration {
{
public: public:
etk::Color<> m_colorBg; //!< display background color etk::Color<> m_colorBg; //!< display background color
etk::Color<> m_colorFg; //!< display foreground color etk::Color<> m_colorFg; //!< display foreground color
ewol::font::mode_te m_mode; //!< display mode Regular/Bold/Italic/BoldItalic ewol::font::mode_te m_mode; //!< display mode Regular/Bold/Italic/BoldItalic
TextDecoration(void) TextDecoration(void) {
{
m_colorBg = etk::color::blue; m_colorBg = etk::color::blue;
m_colorBg = etk::color::green; m_colorBg = etk::color::green;
m_mode = ewol::font::Regular; m_mode = ewol::font::Regular;
@ -37,8 +34,7 @@ namespace ewol
} }
}; };
class Text : public ewol::Compositing class Text : public ewol::Compositing {
{
public: public:
typedef enum { typedef enum {
alignDisable, alignDisable,
@ -368,9 +364,9 @@ namespace ewol
bool extrapolateLastId(const etk::UString& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); bool extrapolateLastId(const etk::UString& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
private: private:
// this section is reserved for HTML parsing and display: // this section is reserved for HTML parsing and display:
etk::UString m_htmlCurrrentLine; //!< current line for HTML display etk::UString m_htmlCurrrentLine; //!< current line for HTML display
etk::Vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display etk::Vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display
TextDecoration m_htmlDecoTmp; //!< current decoration TextDecoration m_htmlDecoTmp; //!< current decoration
/** /**
* @brief add a line with the current m_htmlDecoTmp decoration * @brief add a line with the current m_htmlDecoTmp decoration
* @param[in] _data The cuurent data to add. * @param[in] _data The cuurent data to add.

View File

@ -33,8 +33,7 @@ static const char* cursorDescriptionString[ewol::cursorCount+1] = {
"cursorCount" "cursorCount"
}; };
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::cursorDisplay_te _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::cursorDisplay_te _obj) {
{
if (_obj >= 0 && _obj <ewol::cursorCount) { if (_obj >= 0 && _obj <ewol::cursorCount) {
_os << cursorDescriptionString[_obj]; _os << cursorDescriptionString[_obj];
} else { } else {

View File

@ -14,15 +14,15 @@
extern const char * g_ewolLibName; extern const char * g_ewolLibName;
#define EWOL_CRITICAL(data) ETK_CRITICAL(g_ewolLibName, data) #define EWOL_CRITICAL(data) ETK_CRITICAL(g_ewolLibName, data)
#define EWOL_WARNING(data) ETK_WARNING(g_ewolLibName, data) #define EWOL_WARNING(data) ETK_WARNING(g_ewolLibName, data)
#define EWOL_ERROR(data) ETK_ERROR(g_ewolLibName, data) #define EWOL_ERROR(data) ETK_ERROR(g_ewolLibName, data)
#define EWOL_INFO(data) ETK_INFO(g_ewolLibName, data) #define EWOL_INFO(data) ETK_INFO(g_ewolLibName, data)
#define EWOL_DEBUG(data) ETK_DEBUG(g_ewolLibName, data) #define EWOL_DEBUG(data) ETK_DEBUG(g_ewolLibName, data)
#define EWOL_VERBOSE(data) ETK_VERBOSE(g_ewolLibName, data) #define EWOL_VERBOSE(data) ETK_VERBOSE(g_ewolLibName, data)
#define EWOL_ASSERT(cond, data) ETK_ASSERT(g_ewolLibName, cond, data) #define EWOL_ASSERT(cond, data) ETK_ASSERT(g_ewolLibName, cond, data)
#define EWOL_CHECK_INOUT(cond) ETK_CHECK_INOUT(g_ewolLibName, cond) #define EWOL_CHECK_INOUT(cond) ETK_CHECK_INOUT(g_ewolLibName, cond)
#define EWOL_TODO(cond) ETK_TODO(g_ewolLibName, cond) #define EWOL_TODO(cond) ETK_TODO(g_ewolLibName, cond)
#endif #endif

View File

@ -16,11 +16,10 @@
#include <date/date.h> #include <date/date.h>
#undef __class__ #undef __class__
#define __class__ "ewol" #define __class__ "ewol"
etk::UString ewol::getCompilationMode(void) etk::UString ewol::getCompilationMode(void) {
{
#ifdef MODE_RELEASE #ifdef MODE_RELEASE
return "Release"; return "Release";
#else #else
@ -28,8 +27,7 @@ etk::UString ewol::getCompilationMode(void)
#endif #endif
} }
etk::UString ewol::getBoardType(void) etk::UString ewol::getBoardType(void) {
{
#ifdef __TARGET_OS__Linux #ifdef __TARGET_OS__Linux
return "Linux"; return "Linux";
#elif defined(__TARGET_OS__Android) #elif defined(__TARGET_OS__Android)
@ -45,8 +43,7 @@ etk::UString ewol::getBoardType(void)
#endif #endif
} }
etk::UString ewol::getVersion(void) etk::UString ewol::getVersion(void) {
{
#define FIRST_YEAR (2011) #define FIRST_YEAR (2011)
etk::UString tmpOutput = (date::getYear()-FIRST_YEAR); etk::UString tmpOutput = (date::getYear()-FIRST_YEAR);
tmpOutput += "."; tmpOutput += ".";

View File

@ -12,8 +12,7 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/UString.h>
namespace ewol namespace ewol {
{
/** /**
* @brief This is the only one things the User might done in his main(); * @brief This is the only one things the User might done in his main();
* @note To answare you before you ask the question, this is really simple: * @note To answare you before you ask the question, this is really simple:

View File

@ -25,8 +25,7 @@ static const char* statusDescriptionString[ewol::keyEvent::statusCount+1] = {
"statusCount" "statusCount"
}; };
etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::status_te _obj) etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::status_te _obj) {
{
if (_obj >= 0 && _obj <ewol::keyEvent::statusCount) { if (_obj >= 0 && _obj <ewol::keyEvent::statusCount) {
_os << statusDescriptionString[_obj]; _os << statusDescriptionString[_obj];
} else { } else {
@ -77,8 +76,7 @@ static const char* keyboardDescriptionString[ewol::keyEvent::keyboardCount+1] =
"keyboardCount" "keyboardCount"
}; };
etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::keyboard_te _obj) etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::keyboard_te _obj) {
{
if (_obj >= 0 && _obj <ewol::keyEvent::keyboardCount) { if (_obj >= 0 && _obj <ewol::keyEvent::keyboardCount) {
_os << keyboardDescriptionString[_obj]; _os << keyboardDescriptionString[_obj];
} else { } else {
@ -87,7 +85,6 @@ etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::k
return _os; return _os;
} }
static const char* typeDescriptionString[ewol::keyEvent::typeCount+1] = { static const char* typeDescriptionString[ewol::keyEvent::typeCount+1] = {
"typeUnknow", "typeUnknow",
"typeMouse", "typeMouse",
@ -96,8 +93,7 @@ static const char* typeDescriptionString[ewol::keyEvent::typeCount+1] = {
"typeCount" "typeCount"
}; };
etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::type_te _obj) etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::type_te _obj) {
{
if (_obj >= 0 && _obj < ewol::keyEvent::typeCount) { if (_obj >= 0 && _obj < ewol::keyEvent::typeCount) {
_os << typeDescriptionString[_obj]; _os << typeDescriptionString[_obj];
} else { } else {
@ -107,54 +103,42 @@ etk::CCout& ewol::keyEvent::operator <<(etk::CCout& _os, const ewol::keyEvent::t
} }
ewol::SpecialKey::SpecialKey(void) : ewol::SpecialKey::SpecialKey(void) :
value(0) value(0) {
{
} }
bool ewol::SpecialKey::isSetCapsLock(void) const bool ewol::SpecialKey::isSetCapsLock(void) const {
{
return capLock; return capLock;
} }
bool ewol::SpecialKey::isSetShift(void) const bool ewol::SpecialKey::isSetShift(void) const {
{
return shift; return shift;
} }
bool ewol::SpecialKey::isSetCtrl(void) const bool ewol::SpecialKey::isSetCtrl(void) const {
{
return ctrl; return ctrl;
} }
bool ewol::SpecialKey::isSetMeta(void) const bool ewol::SpecialKey::isSetMeta(void) const {
{
return meta; return meta;
} }
bool ewol::SpecialKey::isSetAlt(void) const bool ewol::SpecialKey::isSetAlt(void) const {
{
return alt; return alt;
} }
bool ewol::SpecialKey::isSetAltGr(void) const bool ewol::SpecialKey::isSetAltGr(void) const {
{
return altGr; return altGr;
} }
bool ewol::SpecialKey::isSetNumLock(void) const bool ewol::SpecialKey::isSetNumLock(void) const {
{
return numLock; return numLock;
} }
bool ewol::SpecialKey::isSetInsert(void) const bool ewol::SpecialKey::isSetInsert(void) const {
{
return insert; return insert;
} }
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::SpecialKey _obj) {
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::SpecialKey _obj)
{
_os << " capLock=" << _obj.capLock; _os << " capLock=" << _obj.capLock;
_os << " shift=" << _obj.shift; _os << " shift=" << _obj.shift;
_os << " ctrl=" << _obj.ctrl; _os << " ctrl=" << _obj.ctrl;

View File

@ -12,10 +12,8 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/Stream.h> #include <etk/Stream.h>
namespace ewol namespace ewol {
{ namespace keyEvent {
namespace keyEvent
{
/** /**
* @brief type of input : Note that the keyboard is not prevent due to the fact that data is too different * @brief type of input : Note that the keyboard is not prevent due to the fact that data is too different
*/ */

View File

@ -10,8 +10,7 @@
bool ewol::PhysicsBox::parse(const char* _line) bool ewol::PhysicsBox::parse(const char* _line) {
{
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ewol::PhysicsShape::parse(_line)) {
return true; return true;
} }

View File

@ -13,10 +13,8 @@
#include <etk/types.h> #include <etk/types.h>
#include <ewol/physicsShape/PhysicsShape.h> #include <ewol/physicsShape/PhysicsShape.h>
namespace ewol namespace ewol {
{ class PhysicsBox : public ewol::PhysicsShape {
class PhysicsBox : public ewol::PhysicsShape
{
public: public:
PhysicsBox(void) {}; PhysicsBox(void) {};
virtual ~PhysicsBox(void) {}; virtual ~PhysicsBox(void) {};

View File

@ -10,8 +10,7 @@
bool ewol::PhysicsCapsule::parse(const char* _line) bool ewol::PhysicsCapsule::parse(const char* _line) {
{
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ewol::PhysicsShape::parse(_line)) {
return true; return true;
} }

View File

@ -14,10 +14,8 @@
#include <ewol/physicsShape/PhysicsShape.h> #include <ewol/physicsShape/PhysicsShape.h>
namespace ewol namespace ewol {
{ class PhysicsCapsule : public ewol::PhysicsShape {
class PhysicsCapsule : public ewol::PhysicsShape
{
public: public:
PhysicsCapsule(void) {}; PhysicsCapsule(void) {};
virtual ~PhysicsCapsule(void) {}; virtual ~PhysicsCapsule(void) {};

View File

@ -10,8 +10,7 @@
bool ewol::PhysicsCone::parse(const char* _line) bool ewol::PhysicsCone::parse(const char* _line) {
{
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ewol::PhysicsShape::parse(_line)) {
return true; return true;
} }

View File

@ -14,10 +14,8 @@
#include <ewol/physicsShape/PhysicsShape.h> #include <ewol/physicsShape/PhysicsShape.h>
namespace ewol namespace ewol {
{ class PhysicsCone : public ewol::PhysicsShape {
class PhysicsCone : public ewol::PhysicsShape
{
public: public:
PhysicsCone(void) {}; PhysicsCone(void) {};
virtual ~PhysicsCone(void) {}; virtual ~PhysicsCone(void) {};

View File

@ -10,8 +10,7 @@
bool ewol::PhysicsConvexHull::parse(const char* _line) bool ewol::PhysicsConvexHull::parse(const char* _line) {
{
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ewol::PhysicsShape::parse(_line)) {
return true; return true;
} }

View File

@ -14,10 +14,8 @@
#include <ewol/physicsShape/PhysicsShape.h> #include <ewol/physicsShape/PhysicsShape.h>
namespace ewol namespace ewol {
{ class PhysicsConvexHull : public ewol::PhysicsShape {
class PhysicsConvexHull : public ewol::PhysicsShape
{
public: public:
PhysicsConvexHull(void) {}; PhysicsConvexHull(void) {};
virtual ~PhysicsConvexHull(void) {}; virtual ~PhysicsConvexHull(void) {};

View File

@ -9,8 +9,7 @@
#include <ewol/physicsShape/PhysicsCylinder.h> #include <ewol/physicsShape/PhysicsCylinder.h>
bool ewol::PhysicsCylinder::parse(const char* _line) bool ewol::PhysicsCylinder::parse(const char* _line) {
{
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ewol::PhysicsShape::parse(_line)) {
return true; return true;
} }

View File

@ -14,10 +14,8 @@
#include <ewol/physicsShape/PhysicsShape.h> #include <ewol/physicsShape/PhysicsShape.h>
namespace ewol namespace ewol {
{ class PhysicsCylinder : public ewol::PhysicsShape {
class PhysicsCylinder : public ewol::PhysicsShape
{
public: public:
PhysicsCylinder(void) {}; PhysicsCylinder(void) {};
virtual ~PhysicsCylinder(void) {}; virtual ~PhysicsCylinder(void) {};

View File

@ -15,8 +15,7 @@
#include <ewol/physicsShape/PhysicsSphere.h> #include <ewol/physicsShape/PhysicsSphere.h>
ewol::PhysicsShape* ewol::PhysicsShape::create(const etk::UString& _name) ewol::PhysicsShape* ewol::PhysicsShape::create(const etk::UString& _name) {
{
ewol::PhysicsShape* tmpp = NULL; ewol::PhysicsShape* tmpp = NULL;
etk::UString name = _name.toLower(); etk::UString name = _name.toLower();
if (name == "box") { if (name == "box") {
@ -42,8 +41,7 @@ ewol::PhysicsShape* ewol::PhysicsShape::create(const etk::UString& _name)
} }
bool ewol::PhysicsShape::parse(const char* _line) bool ewol::PhysicsShape::parse(const char* _line) {
{
if(0 == strncmp(_line, "origin : ", 9) ) { if(0 == strncmp(_line, "origin : ", 9) ) {
sscanf(&_line[9], "%f %f %f", &m_origin.m_floats[0], &m_origin.m_floats[1], &m_origin.m_floats[2] ); sscanf(&_line[9], "%f %f %f", &m_origin.m_floats[0], &m_origin.m_floats[1], &m_origin.m_floats[2] );
EWOL_DEBUG(" Origin=" << m_origin); EWOL_DEBUG(" Origin=" << m_origin);

View File

@ -16,8 +16,7 @@
#include <etk/math/Vector3D.h> #include <etk/math/Vector3D.h>
namespace ewol namespace ewol {
{
class PhysicsBox; class PhysicsBox;
class PhysicsCylinder; class PhysicsCylinder;
class PhysicsCapsule; class PhysicsCapsule;
@ -25,8 +24,7 @@ namespace ewol
class PhysicsConvexHull; class PhysicsConvexHull;
class PhysicsSphere; class PhysicsSphere;
class PhysicsShape class PhysicsShape {
{
public: public:
static PhysicsShape* create(const etk::UString& _name); static PhysicsShape* create(const etk::UString& _name);
public: public:

View File

@ -10,8 +10,7 @@
bool ewol::PhysicsSphere::parse(const char* _line) bool ewol::PhysicsSphere::parse(const char* _line) {
{
if (true == ewol::PhysicsShape::parse(_line)) { if (true == ewol::PhysicsShape::parse(_line)) {
return true; return true;
} }

View File

@ -14,10 +14,8 @@
#include <ewol/physicsShape/PhysicsShape.h> #include <ewol/physicsShape/PhysicsShape.h>
namespace ewol namespace ewol {
{ class PhysicsSphere : public ewol::PhysicsShape {
class PhysicsSphere : public ewol::PhysicsShape
{
public: public:
PhysicsSphere(void) {}; PhysicsSphere(void) {};
virtual ~PhysicsSphere(void) {}; virtual ~PhysicsSphere(void) {};

View File

@ -20,8 +20,7 @@
int64_t ewol::getTime(void) int64_t ewol::getTime(void) {
{
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
@ -41,8 +40,7 @@ void java_check_exception(JNIEnv* _env) {
} }
} }
class AndroidContext : public ewol::eContext class AndroidContext : public ewol::eContext {
{
public: public:
typedef enum { typedef enum {
appl_unknow, appl_unknow,
@ -66,8 +64,7 @@ class AndroidContext : public ewol::eContext
ewol::SpecialKey m_guiKeyBoardSpecialKeyMode;//!< special key of the android system : ewol::SpecialKey m_guiKeyBoardSpecialKeyMode;//!< special key of the android system :
bool m_clipBoardOwnerStd; bool m_clipBoardOwnerStd;
private: private:
bool SafeInitMethodID(jmethodID& _mid, jclass& _cls, char* _name, char* _sign) bool SafeInitMethodID(jmethodID& _mid, jclass& _cls, char* _name, char* _sign) {
{
_mid = m_JavaVirtualMachinePointer->getMethodID(_cls, _name, _sign); _mid = m_JavaVirtualMachinePointer->getMethodID(_cls, _name, _sign);
if(_mid == NULL) { if(_mid == NULL) {
EWOL_ERROR("C->java : Can't find the method " << _name); EWOL_ERROR("C->java : Can't find the method " << _name);
@ -79,20 +76,19 @@ class AndroidContext : public ewol::eContext
} }
public: public:
AndroidContext(JNIEnv* _env, jclass _classBase, jobject _objCallback, application_te _typeAPPL) : AndroidContext(JNIEnv* _env, jclass _classBase, jobject _objCallback, application_te _typeAPPL) :
m_javaApplicationType(_typeAPPL), m_javaApplicationType(_typeAPPL),
m_JavaVirtualMachinePointer(NULL), m_JavaVirtualMachinePointer(NULL),
m_javaClassEwol(0), m_javaClassEwol(0),
m_javaClassEwolCallback(0), m_javaClassEwolCallback(0),
m_javaObjectEwolCallback(0), m_javaObjectEwolCallback(0),
m_javaMethodEwolCallbackStop(0), m_javaMethodEwolCallbackStop(0),
m_javaMethodEwolCallbackEventNotifier(0), m_javaMethodEwolCallbackEventNotifier(0),
m_javaMethodEwolCallbackKeyboardUpdate(0), m_javaMethodEwolCallbackKeyboardUpdate(0),
m_javaMethodEwolCallbackOrientationUpdate(0), m_javaMethodEwolCallbackOrientationUpdate(0),
m_javaMethodEwolActivitySetTitle(0), m_javaMethodEwolActivitySetTitle(0),
m_javaDefaultClassString(0), m_javaDefaultClassString(0),
m_currentHeight(0), m_currentHeight(0),
m_clipBoardOwnerStd(false) m_clipBoardOwnerStd(false) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
if (m_javaApplicationType == appl_application) { if (m_javaApplicationType == appl_application) {
EWOL_DEBUG("** set JVM Pointer (application) **"); EWOL_DEBUG("** set JVM Pointer (application) **");
@ -177,26 +173,21 @@ class AndroidContext : public ewol::eContext
} }
} }
~AndroidContext(void) ~AndroidContext(void) {
{
// TODO ... // TODO ...
} }
void UnInit(JNIEnv* _env) void UnInit(JNIEnv* _env) {
{
_env->DeleteGlobalRef(m_javaObjectEwolCallback); _env->DeleteGlobalRef(m_javaObjectEwolCallback);
m_javaObjectEwolCallback = NULL; m_javaObjectEwolCallback = NULL;
} }
int32_t Run(void) {
int32_t Run(void)
{
// might never be called !!! // might never be called !!!
return -1; return -1;
} }
void Stop(void) void Stop(void) {
{
EWOL_DEBUG("C->java : send message to the java : STOP REQUESTED"); EWOL_DEBUG("C->java : send message to the java : STOP REQUESTED");
int status; int status;
if(!java_attach_current_thread(&status)) { if(!java_attach_current_thread(&status)) {
@ -209,13 +200,11 @@ class AndroidContext : public ewol::eContext
java_detach_current_thread(status); java_detach_current_thread(status);
} }
void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
// this is to force the local system to think we have the buffer // this is to force the local system to think we have the buffer
// TODO : remove this 2 line when code will be writen // TODO : remove this 2 line when code will be writen
m_clipBoardOwnerStd = true; m_clipBoardOwnerStd = true;
switch (_clipboardID) switch (_clipboardID) {
{
case ewol::clipBoard::clipboardSelection: case ewol::clipBoard::clipboardSelection:
// NOTE : Windows does not support the middle button the we do it internaly // NOTE : Windows does not support the middle button the we do it internaly
// just transmit an event , we have the data in the system // just transmit an event , we have the data in the system
@ -236,10 +225,8 @@ class AndroidContext : public ewol::eContext
} }
} }
void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{ switch (_clipboardID) {
switch (_clipboardID)
{
case ewol::clipBoard::clipboardSelection: case ewol::clipBoard::clipboardSelection:
// NOTE : nothing to do : Windows deas ot supported Middle button // NOTE : nothing to do : Windows deas ot supported Middle button
break; break;
@ -255,10 +242,7 @@ class AndroidContext : public ewol::eContext
break; break;
} }
} }
private: private:
bool java_attach_current_thread(int *_rstatus) { bool java_attach_current_thread(int *_rstatus) {
EWOL_DEBUG("C->java : call java"); EWOL_DEBUG("C->java : call java");
if (NULL == g_JavaVM) { if (NULL == g_JavaVM) {
@ -289,8 +273,7 @@ class AndroidContext : public ewol::eContext
} }
void SendJavaKeyboardUpdate(jboolean _showIt) void SendJavaKeyboardUpdate(jboolean _showIt) {
{
int status; int status;
if(!java_attach_current_thread(&status)) { if(!java_attach_current_thread(&status)) {
return; return;
@ -302,12 +285,15 @@ class AndroidContext : public ewol::eContext
java_check_exception(m_JavaVirtualMachinePointer); java_check_exception(m_JavaVirtualMachinePointer);
java_detach_current_thread(status); java_detach_current_thread(status);
} }
void KeyboardShow(void) { SendJavaKeyboardUpdate(JNI_TRUE); }; void KeyboardShow(void) {
void KeyboardHide(void) { SendJavaKeyboardUpdate(JNI_FALSE); }; SendJavaKeyboardUpdate(JNI_TRUE);
};
void KeyboardHide(void) {
SendJavaKeyboardUpdate(JNI_FALSE);
};
// mode 0 : auto; 1 landscape, 2 portrait // mode 0 : auto; 1 landscape, 2 portrait
void forceOrientation(ewol::orientation_te _orientation) void forceOrientation(ewol::orientation_te _orientation) {
{
#ifndef __ANDROID_PERMISSION__SET_ORIENTATION__ #ifndef __ANDROID_PERMISSION__SET_ORIENTATION__
EWOL_ERROR("C->java : call set orientation without Allow application to do it ... Break..."); EWOL_ERROR("C->java : call set orientation without Allow application to do it ... Break...");
return; return;
@ -327,8 +313,7 @@ class AndroidContext : public ewol::eContext
#endif #endif
} }
void setTitle(etk::UString& _title) void setTitle(etk::UString& _title) {
{
EWOL_DEBUG("C->java : send message to the java : \"" << _title << "\""); EWOL_DEBUG("C->java : send message to the java : \"" << _title << "\"");
if (m_javaApplicationType == appl_application) { if (m_javaApplicationType == appl_application) {
int status; int status;
@ -350,8 +335,7 @@ class AndroidContext : public ewol::eContext
void SendSystemMessage(const char* _dataString) void SendSystemMessage(const char* _dataString) {
{
EWOL_DEBUG("C->java : send message to the java : \"" << _dataString << "\""); EWOL_DEBUG("C->java : send message to the java : \"" << _dataString << "\"");
int status; int status;
if(!java_attach_current_thread(&status)) { if(!java_attach_current_thread(&status)) {
@ -385,31 +369,27 @@ class AndroidContext : public ewol::eContext
java_detach_current_thread(status); java_detach_current_thread(status);
} }
public: public:
void OS_SetInputMotion(int _pointerID, const vec2& _pos) void OS_SetInputMotion(int _pointerID, const vec2& _pos) {
{
ewol::eContext::OS_SetInputMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); ewol::eContext::OS_SetInputMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) );
} }
void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos) void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos) {
{
ewol::eContext::OS_SetInputState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); ewol::eContext::OS_SetInputState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) );
} }
void OS_SetMouseMotion(int _pointerID, const vec2& _pos) void OS_SetMouseMotion(int _pointerID, const vec2& _pos) {
{
ewol::eContext::OS_SetMouseMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); ewol::eContext::OS_SetMouseMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) );
} }
void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos) void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos) {
{
ewol::eContext::OS_SetMouseState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); ewol::eContext::OS_SetMouseState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) );
} }
void ANDROID_SetKeyboard(uniChar_t _myChar, bool _isDown, bool _isARepeateKey=false)
{ void ANDROID_SetKeyboard(uniChar_t _myChar, bool _isDown, bool _isARepeateKey=false) {
OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey); OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey);
} }
void OS_Resize(const vec2& _size)
{ void OS_Resize(const vec2& _size) {
m_currentHeight = _size.y(); m_currentHeight = _size.y();
ewol::eContext::OS_Resize(_size); ewol::eContext::OS_Resize(_size);
} }
@ -420,23 +400,24 @@ static etk::Vector<AndroidContext*> s_listInstance;
extern "C" extern "C"
{ {
// JNI onLoad // JNI onLoad
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* _jvm, void* _reserved) JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* _jvm, void* _reserved) {
{
// get the java virtual machine handle ... // get the java virtual machine handle ...
g_JavaVM = _jvm; g_JavaVM = _jvm;
EWOL_DEBUG("JNI-> load the jvm ..." ); EWOL_DEBUG("JNI-> load the jvm ..." );
return JNI_VERSION_1_6; return JNI_VERSION_1_6;
} }
// JNI onUnLoad // JNI onUnLoad
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* _vm, void *_reserved) JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* _vm, void *_reserved) {
{
g_JavaVM = NULL; g_JavaVM = NULL;
EWOL_DEBUG("JNI-> Un-load the jvm ..." ); EWOL_DEBUG("JNI-> Un-load the jvm ..." );
} }
/* Call to initialize the graphics state */ /* Call to initialize the graphics state */
void Java_org_ewol_Ewol_EWparamSetArchiveDir(JNIEnv* _env, jclass _cls, jint _id, jint _mode, jstring _myString) void Java_org_ewol_Ewol_EWparamSetArchiveDir(JNIEnv* _env,
{ jclass _cls,
jint _id,
jint _mode,
jstring _myString) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -456,8 +437,10 @@ extern "C"
} }
} }
jint Java_org_ewol_Ewol_EWsetJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback, int _typeApplication) jint Java_org_ewol_Ewol_EWsetJavaVirtualMachineStart(JNIEnv* _env,
{ jclass _classBase,
jobject _objCallback,
int _typeApplication) {
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Creating EWOL context **"); EWOL_DEBUG("** Creating EWOL context **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -480,8 +463,7 @@ extern "C"
return newID; return newID;
} }
void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id) void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** remove JVM Pointer **"); EWOL_DEBUG("** remove JVM Pointer **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -498,8 +480,7 @@ extern "C"
delete(s_listInstance[_id]); delete(s_listInstance[_id]);
s_listInstance[_id]=NULL; s_listInstance[_id]=NULL;
} }
void Java_org_ewol_Ewol_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG(" == > Touch Event"); EWOL_DEBUG(" == > Touch Event");
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
@ -511,8 +492,7 @@ extern "C"
java_check_exception(_env); java_check_exception(_env);
} }
void Java_org_ewol_Ewol_EWonCreate(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonCreate(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Create **"); EWOL_DEBUG("** Activity on Create **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -526,8 +506,7 @@ extern "C"
//s_listInstance[_id]->init(); //s_listInstance[_id]->init();
} }
void Java_org_ewol_Ewol_EWonStart(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonStart(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Start **"); EWOL_DEBUG("** Activity on Start **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -540,8 +519,7 @@ extern "C"
} }
//SendSystemMessage(" testmessages ... "); //SendSystemMessage(" testmessages ... ");
} }
void Java_org_ewol_Ewol_EWonReStart(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonReStart(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Re-Start **"); EWOL_DEBUG("** Activity on Re-Start **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -553,8 +531,7 @@ extern "C"
return; return;
} }
} }
void Java_org_ewol_Ewol_EWonResume(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonResume(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on resume **"); EWOL_DEBUG("** Activity on resume **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -567,8 +544,7 @@ extern "C"
} }
s_listInstance[_id]->OS_Resume(); s_listInstance[_id]->OS_Resume();
} }
void Java_org_ewol_Ewol_EWonPause(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonPause(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on pause **"); EWOL_DEBUG("** Activity on pause **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -583,8 +559,7 @@ extern "C"
s_listInstance[_id]->getResourcesManager().ContextHasBeenDestroyed(); s_listInstance[_id]->getResourcesManager().ContextHasBeenDestroyed();
s_listInstance[_id]->OS_Suspend(); s_listInstance[_id]->OS_Suspend();
} }
void Java_org_ewol_Ewol_EWonStop(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonStop(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Stop **"); EWOL_DEBUG("** Activity on Stop **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -597,8 +572,7 @@ extern "C"
} }
s_listInstance[_id]->OS_Stop(); s_listInstance[_id]->OS_Stop();
} }
void Java_org_ewol_Ewol_EWonDestroy(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWonDestroy(JNIEnv* _env, jobject _thiz, jint _id) {
{
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Destroy **"); EWOL_DEBUG("** Activity on Destroy **");
EWOL_DEBUG("*******************************************"); EWOL_DEBUG("*******************************************");
@ -617,8 +591,12 @@ extern "C"
/* ********************************************************************************************** /* **********************************************************************************************
* ** IO section : * ** IO section :
* ********************************************************************************************** */ * ********************************************************************************************** */
void Java_org_ewol_Ewol_EWinputEventMotion(JNIEnv* _env, jobject _thiz, jint _id, jint _pointerID, jfloat _x, jfloat _y ) void Java_org_ewol_Ewol_EWinputEventMotion(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _pointerID,
jfloat _x,
jfloat _y) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -629,8 +607,13 @@ extern "C"
s_listInstance[_id]->OS_SetInputMotion(_pointerID+1, vec2(_x,_y)); 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) void Java_org_ewol_Ewol_EWinputEventState(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _pointerID,
jboolean _isUp,
jfloat _x,
jfloat _y) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -641,8 +624,12 @@ extern "C"
s_listInstance[_id]->OS_SetInputState(_pointerID+1, _isUp, vec2(_x,_y)); 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) void Java_org_ewol_Ewol_EWmouseEventMotion(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _pointerID,
jfloat _x,
jfloat _y) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -653,8 +640,13 @@ extern "C"
s_listInstance[_id]->OS_SetMouseMotion(_pointerID+1, vec2(_x,_y)); 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) void Java_org_ewol_Ewol_EWmouseEventState(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _pointerID,
jboolean _isUp,
jfloat _x,
jfloat _y) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -665,8 +657,10 @@ extern "C"
s_listInstance[_id]->OS_SetMouseState(_pointerID+1, _isUp, vec2(_x,_y)); 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) void Java_org_ewol_Ewol_EWunknowEvent(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _pointerID) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -677,8 +671,11 @@ extern "C"
EWOL_DEBUG("Unknown IO event : " << _pointerID << " ???"); EWOL_DEBUG("Unknown IO event : " << _pointerID << " ???");
} }
void Java_org_ewol_Ewol_EWkeyboardEventMove(JNIEnv* _env, jobject _thiz, jint _id, jint _type, jboolean _isdown) void Java_org_ewol_Ewol_EWkeyboardEventMove(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _type,
jboolean _isdown) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -689,8 +686,11 @@ extern "C"
EWOL_DEBUG("IO keyboard Move event : \"" << _type << "\" is down=" << _isdown); EWOL_DEBUG("IO keyboard Move event : \"" << _type << "\" is down=" << _isdown);
} }
void Java_org_ewol_Ewol_EWkeyboardEventKey(JNIEnv* _env, jobject _thiz, jint _id, jint _uniChar, jboolean _isdown) void Java_org_ewol_Ewol_EWkeyboardEventKey(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _uniChar,
jboolean _isdown) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -702,8 +702,11 @@ extern "C"
s_listInstance[_id]->ANDROID_SetKeyboard(_uniChar, _isdown); s_listInstance[_id]->ANDROID_SetKeyboard(_uniChar, _isdown);
} }
void Java_org_ewol_Ewol_EWdisplayPropertyMetrics(JNIEnv* _env, jobject _thiz, jint _id, jfloat _ratioX, jfloat _ratioY) void Java_org_ewol_Ewol_EWdisplayPropertyMetrics(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jfloat _ratioX,
jfloat _ratioY) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -716,8 +719,11 @@ extern "C"
} }
// TODO : set a return true or false if we want to grep this event ... // TODO : set a return true or false if we want to grep this event ...
void Java_org_ewol_Ewol_EWkeyboardEventKeySystem(JNIEnv* _env, jobject _thiz, jint _id, jint _keyVal, jboolean _isdown) void Java_org_ewol_Ewol_EWkeyboardEventKeySystem(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _keyVal,
jboolean _isdown) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -754,8 +760,9 @@ extern "C"
/* ********************************************************************************************** /* **********************************************************************************************
* ** Renderer section : * ** Renderer section :
* ********************************************************************************************** */ * ********************************************************************************************** */
void Java_org_ewol_Ewol_EWrenderInit(JNIEnv* _env, jobject _thiz, jint _id) void Java_org_ewol_Ewol_EWrenderInit(JNIEnv* _env,
{ jobject _thiz,
jint _id) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -766,8 +773,11 @@ extern "C"
} }
void Java_org_ewol_Ewol_EWrenderResize( JNIEnv* _env, jobject _thiz, jint _id, jint _w, jint _h ) void Java_org_ewol_Ewol_EWrenderResize(JNIEnv* _env,
{ jobject _thiz,
jint _id,
jint _w,
jint _h) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -779,8 +789,9 @@ extern "C"
} }
// TODO : Return tur or foalse to not redraw when the under draw has not be done (processing gain of time) // TODO : Return tur or foalse 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) void Java_org_ewol_Ewol_EWrenderDraw(JNIEnv* _env,
{ jobject _thiz,
jint _id) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -791,8 +802,12 @@ extern "C"
s_listInstance[_id]->OS_Draw(true); s_listInstance[_id]->OS_Draw(true);
} }
void Java_org_ewol_Ewol_EWaudioPlayback(JNIEnv* _env, void* _reserved, jint _id, jshortArray _location, jint _frameRate, jint _nbChannels) void Java_org_ewol_Ewol_EWaudioPlayback(JNIEnv* _env,
{ void* _reserved,
jint _id,
jshortArray _location,
jint _frameRate,
jint _nbChannels) {
if( _id >= s_listInstance.size() if( _id >= s_listInstance.size()
|| _id<0 || _id<0
|| NULL == s_listInstance[_id] ) { || NULL == s_listInstance[_id] ) {
@ -816,7 +831,6 @@ extern "C"
}; };
int ewol::Run(int _argc, const char *_argv[]) int ewol::Run(int _argc, const char *_argv[]) {
{
// Never call but needed ... // Never call but needed ...
} }

View File

@ -10,25 +10,22 @@
#include <ewol/resources/FontFreeType.h> #include <ewol/resources/FontFreeType.h>
#undef __class__ #undef __class__
#define __class__ "ConfigFont" #define __class__ "ConfigFont"
ewol::ConfigFont::ConfigFont(void) : ewol::ConfigFont::ConfigFont(void) :
m_folder("DATA:fonts"), m_folder("DATA:fonts"),
m_name("Arial;Helvetica"), m_name("Arial;Helvetica"),
m_size(10), m_size(10),
m_useExternal(false) m_useExternal(false) {
{
ewol::freeTypeInit(); ewol::freeTypeInit();
} }
ewol::ConfigFont::~ConfigFont(void) ewol::ConfigFont::~ConfigFont(void) {
{
// UnInit FreeTypes // UnInit FreeTypes
ewol::freeTypeUnInit(); ewol::freeTypeUnInit();
} }
void ewol::ConfigFont::set(const etk::UString& _fontName, int32_t _size) void ewol::ConfigFont::set(const etk::UString& _fontName, int32_t _size) {
{
m_name = _fontName; m_name = _fontName;
m_size = _size; m_size = _size;
} }

View File

@ -11,16 +11,14 @@
#undef __class__ #undef __class__
#define __class__ "EConfig" #define __class__ "EConfig"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EConfig& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EConfig& _obj) {
{
_os << "{"; _os << "{";
_os << "config=\"" << _obj.getConfig() << "\""; _os << "config=\"" << _obj.getConfig() << "\"";
_os << " data=\"" << _obj.getData() << "\"}"; _os << " data=\"" << _obj.getData() << "\"}";
return _os; return _os;
} }
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EConfigElement& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EConfigElement& _obj) {
{
_os << "{"; _os << "{";
if (NULL != _obj.getConfig()) { if (NULL != _obj.getConfig()) {
_os << "config=\"" << _obj.getConfig() << "\""; _os << "config=\"" << _obj.getConfig() << "\"";

View File

@ -9,10 +9,9 @@
#include <ewol/renderer/EObject.h> #include <ewol/renderer/EObject.h>
#undef __class__ #undef __class__
#define __class__ "EMessage" #define __class__ "EMessage"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EMessage& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EMessage& _obj) {
{
_os << "{"; _os << "{";
if (NULL != _obj.getMessage()) { if (NULL != _obj.getMessage()) {
_os << "msg=\"" << _obj.getMessage() << "\""; _os << "msg=\"" << _obj.getMessage() << "\"";

View File

@ -11,23 +11,20 @@
#include <ewol/renderer/eContext.h> #include <ewol/renderer/eContext.h>
#undef __class__ #undef __class__
#define __class__ "EMultiCast" #define __class__ "EMultiCast"
ewol::EMultiCast::EMultiCast(void) ewol::EMultiCast::EMultiCast(void) {
{
EWOL_INFO("EObject message Multi-Cast"); EWOL_INFO("EObject message Multi-Cast");
} }
ewol::EMultiCast::~EMultiCast(void) ewol::EMultiCast::~EMultiCast(void) {
{
EWOL_INFO("EObject message Multi-Cast"); EWOL_INFO("EObject message Multi-Cast");
m_messageList.clear(); m_messageList.clear();
} }
void ewol::EMultiCast::add(ewol::EObject* _object, const char* const _message) void ewol::EMultiCast::add(ewol::EObject* _object, const char* const _message) {
{
if (NULL == _object) { if (NULL == _object) {
EWOL_ERROR("Add with NULL object"); EWOL_ERROR("Add with NULL object");
return; return;
@ -41,8 +38,7 @@ void ewol::EMultiCast::add(ewol::EObject* _object, const char* const _message)
} }
void ewol::EMultiCast::rm(ewol::EObject* _object) void ewol::EMultiCast::rm(ewol::EObject* _object) {
{
if (NULL == _object) { if (NULL == _object) {
EWOL_ERROR("Rm with NULL object"); EWOL_ERROR("Rm with NULL object");
return; return;
@ -58,8 +54,7 @@ void ewol::EMultiCast::rm(ewol::EObject* _object)
} }
} }
void ewol::EMultiCast::send(ewol::EObject* _object, const char* const _message, const etk::UString& _data) void ewol::EMultiCast::send(ewol::EObject* _object, const char* const _message, const etk::UString& _data) {
{
EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to :"); EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to :");
// send the message at all registered widget ... // send the message at all registered widget ...

View File

@ -17,8 +17,7 @@
#include <ewol/renderer/EObject.h> #include <ewol/renderer/EObject.h>
namespace ewol { namespace ewol {
class EMultiCast class EMultiCast {
{
private: private:
class MessageList { class MessageList {
public: public:

View File

@ -19,8 +19,7 @@ const char* const ewol::EObject::configName = "name";
ewol::EObject::EObject(void) : ewol::EObject::EObject(void) :
m_static(false) m_static(false) {
{
static int32_t ss_globalUniqueId = 0; static int32_t ss_globalUniqueId = 0;
// note this is nearly atomic ... (but it is enough) // note this is nearly atomic ... (but it is enough)
m_uniqueId = ss_globalUniqueId++; m_uniqueId = ss_globalUniqueId++;
@ -29,8 +28,7 @@ ewol::EObject::EObject(void) :
registerConfig(ewol::EObject::configName, "string", NULL, "EObject name, might be a unique reference in all the program"); registerConfig(ewol::EObject::configName, "string", NULL, "EObject name, might be a unique reference in all the program");
} }
ewol::EObject::~EObject(void) ewol::EObject::~EObject(void) {
{
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]"); EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
getEObjectManager().rm(this); getEObjectManager().rm(this);
getMultiCast().rm(this); getMultiCast().rm(this);
@ -45,25 +43,21 @@ ewol::EObject::~EObject(void)
m_uniqueId = -1; m_uniqueId = -1;
} }
void ewol::EObject::autoDestroy(void) {
void ewol::EObject::autoDestroy(void)
{
getEObjectManager().autoRemove(this);
}
void ewol::EObject::removeObject(void)
{
getEObjectManager().autoRemove(this); getEObjectManager().autoRemove(this);
} }
void ewol::EObject::addEventId(const char * _generateEventId) void ewol::EObject::removeObject(void) {
{ getEObjectManager().autoRemove(this);
}
void ewol::EObject::addEventId(const char * _generateEventId) {
if (NULL != _generateEventId) { if (NULL != _generateEventId) {
m_availlableEventId.pushBack(_generateEventId); m_availlableEventId.pushBack(_generateEventId);
} }
} }
void ewol::EObject::generateEventId(const char * _generateEventId, const etk::UString& _data) void ewol::EObject::generateEventId(const char * _generateEventId, const etk::UString& _data) {
{
int32_t nbObject = getEObjectManager().getNumberObject(); int32_t nbObject = getEObjectManager().getNumberObject();
// for every element registered ... // for every element registered ...
for (int32_t iii=0; iii<m_externEvent.size(); iii++) { for (int32_t iii=0; iii<m_externEvent.size(); iii++) {
@ -88,8 +82,7 @@ void ewol::EObject::generateEventId(const char * _generateEventId, const etk::US
} }
} }
void ewol::EObject::sendMultiCast(const char* const _messageId, const etk::UString& _data) void ewol::EObject::sendMultiCast(const char* const _messageId, const etk::UString& _data) {
{
int32_t nbObject = getEObjectManager().getNumberObject(); int32_t nbObject = getEObjectManager().getNumberObject();
getMultiCast().send(this, _messageId, _data); getMultiCast().send(this, _messageId, _data);
if (nbObject > getEObjectManager().getNumberObject()) { if (nbObject > getEObjectManager().getNumberObject()) {
@ -97,16 +90,14 @@ void ewol::EObject::sendMultiCast(const char* const _messageId, const etk::UStri
} }
} }
void ewol::EObject::registerMultiCast(const char* const _messageId) void ewol::EObject::registerMultiCast(const char* const _messageId) {
{
getMultiCast().add(this, _messageId); getMultiCast().add(this, _messageId);
} }
void ewol::EObject::registerOnEvent(ewol::EObject * _destinationObject, void ewol::EObject::registerOnEvent(ewol::EObject * _destinationObject,
const char * _eventId, const char * _eventId,
const char * _eventIdgenerated, const char * _eventIdgenerated,
const etk::UString& _overloadData) const etk::UString& _overloadData) {
{
if (NULL == _destinationObject) { if (NULL == _destinationObject) {
EWOL_ERROR("Input ERROR NULL pointer EObject ..."); EWOL_ERROR("Input ERROR NULL pointer EObject ...");
return; return;
@ -154,8 +145,7 @@ void ewol::EObject::registerOnEvent(ewol::EObject * _destinationObject,
} }
void ewol::EObject::onObjectRemove(ewol::EObject * _removeObject) void ewol::EObject::onObjectRemove(ewol::EObject * _removeObject) {
{
for(int32_t iii=m_externEvent.size()-1; iii >= 0; iii--) { for(int32_t iii=m_externEvent.size()-1; iii >= 0; iii--) {
if (NULL == m_externEvent[iii]) { if (NULL == m_externEvent[iii]) {
m_externEvent.erase(iii); m_externEvent.erase(iii);
@ -166,8 +156,11 @@ void ewol::EObject::onObjectRemove(ewol::EObject * _removeObject)
} }
void ewol::EObject::registerConfig(const char* _config, const char* _type, const char* _control, const char* _description, const char* _default) void ewol::EObject::registerConfig(const char* _config,
{ const char* _type,
const char* _control,
const char* _description,
const char* _default) {
if (NULL == _config) { if (NULL == _config) {
EWOL_ERROR("Try to add NULL config"); EWOL_ERROR("Try to add NULL config");
return; return;
@ -183,8 +176,7 @@ void ewol::EObject::registerConfig(const char* _config, const char* _type, const
} }
bool ewol::EObject::loadXML(exml::Element* _node) bool ewol::EObject::loadXML(exml::Element* _node) {
{
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }
@ -205,8 +197,7 @@ bool ewol::EObject::loadXML(exml::Element* _node)
return errorOccured; return errorOccured;
} }
bool ewol::EObject::storeXML(exml::Element* _node) const bool ewol::EObject::storeXML(exml::Element* _node) const {
{
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }
@ -229,8 +220,7 @@ bool ewol::EObject::storeXML(exml::Element* _node) const
} }
bool ewol::EObject::onSetConfig(const ewol::EConfig& _conf) bool ewol::EObject::onSetConfig(const ewol::EConfig& _conf) {
{
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config : " << _conf); EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config : " << _conf);
if (_conf.getConfig() == ewol::EObject::configName) { if (_conf.getConfig() == ewol::EObject::configName) {
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config name : \"" << _conf.getData() << "\""); EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set config name : \"" << _conf.getData() << "\"");
@ -240,17 +230,15 @@ bool ewol::EObject::onSetConfig(const ewol::EConfig& _conf)
return false; return false;
} }
bool ewol::EObject::onGetConfig(const char* _config, etk::UString& _result) const bool ewol::EObject::onGetConfig(const char* _config, etk::UString& _result) const {
{
if (_config == ewol::EObject::configName) { if (_config == ewol::EObject::configName) {
_result = getName(); _result = getName();
return true; return true;
} }
return false; return false;
}; }
bool ewol::EObject::setConfig(const etk::UString& _config, const etk::UString& _value) bool ewol::EObject::setConfig(const etk::UString& _config, const etk::UString& _value) {
{
for(int32_t iii=0 ; iii<m_listConfig.size() ; iii++) { for(int32_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (NULL != m_listConfig[iii].getConfig()) { if (NULL != m_listConfig[iii].getConfig()) {
if (_config == m_listConfig[iii].getConfig() ) { if (_config == m_listConfig[iii].getConfig() ) {
@ -263,17 +251,15 @@ bool ewol::EObject::setConfig(const etk::UString& _config, const etk::UString& _
return false; return false;
} }
etk::UString ewol::EObject::getConfig(const char* _config) const etk::UString ewol::EObject::getConfig(const char* _config) const {
{
etk::UString res=""; etk::UString res="";
if (NULL != _config) { if (NULL != _config) {
(void)onGetConfig(_config, res); (void)onGetConfig(_config, res);
} }
return res; return res;
}; }
etk::UString ewol::EObject::getConfig(const etk::UString& _config) const etk::UString ewol::EObject::getConfig(const etk::UString& _config) const {
{
for(int32_t iii=0 ; iii<m_listConfig.size() ; iii++) { for(int32_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (NULL != m_listConfig[iii].getConfig()) { if (NULL != m_listConfig[iii].getConfig()) {
if (_config == m_listConfig[iii].getConfig() ) { if (_config == m_listConfig[iii].getConfig() ) {
@ -286,9 +272,7 @@ etk::UString ewol::EObject::getConfig(const etk::UString& _config) const
return ""; return "";
} }
bool ewol::EObject::setConfigNamed(const etk::UString& _name, const ewol::EConfig& _conf) {
bool ewol::EObject::setConfigNamed(const etk::UString& _name, const ewol::EConfig& _conf)
{
ewol::EObject* object = getEObjectManager().get(_name); ewol::EObject* object = getEObjectManager().get(_name);
if (object == NULL) { if (object == NULL) {
return false; return false;
@ -296,8 +280,7 @@ bool ewol::EObject::setConfigNamed(const etk::UString& _name, const ewol::EConfi
return object->setConfig(_conf); return object->setConfig(_conf);
} }
bool ewol::EObject::setConfigNamed(const etk::UString& _name, const etk::UString& _config, const etk::UString& _value) bool ewol::EObject::setConfigNamed(const etk::UString& _name, const etk::UString& _config, const etk::UString& _value) {
{
ewol::EObject* object = getEObjectManager().get(_name); ewol::EObject* object = getEObjectManager().get(_name);
if (object == NULL) { if (object == NULL) {
return false; return false;
@ -305,18 +288,14 @@ bool ewol::EObject::setConfigNamed(const etk::UString& _name, const etk::UString
return object->setConfig(_config, _value); return object->setConfig(_config, _value);
} }
ewol::EObjectManager& ewol::EObject::getEObjectManager(void) {
ewol::EObjectManager& ewol::EObject::getEObjectManager(void)
{
return ewol::getContext().getEObjectManager(); return ewol::getContext().getEObjectManager();
} }
ewol::EMultiCast& ewol::EObject::getMultiCast(void) ewol::EMultiCast& ewol::EObject::getMultiCast(void) {
{
return ewol::getContext().getEObjectManager().multiCast(); return ewol::getContext().getEObjectManager().multiCast();
} }
ewol::eContext& ewol::EObject::getContext(void) ewol::eContext& ewol::EObject::getContext(void) {
{
return ewol::getContext(); return ewol::getContext();
} }

View File

@ -25,7 +25,6 @@ namespace ewol {
#include <ewol/renderer/EMessage.h> #include <ewol/renderer/EMessage.h>
namespace ewol { namespace ewol {
/** /**
* local class for event generation * local class for event generation
*/ */
@ -36,7 +35,6 @@ namespace ewol {
const char* destEventId; //!< generated event ID on the distant widget const char* destEventId; //!< generated event ID on the distant widget
etk::UString overloadData; //!< sometimes the user prefer to receive some specific data on an event (instead of the one sed by the widget) etk::UString overloadData; //!< sometimes the user prefer to receive some specific data on an event (instead of the one sed by the widget)
}; };
/** /**
* @brief Basic message classes for ewol system * @brief Basic message classes for ewol system
* this class mermit at every EObject to communicate between them. * this class mermit at every EObject to communicate between them.
@ -56,34 +54,28 @@ namespace ewol {
* @brief Constructor * @brief Constructor
*/ */
EObject(void); EObject(void);
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~EObject(void); virtual ~EObject(void);
/** /**
* @brief get the static status of the EObject == > mark at true if the user set the object mark as static allocated element ==> not auto remove element * @brief get the static status of the EObject == > mark at true if the user set the object mark as static allocated element ==> not auto remove element
* @return true if it might not be removed == > usefull for conficuration class * @return true if it might not be removed == > usefull for conficuration class
*/ */
bool getStatic(void){ return m_static; }; bool getStatic(void){ return m_static; };
/** /**
* @brief get the UniqueId of the EObject * @brief get the UniqueId of the EObject
* @return the requested ID * @return the requested ID
*/ */
int32_t getId(void){ return m_uniqueId; }; int32_t getId(void){ return m_uniqueId; };
/** /**
* @brief Auto-destroy the object * @brief Auto-destroy the object
*/ */
void autoDestroy(void); void autoDestroy(void);
/** /**
* @brief Asynchronous removing the object * @brief Asynchronous removing the object
*/ */
void removeObject(void); void removeObject(void);
/** /**
* @brief get the current Object type of the EObject * @brief get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast == > this will replace it * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast == > this will replace it
@ -97,21 +89,18 @@ namespace ewol {
* @param[in] _generateEventId event Id to add * @param[in] _generateEventId event Id to add
*/ */
void addEventId(const char * _generateEventId); void addEventId(const char * _generateEventId);
/** /**
* @brief generate event on all registered EObject * @brief generate event on all registered EObject
* @param[in] _generateEventId event Id that is curetly generated * @param[in] _generateEventId event Id that is curetly generated
* @param[in] _data data associated with the event * @param[in] _data data associated with the event
*/ */
void generateEventId(const char * _generateEventId, const etk::UString& _data = ""); void generateEventId(const char * _generateEventId, const etk::UString& _data = "");
/** /**
* @brief generate Multicast event on all EObject requested the event * @brief generate Multicast event on all EObject requested the event
* @param[in] _messageId Event Id that is generated * @param[in] _messageId Event Id that is generated
* @param[in] _data String that is send at all the destinations * @param[in] _data String that is send at all the destinations
*/ */
void sendMultiCast(const char* const _messageId, const etk::UString& _data = ""); void sendMultiCast(const char* const _messageId, const etk::UString& _data = "");
/** /**
* @brief Register of the arrival of a Multicast message * @brief Register of the arrival of a Multicast message
* @param[in] _messageId Event Id waiting for... * @param[in] _messageId Event Id waiting for...
@ -129,14 +118,12 @@ namespace ewol {
const char * _eventId, const char * _eventId,
const char * _eventIdgenerated = NULL, const char * _eventIdgenerated = NULL,
const etk::UString& _overloadData=""); const etk::UString& _overloadData="");
/** /**
* @brief Inform object that an other object is removed ... * @brief Inform object that an other object is removed ...
* @param[in] _removeObject Pointer on the EObject remeved == > the user must remove all reference on this EObject * @param[in] _removeObject Pointer on the EObject remeved == > the user must remove all reference on this EObject
* @note : Sub classes must call this class * @note : Sub classes must call this class
*/ */
virtual void onObjectRemove(ewol::EObject * _removeObject); virtual void onObjectRemove(ewol::EObject * _removeObject);
/** /**
* @brief Receive a message from an other EObject with a specific eventId and data * @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] _msg Message handle * @param[in] _msg Message handle

View File

@ -11,18 +11,16 @@
#include <ewol/ewol.h> #include <ewol/ewol.h>
#undef __class__ #undef __class__
#define __class__ "EObjectManager" #define __class__ "EObjectManager"
ewol::EObjectManager::EObjectManager(void) ewol::EObjectManager::EObjectManager(void) {
{
EWOL_DEBUG(" == > init EObject-Manager"); EWOL_DEBUG(" == > init EObject-Manager");
// Can create mlemory leak ... == > but not predictable comportement otherwise ... // Can create mlemory leak ... == > but not predictable comportement otherwise ...
m_eObjectAutoRemoveList.clear(); m_eObjectAutoRemoveList.clear();
m_eObjectList.clear(); m_eObjectList.clear();
} }
ewol::EObjectManager::~EObjectManager(void) ewol::EObjectManager::~EObjectManager(void) {
{
bool hasError = false; bool hasError = false;
if (m_eObjectAutoRemoveList.size()!=0) { if (m_eObjectAutoRemoveList.size()!=0) {
EWOL_ERROR("Must not have anymore eObject to auto-remove !!!"); EWOL_ERROR("Must not have anymore eObject to auto-remove !!!");
@ -37,8 +35,7 @@ ewol::EObjectManager::~EObjectManager(void)
} }
} }
void ewol::EObjectManager::unInit(void) void ewol::EObjectManager::unInit(void) {
{
EWOL_DEBUG(" == > Un-Init EObject-Manager"); EWOL_DEBUG(" == > Un-Init EObject-Manager");
removeAllAutoRemove(); removeAllAutoRemove();
EWOL_INFO(" remove missing user widget"); EWOL_INFO(" remove missing user widget");
@ -58,8 +55,7 @@ void ewol::EObjectManager::unInit(void)
} }
} }
void ewol::EObjectManager::add(ewol::EObject* _object) void ewol::EObjectManager::add(ewol::EObject* _object) {
{
if (NULL != _object) { if (NULL != _object) {
m_eObjectList.pushBack(_object); m_eObjectList.pushBack(_object);
} else { } else {
@ -67,13 +63,11 @@ void ewol::EObjectManager::add(ewol::EObject* _object)
} }
} }
int32_t ewol::EObjectManager::getNumberObject(void) int32_t ewol::EObjectManager::getNumberObject(void) {
{
return m_eObjectList.size() + m_eObjectAutoRemoveList.size(); return m_eObjectList.size() + m_eObjectAutoRemoveList.size();
} }
void ewol::EObjectManager::informOneObjectIsRemoved(ewol::EObject* _object) void ewol::EObjectManager::informOneObjectIsRemoved(ewol::EObject* _object) {
{
for (int32_t iii=0; iii<m_eObjectList.size(); iii++) { for (int32_t iii=0; iii<m_eObjectList.size(); iii++) {
if (m_eObjectList[iii] != NULL) { if (m_eObjectList[iii] != NULL) {
m_eObjectList[iii]->onObjectRemove(_object); m_eObjectList[iii]->onObjectRemove(_object);
@ -89,8 +83,7 @@ void ewol::EObjectManager::informOneObjectIsRemoved(ewol::EObject* _object)
ewol::getContext().onObjectRemove(_object); ewol::getContext().onObjectRemove(_object);
} }
void ewol::EObjectManager::rm(ewol::EObject* _object) void ewol::EObjectManager::rm(ewol::EObject* _object) {
{
if (NULL == _object) { if (NULL == _object) {
EWOL_ERROR("Try to remove (NULL) EObject"); EWOL_ERROR("Try to remove (NULL) EObject");
return; return;
@ -115,8 +108,7 @@ void ewol::EObjectManager::rm(ewol::EObject* _object)
EWOL_ERROR("Try to remove EObject that is not referenced ..."); EWOL_ERROR("Try to remove EObject that is not referenced ...");
} }
void ewol::EObjectManager::autoRemove(ewol::EObject* _object) void ewol::EObjectManager::autoRemove(ewol::EObject* _object) {
{
if (NULL == _object) { if (NULL == _object) {
EWOL_ERROR("Try to Auto-Remove (NULL) EObject"); EWOL_ERROR("Try to Auto-Remove (NULL) EObject");
return; return;
@ -137,8 +129,7 @@ void ewol::EObjectManager::autoRemove(ewol::EObject* _object)
} }
// clean all EObject that request an autoRemove ... // clean all EObject that request an autoRemove ...
void ewol::EObjectManager::removeAllAutoRemove(void) void ewol::EObjectManager::removeAllAutoRemove(void) {
{
//EWOL_DEBUG("Auto-Remove EObject section : " << m_eObjectAutoRemoveList.size() << " elemeents"); //EWOL_DEBUG("Auto-Remove EObject section : " << m_eObjectAutoRemoveList.size() << " elemeents");
while(0<m_eObjectAutoRemoveList.size()) { while(0<m_eObjectAutoRemoveList.size()) {
if (m_eObjectAutoRemoveList[0]!=NULL) { if (m_eObjectAutoRemoveList[0]!=NULL) {
@ -152,8 +143,7 @@ void ewol::EObjectManager::removeAllAutoRemove(void)
m_eObjectAutoRemoveList.clear(); m_eObjectAutoRemoveList.clear();
} }
ewol::EObject* ewol::EObjectManager::get(const etk::UString& _name) ewol::EObject* ewol::EObjectManager::get(const etk::UString& _name) {
{
if (_name == "") { if (_name == "") {
return NULL; return NULL;
} }

View File

@ -13,10 +13,8 @@
#include <ewol/renderer/EObject.h> #include <ewol/renderer/EObject.h>
#include <ewol/renderer/EMultiCast.h> #include <ewol/renderer/EMultiCast.h>
namespace ewol namespace ewol {
{ class EObjectManager {
class EObjectManager
{
private: private:
etk::Vector<ewol::EObject*> m_eObjectList; // all widget allocated == > all time increment ... never removed ... etk::Vector<ewol::EObject*> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
etk::Vector<ewol::EObject*> m_eObjectAutoRemoveList; // all widget allocated etk::Vector<ewol::EObject*> m_eObjectAutoRemoveList; // all widget allocated

View File

@ -9,10 +9,9 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#undef __class__ #undef __class__
#define __class__ "EventEntry" #define __class__ "EventEntry"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventEntry& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventEntry& _obj) {
{
_os << "{type=" << _obj.getType(); _os << "{type=" << _obj.getType();
_os << " status=" << _obj.getStatus(); _os << " status=" << _obj.getStatus();
if (_obj.getType() == ewol::keyEvent::keyboardChar) { if (_obj.getType() == ewol::keyEvent::keyboardChar) {
@ -22,8 +21,7 @@ etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventEntry& _obj)
return _os; return _os;
} }
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntrySystem& _obj) etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntrySystem& _obj) {
{
_os << _obj.m_event; _os << _obj.m_event;
return _os; return _os;
} }

View File

@ -29,14 +29,30 @@ namespace ewol {
m_specialKey(_specialKey), m_specialKey(_specialKey),
m_unicodeData(_char) m_unicodeData(_char)
{ }; { };
void setType(ewol::keyEvent::keyboard_te _type) { m_type = _type; }; void setType(ewol::keyEvent::keyboard_te _type) {
inline const ewol::keyEvent::keyboard_te& getType(void) const { return m_type; }; m_type = _type;
void setStatus(ewol::keyEvent::status_te _status) { m_status = _status; }; };
inline const ewol::keyEvent::status_te& getStatus(void) const { return m_status; }; inline const ewol::keyEvent::keyboard_te& getType(void) const {
void setSpecialKey(const ewol::SpecialKey& _specialKey) { m_specialKey = _specialKey; }; return m_type;
inline const ewol::SpecialKey& getSpecialKey(void) const { return m_specialKey; }; };
void setChar(uniChar_t _char) { m_unicodeData = _char; }; void setStatus(ewol::keyEvent::status_te _status) {
inline const uniChar_t& getChar(void) const { return m_unicodeData; }; m_status = _status;
};
inline const ewol::keyEvent::status_te& getStatus(void) const {
return m_status;
};
void setSpecialKey(const ewol::SpecialKey& _specialKey) {
m_specialKey = _specialKey;
};
inline const ewol::SpecialKey& getSpecialKey(void) const {
return m_specialKey;
};
void setChar(uniChar_t _char) {
m_unicodeData = _char;
};
inline const uniChar_t& getChar(void) const {
return m_unicodeData;
};
}; };
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntry& _obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntry& _obj);

View File

@ -9,10 +9,9 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#undef __class__ #undef __class__
#define __class__ "EventInput" #define __class__ "EventInput"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInput& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInput& _obj) {
{
_os << "{type=" << _obj.getType(); _os << "{type=" << _obj.getType();
_os << " status=" << _obj.getStatus(); _os << " status=" << _obj.getStatus();
_os << " id=" << _obj.getId(); _os << " id=" << _obj.getId();
@ -21,8 +20,7 @@ etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInput& _obj)
return _os; return _os;
} }
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInputSystem& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInputSystem& _obj) {
{
_os << _obj.m_event; _os << _obj.m_event;
return _os; return _os;
} }

View File

@ -28,14 +28,30 @@ namespace ewol {
m_inputId(_id), m_inputId(_id),
m_pos(_pos) m_pos(_pos)
{ }; { };
void setType(ewol::keyEvent::type_te _type) { m_type = _type; }; void setType(ewol::keyEvent::type_te _type) {
inline const ewol::keyEvent::type_te& getType(void) const { return m_type; }; m_type = _type;
void setStatus(ewol::keyEvent::status_te _status) { m_status = _status; }; };
inline const ewol::keyEvent::status_te& getStatus(void) const { return m_status; }; inline const ewol::keyEvent::type_te& getType(void) const {
void setId(uint8_t _id) { m_inputId = _id; }; return m_type;
inline const uint8_t& getId(void) const { return m_inputId; }; };
void setPos(const vec2& _pos) { m_pos = _pos; }; void setStatus(ewol::keyEvent::status_te _status) {
inline const vec2& getPos(void) const { return m_pos; }; m_status = _status;
};
inline const ewol::keyEvent::status_te& getStatus(void) const {
return m_status;
};
void setId(uint8_t _id) {
m_inputId = _id;
};
inline const uint8_t& getId(void) const {
return m_inputId;
};
void setPos(const vec2& _pos) {
m_pos = _pos;
};
inline const vec2& getPos(void) const {
return m_pos;
};
}; };
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventInput& _obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::EventInput& _obj);
@ -56,10 +72,18 @@ namespace ewol {
ewol::Widget* m_dest; ewol::Widget* m_dest;
int32_t m_realIdEvent; int32_t m_realIdEvent;
public: public:
void setDestWidget(ewol::Widget* _dest) { m_dest = _dest; }; void setDestWidget(ewol::Widget* _dest) {
inline ewol::Widget* getDestWidget(void) const { return m_dest; }; m_dest = _dest;
void setRealId(int32_t _realIdEvent) { m_realIdEvent = _realIdEvent; }; };
inline int32_t getRealId(void) const { return m_realIdEvent; }; inline ewol::Widget* getDestWidget(void) const {
return m_dest;
};
void setRealId(int32_t _realIdEvent) {
m_realIdEvent = _realIdEvent;
};
inline int32_t getRealId(void) const {
return m_realIdEvent;
};
/* /*
private: private:
int64_t m_lastTime; int64_t m_lastTime;

View File

@ -9,10 +9,9 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#undef __class__ #undef __class__
#define __class__ "EventTime" #define __class__ "EventTime"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventTime& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventTime& _obj) {
{
_os << "{time=" << _obj.getTime(); _os << "{time=" << _obj.getTime();
_os << " uptime=" << _obj.getApplUpTime(); _os << " uptime=" << _obj.getApplUpTime();
_os << " delta=" << _obj.getDelta(); _os << " delta=" << _obj.getDelta();

View File

@ -29,15 +29,33 @@ namespace ewol {
m_timeDeltaCall(_timeDeltaCall) m_timeDeltaCall(_timeDeltaCall)
{ }; { };
public: public:
void setTime(int64_t _timeSystem) { m_timeSystem=_timeSystem; }; void setTime(int64_t _timeSystem) {
inline int64_t getTime(void) const { return m_timeSystem; }; m_timeSystem=_timeSystem;
void setApplWakeUpTime(int64_t _timeUpAppl) { m_timeUpAppl=_timeUpAppl; }; };
inline int64_t getApplWakeUpTime(void) const { return m_timeUpAppl; }; inline int64_t getTime(void) const {
inline int64_t getApplUpTime(void) const { return m_timeSystem-m_timeUpAppl; }; return m_timeSystem;
void setDelta(float _timeDelta) { m_timeDelta=_timeDelta; }; };
inline float getDelta(void) const { return m_timeDelta; }; void setApplWakeUpTime(int64_t _timeUpAppl) {
void setDeltaCall(float _timeDeltaCall) { m_timeDeltaCall=_timeDeltaCall; }; m_timeUpAppl=_timeUpAppl;
inline float getDeltaCall(void) const { return m_timeDeltaCall; }; };
inline int64_t getApplWakeUpTime(void) const {
return m_timeUpAppl;
};
inline int64_t getApplUpTime(void) const {
return m_timeSystem-m_timeUpAppl;
};
void setDelta(float _timeDelta) {
m_timeDelta=_timeDelta;
};
inline float getDelta(void) const {
return m_timeDelta;
};
void setDeltaCall(float _timeDeltaCall) {
m_timeDeltaCall=_timeDeltaCall;
};
inline float getDeltaCall(void) const {
return m_timeDeltaCall;
};
}; };
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventTime& _obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::EventTime& _obj);
}; };

View File

@ -9,13 +9,11 @@
#ifndef __EWOL_FPS_H__ #ifndef __EWOL_FPS_H__
#define __EWOL_FPS_H__ #define __EWOL_FPS_H__
namespace ewol namespace ewol {
{
/** /**
* @brief This class is designed to count the number of frame per second in the main renderer system * @brief This class is designed to count the number of frame per second in the main renderer system
*/ */
class Fps class Fps {
{
// display every second ... // display every second ...
#define DISPLAY_PERIODE_US (1000000) #define DISPLAY_PERIODE_US (1000000)
private: private:

View File

@ -32,8 +32,7 @@
#include <mach/mach.h> #include <mach/mach.h>
int64_t ewol::getTime(void) int64_t ewol::getTime(void) {
{
struct timespec now; struct timespec now;
clock_serv_t cclock; clock_serv_t cclock;
mach_timespec_t mts; mach_timespec_t mts;
@ -51,42 +50,34 @@ int64_t ewol::getTime(void)
class MacOSInterface : public ewol::eContext class MacOSInterface : public ewol::eContext {
{
private: private:
ewol::SpecialKey m_guiKeyBoardMode; ewol::SpecialKey m_guiKeyBoardMode;
public: public:
MacOSInterface(int32_t _argc, const char* _argv[]) : MacOSInterface(int32_t _argc, const char* _argv[]) :
ewol::eContext(_argc, _argv) ewol::eContext(_argc, _argv) {
{
mm_main(_argc, _argv); mm_main(_argc, _argv);
} }
int32_t Run(void) int32_t Run(void) {
{ return mm_run();
return mm_run();
} }
public: public:
//interface MacOS : //interface MacOS :
bool MAC_Draw(bool _displayEveryTime) bool MAC_Draw(bool _displayEveryTime) {
{
return OS_Draw(_displayEveryTime); return OS_Draw(_displayEveryTime);
} }
void MAC_Resize(float _x, float _y) void MAC_Resize(float _x, float _y) {
{
OS_Resize(vec2(_x,_y)); OS_Resize(vec2(_x,_y));
} }
void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) {
{
OS_SetMouseState(_id, _isDown, vec2(_x, _y)); OS_SetMouseState(_id, _isDown, vec2(_x, _y));
} }
void MAC_SetMouseMotion(int32_t _id, float _x, float _y) void MAC_SetMouseMotion(int32_t _id, float _x, float _y) {
{
OS_SetMouseMotion(_id, vec2(_x, _y)); OS_SetMouseMotion(_id, vec2(_x, _y));
} }
void MAC_SetKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) void MAC_SetKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
{
if (_unichar == '\r') { if (_unichar == '\r') {
_unichar = '\n'; _unichar = '\n';
} }
@ -100,16 +91,14 @@ MacOSInterface* interface = NULL;
bool MacOs::draw(bool _displayEveryTime) bool MacOs::draw(bool _displayEveryTime) {
{
if (interface == NULL) { if (interface == NULL) {
return false; return false;
} }
return interface->MAC_Draw(_displayEveryTime); return interface->MAC_Draw(_displayEveryTime);
} }
void MacOs::Resize(float _x, float _y) void MacOs::Resize(float _x, float _y) {
{
if (interface == NULL) { if (interface == NULL) {
return; return;
} }
@ -117,24 +106,21 @@ void MacOs::Resize(float _x, float _y)
} }
void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
{
if (interface == NULL) { if (interface == NULL) {
return; return;
} }
interface->MAC_SetMouseState(_id, _isDown, _x, _y); interface->MAC_SetMouseState(_id, _isDown, _x, _y);
} }
void MacOs::setMouseMotion(int32_t _id, float _x, float _y) void MacOs::setMouseMotion(int32_t _id, float _x, float _y) {
{
if (interface == NULL) { if (interface == NULL) {
return; return;
} }
interface->MAC_SetMouseMotion(_id, _x, _y); interface->MAC_SetMouseMotion(_id, _x, _y);
} }
void MacOs::setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) void MacOs::setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
{
if (interface == NULL) { if (interface == NULL) {
return; return;
} }
@ -148,8 +134,7 @@ void MacOs::setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _
* @param std IO * @param std IO
* @return std IO * @return std IO
*/ */
int ewol::Run(int _argc, const char *_argv[]) int ewol::Run(int _argc, const char *_argv[]) {
{
etk::setArgZero(_argv[0]); etk::setArgZero(_argv[0]);
interface = new MacOSInterface(_argc, _argv); interface = new MacOSInterface(_argc, _argv);
if (NULL == interface) { if (NULL == interface) {

View File

@ -14,17 +14,17 @@
namespace MacOs namespace MacOs
{ {
// return true if a flush is needed // return true if a flush is needed
bool draw(bool _displayEveryTime); bool draw(bool _displayEveryTime);
/** /**
* @brief The OS inform that the current windows has change his size. * @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows. * @param[in] _size new size of the windows.
*/ */
void Resize(float _x, float _y); void Resize(float _x, float _y);
void setMouseState(int32_t _id, bool _isDown, 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 setMouseMotion(int32_t _id, float _x, float _y);
void setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey); void setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
}; };

View File

@ -27,8 +27,7 @@
int64_t ewol::getTime(void) int64_t ewol::getTime(void) {
{
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
@ -40,8 +39,7 @@ int64_t ewol::getTime(void)
#define __class__ "ContextWindows" #define __class__ "ContextWindows"
class WindowsContext : public ewol::eContext class WindowsContext : public ewol::eContext {
{
private: private:
int32_t m_currentHeight = 0; int32_t m_currentHeight = 0;
bool m_inputIsPressed[MAX_MANAGE_INPUT]; bool m_inputIsPressed[MAX_MANAGE_INPUT];
@ -50,21 +48,17 @@ class WindowsContext : public ewol::eContext
bool m_clipBoardOwnerStd = false; bool m_clipBoardOwnerStd = false;
public: public:
WindowsContext(int32_t _argc, char* _argv[]) : WindowsContext(int32_t _argc, char* _argv[]) :
ewol::eContext(_argc, _argv) ewol::eContext(_argc, _argv) {
{
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; ++iii) { for (int32_t iii=0; iii<MAX_MANAGE_INPUT; ++iii) {
m_inputIsPressed[iii] = false; m_inputIsPressed[iii] = false;
} }
}
~WindowsContext(void) {
} }
~WindowsContext(void) int32_t Run(void) {
{
}
int32_t Run(void)
{
HINSTANCE hInstance = 0; HINSTANCE hInstance = 0;
WNDCLASS wc; WNDCLASS wc;
HWND hWnd; HWND hWnd;
@ -121,15 +115,13 @@ class WindowsContext : public ewol::eContext
return msg.wParam; return msg.wParam;
} }
void Stop(void) void Stop(void) {
{
m_run = false; m_run = false;
// To exit program ... // To exit program ...
PostQuitMessage(0); PostQuitMessage(0);
} }
void setSize(const vec2& _size) void setSize(const vec2& _size) {
{
int border_thickness = getSystemMetrics(SM_CXSIZEFRAME); int border_thickness = getSystemMetrics(SM_CXSIZEFRAME);
int title_size = getSystemMetrics(SM_CYCAPTION); int title_size = getSystemMetrics(SM_CYCAPTION);
size.setValue(_size.x() + border_thickness*2, size.setValue(_size.x() + border_thickness*2,
@ -138,8 +130,7 @@ class WindowsContext : public ewol::eContext
// TODO : Later // TODO : Later
} }
void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
// this is to force the local system to think we have the buffer // this is to force the local system to think we have the buffer
// TODO : remove this 2 line when code will be writen // TODO : remove this 2 line when code will be writen
l_clipBoardOwnerStd = true; l_clipBoardOwnerStd = true;
@ -165,8 +156,7 @@ class WindowsContext : public ewol::eContext
} }
} }
void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
switch (_clipboardID) switch (_clipboardID)
{ {
case ewol::clipBoard::clipboardSelection: case ewol::clipBoard::clipboardSelection:
@ -188,8 +178,7 @@ class WindowsContext : public ewol::eContext
// enable openGL // enable openGL
void enableOpenGL(HWND _hWnd, HDC* _hDC, HGLRC* _hRC) void enableOpenGL(HWND _hWnd, HDC* _hDC, HGLRC* _hRC) {
{
// get the device context (DC) // get the device context (DC)
*hDC = getDC( _hWnd ); *hDC = getDC( _hWnd );
@ -214,8 +203,7 @@ class WindowsContext : public ewol::eContext
// disable openGL // disable openGL
void disableOpenGL(HWND _hWnd, HDC _hDC, HGLRC _hRC) void disableOpenGL(HWND _hWnd, HDC _hDC, HGLRC _hRC) {
{
wglMakeCurrent( NULL, NULL ); wglMakeCurrent( NULL, NULL );
wglDeleteContext( _hRC ); wglDeleteContext( _hRC );
releaseDC( _hWnd, _hDC ); releaseDC( _hWnd, _hDC );
@ -223,14 +211,12 @@ class WindowsContext : public ewol::eContext
// Window Procedure // Window Procedure
static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) static LRESULT CALLBACK WndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) {
{
// TODO : set this function really work... // TODO : set this function really work...
classPointer->WndProcReal(_hWnd, _message, _wParam, _lParam); classPointer->WndProcReal(_hWnd, _message, _wParam, _lParam);
} }
LRESULT CALLBACK WndProcReal(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) LRESULT CALLBACK WndProcReal(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) {
{
bool buttonIsDown = true; bool buttonIsDown = true;
int32_t mouseButtonId = 0; int32_t mouseButtonId = 0;
ivec2 pos; ivec2 pos;
@ -268,19 +254,18 @@ class WindowsContext : public ewol::eContext
} }
return 0; return 0;
*/ */
case WM_WINDOWPOSCHANGING: case WM_WINDOWPOSCHANGING: {
{ WINDOWPOS* tmpVal = (WINDOWPOS*)_lParam;
WINDOWPOS* tmpVal = (WINDOWPOS*)_lParam; if (NULL != tmpVal) {
if (NULL != tmpVal) { //EWOL_DEBUG("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")");
//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 :
// in windows system, we need to remove the size of the border elements : int border_thickness = getSystemMetrics(SM_CXSIZEFRAME);
int border_thickness = getSystemMetrics(SM_CXSIZEFRAME); int title_size = getSystemMetrics(SM_CYCAPTION);
int title_size = getSystemMetrics(SM_CYCAPTION); m_currentHeight = tmpVal->cy - 2*border_thickness - title_size;
m_currentHeight = tmpVal->cy - 2*border_thickness - title_size; OS_Resize(tmpVal->cx-2*border_thickness, m_currentHeight);
OS_Resize(tmpVal->cx-2*border_thickness, m_currentHeight);
}
} }
return 0; return 0;
}
// these message are not parse by us ... // these message are not parse by us ...
case WM_SETCURSOR: // Call the windows if we want the mouse event : 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 case WM_NCHITTEST: // inform the application the position of the mouse is moving
@ -291,110 +276,109 @@ class WindowsContext : public ewol::eContext
* **************************************************************************/ * **************************************************************************/
case WM_KEYUP: case WM_KEYUP:
buttonIsDown = false; buttonIsDown = false;
case WM_KEYDOWN: case WM_KEYDOWN: {
{ etk::UniChar tmpChar = 0;
etk::UniChar tmpChar = 0; ewol::keyEvent::keyboard_te keyInput;
ewol::keyEvent::keyboard_te keyInput; switch (_wParam) {
switch (_wParam) { //case 80: // keypad
//case 80: // keypad case VK_UP: keyInput = ewol::keyEvent::keyboardUp; break;
case VK_UP: keyInput = ewol::keyEvent::keyboardUp; break; //case 83: // keypad
//case 83: // keypad case VK_LEFT: keyInput = ewol::keyEvent::keyboardLeft; break;
case VK_LEFT: keyInput = ewol::keyEvent::keyboardLeft; break; //case 85: // keypad
//case 85: // keypad case VK_RIGHT: keyInput = ewol::keyEvent::keyboardRight; break;
case VK_RIGHT: keyInput = ewol::keyEvent::keyboardRight; break; //case 88: // keypad
//case 88: // keypad case VK_DOWN: keyInput = ewol::keyEvent::keyboardDown; break;
case VK_DOWN: keyInput = ewol::keyEvent::keyboardDown; break; //case 81: // keypad
//case 81: // keypad case VK_PRIOR: keyInput = ewol::keyEvent::keyboardPageUp; break;
case VK_PRIOR: keyInput = ewol::keyEvent::keyboardPageUp; break; //case 89: // keypad
//case 89: // keypad case VK_NEXT: keyInput = ewol::keyEvent::keyboardPageDown; break;
case VK_NEXT: keyInput = ewol::keyEvent::keyboardPageDown; break; //case 79: // keypad
//case 79: // keypad case VK_HOME: keyInput = ewol::keyEvent::keyboardStart; break;
case VK_HOME: keyInput = ewol::keyEvent::keyboardStart; break; //case 87: // keypad
//case 87: // keypad case VK_END: keyInput = ewol::keyEvent::keyboardEnd; break;
case VK_END: keyInput = ewol::keyEvent::keyboardEnd; break; //case VK_: keyInput = ewol::keyEvent::keyboardStopDefil; break;
//case VK_: keyInput = ewol::keyEvent::keyboardStopDefil; break; case VK_PAUSE: keyInput = ewol::keyEvent::keyboardWait; break;
case VK_PAUSE: keyInput = ewol::keyEvent::keyboardWait; break; //case 90: // keypad
//case 90: // keypad case VK_INSERT:
case VK_INSERT: keyInput = ewol::keyEvent::keyboardInsert;
keyInput = ewol::keyEvent::keyboardInsert; guiKeyBoardMode.insert = buttonIsDown;
guiKeyBoardMode.insert = buttonIsDown; break;
break; case VK_F1: keyInput = ewol::keyEvent::keyboardF1; break;
case VK_F1: keyInput = ewol::keyEvent::keyboardF1; break; case VK_F2: keyInput = ewol::keyEvent::keyboardF2; break;
case VK_F2: keyInput = ewol::keyEvent::keyboardF2; break; case VK_F3: keyInput = ewol::keyEvent::keyboardF3; break;
case VK_F3: keyInput = ewol::keyEvent::keyboardF3; break; case VK_F4: keyInput = ewol::keyEvent::keyboardF4; break;
case VK_F4: keyInput = ewol::keyEvent::keyboardF4; break; case VK_F5: keyInput = ewol::keyEvent::keyboardF5; break;
case VK_F5: keyInput = ewol::keyEvent::keyboardF5; break; case VK_F6: keyInput = ewol::keyEvent::keyboardF6; break;
case VK_F6: keyInput = ewol::keyEvent::keyboardF6; break; case VK_F7: keyInput = ewol::keyEvent::keyboardF7; break;
case VK_F7: keyInput = ewol::keyEvent::keyboardF7; break; case VK_F8: keyInput = ewol::keyEvent::keyboardF8; break;
case VK_F8: keyInput = ewol::keyEvent::keyboardF8; break; case VK_F9: keyInput = ewol::keyEvent::keyboardF9; break;
case VK_F9: keyInput = ewol::keyEvent::keyboardF9; break; case VK_F10: keyInput = ewol::keyEvent::keyboardF10; break;
case VK_F10: keyInput = ewol::keyEvent::keyboardF10; break; case VK_F11: keyInput = ewol::keyEvent::keyboardF11; break;
case VK_F11: keyInput = ewol::keyEvent::keyboardF11; break; case VK_F12:
case VK_F12: case VK_F13:
case VK_F13: case VK_F14:
case VK_F14: case VK_F15:
case VK_F15: case VK_F16:
case VK_F16: case VK_F17:
case VK_F17: case VK_F18:
case VK_F18: case VK_F19:
case VK_F19: case VK_F20:
case VK_F20: case VK_F21:
case VK_F21: case VK_F22:
case VK_F22: case VK_F23:
case VK_F23: case VK_F24: keyInput = ewol::keyEvent::keyboardF12; break;
case VK_F24: keyInput = ewol::keyEvent::keyboardF12; break; case VK_CAPITAL: keyInput = ewol::keyEvent::keyboardCapLock; guiKeyBoardMode.capLock = buttonIsDown; break;
case VK_CAPITAL: keyInput = ewol::keyEvent::keyboardCapLock; guiKeyBoardMode.capLock = buttonIsDown; break;
case VK_SHIFT: case VK_SHIFT:
case VK_LSHIFT: keyInput = ewol::keyEvent::keyboardShiftLeft; guiKeyBoardMode.shift = buttonIsDown; break; case VK_LSHIFT: keyInput = ewol::keyEvent::keyboardShiftLeft; guiKeyBoardMode.shift = buttonIsDown; break;
case VK_RSHIFT: keyInput = ewol::keyEvent::keyboardShiftRight; guiKeyBoardMode.shift = buttonIsDown; break; case VK_RSHIFT: keyInput = ewol::keyEvent::keyboardShiftRight; guiKeyBoardMode.shift = buttonIsDown; break;
case VK_CONTROL: case VK_CONTROL:
case VK_LCONTROL: keyInput = ewol::keyEvent::keyboardCtrlLeft; guiKeyBoardMode.ctrl = buttonIsDown; break; case VK_LCONTROL: keyInput = ewol::keyEvent::keyboardCtrlLeft; guiKeyBoardMode.ctrl = buttonIsDown; break;
case VK_RCONTROL: keyInput = ewol::keyEvent::keyboardCtrlRight; guiKeyBoardMode.ctrl = buttonIsDown; break; case VK_RCONTROL: keyInput = ewol::keyEvent::keyboardCtrlRight; guiKeyBoardMode.ctrl = buttonIsDown; break;
case VK_LWIN: keyInput = ewol::keyEvent::keyboardMetaLeft; guiKeyBoardMode.meta = buttonIsDown; break; case VK_LWIN: keyInput = ewol::keyEvent::keyboardMetaLeft; guiKeyBoardMode.meta = buttonIsDown; break;
case VK_RWIN: keyInput = ewol::keyEvent::keyboardMetaRight; guiKeyBoardMode.meta = buttonIsDown; break; case VK_RWIN: keyInput = ewol::keyEvent::keyboardMetaRight; guiKeyBoardMode.meta = buttonIsDown; break;
case VK_MENU: case VK_MENU:
case VK_LMENU: keyInput = ewol::keyEvent::keyboardAlt; guiKeyBoardMode.alt = buttonIsDown; break; case VK_LMENU: keyInput = ewol::keyEvent::keyboardAlt; guiKeyBoardMode.alt = buttonIsDown; break;
case VK_RMENU: keyInput = ewol::keyEvent::keyboardAltGr; guiKeyBoardMode.altGr = buttonIsDown; break; case VK_RMENU: keyInput = ewol::keyEvent::keyboardAltGr; guiKeyBoardMode.altGr = buttonIsDown; break;
//case : keyInput = ewol::keyEvent::keyboardContextMenu; break; //case : keyInput = ewol::keyEvent::keyboardContextMenu; break;
case VK_NUMLOCK: keyInput = ewol::keyEvent::keyboardNumLock; guiKeyBoardMode.numLock = buttonIsDown; break; case VK_NUMLOCK: keyInput = ewol::keyEvent::keyboardNumLock; guiKeyBoardMode.numLock = buttonIsDown; break;
case VK_BACK: // DEL case VK_BACK: // DEL
tmpChar.set(0x08); tmpChar.set(0x08);
break; break;
// TODO : Really strang, need to understand why ... // TODO : Really strang, need to understand why ...
case 46: // Suppr case 46: // Suppr
tmpChar.set(0x7F); tmpChar.set(0x7F);
break; break;
case VK_TAB: // special case for TAB case VK_TAB: // special case for TAB
tmpChar.set(0x09); tmpChar.set(0x09);
break; break;
case VK_RETURN: // special case for TAB case VK_RETURN: // special case for TAB
tmpChar = '\n'; tmpChar = '\n';
break; break;
default: default:
{ {
BYTE kbd[256]; BYTE kbd[256];
getKeyboardState(kbd); getKeyboardState(kbd);
const int BUFFER_LENGTH = 8; //Length of the buffer const int BUFFER_LENGTH = 8; //Length of the buffer
WCHAR chars[BUFFER_LENGTH]; WCHAR chars[BUFFER_LENGTH];
ToUnicode(wParam,lParam,kbd,chars,BUFFER_LENGTH,0); ToUnicode(wParam,lParam,kbd,chars,BUFFER_LENGTH,0);
tmpChar.setUtf8((char*)chars); tmpChar.setUtf8((char*)chars);
} }
break; break;
} }
EWOL_DEBUG("kjhkjhkjhkjhkj = " << _wParam); EWOL_DEBUG("kjhkjhkjhkjhkj = " << _wParam);
if (tmpChar == 0) { if (tmpChar == 0) {
//EWOL_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) ); //EWOL_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) );
OS_SetKeyboardMove(guiKeyBoardMode, keyInput, buttonIsDown); OS_SetKeyboardMove(guiKeyBoardMode, keyInput, buttonIsDown);
} else { } else {
OS_SetKeyboard(guiKeyBoardMode, tmpChar, buttonIsDown); OS_SetKeyboard(guiKeyBoardMode, tmpChar, buttonIsDown);
}
} }
return 0; return 0;
}
/* ************************************************************************** /* **************************************************************************
* Mouse management * Mouse management
* **************************************************************************/ * **************************************************************************/
@ -470,8 +454,7 @@ class WindowsContext : public ewol::eContext
* @param std IO * @param std IO
* @return std IO * @return std IO
*/ */
int ewol::Run(int _argc, const char *_argv[]) int ewol::Run(int _argc, const char *_argv[]) {
{
GLenum err = glewInit(); GLenum err = glewInit();
if (GLEW_OK != err) { if (GLEW_OK != err) {
/* Problem: glewInit failed, something is seriously wrong. */ /* Problem: glewInit failed, something is seriously wrong. */

View File

@ -51,8 +51,8 @@ bool hasDisplay = false;
#define X11_INFO EWOL_VERBOSE #define X11_INFO EWOL_VERBOSE
#define X11_CRITICAL EWOL_VERBOSE #define X11_CRITICAL EWOL_VERBOSE
#endif #endif
int64_t ewol::getTime(void)
{ int64_t ewol::getTime(void) {
struct timespec now; struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now); int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) { if (ret != 0) {
@ -86,8 +86,7 @@ static int attrListDbl[] = {
}; };
extern "C" { extern "C" {
typedef struct Hints typedef struct Hints {
{
unsigned long flags; unsigned long flags;
unsigned long functions; unsigned long functions;
unsigned long decorations; unsigned long decorations;
@ -103,8 +102,7 @@ extern "C" {
#undef __class__ #undef __class__
#define __class__ "x11Interface" #define __class__ "x11Interface"
class X11Interface : public ewol::eContext class X11Interface : public ewol::eContext {
{
private: private:
ewol::SpecialKey m_guiKeyBoardMode; ewol::SpecialKey m_guiKeyBoardMode;
// for double and triple click selection, we need to save the previous click up and down position , and the previous time ... // for double and triple click selection, we need to save the previous click up and down position , and the previous time ...
@ -143,33 +141,32 @@ class X11Interface : public ewol::eContext
ewol::cursorDisplay_te m_currentCursor; //!< select the current cursor to display : ewol::cursorDisplay_te m_currentCursor; //!< select the current cursor to display :
public: public:
X11Interface(int32_t _argc, const char* _argv[]) : X11Interface(int32_t _argc, const char* _argv[]) :
ewol::eContext(_argc, _argv), ewol::eContext(_argc, _argv),
m_display(NULL), m_display(NULL),
m_originX(0), m_originX(0),
m_originY(0), m_originY(0),
m_cursorEventX(0), m_cursorEventX(0),
m_cursorEventY(0), m_cursorEventY(0),
m_currentHeight(0), m_currentHeight(0),
m_currentWidth(0), m_currentWidth(0),
m_visual(NULL), m_visual(NULL),
m_doubleBuffered(0), m_doubleBuffered(0),
m_run(false), m_run(false),
m_grabAllEvent(false), m_grabAllEvent(false),
m_forcePos(0,0), m_forcePos(0,0),
m_positionChangeRequested(false), m_positionChangeRequested(false),
m_curentGrabDelta(0,0), m_curentGrabDelta(0,0),
m_clipBoardRequestPrimary(false), m_clipBoardRequestPrimary(false),
m_clipBoardOwnerPrimary(false), m_clipBoardOwnerPrimary(false),
m_clipBoardOwnerStd(false), m_clipBoardOwnerStd(false),
XAtomeSelection(0), XAtomeSelection(0),
XAtomeClipBoard(0), XAtomeClipBoard(0),
XAtomeTargetString(0), XAtomeTargetString(0),
XAtomeTargetStringUTF8(0), XAtomeTargetStringUTF8(0),
XAtomeTargetTarget(0), XAtomeTargetTarget(0),
XAtomeEWOL(0), XAtomeEWOL(0),
XAtomeDeleteWindows(0), XAtomeDeleteWindows(0),
m_currentCursor(ewol::cursorArrow) m_currentCursor(ewol::cursorArrow) {
{
X11_INFO("X11:INIT"); X11_INFO("X11:INIT");
for (int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for (int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
m_inputIsPressed[iii] = false; m_inputIsPressed[iii] = false;
@ -191,13 +188,11 @@ class X11Interface : public ewol::eContext
m_run = true; m_run = true;
} }
~X11Interface(void) ~X11Interface(void) {
{
// TODO : ... // TODO : ...
} }
int32_t Run(void) int32_t Run(void) {
{
bool specialEventThatNeedARedraw = false; bool specialEventThatNeedARedraw = false;
// main cycle // main cycle
while(true == m_run) { while(true == m_run) {
@ -207,45 +202,42 @@ class X11Interface : public ewol::eContext
// main X boucle : // main X boucle :
while (XPending(m_display)) { while (XPending(m_display)) {
XNextEvent(m_display, &event); XNextEvent(m_display, &event);
switch (event.type) switch (event.type) {
{ case ClientMessage: {
case ClientMessage: X11_INFO("Receive : ClientMessage");
{ if(XAtomeDeleteWindows == (int64_t)event.xclient.data.l[0]) {
X11_INFO("Receive : ClientMessage"); EWOL_INFO(" == > Kill Requested ...");
if(XAtomeDeleteWindows == (int64_t)event.xclient.data.l[0]) { OS_Stop();
EWOL_INFO(" == > Kill Requested ..."); m_run = false;
OS_Stop();
m_run = false;
}
} }
break; break;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Selection AREA // // Selection AREA //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
case SelectionClear: case SelectionClear: {
// Selection has been done on an other program == > clear ours ... // Selection has been done on an other program == > clear ours ...
X11_INFO("X11 event SelectionClear"); X11_INFO("X11 event SelectionClear");
#ifdef DEBUG_X11_EVENT
{ {
#ifdef DEBUG_X11_EVENT XSelectionRequestEvent *req=&(event.xselectionrequest);
{ char * atomNameProperty = XGetAtomName(m_display, req->property);
XSelectionRequestEvent *req=&(event.xselectionrequest); char * atomNameTarget = XGetAtomName(m_display, req->target);
char * atomNameProperty = XGetAtomName(m_display, req->property); EWOL_INFO("X11 property: \"" << atomNameProperty << "\"");
char * atomNameTarget = XGetAtomName(m_display, req->target); EWOL_INFO("X11 target: \"" << atomNameTarget << "\"");
EWOL_INFO("X11 property: \"" << atomNameProperty << "\""); if (NULL != atomNameProperty) { XFree(atomNameProperty); }
EWOL_INFO("X11 target: \"" << atomNameTarget << "\""); if (NULL != atomNameTarget) { XFree(atomNameTarget); }
if (NULL != atomNameProperty) { XFree(atomNameProperty); } }
if (NULL != atomNameTarget) { XFree(atomNameTarget); } #endif
} if (true == m_clipBoardOwnerPrimary) {
#endif m_clipBoardOwnerPrimary = false;
if (true == m_clipBoardOwnerPrimary) { } else if (true == m_clipBoardOwnerStd) {
m_clipBoardOwnerPrimary = false; m_clipBoardOwnerStd = false;
} else if (true == m_clipBoardOwnerStd) { } else {
m_clipBoardOwnerStd = false; EWOL_ERROR("X11 event SelectionClear == > but no selection requested anymore ...");
} else {
EWOL_ERROR("X11 event SelectionClear == > but no selection requested anymore ...");
}
} }
break; break;
}
case SelectionNotify: case SelectionNotify:
X11_INFO("X11 event SelectionNotify"); X11_INFO("X11 event SelectionNotify");
if (event.xselection.property == None) { if (event.xselection.property == None) {
@ -281,86 +273,85 @@ class X11Interface : public ewol::eContext
} }
} }
break; break;
case SelectionRequest: case SelectionRequest: {
X11_INFO("X11 event SelectionRequest"); X11_INFO("X11 event SelectionRequest");
XSelectionRequestEvent *req=&(event.xselectionrequest);
#ifdef DEBUG_X11_EVENT
{ {
XSelectionRequestEvent *req=&(event.xselectionrequest); char * atomNameProperty = XGetAtomName(m_display, req->property);
#ifdef DEBUG_X11_EVENT char * atomNameSelection = XGetAtomName(m_display, req->selection);
{ char * atomNameTarget = XGetAtomName(m_display, req->target);
char * atomNameProperty = XGetAtomName(m_display, req->property); EWOL_INFO(" from: " << atomNameProperty << " request=" << atomNameSelection << " in " << atomNameTarget);
char * atomNameSelection = XGetAtomName(m_display, req->selection); if (NULL != atomNameProperty) { XFree(atomNameProperty); }
char * atomNameTarget = XGetAtomName(m_display, req->target); if (NULL != atomNameSelection) { XFree(atomNameSelection); }
EWOL_INFO(" from: " << atomNameProperty << " request=" << atomNameSelection << " in " << atomNameTarget); if (NULL != atomNameTarget) { XFree(atomNameTarget); }
if (NULL != atomNameProperty) { XFree(atomNameProperty); }
if (NULL != atomNameSelection) { XFree(atomNameSelection); }
if (NULL != atomNameTarget) { XFree(atomNameTarget); }
}
#endif
etk::UString tmpData = "";
if (req->selection == XAtomeSelection) {
tmpData = ewol::clipBoard::get(ewol::clipBoard::clipboardSelection);
} else if (req->selection == XAtomeClipBoard) {
tmpData = ewol::clipBoard::get(ewol::clipBoard::clipboardStd);
}
etk::Char tmpValueStoredTimeToSend = tmpData.c_str();
const char * magatTextToSend = tmpValueStoredTimeToSend;
Atom listOfAtom[4];
if(strlen(magatTextToSend) == 0 ) {
respond.xselection.property= None;
} else if(XAtomeTargetTarget == req->target) {
// We need to generate the list of the possibles target element of atom
int32_t nbAtomSupported = 0;
listOfAtom[nbAtomSupported++] = XAtomeTargetTarget;
listOfAtom[nbAtomSupported++] = XAtomeTargetString;
listOfAtom[nbAtomSupported++] = XAtomeTargetStringUTF8;
listOfAtom[nbAtomSupported++] = None;
XChangeProperty( m_display,
req->requestor,
req->property,
XA_ATOM,
32,
PropModeReplace,
(unsigned char*)listOfAtom,
nbAtomSupported );
respond.xselection.property=req->property;
EWOL_INFO(" == > Respond ... (test)");
} else if(XAtomeTargetString == req->target) {
XChangeProperty( m_display,
req->requestor,
req->property,
req->target,
8,
PropModeReplace,
(unsigned char*)magatTextToSend,
strlen(magatTextToSend));
respond.xselection.property=req->property;
EWOL_INFO(" == > Respond ...");
} else if (XAtomeTargetStringUTF8 == req->target) {
XChangeProperty( m_display,
req->requestor,
req->property,
req->target,
8,
PropModeReplace,
(unsigned char*)magatTextToSend,
strlen(magatTextToSend));
respond.xselection.property=req->property;
EWOL_INFO(" == > Respond ...");
} else {
respond.xselection.property= None;
}
respond.xselection.type= SelectionNotify;
respond.xselection.display= req->display;
respond.xselection.requestor= req->requestor;
respond.xselection.selection=req->selection;
respond.xselection.target= req->target;
respond.xselection.time = req->time;
XSendEvent (m_display, req->requestor,0,0,&respond);
// flush the message on the pipe ...
XFlush (m_display);
} }
#endif
etk::UString tmpData = "";
if (req->selection == XAtomeSelection) {
tmpData = ewol::clipBoard::get(ewol::clipBoard::clipboardSelection);
} else if (req->selection == XAtomeClipBoard) {
tmpData = ewol::clipBoard::get(ewol::clipBoard::clipboardStd);
}
etk::Char tmpValueStoredTimeToSend = tmpData.c_str();
const char * magatTextToSend = tmpValueStoredTimeToSend;
Atom listOfAtom[4];
if(strlen(magatTextToSend) == 0 ) {
respond.xselection.property= None;
} else if(XAtomeTargetTarget == req->target) {
// We need to generate the list of the possibles target element of atom
int32_t nbAtomSupported = 0;
listOfAtom[nbAtomSupported++] = XAtomeTargetTarget;
listOfAtom[nbAtomSupported++] = XAtomeTargetString;
listOfAtom[nbAtomSupported++] = XAtomeTargetStringUTF8;
listOfAtom[nbAtomSupported++] = None;
XChangeProperty( m_display,
req->requestor,
req->property,
XA_ATOM,
32,
PropModeReplace,
(unsigned char*)listOfAtom,
nbAtomSupported );
respond.xselection.property=req->property;
EWOL_INFO(" == > Respond ... (test)");
} else if(XAtomeTargetString == req->target) {
XChangeProperty( m_display,
req->requestor,
req->property,
req->target,
8,
PropModeReplace,
(unsigned char*)magatTextToSend,
strlen(magatTextToSend));
respond.xselection.property=req->property;
EWOL_INFO(" == > Respond ...");
} else if (XAtomeTargetStringUTF8 == req->target) {
XChangeProperty( m_display,
req->requestor,
req->property,
req->target,
8,
PropModeReplace,
(unsigned char*)magatTextToSend,
strlen(magatTextToSend));
respond.xselection.property=req->property;
EWOL_INFO(" == > Respond ...");
} else {
respond.xselection.property= None;
}
respond.xselection.type= SelectionNotify;
respond.xselection.display= req->display;
respond.xselection.requestor= req->requestor;
respond.xselection.selection=req->selection;
respond.xselection.target= req->target;
respond.xselection.time = req->time;
XSendEvent (m_display, req->requestor,0,0,&respond);
// flush the message on the pipe ...
XFlush (m_display);
break; break;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
case Expose: case Expose:
X11_INFO("X11 event Expose"); X11_INFO("X11 event Expose");
@ -498,199 +489,198 @@ class X11Interface : public ewol::eContext
specialEventThatNeedARedraw=true; specialEventThatNeedARedraw=true;
break; break;
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease: {
{ bool thisIsAReapeateKey = false;
bool thisIsAReapeateKey = false; // filter repeate key :
// filter repeate key : if( event.type == KeyRelease
if( event.type == KeyRelease && XEventsQueued(m_display, QueuedAfterReading)) {
&& XEventsQueued(m_display, QueuedAfterReading)) { XEvent nev;
XEvent nev; XPeekEvent(m_display, &nev);
XPeekEvent(m_display, &nev); if( nev.type == KeyPress
if( nev.type == KeyPress && nev.xkey.time == event.xkey.time
&& nev.xkey.time == event.xkey.time && nev.xkey.keycode == event.xkey.keycode) {
&& nev.xkey.keycode == event.xkey.keycode) { // Key was not actually released
// Key was not actually released // remove next event too ...
// remove next event too ...
//This remove repeate key //This remove repeate key
XNextEvent(m_display, &nev); XNextEvent(m_display, &nev);
//break; //break;
thisIsAReapeateKey = true; thisIsAReapeateKey = true;
}
} }
X11_INFO("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" "); }
{ X11_INFO("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
X11_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state); {
if (event.xkey.state & (1<<0) ) { X11_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state);
//EWOL_DEBUG(" Special Key : SHIFT"); if (event.xkey.state & (1<<0) ) {
m_guiKeyBoardMode.shift = true; //EWOL_DEBUG(" Special Key : SHIFT");
} else { m_guiKeyBoardMode.shift = true;
m_guiKeyBoardMode.shift = false; } else {
} m_guiKeyBoardMode.shift = false;
if (event.xkey.state & (1<<1) ) { }
//EWOL_DEBUG(" Special Key : CAPS_LOCK"); if (event.xkey.state & (1<<1) ) {
m_guiKeyBoardMode.capLock = true; //EWOL_DEBUG(" Special Key : CAPS_LOCK");
} else { m_guiKeyBoardMode.capLock = true;
m_guiKeyBoardMode.capLock = false; } else {
} m_guiKeyBoardMode.capLock = false;
if (event.xkey.state & (1<<2) ) { }
//EWOL_DEBUG(" Special Key : Ctrl"); if (event.xkey.state & (1<<2) ) {
m_guiKeyBoardMode.ctrl = true; //EWOL_DEBUG(" Special Key : Ctrl");
} else { m_guiKeyBoardMode.ctrl = true;
m_guiKeyBoardMode.ctrl = false; } else {
} m_guiKeyBoardMode.ctrl = false;
if (event.xkey.state & (1<<3) ) { }
//EWOL_DEBUG(" Special Key : Alt"); if (event.xkey.state & (1<<3) ) {
m_guiKeyBoardMode.alt = true; //EWOL_DEBUG(" Special Key : Alt");
} else { m_guiKeyBoardMode.alt = true;
m_guiKeyBoardMode.alt = false; } else {
} m_guiKeyBoardMode.alt = false;
if (event.xkey.state & (1<<4) ) { }
//EWOL_DEBUG(" Special Key : VER_num"); if (event.xkey.state & (1<<4) ) {
m_guiKeyBoardMode.numLock = true; //EWOL_DEBUG(" Special Key : VER_num");
} else { m_guiKeyBoardMode.numLock = true;
m_guiKeyBoardMode.numLock = false; } else {
} m_guiKeyBoardMode.numLock = false;
if (event.xkey.state & (1<<5) ) { }
EWOL_DEBUG(" Special Key : MOD"); if (event.xkey.state & (1<<5) ) {
} EWOL_DEBUG(" Special Key : MOD");
if (event.xkey.state & (1<<6) ) { }
//EWOL_DEBUG(" Special Key : META"); if (event.xkey.state & (1<<6) ) {
m_guiKeyBoardMode.meta = true; //EWOL_DEBUG(" Special Key : META");
} else { m_guiKeyBoardMode.meta = true;
m_guiKeyBoardMode.meta = false; } else {
} m_guiKeyBoardMode.meta = false;
if (event.xkey.state & (1<<7) ) { }
//EWOL_DEBUG(" Special Key : ALT_GR"); if (event.xkey.state & (1<<7) ) {
m_guiKeyBoardMode.altGr = true; //EWOL_DEBUG(" Special Key : ALT_GR");
} else { m_guiKeyBoardMode.altGr = true;
m_guiKeyBoardMode.altGr = false; } else {
} m_guiKeyBoardMode.altGr = false;
bool find = true; }
ewol::keyEvent::keyboard_te keyInput; bool find = true;
switch (event.xkey.keycode) { ewol::keyEvent::keyboard_te keyInput;
//case 80: // keypad switch (event.xkey.keycode) {
case 111: keyInput = ewol::keyEvent::keyboardUp; break; //case 80: // keypad
//case 83: // keypad case 111: keyInput = ewol::keyEvent::keyboardUp; break;
case 113: keyInput = ewol::keyEvent::keyboardLeft; break; //case 83: // keypad
//case 85: // keypad case 113: keyInput = ewol::keyEvent::keyboardLeft; break;
case 114: keyInput = ewol::keyEvent::keyboardRight; break; //case 85: // keypad
//case 88: // keypad case 114: keyInput = ewol::keyEvent::keyboardRight; break;
case 116: keyInput = ewol::keyEvent::keyboardDown; break; //case 88: // keypad
//case 81: // keypad case 116: keyInput = ewol::keyEvent::keyboardDown; break;
case 112: keyInput = ewol::keyEvent::keyboardPageUp; break; //case 81: // keypad
//case 89: // keypad case 112: keyInput = ewol::keyEvent::keyboardPageUp; break;
case 117: keyInput = ewol::keyEvent::keyboardPageDown; break; //case 89: // keypad
//case 79: // keypad case 117: keyInput = ewol::keyEvent::keyboardPageDown; break;
case 110: keyInput = ewol::keyEvent::keyboardStart; break; //case 79: // keypad
//case 87: // keypad case 110: keyInput = ewol::keyEvent::keyboardStart; break;
case 115: keyInput = ewol::keyEvent::keyboardEnd; break; //case 87: // keypad
case 78: keyInput = ewol::keyEvent::keyboardStopDefil; break; case 115: keyInput = ewol::keyEvent::keyboardEnd; break;
case 127: keyInput = ewol::keyEvent::keyboardWait; break; case 78: keyInput = ewol::keyEvent::keyboardStopDefil; break;
//case 90: // keypad case 127: keyInput = ewol::keyEvent::keyboardWait; break;
case 118: //case 90: // keypad
keyInput = ewol::keyEvent::keyboardInsert; case 118:
if(event.type == KeyRelease) { keyInput = ewol::keyEvent::keyboardInsert;
if (true == m_guiKeyBoardMode.insert) { if(event.type == KeyRelease) {
m_guiKeyBoardMode.insert = false; if (true == m_guiKeyBoardMode.insert) {
} else { m_guiKeyBoardMode.insert = false;
m_guiKeyBoardMode.insert = true; } else {
} m_guiKeyBoardMode.insert = true;
} }
break; }
//case 84: keyInput = ewol::keyEvent::keyboardCenter; break; // Keypad break;
case 67: keyInput = ewol::keyEvent::keyboardF1; break; //case 84: keyInput = ewol::keyEvent::keyboardCenter; break; // Keypad
case 68: keyInput = ewol::keyEvent::keyboardF2; break; case 67: keyInput = ewol::keyEvent::keyboardF1; break;
case 69: keyInput = ewol::keyEvent::keyboardF3; break; case 68: keyInput = ewol::keyEvent::keyboardF2; break;
case 70: keyInput = ewol::keyEvent::keyboardF4; break; case 69: keyInput = ewol::keyEvent::keyboardF3; break;
case 71: keyInput = ewol::keyEvent::keyboardF5; break; case 70: keyInput = ewol::keyEvent::keyboardF4; break;
case 72: keyInput = ewol::keyEvent::keyboardF6; break; case 71: keyInput = ewol::keyEvent::keyboardF5; break;
case 73: keyInput = ewol::keyEvent::keyboardF7; break; case 72: keyInput = ewol::keyEvent::keyboardF6; break;
case 74: keyInput = ewol::keyEvent::keyboardF8; break; case 73: keyInput = ewol::keyEvent::keyboardF7; break;
case 75: keyInput = ewol::keyEvent::keyboardF9; break; case 74: keyInput = ewol::keyEvent::keyboardF8; break;
case 76: keyInput = ewol::keyEvent::keyboardF10; break; case 75: keyInput = ewol::keyEvent::keyboardF9; break;
case 95: keyInput = ewol::keyEvent::keyboardF11; break; case 76: keyInput = ewol::keyEvent::keyboardF10; break;
case 96: keyInput = ewol::keyEvent::keyboardF12; break; case 95: keyInput = ewol::keyEvent::keyboardF11; break;
case 66: keyInput = ewol::keyEvent::keyboardCapLock; m_guiKeyBoardMode.capLock = (event.type == KeyPress) ? true : false; break; case 96: keyInput = ewol::keyEvent::keyboardF12; break;
case 50: keyInput = ewol::keyEvent::keyboardShiftLeft; m_guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break; case 66: keyInput = ewol::keyEvent::keyboardCapLock; m_guiKeyBoardMode.capLock = (event.type == KeyPress) ? true : false; break;
case 62: keyInput = ewol::keyEvent::keyboardShiftRight; m_guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break; case 50: keyInput = ewol::keyEvent::keyboardShiftLeft; m_guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break;
case 37: keyInput = ewol::keyEvent::keyboardCtrlLeft; m_guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break; case 62: keyInput = ewol::keyEvent::keyboardShiftRight; m_guiKeyBoardMode.shift = (event.type == KeyPress) ? true : false; break;
case 105: keyInput = ewol::keyEvent::keyboardCtrlRight; m_guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break; case 37: keyInput = ewol::keyEvent::keyboardCtrlLeft; m_guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break;
case 133: keyInput = ewol::keyEvent::keyboardMetaLeft; m_guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break; case 105: keyInput = ewol::keyEvent::keyboardCtrlRight; m_guiKeyBoardMode.ctrl = (event.type == KeyPress) ? true : false; break;
case 134: keyInput = ewol::keyEvent::keyboardMetaRight; m_guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break; case 133: keyInput = ewol::keyEvent::keyboardMetaLeft; m_guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break;
case 64: keyInput = ewol::keyEvent::keyboardAlt; m_guiKeyBoardMode.alt = (event.type == KeyPress) ? true : false; break; case 134: keyInput = ewol::keyEvent::keyboardMetaRight; m_guiKeyBoardMode.meta = (event.type == KeyPress) ? true : false; break;
case 108: keyInput = ewol::keyEvent::keyboardAltGr; m_guiKeyBoardMode.altGr = (event.type == KeyPress) ? true : false; break; case 64: keyInput = ewol::keyEvent::keyboardAlt; m_guiKeyBoardMode.alt = (event.type == KeyPress) ? true : false; break;
case 135: keyInput = ewol::keyEvent::keyboardContextMenu; break; case 108: keyInput = ewol::keyEvent::keyboardAltGr; m_guiKeyBoardMode.altGr = (event.type == KeyPress) ? true : false; break;
case 77: keyInput = ewol::keyEvent::keyboardNumLock; m_guiKeyBoardMode.numLock = (event.type == KeyPress) ? true : false; break; case 135: keyInput = ewol::keyEvent::keyboardContextMenu; break;
case 91: // Suppr on keypad case 77: keyInput = ewol::keyEvent::keyboardNumLock; m_guiKeyBoardMode.numLock = (event.type == KeyPress) ? true : false; break;
find = false; case 91: // Suppr on keypad
if(m_guiKeyBoardMode.numLock == true){ find = false;
OS_SetKeyboard(m_guiKeyBoardMode, '.', (event.type == KeyPress), thisIsAReapeateKey); if(m_guiKeyBoardMode.numLock == true){
OS_SetKeyboard(m_guiKeyBoardMode, '.', (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, '.', !(event.type == KeyPress), thisIsAReapeateKey);
}
} else {
OS_SetKeyboard(m_guiKeyBoardMode, 0x7F, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, 0x7F, !(event.type == KeyPress), thisIsAReapeateKey);
}
}
break;
case 23: // special case for TAB
find = false;
OS_SetKeyboard(m_guiKeyBoardMode, 0x09, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, 0x09, !(event.type == KeyPress), thisIsAReapeateKey);
}
break;
default:
find = false;
{
char buf[11];
//EWOL_DEBUG("Keycode: " << event.xkey.keycode);
// change keystate for simple reson of the ctrl error...
int32_t keyStateSave = event.xkey.state;
if (event.xkey.state & (1<<2) ) {
event.xkey.state = event.xkey.state & 0xFFFFFFFB;
}
KeySym keysym;
Status status = 0;
//int count = Xutf8LookupString(m_xic, (XKeyPressedEvent*)&event, buf, 10, &keysym, &status);
int count = Xutf8LookupString(m_xic, &event.xkey, buf, 10, &keysym, &status);
// retreave real keystate
event.xkey.state = keyStateSave;
buf[count] = '\0';
// Replace \r error ...
if (buf[0] == '\r') {
buf[0] = '\n';
buf[1] = '\0';
}
if (count>0) {
// transform it in unicode
etk::UniChar tmpChar = 0;
tmpChar.setUtf8(buf);
//EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue);
OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) { if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, '.', !(event.type == KeyPress), thisIsAReapeateKey); OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, !(event.type == KeyPress), thisIsAReapeateKey);
} }
} else { } else {
OS_SetKeyboard(m_guiKeyBoardMode, 0x7F, (event.type == KeyPress), thisIsAReapeateKey); EWOL_WARNING("Unknow event Key : " << event.xkey.keycode);
if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, 0x7F, !(event.type == KeyPress), thisIsAReapeateKey);
}
} }
break;
case 23: // special case for TAB
find = false;
OS_SetKeyboard(m_guiKeyBoardMode, 0x09, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, 0x09, !(event.type == KeyPress), thisIsAReapeateKey);
}
break;
default:
find = false;
{
char buf[11];
//EWOL_DEBUG("Keycode: " << event.xkey.keycode);
// change keystate for simple reson of the ctrl error...
int32_t keyStateSave = event.xkey.state;
if (event.xkey.state & (1<<2) ) {
event.xkey.state = event.xkey.state & 0xFFFFFFFB;
}
KeySym keysym;
Status status = 0;
//int count = Xutf8LookupString(m_xic, (XKeyPressedEvent*)&event, buf, 10, &keysym, &status);
int count = Xutf8LookupString(m_xic, &event.xkey, buf, 10, &keysym, &status);
// retreave real keystate
event.xkey.state = keyStateSave;
buf[count] = '\0';
// Replace \r error ...
if (buf[0] == '\r') {
buf[0] = '\n';
buf[1] = '\0';
}
if (count>0) {
// transform it in unicode
etk::UniChar tmpChar = 0;
tmpChar.setUtf8(buf);
//EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue);
OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, !(event.type == KeyPress), thisIsAReapeateKey);
}
} else {
EWOL_WARNING("Unknow event Key : " << event.xkey.keycode);
}
}
break;
}
if (true == find) {
//EWOL_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) );
OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, !(event.type == KeyPress), thisIsAReapeateKey);
} }
break;
}
if (true == find) {
//EWOL_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) );
OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, (event.type == KeyPress), thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, !(event.type == KeyPress), thisIsAReapeateKey);
} }
} }
} }
break; break;
}
//case DestroyNotify: //case DestroyNotify:
// break; // break;
case MapNotify: case MapNotify:
@ -722,22 +712,19 @@ class X11Interface : public ewol::eContext
return 0; return 0;
} }
/****************************************************************************************/ /****************************************************************************************/
virtual void Stop(void) virtual void Stop(void) {
{
X11_INFO("X11-API: Stop"); X11_INFO("X11-API: Stop");
m_run = false; m_run = false;
} }
/****************************************************************************************/ /****************************************************************************************/
virtual void setSize(const vec2& _size) virtual void setSize(const vec2& _size) {
{
X11_INFO("X11-API: changeSize=" << _size); X11_INFO("X11-API: changeSize=" << _size);
m_currentHeight = _size.y(); m_currentHeight = _size.y();
m_currentWidth = _size.x(); m_currentWidth = _size.x();
XResizeWindow(m_display, m_WindowHandle, _size.x(), _size.y()); XResizeWindow(m_display, m_WindowHandle, _size.x(), _size.y());
} }
/****************************************************************************************/ /****************************************************************************************/
virtual void setPos(const vec2& _pos) virtual void setPos(const vec2& _pos) {
{
X11_INFO("X11-API: changePos=" << _pos); X11_INFO("X11-API: changePos=" << _pos);
XMoveWindow(m_display, m_WindowHandle, _pos.x(), _pos.y()); XMoveWindow(m_display, m_WindowHandle, _pos.x(), _pos.y());
m_originX = _pos.x(); m_originX = _pos.x();
@ -745,8 +732,7 @@ class X11Interface : public ewol::eContext
} }
/****************************************************************************************/ /****************************************************************************************/
/* /*
virtual void getAbsPos(ivec2& pos) virtual void getAbsPos(ivec2& pos) {
{
X11_INFO("X11-API: getAbsPos"); X11_INFO("X11-API: getAbsPos");
int tmp; int tmp;
unsigned int tmp2; unsigned int tmp2;
@ -755,8 +741,7 @@ class X11Interface : public ewol::eContext
} }
*/ */
/****************************************************************************************/ /****************************************************************************************/
virtual void setCursor(ewol::cursorDisplay_te _newCursor) virtual void setCursor(ewol::cursorDisplay_te _newCursor) {
{
if (_newCursor != m_currentCursor) { if (_newCursor != m_currentCursor) {
X11_DEBUG("X11-API: set New Cursor : " << _newCursor); X11_DEBUG("X11-API: set New Cursor : " << _newCursor);
// undefine previous cursors ... // undefine previous cursors ...
@ -846,8 +831,7 @@ class X11Interface : public ewol::eContext
} }
} }
/****************************************************************************************/ /****************************************************************************************/
void GrabPointerEvents(bool _isGrabbed, const vec2& _forcedPosition) void GrabPointerEvents(bool _isGrabbed, const vec2& _forcedPosition) {
{
if (true == _isGrabbed) { if (true == _isGrabbed) {
X11_DEBUG("X11-API: Grab Events"); X11_DEBUG("X11-API: Grab Events");
int32_t test = XGrabPointer(m_display,RootWindow(m_display, DefaultScreen(m_display)), True, int32_t test = XGrabPointer(m_display,RootWindow(m_display, DefaultScreen(m_display)), True,
@ -897,8 +881,7 @@ class X11Interface : public ewol::eContext
} }
} }
/****************************************************************************************/ /****************************************************************************************/
bool CreateX11Context(void) bool CreateX11Context(void) {
{
X11_INFO("X11: CreateX11Context"); X11_INFO("X11: CreateX11Context");
int x,y, attr_mask; int x,y, attr_mask;
XSizeHints hints; XSizeHints hints;
@ -1048,8 +1031,7 @@ class X11Interface : public ewol::eContext
return true; return true;
} }
/****************************************************************************************/ /****************************************************************************************/
void setIcon(const etk::UString& _inputFile) void setIcon(const etk::UString& _inputFile) {
{
egami::Image dataImage; egami::Image dataImage;
// load data // load data
if (false == egami::load(dataImage, _inputFile)) { if (false == egami::load(dataImage, _inputFile)) {
@ -1187,8 +1169,7 @@ class X11Interface : public ewol::eContext
} }
/****************************************************************************************/ /****************************************************************************************/
static void setVSync(bool _sync) static void setVSync(bool _sync) {
{
// Function pointer for the wgl extention function we need to enable/disable // Function pointer for the wgl extention function we need to enable/disable
typedef int32_t (APIENTRY *PFNWGLSWAPINTERVALPROC)( int ); typedef int32_t (APIENTRY *PFNWGLSWAPINTERVALPROC)( int );
PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0;
@ -1206,8 +1187,7 @@ class X11Interface : public ewol::eContext
} }
} }
/****************************************************************************************/ /****************************************************************************************/
bool CreateOGlContext(void) bool CreateOGlContext(void) {
{
X11_INFO("X11:CreateOGlContext"); X11_INFO("X11:CreateOGlContext");
/* create a GLX context */ /* create a GLX context */
GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE); GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE);
@ -1225,8 +1205,7 @@ class X11Interface : public ewol::eContext
return true; return true;
} }
/****************************************************************************************/ /****************************************************************************************/
void setTitle(const etk::UString& _title) void setTitle(const etk::UString& _title) {
{
X11_INFO("X11: set Title (START)"); X11_INFO("X11: set Title (START)");
XTextProperty tp; XTextProperty tp;
etk::Char tmpChar = _title.c_str(); etk::Char tmpChar = _title.c_str();
@ -1241,8 +1220,7 @@ class X11Interface : public ewol::eContext
X11_INFO("X11: set Title (END)"); X11_INFO("X11: set Title (END)");
} }
/****************************************************************************************/ /****************************************************************************************/
void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
switch (_clipboardID) switch (_clipboardID)
{ {
case ewol::clipBoard::clipboardSelection: case ewol::clipBoard::clipboardSelection:
@ -1281,8 +1259,7 @@ class X11Interface : public ewol::eContext
} }
} }
/****************************************************************************************/ /****************************************************************************************/
void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
switch (_clipboardID) switch (_clipboardID)
{ {
case ewol::clipBoard::clipboardSelection: case ewol::clipBoard::clipboardSelection:
@ -1312,15 +1289,13 @@ class X11Interface : public ewol::eContext
* @param std IO * @param std IO
* @return std IO * @return std IO
*/ */
int ewol::Run(int _argc, const char *_argv[]) int ewol::Run(int _argc, const char *_argv[]) {
{
etk::setArgZero(_argv[0]); etk::setArgZero(_argv[0]);
X11Interface* interface = new X11Interface(_argc, _argv); X11Interface* interface = new X11Interface(_argc, _argv);
if (NULL == interface) { if (NULL == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error"); EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2; return -2;
} }
int32_t retValue = interface->Run(); int32_t retValue = interface->Run();
delete(interface); delete(interface);
interface = NULL; interface = NULL;

View File

@ -30,8 +30,7 @@ static bool isInit = false;
# include <ewol/renderer/audio/interfacePortAudio.h> # include <ewol/renderer/audio/interfacePortAudio.h>
#endif #endif
void ewol::audio::init(void) void ewol::audio::init(void) {
{
if (isInit == true) { if (isInit == true) {
EWOL_ERROR("multiple init requested ... at the audio system ..."); EWOL_ERROR("multiple init requested ... at the audio system ...");
} }
@ -47,8 +46,7 @@ void ewol::audio::init(void)
} }
void ewol::audio::unInit(void) void ewol::audio::unInit(void) {
{
if (false == isInit) { if (false == isInit) {
EWOL_ERROR("multiple un-init requested ... at the audio system ..."); EWOL_ERROR("multiple un-init requested ... at the audio system ...");
return; return;
@ -65,122 +63,106 @@ void ewol::audio::unInit(void)
static ewol::audio::AudioCallback userLocalCallback = NULL; static ewol::audio::AudioCallback userLocalCallback = NULL;
void ewol::audio::getData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels) void ewol::audio::getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
{
// TODO : set the real playing time ... // TODO : set the real playing time ...
currentTimePlaying += 10; currentTimePlaying += 10;
if (nbChannels != 2) { if (_nbChannels != 2) {
EWOL_ERROR("TODO : Support the signal mono or more tha stereo ..."); EWOL_ERROR("TODO : Support the signal mono or more tha stereo ...");
return; return;
} }
// reset the current buffer // reset the current buffer
memset(bufferInterlace, 0, nbSample*sizeof(int16_t)*nbChannels); memset(_bufferInterlace, 0, _nbSample*sizeof(int16_t)*_nbChannels);
// get user data ... // get user data ...
if (NULL != userLocalCallback) { if (NULL != userLocalCallback) {
(*userLocalCallback)(bufferInterlace, nbSample, nbChannels); (*userLocalCallback)(_bufferInterlace, _nbSample, _nbChannels);
} }
// get background music : // get background music :
ewol::audio::music::getData(bufferInterlace, nbSample, nbChannels); ewol::audio::music::getData(_bufferInterlace, _nbSample, _nbChannels);
// add effects : // add effects :
ewol::audio::effects::getData(bufferInterlace, nbSample, nbChannels); ewol::audio::effects::getData(_bufferInterlace, _nbSample, _nbChannels);
static FILE * plop = fopen("/home/edupin/testFile48khzstereo.raw", "w"); static FILE * plop = fopen("/home/edupin/testFile48khzstereo.raw", "w");
if (plop!=NULL) { if (plop!=NULL) {
fwrite(bufferInterlace, sizeof(int16_t), nbSample*nbChannels, plop); fwrite(_bufferInterlace, sizeof(int16_t), _nbSample*_nbChannels, plop);
} }
} }
void ewol::audio::addCallbackOutput(ewol::audio::AudioCallback userCallback) void ewol::audio::addCallbackOutput(ewol::audio::AudioCallback _userCallback) {
{ userLocalCallback = _userCallback;
userLocalCallback = userCallback;
} }
void ewol::audio::music::fading(int32_t timeMs) void ewol::audio::music::fading(int32_t _timeMs) {
{ musicFadingTime = _timeMs;
musicFadingTime = timeMs;
musicFadingTime = etk_avg(-100, musicFadingTime, 20); musicFadingTime = etk_avg(-100, musicFadingTime, 20);
EWOL_INFO("Set music fading time at " << timeMs << "ms == > " << musicFadingTime << "ms"); EWOL_INFO("Set music fading time at " << _timeMs << "ms == > " << musicFadingTime << "ms");
} }
bool ewol::audio::music::listAdd(etk::UString file) bool ewol::audio::music::listAdd(etk::UString _file) {
{
return false; return false;
} }
bool ewol::audio::music::listRm(etk::UString file) bool ewol::audio::music::listRm(etk::UString _file) {
{
return false; return false;
} }
bool ewol::audio::music::listClean(void) bool ewol::audio::music::listClean(void) {
{
return false; return false;
} }
bool ewol::audio::music::listPrevious(void) bool ewol::audio::music::listPrevious(void) {
{
return false; return false;
} }
bool ewol::audio::music::listNext(void) bool ewol::audio::music::listNext(void) {
{
return false; return false;
} }
bool ewol::audio::music::listFirst(void) bool ewol::audio::music::listFirst(void) {
{
return false; return false;
} }
bool ewol::audio::music::listLast(void) bool ewol::audio::music::listLast(void) {
{
return false; return false;
} }
bool ewol::audio::music::listPlay(void) bool ewol::audio::music::listPlay(void) {
{
return false; return false;
} }
bool ewol::audio::music::listStop(void) bool ewol::audio::music::listStop(void) {
{
return false; return false;
} }
bool ewol::audio::music::play(etk::UString file) bool ewol::audio::music::play(etk::UString _file) {
{
return false; return false;
} }
bool ewol::audio::music::stop(void) bool ewol::audio::music::stop(void) {
{
return false; return false;
} }
float ewol::audio::music::volumeGet(void) float ewol::audio::music::volumeGet(void) {
{
return musicVolume; return musicVolume;
} }
static void uptateMusicVolume(void) static void uptateMusicVolume(void) {
{
if (musicMute == true) { if (musicMute == true) {
musicVolumeApply = 0; musicVolumeApply = 0;
} else { } else {
@ -191,31 +173,27 @@ static void uptateMusicVolume(void)
} }
} }
void ewol::audio::music::volumeSet(float newVolume) void ewol::audio::music::volumeSet(float _newVolume) {
{ musicVolume = _newVolume;
musicVolume = newVolume;
musicVolume = etk_avg(-1000, musicVolume, 40); musicVolume = etk_avg(-1000, musicVolume, 40);
EWOL_INFO("Set music Volume at " << newVolume << "dB == > " << musicVolume << "dB"); EWOL_INFO("Set music Volume at " << _newVolume << "dB == > " << musicVolume << "dB");
uptateMusicVolume(); uptateMusicVolume();
} }
bool ewol::audio::music::muteGet(void) bool ewol::audio::music::muteGet(void) {
{
return musicMute; return musicMute;
} }
void ewol::audio::music::muteSet(bool newMute) void ewol::audio::music::muteSet(bool _newMute) {
{ musicMute = _newMute;
musicMute = newMute; EWOL_INFO("Set music Mute at " << _newMute);
EWOL_INFO("Set music Mute at " << newMute);
uptateMusicVolume(); uptateMusicVolume();
} }
void ewol::audio::music::getData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels) void ewol::audio::music::getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
{
/*static int32_t maxValue = 0; /*static int32_t maxValue = 0;
static float angle = 0; static float angle = 0;
maxValue +=10; maxValue +=10;
@ -240,11 +218,11 @@ void ewol::audio::music::getData(int16_t * bufferInterlace, int32_t nbSample, in
//liste d'effet //liste d'effet
class EffectsLoaded { class EffectsLoaded {
public : public :
EffectsLoaded(etk::UString file) EffectsLoaded(etk::UString _file)
{ {
m_file = file; m_file = _file;
m_requestedTime = 1; m_requestedTime = 1;
m_data = ewol::audio::wav::loadData(file, 1, 48000, m_nbSamples); m_data = ewol::audio::wav::loadData(_file, 1, 48000, m_nbSamples);
if (m_data == NULL) { if (m_data == NULL) {
// write an error ... // write an error ...
} }
@ -257,14 +235,14 @@ class EffectsLoaded {
class RequestPlay { class RequestPlay {
private: private:
bool m_freeSlot; bool m_freeSlot;
EffectsLoaded * m_effect; // reference to the effects EffectsLoaded* m_effect; // reference to the effects
int32_t m_playTime; // position in sample playing in the audio effects int32_t m_playTime; // position in sample playing in the audio effects
public : public :
RequestPlay(EffectsLoaded * effect) : m_freeSlot(false), m_effect(effect), m_playTime(0) { }; RequestPlay(EffectsLoaded * _effect) : m_freeSlot(false), m_effect(_effect), m_playTime(0) { };
void reset(EffectsLoaded * effect) { m_effect=effect; m_playTime=0; m_freeSlot=false; }; void reset(EffectsLoaded * _effect) { m_effect=_effect; m_playTime=0; m_freeSlot=false; };
bool isFree(void) { return m_freeSlot; }; bool isFree(void) { return m_freeSlot; };
void play(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels) void play(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels)
{ {
if (true == m_freeSlot) { if (true == m_freeSlot) {
return; return;
@ -273,14 +251,14 @@ class RequestPlay {
m_freeSlot = true; m_freeSlot = true;
return; return;
} }
int32_t processTimeMax = etk_min(nbSample, m_effect->m_nbSamples - m_playTime); int32_t processTimeMax = etk_min(_nbSample, m_effect->m_nbSamples - m_playTime);
processTimeMax = etk_max(0, processTimeMax); processTimeMax = etk_max(0, processTimeMax);
int16_t * pointer = bufferInterlace; int16_t * pointer = _bufferInterlace;
int16_t * newData = &m_effect->m_data[m_playTime]; int16_t * newData = &m_effect->m_data[m_playTime];
//EWOL_DEBUG("AUDIO : Play slot... nb sample : " << processTimeMax << " playTime=" <<m_playTime << " nbCannels=" << nbChannels); //EWOL_DEBUG("AUDIO : Play slot... nb sample : " << processTimeMax << " playTime=" <<m_playTime << " nbCannels=" << nbChannels);
for (int32_t iii=0; iii<processTimeMax; iii++) { for (int32_t iii=0; iii<processTimeMax; iii++) {
// TODO : set volume and spacialisation ... // TODO : set volume and spacialisation ...
for (int32_t jjj=0; jjj<nbChannels; jjj++) { for (int32_t jjj=0; jjj<_nbChannels; jjj++) {
int32_t tmppp = *pointer + ((((int32_t)*newData)*effectsVolumeApply)>>16); int32_t tmppp = *pointer + ((((int32_t)*newData)*effectsVolumeApply)>>16);
*pointer = etk_avg(-32767, tmppp, 32766); *pointer = etk_avg(-32767, tmppp, 32766);
//EWOL_DEBUG("AUDIO : element : " << *pointer); //EWOL_DEBUG("AUDIO : element : " << *pointer);
@ -301,20 +279,19 @@ etk::Vector<EffectsLoaded*> ListEffects;
etk::Vector<RequestPlay*> ListEffectsPlaying; etk::Vector<RequestPlay*> ListEffectsPlaying;
int32_t ewol::audio::effects::add(etk::UString file) int32_t ewol::audio::effects::add(etk::UString _file) {
{
for (int32_t iii=0; iii<ListEffects.size(); iii++) { for (int32_t iii=0; iii<ListEffects.size(); iii++) {
if (NULL != ListEffects[iii]) { if (NULL != ListEffects[iii]) {
if (ListEffects[iii]->m_file == file) { if (ListEffects[iii]->m_file == _file) {
ListEffects[iii]->m_requestedTime++; ListEffects[iii]->m_requestedTime++;
return iii; return iii;
} }
} }
} }
// effect does not exist ... create a new one ... // effect does not exist ... create a new one ...
EffectsLoaded * tmpEffect = new EffectsLoaded(file); EffectsLoaded * tmpEffect = new EffectsLoaded(_file);
if (NULL == tmpEffect) { if (NULL == tmpEffect) {
EWOL_ERROR("Error to load the effects : \"" << file << "\""); EWOL_ERROR("Error to load the effects : \"" << _file << "\"");
return -1; return -1;
} }
ListEffects.pushBack(tmpEffect); ListEffects.pushBack(tmpEffect);
@ -322,63 +299,59 @@ int32_t ewol::audio::effects::add(etk::UString file)
} }
void ewol::audio::effects::rm(int32_t effectId) void ewol::audio::effects::rm(int32_t _effectId) {
{
// find element ... // find element ...
if (effectId <0 || effectId >= ListEffects.size()) { if (_effectId <0 || _effectId >= ListEffects.size()) {
EWOL_ERROR("Wrong effect ID : " << effectId << " != [0.." << ListEffects.size()-1 << "] == > can not remove it ..."); EWOL_ERROR("Wrong effect ID : " << _effectId << " != [0.." << ListEffects.size()-1 << "] == > can not remove it ...");
return; return;
} }
if (ListEffects[effectId] == NULL) { if (ListEffects[_effectId] == NULL) {
EWOL_ERROR("effect ID : " << effectId << " == > has already been removed"); EWOL_ERROR("effect ID : " << _effectId << " == > has already been removed");
return; return;
} }
// check number of requested // check number of requested
if (ListEffects[effectId]->m_requestedTime <= 0) { if (ListEffects[_effectId]->m_requestedTime <= 0) {
EWOL_ERROR("effect ID : " << effectId << " == > request more than predicted a removed of an effects"); EWOL_ERROR("effect ID : " << _effectId << " == > request more than predicted a removed of an effects");
return; return;
} }
ListEffects[effectId]->m_requestedTime--; ListEffects[_effectId]->m_requestedTime--;
// mark to be removed ... TODO : Really removed it when no other element readed it ... // mark to be removed ... TODO : Really removed it when no other element readed it ...
// TODO : ... // TODO : ...
} }
void ewol::audio::effects::play(int32_t effectId, float xxx, float yyy) void ewol::audio::effects::play(int32_t _effectId, float _xxx, float _yyy) {
{ if (_effectId <0 || _effectId >= ListEffects.size()) {
if (effectId <0 || effectId >= ListEffects.size()) { EWOL_ERROR("Wrong effect ID : " << _effectId << " != [0.." << ListEffects.size()-1 << "] == > can not play it ...");
EWOL_ERROR("Wrong effect ID : " << effectId << " != [0.." << ListEffects.size()-1 << "] == > can not play it ...");
return; return;
} }
if (ListEffects[effectId] == NULL) { if (ListEffects[_effectId] == NULL) {
EWOL_ERROR("effect ID : " << effectId << " == > has been removed"); EWOL_ERROR("effect ID : " << _effectId << " == > has been removed");
return; return;
} }
EWOL_VERBOSE("effect play : " << effectId ); EWOL_VERBOSE("effect play : " << _effectId );
// try to find an empty slot : // try to find an empty slot :
for (int32_t iii=0; iii<ListEffectsPlaying.size(); iii++) { for (int32_t iii=0; iii<ListEffectsPlaying.size(); iii++) {
if (ListEffectsPlaying[iii]->isFree()) { if (ListEffectsPlaying[iii]->isFree()) {
ListEffectsPlaying[iii]->reset(ListEffects[effectId]); ListEffectsPlaying[iii]->reset(ListEffects[_effectId]);
return; return;
} }
} }
RequestPlay* newPlay = new RequestPlay(ListEffects[effectId]); RequestPlay* newPlay = new RequestPlay(ListEffects[_effectId]);
if (NULL == newPlay) { if (NULL == newPlay) {
EWOL_CRITICAL("Allocation error of a playing element : " << effectId); EWOL_CRITICAL("Allocation error of a playing element : " << _effectId);
return; return;
} }
ListEffectsPlaying.pushBack(newPlay); ListEffectsPlaying.pushBack(newPlay);
} }
float ewol::audio::effects::volumeGet(void) float ewol::audio::effects::volumeGet(void) {
{
return effectsVolume; return effectsVolume;
} }
static void uptateEffectVolume(void) static void uptateEffectVolume(void) {
{
if (effectsMute == true) { if (effectsMute == true) {
effectsVolumeApply = 0; effectsVolumeApply = 0;
} else { } else {
@ -389,34 +362,30 @@ static void uptateEffectVolume(void)
} }
} }
void ewol::audio::effects::volumeSet(float newVolume) void ewol::audio::effects::volumeSet(float _newVolume) {
{ effectsVolume = _newVolume;
effectsVolume = newVolume;
effectsVolume = etk_avg(-100, effectsVolume, 20); effectsVolume = etk_avg(-100, effectsVolume, 20);
EWOL_INFO("Set music Volume at " << newVolume << "dB == > " << effectsVolume << "dB"); EWOL_INFO("Set music Volume at " << _newVolume << "dB == > " << effectsVolume << "dB");
uptateEffectVolume(); uptateEffectVolume();
} }
bool ewol::audio::effects::muteGet(void) bool ewol::audio::effects::muteGet(void) {
{
return effectsMute; return effectsMute;
} }
void ewol::audio::effects::muteSet(bool newMute) void ewol::audio::effects::muteSet(bool _newMute) {
{ effectsMute = _newMute;
effectsMute = newMute; EWOL_INFO("Set effects Mute at " << _newMute);
EWOL_INFO("Set effects Mute at " << newMute);
} }
void ewol::audio::effects::getData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels) void ewol::audio::effects::getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels) {
{
for (int32_t iii=0; iii<ListEffectsPlaying.size(); iii++) { for (int32_t iii=0; iii<ListEffectsPlaying.size(); iii++) {
if (ListEffectsPlaying[iii]!= NULL) { if (ListEffectsPlaying[iii]!= NULL) {
ListEffectsPlaying[iii]->play(bufferInterlace, nbSample, nbChannels); ListEffectsPlaying[iii]->play(_bufferInterlace, _nbSample, _nbChannels);
} }
} }
} }

View File

@ -18,16 +18,16 @@ namespace ewol {
void init(void); void init(void);
void unInit(void); void unInit(void);
typedef void (*AudioCallback)(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels); typedef void (*AudioCallback)(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
void addCallbackOutput(AudioCallback userCallback); void addCallbackOutput(AudioCallback _userCallback);
void getData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels); void getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
namespace music { namespace music {
void fading(int32_t timeMs); void fading(int32_t _timeMs);
// list playing system : is cyclic ... // list playing system : is cyclic ...
bool listAdd(etk::UString file); bool listAdd(etk::UString _file);
bool listRm(etk::UString file); bool listRm(etk::UString _file);
bool listClean(void); bool listClean(void);
bool listPrevious(void); bool listPrevious(void);
bool listNext(void); bool listNext(void);
@ -36,30 +36,30 @@ namespace ewol {
bool listPlay(void); // List playing bool listPlay(void); // List playing
bool listStop(void); // List stopping bool listStop(void); // List stopping
bool play(etk::UString file); // play specific file ... pause the list element; bool play(etk::UString _file); // play specific file ... pause the list element;
bool stop(void); bool stop(void);
// in db // in db
float volumeGet(void); float volumeGet(void);
void volumeSet(float newVolume); void volumeSet(float _newVolume);
bool muteGet(void); bool muteGet(void);
void muteSet(bool newMute); void muteSet(bool _newMute);
void getData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels); void getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
}; };
// note effect is loaded in memory (then don't create long effect) and unload only when requested // note effect is loaded in memory (then don't create long effect) and unload only when requested
namespace effects { namespace effects {
// note : support file (Mono, 16bit, 48kHz) : .raw or .wav (no encodage) or .ogg (decoded with tremor lib) // note : support file (Mono, 16bit, 48kHz) : .raw or .wav (no encodage) or .ogg (decoded with tremor lib)
int32_t add(etk::UString file); int32_t add(etk::UString _file);
void rm(int32_t effectId); void rm(int32_t _effectId);
void play(int32_t effectId, float xxx, float yyy); void play(int32_t _effectId, float _xxx, float _yyy);
// in db // in db
float volumeGet(void); float volumeGet(void);
void volumeSet(float newVolume); void volumeSet(float _newVolume);
bool muteGet(void); bool muteGet(void);
void muteSet(bool newMute); void muteSet(bool _newMute);
void getData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels); void getData(int16_t * _bufferInterlace, int32_t _nbSample, int32_t _nbChannels);
}; };
}; };

View File

@ -60,8 +60,7 @@ typedef struct {
#define COMPR_G721 (64) #define COMPR_G721 (64)
#define COMPR_MPEG (80) #define COMPR_MPEG (80)
int16_t * ewol::audio::wav::loadData(etk::UString filename, int8_t nbChan, int32_t frequency, int32_t & nbSampleOut) int16_t * ewol::audio::wav::loadData(etk::UString filename, int8_t nbChan, int32_t frequency, int32_t & nbSampleOut) {
{
nbSampleOut = 0; nbSampleOut = 0;
waveHeader myHeader; waveHeader myHeader;
memset(&myHeader, 0, sizeof(waveHeader)); memset(&myHeader, 0, sizeof(waveHeader));

View File

@ -20,8 +20,7 @@ extern "C" {
#include <portaudio/portaudio.h> #include <portaudio/portaudio.h>
} }
typedef struct typedef struct {
{
int32_t sampleRate; int32_t sampleRate;
int32_t nbChanelsInput; int32_t nbChanelsInput;
int32_t nbChanelsOutput; int32_t nbChanelsOutput;
@ -39,20 +38,18 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo, const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags, PaStreamCallbackFlags statusFlags,
void *userData ) void *userData ) {
{ /* Cast data passed through stream to our structure. */
/* Cast data passed through stream to our structure. */ userOutputData *data = (userOutputData*)userData;
userOutputData *data = (userOutputData*)userData; // no use of the input buffer ... (mightt be NULL)
// no use of the input buffer ... (mightt be NULL) (void) inputBuffer;
(void) inputBuffer; ewol::audio::getData((int16_t*)outputBuffer, framesPerBuffer, data->nbChanelsOutput);
ewol::audio::getData((int16_t*)outputBuffer, framesPerBuffer, data->nbChanelsOutput); return 0;
return 0;
} }
#define SAMPLE_RATE (44100) #define SAMPLE_RATE (44100)
void ewol::portAudio::init(void) void ewol::portAudio::init(void) {
{
PaError err; PaError err;
EWOL_DEBUG("Create Audio Thread..."); EWOL_DEBUG("Create Audio Thread...");
@ -81,8 +78,7 @@ void ewol::portAudio::init(void)
EWOL_DEBUG("Create Audio Thread ... might have start"); EWOL_DEBUG("Create Audio Thread ... might have start");
} }
void ewol::portAudio::unInit(void) void ewol::portAudio::unInit(void) {
{
PaError err; PaError err;
// destroy the thread ... // destroy the thread ...
EWOL_DEBUG("Wait end of the thread ..."); EWOL_DEBUG("Wait end of the thread ...");

View File

@ -47,8 +47,7 @@
#include <directfbgl.h> #include <directfbgl.h>
int64_t guiInterface::getTime(void) int64_t guiInterface::getTime(void) {
{
struct timespec now; struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now); int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) { if (ret != 0) {
@ -92,20 +91,17 @@ static int screen_height = 600;
* @param title New desired title * @param title New desired title
* @return --- * @return ---
*/ */
void guiInterface::setTitle(etk::UString& title) void guiInterface::setTitle(etk::UString& title) {
{
// TODO : ... // TODO : ...
} }
void guiInterface::setIcon(etk::UString inputFile) void guiInterface::setIcon(etk::UString inputFile) {
{
// TODO : ... // TODO : ...
} }
void DirectFB_Init(int argc, const char *argv[]) void DirectFB_Init(int argc, const char *argv[]) {
{
EWOL_INFO("DirectFB init (START)"); EWOL_INFO("DirectFB init (START)");
DFBResult err; DFBResult err;
DFBSurfaceDescription dsc; DFBSurfaceDescription dsc;
@ -194,8 +190,7 @@ void DirectFB_Init(int argc, const char *argv[])
EWOL_INFO("DirectFB init (STOP)"); EWOL_INFO("DirectFB init (STOP)");
} }
void DirectFB_UnInit(void) void DirectFB_UnInit(void) {
{
// release our interfaces to shutdown DirectFB // release our interfaces to shutdown DirectFB
primary_gl->release(primary_gl); primary_gl->release(primary_gl);
primary->release(primary); primary->release(primary);
@ -203,8 +198,7 @@ void DirectFB_UnInit(void)
dfb->release(dfb); dfb->release(dfb);
} }
void DirectFB_Run(void) void DirectFB_Run(void) {
{
EWOL_INFO("X11 configure windows size : (" << screen_height << "," << screen_width << ")"); EWOL_INFO("X11 configure windows size : (" << screen_height << "," << screen_width << ")");
eSystem::Resize(screen_width, screen_height); eSystem::Resize(screen_width, screen_height);
@ -375,14 +369,12 @@ void DirectFB_Run(void)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID) void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
// TODO : ... // TODO : ...
} }
void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID) void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
// TODO : ... // TODO : ...
} }
@ -392,49 +384,41 @@ void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
#define __class__ "guiInterface" #define __class__ "guiInterface"
void guiInterface::Stop(void) void guiInterface::Stop(void) {
{
EWOL_INFO("X11-API: Stop"); EWOL_INFO("X11-API: Stop");
m_run = false; m_run = false;
} }
void guiInterface::KeyboardShow(void) void guiInterface::KeyboardShow(void) {
{
// nothing to do : No keyboard on computer ... // nothing to do : No keyboard on computer ...
} }
void guiInterface::KeyboardHide(void) void guiInterface::KeyboardHide(void) {
{
// nothing to do : No keyboard on computer ... // nothing to do : No keyboard on computer ...
} }
void guiInterface::changeSize(ivec2 size) void guiInterface::changeSize(ivec2 _size) {
{
// TODO : ... // TODO : ...
} }
void guiInterface::changePos(ivec2 pos) void guiInterface::changePos(ivec2 _pos) {
{
// TODO : ... // TODO : ...
} }
void guiInterface::getAbsPos(ivec2& pos) void guiInterface::getAbsPos(ivec2& _pos) {
{
// TODO : ... // TODO : ...
} }
void guiInterface::setCursor(ewol::cursorDisplay_te newCursor) void guiInterface::setCursor(ewol::cursorDisplay_te _newCursor) {
{
// TODO : ... // TODO : ...
} }
void guiInterface::GrabPointerEvents(bool isGrabbed, vec2 forcedPosition) void guiInterface::GrabPointerEvents(bool _isGrabbed, vec2 _forcedPosition) {
{
// TODO : ... // TODO : ...
} }
@ -444,8 +428,7 @@ void guiInterface::GrabPointerEvents(bool isGrabbed, vec2 forcedPosition)
* @param std IO * @param std IO
* @return std IO * @return std IO
*/ */
int guiInterface::main(int argc, const char *argv[]) int guiInterface::main(int argc, const char *argv[]) {
{
EWOL_INFO("Main (START)"); EWOL_INFO("Main (START)");
for (int32_t iii=0; iii<NB_MAX_INPUT; iii++) { for (int32_t iii=0; iii<NB_MAX_INPUT; iii++) {
inputIsPressed[iii] = false; inputIsPressed[iii] = false;
@ -468,15 +451,13 @@ int guiInterface::main(int argc, const char *argv[])
} }
void guiInterface::forceOrientation(ewol::orientation_te orientation) void guiInterface::forceOrientation(ewol::orientation_te orientation) {
{
// nothing to do ... // nothing to do ...
} }
/* /*
static void init(int argc, char *argv[]) static void init(int argc, char *argv[]) {
{
glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);

View File

@ -33,16 +33,14 @@
* @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time. * @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time.
* @return the main inteface Mutex * @return the main inteface Mutex
*/ */
static etk::Mutex& mutexInterface(void) static etk::Mutex& mutexInterface(void) {
{
static etk::Mutex s_interfaceMutex; static etk::Mutex s_interfaceMutex;
return s_interfaceMutex; return s_interfaceMutex;
} }
static ewol::eContext* l_curentInterface=NULL; static ewol::eContext* l_curentInterface=NULL;
ewol::eContext& ewol::getContext(void) ewol::eContext& ewol::getContext(void) {
{
#if DEBUG_LEVEL > 2 #if DEBUG_LEVEL > 2
if(NULL == l_curentInterface){ if(NULL == l_curentInterface){
EWOL_CRITICAL("[CRITICAL] try acces at an empty interface"); EWOL_CRITICAL("[CRITICAL] try acces at an empty interface");
@ -55,8 +53,7 @@ ewol::eContext& ewol::getContext(void)
* @brief set the curent interface. * @brief set the curent interface.
* @note this lock the main mutex * @note this lock the main mutex
*/ */
void ewol::eContext::lockContext(void) void ewol::eContext::lockContext(void) {
{
mutexInterface().lock(); mutexInterface().lock();
l_curentInterface = this; l_curentInterface = this;
} }
@ -65,35 +62,30 @@ void ewol::eContext::lockContext(void)
* @brief set the curent interface at NULL. * @brief set the curent interface at NULL.
* @note this un-lock the main mutex * @note this un-lock the main mutex
*/ */
void ewol::eContext::unLockContext(void) void ewol::eContext::unLockContext(void) {
{
l_curentInterface = NULL; l_curentInterface = NULL;
mutexInterface().unLock(); mutexInterface().unLock();
} }
void ewol::eContext::inputEventTransfertWidget(ewol::Widget* source, ewol::Widget* destination) void ewol::eContext::inputEventTransfertWidget(ewol::Widget* _source,
{ ewol::Widget* _destination) {
m_input.transfertEvent(source, destination); m_input.transfertEvent(_source, _destination);
} }
void ewol::eContext::inputEventGrabPointer(ewol::Widget* widget) void ewol::eContext::inputEventGrabPointer(ewol::Widget* _widget) {
{ m_input.grabPointer(_widget);
m_input.grabPointer(widget);
} }
void ewol::eContext::inputEventUnGrabPointer(void) void ewol::eContext::inputEventUnGrabPointer(void) {
{
m_input.unGrabPointer(); m_input.unGrabPointer();
} }
void ewol::eContext::processEvents(void) void ewol::eContext::processEvents(void) {
{
int32_t nbEvent = 0; int32_t nbEvent = 0;
//EWOL_DEBUG(" ******** Event"); //EWOL_DEBUG(" ******** Event");
eSystemMessage data; eSystemMessage data;
while (m_msgSystem.count()>0) while (m_msgSystem.count()>0) {
{
nbEvent++; nbEvent++;
m_msgSystem.wait(data); m_msgSystem.wait(data);
//EWOL_DEBUG("EVENT"); //EWOL_DEBUG("EVENT");
@ -194,27 +186,25 @@ void ewol::eContext::processEvents(void)
} }
} }
void ewol::eContext::setArchiveDir(int mode, const char* str) void ewol::eContext::setArchiveDir(int _mode, const char* _str) {
{ switch(_mode) {
switch(mode)
{
case 0: case 0:
EWOL_DEBUG("Directory APK : path=" << str); EWOL_DEBUG("Directory APK : path=" << _str);
etk::setBaseFolderData(str); etk::setBaseFolderData(_str);
break; break;
case 1: case 1:
EWOL_DEBUG("Directory mode=FILE path=" << str); EWOL_DEBUG("Directory mode=FILE path=" << _str);
etk::setBaseFolderDataUser(str); etk::setBaseFolderDataUser(_str);
break; break;
case 2: case 2:
EWOL_DEBUG("Directory mode=CACHE path=" << str); EWOL_DEBUG("Directory mode=CACHE path=" << _str);
etk::setBaseFolderCache(str); etk::setBaseFolderCache(_str);
break; break;
case 3: case 3:
EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << str); EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << _str);
break; break;
default: default:
EWOL_DEBUG("Directory mode=???? path=" << str); EWOL_DEBUG("Directory mode=???? path=" << _str);
break; break;
} }
} }
@ -222,16 +212,15 @@ void ewol::eContext::setArchiveDir(int mode, const char* str)
ewol::eContext::eContext(int32_t _argc, const char* _argv[]) : ewol::eContext::eContext(int32_t _argc, const char* _argv[]) :
m_previousDisplayTime(0), m_previousDisplayTime(0),
m_input(*this), m_input(*this),
m_displayFps(false), m_displayFps(false),
m_FpsSystemEvent( "Event ", false), m_FpsSystemEvent( "Event ", false),
m_FpsSystemContext("Context ", false), m_FpsSystemContext("Context ", false),
m_FpsSystem( "Draw ", true), m_FpsSystem( "Draw ", true),
m_FpsFlush( "Flush ", false), m_FpsFlush( "Flush ", false),
m_windowsCurrent(NULL), m_windowsCurrent(NULL),
m_windowsSize(320,480) m_windowsSize(320,480) {
{
m_commandLine.parse(_argc, _argv); m_commandLine.parse(_argc, _argv);
EWOL_INFO(" == > Ewol system init (BEGIN)"); EWOL_INFO(" == > Ewol system init (BEGIN)");
// set the curent interface : // set the curent interface :
@ -287,8 +276,7 @@ ewol::eContext::eContext(int32_t _argc, const char* _argv[]) :
EWOL_INFO(" == > Ewol system init (END)"); EWOL_INFO(" == > Ewol system init (END)");
} }
ewol::eContext::~eContext(void) ewol::eContext::~eContext(void) {
{
EWOL_INFO(" == > Ewol system Un-Init (BEGIN)"); EWOL_INFO(" == > Ewol system Un-Init (BEGIN)");
// set the curent interface : // set the curent interface :
lockContext(); lockContext();
@ -308,16 +296,13 @@ ewol::eContext::~eContext(void)
EWOL_INFO(" == > Ewol system Un-Init (END)"); EWOL_INFO(" == > Ewol system Un-Init (END)");
} }
void ewol::eContext::requestUpdateSize(void) {
void ewol::eContext::requestUpdateSize(void)
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_RECALCULATE_SIZE; data.TypeMessage = THREAD_RECALCULATE_SIZE;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Resize(const vec2& _size) void ewol::eContext::OS_Resize(const vec2& _size) {
{
// TODO : Better in the thread ... == > but generate some init error ... // TODO : Better in the thread ... == > but generate some init error ...
ewol::dimension::setPixelWindowsSize(_size); ewol::dimension::setPixelWindowsSize(_size);
eSystemMessage data; eSystemMessage data;
@ -325,8 +310,7 @@ void ewol::eContext::OS_Resize(const vec2& _size)
data.dimention = _size; data.dimention = _size;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Move(const vec2& _pos) void ewol::eContext::OS_Move(const vec2& _pos) {
{
/* /*
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_RESIZE; data.TypeMessage = THREAD_RESIZE;
@ -336,8 +320,7 @@ void ewol::eContext::OS_Move(const vec2& _pos)
*/ */
} }
void ewol::eContext::OS_SetInputMotion(int _pointerID, const vec2& _pos ) void ewol::eContext::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_INPUT_MOTION; data.TypeMessage = THREAD_INPUT_MOTION;
data.inputType = ewol::keyEvent::typeFinger; data.inputType = ewol::keyEvent::typeFinger;
@ -346,9 +329,7 @@ void ewol::eContext::OS_SetInputMotion(int _pointerID, const vec2& _pos )
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) {
void ewol::eContext::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos )
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_INPUT_STATE; data.TypeMessage = THREAD_INPUT_STATE;
data.inputType = ewol::keyEvent::typeFinger; data.inputType = ewol::keyEvent::typeFinger;
@ -358,9 +339,7 @@ void ewol::eContext::OS_SetInputState(int _pointerID, bool _isDown, const vec2&
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
void ewol::eContext::OS_SetMouseMotion(int _pointerID, const vec2& _pos )
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_INPUT_MOTION; data.TypeMessage = THREAD_INPUT_MOTION;
data.inputType = ewol::keyEvent::typeMouse; data.inputType = ewol::keyEvent::typeMouse;
@ -369,9 +348,7 @@ void ewol::eContext::OS_SetMouseMotion(int _pointerID, const vec2& _pos )
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) {
void ewol::eContext::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos )
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_INPUT_STATE; data.TypeMessage = THREAD_INPUT_STATE;
data.inputType = ewol::keyEvent::typeMouse; data.inputType = ewol::keyEvent::typeMouse;
@ -381,12 +358,10 @@ void ewol::eContext::OS_SetMouseState(int _pointerID, bool _isDown, const vec2&
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetKeyboard(ewol::SpecialKey& _special, void ewol::eContext::OS_SetKeyboard(ewol::SpecialKey& _special,
uniChar_t _myChar, uniChar_t _myChar,
bool _isDown, bool _isDown,
bool _isARepeateKey) bool _isARepeateKey) {
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_KEYBORAD_KEY; data.TypeMessage = THREAD_KEYBORAD_KEY;
data.stateIsDown = _isDown; data.stateIsDown = _isDown;
@ -399,8 +374,7 @@ void ewol::eContext::OS_SetKeyboard(ewol::SpecialKey& _special,
void ewol::eContext::OS_SetKeyboardMove(ewol::SpecialKey& _special, void ewol::eContext::OS_SetKeyboardMove(ewol::SpecialKey& _special,
ewol::keyEvent::keyboard_te _move, ewol::keyEvent::keyboard_te _move,
bool _isDown, bool _isDown,
bool _isARepeateKey) bool _isARepeateKey) {
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_KEYBORAD_MOVE; data.TypeMessage = THREAD_KEYBORAD_MOVE;
data.stateIsDown = _isDown; data.stateIsDown = _isDown;
@ -410,32 +384,27 @@ void ewol::eContext::OS_SetKeyboardMove(ewol::SpecialKey& _special,
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Hide(void) {
void ewol::eContext::OS_Hide(void)
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_HIDE; data.TypeMessage = THREAD_HIDE;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Show(void) void ewol::eContext::OS_Show(void) {
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_SHOW; data.TypeMessage = THREAD_SHOW;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_ClipBoardArrive(ewol::clipBoard::clipboardListe_te _clipboardID) void ewol::eContext::OS_ClipBoardArrive(ewol::clipBoard::clipboardListe_te _clipboardID) {
{
eSystemMessage data; eSystemMessage data;
data.TypeMessage = THREAD_CLIPBOARD_ARRIVE; data.TypeMessage = THREAD_CLIPBOARD_ARRIVE;
data.clipboardID = _clipboardID; data.clipboardID = _clipboardID;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
bool ewol::eContext::OS_Draw(bool _displayEveryTime) bool ewol::eContext::OS_Draw(bool _displayEveryTime) {
{
int64_t currentTime = ewol::getTime(); int64_t currentTime = ewol::getTime();
// this is to prevent the multiple display at the a high frequency ... // this is to prevent the multiple display at the a high frequency ...
#if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__Windows)) #if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__Windows))
@ -528,28 +497,20 @@ bool ewol::eContext::OS_Draw(bool _displayEveryTime)
return hasDisplayDone; return hasDisplayDone;
} }
void ewol::eContext::onObjectRemove(ewol::EObject * _removeObject) {
void ewol::eContext::onObjectRemove(ewol::EObject * _removeObject)
{
//EWOL_CRITICAL("element removed"); //EWOL_CRITICAL("element removed");
m_input.onObjectRemove(_removeObject); m_input.onObjectRemove(_removeObject);
} }
void ewol::eContext::resetIOEvent(void) {
void ewol::eContext::resetIOEvent(void)
{
m_input.newLayerSet(); m_input.newLayerSet();
} }
void ewol::eContext::OS_OpenGlContextDestroy(void) {
void ewol::eContext::OS_OpenGlContextDestroy(void)
{
m_resourceManager.contextHasBeenDestroyed(); m_resourceManager.contextHasBeenDestroyed();
} }
void ewol::eContext::setWindows(ewol::Windows* _windows) {
void ewol::eContext::setWindows(ewol::Windows* _windows)
{
// remove current focus : // remove current focus :
m_widgetManager.focusSetDefault(NULL); m_widgetManager.focusSetDefault(NULL);
m_widgetManager.focusRelease(); m_widgetManager.focusRelease();
@ -561,29 +522,24 @@ void ewol::eContext::setWindows(ewol::Windows* _windows)
forceRedrawAll(); forceRedrawAll();
} }
void ewol::eContext::forceRedrawAll(void) {
void ewol::eContext::forceRedrawAll(void)
{
if (NULL != m_windowsCurrent) { if (NULL != m_windowsCurrent) {
m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y())); m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y()));
} }
} }
void ewol::eContext::OS_Stop(void) {
void ewol::eContext::OS_Stop(void)
{
if (NULL != m_windowsCurrent) { if (NULL != m_windowsCurrent) {
m_windowsCurrent->sysOnKill(); m_windowsCurrent->sysOnKill();
} }
} }
void ewol::eContext::OS_Suspend(void) void ewol::eContext::OS_Suspend(void) {
{
m_previousDisplayTime = -1; m_previousDisplayTime = -1;
} }
void ewol::eContext::OS_Resume(void) void ewol::eContext::OS_Resume(void) {
{
m_previousDisplayTime = ewol::getTime(); m_previousDisplayTime = ewol::getTime();
m_widgetManager.periodicCallResume(m_previousDisplayTime); m_widgetManager.periodicCallResume(m_previousDisplayTime);
} }

View File

@ -75,16 +75,14 @@ class eSystemMessage {
} }
}; };
namespace ewol namespace ewol {
{
typedef enum { typedef enum {
SCREEN_ORIENTATION_AUTO = 0, SCREEN_ORIENTATION_AUTO = 0,
SCREEN_ORIENTATION_LANDSCAPE, SCREEN_ORIENTATION_LANDSCAPE,
SCREEN_ORIENTATION_PORTRAIT, SCREEN_ORIENTATION_PORTRAIT,
} orientation_te; } orientation_te;
class eContext class eContext {
{
private: private:
ewol::CommandLine m_commandLine; //!< Start command line information ewol::CommandLine m_commandLine; //!< Start command line information
public: public:

View File

@ -28,16 +28,14 @@
#define EVENT_DEBUG EWOL_VERBOSE #define EVENT_DEBUG EWOL_VERBOSE
//#define EVENT_DEBUG EWOL_DEBUG //#define EVENT_DEBUG EWOL_DEBUG
void ewol::eInput::calculateLimit(void) void ewol::eInput::calculateLimit(void) {
{
m_eventInputLimit.sepatateTime = 300000; // µs m_eventInputLimit.sepatateTime = 300000; // µs
m_eventInputLimit.DpiOffset = m_dpi*100; m_eventInputLimit.DpiOffset = m_dpi*100;
m_eventMouseLimit.sepatateTime = 300000; // µs m_eventMouseLimit.sepatateTime = 300000; // µs
m_eventMouseLimit.DpiOffset = (float)m_dpi*(float)0.1; m_eventMouseLimit.DpiOffset = (float)m_dpi*(float)0.1;
} }
void ewol::eInput::setDpi(int32_t newDPI) void ewol::eInput::setDpi(int32_t newDPI) {
{
m_dpi = newDPI; m_dpi = newDPI;
// recalculate the DPI system ... // recalculate the DPI system ...
calculateLimit(); calculateLimit();
@ -47,8 +45,7 @@ bool ewol::eInput::localEventInput(ewol::keyEvent::type_te _type,
ewol::Widget* _destWidget, ewol::Widget* _destWidget,
int32_t _IdInput, int32_t _IdInput,
ewol::keyEvent::status_te _status, ewol::keyEvent::status_te _status,
vec2 _pos) vec2 _pos) {
{
if (NULL != _destWidget) { if (NULL != _destWidget) {
if (_type == ewol::keyEvent::typeMouse || _type == ewol::keyEvent::typeFinger) { if (_type == ewol::keyEvent::typeMouse || _type == ewol::keyEvent::typeFinger) {
// create the system Event : // create the system Event :
@ -62,8 +59,9 @@ bool ewol::eInput::localEventInput(ewol::keyEvent::type_te _type,
return false; return false;
} }
void ewol::eInput::abortElement(InputPoperty_ts *_eventTable, int32_t _idInput, ewol::keyEvent::type_te _type) void ewol::eInput::abortElement(InputPoperty_ts *_eventTable,
{ int32_t _idInput,
ewol::keyEvent::type_te _type) {
if (NULL == _eventTable) { if (NULL == _eventTable) {
return; return;
} }
@ -76,8 +74,8 @@ void ewol::eInput::abortElement(InputPoperty_ts *_eventTable, int32_t _idInput,
} }
} }
void ewol::eInput::cleanElement(InputPoperty_ts *_eventTable, int32_t _idInput) void ewol::eInput::cleanElement(InputPoperty_ts *_eventTable,
{ int32_t _idInput) {
if (NULL == _eventTable) { if (NULL == _eventTable) {
return; return;
} }
@ -95,32 +93,29 @@ void ewol::eInput::cleanElement(InputPoperty_ts *_eventTable, int32_t _idInput)
_eventTable[_idInput].posEvent.setValue(0,0); _eventTable[_idInput].posEvent.setValue(0,0);
} }
void ewol::eInput::transfertEvent(ewol::Widget* _source, ewol::Widget* _destination) {
if( NULL == _source
void ewol::eInput::transfertEvent(ewol::Widget* source, ewol::Widget* destination) || NULL == _destination) {
{
if( NULL == source
|| NULL == destination) {
// prevent errors ... // prevent errors ...
return; return;
} }
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (m_eventInputSaved[iii].curentWidgetEvent == source) { if (m_eventInputSaved[iii].curentWidgetEvent == _source) {
// inform the widget that it does not receive the event now // 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); EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventInputSaved[iii].posEvent);
localEventInput(ewol::keyEvent::typeFinger, m_eventInputSaved[iii].curentWidgetEvent, m_eventInputSaved[iii].destinationInputId, ewol::keyEvent::statusAbort, m_eventInputSaved[iii].posEvent); localEventInput(ewol::keyEvent::typeFinger, m_eventInputSaved[iii].curentWidgetEvent, m_eventInputSaved[iii].destinationInputId, ewol::keyEvent::statusAbort, m_eventInputSaved[iii].posEvent);
// set the new widget ... // set the new widget ...
m_eventInputSaved[iii].curentWidgetEvent = destination; m_eventInputSaved[iii].curentWidgetEvent = _destination;
// inform the widget that he receive the event property now... // 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); EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventInputSaved[iii].posEvent);
localEventInput(ewol::keyEvent::typeFinger, m_eventInputSaved[iii].curentWidgetEvent, m_eventInputSaved[iii].destinationInputId, ewol::keyEvent::statusTransfert, m_eventInputSaved[iii].posEvent); localEventInput(ewol::keyEvent::typeFinger, m_eventInputSaved[iii].curentWidgetEvent, m_eventInputSaved[iii].destinationInputId, ewol::keyEvent::statusTransfert, m_eventInputSaved[iii].posEvent);
} }
if (m_eventMouseSaved[iii].curentWidgetEvent == source) { if (m_eventMouseSaved[iii].curentWidgetEvent == _source) {
// inform the widget that it does not receive the event now // 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); EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventMouseSaved[iii].posEvent);
localEventInput(ewol::keyEvent::typeMouse, m_eventMouseSaved[iii].curentWidgetEvent, m_eventMouseSaved[iii].destinationInputId, ewol::keyEvent::statusAbort, m_eventMouseSaved[iii].posEvent); localEventInput(ewol::keyEvent::typeMouse, m_eventMouseSaved[iii].curentWidgetEvent, m_eventMouseSaved[iii].destinationInputId, ewol::keyEvent::statusAbort, m_eventMouseSaved[iii].posEvent);
// set the new widget ... // set the new widget ...
m_eventMouseSaved[iii].curentWidgetEvent = destination; m_eventMouseSaved[iii].curentWidgetEvent = _destination;
// inform the widget that he receive the event property now... // 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); EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventMouseSaved[iii].posEvent);
localEventInput(ewol::keyEvent::typeMouse, m_eventMouseSaved[iii].curentWidgetEvent, m_eventMouseSaved[iii].destinationInputId, ewol::keyEvent::statusTransfert, m_eventMouseSaved[iii].posEvent); localEventInput(ewol::keyEvent::typeMouse, m_eventMouseSaved[iii].curentWidgetEvent, m_eventMouseSaved[iii].destinationInputId, ewol::keyEvent::statusTransfert, m_eventMouseSaved[iii].posEvent);
@ -128,23 +123,22 @@ void ewol::eInput::transfertEvent(ewol::Widget* source, ewol::Widget* destinatio
} }
} }
void ewol::eInput::grabPointer(ewol::Widget* widget) void ewol::eInput::grabPointer(ewol::Widget* _widget) {
{ if(NULL == _widget) {
if(NULL == widget) {
return; return;
} }
m_grabWidget = widget; m_grabWidget = _widget;
m_context.grabPointerEvents(true, widget->getOrigin() + ivec2(widget->getSize().x()/2.0f, widget->getSize().y()/2.0f) ); m_context.grabPointerEvents(true, _widget->getOrigin()
+ ivec2(_widget->getSize().x()/2.0f,
_widget->getSize().y()/2.0f) );
} }
void ewol::eInput::unGrabPointer(void) void ewol::eInput::unGrabPointer(void) {
{
m_grabWidget = NULL; m_grabWidget = NULL;
m_context.grabPointerEvents(false, vec2(0,0)); m_context.grabPointerEvents(false, vec2(0,0));
} }
void ewol::eInput::onObjectRemove(ewol::EObject * removeObject) void ewol::eInput::onObjectRemove(ewol::EObject * removeObject) {
{
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (m_eventInputSaved[iii].curentWidgetEvent == removeObject) { if (m_eventInputSaved[iii].curentWidgetEvent == removeObject) {
// remove the property of this input ... // remove the property of this input ...
@ -157,8 +151,7 @@ void ewol::eInput::onObjectRemove(ewol::EObject * removeObject)
} }
} }
void ewol::eInput::newLayerSet(void) void ewol::eInput::newLayerSet(void) {
{
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ... // remove the property of this input ...
abortElement(m_eventInputSaved, iii, ewol::keyEvent::typeFinger); abortElement(m_eventInputSaved, iii, ewol::keyEvent::typeFinger);
@ -169,9 +162,8 @@ void ewol::eInput::newLayerSet(void)
} }
ewol::eInput::eInput(ewol::eContext& _context) : ewol::eInput::eInput(ewol::eContext& _context) :
m_grabWidget(NULL), m_grabWidget(NULL),
m_context(_context) m_context(_context) {
{
setDpi(200); setDpi(200);
EWOL_INFO("Init (start)"); EWOL_INFO("Init (start)");
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
@ -182,15 +174,14 @@ ewol::eInput::eInput(ewol::eContext& _context) :
EWOL_INFO("Init (end)"); EWOL_INFO("Init (end)");
} }
ewol::eInput::~eInput(void) ewol::eInput::~eInput(void) {
{
EWOL_INFO("Un-Init (start)"); EWOL_INFO("Un-Init (start)");
EWOL_INFO("Un-Init (end)"); EWOL_INFO("Un-Init (end)");
} }
int32_t ewol::eInput::localGetDestinationId(ewol::keyEvent::type_te _type,
int32_t ewol::eInput::localGetDestinationId(ewol::keyEvent::type_te _type, ewol::Widget* _destWidget, int32_t _realInputId) ewol::Widget* _destWidget,
{ int32_t _realInputId) {
if (_type == ewol::keyEvent::typeFinger) { if (_type == ewol::keyEvent::typeFinger) {
int32_t lastMinimum = 0; int32_t lastMinimum = 0;
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
@ -208,30 +199,31 @@ int32_t ewol::eInput::localGetDestinationId(ewol::keyEvent::type_te _type, ewol:
} }
// note if id<0 == > the it was finger event ... // note if id<0 == > the it was finger event ...
void ewol::eInput::motion(ewol::keyEvent::type_te type, int pointerID, vec2 pos) void ewol::eInput::motion(ewol::keyEvent::type_te _type,
{ int _pointerID,
EVENT_DEBUG("motion event : " << type << " " << pointerID << " " << pos); vec2 _pos) {
if (MAX_MANAGE_INPUT <= pointerID) { EVENT_DEBUG("motion event : " << _type << " " << _pointerID << " " << _pos);
if (MAX_MANAGE_INPUT <= _pointerID) {
// reject pointer == > out of IDs... // reject pointer == > out of IDs...
return; return;
} }
InputPoperty_ts *eventTable = NULL; InputPoperty_ts *eventTable = NULL;
if (type == ewol::keyEvent::typeMouse) { if (_type == ewol::keyEvent::typeMouse) {
eventTable = m_eventMouseSaved; eventTable = m_eventMouseSaved;
} else if (type == ewol::keyEvent::typeFinger) { } else if (_type == ewol::keyEvent::typeFinger) {
eventTable = m_eventInputSaved; eventTable = m_eventInputSaved;
} else { } else {
EWOL_ERROR("Unknown type of event"); EWOL_ERROR("Unknown type of event");
return; return;
} }
if( pointerID > MAX_MANAGE_INPUT if( _pointerID > MAX_MANAGE_INPUT
|| pointerID < 0) { || _pointerID < 0) {
// not manage input // not manage input
return; return;
} }
ewol::Windows* tmpWindows = m_context.getWindows(); ewol::Windows* tmpWindows = m_context.getWindows();
// special case for the mouse event 0 that represent the hover event of the system : // special case for the mouse event 0 that represent the hover event of the system :
if (type == ewol::keyEvent::typeMouse && pointerID == 0) { if (_type == ewol::keyEvent::typeMouse && _pointerID == 0) {
// this event is all time on the good widget ... and manage the enter and leave ... // 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 : // NOTE : the "layer widget" force us to get the widget at the specific position all the time :
ewol::Widget* tmpWidget = NULL; ewol::Widget* tmpWidget = NULL;
@ -240,90 +232,127 @@ void ewol::eInput::motion(ewol::keyEvent::type_te type, int pointerID, vec2 pos)
tmpWidget = m_grabWidget; tmpWidget = m_grabWidget;
} else { } else {
if (NULL != tmpWindows) { if (NULL != tmpWindows) {
tmpWidget = tmpWindows->getWidgetAtPos(pos); tmpWidget = tmpWindows->getWidgetAtPos(_pos);
} }
} }
if( tmpWidget != eventTable[pointerID].curentWidgetEvent if( tmpWidget != eventTable[_pointerID].curentWidgetEvent
|| ( true == eventTable[pointerID].isInside || ( true == eventTable[_pointerID].isInside
&& ( eventTable[pointerID].origin.x() > pos.x() && ( eventTable[_pointerID].origin.x() > _pos.x()
|| eventTable[pointerID].origin.y() > pos.y() || eventTable[_pointerID].origin.y() > _pos.y()
|| (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) < pos.x() || (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x()
|| (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) < pos.y()) ) ) { || (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) ) ) {
eventTable[pointerID].isInside = false; eventTable[_pointerID].isInside = false;
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [LEAVE] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID << " == >" << eventTable[_pointerID].destinationInputId << " [LEAVE] " << _pos);
eventTable[pointerID].posEvent = pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusLeave, pos); localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusLeave,
_pos);
} }
if (false == eventTable[pointerID].isInside) { if (false == eventTable[_pointerID].isInside) {
// set the element inside ... // set the element inside ...
eventTable[pointerID].isInside = true; eventTable[_pointerID].isInside = true;
// get destination widget : // get destination widget :
eventTable[pointerID].curentWidgetEvent = tmpWidget; eventTable[_pointerID].curentWidgetEvent = tmpWidget;
if (NULL == eventTable[pointerID].curentWidgetEvent) { if (NULL == eventTable[_pointerID].curentWidgetEvent) {
eventTable[pointerID].isInside = false; eventTable[_pointerID].isInside = false;
} }
if (NULL != eventTable[pointerID].curentWidgetEvent) { if (NULL != eventTable[_pointerID].curentWidgetEvent) {
eventTable[pointerID].origin = eventTable[pointerID].curentWidgetEvent->getOrigin(); eventTable[_pointerID].origin = eventTable[_pointerID].curentWidgetEvent->getOrigin();
eventTable[pointerID].size = eventTable[pointerID].curentWidgetEvent->getSize(); eventTable[_pointerID].size = eventTable[_pointerID].curentWidgetEvent->getSize();
} }
eventTable[pointerID].destinationInputId = 0; eventTable[_pointerID].destinationInputId = 0;
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [ENTER] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusEnter, pos); << " [ENTER] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusEnter,
_pos);
} }
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [MOVE] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusMove, pos); << " [MOVE] " << _pos);
} else if (true == eventTable[pointerID].isUsed) { eventTable[_pointerID].posEvent = _pos;
if (true == eventTable[pointerID].isInside) { localEventInput(_type,
if( eventTable[pointerID].origin.x() > pos.x() eventTable[_pointerID].curentWidgetEvent,
|| eventTable[pointerID].origin.y() > pos.y() eventTable[_pointerID].destinationInputId,
|| (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) < pos.x() ewol::keyEvent::statusMove,
|| (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) < pos.y()) { _pos);
eventTable[pointerID].isInside = false; } else if (true == eventTable[_pointerID].isUsed) {
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [LEAVE] " << pos); if (true == eventTable[_pointerID].isInside) {
eventTable[pointerID].posEvent = pos; if( eventTable[_pointerID].origin.x() > _pos.x()
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusLeave, pos); || eventTable[_pointerID].origin.y() > _pos.y()
|| (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x()
|| (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) {
eventTable[_pointerID].isInside = false;
EVENT_DEBUG("GUI : Input ID=" << _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId
<< " [LEAVE] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusLeave,
_pos);
} }
} else { } else {
if( ( eventTable[pointerID].origin.x() <= pos.x() if( ( eventTable[_pointerID].origin.x() <= _pos.x()
&& (eventTable[pointerID].origin.x() + eventTable[pointerID].size.x()) >= pos.x() ) && (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) >= _pos.x() )
&& ( eventTable[pointerID].origin.y() <= pos.y() && ( eventTable[_pointerID].origin.y() <= _pos.y()
&& (eventTable[pointerID].origin.y() + eventTable[pointerID].size.y()) >= pos.y() ) ) { && (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) >= _pos.y() ) ) {
eventTable[pointerID].isInside = true; eventTable[_pointerID].isInside = true;
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [ENTER] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusEnter, pos); << " [ENTER] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusEnter,
_pos);
} }
} }
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [MOVE] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusMove, pos); << " [MOVE] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusMove,
_pos);
} }
} }
void ewol::eInput::state(ewol::keyEvent::type_te type, int pointerID, bool isDown, vec2 pos) void ewol::eInput::state(ewol::keyEvent::type_te _type,
int _pointerID,
bool _isDown,
vec2 _pos)
{ {
if (MAX_MANAGE_INPUT <= pointerID) { if (MAX_MANAGE_INPUT <= _pointerID) {
// reject pointer == > out of IDs... // reject pointer == > out of IDs...
return; return;
} }
EWOL_DEBUG("event pointerId=" << pointerID); EWOL_DEBUG("event pointerId=" << _pointerID);
// convert position in open-GL coordonates ... // convert position in open-GL coordonates ...
InputPoperty_ts *eventTable = NULL; InputPoperty_ts *eventTable = NULL;
inputLimit_ts localLimit; inputLimit_ts localLimit;
if (type == ewol::keyEvent::typeMouse) { if (_type == ewol::keyEvent::typeMouse) {
eventTable = m_eventMouseSaved; eventTable = m_eventMouseSaved;
localLimit = m_eventMouseLimit; localLimit = m_eventMouseLimit;
} else if (type == ewol::keyEvent::typeFinger) { } else if (_type == ewol::keyEvent::typeFinger) {
eventTable = m_eventInputSaved; eventTable = m_eventInputSaved;
localLimit = m_eventInputLimit; localLimit = m_eventInputLimit;
} else { } else {
EWOL_ERROR("Unknown type of event"); EWOL_ERROR("Unknown type of event");
return; return;
} }
if( pointerID > MAX_MANAGE_INPUT if( _pointerID > MAX_MANAGE_INPUT
|| pointerID <= 0) { || _pointerID <= 0) {
// not manage input // not manage input
return; return;
} }
@ -331,106 +360,130 @@ void ewol::eInput::state(ewol::keyEvent::type_te type, int pointerID, bool isDow
int64_t currentTime = ewol::getTime(); int64_t currentTime = ewol::getTime();
ewol::Windows* tmpWindows = m_context.getWindows(); ewol::Windows* tmpWindows = m_context.getWindows();
if (true == isDown) { if (true == _isDown) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); EWOL_VERBOSE("GUI : Input ID=" << _pointerID
if(true == eventTable[pointerID].isUsed) { << " == >" << eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos);
if(true == eventTable[_pointerID].isUsed) {
// we have an event previously ... check delay between click and offset position // we have an event previously ... check delay between click and offset position
if (currentTime - eventTable[pointerID].lastTimeEvent > localLimit.sepatateTime) { if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) {
cleanElement(eventTable, pointerID); cleanElement(eventTable, _pointerID);
} else if( abs(eventTable[pointerID].downStart.x() - pos.x()) >= localLimit.DpiOffset } else if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) >= localLimit.DpiOffset
|| abs(eventTable[pointerID].downStart.y() - pos.y()) >= localLimit.DpiOffset ){ || abs(eventTable[_pointerID].downStart.y() - _pos.y()) >= localLimit.DpiOffset ){
cleanElement(eventTable, pointerID); cleanElement(eventTable, _pointerID);
} }
} }
if(true == eventTable[pointerID].isUsed) { if(true == eventTable[_pointerID].isUsed) {
// save start time // save start time
eventTable[pointerID].lastTimeEvent = currentTime; eventTable[_pointerID].lastTimeEvent = currentTime;
// generate DOWN Event // generate DOWN Event
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusDown, pos); << " [DOWN] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusDown,
_pos);
} else { } else {
// Mark it used : // Mark it used :
eventTable[pointerID].isUsed = true; eventTable[_pointerID].isUsed = true;
// Save current position : // Save current position :
eventTable[pointerID].downStart = pos; eventTable[_pointerID].downStart = _pos;
// save start time // save start time
eventTable[pointerID].lastTimeEvent = currentTime; eventTable[_pointerID].lastTimeEvent = currentTime;
// set the element inside ... // set the element inside ...
eventTable[pointerID].isInside = true; eventTable[_pointerID].isInside = true;
// get destination widget : // get destination widget :
if(NULL != tmpWindows) { if(NULL != tmpWindows) {
if (m_grabWidget != NULL && type == ewol::keyEvent::typeMouse) { if (m_grabWidget != NULL && _type == ewol::keyEvent::typeMouse) {
eventTable[pointerID].curentWidgetEvent = m_grabWidget; eventTable[_pointerID].curentWidgetEvent = m_grabWidget;
} else { } else {
eventTable[pointerID].curentWidgetEvent = tmpWindows->getWidgetAtPos(pos); eventTable[_pointerID].curentWidgetEvent = tmpWindows->getWidgetAtPos(_pos);
} }
} else { } else {
eventTable[pointerID].curentWidgetEvent = NULL; eventTable[_pointerID].curentWidgetEvent = NULL;
} }
if (NULL != eventTable[pointerID].curentWidgetEvent) { if (NULL != eventTable[_pointerID].curentWidgetEvent) {
eventTable[pointerID].origin = eventTable[pointerID].curentWidgetEvent->getOrigin(); eventTable[_pointerID].origin = eventTable[_pointerID].curentWidgetEvent->getOrigin();
eventTable[pointerID].size = eventTable[pointerID].curentWidgetEvent->getSize(); eventTable[_pointerID].size = eventTable[_pointerID].curentWidgetEvent->getSize();
eventTable[pointerID].destinationInputId = localGetDestinationId(type, eventTable[pointerID].curentWidgetEvent, pointerID); eventTable[_pointerID].destinationInputId = localGetDestinationId(_type, eventTable[_pointerID].curentWidgetEvent, _pointerID);
} else { } else {
eventTable[pointerID].destinationInputId = -1; eventTable[_pointerID].destinationInputId = -1;
} }
// generate DOWN Event // generate DOWN Event
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::keyEvent::statusDown, pos); << " [DOWN] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
eventTable[_pointerID].destinationInputId,
ewol::keyEvent::statusDown,
_pos);
} }
} else { } else {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [UP] " << pos); EWOL_VERBOSE("GUI : Input ID=" << _pointerID
if(false == eventTable[pointerID].isUsed) { << " == >" << eventTable[_pointerID].destinationInputId
<< " [UP] " << _pos);
if(false == eventTable[_pointerID].isUsed) {
// bad case ... ??? // bad case ... ???
EWOL_DEBUG("Up event without previous down ... "); EWOL_DEBUG("Up event without previous down ... ");
// Mark it un-used : // Mark it un-used :
eventTable[pointerID].isUsed = false; eventTable[_pointerID].isUsed = false;
// revove the widget ... // revove the widget ...
eventTable[pointerID].curentWidgetEvent = NULL; eventTable[_pointerID].curentWidgetEvent = NULL;
} else { } else {
// generate UP Event // generate UP Event
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [UP] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, eventTable[pointerID].curentWidgetEvent, pointerID, ewol::keyEvent::statusUp, pos); << " [UP] " << _pos);
eventTable[_pointerID].posEvent = _pos;
localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent,
_pointerID,
ewol::keyEvent::statusUp,
_pos);
// generate event (single) // generate event (single)
if( abs(eventTable[pointerID].downStart.x() - pos.x()) < localLimit.DpiOffset if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset
&& abs(eventTable[pointerID].downStart.y() - pos.y()) < localLimit.DpiOffset ){ && abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){
// Save current position : // Save current position :
eventTable[pointerID].downStart = pos; eventTable[_pointerID].downStart = _pos;
// save start time // save start time
eventTable[pointerID].lastTimeEvent = currentTime; eventTable[_pointerID].lastTimeEvent = currentTime;
int32_t nbClickMax = 0; int32_t nbClickMax = 0;
if(eventTable[pointerID].curentWidgetEvent != NULL) { if(eventTable[_pointerID].curentWidgetEvent != NULL) {
nbClickMax = eventTable[pointerID].curentWidgetEvent->getMouseLimit(); nbClickMax = eventTable[_pointerID].curentWidgetEvent->getMouseLimit();
if (nbClickMax>5) { if (nbClickMax>5) {
nbClickMax = 5; nbClickMax = 5;
} }
} }
// in grab mode the single to quinte event are not generated .... // in grab mode the single to quinte event are not generated ....
if( ( m_grabWidget == NULL if( ( m_grabWidget == NULL
|| type != ewol::keyEvent::typeMouse ) || _type != ewol::keyEvent::typeMouse )
&& eventTable[pointerID].nbClickEvent < nbClickMax) { && eventTable[_pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE : // generate event SINGLE :
eventTable[pointerID].nbClickEvent++; eventTable[_pointerID].nbClickEvent++;
EVENT_DEBUG("GUI : Input ID=" << pointerID << " == >" << eventTable[pointerID].destinationInputId << " [" << eventTable[pointerID].nbClickEvent << "] " << pos); EVENT_DEBUG("GUI : Input ID=" << _pointerID
eventTable[pointerID].posEvent = pos; << " == >" << eventTable[_pointerID].destinationInputId
localEventInput(type, << " [" << eventTable[_pointerID].nbClickEvent << "] " << _pos);
eventTable[pointerID].curentWidgetEvent, eventTable[_pointerID].posEvent = _pos;
eventTable[pointerID].destinationInputId, localEventInput(_type,
(ewol::keyEvent::status_te)(ewol::keyEvent::statusSingle + eventTable[pointerID].nbClickEvent-1), eventTable[_pointerID].curentWidgetEvent,
pos); eventTable[_pointerID].destinationInputId,
if( eventTable[pointerID].nbClickEvent >= nbClickMax) { (ewol::keyEvent::status_te)(ewol::keyEvent::statusSingle + eventTable[_pointerID].nbClickEvent-1),
eventTable[pointerID].nbClickEvent = 0; _pos);
if( eventTable[_pointerID].nbClickEvent >= nbClickMax) {
eventTable[_pointerID].nbClickEvent = 0;
} }
} else { } else {
eventTable[pointerID].nbClickEvent = 0; eventTable[_pointerID].nbClickEvent = 0;
} }
} }
// specific for tuch event // specific for tuch event
if (type == ewol::keyEvent::typeFinger) { if (_type == ewol::keyEvent::typeFinger) {
cleanElement(eventTable, pointerID); cleanElement(eventTable, _pointerID);
} }
} }
} }

View File

@ -13,9 +13,7 @@
#define MAX_MANAGE_INPUT (15) #define MAX_MANAGE_INPUT (15)
namespace ewol namespace ewol {
{
// internal structure // internal structure
typedef struct { typedef struct {
bool isUsed; bool isUsed;
@ -36,8 +34,7 @@ namespace ewol
int32_t DpiOffset; int32_t DpiOffset;
} inputLimit_ts; } inputLimit_ts;
class eContext; class eContext;
class eInput class eInput {
{
// special grab pointer mode : // special grab pointer mode :
private: private:
ewol::Widget* m_grabWidget; //!< widget that grab the curent pointer. ewol::Widget* m_grabWidget; //!< widget that grab the curent pointer.
@ -116,7 +113,6 @@ namespace ewol
*/ */
void unGrabPointer(void); void unGrabPointer(void);
}; };
}; };
#endif #endif

View File

@ -15,8 +15,7 @@
* @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time. * @note due ti the fact that the system can be called for multiple instance, for naw we just limit the acces to one process at a time.
* @return the main inteface Mutex * @return the main inteface Mutex
*/ */
static etk::Mutex& mutexOpenGl(void) static etk::Mutex& mutexOpenGl(void) {
{
static etk::Mutex s_drawMutex; static etk::Mutex s_drawMutex;
return s_drawMutex; return s_drawMutex;
} }
@ -41,32 +40,28 @@ void ewol::openGL::lock(void) {
l_programId = -1; l_programId = -1;
} }
void ewol::openGL::unLock(void) void ewol::openGL::unLock(void) {
{
mutexOpenGl().unLock(); mutexOpenGl().unLock();
} }
void ewol::openGL::setBasicMatrix(const mat4& newOne) void ewol::openGL::setBasicMatrix(const mat4& _newOne) {
{
if (l_matrixList.size()!=1) { if (l_matrixList.size()!=1) {
EWOL_ERROR("matrix is not corect size in the stack : " << l_matrixList.size()); EWOL_ERROR("matrix is not corect size in the stack : " << l_matrixList.size());
} }
l_matrixList.clear(); l_matrixList.clear();
l_matrixList.pushBack(newOne); l_matrixList.pushBack(_newOne);
} }
void ewol::openGL::setMatrix(const mat4& newOne) void ewol::openGL::setMatrix(const mat4& _newOne) {
{
if (l_matrixList.size() == 0) { if (l_matrixList.size() == 0) {
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size());
l_matrixList.pushBack(newOne); l_matrixList.pushBack(_newOne);
return; return;
} }
l_matrixList[l_matrixList.size()-1] = newOne; l_matrixList[l_matrixList.size()-1] = _newOne;
} }
void ewol::openGL::push(void) void ewol::openGL::push(void) {
{
if (l_matrixList.size() == 0) { if (l_matrixList.size() == 0) {
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size());
mat4 tmp; mat4 tmp;
@ -77,8 +72,7 @@ void ewol::openGL::push(void)
l_matrixList.pushBack(tmp); l_matrixList.pushBack(tmp);
} }
void ewol::openGL::pop(void) void ewol::openGL::pop(void) {
{
if (l_matrixList.size() <= 1) { if (l_matrixList.size() <= 1) {
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size());
l_matrixList.clear(); l_matrixList.clear();
@ -91,8 +85,7 @@ void ewol::openGL::pop(void)
l_matrixCamera.identity(); l_matrixCamera.identity();
} }
const mat4& ewol::openGL::getMatrix(void) const mat4& ewol::openGL::getMatrix(void) {
{
if (l_matrixList.size() == 0) { if (l_matrixList.size() == 0) {
EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size());
mat4 tmp; mat4 tmp;
@ -101,31 +94,25 @@ const mat4& ewol::openGL::getMatrix(void)
return l_matrixList[l_matrixList.size()-1]; return l_matrixList[l_matrixList.size()-1];
} }
const mat4& ewol::openGL::getCameraMatrix(void) const mat4& ewol::openGL::getCameraMatrix(void) {
{
return l_matrixCamera; return l_matrixCamera;
} }
void ewol::openGL::setCameraMatrix(const mat4& newOne) void ewol::openGL::setCameraMatrix(const mat4& _newOne) {
{ l_matrixCamera = _newOne;
l_matrixCamera = newOne;
} }
void ewol::openGL::finish(void) void ewol::openGL::finish(void) {
{
l_programId = -1; l_programId = -1;
l_textureflags = 0; l_textureflags = 0;
} }
void ewol::openGL::flush(void) void ewol::openGL::flush(void) {
{
l_programId = -1; l_programId = -1;
l_textureflags = 0; l_textureflags = 0;
} }
void ewol::openGL::swap(void) void ewol::openGL::swap(void) {
{
} }
@ -195,40 +182,35 @@ static correspondenceTable_ts basicFlag[] = {
static int32_t basicFlagCount = sizeof(basicFlag) / sizeof(correspondenceTable_ts); static int32_t basicFlagCount = sizeof(basicFlag) / sizeof(correspondenceTable_ts);
void ewol::openGL::enable(ewol::openGL::openGlFlags_te flagID) void ewol::openGL::enable(ewol::openGL::openGlFlags_te _flagID) {
{
#ifdef DIRECT_MODE #ifdef DIRECT_MODE
for (int32_t iii=0; iii<basicFlagCount ; iii++) { for (int32_t iii=0; iii<basicFlagCount ; iii++) {
if ( basicFlag[iii].curentFlag == (uint32_t)flagID ) { if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
glEnable(basicFlag[iii].OGlFlag); glEnable(basicFlag[iii].OGlFlag);
} }
} }
# else # else
//EWOL_DEBUG("Enable FLAGS = " << l_flagsMustBeSet); //EWOL_DEBUG("Enable FLAGS = " << l_flagsMustBeSet);
l_flagsMustBeSet |= (uint32_t)flagID; l_flagsMustBeSet |= (uint32_t)_flagID;
//EWOL_DEBUG(" == >" << l_flagsMustBeSet); //EWOL_DEBUG(" == >" << l_flagsMustBeSet);
#endif #endif
} }
void ewol::openGL::disable(ewol::openGL::openGlFlags_te flagID) void ewol::openGL::disable(ewol::openGL::openGlFlags_te _flagID) {
{
#ifdef DIRECT_MODE #ifdef DIRECT_MODE
for (int32_t iii=0; iii<basicFlagCount ; iii++) { for (int32_t iii=0; iii<basicFlagCount ; iii++) {
if ( basicFlag[iii].curentFlag == (uint32_t)flagID ) { if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
glDisable(basicFlag[iii].OGlFlag); glDisable(basicFlag[iii].OGlFlag);
} }
} }
# else # else
//EWOL_DEBUG("Disable FLAGS = " << l_flagsMustBeSet); //EWOL_DEBUG("Disable FLAGS = " << l_flagsMustBeSet);
l_flagsMustBeSet &= ~((uint32_t)flagID); l_flagsMustBeSet &= ~((uint32_t)_flagID);
//EWOL_DEBUG(" == >" << l_flagsMustBeSet); //EWOL_DEBUG(" == >" << l_flagsMustBeSet);
#endif #endif
} }
void ewol::openGL::updateAllFlags(void) {
void ewol::openGL::updateAllFlags(void)
{
#ifdef DIRECT_MODE #ifdef DIRECT_MODE
return; return;
#endif #endif
@ -251,75 +233,67 @@ void ewol::openGL::updateAllFlags(void)
} }
void ewol::openGL::activeTexture(uint32_t flagID) void ewol::openGL::activeTexture(uint32_t _flagID) {
{
if (l_programId >= 0) { if (l_programId >= 0) {
glActiveTexture(flagID); glActiveTexture(_flagID);
} }
} }
void ewol::openGL::desActiveTexture(uint32_t flagID) void ewol::openGL::desActiveTexture(uint32_t _flagID) {
{
if (l_programId >= 0) { if (l_programId >= 0) {
} }
} }
void ewol::openGL::drawArrays(uint32_t mode, int32_t first, int32_t count) void ewol::openGL::drawArrays(uint32_t _mode, int32_t _first, int32_t _count) {
{
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
glDrawArrays(mode, first, count); glDrawArrays(_mode, _first, _count);
} }
} }
void ewol::openGL::drawElements(uint32_t mode, const etk::Vector<uint32_t>& indices) void ewol::openGL::drawElements(uint32_t _mode, const etk::Vector<uint32_t>& _indices) {
{
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
//EWOL_DEBUG("Request draw of " << indices.size() << "elements"); //EWOL_DEBUG("Request draw of " << indices.size() << "elements");
glDrawElements(mode, indices.size(), GL_UNSIGNED_INT, &indices[0]); glDrawElements(_mode, _indices.size(), GL_UNSIGNED_INT, &_indices[0]);
} }
} }
void ewol::openGL::drawElements16(uint32_t mode, const etk::Vector<uint16_t>& indices) void ewol::openGL::drawElements16(uint32_t _mode, const etk::Vector<uint16_t>& _indices) {
{
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
glDrawElements(mode, indices.size(), GL_UNSIGNED_SHORT, &indices[0]); glDrawElements(_mode, _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]);
} }
} }
void ewol::openGL::drawElements8(uint32_t mode, const etk::Vector<uint8_t>& indices) void ewol::openGL::drawElements8(uint32_t _mode, const etk::Vector<uint8_t>& _indices) {
{
if (l_programId >= 0) { if (l_programId >= 0) {
updateAllFlags(); updateAllFlags();
glDrawElements(mode, indices.size(), GL_UNSIGNED_BYTE, &indices[0]); glDrawElements(_mode, _indices.size(), GL_UNSIGNED_BYTE, &_indices[0]);
} }
} }
void ewol::openGL::useProgram(int32_t _id) {
void ewol::openGL::useProgram(int32_t id)
{
//EWOL_DEBUG("USE prog : " << id); //EWOL_DEBUG("USE prog : " << id);
#if 1 #if 1
// note : In normal openGL case, the system might call with the program ID and at the end with 0, // note : In normal openGL case, the system might call with the program ID and at the end with 0,
// here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the // here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the
// user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ... // user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ...
if (-1 == id) { if (-1 == _id) {
// not used == > because it is unneded // not used == > because it is unneded
return; return;
} }
if (l_programId != id) { if (l_programId != _id) {
l_programId = id; l_programId = _id;
glUseProgram(l_programId); glUseProgram(l_programId);
} }
#else #else
if (-1 == id) { if (-1 == _id) {
glUseProgram(0); glUseProgram(0);
} else { } else {
l_programId = id; l_programId = _id;
glUseProgram(id); glUseProgram(_id);
} }
#endif #endif
} }

View File

@ -65,15 +65,15 @@ namespace ewol {
void unLock(void); void unLock(void);
/** /**
* @brief When you will done an opengl rendering, you might call this reset matrix first. It remove all the stach of the matrix pushed. * @brief When you will done an opengl rendering, you might call this reset matrix first. It remove all the stach of the matrix pushed.
* @param[in] newOne the default matrix that might be set for the graphic card for renderer. if too more pop will be done, this is the last that mmight survived * @param[in] _newOne the default matrix that might be set for the graphic card for renderer. if too more pop will be done, this is the last that mmight survived
*/ */
void setBasicMatrix(const mat4& newOne); void setBasicMatrix(const mat4& _newOne);
/** /**
* @brief this funtion configure the current use matrix for the renderer (call @ref Push before, and @ref Pop when no more needed). * @brief this funtion configure the current use matrix for the renderer (call @ref Push before, and @ref Pop when no more needed).
* @param[in] newOne The new current matrix use for the render. * @param[in] _newOne The new current matrix use for the render.
* @note We did not use opengl standard system, due to the fact that is not supported in opengl ES-2 * @note We did not use opengl standard system, due to the fact that is not supported in opengl ES-2
*/ */
void setMatrix(const mat4& newOne); void setMatrix(const mat4& _newOne);
/** /**
* @brief store current matrix in the matrix stack. * @brief store current matrix in the matrix stack.
*/ */
@ -94,9 +94,9 @@ namespace ewol {
const mat4& getCameraMatrix(void); const mat4& getCameraMatrix(void);
/** /**
* @brief set a reference on the current camera to opengl renderer. * @brief set a reference on the current camera to opengl renderer.
* @param[in] newOne The requested matrix. * @param[in] _newOne The requested matrix.
*/ */
void setCameraMatrix(const mat4& newOne); void setCameraMatrix(const mat4& _newOne);
/** /**
* @brief * @brief
*/ */
@ -146,12 +146,12 @@ namespace ewol {
* @brief enable a flag on the system * @brief enable a flag on the system
* @param[in] flagID The flag requested * @param[in] flagID The flag requested
*/ */
void enable(openGlFlags_te flagID); void enable(openGlFlags_te _flagID);
/** /**
* @brief disable a flag on the system * @brief disable a flag on the system
* @param[in] flagID The flag requested * @param[in] flagID The flag requested
*/ */
void disable(openGlFlags_te flagID); void disable(openGlFlags_te _flagID);
/** /**
* @brieg update all the internal flag needed to be set from tre previous element set ... * @brieg update all the internal flag needed to be set from tre previous element set ...
*/ */
@ -160,24 +160,24 @@ namespace ewol {
* @brief enable Texture on the system * @brief enable Texture on the system
* @param[in] flagID The flag requested * @param[in] flagID The flag requested
*/ */
void activeTexture(uint32_t flagID); void activeTexture(uint32_t _flagID);
/** /**
* @brief disable Texture on the system * @brief disable Texture on the system
* @param[in] flagID The flag requested * @param[in] flagID The flag requested
*/ */
void desActiveTexture(uint32_t flagID); void desActiveTexture(uint32_t _flagID);
/** /**
* @brief draw a specific array == > this enable mode difference ... * @brief draw a specific array == > this enable mode difference ...
*/ */
void drawArrays(uint32_t mode, int32_t first, int32_t count); void drawArrays(uint32_t _mode, int32_t _first, int32_t _count);
void drawElements (uint32_t mode, const etk::Vector<uint32_t>& indices); void drawElements (uint32_t _mode, const etk::Vector<uint32_t>& _indices);
void drawElements16(uint32_t mode, const etk::Vector<uint16_t>& indices); void drawElements16(uint32_t _mode, const etk::Vector<uint16_t>& _indices);
void drawElements8 (uint32_t mode, const etk::Vector<uint8_t>& indices); void drawElements8 (uint32_t _mode, const etk::Vector<uint8_t>& _indices);
/** /**
* @brief Use openGL program * @brief Use openGL program
* @param[in] id Id of the program that might be used * @param[in] id Id of the program that might be used
*/ */
void useProgram(int32_t id); void useProgram(int32_t _id);
}; };
}; };

View File

@ -15,8 +15,7 @@
ewol::Colored3DObject::Colored3DObject(void) : ewol::Colored3DObject::Colored3DObject(void) :
m_GLprogram(NULL) m_GLprogram(NULL) {
{
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:simple3D.prog"); m_GLprogram = ewol::Program::keep("DATA:simple3D.prog");
@ -27,8 +26,7 @@ ewol::Colored3DObject::Colored3DObject(void) :
} }
} }
ewol::Colored3DObject::~Colored3DObject(void) ewol::Colored3DObject::~Colored3DObject(void) {
{
// remove dynamics dependencies : // remove dynamics dependencies :
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
@ -37,8 +35,7 @@ ewol::Colored3DObject::~Colored3DObject(void)
void ewol::Colored3DObject::draw(etk::Vector<vec3>& _vertices, void ewol::Colored3DObject::draw(etk::Vector<vec3>& _vertices,
const etk::Color<float>& _color, const etk::Color<float>& _color,
bool _updateDepthBuffer, bool _updateDepthBuffer,
bool _depthtest) bool _depthtest) {
{
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -81,8 +78,7 @@ void ewol::Colored3DObject::draw(etk::Vector<vec3>& _vertices,
const etk::Color<float>& _color, const etk::Color<float>& _color,
mat4& _transformationMatrix, mat4& _transformationMatrix,
bool _updateDepthBuffer, bool _updateDepthBuffer,
bool _depthtest) bool _depthtest) {
{
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -122,8 +118,7 @@ void ewol::Colored3DObject::drawLine(etk::Vector<vec3>& _vertices,
const etk::Color<float>& _color, const etk::Color<float>& _color,
mat4& _transformationMatrix, mat4& _transformationMatrix,
bool _updateDepthBuffer, bool _updateDepthBuffer,
bool _depthtest) bool _depthtest) {
{
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -159,10 +154,7 @@ void ewol::Colored3DObject::drawLine(etk::Vector<vec3>& _vertices,
} }
} }
ewol::Colored3DObject* ewol::Colored3DObject::keep(void) {
ewol::Colored3DObject* ewol::Colored3DObject::keep(void)
{
EWOL_VERBOSE("KEEP : direct Colored3DObject"); EWOL_VERBOSE("KEEP : direct Colored3DObject");
// need to crate a new one ... // need to crate a new one ...
ewol::Colored3DObject* object = new ewol::Colored3DObject(); ewol::Colored3DObject* object = new ewol::Colored3DObject();
@ -174,8 +166,7 @@ ewol::Colored3DObject* ewol::Colored3DObject::keep(void)
return object; return object;
} }
void ewol::Colored3DObject::release(ewol::Colored3DObject*& _object) void ewol::Colored3DObject::release(ewol::Colored3DObject*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }

View File

@ -15,10 +15,8 @@
#include <ewol/resources/Shader.h> #include <ewol/resources/Shader.h>
#include <ewol/resources/Program.h> #include <ewol/resources/Program.h>
namespace ewol namespace ewol {
{ class Colored3DObject : public ewol::Resource {
class Colored3DObject : public ewol::Resource
{
protected: protected:
ewol::Program* m_GLprogram; ewol::Program* m_GLprogram;
int32_t m_GLPosition; int32_t m_GLPosition;

View File

@ -15,8 +15,7 @@
#define __class__ "ConfigFile" #define __class__ "ConfigFile"
void ewol::SimpleConfigElement::parse(const etk::UString& value) void ewol::SimpleConfigElement::parse(const etk::UString& value) {
{
etk::Char tmp = value.c_str(); etk::Char tmp = value.c_str();
m_valueInt = 0; m_valueInt = 0;
m_valuefloat = 0; m_valuefloat = 0;
@ -28,15 +27,13 @@ void ewol::SimpleConfigElement::parse(const etk::UString& value)
ewol::ConfigFile::ConfigFile(const etk::UString& _filename): ewol::ConfigFile::ConfigFile(const etk::UString& _filename):
ewol::Resource(_filename) ewol::Resource(_filename) {
{
EWOL_DEBUG("SFP : load \"" << _filename << "\""); EWOL_DEBUG("SFP : load \"" << _filename << "\"");
reload(); reload();
} }
ewol::ConfigFile::~ConfigFile(void) ewol::ConfigFile::~ConfigFile(void) {
{
// remove all element // remove all element
for (int32_t iii=0; iii<m_list.size(); iii++){ for (int32_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -48,8 +45,7 @@ ewol::ConfigFile::~ConfigFile(void)
} }
void ewol::ConfigFile::reload(void) void ewol::ConfigFile::reload(void) {
{
// reset all parameters // reset all parameters
for (int32_t iii=0; iii<m_list.size(); iii++){ for (int32_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -129,12 +125,10 @@ void ewol::ConfigFile::reload(void)
} }
// close the file: // close the file:
file.fileClose(); file.fileClose();
} }
int32_t ewol::ConfigFile::request(const etk::UString& _paramName) int32_t ewol::ConfigFile::request(const etk::UString& _paramName) {
{
// check if the parameters existed : // check if the parameters existed :
for (int32_t iii=0; iii<m_list.size(); iii++){ for (int32_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -153,8 +147,7 @@ int32_t ewol::ConfigFile::request(const etk::UString& _paramName)
} }
ewol::ConfigFile* ewol::ConfigFile::keep(const etk::UString& _filename) ewol::ConfigFile* ewol::ConfigFile::keep(const etk::UString& _filename) {
{
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\""); EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\"");
ewol::ConfigFile* object = static_cast<ewol::ConfigFile*>(getManager().localKeep(_filename)); ewol::ConfigFile* object = static_cast<ewol::ConfigFile*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
@ -170,8 +163,7 @@ ewol::ConfigFile* ewol::ConfigFile::keep(const etk::UString& _filename)
return object; return object;
} }
void ewol::ConfigFile::release(ewol::ConfigFile*& _object) void ewol::ConfigFile::release(ewol::ConfigFile*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }

View File

@ -13,16 +13,14 @@
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol namespace ewol {
{ class SimpleConfigElement {
class SimpleConfigElement
{
public: public:
etk::UString m_paramName; etk::UString m_paramName;
private: private:
etk::UString m_value; etk::UString m_value;
int32_t m_valueInt; int32_t m_valueInt;
float m_valuefloat; float m_valuefloat;
public: public:
SimpleConfigElement(const etk::UString& _name) : SimpleConfigElement(const etk::UString& _name) :
m_paramName(_name), m_paramName(_name),
@ -36,11 +34,10 @@ namespace ewol
etk::UString& getString(void) { return m_value; }; etk::UString& getString(void) { return m_value; };
}; };
class ConfigFile : public ewol::Resource class ConfigFile : public ewol::Resource {
{
private: private:
etk::Vector<ewol::SimpleConfigElement*> m_list; etk::Vector<ewol::SimpleConfigElement*> m_list;
etk::UString m_errorString; etk::UString m_errorString;
protected: protected:
ConfigFile(const etk::UString& _filename); ConfigFile(const etk::UString& _filename);
virtual ~ConfigFile(void); virtual ~ConfigFile(void);
@ -50,9 +47,9 @@ namespace ewol
int32_t request(const etk::UString& _paramName); int32_t request(const etk::UString& _paramName);
int32_t getInteger(int32_t id) { if (id<0) { return 0; } return m_list[id]->getInteger(); }; int32_t getInteger(int32_t _id) { if (_id<0) { return 0; } return m_list[_id]->getInteger(); };
float getFloat(int32_t id) { if (id<0) { return 0; } return m_list[id]->getFloat(); }; float getFloat(int32_t _id) { if (_id<0) { return 0; } return m_list[_id]->getFloat(); };
etk::UString& getString(int32_t id) { if (id<0) { return m_errorString; } return m_list[id]->getString(); }; etk::UString& getString(int32_t _id) { if (_id<0) { return m_errorString; } return m_list[_id]->getString(); };
public: public:
/** /**
* @brief keep the resource pointer. * @brief keep the resource pointer.

View File

@ -18,17 +18,14 @@
#include <ewol/resources/font/FontBase.h> #include <ewol/resources/font/FontBase.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#undef __class__ #undef __class__
#define __class__ "FontFreeType" #define __class__ "FontFreeType"
// free Font hnadle of librairies ... entry for acces ... // free Font hnadle of librairies ... entry for acces ...
static int32_t l_countLoaded=0; static int32_t l_countLoaded=0;
static FT_Library library; static FT_Library library;
void ewol::freeTypeInit(void) void ewol::freeTypeInit(void) {
{
EWOL_DEBUG(" == > init Font-Manager"); EWOL_DEBUG(" == > init Font-Manager");
l_countLoaded++; l_countLoaded++;
if (l_countLoaded>1) { if (l_countLoaded>1) {
@ -41,8 +38,7 @@ void ewol::freeTypeInit(void)
} }
} }
void ewol::freeTypeUnInit(void) void ewol::freeTypeUnInit(void) {
{
EWOL_DEBUG(" == > Un-Init Font-Manager"); EWOL_DEBUG(" == > Un-Init Font-Manager");
l_countLoaded--; l_countLoaded--;
if (l_countLoaded>0) { if (l_countLoaded>0) {
@ -56,11 +52,8 @@ void ewol::freeTypeUnInit(void)
} }
} }
ewol::FontFreeType::FontFreeType(const etk::UString& _fontName) : ewol::FontFreeType::FontFreeType(const etk::UString& _fontName) :
FontBase(_fontName) FontBase(_fontName) {
{
m_init = false; m_init = false;
m_FileBuffer = NULL; m_FileBuffer = NULL;
m_FileSize = 0; m_FileSize = 0;
@ -103,8 +96,7 @@ ewol::FontFreeType::FontFreeType(const etk::UString& _fontName) :
} }
} }
ewol::FontFreeType::~FontFreeType(void) ewol::FontFreeType::~FontFreeType(void) {
{
// clean the tmp memory // clean the tmp memory
if (NULL != m_FileBuffer) { if (NULL != m_FileBuffer) {
delete[] m_FileBuffer; delete[] m_FileBuffer;
@ -114,9 +106,7 @@ ewol::FontFreeType::~FontFreeType(void)
FT_Done_Face( m_fftFace ); FT_Done_Face( m_fftFace );
} }
vec2 ewol::FontFreeType::getSize(int32_t _fontSize, const etk::UString& _unicodeString) {
vec2 ewol::FontFreeType::getSize(int32_t _fontSize, const etk::UString& _unicodeString)
{
if(false == m_init) { if(false == m_init) {
return vec2(0,0); return vec2(0,0);
} }
@ -125,13 +115,11 @@ vec2 ewol::FontFreeType::getSize(int32_t _fontSize, const etk::UString& _unicode
return outputSize; return outputSize;
} }
int32_t ewol::FontFreeType::getHeight(int32_t _fontSize) int32_t ewol::FontFreeType::getHeight(int32_t _fontSize) {
{
return _fontSize*1.43f; // this is a really "magic" number ... return _fontSize*1.43f; // this is a really "magic" number ...
} }
bool ewol::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) bool ewol::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) {
{
if(false == m_init) { if(false == m_init) {
return false; return false;
} }
@ -175,8 +163,7 @@ bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut,
int32_t _fontSize, int32_t _fontSize,
ivec2 _glyphPosition, ivec2 _glyphPosition,
ewol::GlyphProperty& _property, ewol::GlyphProperty& _property,
int8_t _posInImage) int8_t _posInImage) {
{
if(false == m_init) { if(false == m_init) {
return false; return false;
} }
@ -236,8 +223,7 @@ bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut,
} }
void ewol::FontFreeType::generateKerning(int32_t fontSize, etk::Vector<ewol::GlyphProperty>& listGlyph) void ewol::FontFreeType::generateKerning(int32_t fontSize, etk::Vector<ewol::GlyphProperty>& listGlyph) {
{
if(false == m_init) { if(false == m_init) {
return; return;
} }
@ -270,8 +256,7 @@ void ewol::FontFreeType::generateKerning(int32_t fontSize, etk::Vector<ewol::Gly
} }
void ewol::FontFreeType::display(void) void ewol::FontFreeType::display(void) {
{
if(false == m_init) { if(false == m_init) {
return; return;
} }
@ -357,10 +342,7 @@ void ewol::FontFreeType::display(void)
//EWOL_INFO(" Current size = " << (int)m_fftFace->size); //EWOL_INFO(" Current size = " << (int)m_fftFace->size);
} }
ewol::FontBase* ewol::FontFreeType::keep(const etk::UString& _filename) {
ewol::FontBase* ewol::FontFreeType::keep(const etk::UString& _filename)
{
EWOL_VERBOSE("KEEP : Font : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP : Font : file : \"" << _filename << "\"");
ewol::FontBase* object = static_cast<ewol::FontBase*>(getManager().localKeep(_filename)); ewol::FontBase* object = static_cast<ewol::FontBase*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
@ -376,8 +358,7 @@ ewol::FontBase* ewol::FontFreeType::keep(const etk::UString& _filename)
return object; return object;
} }
void ewol::FontFreeType::release(ewol::FontBase*& _object) void ewol::FontFreeType::release(ewol::FontBase*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
@ -385,3 +366,4 @@ void ewol::FontFreeType::release(ewol::FontBase*& _object)
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -17,11 +17,9 @@ extern "C" {
} }
#include FT_FREETYPE_H #include FT_FREETYPE_H
namespace ewol namespace ewol {
{
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html // show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
class FontFreeType : public ewol::FontBase class FontFreeType : public ewol::FontBase {
{
private: private:
FT_Byte* m_FileBuffer; FT_Byte* m_FileBuffer;
int32_t m_FileSize; int32_t m_FileSize;
@ -63,7 +61,6 @@ namespace ewol
}; };
void freeTypeInit(void); void freeTypeInit(void);
void freeTypeUnInit(void); void freeTypeUnInit(void);
}; };
#endif #endif

View File

@ -18,15 +18,13 @@
#define __class__ "TextureFile" #define __class__ "TextureFile"
ewol::TextureFile::TextureFile(const etk::UString& _genName) : ewol::TextureFile::TextureFile(const etk::UString& _genName) :
Texture(_genName) Texture(_genName) {
{
} }
ewol::TextureFile::TextureFile(etk::UString _genName, const etk::UString& _tmpfileName, const ivec2& _size) : ewol::TextureFile::TextureFile(etk::UString _genName, const etk::UString& _tmpfileName, const ivec2& _size) :
Texture(_genName) Texture(_genName) {
{
if (false == egami::load(m_data, _tmpfileName, _size)) { if (false == egami::load(m_data, _tmpfileName, _size)) {
EWOL_ERROR("ERROR when loading the image : " << _tmpfileName); EWOL_ERROR("ERROR when loading the image : " << _tmpfileName);
} }
@ -42,8 +40,7 @@ ewol::TextureFile::TextureFile(etk::UString _genName, const etk::UString& _tmpfi
* @param[in] _value Value that we want the next power of 2 * @param[in] _value Value that we want the next power of 2
* @return result value * @return result value
*/ */
static int32_t nextP2(int32_t _value) static int32_t nextP2(int32_t _value) {
{
int32_t val=1; int32_t val=1;
for (int32_t iii=1; iii<31; iii++) { for (int32_t iii=1; iii<31; iii++) {
if (_value <= val) { if (_value <= val) {
@ -58,8 +55,7 @@ static int32_t nextP2(int32_t _value)
ewol::TextureFile* ewol::TextureFile::keep(const etk::UString& _filename, ivec2 _size) ewol::TextureFile* ewol::TextureFile::keep(const etk::UString& _filename, ivec2 _size) {
{
EWOL_INFO("KEEP : TextureFile : file : " << _filename << " basic size=" << _size); EWOL_INFO("KEEP : TextureFile : file : " << _filename << " basic size=" << _size);
if (_filename == "") { if (_filename == "") {
ewol::TextureFile* object = new ewol::TextureFile(""); ewol::TextureFile* object = new ewol::TextureFile("");
@ -114,8 +110,7 @@ ewol::TextureFile* ewol::TextureFile::keep(const etk::UString& _filename, ivec2
} }
void ewol::TextureFile::release(ewol::TextureFile*& _object) void ewol::TextureFile::release(ewol::TextureFile*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }

View File

@ -15,10 +15,8 @@
#include <ewol/resources/Texture.h> #include <ewol/resources/Texture.h>
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol namespace ewol {
{ class TextureFile : public ewol::Texture {
class TextureFile : public ewol::Texture
{
private: private:
vec2 m_realImageSize; vec2 m_realImageSize;
private: private:

View File

@ -15,12 +15,11 @@
#define __class__ "Mesh" #define __class__ "Mesh"
ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName) : ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName) :
ewol::Resource(_fileName), ewol::Resource(_fileName),
m_normalMode(normalModeNone), m_normalMode(normalModeNone),
m_checkNormal(false), m_checkNormal(false),
m_pointerShape(NULL), m_pointerShape(NULL),
m_functionFreeShape(NULL) m_functionFreeShape(NULL) {
{
EWOL_DEBUG("Load a new mesh : '" << _fileName << "'"); EWOL_DEBUG("Load a new mesh : '" << _fileName << "'");
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
@ -65,8 +64,7 @@ ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName)
} }
} }
ewol::Mesh::~Mesh(void) ewol::Mesh::~Mesh(void) {
{
// remove dynamics dependencies : // remove dynamics dependencies :
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
ewol::VirtualBufferObject::release(m_verticesVBO); ewol::VirtualBufferObject::release(m_verticesVBO);
@ -78,8 +76,9 @@ ewol::Mesh::~Mesh(void)
//#define DISPLAY_NB_VERTEX_DISPLAYED //#define DISPLAY_NB_VERTEX_DISPLAYED
void ewol::Mesh::draw(mat4& _positionMatrix, bool _enableDepthTest, bool _enableDepthUpdate) void ewol::Mesh::draw(mat4& _positionMatrix,
{ bool _enableDepthTest,
bool _enableDepthUpdate) {
if (m_GLprogram == NULL) { if (m_GLprogram == NULL) {
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
@ -178,8 +177,7 @@ void ewol::Mesh::draw(mat4& _positionMatrix, bool _enableDepthTest, bool _enable
} }
// normal calculation of the normal face is really easy : // normal calculation of the normal face is really easy :
void ewol::Mesh::calculateNormaleFace(void) void ewol::Mesh::calculateNormaleFace(void) {
{
m_listFacesNormal.clear(); m_listFacesNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeFace) { if (m_normalMode != ewol::Mesh::normalModeFace) {
etk::Vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces; etk::Vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces;
@ -193,8 +191,7 @@ void ewol::Mesh::calculateNormaleFace(void)
} }
} }
void ewol::Mesh::calculateNormaleEdge(void) void ewol::Mesh::calculateNormaleEdge(void) {
{
m_listVertexNormal.clear(); m_listVertexNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeVertex) { if (m_normalMode != ewol::Mesh::normalModeVertex) {
for(int32_t iii=0 ; iii<m_listVertex.size() ; iii++) { for(int32_t iii=0 ; iii<m_listVertex.size() ; iii++) {
@ -223,8 +220,7 @@ void ewol::Mesh::calculateNormaleEdge(void)
//#define PRINT_HALF (1) //#define PRINT_HALF (1)
//#define TRY_MINIMAL_VBO //#define TRY_MINIMAL_VBO
void ewol::Mesh::generateVBO(void) void ewol::Mesh::generateVBO(void) {
{
// calculate the normal of all faces if needed // calculate the normal of all faces if needed
if (m_normalMode == ewol::Mesh::normalModeNone) { if (m_normalMode == ewol::Mesh::normalModeNone) {
// when no normal detected == > auto generate Face normal .... // when no normal detected == > auto generate Face normal ....
@ -287,8 +283,7 @@ void ewol::Mesh::generateVBO(void)
} }
void ewol::Mesh::createViewBox(const etk::UString& _materialName,float _size) void ewol::Mesh::createViewBox(const etk::UString& _materialName,float _size) {
{
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
// This is the direct generation basis on the .obj system // This is the direct generation basis on the .obj system
/* /*
@ -381,8 +376,7 @@ void ewol::Mesh::createViewBox(const etk::UString& _materialName,float _size)
} }
bool ewol::Mesh::loadOBJ(const etk::UString& _fileName) bool ewol::Mesh::loadOBJ(const etk::UString& _fileName) {
{
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
#if 0 #if 0
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
@ -505,8 +499,7 @@ bool ewol::Mesh::loadOBJ(const etk::UString& _fileName)
return true; return true;
} }
void jumpEndLine(etk::FSNode& _file) void jumpEndLine(etk::FSNode& _file) {
{
char current=_file.fileGet(); char current=_file.fileGet();
while( current != '\0' while( current != '\0'
&& current != '\n') { && current != '\n') {
@ -515,8 +508,7 @@ void jumpEndLine(etk::FSNode& _file)
} }
} }
int32_t countIndent(etk::FSNode& _file) int32_t countIndent(etk::FSNode& _file) {
{
int32_t nbIndent=0; int32_t nbIndent=0;
int32_t nbSpacesTab=0; int32_t nbSpacesTab=0;
int32_t nbChar=0; int32_t nbChar=0;
@ -547,8 +539,12 @@ int32_t countIndent(etk::FSNode& _file)
return nbIndent; return nbIndent;
} }
char* loadNextData(char* _elementLine, int64_t _maxData, etk::FSNode& _file, bool _removeTabs=false, bool _stopColomn=false, bool _stopPipe=true) char* loadNextData(char* _elementLine,
{ int64_t _maxData,
etk::FSNode& _file,
bool _removeTabs=false,
bool _stopColomn=false,
bool _stopPipe=true) {
memset(_elementLine, 0, _maxData); memset(_elementLine, 0, _maxData);
char * element = _elementLine; char * element = _elementLine;
int64_t outSize = 0; int64_t outSize = 0;
@ -596,8 +592,7 @@ char* loadNextData(char* _elementLine, int64_t _maxData, etk::FSNode& _file, boo
return NULL; return NULL;
} }
void removeEndLine(char* _val) void removeEndLine(char* _val) {
{
int32_t len = strlen(_val); int32_t len = strlen(_val);
if( len>0 if( len>0
&& ( _val[len-1] == '\n' && ( _val[len-1] == '\n'
@ -611,6 +606,7 @@ void removeEndLine(char* _val)
_val[len-1] = '\0'; _val[len-1] = '\0';
} }
} }
typedef enum { typedef enum {
EMFModuleNone, EMFModuleNone,
EMFModuleMesh, EMFModuleMesh,
@ -629,8 +625,7 @@ typedef enum {
EMFModuleMaterial_END, EMFModuleMaterial_END,
} emfModuleMode_te; } emfModuleMode_te;
bool ewol::Mesh::loadEMF(const etk::UString& _fileName) bool ewol::Mesh::loadEMF(const etk::UString& _fileName) {
{
m_checkNormal = true; m_checkNormal = true;
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
@ -997,10 +992,7 @@ bool ewol::Mesh::loadEMF(const etk::UString& _fileName)
return true; return true;
} }
void ewol::Mesh::addMaterial(const etk::UString& _name, ewol::Material* _data) {
void ewol::Mesh::addMaterial(const etk::UString& _name, ewol::Material* _data)
{
if (NULL == _data) { if (NULL == _data) {
EWOL_ERROR(" can not add material with null pointer"); EWOL_ERROR(" can not add material with null pointer");
return; return;
@ -1013,23 +1005,15 @@ void ewol::Mesh::addMaterial(const etk::UString& _name, ewol::Material* _data)
m_materials.add(_name, _data); m_materials.add(_name, _data);
} }
void ewol::Mesh::setShape(void* _shape) {
void ewol::Mesh::setShape(void* _shape)
{
if (m_functionFreeShape!=NULL) { if (m_functionFreeShape!=NULL) {
m_functionFreeShape(m_pointerShape); m_functionFreeShape(m_pointerShape);
m_pointerShape = NULL; m_pointerShape = NULL;
} }
m_pointerShape=_shape; m_pointerShape=_shape;
}; }
ewol::Mesh* ewol::Mesh::keep(const etk::UString& _meshName) {
ewol::Mesh* ewol::Mesh::keep(const etk::UString& _meshName)
{
ewol::Mesh* object = static_cast<ewol::Mesh*>(getManager().localKeep(_meshName)); ewol::Mesh* object = static_cast<ewol::Mesh*>(getManager().localKeep(_meshName));
if (NULL != object) { if (NULL != object) {
return object; return object;
@ -1043,8 +1027,7 @@ ewol::Mesh* ewol::Mesh::keep(const etk::UString& _meshName)
return object; return object;
} }
void ewol::Mesh::release(ewol::Mesh*& _object) void ewol::Mesh::release(ewol::Mesh*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }

View File

@ -30,10 +30,8 @@
// 4 "float" elements // 4 "float" elements
#define MESH_VBO_COLOR (4) #define MESH_VBO_COLOR (4)
namespace ewol namespace ewol {
{ class Face {
class Face
{
public: public:
int32_t m_vertex[3]; int32_t m_vertex[3];
int32_t m_uv[3]; int32_t m_uv[3];
@ -42,8 +40,7 @@ namespace ewol
Face(void) {}; Face(void) {};
Face(int32_t v1, int32_t t1, Face(int32_t v1, int32_t t1,
int32_t v2, int32_t t2, int32_t v2, int32_t t2,
int32_t v3, int32_t t3) int32_t v3, int32_t t3) {
{
m_vertex[0] = v1; m_vertex[0] = v1;
m_vertex[1] = v2; m_vertex[1] = v2;
m_vertex[2] = v3; m_vertex[2] = v3;
@ -56,8 +53,7 @@ namespace ewol
}; };
Face(int32_t v1, int32_t t1, int32_t n1, Face(int32_t v1, int32_t t1, int32_t n1,
int32_t v2, int32_t t2, int32_t n2, int32_t v2, int32_t t2, int32_t n2,
int32_t v3, int32_t t3, int32_t n3) int32_t v3, int32_t t3, int32_t n3) {
{
m_vertex[0] = v1; m_vertex[0] = v1;
m_vertex[1] = v2; m_vertex[1] = v2;
m_vertex[2] = v3; m_vertex[2] = v3;
@ -69,14 +65,12 @@ namespace ewol
m_normal[2] = n3; m_normal[2] = n3;
}; };
}; };
class FaceIndexing class FaceIndexing {
{
public: public:
etk::Vector<Face> m_faces; etk::Vector<Face> m_faces;
etk::Vector<uint32_t> m_index; etk::Vector<uint32_t> m_index;
}; };
class Mesh : public ewol::Resource class Mesh : public ewol::Resource {
{
public: public:
typedef enum { typedef enum {
normalModeNone, normalModeNone,

View File

@ -17,15 +17,14 @@
#define LOCAL_DEBUG EWOL_DEBUG #define LOCAL_DEBUG EWOL_DEBUG
#undef __class__ #undef __class__
#define __class__ "Program" #define __class__ "Program"
ewol::Program::Program(const etk::UString& filename) : ewol::Program::Program(const etk::UString& _filename) :
ewol::Resource(filename), ewol::Resource(_filename),
m_exist(false), m_exist(false),
m_program(0), m_program(0),
m_hasTexture(false), m_hasTexture(false),
m_hasTexture1(false) m_hasTexture1(false) {
{
m_resourceLevel = 1; m_resourceLevel = 1;
EWOL_DEBUG("OGL : load PROGRAM '" << m_name << "'"); EWOL_DEBUG("OGL : load PROGRAM '" << m_name << "'");
// load data from file "all the time ..." // load data from file "all the time ..."
@ -95,9 +94,7 @@ ewol::Program::Program(const etk::UString& filename) :
updateContext(); updateContext();
} }
ewol::Program::~Program(void) {
ewol::Program::~Program(void)
{
for (int32_t iii=0; iii<m_shaderList.size(); iii++) { for (int32_t iii=0; iii<m_shaderList.size(); iii++) {
ewol::Shader::release(m_shaderList[iii]); ewol::Shader::release(m_shaderList[iii]);
m_shaderList[iii] = 0; m_shaderList[iii] = 0;
@ -109,27 +106,24 @@ ewol::Program::~Program(void)
m_hasTexture1 = false; m_hasTexture1 = false;
} }
static void checkGlError(const char* op, int32_t localLine) static void checkGlError(const char* _op, int32_t _localLine) {
{
for (GLint error = glGetError(); error; error = glGetError()) { for (GLint error = glGetError(); error; error = glGetError()) {
EWOL_INFO("after " << op << "():" << localLine << " glError(" << error << ")"); EWOL_INFO("after " << _op << "():" << _localLine << " glError(" << error << ")");
} }
} }
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) #define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
int32_t ewol::Program::getAttribute(etk::UString _elementName) {
int32_t ewol::Program::getAttribute(etk::UString elementName)
{
// check if it exist previously : // check if it exist previously :
for(int32_t iii=0; iii<m_elementList.size(); iii++) { for(int32_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == elementName) { if (m_elementList[iii].m_name == _elementName) {
return iii; return iii;
} }
} }
progAttributeElement tmp; progAttributeElement tmp;
tmp.m_name = elementName; tmp.m_name = _elementName;
tmp.m_isAttribute = true; tmp.m_isAttribute = true;
tmp.m_elementId = glGetAttribLocation(m_program, tmp.m_name.c_str()); tmp.m_elementId = glGetAttribLocation(m_program, tmp.m_name.c_str());
tmp.m_isLinked = true; tmp.m_isLinked = true;
@ -142,18 +136,15 @@ int32_t ewol::Program::getAttribute(etk::UString elementName)
return m_elementList.size()-1; return m_elementList.size()-1;
} }
int32_t ewol::Program::getUniform(etk::UString _elementName) {
int32_t ewol::Program::getUniform(etk::UString elementName)
{
// check if it exist previously : // check if it exist previously :
for(int32_t iii=0; iii<m_elementList.size(); iii++) { for(int32_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == elementName) { if (m_elementList[iii].m_name == _elementName) {
return iii; return iii;
} }
} }
progAttributeElement tmp; progAttributeElement tmp;
tmp.m_name = elementName; tmp.m_name = _elementName;
tmp.m_isAttribute = false; tmp.m_isAttribute = false;
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str()); tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
tmp.m_isLinked = true; tmp.m_isLinked = true;
@ -166,9 +157,7 @@ int32_t ewol::Program::getUniform(etk::UString elementName)
return m_elementList.size()-1; return m_elementList.size()-1;
} }
void ewol::Program::updateContext(void) {
void ewol::Program::updateContext(void)
{
if (true == m_exist) { if (true == m_exist) {
// Do nothing == > too dangerous ... // Do nothing == > too dangerous ...
} else { } else {
@ -256,8 +245,7 @@ void ewol::Program::updateContext(void)
} }
} }
void ewol::Program::removeContext(void) void ewol::Program::removeContext(void) {
{
if (true == m_exist) { if (true == m_exist) {
glDeleteProgram(m_program); glDeleteProgram(m_program);
m_program = 0; m_program = 0;
@ -268,14 +256,12 @@ void ewol::Program::removeContext(void)
} }
} }
void ewol::Program::removeContextToLate(void) void ewol::Program::removeContextToLate(void) {
{
m_exist = false; m_exist = false;
m_program = 0; m_program = 0;
} }
void ewol::Program::reload(void) void ewol::Program::reload(void) {
{
/* TODO : ... /* TODO : ...
etk::file file(m_name, etk::FILE_TYPE_DATA); etk::file file(m_name, etk::FILE_TYPE_DATA);
if (false == file.Exist()) { if (false == file.Exist()) {
@ -316,389 +302,378 @@ void ewol::Program::reload(void)
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::sendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample) void ewol::Program::sendAttribute(int32_t _idElem,
{ int32_t _nbElement,
void* _pointer,
int32_t _jumpBetweenSample) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glVertexAttribPointer(m_elementList[idElem].m_elementId, // attribute ID of openGL glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
nbElement, // number of elements per vertex, here (r,g,b,a) _nbElement, // number of elements per vertex, here (r,g,b,a)
GL_FLOAT, // the type of each element GL_FLOAT, // the type of each element
GL_FALSE, // take our values as-is GL_FALSE, // take our values as-is
jumpBetweenSample, // no extra data between each position _jumpBetweenSample, // no extra data between each position
pointer); // Pointer on the buffer _pointer); // Pointer on the buffer
//checkGlError("glVertexAttribPointer", __LINE__); //checkGlError("glVertexAttribPointer", __LINE__);
glEnableVertexAttribArray(m_elementList[idElem].m_elementId); glEnableVertexAttribArray(m_elementList[_idElem].m_elementId);
//checkGlError("glEnableVertexAttribArray", __LINE__); //checkGlError("glEnableVertexAttribArray", __LINE__);
} }
void ewol::Program::sendAttributePointer(int32_t idElem, int32_t nbElement, ewol::VirtualBufferObject* vbo, int32_t index, int32_t jumpBetweenSample, int32_t offset) void ewol::Program::sendAttributePointer(int32_t _idElem,
{ int32_t _nbElement,
ewol::VirtualBufferObject* _vbo,
int32_t _index,
int32_t _jumpBetweenSample,
int32_t _offset) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glBindBuffer(GL_ARRAY_BUFFER, vbo->getGL_ID(index)); glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index));
glVertexAttribPointer(m_elementList[idElem].m_elementId, // attribute ID of openGL glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
nbElement, // number of elements per vertex, here (r,g,b,a) _nbElement, // number of elements per vertex, here (r,g,b,a)
GL_FLOAT, // the type of each element GL_FLOAT, // the type of each element
GL_FALSE, // take our values as-is GL_FALSE, // take our values as-is
jumpBetweenSample, // no extra data between each position _jumpBetweenSample, // no extra data between each position
(GLvoid *)offset); // Pointer on the buffer (GLvoid *)_offset); // Pointer on the buffer
//checkGlError("glVertexAttribPointer", __LINE__); //checkGlError("glVertexAttribPointer", __LINE__);
glEnableVertexAttribArray(m_elementList[idElem].m_elementId); glEnableVertexAttribArray(m_elementList[_idElem].m_elementId);
//checkGlError("glEnableVertexAttribArray", __LINE__); //checkGlError("glEnableVertexAttribArray", __LINE__);
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniformMatrix4fv(int32_t idElem, int32_t nbElement, mat4 _matrix, bool transpose) void ewol::Program::uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _matrix, bool _transpose) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
// note : Android des not supported the transposition of the matrix, then we will done it oursef: // note : Android des not supported the transposition of the matrix, then we will done it oursef:
if (true == transpose) { if (true == _transpose) {
_matrix.transpose(); _matrix.transpose();
} }
glUniformMatrix4fv(m_elementList[idElem].m_elementId, nbElement, GL_FALSE, _matrix.m_mat); glUniformMatrix4fv(m_elementList[_idElem].m_elementId, _nbElement, GL_FALSE, _matrix.m_mat);
//checkGlError("glUniformMatrix4fv", __LINE__); //checkGlError("glUniformMatrix4fv", __LINE__);
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1f(int32_t idElem, float value1) void ewol::Program::uniform1f(int32_t _idElem, float _value1) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform1f(m_elementList[idElem].m_elementId, value1); glUniform1f(m_elementList[_idElem].m_elementId, _value1);
//checkGlError("glUniform1f", __LINE__); //checkGlError("glUniform1f", __LINE__);
} }
void ewol::Program::uniform2f(int32_t idElem, float value1, float value2) void ewol::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform2f(m_elementList[idElem].m_elementId, value1, value2); glUniform2f(m_elementList[_idElem].m_elementId, _value1, _value2);
//checkGlError("glUniform2f", __LINE__); //checkGlError("glUniform2f", __LINE__);
} }
void ewol::Program::uniform3f(int32_t idElem, float value1, float value2, float value3) void ewol::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform3f(m_elementList[idElem].m_elementId, value1, value2, value3); glUniform3f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3);
//checkGlError("glUniform3f", __LINE__); //checkGlError("glUniform3f", __LINE__);
} }
void ewol::Program::uniform4f(int32_t idElem, float value1, float value2, float value3, float value4) void ewol::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform4f(m_elementList[idElem].m_elementId, value1, value2, value3, value4); glUniform4f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4);
//checkGlError("glUniform4f", __LINE__); //checkGlError("glUniform4f", __LINE__);
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1i(int32_t idElem, int32_t value1) void ewol::Program::uniform1i(int32_t _idElem, int32_t _value1) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform1i(m_elementList[idElem].m_elementId, value1); glUniform1i(m_elementList[_idElem].m_elementId, _value1);
//checkGlError("glUniform1i", __LINE__); //checkGlError("glUniform1i", __LINE__);
} }
void ewol::Program::uniform2i(int32_t idElem, int32_t value1, int32_t value2) void ewol::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform2i(m_elementList[idElem].m_elementId, value1, value2); glUniform2i(m_elementList[_idElem].m_elementId, _value1, _value2);
//checkGlError("glUniform2i", __LINE__); //checkGlError("glUniform2i", __LINE__);
} }
void ewol::Program::uniform3i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3) void ewol::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform3i(m_elementList[idElem].m_elementId, value1, value2, value3); glUniform3i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3);
//checkGlError("glUniform3i", __LINE__); //checkGlError("glUniform3i", __LINE__);
} }
void ewol::Program::uniform4i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3, int32_t value4) void ewol::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
glUniform4i(m_elementList[idElem].m_elementId, value1, value2, value3, value4); glUniform4i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4);
//checkGlError("glUniform4i", __LINE__); //checkGlError("glUniform4i", __LINE__);
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1fv(int32_t idElem, int32_t nbElement, const float *value) void ewol::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform1fv(m_elementList[idElem].m_elementId, nbElement, value); glUniform1fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform1fv", __LINE__); //checkGlError("glUniform1fv", __LINE__);
} }
void ewol::Program::uniform2fv(int32_t idElem, int32_t nbElement, const float *value) void ewol::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform2fv(m_elementList[idElem].m_elementId, nbElement, value); glUniform2fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform2fv", __LINE__); //checkGlError("glUniform2fv", __LINE__);
} }
void ewol::Program::uniform3fv(int32_t idElem, int32_t nbElement, const float *value) void ewol::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform3fv(m_elementList[idElem].m_elementId, nbElement, value); glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform3fv", __LINE__); //checkGlError("glUniform3fv", __LINE__);
} }
void ewol::Program::uniform4fv(int32_t idElem, int32_t nbElement, const float *value) void ewol::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform4fv(m_elementList[idElem].m_elementId, nbElement, value); glUniform4fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform4fv", __LINE__); //checkGlError("glUniform4fv", __LINE__);
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1iv(int32_t idElem, int32_t nbElement, const int32_t *value) void ewol::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform1iv(m_elementList[idElem].m_elementId, nbElement, value); glUniform1iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform1iv", __LINE__); //checkGlError("glUniform1iv", __LINE__);
} }
void ewol::Program::uniform2iv(int32_t idElem, int32_t nbElement, const int32_t *value) void ewol::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform2iv(m_elementList[idElem].m_elementId, nbElement, value); glUniform2iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform2iv", __LINE__); //checkGlError("glUniform2iv", __LINE__);
} }
void ewol::Program::uniform3iv(int32_t idElem, int32_t nbElement, const int32_t *value) void ewol::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform3iv(m_elementList[idElem].m_elementId, nbElement, value); glUniform3iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform3iv", __LINE__); //checkGlError("glUniform3iv", __LINE__);
} }
void ewol::Program::uniform4iv(int32_t idElem, int32_t nbElement, const int32_t *value) void ewol::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.size()-1) << "]"); EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
if (0 == nbElement) { if (0 == _nbElement) {
EWOL_ERROR("No element to send at open GL ..."); EWOL_ERROR("No element to send at open GL ...");
return; return;
} }
if (NULL == value) { if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ..."); EWOL_ERROR("NULL Input pointer to send at open GL ...");
return; return;
} }
glUniform4iv(m_elementList[idElem].m_elementId, nbElement, value); glUniform4iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform4iv", __LINE__); //checkGlError("glUniform4iv", __LINE__);
} }
@ -710,8 +685,7 @@ void ewol::Program::uniform4iv(int32_t idElem, int32_t nbElement, const int32_t
#endif #endif
void ewol::Program::use(void) void ewol::Program::use(void) {
{
#ifdef PROGRAM_DISPLAY_SPEED #ifdef PROGRAM_DISPLAY_SPEED
g_startTime = ewol::getTime(); g_startTime = ewol::getTime();
#endif #endif
@ -721,15 +695,14 @@ void ewol::Program::use(void)
} }
void ewol::Program::setTexture0(int32_t idElem, GLint textureOpenGlID) void ewol::Program::setTexture0(int32_t _idElem, GLint _textureOpenGlID) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
#if 0 #if 0
@ -739,23 +712,22 @@ void ewol::Program::setTexture0(int32_t idElem, GLint textureOpenGlID)
ewol::openGL::activeTexture(GL_TEXTURE0); ewol::openGL::activeTexture(GL_TEXTURE0);
//checkGlError("glActiveTexture", __LINE__); //checkGlError("glActiveTexture", __LINE__);
// set the textureID // set the textureID
glBindTexture(GL_TEXTURE_2D, textureOpenGlID); glBindTexture(GL_TEXTURE_2D, _textureOpenGlID);
//checkGlError("glBindTexture", __LINE__); //checkGlError("glBindTexture", __LINE__);
// set the texture on the uniform attribute // set the texture on the uniform attribute
glUniform1i(m_elementList[idElem].m_elementId, /*GL_TEXTURE*/0); glUniform1i(m_elementList[_idElem].m_elementId, /*GL_TEXTURE*/0);
//checkGlError("glUniform1i", __LINE__); //checkGlError("glUniform1i", __LINE__);
m_hasTexture = true; m_hasTexture = true;
} }
void ewol::Program::setTexture1(int32_t idElem, GLint textureOpenGlID) void ewol::Program::setTexture1(int32_t _idElem, GLint _textureOpenGlID) {
{
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
if (idElem<0 || idElem>m_elementList.size()) { if (_idElem<0 || _idElem>m_elementList.size()) {
return; return;
} }
if (false == m_elementList[idElem].m_isLinked) { if (false == m_elementList[_idElem].m_isLinked) {
return; return;
} }
#if 0 #if 0
@ -765,17 +737,16 @@ void ewol::Program::setTexture1(int32_t idElem, GLint textureOpenGlID)
ewol::openGL::activeTexture(GL_TEXTURE1); ewol::openGL::activeTexture(GL_TEXTURE1);
//checkGlError("glActiveTexture", __LINE__); //checkGlError("glActiveTexture", __LINE__);
// set the textureID // set the textureID
glBindTexture(GL_TEXTURE_2D, textureOpenGlID); glBindTexture(GL_TEXTURE_2D, _textureOpenGlID);
//checkGlError("glBindTexture", __LINE__); //checkGlError("glBindTexture", __LINE__);
// set the texture on the uniform attribute // set the texture on the uniform attribute
glUniform1i(m_elementList[idElem].m_elementId, /*GL_TEXTURE*/1); glUniform1i(m_elementList[_idElem].m_elementId, /*GL_TEXTURE*/1);
//checkGlError("glUniform1i", __LINE__); //checkGlError("glUniform1i", __LINE__);
m_hasTexture1 = true; m_hasTexture1 = true;
} }
void ewol::Program::unUse(void) void ewol::Program::unUse(void) {
{
//EWOL_WARNING("Will use program : " << m_program); //EWOL_WARNING("Will use program : " << m_program);
if (0 == m_program) { if (0 == m_program) {
return; return;
@ -802,8 +773,7 @@ void ewol::Program::unUse(void)
ewol::Program* ewol::Program::keep(const etk::UString& _filename) ewol::Program* ewol::Program::keep(const etk::UString& _filename) {
{
EWOL_VERBOSE("KEEP : Program : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP : Program : file : \"" << _filename << "\"");
ewol::Program* object = static_cast<ewol::Program*>(getManager().localKeep(_filename)); ewol::Program* object = static_cast<ewol::Program*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
@ -820,8 +790,7 @@ ewol::Program* ewol::Program::keep(const etk::UString& _filename)
} }
void ewol::Program::release(ewol::Program*& _object) void ewol::Program::release(ewol::Program*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }

View File

@ -17,20 +17,18 @@
#include <ewol/resources/Shader.h> #include <ewol/resources/Shader.h>
#include <ewol/resources/VirtualBufferObject.h> #include <ewol/resources/VirtualBufferObject.h>
namespace ewol namespace ewol {
{
/** /**
* @brief In a openGL program we need some data to communicate with them, we register all the name requested by the user in this structure: * @brief In a openGL program we need some data to communicate with them, we register all the name requested by the user in this structure:
* @note Register all requested element permit to abstract the fact that some element does not exist and remove control of existance from upper code. * @note Register all requested element permit to abstract the fact that some element does not exist and remove control of existance from upper code.
* This is important to note when the Program is reloaded the elements availlable can change. * This is important to note when the Program is reloaded the elements availlable can change.
*/ */
class progAttributeElement class progAttributeElement {
{
public : public :
etk::UString m_name; //!< Name of the element etk::UString m_name; //!< Name of the element
GLint m_elementId; //!< openGl Id if this element == > can not exist ==> @ref m_isLinked GLint m_elementId; //!< openGl Id if this element == > can not exist ==> @ref m_isLinked
bool m_isAttribute; //!< true if it was an attribute element, otherwite it was an uniform bool m_isAttribute; //!< true if it was an attribute element, otherwite it was an uniform
bool m_isLinked; //!< if this element does not exist this is false bool m_isLinked; //!< if this element does not exist this is false
}; };
/** /**
* @brief Program is a compilation of some fragment Shader and vertex Shader. This construct automaticly this assiciation * @brief Program is a compilation of some fragment Shader and vertex Shader. This construct automaticly this assiciation
@ -45,15 +43,14 @@ namespace ewol
* filename4.frag * filename4.frag
* </pre> * </pre>
*/ */
class Program : public ewol::Resource class Program : public ewol::Resource {
{
private : private :
bool m_exist; //!< the file existed bool m_exist; //!< the file existed
GLuint m_program; //!< openGL id of the current program GLuint m_program; //!< openGL id of the current program
etk::Vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded etk::Vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded
etk::Vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user etk::Vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
bool m_hasTexture; //!< A texture has been set to the current shader bool m_hasTexture; //!< A texture has been set to the current shader
bool m_hasTexture1; //!< A texture has been set to the current shader bool m_hasTexture1; //!< A texture has been set to the current shader
protected: protected:
/** /**
* @brief Contructor of an opengl Program. * @brief Contructor of an opengl Program.
@ -73,168 +70,168 @@ namespace ewol
/** /**
* @brief User request an attribute on this program. * @brief User request an attribute on this program.
* @note The attribute is send to the fragment shaders * @note The attribute is send to the fragment shaders
* @param[in] elementName Name of the requested attribute. * @param[in] _elementName Name of the requested attribute.
* @return An abstract ID of the current attribute (this value is all time availlable, even if the program will be reloaded) * @return An abstract ID of the current attribute (this value is all time availlable, even if the program will be reloaded)
*/ */
int32_t getAttribute(etk::UString elementName); int32_t getAttribute(etk::UString _elementName);
/** /**
* @brief Send attribute table to the spefified ID attribure (not send if does not really exist in the openGL program). * @brief Send attribute table to the spefified ID attribure (not send if does not really exist in the openGL program).
* @param[in] idElem Id of the Attribute that might be sended. * @param[in] _idElem Id of the Attribute that might be sended.
* @param[in] nbElement Specifies the number of elements that are to be modified. * @param[in] _nbElement Specifies the number of elements that are to be modified.
* @param[in] pointer Pointer on the data that might be sended. * @param[in] _pointer Pointer on the data that might be sended.
* @param[in] jumpBetweenSample Number of byte to jump between 2 vertex (this permit to enterlace informations) * @param[in] _jumpBetweenSample Number of byte to jump between 2 vertex (this permit to enterlace informations)
*/ */
void sendAttribute(int32_t idElem, void sendAttribute(int32_t _idElem,
int32_t nbElement, int32_t _nbElement,
void* pointer, void* _pointer,
int32_t jumpBetweenSample=0); int32_t _jumpBetweenSample=0);
void sendAttributePointer(int32_t idElem, void sendAttributePointer(int32_t _idElem,
int32_t nbElement, int32_t _nbElement,
ewol::VirtualBufferObject* vbo, ewol::VirtualBufferObject* _vbo,
int32_t index, int32_t _index,
int32_t jumpBetweenSample=0, int32_t _jumpBetweenSample=0,
int32_t offset=0); int32_t _offset=0);
/** /**
* @brief User request an Uniform on this program. * @brief User request an Uniform on this program.
* @note uniform value is availlable for all the fragment shader in the program (only one value for all) * @note uniform value is availlable for all the fragment shader in the program (only one value for all)
* @param[in] elementName Name of the requested uniform. * @param[in] _elementName Name of the requested uniform.
* @return An abstract ID of the current uniform (this value is all time availlable, even if the program will be reloaded) * @return An abstract ID of the current uniform (this value is all time availlable, even if the program will be reloaded)
*/ */
int32_t getUniform(etk::UString elementName); int32_t getUniform(etk::UString _elementName);
/** /**
* @brief Send a uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send a uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. * @param[in] _nbElement Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array.
* @param[in] pointer Pointer on the data that might be sended * @param[in] _pointer Pointer on the data that might be sended
* @param[in] transpose Transpose the matrix (needed all the taime in the normal openGl access (only not done in the openGL-ES2 due to the fact we must done it ourself) * @param[in] _transpose Transpose the matrix (needed all the taime in the normal openGl access (only not done in the openGL-ES2 due to the fact we must done it ourself)
*/ */
void uniformMatrix4fv(int32_t idElem, int32_t nbElement, mat4 pointer, bool transpose=true); void uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _pointer, bool _transpose=true);
/** /**
* @brief Send 1 float uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 1 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
*/ */
void uniform1f(int32_t idElem, float value1); void uniform1f(int32_t _idElem, float _value1);
/** /**
* @brief Send 2 float uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 2 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] value2 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
*/ */
void uniform2f(int32_t idElem, float value1, float value2); void uniform2f(int32_t _idElem, float _value1, float _value2);
/** /**
* @brief Send 3 float uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 3 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] value2 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
* @param[in] value3 Value to send at the Uniform * @param[in] _value3 Value to send at the Uniform
*/ */
void uniform3f(int32_t idElem, float value1, float value2, float value3); void uniform3f(int32_t _idElem, float _value1, float _value2, float _value3);
/** /**
* @brief Send 4 float uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 4 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] value2 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
* @param[in] value3 Value to send at the Uniform * @param[in] _value3 Value to send at the Uniform
* @param[in] value4 Value to send at the Uniform * @param[in] _value4 Value to send at the Uniform
*/ */
void uniform4f(int32_t idElem, float value1, float value2, float value3, float value4); void uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4);
/** /**
* @brief Send 1 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 1 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
*/ */
void uniform1i(int32_t idElem, int32_t value1); void uniform1i(int32_t _idElem, int32_t _value1);
/** /**
* @brief Send 2 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 2 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] value2 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
*/ */
void uniform2i(int32_t idElem, int32_t value1, int32_t value2); void uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2);
/** /**
* @brief Send 3 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 3 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] value2 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
* @param[in] value3 Value to send at the Uniform * @param[in] _value3 Value to send at the Uniform
*/ */
void uniform3i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3); void uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3);
/** /**
* @brief Send 4 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send 4 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] value1 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] value2 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
* @param[in] value3 Value to send at the Uniform * @param[in] _value3 Value to send at the Uniform
* @param[in] value4 Value to send at the Uniform * @param[in] _value4 Value to send at the Uniform
*/ */
void uniform4i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3, int32_t value4); void uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4);
/** /**
* @brief Send "vec1" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "vec1" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform1fv(int32_t idElem, int32_t nbElement, const float *value); void uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value);
/** /**
* @brief Send "vec2" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "vec2" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform2fv(int32_t idElem, int32_t nbElement, const float *value); void uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value);
/** /**
* @brief Send "vec3" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "vec3" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform3fv(int32_t idElem, int32_t nbElement, const float *value); void uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value);
/** /**
* @brief Send "vec4" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "vec4" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform4fv(int32_t idElem, int32_t nbElement, const float *value); void uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value);
/** /**
* @brief Send "ivec1" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "ivec1" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform1iv(int32_t idElem, int32_t nbElement, const int32_t *value); void uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
/** /**
* @brief Send "ivec2" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "ivec2" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the Attribute that might be sended. * @param[in] _idElem Id of the Attribute that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform2iv(int32_t idElem, int32_t nbElement, const int32_t *value); void uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
/** /**
* @brief Send "ivec3" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "ivec3" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform3iv(int32_t idElem, int32_t nbElement, const int32_t *value); void uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
/** /**
* @brief Send "ivec4" uniform element to the spefified ID (not send if does not really exist in the openGL program) * @brief Send "ivec4" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] nbElement Number of element sended * @param[in] _nbElement Number of element sended
* @param[in] value Pointer on the data * @param[in] _value Pointer on the data
*/ */
void uniform4iv(int32_t idElem, int32_t nbElement, const int32_t *value); void uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
inline void uniform2(int32_t idElem, const vec2& value) { uniform2fv(idElem, 1, &value.m_floats[0]); }; inline void uniform2(int32_t _idElem, const vec2& _value) { uniform2fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform3(int32_t idElem, const vec3& value) { uniform3fv(idElem, 1, &value.m_floats[0]); }; inline void uniform3(int32_t _idElem, const vec3& _value) { uniform3fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform4(int32_t idElem, const vec4& value) { uniform4fv(idElem, 1, &value.m_floats[0]); }; inline void uniform4(int32_t _idElem, const vec4& _value) { uniform4fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform2(int32_t idElem, const ivec2& value){ uniform2iv(idElem, 1, &value.m_floats[0]); }; inline void uniform2(int32_t _idElem, const ivec2& _value) { uniform2iv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform3(int32_t idElem, const ivec3& value){ uniform3iv(idElem, 1, &value.m_floats[0]); }; inline void uniform3(int32_t _idElem, const ivec3& _value) { uniform3iv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform4(int32_t idElem, const ivec4& value){ uniform4iv(idElem, 1, &value.m_floats[0]); }; inline void uniform4(int32_t _idElem, const ivec4& _value) { uniform4iv(_idElem, 1, &_value.m_floats[0]); };
/** /**
* @brief Request the processing of this program * @brief Request the processing of this program
@ -242,11 +239,11 @@ namespace ewol
void use(void); void use(void);
/** /**
* @brief set the testure Id on the specify uniform element. * @brief set the testure Id on the specify uniform element.
* @param[in] idElem Id of the uniform that might be sended. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] textureOpenGlID Real openGL texture ID * @param[in] _textureOpenGlID Real openGL texture ID
*/ */
void setTexture0(int32_t idElem, GLint textureOpenGlID); void setTexture0(int32_t _idElem, GLint _textureOpenGlID);
void setTexture1(int32_t idElem, GLint textureOpenGlID); void setTexture1(int32_t _idElem, GLint _textureOpenGlID);
/** /**
* @brief Stop the processing of this program * @brief Stop the processing of this program
*/ */

View File

@ -19,27 +19,22 @@
uint32_t ewol::Resource::m_valBase=0; uint32_t ewol::Resource::m_valBase=0;
void ewol::Resource::updateContext(void) void ewol::Resource::updateContext(void) {
{
EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)");
} }
void ewol::Resource::removeContext(void) void ewol::Resource::removeContext(void) {
{
EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)");
} }
void ewol::Resource::removeContextToLate(void) void ewol::Resource::removeContextToLate(void) {
{
EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)");
} }
void ewol::Resource::reload(void) void ewol::Resource::reload(void) {
{
EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << m_uniqueId << "]" << m_name << " loaded " << m_counter << " time(s)");
} }
ewol::ResourceManager& ewol::Resource::getManager(void) ewol::ResourceManager& ewol::Resource::getManager(void) {
{
return ewol::getContext().getResourcesManager(); return ewol::getContext().getResourcesManager();
} }

View File

@ -16,8 +16,7 @@
#define MAX_RESOURCE_LEVEL (5) #define MAX_RESOURCE_LEVEL (5)
namespace ewol namespace ewol {
{
class ResourceManager; class ResourceManager;
// class resources is pure virtual // class resources is pure virtual
class Resource { class Resource {
@ -35,24 +34,21 @@ namespace ewol
uint8_t m_resourceLevel; uint8_t m_resourceLevel;
public: public:
Resource(void) : Resource(void) :
m_name(""), m_name(""),
m_counter(1), m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
{
m_uniqueId = m_valBase; m_uniqueId = m_valBase;
m_valBase++; m_valBase++;
}; };
Resource(const etk::UString& _filename) : Resource(const etk::UString& _filename) :
m_name(_filename), m_name(_filename),
m_counter(1), m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
{
m_uniqueId = m_valBase; m_uniqueId = m_valBase;
m_valBase++; m_valBase++;
}; };
virtual ~Resource(void) { }; virtual ~Resource(void) { };
virtual bool hasName(const etk::UString& _fileName) virtual bool hasName(const etk::UString& _fileName) {
{
EWOL_VERBOSE("G : check : " << _fileName << " ?= " << m_name << " = " << (_fileName == m_name) ); EWOL_VERBOSE("G : check : " << _fileName << " ?= " << m_name << " = " << (_fileName == m_name) );
return _fileName == m_name; return _fileName == m_name;
}; };

View File

@ -17,13 +17,11 @@
ewol::ResourceManager::ResourceManager(void) : ewol::ResourceManager::ResourceManager(void) :
m_contextHasBeenRemoved(true) m_contextHasBeenRemoved(true) {
{
// nothing to do ... // nothing to do ...
} }
ewol::ResourceManager::~ResourceManager(void) ewol::ResourceManager::~ResourceManager(void) {
{
bool hasError = false; bool hasError = false;
if (m_resourceListToUpdate.size()!=0) { if (m_resourceListToUpdate.size()!=0) {
EWOL_ERROR("Must not have anymore resources to update !!!"); EWOL_ERROR("Must not have anymore resources to update !!!");
@ -37,8 +35,8 @@ ewol::ResourceManager::~ResourceManager(void)
EWOL_ERROR("Check if the function UnInit has been called !!!"); EWOL_ERROR("Check if the function UnInit has been called !!!");
} }
} }
void ewol::ResourceManager::unInit(void)
{ void ewol::ResourceManager::unInit(void) {
display(); display();
m_resourceListToUpdate.clear(); m_resourceListToUpdate.clear();
// remove all resources ... // remove all resources ...
@ -54,9 +52,7 @@ void ewol::ResourceManager::unInit(void)
m_resourceList.clear(); m_resourceList.clear();
} }
void ewol::ResourceManager::display(void) {
void ewol::ResourceManager::display(void)
{
EWOL_INFO("Resources loaded : "); EWOL_INFO("Resources loaded : ");
// remove all resources ... // remove all resources ...
for (int32_t iii=m_resourceList.size()-1; iii >= 0; iii--) { for (int32_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
@ -70,8 +66,7 @@ void ewol::ResourceManager::display(void)
EWOL_INFO("Resources ---"); EWOL_INFO("Resources ---");
} }
void ewol::ResourceManager::reLoadResources(void) void ewol::ResourceManager::reLoadResources(void) {
{
EWOL_INFO("------------- Resources re-loaded -------------"); EWOL_INFO("------------- Resources re-loaded -------------");
// remove all resources ... // remove all resources ...
if (m_resourceList.size() != 0) { if (m_resourceList.size() != 0) {
@ -92,8 +87,7 @@ void ewol::ResourceManager::reLoadResources(void)
EWOL_INFO("------------- Resources -------------"); EWOL_INFO("------------- Resources -------------");
} }
void ewol::ResourceManager::update(ewol::Resource* _object) void ewol::ResourceManager::update(ewol::Resource* _object) {
{
// chek if not added before // chek if not added before
for (int32_t iii=0; iii<m_resourceListToUpdate.size(); iii++) { for (int32_t iii=0; iii<m_resourceListToUpdate.size(); iii++) {
if (m_resourceListToUpdate[iii] != NULL) { if (m_resourceListToUpdate[iii] != NULL) {
@ -108,8 +102,7 @@ void ewol::ResourceManager::update(ewol::Resource* _object)
} }
// Specific to load or update the data in the openGl context == > system use only // Specific to load or update the data in the openGl context == > system use only
void ewol::ResourceManager::updateContext(void) void ewol::ResourceManager::updateContext(void) {
{
if (true == m_contextHasBeenRemoved) { if (true == m_contextHasBeenRemoved) {
// need to update all ... // need to update all ...
m_contextHasBeenRemoved = false; m_contextHasBeenRemoved = false;
@ -145,8 +138,7 @@ void ewol::ResourceManager::updateContext(void)
} }
// in this case, it is really too late ... // in this case, it is really too late ...
void ewol::ResourceManager::contextHasBeenDestroyed(void) void ewol::ResourceManager::contextHasBeenDestroyed(void) {
{
for (int32_t iii=0; iii<m_resourceList.size(); iii++) { for (int32_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) { if (m_resourceList[iii] != NULL) {
m_resourceList[iii]->removeContextToLate(); m_resourceList[iii]->removeContextToLate();
@ -156,13 +148,8 @@ void ewol::ResourceManager::contextHasBeenDestroyed(void)
m_contextHasBeenRemoved = true; m_contextHasBeenRemoved = true;
} }
// internal generic keeper ... // internal generic keeper ...
ewol::Resource* ewol::ResourceManager::localKeep(const etk::UString& _filename) ewol::Resource* ewol::ResourceManager::localKeep(const etk::UString& _filename) {
{
EWOL_VERBOSE("KEEP (DEFAULT) : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP (DEFAULT) : file : \"" << _filename << "\"");
for (int32_t iii=0; iii<m_resourceList.size(); iii++) { for (int32_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) { if (m_resourceList[iii] != NULL) {
@ -177,8 +164,7 @@ ewol::Resource* ewol::ResourceManager::localKeep(const etk::UString& _filename)
} }
// internal generic keeper ... // internal generic keeper ...
void ewol::ResourceManager::localAdd(ewol::Resource* _object) void ewol::ResourceManager::localAdd(ewol::Resource* _object) {
{
//Add ... find empty slot //Add ... find empty slot
for (int32_t iii=0; iii<m_resourceList.size(); iii++) { for (int32_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] == NULL) { if (m_resourceList[iii] == NULL) {
@ -190,8 +176,7 @@ void ewol::ResourceManager::localAdd(ewol::Resource* _object)
m_resourceList.pushBack(_object); m_resourceList.pushBack(_object);
} }
void ewol::ResourceManager::release(ewol::Resource*& _object) void ewol::ResourceManager::release(ewol::Resource*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
EWOL_ERROR("Try to remove a resource that have null pointer ..."); EWOL_ERROR("Try to remove a resource that have null pointer ...");
return; return;

View File

@ -22,10 +22,8 @@
#include <ewol/resources/Mesh.h> #include <ewol/resources/Mesh.h>
#include <ewol/resources/Colored3DObject.h> #include <ewol/resources/Colored3DObject.h>
namespace ewol namespace ewol {
{ class ResourceManager {
class ResourceManager
{
private: private:
etk::Vector<ewol::Resource*> m_resourceList; etk::Vector<ewol::Resource*> m_resourceList;
etk::Vector<ewol::Resource*> m_resourceListToUpdate; etk::Vector<ewol::Resource*> m_resourceListToUpdate;

View File

@ -13,15 +13,14 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#undef __class__ #undef __class__
#define __class__ "Shader" #define __class__ "Shader"
ewol::Shader::Shader(const etk::UString& _filename): ewol::Shader::Shader(const etk::UString& _filename) :
ewol::Resource(_filename), ewol::Resource(_filename),
m_exist(false), m_exist(false),
m_fileData(NULL), m_fileData(NULL),
m_shader(0), m_shader(0),
m_type(0) m_type(0) {
{
m_resourceLevel = 0; m_resourceLevel = 0;
EWOL_DEBUG("OGL : load SHADER \"" << _filename << "\""); EWOL_DEBUG("OGL : load SHADER \"" << _filename << "\"");
// load data from file "all the time ..." // load data from file "all the time ..."
@ -37,9 +36,7 @@ ewol::Shader::Shader(const etk::UString& _filename):
reload(); reload();
} }
ewol::Shader::~Shader(void) {
ewol::Shader::~Shader(void)
{
if (NULL != m_fileData) { if (NULL != m_fileData) {
delete [] m_fileData; delete [] m_fileData;
m_fileData = NULL; m_fileData = NULL;
@ -51,18 +48,15 @@ ewol::Shader::~Shader(void)
m_exist = false; m_exist = false;
} }
static void checkGlError(const char* _op) {
static void checkGlError(const char* op)
{
for (GLint error = glGetError(); error; error = glGetError()) { for (GLint error = glGetError(); error; error = glGetError()) {
EWOL_INFO("after " << op << "() glError (" << error << ")"); EWOL_INFO("after " << _op << "() glError (" << error << ")");
} }
} }
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) #define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
void ewol::Shader::updateContext(void) void ewol::Shader::updateContext(void) {
{
if (true == m_exist) { if (true == m_exist) {
// Do nothing == > too dangerous ... // Do nothing == > too dangerous ...
} else { } else {
@ -103,8 +97,7 @@ void ewol::Shader::updateContext(void)
} }
} }
void ewol::Shader::removeContext(void) void ewol::Shader::removeContext(void) {
{
if (true == m_exist) { if (true == m_exist) {
glDeleteShader(m_shader); glDeleteShader(m_shader);
m_exist = false; m_exist = false;
@ -112,14 +105,12 @@ void ewol::Shader::removeContext(void)
} }
} }
void ewol::Shader::removeContextToLate(void) void ewol::Shader::removeContextToLate(void) {
{
m_exist = false; m_exist = false;
m_shader = 0; m_shader = 0;
} }
void ewol::Shader::reload(void) void ewol::Shader::reload(void) {
{
etk::FSNode file(m_name); etk::FSNode file(m_name);
if (false == file.exist()) { if (false == file.exist()) {
EWOL_ERROR("File does not Exist : \"" << file << "\""); EWOL_ERROR("File does not Exist : \"" << file << "\"");
@ -157,10 +148,7 @@ void ewol::Shader::reload(void)
updateContext(); updateContext();
} }
ewol::Shader* ewol::Shader::keep(const etk::UString& _filename) {
ewol::Shader* ewol::Shader::keep(const etk::UString& _filename)
{
EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << _filename << "\"");
ewol::Shader* object = static_cast<ewol::Shader*>(getManager().localKeep(_filename)); ewol::Shader* object = static_cast<ewol::Shader*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
@ -176,8 +164,7 @@ ewol::Shader* ewol::Shader::keep(const etk::UString& _filename)
return object; return object;
} }
void ewol::Shader::release(ewol::Shader*& _object) void ewol::Shader::release(ewol::Shader*& _object) {
{
if (NULL == _object) { if (NULL == _object) {
return; return;
} }

View File

@ -14,18 +14,16 @@
#include <ewol/renderer/openGL.h> #include <ewol/renderer/openGL.h>
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol namespace ewol {
{
/** /**
* @brief Shader is a specific resources for opengl, used only in @ref Program. This are components of the renderer pipe-line * @brief Shader is a specific resources for opengl, used only in @ref Program. This are components of the renderer pipe-line
*/ */
class Shader : public ewol::Resource class Shader : public ewol::Resource {
{
private : private :
bool m_exist; //!< The shader file existed and has been loaded bool m_exist; //!< The shader file existed and has been loaded
char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed) char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed)
GLuint m_shader; //!< opengl id of this element GLuint m_shader; //!< opengl id of this element
GLenum m_type; //!< Type of the current shader(vertex/fragment) GLenum m_type; //!< Type of the current shader(vertex/fragment)
protected: protected:
/** /**
* @brief Contructor of an opengl Shader * @brief Contructor of an opengl Shader

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