change the interface of OS abstractions
This commit is contained in:
parent
3b645645cb
commit
e177dd4db3
2
Build
2
Build
@ -1 +1 @@
|
||||
Subproject commit d04dd75956d79935e17972e6fd938abeb477faa8
|
||||
Subproject commit 4747bc90b663557fc049ebf55ec251eecee6e1d8
|
@ -28,14 +28,13 @@
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
#include <Debug.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
|
||||
#include <ewol/threadMsg.h>
|
||||
#include <ewol/Audio/audio.h>
|
||||
|
||||
// declaration of the ewol android abstraction ...
|
||||
void EWOL_NativeRender(void);
|
||||
void EWOL_NativeGLDestroy(void);
|
||||
|
||||
// get a resources from the java environement :
|
||||
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
||||
@ -195,7 +194,7 @@ extern "C"
|
||||
// direct setting of the date in the string system ...
|
||||
jboolean isCopy;
|
||||
const char* str = env->GetStringUTFChars(myString, &isCopy);
|
||||
guiSystem::SetArchiveDir(mode, str);
|
||||
eSystem::SetArchiveDir(mode, str);
|
||||
if (isCopy == JNI_TRUE) {
|
||||
// from here str is reset ...
|
||||
env->ReleaseStringUTFChars(myString, str);
|
||||
@ -274,7 +273,7 @@ extern "C"
|
||||
APPL_DEBUG("*******************************************");
|
||||
APPL_DEBUG("** Activity On Create **");
|
||||
APPL_DEBUG("*******************************************");
|
||||
guiSystem::Init();
|
||||
eSystem::Init();
|
||||
}
|
||||
void Java_org_ewol_interfaceJNI_ActivityOnStart( JNIEnv* env )
|
||||
{
|
||||
@ -301,8 +300,7 @@ extern "C"
|
||||
APPL_DEBUG("** Activity On Pause **");
|
||||
APPL_DEBUG("*******************************************");
|
||||
// All the openGl has been destroyed ...
|
||||
// TODO : Mark all the texture to be reloaded ...
|
||||
EWOL_NativeGLDestroy();
|
||||
eSystem::OpenGlContextDestroy();
|
||||
}
|
||||
void Java_org_ewol_interfaceJNI_ActivityOnStop( JNIEnv* env )
|
||||
{
|
||||
@ -315,7 +313,7 @@ extern "C"
|
||||
APPL_DEBUG("*******************************************");
|
||||
APPL_DEBUG("** Activity On Destroy **");
|
||||
APPL_DEBUG("*******************************************");
|
||||
guiSystem::UnInit();
|
||||
eSystem::UnInit();
|
||||
}
|
||||
|
||||
|
||||
@ -325,22 +323,22 @@ extern "C"
|
||||
* ********************************************************************************************** */
|
||||
void Java_org_ewol_interfaceJNI_IOInputEventMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
|
||||
{
|
||||
guiSystem::event::SetInputMotion(pointerID+1, x, y);
|
||||
eSystem::SetInputMotion(pointerID+1, x, y);
|
||||
}
|
||||
|
||||
void Java_org_ewol_interfaceJNI_IOInputEventState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
|
||||
{
|
||||
guiSystem::event::SetInputState(pointerID+1, isUp, x, y);
|
||||
eSystem::SetInputState(pointerID+1, isUp, x, y);
|
||||
}
|
||||
|
||||
void Java_org_ewol_interfaceJNI_IOMouseEventMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
|
||||
{
|
||||
guiSystem::event::SetMouseMotion(pointerID+1, x, y);
|
||||
eSystem::SetMouseMotion(pointerID+1, x, y);
|
||||
}
|
||||
|
||||
void Java_org_ewol_interfaceJNI_IOMouseEventState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
|
||||
{
|
||||
guiSystem::event::SetMouseState(pointerID+1, isUp, x, y);
|
||||
eSystem::SetMouseState(pointerID+1, isUp, x, y);
|
||||
}
|
||||
|
||||
void Java_org_ewol_interfaceJNI_IOUnknowEvent( JNIEnv* env, jobject thiz, jint pointerID)
|
||||
@ -356,10 +354,10 @@ extern "C"
|
||||
void Java_org_ewol_interfaceJNI_IOKeyboardEventKey( JNIEnv* env, jobject thiz, jint uniChar, jboolean isdown)
|
||||
{
|
||||
APPL_DEBUG("IO keyboard Key event : \"" << uniChar << "\" is down=" << isdown);
|
||||
guiSystem::event::keyboardKey_ts keyInput;
|
||||
eSystem::keyboardKey_ts keyInput;
|
||||
keyInput.myChar = uniChar;
|
||||
keyInput.isDown = isdown;
|
||||
guiSystem::event::SetKeyboard(keyInput);
|
||||
eSystem::SetKeyboard(keyInput);
|
||||
}
|
||||
|
||||
enum {
|
||||
@ -370,6 +368,7 @@ extern "C"
|
||||
SYSTEM_KEY__HOME,
|
||||
SYSTEM_KEY__POWER,
|
||||
};
|
||||
// TODO : Set a return true or false if we want to grep this event ...
|
||||
void Java_org_ewol_interfaceJNI_IOKeyboardEventKeySystem( JNIEnv* env, jobject thiz, jint keyVal, jboolean isdown)
|
||||
{
|
||||
switch (keyVal)
|
||||
@ -409,12 +408,12 @@ extern "C"
|
||||
|
||||
void Java_org_ewol_interfaceJNI_RenderResize( JNIEnv* env, jobject thiz, jint w, jint h )
|
||||
{
|
||||
guiSystem::event::Resize(w, h);
|
||||
eSystem::Resize(w, h);
|
||||
}
|
||||
|
||||
void Java_org_ewol_interfaceJNI_RenderDraw( JNIEnv* env )
|
||||
{
|
||||
guiSystem::Draw(true);
|
||||
eSystem::Draw(true);
|
||||
}
|
||||
|
||||
void Java_org_ewol_interfaceJNI_IOAudioPlayback(JNIEnv* env, void* reserved, jshortArray location, jint frameRate, jint nbChannels)
|
||||
|
@ -26,7 +26,7 @@ LOCAL_CFLAGS := -Wno-write-strings \
|
||||
# load the common sources file of the platform
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
LOCAL_SRC_FILES := ewol/base/guiAndroid.cpp $(FILE_LIST)
|
||||
LOCAL_SRC_FILES := ewol/base/gui.Android.cpp $(FILE_LIST)
|
||||
|
||||
# Ewol Test Software :
|
||||
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz
|
||||
|
@ -27,7 +27,7 @@ LOCAL_CFLAGS := -Wno-write-strings \
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
ewol/base/guiX11.cpp \
|
||||
ewol/base/gui.X11.cpp \
|
||||
ewol/Audio/interfacePortAudio.cpp \
|
||||
$(FILE_LIST)
|
||||
|
||||
|
@ -26,7 +26,7 @@ LOCAL_CFLAGS := -Wno-write-strings \
|
||||
# load the common sources file of the platform
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
LOCAL_SRC_FILES := $(FILE_LIST) ewol/base/guiWindows.cpp
|
||||
LOCAL_SRC_FILES := $(FILE_LIST) ewol/base/gui.Windows.cpp
|
||||
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/ClipBoard.h>
|
||||
#include <ewol/base/gui.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ClipBoard"
|
||||
@ -92,7 +92,7 @@ void ewol::clipBoard::Set(ewol::clipBoard::clipboardListe_te clipboardID, etk::U
|
||||
|
||||
if( ewol::clipBoard::CLIPBOARD_STD == clipboardID
|
||||
|| ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) {
|
||||
guiAbstraction::ClipBoardSet(clipboardID);
|
||||
guiInterface::ClipBoardSet(clipboardID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,10 +114,10 @@ void ewol::clipBoard::Request(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
|
||||
if( ewol::clipBoard::CLIPBOARD_STD == clipboardID
|
||||
|| ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) {
|
||||
guiAbstraction::ClipBoardGet(clipboardID);
|
||||
guiInterface::ClipBoardGet(clipboardID);
|
||||
} else {
|
||||
// generate an event on the main thread ...
|
||||
guiSystem::event::ClipBoardArrive(clipboardID);
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <ewol/EObjectManager.h>
|
||||
#include <ewol/base/eventInputManagement.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EObjectManager"
|
||||
@ -78,7 +78,7 @@ void informOneObjectIsRemoved(ewol::EObject* object)
|
||||
}
|
||||
}
|
||||
// call input event manager to remove linked widget ...
|
||||
ewol::eventInput::OnObjectRemove(object);
|
||||
eSystem::OnObjectRemove(object);
|
||||
}
|
||||
|
||||
void ewol::EObjectManager::Rm(ewol::EObject* object)
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <etk/unicode.h>
|
||||
#include <etk/Vector.h>
|
||||
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
extern "C" {
|
||||
#include <freetype/ft2build.h>
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <etk/Types.h>
|
||||
#include <etk/UString.h>
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/importgl.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <ewol/OObject/2DColored.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <ewol/OObject/2DText.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/Texture.h>
|
||||
|
||||
#undef __class__
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <ewol/OObject/2DTextColored.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/Texture.h>
|
||||
|
||||
#undef __class__
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <ewol/OObject/2DTextured.h>
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DTextured"
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef __class__
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/Texture/TextureBMP.h>
|
||||
#include <ewol/Texture/TextureSVG.h>
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <ewol/EObjectManager.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
|
||||
char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ namespace ewol {
|
||||
#include <etk/Vector.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/base/eventInputManagement.h>
|
||||
#include <ewol/ClipBoard.h>
|
||||
|
||||
namespace ewol {
|
||||
@ -95,6 +94,12 @@ namespace ewol {
|
||||
EVENT_KB_MOVE_TYPE_VER_NUM,
|
||||
} eventKbMoveType_te;
|
||||
|
||||
typedef enum {
|
||||
INPUT_TYPE_UNKNOW,
|
||||
INPUT_TYPE_MOUSE,
|
||||
INPUT_TYPE_FINGER,
|
||||
} inputType_te;
|
||||
|
||||
char* GetCharTypeMoveEvent(eventKbMoveType_te type);
|
||||
|
||||
class DrawProperty{
|
||||
|
@ -30,9 +30,9 @@
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/Font.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/base/eventInputManagement.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
|
||||
|
||||
|
||||
@ -191,7 +191,8 @@ void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget)
|
||||
m_popUpWidgetList.PushBack(widget);
|
||||
// Regenerate the size calculation :
|
||||
CalculateSize(m_size.x, m_size.y);
|
||||
ewol::eventInput::NewLayerSet();
|
||||
// TODO : it is dansgerous to access directly to the system ...
|
||||
eSystem::ResetIOEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
164
Sources/libewol/ewol/base/Fps.h
Normal file
164
Sources/libewol/ewol/base/Fps.h
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/base/Fps.h
|
||||
* @brief fps counter and displayer (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/08/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_FPS_H__
|
||||
#define __EWOL_FPS_H__
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
/**
|
||||
* @brief This class is designed to count the number of frame per second in the main renderer system
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
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;
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
Fps(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* @brief Destructor
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
~Fps(void)
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief this might be call every time a diplay start
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void Tic(void)
|
||||
{
|
||||
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 ---
|
||||
* @return ---
|
||||
*/
|
||||
void Toc(void)
|
||||
{
|
||||
int64_t currentTime = ewol::GetTime();
|
||||
int64_t processTimeLocal = (currentTime - ticTime);
|
||||
if (drwingDone) {
|
||||
min = etk_min(min, processTimeLocal);
|
||||
max = etk_max(max, processTimeLocal);
|
||||
avg += processTimeLocal;
|
||||
drwingDone = false;
|
||||
} else {
|
||||
min_idle = etk_min(min_idle, processTimeLocal);
|
||||
max_idle = etk_max(max_idle, processTimeLocal);
|
||||
avg_idle += processTimeLocal;
|
||||
}
|
||||
if (true == display) {
|
||||
EWOL_DEBUG("display property : " << nbDisplayTime << "/" << nbCallTime << "fps");
|
||||
if (nbDisplayTime>0) {
|
||||
EWOL_DEBUG("Time Drawind : " << (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_DEBUG("Time 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 ");
|
||||
}
|
||||
max = 0;
|
||||
min = 99999999999999LL;
|
||||
avg = 0;
|
||||
max_idle = 0;
|
||||
min_idle = 99999999999999LL;
|
||||
avg_idle = 0;
|
||||
nbCallTime = 0;
|
||||
nbDisplayTime = 0;
|
||||
startTime = -1;
|
||||
display = false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief this might be call when a display is really done
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void IncrementCounter(void)
|
||||
{
|
||||
nbDisplayTime++;
|
||||
drwingDone = true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This fuction display and calculate the curent frame per second of the display
|
||||
* @note this function must be call 2 time the first at the start of the display and the second at the end of this one
|
||||
* @param[in] Represent the mode of the counter
|
||||
* @param[in] the curent system time
|
||||
* @ return ---
|
||||
*/
|
||||
|
||||
#endif
|
@ -1,85 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainThread.h
|
||||
* @brief Main Ewol thread for the abstraction of the OS problematics (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 27/01/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*O
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef __EWOL_MAIN_TREAD_H__
|
||||
#define __EWOL_MAIN_TREAD_H__
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
namespace guiSystem
|
||||
{
|
||||
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
|
||||
void SetArchiveDir(int mode, const char* str);
|
||||
|
||||
namespace event {
|
||||
void Resize(int w, int h );
|
||||
|
||||
void SetInputMotion(int pointerID, float x, float y);
|
||||
void SetInputState(int pointerID, bool isUp, float x, float y);
|
||||
|
||||
void SetMouseMotion(int pointerID, float x, float y);
|
||||
void SetMouseState(int pointerID, bool isUp, float x, float y);
|
||||
|
||||
typedef struct {
|
||||
bool capLock;
|
||||
bool shift;
|
||||
bool ctrl;
|
||||
bool meta;
|
||||
bool alt;
|
||||
bool altGr;
|
||||
bool verNum;
|
||||
bool insert;
|
||||
} specialKey_ts;
|
||||
|
||||
typedef struct {
|
||||
bool isDown;
|
||||
uniChar_t myChar;
|
||||
guiSystem::event::specialKey_ts special;
|
||||
} keyboardKey_ts;
|
||||
|
||||
typedef struct {
|
||||
bool isDown;
|
||||
ewol::eventKbMoveType_te move;
|
||||
guiSystem::event::specialKey_ts special;
|
||||
} keyboardMove_ts;
|
||||
|
||||
void SetKeyboard(guiSystem::event::keyboardKey_ts& keyInput);
|
||||
void SetKeyboardMove(guiSystem::event::keyboardMove_ts& keyInput);
|
||||
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
|
||||
void ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
};
|
||||
// return true if a flush is needed
|
||||
bool Draw(bool displayEveryTime);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,19 +28,24 @@
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/threadMsg.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
#include <ewol/base/gui.h>
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/EObject.h>
|
||||
#include <ewol/EObjectManager.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/ShortCutManager.h>
|
||||
#include <ewol/base/eventInputManagement.h>
|
||||
|
||||
#include <ewol/base/eSystemInput.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/base/Fps.h>
|
||||
|
||||
static ewol::Windows* windowsCurrent = NULL;
|
||||
static Vector2D<int32_t> windowsSize(320, 480);
|
||||
|
||||
static ewol::threadMsg::threadMsg_ts androidJniMsg;
|
||||
|
||||
static ewol::eSystemInput l_managementInput;
|
||||
|
||||
enum {
|
||||
THREAD_INIT,
|
||||
THREAD_UN_INIT,
|
||||
@ -82,10 +87,7 @@ typedef struct {
|
||||
float y;
|
||||
} eventInputState_ts;
|
||||
|
||||
void EWOL_NativeResize(int w, int h );
|
||||
void EWOL_NativeRegenerateDisplay(void);
|
||||
|
||||
extern guiSystem::event::specialKey_ts specialCurrentKey;
|
||||
extern eSystem::specialKey_ts specialCurrentKey;
|
||||
|
||||
static bool requestEndProcessing = false;
|
||||
|
||||
@ -110,13 +112,15 @@ void ewolProcessEvents(void)
|
||||
requestEndProcessing = true;
|
||||
break;
|
||||
case THREAD_RECALCULATE_SIZE:
|
||||
UpdateGuiSize();
|
||||
eSystem::ForceRedrawAll();
|
||||
break;
|
||||
case THREAD_RESIZE:
|
||||
//EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
|
||||
{
|
||||
eventResize_ts * tmpData = (eventResize_ts*)data.data;
|
||||
EWOL_NativeResize(tmpData->w, tmpData->h);
|
||||
windowsSize.x = tmpData->w;
|
||||
windowsSize.y = tmpData->h;
|
||||
eSystem::ForceRedrawAll();
|
||||
}
|
||||
break;
|
||||
case THREAD_INPUT_MOTION:
|
||||
@ -126,7 +130,7 @@ void ewolProcessEvents(void)
|
||||
Vector2D<float> pos;
|
||||
pos.x = tmpData->x;
|
||||
pos.y = tmpData->y;
|
||||
ewol::eventInput::Motion(tmpData->type, tmpData->pointerID, pos);
|
||||
l_managementInput.Motion(tmpData->type, tmpData->pointerID, pos);
|
||||
}
|
||||
break;
|
||||
case THREAD_INPUT_STATE:
|
||||
@ -136,31 +140,52 @@ void ewolProcessEvents(void)
|
||||
Vector2D<float> pos;
|
||||
pos.x = tmpData->x;
|
||||
pos.y = tmpData->y;
|
||||
ewol::eventInput::State(tmpData->type, tmpData->pointerID, tmpData->state, pos);
|
||||
l_managementInput.State(tmpData->type, tmpData->pointerID, tmpData->state, pos);
|
||||
}
|
||||
break;
|
||||
case THREAD_KEYBORAD_KEY:
|
||||
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
|
||||
{
|
||||
guiSystem::event::keyboardKey_ts * tmpData = (guiSystem::event::keyboardKey_ts*)data.data;
|
||||
eSystem::keyboardKey_ts * tmpData = (eSystem::keyboardKey_ts*)data.data;
|
||||
specialCurrentKey = tmpData->special;
|
||||
if (false==ewol::shortCut::Process(tmpData->special.shift, tmpData->special.ctrl, tmpData->special.alt, tmpData->special.meta, tmpData->myChar, tmpData->isDown)) {
|
||||
guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar);
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(true == tmpData->isDown) {
|
||||
EWOL_VERBOSE("GUI PRESSED : \"" << tmpData->myChar << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, tmpData->myChar);
|
||||
} else {
|
||||
EWOL_VERBOSE("GUI Release : \"" << tmpData->myChar << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, tmpData->myChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case THREAD_KEYBORAD_MOVE:
|
||||
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE");
|
||||
{
|
||||
guiSystem::event::keyboardMove_ts * tmpData = (guiSystem::event::keyboardMove_ts*)data.data;
|
||||
eSystem::keyboardMove_ts * tmpData = (eSystem::keyboardMove_ts*)data.data;
|
||||
specialCurrentKey = tmpData->special;
|
||||
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(true == tmpData->isDown) {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, tmpData->move);
|
||||
} else {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, tmpData->move);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case THREAD_CLIPBOARD_ARRIVE:
|
||||
{
|
||||
ewol::clipBoard::clipboardListe_te * tmpdata = (ewol::clipBoard::clipboardListe_te*)data.data;
|
||||
guiAbstraction::SendClipboard(*tmpdata);
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (tmpWidget != NULL) {
|
||||
tmpWidget->OnEventClipboard(*tmpdata);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case THREAD_HIDE:
|
||||
@ -183,7 +208,7 @@ void ewolProcessEvents(void)
|
||||
|
||||
|
||||
|
||||
void guiSystem::SetArchiveDir(int mode, const char* str)
|
||||
void eSystem::SetArchiveDir(int mode, const char* str)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
@ -217,7 +242,7 @@ void guiSystem::SetArchiveDir(int mode, const char* str)
|
||||
|
||||
bool isGlobalSystemInit = false;
|
||||
|
||||
void guiSystem::Init(void)
|
||||
void eSystem::Init(void)
|
||||
{
|
||||
EWOL_INFO("==> Ewol System Init (BEGIN)");
|
||||
if (false == isGlobalSystemInit) {
|
||||
@ -230,7 +255,7 @@ void guiSystem::Init(void)
|
||||
etk::InitDefaultFolder("ewolApplNoName");
|
||||
ewol::EObjectManager::Init();
|
||||
ewol::EObjectMessageMultiCast::Init();
|
||||
ewol::eventInput::Init();
|
||||
l_managementInput.Reset();
|
||||
ewol::widgetManager::Init();
|
||||
ewol::texture::Init();
|
||||
ewol::InitFont();
|
||||
@ -245,7 +270,7 @@ void guiSystem::Init(void)
|
||||
EWOL_INFO("==> Ewol System Init (END)");
|
||||
}
|
||||
|
||||
void guiSystem::UnInit(void)
|
||||
void eSystem::UnInit(void)
|
||||
{
|
||||
EWOL_INFO("==> Ewol System Un-Init (BEGIN)");
|
||||
if (true == isGlobalSystemInit) {
|
||||
@ -260,7 +285,7 @@ void guiSystem::UnInit(void)
|
||||
ewol::widgetManager::UnInit();
|
||||
ewol::EObjectMessageMultiCast::UnInit();
|
||||
ewol::EObjectManager::UnInit();
|
||||
ewol::eventInput::UnInit();
|
||||
l_managementInput.Reset();
|
||||
ewol::threadMsg::UnInit(androidJniMsg);
|
||||
}
|
||||
EWOL_INFO("==> Ewol System Un-Init (END)");
|
||||
@ -275,7 +300,7 @@ void ewol::RequestUpdateSize(void)
|
||||
|
||||
|
||||
|
||||
void guiSystem::event::Resize(int w, int h )
|
||||
void eSystem::Resize(int w, int h )
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
eventResize_ts tmpData;
|
||||
@ -284,8 +309,19 @@ void guiSystem::event::Resize(int w, int h )
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_RESIZE, ewol::threadMsg::MSG_PRIO_MEDIUM, &tmpData, sizeof(eventResize_ts) );
|
||||
}
|
||||
}
|
||||
void eSystem::Move(int w, int h )
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
/*
|
||||
eventResize_ts tmpData;
|
||||
tmpData.w = w;
|
||||
tmpData.h = h;
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_RESIZE, ewol::threadMsg::MSG_PRIO_MEDIUM, &tmpData, sizeof(eventResize_ts) );
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void guiSystem::event::SetInputMotion(int pointerID, float x, float y )
|
||||
void eSystem::SetInputMotion(int pointerID, float x, float y )
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
eventInputMotion_ts tmpData;
|
||||
@ -298,7 +334,7 @@ void guiSystem::event::SetInputMotion(int pointerID, float x, float y )
|
||||
}
|
||||
|
||||
|
||||
void guiSystem::event::SetInputState(int pointerID, bool isUp, float x, float y )
|
||||
void eSystem::SetInputState(int pointerID, bool isUp, float x, float y )
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
eventInputState_ts tmpData;
|
||||
@ -311,7 +347,7 @@ void guiSystem::event::SetInputState(int pointerID, bool isUp, float x, float y
|
||||
}
|
||||
}
|
||||
|
||||
void guiSystem::event::SetMouseMotion(int pointerID, float x, float y )
|
||||
void eSystem::SetMouseMotion(int pointerID, float x, float y )
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
eventInputMotion_ts tmpData;
|
||||
@ -324,7 +360,7 @@ void guiSystem::event::SetMouseMotion(int pointerID, float x, float y )
|
||||
}
|
||||
|
||||
|
||||
void guiSystem::event::SetMouseState(int pointerID, bool isUp, float x, float y )
|
||||
void eSystem::SetMouseState(int pointerID, bool isUp, float x, float y )
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
eventInputState_ts tmpData;
|
||||
@ -337,28 +373,28 @@ void guiSystem::event::SetMouseState(int pointerID, bool isUp, float x, float y
|
||||
}
|
||||
}
|
||||
|
||||
void guiSystem::event::SetKeyboard(guiSystem::event::keyboardKey_ts& keyInput)
|
||||
void eSystem::SetKeyboard(eSystem::keyboardKey_ts& keyInput)
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(guiSystem::event::keyboardKey_ts) );
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eSystem::keyboardKey_ts) );
|
||||
}
|
||||
}
|
||||
|
||||
void guiSystem::event::SetKeyboardMove(guiSystem::event::keyboardMove_ts& keyInput)
|
||||
void eSystem::SetKeyboardMove(eSystem::keyboardMove_ts& keyInput)
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(guiSystem::event::keyboardMove_ts) );
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eSystem::keyboardMove_ts) );
|
||||
}
|
||||
}
|
||||
|
||||
void guiSystem::event::Hide(void)
|
||||
void eSystem::Hide(void)
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_HIDE, ewol::threadMsg::MSG_PRIO_LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void guiSystem::event::Show(void)
|
||||
void eSystem::Show(void)
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_SHOW, ewol::threadMsg::MSG_PRIO_LOW);
|
||||
@ -366,7 +402,7 @@ void guiSystem::event::Show(void)
|
||||
}
|
||||
|
||||
|
||||
void guiSystem::event::ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
void eSystem::ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_CLIPBOARD_ARRIVE, ewol::threadMsg::MSG_PRIO_LOW, &clipboardID, sizeof(uint8_t));
|
||||
@ -374,19 +410,237 @@ void guiSystem::event::ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipbo
|
||||
}
|
||||
|
||||
|
||||
bool guiSystem::Draw(bool displayEveryTime)
|
||||
|
||||
|
||||
static float gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
|
||||
static float gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
|
||||
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
|
||||
|
||||
static void BasicOpenGlDraw(void)
|
||||
{
|
||||
if (true == isGlobalSystemInit) {
|
||||
ewolProcessEvents();
|
||||
|
||||
int64_t localTime = ewol::GetTime();
|
||||
ewol::widgetManager::PeriodicCall(localTime);
|
||||
|
||||
EWOL_NativeRegenerateDisplay();
|
||||
|
||||
ewol::texture::UpdateContext();
|
||||
EWOL_GenericDraw(true);
|
||||
Vector2D<int32_t> tmpSize = eSystem::GetSize();
|
||||
// set the size of the open GL system
|
||||
glViewport(0, 0, tmpSize.x, tmpSize.y);
|
||||
|
||||
// Clear the screen with transparency ...
|
||||
glClearColor(0.0,0.0,0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//glOrtho(0., width, 0., -height, 1., 20.);
|
||||
glOrthoEwol(-tmpSize.x/2, tmpSize.x/2, tmpSize.y/2, -tmpSize.y/2, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
//glTranslatef(0, -height/2, -5);
|
||||
glTranslatef(-tmpSize.x/2, -tmpSize.y/2, -1.0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
|
||||
//LOGI("engine_draw_frame (%d,%d)",width,height);
|
||||
|
||||
glColor4f(0.0, 1.0, 1.0, 1.0);
|
||||
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices5 );
|
||||
glDrawArrays( GL_TRIANGLES, 0, 6);
|
||||
static int vallllll = 0;
|
||||
static float transparency = 0.0;
|
||||
if (vallllll <= 1) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(1.0, 0.0, 0.0, 1.0);
|
||||
} else {
|
||||
glColor4f(1.0, 0.0, 0.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 2) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(1.0, 1.0, 0.0, 1.0);
|
||||
} else {
|
||||
glColor4f(1.0, 1.0, 0.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 3) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(0.0, 1.0, 0.0, 1.0);
|
||||
} else {
|
||||
glColor4f(0.0, 1.0, 0.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 4) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(0.0, 1.0, 1.0, 1.0);
|
||||
} else {
|
||||
glColor4f(0.0, 1.0, 1.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 5) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
} else {
|
||||
glColor4f(0.0, 0.0, 1.0, transparency);
|
||||
}
|
||||
} else {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll = 0;
|
||||
transparency = 0.0;
|
||||
glColor4f(1.0, 0.0, 1.0, 1.0);
|
||||
} else {
|
||||
glColor4f(1.0, 0.0, 1.0, transparency);
|
||||
}
|
||||
}
|
||||
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices );
|
||||
glDrawArrays( GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
static ewol::Fps l_FpsSystem;
|
||||
|
||||
bool eSystem::Draw(bool displayEveryTime)
|
||||
{
|
||||
int64_t currentTime = ewol::GetTime();
|
||||
// FPS display system
|
||||
l_FpsSystem.Tic();
|
||||
if (true == isGlobalSystemInit) {
|
||||
// process the events
|
||||
ewolProcessEvents();
|
||||
// call all the widget that neded to do something periodicly
|
||||
ewol::widgetManager::PeriodicCall(currentTime);
|
||||
|
||||
// Remove all widget that they are no more usefull (these who decided to destroy themself)
|
||||
ewol::EObjectManager::RemoveAllAutoRemove();
|
||||
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
|
||||
// check if the user selected a windows
|
||||
if (NULL == tmpWindows) {
|
||||
BasicOpenGlDraw();
|
||||
} else {
|
||||
// Redraw all needed elements
|
||||
tmpWindows->OnRegenerateDisplay();
|
||||
// check if the regenerate is needed ...
|
||||
if( true == ewol::widgetManager::IsDrawingNeeded()
|
||||
|| true == displayEveryTime) {
|
||||
ewol::texture::UpdateContext();
|
||||
l_FpsSystem.IncrementCounter();
|
||||
tmpWindows->SysDraw();
|
||||
}
|
||||
}
|
||||
glFlush();
|
||||
}
|
||||
// FPS display system
|
||||
l_FpsSystem.Toc();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void eSystem::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
l_managementInput.OnObjectRemove(removeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief reset event management for the IO like Input ou Mouse or keyborad
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void eSystem::ResetIOEvent(void)
|
||||
{
|
||||
l_managementInput.NewLayerSet();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inform the system that the OpenGL constext has been destroy ==> use to automaticly reload the texture and other thinks ...
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void eSystem::OpenGlContextDestroy(void)
|
||||
{
|
||||
ewol::texture::UpdateContextIsDestroy();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief set the current windows to display :
|
||||
* @param windows windows that might be displayed
|
||||
* @return ---
|
||||
*/
|
||||
void eSystem::SetCurrentWindows(ewol::Windows * windows)
|
||||
{
|
||||
// set the new pointer as windows system
|
||||
windowsCurrent = windows;
|
||||
// request all the widget redrawing
|
||||
eSystem::ForceRedrawAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the current windows that is displayed
|
||||
* @param ---
|
||||
* @return the current handle on the windows (can be null)
|
||||
*/
|
||||
ewol::Windows* eSystem::GetCurrentWindows(void)
|
||||
{
|
||||
return windowsCurrent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the current windows size
|
||||
* @param ---
|
||||
* @return the current size ...
|
||||
*/
|
||||
Vector2D<int32_t> eSystem::GetSize(void)
|
||||
{
|
||||
return windowsSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Redraw all the windows
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void eSystem::ForceRedrawAll(void)
|
||||
{
|
||||
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
|
||||
if (NULL != tmpWindows) {
|
||||
Vector2D<int32_t> tmpSize = eSystem::GetSize();
|
||||
tmpWindows->CalculateSize(tmpSize.x, tmpSize.y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inform the system that the Application has been killed
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void eSystem::OnKill(void)
|
||||
{
|
||||
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
|
||||
if (NULL != tmpWindows) {
|
||||
tmpWindows->SysOnKill();
|
||||
}
|
||||
}
|
||||
|
142
Sources/libewol/ewol/base/eSystem.h
Normal file
142
Sources/libewol/ewol/base/eSystem.h
Normal file
@ -0,0 +1,142 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file eSystem.h
|
||||
* @brief Main Ewol system of management of the input events and drawing request (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 27/01/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*O
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef __EWOL_SYSTEM_H__
|
||||
#define __EWOL_SYSTEM_H__
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
namespace eSystem
|
||||
{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
|
||||
void SetArchiveDir(int mode, const char* str);
|
||||
|
||||
void Resize(int w, int h );
|
||||
void Move(int x, int y );
|
||||
void Hide(void);
|
||||
void Show(void);
|
||||
|
||||
void SetInputMotion(int pointerID, float x, float y);
|
||||
void SetInputState(int pointerID, bool isUp, float x, float y);
|
||||
|
||||
void SetMouseMotion(int pointerID, float x, float y);
|
||||
void SetMouseState(int pointerID, bool isUp, float x, float y);
|
||||
|
||||
typedef struct {
|
||||
bool capLock;
|
||||
bool shift;
|
||||
bool ctrl;
|
||||
bool meta;
|
||||
bool alt;
|
||||
bool altGr;
|
||||
bool verNum;
|
||||
bool insert;
|
||||
} specialKey_ts;
|
||||
|
||||
typedef struct {
|
||||
bool isDown;
|
||||
uniChar_t myChar;
|
||||
eSystem::specialKey_ts special;
|
||||
} keyboardKey_ts;
|
||||
|
||||
typedef struct {
|
||||
bool isDown;
|
||||
ewol::eventKbMoveType_te move;
|
||||
eSystem::specialKey_ts special;
|
||||
} keyboardMove_ts;
|
||||
|
||||
void SetKeyboard(eSystem::keyboardKey_ts& keyInput);
|
||||
void SetKeyboardMove(eSystem::keyboardMove_ts& keyInput);
|
||||
|
||||
void ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
|
||||
// return true if a flush is needed
|
||||
bool Draw(bool displayEveryTime);
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void OnObjectRemove(ewol::EObject * removeObject);
|
||||
|
||||
/**
|
||||
* @brief reset event management for the IO like Input ou Mouse or keyborad
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void ResetIOEvent(void);
|
||||
|
||||
/**
|
||||
* @brief Inform the system that the OpenGL constext has been destroy ==> use to automaticly reload the texture and other thinks ...
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void OpenGlContextDestroy(void);
|
||||
|
||||
/**
|
||||
* @brief Inform the system that the Application has been killed
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void OnKill(void);
|
||||
|
||||
/**
|
||||
* @brief set the current windows to display :
|
||||
* @param windows windows that might be displayed
|
||||
* @return ---
|
||||
*/
|
||||
void SetCurrentWindows(ewol::Windows * windows);
|
||||
|
||||
/**
|
||||
* @brief Get the current windows that is displayed
|
||||
* @param ---
|
||||
* @return the current handle on the windows (can be null)
|
||||
*/
|
||||
ewol::Windows* GetCurrentWindows(void);
|
||||
|
||||
/**
|
||||
* @brief Get the current windows size
|
||||
* @param ---
|
||||
* @return the current size ...
|
||||
*/
|
||||
Vector2D<int32_t> GetSize(void);
|
||||
|
||||
/**
|
||||
* @brief Redraw all the windows
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void ForceRedrawAll(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file eventInputManagement.cpp
|
||||
* @file eSystemInput.cpp
|
||||
* @brief Input (mouse,finger) abstraction layer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 00/04/2011
|
||||
@ -38,29 +38,22 @@
|
||||
#include <ewol/base/gui.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/base/eventInputManagement.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
#include <ewol/base/eSystemInput.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
bool isUsed;
|
||||
int32_t destinationInputId;
|
||||
int64_t lastTimeEvent;
|
||||
ewol::Widget* curentWidgetEvent;
|
||||
Vector2D<float> origin;
|
||||
Vector2D<float> size;
|
||||
Vector2D<float> downStart;
|
||||
bool isDown;
|
||||
bool isInside;
|
||||
int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3
|
||||
} InputPoperty_ts;
|
||||
#define EVENT_DEBUG EWOL_VERBOSE
|
||||
//#define EVENT_DEBUG EWOL_DEBUG
|
||||
|
||||
// defined by the platform specific file :
|
||||
extern int32_t separateClickTime;
|
||||
extern int32_t offsetMoveClicked;
|
||||
extern int32_t offsetMoveClickedDouble;
|
||||
|
||||
|
||||
#define MAX_MANAGE_INPUT (10)
|
||||
InputPoperty_ts eventInputSaved[MAX_MANAGE_INPUT];
|
||||
InputPoperty_ts eventMouseSaved[MAX_MANAGE_INPUT];
|
||||
|
||||
static void CleanElement(InputPoperty_ts *eventTable, int32_t idInput)
|
||||
|
||||
void ewol::eSystemInput::CleanElement(InputPoperty_ts *eventTable, int32_t idInput)
|
||||
{
|
||||
eventTable[idInput].isUsed = false;
|
||||
eventTable[idInput].destinationInputId = 0;
|
||||
@ -84,7 +77,7 @@ static void CleanElement(InputPoperty_ts *eventTable, int32_t idInput)
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::eventInput::OnObjectRemove(ewol::EObject * removeObject)
|
||||
void ewol::eSystemInput::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
if (eventInputSaved[iii].curentWidgetEvent == removeObject) {
|
||||
@ -103,7 +96,7 @@ void ewol::eventInput::OnObjectRemove(ewol::EObject * removeObject)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::eventInput::NewLayerSet(void)
|
||||
void ewol::eSystemInput::NewLayerSet(void)
|
||||
{
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
// remove the property of this input ...
|
||||
@ -112,30 +105,28 @@ void ewol::eventInput::NewLayerSet(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::eSystemInput::Reset(void)
|
||||
{
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
// remove the property of this input ...
|
||||
CleanElement(eventInputSaved, iii);
|
||||
CleanElement(eventMouseSaved, iii);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::eventInput::Init(void)
|
||||
ewol::eSystemInput::eSystemInput(void)
|
||||
{
|
||||
EWOL_INFO("Init");
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
// remove the property of this input ...
|
||||
CleanElement(eventInputSaved, iii);
|
||||
CleanElement(eventMouseSaved, iii);
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
void ewol::eventInput::UnInit(void)
|
||||
ewol::eSystemInput::~eSystemInput(void)
|
||||
{
|
||||
EWOL_INFO("Un-Init");
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
// remove the property of this input ...
|
||||
CleanElement(eventInputSaved, iii);
|
||||
CleanElement(eventMouseSaved, iii);
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
extern ewol::Windows* gui_uniqueWindows;
|
||||
|
||||
/**
|
||||
* @brief generate the event on the destinated widger
|
||||
* @param[in] type Type of the event that might be sended
|
||||
@ -145,7 +136,7 @@ extern ewol::Windows* gui_uniqueWindows;
|
||||
* @param[in] pos position of the event
|
||||
* @return true if event has been greped
|
||||
*/
|
||||
static bool localEventInput(ewol::inputType_te type, ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, Vector2D<float> pos)
|
||||
bool ewol::eSystemInput::localEventInput(ewol::inputType_te type, ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, Vector2D<float> pos)
|
||||
{
|
||||
if (NULL != destWidget) {
|
||||
if (type == ewol::INPUT_TYPE_MOUSE || type == ewol::INPUT_TYPE_FINGER) {
|
||||
@ -164,7 +155,7 @@ static bool localEventInput(ewol::inputType_te type, ewol::Widget* destWidget, i
|
||||
* @param[in] realInputId System Id
|
||||
* @return the ewol input id
|
||||
*/
|
||||
static int32_t localGetDestinationId(ewol::inputType_te type, ewol::Widget* destWidget, int32_t realInputId)
|
||||
int32_t ewol::eSystemInput::localGetDestinationId(ewol::inputType_te type, ewol::Widget* destWidget, int32_t realInputId)
|
||||
{
|
||||
if (type == ewol::INPUT_TYPE_FINGER) {
|
||||
int32_t lastMinimum = 0;
|
||||
@ -182,16 +173,8 @@ static int32_t localGetDestinationId(ewol::inputType_te type, ewol::Widget* dest
|
||||
return realInputId;
|
||||
}
|
||||
|
||||
#define EVENT_DEBUG EWOL_VERBOSE
|
||||
//#define EVENT_DEBUG EWOL_DEBUG
|
||||
|
||||
// defined by the platform specific file :
|
||||
extern int32_t separateClickTime;
|
||||
extern int32_t offsetMoveClicked;
|
||||
extern int32_t offsetMoveClickedDouble;
|
||||
|
||||
// note if id<0 ==> the it was finger event ...
|
||||
void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D<float> pos)
|
||||
void ewol::eSystemInput::Motion(ewol::inputType_te type, int pointerID, Vector2D<float> pos)
|
||||
{
|
||||
// convert position in Open-GL coordonates ...
|
||||
pos.y = ewol::GetCurrentHeight() - pos.y;
|
||||
@ -210,11 +193,15 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D<f
|
||||
// not manage input
|
||||
return;
|
||||
}
|
||||
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
|
||||
// special case for the mouse event 0 that represent the hover event of the system :
|
||||
if (type == ewol::INPUT_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 :
|
||||
ewol::Widget* tmpWidget = gui_uniqueWindows->GetWidgetAtPos(pos);
|
||||
ewol::Widget* tmpWidget = NULL;
|
||||
if (NULL != tmpWindows) {
|
||||
tmpWidget = tmpWindows->GetWidgetAtPos(pos);
|
||||
}
|
||||
if( tmpWidget != eventTable[pointerID].curentWidgetEvent
|
||||
|| ( true == eventTable[pointerID].isInside
|
||||
&& ( eventTable[pointerID].origin.x > pos.x
|
||||
@ -229,8 +216,8 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D<f
|
||||
// Set the element inside ...
|
||||
eventTable[pointerID].isInside = true;
|
||||
// get destination widget :
|
||||
if(NULL != gui_uniqueWindows) {
|
||||
eventTable[pointerID].curentWidgetEvent = gui_uniqueWindows->GetWidgetAtPos(pos);
|
||||
if(NULL != tmpWindows) {
|
||||
eventTable[pointerID].curentWidgetEvent = tmpWindows->GetWidgetAtPos(pos);
|
||||
} else {
|
||||
eventTable[pointerID].curentWidgetEvent = NULL;
|
||||
}
|
||||
@ -272,7 +259,7 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D<f
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown, Vector2D<float> pos)
|
||||
void ewol::eSystemInput::State(ewol::inputType_te type, int pointerID, bool isDown, Vector2D<float> pos)
|
||||
{
|
||||
// convert position in Open-GL coordonates ...
|
||||
pos.y = ewol::GetCurrentHeight() - pos.y;
|
||||
@ -292,6 +279,7 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown
|
||||
}
|
||||
// get the curent time ...
|
||||
int64_t currentTime = ewol::GetTime();
|
||||
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
|
||||
|
||||
if (true == isDown) {
|
||||
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos);
|
||||
@ -320,8 +308,8 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown
|
||||
// Set the element inside ...
|
||||
eventTable[pointerID].isInside = true;
|
||||
// get destination widget :
|
||||
if(NULL != gui_uniqueWindows) {
|
||||
eventTable[pointerID].curentWidgetEvent = gui_uniqueWindows->GetWidgetAtPos(pos);
|
||||
if(NULL != tmpWindows) {
|
||||
eventTable[pointerID].curentWidgetEvent = tmpWindows->GetWidgetAtPos(pos);
|
||||
} else {
|
||||
eventTable[pointerID].curentWidgetEvent = NULL;
|
||||
}
|
85
Sources/libewol/ewol/base/eSystemInput.h
Normal file
85
Sources/libewol/ewol/base/eSystemInput.h
Normal file
@ -0,0 +1,85 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file eSystemInput.h
|
||||
* @brief Input (mouse,finger) abstraction layer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 00/04/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef __EWOL_SYSTEM_INPUT_H__
|
||||
#define __EWOL_SYSTEM_INPUT_H__
|
||||
|
||||
#include <ewol/Widget.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
|
||||
// internal structure
|
||||
typedef struct {
|
||||
bool isUsed;
|
||||
int32_t destinationInputId;
|
||||
int64_t lastTimeEvent;
|
||||
ewol::Widget* curentWidgetEvent;
|
||||
Vector2D<float> origin;
|
||||
Vector2D<float> size;
|
||||
Vector2D<float> downStart;
|
||||
bool isDown;
|
||||
bool isInside;
|
||||
int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3
|
||||
} InputPoperty_ts;
|
||||
|
||||
|
||||
class eSystemInput
|
||||
{
|
||||
private:
|
||||
#define MAX_MANAGE_INPUT (10)
|
||||
InputPoperty_ts eventInputSaved[MAX_MANAGE_INPUT];
|
||||
InputPoperty_ts eventMouseSaved[MAX_MANAGE_INPUT];
|
||||
void CleanElement(InputPoperty_ts *eventTable, int32_t idInput);
|
||||
bool localEventInput(ewol::inputType_te type, ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, Vector2D<float> pos);
|
||||
int32_t localGetDestinationId(ewol::inputType_te type, ewol::Widget* destWidget, int32_t realInputId);
|
||||
public:
|
||||
eSystemInput(void);
|
||||
~eSystemInput(void);
|
||||
void Reset(void);
|
||||
|
||||
// note if id<0 ==> the it was finger event ...
|
||||
void Motion(ewol::inputType_te type, int pointerID, Vector2D<float> pos );
|
||||
void State(ewol::inputType_te type, int pointerID, bool isDown, Vector2D<float> pos);
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void OnObjectRemove(ewol::EObject * removeObject);
|
||||
/**
|
||||
* @brief a new layer on the windows is set ==> might remove all the property of the current element ...
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void NewLayerSet(void);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file eventInputManagement.h
|
||||
* @brief Input (mouse,finger) abstraction layer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 00/04/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef __EWOL_EVENT_INPUT_MANAGEMENT_H__
|
||||
#define __EWOL_EVENT_INPUT_MANAGEMENT_H__
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
typedef enum {
|
||||
INPUT_TYPE_UNKNOW,
|
||||
INPUT_TYPE_MOUSE,
|
||||
INPUT_TYPE_FINGER,
|
||||
} inputType_te;
|
||||
namespace eventInput
|
||||
{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
// note if id<0 ==> the it was finger event ...
|
||||
void Motion(ewol::inputType_te type, int pointerID, Vector2D<float> pos );
|
||||
void State(ewol::inputType_te type, int pointerID, bool isDown, Vector2D<float> pos);
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void OnObjectRemove(ewol::EObject * removeObject);
|
||||
/**
|
||||
* @brief a new layer on the windows is set ==> might remove all the property of the current element ...
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void NewLayerSet(void);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
187
Sources/libewol/ewol/base/gui.Android.cpp
Normal file
187
Sources/libewol/ewol/base/gui.Android.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file guiAndroid.cpp
|
||||
* @brief Gui abstraction layer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/10/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <jni.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <android/log.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <ewol/Debug.h>
|
||||
#include <etk/UString.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/base/gui.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/Texture.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "AndroidJNI"
|
||||
int32_t separateClickTime = 800000;
|
||||
int32_t offsetMoveClicked = 40000;
|
||||
int32_t offsetMoveClickedDouble = 300000;
|
||||
|
||||
int64_t guiInterface::GetTime(void)
|
||||
{
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
void Draw(void);
|
||||
#define OFFSET_MOVE_CLICKED (20)
|
||||
#define OFFSET_MOVE_CLICKED_DOUBLE (40)
|
||||
#undef SEPARATED_CLICK_TIME
|
||||
#define SEPARATED_CLICK_TIME (300)
|
||||
|
||||
//bool inputIsPressed[NB_MAX_INPUT];// = {false, false, false};
|
||||
int32_t m_previousBouttonId = -1;
|
||||
int32_t m_previousDown_x = -1;
|
||||
int32_t m_previousDown_y = -1;
|
||||
int32_t m_previous_x = -1;
|
||||
int32_t m_previous_y = -1;
|
||||
int64_t m_previousTime = 0;
|
||||
bool m_previousDouble = false;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the new title of the windows
|
||||
* @param title New desired title
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::SetTitle(etk::UString& title)
|
||||
{
|
||||
// can not set the title in Android ...
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ClipBoard AREA :
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
bool l_clipBoardOwnerStd = false;
|
||||
/**
|
||||
* @brief Inform the Gui that we want to have a copy of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
// this is to force the local system to think we have the buffer
|
||||
// TODO : Remove this 2 Line when code will be writen
|
||||
l_clipBoardOwnerStd = true;
|
||||
switch (clipboardID)
|
||||
{
|
||||
case ewol::clipBoard::CLIPBOARD_SELECTION:
|
||||
// NOTE : Windows does not support the middle button the we do it internaly
|
||||
// just transmit an event , we have the data in the system
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
break;
|
||||
case ewol::clipBoard::CLIPBOARD_STD:
|
||||
if (false == l_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
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Request an unknow ClipBoard ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inform the Gui that we are the new owner of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
switch (clipboardID)
|
||||
{
|
||||
case ewol::clipBoard::CLIPBOARD_SELECTION:
|
||||
// NOTE : nothing to do : Windows deas ot supported Middle button
|
||||
break;
|
||||
case ewol::clipBoard::CLIPBOARD_STD:
|
||||
// Request the clipBoard :
|
||||
if (false == l_clipBoardOwnerStd) {
|
||||
// TODO : Inform the OS that we have the current buffer of copy ...
|
||||
l_clipBoardOwnerStd = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Request an unknow ClipBoard ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "guiInterface"
|
||||
|
||||
void guiInterface::Stop(void)
|
||||
{
|
||||
// TODo : send a message to the android system to stop ...
|
||||
}
|
||||
|
||||
// java system to send message :
|
||||
void SendSystemMessage(const char * dataString);
|
||||
void SendJava_KeyboardShow(bool showIt);
|
||||
|
||||
void guiInterface::KeyboardShow(void)
|
||||
{
|
||||
// send a message at the java :
|
||||
SendJava_KeyboardShow(true);
|
||||
}
|
||||
|
||||
void guiInterface::KeyboardHide(void)
|
||||
{
|
||||
// send a message at the java :
|
||||
SendJava_KeyboardShow(false);
|
||||
}
|
||||
|
||||
void guiInterface::ChangeSize(Vector2D<int32_t> size)
|
||||
{
|
||||
// The size can not be change on android platform
|
||||
}
|
||||
|
||||
void guiInterface::ChangePos(Vector2D<int32_t> size)
|
||||
{
|
||||
// The position can not be change on Android platform
|
||||
}
|
||||
|
||||
void guiInterface::GetAbsPos(Vector2D<int32_t>& size)
|
||||
{
|
||||
size.x = 0;
|
||||
size.y = 0;
|
||||
}
|
||||
|
0
Sources/libewol/ewol/base/gui.Example.cpp
Normal file
0
Sources/libewol/ewol/base/gui.Example.cpp
Normal file
0
Sources/libewol/ewol/base/gui.MacOs.cpp
Normal file
0
Sources/libewol/ewol/base/gui.MacOs.cpp
Normal file
@ -33,13 +33,12 @@
|
||||
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/Texture/TextureBMP.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/threadMsg.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
#include <ewol/openGl.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
int64_t ewol::GetTime(void)
|
||||
int64_t guiInterface::GetTime(void)
|
||||
{
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
@ -54,40 +53,29 @@ int32_t offsetMoveClickedDouble = 20000;
|
||||
|
||||
bool inputIsPressed[20];
|
||||
|
||||
static guiSystem::event::specialKey_ts guiKeyBoardMode;
|
||||
static eSystem::specialKey_ts guiKeyBoardMode;
|
||||
|
||||
|
||||
void ewol::SetTitle(etk::UString title)
|
||||
/**
|
||||
* @brief Set the new title of the windows
|
||||
* @param title New desired title
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::SetTitle(etk::UString& title)
|
||||
{
|
||||
// TODO ...
|
||||
}
|
||||
|
||||
|
||||
static etk::Vector<etk::UString*> listArgs;
|
||||
|
||||
int32_t ewol::CmdLineNb(void)
|
||||
{
|
||||
return listArgs.Size();
|
||||
}
|
||||
|
||||
etk::UString ewol::CmdLineGet(int32_t id)
|
||||
{
|
||||
if (id<0 && id>=listArgs.Size()) {
|
||||
return "";
|
||||
}
|
||||
if (NULL == listArgs[id]) {
|
||||
return "";
|
||||
}
|
||||
return *listArgs[id];
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "guiAbstraction"
|
||||
#define __class__ "guiInterface"
|
||||
|
||||
bool m_run = true;
|
||||
|
||||
void guiAbstraction::Stop(void)
|
||||
/**
|
||||
* @brief Stop the current program
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::Stop(void)
|
||||
{
|
||||
m_run = false;
|
||||
// To exit program ...
|
||||
@ -95,92 +83,90 @@ void guiAbstraction::Stop(void)
|
||||
}
|
||||
|
||||
|
||||
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
|
||||
/**
|
||||
* @brief Display the virtal keyboard (for touch system only)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::KeyboardShow(void)
|
||||
{
|
||||
// nothing to do : No keyboard on computer ...
|
||||
}
|
||||
|
||||
void guiAbstraction::KeyboardHide(void)
|
||||
|
||||
/**
|
||||
* @brief Hide the virtal keyboard (for touch system only)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::KeyboardHide(void)
|
||||
{
|
||||
// nothing to do : No keyboard on computer ...
|
||||
}
|
||||
|
||||
|
||||
|
||||
void guiAbstraction::ChangeSize(int32_t w, int32_t h)
|
||||
/**
|
||||
* @brief Change the current Windows size
|
||||
* @param size The requested size
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ChangeSize(Vector2D<int32_t> size)
|
||||
{
|
||||
|
||||
// TODO : Later
|
||||
}
|
||||
|
||||
void guiAbstraction::ChangePos(int32_t x, int32_t y)
|
||||
/**
|
||||
* @brief Change the current Windows position
|
||||
* @param pos The position where the winsdows might be placed.
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ChangePos(Vector2D<int32_t> pos)
|
||||
{
|
||||
|
||||
// TODO : Later
|
||||
}
|
||||
|
||||
void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y)
|
||||
/**
|
||||
* @brief Get the current Windows position
|
||||
* @param pos The position where the winsdows is.
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::GetAbsPos(Vector2D<int32_t>& pos)
|
||||
{
|
||||
|
||||
// TODO : Later
|
||||
}
|
||||
|
||||
bool guiAbstraction::IsPressedInput(int32_t inputID)
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ClipBoard AREA :
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
bool l_clipBoardOwnerStd = false;
|
||||
/**
|
||||
* @brief Inform the Gui that we want to have a copy of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
if( NB_MAX_INPUT > inputID
|
||||
&& 0 <= inputID)
|
||||
// this is to force the local system to think we have the buffer
|
||||
// TODO : Remove this 2 Line when code will be writen
|
||||
l_clipBoardOwnerStd = true;
|
||||
switch (clipboardID)
|
||||
{
|
||||
return inputIsPressed[inputID];
|
||||
} else {
|
||||
EWOL_WARNING("Wrong input ID : " << inputID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ClipBoard AREA :
|
||||
|
||||
etk::UString l_clipBoardStd("");
|
||||
etk::UString l_clipBoardPrimary("");
|
||||
|
||||
void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() );
|
||||
#endif
|
||||
newData = "";
|
||||
switch (mode)
|
||||
{
|
||||
case CLIPBOARD_MODE_PRIMARY:
|
||||
// get our own buffer ...
|
||||
newData = l_clipBoardPrimary;
|
||||
case ewol::clipBoard::CLIPBOARD_SELECTION:
|
||||
// NOTE : Windows does not support the middle button the we do it internaly
|
||||
// just transmit an event , we have the data in the system
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
break;
|
||||
case CLIPBOARD_MODE_STD:
|
||||
// get our own buffer ...
|
||||
newData = l_clipBoardStd;
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Request an unknow ClipBoard ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("Request set of a clipboard : " << mode << " size=" << newData.Size() );
|
||||
#endif
|
||||
switch (mode)
|
||||
{
|
||||
case CLIPBOARD_MODE_PRIMARY:
|
||||
if (newData.Size() > 0) {
|
||||
// copy it ...
|
||||
l_clipBoardPrimary = newData;
|
||||
}
|
||||
break;
|
||||
case CLIPBOARD_MODE_STD:
|
||||
if (newData.Size() > 0) {
|
||||
// copy it ...
|
||||
l_clipBoardStd = newData;
|
||||
case ewol::clipBoard::CLIPBOARD_STD:
|
||||
if (false == l_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
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -189,8 +175,32 @@ void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
|
||||
}
|
||||
}
|
||||
|
||||
// might be declared by the application ....
|
||||
etk::File APP_Icon(void);
|
||||
/**
|
||||
* @brief Inform the Gui that we are the new owner of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
switch (clipboardID)
|
||||
{
|
||||
case ewol::clipBoard::CLIPBOARD_SELECTION:
|
||||
// NOTE : nothing to do : Windows deas ot supported Middle button
|
||||
break;
|
||||
case ewol::clipBoard::CLIPBOARD_STD:
|
||||
// Request the clipBoard :
|
||||
if (false == l_clipBoardOwnerStd) {
|
||||
// TODO : Inform the OS that we have the current buffer of copy ...
|
||||
l_clipBoardOwnerStd = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Request an unknow ClipBoard ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
@ -200,10 +210,11 @@ etk::File APP_Icon(void);
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
|
||||
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);
|
||||
int plop(void);
|
||||
int Windows_Run(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ewol::CmdLine::Clean();
|
||||
for( int32_t i=1 ; i<argc; i++) {
|
||||
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
|
||||
if (0==strncmp("-l0", argv[i], 256)) {
|
||||
@ -221,10 +232,8 @@ int main(int argc, char *argv[])
|
||||
} else if (0==strncmp("-l6", argv[i], 256)) {
|
||||
GeneralDebugSetLevel(etk::LOG_LEVEL_VERBOSE);
|
||||
} else {
|
||||
etk::UString* tmpString = new etk::UString(argv[i]);
|
||||
if (NULL != tmpString) {
|
||||
listArgs.PushBack(tmpString);
|
||||
}
|
||||
etk::UString tmpString(argv[i]);
|
||||
ewol::CmdLine::Add(tmpString);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,31 +252,25 @@ int main(int argc, char *argv[])
|
||||
// start X11 thread ...
|
||||
// TODO : ...
|
||||
//start the basic thread :
|
||||
guiSystem::Init();
|
||||
eSystem::Init();
|
||||
// get the icon file :
|
||||
etk::File myIcon = APP_Icon();
|
||||
//SetIcon(myIcon);
|
||||
|
||||
// Run ...
|
||||
plop();
|
||||
Windows_Run();
|
||||
// close X11 :
|
||||
guiAbstraction::Stop();
|
||||
guiInterface::Stop();
|
||||
// uninit ALL :
|
||||
guiSystem::UnInit();
|
||||
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
|
||||
if (NULL != listArgs[iii]) {
|
||||
delete listArgs[iii];
|
||||
listArgs[iii] = NULL;
|
||||
}
|
||||
}
|
||||
listArgs.Clear();
|
||||
eSystem::UnInit();
|
||||
ewol::CmdLine::Clean();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// WinMain
|
||||
|
||||
int plop(void)
|
||||
int Windows_Run(void)
|
||||
{
|
||||
HINSTANCE hInstance = 0;
|
||||
WNDCLASS wc;
|
||||
@ -295,7 +298,7 @@ int plop(void)
|
||||
0, 0, 800, 600,
|
||||
NULL, NULL, hInstance, NULL );
|
||||
|
||||
guiSystem::event::Resize(800, 600-25);
|
||||
eSystem::Resize(800, 600-25);
|
||||
|
||||
// enable OpenGL for the window
|
||||
EnableOpenGL( hWnd, &hDC, &hRC );
|
||||
@ -314,7 +317,7 @@ int plop(void)
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
} else {
|
||||
(void)guiSystem::Draw(true);
|
||||
(void)eSystem::Draw(true);
|
||||
SwapBuffers( hDC );
|
||||
}
|
||||
}
|
||||
@ -374,7 +377,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
WINDOWPOS* tmpVal = (WINDOWPOS*)lParam;
|
||||
if (NULL != tmpVal) {
|
||||
//EWOL_DEBUG("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")");
|
||||
guiSystem::event::Resize(tmpVal->cx-8, tmpVal->cy - 28);
|
||||
eSystem::Resize(tmpVal->cx-8, tmpVal->cy - 28);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -486,17 +489,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
EWOL_DEBUG("kjhkjhkjhkjhkj = " << wParam);
|
||||
if (tmpChar == 0) {
|
||||
//EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) );
|
||||
guiSystem::event::keyboardMove_ts specialEvent;
|
||||
eSystem::keyboardMove_ts specialEvent;
|
||||
specialEvent.special = guiKeyBoardMode;
|
||||
specialEvent.move = keyInput;
|
||||
specialEvent.isDown = buttonIsDown;
|
||||
guiSystem::event::SetKeyboardMove(specialEvent);
|
||||
eSystem::SetKeyboardMove(specialEvent);
|
||||
} else {
|
||||
guiSystem::event::keyboardKey_ts specialEvent;
|
||||
eSystem::keyboardKey_ts specialEvent;
|
||||
specialEvent.special = guiKeyBoardMode;
|
||||
specialEvent.myChar = tmpChar;
|
||||
specialEvent.isDown = buttonIsDown;
|
||||
guiSystem::event::SetKeyboard(specialEvent);
|
||||
eSystem::SetKeyboard(specialEvent);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -510,7 +513,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
inputIsPressed[mouseButtonId] = buttonIsDown;
|
||||
guiSystem::event::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y);
|
||||
return 0;
|
||||
|
||||
case WM_MBUTTONUP:
|
||||
@ -520,7 +523,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
inputIsPressed[mouseButtonId] = buttonIsDown;
|
||||
guiSystem::event::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y);
|
||||
return 0;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
@ -530,7 +533,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
inputIsPressed[mouseButtonId] = buttonIsDown;
|
||||
guiSystem::event::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y);
|
||||
return 0;
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
@ -543,8 +546,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
guiSystem::event::SetMouseState(mouseButtonId, true, (float)pos.x, (float)pos.y);
|
||||
guiSystem::event::SetMouseState(mouseButtonId, false, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseState(mouseButtonId, true, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseState(mouseButtonId, false, (float)pos.x, (float)pos.y);
|
||||
return 0;
|
||||
|
||||
case WM_MOUSEHOVER:
|
||||
@ -554,12 +557,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
for (int32_t iii=0; iii<NB_MAX_INPUT ; iii++) {
|
||||
if (true == inputIsPressed[iii]) {
|
||||
EWOL_VERBOSE("Windows event: bt=" << iii << " " << message << " = \"WM_MOUSEMOVE\" " << pos );
|
||||
guiSystem::event::SetMouseMotion(iii, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseMotion(iii, (float)pos.x, (float)pos.y);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE("Windows event: bt=" << 0 << " " << message << " = \"WM_MOUSEMOVE\" " << pos );
|
||||
guiSystem::event::SetMouseMotion(0, (float)pos.x, (float)pos.y);
|
||||
eSystem::SetMouseMotion(0, (float)pos.x, (float)pos.y);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
@ -570,7 +573,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
// Enable OpenGL
|
||||
|
||||
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
@ -32,8 +32,7 @@
|
||||
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/Texture/TextureBMP.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/threadMsg.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -50,7 +49,7 @@
|
||||
|
||||
//#define DEBUG_X11_EVENT
|
||||
|
||||
int64_t ewol::GetTime(void)
|
||||
int64_t guiInterface::GetTime(void)
|
||||
{
|
||||
struct timespec now;
|
||||
int ret = clock_gettime(CLOCK_REALTIME, &now);
|
||||
@ -64,7 +63,7 @@ int64_t ewol::GetTime(void)
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "guiAbstraction"
|
||||
#define __class__ "guiInterface"
|
||||
|
||||
// attributes for a single buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer
|
||||
static int attrListSgl[] = {
|
||||
@ -87,7 +86,7 @@ static int attrListDbl[] = {
|
||||
None
|
||||
};
|
||||
|
||||
static guiSystem::event::specialKey_ts guiKeyBoardMode;
|
||||
static eSystem::specialKey_ts guiKeyBoardMode;
|
||||
|
||||
|
||||
extern "C" {
|
||||
@ -120,21 +119,14 @@ int32_t m_cursorEventY = 0;
|
||||
XVisualInfo * m_visual = NULL;
|
||||
bool m_doubleBuffered = 0;
|
||||
bool m_run = 0;
|
||||
extern ewol::Windows* gui_uniqueWindows;
|
||||
extern float gui_width;
|
||||
extern float gui_height;
|
||||
|
||||
int32_t separateClickTime = 300000;
|
||||
int32_t offsetMoveClicked = 10000;
|
||||
int32_t offsetMoveClickedDouble = 20000;
|
||||
|
||||
bool l_titleChange = false;
|
||||
etk::UString l_title = "Ewol";
|
||||
|
||||
bool inputIsPressed[20];
|
||||
|
||||
// internal copy of the clipBoard ...
|
||||
static ewol::simpleMsg::simpleMsg_ts l_clipboardMessage; /// message to prevent the other thread that we have receive the requested data
|
||||
static bool l_clipBoardRequestPrimary = false; // if false : request the copy/past buffer, if true : request current selection
|
||||
static bool l_clipBoardOwnerPrimary = false; // we are the owner of the current selection
|
||||
static bool l_clipBoardOwnerStd = false; // we are the owner of the current copy buffer
|
||||
@ -148,10 +140,6 @@ static Atom XAtomeEWOL = 0;
|
||||
static Atom XAtomeDeleteWindows = 0;
|
||||
|
||||
|
||||
static void X11_ChangeSize(int32_t w, int32_t h);
|
||||
static void X11_ChangePos(int32_t x, int32_t y);
|
||||
static void X11_GetAbsPos(int32_t & x, int32_t & y);
|
||||
|
||||
bool CreateX11Context(void)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
@ -216,7 +204,7 @@ bool CreateX11Context(void)
|
||||
// Create the window
|
||||
int32_t tmp_width = DisplayWidth(m_display, DefaultScreen(m_display))/2;
|
||||
int32_t tmp_height = DisplayHeight(m_display, DefaultScreen(m_display))/2;
|
||||
EWOL_NativeResize(tmp_width, tmp_height);
|
||||
eSystem::Resize(tmp_width, tmp_height);
|
||||
x=tmp_width/2;
|
||||
y=tmp_height/4;
|
||||
|
||||
@ -268,12 +256,19 @@ bool CreateX11Context(void)
|
||||
XSetWMProtocols(m_display, WindowHandle, &m_delAtom, 1);
|
||||
}
|
||||
|
||||
X11_ChangeSize(400, 300);
|
||||
Vector2D<int32_t> tmpSize(400, 300);
|
||||
guiInterface::ChangeSize(tmpSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void local_SetTitle(etk::UString title)
|
||||
|
||||
/**
|
||||
* @brief Set the new title of the windows
|
||||
* @param title New desired title
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::SetTitle(etk::UString& title)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: Set Title (START)");
|
||||
@ -292,19 +287,6 @@ static void local_SetTitle(etk::UString title)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// the set title is abstract, because otherwise it generate latency in the display ...
|
||||
// TODO : We might generate system like this for evry other requested
|
||||
void ewol::SetTitle(etk::UString title)
|
||||
{
|
||||
// set new title and inform that it change
|
||||
if (true == l_titleChange) {
|
||||
usleep(30);
|
||||
}
|
||||
l_title = title;
|
||||
l_titleChange = true;
|
||||
}
|
||||
|
||||
/* this variable will contain the ID of the newly created pixmap. */
|
||||
Pixmap icon_pixmap;
|
||||
|
||||
@ -446,7 +428,6 @@ void X11_Init(void)
|
||||
l_clipBoardRequestPrimary = false;
|
||||
l_clipBoardOwnerPrimary = false;
|
||||
l_clipBoardOwnerStd = false;
|
||||
ewol::simpleMsg::Init(l_clipboardMessage);
|
||||
// reset the Atom properties ...
|
||||
XAtomeSelection = XInternAtom(m_display, "PRIMARY", 0);
|
||||
XAtomeClipBoard = XInternAtom(m_display, "CLIPBOARD", 0);
|
||||
@ -473,11 +454,6 @@ void X11_Run(void)
|
||||
EWOL_INFO("X11:Event");
|
||||
#endif
|
||||
XNextEvent(m_display, &event);
|
||||
// change title if needed
|
||||
if (l_titleChange) {
|
||||
local_SetTitle(l_title);
|
||||
l_titleChange = false;
|
||||
}
|
||||
switch (event.type)
|
||||
{
|
||||
case ClientMessage:
|
||||
@ -487,9 +463,7 @@ void X11_Run(void)
|
||||
#endif
|
||||
if(XAtomeDeleteWindows == (int64_t)event.xclient.data.l[0]) {
|
||||
EWOL_INFO(" ==> Kill Requested ...");
|
||||
if (NULL != gui_uniqueWindows) {
|
||||
gui_uniqueWindows->SysOnKill();
|
||||
}
|
||||
eSystem::OnKill();
|
||||
m_run = false;
|
||||
}
|
||||
}
|
||||
@ -551,12 +525,12 @@ void X11_Run(void)
|
||||
etk::UString tmpppp((char*)buf);
|
||||
ewol::clipBoard::SetSystem(ewol::clipBoard::CLIPBOARD_SELECTION, tmpppp);
|
||||
// just transmit an event , we have the data in the system
|
||||
guiSystem::event::ClipBoardArrive(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
eSystem::ClipBoardArrive(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
} else {
|
||||
etk::UString tmpppp((char*)buf);
|
||||
ewol::clipBoard::SetSystem(ewol::clipBoard::CLIPBOARD_STD, tmpppp);
|
||||
// just transmit an event , we have the data in the system
|
||||
guiSystem::event::ClipBoardArrive(ewol::clipBoard::CLIPBOARD_STD);
|
||||
eSystem::ClipBoardArrive(ewol::clipBoard::CLIPBOARD_STD);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -699,7 +673,7 @@ void X11_Run(void)
|
||||
#endif
|
||||
m_originX = event.xconfigure.x;
|
||||
m_originY = event.xconfigure.y;
|
||||
guiSystem::event::Resize(event.xconfigure.width, event.xconfigure.height);
|
||||
eSystem::Resize(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case ButtonPress:
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
@ -710,7 +684,7 @@ void X11_Run(void)
|
||||
if (event.xbutton.button < NB_MAX_INPUT) {
|
||||
inputIsPressed[event.xbutton.button] = true;
|
||||
}
|
||||
guiSystem::event::SetMouseState(event.xbutton.button, true, (float)event.xbutton.x, (float)event.xbutton.y);
|
||||
eSystem::SetMouseState(event.xbutton.button, true, (float)event.xbutton.x, (float)event.xbutton.y);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
@ -721,7 +695,7 @@ void X11_Run(void)
|
||||
if (event.xbutton.button < NB_MAX_INPUT) {
|
||||
inputIsPressed[event.xbutton.button] = false;
|
||||
}
|
||||
guiSystem::event::SetMouseState(event.xbutton.button, false, (float)event.xbutton.x, (float)event.xbutton.y);
|
||||
eSystem::SetMouseState(event.xbutton.button, false, (float)event.xbutton.x, (float)event.xbutton.y);
|
||||
break;
|
||||
case EnterNotify:
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
@ -752,13 +726,13 @@ void X11_Run(void)
|
||||
for (int32_t iii=0; iii<NB_MAX_INPUT ; iii++) {
|
||||
if (true == inputIsPressed[iii]) {
|
||||
EWOL_VERBOSE("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << (float)event.xmotion.x << "," << (float)event.xmotion.y << ")");
|
||||
guiSystem::event::SetMouseMotion(iii, (float)event.xmotion.x, (float)event.xmotion.y);
|
||||
eSystem::SetMouseMotion(iii, (float)event.xmotion.x, (float)event.xmotion.y);
|
||||
findOne = true;
|
||||
}
|
||||
}
|
||||
if (false == findOne) {
|
||||
EWOL_VERBOSE("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << (float)event.xmotion.x << "," << (float)event.xmotion.y << ")");
|
||||
guiSystem::event::SetMouseMotion(0, (float)event.xmotion.x, (float)event.xmotion.y);
|
||||
eSystem::SetMouseMotion(0, (float)event.xmotion.x, (float)event.xmotion.y);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -883,7 +857,7 @@ void X11_Run(void)
|
||||
case 91: // Suppr on keypad
|
||||
find = false;
|
||||
{
|
||||
guiSystem::event::keyboardKey_ts specialEvent;
|
||||
eSystem::keyboardKey_ts specialEvent;
|
||||
specialEvent.special = guiKeyBoardMode;
|
||||
specialEvent.myChar = 0x0000007F;
|
||||
if(event.type == KeyPress) {
|
||||
@ -891,13 +865,13 @@ void X11_Run(void)
|
||||
} else {
|
||||
specialEvent.isDown = false;
|
||||
}
|
||||
guiSystem::event::SetKeyboard(specialEvent);
|
||||
eSystem::SetKeyboard(specialEvent);
|
||||
}
|
||||
break;
|
||||
case 23: // special case for TAB
|
||||
find = false;
|
||||
{
|
||||
guiSystem::event::keyboardKey_ts specialEvent;
|
||||
eSystem::keyboardKey_ts specialEvent;
|
||||
specialEvent.special = guiKeyBoardMode;
|
||||
specialEvent.myChar = 0x00000009;
|
||||
if(event.type == KeyPress) {
|
||||
@ -905,7 +879,7 @@ void X11_Run(void)
|
||||
} else {
|
||||
specialEvent.isDown = false;
|
||||
}
|
||||
guiSystem::event::SetKeyboard(specialEvent);
|
||||
eSystem::SetKeyboard(specialEvent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -931,7 +905,7 @@ void X11_Run(void)
|
||||
}
|
||||
if (count>0) {
|
||||
// transform iun unicode
|
||||
guiSystem::event::keyboardKey_ts specialEvent;
|
||||
eSystem::keyboardKey_ts specialEvent;
|
||||
specialEvent.special = guiKeyBoardMode;
|
||||
unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], specialEvent.myChar);
|
||||
//EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue);
|
||||
@ -940,7 +914,7 @@ void X11_Run(void)
|
||||
} else {
|
||||
specialEvent.isDown = false;
|
||||
}
|
||||
guiSystem::event::SetKeyboard(specialEvent);
|
||||
eSystem::SetKeyboard(specialEvent);
|
||||
} else {
|
||||
EWOL_WARNING("Unknow event Key : " << event.xkey.keycode);
|
||||
}
|
||||
@ -949,7 +923,7 @@ void X11_Run(void)
|
||||
}
|
||||
if (true == find) {
|
||||
//EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) );
|
||||
guiSystem::event::keyboardMove_ts specialEvent;
|
||||
eSystem::keyboardMove_ts specialEvent;
|
||||
specialEvent.special = guiKeyBoardMode;
|
||||
if(event.type == KeyPress) {
|
||||
specialEvent.isDown = true;
|
||||
@ -957,7 +931,7 @@ void X11_Run(void)
|
||||
specialEvent.isDown = false;
|
||||
}
|
||||
specialEvent.move = keyInput;
|
||||
guiSystem::event::SetKeyboardMove(specialEvent);
|
||||
eSystem::SetKeyboardMove(specialEvent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -967,13 +941,13 @@ void X11_Run(void)
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11 event : MapNotify");
|
||||
#endif
|
||||
guiSystem::event::Show();
|
||||
eSystem::Show();
|
||||
break;
|
||||
case UnmapNotify:
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11 event : UnmapNotify");
|
||||
#endif
|
||||
guiSystem::event::Hide();
|
||||
eSystem::Hide();
|
||||
break;
|
||||
default:
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
@ -983,7 +957,7 @@ void X11_Run(void)
|
||||
}
|
||||
}
|
||||
if(true == m_run) {
|
||||
(void)guiSystem::Draw(false);
|
||||
(void)eSystem::Draw(false);
|
||||
if (m_doubleBuffered) {
|
||||
glXSwapBuffers(m_display, WindowHandle);
|
||||
}
|
||||
@ -994,38 +968,17 @@ void X11_Run(void)
|
||||
}
|
||||
};
|
||||
|
||||
void X11_ChangeSize(int32_t w, int32_t h)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: X11_ChangeSize");
|
||||
#endif
|
||||
XResizeWindow(m_display, WindowHandle, w, h);
|
||||
};
|
||||
|
||||
void X11_ChangePos(int32_t x, int32_t y)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: X11_ChangePos");
|
||||
#endif
|
||||
XMoveWindow(m_display, WindowHandle, x, y);
|
||||
};
|
||||
// -------------------------------------------------------------------------
|
||||
// ClipBoard AREA :
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void X11_GetAbsPos(int32_t & x, int32_t & y)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: X11_GetAbsPos");
|
||||
#endif
|
||||
int tmp;
|
||||
unsigned int tmp2;
|
||||
Window fromroot, tmpwin;
|
||||
XQueryPointer(m_display, WindowHandle, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ClipBoard AREA :
|
||||
|
||||
void guiAbstraction::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
/**
|
||||
* @brief Inform the Gui that we want to have a copy of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
switch (clipboardID)
|
||||
{
|
||||
@ -1041,7 +994,7 @@ void guiAbstraction::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID
|
||||
CurrentTime);
|
||||
} else {
|
||||
// just transmit an event , we have the data in the system
|
||||
guiSystem::event::ClipBoardArrive(clipboardID);
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
}
|
||||
break;
|
||||
case ewol::clipBoard::CLIPBOARD_STD:
|
||||
@ -1056,7 +1009,7 @@ void guiAbstraction::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID
|
||||
CurrentTime);
|
||||
} else {
|
||||
// just transmit an event , we have the data in the system
|
||||
guiSystem::event::ClipBoardArrive(clipboardID);
|
||||
eSystem::ClipBoardArrive(clipboardID);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -1065,7 +1018,12 @@ void guiAbstraction::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID
|
||||
}
|
||||
}
|
||||
|
||||
void guiAbstraction::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
/**
|
||||
* @brief Inform the Gui that we are the new owner of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
switch (clipboardID)
|
||||
{
|
||||
@ -1092,10 +1050,15 @@ void guiAbstraction::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "guiAbstraction"
|
||||
#define __class__ "guiInterface"
|
||||
|
||||
|
||||
void guiAbstraction::Stop(void)
|
||||
/**
|
||||
* @brief Stop the current program
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::Stop(void)
|
||||
{
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: Stop");
|
||||
@ -1103,70 +1066,81 @@ void guiAbstraction::Stop(void)
|
||||
m_run = false;
|
||||
}
|
||||
|
||||
|
||||
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
|
||||
{
|
||||
// nothing to do : No keyboard on computer ...
|
||||
}
|
||||
|
||||
void guiAbstraction::KeyboardHide(void)
|
||||
/**
|
||||
* @brief Display the virtal keyboard (for touch system only)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::KeyboardShow(void)
|
||||
{
|
||||
// nothing to do : No keyboard on computer ...
|
||||
}
|
||||
|
||||
|
||||
|
||||
void guiAbstraction::ChangeSize(int32_t w, int32_t h)
|
||||
/**
|
||||
* @brief Hide the virtal keyboard (for touch system only)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::KeyboardHide(void)
|
||||
{
|
||||
X11_ChangeSize(w, h);
|
||||
// nothing to do : No keyboard on computer ...
|
||||
}
|
||||
|
||||
void guiAbstraction::ChangePos(int32_t x, int32_t y)
|
||||
|
||||
/**
|
||||
* @brief Change the current Windows size
|
||||
* @param size The requested size
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ChangeSize(Vector2D<int32_t> size)
|
||||
{
|
||||
X11_ChangePos(x, y);
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: ChangeSize");
|
||||
#endif
|
||||
XResizeWindow(m_display, WindowHandle, size.x, size.y);
|
||||
}
|
||||
|
||||
void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y)
|
||||
|
||||
/**
|
||||
* @brief Change the current Windows position
|
||||
* @param pos The position where the winsdows might be placed.
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::ChangePos(Vector2D<int32_t> pos)
|
||||
{
|
||||
X11_GetAbsPos(x, y);
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: ChangePos");
|
||||
#endif
|
||||
XMoveWindow(m_display, WindowHandle, pos.x, pos.y);
|
||||
}
|
||||
|
||||
bool guiAbstraction::IsPressedInput(int32_t inputID)
|
||||
|
||||
/**
|
||||
* @brief Get the current Windows position
|
||||
* @param pos The position where the winsdows is.
|
||||
* @return ---
|
||||
*/
|
||||
void guiInterface::GetAbsPos(Vector2D<int32_t>& pos)
|
||||
{
|
||||
if( NB_MAX_INPUT > inputID
|
||||
&& 0 <= inputID)
|
||||
{
|
||||
return inputIsPressed[inputID];
|
||||
} else {
|
||||
EWOL_WARNING("Wrong input ID : " << inputID);
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_X11_EVENT
|
||||
EWOL_INFO("X11: GetAbsPos");
|
||||
#endif
|
||||
int tmp;
|
||||
unsigned int tmp2;
|
||||
Window fromroot, tmpwin;
|
||||
XQueryPointer(m_display, WindowHandle, &fromroot, &tmpwin, &pos.x, &pos.y, &tmp, &tmp, &tmp2);
|
||||
}
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
static etk::Vector<etk::UString*> listArgs;
|
||||
|
||||
int32_t ewol::CmdLineNb(void)
|
||||
{
|
||||
return listArgs.Size();
|
||||
}
|
||||
|
||||
etk::UString ewol::CmdLineGet(int32_t id)
|
||||
{
|
||||
if (id<0 && id>=listArgs.Size()) {
|
||||
return "";
|
||||
}
|
||||
if (NULL == listArgs[id]) {
|
||||
return "";
|
||||
}
|
||||
return *listArgs[id];
|
||||
}
|
||||
// might be declared by the application ....
|
||||
etk::File APP_Icon(void);
|
||||
|
||||
/**
|
||||
* @brief Main of the program
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ewol::CmdLine::Clean();
|
||||
for( int32_t i=1 ; i<argc; i++) {
|
||||
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
|
||||
if (0==strncmp("-l0", argv[i], 256)) {
|
||||
@ -1184,10 +1158,8 @@ int main(int argc, char *argv[])
|
||||
} else if (0==strncmp("-l6", argv[i], 256)) {
|
||||
GeneralDebugSetLevel(etk::LOG_LEVEL_VERBOSE);
|
||||
} else {
|
||||
etk::UString* tmpString = new etk::UString(argv[i]);
|
||||
if (NULL != tmpString) {
|
||||
listArgs.PushBack(tmpString);
|
||||
}
|
||||
etk::UString tmpString(argv[i]);
|
||||
ewol::CmdLine::Add(tmpString);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1206,7 +1178,7 @@ int main(int argc, char *argv[])
|
||||
// start X11 thread ...
|
||||
X11_Init();
|
||||
//start the basic thread :
|
||||
guiSystem::Init();
|
||||
eSystem::Init();
|
||||
// get the icon file :
|
||||
etk::File myIcon = APP_Icon();
|
||||
SetIcon(myIcon);
|
||||
@ -1214,16 +1186,10 @@ int main(int argc, char *argv[])
|
||||
// Run ...
|
||||
X11_Run();
|
||||
// close X11 :
|
||||
guiAbstraction::Stop();
|
||||
guiInterface::Stop();
|
||||
// uninit ALL :
|
||||
guiSystem::UnInit();
|
||||
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
|
||||
if (NULL != listArgs[iii]) {
|
||||
delete listArgs[iii];
|
||||
listArgs[iii] = NULL;
|
||||
}
|
||||
}
|
||||
listArgs.Clear();
|
||||
eSystem::UnInit();
|
||||
ewol::CmdLine::Clean();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,347 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file gui.cpp
|
||||
* @brief Gui abstraction layer common part (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 01/02/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <ewol/Debug.h>
|
||||
#include <etk/UString.h>
|
||||
#include <ewol/EObject.h>
|
||||
#include <ewol/EObjectManager.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/base/gui.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/importgl.h>
|
||||
|
||||
ewol::Windows* gui_uniqueWindows = NULL;
|
||||
float gui_width = 320;
|
||||
float gui_height = 480;
|
||||
|
||||
|
||||
int32_t ewol::GetCurrentWidth(void)
|
||||
{
|
||||
return gui_width;
|
||||
}
|
||||
|
||||
int32_t ewol::GetCurrentHeight(void)
|
||||
{
|
||||
return gui_height;
|
||||
}
|
||||
|
||||
|
||||
void ewol::PopUpWidgetPush(ewol::Widget * tmpWidget)
|
||||
{
|
||||
if (NULL != gui_uniqueWindows && NULL != tmpWidget) {
|
||||
gui_uniqueWindows->PopUpWidgetPush(tmpWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateGuiSize(void)
|
||||
{
|
||||
if (NULL != gui_uniqueWindows) {
|
||||
gui_uniqueWindows->CalculateSize((float)gui_width, (float)gui_height);
|
||||
gui_uniqueWindows->SetOrigin(0.0, 0.0);
|
||||
}
|
||||
}
|
||||
void EWOL_NativeResize(int w, int h )
|
||||
{
|
||||
gui_width = w;
|
||||
gui_height = h;
|
||||
//EWOL_INFO("Resize w=" << w << " h=" << h);
|
||||
UpdateGuiSize();
|
||||
}
|
||||
|
||||
void EWOL_NativeRegenerateDisplay(void)
|
||||
{
|
||||
// Remove all widget that they are no more usefull (these who decided to destroy themself)
|
||||
ewol::EObjectManager::RemoveAllAutoRemove();
|
||||
|
||||
//EWOL_INFO("Resize w=" << w << " h=" << h);
|
||||
if (NULL != gui_uniqueWindows) {
|
||||
// Redraw all needed elements
|
||||
gui_uniqueWindows->OnRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
void guiAbstraction::ForceRedrawAll(void)
|
||||
{
|
||||
if (NULL != gui_uniqueWindows) {
|
||||
gui_uniqueWindows->CalculateSize((float)gui_width, (float)gui_height);
|
||||
}
|
||||
}
|
||||
|
||||
void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newWindows)
|
||||
{
|
||||
gui_uniqueWindows = newWindows;
|
||||
ForceRedrawAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void guiAbstraction::SendKeyboardEvent(bool isDown, uniChar_t keyInput)
|
||||
{
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(true == isDown) {
|
||||
EWOL_VERBOSE("GUI PRESSED : \"" << keyInput << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput);
|
||||
} else {
|
||||
EWOL_VERBOSE("GUI Release : \"" << keyInput << "\"");
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput)
|
||||
{
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(true == isDown) {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, keyInput);
|
||||
} else {
|
||||
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, keyInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void guiAbstraction::SendClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
|
||||
{
|
||||
if (NULL != gui_uniqueWindows) {
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (tmpWidget != NULL) {
|
||||
tmpWidget->OnEventClipboard(clipboardID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int64_t startTime = -1;
|
||||
static int64_t nbCallTime = 0;
|
||||
static int64_t nbDisplayTime = 0;
|
||||
static int64_t min = 99999999999999LL;
|
||||
static int64_t avg = 0;
|
||||
static int64_t max = 0;
|
||||
static int64_t min2 = 99999999999999LL;
|
||||
static int64_t avg2 = 0;
|
||||
static int64_t max2 = 0;
|
||||
// display every second ...
|
||||
#define DISPLAY_PERIODE_US (1000000)
|
||||
|
||||
|
||||
static float gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
|
||||
static float gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
|
||||
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
|
||||
|
||||
void EWOL_GenericDraw(bool everyTime)
|
||||
{
|
||||
|
||||
//EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")");
|
||||
if(NULL == gui_uniqueWindows) {
|
||||
// set the size of the open GL system
|
||||
glViewport(0,0,gui_width,gui_height);
|
||||
|
||||
// Clear the screen with transparency ...
|
||||
glClearColor(0.0,0.0,0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//glOrtho(0., width, 0., -height, 1., 20.);
|
||||
glOrthoEwol(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
//glTranslatef(0, -height/2, -5);
|
||||
glTranslatef(-gui_width/2, -gui_height/2, -1.0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
|
||||
//LOGI("engine_draw_frame (%d,%d)",width,height);
|
||||
|
||||
glColor4f(0.0, 1.0, 1.0, 1.0);
|
||||
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices5 );
|
||||
glDrawArrays( GL_TRIANGLES, 0, 6);
|
||||
static int vallllll = 0;
|
||||
static float transparency = 0.0;
|
||||
if (vallllll <= 1) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(1.0, 0.0, 0.0, 1.0);
|
||||
} else {
|
||||
glColor4f(1.0, 0.0, 0.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 2) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(1.0, 1.0, 0.0, 1.0);
|
||||
} else {
|
||||
glColor4f(1.0, 1.0, 0.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 3) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(0.0, 1.0, 0.0, 1.0);
|
||||
} else {
|
||||
glColor4f(0.0, 1.0, 0.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 4) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(0.0, 1.0, 1.0, 1.0);
|
||||
} else {
|
||||
glColor4f(0.0, 1.0, 1.0, transparency);
|
||||
}
|
||||
} else if (vallllll <= 5) {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll++;
|
||||
transparency = 0.0;
|
||||
glColor4f(0.0, 0.0, 1.0, 1.0);
|
||||
} else {
|
||||
glColor4f(0.0, 0.0, 1.0, transparency);
|
||||
}
|
||||
} else {
|
||||
transparency +=0.025;
|
||||
if (transparency >= 1.0) {
|
||||
vallllll = 0;
|
||||
transparency = 0.0;
|
||||
glColor4f(1.0, 0.0, 1.0, 1.0);
|
||||
} else {
|
||||
glColor4f(1.0, 0.0, 1.0, transparency);
|
||||
}
|
||||
}
|
||||
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices );
|
||||
glDrawArrays( GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
} else {
|
||||
bool display = false;
|
||||
nbCallTime++;
|
||||
if (startTime<0) {
|
||||
startTime = ewol::GetTime();
|
||||
}
|
||||
int64_t currentTime = ewol::GetTime();
|
||||
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
|
||||
if ( (currentTime - startTime) > DISPLAY_PERIODE_US) {
|
||||
display = true;
|
||||
}
|
||||
int64_t currentTime3 = ewol::GetTime();
|
||||
// check if the regenerate is needed ...
|
||||
if( true == ewol::widgetManager::IsDrawingNeeded()
|
||||
|| true == everyTime) {
|
||||
ewol::texture::UpdateContext();
|
||||
nbDisplayTime++;
|
||||
gui_uniqueWindows->SysDraw();
|
||||
}
|
||||
// send Message that we just finished a display ...
|
||||
//EWOL_ThreadEventHasJustDisplay();
|
||||
int64_t currentTime2 = ewol::GetTime();
|
||||
int64_t processTimeLocal = (currentTime2 - currentTime);
|
||||
min = etk_min(min, processTimeLocal);
|
||||
max = etk_max(max, processTimeLocal);
|
||||
avg += processTimeLocal;
|
||||
processTimeLocal = (currentTime2 - currentTime3);
|
||||
min2 = etk_min(min2, processTimeLocal);
|
||||
max2 = etk_max(max2, processTimeLocal);
|
||||
avg2 += processTimeLocal;
|
||||
if (true == display) {
|
||||
EWOL_DEBUG("display property : " << nbDisplayTime << "/" << nbCallTime << "fps");
|
||||
EWOL_DEBUG("timeToProcess1 : " << (float)((float)min / 1000.0) << "ms "
|
||||
<< (float)((float)avg/(float)nbDisplayTime / 1000.0) << "ms "
|
||||
<< (float)((float)max / 1000.0) << "ms ");
|
||||
EWOL_DEBUG("timeToProcess2 : " << (float)((float)min2 / 1000.0) << "ms "
|
||||
<< (float)((float)avg2/(float)nbDisplayTime / 1000.0) << "ms "
|
||||
<< (float)((float)max2 / 1000.0) << "ms ");
|
||||
max2 = 0;
|
||||
max = 0;
|
||||
min = 99999999999999LL;
|
||||
min2 = 99999999999999LL;
|
||||
avg=0;
|
||||
avg2=0;
|
||||
|
||||
nbCallTime = 0;
|
||||
nbDisplayTime = 0;
|
||||
startTime = -1;
|
||||
}
|
||||
}
|
||||
glFlush();
|
||||
}
|
||||
|
||||
void EWOL_NativeGLDestroy(void)
|
||||
{
|
||||
ewol::texture::UpdateContextIsDestroy();
|
||||
}
|
||||
|
||||
|
||||
#include <ewol/importgl.h>
|
||||
|
||||
|
||||
void glOrthoEwol(GLfloat left,
|
||||
GLfloat right,
|
||||
GLfloat bottom,
|
||||
GLfloat top,
|
||||
GLfloat nearVal,
|
||||
GLfloat farVal)
|
||||
{
|
||||
GLfloat myMatrix[4*4];
|
||||
int iii;
|
||||
for(iii=0; iii<4*4 ; iii++) {
|
||||
myMatrix[iii] = 0;
|
||||
}
|
||||
myMatrix[0] = 2.0 / (right - left);
|
||||
myMatrix[5] = 2.0 / (top - bottom);
|
||||
myMatrix[10] = -2.0 / (farVal - nearVal);
|
||||
#if 1
|
||||
myMatrix[3] = -1*(right + left) / (right - left);
|
||||
myMatrix[7] = -1*(top + bottom) / (top - bottom);
|
||||
myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
|
||||
#else
|
||||
// test if matrix is not corectly instanciate ...
|
||||
myMatrix[12] = -1*(right + left) / (right - left);
|
||||
myMatrix[13] = -1*(top + bottom) / (top - bottom);
|
||||
myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal);
|
||||
#endif
|
||||
myMatrix[15] = 1;
|
||||
|
||||
glLoadMatrixf(myMatrix);
|
||||
|
||||
|
||||
}
|
@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GUI_ABSTRACTION_H__
|
||||
#define __GUI_ABSTRACTION_H__
|
||||
#ifndef __GUI_INTERFACE_H__
|
||||
#define __GUI_INTERFACE_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <etk/UString.h>
|
||||
@ -32,36 +32,76 @@
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/ClipBoard.h>
|
||||
|
||||
void EWOL_NativeRender(void);
|
||||
void EWOL_NativeResize(int w, int h );
|
||||
void EWOL_GenericDraw(bool everyTime);
|
||||
void EWOL_NativeGLDestroy(void);
|
||||
|
||||
void UpdateGuiSize(void);
|
||||
|
||||
namespace guiAbstraction
|
||||
namespace guiInterface
|
||||
{
|
||||
/**
|
||||
* @brief Get the curent time in micro-second
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
int64_t GetTime(void);
|
||||
/**
|
||||
* @brief Stop the current program
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void Stop(void);
|
||||
void SetDisplayOnWindows(ewol::Windows * newOne);
|
||||
void ChangeSize(int32_t w, int32_t h);
|
||||
void ChangePos(int32_t x, int32_t y);
|
||||
void GetAbsPos(int32_t & x, int32_t & y);
|
||||
bool IsPressedInput(int32_t inputID);
|
||||
void KeyboardShow(ewol::keyboardMode_te mode);
|
||||
/**
|
||||
* @brief Change the current Windows size
|
||||
* @param size The requested size
|
||||
* @return ---
|
||||
*/
|
||||
void ChangeSize(Vector2D<int32_t> size);
|
||||
/**
|
||||
* @brief Change the current Windows position
|
||||
* @param pos The position where the winsdows might be placed.
|
||||
* @return ---
|
||||
*/
|
||||
void ChangePos(Vector2D<int32_t> pos);
|
||||
/**
|
||||
* @brief Get the current Windows position
|
||||
* @param pos The position where the winsdows is.
|
||||
* @return ---
|
||||
*/
|
||||
void GetAbsPos(Vector2D<int32_t>& pos);
|
||||
/**
|
||||
* @brief Display the virtal keyboard (for touch system only)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void KeyboardShow(void);
|
||||
/**
|
||||
* @brief Hide the virtal keyboard (for touch system only)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void KeyboardHide(void);
|
||||
void ForceRedrawAll(void);
|
||||
void SendKeyboardEvent(bool isDown, uniChar_t keyInput);
|
||||
void SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput);
|
||||
void SendClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
|
||||
/**
|
||||
* @brief Inform the Gui that we want to have a copy of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
/**
|
||||
* @brief Inform the Gui that we are the new owner of the clipboard
|
||||
* @param ID of the clipboard (STD/SELECTION) only apear here
|
||||
* @return ---
|
||||
*/
|
||||
void ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID);
|
||||
/**
|
||||
* @brief Set the new title of the windows
|
||||
* @param title New desired title
|
||||
* @return ---
|
||||
*/
|
||||
void SetTitle(etk::UString& title);
|
||||
};
|
||||
|
||||
|
||||
//!< must be define in CPP by the application ...
|
||||
void APP_Init(void);
|
||||
void APP_UnInit(void);
|
||||
//!< must be define in CPP by the application ... this are the main init and unInit of the Application
|
||||
void APP_Init(void);
|
||||
void APP_UnInit(void);
|
||||
etk::File APP_Icon(void);
|
||||
|
||||
#define NB_MAX_INPUT (20)
|
||||
|
||||
|
@ -1,191 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file guiAndroid.cpp
|
||||
* @brief Gui abstraction layer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/10/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <jni.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <android/log.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <ewol/Debug.h>
|
||||
#include <etk/UString.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/base/gui.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/Texture.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "AndroidJNI"
|
||||
int32_t separateClickTime = 800000;
|
||||
int32_t offsetMoveClicked = 40000;
|
||||
int32_t offsetMoveClickedDouble = 300000;
|
||||
|
||||
extern float gui_width;
|
||||
extern float gui_height;
|
||||
extern ewol::Windows* gui_uniqueWindows;
|
||||
|
||||
int64_t ewol::GetTime(void)
|
||||
{
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
void Draw(void);
|
||||
#define OFFSET_MOVE_CLICKED (20)
|
||||
#define OFFSET_MOVE_CLICKED_DOUBLE (40)
|
||||
#undef SEPARATED_CLICK_TIME
|
||||
#define SEPARATED_CLICK_TIME (300)
|
||||
|
||||
//bool inputIsPressed[NB_MAX_INPUT];// = {false, false, false};
|
||||
int32_t m_previousBouttonId = -1;
|
||||
int32_t m_previousDown_x = -1;
|
||||
int32_t m_previousDown_y = -1;
|
||||
int32_t m_previous_x = -1;
|
||||
int32_t m_previous_y = -1;
|
||||
int64_t m_previousTime = 0;
|
||||
bool m_previousDouble = false;
|
||||
|
||||
|
||||
static etk::UString l_clipBoardPrimary(""); // local copy of the selection
|
||||
static etk::UString l_clipBoardStd(""); // local copy of the clipboard
|
||||
|
||||
|
||||
|
||||
void ewol::SetTitle(etk::UString title)
|
||||
{
|
||||
// can not set the title in Android ...
|
||||
}
|
||||
|
||||
// ClipBoard AREA :
|
||||
void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
|
||||
{
|
||||
EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() );
|
||||
newData = "";
|
||||
switch (mode)
|
||||
{
|
||||
case CLIPBOARD_MODE_PRIMARY:
|
||||
// get our own buffer ... (no current selectin on Android ...
|
||||
newData = l_clipBoardPrimary;
|
||||
break;
|
||||
case CLIPBOARD_MODE_STD:
|
||||
EWOL_TODO("implement on Android");
|
||||
// get our own buffer ...
|
||||
newData = l_clipBoardStd;
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Request an unknow ClipBoard ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
|
||||
{
|
||||
EWOL_VERBOSE("Request set of a clipboard : " << mode << " size=" << newData.Size() );
|
||||
switch (mode)
|
||||
{
|
||||
case CLIPBOARD_MODE_PRIMARY:
|
||||
if (newData.Size() > 0) {
|
||||
// copy it ...
|
||||
l_clipBoardPrimary = newData;
|
||||
}
|
||||
break;
|
||||
case CLIPBOARD_MODE_STD:
|
||||
if (newData.Size() > 0) {
|
||||
// copy it ...
|
||||
l_clipBoardStd = newData;
|
||||
// Request the clipBoard :
|
||||
EWOL_TODO("implement on Android copy the copy data");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Request an unknow ClipBoard ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "guiAbstraction"
|
||||
|
||||
void guiAbstraction::Stop(void)
|
||||
{
|
||||
// TODo : send a message to the android system to stop ...
|
||||
}
|
||||
|
||||
// java system to send message :
|
||||
void SendSystemMessage(const char * dataString);
|
||||
void SendJava_KeyboardShow(bool showIt);
|
||||
|
||||
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
|
||||
{
|
||||
// send a message at the java :
|
||||
SendJava_KeyboardShow(true);
|
||||
}
|
||||
|
||||
void guiAbstraction::KeyboardHide(void)
|
||||
{
|
||||
// send a message at the java :
|
||||
SendJava_KeyboardShow(false);
|
||||
}
|
||||
|
||||
void guiAbstraction::ChangeSize(int32_t w, int32_t h)
|
||||
{
|
||||
// nothing to do with Android
|
||||
}
|
||||
|
||||
void guiAbstraction::ChangePos(int32_t x, int32_t y)
|
||||
{
|
||||
// nothing to do with Android
|
||||
}
|
||||
|
||||
void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y)
|
||||
{
|
||||
}
|
||||
|
||||
bool guiAbstraction::IsPressedInput(int32_t inputID)
|
||||
{
|
||||
//if (true == guiAbstractionIsInit) {
|
||||
// return myX11Access->IsPressedInput(inputID);
|
||||
//} else {
|
||||
// EWOL_CRITICAL("X11 ==> not init ... ");
|
||||
return false;
|
||||
//}
|
||||
}
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
int32_t ewol::CmdLineNb(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
etk::UString ewol::CmdLineGet(int32_t id)
|
||||
{
|
||||
return "";
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file guiDoubleBuffer.cpp
|
||||
* @brief Gui abstraction layer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/10/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <ewol/Debug.h>
|
||||
#include <base/guiDoubleBuffer.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "guiAbstraction"
|
||||
|
||||
void guiAbstraction::Init(int32_t argc, char *argv[])
|
||||
{
|
||||
EWOL_INFO("INIT for DoubleBuffer environement");
|
||||
}
|
||||
|
||||
void guiAbstraction::Run(void)
|
||||
{
|
||||
EWOL_INFO("Start Running");
|
||||
EWOL_INFO("Stop Running");
|
||||
}
|
||||
|
||||
void guiAbstraction::UnInit(void)
|
||||
{
|
||||
EWOL_INFO("UN-INIT for DoubleBuffer environement");
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/base/MainThread.h>
|
||||
#include <ewol/base/eSystem.h>
|
||||
|
||||
#include <ewol/base/gui.h>
|
||||
|
||||
@ -38,7 +38,7 @@ void ewol::DisplayWindows(ewol::Windows * windows)
|
||||
ewol::widgetManager::FocusSetDefault(NULL);
|
||||
ewol::widgetManager::FocusRelease();
|
||||
// set display of the windows :
|
||||
guiAbstraction::SetDisplayOnWindows(windows);
|
||||
eSystem::SetCurrentWindows(windows);
|
||||
// Set the new default Focus :
|
||||
ewol::widgetManager::FocusSetDefault(windows);
|
||||
}
|
||||
@ -46,48 +46,43 @@ void ewol::DisplayWindows(ewol::Windows * windows)
|
||||
|
||||
void ewol::Stop(void)
|
||||
{
|
||||
guiAbstraction::Stop();
|
||||
guiInterface::Stop();
|
||||
}
|
||||
|
||||
|
||||
void ewol::ChangeSize(int32_t w, int32_t h)
|
||||
void ewol::ChangeSize(Vector2D<int32_t> size)
|
||||
{
|
||||
guiAbstraction::ChangeSize(w, h);
|
||||
guiInterface::ChangeSize(size);
|
||||
}
|
||||
|
||||
void ewol::ChangePos(int32_t x, int32_t y)
|
||||
void ewol::ChangePos(Vector2D<int32_t> pos)
|
||||
{
|
||||
guiAbstraction::ChangePos(x, y);
|
||||
guiInterface::ChangePos(pos);
|
||||
}
|
||||
|
||||
void ewol::GetAbsPos(int32_t & x, int32_t & y)
|
||||
void ewol::GetAbsPos(Vector2D<int32_t>& pos)
|
||||
{
|
||||
guiAbstraction::GetAbsPos(x, y);
|
||||
guiInterface::GetAbsPos(pos);
|
||||
}
|
||||
|
||||
|
||||
bool ewol::IsPressedInput(int32_t inputID)
|
||||
void ewol::KeyboardShow(void)
|
||||
{
|
||||
return guiAbstraction::IsPressedInput(inputID);
|
||||
}
|
||||
|
||||
void ewol::KeyboardShow(ewol::keyboardMode_te mode)
|
||||
{
|
||||
guiAbstraction::KeyboardShow(mode);
|
||||
guiInterface::KeyboardShow();
|
||||
}
|
||||
|
||||
void ewol::KeyboardHide(void)
|
||||
{
|
||||
guiAbstraction::KeyboardHide();
|
||||
guiInterface::KeyboardHide();
|
||||
}
|
||||
|
||||
void ewol::ForceRedrawAll(void)
|
||||
{
|
||||
guiAbstraction::ForceRedrawAll();
|
||||
eSystem::ForceRedrawAll();
|
||||
}
|
||||
|
||||
|
||||
guiSystem::event::specialKey_ts specialCurrentKey;
|
||||
eSystem::specialKey_ts specialCurrentKey;
|
||||
bool ewol::IsSetCapsLock(void)
|
||||
{
|
||||
return specialCurrentKey.capLock;
|
||||
@ -134,3 +129,75 @@ etk::UString ewol::GetVersion(void)
|
||||
return EWOL_VERSION_TAG_NAME;
|
||||
}
|
||||
|
||||
|
||||
int32_t ewol::GetCurrentWidth(void)
|
||||
{
|
||||
Vector2D<int32_t> tmpSize = eSystem::GetSize();
|
||||
return tmpSize.x;
|
||||
}
|
||||
|
||||
int32_t ewol::GetCurrentHeight(void)
|
||||
{
|
||||
Vector2D<int32_t> tmpSize = eSystem::GetSize();
|
||||
return tmpSize.y;
|
||||
}
|
||||
|
||||
|
||||
void ewol::PopUpWidgetPush(ewol::Widget * tmpWidget)
|
||||
{
|
||||
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
|
||||
if (NULL != tmpWindows && NULL != tmpWidget) {
|
||||
tmpWindows->PopUpWidgetPush(tmpWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::SetTitle(etk::UString title)
|
||||
{
|
||||
guiInterface::SetTitle(title);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Command line arguments
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static etk::Vector<etk::UString*> listArgs;
|
||||
|
||||
void ewol::CmdLine::Clean(void)
|
||||
{
|
||||
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
|
||||
if (NULL != listArgs[iii]) {
|
||||
delete listArgs[iii];
|
||||
listArgs[iii] = NULL;
|
||||
}
|
||||
}
|
||||
listArgs.Clear();
|
||||
}
|
||||
|
||||
int32_t ewol::CmdLine::Nb(void)
|
||||
{
|
||||
return listArgs.Size();
|
||||
}
|
||||
|
||||
etk::UString ewol::CmdLine::Get(int32_t id)
|
||||
{
|
||||
if (id<0 && id>=listArgs.Size()) {
|
||||
return "";
|
||||
}
|
||||
if (NULL == listArgs[id]) {
|
||||
return "";
|
||||
}
|
||||
return *listArgs[id];
|
||||
}
|
||||
|
||||
void ewol::CmdLine::Add(etk::UString& newElement)
|
||||
{
|
||||
etk::UString* tmpString = new etk::UString(newElement);
|
||||
if (NULL != tmpString) {
|
||||
listArgs.PushBack(tmpString);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t ewol::GetTime(void)
|
||||
{
|
||||
return guiInterface::GetTime();
|
||||
}
|
@ -38,25 +38,19 @@ namespace ewol {
|
||||
void Stop(void);
|
||||
void DisplayWindows(ewol::Windows * windows);
|
||||
// only on computer
|
||||
void ChangeSize(int32_t w, int32_t h);
|
||||
void ChangePos(int32_t x, int32_t y);
|
||||
// TODO : Deprecated used FOR???
|
||||
void GetAbsPos(int32_t & x, int32_t & y);
|
||||
|
||||
// TODO : Deprecated remove it ...
|
||||
bool IsPressedInput(int32_t inputID);
|
||||
typedef enum {
|
||||
KEYBOARD_MODE_TEXT,
|
||||
KEYBOARD_MODE_NUMBER,
|
||||
KEYBOARD_MODE_CODE,
|
||||
} keyboardMode_te;
|
||||
void KeyboardShow(ewol::keyboardMode_te mode);
|
||||
void ChangeSize(Vector2D<int32_t> size);
|
||||
void ChangePos(Vector2D<int32_t> pos);
|
||||
void GetAbsPos(Vector2D<int32_t>& pos);
|
||||
void KeyboardShow(void);
|
||||
void KeyboardHide(void);
|
||||
void ForceRedrawAll(void);
|
||||
void PopUpWidgetPush(ewol::Widget * tmpWidget);
|
||||
|
||||
int32_t CmdLineNb(void);
|
||||
etk::UString CmdLineGet(int32_t id);
|
||||
namespace CmdLine {
|
||||
void Clean(void);
|
||||
int32_t Nb(void);
|
||||
etk::UString Get(int32_t id);
|
||||
void Add(etk::UString& newElement);
|
||||
};
|
||||
// TODO : This might be deprecated ...
|
||||
bool IsSetCapsLock(void);
|
||||
bool IsSetShift(void);
|
||||
|
@ -1,31 +0,0 @@
|
||||
|
||||
#ifndef __IMPORTGL_H__
|
||||
#define __IMPORTGL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__TARGET_OS__Linux)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#elif defined(__TARGET_OS__Android)
|
||||
#include <GLES/gl.h>
|
||||
#elif defined(__TARGET_OS__Windows)
|
||||
#include <GL/gl.h>
|
||||
#elif defined(__TARGET_OS__MacOs)
|
||||
|
||||
#elif defined(__TARGET_OS__IOs)
|
||||
|
||||
#else
|
||||
#error you need to specify a __TAGET_OS__ ...
|
||||
#endif
|
||||
|
||||
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
58
Sources/libewol/ewol/openGl.cpp
Normal file
58
Sources/libewol/ewol/openGl.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/openGl.cpp
|
||||
* @brief ewol openGl abstarction (sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/09/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewol/openGl.h>
|
||||
|
||||
|
||||
void glOrthoEwol(GLfloat left,
|
||||
GLfloat right,
|
||||
GLfloat bottom,
|
||||
GLfloat top,
|
||||
GLfloat nearVal,
|
||||
GLfloat farVal)
|
||||
{
|
||||
GLfloat myMatrix[4*4];
|
||||
int iii;
|
||||
for(iii=0; iii<4*4 ; iii++) {
|
||||
myMatrix[iii] = 0;
|
||||
}
|
||||
myMatrix[0] = 2.0 / (right - left);
|
||||
myMatrix[5] = 2.0 / (top - bottom);
|
||||
myMatrix[10] = -2.0 / (farVal - nearVal);
|
||||
#if 1
|
||||
myMatrix[3] = -1*(right + left) / (right - left);
|
||||
myMatrix[7] = -1*(top + bottom) / (top - bottom);
|
||||
myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
|
||||
#else
|
||||
// test if matrix is not corectly instanciate ...
|
||||
myMatrix[12] = -1*(right + left) / (right - left);
|
||||
myMatrix[13] = -1*(top + bottom) / (top - bottom);
|
||||
myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal);
|
||||
#endif
|
||||
myMatrix[15] = 1;
|
||||
|
||||
glLoadMatrixf(myMatrix);
|
||||
|
||||
|
||||
}
|
54
Sources/libewol/ewol/openGl.h
Normal file
54
Sources/libewol/ewol/openGl.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/openGl.h
|
||||
* @brief ewol openGl abstarction (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 19/09/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __OPEN_GL_H__
|
||||
#define __OPEN_GL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__TARGET_OS__Linux)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#elif defined(__TARGET_OS__Android)
|
||||
#include <GLES/gl.h>
|
||||
#elif defined(__TARGET_OS__Windows)
|
||||
#include <GL/gl.h>
|
||||
#elif defined(__TARGET_OS__MacOs)
|
||||
|
||||
#elif defined(__TARGET_OS__IOs)
|
||||
|
||||
#else
|
||||
#error you need to specify a __TAGET_OS__ ...
|
||||
#endif
|
||||
|
||||
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -312,7 +312,7 @@ void ewol::Entry::UpdateTextPosition(void)
|
||||
void ewol::Entry::OnGetFocus(void)
|
||||
{
|
||||
m_displayCursor = true;
|
||||
ewol::KeyboardShow(ewol::KEYBOARD_MODE_TEXT);
|
||||
ewol::KeyboardShow();
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
|
||||
/**
|
||||
* @brief Initilise the basic widget property ==> due to the android system
|
||||
@ -200,4 +200,5 @@ Vector2D<float> ewol::Scene::RelativePosition(Vector2D<float> pos)
|
||||
pos.y *= m_zoom;
|
||||
|
||||
return pos;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -78,4 +78,5 @@ void ewol::Spacer::OnRegenerateDisplay(void)
|
||||
|
||||
BGOObjects->SetColor(m_color);
|
||||
BGOObjects->Rectangle(0, 0, m_size.x, m_size.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <ewol/openGl.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
|
||||
@ -436,4 +436,5 @@ void ewol::WidgetScrooled::ScroolingMode(scrollingMode_te newMode)
|
||||
m_maxSize.y = m_maxSize.x;
|
||||
m_zoom = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
FILE_LIST = ewol/ewol.cpp \
|
||||
ewol/threadMsg.cpp \
|
||||
ewol/base/MainThread.cpp \
|
||||
ewol/base/gui.cpp \
|
||||
ewol/base/eventInputManagement.cpp \
|
||||
ewol/openGl.cpp \
|
||||
ewol/base/eSystem.cpp \
|
||||
ewol/base/eSystemInput.cpp \
|
||||
ewol/ClipBoard.cpp \
|
||||
ewol/Debug.cpp \
|
||||
ewol/EObject.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user