diff --git a/.travis.yml b/.travis.yml index 7f17f36d..892b6287 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,47 +1,76 @@ -# language type: language: -- cpp -- Objective-c + - cpp -# compilator system: -compiler: -- clang -- gcc +sudo: false + +os: + - linux + - osx -# build branch requested branches: only: - master - dev -# previous actions: -before_script: - - git clone git://github.com/HeeroYui/lutin.git - - git submodule init - - git submodule update - - cd external/z - - git submodule init - - git submodule update - - cd ../.. - - if [ "$CXX" == "clang++" ]; then BUILDER=clang; else BUILDER=gcc; fi +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + +env: + - CONF=debug BUILDER=clang + - CONF=debug BUILDER=gcc + +matrix: + include: + - os: linux + env: CONF=debug BUILDER=gcc GCOV=--gcov + - os: linux + env: CONF=release BUILDER=clang + - os: linux + env: CONF=release BUILDER=gcc + exclude: + - os: mingw + env: CONF=debug BUILDER=clang install: - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo apt-get update -qq - - sudo apt-get install -qq libstdc++-4.9-dev - - sudo apt-get install -qq g++-4.9 - - sudo rm /usr/bin/gcc /usr/bin/g++ - - sudo ln -s /usr/bin/gcc-4.9 /usr/bin/gcc - - sudo ln -s /usr/bin/g++-4.9 /usr/bin/g++ + - pip install --user lutin + +before_script: + - cd .. + - wget http://atria-soft.com/ci/coverage_send.py + - wget http://atria-soft.com/ci/test_send.py + - wget http://atria-soft.com/ci/warning_send.py + - mkdir bin + - curl https://storage.googleapis.com/git-repo-downloads/repo > bin/repo + - chmod a+x bin/repo + - git config --global user.email "travis@travis.com" + - git config --global user.name "Travis" + - git config --global color.ui "auto" + - git config --global core.editor "vi" + - mkdir WORKING_DIRECTORY + - cd WORKING_DIRECTORY + - ../bin/repo init -u https://github.com/atria-soft/manifest.git + - ../bin/repo sync -j8 + - rm -rf atria-soft/ewol + - cd .. + - pwd + - ls -l + - if [ "$BUILDER" == "gcc" ]; then + COMPILATOR_OPTION="--compilator-version=4.9"; + else + COMPILATOR_OPTION=""; + fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then + export PATH=$PATH:/Users/travis/Library/Python/2.7/bin/; + fi + +script: + - lutin -w -j4 -C -P -c $BUILDER $COMPILATOR_OPTION -m $CONF $GCOV -p ewol-test 0XX_customwidget 001_HelloWord -# build sequence with Lutin : -script: - - ./lutin/lutin.py -C -P -c$BUILDER -mdebug -p ewol etk_test exml_test ejson_test enettest - - ./out/Linux_x86_64/debug/staging/$BUILDER/etk_test/usr/bin/etk_test - - ./out/Linux_x86_64/debug/staging/$BUILDER/ejson_test/usr/bin/ejson_test - - ./out/Linux_x86_64/debug/staging/$BUILDER/exml_test/usr/bin/exml_test -#send e-mail on compilation result: notifications: email: - yui.heero@gmail.com diff --git a/README.md b/README.md index d9866651..7f578eb2 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,24 @@ -[![Build Status](https://secure.travis-ci.org/HeeroYui/ewol.svg?branch=master)](https://travis-ci.org/HeeroYui/ewol) - Ewol ==== `Ewol` (Edn Widget OpenGl Layer) is a FREE software. +Release (master) +---------------- + +[![Build Status](https://travis-ci.org/atria-soft/ewol.svg?branch=master)](https://travis-ci.org/atria-soft/ewol) +[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/ewol.svg?branch=master)](http://atria-soft.com/ci/atria-soft/ewol) +[![Test Status](http://atria-soft.com/ci/test/atria-soft/ewol.svg?branch=master)](http://atria-soft.com/ci/atria-soft/ewol) +[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/ewol.svg?branch=master)](http://atria-soft.com/ci/atria-soft/ewol) + +Developement (dev) +------------------ + +[![Build Status](https://travis-ci.org/atria-soft/ewol.svg?branch=dev)](https://travis-ci.org/atria-soft/ewol) +[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/ewol.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/ewol) +[![Test Status](http://atria-soft.com/ci/test/atria-soft/ewol.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/ewol) +[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/ewol.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/ewol) + Instructions ============ @@ -24,7 +38,8 @@ download the software: mkdir WORKING_DIRECTORY cd WORKING_DIRECTORY - git clone git://github.com/HeeroYui/lutin.git + sudo pip install lutin + sudo pip install pillow repo init -u git://github.com/HeeroYui/manifest.git repo sync -j8 @@ -38,19 +53,35 @@ Compile software and install: Dependency packages =================== +Ubuntu Or Debian: + sudo apt-get install g++ libgl1-mesa-dev zlib1g-dev libasound2-dev - # if you want to compile with clang : + # Compile with Clang: sudo apt-get install clang - # For andoid compilation (jdk 7 does not work...) + # For andoid compilation (jdk 7 does not work...): sudo apt-get install javacc openjdk-6-jdk - # if you want to compile for windows : + # Cross compile for windows: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-mingw-w64 - # on 64 bits processor for compatibility + # On 64 bits processor for compatibility: sudo apt-get install ia32-libs sudo apt-get install g++-multilib libc6-dev-i386 +Arch-linux: + + # Cross compile for windows: + pacman -S mingw-w64-gcc + + # Cross compile for Android: + in /etc/pacman.conf file uncomment: + [multilib] + Include = /etc/pacman.d/mirrorlist + # update the system: + Pacman -Syu + # install lib C: + pacman -S lib32-glibc + License (APACHE v2.0) ===================== diff --git a/android/src/org/ewol/Ewol.java b/android/src/org/ewol/Ewol.java deleted file mode 100644 index fce9b416..00000000 --- a/android/src/org/ewol/Ewol.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; - -import android.app.Activity; -import android.service.wallpaper.WallpaperService; -import android.service.wallpaper.WallpaperService.Engine; -import android.util.Log; - -public class Ewol { - private int instanceID = -1; // local and private instance ID - private boolean m_hardKeyboardHidden = true; - - public Ewol(T activityInstance, int typeApplication) { - instanceID = -1; - m_hardKeyboardHidden = true; - instanceID = EWsetJavaVirtualMachineStart(activityInstance, typeApplication); - Log.d("Ewol", "new : " + instanceID); - } - - public void setJavaVirtualMachineStop() { - EWsetJavaVirtualMachineStop(instanceID); - } - public void paramSetArchiveDir(int mode, String myString) { - EWparamSetArchiveDir(instanceID, mode, myString); - } - - public boolean getHardKeyboardHidden() { - return m_hardKeyboardHidden; - } - public void setHardKeyboardHidden(boolean val) { - m_hardKeyboardHidden = val; - } - - // activity status - public void onCreate() { EWonCreate(instanceID); } - public void onStart() { EWonStart(instanceID); } - public void onReStart() { EWonReStart(instanceID); } - public void onResume() { EWonResume(instanceID); } - public void onPause() { EWonPause(instanceID); } - public void onStop() { EWonStop(instanceID); } - public void onDestroy() { EWonDestroy(instanceID); } - // set display properties : - public void displayPropertyMetrics(float ratioX, float ratioY) { - EWdisplayPropertyMetrics(instanceID, ratioX, ratioY); - } - // IO native function : - // 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) { - EWinputEventMotion(instanceID, pointerID, x, y); - } - public void inputEventState(int pointerID, boolean isDown, float x, float y) { - EWinputEventState(instanceID, pointerID, isDown, x, y); - } - // Specific for the type of input : TOOL_TYPE_MOUSE - public void mouseEventMotion(int pointerID, float x, float y) { - EWmouseEventMotion(instanceID, pointerID, x, y); - } - public void mouseEventState(int pointerID, boolean isDown, float x, float y) { - EWmouseEventState(instanceID, pointerID, isDown, x, y); - } - // other unknow event ... - public void unknowEvent(int eventID) { - EWunknowEvent(instanceID, eventID); - } - - public void keyboardEventMove(int type, boolean isDown) { - EWkeyboardEventMove(instanceID, type, isDown); - } - public void keyboardEventKey(int uniChar, boolean isDown) { - EWkeyboardEventKey(instanceID, uniChar, isDown); - } - - // Audio section ... - public void audioPlayback(short[] bufferData, int frames, int nbChannels) { - EWaudioPlayback(instanceID, bufferData, frames, nbChannels); - } - - public boolean keyboardEventKeySystem(int keyVal, boolean isDown) { - return EWkeyboardEventKeySystem(instanceID, keyVal, isDown); - } - // renderer Event : - public void renderInit() { - EWrenderInit(instanceID); - } - public void renderResize(int w, int h) { - EWrenderResize(instanceID, w, h); - } - public void renderDraw() { - EWrenderDraw(instanceID); - } - - - private native int EWsetJavaVirtualMachineStart(T activityInstance, int typeApplication); - private native void EWsetJavaVirtualMachineStop(int instanceId); - private native void EWparamSetArchiveDir(int instanceId, int mode, String myString); - - // activity status - private native void EWonCreate(int instanceId); - private native void EWonStart(int instanceId); - private native void EWonReStart(int instanceId); - private native void EWonResume(int instanceId); - private native void EWonPause(int instanceId); - private native void EWonStop(int instanceId); - private native void EWonDestroy(int instanceId); - // set display properties : - private native void EWdisplayPropertyMetrics(int instanceId, float ratioX, float ratioY); - // IO native function : - // Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same) - private native void EWinputEventMotion(int instanceId, int pointerID, float x, float y); - private native void EWinputEventState(int instanceId, int pointerID, boolean isDown, float x, float y); - // Specific for the type of input : TOOL_TYPE_MOUSE - private native void EWmouseEventMotion(int instanceId, int pointerID, float x, float y); - private native void EWmouseEventState(int instanceId, int pointerID, boolean isDown, float x, float y); - // other unknow event ... - private native void EWunknowEvent(int instanceId, int eventID); - - private native void EWkeyboardEventMove(int instanceId, int type, boolean isDown); - private native void EWkeyboardEventKey(int instanceId, int uniChar, boolean isDown); - - // Audio section ... - public native void EWaudioPlayback(int instanceId, short[] bufferData, int frames, int nbChannels); - - private native boolean EWkeyboardEventKeySystem(int instanceId, int keyVal, boolean isDown); - // renderer Event : - private native void EWrenderInit(int instanceId); - private native void EWrenderResize(int instanceId, int w, int h); - private native void EWrenderDraw(int instanceId); -} - diff --git a/android/src/org/ewol/EwolActivity.java b/android/src/org/ewol/EwolActivity.java deleted file mode 100644 index 93651208..00000000 --- a/android/src/org/ewol/EwolActivity.java +++ /dev/null @@ -1,389 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -package org.ewol; - -import android.app.Activity; -import android.content.Context; -import android.Manifest; -import android.opengl.GLSurfaceView; -import android.os.Bundle; -import android.view.MotionEvent; -import android.view.KeyEvent; -// For No Title : -import android.view.Window; - -// For the full screen : -import android.view.WindowManager; -// for the keyboard event : -import android.view.inputmethod.InputMethodManager; -import android.Manifest; - -import java.io.File; -import android.content.Context; -import android.content.res.Configuration; - -// For the getting apk name : -import android.content.pm.ActivityInfo; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetFileDescriptor; -import android.content.res.AssetManager; -import android.util.DisplayMetrics; -import android.util.Log; -// copy past events : -import android.content.ClipboardManager; -import android.content.ClipData; - -import android.net.Uri; -import android.content.Intent; -import android.content.ActivityNotFoundException; - -import java.io.IOException; -//import activityRootView - -import org.ewol.Ewol; - -/** - * @brief Class : - * - */ -public abstract class EwolActivity extends Activity implements EwolCallback, EwolConstants { - private static Context mContext; - protected EwolSurfaceViewGL mGLView = null; - private Ewol EWOL; - // clipboard section - private String tmpClipBoard; // TODO : Remove this ==> clipboard acces does not work - // Audio section : - private EwolAudioTask mStreams; - private Thread mAudioThread; - private boolean mAudioStarted; - - static { - try { - System.loadLibrary("ewol"); - } catch (UnsatisfiedLinkError e) { - Log.e("EwolActivity", "error getting lib(): " + e); - } - } - - public static Context getAppContext() { - return EwolActivity.mContext; - } - - public EwolActivity() { - // set the java evironement in the C sources : - EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY); - tmpClipBoard = ""; - } - - protected void initApkPath(String org, String vendor, String project) { - StringBuilder sb = new StringBuilder(); - sb.append(org).append("."); - sb.append(vendor).append("."); - sb.append(project); - String apkFilePath = null; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(sb.toString(), 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - EWOL.paramSetArchiveDir(0, apkFilePath); - } - - @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - //setListnerToRootView(); - mAudioStarted = false; - mAudioThread = null; - EwolActivity.mContext = getApplicationContext(); - - // Load the application directory - EWOL.paramSetArchiveDir(1, getFilesDir().toString()); - EWOL.paramSetArchiveDir(2, getCacheDir().toString()); - // to enable extarnal storage: add in the manifest the restriction needed ... - //packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED; - //Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString()); - - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi); - - // call C init ... - EWOL.onCreate(); - - // Remove the title of the current display : - requestWindowFeature(Window.FEATURE_NO_TITLE); - // set full screen Mode : - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - // display keyboard: - //getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); - // hide keyboard : - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); - - // create bsurface system - mGLView = new EwolSurfaceViewGL(this, EWOL); - - // create element audio ... - mStreams = new EwolAudioTask(EWOL); - - setContentView(mGLView); - } - - @Override protected void onStart() { - super.onStart(); - EWOL.onStart(); - } - - @Override protected void onRestart() { - super.onRestart(); - EWOL.onReStart(); - } - - @Override protected void onResume() { - super.onResume(); - mGLView.onResume(); - if (mAudioStarted == true) { - Log.e("EwolActivity", "Start audio interface"); - if (mAudioThread == null) { - Log.e("EwolActivity", "create thread with stream"); - mAudioThread = new Thread(mStreams); - if (mAudioThread != null) { - Log.e("EwolActivity", "start audio"); - mAudioThread.start(); - } - } - } - EWOL.onResume(); - } - - @Override protected void onPause() { - super.onPause(); - mGLView.onPause(); - if (mAudioStarted == true) { - Log.e("EwolActivity", "Pause audio interface"); - if (mAudioThread != null) { - // request audio stop - mStreams.AutoStop(); - // wait the thread ended ... - try { - mAudioThread.join(); - } catch(InterruptedException e) { } - mAudioThread = null; - } - } - EWOL.onPause(); - } - - @Override protected void onStop() { - super.onStop(); - // call C - EWOL.onStop(); - } - @Override protected void onDestroy() { - super.onDestroy(); - // call C - EWOL.onDestroy(); - // Remove the java Virtual machine pointer form the C code - EWOL.setJavaVirtualMachineStop(); - } - - @Override protected void finalize() throws Throwable { - super.finalize(); - // cleanup your object here - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - Log.e("EwolActivity", "Receive event ... "); - super.onConfigurationChanged(newConfig); - // Checks whether a hardware keyboard is available - if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { - EWOL.setHardKeyboardHidden(false); - Log.e("EwolActivity", "HARD Keyboard active = " + !EWOL.getHardKeyboardHidden() + " (visible)"); - } else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) { - EWOL.setHardKeyboardHidden(true); - Log.e("EwolActivity", "HARD Keyboard active = " + !EWOL.getHardKeyboardHidden() + " (hidden)"); - } - } - - public void keyboardUpdate(boolean show) { - Log.i("EwolActivity", "set keyboard status visibility :" + show); - final InputMethodManager imm; - try { - imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - } catch(Exception e) { - Log.e("EwolActivity", "Can not get keyboard manager ..."); - return; - } - Log.i("EwolActivity", "Get input manager done"); - if(show == true) { - try { - imm.showSoftInput(mGLView, InputMethodManager.SHOW_IMPLICIT); - } catch(Exception e) { - Log.e("EwolActivity", "Can not set keyboard state ... (exeption !!!!)"); - } - Log.i("EwolActivity", "Display it Done"); - } else { - // this is a little sutid this ==> display keyboard to be sure that it toggle in the hide state ... - try { - imm.showSoftInput(mGLView, InputMethodManager.SHOW_IMPLICIT); - } catch(Exception e) { - Log.e("EwolActivity", "Can not set keyboard state ... (exeption !!!!)"); - } - Log.i("EwolActivity", "Display it Done"); - try { - imm.toggleSoftInput(0 ,InputMethodManager.HIDE_IMPLICIT_ONLY + InputMethodManager.HIDE_NOT_ALWAYS); - } catch(Exception e) { - Log.e("EwolActivity", "Can not set keyboard state ... (exeption !!!!)"); - } - Log.i("EwolActivity", "Toggle it Done"); - } - } - - public void eventNotifier(String[] args) { - // TODO : ... - } - - public void orientationUpdate(int screenMode) { - Context localContext = getAppContext(); - int result = localContext.checkCallingOrSelfPermission(Manifest.permission.SET_ORIENTATION); - if (result != PackageManager.PERMISSION_GRANTED) { - if (screenMode == EWOL_ORIENTATION_LANDSCAPE) { - //Force landscape - //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); - } else if (screenMode == EWOL_ORIENTATION_PORTRAIT) { - //Force portrait - //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); - } else { - //Force auto Rotation - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); - } - } else { - Log.e("EwolActivity", "Not the right 'SET_ORIENTATION' to access on the screen orientation..."); - } - } - - public void titleSet(String value) { - setTitle(value); - } - - public void openURI(String uri) { - try { - Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); - startActivity(myIntent); - } catch (ActivityNotFoundException e) { - Log.e("EwolActivity", "Can not request an URL"); - } - } - - public void stop() { - // end application is requested ... - finish(); - } - - //http://developer.android.com/guide/topics/text/copy-paste.html - public String getClipBoardString() { - return tmpClipBoard; - // TODO : Rework this it does not work - /* - // Gets a handle to the clipboard service. - ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); - // If the clipboard doesn't contain data, disable the paste menu item. - // If it does contain data, decide if you can handle the data. - if (!(clipboard.hasPrimaryClip())) { - return ""; - } - // Examines the item on the clipboard. If getText() does not return null, the clip item contains the - // text. Assumes that this application can only handle one item at a time. - ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); - if (item == null) { - return ""; - } - // Gets the clipboard as text. - String pasteData = item.getText().toString();; - // If the string contains data, then the paste operation is done - if (pasteData != null) { - return pasteData; - } - return ""; - */ - } - - public void setClipBoardString(String data) { - tmpClipBoard = data; - return; - // TODO : Rework this it does not work - /* - // Gets a handle to the clipboard service. - ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); - // Creates a new text clip to put on the clipboard - ClipData clip = ClipData.newPlainText("simple text", data); - // Set the clipboard's primary clip. - clipboard.setPrimaryClip(clip); - */ - } - - public int audioGetDeviceCount() { - //Log.e("EwolActivity", "Get device List"); - return 1; - } - - public String audioGetDeviceProperty(int idDevice) { - if (idDevice == 0) { - return "speaker:out:8000,16000,24000,32000,48000,96000:2:int16"; - } else { - return "::::"; - } - } - - public boolean audioOpenDevice(int idDevice, int freq, int nbChannel, int format) { - if (idDevice == 0) { - mAudioStarted = true; - mAudioThread = new Thread(mStreams); - if (mAudioThread != null) { - mAudioThread.start(); - return true; - } - return false; - } else { - Log.e("EwolActivity", "can not open : error unknow device ..."); - return false; - } - } - - public boolean audioCloseDevice(int idDevice) { - if (idDevice == 0) { - if (mAudioThread != null) { - // request audio stop - mStreams.AutoStop(); - // wait the thread ended ... - try { - mAudioThread.join(); - } catch(InterruptedException e) { } - mAudioThread = null; - } - mAudioStarted = false; - return true; - } else { - Log.e("EwolActivity", "can not close : error unknow device ..."); - return false; - } - } -} - - - diff --git a/android/src/org/ewol/EwolAudioTask.java b/android/src/org/ewol/EwolAudioTask.java deleted file mode 100644 index f42d78dc..00000000 --- a/android/src/org/ewol/EwolAudioTask.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; - -import android.media.AudioTrack; -import android.media.AudioFormat; -import android.media.AudioManager; -import android.media.AudioRecord; -import android.util.Log; - -// import the ewol package : -/* no need in same package... */ -//import org.ewol.NativeInterface; - -import org.ewol.Ewol; - - -public class EwolAudioTask implements Runnable, EwolConstants -{ - public static final int SAMPLE_FREQ_44100 = 44100; - private boolean m_stopAudioThreads = false; - private AudioTrack m_musicTrack = null; - private Ewol EWOL; - - // constructor : - public EwolAudioTask(Ewol ewolInstance) { - EWOL = ewolInstance; - m_stopAudioThreads = false; - } - - public void run() { - Log.e("audioEWOL", "RUN (start)"); - if(m_musicTrack != null) { - Log.e("audioEWOL", " ==> rejected"); - return; - } - - int sampleFreq = SAMPLE_FREQ_44100; //AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC); - int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_STEREO; - int audioFormat = AudioFormat.ENCODING_PCM_16BIT; - int nbChannels = 2; - // we keep the minimum buffer size, otherwite the delay is too big ... - int bufferSize = AudioTrack.getMinBufferSize(sampleFreq, channelConfig, audioFormat); - // Create a streaming AudioTrack for music playback - short[] streamBuffer = new short[bufferSize]; - m_musicTrack = new AudioTrack(AudioManager.STREAM_MUSIC, - SAMPLE_FREQ_44100, - AudioFormat.CHANNEL_CONFIGURATION_STEREO, - AudioFormat.ENCODING_PCM_16BIT, - bufferSize, - AudioTrack.MODE_STREAM); - m_musicTrack.play(); - m_stopAudioThreads = false; - //m_musicTrack.setPositionNotificationPeriod(2048); - - while (!m_stopAudioThreads) { - // Fill buffer with PCM data from C++ - EWOL.audioPlayback(streamBuffer, NATIVE_AUDIO_BUFFER_SIZE, nbChannels); - int xxx = NATIVE_AUDIO_BUFFER_SIZE; - /* - while (xxx>0) { - Log.e("audioEWOL", (NATIVE_AUDIO_BUFFER_SIZE-xxx) + " data : " + streamBuffer[NATIVE_AUDIO_BUFFER_SIZE-xxx]); - xxx--; - } - */ - // Stream PCM data into the music AudioTrack - m_musicTrack.write(streamBuffer, 0, NATIVE_AUDIO_BUFFER_SIZE); - } - - m_musicTrack.flush(); - m_musicTrack.stop(); - m_musicTrack = null; - streamBuffer = null; - Log.e("audioEWOL", "RUN (stop)"); - } - public void Pause() { - if(m_musicTrack == null) { - return; - } - m_musicTrack.pause(); - } - public void Resume() { - if(m_musicTrack == null) { - return; - } - m_musicTrack.play(); - } - public void AutoStop() { - if(m_musicTrack == null) { - return; - } - m_stopAudioThreads=true; - } -} diff --git a/android/src/org/ewol/EwolCallback.java b/android/src/org/ewol/EwolCallback.java deleted file mode 100644 index b3eab01b..00000000 --- a/android/src/org/ewol/EwolCallback.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; -import android.util.Log; - -public interface EwolCallback { - public void openURI(String uri); - public void keyboardUpdate(boolean show); - public void eventNotifier(String[] args); - public void orientationUpdate(int screenMode); - public void titleSet(String value); - public void stop(); - public int audioGetDeviceCount(); - public String audioGetDeviceProperty(int idDevice); - public boolean audioOpenDevice(int idDevice, int freq, int nbChannel, int format); - public boolean audioCloseDevice(int idDevice); -} diff --git a/android/src/org/ewol/EwolConstants.java b/android/src/org/ewol/EwolConstants.java deleted file mode 100644 index cdbb61de..00000000 --- a/android/src/org/ewol/EwolConstants.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; - -public interface EwolConstants { - public static final int NATIVE_AUDIO_BUFFER_SIZE = 512; - public static final int EWOL_SYSTEM_KEY_VOLUME_UP = 1; - public static final int EWOL_SYSTEM_KEY_VOLUME_DOWN = 2; - public static final int EWOL_SYSTEM_KEY_MENU = 3; - public static final int EWOL_SYSTEM_KEY_CAMERA = 4; - public static final int EWOL_SYSTEM_KEY_HOME = 5; - public static final int EWOL_SYSTEM_KEY_POWER = 6; - // the back key is wrapped in the key to simplify PC validation ... - public static final int EWOL_SYSTEM_KEY_BACK = 0x1B; - public static final int EWOL_SYSTEM_KEY_DEL = 0x08; - - public static final int EWOL_ORIENTATION_AUTO = 0; - public static final int EWOL_ORIENTATION_LANDSCAPE = 1; - public static final int EWOL_ORIENTATION_PORTRAIT = 2; - - - public static final int EWOL_APPL_TYPE_ACTIVITY = 0; - public static final int EWOL_APPL_TYPE_WALLPAPER = 1; - - // Key binding of the element ewol::key::keyboard : - public static final int EWOL_MOVE_KEY_LEFT = 2; - public static final int EWOL_MOVE_KEY_RIGHT = 3; - public static final int EWOL_MOVE_KEY_UP = 4; - public static final int EWOL_MOVE_KEY_DOWN = 5; - public static final int EWOL_MOVE_KEY_PAGE_UP = 6; - public static final int EWOL_MOVE_KEY_PAGE_DOWN = 7; - public static final int EWOL_MOVE_KEY_START = 8; - public static final int EWOL_MOVE_KEY_END = 9; - public static final int EWOL_MOVE_KEY_PRINT = 10; - public static final int EWOL_MOVE_KEY_STOP_DEFIL = 11; - public static final int EWOL_MOVE_KEY_WAIT = 12; - public static final int EWOL_MOVE_KEY_INSERT = 13; - public static final int EWOL_MOVE_KEY_F1 = 14; - public static final int EWOL_MOVE_KEY_F2 = 15; - public static final int EWOL_MOVE_KEY_F3 = 16; - public static final int EWOL_MOVE_KEY_F4 = 17; - public static final int EWOL_MOVE_KEY_F5 = 18; - public static final int EWOL_MOVE_KEY_F6 = 19; - public static final int EWOL_MOVE_KEY_F7 = 20; - public static final int EWOL_MOVE_KEY_F8 = 21; - public static final int EWOL_MOVE_KEY_F9 = 22; - public static final int EWOL_MOVE_KEY_F10 = 23; - public static final int EWOL_MOVE_KEY_F11 = 24; - public static final int EWOL_MOVE_KEY_F12 = 25; - public static final int EWOL_MOVE_KEY_CAP_LOCK = 26; - public static final int EWOL_MOVE_KEY_SHIFT_LEFT = 27; - public static final int EWOL_MOVE_KEY_SHIFT_RIGHT = 28; - public static final int EWOL_MOVE_KEY_CTRL_LEFT = 29; - public static final int EWOL_MOVE_KEY_CTRL_RIGHT = 30; - public static final int EWOL_MOVE_KEY_META_LEFT = 31; - public static final int EWOL_MOVE_KEY_META_RIGHT = 32; - public static final int EWOL_MOVE_KEY_ALT = 33; - public static final int EWOL_MOVE_KEY_ALT_GR = 34; - public static final int EWOL_MOVE_KEY_CONTEXT_MENU = 35; - public static final int EWOL_MOVE_KEY_NUM_LOCK = 36; - -} diff --git a/android/src/org/ewol/EwolRendererGL.java b/android/src/org/ewol/EwolRendererGL.java deleted file mode 100644 index 24eae14a..00000000 --- a/android/src/org/ewol/EwolRendererGL.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; -import android.opengl.GLES20; -import android.opengl.GLSurfaceView; - -// import the ewol package : -/* no need in same package... */ -//import org.ewol.Ewol; - -import org.ewol.Ewol; - -/** - * @brief Class : - * - */ -public class EwolRendererGL implements GLSurfaceView.Renderer -{ - private Ewol EWOL; - - public EwolRendererGL(Ewol ewolInstance) { - EWOL = ewolInstance; - } - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - EWOL.renderInit(); - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - EWOL.renderResize(w, h); - } - - public void onDrawFrame(GL10 gl) { - EWOL.renderDraw(); - } -} diff --git a/android/src/org/ewol/EwolSurfaceViewGL.java b/android/src/org/ewol/EwolSurfaceViewGL.java deleted file mode 100644 index 4a22e4b6..00000000 --- a/android/src/org/ewol/EwolSurfaceViewGL.java +++ /dev/null @@ -1,304 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Bundle; -import android.view.MotionEvent; -import android.view.KeyEvent; -import android.util.Log; - -import org.ewol.Ewol; - -/** - * @brief Class : - * - */ -public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants { - public static final int SDK_VERSION = android.os.Build.VERSION.SDK_INT; - private EwolRendererGL m_ewolDrawer = null; - private boolean inputDown1 = false; - private boolean inputDown2 = false; - private boolean inputDown3 = false; - private Ewol EWOL; - - public EwolSurfaceViewGL(Context context, Ewol ewolInstance) { - // super must be first statement in constructor - super(context); - EWOL = ewolInstance; - /* - List of the Android API : - Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights - Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights - Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH - Android 3.2 13 HONEYCOMB_MR2 - Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights - Android 3.0.x 11 HONEYCOMB Platform Highlights - Android 2.3.4 - Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights - Android 2.3.2 - Android 2.3.1 - Android 2.3 9 GINGERBREAD - Android 2.2.x 8 FROYO Platform Highlights - Android 2.1.x 7 ECLAIR_MR1 Platform Highlights - Android 2.0.1 6 ECLAIR_0_1 - Android 2.0 5 ECLAIR - Android 1.6 4 DONUT Platform Highlights - Android 1.5 3 CUPCAKE Platform Highlights - Android 1.1 2 BASE_1_1 - Android 1.0 1 BASE - */ - // Create an OpenGL ES 2.0 context - setEGLContextClientVersion(2); - - // je n'ai pas compris ... - m_ewolDrawer = new EwolRendererGL(EWOL); - setRenderer(m_ewolDrawer); - - // Can get the focus ==> get keyboard from JAVA : - setFocusable(true); - setFocusableInTouchMode(true); - } - - public boolean onTouchEvent(final MotionEvent event) { - // Wrapper on input events : - - int tmpActionType = event.getAction(); - - if (tmpActionType == MotionEvent.ACTION_MOVE) { - final int pointerCount = event.getPointerCount(); - for (int p = 0; p < pointerCount; p++) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(p); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); - } - } else { - EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p)); - } - } - } else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN - || tmpActionType == MotionEvent.ACTION_DOWN) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0)); - } - inputDown1 = true; - } else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown1 = false; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(1); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); - } - } else { - EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1)); - } - inputDown2 = true; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(1); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); - } - } else { - EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1)); - } - inputDown2 = false; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(2); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); - } - } else { - EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2)); - } - inputDown3 = true; - } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(2); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); - } - } else { - EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2)); - } - inputDown3 = false; - } else if(tmpActionType == MotionEvent.ACTION_UP){ - if (inputDown1) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown1 = false; - } else if (inputDown2) { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown2 = false; - } else { - if (SDK_VERSION>=14) { - final int typeOfPointer = event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { - EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - } else { - EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); - } - inputDown3 = false; - } - } - return true; - } - - private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown) { - int actionDone = event.getAction(); - Log.i("Surface GL", "get event : " + keyCode + " is down : " + isDown); - switch(keyCode) { - case KeyEvent.KEYCODE_VOLUME_DOWN: - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_DOWN, isDown); - case KeyEvent.KEYCODE_VOLUME_UP: - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_UP, isDown); - case KeyEvent.KEYCODE_MENU: - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_MENU, isDown); - case KeyEvent.KEYCODE_CAMERA: - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_CAMERA, isDown); - case KeyEvent.KEYCODE_HOME: - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_HOME, isDown); - case KeyEvent.KEYCODE_POWER: - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_POWER, isDown); - case KeyEvent.KEYCODE_BACK: - // the back key is wrapped in the key to simplify PC validation ... - return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_BACK, isDown); - /* - EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_BACK, isDown); - return false; - */ - case KeyEvent.KEYCODE_DEL: - EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_DEL, isDown); - return true; - // Joystick event : - case KeyEvent.KEYCODE_DPAD_UP: EWOL.keyboardEventMove(EWOL_MOVE_KEY_UP, isDown); return true; - case KeyEvent.KEYCODE_DPAD_DOWN: EWOL.keyboardEventMove(EWOL_MOVE_KEY_DOWN, isDown); return true; - case KeyEvent.KEYCODE_DPAD_LEFT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_LEFT, isDown); return true; - case KeyEvent.KEYCODE_DPAD_RIGHT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_RIGHT, isDown); return true; - case KeyEvent.KEYCODE_PAGE_UP: EWOL.keyboardEventMove(EWOL_MOVE_KEY_PAGE_UP, isDown); return true; - case KeyEvent.KEYCODE_PAGE_DOWN: EWOL.keyboardEventMove(EWOL_MOVE_KEY_PAGE_DOWN, isDown); return true; - case KeyEvent.KEYCODE_MOVE_HOME: EWOL.keyboardEventMove(EWOL_MOVE_KEY_START, isDown); return true; - case KeyEvent.KEYCODE_MOVE_END: EWOL.keyboardEventMove(EWOL_MOVE_KEY_END, isDown); return true; - case KeyEvent.KEYCODE_SYSRQ: EWOL.keyboardEventMove(EWOL_MOVE_KEY_PRINT, isDown); return true; - //case KeyEvent.: EWOL.keyboardEventMove(EWOL_MOVE_KEY_STOP_DEFIL, isDown); return true; - case KeyEvent.KEYCODE_BREAK: EWOL.keyboardEventMove(EWOL_MOVE_KEY_WAIT, isDown); return true; - case KeyEvent.KEYCODE_INSERT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_INSERT, isDown); return true; - case KeyEvent.KEYCODE_F1: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F1, isDown); return true; - case KeyEvent.KEYCODE_F2: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F2, isDown); return true; - case KeyEvent.KEYCODE_F3: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F3, isDown); return true; - case KeyEvent.KEYCODE_F4: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F4, isDown); return true; - case KeyEvent.KEYCODE_F5: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F5, isDown); return true; - case KeyEvent.KEYCODE_F6: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F6, isDown); return true; - case KeyEvent.KEYCODE_F7: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F7, isDown); return true; - case KeyEvent.KEYCODE_F8: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F8, isDown); return true; - case KeyEvent.KEYCODE_F9: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F9, isDown); return true; - case KeyEvent.KEYCODE_F10: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F10, isDown); return true; - case KeyEvent.KEYCODE_F11: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F11, isDown); return true; - case KeyEvent.KEYCODE_F12: EWOL.keyboardEventMove(EWOL_MOVE_KEY_F12, isDown); return true; - case KeyEvent.KEYCODE_CAPS_LOCK: EWOL.keyboardEventMove(EWOL_MOVE_KEY_CAP_LOCK, isDown); return true; - case KeyEvent.KEYCODE_SHIFT_LEFT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_SHIFT_LEFT, isDown); return true; - case KeyEvent.KEYCODE_SHIFT_RIGHT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_SHIFT_RIGHT, isDown); return true; - case KeyEvent.KEYCODE_CTRL_LEFT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_CTRL_LEFT, isDown); return true; - case KeyEvent.KEYCODE_CTRL_RIGHT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_CTRL_RIGHT, isDown); return true; - case KeyEvent.KEYCODE_META_LEFT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_META_LEFT, isDown); return true; - case KeyEvent.KEYCODE_META_RIGHT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_META_RIGHT, isDown); return true; - case KeyEvent.KEYCODE_ALT_LEFT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_ALT, isDown); return true; - case KeyEvent.KEYCODE_ALT_RIGHT: EWOL.keyboardEventMove(EWOL_MOVE_KEY_ALT_GR, isDown); return true; - //case KeyEvent.KEYCODE_MENU: EWOL.keyboardEventMove(EWOL_MOVE_KEY_CONTEXT_MENU, isDown); return true; - case KeyEvent.KEYCODE_NUM_LOCK: EWOL.keyboardEventMove(EWOL_MOVE_KEY_NUM_LOCK, isDown); return true; - default: - break; - } - // key wrapping : - if( (actionDone == KeyEvent.ACTION_DOWN) - || (actionDone == KeyEvent.ACTION_MULTIPLE) - || (actionDone == KeyEvent.ACTION_UP)) - { - // convert the key in UniChar to prevent errors ... - int uchar = event.getUnicodeChar(); - // pb on the return methode ... in java it is like windows ... - if (uchar == '\r') { - uchar = '\n'; - } - // send it to ewol ... - EWOL.keyboardEventKey(uchar, isDown); - return true; - } - return false; - } - - public boolean onKeyDown(int keyCode, KeyEvent event) { - return keyboardEvent(keyCode, event, true); - } - - public boolean onKeyUp(int keyCode, KeyEvent event) { - return keyboardEvent(keyCode, event, false); - } -} diff --git a/android/src/org/ewol/EwolWallpaper.java b/android/src/org/ewol/EwolWallpaper.java deleted file mode 100644 index 33cdbf32..00000000 --- a/android/src/org/ewol/EwolWallpaper.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -package org.ewol; - -import android.app.ActivityManager; -import android.content.pm.ApplicationInfo; -import android.content.pm.ConfigurationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.opengl.GLSurfaceView.Renderer; -import android.os.Build; -import android.service.wallpaper.WallpaperService; -import android.util.Log; -import android.view.SurfaceHolder; -import org.ewol.EwolSurfaceViewGL; -import android.view.MotionEvent; - -import android.net.Uri; -import android.content.Intent; -import android.content.ActivityNotFoundException; - -import org.ewol.Ewol; - -public abstract class EwolWallpaper extends WallpaperService implements EwolCallback, EwolConstants -{ - private GLEngine mGLView; - private Ewol EWOL; - static { - System.loadLibrary("ewol"); - } - - protected void initApkPath(String org, String vendor, String project) { - StringBuilder sb = new StringBuilder(); - sb.append(org).append("."); - sb.append(vendor).append("."); - sb.append(project); - String apkFilePath = null; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(sb.toString(), 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - EWOL.paramSetArchiveDir(0, apkFilePath); - } - - @Override public Engine onCreateEngine() { - // set the java evironement in the C sources : - EWOL = new Ewol(this, EWOL_APPL_TYPE_WALLPAPER); - - // Load the application directory - EWOL.paramSetArchiveDir(1, getFilesDir().toString()); - EWOL.paramSetArchiveDir(2, getCacheDir().toString()); - // to enable extarnal storage: add in the manifest the restriction needed ... - //packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED; - //Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString()); - - - //! DisplayMetrics metrics = new DisplayMetrics(); - //! getWindowManager().getDefaultDisplay().getMetrics(metrics); - //! EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi); - - // call C init ... - EWOL.onCreate(); - - // create bsurface system - mGLView = new GLEngine(EWOL); - - return mGLView; - } - - public class GLEngine extends Engine { - private Ewol EWOL; - public GLEngine(Ewol ewolInstance) { - EWOL = ewolInstance; - } - - class WallpaperGLSurfaceView extends EwolSurfaceViewGL - { - private static final String TAG = "WallpaperGLSurfaceView"; - WallpaperGLSurfaceView(Context context, Ewol ewolInstance) { - super(context, ewolInstance); - Log.d(TAG, "WallpaperGLSurfaceView(" + context + ")"); - } - @Override public SurfaceHolder getHolder() { - Log.d(TAG, "getHolder(): returning " + getSurfaceHolder()); - return getSurfaceHolder(); - } - public void onDestroy() { - Log.d(TAG, "onDestroy()"); - super.onDetachedFromWindow(); - } - } - - private static final String TAG = "GLEngine"; - private WallpaperGLSurfaceView glSurfaceView; - - @Override public void onCreate(SurfaceHolder surfaceHolder) { - Log.d(TAG, "onCreate(" + surfaceHolder + ")"); - super.onCreate(surfaceHolder); - - glSurfaceView = new WallpaperGLSurfaceView(EwolWallpaper.this, EWOL); - - // Check if the system supports OpenGL ES 2.0. - final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); - final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; - - if (false==supportsEs2) { - Log.d("LiveWallpaper", "does not support board with only open GL ES 1"); - return; - } - // Request an OpenGL ES 2.0 compatible context. - //setEGLContextClientVersion(2); - - // On Honeycomb+ devices, this improves the performance when - // leaving and resuming the live wallpaper. - //setPreserveEGLContextOnPause(true); - - } - - @Override public void onTouchEvent(MotionEvent event) { - glSurfaceView.onTouchEvent(event); - } - - @Override public void onVisibilityChanged(boolean visible) { - Log.d(TAG, "onVisibilityChanged(" + visible + ")"); - super.onVisibilityChanged(visible); - if (true==visible) { - glSurfaceView.onResume(); - // call C - EWOL.onResume(); - } else { - glSurfaceView.onPause(); - // call C - EWOL.onPause(); - } - } - - @Override public void onDestroy() { - Log.d(TAG, "onDestroy()"); - super.onDestroy(); - // call C - EWOL.onStop(); - EWOL.onDestroy(); - glSurfaceView.onDestroy(); - } - - protected void setPreserveEGLContextOnPause(boolean preserve) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - Log.d(TAG, "setPreserveEGLContextOnPause(" + preserve + ")"); - glSurfaceView.setPreserveEGLContextOnPause(preserve); - } - } - - protected void setEGLContextClientVersion(int version) { - Log.d(TAG, "setEGLContextClientVersion(" + version + ")"); - glSurfaceView.setEGLContextClientVersion(version); - } - } - - public void keyboardUpdate(boolean show) { - // never display keyboard on wallpaer... - Log.d("EwolCallback", "KEABOARD UPDATE is not implemented ..."); - } - - public void eventNotifier(String[] args) { - // just for the test ... - Log.d("EwolCallback", "EVENT NOTIFIER is not implemented ..."); - - } - - public void orientationUpdate(int screenMode) { - Log.d("EwolCallback", "SET ORIENTATION is not implemented ..."); - } - - public void titleSet(String value) { - // no title in the wallpaper ... - Log.d("EwolCallback", "SET TITLE is not implemented ..."); - } - - public void openURI(String uri) { - try { - Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); - startActivity(myIntent); - } catch (ActivityNotFoundException e) { - Log.e("EwolActivity", "Can not request an URL"); - } - } - - public void stop() { - Log.d("EwolCallback", "STOP is not implemented ..."); - } - - public int audioGetDeviceCount() { - Log.e("EwolActivity", "Get device List"); - return 0; - } - - public String audioGetDeviceProperty(int idDevice) { - Log.e("EwolActivity", "Get device property"); - return ""; - } - - public boolean audioOpenDevice(int idDevice, int freq, int nbChannel, int format) { - Log.e("EwolActivity", "Open device"); - return false; - } - - public boolean audioCloseDevice(int idDevice) { - Log.e("EwolActivity", "Close device"); - return false; - } -} - - diff --git a/data/theme/shape/round/Button.json b/data/theme/shape/round/Button.json index 705d5e1c..07b27a06 100644 --- a/data/theme/shape/round/Button.json +++ b/data/theme/shape/round/Button.json @@ -18,6 +18,6 @@ padding-in-buttom:1, change-time:356, - program:"THEME:GUI:Button.prog", - color:"THEME:COLOR:Button.json" + program:"{ewol}THEME:GUI:Button.prog", + color:"{ewol}THEME:COLOR:Button.json" } diff --git a/data/theme/shape/round/CheckBox.json b/data/theme/shape/round/CheckBox.json index 84c3149c..78251d7f 100644 --- a/data/theme/shape/round/CheckBox.json +++ b/data/theme/shape/round/CheckBox.json @@ -6,6 +6,6 @@ padding-top:10, padding-buttom:10, change-time:356, - program:"THEME:GUI:CheckBox.prog", - color:"THEME:COLOR:CheckBox.json" + program:"{ewol}THEME:GUI:CheckBox.prog", + color:"{ewol}THEME:COLOR:CheckBox.json" } diff --git a/data/theme/shape/round/ContextMenu.json b/data/theme/shape/round/ContextMenu.json index 003a53a9..b0af03e4 100644 --- a/data/theme/shape/round/ContextMenu.json +++ b/data/theme/shape/round/ContextMenu.json @@ -18,6 +18,6 @@ padding-in-buttom:1, change-time:356, - program:"THEME:GUI:ContextMenu.prog", - color:"THEME:COLOR:ContextMenu.json" + program:"{ewol}THEME:GUI:ContextMenu.prog", + color:"{ewol}THEME:COLOR:ContextMenu.json" } diff --git a/data/theme/shape/round/Entry.json b/data/theme/shape/round/Entry.json index 74a540b4..245ee9da 100644 --- a/data/theme/shape/round/Entry.json +++ b/data/theme/shape/round/Entry.json @@ -18,6 +18,6 @@ padding-in-buttom:1, change-time:356, - program:"THEME:GUI:Entry.prog", - color:"THEME:COLOR:Entry.json" + program:"{ewol}THEME:GUI:Entry.prog", + color:"{ewol}THEME:COLOR:Entry.json" } diff --git a/data/theme/shape/round/PopUp.json b/data/theme/shape/round/PopUp.json index 7d268723..c675c473 100644 --- a/data/theme/shape/round/PopUp.json +++ b/data/theme/shape/round/PopUp.json @@ -18,6 +18,6 @@ padding-in-buttom:1, change-time:356, - program:"THEME:GUI:PopUp.prog", - color:"THEME:COLOR:PopUp.json" + program:"{ewol}THEME:GUI:PopUp.prog", + color:"{ewol}THEME:COLOR:PopUp.json" } diff --git a/data/theme/shape/round/WidgetScrolled.json b/data/theme/shape/round/WidgetScrolled.json index eca19e65..1cd14f2b 100644 --- a/data/theme/shape/round/WidgetScrolled.json +++ b/data/theme/shape/round/WidgetScrolled.json @@ -4,6 +4,6 @@ padding-top:16, padding-buttom:16, change-time:200, - program:"THEME:GUI:WidgetScrolled.prog", - color:"THEME:COLOR:WidgetScrolled.json" + program:"{ewol}THEME:GUI:WidgetScrolled.prog", + color:"{ewol}THEME:COLOR:WidgetScrolled.json" } diff --git a/data/theme/shape/square/Button.json b/data/theme/shape/square/Button.json index 17b716ef..f63d510a 100644 --- a/data/theme/shape/square/Button.json +++ b/data/theme/shape/square/Button.json @@ -18,6 +18,6 @@ padding-in-buttom:1, change-time:356, - program:"THEME:GUI:Button.prog", - color:"THEME:COLOR:Button.json" + program:"{ewol}THEME:GUI:Button.prog", + color:"{ewol}THEME:COLOR:Button.json" } diff --git a/data/theme/shape/square/CheckBox.json b/data/theme/shape/square/CheckBox.json index 0d737f70..9302ab92 100644 --- a/data/theme/shape/square/CheckBox.json +++ b/data/theme/shape/square/CheckBox.json @@ -20,6 +20,6 @@ box-size:20, box-inside:12, change-time:356, - program:"THEME:GUI:CheckBox.prog", - color:"THEME:COLOR:CheckBox.json" + program:"{ewol}THEME:GUI:CheckBox.prog", + color:"{ewol}THEME:COLOR:CheckBox.json" } \ No newline at end of file diff --git a/data/theme/shape/square/ContextMenu.json b/data/theme/shape/square/ContextMenu.json index d9c13822..36a8b8e7 100644 --- a/data/theme/shape/square/ContextMenu.json +++ b/data/theme/shape/square/ContextMenu.json @@ -18,6 +18,6 @@ padding-in-buttom:2, change-time:356, - program:"THEME:GUI:ContextMenu.prog", - color:"THEME:COLOR:ContextMenu.json" + program:"{ewol}THEME:GUI:ContextMenu.prog", + color:"{ewol}THEME:COLOR:ContextMenu.json" } diff --git a/data/theme/shape/square/Entry.json b/data/theme/shape/square/Entry.json index 8426b668..2351c455 100644 --- a/data/theme/shape/square/Entry.json +++ b/data/theme/shape/square/Entry.json @@ -18,6 +18,6 @@ padding-in-buttom:2, change-time:356, - program:"THEME:GUI:Entry.prog", - color:"THEME:COLOR:Entry.json" + program:"{ewol}THEME:GUI:Entry.prog", + color:"{ewol}THEME:COLOR:Entry.json" } diff --git a/data/theme/shape/square/PopUp.json b/data/theme/shape/square/PopUp.json index c669e557..6d2ddd9f 100644 --- a/data/theme/shape/square/PopUp.json +++ b/data/theme/shape/square/PopUp.json @@ -18,6 +18,6 @@ padding-in-buttom:2, change-time:356, - program:"THEME:GUI:PopUp.prog", - color:"THEME:COLOR:PopUp.json" + program:"{ewol}THEME:GUI:PopUp.prog", + color:"{ewol}THEME:COLOR:PopUp.json" } diff --git a/data/theme/shape/square/WidgetScrolled.json b/data/theme/shape/square/WidgetScrolled.json index dbe3b1e3..7ac384d7 100644 --- a/data/theme/shape/square/WidgetScrolled.json +++ b/data/theme/shape/square/WidgetScrolled.json @@ -18,6 +18,6 @@ padding-in-buttom:3, change-time:200, - program:"THEME:GUI:WidgetScrolled.prog", - color:"THEME:COLOR:WidgetScrolled.json" + program:"{ewol}THEME:GUI:WidgetScrolled.prog", + color:"{ewol}THEME:COLOR:WidgetScrolled.json" } diff --git a/ewol/Dimension.cpp b/ewol/Dimension.cpp deleted file mode 100644 index b993327c..00000000 --- a/ewol/Dimension.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include - -#undef __class__ -#define __class__ "Dimension" - -// TODO : set this in a super class acced in a statin fuction... -// ratio in milimeter : -static bool isInit = false; -static vec2 ratio(9999999,888888); -static vec2 invRatio(1,1); -static ewol::Dimension windowsSize(vec2(9999999,888888), ewol::Dimension::Pixel); - -static const float inchToMillimeter = 1.0f/25.4f; -static const float footToMillimeter = 1.0f/304.8f; -static const float meterToMillimeter = 1.0f/1000.0f; -static const float centimeterToMillimeter = 1.0f/10.0f; -static const float kilometerToMillimeter = 1.0f/1000000.0f; -static const float millimeterToInch = 25.4f; -static const float millimeterToFoot = 304.8f; -static const float millimeterToMeter =1000.0f; -static const float millimeterToCentimeter = 10.0f; -static const float millimeterToKilometer = 1000000.0f; - - -void ewol::Dimension::init() { - if (true == isInit) { - return; - } - ewol::Dimension conversion(vec2(72,72), ewol::Dimension::Inch); - ratio = conversion.getMillimeter(); - invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y()); - windowsSize.set(vec2(200,200), ewol::Dimension::Pixel); - isInit = true; -} - -void ewol::Dimension::unInit() { - isInit = false; - ratio.setValue(9999999,888888); - invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y()); - windowsSize.set(vec2(9999999,88888), ewol::Dimension::Pixel); -} - -void ewol::Dimension::setPixelRatio(const vec2& _ratio, enum ewol::Dimension::distance _type) { - ewol::Dimension::init(); - EWOL_INFO("Set a new screen ratio for the screen : ratio=" << _ratio << " type=" << _type); - ewol::Dimension conversion(_ratio, _type); - EWOL_INFO(" == > " << conversion); - ratio = conversion.getMillimeter(); - invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y()); - EWOL_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio); -} - -void ewol::Dimension::setPixelWindowsSize(const vec2& _size) { - windowsSize = _size; - EWOL_VERBOSE("Set a new Windows property size " << windowsSize << "px"); -} - -vec2 ewol::Dimension::getWindowsSize(enum ewol::Dimension::distance _type) { - return windowsSize.get(_type); -} - -float ewol::Dimension::getWindowsDiag(enum ewol::Dimension::distance _type) { - vec2 size = ewol::Dimension::getWindowsSize(_type); - return size.length(); -} - -ewol::Dimension::Dimension() : - m_data(0,0), - m_type(ewol::Dimension::Pixel) { - // notinh to do ... -} - -ewol::Dimension::Dimension(const vec2& _size, enum ewol::Dimension::distance _type) : - m_data(0,0), - m_type(ewol::Dimension::Pixel) { - set(_size, _type); -} - -void ewol::Dimension::set(std::string _config) { - m_data.setValue(0,0); - m_type = ewol::Dimension::Pixel; - enum distance type = ewol::Dimension::Pixel; - if (etk::end_with(_config, "%", false) == true) { - type = ewol::Dimension::Pourcent; - _config.erase(_config.size()-1, 1); - } else if (etk::end_with(_config, "px",false) == true) { - type = ewol::Dimension::Pixel; - _config.erase(_config.size()-2, 2); - } else if (etk::end_with(_config, "ft",false) == true) { - type = ewol::Dimension::foot; - _config.erase(_config.size()-2, 2); - } else if (etk::end_with(_config, "in",false) == true) { - type = ewol::Dimension::Inch; - _config.erase(_config.size()-2, 2); - } else if (etk::end_with(_config, "km",false) == true) { - type = ewol::Dimension::Kilometer; - _config.erase(_config.size()-2, 2); - } else if (etk::end_with(_config, "mm",false) == true) { - type = ewol::Dimension::Millimeter; - _config.erase(_config.size()-2, 2); - } else if (etk::end_with(_config, "cm",false) == true) { - type = ewol::Dimension::Centimeter; - _config.erase(_config.size()-2, 2); - } else if (etk::end_with(_config, "m",false) == true) { - type = ewol::Dimension::Meter; - _config.erase(_config.size()-1, 1); - } else { - EWOL_CRITICAL("Can not parse dimention : \"" << _config << "\""); - return; - } - vec2 tmp = _config; - set(tmp, type); - EWOL_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this ); -} - -ewol::Dimension::~Dimension() { - // nothing to do ... -} - -ewol::Dimension::operator std::string() const { - std::string str; - str = get(getType()); - - switch(getType()) { - case ewol::Dimension::Pourcent: - str += "%"; - break; - case ewol::Dimension::Pixel: - str += "px"; - break; - case ewol::Dimension::Meter: - str += "m"; - break; - case ewol::Dimension::Centimeter: - str += "cm"; - break; - case ewol::Dimension::Millimeter: - str += "mm"; - break; - case ewol::Dimension::Kilometer: - str += "km"; - break; - case ewol::Dimension::Inch: - str += "in"; - break; - case ewol::Dimension::foot: - str += "ft"; - break; - } - return str; -} - -vec2 ewol::Dimension::get(enum ewol::Dimension::distance _type) const { - switch(_type) { - case ewol::Dimension::Pourcent: - return getPourcent(); - case ewol::Dimension::Pixel: - return getPixel(); - case ewol::Dimension::Meter: - return getMeter(); - case ewol::Dimension::Centimeter: - return getCentimeter(); - case ewol::Dimension::Millimeter: - return getMillimeter(); - case ewol::Dimension::Kilometer: - return getKilometer(); - case ewol::Dimension::Inch: - return getInch(); - case ewol::Dimension::foot: - return getFoot(); - } - return vec2(0,0); -} - -void ewol::Dimension::set(const vec2& _size, enum ewol::Dimension::distance _type) { - // set min max on input to limit error : - vec2 size(std::avg(0.0f,_size.x(),9999999.0f), - std::avg(0.0f,_size.y(),9999999.0f)); - switch(_type) { - case ewol::Dimension::Pourcent: { - vec2 size2(std::avg(0.0f,_size.x(),100.0f), - std::avg(0.0f,_size.y(),100.0f)); - m_data = vec2(size2.x()*0.01f, size2.y()*0.01f); - //EWOL_VERBOSE("Set % : " << size2 << " == > " << m_data); - break; - } - case ewol::Dimension::Pixel: - m_data = size; - break; - case ewol::Dimension::Meter: - m_data = vec2(size.x()*meterToMillimeter*ratio.x(), size.y()*meterToMillimeter*ratio.y()); - break; - case ewol::Dimension::Centimeter: - m_data = vec2(size.x()*centimeterToMillimeter*ratio.x(), size.y()*centimeterToMillimeter*ratio.y()); - break; - case ewol::Dimension::Millimeter: - m_data = vec2(size.x()*ratio.x(), size.y()*ratio.y()); - break; - case ewol::Dimension::Kilometer: - m_data = vec2(size.x()*kilometerToMillimeter*ratio.x(), size.y()*kilometerToMillimeter*ratio.y()); - break; - case ewol::Dimension::Inch: - m_data = vec2(size.x()*inchToMillimeter*ratio.x(), size.y()*inchToMillimeter*ratio.y()); - break; - case ewol::Dimension::foot: - m_data = vec2(size.x()*footToMillimeter*ratio.x(), size.y()*footToMillimeter*ratio.y()); - break; - } - m_type = _type; -} - -vec2 ewol::Dimension::getPixel() const { - if (m_type!=ewol::Dimension::Pourcent) { - return m_data; - } else { - vec2 windDim = windowsSize.getPixel(); - vec2 res = vec2(windDim.x()*m_data.x(), windDim.y()*m_data.y()); - //EWOL_DEBUG("Get % : " << m_data << " / " << windDim << " == > " << res); - return res; - } -} - -vec2 ewol::Dimension::getPourcent() const { - if (m_type!=ewol::Dimension::Pourcent) { - vec2 windDim = windowsSize.getPixel(); - //EWOL_DEBUG(" windows dimention : " /*<< windowsSize*/ << " == > " << windDim << "px"); // ==> infinite loop ... - //printf(" windows dimention : %f,%f", windDim.x(),windDim.y()); - //printf(" data : %f,%f", m_data.x(),m_data.y()); - return vec2((m_data.x()/windDim.x())*100.0f, (m_data.y()/windDim.y())*100.0f); - } - return vec2(m_data.x()*100.0f, m_data.y()*100.0f);; -} - -vec2 ewol::Dimension::getMeter() const { - return ewol::Dimension::getMillimeter()*millimeterToMeter; -} - -vec2 ewol::Dimension::getCentimeter() const { - return ewol::Dimension::getMillimeter()*millimeterToCentimeter; -} - -vec2 ewol::Dimension::getMillimeter() const { - return ewol::Dimension::getPixel()*invRatio; -} - -vec2 ewol::Dimension::getKilometer() const { - return ewol::Dimension::getMillimeter()*millimeterToKilometer; -} - -vec2 ewol::Dimension::getInch() const { - return ewol::Dimension::getMillimeter()*millimeterToInch; -} - -vec2 ewol::Dimension::getFoot() const { - return ewol::Dimension::getMillimeter()*millimeterToFoot; -} - -std::ostream& ewol::operator <<(std::ostream& _os, enum ewol::Dimension::distance _obj) { - switch(_obj) { - case ewol::Dimension::Pourcent: - _os << "%"; - break; - case ewol::Dimension::Pixel: - _os << "px"; - break; - case ewol::Dimension::Meter: - _os << "m"; - break; - case ewol::Dimension::Centimeter: - _os << "cm"; - break; - case ewol::Dimension::Millimeter: - _os << "mm"; - break; - case ewol::Dimension::Kilometer: - _os << "km"; - break; - case ewol::Dimension::Inch: - _os << "in"; - break; - case ewol::Dimension::foot: - _os << "ft"; - break; - } - return _os; -} - -std::ostream& ewol::operator <<(std::ostream& _os, const ewol::Dimension& _obj) { - _os << _obj.get(_obj.getType()) << _obj.getType(); - return _os; -} - -namespace etk { - template<> std::string to_string(const ewol::Dimension& _obj) { - return _obj; - } - template<> std::u32string to_u32string(const ewol::Dimension& _obj) { - return etk::to_u32string(etk::to_string(_obj)); - } - template<> bool from_string(ewol::Dimension& _variableRet, const std::string& _value) { - _variableRet = ewol::Dimension(_value); - return true; - } - template<> bool from_string(ewol::Dimension& _variableRet, const std::u32string& _value) { - return from_string(_variableRet, etk::to_string(_value)); - } -}; diff --git a/ewol/Dimension.h b/ewol/Dimension.h deleted file mode 100644 index 9939d8ed..00000000 --- a/ewol/Dimension.h +++ /dev/null @@ -1,212 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_DIMENSION_H__ -#define __EWOL_DIMENSION_H__ - -#include -#include -#include - -namespace ewol { - /** - * @brief in the dimention class we store the data as the more usefull unit (pixel) - * but one case need to be dynamic the %, then when requested in % the register the % value - */ - class Dimension { - public: - enum distance { - Pourcent=0, - Pixel, - Meter, - Centimeter, - Millimeter, - Kilometer, - Inch, - foot, - }; - private: - vec2 m_data; - enum distance m_type; - public: - /** - * @brief Constructor (default :0,0 mode pixel) - */ - Dimension(); - /** - * @brief Constructor - * @param[in] _size Requested dimention - * @param[in] _type Unit of the Dimention - */ - Dimension(const vec2& _size, enum ewol::Dimension::distance _type=ewol::Dimension::Pixel); - /** - * @brief Constructor - * @param[in] _config dimension configuration. - */ - Dimension(const std::string& _config) : - m_data(0,0), - m_type(ewol::Dimension::Pixel) { - set(_config); - }; - /** - * @brief Constructor - * @param[in] _config dimension configuration. - */ - Dimension(const char* _config) : - m_data(0,0), - m_type(ewol::Dimension::Pixel) { - set(_config); - }; - /** - * @brief Destructor - */ - ~Dimension(); - - /** - * @brief string cast : - */ - operator std::string() const; - - /** - * @brief get the current dimention in requested type - * @param[in] _type Type of unit requested. - * @return dimention requested. - */ - vec2 get(enum distance _type) const; - /** - * @brief set the current dimention in requested type - * @param[in] _size Dimention to set - * @param[in] _type Type of unit requested. - */ - void set(const vec2& _size, enum distance _type); - - private: - /** - * @brief set the current dimention in requested type - * @param[in] _config dimension configuration. - */ - void set(std::string _config); - public: - /** - * @brief get the current dimention in pixel - * @return dimention in Pixel - */ - vec2 getPixel() const; - /** - * @brief get the current dimention in Pourcent - * @return dimention in Pourcent - */ - vec2 getPourcent() const; - /** - * @brief get the current dimention in Meter - * @return dimention in Meter - */ - vec2 getMeter() const; - /** - * @brief get the current dimention in Centimeter - * @return dimention in Centimeter - */ - vec2 getCentimeter() const; - /** - * @brief get the current dimention in Millimeter - * @return dimention in Millimeter - */ - vec2 getMillimeter() const; - /** - * @brief get the current dimention in Kilometer - * @return dimention in Kilometer - */ - vec2 getKilometer() const; - /** - * @brief get the current dimention in Inch - * @return dimention in Inch - */ - vec2 getInch() const; - /** - * @brief get the current dimention in Foot - * @return dimention in Foot - */ - vec2 getFoot() const; - /***************************************************** - * = assigment - *****************************************************/ - const Dimension& operator= (const Dimension& _obj ) { - if (this!=&_obj) { - m_data = _obj.m_data; - m_type = _obj.m_type; - } - return *this; - } - /***************************************************** - * == operator - *****************************************************/ - bool operator == (const Dimension& _obj) const { - if( m_data == _obj.m_data - && m_type == _obj.m_type) { - return true; - } - return false; - } - /***************************************************** - * != operator - *****************************************************/ - bool operator!= (const Dimension& _obj) const { - if( m_data != _obj.m_data - || m_type != _obj.m_type) { - return true; - } - return false; - } - /** - * @breif get the dimension type - * @return the type - */ - enum distance getType() const { - return m_type; - }; - public : // Global static access : - /** - * @brief basic init - */ - static void init(); - /** - * @brief basic un-init - */ - static void unInit(); - /** - * @brief set the Milimeter ratio for calculation - * @param[in] Ratio Milimeter ration for the screen calculation interpolation - * @param[in] type Unit type requested. - * @note: same as @ref setPixelPerInch (internal manage convertion) - */ - static void setPixelRatio(const vec2& _ratio, enum ewol::Dimension::distance _type); - /** - * @brief set the current Windows size - * @param[in] size size of the current windows in pixel. - */ - static void setPixelWindowsSize(const vec2& _size); - /** - * @brief get the Windows size in the request unit - * @param[in] type Unit type requested. - * @return the requested size - */ - static vec2 getWindowsSize(enum ewol::Dimension::distance _type); - /** - * @brief get the Windows diagonal size in the request unit - * @param[in] type Unit type requested. - * @return the requested size - */ - static float getWindowsDiag(enum ewol::Dimension::distance _type); - - }; - std::ostream& operator <<(std::ostream& _os, enum ewol::Dimension::distance _obj); - std::ostream& operator <<(std::ostream& _os, const ewol::Dimension& _obj); -}; - -#endif - diff --git a/ewol/compositing/Area.cpp b/ewol/compositing/Area.cpp index e8bb6d75..98effac8 100644 --- a/ewol/compositing/Area.cpp +++ b/ewol/compositing/Area.cpp @@ -35,7 +35,7 @@ ewol::compositing::Area::~Area() { void ewol::compositing::Area::loadProgram() { // get the shader resource : m_GLPosition = 0; - m_GLprogram = ewol::resource::Program::create(std::string("DATA:textured3D.prog")); + m_GLprogram = gale::resource::Program::create(std::string("{ewol}DATA:textured3D.prog")); if (nullptr != m_GLprogram) { m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); m_GLColor = m_GLprogram->getAttribute("EW_color"); @@ -59,11 +59,11 @@ void ewol::compositing::Area::draw(bool _disableDepthTest) { return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply; + mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // TextureID - m_GLprogram->setTexture0(m_GLtexID, m_resource->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); // position : m_GLprogram->sendAttribute(m_GLPosition, m_coord); // Texture : @@ -71,7 +71,7 @@ void ewol::compositing::Area::draw(bool _disableDepthTest) { // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); } diff --git a/ewol/compositing/Area.h b/ewol/compositing/Area.h index 002ba4be..06d4b072 100644 --- a/ewol/compositing/Area.h +++ b/ewol/compositing/Area.h @@ -12,8 +12,9 @@ #include #include #include -#include +#include #include +#include namespace ewol { namespace compositing { @@ -22,7 +23,7 @@ namespace ewol { vec3 m_position; //!< The current position to draw etk::Color<> m_color; //!< The text foreground color private: - std::shared_ptr m_GLprogram; //!< pointer on the opengl display program + std::shared_ptr m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLColor; //!< openGL id on the element (color buffer) diff --git a/ewol/compositing/Drawing.cpp b/ewol/compositing/Drawing.cpp index 8b0ef79b..3d1fbfc9 100644 --- a/ewol/compositing/Drawing.cpp +++ b/ewol/compositing/Drawing.cpp @@ -285,7 +285,7 @@ void ewol::compositing::Drawing::loadProgram() { // remove previous loading ... in case unLoadProgram(); // oad the new ... - m_GLprogram = ewol::resource::Program::create("DATA:color3.prog"); + m_GLprogram = gale::resource::Program::create("{ewol}DATA:color3.prog"); // get the shader resource : if (nullptr != m_GLprogram ) { m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); @@ -306,7 +306,7 @@ void ewol::compositing::Drawing::draw(bool _disableDepthTest) { return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply; + mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); mat4 tmpMatrix2; @@ -316,7 +316,7 @@ void ewol::compositing::Drawing::draw(bool _disableDepthTest) { // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); } diff --git a/ewol/compositing/Drawing.h b/ewol/compositing/Drawing.h index dfdff3a8..382a2515 100644 --- a/ewol/compositing/Drawing.h +++ b/ewol/compositing/Drawing.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace ewol { @@ -28,12 +28,12 @@ namespace ewol { etk::Color<> m_color; //!< The text foreground color etk::Color<> m_colorBg; //!< The text background color private: - std::shared_ptr m_GLprogram; //!< pointer on the opengl display program + std::shared_ptr m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLMatrixPosition; //!< position matrix int32_t m_GLColor; //!< openGL id on the element (color buffer) - private: // Background Color (display only when needed) + public: // Background Color (display only when needed) std::vector m_coord; //!< internal position for the text display std::vector > m_coordColor; //!< internal color of the background public: diff --git a/ewol/compositing/Image.cpp b/ewol/compositing/Image.cpp index 17a1711c..b9e6bc05 100644 --- a/ewol/compositing/Image.cpp +++ b/ewol/compositing/Image.cpp @@ -43,9 +43,9 @@ void ewol::compositing::Image::loadProgram() { m_GLPosition = 0; m_GLprogram.reset(); if (m_distanceFieldMode == true) { - m_GLprogram = ewol::resource::Program::create("DATA:texturedDF.prog"); + m_GLprogram = gale::resource::Program::create("{ewol}DATA:texturedDF.prog"); } else { - m_GLprogram = ewol::resource::Program::create("DATA:textured3D.prog"); + m_GLprogram = gale::resource::Program::create("{ewol}DATA:textured3D.prog"); } if (m_GLprogram != nullptr) { m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); @@ -71,12 +71,12 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) { return; } if (_disableDepthTest == true) { - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_depthTest); } else { - ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::enable(gale::openGL::flag_depthTest); } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply; + mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // TextureID @@ -84,12 +84,12 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) { if (m_distanceFieldMode == true) { EWOL_ERROR("FONT type error Request distance field and display normal ..."); } - m_GLprogram->setTexture0(m_GLtexID, m_resource->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); } else { if (m_distanceFieldMode == false) { EWOL_ERROR("FONT type error Request normal and display distance field ..."); } - m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getRendererId()); } // position : m_GLprogram->sendAttribute(m_GLPosition, m_coord); @@ -98,7 +98,7 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) { // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); } diff --git a/ewol/compositing/Image.h b/ewol/compositing/Image.h index ec9e8545..af844d5e 100644 --- a/ewol/compositing/Image.h +++ b/ewol/compositing/Image.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -29,7 +29,7 @@ namespace ewol { etk::Color<> m_color; //!< The text foreground color float m_angle; //!< Angle to set at the axes private: - std::shared_ptr m_GLprogram; //!< pointer on the opengl display program + std::shared_ptr m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLColor; //!< openGL id on the element (color buffer) diff --git a/ewol/compositing/Shaper.cpp b/ewol/compositing/Shaper.cpp index d06d3f34..7a9e5f5f 100644 --- a/ewol/compositing/Shaper.cpp +++ b/ewol/compositing/Shaper.cpp @@ -100,7 +100,7 @@ void ewol::compositing::Shaper::loadProgram() { m_confIdPaddingIn[shaperPosRight] = m_config->request("padding-in-right"); m_confIdPaddingIn[shaperPosTop] = m_config->request("padding-in-top"); m_confIdPaddingIn[shaperPosButtom] = m_config->request("padding-in-buttom"); - m_confIdChangeTime = m_config->request("ChangeTime"); + m_confIdChangeTime = m_config->request("change-time"); m_confProgramFile = m_config->request("program"); m_confImageFile = m_config->request("image"); m_confColorFile = m_config->request("color"); @@ -118,7 +118,7 @@ void ewol::compositing::Shaper::loadProgram() { } // get the shader resource : m_GLPosition = 0; - m_GLprogram = ewol::resource::Program::create(tmpFilename); + m_GLprogram = gale::resource::Program::create(tmpFilename); if (m_GLprogram != nullptr) { m_GLPosition = m_GLprogram->getAttribute("EW_coord2d"); m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); @@ -183,7 +183,7 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) { //glScalef(m_scaling.x, m_scaling.y, 1.0); m_GLprogram->use(); // set Matrix : translation/positionMatrix - mat4 tmpMatrix = ewol::openGL::getMatrix(); + mat4 tmpMatrix = gale::openGL::getMatrix(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // position : m_GLprogram->sendAttribute(m_GLPosition, 2/*x,y*/, m_coord); @@ -199,11 +199,11 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) { } if (nullptr!=m_resourceTexture) { // TextureID - m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getRendererId()); } // Request the draw of the elements : - //ewol::openGL::drawArrays(GL_TRIANGLES, 0, SHAPER_NB_MAX_VERTEX); - ewol::openGL::drawArrays(GL_TRIANGLE_STRIP, 0, m_nbVertexToDisplay); + //gale::openGL::drawArrays(gale::openGL::render_triangle, 0, SHAPER_NB_MAX_VERTEX); + gale::openGL::drawArrays(gale::openGL::render_triangleStrip, 0, m_nbVertexToDisplay); m_GLprogram->unUse(); } @@ -229,7 +229,7 @@ bool ewol::compositing::Shaper::changeStatusIn(int32_t _newStatusId) { } bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) { - //EWOL_DEBUG("call=" << _event); + EWOL_VERBOSE("call=" << _event << "state transition=" << m_stateTransition << " speedTime=" << m_config->getNumber(m_confIdChangeTime)); // start : if (m_stateTransition >= 1.0) { m_stateOld = m_stateNew; @@ -238,7 +238,7 @@ bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) { m_stateNew = m_nextStatusRequested; m_nextStatusRequested = -1; m_stateTransition = 0.0; - //EWOL_DEBUG(" ##### START ##### "); + EWOL_VERBOSE(" ##### START ##### "); } else { m_nextStatusRequested = -1; // disable periodic call ... @@ -257,11 +257,14 @@ bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) { m_nextStatusRequested = -1; } } - float timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0; + float timeRelativity = 0.0f; + if (m_config != nullptr) { + timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0; + } m_stateTransition += _event.getDeltaCall() / timeRelativity; //m_stateTransition += _event.getDeltaCall(); m_stateTransition = std::avg(0.0f, m_stateTransition, 1.0f); - //EWOL_DEBUG("relative=" << timeRelativity << " Transition : " << m_stateTransition); + EWOL_VERBOSE("relative=" << timeRelativity << " Transition : " << m_stateTransition); } return true; } @@ -471,10 +474,11 @@ void ewol::compositing::Shaper::setShape(const vec2& _origin, const vec2& _size, EWOL_ERROR(" inside = " << inside); */ int32_t mode = 0; + bool displayOutside = false; if (m_config != nullptr) { mode = m_config->getNumber(m_confIdMode); + displayOutside = m_config->getBoolean(m_confIdDisplayOutside); } - bool displayOutside = m_config->getBoolean(m_confIdDisplayOutside); m_nbVertexToDisplay = 0; if (displayOutside == true) { addVertexLine(enveloppe.yTop(), border.yTop(), diff --git a/ewol/compositing/Shaper.h b/ewol/compositing/Shaper.h index 0322ec84..fd70d786 100644 --- a/ewol/compositing/Shaper.h +++ b/ewol/compositing/Shaper.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -55,7 +55,7 @@ namespace ewol { int32_t m_confColorFile; //!< ConfigFile opengGl color file Name int32_t m_confImageFile; //!< ConfigFile opengGl program Name // openGL shaders programs: - std::shared_ptr m_GLprogram; //!< pointer on the opengl display program + std::shared_ptr m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on vec2(X,Y)) diff --git a/ewol/compositing/Sprite.h b/ewol/compositing/Sprite.h index 2588f790..363b56cb 100644 --- a/ewol/compositing/Sprite.h +++ b/ewol/compositing/Sprite.h @@ -11,7 +11,6 @@ #include #include -#include namespace ewol { namespace compositing { diff --git a/ewol/compositing/Text.cpp b/ewol/compositing/Text.cpp index 81882932..90a75964 100644 --- a/ewol/compositing/Text.cpp +++ b/ewol/compositing/Text.cpp @@ -44,16 +44,16 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en return; } if (_enableDepthTest == true) { - ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::enable(gale::openGL::flag_depthTest); } // set Matrix : translation/positionMatrix - mat4 projMatrix = ewol::openGL::getMatrix(); - mat4 camMatrix = ewol::openGL::getCameraMatrix(); + mat4 projMatrix = gale::openGL::getMatrix(); + mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // Texture : - m_GLprogram->setTexture0(m_GLtexID, m_font->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); // position : @@ -63,19 +63,18 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en // color : m_GLprogram->sendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); if (_enableDepthTest == true) { - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_depthTest); } } void ewol::compositing::Text::drawD(bool _disableDepthTest) { // draw BG in any case: - m_vectorialDraw.draw(); + m_vectorialDraw.draw(_disableDepthTest); if (m_coord.size() <= 0 || m_font == nullptr) { - // TODO : a remèe ... //EWOL_WARNING("Nothink to draw..."); return; } @@ -88,11 +87,11 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) { return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply; + mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // Texture : - m_GLprogram->setTexture0(m_GLtexID, m_font->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); // position : @@ -102,7 +101,7 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) { // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); } @@ -348,10 +347,19 @@ vec3 ewol::compositing::Text::calculateSizeChar(const char32_t& _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode); int32_t fontHeigh = getHeight(); - + if (myGlyph == nullptr) { + if (m_font == nullptr) { + EWOL_WARNING("no Glyph... in no font"); + } else { + EWOL_WARNING("no Glyph... in font : " << m_font->getName()); + } + return vec3((float)(0.2), + (float)(fontHeigh), + (float)(0.0)); + } // get the kerning ofset : float kerningOffset = 0.0; - if (true == m_kerning) { + if (m_kerning == true) { kerningOffset = myGlyph->kerningGet(m_previousCharcode); } diff --git a/ewol/compositing/TextBase.cpp b/ewol/compositing/TextBase.cpp index 9977d3c8..ab5a49c3 100644 --- a/ewol/compositing/TextBase.cpp +++ b/ewol/compositing/TextBase.cpp @@ -53,8 +53,8 @@ ewol::compositing::TextBase::~TextBase() { void ewol::compositing::TextBase::loadProgram(const std::string& _shaderName) { // get the shader resource : m_GLPosition = 0; - std::shared_ptr old = m_GLprogram; - m_GLprogram = ewol::resource::Program::create(_shaderName); + std::shared_ptr old = m_GLprogram; + m_GLprogram = gale::resource::Program::create(_shaderName); if (m_GLprogram != nullptr) { m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); m_GLColor = m_GLprogram->getAttribute("EW_color"); diff --git a/ewol/compositing/TextBase.h b/ewol/compositing/TextBase.h index 57a89c7a..9bb4241e 100644 --- a/ewol/compositing/TextBase.h +++ b/ewol/compositing/TextBase.h @@ -77,7 +77,7 @@ namespace ewol { float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one) enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...) protected: - std::shared_ptr m_GLprogram; //!< pointer on the opengl display program + std::shared_ptr m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLColor; //!< openGL id on the element (color buffer) @@ -101,7 +101,7 @@ namespace ewol { /** * @brief generic constructor */ - TextBase(const std::string& _shaderName = "DATA:text.prog", bool _loadProgram = true); + TextBase(const std::string& _shaderName = "{ewol}DATA:text.prog", bool _loadProgram = true); /** * @brief generic destructor */ diff --git a/ewol/compositing/TextDF.cpp b/ewol/compositing/TextDF.cpp index 16bfb9e4..a3a7585b 100644 --- a/ewol/compositing/TextDF.cpp +++ b/ewol/compositing/TextDF.cpp @@ -21,7 +21,7 @@ ewol::compositing::TextDF::TextDF(const std::string& _fontName, int32_t _fontSiz m_GLglyphLevel(-1), m_size(12.0) { setFont(_fontName, _fontSize); - loadProgram("DATA:fontDistanceField/font1.prog"); + loadProgram("{ewol}DATA:fontDistanceField/font1.prog"); } @@ -55,16 +55,16 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _ return; } if (_enableDepthTest == true) { - ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::enable(gale::openGL::flag_depthTest); } // set Matrix : translation/positionMatrix - mat4 projMatrix = ewol::openGL::getMatrix(); - mat4 camMatrix = ewol::openGL::getCameraMatrix(); + mat4 projMatrix = gale::openGL::getMatrix(); + mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // Texture : - m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId()); m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); m_GLprogram->sendAttribute(m_GLPosition, m_coord); @@ -72,10 +72,10 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _ m_GLprogram->sendAttribute(m_GLColor, m_coordColor); m_GLprogram->sendAttribute(m_GLglyphLevel, m_glyphLevel); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); if (_enableDepthTest == true) { - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_depthTest); } } @@ -98,11 +98,11 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) { return; } // set Matrix : translation/positionMatrix - mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply; + mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // Texture : - m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId()); + m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId()); m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); m_GLprogram->sendAttribute(m_GLPosition, m_coord); @@ -110,7 +110,7 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) { m_GLprogram->sendAttribute(m_GLColor, m_coordColor); m_GLprogram->sendAttribute(m_GLglyphLevel, m_glyphLevel); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, m_coord.size()); m_GLprogram->unUse(); } diff --git a/ewol/context/Android/Context.cpp b/ewol/context/Android/Context.cpp deleted file mode 100644 index c105078a..00000000 --- a/ewol/context/Android/Context.cpp +++ /dev/null @@ -1,1122 +0,0 @@ -/** - * @author Edouard DUPIN, Kevin BILLONNEAU - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -/* include auto generated file */ -#include - - - -int64_t ewol::getTime() { - struct timeval now; - gettimeofday(&now, nullptr); - //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); - return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec); -} - - -// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include - -static JavaVM* g_JavaVM=nullptr; // global acces on the unique JVM !!! -std::mutex g_interfaceMutex; -std::mutex g_interfaceAudioMutex; - - -void java_check_exception(JNIEnv* _env) { - if (_env->ExceptionOccurred()) { - EWOL_ERROR("C->java : EXEPTION ..."); - _env->ExceptionDescribe(); - _env->ExceptionClear(); - } -} - -class AndroidContext : public ewol::Context { - public: - enum application { - appl_unknow, - appl_application, - appl_wallpaper - }; - private: - enum application m_javaApplicationType; - // get a resources from the java environement : - JNIEnv* m_JavaVirtualMachinePointer; //!< the JVM - jclass m_javaClassEwol; //!< main activity class (android ...) - jclass m_javaClassEwolCallback; - jobject m_javaObjectEwolCallback; - jmethodID m_javaMethodEwolCallbackStop; //!< Stop function identifier - jmethodID m_javaMethodEwolCallbackEventNotifier; //!< basic methode to call ... - jmethodID m_javaMethodEwolCallbackKeyboardUpdate; //!< basic methode to call ... - jmethodID m_javaMethodEwolCallbackOrientationUpdate; - jmethodID m_javaMethodEwolActivitySetTitle; - jmethodID m_javaMethodEwolActivityOpenURI; - jmethodID m_javaMethodEwolActivitySetClipBoardString; - jmethodID m_javaMethodEwolActivityGetClipBoardString; - // List of all Audio interface : - jmethodID m_javaMethodEwolActivityAudioGetDeviceCount; - jmethodID m_javaMethodEwolActivityAudioGetDeviceProperty; - jmethodID m_javaMethodEwolActivityAudioOpenDevice; - jmethodID m_javaMethodEwolActivityAudioCloseDevice; - jclass m_javaDefaultClassString; //!< default string class - int32_t m_currentHeight; - ewol::key::Special m_guiKeyBoardSpecialKeyMode;//!< special key of the android system : - bool m_clipBoardOwnerStd; - private: - bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) { - _mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign); - if(_mid == nullptr) { - EWOL_ERROR("C->java : Can't find the method " << _name); - /* remove access on the virtual machine : */ - m_JavaVirtualMachinePointer = nullptr; - return false; - } - return true; - } - public: - AndroidContext(ewol::context::Application* _application, JNIEnv* _env, jclass _classBase, jobject _objCallback, enum application _typeAPPL) : - ewol::Context(_application), - m_javaApplicationType(_typeAPPL), - m_JavaVirtualMachinePointer(nullptr), - m_javaClassEwol(0), - m_javaClassEwolCallback(0), - m_javaObjectEwolCallback(0), - m_javaMethodEwolCallbackStop(0), - m_javaMethodEwolCallbackEventNotifier(0), - m_javaMethodEwolCallbackKeyboardUpdate(0), - m_javaMethodEwolCallbackOrientationUpdate(0), - m_javaMethodEwolActivitySetTitle(0), - m_javaMethodEwolActivityOpenURI(0), - m_javaMethodEwolActivitySetClipBoardString(0), - m_javaMethodEwolActivityGetClipBoardString(0), - m_javaMethodEwolActivityAudioGetDeviceCount(0), - m_javaMethodEwolActivityAudioGetDeviceProperty(0), - m_javaMethodEwolActivityAudioOpenDevice(0), - m_javaMethodEwolActivityAudioCloseDevice(0), - m_javaDefaultClassString(0), - m_currentHeight(0), - m_clipBoardOwnerStd(false), - m_audioCallBack(nullptr), - m_audioCallBackUserData(nullptr) { - EWOL_DEBUG("*******************************************"); - if (m_javaApplicationType == appl_application) { - EWOL_DEBUG("** set JVM Pointer (application) **"); - } else { - EWOL_DEBUG("** set JVM Pointer (LiveWallpaper) **"); - } - EWOL_DEBUG("*******************************************"); - m_JavaVirtualMachinePointer = _env; - // get default needed all time elements : - if (nullptr != m_JavaVirtualMachinePointer) { - EWOL_DEBUG("C->java : try load org/ewol/Ewol class"); - m_javaClassEwol = m_JavaVirtualMachinePointer->FindClass("org/ewol/Ewol" ); - if (m_javaClassEwol == 0) { - EWOL_ERROR("C->java : Can't find org/ewol/Ewol class"); - // remove access on the virtual machine : - m_JavaVirtualMachinePointer = nullptr; - return; - } - /* The object field extends Activity and implement EwolCallback */ - m_javaClassEwolCallback = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback); - if(m_javaClassEwolCallback == nullptr) { - EWOL_ERROR("C->java : Can't find org/ewol/EwolCallback class"); - // remove access on the virtual machine : - m_JavaVirtualMachinePointer = nullptr; - return; - } - bool functionCallbackIsMissing = false; - bool ret= false; - ret = safeInitMethodID(m_javaMethodEwolActivitySetTitle, - m_javaClassEwolCallback, - "titleSet", - "(Ljava/lang/String;)V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : titleSet"); - functionCallbackIsMissing = true; - } - ret = safeInitMethodID(m_javaMethodEwolActivityOpenURI, - m_javaClassEwolCallback, - "openURI", - "(Ljava/lang/String;)V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : openURI"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolCallbackStop, - m_javaClassEwolCallback, - "stop", - "()V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : stop"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolCallbackEventNotifier, - m_javaClassEwolCallback, - "eventNotifier", - "([Ljava/lang/String;)V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : eventNotifier"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolCallbackKeyboardUpdate, - m_javaClassEwolCallback, - "keyboardUpdate", - "(Z)V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : keyboardUpdate"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolCallbackOrientationUpdate, - m_javaClassEwolCallback, - "orientationUpdate", - "(I)V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : orientationUpdate"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolActivitySetClipBoardString, - m_javaClassEwolCallback, - "setClipBoardString", - "(Ljava/lang/String;)V"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : setClipBoardString"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolActivityGetClipBoardString, - m_javaClassEwolCallback, - "getClipBoardString", - "()Ljava/lang/String;"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : getClipBoardString"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolActivityAudioGetDeviceCount, - m_javaClassEwolCallback, - "audioGetDeviceCount", - "()I"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : audioGetDeviceCount"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolActivityAudioGetDeviceProperty, - m_javaClassEwolCallback, - "audioGetDeviceProperty", - "(I)Ljava/lang/String;"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : audioGetDeviceProperty"); - functionCallbackIsMissing = true; - } - - ret = safeInitMethodID(m_javaMethodEwolActivityAudioOpenDevice, - m_javaClassEwolCallback, - "audioOpenDevice", - "(IIII)Z"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : audioOpenDevice"); - functionCallbackIsMissing = true; - } - ret = safeInitMethodID(m_javaMethodEwolActivityAudioCloseDevice, - m_javaClassEwolCallback, - "audioCloseDevice", - "(I)Z"); - if (ret == false) { - java_check_exception(_env); - EWOL_ERROR("system can not start without function : audioCloseDevice"); - functionCallbackIsMissing = true; - } - - m_javaObjectEwolCallback = _env->NewGlobalRef(_objCallback); - //javaObjectEwolCallbackAndActivity = objCallback; - if (m_javaObjectEwolCallback == nullptr) { - functionCallbackIsMissing = true; - } - - m_javaDefaultClassString = m_JavaVirtualMachinePointer->FindClass("java/lang/String" ); - if (m_javaDefaultClassString == 0) { - EWOL_ERROR("C->java : Can't find java/lang/String" ); - // remove access on the virtual machine : - m_JavaVirtualMachinePointer = nullptr; - functionCallbackIsMissing = true; - } - if (functionCallbackIsMissing == true) { - EWOL_CRITICAL(" mission one function ==> system can not work withut it..."); - } - } - } - - ~AndroidContext() { - // TODO ... - } - - void unInit(JNIEnv* _env) { - _env->DeleteGlobalRef(m_javaObjectEwolCallback); - m_javaObjectEwolCallback = nullptr; - } - - int32_t run() { - // might never be called !!! - return -1; - } - - void stop() { - EWOL_DEBUG("C->java : send message to the java : STOP REQUESTED"); - int status; - if(!java_attach_current_thread(&status)) { - return; - } - //Call java ... - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackStop); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } - - void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - // this is to force the local system to think we have the buffer - // TODO : remove this 2 line when code will be writen - m_clipBoardOwnerStd = true; - switch (_clipboardID) { - case ewol::context::clipBoard::clipboardSelection: - // NOTE : Windows does not support the middle button the we do it internaly - // just transmit an event , we have the data in the system - OS_ClipBoardArrive(_clipboardID); - break; - case ewol::context::clipBoard::clipboardStd: - if (false == m_clipBoardOwnerStd) { - // generate a request TO the OS - // TODO : Send the message to the OS "We disire to receive the copy buffer ... - } else { - // just transmit an event , we have the data in the system - OS_ClipBoardArrive(_clipboardID); - } - break; - default: - EWOL_ERROR("Request an unknow ClipBoard ..."); - break; - } - } - - void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - switch (_clipboardID) { - case ewol::context::clipBoard::clipboardSelection: - // NOTE : nothing to do : Windows deas ot supported Middle button - break; - case ewol::context::clipBoard::clipboardStd: - - // Request the clipBoard : - EWOL_DEBUG("C->java : set clipboard"); - if (m_javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return; - } - //Call java ... - jstring data = m_JavaVirtualMachinePointer->NewStringUTF(ewol::context::clipBoard::get(_clipboardID).c_str()); - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityGetClipBoardString, data); - m_JavaVirtualMachinePointer->DeleteLocalRef(data); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } else { - EWOL_ERROR("C->java : can not set clipboard"); - } - break; - default: - EWOL_ERROR("Request an unknow ClipBoard ..."); - break; - } - } - int32_t audioGetDeviceCount() { - // Request the clipBoard : - EWOL_DEBUG("C->java : audio get device count"); - if (m_javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return 0; - } - EWOL_DEBUG("Call CallIntMethod ..."); - //Call java ... - jint ret = m_JavaVirtualMachinePointer->CallIntMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityAudioGetDeviceCount); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - return (int32_t)ret; - } else { - EWOL_ERROR("C->java : can not get audio device count"); - } - return 0; - } - std::string audioGetDeviceProperty(int32_t _idDevice) { - // Request the clipBoard : - EWOL_DEBUG("C->java : audio get device count"); - if (m_javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return ""; - } - //Call java ... - jstring returnString = (jstring) m_JavaVirtualMachinePointer->CallObjectMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityAudioGetDeviceProperty, _idDevice); - const char *js = m_JavaVirtualMachinePointer->GetStringUTFChars(returnString, nullptr); - std::string retString(js); - m_JavaVirtualMachinePointer->ReleaseStringUTFChars(returnString, js); - //m_JavaVirtualMachinePointer->DeleteLocalRef(returnString); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - return retString; - } else { - EWOL_ERROR("C->java : can not get audio device count"); - } - return ""; - } - private: - AndroidAudioCallback m_audioCallBack; - void* m_audioCallBackUserData; - public: - bool audioOpenDevice(int32_t _idDevice, - int32_t _freq, - int32_t _nbChannel, - int32_t _format, - AndroidAudioCallback _callback, - void* _userData) { - if (m_audioCallBack != nullptr) { - EWOL_ERROR("AudioCallback already started ..."); - return false; - } - // Request the clipBoard : - EWOL_DEBUG("C->java : audio get device count"); - if (m_javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return false; - } - //Call java ... - jboolean ret = m_JavaVirtualMachinePointer->CallBooleanMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityAudioOpenDevice, _idDevice, _freq, _nbChannel, _format); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - if (ret == true) { - m_audioCallBack = _callback; - m_audioCallBackUserData = _userData; - } - return (bool)ret; - } else { - EWOL_ERROR("C->java : can not get audio device count"); - } - return false; - } - bool audioCloseDevice(int32_t _idDevice) { - if (m_audioCallBack == nullptr) { - EWOL_ERROR("AudioCallback Not started ..."); - return false; - } - // Request the clipBoard : - EWOL_DEBUG("C->java : audio get device count"); - if (m_javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return false; - } - //Call java ... - jboolean ret = m_JavaVirtualMachinePointer->CallBooleanMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityAudioCloseDevice, _idDevice); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - m_audioCallBack = nullptr; - m_audioCallBackUserData = nullptr; - return (bool)ret; - } else { - EWOL_ERROR("C->java : can not get audio device count"); - } - return false; - } - private: - bool java_attach_current_thread(int *_rstatus) { - EWOL_DEBUG("C->java : call java"); - if (g_JavaVM == nullptr) { - EWOL_ERROR("C->java : JVM not initialised"); - m_JavaVirtualMachinePointer = nullptr; - return false; - } - *_rstatus = g_JavaVM->GetEnv((void **) &m_JavaVirtualMachinePointer, JNI_VERSION_1_6); - if (*_rstatus == JNI_EDETACHED) { - JavaVMAttachArgs lJavaVMAttachArgs; - lJavaVMAttachArgs.version = JNI_VERSION_1_6; - lJavaVMAttachArgs.name = "EwolNativeThread"; - lJavaVMAttachArgs.group = nullptr; - int status = g_JavaVM->AttachCurrentThread(&m_JavaVirtualMachinePointer, &lJavaVMAttachArgs); - java_check_exception(m_JavaVirtualMachinePointer); - if (status != JNI_OK) { - EWOL_ERROR("C->java : AttachCurrentThread failed : " << status); - m_JavaVirtualMachinePointer = nullptr; - return false; - } - } - return true; - } - - void java_detach_current_thread(int _status) { - if(_status == JNI_EDETACHED) { - g_JavaVM->DetachCurrentThread(); - m_JavaVirtualMachinePointer = nullptr; - } - } - - void sendJavaKeyboardUpdate(jboolean _showIt) { - int status; - if(!java_attach_current_thread(&status)) { - return; - } - //Call java ... - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackKeyboardUpdate, _showIt); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } - void keyboardShow() { - sendJavaKeyboardUpdate(JNI_TRUE); - }; - void keyboardHide() { - sendJavaKeyboardUpdate(JNI_FALSE); - }; - - // mode 0 : auto; 1 landscape, 2 portrait - void forceOrientation(enum ewol::orientation _orientation) { - int status; - if(!java_attach_current_thread(&status)) { - return; - } - jint param = (jint)_orientation; - - //Call java ... - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackOrientationUpdate, param); - - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } - - void setTitle(const std::string& _title) { - EWOL_DEBUG("C->java : send message to the java : \"" << _title << "\""); - if (m_javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return; - } - //Call java ... - jstring title = m_JavaVirtualMachinePointer->NewStringUTF(_title.c_str()); - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivitySetTitle, title); - m_JavaVirtualMachinePointer->DeleteLocalRef(title); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } else { - EWOL_ERROR("C->java : can not set title on appliation that is not real application"); - } - } - - void openURL(const std::string& _url) { - EWOL_DEBUG("C->java : send message to the java : open URL'" << _url << "'"); - int status; - if(!java_attach_current_thread(&status)) { - return; - } - //Call java ... - jstring url = m_JavaVirtualMachinePointer->NewStringUTF(_url.c_str()); - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityOpenURI, url); - m_JavaVirtualMachinePointer->DeleteLocalRef(url); - // manage execption : - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } - - void sendSystemMessage(const char* _dataString) { - EWOL_DEBUG("C->java : send message to the java : \"" << _dataString << "\""); - int status; - if(!java_attach_current_thread(&status)) { - return; - } - EWOL_DEBUG("C->java : 222"); - if (nullptr == _dataString) { - EWOL_ERROR("C->java : No data to send ..."); - return; - } - EWOL_DEBUG("C->java : 333"); - // create the string to the java - jstring jstr = m_JavaVirtualMachinePointer->NewStringUTF(_dataString); - if (jstr == 0) { - EWOL_ERROR("C->java : Out of memory" ); - return; - } - EWOL_DEBUG("C->java : 444"); - // create argument list - jobjectArray args = m_JavaVirtualMachinePointer->NewObjectArray(1, m_javaDefaultClassString, jstr); - if (args == 0) { - EWOL_ERROR("C->java : Out of memory" ); - return; - } - EWOL_DEBUG("C->java : 555"); - //Call java ... - m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackEventNotifier, args); - - EWOL_DEBUG("C->java : 666"); - java_check_exception(m_JavaVirtualMachinePointer); - java_detach_current_thread(status); - } - public: - void OS_SetInputMotion(int _pointerID, const vec2& _pos) { - ewol::Context::OS_SetInputMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos) { - ewol::Context::OS_SetInputState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void OS_SetMouseMotion(int _pointerID, const vec2& _pos) { - ewol::Context::OS_SetMouseMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos) { - ewol::Context::OS_SetMouseState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); - } - - void ANDROID_SetKeyboard(char32_t _myChar, bool _isDown, bool _isARepeateKey=false) { - OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey); - } - - bool ANDROID_systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) { - return systemKeyboradEvent(_key, _down); - } - void ANDROID_SetKeyboardMove(int _move, bool _isDown, bool _isARepeateKey=false) { - // direct wrapping : - enum ewol::key::keyboard move = (enum ewol::key::keyboard)_move; - m_guiKeyBoardSpecialKeyMode.update(move, _isDown); - OS_SetKeyboardMove(m_guiKeyBoardSpecialKeyMode, move, _isDown, _isARepeateKey); - } - - void OS_Resize(const vec2& _size) { - m_currentHeight = _size.y(); - ewol::Context::OS_Resize(_size); - } - - void audioPlayback(void* _dataOutput, int32_t _frameRate) { - if (m_audioCallBack != nullptr) { - //EWOL_DEBUG("IO Audio event request: Frames=" << _frameRate); - m_audioCallBack(_dataOutput, _frameRate, m_audioCallBackUserData); - } - } -}; - -static std::vector s_listInstance; -ewol::context::Application* s_applicationInit = NULL; - -extern "C" { - // JNI onLoad - JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* _jvm, void* _reserved) { - // get the java virtual machine handle ... - std::unique_lock lock(g_interfaceMutex); - std::unique_lock lockAudio(g_interfaceAudioMutex); - g_JavaVM = _jvm; - EWOL_DEBUG("JNI-> load the jvm ..." ); - return JNI_VERSION_1_6; - } - // JNI onUnLoad - JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* _vm, void *_reserved) { - std::unique_lock lock(g_interfaceMutex); - std::unique_lock lockAudio(g_interfaceAudioMutex); - g_JavaVM = nullptr; - EWOL_DEBUG("JNI-> Un-load the jvm ..." ); - } - - /* Call to initialize the graphics state */ - void Java_org_ewol_Ewol_EWparamSetArchiveDir(JNIEnv* _env, - jclass _cls, - jint _id, - jint _mode, - jstring _myString) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - //EWOL_CRITICAL(" call with ID : " << _id); - // direct setting of the date in the string system ... - jboolean isCopy; - const char* str = _env->GetStringUTFChars(_myString, &isCopy); - s_listInstance[_id]->setArchiveDir(_mode, str); - if (isCopy == JNI_TRUE) { - // from here str is reset ... - _env->ReleaseStringUTFChars(_myString, str); - str = nullptr; - } - } - - // declare main application instance like an application: - int main(int argc, char**argv); - jint Java_org_ewol_Ewol_EWsetJavaVirtualMachineStart(JNIEnv* _env, - jclass _classBase, - jobject _objCallback, - int _typeApplication) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Creating EWOL context **"); - EWOL_DEBUG("*******************************************"); - AndroidContext* tmpContext = nullptr; - s_applicationInit = NULL; - ewol::context::Application* localApplication = NULL; - // call the basic init of all application (that call us ...) - main(0,NULL); - localApplication = s_applicationInit; - s_applicationInit = NULL; - if (org_ewol_EwolConstants_EWOL_APPL_TYPE_ACTIVITY == _typeApplication) { - tmpContext = new AndroidContext(localApplication, _env, _classBase, _objCallback, AndroidContext::appl_application); - } else if (org_ewol_EwolConstants_EWOL_APPL_TYPE_WALLPAPER == _typeApplication) { - tmpContext = new AndroidContext(localApplication, _env, _classBase, _objCallback, AndroidContext::appl_wallpaper); - } else { - EWOL_CRITICAL(" try to create an instance with no apply type: " << _typeApplication); - return -1; - } - if (nullptr == tmpContext) { - EWOL_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.size()-1)); - return -1; - } - // for future case : all time this ... - s_listInstance.push_back(tmpContext); - int32_t newID = s_listInstance.size()-1; - return newID; - } - - void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** remove JVM Pointer **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - return; - } - if (nullptr == s_listInstance[_id]) { - EWOL_ERROR("the requested instance _id=" << (int32_t)_id << " is already removed ..."); - return; - } - s_listInstance[_id]->unInit(_env); - delete(s_listInstance[_id]); - s_listInstance[_id]=nullptr; - } - void Java_org_ewol_Ewol_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG(" == > Touch Event"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - java_check_exception(_env); - } - - void Java_org_ewol_Ewol_EWonCreate(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on Create **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - //s_listInstance[_id]->init(); - } - - void Java_org_ewol_Ewol_EWonStart(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on Start **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - //SendSystemMessage(" testmessages ... "); - } - void Java_org_ewol_Ewol_EWonReStart(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on Re-Start **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - } - void Java_org_ewol_Ewol_EWonResume(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on resume **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_Resume(); - } - void Java_org_ewol_Ewol_EWonPause(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on pause **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - // All the openGl has been destroyed ... - s_listInstance[_id]->getResourcesManager().contextHasBeenDestroyed(); - s_listInstance[_id]->OS_Suspend(); - } - void Java_org_ewol_Ewol_EWonStop(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on Stop **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_Stop(); - } - void Java_org_ewol_Ewol_EWonDestroy(JNIEnv* _env, jobject _thiz, jint _id) { - std::unique_lock lock(g_interfaceMutex); - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity on Destroy **"); - EWOL_DEBUG("*******************************************"); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - //s_listInstance[_id]->UnInit(); - } - - - - /* ********************************************************************************************** - * ** IO section : - * ********************************************************************************************** */ - void Java_org_ewol_Ewol_EWinputEventMotion(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _pointerID, - jfloat _x, - jfloat _y) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_SetInputMotion(_pointerID+1, vec2(_x,_y)); - } - - void Java_org_ewol_Ewol_EWinputEventState(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _pointerID, - jboolean _isUp, - jfloat _x, - jfloat _y) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_SetInputState(_pointerID+1, _isUp, vec2(_x,_y)); - } - - void Java_org_ewol_Ewol_EWmouseEventMotion(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _pointerID, - jfloat _x, - jfloat _y) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_SetMouseMotion(_pointerID+1, vec2(_x,_y)); - } - - void Java_org_ewol_Ewol_EWmouseEventState(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _pointerID, - jboolean _isUp, - jfloat _x, - jfloat _y) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_SetMouseState(_pointerID+1, _isUp, vec2(_x,_y)); - } - - void Java_org_ewol_Ewol_EWunknowEvent(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _pointerID) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - EWOL_DEBUG("Unknown IO event : " << _pointerID << " ???"); - } - - void Java_org_ewol_Ewol_EWkeyboardEventMove(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _type, - jboolean _isdown) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - EWOL_DEBUG("IO keyboard Move event : \"" << _type << "\" is down=" << _isdown); - s_listInstance[_id]->ANDROID_SetKeyboardMove(_type, _isdown); - } - - void Java_org_ewol_Ewol_EWkeyboardEventKey(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _uniChar, - jboolean _isdown) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - EWOL_DEBUG("IO keyboard Key event : \"" << _uniChar << "\" is down=" << _isdown); - s_listInstance[_id]->ANDROID_SetKeyboard(_uniChar, _isdown); - } - - void Java_org_ewol_Ewol_EWdisplayPropertyMetrics(JNIEnv* _env, - jobject _thiz, - jint _id, - jfloat _ratioX, - jfloat _ratioY) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - // set the internal system ratio properties ... - ewol::Dimension::setPixelRatio(vec2(_ratioX,_ratioY), ewol::Dimension::Inch); - } - - // TODO : set a return true or false if we want to grep this event ... - bool Java_org_ewol_Ewol_EWkeyboardEventKeySystem(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _keyVal, - jboolean _isdown) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return false; - } - switch (_keyVal) { - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_UP: - EWOL_VERBOSE("IO keyboard Key system \"VOLUME_UP\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemVolumeUp, _isdown); - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_DOWN: - EWOL_DEBUG("IO keyboard Key system \"VOLUME_DOWN\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemVolumeDown, _isdown); - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_MENU: - EWOL_DEBUG("IO keyboard Key system \"MENU\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemMenu, _isdown); - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_CAMERA: - EWOL_DEBUG("IO keyboard Key system \"CAMERA\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemCamera, _isdown); - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_HOME: - EWOL_DEBUG("IO keyboard Key system \"HOME\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemHome, _isdown); - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_POWER: - EWOL_DEBUG("IO keyboard Key system \"POWER\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemPower, _isdown); - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_BACK: - EWOL_DEBUG("IO keyboard Key system \"BACK\" is down=" << _isdown); - return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemBack, _isdown); - default: - EWOL_ERROR("IO keyboard Key system event : \"" << _keyVal << "\" is down=" << _isdown); - break; - } - return false; - } - - - /* ********************************************************************************************** - * ** Renderer section : - * ********************************************************************************************** */ - void Java_org_ewol_Ewol_EWrenderInit(JNIEnv* _env, - jobject _thiz, - jint _id) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - } - - void Java_org_ewol_Ewol_EWrenderResize(JNIEnv* _env, - jobject _thiz, - jint _id, - jint _w, - jint _h) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_Resize(vec2(_w, _h)); - } - - // TODO : Return true or false to not redraw when the under draw has not be done (processing gain of time) - void Java_org_ewol_Ewol_EWrenderDraw(JNIEnv* _env, - jobject _thiz, - jint _id) { - std::unique_lock lock(g_interfaceMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - s_listInstance[_id]->OS_Draw(true); - } - - void Java_org_ewol_Ewol_EWaudioPlayback(JNIEnv* _env, - void* _reserved, - jint _id, - jshortArray _location, - jint _frameRate, - jint _nbChannels) { - std::unique_lock lock(g_interfaceAudioMutex); - if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { - EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); - // TODO : generate error in java to stop the current instance - return; - } - // get the short* pointer from the Java array - jboolean isCopy; - jshort* dst = _env->GetShortArrayElements(_location, &isCopy); - if (nullptr != dst) { - memset(dst, sizeof(jshort), _frameRate*_nbChannels); - //EWOL_DEBUG("IO Audio event request: Frames=" << _frameRate << " channels=" << _nbChannels); - s_listInstance[_id]->audioPlayback(dst, _frameRate); - } - // TODO : Understand why it did not work corectly ... - //if (isCopy == JNI_TRUE) { - // release the short* pointer - _env->ReleaseShortArrayElements(_location, dst, 0); - //} - } -}; - - -int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) { - s_applicationInit = _application; - return 0; -} diff --git a/ewol/context/Application.h b/ewol/context/Application.h index 6d137c21..04ddc12d 100644 --- a/ewol/context/Application.h +++ b/ewol/context/Application.h @@ -13,19 +13,40 @@ namespace ewol { class Context; namespace context { class Application { - protected: - size_t m_nbStepInit; public: - size_t getNbStepInit() { - return m_nbStepInit; - } - public: - Application() : - m_nbStepInit(1) {}; + Application() {}; virtual ~Application() {}; public: - virtual bool init(ewol::Context& _context, size_t _initId) = 0; - virtual void unInit(ewol::Context& _context) = 0; + /** + * @brief The application is created. + * @param[in] _context Current ewol context. + */ + virtual void onCreate(ewol::Context& _context) {}; + /** + * @brief The application is started. + * @param[in] _context Current ewol context. + */ + virtual void onStart(ewol::Context& _context) {}; + /** + * @brief The application is resumed (now visible). + * @param[in] _context Current ewol context. + */ + virtual void onResume(ewol::Context& _context) {}; + /** + * @brief The application is Hide / not visible. + * @param[in] _context Current ewol context. + */ + virtual void onPause(ewol::Context& _context) {}; + /** + * @brief The application is stopped. + * @param[in] _context Current ewol context. + */ + virtual void onStop(ewol::Context& _context) {}; + /** + * @brief The application is remoed (call destructor just adter it.). + * @param[in] _context Current ewol context. + */ + virtual void onDestroy(ewol::Context& _context) {}; }; }; }; diff --git a/ewol/context/ConfigFont.cpp b/ewol/context/ConfigFont.cpp index f4232c74..d6042b4d 100644 --- a/ewol/context/ConfigFont.cpp +++ b/ewol/context/ConfigFont.cpp @@ -13,10 +13,13 @@ #define __class__ "context::ConfigFont" ewol::context::ConfigFont::ConfigFont() : - m_folder("DATA:fonts"), + m_folder("{ewol}DATA:fonts"), m_name("Arial;Helvetica"), m_size(10), m_useExternal(false) { + #ifdef __TARGET_OS__Android + m_name = "Roboto;DroidSans"; + #endif ewol::resource::freeTypeInit(); } @@ -28,7 +31,16 @@ ewol::context::ConfigFont::~ConfigFont() { void ewol::context::ConfigFont::set(const std::string& _fontName, int32_t _size) { m_name = _fontName; m_size = _size; - EWOL_INFO("Set default Font : '" << _fontName << "' size=" << _size); + EWOL_INFO("Set default Font : '" << m_name << "' size=" << m_size); } +void ewol::context::ConfigFont::setSize(int32_t _size) { + m_size = _size; + EWOL_INFO("Set default Font : '" << m_name << "' size=" << m_size << " (change size only)"); +} + +void ewol::context::ConfigFont::setName(const std::string& _fontName) { + m_name = _fontName; + EWOL_INFO("Set default Font : '" << m_name << "' size=" << m_size << " (change name only)"); +} diff --git a/ewol/context/ConfigFont.h b/ewol/context/ConfigFont.h index 452df1b8..e6ba452d 100644 --- a/ewol/context/ConfigFont.h +++ b/ewol/context/ConfigFont.h @@ -54,6 +54,11 @@ namespace ewol { const std::string& getName() { return m_name; }; + /** + * @brief Set the current default font name + * @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica". + */ + void setName(const std::string& _fontName); /** * @brief get the default font size. * @return the font size. @@ -61,6 +66,11 @@ namespace ewol { int32_t getSize() { return m_size; }; + /** + * @brief Set the default font size. + * @param[in] _size new font size. + */ + void setSize(int32_t _size); private: bool m_useExternal; public: diff --git a/ewol/context/Context.cpp b/ewol/context/Context.cpp index 2be4fb1b..9586d73f 100644 --- a/ewol/context/Context.cpp +++ b/ewol/context/Context.cpp @@ -9,20 +9,20 @@ #include #include +#include #include #include #include #include -#include - #include -#include #include +#include +#include + #include -#include #include #include #include @@ -30,112 +30,28 @@ #include #include -#include - - - - -/** - * @brief get the main ewol mutex (event or periodic call mutex). - * @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 - */ -static std::mutex& mutexInterface() { - static std::mutex s_interfaceMutex; - return s_interfaceMutex; -} +#undef __class__ +#define __class__ "Context" static ewol::Context* l_curentInterface=nullptr; ewol::Context& ewol::getContext() { - #if DEBUG_LEVEL > 2 - if(nullptr == l_curentInterface){ - EWOL_CRITICAL("[CRITICAL] try acces at an empty interface"); - } - #endif - return *l_curentInterface; + gale::Context& context = gale::getContext(); + std::shared_ptr appl = context.getApplication(); + if (appl == nullptr) { + EWOL_CRITICAL("[CRITICAL] try acces at an empty GALE application (can not get Context)"); + // ??? + } + return *(std::static_pointer_cast(appl)); } - void ewol::Context::setInitImage(const std::string& _fileName) { //m_initDisplayImageName = _fileName; } -/** - * @brief set the curent interface. - * @note this lock the main mutex - */ -void ewol::Context::lockContext() { - mutexInterface().lock(); - l_curentInterface = this; -} - -/** - * @brief set the curent interface at nullptr. - * @note this un-lock the main mutex - */ -void ewol::Context::unLockContext() { - l_curentInterface = nullptr; - mutexInterface().unlock(); -} - - -namespace ewol { - class eSystemMessage { - public: - enum theadMessage { - msgNone, - msgInit, - msgRecalculateSize, - msgResize, - msgHide, - msgShow, - - msgInputMotion, - msgInputState, - - msgKeyboardKey, - msgKeyboardMove, - - msgClipboardArrive - }; - public : - // specify the message type - enum theadMessage TypeMessage; - // can not set a union ... - enum ewol::context::clipBoard::clipboardListe clipboardID; - // InputId - enum ewol::key::type inputType; - int32_t inputId; - // generic dimentions - vec2 dimention; - // keyboard events : - bool repeateKey; //!< special flag for the repeating key on the PC interface - bool stateIsDown; - char32_t keyboardChar; - enum ewol::key::keyboard keyboardMove; - ewol::key::Special keyboardSpecial; - - eSystemMessage() : - TypeMessage(msgNone), - clipboardID(ewol::context::clipBoard::clipboardStd), - inputType(ewol::key::typeUnknow), - inputId(-1), - dimention(0,0), - repeateKey(false), - stateIsDown(false), - keyboardChar(0), - keyboardMove(ewol::key::keyboardUnknow) - { - - } - }; -}; - - void ewol::Context::inputEventTransfertWidget(std::shared_ptr _source, std::shared_ptr _destination) { m_input.transfertEvent(_source, _destination); @@ -150,226 +66,36 @@ void ewol::Context::inputEventUnGrabPointer() { m_input.unGrabPointer(); } -void ewol::Context::processEvents() { - int32_t nbEvent = 0; - //EWOL_DEBUG(" ******** Event"); - ewol::eSystemMessage* data = nullptr; - while (m_msgSystem.count()>0) { - nbEvent++; - if (data != nullptr) { - delete(data); - data = nullptr; - } - m_msgSystem.wait(data); - //EWOL_DEBUG("EVENT"); - switch (data->TypeMessage) { - case eSystemMessage::msgInit: - // this is due to the openGL context - /*bool returnVal = */ - m_application->init(*this, m_initStepId); - m_initStepId++; - break; - case eSystemMessage::msgRecalculateSize: - forceRedrawAll(); - break; - case eSystemMessage::msgResize: - //EWOL_DEBUG("Receive MSG : THREAD_RESIZE"); - m_windowsSize = data->dimention; - ewol::Dimension::setPixelWindowsSize(m_windowsSize); - forceRedrawAll(); - break; - case eSystemMessage::msgInputMotion: - //EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION"); - m_input.motion(data->inputType, data->inputId, data->dimention); - break; - case eSystemMessage::msgInputState: - //EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE"); - m_input.state(data->inputType, data->inputId, data->stateIsDown, data->dimention); - break; - case eSystemMessage::msgKeyboardKey: - case eSystemMessage::msgKeyboardMove: - //EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY"); - // store the keyboard special key status for mouse event... - m_input.setLastKeyboardSpecial(data->keyboardSpecial); - if (nullptr != m_windowsCurrent) { - if (false == m_windowsCurrent->onEventShortCut(data->keyboardSpecial, - data->keyboardChar, - data->keyboardMove, - data->stateIsDown) ) { - // get the current focused Widget : - std::shared_ptr tmpWidget = m_widgetManager.focusGet(); - if (nullptr != tmpWidget) { - // check if the widget allow repeating key events. - //EWOL_DEBUG("repeating test :" << data->repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data->stateIsDown); - if( false == data->repeateKey - || ( true == data->repeateKey - && true == tmpWidget->getKeyboardRepeate()) ) { - // check Widget shortcut - if (false == tmpWidget->onEventShortCut(data->keyboardSpecial, - data->keyboardChar, - data->keyboardMove, - data->stateIsDown) ) { - // generate the direct event ... - if (data->TypeMessage == eSystemMessage::msgKeyboardKey) { - ewol::event::EntrySystem tmpEntryEvent(ewol::key::keyboardChar, - ewol::key::statusUp, - data->keyboardSpecial, - data->keyboardChar); - if(true == data->stateIsDown) { - tmpEntryEvent.m_event.setStatus(ewol::key::statusDown); - } - tmpWidget->systemEventEntry(tmpEntryEvent); - } else { // THREAD_KEYBORAD_MOVE - EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data->keyboardMove << " " << data->stateIsDown); - ewol::event::EntrySystem tmpEntryEvent(data->keyboardMove, - ewol::key::statusUp, - data->keyboardSpecial, - 0); - if(true == data->stateIsDown) { - tmpEntryEvent.m_event.setStatus(ewol::key::statusDown); - } - tmpWidget->systemEventEntry(tmpEntryEvent); - } - } else { - EWOL_DEBUG("remove Repeate key ..."); - } - } - } - } - } - break; - case eSystemMessage::msgClipboardArrive: - { - std::shared_ptr tmpWidget = m_widgetManager.focusGet(); - if (tmpWidget != nullptr) { - tmpWidget->onEventClipboard(data->clipboardID); - } - } - break; - case eSystemMessage::msgHide: - EWOL_DEBUG("Receive MSG : msgHide"); - //guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); - //gui_uniqueWindows->SysOnHide(); - break; - case eSystemMessage::msgShow: - EWOL_DEBUG("Receive MSG : msgShow"); - //guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); - //gui_uniqueWindows->SysOnShow(); - break; - default: - EWOL_DEBUG("Receive MSG : UNKNOW"); - break; - } - } -} -void ewol::Context::setArchiveDir(int _mode, const char* _str) { - switch(_mode) { - case 0: - EWOL_DEBUG("Directory APK : path=" << _str); - etk::setBaseFolderData(_str); - break; - case 1: - EWOL_DEBUG("Directory mode=FILE path=" << _str); - etk::setBaseFolderDataUser(_str); - break; - case 2: - EWOL_DEBUG("Directory mode=CACHE path=" << _str); - etk::setBaseFolderCache(_str); - break; - case 3: - EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << _str); - break; - default: - EWOL_DEBUG("Directory mode=???? path=" << _str); - break; - } -} - - - -ewol::Context::Context(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) : - //m_application(std::make_shared(_application)), - m_application(_application), - m_objectManager(*this), - m_previousDisplayTime(0), - m_input(*this), -#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs)) - m_displayFps(true), -#else - m_displayFps(false), -#endif - m_FpsSystemEvent( "Event ", false), - m_FpsSystemContext("Context ", false), - m_FpsSystem( "Draw ", true), - m_FpsFlush( "Flush ", false), - m_windowsCurrent(nullptr), - m_windowsSize(320,480), - m_initStepId(0) { - // set a basic - etk::thread::setName("ewol"); - if (m_application == nullptr) { - EWOL_CRITICAL("Can not start context with no Application ==> rtfm ..."); - } - m_commandLine.parse(_argc, _argv); - EWOL_INFO(" == > Ewol system init (BEGIN)"); +void ewol::Context::onCreate(gale::Context& _context) { + EWOL_INFO(" == > Ewol system create (BEGIN)"); // Add basic ewol translation: - ewol::translate::addPath("ewol", "DATA:translate/ewol/"); + ewol::translate::addPath("ewol", "{ewol}DATA:translate/ewol/"); ewol::translate::autoDetectLanguage(); - // Reset the random system to be sure have real random values... - etk::tool::resetRandom(); - // set the curent interface : - lockContext(); // By default we set 2 themes (1 color and 1 shape ...) : etk::theme::setNameDefault("GUI", "shape/square/"); etk::theme::setNameDefault("COLOR", "color/black/"); - // parse the debug level: - for(int32_t iii = 0; iii < m_commandLine.size() ; ++iii) { - if (m_commandLine.get(iii) == "-l0") { - etk::log::setLevel(etk::log::logLevelNone); - } else if (m_commandLine.get(iii) == "-l1") { - etk::log::setLevel(etk::log::logLevelCritical); - } else if (m_commandLine.get(iii) == "-l2") { - etk::log::setLevel(etk::log::logLevelError); - } else if (m_commandLine.get(iii) == "-l3") { - etk::log::setLevel(etk::log::logLevelWarning); - } else if (m_commandLine.get(iii) == "-l4") { - etk::log::setLevel(etk::log::logLevelInfo); - } else if (m_commandLine.get(iii) == "-l5") { - etk::log::setLevel(etk::log::logLevelDebug); - } else if( m_commandLine.get(iii) == "-l6" - || m_commandLine.get(iii) == "-l7" - || m_commandLine.get(iii) == "-l8" - || m_commandLine.get(iii) == "-l9") { - etk::log::setLevel(etk::log::logLevelVerbose); - } else if (m_commandLine.get(iii) == "-fps") { - m_displayFps=true; - } else if (m_commandLine.get(iii) == "--dbg-file") { - // TODO : Set it back ... - //etk::cout.setOutputFile(true); + // parse for help: + for(int32_t iii = 0; iii < _context.getCmd().size() ; ++iii) { + if ( _context.getCmd().get(iii) == "-h" + || _context.getCmd().get(iii) == "--help") { + EWOL_PRINT("ewol - help : "); + EWOL_PRINT(" " << etk::getApplicationName() << " [options]"); + EWOL_PRINT(" -h/--help: Display this help"); + EWOL_PRINT(" example:"); + EWOL_PRINT(" " << etk::getApplicationName() << " --help"); + // this is a global help system does not remove it + continue; } else { continue; } - m_commandLine.remove(iii); + _context.getCmd().remove(iii); --iii; } - //etk::cout.setOutputFile(true); EWOL_INFO("EWOL v:" << ewol::getVersion()); - EWOL_INFO("Build Date: " << date::getYear() << "/" << date::getMonth() << "/" << date::getDay() << " " << date::getHour() << "h" << date::getMinute()); - // TODO : remove this ... - etk::initDefaultFolder("ewolApplNoName"); - // request the init of the application in the main context of openGL ... - { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - } else { - data->TypeMessage = eSystemMessage::msgInit; - m_msgSystem.post(data); - } - } // force a recalculation + /* requestUpdateSize(); #if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__) forceOrientation(ewol::screenLandscape); @@ -378,201 +104,239 @@ ewol::Context::Context(ewol::context::Application* _application, int32_t _argc, #else forceOrientation(ewol::screenAuto); #endif - // release the curent interface : - unLockContext(); - EWOL_INFO(" == > Ewol system init (END)"); + */ + std::shared_ptr appl = m_application; + if (appl == nullptr) { + EWOL_ERROR(" == > Create without application"); + return; + } + appl->onCreate(*this); + EWOL_INFO(" == > Ewol system create (END)"); } -ewol::Context::~Context() { - EWOL_INFO(" == > Ewol system Un-Init (BEGIN)"); - // TODO : Clean the message list ... - // set the curent interface : - lockContext(); +void ewol::Context::onStart(gale::Context& _context) { + EWOL_INFO(" == > Ewol system start (BEGIN)"); + std::shared_ptr appl = m_application; + if (appl == nullptr) { + // TODO : Request exit of the application .... with error ... + return; + } + appl->onStart(*this); + EWOL_INFO(" == > Ewol system start (END)"); +} + +void ewol::Context::onResume(gale::Context& _context) { + EWOL_INFO(" == > Ewol system resume (BEGIN)"); + std::shared_ptr appl = m_application; + if (appl == nullptr) { + return; + } + appl->onResume(*this); + EWOL_INFO(" == > Ewol system resume (END)"); +} + +void ewol::Context::onRegenerateDisplay(gale::Context& _context) { + //EWOL_INFO("REGENERATE_DISPLAY"); + // check if the user selected a windows + std::shared_ptr window = m_windowsCurrent; + if (window == nullptr) { + EWOL_DEBUG("No windows ..."); + return; + } + // Redraw all needed elements + window->onRegenerateDisplay(); + if (m_widgetManager.isDrawingNeeded() == true) { + markDrawingIsNeeded(); + } + //markDrawingIsNeeded(); +} + +void ewol::Context::onDraw(gale::Context& _context) { + //EWOL_INFO("DRAW"); + // clean internal data... + m_objectManager.cleanInternalRemoved(); + // real draw... + std::shared_ptr window = m_windowsCurrent; + if (window == nullptr) { + return; + } + window->sysDraw(); +} + +void ewol::Context::onPause(gale::Context& _context) { + EWOL_INFO(" == > Ewol system pause (BEGIN)"); + std::shared_ptr appl = m_application; + if (appl == nullptr) { + return; + } + appl->onPause(*this); + EWOL_INFO(" == > Ewol system pause (END)"); +} + +void ewol::Context::onStop(gale::Context& _context) { + EWOL_INFO(" == > Ewol system stop (BEGIN)"); + std::shared_ptr appl = m_application; + if (appl == nullptr) { + return; + } + appl->onStop(*this); + EWOL_INFO(" == > Ewol system stop (END)"); +} + +void ewol::Context::onDestroy(gale::Context& _context) { + EWOL_INFO(" == > Ewol system destroy (BEGIN)"); // Remove current windows m_windowsCurrent.reset(); // clean all widget and sub widget with their resources: m_objectManager.cleanInternalRemoved(); - // call application to uninit - m_application->unInit(*this); - m_application.reset(); - // clean all messages - m_msgSystem.clean(); + std::shared_ptr appl = m_application; + if (appl != nullptr) { + // call application to uninit + appl->onDestroy(*this); + m_application.reset(); + } // internal clean elements m_objectManager.cleanInternalRemoved(); - m_resourceManager.cleanInternalRemoved(); - EWOL_INFO("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing"); m_objectManager.displayListObject(); - // Resource is an lower element as objects ... - m_resourceManager.unInit(); // now All must be removed !!! m_objectManager.unInit(); - // release the curent interface : - unLockContext(); - EWOL_INFO(" == > Ewol system Un-Init (END)"); + EWOL_INFO(" == > Ewol system destroy (END)"); +} + +void ewol::Context::onPointer(enum gale::key::type _type, + int32_t _pointerID, + const vec2& _pos, + gale::key::status _state) { + switch (_state) { + case gale::key::status_move: + //EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION"); + m_input.motion(_type, _pointerID, _pos); + break; + case gale::key::status_down: + case gale::key::status_downRepeate: + //EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE"); + m_input.state(_type, _pointerID, true, _pos); + break; + case gale::key::status_up: + //EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE"); + m_input.state(_type, _pointerID, false, _pos); + break; + default: + EWOL_DEBUG("Unknow state : " << _state); + break; + } +} +void ewol::Context::onKeyboard(const gale::key::Special& _special, + enum gale::key::keyboard _type, + char32_t _value, + gale::key::status _state) { + EWOL_VERBOSE("event {" << _special << "} " << _type << " " << _value << " " << _state); + // store the keyboard special key status for mouse event... + m_input.setLastKeyboardSpecial(_special); + if (m_windowsCurrent == nullptr) { + // No windows ... + return; + } + bool repeate = (_state == gale::key::status_downRepeate); + bool isDown = (_state == gale::key::status_downRepeate) + || (_state == gale::key::status_down); + if (m_windowsCurrent->onEventShortCut(_special, + _value, + _type, + isDown) == true) { + // Keep a shortcut ... + return; + } + // get the current focused Widget : + std::shared_ptr tmpWidget = m_widgetManager.focusGet(); + if (tmpWidget == nullptr) { + // no Widget ... + return; + } + // check if the widget allow repeating key events. + //EWOL_INFO("repeating test :" << repeate << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << isDown); + if( repeate == false + || ( repeate == true + && tmpWidget->getKeyboardRepeate() == true) ) { + // check Widget shortcut + if (tmpWidget->onEventShortCut(_special, + _value, + _type, + isDown) == false) { + // generate the direct event ... + if (_type == gale::key::keyboard_char) { + ewol::event::EntrySystem tmpEntryEvent(gale::key::keyboard_char, + gale::key::status_up, + _special, + _value); + if(isDown == true) { + tmpEntryEvent.m_event.setStatus(gale::key::status_down); + } + tmpWidget->systemEventEntry(tmpEntryEvent); + } else { // THREAD_KEYBORAD_MOVE + ewol::event::EntrySystem tmpEntryEvent(_type, + gale::key::status_up, + _special, + 0); + if(isDown == true) { + tmpEntryEvent.m_event.setStatus(gale::key::status_down); + } + tmpWidget->systemEventEntry(tmpEntryEvent); + } + } else { + EWOL_DEBUG("remove Repeate key ..."); + } + } +} + +/* +void ewol::Context::processEvents() { + case eSystemMessage::msgResize: + //EWOL_DEBUG("Receive MSG : THREAD_RESIZE"); + m_windowsSize = data->dimention; + ewol::Dimension::setPixelWindowsSize(m_windowsSize); + forceRedrawAll(); + break; +*/ + +void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) { + std::shared_ptr tmpWidget = m_widgetManager.focusGet(); + if (tmpWidget != nullptr) { + tmpWidget->onEventClipboard(_clipboardId); + } +} + + +ewol::Context::Context(ewol::context::Application* _application) : + //m_application(std::make_shared(_application)), + m_application(_application), + m_objectManager(*this), + m_input(*this), + m_windowsCurrent(nullptr), + m_initStepId(0) { + if (m_application == nullptr) { + EWOL_CRITICAL("Can not start context with no Application ==> rtfm ..."); + } +} + +ewol::Context::~Context() { + // nothing to do ... } void ewol::Context::requestUpdateSize() { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgRecalculateSize; - m_msgSystem.post(data); + gale::Context& context = gale::getContext(); + context.requestUpdateSize(); } -void ewol::Context::OS_Resize(const vec2& _size) { - // TODO : Better in the thread ... == > but generate some init error ... - ewol::Dimension::setPixelWindowsSize(_size); - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgResize; - data->dimention = _size; - m_msgSystem.post(data); -} -void ewol::Context::OS_Move(const vec2& _pos) { - /* - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - data->TypeMessage = eSystemMessage::msgResize; - data->resize.w = w; - data->resize.h = h; - m_msgSystem.Post(data); - */ -} - -void ewol::Context::OS_SetInputMotion(int _pointerID, const vec2& _pos ) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgInputMotion; - data->inputType = ewol::key::typeFinger; - data->inputId = _pointerID; - data->dimention = _pos; - m_msgSystem.post(data); -} - -void ewol::Context::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgInputState; - data->inputType = ewol::key::typeFinger; - data->inputId = _pointerID; - data->stateIsDown = _isDown; - data->dimention = _pos; - m_msgSystem.post(data); -} - -void ewol::Context::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgInputMotion; - data->inputType = ewol::key::typeMouse; - data->inputId = _pointerID; - data->dimention = _pos; - m_msgSystem.post(data); -} - -void ewol::Context::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgInputState; - data->inputType = ewol::key::typeMouse; - data->inputId = _pointerID; - data->stateIsDown = _isDown; - data->dimention = _pos; - m_msgSystem.post(data); -} - -void ewol::Context::OS_SetKeyboard(ewol::key::Special& _special, - char32_t _myChar, - bool _isDown, - bool _isARepeateKey) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgKeyboardKey; - data->stateIsDown = _isDown; - data->keyboardChar = _myChar; - data->keyboardSpecial = _special; - data->repeateKey = _isARepeateKey; - m_msgSystem.post(data); -} - -void ewol::Context::OS_SetKeyboardMove(ewol::key::Special& _special, - enum ewol::key::keyboard _move, - bool _isDown, - bool _isARepeateKey) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgKeyboardMove; - data->stateIsDown = _isDown; - data->keyboardMove = _move; - data->keyboardSpecial = _special; - data->repeateKey = _isARepeateKey; - m_msgSystem.post(data); -} - -void ewol::Context::OS_Hide() { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgHide; - m_msgSystem.post(data); -} - -void ewol::Context::OS_Show() { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgShow; - m_msgSystem.post(data); -} - - -void ewol::Context::OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - ewol::eSystemMessage *data = new ewol::eSystemMessage(); - if (data == nullptr) { - EWOL_ERROR("allocationerror of message"); - return; - } - data->TypeMessage = eSystemMessage::msgClipboardArrive; - data->clipboardID = _clipboardID; - m_msgSystem.post(data); +void ewol::Context::onPeriod(int64_t _time) { + m_objectManager.timeCall(_time); } +#if 0 bool ewol::Context::OS_Draw(bool _displayEveryTime) { int64_t currentTime = ewol::getTime(); // this is to prevent the multiple display at the a high frequency ... - #if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__Windows)) - if(currentTime - m_previousDisplayTime < 1000000/120) { - usleep(1000); - return false; - } - #endif m_previousDisplayTime = currentTime; // process the events @@ -583,7 +347,6 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) { //! Event management section ... { // set the curent interface : - lockContext(); processEvents(); if (m_initStepId < m_application->getNbStepInit()) { ewol::eSystemMessage *data = new ewol::eSystemMessage(); @@ -596,11 +359,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) { } // call all the widget that neded to do something periodicly m_objectManager.timeCall(currentTime); - // check if the user selected a windows - if (nullptr != m_windowsCurrent) { - // Redraw all needed elements - m_windowsCurrent->onRegenerateDisplay(); - } + if (m_displayFps == true) { m_FpsSystemEvent.incrementCounter(); m_FpsSystemEvent.toc(); @@ -608,13 +367,12 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) { //! bool needRedraw = ewol::widgetManager::isDrawingNeeded(); needRedraw = m_widgetManager.isDrawingNeeded(); // release the curent interface : - unLockContext(); } bool hasDisplayDone = false; //! drawing section : { // Lock openGl context: - ewol::openGL::lock(); + gale::openGL::lock(); if (m_displayFps == true) { m_FpsSystemContext.tic(); } @@ -642,48 +400,42 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) { if (m_displayFps == true) { m_FpsSystem.toc(); m_FpsFlush.tic(); - m_FpsFlush.incrementCounter(); } - ewol::openGL::flush(); - //glFinish(); + if (hasDisplayDone == true) { + if (m_displayFps == true) { + m_FpsFlush.incrementCounter(); + } + gale::openGL::flush(); + } if (m_displayFps == true) { m_FpsFlush.toc(); } // release open GL Context - ewol::openGL::unLock(); - } - if (m_displayFps == true) { - m_FpsSystemEvent.draw(); - m_FpsSystemContext.draw(); - m_FpsSystem.draw(); - m_FpsFlush.draw(); + gale::openGL::unLock(); } { // set the curent interface : - lockContext(); // release open GL Context - ewol::openGL::lock(); + gale::openGL::lock(); // while The Gui is drawing in OpenGl, we do some not realTime things m_resourceManager.updateContext(); // release open GL Context - ewol::openGL::unLock(); + gale::openGL::unLock(); m_objectManager.cleanInternalRemoved(); m_resourceManager.cleanInternalRemoved(); // release the curent interface : - unLockContext(); } return hasDisplayDone; } +#endif void ewol::Context::resetIOEvent() { m_input.newLayerSet(); } -void ewol::Context::OS_OpenGlContextDestroy() { - m_resourceManager.contextHasBeenDestroyed(); -} void ewol::Context::setWindows(const std::shared_ptr& _windows) { + EWOL_INFO("set New windows"); // remove current focus : m_widgetManager.focusSetDefault(nullptr); m_widgetManager.focusRelease(); @@ -698,40 +450,40 @@ void ewol::Context::setWindows(const std::shared_ptr& _wi std::shared_ptr ewol::Context::getWindows() { return m_windowsCurrent; }; +void ewol::Context::onResize(const ivec2& _size) { + EWOL_VERBOSE("Resize: " << _size); + forceRedrawAll(); +} void ewol::Context::forceRedrawAll() { if (m_windowsCurrent == nullptr) { return; } - m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y())); + ivec2 size = getSize(); + m_windowsCurrent->calculateSize(vec2(size.x(), size.y())); } - +/* void ewol::Context::OS_Stop() { // set the curent interface : - lockContext(); EWOL_INFO("OS_Stop..."); if (m_windowsCurrent != nullptr) { m_windowsCurrent->sysOnKill(); } // release the curent interface : - unLockContext(); } void ewol::Context::OS_Suspend() { // set the curent interface : - lockContext(); EWOL_INFO("OS_Suspend..."); m_previousDisplayTime = -1; if (m_windowsCurrent != nullptr) { m_windowsCurrent->onStateSuspend(); } // release the curent interface : - unLockContext(); } void ewol::Context::OS_Resume() { // set the curent interface : - lockContext(); EWOL_INFO("OS_Resume..."); m_previousDisplayTime = ewol::getTime(); m_objectManager.timeCallResume(m_previousDisplayTime); @@ -739,71 +491,27 @@ void ewol::Context::OS_Resume() { m_windowsCurrent->onStateResume(); } // release the curent interface : - unLockContext(); } void ewol::Context::OS_Foreground() { // set the curent interface : - lockContext(); EWOL_INFO("OS_Foreground..."); if (m_windowsCurrent != nullptr) { m_windowsCurrent->onStateForeground(); } // release the curent interface : - unLockContext(); } void ewol::Context::OS_Background() { // set the curent interface : - lockContext(); EWOL_INFO("OS_Background..."); if (m_windowsCurrent != nullptr) { m_windowsCurrent->onStateBackground(); } // release the curent interface : - unLockContext(); } - +*/ void ewol::Context::stop() { } -void ewol::Context::setSize(const vec2& _size) { - EWOL_INFO("setSize: NOT implemented ..."); -}; - -void ewol::Context::setPos(const vec2& _pos) { - EWOL_INFO("setPos: NOT implemented ..."); -} - -void ewol::Context::hide() { - EWOL_INFO("hide: NOT implemented ..."); -}; - -void ewol::Context::show() { - EWOL_INFO("show: NOT implemented ..."); -} - -void ewol::Context::setTitle(const std::string& _title) { - EWOL_INFO("setTitle: NOT implemented ..."); -} - -void ewol::Context::keyboardShow() { - EWOL_INFO("keyboardShow: NOT implemented ..."); -} - - -void ewol::Context::keyboardHide() { - EWOL_INFO("keyboardHide: NOT implemented ..."); -} - - -bool ewol::Context::systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) { - if (m_windowsCurrent == nullptr) { - return false; - } - lockContext(); - bool ret = m_windowsCurrent->onEventHardwareInput(_key, _down); - unLockContext(); - return ret; -} \ No newline at end of file diff --git a/ewol/context/Context.h b/ewol/context/Context.h index 4962b403..c347a7e7 100644 --- a/ewol/context/Context.h +++ b/ewol/context/Context.h @@ -9,48 +9,34 @@ #ifndef __EWOL_CONTEXT_H__ #define __EWOL_CONTEXT_H__ -#include +#include +#include +#include +#include +#include + #include #include -#include #include -#include #include #include #include -#include #include -#include #include -#include #include namespace ewol { - /** - * @not-in-doc - */ - class eSystemMessage; - /** - * @not-in-doc - */ - enum orientation{ - screenAuto = 0, - screenLandscape, - screenPortrait - }; - - class Context/* : private ewol::object::RemoveEvent */{ + // Here we hereted from the gale application to be agnostic of the OW where we work ... + class Context : public gale::Application { private: std::shared_ptr m_application; //!< Application handle public: std::shared_ptr getApplication() { return m_application; } - private: - ewol::context::CommandLine m_commandLine; //!< Start command line information public: - ewol::context::CommandLine& getCmd() { - return m_commandLine; + gale::context::CommandLine& getCmd() { + return gale::getContext().getCmd(); }; private: ewol::context::ConfigFont m_configFont; //!< global font configuration @@ -70,92 +56,39 @@ namespace ewol { ewol::widget::Manager& getWidgetManager() { return m_widgetManager; }; - private: - ewol::resource::Manager m_resourceManager; //!< global resources Manager public: - ewol::resource::Manager& getResourcesManager() { - return m_resourceManager; + gale::resource::Manager& getResourcesManager() { + return gale::getContext().getResourcesManager(); }; public: - Context(ewol::context::Application* _application, int32_t _argc=0, const char* _argv[]=nullptr); + Context(ewol::context::Application* _application); virtual ~Context(); - protected: - /** - * @brief set the curent interface. - * @note this lock the main mutex - */ - void lockContext(); - /** - * @brief set the curent interface at nullptr. - * @note this un-lock the main mutex - */ - void unLockContext(); private: - int64_t m_previousDisplayTime; // this is to limit framerate ... in case... ewol::context::InputManager m_input; - etk::Fifo m_msgSystem; - bool m_displayFps; - ewol::context::Fps m_FpsSystemEvent; - ewol::context::Fps m_FpsSystemContext; - ewol::context::Fps m_FpsSystem; - ewol::context::Fps m_FpsFlush; - /** - * @brief Processing all the event arrived ... (commoly called in draw function) - */ - void processEvents(); - public: + public: // herited function: + virtual void onCreate(gale::Context& _context); + virtual void onStart(gale::Context& _context); + virtual void onResume(gale::Context& _context); + virtual void onRegenerateDisplay(gale::Context& _context); + virtual void onDraw(gale::Context& _context); + virtual void onPause(gale::Context& _context); + virtual void onStop(gale::Context& _context); + virtual void onDestroy(gale::Context& _context); + virtual void onPointer(enum gale::key::type _type, + int32_t _pointerID, + const vec2& _pos, + gale::key::status _state); + virtual void onKeyboard(const gale::key::Special& _special, + enum gale::key::keyboard _type, + char32_t _value, + gale::key::status _state); + virtual void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId); - virtual void setArchiveDir(int _mode, const char* _str); - - virtual void OS_SetInputMotion(int _pointerID, const vec2& _pos); - virtual void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos); - - virtual void OS_SetMouseMotion(int _pointerID, const vec2& _pos); - virtual void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos); - - virtual void OS_SetKeyboard(ewol::key::Special& _special, - char32_t _myChar, - bool _isDown, - bool _isARepeateKey=false); - virtual void OS_SetKeyboardMove(ewol::key::Special& _special, - enum ewol::key::keyboard _move, - bool _isDown, - bool _isARepeateKey=false); - /** - * @brief The current context is suspended - */ - virtual void OS_Suspend(); - /** - * @brief The current context is resumed - */ - virtual void OS_Resume(); - - /** - * @brief The current context is set in foreground (framerate is maximum speed) - */ - virtual void OS_Foreground(); - /** - * @brief The current context is set in background (framerate is slowing down (max fps)/5 # 4fps) - */ - virtual void OS_Background(); - - void requestUpdateSize(); - - // return true if a flush is needed - bool OS_Draw(bool _displayEveryTime); public: /** * @brief reset event management for the IO like Input ou Mouse or keyborad */ void resetIOEvent(); - /** - * @brief The OS inform that the openGL constext has been destroy == > use to automaticly reload the texture and other thinks ... - */ - void OS_OpenGlContextDestroy(); - /** - * @brief The OS Inform that the Window has been killed - */ - void OS_Stop(); /** * @brief The application request that the Window will be killed */ @@ -173,52 +106,7 @@ namespace ewol { * @return the current handle on the windows (can be null) */ std::shared_ptr getWindows(); - private: - vec2 m_windowsSize; //!< current size of the system - public: - /** - * @brief get the current windows size - * @return the current size ... - */ - const vec2& getSize() { - return m_windowsSize; - }; - /** - * @brief The OS inform that the current windows has change his size. - * @param[in] _size new size of the windows. - */ - virtual void OS_Resize(const vec2& _size); - /** - * @brief The application request a change of his curent size. - * @param[in] _size new Requested size of the windows. - */ - virtual void setSize(const vec2& _size); - /** - * @brief The OS inform that the current windows has change his position. - * @param[in] _pos New position of the Windows. - */ - void OS_Move(const vec2& _pos); - /** - * @brief The Application request that the current windows will change his position. - * @param[in] _pos New position of the Windows requested. - */ - virtual void setPos(const vec2& _pos); - /** - * @brief The OS inform that the Windows is now Hidden. - */ - void OS_Hide(); - /** - * @brief The Application request that the Windows will be Hidden. - */ - virtual void hide(); - /** - * @brief The OS inform that the Windows is now visible. - */ - void OS_Show(); - /** - * @brief The Application request that the Windows will be visible. - */ - virtual void show(); + /** * @brief Redraw all the windows */ @@ -240,41 +128,27 @@ namespace ewol { * @brief This fonction un-lock the pointer properties to move in relative instead of absolute */ void inputEventUnGrabPointer(); - - /** - * @brief display the virtal keyboard (for touch system only) - */ - virtual void keyboardShow(); - /** - * @brief Hide the virtal keyboard (for touch system only) - */ - virtual void keyboardHide(); - + // herited function: + virtual void onResize(const ivec2& _size); + #if 0 /** * @brief Inform the Gui that we want to have a copy of the clipboard * @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here */ - virtual void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { }; + virtual void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID); /** * @brief Inform the Gui that we are the new owner of the clipboard * @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here */ - virtual void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { }; + virtual void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID); /** * @brief Call by the OS when a clipboard arrive to US (previously requested by a widget) * @param[in] Id of the clipboard */ void OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardListe _clipboardID); - /** - * @brief set the new title of the windows - * @param[in] title New desired title - */ - virtual void setTitle(const std::string& _title); - /** - * @brief Open an URL on an eternal brother. - * @param[in] _url URL to open. - */ - virtual void openURL(const std::string& _url) { }; + #endif + + #if 0 /** * @brief force the screen orientation (availlable on portable elements ... * @param[in] _orientation Selected orientation. @@ -286,49 +160,14 @@ namespace ewol { * @param[in] _forcedPosition the position where the mouse might be reset at every events ... */ virtual void grabPointerEvents(bool _isGrabbed, const vec2& _forcedPosition) { }; - /** - * @brief set the cursor display type. - * @param[in] _newCursor selected new cursor. - */ - virtual void setCursor(enum ewol::context::cursorDisplay _newCursor) { }; - /** - * @brief set the Icon of the program - * @param[in] _inputFile new filename icon of the curent program. - */ - virtual void setIcon(const std::string& _inputFile) { }; + /** * @brief get the curent time in micro-second * @note : must be implemented in all system OS implementation * @return The curent time of the process */ static int64_t getTime(); - #if defined(__TARGET_OS__Android) - public: - typedef void (*AndroidAudioCallback)(void* _data, - int32_t _size, - void* _userData); - // Android specific audio interface : - virtual int32_t audioGetDeviceCount() { - return 0; - } - virtual std::string audioGetDeviceProperty(int32_t _idDevice) { - return ""; - } - virtual bool audioOpenDevice(int32_t _idDevice, - int32_t _freq, - int32_t _nbChannel, - int32_t _format, - AndroidAudioCallback _callback, - void* _userData) { - return false; - } - virtual bool audioCloseDevice(int32_t _idDevice) { - return false; - } - #endif - private: - // TODO : set user argument here .... - + #endif public: /** * @brief This is the only one things the User might done in his main(); @@ -353,13 +192,21 @@ namespace ewol { */ void setInitImage(const std::string& _fileName); protected: + # if 0 /** * @brief HARDWARE keyboard event from the system * @param[in] _key event type * @param[in] _status Up or down status * @return Keep the event or not */ - virtual bool systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down); + virtual bool systemKeyboradEvent(enum gale:key::keyboardSystem _key, bool _down); + #endif + public: + /** + * @brief Request a display after call a resize + */ + void requestUpdateSize(); + virtual void onPeriod(int64_t _time); }; /** * @brief From everyware in the program, we can get the context inteface. diff --git a/ewol/context/Fps.h b/ewol/context/Fps.h deleted file mode 100644 index cc92ad29..00000000 --- a/ewol/context/Fps.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_FPS_H__ -#define __EWOL_FPS_H__ - -namespace ewol { - namespace context { - /** - * @brief This class is designed to count the number of frame per second in the main renderer system - * @not-in-doc - */ - class Fps { - // display every second ... - #define DISPLAY_PERIODE_US (1000000) - private: - int64_t startTime; - int64_t nbCallTime; - int64_t nbDisplayTime; - int64_t min; - int64_t avg; - int64_t max; - int64_t min_idle; - int64_t avg_idle; - int64_t max_idle; - int64_t ticTime; - bool display; - bool drwingDone; - const char * m_displayName; - bool m_displayFPS; - public: - /** - * @brief Constructor - */ - Fps(const char * displayName, bool displayFPS) { - startTime = -1; - nbCallTime = 0; - nbDisplayTime = 0; - min = 99999999999999LL; - avg = 0; - max = 0; - min_idle = 99999999999999LL; - avg_idle = 0; - max_idle = 0; - ticTime = 0; - display = false; - drwingDone = false; - m_displayName = displayName; - m_displayFPS = displayFPS; - } - /** - * @brief Destructor - */ - ~Fps() { - - } - /** - * @brief this might be call every time a diplay start - */ - void tic() { - int64_t currentTime = ewol::getTime(); - ticTime = currentTime; - nbCallTime++; - if (startTime<0) { - startTime = currentTime; - } - //EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime)); - if ( (currentTime - startTime) > DISPLAY_PERIODE_US) { - display = true; - } - } - /** - * @brief this might be call every time a diplay stop, it do the display every second - * @param[in] displayTime display curent time of the frame. - */ - void toc(bool displayTime = false) { - int64_t currentTime = ewol::getTime(); - int64_t processTimeLocal = (currentTime - ticTime); - if (displayTime == true) { - EWOL_INFO(m_displayName << " : processTime : " << (float)((float)processTimeLocal / 1000.0) << "ms "); - } - if (drwingDone) { - min = std::min(min, processTimeLocal); - max = std::max(max, processTimeLocal); - avg += processTimeLocal; - drwingDone = false; - } else { - min_idle = std::min(min_idle, processTimeLocal); - max_idle = std::max(max_idle, processTimeLocal); - avg_idle += processTimeLocal; - } - } - /** - * @brief this might be call when a display is really done - */ - void incrementCounter() { - nbDisplayTime++; - drwingDone = true; - } - /** - * @brief draw debug display ... - */ - void draw() { - if (true == display) { - if (nbDisplayTime>0) { - EWOL_INFO(m_displayName << " : Active : " - << (float)((float)min / 1000.0) << "ms " - << (float)((float)avg / (float)nbDisplayTime / 1000.0) << "ms " - << (float)((float)max / 1000.0) << "ms "); - } - if (nbCallTime-nbDisplayTime>0) { - EWOL_INFO(m_displayName << " : idle : " - << (float)((float)min_idle / 1000.0) << "ms " - << (float)((float)avg_idle / (float)(nbCallTime-nbDisplayTime) / 1000.0) << "ms " - << (float)((float)max_idle / 1000.0) << "ms "); - } - if (true == m_displayFPS) { - EWOL_INFO("FPS : " << nbDisplayTime << "/" << nbCallTime << "fps"); - } - max = 0; - min = 99999999999999LL; - avg = 0; - max_idle = 0; - min_idle = 99999999999999LL; - avg_idle = 0; - nbCallTime = 0; - nbDisplayTime = 0; - startTime = -1; - display = false; - } - } - }; - }; -}; -#endif - diff --git a/ewol/context/IOs/AppDelegate.h b/ewol/context/IOs/AppDelegate.h deleted file mode 100644 index 602aab4a..00000000 --- a/ewol/context/IOs/AppDelegate.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import -@class OpenglView; - -@interface AppDelegate : UIResponder { - UIWindow *window; - OpenglView *glView; -} - -@property (nonatomic, retain) IBOutlet UIWindow *window; -@property (nonatomic, retain) IBOutlet OpenglView *glView; - -@end diff --git a/ewol/context/IOs/AppDelegate.mm b/ewol/context/IOs/AppDelegate.mm deleted file mode 100644 index 5eb14304..00000000 --- a/ewol/context/IOs/AppDelegate.mm +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import -#include "ewol/context/IOs/Interface.h" - -#import -#import -#include -#include - -@implementation AppDelegate - -@synthesize window; -@synthesize glView; - -- (void)applicationDidFinishLaunching:(UIApplication *)application { - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - CGFloat screenScale = [[UIScreen mainScreen] scale]; - NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height); - CGSize currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); - //screenBounds.size.width *= screenScale; - //screenBounds.size.height *= screenScale; - NSLog(@"Start with screeen bounds : %fx%f\n", screenBounds.size.width, screenBounds.size.height); - window = [[UIWindow alloc] initWithFrame:screenBounds]; - window.contentMode = UIViewContentModeRedraw; - glView = [[OpenglView alloc] initWithFrame:window.bounds]; - glView.contentMode = UIViewContentModeRedraw; - [window addSubview:glView]; - [window makeKeyAndVisible]; - // Create interface of ewol here .... - NSLog(@"CREATE EWOL interface creation\n"); - IOs::createInterface(); - IOs::resize(currentSize.width, currentSize.height); - IOs::start(); -} -/* - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - { - // Override point for customization after application launch. - return YES; - } - */ - -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - EWOL_INFO("move windows in applicationWillResignActive"); - [glView speedSlow]; - IOs::background(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - EWOL_INFO("move windows in applicationDidEnterBackground"); - [glView stopDisplayLink]; - IOs::suspend(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - EWOL_INFO("move windows in applicationWillEnterForeground"); - IOs::resume(); - [glView startDisplayLink]; -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - EWOL_INFO("move windows in applicationDidBecomeActive"); - [glView speedNormal]; - IOs::foreground(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - // Create interface of ewol here .... - EWOL_INFO("move windows in applicationWillTerminate"); - IOs::stop(); - IOs::releaseInterface(); -} - - -/* - - (void)dealloc { - [window release]; - [glView release]; - [super dealloc]; - } - */ - -@end diff --git a/ewol/context/IOs/Context.cpp b/ewol/context/IOs/Context.cpp deleted file mode 100644 index 0b5a7b66..00000000 --- a/ewol/context/IOs/Context.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include - - -int64_t ewol::getTime() { - struct timespec now; - clock_serv_t cclock; - mach_timespec_t mts; - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - now.tv_sec = mts.tv_sec; - now.tv_nsec = mts.tv_nsec; - //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); - return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000); -} - -#undef __class__ -#define __class__ "MacOSInterface" - - - -class MacOSInterface : public ewol::Context { -private: - ewol::key::Special m_guiKeyBoardMode; -public: - MacOSInterface(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) : - ewol::Context(_application, _argc, _argv) { - // nothing to do ... - } - - int32_t Run() { - - return 0; - } - virtual void stop() { - mm_exit(); - } -public: - //interface MacOS : - - bool MAC_Draw(bool _displayEveryTime) { - return OS_Draw(_displayEveryTime); - } - void MAC_Resize(float _x, float _y) { - OS_Resize(vec2(_x,_y)); - } - void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) { - OS_SetMouseState(_id, _isDown, vec2(_x, _y)); - } - void MAC_SetMouseMotion(int32_t _id, float _x, float _y) { - OS_SetMouseMotion(_id, vec2(_x, _y)); - } - void MAC_SetInputState(int32_t _id, bool _isDown, float _x, float _y) { - OS_SetInputState(_id, _isDown, vec2(_x, _y)); - } - void MAC_SetInputMotion(int32_t _id, float _x, float _y) { - OS_SetInputMotion(_id, vec2(_x, _y)); - } - void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { - if (_unichar == u32char::Delete) { - _unichar = u32char::Suppress; - } else if (_unichar == u32char::Suppress) { - _unichar = u32char::Delete; - } - if (_unichar == u32char::CarrierReturn) { - _unichar = u32char::Return; - } - //EWOL_DEBUG("key: " << _unichar << " up=" << !_isDown); - if (_unichar <= 4) { - enum ewol::key::keyboard move; - switch(_unichar) { - case 0: - move = ewol::key::keyboardUp; - break; - case 1: - move = ewol::key::keyboardDown; - break; - case 2: - move = ewol::key::keyboardLeft; - break; - case 3: - move = ewol::key::keyboardRight; - break; - } - OS_SetKeyboardMove(_keyboardMode, move, !_isDown, _isAReapeateKey); - } else { - OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey); - } - } - void MAC_SetKeyboardMove(ewol::key::Special& _special, - enum ewol::key::keyboard _move, - bool _isDown) { - OS_SetKeyboardMove(_special, _move, _isDown); - } - void openURL(const std::string& _url) { - mm_openURL(_url.c_str()); - } -}; - - -MacOSInterface* interface = nullptr; - - - -bool IOs::draw(bool _displayEveryTime) { - if (interface == nullptr) { - return false; - } - return interface->MAC_Draw(_displayEveryTime); -} - -void IOs::resize(float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_Resize(_x, _y); -} - - -void IOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_SetMouseState(_id, _isDown, _x, _y); -} - -void IOs::setMouseMotion(int32_t _id, float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_SetMouseMotion(_id, _x, _y); -} - -void IOs::setInputState(int32_t _id, bool _isDown, float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_SetInputState(_id, _isDown, _x, _y); -} - -void IOs::setInputMotion(int32_t _id, float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_SetInputMotion(_id, _x, _y); -} - -void IOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { - if (interface == nullptr) { - return; - } - interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey); -} - -void IOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) { - if (interface == nullptr) { - return; - } - interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown); -} - -void IOs::start() { - if (interface == nullptr) { - return; - } - //interface->OS_Start(); -} - -void IOs::resume() { - if (interface == nullptr) { - return; - } - interface->OS_Resume(); -} - -void IOs::suspend() { - if (interface == nullptr) { - return; - } - interface->OS_Suspend(); -} - -void IOs::stop() { - if (interface == nullptr) { - return; - } - interface->OS_Stop(); -} -void IOs::background() { - if (interface == nullptr) { - return; - } - interface->OS_Background(); -} -void IOs::foreground() { - if (interface == nullptr) { - return; - } - interface->OS_Foreground(); -} - - -static int l_argc = 0; -static const char **l_argv = nullptr; -static ewol::context::Application* l_application; -/** - * @brief Main of the program - * @param std IO - * @return std IO - */ -int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) { - l_argc = _argc; - l_argv = _argv; - l_application = _application; - return mm_main(_argc, _argv); -} - -// Creat and relaese ewol::Context interface: -void IOs::createInterface() { - etk::init(l_argc, l_argv); - EWOL_INFO("Create new interface"); - interface = new MacOSInterface(l_application, l_argc, l_argv); - l_application = nullptr; - if (nullptr == interface) { - EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error"); - return; - } -} - -void IOs::releaseInterface() { - if (interface != nullptr) { - EWOL_INFO("Remove interface"); - } - delete(interface); - interface = nullptr; -} - - - - - - diff --git a/ewol/context/IOs/Context.h b/ewol/context/IOs/Context.h deleted file mode 100644 index 6b48f650..00000000 --- a/ewol/context/IOs/Context.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __MAC_OS_CONTEXT_H__ -#define __MAC_OS_CONTEXT_H__ - -#include - -namespace IOs { - // Create and relaese ewol::Context interface: - void createInterface(); - void releaseInterface(); - // return true if a flush is needed - bool draw(bool _displayEveryTime); - /** - * @brief The OS inform that the current windows has change his size. - * @param[in] _size new size of the windows. - */ - void resize(float _x, float _y); - void setMouseState(int32_t _id, bool _isDown, float _x, float _y); - void setMouseMotion(int32_t _id, float _x, float _y); - void setInputState(int32_t _id, bool _isDown, float _x, float _y); - void setInputMotion(int32_t _id, float _x, float _y); - void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey); - void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown); - void start(); - void stop(); - void foreground(); - void background(); - void resume(); - void suspend(); -}; - - -#endif \ No newline at end of file diff --git a/ewol/context/IOs/Interface.h b/ewol/context/IOs/Interface.h deleted file mode 100644 index d17d4886..00000000 --- a/ewol/context/IOs/Interface.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_MM_INTERFACE_H__ -#define __EWOL_MM_INTERFACE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -int mm_main(int argc, const char *argv[]); -void mm_exit(); -void mm_openURL(const char *_url); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ewol/context/IOs/Interface.m b/ewol/context/IOs/Interface.m deleted file mode 100644 index 681e44c1..00000000 --- a/ewol/context/IOs/Interface.m +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import -#import -//#import "AppDelegate.h" - - - -int mm_main(int argc, const char *argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, (char**)argv, nil, NSStringFromClass([AppDelegate class])); - } - // return no error - return 0; -} - -void mm_exit(void) { - [[NSThread mainThread] cancel]; -} - -void mm_openURL(const char *_url) { - NSString* url = [[NSString alloc] initWithUTF8String:_url]; - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; -} - diff --git a/ewol/context/IOs/OpenglView.h b/ewol/context/IOs/OpenglView.h deleted file mode 100644 index 2cf99c46..00000000 --- a/ewol/context/IOs/OpenglView.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// EAGLView.h -// OpenGLBasics -// -// Created by Charlie Key on 6/24/09. -// - - -#import -#import -#include -#include - -/* - This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. - The view content is basically an EAGL surface you render your OpenGL scene into. - Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. - */ -@interface OpenglView : UIView { -@private - CAEAGLLayer* _eaglLayer; - - EAGLContext *_context; - GLuint _colorRenderBuffer; - GLuint _depthRenderBuffer; - - /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ - GLuint viewRenderbuffer, viewFramebuffer; - - /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ - GLuint depthRenderbuffer; - CGSize m_currentSize; - CADisplayLink* displayLink; //!< link to start and stop display of the view... - int deltaDisplay; - int displayCounter; -} -- (void)stopDisplayLink; -- (void)startDisplayLink; -- (void)speedSlow; -- (void)speedNormal; -@end diff --git a/ewol/context/IOs/OpenglView.mm b/ewol/context/IOs/OpenglView.mm deleted file mode 100644 index 66f6d32c..00000000 --- a/ewol/context/IOs/OpenglView.mm +++ /dev/null @@ -1,281 +0,0 @@ -// -// EAGLView.m -// OpenGLBasics -// -// Created by Charlie Key on 6/24/09. -// - -#import -#import -#include -#include - - -#include -#include - -#import "OpenglView.h" -#include - - -@interface OpenglView () -@end - - -@implementation OpenglView - -// You must implement this method (it does not work without it) -+ (Class)layerClass { - return [CAEAGLLayer class]; -} - -- (NSString *) platform { - size_t size; - sysctlbyname("hw.machine", NULL, &size, NULL, 0); - char *machine = (char*)malloc(size); - sysctlbyname("hw.machine", machine, &size, NULL, 0); - NSString *platform = [NSString stringWithUTF8String:machine]; - free(machine); - return platform; -} - -- (NSString *) platformString { - NSString *platform = [self platform]; - if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; - if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; - if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS"; - if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; - if ([platform isEqualToString:@"iPhone3,3"]) return @"Verizon iPhone 4"; - if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S"; - if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)"; - if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)"; - if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)"; - if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)"; - if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)"; - if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)"; - if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G"; - if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G"; - if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G"; - if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G"; - if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch 5G"; - if ([platform isEqualToString:@"iPad1,1"]) return @"iPad"; - if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)"; - if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (GSM)"; - if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)"; - if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (WiFi)"; - if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)"; - if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini (GSM)"; - if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini (GSM+CDMA)"; - if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)"; - if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (GSM+CDMA)"; - if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (GSM)"; - if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)"; - if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (GSM)"; - if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (GSM+CDMA)"; - if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)"; - if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)"; - if ([platform isEqualToString:@"iPad4,4"]) return @"iPad mini 2G (WiFi)"; - if ([platform isEqualToString:@"iPad4,5"]) return @"iPad mini 2G (Cellular)"; - if ([platform isEqualToString:@"i386"]) return @"Simulator"; - if ([platform isEqualToString:@"x86_64"]) return @"Simulator"; - return platform; -} -- (float)getScreenPPP { - NSString *platform = [self platform]; - if ([platform isEqualToString:@"iPhone1,1"]) return 326.0f; //@"iPhone 1G"; - if ([platform isEqualToString:@"iPhone1,2"]) return 326.0f; //@"iPhone 3G"; - if ([platform isEqualToString:@"iPhone2,1"]) return 326.0f; //@"iPhone 3GS"; - if ([platform isEqualToString:@"iPhone3,1"]) return 326.0f; //@"iPhone 4"; - if ([platform isEqualToString:@"iPhone3,3"]) return 326.0f; //@"Verizon iPhone 4"; - if ([platform isEqualToString:@"iPhone4,1"]) return 326.0f; //@"iPhone 4S"; - if ([platform isEqualToString:@"iPhone5,1"]) return 326.0f; //@"iPhone 5 (GSM)"; - if ([platform isEqualToString:@"iPhone5,2"]) return 326.0f; //@"iPhone 5 (GSM+CDMA)"; - if ([platform isEqualToString:@"iPhone5,3"]) return 326.0f; //@"iPhone 5c (GSM)"; - if ([platform isEqualToString:@"iPhone5,4"]) return 326.0f; //@"iPhone 5c (GSM+CDMA)"; - if ([platform isEqualToString:@"iPhone6,1"]) return 326.0f; //@"iPhone 5s (GSM)"; - if ([platform isEqualToString:@"iPhone6,2"]) return 326.0f; //@"iPhone 5s (GSM+CDMA)"; - if ([platform isEqualToString:@"iPod1,1"]) return 326.0f; //@"iPod Touch 1G"; - if ([platform isEqualToString:@"iPod2,1"]) return 326.0f; //@"iPod Touch 2G"; - if ([platform isEqualToString:@"iPod3,1"]) return 326.0f; //@"iPod Touch 3G"; - if ([platform isEqualToString:@"iPod4,1"]) return 326.0f; //@"iPod Touch 4G"; - if ([platform isEqualToString:@"iPod5,1"]) return 326.0f; //@"iPod Touch 5G"; - if ([platform isEqualToString:@"iPad1,1"]) return 264.0f; //@"iPad"; - if ([platform isEqualToString:@"iPad2,1"]) return 264.0f; //@"iPad 2 (WiFi)"; - if ([platform isEqualToString:@"iPad2,2"]) return 264.0f; //@"iPad 2 (GSM)"; - if ([platform isEqualToString:@"iPad2,3"]) return 264.0f; //@"iPad 2 (CDMA)"; - if ([platform isEqualToString:@"iPad2,4"]) return 264.0f; //@"iPad 2 (WiFi)"; - if ([platform isEqualToString:@"iPad2,5"]) return 163.0f; //@"iPad Mini (WiFi)"; - if ([platform isEqualToString:@"iPad2,6"]) return 163.0f; //@"iPad Mini (GSM)"; - if ([platform isEqualToString:@"iPad2,7"]) return 163.0f; //@"iPad Mini (GSM+CDMA)"; - if ([platform isEqualToString:@"iPad3,1"]) return 264.0f; //@"iPad 3 (WiFi)"; - if ([platform isEqualToString:@"iPad3,2"]) return 264.0f; //@"iPad 3 (GSM+CDMA)"; - if ([platform isEqualToString:@"iPad3,3"]) return 264.0f; //@"iPad 3 (GSM)"; - if ([platform isEqualToString:@"iPad3,4"]) return 264.0f; //@"iPad 4 (WiFi)"; - if ([platform isEqualToString:@"iPad3,5"]) return 264.0f; //@"iPad 4 (GSM)"; - if ([platform isEqualToString:@"iPad3,6"]) return 264.0f; //@"iPad 4 (GSM+CDMA)"; - if ([platform isEqualToString:@"iPad4,1"]) return 264.0f; //@"iPad Air (WiFi)"; - if ([platform isEqualToString:@"iPad4,2"]) return 264.0f; //@"iPad Air (Cellular)"; - if ([platform isEqualToString:@"iPad4,4"]) return 326.0f; //@"iPad mini 2G (WiFi)"; - if ([platform isEqualToString:@"iPad4,5"]) return 326.0f; //@"iPad mini 2G (Cellular)"; - if ([platform isEqualToString:@"i386"]) return 200.0f; //@"Simulator"; - if ([platform isEqualToString:@"x86_64"]) return 326.0f; //@"Simulator"; - return 326.0f; -} - -- (void)setNeedsDisplay { - EWOL_INFO("**** setNeedsDisplay:" << vec2(self.frame.size.width, self.frame.size.height)); - // TODO : SIZE change ... - -} -- (void)configureAspectRatio { - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - CGFloat screenScale = [[UIScreen mainScreen] scale]; - m_currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); - //self.frame.size = m_currentSize; - - EWOL_INFO("**** screen size:" << vec2(m_currentSize.width, m_currentSize.height)); - float ratio = [self getScreenPPP]; - EWOL_INFO("**** pixel ratio: " << ratio); - ewol::Dimension::setPixelRatio(vec2(1.0f/ratio, 1.0f/ratio), ewol::Dimension::Inch); - IOs::resize(m_currentSize.width, m_currentSize.height); - CGRect localBounds = [self bounds]; - EWOL_INFO("**** localBounds:" << vec2(localBounds.size.width, localBounds.size.height)); - -} -- (void)setupLayer { - _eaglLayer = (CAEAGLLayer*) self.layer; - CGFloat screenScale = [[UIScreen mainScreen] scale]; - _eaglLayer.contentsScale = screenScale; - _eaglLayer.opaque = YES; -} - -- (void)setupContext { - EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES2; - _context = [[EAGLContext alloc] initWithAPI:api]; - if (!_context) { - NSLog(@"Failed to initialize OpenGLES 2.0 context"); - exit(1); - } - if (![EAGLContext setCurrentContext:_context]) { - NSLog(@"Failed to set current OpenGL context"); - exit(1); - } -} - - -- (void)setupRenderBuffer { - glGenRenderbuffers(1, &_colorRenderBuffer); - glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer); - [_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:_eaglLayer]; -} - -- (void)setupDepthBuffer { - glGenRenderbuffers(1, &_depthRenderBuffer); - glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBuffer); - CGFloat screenScale = [[UIScreen mainScreen] scale]; - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, self.frame.size.width*screenScale, self.frame.size.height*screenScale); -} - -- (void)setupFrameBuffer { - GLuint framebuffer; - glGenFramebuffers(1, &framebuffer); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderBuffer); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBuffer); -} - -- (void)render:(CADisplayLink*)displayLink { - displayCounter++; - if (displayCounter >= deltaDisplay) { - displayCounter = 0; - IOs::draw(true); - [_context presentRenderbuffer:GL_RENDERBUFFER]; - } -} - -- (void)speedSlow { - deltaDisplay = 5; -} - -- (void)speedNormal { - deltaDisplay = 1; -} - -- (void)startDisplayLink { - if (displayLink != NULL) { - return; - } - displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render:)]; - [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; -} - -- (void)stopDisplayLink { - if (displayLink == NULL) { - return; - } - [displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - displayLink = NULL; -} - -- (id)initWithFrame:(CGRect)frame { - deltaDisplay = 1; - displayCounter = 0; - NSLog(@"INIT with size : %fx%f, %fx%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); - self = [super initWithFrame:frame]; - self.contentScaleFactor = 1.0f; - // TODO : Enable multi touch ==> but this generate many sub errors ... 3 touch can be appear in 1 event ... - //self.multipleTouchEnabled = YES; - if (self) { - [self configureAspectRatio]; - [self setupLayer]; - [self setupContext]; - [self setupDepthBuffer]; - [self setupRenderBuffer]; - [self setupFrameBuffer]; - [self startDisplayLink]; - } - return self; -} - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - UITouch *touch = [touches anyObject]; - CGPoint touchLocation = [touch locationInView:self]; - CGRect localBounds = [self bounds]; - CGFloat screenScale = [[UIScreen mainScreen] scale]; - vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); - EWOL_DEBUG(touches.count << " touchesBegan: " << positionEvent); - IOs::setInputState(1, true, positionEvent.x(), positionEvent.y()); -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - UITouch *touch = [touches anyObject]; - CGPoint touchLocation = [touch locationInView:self]; - CGRect localBounds = [self bounds]; - CGFloat screenScale = [[UIScreen mainScreen] scale]; - vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); - EWOL_DEBUG(touches.count << " touchesEnded: " << positionEvent); - IOs::setInputState(1, false, positionEvent.x(), positionEvent.y()); -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - UITouch *touch = [touches anyObject]; - CGPoint touchLocation = [touch locationInView:self]; - CGRect localBounds = [self bounds]; - CGFloat screenScale = [[UIScreen mainScreen] scale]; - vec2 positionEvent(touchLocation.x*screenScale, (localBounds.size.height - touchLocation.y)*screenScale); - EWOL_DEBUG(touches.count << " touchesMoved: " << positionEvent); - IOs::setInputMotion(1, positionEvent.x(), positionEvent.y()); -} - -- (void)layoutSubviews { - [EAGLContext setCurrentContext:_context]; -} - -- (void)dealloc { - if ([EAGLContext currentContext] == _context) { - [EAGLContext setCurrentContext:nil]; - } -} - - -@end diff --git a/ewol/context/InputManager.cpp b/ewol/context/InputManager.cpp index b3b9dda2..168a1e29 100644 --- a/ewol/context/InputManager.cpp +++ b/ewol/context/InputManager.cpp @@ -41,13 +41,13 @@ void ewol::context::InputManager::setDpi(int32_t newDPI) { calculateLimit(); } -bool ewol::context::InputManager::localEventInput(enum ewol::key::type _type, +bool ewol::context::InputManager::localEventInput(enum gale::key::type _type, std::shared_ptr _destWidget, int32_t _IdInput, - enum ewol::key::status _status, + enum gale::key::status _status, vec2 _pos) { if (nullptr != _destWidget) { - if (_type == ewol::key::typeMouse || _type == ewol::key::typeFinger) { + if (_type == gale::key::type_mouse || _type == gale::key::type_finger) { // create the system Event : ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, m_specialKey); // TODO : set the real ID ... // generate the event : @@ -61,7 +61,7 @@ bool ewol::context::InputManager::localEventInput(enum ewol::key::type _type, void ewol::context::InputManager::abortElement(InputPoperty *_eventTable, int32_t _idInput, - enum ewol::key::type _type) { + enum gale::key::type _type) { if (nullptr == _eventTable) { return; } @@ -69,7 +69,7 @@ void ewol::context::InputManager::abortElement(InputPoperty *_eventTable, localEventInput(_type, _eventTable[_idInput].curentWidgetEvent.lock(), _eventTable[_idInput].destinationInputId, - ewol::key::statusAbort, + gale::key::status_abort, _eventTable[_idInput].posEvent); } } @@ -104,23 +104,23 @@ void ewol::context::InputManager::transfertEvent(std::shared_ptr _ if (tmpWidget == _source) { // inform the widget that it does not receive the event now EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventInputSaved[iii].posEvent); - localEventInput(ewol::key::typeFinger, tmpWidget, m_eventInputSaved[iii].destinationInputId, ewol::key::statusAbort, m_eventInputSaved[iii].posEvent); + localEventInput(gale::key::type_finger, tmpWidget, m_eventInputSaved[iii].destinationInputId, gale::key::status_abort, m_eventInputSaved[iii].posEvent); // set the new widget ... m_eventInputSaved[iii].curentWidgetEvent = _destination; // inform the widget that he receive the event property now... EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventInputSaved[iii].posEvent); - localEventInput(ewol::key::typeFinger, _destination, m_eventInputSaved[iii].destinationInputId, ewol::key::statusTransfert, m_eventInputSaved[iii].posEvent); + localEventInput(gale::key::type_finger, _destination, m_eventInputSaved[iii].destinationInputId, gale::key::status_transfert, m_eventInputSaved[iii].posEvent); } tmpWidget = m_eventMouseSaved[iii].curentWidgetEvent.lock(); if (tmpWidget == _source) { // inform the widget that it does not receive the event now EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventMouseSaved[iii].posEvent); - localEventInput(ewol::key::typeMouse, tmpWidget, m_eventMouseSaved[iii].destinationInputId, ewol::key::statusAbort, m_eventMouseSaved[iii].posEvent); + localEventInput(gale::key::type_mouse, tmpWidget, m_eventMouseSaved[iii].destinationInputId, gale::key::status_abort, m_eventMouseSaved[iii].posEvent); // set the new widget ... m_eventMouseSaved[iii].curentWidgetEvent = _destination; // inform the widget that he receive the event property now... EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventMouseSaved[iii].posEvent); - localEventInput(ewol::key::typeMouse, _destination, m_eventMouseSaved[iii].destinationInputId, ewol::key::statusTransfert, m_eventMouseSaved[iii].posEvent); + localEventInput(gale::key::type_mouse, _destination, m_eventMouseSaved[iii].destinationInputId, gale::key::status_transfert, m_eventMouseSaved[iii].posEvent); } } } @@ -130,22 +130,24 @@ void ewol::context::InputManager::grabPointer(std::shared_ptr _wid return; } m_grabWidget = _widget; + /* TODO : m_context.grabPointerEvents(true, _widget->getOrigin() + ivec2(_widget->getSize().x()/2.0f, _widget->getSize().y()/2.0f) ); + */ } void ewol::context::InputManager::unGrabPointer() { m_grabWidget.reset(); - m_context.grabPointerEvents(false, vec2(0,0)); + // TODO: m_context.grabPointerEvents(false, vec2(0,0)); } void ewol::context::InputManager::newLayerSet() { for(int32_t iii=0; iii _destWidget, int32_t _realInputId) { - if (_type == ewol::key::typeFinger) { + if (_type == gale::key::type_finger) { int32_t lastMinimum = 0; for(int32_t iii=0; iii the it was finger event ... -void ewol::context::InputManager::motion(enum ewol::key::type _type, +void ewol::context::InputManager::motion(enum gale::key::type _type, int _pointerID, vec2 _pos) { EVENT_DEBUG("motion event : " << _type << " " << _pointerID << " " << _pos); @@ -198,9 +200,9 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, return; } InputPoperty *eventTable = nullptr; - if (_type == ewol::key::typeMouse) { + if (_type == gale::key::type_mouse) { eventTable = m_eventMouseSaved; - } else if (_type == ewol::key::typeFinger) { + } else if (_type == gale::key::type_finger) { eventTable = m_eventInputSaved; } else { EWOL_ERROR("Unknown type of event"); @@ -213,7 +215,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, } std::shared_ptr tmpWindows = m_context.getWindows(); // special case for the mouse event 0 that represent the hover event of the system : - if (_type == ewol::key::typeMouse && _pointerID == 0) { + if (_type == gale::key::type_mouse && _pointerID == 0) { // this event is all time on the good widget ... and manage the enter and leave ... // NOTE : the "layer widget" force us to get the widget at the specific position all the time : std::shared_ptr tmpWidget; @@ -237,7 +239,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - ewol::key::statusLeave, + gale::key::status_leave, _pos); } if (eventTable[_pointerID].isInside == false) { @@ -259,7 +261,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - ewol::key::statusEnter, + gale::key::status_enter, _pos); } EVENT_DEBUG("GUI : Input ID=" << _pointerID @@ -269,7 +271,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - ewol::key::statusMove, + gale::key::status_move, _pos); } else if (true == eventTable[_pointerID].isUsed) { if (true == eventTable[_pointerID].isInside) { @@ -285,7 +287,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - ewol::key::statusLeave, + gale::key::status_leave, _pos); } } else { @@ -301,7 +303,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - ewol::key::statusEnter, + gale::key::status_enter, _pos); } } @@ -312,12 +314,12 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type, localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - ewol::key::statusMove, + gale::key::status_move, _pos); } } -void ewol::context::InputManager::state(enum ewol::key::type _type, +void ewol::context::InputManager::state(enum gale::key::type _type, int _pointerID, bool _isDown, vec2 _pos) @@ -330,10 +332,10 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, // convert position in open-GL coordonates ... InputPoperty *eventTable = nullptr; InputLimit localLimit; - if (_type == ewol::key::typeMouse) { + if (_type == gale::key::type_mouse) { eventTable = m_eventMouseSaved; localLimit = m_eventMouseLimit; - } else if (_type == ewol::key::typeFinger) { + } else if (_type == gale::key::type_finger) { eventTable = m_eventInputSaved; localLimit = m_eventInputLimit; } else { @@ -373,7 +375,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, localEventInput(_type, eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].destinationInputId, - ewol::key::statusDown, + gale::key::status_down, _pos); } else { // Mark it used : @@ -388,7 +390,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, // get destination widget : if(nullptr != tmpWindows) { if ( tmpWidget != nullptr - && _type == ewol::key::typeMouse) { + && _type == gale::key::type_mouse) { eventTable[_pointerID].curentWidgetEvent = tmpWidget; } else { eventTable[_pointerID].curentWidgetEvent = tmpWindows->getWidgetAtPos(_pos); @@ -412,7 +414,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - ewol::key::statusDown, + gale::key::status_down, _pos); } } else { @@ -437,7 +439,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, localEventInput(_type, tmpWidget, _pointerID, - ewol::key::statusUp, + gale::key::status_up, _pos); // generate event (single) if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset @@ -455,7 +457,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, } // in grab mode the single to quinte event are not generated .... if( ( m_grabWidget.lock() == nullptr - || _type != ewol::key::typeMouse ) + || _type != gale::key::type_mouse ) && eventTable[_pointerID].nbClickEvent < nbClickMax) { // generate event SINGLE : eventTable[_pointerID].nbClickEvent++; @@ -466,7 +468,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, localEventInput(_type, tmpWidget, eventTable[_pointerID].destinationInputId, - (enum ewol::key::status)(ewol::key::statusSingle + eventTable[_pointerID].nbClickEvent-1), + (enum gale::key::status)(gale::key::status_single + eventTable[_pointerID].nbClickEvent-1), _pos); if( eventTable[_pointerID].nbClickEvent >= nbClickMax) { eventTable[_pointerID].nbClickEvent = 0; @@ -479,10 +481,10 @@ void ewol::context::InputManager::state(enum ewol::key::type _type, localEventInput(_type, tmpWidget, _pointerID, - ewol::key::statusUpAfter, + gale::key::status_upAfter, _pos); // specific for tuch event - if (_type == ewol::key::typeFinger) { + if (_type == gale::key::type_finger) { cleanElement(eventTable, _pointerID); } } diff --git a/ewol/context/InputManager.h b/ewol/context/InputManager.h index 2e9a09d6..ce561608 100644 --- a/ewol/context/InputManager.h +++ b/ewol/context/InputManager.h @@ -55,7 +55,7 @@ namespace ewol { void calculateLimit(); InputPoperty m_eventInputSaved[MAX_MANAGE_INPUT]; InputPoperty m_eventMouseSaved[MAX_MANAGE_INPUT]; - void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum ewol::key::type _type); + void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum gale::key::type _type); void cleanElement(InputPoperty* _eventTable, int32_t _idInput); /** * @brief generate the event on the destinated widget. @@ -66,10 +66,10 @@ namespace ewol { * @param[in] _pos position of the event * @return true if event has been greped */ - bool localEventInput(enum ewol::key::type _type, + bool localEventInput(enum gale::key::type _type, std::shared_ptr _destWidget, int32_t _IdInput, - enum ewol::key::status _typeEvent, + enum gale::key::status _typeEvent, vec2 _pos); /** * @brief convert the system event id in the correct EWOL id depending of the system management mode @@ -80,7 +80,7 @@ namespace ewol { * @param[in] _realInputId system Id * @return the ewol input id */ - int32_t localGetDestinationId(enum ewol::key::type _type, + int32_t localGetDestinationId(enum gale::key::type _type, std::shared_ptr _destWidget, int32_t _realInputId); private: @@ -91,8 +91,8 @@ namespace ewol { void setDpi(int32_t _newDPI); // note if id<0 == > the it was finger event ... - void motion(enum ewol::key::type _type, int _pointerID, vec2 _pos ); - void state(enum ewol::key::type _type, int _pointerID, bool _isDown, vec2 _pos); + void motion(enum gale::key::type _type, int _pointerID, vec2 _pos ); + void state(enum gale::key::type _type, int _pointerID, bool _isDown, vec2 _pos); public: /** * @brief a new layer on the windows is set == > might remove all the property of the current element ... @@ -114,9 +114,9 @@ namespace ewol { */ void unGrabPointer(); private: - ewol::key::Special m_specialKey; + gale::key::Special m_specialKey; public: - void setLastKeyboardSpecial(const ewol::key::Special& _specialKey) { + void setLastKeyboardSpecial(const gale::key::Special& _specialKey) { m_specialKey = _specialKey; } }; diff --git a/ewol/context/MacOs/AppDelegate.h b/ewol/context/MacOs/AppDelegate.h deleted file mode 100644 index 30bf4594..00000000 --- a/ewol/context/MacOs/AppDelegate.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import - -@interface MacOsAppDelegate : NSObject - -@property (assign) IBOutlet NSWindow *window; -- ()sendEvent:(NSEvent *)event; -- ()applicationWillResignActive:(MacOsAppDelegate *)application; -@end diff --git a/ewol/context/MacOs/AppDelegate.mm b/ewol/context/MacOs/AppDelegate.mm deleted file mode 100644 index b14a3b51..00000000 --- a/ewol/context/MacOs/AppDelegate.mm +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#import -#import - -#include - -@implementation MacOsAppDelegate -@synthesize window=_window; - -- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] bounds]]; - // Override point for customization after application launch. - [self.window addSubview:view]; - [self.window makeKeyAndVisible]; - return YES; -} - -- (void)applicationWillResignActive:(MacOsAppDelegate *)application { - /* - Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - */ - EWOL_INFO("move windows in applicationWillResignActive"); -} - -- (void)applicationDidEnterBackground:(MacOsAppDelegate *)application { - /* - Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - */ - EWOL_INFO("move windows in applicationDidEnterBackground"); -} - -- (void)applicationWillEnterForeground:(MacOsAppDelegate *)application { - /* - Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - */ - EWOL_INFO("move windows in applicationWillEnterForeground"); -} - -- (void)applicationDidBecomeActive:(MacOsAppDelegate *)application { - /* - Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - */ - EWOL_INFO("move windows in applicationDidBecomeActive"); -} - -- (void)applicationWillTerminate:(MacOsAppDelegate *)application { - /* - Called when the application is about to terminate. - Save data if appropriate. - See also applicationDidEnterBackground:. - */ - EWOL_INFO("move windows in applicationWillTerminate"); -} - -- (void)dealloc { - [_window release]; - [super dealloc]; -} - - -- (void)sendEvent:(NSEvent *)event { - EWOL_WARNING(" EVENT ... "); -} - - -@end - - - diff --git a/ewol/context/MacOs/Context.cpp b/ewol/context/MacOs/Context.cpp deleted file mode 100644 index e0385f36..00000000 --- a/ewol/context/MacOs/Context.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include - - -int64_t ewol::getTime() { - struct timespec now; - clock_serv_t cclock; - mach_timespec_t mts; - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - now.tv_sec = mts.tv_sec; - now.tv_nsec = mts.tv_nsec; - //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); - return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000); -} - -#undef __class__ -#define __class__ "MacOSInterface" - - - -class MacOSInterface : public ewol::Context { - private: - ewol::key::Special m_guiKeyBoardMode; - public: - MacOSInterface(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) : - ewol::Context(_application, _argc, _argv) { - mm_main(_argc, _argv); - } - - int32_t Run() { - return mm_run(); - } - public: - //interface MacOS : - - bool MAC_Draw(bool _displayEveryTime) { - return OS_Draw(_displayEveryTime); - } - void MAC_Resize(float _x, float _y) { - OS_Resize(vec2(_x,_y)); - } - void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y) { - OS_SetMouseState(_id, _isDown, vec2(_x, _y)); - } - void MAC_SetMouseMotion(int32_t _id, float _x, float _y) { - OS_SetMouseMotion(_id, vec2(_x, _y)); - } - void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { - if (_unichar == u32char::Delete) { - _unichar = u32char::Suppress; - } else if (_unichar == u32char::Suppress) { - _unichar = u32char::Delete; - } - if (_unichar == u32char::CarrierReturn) { - _unichar = u32char::Return; - } - //EWOL_DEBUG("key: " << _unichar << " up=" << !_isDown); - if (_unichar <= 4) { - enum ewol::key::keyboard move; - switch(_unichar) { - case 0: - move = ewol::key::keyboardUp; - break; - case 1: - move = ewol::key::keyboardDown; - break; - case 2: - move = ewol::key::keyboardLeft; - break; - case 3: - move = ewol::key::keyboardRight; - break; - } - OS_SetKeyboardMove(_keyboardMode, move, !_isDown, _isAReapeateKey); - } else { - OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey); - } - } - void MAC_SetKeyboardMove(ewol::key::Special& _special, - enum ewol::key::keyboard _move, - bool _isDown) { - OS_SetKeyboardMove(_special, _move, _isDown); - } - void openURL(const std::string& _url) { - std::string req = "open " + _url; - system(req.c_str()); - } -}; - - -MacOSInterface* interface = nullptr; - - - -bool MacOs::draw(bool _displayEveryTime) { - if (interface == nullptr) { - return false; - } - return interface->MAC_Draw(_displayEveryTime); -} - -void MacOs::resize(float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_Resize(_x, _y); -} - - -void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_SetMouseState(_id, _isDown, _x, _y); -} - -void MacOs::setMouseMotion(int32_t _id, float _x, float _y) { - if (interface == nullptr) { - return; - } - interface->MAC_SetMouseMotion(_id, _x, _y); -} - -void MacOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) { - if (interface == nullptr) { - return; - } - interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey); -} - -void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) { - if (interface == nullptr) { - return; - } - interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown); -} - - -/** - * @brief Main of the program - * @param std IO - * @return std IO - */ -int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) { - etk::init(_argc, _argv); - interface = new MacOSInterface(_application, _argc, _argv); - if (nullptr == interface) { - EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error"); - return -2; - } - - int32_t retValue = interface->Run(); - delete(interface); - interface = nullptr; - return retValue; -} - - - - - - - diff --git a/ewol/context/MacOs/Context.h b/ewol/context/MacOs/Context.h deleted file mode 100644 index 979f22a7..00000000 --- a/ewol/context/MacOs/Context.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __MAC_OS_CONTEXT_H__ -#define __MAC_OS_CONTEXT_H__ - -#include - -namespace MacOs { - // return true if a flush is needed - bool draw(bool _displayEveryTime); - /** - * @brief The OS inform that the current windows has change his size. - * @param[in] _size new size of the windows. - */ - void resize(float _x, float _y); - void setMouseState(int32_t _id, bool _isDown, float _x, float _y); - void setMouseMotion(int32_t _id, float _x, float _y); - void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey); - void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown); -}; - -#endif \ No newline at end of file diff --git a/ewol/context/MacOs/Interface.h b/ewol/context/MacOs/Interface.h deleted file mode 100644 index 3a412b21..00000000 --- a/ewol/context/MacOs/Interface.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_MM_INTERFACE_H__ -#define __EWOL_MM_INTERFACE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -int mm_main(int argc, const char *argv[]); -int mm_run(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ewol/context/MacOs/Interface.mm b/ewol/context/MacOs/Interface.mm deleted file mode 100644 index 5f0e855d..00000000 --- a/ewol/context/MacOs/Interface.mm +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import -#include "ewol/context/MacOs/Interface.h" - -#import -#import -#import - - - -int mm_main(int argc, const char *argv[]) { - [NSAutoreleasePool new]; - - [NSApplication sharedApplication]; - // set the quit policy and all stadard for Mac - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - - // --------------------------------------------------------------- - // -- basic menu bar creation : - // --------------------------------------------------------------- - // set the basic menu bar (stadard on Mac OSX) - id menubar = [[NSMenu new] autorelease]; - //add an item - id appMenuItem = [[NSMenuItem new] autorelease]; - // add the item to the menu bar: - [menubar addItem:appMenuItem]; - // set the main menu in the menu bar ... - [NSApp setMainMenu:menubar]; - - id appMenu = [[NSMenu new] autorelease]; - id appName = [[NSProcessInfo processInfo] processName]; - // create the label to qui the application : - id quitTitle = [@"Quit " stringByAppendingString:appName]; - // create the item to quit the appllication with META+q at shortCut - id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle - action:@selector(terminate:) keyEquivalent:@"q"] autorelease]; - // add the item to the menu: - [appMenu addItem:quitMenuItem]; - // set the application menu to the main app menu ... - [appMenuItem setSubmenu:appMenu]; - - // --------------------------------------------------------------- - // -- basic windows creation : - // ----------------------- ---------------------------------------- - // create a windows of size 800/600 -#if 1 - id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) - styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO] - autorelease]; - [window setAcceptsMouseMovedEvents:YES]; - //id window = [ [MacOsAppDelegate alloc] autorelease]; - - // set the windows at a specific position : - [window cascadeTopLeftFromPoint:NSMakePoint(50,50)]; - // set the windows resizable - [window setStyleMask:[window styleMask] | NSResizableWindowMask]; - // oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask]; - // set the title - [window setTitle:appName]; - - [window setAcceptsMouseMovedEvents:YES]; - // ??? - [window makeKeyAndOrderFront:nil]; - [NSApp activateIgnoringOtherApps:YES]; - - NSRect window_frame = [window frame]; - - OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)]; - NSTrackingArea *track = [[NSTrackingArea alloc] initWithRect:window_frame options: NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder | NSTrackingActiveInKeyWindow - owner:window userInfo:nil]; - [view addTrackingArea:track]; - [window setContentView:view]; - [view setAutoresizesSubviews:YES]; - - // Override point for customization after application launch. - //[window addSubview:view]; - //[window addChildWindow:view]; - //[window makeKeyAndVisible]; - - //[window setDelegate:view]; -#else - @autoreleasepool - { - const ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - SetFrontProcess(&psn); - - [MyApplication sharedApplication]; - [NSApp setDelegate: NSApp]; - - [NSApp run]; - } -#endif - // return no error - return 0; -} - -int mm_run(void) { - [NSApp run]; - // return no error - return 0; -} diff --git a/ewol/context/MacOs/OpenglView.h b/ewol/context/MacOs/OpenglView.h deleted file mode 100644 index 0b6282e1..00000000 --- a/ewol/context/MacOs/OpenglView.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import -#import -#import - - -@interface OpenGLView : NSOpenGLView { - NSTimer* _refreshTimer; -} -- ()prepareOpenGL; -- ()drawRect:(NSRect) bounds; -- ()mouseDown:(NSEvent *) event; -- ()mouseDragged:(NSEvent *) event; -- ()mouseUp:(NSEvent *)event; -- ()mouseMoved:(NSEvent *)event; -- ()mouseEntered:(NSEvent *)event; -- ()mouseExited:(NSEvent *)event; -- ()rightMouseDown:(NSEvent *)event; -- ()rightMouseDragged:(NSEvent *)event; -- ()rightMouseUp:(NSEvent *)event; -- ()otherMouseDown:(NSEvent *)event; -- ()otherMouseDragged:(NSEvent *)event; -- ()otherMouseUp:(NSEvent *)event; -//- ()sendEvent:(NSEvent *)event -- ()keyDown:(NSEvent *)theEvent; -- ()flagsChanged:(NSEvent *)theEvent; -@end diff --git a/ewol/context/MacOs/OpenglView.mm b/ewol/context/MacOs/OpenglView.mm deleted file mode 100644 index 6389cd78..00000000 --- a/ewol/context/MacOs/OpenglView.mm +++ /dev/null @@ -1,379 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#import -#include -#include -#include -#include - - -@implementation OpenGLView - -static ewol::key::Special guiKeyBoardMode; - -- (void) prepareOpenGL -{ - EWOL_ERROR("prepare"); - GLint swapInt = 1; - [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync - // set system dpi size : - NSScreen *screen = [NSScreen mainScreen]; - NSDictionary *description = [screen deviceDescription]; - NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; - CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); - - ewol::Dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width, - (float)displayPixelSize.height/(float)displayPhysicalSize.height), - ewol::Dimension::Millimeter); - _refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ; - -} - --(void) drawRect: (NSRect) bounds { - if ( ! _refreshTimer ) { - _refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ; - } - MacOs::draw(true); - glFlush(); -} - -/** - * Service the animation timer. - */ -- (void) animationTimerFired: (NSTimer *) timer { - [ self setNeedsDisplay: YES ]; - //EWOL_INFO("view refresh ..." ); -} - --(void)reshape { - EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" ); - - // window resize; width and height are in pixel coordinates - // but they are floats - float width = [self frame].size.width; - float height = [self frame].size.height; - MacOs::resize(width,height); -} - --(void)mouseDown:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //float x = [event locationInWindow].x; //point.x; - //EWOL_INFO("mouseDown : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseState(1, true, point.x, point.y); -} --(void)mouseDragged:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //EWOL_INFO("mouseDragged : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseMotion(1, point.x, point.y); -} --(void)mouseUp:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //EWOL_INFO("mouseUp : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseState(1, false, point.x, point.y); -} --(void)mouseMoved:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseMotion(0, point.x, point.y); -} --(void)mouseEntered:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("mouseEntered : " << (float)point.x << " " << (float)point.y); -} --(void)mouseExited:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y); -} --(void)rightMouseDown:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //EWOL_INFO("rightMouseDown : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseState(3, true, point.x, point.y); -} --(void)rightMouseDragged:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //EWOL_INFO("rightMouseDragged : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseMotion(3, point.x, point.y); -} --(void)rightMouseUp:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //EWOL_INFO("rightMouseUp : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseState(3, false, point.x, point.y); -} --(void)otherMouseDown:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - int32_t btNumber = [event buttonNumber]; - switch (btNumber) { - case 2: // 2 : Middle button - btNumber = 2; - break; - case 3: // 3 : border button DOWN - btNumber = 8; - break; - case 4: // 4 : border button UP - btNumber = 9; - break; - case 5: // 5 : horizontal scroll Right to left - btNumber = 11; - break; - case 6: // 6 : horizontal scroll left to Right - btNumber = 10; - break; - case 7: // 7 : Red button - btNumber = 12; - break; - default: - btNumber = 15; - break; - } - //EWOL_INFO("otherMouseDown : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseState(btNumber, true, point.x, point.y); -} --(void)otherMouseDragged:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - int32_t btNumber = [event buttonNumber]; - switch (btNumber) { - case 2: // 2 : Middle button - btNumber = 2; - break; - case 3: // 3 : border button DOWN - btNumber = 8; - break; - case 4: // 4 : border button UP - btNumber = 9; - break; - case 5: // 5 : horizontal scroll Right to left - btNumber = 11; - break; - case 6: // 6 : horizontal scroll left to Right - btNumber = 10; - break; - case 7: // 7 : Red button - btNumber = 12; - break; - default: - btNumber = 15; - break; - } - //EWOL_INFO("otherMouseDragged : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseMotion(btNumber, point.x, point.y); -} --(void)otherMouseUp:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - int32_t btNumber = [event buttonNumber]; - switch (btNumber) { - case 2: // 2 : Middle button - btNumber = 2; - break; - case 3: // 3 : border button DOWN - btNumber = 8; - break; - case 4: // 4 : border button UP - btNumber = 9; - break; - case 5: // 5 : horizontal scroll Right to left - btNumber = 11; - break; - case 6: // 6 : horizontal scroll left to Right - btNumber = 10; - break; - case 7: // 7 : Red button - btNumber = 12; - break; - default: - btNumber = 15; - break; - } - //EWOL_INFO("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber ); - MacOs::setMouseState(btNumber, false, point.x, point.y); -} -- (void)scrollWheel:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - //EWOL_INFO("scrollWheel : " << (float)point.x << " " << (float)point.y << "button : " << (int32_t)([event buttonNumber])); - EWOL_INFO("scrollWheel : " << (float)point.x << " " << (float)point.y << " delta(" << (float)([event deltaX]) << "," << (float)([event deltaY]) << ")"); - float deltaY = [event deltaY]; - int32_t idEvent = 4; - if (deltaY < 0) { - idEvent = 5; - } - if (abs(deltaY) < 0.1f) { - return; - } - for (float iii=abs(deltaY) ; iii>=0.0f ; iii-=1.0f) { - MacOs::setMouseState(idEvent, true , point.x, point.y); - MacOs::setMouseState(idEvent, false, point.x, point.y); - } -} -/* -// https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html -// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html --(void)sendEvent:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("sendEvent : " << (float)point.x << " " << (float)point.y); -} -*/ -/* -// this generate all the event entry availlable ==> like a big keep focus ... -- (BOOL)acceptsFirstResponder { - return YES; -} -- (BOOL)becomeFirstResponder { - return YES; -} -*/ -- (void)keyDown:(NSEvent *)theEvent { - bool thisIsAReapeateKey = false; - if ([theEvent isARepeat]) { - thisIsAReapeateKey = true; - } - NSString *str = [theEvent charactersIgnoringModifiers]; - // TODO : set if for every char in the string !!! - unichar c = [str characterAtIndex:0]; - //EWOL_DEBUG("KeyDown " << (char)c); - MacOs::setKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey); - if (true==thisIsAReapeateKey) { - MacOs::setKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey); - } -} - -- (void)keyUp:(NSEvent *)theEvent { - bool thisIsAReapeateKey = false; - if ([theEvent isARepeat]) { - thisIsAReapeateKey = true; - } - //EWOL_DEBUG("KeyUp "); - NSString *str = [theEvent charactersIgnoringModifiers]; - unichar c = [str characterAtIndex:0]; - MacOs::setKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey); - if (true==thisIsAReapeateKey) { - MacOs::setKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey); - } -} - -- (void)flagsChanged:(NSEvent *)theEvent { - if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) { - EWOL_DEBUG("NSAlphaShiftKeyMask"); - if (guiKeyBoardMode.getCapsLock() == false) { - guiKeyBoardMode.setCapsLock(true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, true); - } - } else { - if (guiKeyBoardMode.getCapsLock() == true) { - guiKeyBoardMode.setCapsLock(false); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, false); - } - } - - if (([theEvent modifierFlags] & NSShiftKeyMask) != 0) { - EWOL_DEBUG("NSShiftKeyMask"); - if (guiKeyBoardMode.getShift() == false) { - guiKeyBoardMode.setShift(true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, true); - } - } else { - if (guiKeyBoardMode.getShift() == true) { - guiKeyBoardMode.setShift(false); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, false); - } - } - - if (([theEvent modifierFlags] & NSControlKeyMask) != 0) { - EWOL_DEBUG("NSControlKeyMask"); - if (guiKeyBoardMode.getCtrl() == false) { - guiKeyBoardMode.setCtrl(true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, true); - } - } else { - if (guiKeyBoardMode.getCtrl() == true) { - guiKeyBoardMode.setCtrl(false); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, false); - } - } - - if (([theEvent modifierFlags] & NSAlternateKeyMask) != 0) { - EWOL_DEBUG("NSAlternateKeyMask"); - if (guiKeyBoardMode.getAlt() == false) { - guiKeyBoardMode.setAlt(true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, true); - } - } else { - if (guiKeyBoardMode.getAlt() == true) { - guiKeyBoardMode.setAlt(false); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, false); - } - } - - if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) { - EWOL_DEBUG("NSCommandKeyMask"); - if (guiKeyBoardMode.getMeta() == false) { - guiKeyBoardMode.setMeta(true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, true); - } - } else { - if (guiKeyBoardMode.getMeta() == true) { - guiKeyBoardMode.setMeta(false); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, false); - } - } - - if (([theEvent modifierFlags] & NSNumericPadKeyMask) != 0) { - EWOL_DEBUG("NSNumericPadKeyMask"); - if (guiKeyBoardMode.getNumLock() == false) { - guiKeyBoardMode.setNumLock(true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, true); - } - } else { - if (guiKeyBoardMode.getNumLock() == true) { - guiKeyBoardMode.setNumLock(false); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, false); - } - } - if (([theEvent modifierFlags] & NSHelpKeyMask) != 0) { - EWOL_DEBUG("NSHelpKeyMask"); - } - if (([theEvent modifierFlags] & NSFunctionKeyMask) != 0) { - EWOL_DEBUG("NSFunctionKeyMask"); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, true); - MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, false); - } -} - -#define FRAME_INTERVAL (0.01) - -static NSTimer *timer = nil; - -- (void)windowDidResignMain:(NSNotification *)notification { -// NSLog(@"window did resign main"); - [timer invalidate]; - - //game_deactivate(); // freeze, pause -} - -- (void)windowDidBecomeMain:(NSNotification *)notification { -// NSLog(@"window did become main"); - - //game_activate(); - /* - timer = [NSTimer timerWithTimeInterval:FRAME_INTERVAL - target:self - selector:@selector(timerEvent:) - userInfo:nil - repeats:YES]; - - [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode]; - */ -} - -- (void)timerEvent:(NSTimer *)t { - //run_game(); -} - - -@end - diff --git a/ewol/context/MacOs/Windows.h b/ewol/context/MacOs/Windows.h deleted file mode 100644 index 43f9340f..00000000 --- a/ewol/context/MacOs/Windows.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#import - -@interface EwolMainWindows : NSWindow { - -} -+ (id)alloc; -- (id)init; -+ (void)dealloc; -@end - - -@interface MyApplication : NSApplication - -@property (strong, nonatomic) NSWindow *window; - -@end \ No newline at end of file diff --git a/ewol/context/MacOs/Windows.mm b/ewol/context/MacOs/Windows.mm deleted file mode 100644 index 0fb8a7a5..00000000 --- a/ewol/context/MacOs/Windows.mm +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#import -#import -#include - -#include - -@implementation EwolMainWindows - -+ (id)alloc { - id windowsID = [super alloc]; - EWOL_DEBUG("ALLOCATE ..."); - return windowsID; -} - -- (id)init { - id windowsID = [super init]; - EWOL_DEBUG("INIT ..."); - // set the windows at a specific position : - [windowsID cascadeTopLeftFromPoint:NSMakePoint(50,50)]; - EWOL_DEBUG("ALLOCATE ..."); - // set the windows resizable - [windowsID setStyleMask:[windowsID styleMask] | NSResizableWindowMask]; - EWOL_DEBUG("ALLOCATE ..."); - // oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask]; - // set the title - id appName = [[NSProcessInfo processInfo] processName]; - EWOL_DEBUG("ALLOCATE ..."); - [windowsID setTitle:appName]; - EWOL_DEBUG("ALLOCATE ..."); - - [windowsID setAcceptsMouseMovedEvents:YES]; - EWOL_DEBUG("ALLOCATE ..."); - // ??? - [windowsID makeKeyAndOrderFront:nil]; - EWOL_DEBUG("ALLOCATE ..."); - [NSApp activateIgnoringOtherApps:YES]; - EWOL_DEBUG("ALLOCATE ..."); - - NSRect window_frame = [windowsID frame]; - EWOL_DEBUG("ALLOCATE ..."); - - OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)]; - EWOL_DEBUG("ALLOCATE ..."); - [windowsID setContentView:view]; - EWOL_DEBUG("ALLOCATE ..."); - [view setAutoresizesSubviews:YES]; - EWOL_DEBUG("ALLOCATE ..."); - - // Override point for customization after application launch. - //[window addSubview:view]; - //[window addChildWindow:view]; - //[window makeKeyAndVisible]; - - //[windowsID setDelegate:view]; - EWOL_DEBUG("ALLOCATE ..."); - return windowsID; -} - - -+ (void)dealloc { - EWOL_DEBUG("FREE ..."); - //[_window release]; - [super dealloc]; -} - -/* -- (void)sendEvent:(NSEvent *)event { - EWOL_WARNING(" EVENT ... "); -} -*/ - - -// this generate all the event entry availlable ==> like a big keep focus ... -- (BOOL)acceptsFirstResponder { - return YES; -} -- (BOOL)becomeFirstResponder { - return YES; -} - --(void)mouseMoved:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y); - MacOs::setMouseMotion(0, point.x, point.y); -} --(void)mouseEntered:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("mouseEntered : " << (float)point.x << " " << (float)point.y); -} --(void)mouseExited:(NSEvent *)event { - NSPoint point = [event locationInWindow]; - EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y); -} - - - - -@end - - - - -@implementation MyApplication - -- (void) applicationDidFinishLaunching: (NSNotification *) note -{ - NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 100, 100) - styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES]; - - self.window = window; - - [window close]; - - [super stop: self]; -} - -@end - - diff --git a/ewol/context/Windows/Context.cpp b/ewol/context/Windows/Context.cpp deleted file mode 100644 index 75798f46..00000000 --- a/ewol/context/Windows/Context.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - - - -int64_t ewol::getTime() { - struct timeval now; - gettimeofday(&now, nullptr); - //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); - return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec); -} - - -#undef __class__ -#define __class__ "ContextWindows" - - -class WindowsContext : public ewol::Context { - private: - int32_t m_currentHeight = 0; - bool m_inputIsPressed[MAX_MANAGE_INPUT]; - ewol::key::Special m_guiKeyBoardMode; - bool m_run = true; - bool m_clipBoardOwnerStd = false; - public: - WindowsContext(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) : - ewol::Context(_application, _argc, _argv) { - for (int32_t iii=0; iiiWndProcReal(_hWnd, _message, _wParam, _lParam); - return 0; - } - - LRESULT CALLBACK WndProcReal(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam) { - bool buttonIsDown = true; - int32_t mouseButtonId = 0; - ivec2 pos; - // to know all _message : http://wiki.winehq.org/List_Of_Windows__messages - switch (_message) { - /* ************************************************************************** - * Gui event - * **************************************************************************/ - case WM_CREATE: - EWOL_DEBUG("WM_CREATE"); - return 0; - case WM_CLOSE: - EWOL_DEBUG("WM_CLOSE"); - PostQuitMessage( 0 ); - return 0; - case WM_DESTROY: - EWOL_DEBUG("WM_DESTROY"); - return 0; - case WM_MOVE: - EWOL_DEBUG("WM_MOVE"); - return 0; - case WM_SIZE: - EWOL_DEBUG("WM_SIZE"); - return 0; - /* - case WM_GETMINMAXINFO: - { - MINMAXINFO* tmpVal = (MINMAXINFO*)lParam; - EWOL_DEBUG("WM_GETMINMAXINFO : "); - EWOL_DEBUG(" ptMaxSize : " << tmpVal->ptMaxSize.x << "," << tmpVal->ptMaxSize.y << ")"); - EWOL_DEBUG(" ptMaxPosition : " << tmpVal->ptMaxPosition.x << "," << tmpVal->ptMaxPosition.y << ")"); - EWOL_DEBUG(" ptMinTrackSize : " << tmpVal->ptMinTrackSize.x << "," << tmpVal->ptMinTrackSize.y << ")"); - EWOL_DEBUG(" ptMaxTrackSize : " << tmpVal->ptMaxTrackSize.x << "," << tmpVal->ptMaxTrackSize.y << ")"); - } - return 0; - */ - case WM_WINDOWPOSCHANGING: { - WINDOWPOS* tmpVal = (WINDOWPOS*)_lParam; - if (nullptr != tmpVal) { - //EWOL_DEBUG("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")"); - // in windows system, we need to remove the size of the border elements : - int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); - int title_size = GetSystemMetrics(SM_CYCAPTION); - m_currentHeight = tmpVal->cy - 2*border_thickness - title_size; - OS_Resize(vec2(tmpVal->cx-2*border_thickness, m_currentHeight)); - } - return 0; - } - // these message are not parse by us ... - case WM_SETCURSOR: // Call the windows if we want the mouse event : - case WM_NCHITTEST: // inform the application the position of the mouse is moving - return DefWindowProc( _hWnd, _message, _wParam, _lParam ); - - /* ************************************************************************** - * Keyboard management - * **************************************************************************/ - case WM_KEYUP: - buttonIsDown = false; - case WM_KEYDOWN: { - char32_t tmpChar = 0; - enum ewol::key::keyboard keyInput; - switch (_wParam) { - //case 80: // keypad - case VK_UP: keyInput = ewol::key::keyboardUp; break; - //case 83: // keypad - case VK_LEFT: keyInput = ewol::key::keyboardLeft; break; - //case 85: // keypad - case VK_RIGHT: keyInput = ewol::key::keyboardRight; break; - //case 88: // keypad - case VK_DOWN: keyInput = ewol::key::keyboardDown; break; - //case 81: // keypad - case VK_PRIOR: keyInput = ewol::key::keyboardPageUp; break; - //case 89: // keypad - case VK_NEXT: keyInput = ewol::key::keyboardPageDown; break; - //case 79: // keypad - case VK_HOME: keyInput = ewol::key::keyboardStart; break; - //case 87: // keypad - case VK_END: keyInput = ewol::key::keyboardEnd; break; - //case VK_: keyInput = ewol::key::keyboardStopDefil; break; - case VK_PAUSE: keyInput = ewol::key::keyboardWait; break; - //case 90: // keypad - case VK_INSERT: - keyInput = ewol::key::keyboardInsert; - m_guiKeyBoardMode.setInsert(buttonIsDown); - break; - case VK_F1: keyInput = ewol::key::keyboardF1; break; - case VK_F2: keyInput = ewol::key::keyboardF2; break; - case VK_F3: keyInput = ewol::key::keyboardF3; break; - case VK_F4: keyInput = ewol::key::keyboardF4; break; - case VK_F5: keyInput = ewol::key::keyboardF5; break; - case VK_F6: keyInput = ewol::key::keyboardF6; break; - case VK_F7: keyInput = ewol::key::keyboardF7; break; - case VK_F8: keyInput = ewol::key::keyboardF8; break; - case VK_F9: keyInput = ewol::key::keyboardF9; break; - case VK_F10: keyInput = ewol::key::keyboardF10; break; - case VK_F11: keyInput = ewol::key::keyboardF11; break; - case VK_F12: - case VK_F13: - case VK_F14: - case VK_F15: - case VK_F16: - case VK_F17: - case VK_F18: - case VK_F19: - case VK_F20: - case VK_F21: - case VK_F22: - case VK_F23: - case VK_F24: keyInput = ewol::key::keyboardF12; break; - case VK_CAPITAL: - keyInput = ewol::key::keyboardCapLock; - m_guiKeyBoardMode.setCapsLock(buttonIsDown); - break; - case VK_SHIFT: - case VK_LSHIFT: - keyInput = ewol::key::keyboardShiftLeft; - m_guiKeyBoardMode.setShift(buttonIsDown); - break; - case VK_RSHIFT: - keyInput = ewol::key::keyboardShiftRight; - m_guiKeyBoardMode.setShift(buttonIsDown); - break; - case VK_CONTROL: - case VK_LCONTROL: - keyInput = ewol::key::keyboardCtrlLeft; - m_guiKeyBoardMode.setCtrl(buttonIsDown); - break; - case VK_RCONTROL: - keyInput = ewol::key::keyboardCtrlRight; - m_guiKeyBoardMode.setCtrl(buttonIsDown); - break; - case VK_LWIN: - keyInput = ewol::key::keyboardMetaLeft; - m_guiKeyBoardMode.setMeta(buttonIsDown); - break; - case VK_RWIN: - keyInput = ewol::key::keyboardMetaRight; - m_guiKeyBoardMode.setMeta(buttonIsDown); - break; - case VK_MENU: - case VK_LMENU: - keyInput = ewol::key::keyboardAlt; - m_guiKeyBoardMode.setAlt(buttonIsDown); - break; - case VK_RMENU: - keyInput = ewol::key::keyboardAltGr; - m_guiKeyBoardMode.setAltGr(buttonIsDown); - break; - //case : keyInput = ewol::key::keyboardContextMenu; break; - case VK_NUMLOCK: - keyInput = ewol::key::keyboardNumLock; - m_guiKeyBoardMode.setNumLock(buttonIsDown); - break; - case VK_BACK: // DEL - tmpChar = 0x08; - break; - // TODO : Really strang, need to understand why ... - case 46: // Suppr - tmpChar = 0x7F; - break; - case VK_TAB: // special case for TAB - tmpChar = 0x09; - break; - case VK_RETURN: // special case for TAB - tmpChar = '\n'; - break; - default: - { - BYTE kbd[256]; - GetKeyboardState(kbd); - const int BUFFER_LENGTH = 8; //Length of the buffer - WCHAR chars[BUFFER_LENGTH]; - - ToUnicode(_wParam, _lParam, kbd, chars,BUFFER_LENGTH,0); - tmpChar = utf8::convertChar32((char*)chars); - } - break; - } - EWOL_DEBUG("kjhkjhkjhkjhkj = " << _wParam); - if (tmpChar == 0) { - //EWOL_DEBUG("eventKey Move type : " << getCharTypeMoveEvent(keyInput) ); - OS_SetKeyboardMove(m_guiKeyBoardMode, keyInput, buttonIsDown); - } else { - OS_SetKeyboard(m_guiKeyBoardMode, tmpChar, buttonIsDown); - } - return 0; - } - /* ************************************************************************** - * Mouse management - * **************************************************************************/ - case WM_LBUTTONUP: - buttonIsDown = false; - case WM_LBUTTONDOWN: - mouseButtonId = 1; - pos.setValue(GET_X_LPARAM(_lParam), - m_currentHeight-GET_Y_LPARAM(_lParam)); - m_inputIsPressed[mouseButtonId] = buttonIsDown; - OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y())); - return 0; - - case WM_MBUTTONUP: - buttonIsDown = false; - case WM_MBUTTONDOWN: - mouseButtonId = 2; - pos.setValue(GET_X_LPARAM(_lParam), - m_currentHeight-GET_Y_LPARAM(_lParam)); - m_inputIsPressed[mouseButtonId] = buttonIsDown; - OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y())); - return 0; - - case WM_RBUTTONUP: - buttonIsDown = false; - case WM_RBUTTONDOWN: - mouseButtonId = 3; - pos.setValue(GET_X_LPARAM(_lParam), - m_currentHeight-GET_Y_LPARAM(_lParam)); - m_inputIsPressed[mouseButtonId] = buttonIsDown; - OS_SetMouseState(mouseButtonId, buttonIsDown, vec2(pos.x(),pos.y())); - return 0; - - case WM_MOUSEWHEEL: - if (_wParam & 0x200000) { - EWOL_DEBUG("event SCROOL UP"); - mouseButtonId = 4; - } else { - EWOL_DEBUG("event SCROOL DOWN"); - mouseButtonId = 5; - } - pos.setValue(GET_X_LPARAM(_lParam), - m_currentHeight-GET_Y_LPARAM(_lParam)); - OS_SetMouseState(mouseButtonId, true, vec2(pos.x(),pos.y())); - OS_SetMouseState(mouseButtonId, false, vec2(pos.x(),pos.y())); - return 0; - - case WM_MOUSEHOVER: - case WM_MOUSEMOVE: - pos.setValue(GET_X_LPARAM(_lParam), - m_currentHeight-GET_Y_LPARAM(_lParam)); - for (int32_t iii=0; iiirun(); - delete(localInterface); - localInterface = nullptr; - return retValue; -} - diff --git a/ewol/context/X11/Context.cpp b/ewol/context/X11/Context.cpp deleted file mode 100644 index 54d306de..00000000 --- a/ewol/context/X11/Context.cpp +++ /dev/null @@ -1,1337 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#if defined(__TARGET_OS__Linux) -#include -#elif defined(__TARGET_OS__MacOs) -#include -#endif - -#include -#include - -/* -#define GUI_LOCK() XLockDisplay(m_display) -#define GUI_UNLOCK() XUnlockDisplay(m_display) -*/ -bool hasDisplay = false; -//#define DEBUG_X11_EVENT -#ifdef DEBUG_X11_EVENT - #define X11_DEBUG EWOL_DEBUG - #define X11_VERBOSE EWOL_VERBOSE - #define X11_INFO EWOL_INFO - #define X11_CRITICAL EWOL_CRITICAL -#else - #define X11_DEBUG EWOL_VERBOSE - #define X11_VERBOSE EWOL_VERBOSE - #define X11_INFO EWOL_VERBOSE - #define X11_CRITICAL EWOL_VERBOSE -#endif - -int64_t ewol::getTime() { - struct timespec now; - int ret = clock_gettime(CLOCK_REALTIME, &now); - if (ret != 0) { - // Error to get the time ... - now.tv_sec = time(nullptr); - now.tv_nsec = 0; - } - //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); - return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000); -} - -// attributes for a single buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer -static int attrListSgl[] = { - GLX_RGBA, - GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, - GLX_BLUE_SIZE, 4, - GLX_DEPTH_SIZE, 16, - None -}; - -// attributes for a double buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer -static int attrListDbl[] = { - GLX_RGBA, - GLX_DOUBLEBUFFER, - GLX_RED_SIZE, 4, - GLX_GREEN_SIZE, 4, - GLX_BLUE_SIZE, 4, - GLX_DEPTH_SIZE, 16, - None -}; - -extern "C" { - typedef struct Hints { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long inputMode; - unsigned long status; - } Hints; -} - -#include - -#include - -#undef __class__ -#define __class__ "x11Interface" - -class X11Interface : public ewol::Context { - private: - ewol::key::Special m_guiKeyBoardMode; - // for double and triple click selection, we need to save the previous click up and down position , and the previous time ... - Atom m_delAtom; - Display* m_display; - Window m_WindowHandle; - XIM m_xim; - XIC m_xic; - int32_t m_originX; - int32_t m_originY; - int32_t m_cursorEventX; - int32_t m_cursorEventY; - int32_t m_currentHeight; - int32_t m_currentWidth; - XVisualInfo* m_visual; - bool m_doubleBuffered; - bool m_run; - //forcing the position - bool m_grabAllEvent; //!< grab mode enable... - vec2 m_forcePos; //!< position to reset the cursor - bool m_positionChangeRequested; //!< the position modifiquation has been requested - vec2 m_curentGrabDelta; //!< the position in X11 will arrive by pool - bool m_inputIsPressed[MAX_MANAGE_INPUT]; - // internal copy of the clipBoard ... - bool m_clipBoardRequestPrimary; //!< if false : request the copy/past buffer, if true : request current selection - bool m_clipBoardOwnerPrimary; //!< we are the owner of the current selection - bool m_clipBoardOwnerStd; //!< we are the owner of the current copy buffer - // Atom access... - Atom XAtomeSelection; - Atom XAtomeClipBoard; - Atom XAtomeTargetString; - Atom XAtomeTargetStringUTF8; - Atom XAtomeTargetTarget; - Atom XAtomeEWOL; - Atom XAtomeDeleteWindows; - enum ewol::context::cursorDisplay m_currentCursor; //!< select the current cursor to display : - char32_t m_lastKeyPressed; //!< The last element key presed... - public: - X11Interface(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) : - ewol::Context(_application, _argc, _argv), - m_display(nullptr), - m_originX(0), - m_originY(0), - m_cursorEventX(0), - m_cursorEventY(0), - m_currentHeight(0), - m_currentWidth(0), - m_visual(nullptr), - m_doubleBuffered(0), - m_run(false), - m_grabAllEvent(false), - m_forcePos(0,0), - m_positionChangeRequested(false), - m_curentGrabDelta(0,0), - m_clipBoardRequestPrimary(false), - m_clipBoardOwnerPrimary(false), - m_clipBoardOwnerStd(false), - XAtomeSelection(0), - XAtomeClipBoard(0), - XAtomeTargetString(0), - XAtomeTargetStringUTF8(0), - XAtomeTargetTarget(0), - XAtomeEWOL(0), - XAtomeDeleteWindows(0), - m_currentCursor(ewol::context::cursorArrow), - m_lastKeyPressed(0) { - X11_INFO("X11:INIT"); - for (int32_t iii=0; iii Kill Requested ..."); - OS_Stop(); - m_run = false; - } - break; - } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Selection AREA // - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - case SelectionClear: { - // Selection has been done on an other program == > clear ours ... - X11_INFO("X11 event SelectionClear"); - #ifdef DEBUG_X11_EVENT - { - XSelectionRequestEvent *req=&(event.xselectionrequest); - if (req->property == 0) { - EWOL_ERROR("Get nullptr ATOM ... property"); - break; - } - if (req->target == 0) { - EWOL_ERROR("Get nullptr ATOM ... target"); - break; - } - char * atomNameProperty = XGetAtomName(m_display, req->property); - char * atomNameTarget = XGetAtomName(m_display, req->target); - EWOL_INFO("X11 property: \"" << atomNameProperty << "\""); - EWOL_INFO("X11 target: \"" << atomNameTarget << "\""); - if (atomNameProperty != nullptr) { - XFree(atomNameProperty); - } - if (atomNameTarget != nullptr) { - XFree(atomNameTarget); - } - } - #endif - if (true == m_clipBoardOwnerPrimary) { - m_clipBoardOwnerPrimary = false; - } else if (true == m_clipBoardOwnerStd) { - m_clipBoardOwnerStd = false; - } else { - EWOL_ERROR("X11 event SelectionClear == > but no selection requested anymore ..."); - } - break; - } - case SelectionNotify: - X11_INFO("X11 event SelectionNotify"); - if (event.xselection.property == None) { - EWOL_VERBOSE(" == > no data ..."); - } else { - unsigned char *buf = 0; - Atom type; - int format; - unsigned long nitems, bytes; - XGetWindowProperty(m_display, - m_WindowHandle, - event.xselection.property, - 0, // offset - (~0L), // length - False, // delete - AnyPropertyType, // reg_type - &type,// *actual_type_return, - &format,// *actual_format_return - &nitems,// *nitems_return - &bytes, // *bytes_after_return - &buf// **prop_return); - ); - if (true == m_clipBoardRequestPrimary) { - std::string tmpppp((char*)buf); - ewol::context::clipBoard::setSystem(ewol::context::clipBoard::clipboardSelection, tmpppp); - // just transmit an event , we have the data in the system - OS_ClipBoardArrive(ewol::context::clipBoard::clipboardSelection); - } else { - std::string tmpppp((char*)buf); - ewol::context::clipBoard::setSystem(ewol::context::clipBoard::clipboardStd, tmpppp); - // just transmit an event , we have the data in the system - OS_ClipBoardArrive(ewol::context::clipBoard::clipboardStd); - } - } - break; - case SelectionRequest: { - X11_INFO("X11 event SelectionRequest"); - XSelectionRequestEvent *req=&(event.xselectionrequest); - #ifdef DEBUG_X11_EVENT - { - if (req->property == 0) { - EWOL_ERROR("Get nullptr ATOM ... property"); - break; - } - if (req->selection == 0) { - EWOL_ERROR("Get nullptr ATOM ... selection"); - break; - } - if (req->target == 0) { - EWOL_ERROR("Get nullptr ATOM ... target"); - break; - } - char * atomNameProperty = XGetAtomName(m_display, req->property); - char * atomNameSelection = XGetAtomName(m_display, req->selection); - char * atomNameTarget = XGetAtomName(m_display, req->target); - EWOL_INFO(" from: " << atomNameProperty << " request=" << atomNameSelection << " in " << atomNameTarget); - if (nullptr != atomNameProperty) { XFree(atomNameProperty); } - if (nullptr != atomNameSelection) { XFree(atomNameSelection); } - if (nullptr != atomNameTarget) { XFree(atomNameTarget); } - } - #endif - - std::string tmpData = ""; - if (req->selection == XAtomeSelection) { - tmpData = ewol::context::clipBoard::get(ewol::context::clipBoard::clipboardSelection); - } else if (req->selection == XAtomeClipBoard) { - tmpData = ewol::context::clipBoard::get(ewol::context::clipBoard::clipboardStd); - } - const char * magatTextToSend = tmpData.c_str(); - 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; - } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - case Expose: - X11_INFO("X11 event Expose"); - specialEventThatNeedARedraw=true; - break; - case GraphicsExpose: - X11_INFO("X11 event GraphicsExpose"); - specialEventThatNeedARedraw=true; - break; - case NoExpose: - X11_INFO("X11 event NoExpose"); - break; - case CreateNotify: - X11_INFO("X11 event CreateNotify"); - break; - case DestroyNotify: - X11_INFO("X11 event DestroyNotify"); - break; - case GravityNotify: - X11_INFO("X11 event GravityNotify"); - break; - case VisibilityNotify: - X11_INFO("X11 event VisibilityNotify"); - break; - case CirculateNotify: - X11_INFO("X11 event CirculateNotify"); - break; - case ReparentNotify: - X11_INFO("X11 event ReparentNotify"); - break; - case PropertyNotify: - specialEventThatNeedARedraw=true; - X11_INFO("X11 event PropertyNotify"); - break; - case ConfigureNotify: - specialEventThatNeedARedraw=true; - X11_INFO("X11 event ConfigureNotify"); - if (m_display == event.xconfigure.display) { - //EWOL_INFO("X11 event ConfigureNotify event=" << (int32_t)event.xconfigure.event << " Window=" << (int32_t)event.xconfigure.window << " above=" << (int32_t)event.xconfigure.above << " border_width=" << (int32_t)event.xconfigure.border_width ); - m_originX = event.xconfigure.x; - m_originY = event.xconfigure.y; - X11_INFO("X11 configure windows position : (" << m_originX << "," << m_originY << ")"); - m_currentHeight = event.xconfigure.height; - m_currentWidth = event.xconfigure.width; - X11_INFO("X11 configure windows size : (" << m_currentHeight << "," << m_currentWidth << ")"); - OS_Resize(vec2(event.xconfigure.width, event.xconfigure.height)); - } - break; - case ButtonPress: - X11_INFO("X11 event ButtonPress"); - m_cursorEventX = event.xbutton.x; - m_cursorEventY = (m_currentHeight-event.xbutton.y); - if (event.xbutton.button < MAX_MANAGE_INPUT) { - m_inputIsPressed[event.xbutton.button] = true; - } - OS_SetMouseState(event.xbutton.button, true, vec2(event.xbutton.x, m_cursorEventY)); - break; - case ButtonRelease: - X11_INFO("X11 event ButtonRelease"); - m_cursorEventX = event.xbutton.x; - m_cursorEventY = (m_currentHeight-event.xbutton.y); - if (event.xbutton.button < MAX_MANAGE_INPUT) { - m_inputIsPressed[event.xbutton.button] = false; - } - OS_SetMouseState(event.xbutton.button, false, vec2(event.xbutton.x, m_cursorEventY)); - break; - case EnterNotify: - X11_INFO("X11 event EnterNotify"); - m_cursorEventX = event.xcrossing.x; - m_cursorEventY = (m_currentHeight-event.xcrossing.y); - //EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (float)event.xcrossing.x << "," << (float)event.xcrossing.y << ")"); - //gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (float)event.xcrossing.x, (float)event.xcrossing.y); - m_curentGrabDelta -= vec2(m_originX, -m_originY); - EWOL_VERBOSE("change grab delta of : " << vec2(m_originX, m_originY) ); - break; - case LeaveNotify: - X11_INFO("X11 event LeaveNotify"); - m_cursorEventX = event.xcrossing.x; - m_cursorEventY = (m_currentHeight-event.xcrossing.y); - //EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (float)event.xcrossing.x << "," << (float)event.xcrossing.y << ")"); - m_curentGrabDelta += vec2(m_originX, -m_originY); - EWOL_VERBOSE("change grab delta of : " << vec2(m_originX, m_originY) ); - break; - case MotionNotify: - X11_INFO("X11 event MotionNotify"); - if( true == m_grabAllEvent - && event.xmotion.x == (int32_t)m_forcePos.x() - && event.xmotion.y == (int32_t)m_forcePos.y()) { - X11_VERBOSE("X11 reject mouse move (grab mode)"); - // we get our requested position... - m_positionChangeRequested = false; - m_curentGrabDelta = vec2(0,0); - } else { - m_cursorEventX = event.xmotion.x; - m_cursorEventY = (m_currentHeight-event.xmotion.y); - if(true == m_grabAllEvent) { - m_cursorEventX -= m_forcePos.x(); - m_cursorEventY -= (m_currentHeight-m_forcePos.y()); - } - vec2 newDelta = vec2(m_cursorEventX, m_cursorEventY); - if(true == m_grabAllEvent) { - m_cursorEventX -= m_curentGrabDelta.x(); - m_cursorEventY -= m_curentGrabDelta.y(); - } - m_curentGrabDelta = newDelta; - // For compatibility of the Android system : - bool findOne = false; - for (int32_t iii=0; iii= 0) { - // repeated kay from previous element : - if (count>0) { - // transform it in unicode - m_lastKeyPressed = utf8::convertChar32(buf); - } - X11_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << m_lastKeyPressed); - OS_SetKeyboard(m_guiKeyBoardMode, m_lastKeyPressed, (event.type == KeyPress), thisIsAReapeateKey); - if (true == thisIsAReapeateKey) { - OS_SetKeyboard(m_guiKeyBoardMode, m_lastKeyPressed, !(event.type == KeyPress), thisIsAReapeateKey); - } - } else { - EWOL_WARNING("Unknow event Key : " << event.xkey.keycode << " res='" << buf << "' repeate=" << 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; - } - //case DestroyNotify: - // break; - case MapNotify: - X11_INFO("X11 event : MapNotify"); - specialEventThatNeedARedraw=true; - OS_Show(); - break; - case UnmapNotify: - X11_INFO("X11 event : UnmapNotify"); - specialEventThatNeedARedraw=true; - OS_Hide(); - break; - default: - X11_INFO("X11 event : " << event.type << " = \"???\""); - break; - } - } - if(true == m_run) { - if (m_doubleBuffered && hasDisplay) { - glXSwapBuffers(m_display, m_WindowHandle); - XSync(m_display,0); - } - // draw after switch the previous windows ... - //EWOL_DEBUG("specialEventThatNeedARedraw"<visual, AllocNone); - - attr.border_pixel = 0; - attr.event_mask = StructureNotifyMask - | SubstructureNotifyMask - | EnterWindowMask - | LeaveWindowMask - | ExposureMask - | ButtonPressMask - | ButtonReleaseMask - | OwnerGrabButtonMask - | KeyPressMask - | KeyReleaseMask - | PointerMotionMask - | FocusChangeMask - | SubstructureRedirectMask; - - // set no background at the gui - attr.background_pixmap = None; - - // select internal attribute - attr_mask = CWBackPixmap | CWColormap | CWBorderPixel | CWEventMask; - // Create the window - int32_t tmp_width = 640;//DisplayWidth(m_display, DefaultScreen(m_display))/2; - int32_t tmp_height = 480;//DisplayHeight(m_display, DefaultScreen(m_display))/2; - OS_Resize(vec2(tmp_width, tmp_height)); - x=20; - y=20; - m_originX = x; - m_originY = y; - EWOL_INFO("X11 request creating windows at pos=(" << m_originX << "," << m_originY << ") size=(" << tmp_width << "," << tmp_height << ")" ); - // Real create of the window - m_WindowHandle = XCreateWindow(m_display, - Xroot, - x, y, tmp_width, tmp_height, - 1, - m_visual->depth, - InputOutput, - m_visual->visual, - attr_mask, &attr); - - if( !m_WindowHandle ) { - EWOL_CRITICAL("Couldn't create the window"); - exit(-1); - } - - /* Configure it... (ok, ok, this next bit isn't "minimal") */ - textprop.value = (unsigned char*)title; - textprop.encoding = XA_STRING; - textprop.format = 8; - textprop.nitems = strlen(title); - - hints.x = x; - hints.y = y; - hints.width = tmp_width; - hints.height = tmp_height; - hints.flags = USPosition|USSize; - - StartupState = XAllocWMHints(); - StartupState->initial_state = NormalState; - StartupState->flags = StateHint; - - XSetWMProperties(m_display, m_WindowHandle,&textprop, &textprop,/* Window title/icon title*/ - nullptr, 0,/* Argv[], argc for program*/ - &hints, /* Start position/size*/ - StartupState,/* Iconised/not flag */ - nullptr); - - XFree(StartupState); - - /* open it, wait for it to appear */ - XMapWindow(m_display, m_WindowHandle); - //XIfEvent(m_display, &event, WaitForMapNotify, (char*)&m_WindowHandle); - - - m_xim = XOpenIM(m_display, nullptr, NULL, NULL); - if (m_xim == nullptr) { - EWOL_ERROR("Could not open input method"); - return false; - } - /* - XIMStyles *styles=nullptr; - char* failed_arg = XGetIMValues(m_xim, XNQueryInputStyle, &styles, nullptr); - if (failed_arg != nullptr) { - EWOL_ERROR("XIM Can't get styles"); - return false; - } - for (int32_t iii=0; iiicount_styles; ++iii) { - EWOL_INFO("style " << styles->supported_styles[iii]); - } - */ - m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_WindowHandle, nullptr); - if (m_xic == nullptr) { - EWOL_ERROR("Could not open IC"); - return false; - } - - XSetICFocus(m_xic); - - // set the kill atom so we get a message when the user tries to close the window - if ((m_delAtom = XInternAtom(m_display, "WM_DELETE_WINDOW", 0)) != None) { - XSetWMProtocols(m_display, m_WindowHandle, &m_delAtom, 1); - } - - vec2 tmpSize(400, 300); - OS_Resize(tmpSize); - - return true; - } - /****************************************************************************************/ - void setIcon(const std::string& _inputFile) { - egami::Image dataImage; - // load data - if (false == egami::load(dataImage, _inputFile)) { - EWOL_ERROR("Error when loading Icon"); - return; - } - int32_t depth = DefaultDepth(m_display, DefaultScreen(m_display) ); - EWOL_DEBUG("X11 Create icon size=(" << dataImage.getWidth() << "," << dataImage.getHeight() << ") depth=" << depth); - switch(depth) { - case 8: - EWOL_CRITICAL("Not manage pixmap in 8 bit... == > no icon ..."); - return; - case 16: - break; - case 24: - break; - case 32: - break; - default: - EWOL_CRITICAL("Unknow thys type of bitDepth : " << depth); - return; - } - char* tmpVal = new char[4*dataImage.getWidth()*dataImage.getHeight()]; - if (nullptr == tmpVal) { - EWOL_CRITICAL("Allocation error ..."); - return; - } - char* tmpPointer = tmpVal; - switch(depth) { - case 16: - for(ivec2 pos(0,0); pos.y() tmpColor = dataImage.get(pos); - int16_t tmpVal = (((uint16_t)((uint16_t)tmpColor.r()>>3))<<11) - + (((uint16_t)((uint16_t)tmpColor.g()>>2))<<5) - + ((uint16_t)((uint16_t)tmpColor.b()>>3)); - *tmpPointer++ = (uint8_t)(tmpVal>>8); - *tmpPointer++ = (uint8_t)(tmpVal&0x00FF); - } - } - break; - case 24: - for(ivec2 pos(0,0); pos.y() tmpColor = dataImage.get(pos); - *tmpPointer++ = tmpColor.b(); - *tmpPointer++ = tmpColor.g(); - *tmpPointer++ = tmpColor.r(); - tmpPointer++; - } - } - break; - case 32: - for(ivec2 pos(0,0); pos.y() tmpColor = dataImage.get(pos); - *tmpPointer++ = tmpColor.a(); - *tmpPointer++ = tmpColor.b(); - *tmpPointer++ = tmpColor.g(); - *tmpPointer++ = tmpColor.r(); - } - } - break; - default: - return; - } - - XImage* myImage = XCreateImage(m_display, - m_visual->visual, - depth, - ZPixmap, - 0, - (char*)tmpVal, - dataImage.getWidth(), - dataImage.getHeight(), - 32, - 0); - - Pixmap tmpPixmap = XCreatePixmap(m_display, m_WindowHandle, dataImage.getWidth(), dataImage.getHeight(), depth); - switch(tmpPixmap) { - case BadAlloc: - EWOL_ERROR("X11: BadAlloc"); - break; - case BadDrawable: - EWOL_ERROR("X11: BadDrawable"); - break; - case BadValue: - EWOL_ERROR("X11: BadValue"); - break; - default: - EWOL_DEBUG("Create Pixmap OK"); - break; - } - GC tmpGC = DefaultGC(m_display, DefaultScreen(m_display) ); - int error = XPutImage(m_display, tmpPixmap, tmpGC, myImage, 0, 0, 0, 0, dataImage.getWidth(), dataImage.getHeight()); - switch(error) { - case BadDrawable: - EWOL_ERROR("X11: BadDrawable"); - break; - case BadGC: - EWOL_ERROR("X11: BadGC"); - break; - case BadMatch: - EWOL_ERROR("X11: BadMatch"); - break; - case BadValue: - EWOL_ERROR("X11: BadValue"); - break; - default: - EWOL_DEBUG("insert image OK"); - break; - } - // allocate a WM hints structure. - XWMHints* win_hints = XAllocWMHints(); - if (!win_hints) { - EWOL_ERROR("XAllocWMHints - out of memory"); - return; - } - // initialize the structure appropriately. first, specify which size hints we want to fill in. in our case - setting the icon's pixmap. - win_hints->flags = IconPixmapHint; - // next, specify the desired hints data. in our case - supply the icon's desired pixmap. - win_hints->icon_pixmap = tmpPixmap; - // pass the hints to the window manager. - XSetWMHints(m_display, m_WindowHandle, win_hints); - EWOL_INFO(" == > might be done "); - // finally, we can free the WM hints structure. - XFree(win_hints); - - // Note when we free the pixmap ... the icon is removed ... == > this is a real memory leek ... - //XFreePixmap(m_display, tmpPixmap); - - myImage->data = nullptr; - XDestroyImage(myImage); - delete[] tmpVal; - - } - /****************************************************************************************/ - static void setVSync(bool _sync) { - // Function pointer for the wgl extention function we need to enable/disable - typedef int32_t (APIENTRY *PFNWGLSWAPINTERVALPROC)( int ); - PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; - const char *extensions = (char*)glGetString( GL_EXTENSIONS ); - if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 ) { - EWOL_ERROR("Can not set the vertical synchronisation status" << _sync << " (1)"); - return; - } else { - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)glXGetProcAddress( (const GLubyte *)"wglSwapIntervalEXT" ); - if(wglSwapIntervalEXT) { - wglSwapIntervalEXT(_sync); - } else { - EWOL_ERROR("Can not set the vertical synchronisation status" << _sync << " (2)"); - } - } - } - /****************************************************************************************/ - bool createOGlContext() { - X11_INFO("X11:CreateOGlContext"); - /* create a GLX context */ - GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE); - /* connect the glx-context to the window */ - glXMakeCurrent(m_display, m_WindowHandle, RenderContext); - if (glXIsDirect(m_display, RenderContext)) { - EWOL_INFO("XF86 DRI enabled\n"); - } else { - EWOL_INFO("XF86 DRI NOT available\n"); - } - - // enable vertical synchronisation : (some computer has synchronisation disable) - setVSync(true); - - return true; - } - /****************************************************************************************/ - void setTitle(const std::string& _title) { - X11_INFO("X11: set Title (START)"); - XTextProperty tp; - tp.value = (unsigned char *)_title.c_str(); - tp.encoding = XA_WM_NAME; - tp.format = 8; - tp.nitems = strlen((const char*)tp.value); - XSetWMName(m_display, m_WindowHandle, &tp); - XStoreName(m_display, m_WindowHandle, (const char*)tp.value); - XSetIconName(m_display, m_WindowHandle, (const char*)tp.value); - XSetWMIconName(m_display, m_WindowHandle, &tp); - X11_INFO("X11: set Title (END)"); - } - - void openURL(const std::string& _url) { - std::string req = "xdg-open "; - req += _url; - system(req.c_str()); - return; - } - /****************************************************************************************/ - void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - switch (_clipboardID) { - case ewol::context::clipBoard::clipboardSelection: - if (false == m_clipBoardOwnerPrimary) { - m_clipBoardRequestPrimary = true; - // generate a request on X11 - XConvertSelection(m_display, - XAtomeSelection, - XAtomeTargetStringUTF8, - XAtomeEWOL, - m_WindowHandle, - CurrentTime); - } else { - // just transmit an event , we have the data in the system - OS_ClipBoardArrive(_clipboardID); - } - break; - case ewol::context::clipBoard::clipboardStd: - if (false == m_clipBoardOwnerStd) { - m_clipBoardRequestPrimary = false; - // generate a request on X11 - XConvertSelection(m_display, - XAtomeClipBoard, - XAtomeTargetStringUTF8, - XAtomeEWOL, - m_WindowHandle, - CurrentTime); - } else { - // just transmit an event , we have the data in the system - OS_ClipBoardArrive(_clipboardID); - } - break; - default: - EWOL_ERROR("Request an unknow ClipBoard ..."); - break; - } - } - /****************************************************************************************/ - void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - switch (_clipboardID) - { - case ewol::context::clipBoard::clipboardSelection: - // Request the selection : - if (false == m_clipBoardOwnerPrimary) { - XSetSelectionOwner(m_display, XAtomeSelection, m_WindowHandle, CurrentTime); - m_clipBoardOwnerPrimary = true; - } - break; - case ewol::context::clipBoard::clipboardStd: - // Request the clipBoard : - if (false == m_clipBoardOwnerStd) { - XSetSelectionOwner(m_display, XAtomeClipBoard, m_WindowHandle, CurrentTime); - m_clipBoardOwnerStd = true; - } - break; - default: - EWOL_ERROR("Request an unknow ClipBoard ..."); - break; - } - } -}; - - -/** - * @brief Main of the program - * @param std IO - * @return std IO - */ -int ewol::run(ewol::context::Application* _application, int _argc, const char *_argv[]) { - etk::init(_argc, _argv); - X11Interface* interface = new X11Interface(_application, _argc, _argv); - if (interface == nullptr) { - EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error"); - return -2; - } - int32_t retValue = interface->run(); - delete(interface); - interface = nullptr; - return retValue; -} diff --git a/ewol/context/clipBoard.cpp b/ewol/context/clipBoard.cpp deleted file mode 100644 index cd3377e6..00000000 --- a/ewol/context/clipBoard.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -#include -#include -#include - -#undef __class__ -#define __class__ "ClipBoard" - - -/* -note: la copy dans le : - 0 : copy standard - [1..9] : copy interne - 10 : bouton du milieux -*/ -//!< Local copy of the clipboards -static std::string mesCopy[ewol::context::clipBoard::clipboardCount]; - -static const char* clipboardDescriptionString[ewol::context::clipBoard::clipboardCount+1] = { - "clipboard0", - "clipboard1", - "clipboard2", - "clipboard3", - "clipboard4", - "clipboard5", - "clipboard6", - "clipboard7", - "clipboard8", - "clipboard9", - "clipboardStd", - "clipboardSelection", - "clipboardCount" -}; - -std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::context::clipBoard::clipboardListe _obj) { - if (_obj >= 0 && _obj = ewol::context::clipBoard::clipboardCount) { - EWOL_WARNING("request ClickBoard id error"); - return; - } - - ewol::context::clipBoard::setSystem(_clipboardID, _data); - - if( ewol::context::clipBoard::clipboardStd == _clipboardID - || ewol::context::clipBoard::clipboardSelection == _clipboardID) { - ewol::getContext().clipBoardSet(_clipboardID); - } -} - - -void ewol::context::clipBoard::request(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - if(_clipboardID >= ewol::context::clipBoard::clipboardCount) { - EWOL_WARNING("request ClickBoard id error"); - return; - } - - if( ewol::context::clipBoard::clipboardStd == _clipboardID - || ewol::context::clipBoard::clipboardSelection == _clipboardID) { - ewol::getContext().clipBoardGet(_clipboardID); - } else { - // generate an event on the main thread ... - ewol::getContext().OS_ClipBoardArrive(_clipboardID); - } -} - - -void ewol::context::clipBoard::setSystem(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data) { - if(_clipboardID >= ewol::context::clipBoard::clipboardCount) { - EWOL_WARNING("request ClickBoard id error"); - return; - } - // Copy datas ... - mesCopy[_clipboardID] = _data; -} - - -const std::string& ewol::context::clipBoard::get(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - static const std::string emptyString(""); - if(_clipboardID >= ewol::context::clipBoard::clipboardCount) { - EWOL_WARNING("request ClickBoard id error"); - return emptyString; - } - // Copy datas ... - return mesCopy[_clipboardID]; -} - - - - - diff --git a/ewol/context/clipBoard.h b/ewol/context/clipBoard.h deleted file mode 100644 index d3d1e1e7..00000000 --- a/ewol/context/clipBoard.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_CLIPBOARD_H__ -#define __EWOL_CLIPBOARD_H__ - -#include - -// TODO : Remove this ... ==> set it in the context .... -namespace ewol { - namespace context { - namespace clipBoard { - enum clipboardListe { - clipboard0, //!< internal clipboard 0 - clipboard1, //!< internal clipboard 1 - clipboard2, //!< internal clipboard 2 - clipboard3, //!< internal clipboard 3 - clipboard4, //!< internal clipboard 4 - clipboard5, //!< internal clipboard 5 - clipboard6, //!< internal clipboard 6 - clipboard7, //!< internal clipboard 7 - clipboard8, //!< internal clipboard 8 - clipboard9, //!< internal clipboard 9 - clipboardStd, //!< External clipboard represent the Copy/Cut/Past buffer - clipboardSelection, //!< External or internal clipboard depending on the OS, represent the middle button - clipboardCount, //!< Total number of clipboard - }; - - /** - * @brief set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change - * @param[in] _clipboardID Select the specific ID of the clipboard - * @param[in] _data The string that might be send to the clipboard - */ - void set(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data); - /** - * @brief Call system to request the current clipboard. - * @note Due to some system that manage the clipboard request asynchronous (like X11) and ewol managing the system with only one thread, - * we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the - * notification of the arrival of this buffer id - * @param[in] _clipboardID the needed clipboard ID - */ - void request(enum ewol::context::clipBoard::clipboardListe _clipboardID); - /** - * @brief set the ewol internal buffer (no notification at the GUI). This fuction might be use by the - * Gui abstraction to set the buffer we receive. The end user must not use it. - * @param[in] _clipboardID selected clipboard ID - * @param[in] _data new buffer data - */ - void setSystem(enum ewol::context::clipBoard::clipboardListe _clipboardID,const std::string& _data); - /** - * @brief get the ewol internal buffer of the curent clipboard. The end user can use it when he receive the event in - * the widget : @ref onEventClipboard == > we can nothe this function is the only one which permit it. - * @note if we call this fuction withoutcallin @ref ewol::context::clipBoard::Request, we only get the previous clipboard - * @param[in] _clipboardID selected clipboard ID - * @return the requested buffer - */ - const std::string& get(enum ewol::context::clipBoard::clipboardListe _clipboardID); - - // internal section - - /** - * @brief initialize the clipboard system (done by ewol) - */ - void init(); - /** - * @brief Un-Initialize the clipboard system (done by ewol) - */ - void unInit(); - }; - }; - /** - * @brief Debug operator To display the curent element in a Human redeable information - */ - std::ostream& operator <<(std::ostream& _os, const enum ewol::context::clipBoard::clipboardListe _obj); -}; - -#endif - - diff --git a/ewol/context/commandLine.cpp b/ewol/context/commandLine.cpp deleted file mode 100644 index 52e44a8c..00000000 --- a/ewol/context/commandLine.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include - -void ewol::context::CommandLine::parse(int32_t _argc, const char* _argv[]) { - for (int32_t i=1 ; i<_argc; i++) { - EWOL_INFO("commandLine : \"" << _argv[i] << "\"" ); - m_listArgs.push_back(_argv[i]); - } -} - -int32_t ewol::context::CommandLine::size() { - return m_listArgs.size(); -} - -const std::string& ewol::context::CommandLine::get(int32_t _id) { - static const std::string errorArg(""); - if ( _id < 0 - && _id >= (int64_t)m_listArgs.size()) { - return errorArg; - } - return m_listArgs[_id]; -} - -void ewol::context::CommandLine::add(const std::string& _newElement) { - m_listArgs.push_back(_newElement); -} - -void ewol::context::CommandLine::remove(int32_t _id) { - m_listArgs.erase(m_listArgs.begin()+_id); -} - diff --git a/ewol/context/commandLine.h b/ewol/context/commandLine.h deleted file mode 100644 index 22a4cc82..00000000 --- a/ewol/context/commandLine.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_COMMAND_LINE_H__ -#define __EWOL_COMMAND_LINE_H__ - -#include - -namespace ewol { - namespace context { - class CommandLine { - private: - std::vector m_listArgs; //!< list of all argument parsed - public: - /** - * @brief Parse the command line parameters - */ - void parse(int32_t _argc, const char* _argv[]); - /** - * @brief get the number of element in the Command line - * @return the number of element - */ - int32_t size(); - /** - * @brief get an element with a specific ID - * @return _id The cmdLine Id element - */ - const std::string& get(int32_t _id); - /** - * @brief add one element at the Command line - * @param[in] _newElement String in the input that might be added. - */ - void add(const std::string& _newElement); - /** - * @brief remove an element - * @param[in] _id Id of the element - */ - void remove(int32_t _id); - }; - }; -}; - -#endif diff --git a/ewol/context/cursor.cpp b/ewol/context/cursor.cpp deleted file mode 100644 index 206f06f5..00000000 --- a/ewol/context/cursor.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -static const char* cursorDescriptionString[ewol::context::cursorCount+1] = { - "cursorArrow", - "cursorLeftArrow", - "cursorInfo", - "cursorDestroy", - "cursorHelp", - "cursorCycle", - "cursorSpray", - "cursorWait", - "cursorText", - "cursorCrossHair", - "cursorSlideUpDown", - "cursorSlideLeftRight", - "cursorResizeUp", - "cursorResizeDown", - "cursorResizeLeft", - "cursorResizeRight", - "cursorCornerTopLeft", - "cursorCornerTopRight", - "cursorCornerButtomLeft", - "cursorCornerButtomRight", - "cursorNone", - "cursorCount" -}; - -std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::context::cursorDisplay _obj) { - if (_obj >= 0 && _obj - -namespace ewol { - namespace context { - enum cursorDisplay { - cursorArrow, // this is the normal arrow ... - cursorLeftArrow, - cursorInfo, - cursorDestroy, - cursorHelp, - cursorCycle, - cursorSpray, - cursorWait, - cursorText, - cursorCrossHair, - cursorSlideUpDown, //!< change the position (slide) vertical - cursorSlideLeftRight, //!< change the position (slide) horizontal - cursorResizeUp, - cursorResizeDown, - cursorResizeLeft, - cursorResizeRight, - cursorCornerTopLeft, - cursorCornerTopRight, - cursorCornerButtomLeft, - cursorCornerButtomRight, - cursorNone, - // just for the count: - cursorCount - }; - }; - /** - * @brief Debug operator To display the curent element in a Human readable information - */ - std::ostream& operator <<(std::ostream& _os, const enum ewol::context::cursorDisplay _obj); -}; - -#endif - - diff --git a/ewol/context/directFB/Context.cpp b/ewol/context/directFB/Context.cpp deleted file mode 100644 index 3fcae692..00000000 --- a/ewol/context/directFB/Context.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -/* - notes : - sudo edn /etc/udev/rules.d/framebuffer.rules - KERNEL == "fb0", OWNER="root", MODE="0660" - sudo usermod -a -G video username - sudo usermod -a -G tty username - sudo fbset -i - sudo chmod o+wr /dev/fb0 - - - http://mail.directfb.org/pipermail/directfb-users/2010-February/002115.html - on X11 : - http://stackoverflow.com/questions/521957/how-to-develop-a-directfb-app-without-leaving-x-11-environment - $ sudo apt-get install libdirectfb-extra # for Debian and Ubuntu, anyhow - $ cat ~/.directfbrc - system=x11 - force-windowed -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - - -int64_t guiInterface::getTime() { - struct timespec now; - int ret = clock_gettime(CLOCK_REALTIME, &now); - if (ret != 0) { - // Error to get the time ... - now.tv_sec = time(nullptr); - now.tv_nsec = 0; - } - //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); - return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000); -} - -#undef __class__ -#define __class__ "guiInterface" - - -static ewol::SpecialKey guiKeyBoardMode; - -bool inputIsPressed[20]; -bool m_run = true; -bool m_grabAllEvent = false; - - -// the super interface -IDirectFB *dfb = nullptr; - -// the primary surface (surface of primary layer) -IDirectFBSurface *primary = nullptr; - -// the GL context -IDirectFBGL *primary_gl = nullptr; - -// event buffer -IDirectFBEventBuffer *events = nullptr; - -static int screen_width =800; -static int screen_height = 600; - - -/** - * @brief set the new title of the windows - * @param title New desired title - * @return --- - */ -void guiInterface::setTitle(std::string& title) { - // TODO : ... -} - - -void guiInterface::setIcon(std::string inputFile) { - // TODO : ... -} - - -void DirectFB_Init(int argc, const char *argv[]) { - EWOL_INFO("DirectFB init (START)"); - DFBResult err; - DFBSurfaceDescription dsc; - - EWOL_INFO("call DirectFBInit"); - int argc2 = 1; - err = DirectFBInit(&argc2, (char***)&argv); - if (DFB_OK!=err) { - EWOL_ERROR("DirectFBInit"); - DirectFBErrorFatal("DirectFBInit", err); - exit(-1); - } - EWOL_INFO("call DirectFBCreate"); - // create the super interface - err = DirectFBCreate(&dfb); - if (DFB_OK!=err) { - EWOL_ERROR("DirectFBCreate"); - DirectFBErrorFatal("DirectFBCreate", err); - exit(-1); - } - - EWOL_INFO("call setCooperativeLevel"); - // set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer - dfb->setCooperativeLevel(dfb, DFSCL_FULLSCREEN); - //dfb->setCooperativeLevel(dfb, DFSCL_NORMAL); - - // get the primary surface, i.e. the surface of the primary layer we have exclusive access to - dsc.flags = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS);// | DSDESC_PIXELFORMAT); - //dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_DEPTH); // DSCAPS_SHARED - dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | DSCAPS_DOUBLE | DSCAPS_GL);// | DSCAPS_FLIPPING); - //dsc.caps = (DFBSurfaceCapabilities) (DSCAPS_SUBSURFACE | DSCAPS_VIDEOONLY | DSCAPS_PREMULTIPLIED | DSCAPS_FLIPPING); - - - dsc.pixelformat = DSPF_ARGB; - dsc.width = 600; - dsc.height = 400; - - EWOL_INFO("call CreateSurface"); - err = dfb->CreateSurface(dfb, &dsc, &primary); - if (DFB_OK!=err) { - EWOL_ERROR("dfb->CreateSurface"); - DirectFBErrorFatal("dfb->CreateSurface", err); - exit(-1); - } - - primary->setBlittingFlags(primary, DSBLIT_BLEND_ALPHACHANNEL); - primary->setPorterDuff( primary, DSPD_ADD ); - primary->setDstBlendFunction(primary, DSBF_SRCALPHA); - primary->setDrawingFlags(primary, DSDRAW_BLEND); - - primary->Blit(primary, primary, nullptr, 0, 0); - - - EWOL_INFO("call getSize"); - // get the size of the surface and fill it - err = primary->getSize(primary, &screen_width, &screen_height); - if (DFB_OK!=err) { - EWOL_ERROR("primary->getSize"); - DirectFBErrorFatal("primary->getSize", err); - exit(-1); - } - - - EWOL_INFO("call CreateInputEventBuffer"); - // create an event buffer for all devices with these caps - err = dfb->CreateInputEventBuffer(dfb, (DFBInputDeviceCapabilities)(DICAPS_KEYS | DICAPS_AXES), DFB_FALSE, &events); - if (DFB_OK!=err) { - EWOL_ERROR("dfb->CreateInputEventBuffer"); - DirectFBErrorFatal("CreateInputEventBuffer", err); - exit(-1); - } - - EWOL_INFO("call Flip"); - primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC); - - // NOTE : we need to force it on X11 display ... - EWOL_INFO("call getGL"); - // get the GL context - err = primary->getGL(primary, &primary_gl); - if (DFB_OK!=err) { - EWOL_ERROR("primary->getGL"); - DirectFBErrorFatal("GetGL", err); - exit(-1); - } - - EWOL_INFO("DirectFB init (STOP)"); -} - -void DirectFB_UnInit() { - // release our interfaces to shutdown DirectFB - primary_gl->release(primary_gl); - primary->release(primary); - events->release(events); - dfb->release(dfb); -} - -void DirectFB_Run() { - EWOL_INFO("X11 configure windows size : (" << screen_height << "," << screen_width << ")"); - eSystem::Resize(screen_width, screen_height); - - DFBResult err; - int32_t position = 0; - while (true == m_run) { - DFBInputEvent evt; - unsigned long t; - /* - primary->setColor (primary, 0x00, 0x00, 0x00, 0xFF); - primary->FillRectangle(primary, 0, 0, screen_width, screen_height); - primary->setColor (primary, 0xFF, (uint8_t)position, 0x00, 0xFF); - primary->FillRectangle(primary, position, position, 300, 300); - primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC); - position++; - if (position>600) { - position = 0; - } - */ - if(true == m_run) { - err = primary_gl->Lock(primary_gl); - if (DFB_OK!=err) { - EWOL_ERROR("primary_gl->Lock"); - DirectFBErrorFatal("primary_gl->Lock", err); - } - // TODO : set at false - bool hasDisplay = eSystem::draw(true); - if (true == hasDisplay) { - glFinish(); - } - err = primary_gl->Unlock(primary_gl); - if (DFB_OK!=err) { - EWOL_ERROR("primary_gl->Unlock"); - DirectFBErrorFatal("primary_gl->Unlock", err); - } - primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC); - } - - while (events->getEvent(events, DFB_EVENT(&evt)) == DFB_OK) { - switch (evt.type) { - default: - case DIET_UNKNOWN: /* unknown event */ - EWOL_DEBUG("event unknown type : " << evt.type << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " ..."); - break; - case DIET_KEYPRESS: /* a key is been pressed */ - case DIET_KEYRELEASE: /* a key is been released */ - { - bool isPressed = (evt.type == DIET_KEYPRESS); - //EWOL_DEBUG("event KeyBoard isPressed : " << isPressed << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " ..."); - if( 1 <= evt.key_symbol && evt.key_symbol <= 0x7F ) { - eSystem::setKeyboard(guiKeyBoardMode, evt.key_symbol, isPressed, false); - } else { - EWOL_DEBUG("event KeyBoard isPressed : " << isPressed << " symbole=\"" << (char)evt.key_symbol << "\"=" << ((int32_t)evt.key_symbol) << " == > not managed key"); - } - } - break; - case DIET_AXISMOTION: /* mouse/joystick movement */ - { - /* - if (evt.flags & DIEF_AXISREL) { - switch (evt.axis) { - case DIAI_X: - //view_roty += evt.axisrel / 2.0; - break; - case DIAI_Y: - //view_rotx += evt.axisrel / 2.0; - break; - case DIAI_Z: - //view_rotz += evt.axisrel / 2.0; - break; - default: - ; - } - } - */ - EWOL_DEBUG("event mouse motion flag" << (char)evt.flags << " axis=" << evt.axis << " value=" << evt.axisrel); - } - break; - case DIET_BUTTONPRESS: /* a (mouse) button is been pressed */ - case DIET_BUTTONRELEASE: /* a (mouse) button is been released */ - { - bool isPressed = (evt.type == DIET_KEYPRESS); - EWOL_DEBUG("event mouse event pressed=" << isPressed << " flag" << (char)evt.flags << " axis=" << evt.axis << " value=" << evt.axisrel); - } - break; - /* - case DIET_KEYPRESS: - switch (evt.key_symbol) { - case DIKS_ESCAPE: - m_run = false; - break; - case DIKS_CURSOR_UP: - //inc_rotx = 5.0; - break; - case DIKS_CURSOR_DOWN: - //inc_rotx = -5.0; - break; - case DIKS_CURSOR_LEFT: - //inc_roty = 5.0; - break; - case DIKS_CURSOR_RIGHT: - //inc_roty = -5.0; - break; - case DIKS_PAGE_UP: - //inc_rotz = 5.0; - break; - case DIKS_PAGE_DOWN: - //inc_rotz = -5.0; - break; - default: - ; - } - break; - case DIET_KEYRELEASE: - switch (evt.key_symbol) { - case DIKS_CURSOR_UP: - //inc_rotx = 0; - break; - case DIKS_CURSOR_DOWN: - //inc_rotx = 0; - break; - case DIKS_CURSOR_LEFT: - //inc_roty = 0; - break; - case DIKS_CURSOR_RIGHT: - //inc_roty = 0; - break; - case DIKS_PAGE_UP: - //inc_rotz = 0; - break; - case DIKS_PAGE_DOWN: - //inc_rotz = 0; - break; - default: - ; - } - break; - case DIET_AXISMOTION: - if (evt.flags & DIEF_AXISREL) { - switch (evt.axis) { - case DIAI_X: - //view_roty += evt.axisrel / 2.0; - break; - case DIAI_Y: - //view_rotx += evt.axisrel / 2.0; - break; - case DIAI_Z: - //view_rotz += evt.axisrel / 2.0; - break; - default: - ; - } - } - break; - default: - ; - */ - } - } - } - // Note : if we not stop like this the system break ... - exit(-1); -}; - - -// ------------------------------------------------------------------------- -// ClipBoard AREA : -// ------------------------------------------------------------------------- - - -void guiInterface::ClipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - // TODO : ... -} - - -void guiInterface::ClipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { - // TODO : ... -} - - - -#undef __class__ -#define __class__ "guiInterface" - - -void guiInterface::Stop() { - EWOL_INFO("X11-API: Stop"); - m_run = false; -} - -void guiInterface::KeyboardShow() { - // nothing to do : No keyboard on computer ... -} - - -void guiInterface::KeyboardHide() { - // nothing to do : No keyboard on computer ... -} - - -void guiInterface::changeSize(ivec2 _size) { - // TODO : ... -} - - -void guiInterface::changePos(ivec2 _pos) { - // TODO : ... -} - - -void guiInterface::getAbsPos(ivec2& _pos) { - // TODO : ... -} - - -void guiInterface::setCursor(enum ewol::cursorDisplay _newCursor) { - // TODO : ... -} - -void guiInterface::GrabPointerEvents(bool _isGrabbed, vec2 _forcedPosition) { - // TODO : ... -} - - -/** - * @brief Main of the program - * @param std IO - * @return std IO - */ -int guiInterface::main(int argc, const char *argv[]) { - EWOL_INFO("Main (START)"); - for (int32_t iii=0; iii -#include +#include namespace ewol { namespace event { class Entry { private: - enum ewol::key::keyboard m_type; //!< type of hardware event - enum ewol::key::status m_status; //!< status of hardware event - ewol::key::Special m_specialKey; //!< input key status (prevent change in time..) + enum gale::key::keyboard m_type; //!< type of hardware event + enum gale::key::status m_status; //!< status of hardware event + gale::key::Special m_specialKey; //!< input key status (prevent change in time..) char32_t m_unicodeData; //!< Unicode data (in some case) public: - Entry(enum ewol::key::keyboard _type, - enum ewol::key::status _status, - ewol::key::Special _specialKey, + Entry(enum gale::key::keyboard _type, + enum gale::key::status _status, + gale::key::Special _specialKey, char32_t _char) : m_type(_type), m_status(_status), @@ -31,22 +31,22 @@ namespace ewol { m_unicodeData(_char) { }; - void setType(enum ewol::key::keyboard _type) { + void setType(enum gale::key::keyboard _type) { m_type = _type; }; - inline const enum ewol::key::keyboard& getType() const { + inline const enum gale::key::keyboard& getType() const { return m_type; }; - void setStatus(enum ewol::key::status _status) { + void setStatus(enum gale::key::status _status) { m_status = _status; }; - inline const enum ewol::key::status& getStatus() const { + inline const enum gale::key::status& getStatus() const { return m_status; }; - void setSpecialKey(const ewol::key::Special& _specialKey) { + void setSpecialKey(const gale::key::Special& _specialKey) { m_specialKey = _specialKey; }; - inline const ewol::key::Special& getSpecialKey() const { + inline const gale::key::Special& getSpecialKey() const { return m_specialKey; }; void setChar(char32_t _char) { @@ -60,9 +60,9 @@ namespace ewol { class EntrySystem { public: - EntrySystem(enum ewol::key::keyboard _type, - enum ewol::key::status _status, - ewol::key::Special _specialKey, + EntrySystem(enum gale::key::keyboard _type, + enum gale::key::status _status, + gale::key::Special _specialKey, char32_t _char) : m_event(_type, _status, _specialKey, _char) { diff --git a/ewol/event/Input.h b/ewol/event/Input.h index 609d61ae..32e84656 100644 --- a/ewol/event/Input.h +++ b/ewol/event/Input.h @@ -15,17 +15,17 @@ namespace ewol { namespace event { class Input { private: - enum ewol::key::type m_type; - enum ewol::key::status m_status; + enum gale::key::type m_type; + enum gale::key::status m_status; uint8_t m_inputId; vec2 m_pos; - ewol::key::Special m_specialKey; //!< input key status (prevent change in time..) + gale::key::Special m_specialKey; //!< input key status (prevent change in time..) public: - Input(enum ewol::key::type _type, - enum ewol::key::status _status, + Input(enum gale::key::type _type, + enum gale::key::status _status, uint8_t _id, const vec2& _pos, - ewol::key::Special _specialKey): + gale::key::Special _specialKey): m_type(_type), m_status(_status), m_inputId(_id), @@ -33,16 +33,16 @@ namespace ewol { m_specialKey(_specialKey) { }; - void setType(enum ewol::key::type _type) { + void setType(enum gale::key::type _type) { m_type = _type; }; - inline const enum ewol::key::type& getType() const { + inline const enum gale::key::type& getType() const { return m_type; }; - void setStatus(enum ewol::key::status _status) { + void setStatus(enum gale::key::status _status) { m_status = _status; }; - inline const enum ewol::key::status& getStatus() const { + inline const enum gale::key::status& getStatus() const { return m_status; }; void setId(uint8_t _id) { @@ -57,10 +57,10 @@ namespace ewol { inline const vec2& getPos() const { return m_pos; }; - void setSpecialKey(const ewol::key::Special& _specialKey) { + void setSpecialKey(const gale::key::Special& _specialKey) { m_specialKey = _specialKey; }; - inline const ewol::key::Special& getSpecialKey() const { + inline const gale::key::Special& getSpecialKey() const { return m_specialKey; }; /** @@ -74,13 +74,13 @@ namespace ewol { class InputSystem { public: - InputSystem(enum ewol::key::type _type, - enum ewol::key::status _status, + InputSystem(enum gale::key::type _type, + enum gale::key::status _status, uint8_t _id, const vec2& _pos, std::shared_ptr _dest, int32_t _realIdEvent, - ewol::key::Special _specialKey) : + gale::key::Special _specialKey) : m_event(_type, _status, _id, _pos, _specialKey), m_dest(_dest), m_realIdEvent(_realIdEvent) { }; diff --git a/ewol/ewol.cpp b/ewol/ewol.cpp index 4c2cf6c5..a0002d5d 100644 --- a/ewol/ewol.cpp +++ b/ewol/ewol.cpp @@ -9,11 +9,11 @@ #include #include #include +#include -#include +#include #include -#include -#include +#include #undef __class__ #define __class__ "ewol" @@ -48,4 +48,14 @@ std::string ewol::getBoardType() { std::string ewol::getVersion() { return EWOL_VERSION; } +int64_t ewol::getTime() { + return gale::getTime(); +} + +int32_t ewol::run(ewol::context::Application* _application, + int32_t _argc, + const char* _argv[]) { + return gale::run(new ewol::Context(_application), _argc, _argv); +} + diff --git a/ewol/ewol.h b/ewol/ewol.h index 9998d144..be9abc9e 100644 --- a/ewol/ewol.h +++ b/ewol/ewol.h @@ -36,16 +36,19 @@ namespace ewol { * @return The current time * @note is implemented by the OS implementation cf renderer/X11/... */ + // TODO : Remove ... int64_t getTime(); /** * @brief get compilation mode (release/debug) * @return the string of the mode of commpilation */ + // TODO : Remove ... std::string getCompilationMode(); /** * @brief get the board type (Android/Linux/MacOs/...) * @return the string of the mode of commpilation */ + // TODO : Remove ... std::string getBoardType(); }; diff --git a/ewol/key/Special.cpp b/ewol/key/Special.cpp deleted file mode 100644 index 18a786a8..00000000 --- a/ewol/key/Special.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -#define EWOL_FLAG_KEY_CAPS_LOCK 0x00000001 -#define EWOL_FLAG_KEY_SHIFT 0x00000002 -#define EWOL_FLAG_KEY_CTRL 0x00000004 -#define EWOL_FLAG_KEY_META 0x00000008 -#define EWOL_FLAG_KEY_ALT 0x00000010 -#define EWOL_FLAG_KEY_ALTGR 0x00000020 -#define EWOL_FLAG_KEY_NUM_LOCK 0x00000040 -#define EWOL_FLAG_KEY_INSERT 0x00000080 - -// TODO : Update to support the Left and right of some key ... - -ewol::key::Special::Special() : - m_value(0) { - -} -void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) { - switch (_move) { - case keyboardInsert: - setInsert(_isDown); - break; - case keyboardCapLock: - setCapsLock(_isDown); - break; - case keyboardShiftLeft: - case keyboardShiftRight: - setShift(_isDown); - break; - case keyboardCtrlLeft: - case keyboardCtrlRight: - setCtrl(_isDown); - break; - case keyboardMetaLeft: - case keyboardMetaRight: - setMeta(_isDown); - break; - case keyboardAlt: - setAlt(_isDown); - break; - case keyboardAltGr: - setAltGr(_isDown); - break; - case keyboardNumLock: - setNumLock(_isDown); - break; - default: - break; - } -} - -bool ewol::key::Special::getCapsLock() const { - if ((m_value & EWOL_FLAG_KEY_CAPS_LOCK) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setCapsLock(bool _value) { - if ((m_value & EWOL_FLAG_KEY_CAPS_LOCK) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_CAPS_LOCK; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_CAPS_LOCK; - } - } -} - -bool ewol::key::Special::getShift() const { - if ((m_value & EWOL_FLAG_KEY_SHIFT) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setShift(bool _value) { - if ((m_value & EWOL_FLAG_KEY_SHIFT) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_SHIFT; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_SHIFT; - } - } -} - -bool ewol::key::Special::getCtrl() const { - if ((m_value & EWOL_FLAG_KEY_CTRL) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setCtrl(bool _value) { - if ((m_value & EWOL_FLAG_KEY_CTRL) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_CTRL; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_CTRL; - } - } -} - -bool ewol::key::Special::getMeta() const { - if ((m_value & EWOL_FLAG_KEY_META) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setMeta(bool _value) { - if ((m_value & EWOL_FLAG_KEY_META) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_META; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_META; - } - } -} - -bool ewol::key::Special::getAlt() const { - if ((m_value & EWOL_FLAG_KEY_ALT) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setAlt(bool _value) { - if ((m_value & EWOL_FLAG_KEY_ALT) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_ALT; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_ALT; - } - } -} - -bool ewol::key::Special::getAltGr() const { - if ((m_value & EWOL_FLAG_KEY_ALTGR) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setAltGr(bool _value) { - if ((m_value & EWOL_FLAG_KEY_ALTGR) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_ALTGR; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_ALTGR; - } - } -} - -bool ewol::key::Special::getNumLock() const { - if ((m_value & EWOL_FLAG_KEY_NUM_LOCK) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setNumLock(bool _value) { - if ((m_value & EWOL_FLAG_KEY_NUM_LOCK) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_NUM_LOCK; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_NUM_LOCK; - } - } -} - -bool ewol::key::Special::getInsert() const { - if ((m_value & EWOL_FLAG_KEY_INSERT) != 0) { - return true; - } - return false; -} -void ewol::key::Special::setInsert(bool _value) { - if ((m_value & EWOL_FLAG_KEY_INSERT) != 0) { - if (_value == false) { - m_value -= EWOL_FLAG_KEY_INSERT; - } - } else { - if (_value == true) { - m_value += EWOL_FLAG_KEY_INSERT; - } - } -} - -std::ostream& ewol::key::operator <<(std::ostream& _os, const ewol::key::Special _obj) { - _os << " capLock=" << _obj.getCapsLock(); - _os << " shift=" << _obj.getShift(); - _os << " ctrl=" << _obj.getCtrl(); - _os << " meta=" << _obj.getMeta(); - _os << " alt=" << _obj.getAlt(); - _os << " altGr=" << _obj.getAltGr(); - _os << " verNum=" << _obj.getNumLock(); - _os << " insert=" << _obj.getInsert(); - return _os; -} diff --git a/ewol/key/Special.h b/ewol/key/Special.h deleted file mode 100644 index 272e35ed..00000000 --- a/ewol/key/Special.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_KEY_SPECIAL_H__ -#define __EWOL_KEY_SPECIAL_H__ - -#include -#include - -namespace ewol { - namespace key { - /** - * @brief This class consider generic special keyborad key (insert, control, shift ...) - */ - class Special { - private: - uint32_t m_value; - public: - /** - * @brief Main constructor - */ - Special(); - /** - * @brief get the current CapLock Status - * @return The CapLock value - */ - bool getCapsLock() const; - /** - * @brief set the current CapLock Status - * @param[in] _value The new CapLock value - */ - void setCapsLock(bool _value); - /** - * @brief Get the current Shift key status - * @return The Shift value - */ - bool getShift() const; - /** - * @brief Set the current Shift key status - * @param[in] _value The new Shift value - */ - void setShift(bool _value); - /** - * @brief Get the Current Control key status - * @return The Control value - */ - bool getCtrl() const; - /** - * @brief Set the Current Control key status - * @param[in] _value The new Control value - */ - void setCtrl(bool _value); - /** - * @brief Get the current Meta key status (also named windows or apple key) - * @return The Meta value (name Windows key, apple key, command key ...) - */ - bool getMeta() const; - /** - * @brief Set the current Meta key status (also named windows or apple key) - * @param[in] _value The new Meta value (name Windows key, apple key, command key ...) - */ - void setMeta(bool _value); - /** - * @brief Get the current Alt key status - * @return The Alt value - */ - bool getAlt() const; - /** - * @brief Set the current Alt key status - * @param[in] _value The new Alt value - */ - void setAlt(bool _value); - /** - * @brief Get the current Alt-Gr key status - * @return The Alt-gr value (does not exist on MacOs) - */ - bool getAltGr() const; - /** - * @brief Set the current Alt-Gr key status - * @param[in] _value The new Alt-gr value (does not exist on MacOs) - */ - void setAltGr(bool _value); - /** - * @brief Get the current Ver-num key status - * @return The Numerical Lock value - */ - bool getNumLock() const; - /** - * @brief Set the current Ver-num key status - * @param[in] _value The new Numerical Lock value - */ - void setNumLock(bool _value); - /** - * @brief Get the current Intert key status - * @return The Insert value - */ - bool getInsert() const; - /** - * @brief Set the current Intert key status - * @param[in] _value The new Insert value - */ - void setInsert(bool _value); - /** - * @brief Update the internal value with the input moving key. - * @param[in] _move Moving key. - * @param[in] _isFown The Key is pressed or not. - */ - void update(enum ewol::key::keyboard _move, bool _isDown); - }; - std::ostream& operator <<(std::ostream& _os, const ewol::key::Special _obj); - }; -}; - -#endif - - diff --git a/ewol/key/key.h b/ewol/key/key.h deleted file mode 100644 index b455a72f..00000000 --- a/ewol/key/key.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_KEY_H__ -#define __EWOL_KEY_H__ - -#include -#include -#include -#include - -#endif - - diff --git a/ewol/key/keyboard.cpp b/ewol/key/keyboard.cpp deleted file mode 100644 index 997e2115..00000000 --- a/ewol/key/keyboard.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -static const char* keyboardDescriptionString[ewol::key::keyboardCount+1] = { - "keyboardUnknow", - "keyboardChar", - "keyboardLeft", - "keyboardRight", - "keyboardUp", - "keyboardDown", - "keyboardPageUp", - "keyboardPageDown", - "keyboardStart", - "keyboardEnd", - "keyboardPrint", - "keyboardStopDefil", - "keyboardWait", - "keyboardInsert", - "keyboardF1", - "keyboardF2", - "keyboardF3", - "keyboardF4", - "keyboardF5", - "keyboardF6", - "keyboardF7", - "keyboardF8", - "keyboardF9", - "keyboardF10", - "keyboardF11", - "keyboardF12", - "keyboardCapLock", - "keyboardShiftLeft", - "keyboardShiftRight", - "keyboardCtrlLeft", - "keyboardCtrlRight", - "keyboardMetaLeft", - "keyboardMetaRight", - "keyboardAlt", - "keyboardAltGr", - "keyboardContextMenu", - "keyboardNumLock", - "keyboardCount" -}; - -std::ostream& ewol::key::operator <<(std::ostream& _os, const enum ewol::key::keyboard _obj) { - if (_obj >= 0 && _obj = 0 && _obj - -namespace ewol { - namespace key { - /** - * @brief Keybord event or joystick event - * @warning If you modify Id of these element check the java interface file of constant : EwolConstant.java - */ - enum keyboard { - keyboardUnknow = 0, //!< Unknown keyboard key - keyboardChar, //!< Char input is arrived ... - keyboardLeft, //!< Left key <-- - keyboardRight, //!< Right key --> - keyboardUp, //!< Up key ^ - keyboardDown, //!< Down key \/ - keyboardPageUp, //!< Page Up key - keyboardPageDown, //!< page down key - keyboardStart, //!< Start key - keyboardEnd, //!< End key - keyboardPrint, //!< print screen key. - keyboardStopDefil, //!< Stop display key. - keyboardWait, //!< Wait key. - keyboardInsert, //!< insert key. - keyboardF1, //!< F1 key. - keyboardF2, //!< F2 key. - keyboardF3, //!< F3 key. - keyboardF4, //!< F4 key. - keyboardF5, //!< F5 key. - keyboardF6, //!< F6 key. - keyboardF7, //!< F7 key. - keyboardF8, //!< F8 key. - keyboardF9, //!< F9 key. - keyboardF10, //!< F10 key. - keyboardF11, //!< F11 key. - keyboardF12, //!< F12 key. - keyboardCapLock, //!< Capital Letter Lock key. - keyboardShiftLeft, //!< Shift left key. - keyboardShiftRight, //!< Shift right key. - keyboardCtrlLeft, //!< Control left key. - keyboardCtrlRight, //!< Control right key. - keyboardMetaLeft, //!< Meta left key (apple key or windows key). - keyboardMetaRight, //!< Meta right key (apple key or windows key). - keyboardAlt, //!< Alt key. - keyboardAltGr, //!< Alt ground key. - keyboardContextMenu, //!< Contextual menu key. - keyboardNumLock, //!< Numerical Lock key. - keyboardCount //!< number of posible key - }; - /** - * @brief Debug operator To display the curent element in a Human redeable information - */ - std::ostream& operator <<(std::ostream& _os, const enum ewol::key::keyboard _obj); - - enum keyboardSystem { - keyboardSystemUnknow = 0, //!< Unknown keyboard system key - keyboardSystemVolumeUp, //!< Hardware volume UP key - keyboardSystemVolumeDown, //!< Hardware volume DOWN key - keyboardSystemMenu, //!< Hardware Menu key - keyboardSystemCamera, //!< Hardware Camera key - keyboardSystemHome, //!< Hardware Home key - keyboardSystemPower, //!< Hardware Power key - keyboardSystemBack, //!< Hardware Back key - keyboardSystemCount //!< number of posible System key - }; - std::ostream& operator <<(std::ostream& _os, const enum ewol::key::keyboardSystem _obj); - }; -}; - - - -#endif - - diff --git a/ewol/key/status.cpp b/ewol/key/status.cpp deleted file mode 100644 index 6764f3d6..00000000 --- a/ewol/key/status.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - -static const char* statusDescriptionString[ewol::key::statusCount+1] = { - "statusUnknow", - "statusDown", - "statusMove", - "statusSingle", - "statusDouble", - "statusTriple", - "statusQuad", - "statusQuinte", - "statusUp", - "statusUpAfter", - "statusEnter", - "statusLeave", - "statusAbort", - "statusTransfert", - "statusCount" -}; - -std::ostream& ewol::key::operator <<(std::ostream& _os, const enum ewol::key::status _obj) { - if (_obj >= 0 && _obj - -namespace ewol { - namespace key { - /** - * @brief Keybord event or joyestick event - */ - enum status { - statusUnknow = 0, - statusDown, // availlable on Keyboard too - statusMove, - statusSingle, - statusDouble, - statusTriple, - statusQuad, - statusQuinte, - statusUp, // availlable on Keyboard too - statusUpAfter, // mouse input & finger input this appear after the single event (depending on some case...) - statusEnter, - statusLeave, - statusAbort, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has lost the events) - statusTransfert, // Appeare when an event is tranfert betwwen widgets (the widget which receive this has receive the transfert of the event) - statusCount, // number max of imput possible - }; - /** - * @brief Debug operator To display the curent element in a Human redeable information - */ - std::ostream& operator <<(std::ostream& _os, const enum ewol::key::status _obj); - }; -}; - - - -#endif - - diff --git a/ewol/key/type.cpp b/ewol/key/type.cpp deleted file mode 100644 index 66b3ea44..00000000 --- a/ewol/key/type.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include - - -static const char* typeDescriptionString[ewol::key::typeCount+1] = { - "typeUnknow", - "typeMouse", - "typeFinger", - "typeStylet", - "typeCount" -}; - -std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::key::type _obj) { - if (_obj >= 0 && _obj < ewol::key::typeCount) { - _os << typeDescriptionString[_obj]; - } else { - _os << "[ERROR]"; - } - return _os; -} - diff --git a/ewol/key/type.h b/ewol/key/type.h deleted file mode 100644 index a81f6cd6..00000000 --- a/ewol/key/type.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __EWOL_KEY_TYPE_H__ -#define __EWOL_KEY_TYPE_H__ - -#include - -namespace ewol { - namespace key { - /** - * @brief type of input : Note that the keyboard is not prevent due to the fact that data is too different - */ - enum type { - typeUnknow = 0, //!< Unknow input Type - typeMouse, //!< Mouse type - typeFinger, //!< Finger type - typeStylet, //!< Stylet type - typeCount //!< number of types - }; - }; - /** - * @brief Debug operator To display the curent element in a Human redeable information - */ - std::ostream& operator <<(std::ostream& _os, const enum ewol::key::type _obj); -}; - - - -#endif - - diff --git a/ewol/object/Manager.cpp b/ewol/object/Manager.cpp index 26342d37..53d3abc7 100644 --- a/ewol/object/Manager.cpp +++ b/ewol/object/Manager.cpp @@ -17,7 +17,7 @@ ewol::object::Manager::Manager(ewol::Context& _context) : m_context(_context), - periodicCall(*this, "periodic", "Call every time system render"), + periodicCall(*this, "periodic", "Call every time system render", true), m_applWakeUpTime(0), m_lastPeriodicCallTime(0) { EWOL_DEBUG(" == > init Object-Manager"); diff --git a/ewol/object/Object.cpp b/ewol/object/Object.cpp index baa5bc16..3c89f5ef 100644 --- a/ewol/object/Object.cpp +++ b/ewol/object/Object.cpp @@ -145,15 +145,16 @@ bool ewol::Object::parameterSetOnWidgetNamed(const std::string& _objectName, con return object->parameterSet(_config, _value); } -ewol::object::Manager& ewol::Object::getObjectManager() const { +ewol::object::Manager& ewol::Object::getObjectManager() { ewol::object::Manager& tmp = ewol::getContext().getEObjectManager(); return tmp; } -ewol::Context& ewol::Object::getContext() const { +ewol::Context& ewol::Object::getContext() { return ewol::getContext(); } -std::shared_ptr ewol::Object::getObjectNamed(const std::string& _objectName) const { + +std::shared_ptr ewol::Object::getObjectNamed(const std::string& _objectName) { return getObjectManager().getObjectNamed(_objectName); } @@ -171,4 +172,5 @@ bool ewol::parameterSetOnObjectNamed(const std::string& _objectName, const std:: return false; } return object->parameterSet(_config, _value); -} \ No newline at end of file +} + diff --git a/ewol/object/Object.h b/ewol/object/Object.h index 549edadf..8211cd64 100644 --- a/ewol/object/Object.h +++ b/ewol/object/Object.h @@ -45,6 +45,32 @@ namespace ewol { return object; \ } +#define DECLARE_SINGLE_FACTORY(className,uniqueName) \ + template static std::shared_ptr create( T&& ... all ) { \ + std::shared_ptr object; \ + std::shared_ptr object2 = getObjectNamed(uniqueName); \ + if (object2 != nullptr) { \ + object = std::dynamic_pointer_cast(object2); \ + if (object == nullptr) { \ + GALE_CRITICAL("Request object element: '" << uniqueName << "' With the wrong type (dynamic cast error)"); \ + return nullptr; \ + } \ + } \ + if (object != nullptr) { \ + return object; \ + } \ + object = std::shared_ptr(new className()); \ + if (object == nullptr) { \ + EWOL_ERROR("Factory error"); \ + return nullptr; \ + } \ + object->init(uniqueName, std::forward(all)... ); \ + if (object->objectHasBeenCorectlyInit() == false) { \ + EWOL_CRITICAL("Object is not correctly init : " << #className ); \ + } \ + return object; \ + } + namespace ewol { /** * @brief Basic message classes for ewol system @@ -181,12 +207,12 @@ namespace ewol { * @breif get the current Object manager. * @return the requested object manager. */ - ewol::object::Manager& getObjectManager() const; + static ewol::object::Manager& getObjectManager(); /** * @brief get the curent the system inteface. * @return current reference on the instance. */ - ewol::Context& getContext() const; + static ewol::Context& getContext(); private: bool m_isResource; //!< enable this when you want to declare this element is auto-remove public: @@ -210,7 +236,7 @@ namespace ewol { * @param[in] _name Name of the object * @return the requested object or nullptr */ - std::shared_ptr getObjectNamed(const std::string& _objectName) const; + static std::shared_ptr getObjectNamed(const std::string& _objectName); /** * @brief Retrive an object with his name (in the global list) * @param[in] _name Name of the object diff --git a/ewol/openGL/openGL.cpp b/ewol/openGL/openGL.cpp deleted file mode 100644 index cc6d2306..00000000 --- a/ewol/openGL/openGL.cpp +++ /dev/null @@ -1,496 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -//#define DIRECT_MODE - -#define CHECK_ERROR_OPENGL - -static void checkGlError(const char* _op, int32_t _localLine) { - #ifdef CHECK_ERROR_OPENGL - bool hasError = false; - for (GLint error = glGetError(); error; error = glGetError()) { - EWOL_ERROR("after " << _op << "():" << _localLine << " glError(" << error << ")"); - hasError = true; - } - if (hasError == true) { - EWOL_CRITICAL("plop"); - } - #endif -} - -#define OPENGL_ERROR(data) do { } while (false) -//#define OPENGL_ERROR(data) EWOL_ERROR(data) -#define OPENGL_WARNING(data) do { } while (false) -//#define OPENGL_WARNING(data) EWOL_WARNING(data) -#define OPENGL_INFO(data) do { } while (false) -//#define OPENGL_INFO(data) EWOL_INFO(data) - - -/** - * @brief get the draw mutex (ewol render). - * @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 - */ -static std::mutex& mutexOpenGl() { - static std::mutex s_drawMutex; - return s_drawMutex; -} - -std::vector l_matrixList; -mat4 l_matrixCamera; -static uint32_t l_flagsCurrent = 0; -static uint32_t l_flagsMustBeSet = 0; -static uint32_t l_textureflags = 0; -static int32_t l_programId = 0; - - -void ewol::openGL::lock() { - mutexOpenGl().lock(); - l_matrixList.clear(); - mat4 tmpMat; - l_matrixList.push_back(tmpMat); - l_matrixCamera.identity(); - l_flagsCurrent = 0; - l_flagsMustBeSet = 0; - l_textureflags = 0; - l_programId = -1; -} - -void ewol::openGL::unLock() { - mutexOpenGl().unlock(); -} - -void ewol::openGL::setBasicMatrix(const mat4& _newOne) { - if (l_matrixList.size()!=1) { - EWOL_ERROR("matrix is not corect size in the stack : " << l_matrixList.size()); - } - l_matrixList.clear(); - l_matrixList.push_back(_newOne); -} - -void ewol::openGL::setMatrix(const mat4& _newOne) { - if (l_matrixList.size() == 0) { - EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); - l_matrixList.push_back(_newOne); - return; - } - l_matrixList[l_matrixList.size()-1] = _newOne; -} - -void ewol::openGL::push() { - if (l_matrixList.size() == 0) { - EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); - mat4 tmp; - l_matrixList.push_back(tmp); - return; - } - mat4 tmp = l_matrixList[l_matrixList.size()-1]; - l_matrixList.push_back(tmp); -} - -void ewol::openGL::pop() { - if (l_matrixList.size() <= 1) { - EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); - l_matrixList.clear(); - mat4 tmp; - l_matrixList.push_back(tmp); - l_matrixCamera.identity(); - return; - } - l_matrixList.pop_back(); - l_matrixCamera.identity(); -} - -const mat4& ewol::openGL::getMatrix() { - if (l_matrixList.size() == 0) { - EWOL_ERROR("set matrix list is not corect size in the stack : " << l_matrixList.size()); - mat4 tmp; - l_matrixList.push_back(tmp); - } - return l_matrixList[l_matrixList.size()-1]; -} - -const mat4& ewol::openGL::getCameraMatrix() { - return l_matrixCamera; -} - -void ewol::openGL::setCameraMatrix(const mat4& _newOne) { - l_matrixCamera = _newOne; -} - -void ewol::openGL::finish() { - l_programId = -1; - l_textureflags = 0; -} - -void ewol::openGL::flush() { - l_programId = -1; - l_textureflags = 0; - glFlush(); - OPENGL_INFO("========================" ); - OPENGL_INFO("== FLUSH OPEN GL ==" ); - OPENGL_INFO("========================"); -} - -void ewol::openGL::swap() { - -} - - -std::ostream& ewol::operator <<(std::ostream& _os, const enum openGL::openGlFlags& _obj) { - static std::vector> list = { - std::make_pair(openGL::FLAG_BLEND, "FLAG_BLEND"), - std::make_pair(openGL::FLAG_CLIP_DISTANCE_I, "FLAG_CLIP_DISTANCE_I"), - std::make_pair(openGL::FLAG_COLOR_LOGIC_OP, "FLAG_COLOR_LOGIC_OP"), - std::make_pair(openGL::FLAG_CULL_FACE, "FLAG_CULL_FACE"), - std::make_pair(openGL::FLAG_DEBUG_OUTPUT, "FLAG_DEBUG_OUTPUT"), - std::make_pair(openGL::FLAG_DEBUG_OUTPUT_SYNCHRONOUS, "FLAG_DEBUG_OUTPUT_SYNCHRONOUS"), - std::make_pair(openGL::FLAG_DEPTH_CLAMP, "FLAG_DEPTH_CLAMP"), - std::make_pair(openGL::FLAG_DEPTH_TEST, "FLAG_DEPTH_TEST"), - std::make_pair(openGL::FLAG_DITHER, "FLAG_DITHER"), - std::make_pair(openGL::FLAG_FRAMEBUFFER_SRGB, "FLAG_FRAMEBUFFER_SRGB"), - std::make_pair(openGL::FLAG_LINE_SMOOTH, "FLAG_LINE_SMOOTH"), - std::make_pair(openGL::FLAG_MULTISAMPLE, "FLAG_MULTISAMPLE"), - std::make_pair(openGL::FLAG_POLYGON_OFFSET_FILL, "FLAG_POLYGON_OFFSET_FILL"), - std::make_pair(openGL::FLAG_POLYGON_OFFSET_LINE, "FLAG_POLYGON_OFFSET_LINE"), - std::make_pair(openGL::FLAG_POLYGON_OFFSET_POINT, "FLAG_POLYGON_OFFSET_POINT"), - std::make_pair(openGL::FLAG_POLYGON_SMOOTH, "FLAG_POLYGON_SMOOTH"), - std::make_pair(openGL::FLAG_PRIMITIVE_RESTART, "FLAG_PRIMITIVE_RESTART"), - std::make_pair(openGL::FLAG_PRIMITIVE_RESTART_FIXED_INDEX, "FLAG_PRIMITIVE_RESTART_FIXED_INDEX"), - std::make_pair(openGL::FLAG_SAMPLE_ALPHA_TO_COVERAGE, "FLAG_SAMPLE_ALPHA_TO_COVERAGE"), - std::make_pair(openGL::FLAG_SAMPLE_ALPHA_TO_ONE, "FLAG_SAMPLE_ALPHA_TO_ONE"), - std::make_pair(openGL::FLAG_SAMPLE_COVERAGE, "FLAG_SAMPLE_COVERAGE"), - std::make_pair(openGL::FLAG_SAMPLE_SHADING, "FLAG_SAMPLE_SHADING"), - std::make_pair(openGL::FLAG_SAMPLE_MASK, "FLAG_SAMPLE_MASK"), - std::make_pair(openGL::FLAG_SCISSOR_TEST, "FLAG_SCISSOR_TEST"), - std::make_pair(openGL::FLAG_STENCIL_TEST, "FLAG_STENCIL_TEST"), - std::make_pair(openGL::FLAG_PROGRAM_POINT_SIZE, "FLAG_PROGRAM_POINT_SIZE"), - std::make_pair(openGL::FLAG_TEXTURE_2D, "FLAG_TEXTURE_2D"), - std::make_pair(openGL::FLAG_ALPHA_TEST, "FLAG_ALPHA_TEST"), - std::make_pair(openGL::FLAG_FOG, "FLAG_FOG") - }; - _os << "{"; - bool hasOne = false; - for (auto &it : list) { - if ((_obj & it.first) != 0) { - if (hasOne==true) { - _os << ","; - } - _os << it.second; - hasOne = true; - } - } - _os << "}"; - return _os; -} - - -std::vector>& getListRenderMode() { - static std::vector> list = { - std::make_pair(ewol::openGL::renderPoint, "POINTS"), - std::make_pair(ewol::openGL::renderLine, "LINES"), - std::make_pair(ewol::openGL::renderLineStrip, "LINES_STRIP"), - std::make_pair(ewol::openGL::renderLineLoop, "LINE_LOOP"), - std::make_pair(ewol::openGL::renderTriangle, "TRIANGLE"), - std::make_pair(ewol::openGL::renderTriangleStrip, "TRIANGLE_STRIP"), - std::make_pair(ewol::openGL::renderTriangleFan, "TRIANGLE_FAN"), - std::make_pair(ewol::openGL::renderQuad, "QUAD"), - std::make_pair(ewol::openGL::renderQuadStrip, "QUAD_STRIP"), - std::make_pair(ewol::openGL::renderPolygon, "POLYGON"), - }; - return list; -} - - -namespace etk { - template<> std::string to_string(const ewol::openGL::renderMode& _obj) { - for (auto &it : getListRenderMode()) { - if (it.first == _obj) { - return it.second; - } - } - EWOL_ERROR("Can not convert : " << static_cast(_obj) << " return UNKNOW"); - return "UNKNOW"; - } - template<> std::u32string to_u32string(const ewol::openGL::renderMode& _obj) { - return etk::to_u32string(etk::to_string(_obj)); - } - template<> bool from_string(ewol::openGL::renderMode& _variableRet, const std::string& _value) { - for (auto &it : getListRenderMode()) { - if (it.second == _value) { - _variableRet = it.first; - return true; - } - } - EWOL_WARNING("Can not parse : '" << _value << "' set Triangle default value"); - _variableRet = ewol::openGL::renderTriangle; - return false; - } - template<> bool from_string(ewol::openGL::renderMode& _variableRet, const std::u32string& _value) { - return from_string(_variableRet, etk::to_string(_value)); - } -}; - -std::ostream& ewol::operator <<(std::ostream& _os, const enum openGL::renderMode& _obj) { - _os << etk::to_string(_obj); - return _os; -} - - -typedef struct { - uint32_t curentFlag; - GLenum OGlFlag; -} correspondenceTable_ts; - -static correspondenceTable_ts basicFlag[] = { - {(uint32_t)ewol::openGL::FLAG_BLEND, GL_BLEND}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_CLIP_DISTANCE_I, GL_CLIP_DISTANCE0}, - {(uint32_t)ewol::openGL::FLAG_COLOR_LOGIC_OP, GL_COLOR_LOGIC_OP}, - #endif - {(uint32_t)ewol::openGL::FLAG_CULL_FACE, GL_CULL_FACE}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_DEBUG_OUTPUT, GL_DEBUG_OUTPUT}, - {(uint32_t)ewol::openGL::FLAG_DEBUG_OUTPUT_SYNCHRONOUS, GL_DEBUG_OUTPUT_SYNCHRONOUS}, - {(uint32_t)ewol::openGL::FLAG_DEPTH_CLAMP, GL_DEPTH_CLAMP}, - #endif - {(uint32_t)ewol::openGL::FLAG_DEPTH_TEST, GL_DEPTH_TEST}, - {(uint32_t)ewol::openGL::FLAG_DITHER, GL_DITHER}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_FRAMEBUFFER_SRGB, GL_FRAMEBUFFER_SRGB}, - {(uint32_t)ewol::openGL::FLAG_LINE_SMOOTH, GL_LINE_SMOOTH}, - {(uint32_t)ewol::openGL::FLAG_MULTISAMPLE, GL_MULTISAMPLE}, - #endif - {(uint32_t)ewol::openGL::FLAG_POLYGON_OFFSET_FILL, GL_POLYGON_OFFSET_FILL}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_POLYGON_OFFSET_LINE, GL_POLYGON_OFFSET_LINE}, - {(uint32_t)ewol::openGL::FLAG_POLYGON_OFFSET_POINT, GL_POLYGON_OFFSET_POINT}, - {(uint32_t)ewol::openGL::FLAG_POLYGON_SMOOTH, GL_POLYGON_SMOOTH}, - {(uint32_t)ewol::openGL::FLAG_PRIMITIVE_RESTART, GL_PRIMITIVE_RESTART}, - {(uint32_t)ewol::openGL::FLAG_PRIMITIVE_RESTART_FIXED_INDEX, GL_PRIMITIVE_RESTART_FIXED_INDEX}, - #endif - {(uint32_t)ewol::openGL::FLAG_SAMPLE_ALPHA_TO_COVERAGE, GL_SAMPLE_ALPHA_TO_COVERAGE}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_SAMPLE_ALPHA_TO_ONE, GL_SAMPLE_ALPHA_TO_ONE}, - #endif - {(uint32_t)ewol::openGL::FLAG_SAMPLE_COVERAGE, GL_SAMPLE_COVERAGE}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_SAMPLE_SHADING, GL_SAMPLE_SHADING}, - {(uint32_t)ewol::openGL::FLAG_SAMPLE_MASK, GL_SAMPLE_MASK}, - #endif - {(uint32_t)ewol::openGL::FLAG_SCISSOR_TEST, GL_SCISSOR_TEST}, - {(uint32_t)ewol::openGL::FLAG_STENCIL_TEST, GL_STENCIL_TEST}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_PROGRAM_POINT_SIZE, GL_PROGRAM_POINT_SIZE}, - #endif - {(uint32_t)ewol::openGL::FLAG_TEXTURE_2D, GL_TEXTURE_2D}, - #if 0 - !(defined(__TARGET_OS__Android) || defined(__TARGET_OS__MacOs)) - {(uint32_t)ewol::openGL::FLAG_ALPHA_TEST, GL_ALPHA_TEST}, - {(uint32_t)ewol::openGL::FLAG_FOG, GL_FOG} - #endif - //{(uint32_t)ewol::openGL::FLAG_, GL_} -}; -static int32_t basicFlagCount = sizeof(basicFlag) / sizeof(correspondenceTable_ts); - -void ewol::openGL::reset() { - #ifdef DIRECT_MODE - EWOL_TODO("..."); - #else - l_flagsMustBeSet = 0; - l_programId = -1; - l_textureflags = 0; - updateAllFlags(); - #endif -} - -void ewol::openGL::enable(enum ewol::openGL::openGlFlags _flagID) { - //EWOL_INFO("Enable : " " << l_flagsMustBeSet); - #endif -} - -void ewol::openGL::disable(enum ewol::openGL::openGlFlags _flagID) { - //EWOL_INFO("Disable : " << _flagID); - #ifdef DIRECT_MODE - for (int32_t iii=0; iii" << l_flagsMustBeSet); - #endif -} - -void ewol::openGL::updateAllFlags() { - #ifdef DIRECT_MODE - return; - #endif - // check if fhags has change : - if (l_flagsMustBeSet == l_flagsCurrent ) { - OPENGL_INFO("OGL: current flag : " << (enum openGL::openGlFlags)l_flagsMustBeSet); - return; - } - OPENGL_INFO("OGL: set new flag : " << (enum openGL::openGlFlags)l_flagsMustBeSet); - for (int32_t iii=0; iii= 0) { - glActiveTexture(_flagID); - } -} - -void ewol::openGL::desActiveTexture(uint32_t _flagID) { - if (l_programId >= 0) { - - } -} - -void ewol::openGL::drawArrays(uint32_t _mode, int32_t _first, int32_t _count) { - if (l_programId >= 0) { - updateAllFlags(); - glDrawArrays(_mode, _first, _count); - } -} - -void ewol::openGL::drawElements(uint32_t _mode, const std::vector& _indices) { - if (l_programId >= 0) { - updateAllFlags(); - //EWOL_DEBUG("Request draw of " << indices.size() << "elements"); - glDrawElements(_mode, _indices.size(), GL_UNSIGNED_INT, &_indices[0]); - } -} - -void ewol::openGL::drawElements16(uint32_t _mode, const std::vector& _indices) { - if (l_programId >= 0) { - updateAllFlags(); - glDrawElements(_mode, _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]); - } -} - -void ewol::openGL::drawElements8(uint32_t _mode, const std::vector& _indices) { - if (l_programId >= 0) { - updateAllFlags(); - glDrawElements(_mode, _indices.size(), GL_UNSIGNED_BYTE, &_indices[0]); - } -} - -void ewol::openGL::useProgram(int32_t _id) { - //EWOL_DEBUG("USE prog : " << id); - #if 1 - // 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 - // user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ... - if (-1 == _id) { - // not used == > because it is unneded - return; - } - if (l_programId != _id) { - l_programId = _id; - glUseProgram(l_programId); - } - #else - if (-1 == _id) { - glUseProgram(0); - } else { - l_programId = _id; - glUseProgram(_id); - } - #endif -} - - - - -bool ewol::openGL::genBuffers(std::vector& _buffers) { - if (_buffers.size() == 0) { - EWOL_WARNING("try to generate vector buffer with size 0"); - return true; - } - OPENGL_INFO("Create N=" << _buffers.size() << " Buffer"); - glGenBuffers(_buffers.size(), &_buffers[0]); - checkGlError("glGenBuffers", __LINE__); - bool hasError = false; - for (size_t iii=0; iii<_buffers.size(); iii++) { - if (_buffers[iii] == 0) { - EWOL_ERROR("[" << iii << "] error to create a buffer id=" << _buffers[iii]); - hasError = true; - } - } - return hasError; -} - -bool ewol::openGL::deleteBuffers(std::vector& _buffers) { - if (_buffers.size() == 0) { - EWOL_WARNING("try to delete vector buffer with size 0"); - return true; - } - glDeleteBuffers(_buffers.size(), &_buffers[0]); - checkGlError("glDeleteBuffers", __LINE__); - for (auto &it : _buffers) { - it = 0; - } - return true; -} - -bool ewol::openGL::bindBuffer(GLuint _bufferId) { - glBindBuffer(GL_ARRAY_BUFFER, _bufferId); - checkGlError("glBindBuffer", __LINE__); - return true; -} - -bool ewol::openGL::bufferData(size_t _size, const void* _data, GLenum _usage) { - glBufferData(GL_ARRAY_BUFFER, _size, _data, _usage); - checkGlError("glBufferData", __LINE__); - return true; -} - -bool ewol::openGL::unbindBuffer() { - glBindBuffer(GL_ARRAY_BUFFER, 0); - checkGlError("glBindBuffer(0)", __LINE__); - return true; -} - diff --git a/ewol/openGL/openGL.h b/ewol/openGL/openGL.h deleted file mode 100644 index 5a880fd1..00000000 --- a/ewol/openGL/openGL.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __OPEN_GL_H__ -#define __OPEN_GL_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(__TARGET_OS__Linux) - // TO ENABLE THE SHADER api ... - #define GL_GLEXT_PROTOTYPES - #include - // TODO : Check it it work - // This is to prevent the use of these element that is not allowed in the openGL ES - #undef glVertexPointer - #undef glTexCoordPointer - #undef glColorPointer - #undef glPopMatrix - #undef glPushMatrix - #undef glMatrixMode - #undef glLoadIdentity - #undef glTranslatef -#elif defined(__TARGET_OS__Android) - // Include openGL ES 2 - #include - #include -#elif defined(__TARGET_OS__Windows) - // TO ENABLE THE SHADER api ... - //#define GL_GLEXT_PROTOTYPES - #define GLEW_STATIC - #include -#elif defined(__TARGET_OS__MacOs) - #include - #include -#elif defined(__TARGET_OS__IOs) - #include -#else - #error you need to specify a __TAGET_OS__ ... -#endif - -#ifdef __cplusplus -} -#endif - -namespace ewol { - namespace openGL { - /** - * @brief Lock the openGL context for one user only == > better to keep flags and other things ... - */ - void lock(); - /** - * @brief Un-lock the openGL context for an other user... - */ - void unLock(); - /** - * @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 - */ - 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). - * @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 - */ - void setMatrix(const mat4& _newOne); - /** - * @brief store current matrix in the matrix stack. - */ - void push(); - /** - * @brief remove the current matrix and get the last one from the matrix stack. - */ - void pop(); - /** - * @brief get a reference on the current matrix destinate to opengl renderer. - * @return The requested matrix. - */ - const mat4& getMatrix(); - /** - * @brief get a reference on the current matrix camera destinate to opengl renderer. - * @return The requested matrix. - */ - const mat4& getCameraMatrix(); - /** - * @brief set a reference on the current camera to opengl renderer. - * @param[in] _newOne The requested matrix. - */ - void setCameraMatrix(const mat4& _newOne); - /** - * @brief - */ - void finish(); - /** - * @brief - */ - void flush(); - /** - * @brief - */ - void swap(); - - enum openGlFlags { - FLAG_BLEND = 1<<0, //!< If enabled, blend the computed fragment color values with the values in the color buffers. See glBlendFunc. - FLAG_CLIP_DISTANCE_I = 1<<1, //!< If enabled, clip geometry against user-defined half space i. - FLAG_COLOR_LOGIC_OP = 1<<2, //!< If enabled, apply the currently selected logical operation to the computed fragment color and color buffer values. See glLogicOp. - FLAG_CULL_FACE = 1<<3, //!< If enabled, cull polygons based on their winding in window coordinates. See glCullFace. - FLAG_DEBUG_OUTPUT = 1<<4, //!< If enabled, debug messages are produced by a debug context. When disabled, the debug message log is silenced. Note that in a non-debug context, very few, if any messages might be produced, even when GL_DEBUG_OUTPUT is enabled. - FLAG_DEBUG_OUTPUT_SYNCHRONOUS = 1<<5, //!< If enabled, debug messages are produced synchronously by a debug context. If disabled, debug messages may be produced asynchronously. In particular, they may be delayed relative to the execution of GL commands, and the debug callback function may be called from a thread other than that in which the commands are executed. See glDebugMessageCallback. - FLAG_DEPTH_CLAMP = 1<<6, //!< If enabled, the -wc≤zc≤wc plane equation is ignored by view volume clipping (effectively, there is no near or far plane clipping). See glDepthRange. - FLAG_DEPTH_TEST = 1<<7, //!< If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See glDepthFunc and glDepthRange. - FLAG_DITHER = 1<<8, //!< If enabled, dither color components or indices before they are written to the color buffer. - FLAG_FRAMEBUFFER_SRGB = 1<<9, //!< If enabled and the value of GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment corresponding to the destination buffer is GL_SRGB, the R, G, and B destination color values (after conversion from fixed-point to floating-point) are considered to be encoded for the sRGB color space and hence are linearized prior to their use in blending. - FLAG_LINE_SMOOTH = 1<<10, //!< If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth. - FLAG_MULTISAMPLE = 1<<11, //!< If enabled, use multiple fragment samples in computing the final color of a pixel. See glSampleCoverage. - FLAG_POLYGON_OFFSET_FILL = 1<<12, //!< If enabled, and if the polygon is rendered in GL_FILL mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset. - FLAG_POLYGON_OFFSET_LINE = 1<<13, //!< If enabled, and if the polygon is rendered in GL_LINE mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset. - FLAG_POLYGON_OFFSET_POINT = 1<<14, //!< If enabled, an offset is added to depth values of a polygon's fragments before the depth comparison is performed, if the polygon is rendered in GL_POINT mode. See glPolygonOffset. - FLAG_POLYGON_SMOOTH = 1<<15, //!< If enabled, draw polygons with proper filtering. Otherwise, draw aliased polygons. For correct antialiased polygons, an alpha buffer is needed and the polygons must be sorted front to back. - FLAG_PRIMITIVE_RESTART = 1<<16, //!< enables primitive restarting. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the primitive restart index. See glPrimitiveRestartIndex. - FLAG_PRIMITIVE_RESTART_FIXED_INDEX = 1<<17, //!< enables primitive restarting with a fixed index. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the fixed primitive index for the specified index type. The fixed index is equal to 2n−1 where n is equal to 8 for GL_UNSIGNED_BYTE, 16 for GL_UNSIGNED_SHORT and 32 for GL_UNSIGNED_INT. - FLAG_SAMPLE_ALPHA_TO_COVERAGE = 1<<18, //!< If enabled, compute a temporary coverage value where each bit is determined by the alpha value at the corresponding sample location. The temporary coverage value is then ANDed with the fragment coverage value. - FLAG_SAMPLE_ALPHA_TO_ONE = 1<<19, //!< If enabled, each sample alpha value is replaced by the maximum representable alpha value. - FLAG_SAMPLE_COVERAGE = 1<<20, //!< If enabled, the fragment's coverage is ANDed with the temporary coverage value. If GL_SAMPLE_COVERAGE_INVERT is set to GL_TRUE, invert the coverage value. See glSampleCoverage. - FLAG_SAMPLE_SHADING = 1<<21, //!< If enabled, the active fragment shader is run once for each covered sample, or at fraction of this rate as determined by the current value of GL_MIN_SAMPLE_SHADING_VALUE. See glMinSampleShading. - FLAG_SAMPLE_MASK = 1<<22, //!< If enabled, the sample coverage mask generated for a fragment during rasterization will be ANDed with the value of GL_SAMPLE_MASK_VALUE before shading occurs. See glSampleMaski. - FLAG_SCISSOR_TEST = 1<<23, //!< If enabled, discard fragments that are outside the scissor rectangle. See glScissor. - FLAG_STENCIL_TEST = 1<<24, //!< If enabled, do stencil testing and update the stencil buffer. See glStencilFunc and glStencilOp. GL_TEXTURE_CUBE_MAP_SEAMLESS = 1<<0, //!< If enabled, cubemap textures are sampled such that when linearly sampling from the border between two adjacent faces, texels from both faces are used to generate the final sample value. When disabled, texels from only a single face are used to construct the final sample value. - FLAG_PROGRAM_POINT_SIZE = 1<<25, //!< If enabled and a vertex or geometry shader is active, then the derived point size is taken from the (potentially clipped) shader builtin gl_PointSize and clamped to the implementation-dependent point size range. - FLAG_TEXTURE_2D = 1<<26, //!< - FLAG_ALPHA_TEST = 1<<27, //!< - FLAG_FOG = 1<<28, //!< - }; - enum renderMode { - renderPoint = GL_POINTS, - renderLine = GL_LINES, - renderLineStrip = GL_LINE_STRIP, //!< Not supported in EWOL (TODO : Later) - renderLineLoop = GL_LINE_LOOP, - renderTriangle = GL_TRIANGLES, - renderTriangleStrip = GL_TRIANGLE_STRIP, //!< Not supported in EWOL (TODO : Later) - renderTriangleFan = GL_TRIANGLE_FAN, //!< Not supported in EWOL (TODO : Later) - #if (!defined(__TARGET_OS__IOs) && !defined(__TARGET_OS__Android)) - renderQuad = GL_QUADS, //!< Not supported in OpenGL-ES2 - renderQuadStrip = GL_QUAD_STRIP, //!< Not supported in OpenGL-ES2 - renderPolygon = GL_POLYGON //!< Not supported in OpenGL-ES2 - #else - renderQuad, //!< Not supported in OpenGL-ES2 - renderQuadStrip, //!< Not supported in OpenGL-ES2 - renderPolygon //!< Not supported in OpenGL-ES2 - #endif - }; - - /** - * @brief enable a flag on the system - * @param[in] flagID The flag requested - */ - void enable(enum openGlFlags _flagID); - /** - * @brief disable a flag on the system - * @param[in] flagID The flag requested - */ - void disable(enum openGlFlags _flagID); - /** - * @brieg update all the internal flag needed to be set from tre previous element set ... - */ - void updateAllFlags(); - /** - * @brief enable Texture on the system - * @param[in] flagID The flag requested - */ - void activeTexture(uint32_t _flagID); - /** - * @brief disable Texture on the system - * @param[in] flagID The flag requested - */ - void desActiveTexture(uint32_t _flagID); - /** - * @brief draw a specific array == > this enable mode difference ... - */ - void drawArrays(uint32_t _mode, int32_t _first, int32_t _count); - void drawElements (uint32_t _mode, const std::vector& _indices); - void drawElements16(uint32_t _mode, const std::vector& _indices); - void drawElements8 (uint32_t _mode, const std::vector& _indices); - /** - * @brief Use openGL program - * @param[in] id Id of the program that might be used - */ - void useProgram(int32_t _id); - void reset(); - - - bool genBuffers(std::vector& _buffers); - bool deleteBuffers(std::vector& _buffers); - bool bindBuffer(GLuint _bufferId); - bool bufferData(size_t _size, const void* _data, GLenum _usage); - bool unbindBuffer(); - }; - std::ostream& operator <<(std::ostream& _os, const enum openGL::openGlFlags& _obj); - std::ostream& operator <<(std::ostream& _os, const enum openGL::renderMode& _obj); -}; - - -#endif diff --git a/ewol/resource/ColorFile.cpp b/ewol/resource/ColorFile.cpp index 750b8450..5e38c4c5 100644 --- a/ewol/resource/ColorFile.cpp +++ b/ewol/resource/ColorFile.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -18,13 +17,14 @@ ewol::resource::ColorFile::ColorFile() : - ewol::Resource(), + gale::Resource(), m_errorColor(etk::color::orange) { - addObjectType("ewol::ColorFile"); + addResourceType("ewol::ColorFile"); } void ewol::resource::ColorFile::init(const std::string& _filename) { - ewol::Resource::init(_filename); + std11::unique_lock lock(m_mutex); + gale::Resource::init(_filename); EWOL_DEBUG("CF : load \"" << _filename << "\""); reload(); EWOL_DEBUG("List of all color : " << m_list.getKeys()); @@ -37,6 +37,7 @@ ewol::resource::ColorFile::~ColorFile() { void ewol::resource::ColorFile::reload() { + std11::unique_lock lock(m_mutex); // remove all previous set of value : for (int32_t iii = 0; iii < m_list.size() ; ++iii) { m_list[iii] = m_errorColor; @@ -71,6 +72,7 @@ void ewol::resource::ColorFile::reload() { int32_t ewol::resource::ColorFile::request(const std::string& _paramName) { + std11::unique_lock lock(m_mutex); // check if the parameters existed : if (m_list.exist(_paramName) == false) { m_list.add(_paramName, m_errorColor); diff --git a/ewol/resource/ColorFile.h b/ewol/resource/ColorFile.h index 3b152c49..0338632f 100644 --- a/ewol/resource/ColorFile.h +++ b/ewol/resource/ColorFile.h @@ -13,14 +13,14 @@ #include #include #include -#include +#include namespace ewol { namespace resource { /** * @brief ColorFile is a Resource designed to be specific with the theme (for example black, or white or orange ...) */ - class ColorFile : public ewol::Resource { + class ColorFile : public gale::Resource { private: etk::Hash > m_list; //!< List of all color in the file etk::Color m_errorColor; //!< Error returned color diff --git a/ewol/resource/Colored3DObject.cpp b/ewol/resource/Colored3DObject.cpp index d934aea0..61467d4c 100644 --- a/ewol/resource/Colored3DObject.cpp +++ b/ewol/resource/Colored3DObject.cpp @@ -8,7 +8,8 @@ #include #include -#include +#include +#include #undef __class__ #define __class__ "resource::Colored3DObject" @@ -16,15 +17,15 @@ ewol::resource::Colored3DObject::Colored3DObject() : m_GLprogram(nullptr) { - addObjectType("ewol::Colored3DObject"); + addResourceType("ewol::Colored3DObject"); } void ewol::resource::Colored3DObject::init() { - ewol::Resource::init(); + gale::Resource::init(); // get the shader resource : m_GLPosition = 0; - m_GLprogram = ewol::resource::Program::create("DATA:simple3D.prog"); - if (nullptr != m_GLprogram ) { + m_GLprogram = gale::resource::Program::create("{ewol}DATA:simple3D.prog"); + if (m_GLprogram != nullptr) { m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); m_GLColor = m_GLprogram->getUniform("EW_color"); m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); @@ -48,7 +49,7 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, return; } if (true == _depthtest) { - ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::enable(gale::openGL::flag_depthTest); if (false == _updateDepthBuffer) { glDepthMask(GL_FALSE); } @@ -56,8 +57,8 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, //EWOL_DEBUG(" display " << m_coord.size() << " elements" ); m_GLprogram->use(); // set Matrix : translation/positionMatrix - mat4 projMatrix = ewol::openGL::getMatrix(); - mat4 camMatrix = ewol::openGL::getCameraMatrix(); + mat4 projMatrix = gale::openGL::getMatrix(); + mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix; m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // position : @@ -65,7 +66,7 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, // color : m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, _vertices.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, _vertices.size()); m_GLprogram->unUse(); // Request the draw od the elements : //glDrawArrays(GL_LINES, 0, vertices.size()); @@ -74,7 +75,7 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); } - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_depthTest); } } @@ -91,7 +92,7 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, return; } if (true == _depthtest) { - ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::enable(gale::openGL::flag_depthTest); if (false == _updateDepthBuffer) { glDepthMask(GL_FALSE); } @@ -99,8 +100,8 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, //EWOL_DEBUG(" display " << m_coord.size() << " elements" ); m_GLprogram->use(); // set Matrix : translation/positionMatrix - mat4 projMatrix = ewol::openGL::getMatrix(); - mat4 camMatrix = ewol::openGL::getCameraMatrix(); + mat4 projMatrix = gale::openGL::getMatrix(); + mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // position : @@ -108,13 +109,13 @@ void ewol::resource::Colored3DObject::draw(std::vector& _vertices, // color : m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, _vertices.size()); + gale::openGL::drawArrays(gale::openGL::render_triangle, 0, _vertices.size()); m_GLprogram->unUse(); if (true == _depthtest) { if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); } - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_depthTest); } } @@ -131,7 +132,7 @@ void ewol::resource::Colored3DObject::drawLine(std::vector& _vertices, return; } if (true == _depthtest) { - ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::enable(gale::openGL::flag_depthTest); if (false == _updateDepthBuffer) { glDepthMask(GL_FALSE); } @@ -139,8 +140,8 @@ void ewol::resource::Colored3DObject::drawLine(std::vector& _vertices, //EWOL_DEBUG(" display " << m_coord.size() << " elements" ); m_GLprogram->use(); // set Matrix : translation/positionMatrix - mat4 projMatrix = ewol::openGL::getMatrix(); - mat4 camMatrix = ewol::openGL::getCameraMatrix(); + mat4 projMatrix = gale::openGL::getMatrix(); + mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // position : @@ -148,13 +149,13 @@ void ewol::resource::Colored3DObject::drawLine(std::vector& _vertices, // color : m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); // Request the draw od the elements : - ewol::openGL::drawArrays(GL_LINES, 0, _vertices.size()); + gale::openGL::drawArrays(gale::openGL::render_line, 0, _vertices.size()); m_GLprogram->unUse(); if (true == _depthtest) { if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); } - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_depthTest); } } diff --git a/ewol/resource/Colored3DObject.h b/ewol/resource/Colored3DObject.h index 0b3e8627..6f684d80 100644 --- a/ewol/resource/Colored3DObject.h +++ b/ewol/resource/Colored3DObject.h @@ -10,16 +10,15 @@ #define __COLORED_3D_OBJECT_H__ #include -#include +#include #include -#include -#include +#include namespace ewol { namespace resource { - class Colored3DObject : public ewol::Resource { + class Colored3DObject : public gale::Resource { protected: - std::shared_ptr m_GLprogram; + std::shared_ptr m_GLprogram; int32_t m_GLPosition; int32_t m_GLMatrix; int32_t m_GLColor; diff --git a/ewol/resource/ConfigFile.cpp b/ewol/resource/ConfigFile.cpp index fdf32f2c..d24b1919 100644 --- a/ewol/resource/ConfigFile.cpp +++ b/ewol/resource/ConfigFile.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -20,12 +20,13 @@ ewol::resource::ConfigFile::ConfigFile() : - ewol::Resource() { - addObjectType("ewol::ConfigFile"); + gale::Resource() { + addResourceType("ewol::ConfigFile"); } void ewol::resource::ConfigFile::init(const std::string& _filename) { - ewol::Resource::init(_filename); + std11::unique_lock lock(m_mutex); + gale::Resource::init(_filename); EWOL_DEBUG("SFP : load \"" << _filename << "\""); reload(); } @@ -36,6 +37,7 @@ ewol::resource::ConfigFile::~ConfigFile() { } void ewol::resource::ConfigFile::reload() { + std11::unique_lock lock(m_mutex); // reset all parameters for (int32_t iii=0; iii lock(m_mutex); // check if the parameters existed : if (m_list.exist(_paramName) == false) { m_list.add(_paramName, nullptr); @@ -65,6 +68,7 @@ int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) { double ewol::resource::ConfigFile::getNumber(int32_t _id) { + std11::unique_lock lock(m_mutex); if ( _id < 0 || m_list[_id] == nullptr) { return 0.0; @@ -77,6 +81,7 @@ double ewol::resource::ConfigFile::getNumber(int32_t _id) { } const std::string& ewol::resource::ConfigFile::getString(int32_t _id) { + std11::unique_lock lock(m_mutex); static const std::string& errorString(""); if ( _id < 0 || m_list[_id] == nullptr) { @@ -90,6 +95,7 @@ const std::string& ewol::resource::ConfigFile::getString(int32_t _id) { } bool ewol::resource::ConfigFile::getBoolean(int32_t _id) { + std11::unique_lock lock(m_mutex); if ( _id < 0 || m_list[_id] == nullptr) { return false; diff --git a/ewol/resource/ConfigFile.h b/ewol/resource/ConfigFile.h index a0bcb048..7a8749dd 100644 --- a/ewol/resource/ConfigFile.h +++ b/ewol/resource/ConfigFile.h @@ -13,11 +13,11 @@ #include #include #include -#include +#include namespace ewol { namespace resource { - class ConfigFile : public ewol::Resource { + class ConfigFile : public gale::Resource { private: ejson::Document m_doc; etk::Hash> m_list; diff --git a/ewol/resource/DistanceFieldFont.cpp b/ewol/resource/DistanceFieldFont.cpp index 5cae8478..0bc1a714 100644 --- a/ewol/resource/DistanceFieldFont.cpp +++ b/ewol/resource/DistanceFieldFont.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -28,7 +28,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() : ewol::resource::Texture(), m_borderSize(10), m_textureBorderSize(0,0) { - addObjectType("ewol::resource::DistanceFieldFont"); + addResourceType("ewol::resource::DistanceFieldFont"); m_font = nullptr; m_lastGlyphPos.setValue(1,1); m_lastRawHeigh = 0; @@ -36,17 +36,22 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() : } void ewol::resource::DistanceFieldFont::init(const std::string& _fontName) { + std11::unique_lock lock(m_mutex); ewol::resource::Texture::init(_fontName); std::string localName = _fontName; std::vector folderList; if (true == ewol::getContext().getFontDefault().getUseExternal()) { #if defined(__TARGET_OS__Android) - folderList.push_back("/system/fonts"); + folderList.push_back("ROOT:system/fonts"); #elif defined(__TARGET_OS__Linux) - folderList.push_back("/usr/share/fonts/truetype"); + folderList.push_back("ROOT:usr/share/fonts/truetype"); #endif } - folderList.push_back(ewol::getContext().getFontDefault().getFolder()); + std::string applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); + std::vector applicationBaseFontList = etk::FSNodeExplodeMultiplePath(applicationBaseFont); + for (auto &it : applicationBaseFontList) { + folderList.push_back(it); + } for (size_t folderID = 0; folderID < folderList.size() ; folderID++) { etk::FSNode myFolder(folderList[folderID]); // find the real Font name : @@ -130,11 +135,13 @@ ewol::resource::DistanceFieldFont::~DistanceFieldFont() { float ewol::resource::DistanceFieldFont::getDisplayRatio(float _size) { + std11::unique_lock lock(m_mutex); return _size / (float)SIZE_GENERATION; } void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) { + std11::unique_lock lock(m_mutex); int32_t size = _input.getSize().x() * _input.getSize().y(); std::vector xdist(size); std::vector ydist(size); @@ -214,6 +221,7 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image } bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) { + std11::unique_lock lock(m_mutex); bool hasChange = false; if (m_font == nullptr) { return false; @@ -295,6 +303,7 @@ bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) { } int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) { + std11::unique_lock lock(m_mutex); if (_charcode < 0x20) { return 0; } else if (_charcode < 0x80) { @@ -321,6 +330,7 @@ int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) { } ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const char32_t& _charcode) { + std11::unique_lock lock(m_mutex); //EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]); int32_t index = getIndex(_charcode); if( index < 0 @@ -340,6 +350,7 @@ ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const ch } void ewol::resource::DistanceFieldFont::exportOnFile() { + std11::unique_lock lock(m_mutex); EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'"); ejson::Document doc; std::shared_ptr tmpList = ejson::Array::create(); @@ -374,6 +385,7 @@ void ewol::resource::DistanceFieldFont::exportOnFile() { } bool ewol::resource::DistanceFieldFont::importFromFile() { + std11::unique_lock lock(m_mutex); EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'"); // test file existance: etk::FSNode fileJSON(m_fileName + ".json"); diff --git a/ewol/resource/DistanceFieldFont.h b/ewol/resource/DistanceFieldFont.h index 8fbf312a..c14bedae 100644 --- a/ewol/resource/DistanceFieldFont.h +++ b/ewol/resource/DistanceFieldFont.h @@ -11,7 +11,6 @@ #include #include -#include #include namespace ewol { diff --git a/ewol/resource/FontFreeType.cpp b/ewol/resource/FontFreeType.cpp index ef10875d..350a9963 100644 --- a/ewol/resource/FontFreeType.cpp +++ b/ewol/resource/FontFreeType.cpp @@ -11,12 +11,12 @@ #include -#include +#include #include #include #include -#include +#include #undef __class__ #define __class__ "resource::FontFreeType" @@ -53,13 +53,14 @@ void ewol::resource::freeTypeUnInit() { } ewol::resource::FontFreeType::FontFreeType() { - addObjectType("ewol::FontFreeType"); + addResourceType("ewol::FontFreeType"); m_init = false; m_FileBuffer = nullptr; m_FileSize = 0; } void ewol::resource::FontFreeType::init(const std::string& _fontName) { + std11::unique_lock lock(m_mutex); ewol::resource::FontBase::init(_fontName); etk::FSNode myfile(_fontName); if (false == myfile.exist()) { @@ -100,6 +101,7 @@ void ewol::resource::FontFreeType::init(const std::string& _fontName) { } ewol::resource::FontFreeType::~FontFreeType() { + std11::unique_lock lock(m_mutex); // clean the tmp memory if (nullptr != m_FileBuffer) { delete[] m_FileBuffer; @@ -110,6 +112,7 @@ ewol::resource::FontFreeType::~FontFreeType() { } vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const std::string& _unicodeString) { + std11::unique_lock lock(m_mutex); if(false == m_init) { return vec2(0,0); } @@ -119,13 +122,16 @@ vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const std::string& } int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) { + std11::unique_lock lock(m_mutex); return _fontSize*1.43f; // this is a really "magic" number ... } float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) { + std11::unique_lock lock(m_mutex); return _fontHeight*0.6993f; // this is a really "magic" number ... } bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) { + std11::unique_lock lock(m_mutex); if(false == m_init) { return false; } @@ -170,6 +176,7 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut, ivec2 _glyphPosition, ewol::GlyphProperty& _property, int8_t _posInImage) { + std11::unique_lock lock(m_mutex); if(false == m_init) { return false; } @@ -231,6 +238,7 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut, int32_t _fontSize, ewol::GlyphProperty& _property, int32_t _borderSize) { + std11::unique_lock lock(m_mutex); if(false == m_init) { return false; } @@ -274,7 +282,8 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut, void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, std::vector& listGlyph) { - if(false == m_init) { + std11::unique_lock lock(m_mutex); + if(m_init == false) { return; } if ((FT_FACE_FLAG_KERNING & m_fftFace->face_flags) == 0) { @@ -307,7 +316,8 @@ void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, std::vector void ewol::resource::FontFreeType::display() { - if(false == m_init) { + std11::unique_lock lock(m_mutex); + if(m_init == false) { return; } EWOL_INFO(" number of glyph = " << (int)m_fftFace->num_glyphs); diff --git a/ewol/resource/Image.cpp b/ewol/resource/Image.cpp index 79eda1a9..f401ad48 100644 --- a/ewol/resource/Image.cpp +++ b/ewol/resource/Image.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -18,15 +18,17 @@ #define __class__ "resource::TextureFile" ewol::resource::TextureFile::TextureFile() { - addObjectType("ewol::resource::Image"); + addResourceType("ewol::resource::Image"); } void ewol::resource::TextureFile::init() { + std11::unique_lock lock(m_mutex); ewol::resource::Texture::init(); } void ewol::resource::TextureFile::init(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) { + std11::unique_lock lock(m_mutex); ewol::resource::Texture::init(_genName); EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size); if (false == egami::load(m_data, _tmpfileName, _size)) { @@ -104,21 +106,21 @@ std::shared_ptr ewol::resource::TextureFile::create EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); std::shared_ptr object = nullptr; - std::shared_ptr object2 = getManager().localKeep(TmpFilename); - if (nullptr != object2) { + std::shared_ptr object2 = getManager().localKeep(TmpFilename); + if (object2 != nullptr) { object = std::dynamic_pointer_cast(object2); - if (nullptr == object) { + if (object == nullptr) { EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)"); return nullptr; } } - if (nullptr != object) { + if (object != nullptr) { return object; } EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size); // need to crate a new one ... object = std::shared_ptr(new ewol::resource::TextureFile()); - if (nullptr == object) { + if (object == nullptr) { EWOL_ERROR("allocation error of a resource : " << _filename); return nullptr; } diff --git a/ewol/resource/Image.h b/ewol/resource/Image.h index 0992cc41..bbf9ce46 100644 --- a/ewol/resource/Image.h +++ b/ewol/resource/Image.h @@ -13,7 +13,6 @@ #include #include #include -#include namespace ewol { namespace resource { diff --git a/ewol/resource/ImageDF.cpp b/ewol/resource/ImageDF.cpp index 3af97e6c..b14fe28b 100644 --- a/ewol/resource/ImageDF.cpp +++ b/ewol/resource/ImageDF.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -19,15 +19,17 @@ #define __class__ "resource::TextureFile" ewol::resource::ImageDF::ImageDF() { - addObjectType("ewol::resource::ImageDF"); + addResourceType("ewol::resource::ImageDF"); } void ewol::resource::ImageDF::init() { + std11::unique_lock lock(m_mutex); ewol::resource::Texture::init(); } void ewol::resource::ImageDF::init(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) { + std11::unique_lock lock(m_mutex); ewol::resource::Texture::init(_genName); EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size); if (false == egami::load(m_data, _tmpfileName, _size)) { @@ -52,6 +54,7 @@ void ewol::resource::ImageDF::init(std::string _genName, const std::string& _tmp void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) { + std11::unique_lock lock(m_mutex); int32_t size = _input.getSize().x() * _input.getSize().y(); std::vector xdist(size); std::vector ydist(size); @@ -193,7 +196,7 @@ std::shared_ptr ewol::resource::ImageDF::create(const s EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); std::shared_ptr object = nullptr; - std::shared_ptr object2 = getManager().localKeep("DF__" + TmpFilename); + std::shared_ptr object2 = getManager().localKeep("DF__" + TmpFilename); if (nullptr != object2) { object = std::dynamic_pointer_cast(object2); if (nullptr == object) { diff --git a/ewol/resource/ImageDF.h b/ewol/resource/ImageDF.h index c2648450..a6696687 100644 --- a/ewol/resource/ImageDF.h +++ b/ewol/resource/ImageDF.h @@ -14,7 +14,6 @@ #include #include #include -#include namespace ewol { namespace resource { diff --git a/ewol/resource/Manager.cpp b/ewol/resource/Manager.cpp deleted file mode 100644 index 7b15bde2..00000000 --- a/ewol/resource/Manager.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -#include -#include - - - -ewol::resource::Manager::Manager() : - m_contextHasBeenRemoved(true) { - // nothing to do ... -} - -ewol::resource::Manager::~Manager() { - bool hasError = false; - if (m_resourceListToUpdate.size()!=0) { - EWOL_ERROR("Must not have anymore resources to update !!!"); - hasError = true; - } - // TODO : Remove unneeded elements - if (m_resourceList.size()!=0) { - EWOL_ERROR("Must not have anymore resources !!!"); - hasError = true; - } - if (true == hasError) { - EWOL_ERROR("Check if the function UnInit has been called !!!"); - } -} - -void ewol::resource::Manager::unInit() { - display(); - m_resourceListToUpdate.clear(); - // remove all resources ... - auto it(m_resourceList.begin()); - while(it != m_resourceList.end()) { - std::shared_ptr tmpRessource = (*it).lock(); - if (tmpRessource != nullptr) { - EWOL_WARNING("Find a resource that is not removed : [" << tmpRessource->getId() << "]" - << "=\"" << tmpRessource->getName() << "\" " - << tmpRessource.use_count() << " elements"); - } - m_resourceList.erase(it); - it = m_resourceList.begin(); - } - m_resourceList.clear(); -} - -void ewol::resource::Manager::display() { - EWOL_INFO("Resources loaded : "); - // remove all resources ... - for (auto &it : m_resourceList) { - std::shared_ptr tmpRessource = it.lock(); - if (tmpRessource != nullptr) { - EWOL_INFO(" [" << tmpRessource->getId() << "]" - << tmpRessource->getObjectType() - << "=\"" << tmpRessource->getName() << "\" " - << tmpRessource.use_count() << " elements"); - } - } - EWOL_INFO("Resources ---"); -} - -void ewol::resource::Manager::reLoadResources() { - EWOL_INFO("------------- Resources re-loaded -------------"); - // remove all resources ... - if (m_resourceList.size() != 0) { - for (size_t jjj=0; jjj tmpRessource = it.lock(); - if(tmpRessource != nullptr) { - if (jjj == tmpRessource->getResourceLevel()) { - tmpRessource->reload(); - EWOL_INFO(" [" << tmpRessource->getId() << "]="<< tmpRessource->getObjectType()); - } - } - } - } - } - // TODO : UNderstand why it is set here ... - //ewol::requestUpdateSize(); - EWOL_INFO("------------- Resources -------------"); -} - -void ewol::resource::Manager::update(const std::shared_ptr& _object) { - // chek if not added before - for (auto &it : m_resourceListToUpdate) { - if ( it != nullptr - && it == _object) { - // just prevent some double add ... - return; - } - } - // add it ... - m_resourceListToUpdate.push_back(_object); -} - -// Specific to load or update the data in the openGl context == > system use only -void ewol::resource::Manager::updateContext() { - if (m_contextHasBeenRemoved == true) { - // need to update all ... - m_contextHasBeenRemoved = false; - if (m_resourceList.size() != 0) { - for (size_t jjj=0; jjj tmpRessource = it.lock(); - if( tmpRessource != nullptr - && jjj == tmpRessource->getResourceLevel()) { - //EWOL_DEBUG("Update context named : " << l_resourceList[iii]->getName()); - tmpRessource->updateContext(); - } - } - } - } - } else { - if (m_resourceListToUpdate.size() != 0) { - for (size_t jjj=0; jjjgetResourceLevel()) { - it->updateContext(); - } - } - } - } - } - // Clean the update list - m_resourceListToUpdate.clear(); -} - -// in this case, it is really too late ... -void ewol::resource::Manager::contextHasBeenDestroyed() { - for (auto &it : m_resourceList) { - std::shared_ptr tmpRessource = it.lock(); - if (tmpRessource != nullptr) { - tmpRessource->removeContextToLate(); - } - } - // no context preent ... - m_contextHasBeenRemoved = true; -} - -// internal generic keeper ... -std::shared_ptr ewol::resource::Manager::localKeep(const std::string& _filename) { - EWOL_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources"); - for (auto &it : m_resourceList) { - std::shared_ptr tmpRessource = it.lock(); - if (tmpRessource != nullptr) { - if (tmpRessource->getName() == _filename) { - return tmpRessource; - } - } - } - return nullptr; -} - -// internal generic keeper ... -void ewol::resource::Manager::localAdd(const std::shared_ptr& _object) { - //Add ... find empty slot - for (auto &it : m_resourceList) { - std::shared_ptr tmpRessource = it.lock(); - if (tmpRessource == nullptr) { - it = _object; - return; - } - } - // add at the end if no slot is free - m_resourceList.push_back(_object); -} - -// in case of error ... -void ewol::resource::Manager::cleanInternalRemoved() { - //EWOL_INFO("remove object in Manager"); - updateContext(); - for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) { - if ((*it).expired() == true) { - m_resourceList.erase(it); - it = m_resourceList.begin(); - } - } -} diff --git a/ewol/resource/Manager.h b/ewol/resource/Manager.h deleted file mode 100644 index 2a8bf023..00000000 --- a/ewol/resource/Manager.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __RESOURCES_MANAGER_H__ -#define __RESOURCES_MANAGER_H__ - -#include -#include -#include -#include -#include - -namespace ewol { - namespace resource { - class Manager{ - private: - std::list> m_resourceList; - std::vector> m_resourceListToUpdate; - bool m_contextHasBeenRemoved; - public: - /** - * @brief initialize the internal variable - */ - Manager(); - /** - * @brief Uninitiamize the resource manager, free all resources previously requested - * @note when not free == > generate warning, because the segfault can appear after... - */ - virtual ~Manager(); - /** - * @brief remove all resources (un-init) out of the destructor (due to the system implementation) - */ - void unInit(); - /** - * @brief display in the log all the resources loaded ... - */ - void display(); - /** - * @brief Reload all resources from files, and send there in openGL card if needed. - * @note If file is reference at THEME:XXX:filename if the Theme change the file will reload the newOne - */ - void reLoadResources(); - /** - * @brief Call by the system to send all the needed data on the graphic card chen they change ... - * @param[in] _object The resources that might be updated - */ - void update(const std::shared_ptr& _object); - /** - * @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other .... - */ - void updateContext(); - /** - * @brief This is to inform the resources manager that we have no more openGl context ... - */ - void contextHasBeenDestroyed(); - public: - // internal API to extent eResources in extern Soft - std::shared_ptr localKeep(const std::string& _filename); - void localAdd(const std::shared_ptr& _object); - virtual void cleanInternalRemoved(); - }; - }; -}; - - -#endif - diff --git a/ewol/resource/Program.cpp b/ewol/resource/Program.cpp deleted file mode 100644 index 473fa7e3..00000000 --- a/ewol/resource/Program.cpp +++ /dev/null @@ -1,842 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -#include - -//#define LOCAL_DEBUG EWOL_VERBOSE -#define LOCAL_DEBUG EWOL_DEBUG - -#undef __class__ -#define __class__ "resource::Program" - -ewol::resource::Program::Program() : - ewol::Resource(), - m_exist(false), - m_program(0), - m_hasTexture(false), - m_hasTexture1(false) { - addObjectType("ewol::resource::Program"); - m_resourceLevel = 1; -} - -void ewol::resource::Program::init(const std::string& _filename) { - ewol::Resource::init(_filename); - EWOL_DEBUG("OGL : load PROGRAM '" << m_name << "'"); - // load data from file "all the time ..." - - etk::FSNode file(m_name); - if (false == file.exist()) { - EWOL_INFO("File does not Exist : \"" << file << "\" == > automatic load of framment and shader with same names... "); - std::string tmpFilename = m_name; - // remove extention ... - tmpFilename.erase(tmpFilename.size()-4, 4); - std::shared_ptr tmpShader = ewol::resource::Shader::create(tmpFilename+"vert"); - if (nullptr == tmpShader) { - EWOL_ERROR("Error while getting a specific shader filename : " << tmpFilename); - return; - } else { - EWOL_DEBUG("Add shader on program : "<< tmpFilename << "vert"); - m_shaderList.push_back(tmpShader); - } - tmpShader = ewol::resource::Shader::create(tmpFilename+"frag"); - if (nullptr == tmpShader) { - EWOL_ERROR("Error while getting a specific shader filename : " << tmpFilename); - return; - } else { - EWOL_DEBUG("Add shader on program : "<< tmpFilename << "frag"); - m_shaderList.push_back(tmpShader); - } - } else { - std::string fileExtention = file.fileGetExtention(); - if (fileExtention != "prog") { - EWOL_ERROR("File does not have extention \".prog\" for program but : \"" << fileExtention << "\""); - return; - } - if (false == file.fileOpenRead()) { - EWOL_ERROR("Can not open the file : \"" << file << "\""); - return; - } - #define MAX_LINE_SIZE (2048) - char tmpData[MAX_LINE_SIZE]; - while (file.fileGets(tmpData, MAX_LINE_SIZE) != nullptr) { - int32_t len = strlen(tmpData); - if( tmpData[len-1] == '\n' - || tmpData[len-1] == '\r') { - tmpData[len-1] = '\0'; - len--; - } - EWOL_DEBUG(" Read data : \"" << tmpData << "\""); - if (len == 0) { - continue; - } - if (tmpData[0] == '#') { - continue; - } - // get it with relative position : - std::string tmpFilename = file.getRelativeFolder() + tmpData; - std::shared_ptr tmpShader = ewol::resource::Shader::create(tmpFilename); - if (nullptr == tmpShader) { - EWOL_ERROR("Error while getting a specific shader filename : " << tmpFilename); - } else { - EWOL_DEBUG("Add shader on program : "<< tmpFilename); - m_shaderList.push_back(tmpShader); - } - - } - // close the file: - file.fileClose(); - } - updateContext(); -} - -ewol::resource::Program::~Program() { - m_shaderList.clear(); - removeContext(); - m_elementList.clear(); - m_hasTexture = false; - m_hasTexture1 = false; -} - -std::ostream& ewol::resource::operator <<(std::ostream& _os, const ewol::resource::progAttributeElement& _obj) { - _os << "{"; - _os << "[" << _obj.m_name << "] "; - _os << _obj.m_elementId << " "; - _os << _obj.m_isLinked; - _os << "}"; - return _os; -} - -std::ostream& ewol::resource::operator <<(std::ostream& _os, const std::vector& _obj){ - _os << "{"; - for (auto &it : _obj) { - _os << it; - } - _os << "}"; - return _os; -} - -void ewol::resource::Program::checkGlError(const char* _op, int32_t _localLine, int32_t _idElem) { - #ifdef DEBUG - bool isPresent = false; - for (GLint error = glGetError(); error; error = glGetError()) { - EWOL_ERROR("after " << _op << "() line=" << _localLine << " glError(" << error << ")"); - isPresent = true; - } - if (isPresent == true) { - EWOL_ERROR(" in program name : " << m_name); - EWOL_ERROR(" program OpenGL ID =" << m_program); - EWOL_ERROR(" List IO :"); - int32_t id = 0; - for (auto &it : m_elementList) { - if (id == _idElem) { - EWOL_ERROR(" * name :" << it.m_name << " OpenGL ID=" << it.m_elementId << " attribute=" << it.m_isAttribute << " is linked=" << it.m_isLinked); - } else { - EWOL_ERROR(" name :" << it.m_name << " OpenGL ID=" << it.m_elementId << " attribute=" << it.m_isAttribute << " is linked=" << it.m_isLinked); - } - id++; - } - EWOL_CRITICAL("Stop on openGL ERROR"); - } - #endif -} - -#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) -static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; - -bool ewol::resource::Program::checkIdValidity(int32_t _idElem) { - if ( _idElem < 0 - || (size_t)_idElem > m_elementList.size()) { - return false; - } - return m_elementList[_idElem].m_isLinked; -} - -int32_t ewol::resource::Program::getAttribute(std::string _elementName) { - // check if it exist previously : - for(size_t iii=0; iiigetShaderType() == GL_FRAGMENT_SHADER) { - glAttachShader(m_program, m_shaderList[iii]->getGL_ID()); - checkGlError("glAttachShader", __LINE__); - } - } - } - glLinkProgram(m_program); - checkGlError("glLinkProgram", __LINE__); - GLint linkStatus = GL_FALSE; - glGetProgramiv(m_program, GL_LINK_STATUS, &linkStatus); - checkGlError("glGetProgramiv", __LINE__); - if (linkStatus != GL_TRUE) { - GLint bufLength = 0; - l_bufferDisplayError[0] = '\0'; - glGetProgramInfoLog(m_program, LOG_OGL_INTERNAL_BUFFER_LEN, &bufLength, l_bufferDisplayError); - char tmpLog[256]; - int32_t idOut=0; - EWOL_ERROR("Could not compile \"PROGRAM\": \"" << m_name << "\""); - for (size_t iii=0; iii= 256) { - tmpLog[idOut] = '\0'; - EWOL_ERROR(" == > " << tmpLog); - idOut=0; - } else { - idOut++; - } - if (l_bufferDisplayError[iii] == '\0') { - break; - } - } - if (idOut != 0) { - tmpLog[idOut] = '\0'; - EWOL_ERROR(" == > " << tmpLog); - } - glDeleteProgram(m_program); - checkGlError("glDeleteProgram", __LINE__); - m_program = 0; - return; - } - m_exist = true; - // now get the old attribute requested priviously ... - for(size_t iii=0; iii& _vbo, - int32_t _index, - int32_t _jumpBetweenSample, - int32_t _offset) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - // check error of the VBO goog enought ... - if (_vbo->getElementSize(_index) <= 0) { - EWOL_ERROR("Can not bind a VBO Buffer with an element size of : " << _vbo->getElementSize(_index) << " named=" << _vbo->getName()); - return; - } - - EWOL_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _vbo->getElementSize(_index) << " element on oglID=" << _vbo->getGL_ID(_index) << " VBOindex=" << _index); - glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index)); - checkGlError("glBindBuffer", __LINE__, _idElem); - EWOL_VERBOSE(" id=" << m_elementList[_idElem].m_elementId); - EWOL_VERBOSE(" eleme size=" << _vbo->getElementSize(_index)); - EWOL_VERBOSE(" jump sample=" << _jumpBetweenSample); - EWOL_VERBOSE(" offset=" << _offset); - glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL - _vbo->getElementSize(_index), // number of elements per vertex, here (r,g,b,a) - GL_FLOAT, // the type of each element - GL_FALSE, // take our values as-is - _jumpBetweenSample, // no extra data between each position - (GLvoid *)_offset); // Pointer on the buffer - checkGlError("glVertexAttribPointer", __LINE__, _idElem); - glEnableVertexAttribArray(m_elementList[_idElem].m_elementId); - checkGlError("glEnableVertexAttribArray", __LINE__, _idElem); -} - -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::resource::Program::uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - //EWOL_ERROR("[" << m_elementList[_idElem].m_name << "] send 1 matrix"); - // note : Android des not supported the transposition of the matrix, then we will done it oursef: - if (true == _transpose) { - mat4 tmp = _matrix; - tmp.transpose(); - glUniformMatrix4fv(m_elementList[_idElem].m_elementId, 1, GL_FALSE, tmp.m_mat); - } else { - glUniformMatrix4fv(m_elementList[_idElem].m_elementId, 1, GL_FALSE, _matrix.m_mat); - } - checkGlError("glUniformMatrix4fv", __LINE__, _idElem); -} - -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::resource::Program::uniform1f(int32_t _idElem, float _value1) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform1f(m_elementList[_idElem].m_elementId, _value1); - checkGlError("glUniform1f", __LINE__, _idElem); -} -void ewol::resource::Program::uniform2f(int32_t _idElem, float _value1, float _value2) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform2f(m_elementList[_idElem].m_elementId, _value1, _value2); - checkGlError("glUniform2f", __LINE__, _idElem); -} -void ewol::resource::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform3f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3); - checkGlError("glUniform3f", __LINE__, _idElem); -} -void ewol::resource::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform4f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4); - checkGlError("glUniform4f", __LINE__, _idElem); -} - -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform1i(m_elementList[_idElem].m_elementId, _value1); - checkGlError("glUniform1i", __LINE__, _idElem); -} -void ewol::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform2i(m_elementList[_idElem].m_elementId, _value1, _value2); - checkGlError("glUniform2i", __LINE__, _idElem); -} -void ewol::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform3i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3); - checkGlError("glUniform3i", __LINE__, _idElem); -} -void ewol::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - glUniform4i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3, _value4); - checkGlError("glUniform4i", __LINE__, _idElem); -} - - -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - glUniform1fv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform1fv", __LINE__, _idElem); -} -void ewol::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - glUniform2fv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform2fv", __LINE__, _idElem); -} -void ewol::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - EWOL_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " vec3"); - glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform3fv", __LINE__, _idElem); -} -void ewol::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - EWOL_VERBOSE("[" << m_elementList[_idElem].m_name << "] send " << _nbElement << " vec4"); - glUniform4fv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform4fv", __LINE__, _idElem); -} - -////////////////////////////////////////////////////////////////////////////////////////////// - -void ewol::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - glUniform1iv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform1iv", __LINE__, _idElem); -} -void ewol::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - glUniform2iv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform2iv", __LINE__, _idElem); -} -void ewol::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - glUniform3iv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform3iv", __LINE__, _idElem); -} -void ewol::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]"); - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - if (0 == _nbElement) { - EWOL_ERROR("No element to send at open GL ..."); - return; - } - if (nullptr == _value) { - EWOL_ERROR("nullptr Input pointer to send at open GL ..."); - return; - } - glUniform4iv(m_elementList[_idElem].m_elementId, _nbElement, _value); - checkGlError("glUniform4iv", __LINE__, _idElem); -} - -//#define PROGRAM_DISPLAY_SPEED - -////////////////////////////////////////////////////////////////////////////////////////////// -#ifdef PROGRAM_DISPLAY_SPEED - int64_t g_startTime = 0; -#endif - - -void ewol::resource::Program::use() { - #ifdef PROGRAM_DISPLAY_SPEED - g_startTime = ewol::getTime(); - #endif - // event if it was 0 == > set it to prevent other use of the previous shader display ... - ewol::openGL::useProgram(m_program); - checkGlError("glUseProgram", __LINE__); -} - - -void ewol::resource::Program::setTexture0(int32_t _idElem, GLint _textureOpenGlID) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - #if 0 - ewol::openGL::enable(GL_TEXTURE_2D); - checkGlError("glEnable", __LINE__); - #endif - ewol::openGL::activeTexture(GL_TEXTURE0); - checkGlError("glActiveTexture", __LINE__, _idElem); - // set the textureID - glBindTexture(GL_TEXTURE_2D, _textureOpenGlID); - checkGlError("glBindTexture", __LINE__, _idElem); - // set the texture on the uniform attribute - glUniform1i(m_elementList[_idElem].m_elementId, /*GL_TEXTURE*/0); - checkGlError("glUniform1i", __LINE__, _idElem); - m_hasTexture = true; -} - -void ewol::resource::Program::setTexture1(int32_t _idElem, GLint _textureOpenGlID) { - if (0 == m_program) { - return; - } - if (_idElem<0 || (size_t)_idElem>m_elementList.size()) { - return; - } - if (false == m_elementList[_idElem].m_isLinked) { - return; - } - #if 0 - ewol::openGL::enable(GL_TEXTURE_2D); - checkGlError("glEnable", __LINE__); - #endif - ewol::openGL::activeTexture(GL_TEXTURE1); - checkGlError("glActiveTexture", __LINE__, _idElem); - // set the textureID - glBindTexture(GL_TEXTURE_2D, _textureOpenGlID); - checkGlError("glBindTexture", __LINE__, _idElem); - // set the texture on the uniform attribute - glUniform1i(m_elementList[_idElem].m_elementId, /*GL_TEXTURE*/1); - checkGlError("glUniform1i", __LINE__, _idElem); - m_hasTexture1 = true; -} - - -void ewol::resource::Program::unUse() { - //EWOL_WARNING("Will use program : " << m_program); - if (0 == m_program) { - return; - } - #if 0 - if (true == m_hasTexture) { - ewol::openGL::disable(GL_TEXTURE_2D); - //checkGlError("glDisable", __LINE__); - m_hasTexture = false; - } - #endif - // no need to disable program == > this only generate perturbation on speed ... - ewol::openGL::useProgram(-1); - #ifdef PROGRAM_DISPLAY_SPEED - float localTime = (float)(ewol::getTime() - g_startTime) / 1000.0f; - if (localTime>1) { - EWOL_ERROR(" prog : " << localTime << "ms resource=\"" << m_name << "\""); - } else { - EWOL_DEBUG(" prog : " << localTime << "ms resource=\"" << m_name << "\""); - } - #endif - checkGlError("glUseProgram", __LINE__); -} - diff --git a/ewol/resource/Program.h b/ewol/resource/Program.h deleted file mode 100644 index 3e4eb1aa..00000000 --- a/ewol/resource/Program.h +++ /dev/null @@ -1,313 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __OPEN_GL__PROGRAM_H__ -#define __OPEN_GL__PROGRAM_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ewol { - namespace resource { - /** - * @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. - * This is important to note when the Program is reloaded the elements availlable can change. - * @not-in-doc - */ - class progAttributeElement { - public : - std::string m_name; //!< Name of the element - 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_isLinked; //!< if this element does not exist this is false - }; - //! @not-in-doc - std::ostream& operator <<(std::ostream& _os, const ewol::resource::progAttributeElement& _obj); - //! @not-in-doc - std::ostream& operator <<(std::ostream& _os, const std::vector& _obj); - /** - * @brief Program is a compilation of some fragment Shader and vertex Shader. This construct automaticly this assiciation - * The input file must have the form : "myFile.prog" - * The data is simple : - *
-		 * # Comment line ... paid attention at the space at the end of lines, they are considered like a part of the file ...
-		 * # The folder is automaticly get from the program file basic folder
-		 * filename1.vert
-		 * filename2.frag
-		 * filename3.vert
-		 * filename4.frag
-		 * 
- */ - class Program : public ewol::Resource { - private : - bool m_exist; //!< the file existed - GLuint m_program; //!< openGL id of the current program - std::vector> m_shaderList; //!< List of all the shader loaded - std::vector 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_hasTexture1; //!< A texture has been set to the current shader - protected: - /** - * @brief Contructor of an opengl Program. - * @param[in] filename Standard file name format. see @ref etk::FSNode - */ - Program(); - void init(const std::string& _filename); - public: - DECLARE_RESOURCE_NAMED_FACTORY(Program); - /** - * @brief Destructor, remove the current Program. - */ - virtual ~Program(); - public: - /** - * @brief Check If an Id is valid in the shader or not (sometime the shader have not some attribute, then we need to display some error) - * @return _idElem Id of the Attribute that might be sended. - * @return true The id is valid, false otherwise - */ - bool checkIdValidity(int32_t _idElem); - /** - * @brief User request an attribute on this program. - * @note The attribute is send to the fragment shaders - * @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) - */ - int32_t getAttribute(std::string _elementName); - /** - * @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] _nbElement Specifies the number of elements that are to be modified. - * @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) - */ - void sendAttribute(int32_t _idElem, - int32_t _nbElement, - const void* _pointer, - int32_t _jumpBetweenSample=0); - void sendAttributePointer(int32_t _idElem, - const std::shared_ptr& _vbo, - int32_t _index, - int32_t _jumpBetweenSample=0, - int32_t _offset=0); - inline void sendAttribute(int32_t _idElem, const std::vector& _data) { - sendAttribute(_idElem, 2/*u,v / x,y*/, &_data[0]); - } - inline void sendAttribute(int32_t _idElem, const std::vector& _data) { - sendAttribute(_idElem, 3/*x,y,z,unused*/, &_data[0], 4*sizeof(btScalar)); - } - inline void sendAttribute(int32_t _idElem, const std::vector>& _data) { - sendAttribute(_idElem, 4/*r,g,b,a*/, &_data[0]); - } - inline void sendAttribute(int32_t _idElem, const std::vector& _data) { - sendAttribute(_idElem, 1, &_data[0]); - } - /** - * @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) - * @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) - */ - int32_t getUniform(std::string _elementName); - /** - * @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] _matrix Matrix 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) - */ - void uniformMatrix(int32_t _idElem, const mat4& _matrix, bool _transpose=true); - - inline void uniform(int32_t _idElem, const etk::Color& _value) { - uniform4f(_idElem, _value.r(), _value.g(), _value.b(), _value.a()); - } - - /** - * @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] _value1 Value to send at the Uniform - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _value1 Value to send at the Uniform - * @param[in] _value2 Value to send at the Uniform - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _value1 Value to send at the Uniform - * @param[in] _value2 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); - /** - * @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] _value1 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] _value4 Value to send at the Uniform - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _value1 Value to send at the Uniform - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _value1 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); - /** - * @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] _value1 Value to send at the Uniform - * @param[in] _value2 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); - /** - * @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] _value1 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] _value4 Value to send at the Uniform - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the Attribute that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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) - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _nbElement Number of element sended - * @param[in] _value Pointer on the data - */ - 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 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 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 uniform4(int32_t _idElem, const ivec4& _value) { - uniform4iv(_idElem, 1, &_value.m_floats[0]); - }; - - /** - * @brief Request the processing of this program - */ - void use(); - /** - * @brief set the testure Id on the specify uniform element. - * @param[in] _idElem Id of the uniform that might be sended. - * @param[in] _textureOpenGlID Real openGL texture ID - */ - void setTexture0(int32_t _idElem, GLint _textureOpenGlID); - void setTexture1(int32_t _idElem, GLint _textureOpenGlID); - /** - * @brief Stop the processing of this program - */ - void unUse(); - /** - * @brief This load/reload the data in the opengl context, needed when removed previously. - */ - void updateContext(); - /** - * @brief remove the data from the opengl context. - */ - void removeContext(); - /** - * @brief Special android spec! It inform us that all context is removed and after notify us... - */ - void removeContextToLate(); - /** - * @brief Relode the shader from the file. used when a request of resouces reload is done. - * @note this is really usefull when we tested the new themes or shader developpements. - */ - void reload(); - private: - void checkGlError(const char* _op, int32_t _localLine, int32_t _idElem=-2); - }; - }; -}; - -#endif - diff --git a/ewol/resource/Resource.cpp b/ewol/resource/Resource.cpp deleted file mode 100644 index cf1cb416..00000000 --- a/ewol/resource/Resource.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include -#include -#include - -void ewol::Resource::init() { - ewol::Object::init(); -} - -void ewol::Resource::init(const std::string& _name) { - ewol::Object::init(_name); -} - -void ewol::Resource::updateContext() { - EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)"); -} - -void ewol::Resource::removeContext() { - EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)"); -} - -void ewol::Resource::removeContextToLate() { - EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)"); -} - -void ewol::Resource::reload() { - EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)"); -} - -ewol::resource::Manager& ewol::Resource::getManager() { - return ewol::getContext().getResourcesManager(); -} \ No newline at end of file diff --git a/ewol/resource/Resource.h b/ewol/resource/Resource.h deleted file mode 100644 index d35427f8..00000000 --- a/ewol/resource/Resource.h +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - - -#ifndef __RESOURCES_H__ -#define __RESOURCES_H__ - -#include -#include -#include -#include - -#define MAX_RESOURCE_LEVEL (5) - -#define DECLARE_RESOURCE_FACTORY(className) \ - template static std::shared_ptr create( T&& ... all ) { \ - std::shared_ptr object(new className()); \ - if (object == nullptr) { \ - EWOL_ERROR("Factory resource error"); \ - return nullptr; \ - } \ - object->init(std::forward(all)... ); \ - if (object->objectHasBeenCorectlyInit() == false) { \ - EWOL_CRITICAL("Object Is not correctly init : " << #className ); \ - } \ - getManager().localAdd(object); \ - return object; \ - } - -#define DECLARE_RESOURCE_NAMED_FACTORY(className) \ - template static std::shared_ptr create(const std::string& _name, T&& ... all ) { \ - std::shared_ptr object; \ - std::shared_ptr object2; \ - if (_name != "" && _name != "---") { \ - object2 = getManager().localKeep(_name); \ - } \ - if (object2 != nullptr) { \ - object = std::dynamic_pointer_cast(object2); \ - if (object == nullptr) { \ - EWOL_CRITICAL("Request resource file : '" << _name << "' With the wrong type (dynamic cast error)"); \ - return nullptr; \ - } \ - } \ - if (object != nullptr) { \ - return object; \ - } \ - object = std::shared_ptr(new className()); \ - if (object == nullptr) { \ - EWOL_ERROR("allocation error of a resource : " << _name); \ - return nullptr; \ - } \ - object->init(_name, std::forward(all)... ); \ - if (object->objectHasBeenCorectlyInit() == false) { \ - EWOL_CRITICAL("Object Is not correctly init : " << #className ); \ - } \ - getManager().localAdd(object); \ - return object; \ - } - -#define DECLARE_RESOURCE_SINGLE_FACTORY(className,uniqueName) \ - template static std::shared_ptr create(T&& ... all ) { \ - std::shared_ptr object; \ - std::shared_ptr object2 = getManager().localKeep(uniqueName); \ - if (object2 != nullptr) { \ - object = std::dynamic_pointer_cast(object2); \ - if (object == nullptr) { \ - EWOL_CRITICAL("Request resource file : '" << uniqueName << "' With the wrong type (dynamic cast error)"); \ - return nullptr; \ - } \ - } \ - if (object != nullptr) { \ - return object; \ - } \ - object = std::shared_ptr(new className()); \ - if (object == nullptr) { \ - EWOL_ERROR("allocation error of a resource : " << uniqueName); \ - return nullptr; \ - } \ - object->init(uniqueName, std::forward(all)... ); \ - if (object->objectHasBeenCorectlyInit() == false) { \ - EWOL_CRITICAL("Object Is not correctly init : " << #className ); \ - } \ - getManager().localAdd(object); \ - return object; \ - } - -namespace ewol { - namespace resource { - class Manager; - }; - /** - * @brief A Resource is a generic interface to have an instance that have things that can be used by many people, ad have some hardware dependency. - * For example of resources : - * :** Shaders: openGL display interface. - * :** Texture: openGL imega interface. - * :** Font: Single file interface to store many glyphe ==> reduce the number of parallele loaded files. - * :** ConfigFile: simple widget configuration files - * :** ... - */ - class Resource : public ewol::Object { - protected: - /** - * @brief generic protected contructor (use factory to create this class) - */ - Resource() : - m_resourceLevel(MAX_RESOURCE_LEVEL-1) { - addObjectType("ewol::Resource"); - setStatusResource(true); - }; - /** - * @brief Initialisation of the class and previous classes. - * @param[in] _name Name of the resource. - */ - void init(); - //! @previous - void init(const std::string& _name); - public: - //! geenric destructor - virtual ~Resource() { - - }; - protected: - uint8_t m_resourceLevel; //!< Level of the resource ==> for update priority [0..5] 0 must be update first. - public: - /** - * @brief Get the current resource level; - * @return value in [0..5] - */ - uint8_t getResourceLevel() { - return m_resourceLevel; - }; - /** - * @brief Call when need to send data on the harware (openGL) - * @note This is done asynchronously with the create of the Resource. - */ - virtual void updateContext(); - /** - * @brief The current OpenGl context is removing ==> remove yout own system data - */ - virtual void removeContext(); - /** - * @brief The notification of the Context removing is too late, we have no more acces on the OpenGl context (thank you Android). - * Juste update your internal state - */ - virtual void removeContextToLate(); - /** - * @brief User request the reload of all resources (usefull when the file depend on DATA:GUI:xxx ... - */ - virtual void reload(); - protected: - /** - * @brief Get the current resource Manager - */ - static ewol::resource::Manager& getManager(); - }; -}; - -#include - -#endif - diff --git a/ewol/resource/Shader.cpp b/ewol/resource/Shader.cpp deleted file mode 100644 index b7378bda..00000000 --- a/ewol/resource/Shader.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "resource::Shader" - -ewol::resource::Shader::Shader() : - ewol::Resource(), - m_exist(false), - m_fileData(nullptr), - m_shader(0), - m_type(0) { - addObjectType("ewol::Shader"); - m_resourceLevel = 0; -} - -void ewol::resource::Shader::init(const std::string& _filename) { - ewol::Resource::init(_filename); - EWOL_DEBUG("OGL : load SHADER \"" << _filename << "\""); - // load data from file "all the time ..." - - if (etk::end_with(m_name, ".frag") == true) { - m_type = GL_FRAGMENT_SHADER; - } else if (etk::end_with(m_name, ".vert") == true) { - m_type = GL_VERTEX_SHADER; - } else { - EWOL_ERROR("File does not have extention \".vert\" for Vertex Shader or \".frag\" for Fragment Shader. but : \"" << m_name << "\""); - return; - } - reload(); -} - -ewol::resource::Shader::~Shader() { - if (nullptr != m_fileData) { - delete [] m_fileData; - m_fileData = nullptr; - } - if (0!=m_shader) { - glDeleteShader(m_shader); - m_shader = 0; - } - m_exist = false; -} - -static void checkGlError(const char* _op) { - for (GLint error = glGetError(); error; error = glGetError()) { - EWOL_ERROR("after " << _op << "() glError (" << error << ")"); - } -} -#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) -static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; - -void ewol::resource::Shader::updateContext() { - if (true == m_exist) { - // Do nothing == > too dangerous ... - } else { - // create the Shader - if (nullptr == m_fileData) { - m_shader = 0; - return; - } - EWOL_INFO("Create Shader : '" << m_name << "'"); - m_shader = glCreateShader(m_type); - if (!m_shader) { - EWOL_ERROR("glCreateShader return error ..."); - checkGlError("glCreateShader"); - EWOL_CRITICAL(" can not load shader"); - return; - } else { - EWOL_INFO("Compile shader with GLID=" << m_shader); - glShaderSource(m_shader, 1, (const char**)&m_fileData, nullptr); - glCompileShader(m_shader); - GLint compiled = 0; - glGetShaderiv(m_shader, GL_COMPILE_STATUS, &compiled); - if (!compiled) { - GLint infoLen = 0; - l_bufferDisplayError[0] = '\0'; - glGetShaderInfoLog(m_shader, LOG_OGL_INTERNAL_BUFFER_LEN, &infoLen, l_bufferDisplayError); - const char * tmpShaderType = "GL_FRAGMENT_SHADER"; - if (m_type == GL_VERTEX_SHADER){ - tmpShaderType = "GL_VERTEX_SHADER"; - } - EWOL_ERROR("Could not compile \"" << tmpShaderType << "\" name='" << m_name << "'"); - EWOL_ERROR("Error " << l_bufferDisplayError); - std::vector lines = etk::split(m_fileData, '\n'); - for (size_t iii=0 ; iii + +bool ewol::resource::Texture::updateContext() { + std11::unique_lock lock(m_mutex, std11::defer_lock); + if (lock.try_lock() == false) { + //Lock error ==> try later ... + return false; + } if (false == m_loaded) { // Request a new texture at openGl : glGenTextures(1, &m_texId); } + EWOL_ERROR("plop : load the image:" << m_name); // in all case we set the texture properties : // TODO : check error ??? glBindTexture(GL_TEXTURE_2D, m_texId); @@ -69,6 +78,7 @@ void ewol::resource::Texture::updateContext() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" < lock(m_mutex); if (true == m_loaded) { // Request remove texture ... EWOL_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); @@ -92,16 +104,19 @@ void ewol::resource::Texture::removeContext() { } void ewol::resource::Texture::removeContextToLate() { + std11::unique_lock lock(m_mutex); m_loaded = false; m_texId=0; } void ewol::resource::Texture::flush() { + std11::unique_lock lock(m_mutex); // request to the manager to be call at the next update ... - getManager().update(std::dynamic_pointer_cast(shared_from_this())); + getManager().update(std::dynamic_pointer_cast(shared_from_this())); } void ewol::resource::Texture::setImageSize(ivec2 _newSize) { + std11::unique_lock lock(m_mutex); _newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) ); m_data.resize(_newSize); } diff --git a/ewol/resource/Texture.h b/ewol/resource/Texture.h index 63f9158a..e8effcf6 100644 --- a/ewol/resource/Texture.h +++ b/ewol/resource/Texture.h @@ -12,37 +12,19 @@ #include #include #include -#include -#include +#include namespace ewol { namespace resource { - class Texture : public ewol::Resource { + class Texture : public gale::Resource { protected: + uint32_t m_texId; //!< openGl textureID. // openGl Context propoerties : egami::Image m_data; - // openGl textureID : - GLuint m_texId; // some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0 vec2 m_endPointSize; // internal state of the openGl system : bool m_loaded; - // Ewol internal API: - public: - void updateContext(); - void removeContext(); - void removeContextToLate(); - // middleware interface: - public: - GLuint getId() const { - return m_texId; - }; - const vec2& getUsableSize() const { - return m_endPointSize; - }; - const ivec2& getOpenGlSize() const { - return m_data.getSize(); - }; // Public API: protected: void init(const std::string& _filename); @@ -60,6 +42,15 @@ namespace ewol { }; // flush the data to send it at the openGl system void flush(); + bool updateContext(); + void removeContext(); + void removeContextToLate(); + const ivec2& getOpenGlSize() const { + return m_data.getSize(); + }; + uint32_t getRendererId() const { + return m_texId; + }; }; }; }; diff --git a/ewol/resource/TexturedFont.cpp b/ewol/resource/TexturedFont.cpp index b0ac265f..27a98433 100644 --- a/ewol/resource/TexturedFont.cpp +++ b/ewol/resource/TexturedFont.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -43,10 +43,11 @@ std::ostream& ewol::operator <<(std::ostream& _os, enum ewol::font::mode _obj) { #define __class__ "resource::TexturedFont" ewol::resource::TexturedFont::TexturedFont() { - addObjectType("ewol::resource::TexturedFont"); + addResourceType("ewol::resource::TexturedFont"); } void ewol::resource::TexturedFont::init(const std::string& _fontName) { + std11::unique_lock lock(m_mutex); ewol::resource::Texture::init(_fontName); EWOL_DEBUG("Load font : '" << _fontName << "'" ); @@ -96,12 +97,16 @@ void ewol::resource::TexturedFont::init(const std::string& _fontName) { std::vector folderList; if (true == ewol::getContext().getFontDefault().getUseExternal()) { #if defined(__TARGET_OS__Android) - folderList.push_back("/system/fonts"); + folderList.push_back("ROOT:system/fonts"); #elif defined(__TARGET_OS__Linux) - folderList.push_back("/usr/share/fonts/truetype"); + folderList.push_back("ROOT:usr/share/fonts/truetype"); #endif } - folderList.push_back(ewol::getContext().getFontDefault().getFolder()); + std::string applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); + std::vector applicationBaseFontList = etk::FSNodeExplodeMultiplePath(applicationBaseFont); + for (auto &it : applicationBaseFontList) { + folderList.push_back(it); + } for (size_t folderID=0; folderID lock(m_mutex); bool hasChange = false; // for each font : for (int32_t iii=0; iii<4 ; iii++) { @@ -300,6 +306,7 @@ bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) { } int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) { + std11::unique_lock lock(m_mutex); if (_charcode < 0x20) { return 0; } else if (_charcode < 0x80) { @@ -326,6 +333,7 @@ int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ew } ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) { + std11::unique_lock lock(m_mutex); //EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]); int32_t index = getIndex(_charcode, _displayMode); if( index < 0 diff --git a/ewol/resource/TexturedFont.h b/ewol/resource/TexturedFont.h index 8c96b869..33efcea9 100644 --- a/ewol/resource/TexturedFont.h +++ b/ewol/resource/TexturedFont.h @@ -11,7 +11,6 @@ #include #include -#include namespace ewol { namespace font { diff --git a/ewol/resource/VirtualBufferObject.cpp b/ewol/resource/VirtualBufferObject.cpp deleted file mode 100644 index d54cedcf..00000000 --- a/ewol/resource/VirtualBufferObject.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include -#include -#include - -#undef __class__ -#define __class__ "resource::VirtualBufferObject" - -void ewol::resource::VirtualBufferObject::init(int32_t _number) { - ewol::Resource::init(); - m_vbo.resize(_number, 0); - m_vboUsed.resize(_number, false); - m_buffer.resize(_number); - m_vboSizeDataOffset.resize(_number, -1); - EWOL_DEBUG("OGL : load VBO count=\"" << _number << "\""); -} - -ewol::resource::VirtualBufferObject::VirtualBufferObject() : - m_exist(false) { - addObjectType("ewol::VirtualBufferObject"); - m_resourceLevel = 3; -} - -ewol::resource::VirtualBufferObject::~VirtualBufferObject() { - removeContext(); -} - -void ewol::resource::VirtualBufferObject::retreiveData() { - EWOL_ERROR("TODO ... "); -} - -void ewol::resource::VirtualBufferObject::updateContext() { - if (false == m_exist) { - // Allocate and assign a Vertex Array Object to our handle - ewol::openGL::genBuffers(m_vbo); - } - m_exist = true; - for (size_t iii=0; iii TODO : Maybe update it"); - return; - } - m_vboUsed[_id] = true; - m_buffer[_id].push_back(_data.x()); - m_buffer[_id].push_back(_data.y()); - m_buffer[_id].push_back(_data.z()); -} - -vec3 ewol::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID) { - if ((size_t)_elementID*3 > m_buffer[_id].size()) { - return vec3(0,0,0); - } - return vec3(m_buffer[_id][3*_elementID], - m_buffer[_id][3*_elementID+1], - m_buffer[_id][3*_elementID+2]); -} - -int32_t ewol::resource::VirtualBufferObject::bufferSize(int32_t _id) { - return m_buffer[_id].size()/m_vboSizeDataOffset[_id]; -} -int32_t ewol::resource::VirtualBufferObject::getElementSize(int32_t _id) { - return m_vboSizeDataOffset[_id]; -} - -void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) { - if (m_vboSizeDataOffset[_id] == -1) { - m_vboSizeDataOffset[_id] = 2; - } else if (m_vboSizeDataOffset[_id] != 2) { - EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); - return; - } - m_vboUsed[_id] = true; - m_buffer[_id].push_back(_data.x()); - m_buffer[_id].push_back(_data.y()); -} - -vec2 ewol::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID) { - if ((size_t)_elementID*2 > m_buffer[_id].size()) { - return vec2(0,0); - } - return vec2(m_buffer[_id][2*_elementID], - m_buffer[_id][2*_elementID+1]); -} - - -void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { - if (m_vboSizeDataOffset[_id] == -1) { - m_vboSizeDataOffset[_id] = 4; - } else if (m_vboSizeDataOffset[_id] != 4) { - EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); - return; - } - m_vboUsed[_id] = true; - m_buffer[_id].push_back(_data.r()); - m_buffer[_id].push_back(_data.g()); - m_buffer[_id].push_back(_data.b()); - m_buffer[_id].push_back(_data.a()); -} - -void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { - if (m_vboSizeDataOffset[_id] == -1) { - m_vboSizeDataOffset[_id] = 3; - } else if (m_vboSizeDataOffset[_id] != 3) { - EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); - return; - } - m_vboUsed[_id] = true; - m_buffer[_id].push_back(_data.r()); - m_buffer[_id].push_back(_data.g()); - m_buffer[_id].push_back(_data.b()); -} - -void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { - if (m_vboSizeDataOffset[_id] == -1) { - m_vboSizeDataOffset[_id] = 2; - } else if (m_vboSizeDataOffset[_id] != 2) { - EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); - return; - } - m_vboUsed[_id] = true; - m_buffer[_id].push_back(_data.r()); - m_buffer[_id].push_back(_data.g()); -} - -void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color& _data) { - if (m_vboSizeDataOffset[_id] == -1) { - m_vboSizeDataOffset[_id] = 1; - } else if (m_vboSizeDataOffset[_id] != 1) { - EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it"); - return; - } - m_vboUsed[_id] = true; - m_buffer[_id].push_back(_data.r()); -} - diff --git a/ewol/resource/VirtualBufferObject.h b/ewol/resource/VirtualBufferObject.h deleted file mode 100644 index 7ebc672d..00000000 --- a/ewol/resource/VirtualBufferObject.h +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#ifndef __OPEN_GL__VIRTUAL_BUFFER_OBJECT_H__ -#define __OPEN_GL__VIRTUAL_BUFFER_OBJECT_H__ - -#include -#include -#include -#include -#include -#include - -namespace ewol { - namespace resource { - /** - * @brief VirtualBufferObject is a specific resources for opengl, this load the data directly in the graphic card ad keep these inside - */ - class VirtualBufferObject : public ewol::Resource { - private : - bool m_exist; //!< This data is availlable in the Graphic card - std::vector m_vbo; //!< openGl ID of this VBO - std::vector m_vboUsed; //!< true if the VBO is allocated or used ... - std::vector> m_buffer; //!< data that is availlable in the VBO system ... - std::vector m_vboSizeDataOffset; //!< Internal size of the VBO (dynamicly set) - protected: - /** - * @brief Constructor of this VBO. - * @param[in] accesMode Acces mode : ??? - */ - VirtualBufferObject(); - void init(int32_t _number); - public: - DECLARE_RESOURCE_FACTORY(VirtualBufferObject); - /** - * @brief Destructor of this VBO. - */ - virtual ~VirtualBufferObject(); - public: - /** - * @brief get the real openGL ID. - * @return the Ogl id reference of this VBO. - */ - GLuint getGL_ID(int32_t _id) { - return m_vbo[_id]; - }; - /** - * @brief get a reference on hte buffer data for this VBO. - * @param[in] id Id of the buffer requested - * @return A reference on the data. - */ - std::vector& getRefBuffer(int32_t _id) { - m_vboUsed[_id] = true; - return m_buffer[_id]; - }; - /** - * @brief Get the buffer Number of element. - * @param[in] _id VBO Element - * @return Number of Float in the buffer. - */ - int32_t bufferSize(int32_t _id); - /** - * @brief Get the offset between element. - * @param[in] _id VBO Element - * @return Number of Float to jump between target. - */ - int32_t getElementSize(int32_t _id); - /** - * @brief push data on a buffer with a custum type : - * @param[in] _id Id of the buffer requested. - * @param[in] _data Direct data that might be set. - */ - void pushOnBuffer(int32_t _id, const vec3& _data); - vec3 getOnBufferVec3(int32_t _id, int32_t _elementID); - /** - * @brief push data on a buffer with a custum type : - * @param[in] _id Id of the buffer requested. - * @param[in] _data Direct data that might be set. - */ - void pushOnBuffer(int32_t _id, const vec2& _data); - vec2 getOnBufferVec2(int32_t _id, int32_t _elementID); - /** - * @brief push data on a buffer with a custum type : - * @param[in] _id Id of the buffer requested. - * @param[in] _data Direct data that might be set (Color). - */ - void pushOnBuffer(int32_t _id, const etk::Color& _data); - //! @previous - void pushOnBuffer(int32_t _id, const etk::Color& _data); - //! @previous - void pushOnBuffer(int32_t _id, const etk::Color& _data); - //! @previous - void pushOnBuffer(int32_t _id, const etk::Color& _data); - /** - * @brief get the data from the graphic card. - */ - void retreiveData(); - /** - * @brief Send the data to the graphic card. - */ - void flush(); - /** - * @brief This load/reload the data in the opengl context, needed when removed previously. - */ - void updateContext(); - /** - * @brief remove the data from the opengl context. - */ - void removeContext(); - /** - * @brief Special android spec! It inform us that all context is removed and after notify us... - */ - void removeContextToLate(); - /** - * @brief Relode the shader from the file. used when a request of resouces reload is done. - * @note this is really usefull when we tested the new themes or shader developpements. - */ - void reload(); - }; - }; -}; -#endif - diff --git a/ewol/resource/font/FontBase.h b/ewol/resource/font/FontBase.h index cd237c15..6faa746d 100644 --- a/ewol/resource/font/FontBase.h +++ b/ewol/resource/font/FontBase.h @@ -14,19 +14,19 @@ #include #include #include -#include +#include #include namespace ewol { namespace resource { - class FontBase : public ewol::Resource { + class FontBase : public gale::Resource { public: FontBase() { - addObjectType("ewol::FontFreeType"); + addResourceType("ewol::FontFreeType"); } void init(const std::string& _fontName) { - ewol::Resource::init(_fontName); + gale::Resource::init(_fontName); }; virtual ~FontBase() { }; diff --git a/ewol/signal/Base.cpp b/ewol/signal/Base.cpp index 444ba2af..2e7f62ae 100644 --- a/ewol/signal/Base.cpp +++ b/ewol/signal/Base.cpp @@ -18,12 +18,14 @@ ewol::signal::Base::Base(ewol::signal::Interface& _signalInterfaceLink, const std::string& _name, - const std::string& _description) : + const std::string& _description, + bool _periodic) : m_signalInterfaceLink(_signalInterfaceLink), m_name(_name), m_description(_description), m_callInProgress(0), - m_someOneRemoveInCall(false) { + m_someOneRemoveInCall(false), + m_periodic(_periodic) { // add a reference on the current signal ... m_signalInterfaceLink.signalAdd(this); } diff --git a/ewol/signal/Base.h b/ewol/signal/Base.h index f2a3d60d..6dd1928a 100644 --- a/ewol/signal/Base.h +++ b/ewol/signal/Base.h @@ -25,16 +25,19 @@ namespace ewol { std::string m_description; int32_t m_callInProgress; bool m_someOneRemoveInCall; + bool m_periodic; public: /** * @brief Create a parameter with a specific type. * @param[in] _signalInterfaceLink reference on the signal list. * @param[in] _name Static name of the parameter. * @param[in] _description description of the parameter. + * @param[in] _periodic Customisation of the log display tag at true to down debug lebel at verbose. */ Base(ewol::signal::Interface& _signalInterfaceLink, - const std::string& _name, - const std::string& _description = ""); + const std::string& _name, + const std::string& _description = "", + bool _periodic = false); /** * @brief Destructor. */ diff --git a/ewol/signal/Signal.h b/ewol/signal/Signal.h index ecbd03c9..e029a100 100644 --- a/ewol/signal/Signal.h +++ b/ewol/signal/Signal.h @@ -23,18 +23,17 @@ namespace ewol { std::function>> m_callerListInCallback; // temporaty list (when add one in call process) public: /** - * @brief Create a parameter with a specific type. - * @param[in] _signalInterfaceLink reference on the parameter lister. - * @param[in] _name Static name of the parameter. - * @param[in] _defaultValue Default value of the parameter. - * @param[in] _min Minumum value. - * @param[in] _max Maximum value. - * @param[in] _description description of the parameter. + * @brief Create a signal with a specific type. + * @param[in] _signalInterfaceLink reference on the signal lister. + * @param[in] _name Static name of the signal. + * @param[in] _description Description of the signal. + * @param[in] _periodic Customisation of the log display tag at true to down debug lebel at verbose. */ Signal(ewol::signal::Interface& _signalInterfaceLink, const std::string& _name, - const std::string& _description = "") : - signal::Base(_signalInterfaceLink, _name, _description) { + const std::string& _description = "", + bool _periodic = false) : + signal::Base(_signalInterfaceLink, _name, _description, _periodic) { }; /** @@ -73,6 +72,30 @@ namespace ewol { m_callerListInCallback.push_back(std::make_pair(std::weak_ptr(_obj), _function)); } } + /** + * @brief Check if an object is registered in the Signal + * @param[in] _obj shared pointer on the object + * @return true The object is connected at this signal. + * @return false The object is NOT connected on this signal. + */ + bool isRegistered(std::shared_ptr _obj) { + if (_obj == nullptr) { + return false; + } + for (auto &it : m_callerList) { + std::shared_ptr obj = it.first.lock(); + if (obj == _obj) { + return true; + } + } + for (auto &it : m_callerListInCallback) { + std::shared_ptr obj = it.first.lock(); + if (obj == _obj) { + return true; + } + } + return false; + } /** * @brief remove link on the signal. * @param[in] _obj shared pointer on the removing object @@ -120,7 +143,11 @@ namespace ewol { int32_t tmpID = m_uidSignal++; #endif m_callInProgress++; - EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' data='" << etk::to_string(_data) << "' to: " << m_callerList.size() << " element(s)"); + if (m_periodic == true) { + EWOL_VERBOSE(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' data='" << etk::to_string(_data) << "' to: " << m_callerList.size() << " element(s)"); + } else { + EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' data='" << etk::to_string(_data) << "' to: " << m_callerList.size() << " element(s)"); + } auto it(m_callerList.begin()); while (it != m_callerList.end()) { std::shared_ptr destObject = it->first.lock(); @@ -129,7 +156,11 @@ namespace ewol { EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " nullptr dest"); continue; } - EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType()); + if (m_periodic == true) { + EWOL_VERBOSE(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType()); + } else { + EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType()); + } it->second(_data); ++it; } @@ -170,18 +201,17 @@ namespace ewol { std::vector, std::function>> m_callerListInCallback; public: /** - * @brief Create a parameter with a specific type. - * @param[in] _signalInterfaceLink reference on the parameter lister. - * @param[in] _name Static name of the parameter. - * @param[in] _defaultValue Default value of the parameter. - * @param[in] _min Minumum value. - * @param[in] _max Maximum value. - * @param[in] _description description of the parameter. + * @brief Create a signal with a specific 'void' type. + * @param[in] _signalInterfaceLink reference on the signal lister. + * @param[in] _name Static name of the signal. + * @param[in] _description Description of the signal. + * @param[in] _periodic Customisation of the log display tag at true to down debug lebel at verbose. */ Signal(ewol::signal::Interface& _signalInterfaceLink, const std::string& _name, - const std::string& _description = "") : - signal::Base(_signalInterfaceLink, _name, _description) { + const std::string& _description = "", + bool _periodic = false) : + signal::Base(_signalInterfaceLink, _name, _description, _periodic) { }; /** @@ -253,7 +283,11 @@ namespace ewol { int32_t tmpID = m_uidSignal++; #endif m_callInProgress++; - EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' to: " << m_callerList.size() << " element(s)"); + if (m_periodic == true) { + EWOL_VERBOSE(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' to: " << m_callerList.size() << " element(s)"); + } else { + EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << "emit signal{" << tmpID << "} : signal='" << m_name << "' to: " << m_callerList.size() << " element(s)"); + } auto it(m_callerList.begin()); while (it != m_callerList.end()) { std::shared_ptr destObject = it->first.lock(); @@ -262,7 +296,11 @@ namespace ewol { EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " nullptr dest"); continue; } - EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType()); + if (m_periodic == true) { + EWOL_VERBOSE(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType()); + } else { + EWOL_DEBUG(ewol::signal::logIndent(m_signalCallLevel-1) << " signal{" << tmpID << "} :");// [" << destObject->getId() << "]" << destObject->getObjectType()); + } it->second(); ++it; } diff --git a/ewol/widget/Button.cpp b/ewol/widget/Button.cpp index d6821ce0..4c7948b3 100644 --- a/ewol/widget/Button.cpp +++ b/ewol/widget/Button.cpp @@ -101,8 +101,8 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { if(ewol::widget::Button::lockAccess == m_lock) { return false; } - if( ewol::key::statusLeave == _event.getStatus() - || ewol::key::statusAbort == _event.getStatus()) { + if( gale::key::status_leave == _event.getStatus() + || gale::key::status_abort == _event.getStatus()) { m_mouseHover = false; m_buttonPressed = false; } else { @@ -121,19 +121,19 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { EWOL_VERBOSE("Event on BT ... mouse hover : " << m_mouseHover); if (true == m_mouseHover) { if (1 == _event.getId()) { - if(ewol::key::statusDown == _event.getStatus()) { + if(gale::key::status_down == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); signalDown.emit(); m_buttonPressed = true; markToRedraw(); } - if(ewol::key::statusUp == _event.getStatus()) { + if(gale::key::status_up == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); signalUp.emit(); m_buttonPressed = false; markToRedraw(); } - if(ewol::key::statusSingle == _event.getStatus()) { + if(gale::key::status_single == _event.getStatus()) { if( ( m_value.get() == true && ewol::widget::Button::lockWhenPressed == m_lock) || ( m_value.get() == false @@ -165,8 +165,8 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); - if( _event.getType() == ewol::key::keyboardChar - && _event.getStatus() == ewol::key::statusDown + if( _event.getType() == gale::key::keyboard_char + && _event.getStatus() == gale::key::status_down && _event.getChar() == '\r') { signalEnter.emit(); return true; diff --git a/ewol/widget/Button.h b/ewol/widget/Button.h index 03b00be1..5017649a 100644 --- a/ewol/widget/Button.h +++ b/ewol/widget/Button.h @@ -50,7 +50,7 @@ namespace ewol { * @param[in] _shaperName Shaper file properties */ Button(); - void init(const std::string& _shaperName="THEME:GUI:Button.json"); + void init(const std::string& _shaperName="{ewol}THEME:GUI:Button.json"); public: DECLARE_WIDGET_FACTORY(Button, "Button"); /** diff --git a/ewol/widget/ButtonColor.cpp b/ewol/widget/ButtonColor.cpp index d0ad664f..72271e52 100644 --- a/ewol/widget/ButtonColor.cpp +++ b/ewol/widget/ButtonColor.cpp @@ -137,7 +137,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() { bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { bool previousHoverState = m_mouseHover; - if(ewol::key::statusLeave == _event.getStatus()) { + if(gale::key::status_leave == _event.getStatus()) { m_mouseHover = false; m_buttonPressed = false; } else { @@ -157,15 +157,15 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover); if (true == m_mouseHover) { if (1 == _event.getId()) { - if(ewol::key::statusDown == _event.getStatus()) { + if(gale::key::status_down == _event.getStatus()) { m_buttonPressed = true; markToRedraw(); } - if(ewol::key::statusUp == _event.getStatus()) { + if(gale::key::status_up == _event.getStatus()) { m_buttonPressed = false; markToRedraw(); } - if(ewol::key::statusSingle == _event.getStatus()) { + if(gale::key::status_single == _event.getStatus()) { m_buttonPressed = false; m_mouseHover = false; // create a context menu : diff --git a/ewol/widget/ButtonColor.h b/ewol/widget/ButtonColor.h index dca4ac19..95069804 100644 --- a/ewol/widget/ButtonColor.h +++ b/ewol/widget/ButtonColor.h @@ -41,7 +41,7 @@ namespace ewol { * @param[in] _shaperName The new shaper filename. */ ButtonColor(); - void init(etk::Color<> _baseColor=etk::color::black, std::string _shaperName="THEME:GUI:Button.json"); + void init(etk::Color<> _baseColor=etk::color::black, std::string _shaperName="{ewol}THEME:GUI:Button.json"); public: DECLARE_WIDGET_FACTORY(ButtonColor, "ButtonColor"); /** diff --git a/ewol/widget/CheckBox.cpp b/ewol/widget/CheckBox.cpp index f4a191ce..11bd37ba 100644 --- a/ewol/widget/CheckBox.cpp +++ b/ewol/widget/CheckBox.cpp @@ -105,8 +105,8 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { EWOL_VERBOSE("Event on BT : " << _event); bool previousHoverState = m_mouseHover; - if( ewol::key::statusLeave == _event.getStatus() - || ewol::key::statusAbort == _event.getStatus()) { + if( gale::key::status_leave == _event.getStatus() + || gale::key::status_abort == _event.getStatus()) { m_mouseHover = false; m_buttonPressed = false; } else { @@ -126,19 +126,19 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { EWOL_VERBOSE("Event on BT ... mouse hover : " << m_mouseHover); if (true == m_mouseHover) { if (1 == _event.getId()) { - if(ewol::key::statusDown == _event.getStatus()) { + if(gale::key::status_down == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); signalDown.emit(); m_buttonPressed = true; markToRedraw(); } - if(ewol::key::statusUp == _event.getStatus()) { + if(gale::key::status_up == _event.getStatus()) { EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); signalUp.emit(); m_buttonPressed = false; markToRedraw(); } - if(ewol::key::statusSingle == _event.getStatus()) { + if(gale::key::status_single == _event.getStatus()) { // inverse value : setValue((m_value)?false:true); EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); @@ -159,8 +159,8 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); - if( _event.getType() == ewol::key::keyboardChar - && _event.getStatus() == ewol::key::statusDown + if( _event.getType() == gale::key::keyboard_char + && _event.getStatus() == gale::key::status_down && _event.getChar() == '\r') { signalEnter.emit(); return true; diff --git a/ewol/widget/CheckBox.h b/ewol/widget/CheckBox.h index 7e606a76..6c49d7fc 100644 --- a/ewol/widget/CheckBox.h +++ b/ewol/widget/CheckBox.h @@ -43,7 +43,7 @@ namespace ewol { * @param[in] _shaperName Shaper file properties */ CheckBox(); - void init(const std::string& _shaperName="THEME:GUI:CheckBox.json"); + void init(const std::string& _shaperName="{ewol}THEME:GUI:CheckBox.json"); public: DECLARE_WIDGET_FACTORY(CheckBox, "CheckBox"); /** diff --git a/ewol/widget/ColorBar.cpp b/ewol/widget/ColorBar.cpp index 4ba95fa6..69fe3989 100644 --- a/ewol/widget/ColorBar.cpp +++ b/ewol/widget/ColorBar.cpp @@ -170,8 +170,8 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { if (1 == _event.getId()) { relativePos.setValue( std::avg(0.0f, m_size.x(),relativePos.x()), std::avg(0.0f, m_size.y(),relativePos.y()) ); - if( ewol::key::statusSingle == _event.getStatus() - || ewol::key::statusMove == _event.getStatus()) { + if( gale::key::status_single == _event.getStatus() + || gale::key::status_move == _event.getStatus()) { // nothing to do ... m_currentUserPos.setValue( relativePos.x()/m_size.x(), relativePos.y()/m_size.y() ); diff --git a/ewol/widget/ContextMenu.cpp b/ewol/widget/ContextMenu.cpp index 061181a1..48c3d517 100644 --- a/ewol/widget/ContextMenu.cpp +++ b/ewol/widget/ContextMenu.cpp @@ -204,12 +204,12 @@ bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { if (nullptr != ewol::widget::Container::getWidgetAtPos(_event.getPos())) { return false; } - if( _event.getStatus() == ewol::key::statusDown - || _event.getStatus() == ewol::key::statusMove - || _event.getStatus() == ewol::key::statusSingle - || _event.getStatus() == ewol::key::statusUp - || _event.getStatus() == ewol::key::statusEnter - || _event.getStatus() == ewol::key::statusLeave ) { + if( _event.getStatus() == gale::key::status_down + || _event.getStatus() == gale::key::status_move + || _event.getStatus() == gale::key::status_single + || _event.getStatus() == gale::key::status_up + || _event.getStatus() == gale::key::status_enter + || _event.getStatus() == gale::key::status_leave ) { // Auto-remove ... autoDestroy(); return true; diff --git a/ewol/widget/ContextMenu.h b/ewol/widget/ContextMenu.h index b250f8c8..d8494f9e 100644 --- a/ewol/widget/ContextMenu.h +++ b/ewol/widget/ContextMenu.h @@ -33,7 +33,7 @@ namespace ewol { }; protected: ContextMenu(); - void init(const std::string& _shaperName="THEME:GUI:ContextMenu.json"); + void init(const std::string& _shaperName="{ewol}THEME:GUI:ContextMenu.json"); public: DECLARE_WIDGET_FACTORY(ContextMenu, "ContextMenu"); virtual ~ContextMenu(); diff --git a/ewol/widget/Entry.cpp b/ewol/widget/Entry.cpp index 09029652..2b0f31b7 100644 --- a/ewol/widget/Entry.cpp +++ b/ewol/widget/Entry.cpp @@ -41,7 +41,7 @@ ewol::widget::Entry::Entry() : void ewol::widget::Entry::init(const std::string& _newData) { ewol::Widget::init(); m_data.set(_newData); - m_shaper.setString("THEME:GUI:Entry.json"); + m_shaper.setString("{ewol}THEME:GUI:Entry.json"); setCanHaveFocus(true); try { @@ -234,7 +234,7 @@ void ewol::widget::Entry::removeSelected() { } -void ewol::widget::Entry::copySelectionToClipBoard(enum ewol::context::clipBoard::clipboardListe _clipboardID) { +void ewol::widget::Entry::copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID) { if (m_displayCursorPosSelection == m_displayCursorPos) { // nothing to cut ... return; @@ -247,19 +247,19 @@ void ewol::widget::Entry::copySelectionToClipBoard(enum ewol::context::clipBoard } // Copy std::string tmpData = std::string(m_data, pos1, pos2); - ewol::context::clipBoard::set(_clipboardID, tmpData); + gale::context::clipBoard::set(_clipboardID, tmpData); } bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput); if (1 == _event.getId()) { - if (ewol::key::statusSingle == _event.getStatus()) { + if (gale::key::status_single == _event.getStatus()) { keepFocus(); signalClick.emit(); //nothing to do ... return true; - } else if (ewol::key::statusDouble == _event.getStatus()) { + } else if (gale::key::status_double == _event.getStatus()) { keepFocus(); // select word m_displayCursorPosSelection = m_displayCursorPos-1; @@ -302,42 +302,42 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { } } // Copy to clipboard Middle ... - copySelectionToClipBoard(ewol::context::clipBoard::clipboardSelection); + copySelectionToClipBoard(gale::context::clipBoard::clipboardSelection); markToRedraw(); - } else if (ewol::key::statusTriple == _event.getStatus()) { + } else if (gale::key::status_triple == _event.getStatus()) { keepFocus(); m_displayCursorPosSelection = 0; m_displayCursorPos = m_data->size(); - } else if (ewol::key::statusDown == _event.getStatus()) { + } else if (gale::key::status_down == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos()); markToRedraw(); - } else if (ewol::key::statusMove == _event.getStatus()) { + } else if (gale::key::status_move == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos(), true); markToRedraw(); - } else if (ewol::key::statusUp == _event.getStatus()) { + } else if (gale::key::status_up == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos(), true); // Copy to clipboard Middle ... - copySelectionToClipBoard(ewol::context::clipBoard::clipboardSelection); + copySelectionToClipBoard(gale::context::clipBoard::clipboardSelection); markToRedraw(); } } - else if( ewol::key::typeMouse == _event.getType() + else if( gale::key::type_mouse == _event.getType() && _event.getId() == 2) { - if( _event.getStatus() == ewol::key::statusDown - || _event.getStatus() == ewol::key::statusMove - || _event.getStatus() == ewol::key::statusUp) { + if( _event.getStatus() == gale::key::status_down + || _event.getStatus() == gale::key::status_move + || _event.getStatus() == gale::key::status_up) { keepFocus(); // updatethe cursor position : updateCursorPosition(_event.getPos()); } // Paste current selection only when up button - if (_event.getStatus() == ewol::key::statusUp) { + if (_event.getStatus() == gale::key::status_up) { keepFocus(); // middle button => past data... - ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardSelection); + gale::context::clipBoard::request(gale::context::clipBoard::clipboardSelection); } } return false; @@ -345,8 +345,8 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { - if (_event.getType() == ewol::key::keyboardChar) { - if(_event.getStatus() == ewol::key::statusDown) { + if (_event.getType() == gale::key::keyboard_char) { + if(_event.getStatus() == gale::key::status_down) { // remove curent selected data ... removeSelected(); if( _event.getChar() == '\n' @@ -387,19 +387,19 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { } return false; } else { - if(_event.getStatus() == ewol::key::statusDown) { + if(_event.getStatus() == gale::key::status_down) { switch (_event.getType()) { - case ewol::key::keyboardLeft: + case gale::key::keyboard_left: m_displayCursorPos--; break; - case ewol::key::keyboardRight: + case gale::key::keyboard_right: m_displayCursorPos++; break; - case ewol::key::keyboardStart: + case gale::key::keyboard_start: m_displayCursorPos = 0; break; - case ewol::key::keyboardEnd: + case gale::key::keyboard_end: m_displayCursorPos = m_data->size(); break; default: @@ -437,7 +437,7 @@ void ewol::widget::Entry::setInternalValue(const std::string& _newData) { markToRedraw(); } -void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID) { +void ewol::widget::Entry::onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID) { // remove curent selected data ... removeSelected(); // get current selection / Copy : @@ -469,17 +469,17 @@ void ewol::widget::Entry::onCallbackEntryClean() { } void ewol::widget::Entry::onCallbackCut() { - copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); + copySelectionToClipBoard(gale::context::clipBoard::clipboardStd); removeSelected(); signalModify.emit(m_data); } void ewol::widget::Entry::onCallbackCopy() { - copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); + copySelectionToClipBoard(gale::context::clipBoard::clipboardStd); } void ewol::widget::Entry::onCallbackPaste() { - ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd); + gale::context::clipBoard::request(gale::context::clipBoard::clipboardStd); } void ewol::widget::Entry::onCallbackSelect(bool _all) { diff --git a/ewol/widget/Entry.h b/ewol/widget/Entry.h index f5e88760..6a202396 100644 --- a/ewol/widget/Entry.h +++ b/ewol/widget/Entry.h @@ -140,7 +140,7 @@ namespace ewol { * @brief Copy the selected data on the specify clipboard * @param[in] _clipboardID Selected clipboard */ - virtual void copySelectionToClipBoard(enum ewol::context::clipBoard::clipboardListe _clipboardID); + virtual void copySelectionToClipBoard(enum gale::context::clipBoard::clipboardListe _clipboardID); /** * @brief remove the selected area * @note This request a regeneration of the display @@ -167,7 +167,7 @@ namespace ewol { virtual void onRegenerateDisplay(); virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventEntry(const ewol::event::Entry& _event); - virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); + virtual void onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID); virtual void calculateMinMaxSize(); protected: // Derived function virtual void onDraw(); diff --git a/ewol/widget/Image.cpp b/ewol/widget/Image.cpp index 9fa8a37d..ba8d2955 100644 --- a/ewol/widget/Image.cpp +++ b/ewol/widget/Image.cpp @@ -26,15 +26,17 @@ ewol::widget::Image::Image() : m_keepRatio(*this, "ratio", true, "Keep ratio of the image"), m_posStart(*this, "part-start", vec2(0.0f, 0.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), m_posStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), - m_distanceFieldMode(*this, "distance-field", false, "Distance field mode") { + m_distanceFieldMode(*this, "distance-field", false, "Distance field mode"), + m_smooth(*this, "smooth", true, "Smooth display of the image") { addObjectType("ewol::widget::Image"); - m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Image.json"); + m_imageRenderSize = vec2(0,0); + m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:Image.json"); if (m_colorProperty != nullptr) { m_colorId = m_colorProperty->request("foreground"); } } -void ewol::widget::Image::init(const std::string& _file, const ewol::Dimension& _border) { +void ewol::widget::Image::init(const std::string& _file, const gale::Dimension& _border) { ewol::Widget::init(); set(_file, _border); } @@ -44,7 +46,7 @@ ewol::widget::Image::~Image() { } -void ewol::widget::Image::set(const std::string& _file, const ewol::Dimension& _border) { +void ewol::widget::Image::set(const std::string& _file, const gale::Dimension& _border) { EWOL_VERBOSE("Set Image : " << _file << " border=" << _border); m_border.set(_border); m_fileName.set(_file); @@ -65,7 +67,7 @@ void ewol::widget::Image::onRegenerateDisplay() { vec2 imageBoder = m_border->getPixel(); vec2 origin = imageBoder; imageBoder *= 2.0f; - vec2 imageRealSize = m_minSize - imageBoder; + vec2 imageRealSize = m_imageRenderSize - imageBoder; vec2 imageRealSizeMax = m_size - imageBoder; vec2 ratioSizeDisplayRequested = m_posStop.get() - m_posStart.get(); @@ -74,13 +76,47 @@ void ewol::widget::Image::onRegenerateDisplay() { if (m_userFill->x() == true) { imageRealSize.setX(imageRealSizeMax.x()); } else { - origin.setX(origin.x() + (m_size.x()-m_minSize.x())*0.5f); + switch(m_gravity) { + case gravityCenter: + case gravityTop: + case gravityButtom: + origin.setX(origin.x() + (m_size.x()-m_imageRenderSize.x())*0.5f); + break; + case gravityTopLeft: + case gravityButtomLeft: + case gravityLeft: + // nothing to do ... + break; + case gravityTopRight: + case gravityRight: + case gravityButtomRight: + origin.setX(origin.x() + (m_size.x()-m_imageRenderSize.x())*0.5f); + break; + } } if (m_userFill->y() == true) { imageRealSize.setY(imageRealSizeMax.y()); } else { - origin.setY(origin.y() + (m_size.y()-m_minSize.y())*0.5f); + // + switch(m_gravity) { + case gravityCenter: + case gravityRight: + case gravityLeft: + origin.setY(origin.y() + (m_size.y()-m_imageRenderSize.y())*0.5f); + break; + case gravityTopLeft: + case gravityTop: + case gravityTopRight: + origin.setY(origin.y() + (m_size.y()-m_imageRenderSize.y())); + break; + case gravityButtomRight: + case gravityButtom: + case gravityButtomLeft: + // nothing to do ... + break; + } } + if (m_keepRatio == true) { vec2 tmpSize = m_compositing.getRealSize(); //float ratio = tmpSize.x() / tmpSize.y(); @@ -101,7 +137,11 @@ void ewol::widget::Image::onRegenerateDisplay() { } // set the somposition properties : - m_compositing.setPos(origin); + if (m_smooth.get() == true) { + m_compositing.setPos(origin); + } else { + m_compositing.setPos(ivec2(origin)); + } m_compositing.printPart(imageRealSize, m_posStart, m_posStop); //EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin); EWOL_VERBOSE("Paint Image :" << m_fileName << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize); @@ -111,7 +151,8 @@ void ewol::widget::Image::onRegenerateDisplay() { void ewol::widget::Image::calculateMinMaxSize() { vec2 imageBoder = m_border->getPixel()*2.0f; vec2 imageSize = m_imageSize->getPixel(); - if (imageSize!=vec2(0,0)) { + vec2 size = m_userMinSize->getPixel(); + if (imageSize != vec2(0,0)) { m_minSize = imageBoder+imageSize; m_maxSize = m_minSize; } else { @@ -124,7 +165,10 @@ void ewol::widget::Image::calculateMinMaxSize() { m_maxSize = imageBoder+m_userMaxSize->getPixel(); m_minSize.setMin(m_maxSize); } - //EWOL_DEBUG("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << imageSizeReal); + m_imageRenderSize = m_minSize; + m_minSize.setMax(size); + m_maxSize.setMax(m_minSize); + //EWOL_ERROR("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << m_imageSize); markToRedraw(); } @@ -132,7 +176,7 @@ void ewol::widget::Image::calculateMinMaxSize() { bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on BT ..."); if (_event.getId() == 1) { - if(ewol::key::statusSingle == _event.getStatus()) { + if(gale::key::status_single == _event.getStatus()) { signalPressed.emit(); return true; } @@ -167,6 +211,10 @@ bool ewol::widget::Image::loadXML(const std::shared_ptr& _n if (tmpAttributeValue.size() != 0) { m_border = tmpAttributeValue; } + tmpAttributeValue = _node->getAttribute("smooth"); + if (tmpAttributeValue.size() != 0) { + m_smooth = etk::string_to_bool(tmpAttributeValue); + } //EWOL_DEBUG("Load label:" << node->ToElement()->getText()); if (_node->size() != 0) { setFile(_node->getText()); @@ -195,5 +243,7 @@ void ewol::widget::Image::onParameterChangeValue(const ewol::parameter::Ref& _pa requestUpdateSize(); } else if (_paramPointer == m_distanceFieldMode) { markToRedraw(); + } else if (_paramPointer == m_smooth) { + markToRedraw(); } } diff --git a/ewol/widget/Image.h b/ewol/widget/Image.h index bede5c6d..0c9f502f 100644 --- a/ewol/widget/Image.h +++ b/ewol/widget/Image.h @@ -37,7 +37,7 @@ namespace ewol { */ Image(); void init(const std::string& _file="", - const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter)); + const gale::Dimension& _border=gale::Dimension(vec2(0,0),gale::Dimension::Millimeter)); public: DECLARE_WIDGET_FACTORY(Image, "Image"); /** @@ -49,7 +49,7 @@ namespace ewol { * @param[in] _file Filaneme of the new image * @param[in] _border New border size to set */ - void set(const std::string& _file, const ewol::Dimension& _border); + void set(const std::string& _file, const gale::Dimension& _border); protected: ewol::parameter::Value m_fileName; //!< file name of the image. public: @@ -68,33 +68,34 @@ namespace ewol { return m_fileName; }; protected: - ewol::parameter::Value m_border; //!< border to add at the image. + ewol::parameter::Value m_border; //!< border to add at the image. public: /** * @brief set tge Border size around the image * @param[in] _border New border size to set */ - void setBorder(const ewol::Dimension& _border); + void setBorder(const gale::Dimension& _border); /** * @brief get the current border request at the image * @return the border size */ - const ewol::Dimension& getBorder() const { + const gale::Dimension& getBorder() const { return m_border; }; protected: - ewol::parameter::Value m_imageSize; //!< border to add at the image. + ewol::parameter::Value m_imageSize; //!< border to add at the image. + vec2 m_imageRenderSize; //!< size of the image when we render it public: /** * @brief set tge Border size around the image * @param[in] _size New border size to set */ - void setImageSize(const ewol::Dimension& _size); + void setImageSize(const gale::Dimension& _size); /** * @brief get the current border request at the image * @return the border size */ - const ewol::Dimension& getImageSize() const { + const gale::Dimension& getImageSize() const { return m_imageSize; }; protected: @@ -142,7 +143,7 @@ namespace ewol { vec2 getStopPos() const { return m_posStop; }; - public: + protected: ewol::parameter::Value m_distanceFieldMode; //!< to have a parameter public: /** @@ -159,6 +160,23 @@ namespace ewol { bool getDistanceField() const { return m_compositing.getDistanceFieldMode(); } + protected: + ewol::parameter::Value m_smooth; //!< display is done in the pixed approximation if false + public: + /** + * @brief Set smooth rendering mode + * @param[in] _value enable smooting of the display + */ + void setSmooth(bool _value) { + m_smooth.set(_value); + } + /** + * @brief Get smooth rendering mode + * @return Status of the smooting render mode. + */ + bool getSmooth() const { + return m_smooth; + } protected: // Derived function virtual void onDraw(); virtual void onParameterChangeValue(const ewol::parameter::Ref& _paramPointer); diff --git a/ewol/widget/Joystick.cpp b/ewol/widget/Joystick.cpp index b4be3bea..539f7f80 100644 --- a/ewol/widget/Joystick.cpp +++ b/ewol/widget/Joystick.cpp @@ -117,8 +117,8 @@ Tangent Function: tan(teta) = Opposite / Adjacent bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { /* if (1 == IdInput) { - if( ewol::key::statusDown == typeEvent - || ewol::key::statusMove == typeEvent) { + if( gale::key::status_down == typeEvent + || gale::key::status_move == typeEvent) { // get local relative position vec2 relativePos = relativePosition(pos); float sizeElement = m_size.x*m_ratio; @@ -143,7 +143,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { m_displayPos.y = sin(m_angle)*m_distance; } markToRedraw(); - if(ewol::key::statusDown == typeEvent) { + if(gale::key::status_down == typeEvent) { signalEnable.emit(); } else { std::string tmp = std::string("distance=") + std::string(m_distance) + std::string("angle=") + std::string(m_angle+M_PI/2); @@ -152,7 +152,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) { //teta += M_PI/2; //EWOL_DEBUG("TETA = " << (m_angle*180/M_PI) << " deg distance = " << m_distance); return true; - } else if( ewol::key::statusUp == typeEvent) { + } else if( gale::key::status_up == typeEvent) { if( true == m_lock && m_distance == 1) { // nothing to do ... diff --git a/ewol/widget/Label.cpp b/ewol/widget/Label.cpp index c118c78c..c881ad4b 100644 --- a/ewol/widget/Label.cpp +++ b/ewol/widget/Label.cpp @@ -23,7 +23,7 @@ ewol::widget::Label::Label() : m_colorDefaultFgText(-1), m_colorDefaultBgText(-1){ addObjectType("ewol::widget::Label"); - m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Label.json"); + m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:Label.json"); if (m_colorProperty != nullptr) { m_colorDefaultFgText = m_colorProperty->request("foreground"); m_colorDefaultBgText = m_colorProperty->request("background"); @@ -122,7 +122,7 @@ void ewol::widget::Label::onRegenerateDisplay() { bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on Label ..."); if (1 == _event.getId()) { - if (ewol::key::statusSingle == _event.getStatus()) { + if (gale::key::status_single == _event.getStatus()) { // nothing to do ... signalPressed.emit(); return true; diff --git a/ewol/widget/List.h b/ewol/widget/List.h index 067f7bd5..faffa819 100644 --- a/ewol/widget/List.h +++ b/ewol/widget/List.h @@ -68,7 +68,7 @@ namespace ewol { } return false; }; - virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) { + virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) { return false; } /** diff --git a/ewol/widget/ListFileSystem.cpp b/ewol/widget/ListFileSystem.cpp index b987d111..a2f2a152 100644 --- a/ewol/widget/ListFileSystem.cpp +++ b/ewol/widget/ListFileSystem.cpp @@ -31,7 +31,7 @@ ewol::widget::ListFileSystem::ListFileSystem() : #if defined(__TARGET_OS__Windows) m_folder = "c:/"; #endif - m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:ListFileSystem.json"); + m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:ListFileSystem.json"); if (m_colorProperty != nullptr) { m_colorIdText = m_colorProperty->request("text"); m_colorIdBackground1 = m_colorProperty->request("background1"); @@ -159,7 +159,7 @@ bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, - enum ewol::key::status _typeEvent, + enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, @@ -172,7 +172,7 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, offset = 2; } } - if (_typeEvent == ewol::key::statusSingle) { + if (_typeEvent == gale::key::status_single) { EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); if (1 == _IdInput) { int32_t previousRaw = m_selectedLine; diff --git a/ewol/widget/ListFileSystem.h b/ewol/widget/ListFileSystem.h index f37bb22f..643e8fce 100644 --- a/ewol/widget/ListFileSystem.h +++ b/ewol/widget/ListFileSystem.h @@ -44,7 +44,7 @@ namespace ewol { virtual bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg); virtual uint32_t getNuberOfRaw(); virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg); - virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y); + virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y); protected: std::vector m_list; //!< List of all element in the path. (they are filtered) /** diff --git a/ewol/widget/Manager.cpp b/ewol/widget/Manager.cpp index dbd45161..ead8e708 100644 --- a/ewol/widget/Manager.cpp +++ b/ewol/widget/Manager.cpp @@ -157,48 +157,18 @@ void ewol::widget::Manager::focusRemoveIfRemove(const std::shared_ptr= 0 ; iii--) { - auto tmpWidget = m_listOfPeriodicWidget[iii].lock(); - if (nullptr != tmpWidget) { - int64_t deltaTimeCallUser = tmpWidget->systemGetCallDeltaTime(); - if (deltaTimeCallUser <= 0) { - myTime.setDeltaCall(deltaTime); - EWOL_VERBOSE("[" << iii << "] periodic : " << myTime); - tmpWidget->systemSetLastCallTime(_localTime); - tmpWidget->periodicCall(myTime); - } else { - int64_t lastCallTime = tmpWidget->systemGetLastCallTime(); - if (lastCallTime == 0) { - lastCallTime = _localTime; - } - float deltaLocalTime = (float)(_localTime-lastCallTime)/1000000.0;; - if (deltaLocalTime >= lastCallTime) { - myTime.setDeltaCall(deltaLocalTime); - EWOL_VERBOSE("[" << iii << "] periodic : " << myTime); - tmpWidget->systemSetLastCallTime(_localTime); - tmpWidget->periodicCall(myTime); - } - } - } - } +void ewol::widget::Manager::setCallbackonRedrawNeeded(const std::function& _func) { + m_funcRedrawNeeded = _func; } -*/ - void ewol::widget::Manager::markDrawingIsNeeded() { + if (m_haveRedraw == true) { + return; + } m_haveRedraw = true; + if (m_funcRedrawNeeded != nullptr) { + m_funcRedrawNeeded(); + } } bool ewol::widget::Manager::isDrawingNeeded() { diff --git a/ewol/widget/Manager.h b/ewol/widget/Manager.h index f3bcea8b..c839c921 100644 --- a/ewol/widget/Manager.h +++ b/ewol/widget/Manager.h @@ -36,9 +36,12 @@ namespace ewol { void focusRelease(); // release focus from the current widget to the default std::shared_ptr focusGet(); void focusRemoveIfRemove(const std::shared_ptr& _newWidget); - + private: + std::function m_funcRedrawNeeded; + public: void markDrawingIsNeeded(); bool isDrawingNeeded(); + void setCallbackonRedrawNeeded(const std::function& _func); // element that generate the list of elements void addWidgetCreator(const std::string& _name, creator_tf _pointer); diff --git a/ewol/widget/PopUp.cpp b/ewol/widget/PopUp.cpp index 8f900e96..dfde20f0 100644 --- a/ewol/widget/PopUp.cpp +++ b/ewol/widget/PopUp.cpp @@ -29,7 +29,7 @@ ewol::widget::PopUp::PopUp() : void ewol::widget::PopUp::init(const std::string& _shaperName) { ewol::widget::Container::init(); m_shaper.setString(_shaperName); - setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent)); + setMinSize(gale::Dimension(vec2(80,80),gale::Dimension::Pourcent)); m_userExpand.set(bvec2(false, false)); } ewol::widget::PopUp::~PopUp() { diff --git a/ewol/widget/PopUp.h b/ewol/widget/PopUp.h index 2739109d..cd6d1af8 100644 --- a/ewol/widget/PopUp.h +++ b/ewol/widget/PopUp.h @@ -31,7 +31,7 @@ namespace ewol { * @param[in] _shaperName Shaper file properties */ PopUp(); - void init(const std::string& _shaperName="THEME:GUI:PopUp.json"); + void init(const std::string& _shaperName="{ewol}THEME:GUI:PopUp.json"); public: DECLARE_WIDGET_FACTORY(PopUp, "PopUp"); /** diff --git a/ewol/widget/Scroll.cpp b/ewol/widget/Scroll.cpp index 5edb9531..836b853a 100644 --- a/ewol/widget/Scroll.cpp +++ b/ewol/widget/Scroll.cpp @@ -20,7 +20,7 @@ ewol::widget::Scroll::Scroll() : m_highSpeedStartPos(0,0), m_highSpeedMode(speedModeDisable), m_highSpeedButton(-1), - m_highSpeedType(ewol::key::typeUnknow) { + m_highSpeedType(gale::key::type_unknow) { addObjectType("ewol::widget::Scroll"); } @@ -113,7 +113,7 @@ void ewol::widget::Scroll::onRegenerateDisplay() { bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { //ewol::event::Input _event = event; - //_event.setType(ewol::key::typeFinger); + //_event.setType(gale::key::type_finger); vec2 relativePos = relativePosition(_event.getPos()); vec2 scrollOffset(0,0); vec2 scrollSize(0,0); @@ -123,17 +123,17 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { } EWOL_VERBOSE("Get Event on scroll : " << _event); relativePos.setY(m_size.y() - relativePos.y()); - if( _event.getType() == ewol::key::typeMouse - && ( ewol::key::typeUnknow == m_highSpeedType - || ewol::key::typeMouse == m_highSpeedType ) ) { + if( _event.getType() == gale::key::type_mouse + && ( gale::key::type_unknow == m_highSpeedType + || gale::key::type_mouse == m_highSpeedType ) ) { if( _event.getId() == 1 - && _event.getStatus() == ewol::key::statusDown) { + && _event.getStatus() == gale::key::status_down) { // check if selected the scrolling position whth the scrolling bar ... if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) { if( m_size.y() < scrollSize.y() || scrollOffset.y() != 0) { m_highSpeedMode = speedModeEnableVertical; - m_highSpeedType = ewol::key::typeMouse; + m_highSpeedType = gale::key::type_mouse; m_highSpeedStartPos.setX(relativePos.x()); m_highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (m_size.y()-SCROLL_BAR_SPACE*2)); m_highSpeedButton = 1; @@ -150,7 +150,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { if( m_size.x() < scrollSize.x() || scrollOffset.x()!=0) { m_highSpeedMode = speedModeEnableHorizontal; - m_highSpeedType = ewol::key::typeMouse; + m_highSpeedType = gale::key::type_mouse; m_highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (m_size.x()-SCROLL_BAR_SPACE*2)); m_highSpeedStartPos.setY(relativePos.y()); m_highSpeedButton = 1; @@ -166,7 +166,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { } return false; } else if( _event.getId() == 4 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { if(m_size.y() < scrollSize.y()) { scrollOffset.setY(scrollOffset.y()-m_pixelScrolling); scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); @@ -177,7 +177,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } } else if( _event.getId() == 5 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { if(m_size.y() < scrollSize.y()) { scrollOffset.setY(scrollOffset.y()+m_pixelScrolling); scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); @@ -188,28 +188,28 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } }else if (_event.getId() == 2) { - if (_event.getStatus() == ewol::key::statusDown) { + if (_event.getStatus() == gale::key::status_down) { m_highSpeedMode = speedModeInit; - m_highSpeedType = ewol::key::typeMouse; + m_highSpeedType = gale::key::type_mouse; m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); m_highSpeedButton = 2; // not really use... == > just keep some informations return false; } } else if( m_highSpeedMode != speedModeDisable - && _event.getStatus() == ewol::key::statusLeave) { + && _event.getStatus() == gale::key::status_leave) { m_highSpeedMode = speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; markToRedraw(); return true; } if ( _event.getId() == m_highSpeedButton && m_highSpeedMode != speedModeDisable) { - if (_event.getStatus() == ewol::key::statusUp) { + if (_event.getStatus() == gale::key::status_up) { if (m_highSpeedMode == speedModeInit) { // TODO : generate back the down event ... m_highSpeedMode = speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; return false; } else { m_highSpeedMode = speedModeGrepEndEvent; @@ -217,15 +217,15 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } } else if (m_highSpeedMode == speedModeGrepEndEvent) { - if (_event.getStatus() == ewol::key::statusSingle) { + if (_event.getStatus() == gale::key::status_single) { m_highSpeedMode = speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; m_highSpeedButton = -1; markToRedraw(); } return true; } else if( m_highSpeedMode == speedModeInit - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { // wait that the cursor move more than 10 px to enable it : if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { @@ -257,7 +257,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } if( m_highSpeedMode == speedModeEnableHorizontal - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2))); scrollOffset.setX(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit->x() ))); markToRedraw(); @@ -267,7 +267,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } if( m_highSpeedMode == speedModeEnableVertical - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2))); scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->x()))); markToRedraw(); @@ -277,25 +277,25 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } } - } else if( ewol::key::typeFinger == _event.getType() - && ( ewol::key::typeUnknow == m_highSpeedType - || ewol::key::typeFinger == m_highSpeedType ) ) { + } else if( gale::key::type_finger == _event.getType() + && ( gale::key::type_unknow == m_highSpeedType + || gale::key::type_finger == m_highSpeedType ) ) { if (1 == _event.getId()) { EWOL_VERBOSE("event: " << _event); - if (ewol::key::statusDown == _event.getStatus()) { + if (gale::key::status_down == _event.getStatus()) { m_highSpeedMode = speedModeInit; - m_highSpeedType = ewol::key::typeFinger; + m_highSpeedType = gale::key::type_finger; m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); EWOL_VERBOSE("SCROOL == > INIT pos=" << m_highSpeedStartPos << " && curent scrollOffset=" << scrollOffset); return true; - } else if (ewol::key::statusUpAfter == _event.getStatus()) { + } else if (gale::key::status_upAfter == _event.getStatus()) { m_highSpeedMode = speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; EWOL_VERBOSE("SCROOL == > DISABLE"); markToRedraw(); return true; } else if ( m_highSpeedMode == speedModeInit - && ewol::key::statusMove == _event.getStatus()) { + && gale::key::status_move == _event.getStatus()) { // wait that the cursor move more than 10 px to enable it : if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { @@ -308,7 +308,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } if ( m_highSpeedMode == speedModeEnableFinger - && ewol::key::statusMove == _event.getStatus()) { + && gale::key::status_move == _event.getStatus()) { EWOL_VERBOSE("SCROOL == > INIT scrollOffset=" << scrollOffset.y() << " relativePos=" << relativePos.y() << " m_highSpeedStartPos=" << m_highSpeedStartPos.y()); //scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x); if (m_limit->x() != 0.0f) { @@ -332,9 +332,9 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { return true; } } else if ( m_highSpeedMode != speedModeDisable - && ewol::key::statusLeave == _event.getStatus()) { + && gale::key::status_leave == _event.getStatus()) { m_highSpeedMode = speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; EWOL_VERBOSE("SCROOL == > DISABLE"); markToRedraw(); return true; diff --git a/ewol/widget/Scroll.h b/ewol/widget/Scroll.h index 5b0c471f..4475755a 100644 --- a/ewol/widget/Scroll.h +++ b/ewol/widget/Scroll.h @@ -38,10 +38,10 @@ namespace ewol { vec2 m_highSpeedStartPos; enum highSpeedMode m_highSpeedMode; int32_t m_highSpeedButton; - enum ewol::key::type m_highSpeedType; + enum gale::key::type m_highSpeedType; protected: Scroll(); - void init(const std::string& _shaperName="THEME:GUI:WidgetScrolled.json"); + void init(const std::string& _shaperName="{ewol}THEME:GUI:WidgetScrolled.json"); public: DECLARE_WIDGET_FACTORY(Scroll, "Scroll"); virtual ~Scroll(); diff --git a/ewol/widget/Sizer.h b/ewol/widget/Sizer.h index 46968f41..81c12374 100644 --- a/ewol/widget/Sizer.h +++ b/ewol/widget/Sizer.h @@ -60,20 +60,20 @@ namespace ewol { return m_mode; } private: - ewol::parameter::Value m_borderSize; //!< Border size needed for all the display + ewol::parameter::Value m_borderSize; //!< Border size needed for all the display public: /** * @brief set the current border size of the current element: * @param[in] _newBorderSize The border size to set (0 if not used) */ - void setBorderSize(const ewol::Dimension& _newBorderSize) { + void setBorderSize(const gale::Dimension& _newBorderSize) { m_borderSize.set(_newBorderSize); } /** * @brief get the current border size of the current element: * @return the border size (0 if not used) */ - const ewol::Dimension& getBorderSize() const { + const gale::Dimension& getBorderSize() const { return m_borderSize; }; public: diff --git a/ewol/widget/Slider.cpp b/ewol/widget/Slider.cpp index 1e6e47ad..f10e3701 100644 --- a/ewol/widget/Slider.cpp +++ b/ewol/widget/Slider.cpp @@ -77,8 +77,8 @@ bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { vec2 relativePos = relativePosition(_event.getPos()); //EWOL_DEBUG("Event on Slider ..." << _event); if (1 == _event.getId()) { - if( ewol::key::statusSingle == _event.getStatus() - || ewol::key::statusMove == _event.getStatus()) { + if( gale::key::status_single == _event.getStatus() + || gale::key::status_move == _event.getStatus()) { // get the new position : EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")"); float oldValue = m_value.get(); diff --git a/ewol/widget/Spacer.cpp b/ewol/widget/Spacer.cpp index fb43fe42..a472f2aa 100644 --- a/ewol/widget/Spacer.cpp +++ b/ewol/widget/Spacer.cpp @@ -17,7 +17,7 @@ ewol::widget::Spacer::Spacer() : m_color(*this, "color", etk::color::none, "background of the spacer") { addObjectType("ewol::widget::Spacer"); - m_userMinSize = ewol::Dimension(vec2(10,10)); + m_userMinSize = gale::Dimension(vec2(10,10)); setCanHaveFocus(false); } diff --git a/ewol/widget/Widget.cpp b/ewol/widget/Widget.cpp index af2ef2ec..f8046240 100644 --- a/ewol/widget/Widget.cpp +++ b/ewol/widget/Widget.cpp @@ -10,7 +10,8 @@ #include #include #include -#include +#include +#include #include #undef __class__ @@ -93,8 +94,8 @@ ewol::Widget::Widget() : m_offset(0,0), m_zoom(1.0f), m_origin(0,0), - m_userMinSize(*this, "min-size", ewol::Dimension(vec2(0,0),ewol::Dimension::Pixel), "User minimum size"), - m_userMaxSize(*this, "max-size", ewol::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),ewol::Dimension::Pixel), "User maximum size"), + m_userMinSize(*this, "min-size", gale::Dimension(vec2(0,0),gale::Dimension::Pixel), "User minimum size"), + m_userMaxSize(*this, "max-size", gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel), "User maximum size"), m_userExpand(*this, "expand", bvec2(false,false), "Request the widget Expand size wile space is available"), m_userFill(*this, "fill", bvec2(false,false), "Fill the widget available size"), m_hide(*this, "hide", false, "The widget start hided"), @@ -106,7 +107,7 @@ ewol::Widget::Widget() : signalShortcut(*this, "shortcut"), m_needRegenerateDisplay(true), m_grabCursor(false), - m_cursorDisplay(ewol::context::cursorArrow), + m_cursorDisplay(gale::context::cursor_arrow), signalAnnimationStart(*this, "annimation-start"), signalAnnimationRatio(*this, "annimation-ratio"), signalAnnimationStop(*this, "annimation-stop"), @@ -255,9 +256,9 @@ void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) { (int32_t)( 1)); mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; - ewol::openGL::push(); + gale::openGL::push(); // set internal matrix system : - ewol::openGL::setMatrix(tmpMat); + gale::openGL::setMatrix(tmpMat); //int64_t ___startTime = ewol::getTime(); onDraw(); @@ -284,7 +285,7 @@ void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) { mat4 tmpProjection = etk::matOrtho(-tmpclipX/2, tmpclipX/2, -m_size.y()/2, m_size.y()/2, -1, 1); mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; // set internal matrix system : - ewol::openGL::setMatrix(tmpMat); + gale::openGL::setMatrix(tmpMat); //int64_t ___startTime = ewol::getTime(); onDraw(); //float ___localTime = (float)(ewol::getTime() - ___startTime) / 1000.0f; @@ -300,22 +301,29 @@ void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) { mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1); mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; // set internal matrix system : - ewol::openGL::setMatrix(tmpMat); + gale::openGL::setMatrix(tmpMat); //int64_t ___startTime = ewol::getTime(); onDraw(); //float ___localTime = (float)(ewol::getTime() - ___startTime) / 1000.0f; //EWOL_DEBUG(" Widget2 : " << ___localTime << "ms "); } #endif - ewol::openGL::pop(); + gale::openGL::pop(); return; } void ewol::Widget::periodicCallDisable() { + EWOL_VERBOSE("Perodic call disable " << getName()); getObjectManager().periodicCall.release(shared_from_this()); } void ewol::Widget::periodicCallEnable() { + if (getObjectManager().periodicCall.isRegistered(shared_from_this()) == true) { + EWOL_VERBOSE("Perodic call enable " << getName() << " ==> rejected"); + return; + } else { + EWOL_VERBOSE("Perodic call enable " << getName()); + } getObjectManager().periodicCall.bind(shared_from_this(), &ewol::Widget::periodicCall); } @@ -379,7 +387,7 @@ vec2 ewol::Widget::getCalculateMaxSize() { } void ewol::Widget::setNoMinSize() { - m_userMinSize.set(ewol::Dimension(vec2(0,0),ewol::Dimension::Pixel)); + m_userMinSize.set(gale::Dimension(vec2(0,0),gale::Dimension::Pixel)); } void ewol::Widget::checkMinSize() { @@ -389,7 +397,7 @@ void ewol::Widget::checkMinSize() { } void ewol::Widget::setNoMaxSize() { - m_userMaxSize.set(ewol::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),ewol::Dimension::Pixel)); + m_userMaxSize.set(gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel)); } void ewol::Widget::checkMaxSize() { @@ -450,59 +458,59 @@ void ewol::Widget::shortCutAdd(const std::string& _descriptiveString, const std: tmpElement->specialKey.setMeta(true); } if(_descriptiveString.find("F12") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF12; + tmpElement->keyboardMoveValue = gale::key::keyboard_f12; } else if(_descriptiveString.find("F11") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF11; + tmpElement->keyboardMoveValue = gale::key::keyboard_f11; } else if(_descriptiveString.find("F10") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF10; + tmpElement->keyboardMoveValue = gale::key::keyboard_f10; } else if(_descriptiveString.find("F9") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF9; + tmpElement->keyboardMoveValue = gale::key::keyboard_f9; } else if(_descriptiveString.find("F8") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF8; + tmpElement->keyboardMoveValue = gale::key::keyboard_f8; } else if(_descriptiveString.find("F7") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF7; + tmpElement->keyboardMoveValue = gale::key::keyboard_f7; } else if(_descriptiveString.find("F6") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF6; + tmpElement->keyboardMoveValue = gale::key::keyboard_f6; } else if(_descriptiveString.find("F5") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF5; + tmpElement->keyboardMoveValue = gale::key::keyboard_f5; } else if(_descriptiveString.find("F4") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF4; + tmpElement->keyboardMoveValue = gale::key::keyboard_f4; } else if(_descriptiveString.find("F3") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF3; + tmpElement->keyboardMoveValue = gale::key::keyboard_f3; } else if(_descriptiveString.find("F2") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF2; + tmpElement->keyboardMoveValue = gale::key::keyboard_f2; } else if(_descriptiveString.find("F1") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardF1; + tmpElement->keyboardMoveValue = gale::key::keyboard_f1; } else if(_descriptiveString.find("LEFT") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardLeft; + tmpElement->keyboardMoveValue = gale::key::keyboard_left; } else if(_descriptiveString.find("RIGHT") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardRight; + tmpElement->keyboardMoveValue = gale::key::keyboard_right; } else if(_descriptiveString.find("UP") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardUp; + tmpElement->keyboardMoveValue = gale::key::keyboard_up; } else if(_descriptiveString.find("DOWN") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardDown; + tmpElement->keyboardMoveValue = gale::key::keyboard_down; } else if(_descriptiveString.find("PAGE_UP") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardPageUp; + tmpElement->keyboardMoveValue = gale::key::keyboard_pageUp; } else if(_descriptiveString.find("PAGE_DOWN") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardPageDown; + tmpElement->keyboardMoveValue = gale::key::keyboard_pageDown; } else if(_descriptiveString.find("START") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardStart; + tmpElement->keyboardMoveValue = gale::key::keyboard_start; } else if(_descriptiveString.find("END") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardEnd; + tmpElement->keyboardMoveValue = gale::key::keyboard_end; } else if(_descriptiveString.find("PRINT") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardPrint; + tmpElement->keyboardMoveValue = gale::key::keyboard_print; } else if(_descriptiveString.find("ARRET_DEFIL") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardStopDefil; + tmpElement->keyboardMoveValue = gale::key::keyboard_stopDefil; } else if(_descriptiveString.find("WAIT") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardWait; + tmpElement->keyboardMoveValue = gale::key::keyboard_wait; } else if(_descriptiveString.find("INSERT") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardInsert; + tmpElement->keyboardMoveValue = gale::key::keyboard_insert; } else if(_descriptiveString.find("CAPLOCK") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardCapLock; + tmpElement->keyboardMoveValue = gale::key::keyboard_capLock; } else if(_descriptiveString.find("CONTEXT_MENU") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardContextMenu; + tmpElement->keyboardMoveValue = gale::key::keyboard_contextMenu; } else if(_descriptiveString.find("NUM_LOCK") != std::string::npos) { - tmpElement->keyboardMoveValue = ewol::key::keyboardNumLock; + tmpElement->keyboardMoveValue = gale::key::keyboard_numLock; } else { tmpElement->unicodeValue = _descriptiveString[_descriptiveString.size() -1]; } @@ -533,9 +541,9 @@ void ewol::Widget::shortCutClean() { m_localShortcut.clear(); } -bool ewol::Widget::onEventShortCut(ewol::key::Special& _special, +bool ewol::Widget::onEventShortCut(const gale::key::Special& _special, char32_t _unicodeValue, - enum ewol::key::keyboard _kbMove, + enum gale::key::keyboard _kbMove, bool _isDown) { if (_unicodeValue >= 'A' && _unicodeValue <= 'Z') { _unicodeValue += 'a' - 'A'; @@ -547,7 +555,7 @@ bool ewol::Widget::onEventShortCut(ewol::key::Special& _special, && m_localShortcut[iii]->specialKey.getCtrl() == _special.getCtrl() && m_localShortcut[iii]->specialKey.getAlt() == _special.getAlt() && m_localShortcut[iii]->specialKey.getMeta() == _special.getMeta() - && ( ( m_localShortcut[iii]->keyboardMoveValue == ewol::key::keyboardUnknow + && ( ( m_localShortcut[iii]->keyboardMoveValue == gale::key::keyboard_unknow && m_localShortcut[iii]->unicodeValue == _unicodeValue) || ( m_localShortcut[iii]->keyboardMoveValue == _kbMove && m_localShortcut[iii]->unicodeValue == 0) @@ -581,13 +589,13 @@ bool ewol::Widget::getGrabStatus() { return m_grabCursor; } -void ewol::Widget::setCursor(enum ewol::context::cursorDisplay _newCursor) { +void ewol::Widget::setCursor(enum gale::context::cursor _newCursor) { EWOL_DEBUG("Change Cursor in " << _newCursor); m_cursorDisplay = _newCursor; getContext().setCursor(m_cursorDisplay); } -enum ewol::context::cursorDisplay ewol::Widget::getCursor() { +enum gale::context::cursor ewol::Widget::getCursor() { return m_cursorDisplay; } @@ -647,7 +655,7 @@ void ewol::Widget::onParameterChangeValue(const ewol::parameter::Ref& _paramPoin } if (error == true) { EWOL_ERROR("Can not set a 'min size' > 'max size' reset to maximum ..."); - m_userMaxSize = ewol::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),ewol::Dimension::Pixel); + m_userMaxSize = gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel); } requestUpdateSize(); } else if (_paramPointer == m_userMinSize) { @@ -663,7 +671,7 @@ void ewol::Widget::onParameterChangeValue(const ewol::parameter::Ref& _paramPoin } if (error == true) { EWOL_ERROR("Can not set a 'min size' > 'max size' set nothing ..."); - m_userMinSize = ewol::Dimension(vec2(0,0),ewol::Dimension::Pixel); + m_userMinSize = gale::Dimension(vec2(0,0),gale::Dimension::Pixel); } requestUpdateSize(); } else if (_paramPointer == m_annimationTypeStart) { diff --git a/ewol/widget/Widget.h b/ewol/widget/Widget.h index 4fdb79aa..a78fbc1c 100644 --- a/ewol/widget/Widget.h +++ b/ewol/widget/Widget.h @@ -15,7 +15,8 @@ #include #include -#include +#include +#include namespace ewol { class Widget; @@ -24,9 +25,9 @@ namespace ewol { class Windows; }; }; -#include -#include -#include +#include +#include +#include #include #include #include @@ -101,13 +102,13 @@ namespace ewol { class EventShortCut { public: std::string message; //!< data link with the event - ewol::key::Special specialKey; //!< special board key + gale::key::Special specialKey; //!< special board key char32_t unicodeValue; //!< 0 if not used - enum ewol::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used + enum gale::key::keyboard keyboardMoveValue; //!< ewol::EVENT_KB_MOVE_TYPE_NONE if not used EventShortCut() { message = ""; unicodeValue = 0; - keyboardMoveValue = ewol::key::keyboardUnknow; + keyboardMoveValue = gale::key::keyboard_unknow; }; virtual ~EventShortCut() { }; }; @@ -228,13 +229,13 @@ namespace ewol { */ virtual vec2 getOrigin(); protected: - ewol::parameter::Value m_userMinSize; //!< user define the minimum size of the widget + ewol::parameter::Value m_userMinSize; //!< user define the minimum size of the widget public: /** * @brief User set the minimum size he want to set the display * @param[in] _size set minimum size (none : 0) */ - void setMinSize(const ewol::Dimension& _size) { + void setMinSize(const gale::Dimension& _size) { m_userMinSize.set(_size); } /** @@ -245,7 +246,7 @@ namespace ewol { * @brief get the current calculated min size * @return the size requested */ - const ewol::Dimension& getMinSize() { + const gale::Dimension& getMinSize() { return m_userMinSize.get(); }; /** @@ -255,13 +256,13 @@ namespace ewol { */ virtual void checkMinSize(); protected: - ewol::parameter::Value m_userMaxSize; //!< user define the maximum size of the widget + ewol::parameter::Value m_userMaxSize; //!< user define the maximum size of the widget public: /** * @brief User set the maximum size he want to set the display * @param[in] _size The new maximum size requested (vec2(0,0) to unset) */ - void setMaxSize(const ewol::Dimension& _size) { + void setMaxSize(const gale::Dimension& _size) { m_userMaxSize.set(_size); } /** @@ -272,7 +273,7 @@ namespace ewol { * @brief get the current maximum size * @return the size requested */ - const ewol::Dimension& getMaxSize() { + const gale::Dimension& getMaxSize() { return m_userMaxSize.get(); }; /** @@ -552,7 +553,7 @@ namespace ewol { * @note : need to have focus ... * @param[in] mode Mode of data requested */ - virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID) { }; + virtual void onEventClipboard(enum gale::context::clipBoard::clipboardListe _clipboardID) { }; // ---------------------------------------------------------------------------------------------------------------- // -- Shortcut : management of the shortcut @@ -588,9 +589,9 @@ namespace ewol { * @return false if the event has not been used. * @note To prevent some error when you get an event get it if it is down and Up ... == > like this it could not generate some ununderstanding error. */ - virtual bool onEventShortCut(ewol::key::Special& _special, + virtual bool onEventShortCut(const gale::key::Special& _special, char32_t _unicodeValue, - enum ewol::key::keyboard _kbMove, + enum gale::key::keyboard _kbMove, bool _isDown); // ---------------------------------------------------------------------------------------------------------------- // -- drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working... @@ -650,18 +651,18 @@ namespace ewol { */ virtual bool getGrabStatus(); private: - enum ewol::context::cursorDisplay m_cursorDisplay; + enum gale::context::cursor m_cursorDisplay; public: /** * @brief set the cursor display type. * @param[in] _newCursor selected new cursor. */ - virtual void setCursor(enum ewol::context::cursorDisplay _newCursor); + virtual void setCursor(enum gale::context::cursor _newCursor); /** * @brief get the currrent cursor. * @return the type of the cursor. */ - virtual enum ewol::context::cursorDisplay getCursor(); + virtual enum gale::context::cursor getCursor(); public: // Derived function virtual bool loadXML(const std::shared_ptr& _node); protected: // Derived function diff --git a/ewol/widget/WidgetScrolled.cpp b/ewol/widget/WidgetScrolled.cpp index aedacfae..8865e150 100644 --- a/ewol/widget/WidgetScrolled.cpp +++ b/ewol/widget/WidgetScrolled.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include @@ -24,7 +24,7 @@ ewol::widget::WidgetScrolled::WidgetScrolled() : m_pixelScrolling = 20; m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; m_scroollingMode = scroolModeNormal; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; m_highSpeedButton = -1; m_limitScrolling = 0.5; @@ -87,17 +87,17 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event ewol::Padding paddingV = m_shaperV.getPadding(); ewol::Padding paddingH = m_shaperH.getPadding(); if (m_scroollingMode == scroolModeNormal) { - if ( _event.getType() == ewol::key::typeMouse - && ( m_highSpeedType == ewol::key::typeUnknow - || m_highSpeedType == ewol::key::typeMouse) ) { + if ( _event.getType() == gale::key::type_mouse + && ( m_highSpeedType == gale::key::type_unknow + || m_highSpeedType == gale::key::type_mouse) ) { if ( _event.getId() == 1 - && _event.getStatus() == ewol::key::statusDown) { + && _event.getStatus() == gale::key::status_down) { // check if selected the scrolling position whth the scrolling bar ... if (relativePos.x() >= (m_size.x()-paddingV.x())) { if( m_size.y() < m_maxSize.y() || m_originScrooled.y() != 0) { m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; - m_highSpeedType = ewol::key::typeMouse; + m_highSpeedType = gale::key::type_mouse; m_highSpeedStartPos.setX(relativePos.x()); m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.yButtom()*2)); m_highSpeedButton = 1; @@ -111,7 +111,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event if( m_size.x() < m_maxSize.x() || m_originScrooled.x()!=0) { m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; - m_highSpeedType = ewol::key::typeMouse; + m_highSpeedType = gale::key::type_mouse; m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingH.xLeft()*2)); m_highSpeedStartPos.setY(relativePos.y()); m_highSpeedButton = 1; @@ -124,7 +124,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } return false; } else if ( _event.getId() == 4 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { if (true == _event.getSpecialKey().getCtrl()) { changeZoom(1); /* @@ -143,7 +143,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } } } else if ( _event.getId() == 5 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { if (true == _event.getSpecialKey().getCtrl()) { changeZoom(-1); /* @@ -162,7 +162,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } } } else if ( _event.getId() == 11 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { // Scrool Left if(m_size.x() < m_maxSize.x() || m_originScrooled.x()!=0 @@ -173,7 +173,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event return true; } } else if ( _event.getId() == 10 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { // Scrool Right if(m_size.x() < m_maxSize.x() || m_originScrooled.x()!=0 @@ -186,44 +186,44 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event }else if (_event.getId() == 2) { /* if (true == ewol::isSetCtrl()) { - if (ewol::key::statusDown == typeEvent) { + if (gale::key::status_down == typeEvent) { float zoom = 1.0; setZoom(zoom); } } else */{ - if (_event.getStatus() == ewol::key::statusDown) { + if (_event.getStatus() == gale::key::status_down) { m_highSpeedMode = ewol::widget::Scroll::speedModeInit; - m_highSpeedType = ewol::key::typeMouse; + m_highSpeedType = gale::key::type_mouse; m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); m_highSpeedButton = 2; return true; } } } else if ( m_highSpeedMode != ewol::widget::Scroll::speedModeDisable - && _event.getStatus() == ewol::key::statusLeave) { + && _event.getStatus() == gale::key::status_leave) { m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; markToRedraw(); return true; } if ( _event.getId() == m_highSpeedButton && m_highSpeedMode != ewol::widget::Scroll::speedModeDisable) { - if (_event.getStatus() == ewol::key::statusUpAfter) { + if (_event.getStatus() == gale::key::status_upAfter) { m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; return false; } else if (m_highSpeedMode == ewol::widget::Scroll::speedModeGrepEndEvent) { - if (_event.getStatus() == ewol::key::statusSingle) { + if (_event.getStatus() == gale::key::status_single) { m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; m_highSpeedButton = -1; markToRedraw(); } return true; - } else if (_event.getStatus() == ewol::key::statusUp) { + } else if (_event.getStatus() == gale::key::status_up) { return true; } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { // wait that the cursor move more than 10 px to enable it : if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { @@ -252,23 +252,23 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event return true; } if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (m_size.x()-paddingH.x()))); m_originScrooled.setX(std::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling))); markToRedraw(); return true; } if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableVertical - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (m_size.y()-paddingV.y()))); m_originScrooled.setY(std::avg(0.0f, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling))); markToRedraw(); return true; } } - } else if ( _event.getType() == ewol::key::typeFinger - && ( m_highSpeedType == ewol::key::typeUnknow - || m_highSpeedType == ewol::key::typeFinger) ) { + } else if ( _event.getType() == gale::key::type_finger + && ( m_highSpeedType == gale::key::type_unknow + || m_highSpeedType == gale::key::type_finger) ) { if (m_singleFingerMode == false) { // *********************** // ** Two finger mode : ** @@ -277,9 +277,9 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event return false; } int32_t idTable = _event.getId()-1; - if (_event.getStatus() == ewol::key::statusDown) { + if (_event.getStatus() == gale::key::status_down) { m_fingerPresent[idTable] = true; - } else if (_event.getStatus() == ewol::key::statusUpAfter) { + } else if (_event.getStatus() == gale::key::status_upAfter) { m_fingerPresent[idTable] = false; } if (m_fingerScoolActivated == false) { @@ -294,7 +294,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event if (m_fingerScoolActivated == true) { // 1: scroll... // 2: remove all unneeded sub event ... ==> maybe a better methode ... - if (_event.getStatus() == ewol::key::statusMove) { + if (_event.getStatus() == gale::key::status_move) { m_originScrooled.setX(m_originScrooled.x() - (relativePos.x() - m_fingerMoveStartPos[idTable].x())*0.5f); m_originScrooled.setY(m_originScrooled.y() - (relativePos.y() - m_fingerMoveStartPos[idTable].y())*0.5f); m_originScrooled.setX(std::avg(0.0f, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling))); @@ -305,7 +305,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } if ( m_fingerPresent[0] == false && m_fingerPresent[1] == false) { - if (_event.getStatus() == ewol::key::statusUpAfter) { + if (_event.getStatus() == gale::key::status_upAfter) { // TODO : Reset event ... m_fingerScoolActivated = false; _event.reset(); @@ -319,20 +319,20 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event // ************************** if (_event.getId() == 1) { EWOL_VERBOSE("event 1 " << _event); - if (_event.getStatus() == ewol::key::statusDown) { + if (_event.getStatus() == gale::key::status_down) { m_highSpeedMode = ewol::widget::Scroll::speedModeInit; - m_highSpeedType = ewol::key::typeFinger; + m_highSpeedType = gale::key::type_finger; m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y()); EWOL_VERBOSE("SCROOL == > INIT"); return true; - } else if (_event.getStatus() == ewol::key::statusUpAfter) { + } else if (_event.getStatus() == gale::key::status_upAfter) { m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; EWOL_VERBOSE("SCROOL == > DISABLE"); markToRedraw(); return true; } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { // wait that the cursor move more than 10 px to enable it : if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { @@ -344,7 +344,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } return true; } if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableFinger - && _event.getStatus() == ewol::key::statusMove) { + && _event.getStatus() == gale::key::status_move) { //m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x); m_originScrooled.setX(m_originScrooled.x() - (relativePos.x() - m_highSpeedStartPos.x())); m_originScrooled.setY(m_originScrooled.y() - (relativePos.y() - m_highSpeedStartPos.y())); @@ -356,9 +356,9 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event return true; } } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeDisable - && _event.getStatus() == ewol::key::statusLeave) { + && _event.getStatus() == gale::key::status_leave) { m_highSpeedMode = ewol::widget::Scroll::speedModeDisable; - m_highSpeedType = ewol::key::typeUnknow; + m_highSpeedType = gale::key::type_unknow; EWOL_VERBOSE("SCROOL == > DISABLE"); markToRedraw(); return true; @@ -366,13 +366,13 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } } } else if (m_scroollingMode == scroolModeCenter) { - if (_event.getType() == ewol::key::typeMouse) { + if (_event.getType() == gale::key::type_mouse) { float tmp1=m_size.x() / m_maxSize.y(); float tmp2=m_size.y() / m_maxSize.x(); //EWOL_INFO(" elements Zoom : " << tmp1 << " " << tmp2); tmp1 = std::min(tmp1, tmp2); if ( _event.getId() == 4 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { m_zoom -= 0.1; if (tmp1 < 1.0) { m_zoom = std::max(tmp1, m_zoom); @@ -382,7 +382,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event markToRedraw(); return true; } else if ( _event.getId() == 5 - && _event.getStatus() == ewol::key::statusUp) { + && _event.getStatus() == gale::key::status_up) { m_zoom += 0.1; if (tmp1 > 1.0) { m_zoom = std::min(tmp1, m_zoom); @@ -408,39 +408,32 @@ void ewol::widget::WidgetScrolled::onDraw() { } void ewol::widget::WidgetScrolled::systemDraw(const ewol::DrawProperty& _displayProp) { - ewol::openGL::push(); + gale::openGL::push(); if (m_scroollingMode == scroolModeCenter) { // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left - glViewport( m_origin.x(), - m_origin.y(), - m_size.x(), - m_size.y()); + gale::openGL::setViewPort(m_origin, m_size); mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1); mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0) ); mat4 tmpTranslate = etk::matTranslate(vec3(-m_maxSize.x()/2, -m_maxSize.y()/2, -1.0) ); mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate; // set internal matrix system : - ewol::openGL::setMatrix(tmpMat); + gale::openGL::setMatrix(tmpMat); // Call the widget drawing methode onDraw(); } if (m_scroollingMode == scroolModeGame) { // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left - glViewport( m_origin.x(), - m_origin.y(), - m_size.x(), - m_size.y()); - + gale::openGL::setViewPort(m_origin, m_size); mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1); mat4 tmpTranslate = etk::matTranslate(vec3( -m_maxSize.x()/2, -m_maxSize.y()/2, -1.0) ); mat4 tmpMat = tmpProjection * tmpTranslate; // set internal matrix system : - ewol::openGL::setMatrix(tmpMat); + gale::openGL::setMatrix(tmpMat); // Call the widget drawing methode onDraw(); } else { ewol::Widget::systemDraw(_displayProp); } - ewol::openGL::pop(); + gale::openGL::pop(); } void ewol::widget::WidgetScrolled::setScrollingPositionDynamic(vec2 _borderWidth, const vec2& _currentPosition, bool _center) { diff --git a/ewol/widget/WidgetScrolled.h b/ewol/widget/WidgetScrolled.h index 2c0fd09d..2648ea71 100644 --- a/ewol/widget/WidgetScrolled.h +++ b/ewol/widget/WidgetScrolled.h @@ -42,7 +42,7 @@ namespace ewol { vec2 m_highSpeedStartPos; enum Scroll::highSpeedMode m_highSpeedMode; int32_t m_highSpeedButton; - enum ewol::key::type m_highSpeedType; + enum gale::key::type m_highSpeedType; private: // finger section: bool m_singleFingerMode; //!< in many case the moving in a subwidget is done with one finger, it is enought ==> the user select... public: @@ -69,7 +69,7 @@ namespace ewol { * @param[in] _shaperName Shaper name if the scrolled widget. */ WidgetScrolled(); - void init(const std::string& _shaperName="THEME:GUI:WidgetScrolled.json"); + void init(const std::string& _shaperName="{ewol}THEME:GUI:WidgetScrolled.json"); public: DECLARE_WIDGET_FACTORY(WidgetScrolled, "WidgetScrolled"); /** diff --git a/ewol/widget/Windows.cpp b/ewol/widget/Windows.cpp index 67ad716a..1c8e169a 100644 --- a/ewol/widget/Windows.cpp +++ b/ewol/widget/Windows.cpp @@ -9,7 +9,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -28,7 +29,7 @@ ewol::widget::Windows::Windows() : m_colorBg(-1) { addObjectType("ewol::widget::Windows"); setCanHaveFocus(true); - m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Windows.json"); + m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:Windows.json"); if (m_colorProperty != nullptr) { m_colorBg = m_colorProperty->request("background"); } @@ -41,7 +42,7 @@ ewol::widget::Windows::~Windows() { } void ewol::widget::Windows::calculateSize(const vec2& _availlable) { - //EWOL_DEBUG(" _availlable : " << _availlable); + EWOL_DEBUG(" _availlable : " << _availlable); m_size = _availlable; if (m_subWidget != nullptr) { m_subWidget->calculateMinMaxSize(); @@ -72,34 +73,33 @@ std::shared_ptr ewol::widget::Windows::getWidgetAtPos(const vec2& } void ewol::widget::Windows::sysDraw() { - //EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")"); + EWOL_VERBOSE("Draw on " << m_size); // set the size of the open GL system - glViewport(0,0,m_size.x(),m_size.y()); - - ewol::openGL::disable(ewol::openGL::FLAG_DITHER); - //ewol::openGL::disable(ewol::openGL::FLAG_BLEND); - ewol::openGL::disable(ewol::openGL::FLAG_STENCIL_TEST); - ewol::openGL::disable(ewol::openGL::FLAG_ALPHA_TEST); - ewol::openGL::disable(ewol::openGL::FLAG_FOG); + gale::openGL::setViewPort(vec2(0,0), m_size); + gale::openGL::disable(gale::openGL::flag_dither); + //gale::openGL::disable(gale::openGL::flag_blend); + gale::openGL::disable(gale::openGL::flag_stencilTest); + gale::openGL::disable(gale::openGL::flag_alphaTest); + gale::openGL::disable(gale::openGL::flag_fog); #if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__IOs)) glPixelZoom(1.0,1.0); #endif - ewol::openGL::disable(ewol::openGL::FLAG_TEXTURE_2D); - ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST); + gale::openGL::disable(gale::openGL::flag_texture2D); + gale::openGL::disable(gale::openGL::flag_depthTest); - ewol::openGL::enable(ewol::openGL::FLAG_BLEND); + gale::openGL::enable(gale::openGL::flag_blend); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // clear the matrix system : mat4 newOne; - ewol::openGL::setBasicMatrix(newOne); + gale::openGL::setBasicMatrix(newOne); ewol::DrawProperty displayProp; displayProp.m_windowsSize = m_size; displayProp.m_origin.setValue(0,0); displayProp.m_size = m_size; systemDraw(displayProp); - ewol::openGL::disable(ewol::openGL::FLAG_BLEND); + gale::openGL::disable(gale::openGL::flag_blend); return; } @@ -121,18 +121,17 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) { #ifdef TEST_PERFO_WINDOWS int64_t ___startTime0 = ewol::getTime(); #endif - // clear the screen with transparency ... etk::Color colorBg(0.5, 0.5, 0.5, 0.5); if (m_colorProperty != nullptr) { colorBg = m_colorProperty->get(m_colorBg); } - glClearColor(colorBg.r(), colorBg.g(), colorBg.b(), colorBg.a()); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gale::openGL::clearColor(colorBg); + gale::openGL::clear( gale::openGL::clearFlag_colorBuffer + | gale::openGL::clearFlag_depthBuffer); #ifdef TEST_PERFO_WINDOWS float ___localTime0 = (float)(ewol::getTime() - ___startTime0) / 1000.0f; EWOL_ERROR(" Windows000 : " << ___localTime0 << "ms "); - int64_t ___startTime1 = ewol::getTime(); #endif //EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId); @@ -144,7 +143,6 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) { #ifdef TEST_PERFO_WINDOWS float ___localTime1 = (float)(ewol::getTime() - ___startTime1) / 1000.0f; EWOL_ERROR(" Windows111 : " << ___localTime1 << "ms "); - int64_t ___startTime2 = ewol::getTime(); #endif // second display the pop-up @@ -291,4 +289,9 @@ std::shared_ptr ewol::widget::Windows::getSubObjectNamed(const std return nullptr; } +void ewol::widget::Windows::sysOnKill() { + if (onKill() == true) { + getContext().stop(); + } +} diff --git a/ewol/widget/Windows.h b/ewol/widget/Windows.h index abe01766..a56f0bc0 100644 --- a/ewol/widget/Windows.h +++ b/ewol/widget/Windows.h @@ -37,12 +37,13 @@ namespace ewol { void sysDraw(); void sysOnShow() {}; void sysOnHide() {}; - void sysOnKill() {}; + void sysOnKill(); public: virtual void onShow() { }; virtual void onHide() { }; virtual bool onKill() { - return true; + // TODO : Check this in speck for android ... + return false; }; virtual void onReduce() { }; virtual void onStateBackground() {}; @@ -125,10 +126,11 @@ namespace ewol { createPopUpMessage(messageTypeCritical, _message); } - - virtual bool onEventHardwareInput(const ewol::key::keyboardSystem& _event, bool _down) { + /* TODO : + virtual bool onEventHardwareInput(const gale::key::keyboardSystem& _event, bool _down) { return false; }; + */ }; }; }; diff --git a/ewol/widget/meta/FileChooser.cpp b/ewol/widget/meta/FileChooser.cpp index 9283f09b..e901e34d 100644 --- a/ewol/widget/meta/FileChooser.cpp +++ b/ewol/widget/meta/FileChooser.cpp @@ -53,13 +53,13 @@ void ewol::widget::FileChooser::init() { + " \n" + " \n" + " \n" @@ -83,13 +83,13 @@ void ewol::widget::FileChooser::init() { + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" diff --git a/ewol/widget/meta/Parameter.cpp b/ewol/widget/meta/Parameter.cpp index 2be06985..9c7b5dba 100644 --- a/ewol/widget/meta/Parameter.cpp +++ b/ewol/widget/meta/Parameter.cpp @@ -36,9 +36,9 @@ void ewol::widget::Parameter::init() { std::shared_ptr mySizerHori = nullptr; std::shared_ptr mySpacer = nullptr; #ifdef __TARGET_OS__Android - setMinSize(ewol::Dimension(vec2(90, 90), ewol::Dimension::Pourcent)); + setMinSize(gale::Dimension(vec2(90, 90), gale::Dimension::Pourcent)); #else - setMinSize(ewol::Dimension(vec2(80, 80), ewol::Dimension::Pourcent)); + setMinSize(gale::Dimension(vec2(80, 80), gale::Dimension::Pourcent)); #endif mySizerVert = ewol::widget::Sizer::create(widget::Sizer::modeVert); @@ -72,7 +72,7 @@ void ewol::widget::Parameter::init() { tmpButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, "\n" " \n" - " \n" + " \n" " \n" " \n" "\n")); @@ -85,7 +85,7 @@ void ewol::widget::Parameter::init() { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setExpand(bvec2(false,false)); - mySpacer->setMinSize(ewol::Dimension(vec2(10,0))); + mySpacer->setMinSize(gale::Dimension(vec2(10,0))); mySizerHori->subWidgetAdd(mySpacer); } @@ -96,7 +96,7 @@ void ewol::widget::Parameter::init() { tmpButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, "\n" " \n" - " \n" + " \n" " \n" " \n" "\n")); diff --git a/ewol/widget/meta/ParameterList.cpp b/ewol/widget/meta/ParameterList.cpp index 4d3cd2c3..901ba662 100644 --- a/ewol/widget/meta/ParameterList.cpp +++ b/ewol/widget/meta/ParameterList.cpp @@ -174,7 +174,7 @@ bool ewol::widget::ParameterList::onEventInput(const ewol::event::Input& _event) // nothing to do ... done on upper widet ... return true; } - if (_event.getId() == 1 && _event.getStatus() == ewol::key::statusSingle) { + if (_event.getId() == 1 && _event.getStatus() == gale::key::status_single) { vec2 relativePos = relativePosition(_event.getPos()); // corection for the openGl abstraction relativePos.setY(m_size.y() - relativePos.y()); diff --git a/ewol/widget/meta/StdPopUp.cpp b/ewol/widget/meta/StdPopUp.cpp index f607c43b..43929ed8 100644 --- a/ewol/widget/meta/StdPopUp.cpp +++ b/ewol/widget/meta/StdPopUp.cpp @@ -21,7 +21,7 @@ ewol::widget::StdPopUp::StdPopUp() : m_comment(nullptr), m_subBar(nullptr) { addObjectType("ewol::widget::StdPopUp"); - setMinSize(ewol::Dimension(vec2(20,10),ewol::Dimension::Pourcent)); + setMinSize(gale::Dimension(vec2(20,10),gale::Dimension::Pourcent)); } void ewol::widget::StdPopUp::init() { @@ -44,12 +44,12 @@ void ewol::widget::StdPopUp::init() { mySpacer = ewol::widget::Spacer::create(); mySpacer->setExpand(bvec2(true,false)); mySpacer->setColor(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); - mySpacer->setMinSize(ewol::Dimension(vec2(0,3),ewol::Dimension::Pixel)); + mySpacer->setMinSize(gale::Dimension(vec2(0,3),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); mySpacer->setExpand(bvec2(true,false)); - mySpacer->setMinSize(ewol::Dimension(vec2(0,5),ewol::Dimension::Pixel)); + mySpacer->setMinSize(gale::Dimension(vec2(0,5),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); m_comment = ewol::widget::Label::create("No Label"); @@ -58,13 +58,13 @@ void ewol::widget::StdPopUp::init() { mySpacer = ewol::widget::Spacer::create(); mySpacer->setExpand(bvec2(true,false)); - mySpacer->setMinSize(ewol::Dimension(vec2(0,5),ewol::Dimension::Pixel)); + mySpacer->setMinSize(gale::Dimension(vec2(0,5),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); mySpacer->setExpand(bvec2(true,false)); mySpacer->setColor(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); - mySpacer->setMinSize(ewol::Dimension(vec2(0,3),ewol::Dimension::Pixel)); + mySpacer->setMinSize(gale::Dimension(vec2(0,3),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); m_title = ewol::widget::Label::create("Message"); diff --git a/lutin_ewol-test.py b/lutin_ewol-test.py new file mode 100644 index 00000000..e468f6dd --- /dev/null +++ b/lutin_ewol-test.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +import lutin.module as module +import lutin.tools as tools +import datetime + + +def get_type(): + return "BINARY" + +def get_sub_type(): + return "TEST" + +def get_desc(): + return "ewol test software" + +def get_licence(): + return "APACHE-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def create(target, module_name): + my_module = module.Module(__file__, module_name, get_type()) + my_module.add_src_file([ + 'test/main.cpp', + 'test/testApplication.cpp', + 'test/testWindows.cpp' + ]) + my_module.add_module_depend(['ewol', 'gtest', 'test-debug']) + return my_module + diff --git a/lutin_ewol.py b/lutin_ewol.py old mode 100755 new mode 100644 index af8cac60..507133f8 --- a/lutin_ewol.py +++ b/lutin_ewol.py @@ -1,36 +1,54 @@ #!/usr/bin/python -import lutinModule as module -import lutinTools as tools -import lutinDebug as debug +import lutin.module as module +import lutin.tools as tools +import lutin.debug as debug import os -import lutinMultiprocess +import lutin.multiprocess as lutinMultiprocess + + +def get_type(): + return "LIBRARY" def get_desc(): return "ewol is a main library to use widget in the openGl environement and manage all the wraping os" -def get_license(): - return "APACHE v2.0" +def get_licence(): + return "APACHE-2" -def create(target): - # set the ewol folder for Android basic sources ... - target.set_ewol_folder(tools.get_current_path(__file__) + "/../") - +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def get_version(): + return [0,0,0] + +def create(target, module_name): # module name is 'edn' and type binary. - myModule = module.Module(__file__, 'ewol', 'LIBRARY') + my_module = module.Module(__file__, module_name, get_type()) - # add extra compilation flags : - myModule.add_extra_compile_flags() + # add extra compilation flags: + my_module.add_extra_compile_flags() # add the file to compile: - myModule.add_src_file([ + my_module.add_src_file([ 'ewol/ewol.cpp', 'ewol/debug.cpp', 'ewol/Padding.cpp', - 'ewol/Dimension.cpp', 'ewol/translate.cpp' ]) + my_module.add_header_file([ + 'ewol/debug.h', # TODO : Remove this ... + 'ewol/ewol.h', + 'ewol/Padding.h', + 'ewol/translate.h' + ]) - # compositing : - myModule.add_src_file([ + # compositing: + my_module.add_src_file([ 'ewol/compositing/Compositing.cpp', 'ewol/compositing/TextBase.cpp', 'ewol/compositing/Text.cpp', @@ -41,95 +59,108 @@ def create(target): 'ewol/compositing/Shaper.cpp', 'ewol/compositing/Area.cpp' ]) + my_module.add_header_file([ + 'ewol/compositing/Text.h', + 'ewol/compositing/Drawing.h', + 'ewol/compositing/Sprite.h', + 'ewol/compositing/Area.h', + 'ewol/compositing/Shaper.h', + 'ewol/compositing/TextDF.h', + 'ewol/compositing/TextBase.h', + 'ewol/compositing/Compositing.h', + 'ewol/compositing/Image.h' + ]) - # context : - myModule.add_src_file([ - 'ewol/context/clipBoard.cpp', - 'ewol/context/commandLine.cpp', + # context: + my_module.add_src_file([ 'ewol/context/ConfigFont.cpp', 'ewol/context/Context.cpp', - 'ewol/context/cursor.cpp', 'ewol/context/InputManager.cpp' ]) - if target.name=="Linux": - myModule.add_src_file('ewol/context/X11/Context.cpp') - elif target.name=="Windows": - myModule.add_src_file('ewol/context/Windows/Context.cpp') - elif target.name=="Android": - myModule.add_src_file('ewol/context/Android/Context.cpp') - elif target.name=="MacOs": - myModule.add_src_file([ - 'ewol/context/MacOs/Context.cpp', - 'ewol/context/MacOs/Interface.mm', - 'ewol/context/MacOs/Windows.mm', - 'ewol/context/MacOs/OpenglView.mm', - 'ewol/context/MacOs/AppDelegate.mm']) - elif target.name=="IOs": - myModule.add_src_file([ - 'ewol/context/IOs/Context.cpp', - 'ewol/context/IOs/Interface.m', - 'ewol/context/IOs/OpenglView.mm', - 'ewol/context/IOs/AppDelegate.mm']) - else: - debug.error("unknow mode...") + my_module.add_header_file([ + 'ewol/context/ConfigFont.h', + 'ewol/context/Context.h', + 'ewol/context/Application.h', + 'ewol/context/InputManager.h' + ]) - # event properties : - myModule.add_src_file([ + # event properties: + my_module.add_src_file([ 'ewol/event/Entry.cpp', 'ewol/event/Time.cpp', 'ewol/event/Input.cpp' ]) - - # Key properties : - myModule.add_src_file([ - 'ewol/key/keyboard.cpp', - 'ewol/key/Special.cpp', - 'ewol/key/status.cpp', - 'ewol/key/type.cpp' + my_module.add_header_file([ + 'ewol/event/Time.h', + 'ewol/event/Input.h', + 'ewol/event/Entry.h' ]) - # object : - myModule.add_src_file([ + # object: + my_module.add_src_file([ 'ewol/object/Manager.cpp', 'ewol/object/Object.cpp', 'ewol/object/Worker.cpp' ]) - # parameter : - myModule.add_src_file([ + my_module.add_header_file([ + 'ewol/object/Worker.h', + 'ewol/object/Manager.h', + 'ewol/object/Object.h' + ]) + + # parameter: + my_module.add_src_file([ 'ewol/parameter/Parameter.cpp', 'ewol/parameter/Interface.cpp', ]) - # Signal : - myModule.add_src_file([ + my_module.add_header_file([ + 'ewol/parameter/Value.h', + 'ewol/parameter/Interface.h', + 'ewol/parameter/Parameter.h', + 'ewol/parameter/Range.h', + 'ewol/parameter/List.h' + ]) + + # Signal: + my_module.add_src_file([ 'ewol/signal/Interface.cpp', 'ewol/signal/Base.cpp' ]) - - # OpenGL interface : - myModule.add_src_file([ - 'ewol/openGL/openGL.cpp' + my_module.add_header_file([ + 'ewol/signal/Interface.h', + 'ewol/signal/Base.h', + 'ewol/signal/Signal.h' ]) - # resources : - myModule.add_src_file([ + # resources: + my_module.add_src_file([ 'ewol/resource/Colored3DObject.cpp', 'ewol/resource/ColorFile.cpp', 'ewol/resource/ConfigFile.cpp', 'ewol/resource/FontFreeType.cpp', 'ewol/resource/Image.cpp', 'ewol/resource/ImageDF.cpp', - 'ewol/resource/Manager.cpp', - 'ewol/resource/Program.cpp', - 'ewol/resource/Resource.cpp', - 'ewol/resource/Shader.cpp', 'ewol/resource/Texture.cpp', 'ewol/resource/TexturedFont.cpp', - 'ewol/resource/DistanceFieldFont.cpp', - 'ewol/resource/VirtualBufferObject.cpp' + 'ewol/resource/DistanceFieldFont.cpp' + ]) + my_module.add_header_file([ + 'ewol/resource/FontFreeType.h', + 'ewol/resource/TexturedFont.h', + 'ewol/resource/ColorFile.h', + 'ewol/resource/font/FontBase.h', + 'ewol/resource/font/Kerning.h', + 'ewol/resource/font/GlyphProperty.h', + 'ewol/resource/DistanceFieldFont.h', + 'ewol/resource/ImageDF.h', + 'ewol/resource/Colored3DObject.h', + 'ewol/resource/ConfigFile.h', + 'ewol/resource/Texture.h', + 'ewol/resource/Image.h' ]) - # widget : - myModule.add_src_file([ + # widget: + my_module.add_src_file([ 'ewol/widget/ButtonColor.cpp', 'ewol/widget/Button.cpp', 'ewol/widget/CheckBox.cpp', @@ -165,85 +196,70 @@ def create(target): 'ewol/widget/Windows.cpp', 'ewol/widget/WSlider.cpp', ]) + my_module.add_header_file([ + 'ewol/widget/Menu.h', + 'ewol/widget/Slider.h', + 'ewol/widget/WidgetScrolled.h', + 'ewol/widget/ListFileSystem.h', + 'ewol/widget/Panned.h', + 'ewol/widget/WSlider.h', + 'ewol/widget/Container2.h', + 'ewol/widget/Windows.h', + 'ewol/widget/CheckBox.h', + 'ewol/widget/Container.h', + 'ewol/widget/PopUp.h', + 'ewol/widget/Label.h', + 'ewol/widget/Composer.h', + 'ewol/widget/Sizer.h', + 'ewol/widget/Scroll.h', + 'ewol/widget/ContainerN.h', + 'ewol/widget/Spacer.h', + 'ewol/widget/Button.h', + 'ewol/widget/Manager.h', + 'ewol/widget/Entry.h', + 'ewol/widget/ContextMenu.h', + 'ewol/widget/Gird.h', + 'ewol/widget/ProgressBar.h', + 'ewol/widget/ColorBar.h', + 'ewol/widget/ButtonColor.h', + 'ewol/widget/Layer.h', + 'ewol/widget/Joystick.h', + 'ewol/widget/Widget.h', + 'ewol/widget/meta/StdPopUp.h', + 'ewol/widget/meta/ParameterList.h', + 'ewol/widget/meta/ColorChooser.h', + 'ewol/widget/meta/Parameter.h', + 'ewol/widget/meta/FileChooser.h', + 'ewol/widget/Image.h', + 'ewol/widget/List.h' + ]) - myModule.copy_folder('data/theme/shape/square/*','theme/shape/square') - myModule.copy_folder('data/theme/shape/round/*','theme/shape/round') - myModule.copy_folder('data/theme/color/black/*','theme/color/black') - myModule.copy_folder('data/theme/color/white/*','theme/color/white') - myModule.copy_folder('data/textured.*','') - myModule.copy_folder('data/texturedNoMaterial.*','') - myModule.copy_folder('data/text.*','') - myModule.copy_folder('data/simple3D.*','') - myModule.copy_folder('data/color.*','') - myModule.copy_folder('data/color3.*','') - myModule.copy_folder('data/textured3D2.*','') - myModule.copy_folder('data/textured3D.*','') - myModule.copy_folder('data/texturedDF.*','') - myModule.copy_folder('data/fontDistanceField/*','fontDistanceField') - myModule.copy_folder('data/translate/*','translate/ewol/') + my_module.copy_path('data/theme/shape/square/*','theme/shape/square') + my_module.copy_path('data/theme/shape/round/*','theme/shape/round') + my_module.copy_path('data/theme/color/black/*','theme/color/black') + my_module.copy_path('data/theme/color/white/*','theme/color/white') + my_module.copy_path('data/textured.*','') + my_module.copy_path('data/texturedNoMaterial.*','') + my_module.copy_path('data/text.*','') + my_module.copy_path('data/simple3D.*','') + my_module.copy_path('data/color.*','') + my_module.copy_path('data/color3.*','') + my_module.copy_path('data/textured3D2.*','') + my_module.copy_path('data/textured3D.*','') + my_module.copy_path('data/texturedDF.*','') + my_module.copy_path('data/fontDistanceField/*','fontDistanceField') + my_module.copy_path('data/translate/*','translate/ewol') # name of the dependency - myModule.add_module_depend(['etk', 'freetype', 'exml', 'ejson', 'egami', 'edtaa3', 'date']) + my_module.add_module_depend(['etk', 'gale', 'freetype', 'exml', 'ejson', 'egami', 'edtaa3']) + + my_module.add_path(tools.get_current_path(__file__)) - myModule.add_export_path(tools.get_current_path(__file__)) - tagFile = tools.get_current_path(__file__) + "/tag" ewolVersionID = tools.file_read_data(tagFile) - myModule.compile_flags_CC([ + my_module.compile_flags('c++', [ "-DEWOL_VERSION=\"\\\""+ewolVersionID+"\\\"\"" ]) - if target.name=="Linux": - myModule.add_export_flag_LD('-lGL') - - #`pkg-config --cflags directfb` `pkg-config --libs directfb` - - #ifeq ("$(CONFIG___EWOL_LINUX_GUI_MODE_X11__)","y") - myModule.add_export_flag_LD('-lX11') - #endif - #ifeq ("$(CONFIG___EWOL_LINUX_GUI_MODE_DIRECT_FB__)","y") - #myModule.add_export_flag_LD(['-L/usr/local/lib', '-ldirectfb', '-lfusion', '-ldirect']) - #endif - - #http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction - # needed package on linux : libgl1-mesa-dev libglew1.5-dev - - #ifeq ("$(CONFIG_BUILD_PORTAUDIO)","y") - #myModule.add_src_file('ewol/renderer/audio/interfacePortAudio.cpp') - #endif - - elif target.name=="Android": - myModule.add_export_flag_LD("-lGLESv2") - - myModule.add_export_flag_LD("-ldl") - myModule.add_export_flag_LD("-llog") - myModule.add_export_flag_LD("-landroid") - java_tmp_dir = tools.get_current_path(__file__) + "/android/src/" - cpp_tmp_dir = tools.get_current_path(__file__) + "/ewol/renderer/Android/" - java_tmp_src = java_tmp_dir + "org/ewol/EwolConstants" - # TODO : set the build directory in out/.build with option -d ... - debugCommand = "" - if debug.get_level() >= 4: - debugCommand = " -verbose " - lutinMultiprocess.run_command("javac " + debugCommand + java_tmp_src + ".java") - lutinMultiprocess.run_command("javah " + debugCommand + "-classpath " + java_tmp_dir + " -d " + cpp_tmp_dir + " org.ewol.EwolConstants") - tools.remove_file(java_tmp_src + ".class") - elif target.name=="Windows": - myModule.add_module_depend("glew") - elif target.name=="MacOs": - myModule.add_export_flag_LD([ - "-framework Cocoa", - "-framework OpenGL", - "-framework QuartzCore", - "-framework AppKit"]) - elif target.name=="IOs": - myModule.add_export_flag_LD([ - "-framework OpenGLES", - "-framework CoreGraphics", - "-framework UIKit", - "-framework GLKit", - "-framework Foundation", - "-framework QuartzCore"]) - - return myModule + return my_module diff --git a/sample/001_HelloWord/appl/Main.cpp b/sample/001_HelloWord/appl/Main.cpp index 49b711c8..cad4b1ae 100644 --- a/sample/001_HelloWord/appl/Main.cpp +++ b/sample/001_HelloWord/appl/Main.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/sample/001_HelloWord/appl/Windows.cpp b/sample/001_HelloWord/appl/Windows.cpp index 5d35ce31..5c9c8ea2 100644 --- a/sample/001_HelloWord/appl/Windows.cpp +++ b/sample/001_HelloWord/appl/Windows.cpp @@ -18,12 +18,13 @@ appl::Windows::Windows() { addObjectType("appl::Windows"); } void appl::Windows::init() { - setTitle("example 001_HelloWord"); + ewol::widget::Windows::init(); + setTitle("example 001_HelloWorld"); std::shared_ptr tmpWidget = ewol::widget::Label::create(); if (tmpWidget == nullptr) { APPL_ERROR("Can not allocate widget ==> display might be in error"); } else { - tmpWidget->setLabel("Hello Word"); + tmpWidget->setLabel("Hello World"); tmpWidget->setExpand(bvec2(true,true)); setSubWidget(tmpWidget); } diff --git a/sample/001_HelloWord/lutin_001_HelloWord.py b/sample/001_HelloWord/lutin_001_HelloWord.py old mode 100755 new mode 100644 index 04064803..a6235d72 --- a/sample/001_HelloWord/lutin_001_HelloWord.py +++ b/sample/001_HelloWord/lutin_001_HelloWord.py @@ -1,31 +1,43 @@ #!/usr/bin/python -import lutinModule as module -import lutinTools as tools +import lutin.module as module +import lutin.tools as tools +def get_type(): + return "BINARY" + +def get_sub_type(): + return "SAMPLE" -# optionnal : Describe in the "lutin.py --help" def get_desc(): return "Tutorial 001 : Hello Word" -# Module creation instance (not optionnal) -def create(target): - # module name is '001_HelloWord' and type binary. - myModule = module.Module(__file__, '001_HelloWord', 'BINARY') - # add the file to compile: - myModule.add_src_file([ +def get_licence(): + return "APACHE-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def get_version(): + return [0,1] + +def create(target, module_name): + my_module = module.Module(__file__, module_name, get_type()) + my_module.add_src_file([ 'appl/Main.cpp', 'appl/debug.cpp', 'appl/Windows.cpp', ]) - # add Library dependency name - myModule.add_module_depend(['ewol']) - # add application C flags - myModule.compile_flags_CC([ - "-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""]) - # Add current include Path - myModule.add_path(tools.get_current_path(__file__)) - # return the created module - return myModule + my_module.add_module_depend(['ewol']) + my_module.compile_flags('c++', [ + "-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""]) + my_module.add_path(tools.get_current_path(__file__)) + return my_module diff --git a/sample/0XX_CustomWidgets/appl/Main.cpp b/sample/0XX_CustomWidgets/appl/Main.cpp index 975e6c2a..c0431920 100644 --- a/sample/0XX_CustomWidgets/appl/Main.cpp +++ b/sample/0XX_CustomWidgets/appl/Main.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.cpp b/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.cpp index f1d2f224..c7506705 100644 --- a/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.cpp +++ b/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.cpp @@ -1,9 +1,7 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD 3 clauses (see license file) +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) */ #include diff --git a/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.h b/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.h index 3b67b534..929e751d 100644 --- a/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.h +++ b/sample/0XX_CustomWidgets/appl/widget/VectorDisplay.h @@ -1,9 +1,7 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD 3 clauses (see license file) +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) */ #ifndef __APPL_WIDGET_VECTOR_DISPLAY_H__ diff --git a/sample/0XX_CustomWidgets/lutin_0XX_customwidget.py b/sample/0XX_CustomWidgets/lutin_0XX_customwidget.py old mode 100755 new mode 100644 index 9824d353..994e0b61 --- a/sample/0XX_CustomWidgets/lutin_0XX_customwidget.py +++ b/sample/0XX_CustomWidgets/lutin_0XX_customwidget.py @@ -1,33 +1,44 @@ #!/usr/bin/python -import lutinModule as module -import lutinTools as tools +import lutin.module as module +import lutin.tools as tools +def get_type(): + return "BINARY" + +def get_sub_type(): + return "SAMPLE" -# optionnal : Describe in the "lutin.py --help" def get_desc(): - return "Tutorial 0XX : Create custom Widget" + return "Tutorial 0XX : Create costum Widget" -# Module creation instance (not optionnal) -def create(target): - # module name is '001_HelloWord' and type binary. - myModule = module.Module(__file__, '0XX_customwidget', 'BINARY') - # add the file to compile: - myModule.add_src_file([ +def get_licence(): + return "APACHE-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def get_version(): + return [0,1] + +def create(target, module_name): + my_module = module.Module(__file__, module_name, get_type()) + my_module.add_src_file([ 'appl/Main.cpp', 'appl/debug.cpp', 'appl/Windows.cpp', 'appl/widget/VectorDisplay.cpp', ]) - - # add Library dependency name - myModule.add_module_depend(['ewol']) - # add application C flags - myModule.compile_flags_CC([ - "-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""]) - # Add current include Path - myModule.add_path(tools.get_current_path(__file__)) - # return the created module - return myModule + my_module.add_module_depend(['ewol']) + my_module.compile_flags('c++', [ + "-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""]) + my_module.add_path(tools.get_current_path(__file__)) + return my_module diff --git a/sample/examplewallpaper/appl/Main.cpp b/sample/examplewallpaper/appl/Main.cpp index 85eb2a38..7a339065 100644 --- a/sample/examplewallpaper/appl/Main.cpp +++ b/sample/examplewallpaper/appl/Main.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/sample/examplewallpaper/appl/WidgetDisplay.cpp b/sample/examplewallpaper/appl/WidgetDisplay.cpp index a8918c8a..df508a02 100644 --- a/sample/examplewallpaper/appl/WidgetDisplay.cpp +++ b/sample/examplewallpaper/appl/WidgetDisplay.cpp @@ -104,7 +104,7 @@ void appl::WidgetDisplay::periodicCall(const ewol::event::Time& _event) { bool appl::WidgetDisplay::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Input event : " << _event); vec2 relPos = relativePosition(_event.getPos()); - if (_event.getType() == ewol::key::typeFinger) { + if (_event.getType() == gale::key::type_finger) { keepFocus(); if (1 == _event.getId()) { APPL_DEBUG("Touch event ... "); diff --git a/sample/examplewallpaper/lutin_examplewallpaper.py b/sample/examplewallpaper/lutin_examplewallpaper.py old mode 100755 new mode 100644 index 757608e3..4ef6926a --- a/sample/examplewallpaper/lutin_examplewallpaper.py +++ b/sample/examplewallpaper/lutin_examplewallpaper.py @@ -1,60 +1,73 @@ #!/usr/bin/python -import lutinModule as module -import lutinTools as tools +import lutin.module as module +import lutin.tools as tools import datetime + +def get_type(): + return "BINARY" + +def get_name(): + return "ewol Wallpaper sample" + +def get_sub_type(): + return "SAMPLE" + def get_desc(): return "Tutorial xxx example wallpaper" +def get_licence(): + return "APACHE-2" -def create(target): - # module name is 'edn' and type binary. - myModule = module.Module(__file__, 'examplewallpaper', 'PACKAGE') - # add the file to compile: - myModule.add_src_file([ +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def create(target, module_name): + my_module = module.Module(__file__, module_name, get_type()) + my_module.add_src_file([ 'appl/Main.cpp', 'appl/debug.cpp', 'appl/WidgetDisplay.cpp', 'appl/Windows.cpp', ]) - - myModule.add_module_depend(['ewol']) - - myModule.compile_flags_CC([ - "-DPROJECT_NAME=\"\\\""+myModule.name+"\\\"\""]) - - myModule.copy_folder('data/SnowFlake.svg','') - - myModule.add_path(tools.get_current_path(__file__)) - - + my_module.add_module_depend(['ewol']) + my_module.compile_flags('c++', [ + "-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\"" + ]) + my_module.copy_path('data/SnowFlake.svg','') + my_module.add_path(tools.get_current_path(__file__)) now = datetime.datetime.now() versionID=str(now.year-2013)+"."+str(now.month)+"."+str(now.day) - # set the package properties : - myModule.pkg_set("VERSION", versionID) - myModule.pkg_set("COMPAGNY_TYPE", "org") - myModule.pkg_set("COMPAGNY_NAME", "EWOL") - myModule.pkg_set("MAINTAINER", ["Mr DUPIN Edouard "]) - myModule.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.png") - myModule.pkg_set("SECTION", "example") - myModule.pkg_set("PRIORITY", "extra") - myModule.pkg_set("DESCRIPTION", "EWOL example for Wallpaper on Android") - myModule.pkg_set("NAME", "ewol Wallpaper ewample") + my_module.pkg_set("VERSION", versionID) + my_module.pkg_set("COMPAGNY_TYPE", get_compagny_type()) + my_module.pkg_set("COMPAGNY_NAME", get_compagny_name()) + my_module.pkg_set("MAINTAINER", get_maintainer()) + my_module.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.png") + my_module.pkg_set("SECTION", "example") + my_module.pkg_set("PRIORITY", "extra") + my_module.pkg_set("DESCRIPTION", get_desc()) + my_module.pkg_set("NAME", get_name()) - myModule.pkg_set("ANDROID_APPL_TYPE", "WALLPAPER") + my_module.pkg_set("ANDROID_APPL_TYPE", "WALLPAPER") #for the exemple : - myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", "testpattern", "Select test pattern", "Choose which test pattern to display", \ + my_module.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", "testpattern", "Select test pattern", "Choose which test pattern to display", \ [ ["key","value display"],\ ["key2","value display 2"]\ ] \ ]) - myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", "movement", "Motion", "Apply movement to test pattern", ["Moving test pattern", "Still test pattern"]]) + my_module.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["bool", "movement", "Motion", "Apply movement to test pattern", ["Moving test pattern", "Still test pattern"]]) # add the currrent module at the - return myModule + return my_module diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 00000000..e9986593 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,38 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAME "Empty" +#include + +#undef __class__ +#define __class__ "ewol-test" + + +int main(int argc, const char *argv[]) { + // init Google test : + ::testing::InitGoogleTest(&argc, const_cast(argv)); + // the only one init for etk: + //etk::log::setLevel(etk::log::logLevelVerbose); + etk::log::setLevel(etk::log::logLevelInfo); + etk::setArgZero(argv[0]); + etk::initDefaultFolder("ewol-test"); + return RUN_ALL_TESTS(); +} + diff --git a/test/testApplication.cpp b/test/testApplication.cpp new file mode 100644 index 00000000..7974b11e --- /dev/null +++ b/test/testApplication.cpp @@ -0,0 +1,22 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2015, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#define NAME "Application" + +#undef __class__ +#define __class__ "TestEwolApplication" + +TEST(TestEwolApplication, Creation) { + ewol::context::Application* tmpAppl = new ewol::context::Application(); + EXPECT_NE(tmpAppl, nullptr); + delete tmpAppl; +} + diff --git a/test/testWindows.cpp b/test/testWindows.cpp new file mode 100644 index 00000000..7bf62fa5 --- /dev/null +++ b/test/testWindows.cpp @@ -0,0 +1,42 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2015, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#define NAME "Windows" + +#undef __class__ +#define __class__ "TestEwolWindows" + +namespace appl { + class Windows : public ewol::widget::Windows { + protected: + Windows() { + addObjectType("appl::Windows"); + } + void init() { + ewol::widget::Windows::init(); + setTitle("test set"); + } + public: + DECLARE_FACTORY(Windows); + }; +}; + + + + +TEST(TestEwolWindows, Creation) { + /* + std::shared_ptr tmpWindows = appl::Windows::create(); + EXPECT_NE(tmpWindows, nullptr); + tmpWindows.reset(); + */ +} +