Merge branch 'dev'

This commit is contained in:
Edouard DUPIN 2015-10-19 09:07:40 +02:00
commit 7f6acfc024
176 changed files with 1714 additions and 12863 deletions

View File

@ -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

View File

@ -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)
=====================

View File

@ -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 <T extends EwolCallback> 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 <T extends EwolCallback> 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);
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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 <esc> 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;
}

View File

@ -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();
}
}

View File

@ -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 <esc> 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);
}
}

View File

@ -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;
}
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

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

View File

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

View File

@ -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();
}

View File

@ -12,8 +12,9 @@
#include <etk/Color.h>
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/resource/Program.h>
#include <gale/resource/Program.h>
#include <ewol/resource/Texture.h>
#include <egami/Image.h>
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<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
std::shared_ptr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer)

View File

@ -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();
}

View File

@ -13,7 +13,7 @@
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/resource/Program.h>
#include <gale/resource/Program.h>
namespace ewol {
@ -28,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<ewol::resource::Program> m_GLprogram; //!< pointer on the opengl display program
std::shared_ptr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLMatrixPosition; //!< position matrix
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<vec3 > m_coord; //!< internal position for the text display
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the background
public:

View File

@ -43,9 +43,9 @@ void ewol::compositing::Image::loadProgram() {
m_GLPosition = 0;
m_GLprogram.reset();
if (m_distanceFieldMode == true) {
m_GLprogram = ewol::resource::Program::create("DATA:texturedDF.prog");
m_GLprogram = gale::resource::Program::create("{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();
}

View File

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

View File

@ -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(),

View File

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

View File

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

View File

@ -44,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);
}

View File

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

View File

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

View File

@ -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();
}

File diff suppressed because it is too large Load Diff

View File

@ -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) {};
};
};
};

View File

@ -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)");
}

View File

@ -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:

File diff suppressed because it is too large Load Diff

View File

@ -9,48 +9,34 @@
#ifndef __EWOL_CONTEXT_H__
#define __EWOL_CONTEXT_H__
#include <etk/os/Fifo.h>
#include <gale/key/key.h>
#include <gale/Application.h>
#include <gale/context/Context.h>
#include <gale/context/clipBoard.h>
#include <gale/context/commandLine.h>
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/key/key.h>
#include <ewol/object/Manager.h>
#include <ewol/resource/Manager.h>
#include <ewol/widget/Manager.h>
#include <ewol/widget/Windows.h>
#include <ewol/context/Application.h>
#include <ewol/context/clipBoard.h>
#include <ewol/context/ConfigFont.h>
#include <ewol/context/commandLine.h>
#include <ewol/context/InputManager.h>
#include <ewol/context/Fps.h>
#include <memory>
namespace ewol {
/**
* @not-in-doc
*/
class eSystemMessage;
/**
* @not-in-doc
*/
enum orientation{
screenAuto = 0,
screenLandscape,
screenPortrait
};
class Context/* : private ewol::object::RemoveEvent */{
// Here we hereted from the gale application to be agnostic of the OW where we work ...
class Context : public gale::Application {
private:
std::shared_ptr<ewol::context::Application> m_application; //!< Application handle
public:
std::shared_ptr<ewol::context::Application> getApplication() {
return m_application;
}
private:
ewol::context::CommandLine m_commandLine; //!< Start command line information
public:
ewol::context::CommandLine& getCmd() {
return m_commandLine;
gale::context::CommandLine& getCmd() {
return gale::getContext().getCmd();
};
private:
ewol::context::ConfigFont m_configFont; //!< global font configuration
@ -70,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<ewol::eSystemMessage*> m_msgSystem;
bool m_displayFps;
ewol::context::Fps m_FpsSystemEvent;
ewol::context::Fps m_FpsSystemContext;
ewol::context::Fps m_FpsSystem;
ewol::context::Fps m_FpsFlush;
/**
* @brief Processing all the event arrived ... (commoly called in draw function)
*/
void processEvents();
public:
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<ewol::widget::Windows> getWindows();
private:
vec2 m_windowsSize; //!< current size of the system
public:
/**
* @brief get the current windows size
* @return the current size ...
*/
const vec2& getSize() {
return m_windowsSize;
};
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
virtual void OS_Resize(const vec2& _size);
/**
* @brief The application request a change of his curent size.
* @param[in] _size new Requested size of the windows.
*/
virtual void setSize(const vec2& _size);
/**
* @brief The OS inform that the current windows has change his position.
* @param[in] _pos New position of the Windows.
*/
void OS_Move(const vec2& _pos);
/**
* @brief The Application request that the current windows will change his position.
* @param[in] _pos New position of the Windows requested.
*/
virtual void setPos(const vec2& _pos);
/**
* @brief The OS inform that the Windows is now Hidden.
*/
void OS_Hide();
/**
* @brief The Application request that the Windows will be Hidden.
*/
virtual void hide();
/**
* @brief The OS inform that the Windows is now visible.
*/
void OS_Show();
/**
* @brief The Application request that the Windows will be visible.
*/
virtual void show();
/**
* @brief Redraw all the windows
*/
@ -240,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.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,79 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <ewol/context/MacOs/AppDelegate.h>
#import <ewol/context/MacOs/OpenglView.h>
#include <ewol/debug.h>
@implementation MacOsAppDelegate
@synthesize window=_window;
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] 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

View File

@ -1,195 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/key/key.h>
#include <ewol/context/commandLine.h>
#include <etk/types.h>
#include <etk/os/FSNode.h>
#include <ewol/widget/Manager.h>
#include <ewol/resource/Manager.h>
#include <ewol/context/Context.h>
#include <ewol/context/MacOs/Interface.h>
#include <ewol/context/MacOs/Context.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/times.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <etk/etk.h>
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;
}

View File

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

View File

@ -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

View File

@ -1,109 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
#include "ewol/context/MacOs/Interface.h"
#import <ewol/context/MacOs/OpenglView.h>
#import <ewol/context/MacOs/Windows.h>
#import <ewol/context/MacOs/AppDelegate.h>
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;
}

View File

@ -1,34 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
NSTimer* _refreshTimer;
}
- ()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

View File

@ -1,379 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <ewol/context/MacOs/OpenglView.h>
#include <OpenGL/gl.h>
#include <ewol/context/MacOS/Context.h>
#include <ewol/debug.h>
#include <ewol/Dimension.h>
@implementation OpenGLView
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

View File

@ -1,24 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <Cocoa/Cocoa.h>
@interface EwolMainWindows : NSWindow {
}
+ (id)alloc;
- (id)init;
+ (void)dealloc;
@end
@interface MyApplication : NSApplication
@property (strong, nonatomic) NSWindow *window;
@end

View File

@ -1,128 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#import <ewol/context/MacOs/Windows.h>
#import <ewol/context/MacOs/OpenglView.h>
#include <ewol/context/MacOS/Context.h>
#include <ewol/debug.h>
@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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/context/clipBoard.h>
#include <ewol/context/Context.h>
#undef __class__
#define __class__ "ClipBoard"
/*
note: 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) {
_os << clipboardDescriptionString[_obj];
} else {
_os << "[ERROR]";
}
return _os;
}
void ewol::context::clipBoard::init() {
EWOL_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<ewol::context::clipBoard::clipboardCount; i++) {
mesCopy[i].clear();
}
}
void ewol::context::clipBoard::unInit() {
EWOL_INFO("Initialyse ClipBoards");
for(int32_t i=0; i<ewol::context::clipBoard::clipboardCount; i++) {
mesCopy[i].clear();
}
}
void ewol::context::clipBoard::set(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data) {
// check if ID is correct
if(0 == _data.size()) {
EWOL_INFO("request a copy of nothing");
return;
} else
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return;
}
ewol::context::clipBoard::setSystem(_clipboardID, _data);
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
ewol::getContext().clipBoardSet(_clipboardID);
}
}
void ewol::context::clipBoard::request(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return;
}
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
ewol::getContext().clipBoardGet(_clipboardID);
} else {
// generate an event on the main thread ...
ewol::getContext().OS_ClipBoardArrive(_clipboardID);
}
}
void ewol::context::clipBoard::setSystem(enum ewol::context::clipBoard::clipboardListe _clipboardID, const std::string& _data) {
if(_clipboardID >= ewol::context::clipBoard::clipboardCount) {
EWOL_WARNING("request ClickBoard id error");
return;
}
// Copy datas ...
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];
}

View File

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

View File

@ -1,40 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/context/commandLine.h>
#include <vector>
void ewol::context::CommandLine::parse(int32_t _argc, const char* _argv[]) {
for (int32_t i=1 ; i<_argc; i++) {
EWOL_INFO("commandLine : \"" << _argv[i] << "\"" );
m_listArgs.push_back(_argv[i]);
}
}
int32_t ewol::context::CommandLine::size() {
return m_listArgs.size();
}
const std::string& ewol::context::CommandLine::get(int32_t _id) {
static const std::string errorArg("");
if ( _id < 0
&& _id >= (int64_t)m_listArgs.size()) {
return errorArg;
}
return m_listArgs[_id];
}
void ewol::context::CommandLine::add(const std::string& _newElement) {
m_listArgs.push_back(_newElement);
}
void ewol::context::CommandLine::remove(int32_t _id) {
m_listArgs.erase(m_listArgs.begin()+_id);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@ namespace ewol {
};
#define EWOL_BASE(info,data) TK_LOG_BASE(ewol::getLogId(),info,data)
#define EWOL_PRINT(data) EWOL_BASE(-1, data)
#define EWOL_CRITICAL(data) EWOL_BASE(1, data)
#define EWOL_ERROR(data) EWOL_BASE(2, data)
#define EWOL_WARNING(data) EWOL_BASE(3, data)

View File

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

View File

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

View File

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

View File

@ -9,11 +9,11 @@
#include <ewol/ewol.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <gale/gale.h>
#include <ewol/context/commandLine.h>
#include <gale/context/commandLine.h>
#include <etk/os/FSNode.h>
#include <ewol/Dimension.h>
#include <date/date.h>
#include <gale/Dimension.h>
#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);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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");

View File

@ -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> ewol::Object::getObjectNamed(const std::string& _objectName) const {
std::shared_ptr<ewol::Object> 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);
}
}

View File

@ -45,6 +45,32 @@ namespace ewol {
return object; \
}
#define DECLARE_SINGLE_FACTORY(className,uniqueName) \
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
std::shared_ptr<className> object; \
std::shared_ptr<ewol::Object> object2 = getObjectNamed(uniqueName); \
if (object2 != nullptr) { \
object = std::dynamic_pointer_cast<className>(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<className>(new className()); \
if (object == nullptr) { \
EWOL_ERROR("Factory error"); \
return nullptr; \
} \
object->init(uniqueName, std::forward<T>(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<ewol::Object> getObjectNamed(const std::string& _objectName) const;
static std::shared_ptr<ewol::Object> getObjectNamed(const std::string& _objectName);
/**
* @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object

View File

@ -1,496 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <vector>
#include <ewol/debug.h>
#include <ewol/openGL/openGL.h>
#include <etk/stdTools.h>
#include <mutex>
//#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<mat4> 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<std::pair<enum openGL::openGlFlags, const char*>> 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<std::pair<enum ewol::openGL::renderMode, std::string>>& getListRenderMode() {
static std::vector<std::pair<enum ewol::openGL::renderMode, std::string>> 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<ewol::openGL::renderMode>(const ewol::openGL::renderMode& _obj) {
for (auto &it : getListRenderMode()) {
if (it.first == _obj) {
return it.second;
}
}
EWOL_ERROR("Can not convert : " << static_cast<int32_t>(_obj) << " return UNKNOW");
return "UNKNOW";
}
template<> std::u32string to_u32string<ewol::openGL::renderMode>(const ewol::openGL::renderMode& _obj) {
return etk::to_u32string(etk::to_string(_obj));
}
template<> bool from_string<ewol::openGL::renderMode>(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>(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 : " <EWOL_ERROR< _flagID);
#ifdef DIRECT_MODE
for (int32_t iii=0; iii<basicFlagCount ; iii++) {
if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
glEnable(basicFlag[iii].OGlFlag);
}
}
# else
//EWOL_DEBUG("Enable FLAGS = " << l_flagsMustBeSet);
l_flagsMustBeSet |= (uint32_t)_flagID;
//EWOL_DEBUG(" == >" << 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<basicFlagCount ; iii++) {
if ( basicFlag[iii].curentFlag == (uint32_t)_flagID ) {
glDisable(basicFlag[iii].OGlFlag);
}
}
# else
//EWOL_DEBUG("Disable FLAGS = " << l_flagsMustBeSet);
l_flagsMustBeSet &= ~((uint32_t)_flagID);
//EWOL_DEBUG(" == >" << 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<basicFlagCount ; iii++) {
uint32_t CurrentFlag = basicFlag[iii].curentFlag;
if ( (l_flagsMustBeSet&CurrentFlag)!=(l_flagsCurrent&CurrentFlag) ) {
if ( (l_flagsMustBeSet&CurrentFlag) != 0) {
glEnable(basicFlag[iii].OGlFlag);
OPENGL_INFO(" enable : " << (enum openGL::openGlFlags)basicFlag[iii].curentFlag);
} else {
glDisable(basicFlag[iii].OGlFlag);
OPENGL_INFO(" disable : " << (enum openGL::openGlFlags)basicFlag[iii].curentFlag);
}
}
}
l_flagsCurrent = l_flagsMustBeSet;
}
void ewol::openGL::activeTexture(uint32_t _flagID) {
if (l_programId >= 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<uint32_t>& _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<uint16_t>& _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<uint8_t>& _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<GLuint>& _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<GLuint>& _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;
}

View File

@ -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 <etk/types.h>
#include <vector>
#include <etk/math/Matrix4.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__TARGET_OS__Linux)
// TO ENABLE THE SHADER api ...
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
// 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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#elif defined(__TARGET_OS__Windows)
// TO ENABLE THE SHADER api ...
//#define GL_GLEXT_PROTOTYPES
#define GLEW_STATIC
#include <GL/glew.h>
#elif defined(__TARGET_OS__MacOs)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#elif defined(__TARGET_OS__IOs)
#include <OpenGLES/ES2/gl.h>
#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 2n1 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<uint32_t>& _indices);
void drawElements16(uint32_t _mode, const std::vector<uint16_t>& _indices);
void drawElements8 (uint32_t _mode, const std::vector<uint8_t>& _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<GLuint>& _buffers);
bool deleteBuffers(std::vector<GLuint>& _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

View File

@ -9,7 +9,6 @@
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <ewol/resource/ColorFile.h>
#include <ewol/resource/Manager.h>
#include <ejson/ejson.h>
#include <stdexcept>
@ -18,13 +17,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<std11::recursive_mutex> 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<std11::recursive_mutex> 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<std11::recursive_mutex> lock(m_mutex);
// check if the parameters existed :
if (m_list.exist(_paramName) == false) {
m_list.add(_paramName, m_errorColor);

View File

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

View File

@ -8,7 +8,8 @@
#include <ewol/debug.h>
#include <ewol/resource/Colored3DObject.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <gale/renderer/openGL/openGL-include.h>
#undef __class__
#define __class__ "resource::Colored3DObject"
@ -16,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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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<vec3>& _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);
}
}

View File

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

View File

@ -9,7 +9,7 @@
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <ewol/resource/ConfigFile.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ejson/ejson.h>
#include <ejson/Number.h>
#include <ejson/String.h>
@ -20,12 +20,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<std11::recursive_mutex> 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<std11::recursive_mutex> lock(m_mutex);
// reset all parameters
for (int32_t iii=0; iii<m_list.size(); iii++){
if (nullptr != m_list[iii]) {
@ -53,6 +55,7 @@ void ewol::resource::ConfigFile::reload() {
int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) {
std11::unique_lock<std11::recursive_mutex> 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<std11::recursive_mutex> 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<std11::recursive_mutex> 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<std11::recursive_mutex> lock(m_mutex);
if ( _id < 0
|| m_list[_id] == nullptr) {
return false;

View File

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

View File

@ -10,7 +10,7 @@
#include <etk/os/FSNode.h>
#include <egami/egami.h>
#include <ewol/resource/Manager.h>
#include <gale/resource/Manager.h>
#include <ewol/resource/font/FontBase.h>
#include <ewol/resource/TexturedFont.h>
@ -28,7 +28,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() :
ewol::resource::Texture(),
m_borderSize(10),
m_textureBorderSize(0,0) {
addObjectType("ewol::resource::DistanceFieldFont");
addResourceType("ewol::resource::DistanceFieldFont");
m_font = nullptr;
m_lastGlyphPos.setValue(1,1);
m_lastRawHeigh = 0;
@ -36,17 +36,22 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() :
}
void ewol::resource::DistanceFieldFont::init(const std::string& _fontName) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
ewol::resource::Texture::init(_fontName);
std::string localName = _fontName;
std::vector<std::string> 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<std::string> 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<std11::recursive_mutex> lock(m_mutex);
return _size / (float)SIZE_GENERATION;
}
void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
int32_t size = _input.getSize().x() * _input.getSize().y();
std::vector<short> xdist(size);
std::vector<short> 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<std11::recursive_mutex> 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<std11::recursive_mutex> 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<std11::recursive_mutex> 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<std11::recursive_mutex> lock(m_mutex);
EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
ejson::Document doc;
std::shared_ptr<ejson::Array> tmpList = ejson::Array::create();
@ -374,6 +385,7 @@ void ewol::resource::DistanceFieldFont::exportOnFile() {
}
bool ewol::resource::DistanceFieldFont::importFromFile() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
// test file existance:
etk::FSNode fileJSON(m_fileName + ".json");

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