Better font stop, jet texture internal Id and not OpenGl ID, Correction of multiCast RM, wcrolling widget is good

This commit is contained in:
Edouard Dupin 2012-02-07 18:07:06 +01:00
parent 5447f326c6
commit 165b3da4d3
16 changed files with 173 additions and 54 deletions

View File

@ -91,14 +91,14 @@ namespace ewol
coord2D_ts & drawPosition,
coord2D_ts & clipSize,
const char * utf8String,
uint32_t & fontTextureId,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const uniChar_t * unicodeString,
uint32_t & fontTextureId,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
/*

View File

@ -437,7 +437,7 @@ class FTFont{
uint32_t GetOglId(void)
{
return ewol::GetTextureGLID(m_textureId);
return m_textureId;
};
int32_t GetSize(void)
@ -497,10 +497,19 @@ void ewol::UnInitFont(void)
EWOL_CRITICAL(" when Un-loading FreeType Librairy ...");
}
*/
/*
s_currentFolderName = "";
s_currentDefaultFontName = "";
s_currentDefaultFontId = -1;
// unload global font
for(int32_t iii=0; iii<m_listLoadedFont.Size(); iii++) {
if (NULL != m_listLoadedFont[iii]) {
delete(m_listLoadedFont[iii]);
}
m_listLoadedFont[iii] = NULL;
}
m_listLoadedFont.Clear();
// unload TFT font ...
for(int32_t iii=0; iii<m_listLoadedTTFont.Size(); iii++) {
if (NULL != m_listLoadedTTFont[iii]) {
delete(m_listLoadedTTFont[iii]);
@ -508,7 +517,6 @@ void ewol::UnInitFont(void)
m_listLoadedTTFont[iii] = NULL;
}
m_listLoadedTTFont.Clear();
*/
}
void ewol::SetDefaultFont(etk::String fontName, int32_t size)
@ -565,7 +573,7 @@ int32_t ewol::DrawText(int32_t fontID,
coord2D_ts & drawPosition,
coord2D_ts & clipSize,
const char * utf8String,
uint32_t & fontTextureId,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex)
{
@ -684,7 +692,7 @@ int32_t ewol::DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const uniChar_t * unicodeString,
uint32_t & fontTextureId,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex)
{

View File

@ -24,6 +24,7 @@
#include <ewol/OObject/2DText.h>
#include <ewol/importgl.h>
#include <ewol/Texture.h>
#undef __class__
#define __class__ "ewol::OObject2DText"
@ -64,7 +65,7 @@ void ewol::OObject2DText::Draw(void)
}
glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_FontTextureId);
glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_FontTextureId));
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );

View File

@ -42,7 +42,7 @@ namespace ewol {
protected:
int32_t m_FontId; //!< font internal ID
color_ts m_textColorFg; //!< text color ...
uint32_t m_FontTextureId; //!< font internal Texture ID
int32_t m_FontTextureId; //!< font internal Texture ID
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
public:

View File

@ -24,6 +24,7 @@
#include <ewol/OObject/2DTextColored.h>
#include <ewol/importgl.h>
#include <ewol/Texture.h>
#undef __class__
#define __class__ "ewol::OObject2DTextColored"
@ -80,7 +81,7 @@ void ewol::OObject2DTextColored::Draw(void)
return;
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_FontTextureId);
glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_FontTextureId));
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays

View File

@ -46,7 +46,7 @@ namespace ewol {
protected:
int32_t m_FontId; //!< font internal ID
color_ts m_color; //!< tmp text color ...
uint32_t m_FontTextureId; //!< font internal Texture ID
int32_t m_FontTextureId; //!< font internal Texture ID
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
etk::VectorType<color_ts> m_coordColor; //!< internal color of the different point

View File

@ -51,7 +51,7 @@ void ewol::OObject2DTextured::Draw(void)
glColor4f(1.0, 1.0, 1.0, 1.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textureId);
glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_textureId));
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );

View File

@ -37,7 +37,7 @@ namespace ewol {
virtual void Draw(void);
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t texX=0.0, etkFloat_t texY=0.0, etkFloat_t texSX=1.0, etkFloat_t texSY=1.0);
protected:
uint32_t m_textureId; //!< texture internal ID
int32_t m_textureId; //!< texture internal ID
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
public:

View File

@ -189,12 +189,12 @@ namespace ewol {
void SetOrigin(etkFloat_t x, etkFloat_t y) { m_origin.x=x; m_origin.y=y; };
coord GetOrigin(void) { return m_origin; };
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ...
//update the min Size ... and the expend parameters for the sizer
//update the min Size ... and the expend parameters for the sizer
virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; return true; };
virtual void SetMinSize(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; };
coord GetMinSize(void) { return m_minSize; };
coord GetSize(void) { return m_size; };
void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; };
void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; MarkToReedraw();};
coord GetCurrentSize(void) { return m_size; };
virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; };
virtual bool CanExpentX(void) { return m_userExpendX; };

View File

@ -58,6 +58,7 @@ void ewol::widgetMessageMultiCast::Add(int32_t widgetId, const char* const messa
tmpMessage.widgetId = widgetId;
tmpMessage.message = message;
m_messageList.PushBack(tmpMessage);
EWOL_DEBUG("SendMulticast ADD listener :" << widgetId << " on \"" << message << "\"" );
}
// TODO : Do this better ...
@ -65,7 +66,8 @@ void ewol::widgetMessageMultiCast::Rm(int32_t widgetId)
{
// send the message at all registered widget ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if(m_messageList[iii].widgetId != widgetId) {
if(m_messageList[iii].widgetId == widgetId) {
EWOL_DEBUG("SendMulticast RM listener :" << widgetId);
m_messageList[iii].message = NULL;
m_messageList[iii].widgetId = -1;
}
@ -81,7 +83,11 @@ void ewol::widgetMessageMultiCast::Send(int32_t widgetId, const char* const mess
void ewol::widgetMessageMultiCast::Send(int32_t widgetId, const char* const message, const char * data)
{
EWOL_DEBUG("SendMulticast message \"" << message << "\" to :");
if (data!=NULL) {
EWOL_DEBUG("SendMulticast message \"" << message << "\" data=\"" << data << "\" to :");
} else {
EWOL_DEBUG("SendMulticast message \"" << message << "\" data=NULL to :");
}
// send the message at all registered widget ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if( m_messageList[iii].message == message

View File

@ -228,11 +228,15 @@ void EWOL_SystemStart(void)
{
if (false == isGlobalSystemInit) {
// create interface mutex :
EWOL_DEBUG("Init thread message system");
ewol::threadMsg::Init(androidJniMsg);
// init the thread :
EWOL_DEBUG("Create the thread");
pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
isGlobalSystemInit = true;
EWOL_DEBUG("Send Init message to the thread");
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EWOL_DEBUG("end basic init");
}
}

View File

@ -136,7 +136,7 @@ void EWOL_NativeEventInputMotion(int pointerID, float x, float y )
//EWOL_INFO("Event : Input Motion ID=" << pointerID << " x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
if(NULL != gui_uniqueWindows) {
//EWOL_DEBUG("ANDROID event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
//EWOL_DEBUG("Event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)x, (etkFloat_t)y);
}
}

View File

@ -103,24 +103,24 @@ extern "C" {
}
// for double and triple click selection, we need to save the previous click up and down position , and the previous time ...
int32_t m_previousBouttonId;
int32_t m_previousDown_x;
int32_t m_previousDown_y;
int32_t m_previous_x;
int32_t m_previous_y;
int64_t m_previousTime;
bool m_previousDouble;
int32_t m_previousBouttonId = -1;
int32_t m_previousDown_x = 0;
int32_t m_previousDown_y = 0;
int32_t m_previous_x = 0;
int32_t m_previous_y = 0;
int64_t m_previousTime = 0;
bool m_previousDouble = 0;
Atom m_delAtom;
Display * m_display;
Display * m_display = NULL;;
Window WindowHandle;
int32_t m_originX;
int32_t m_originY;
int32_t m_cursorEventX;
int32_t m_cursorEventY;
XVisualInfo * m_visual;
bool m_doubleBuffered;
bool m_run;
int32_t m_originX = 0;
int32_t m_originY = 0;
int32_t m_cursorEventX = 0;
int32_t m_cursorEventY = 0;
XVisualInfo * m_visual = NULL;
bool m_doubleBuffered = 0;
bool m_run = 0;
extern ewol::Windows* gui_uniqueWindows;
extern etkFloat_t gui_width;
extern etkFloat_t gui_height;
@ -369,9 +369,11 @@ void X11_Run(void)
{
// main cycle
while(true == m_run) {
//EWOL_ERROR("plop1");
XEvent event;
// main X boucle :
while (XPending(m_display)) {
//EWOL_ERROR("plop 22222");
XNextEvent(m_display, &event);
switch (event.type)
@ -427,8 +429,8 @@ void X11_Run(void)
bool findOne = false;
for (int32_t iii=0; iii<NB_MAX_INPUT ; iii++) {
if (true == inputIsPressed[iii]) {
EWOL_VERBOSE("X11 event: bt=" << iii+1 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")");
EWOL_ThreadEventInputMotion(iii+1, (float)event.xmotion.x, (float)event.xmotion.y);
EWOL_VERBOSE("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")");
EWOL_ThreadEventInputMotion(iii, (float)event.xmotion.x, (float)event.xmotion.y);
findOne = true;
}
}
@ -712,6 +714,7 @@ int main(int argc, char *argv[])
X11_Init();
//start the basic thread :
EWOL_SystemStart();
usleep(500);
// Run ...
X11_Run();
// close X11 :

View File

@ -58,15 +58,33 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
} else {
TiXmlDocument XmlDocument;
// open the curent File
#ifdef DATA_INTERNAL_BINARY
if (etk::FILE_TYPE_DATA == newFile.GetTypeAccess()) {
XmlDocument.Parse(newFile.GetDirectPointer());
} else {
XmlDocument.LoadFile(newFile.GetCompleateName().c_str());
}
#else
XmlDocument.LoadFile(newFile.GetCompleateName().c_str());
#endif
if (false == newFile.Exist()) {
EWOL_ERROR("File Does not exist : " << newFile);
return;
}
int32_t fileSize = newFile.Size();
if (0==fileSize) {
EWOL_ERROR("This file is empty : " << newFile);
return;
}
if (false == newFile.fOpenRead()) {
EWOL_ERROR("Can not open the file : " << newFile);
return;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
newFile.fRead(fileBuffer, 1, fileSize);
// close the file:
newFile.fClose();
// load the XML from the memory
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
TiXmlElement* root = XmlDocument.FirstChildElement( "eol" );
if (NULL == root ) {
EWOL_ERROR("(l ?) main node not find: \"eol\" in \"" << newFile << "\"");
@ -171,6 +189,9 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
}
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
}
}

View File

@ -31,9 +31,10 @@
ewol::WidgetScrooled::WidgetScrooled(void)
{
m_originScrooledX = 0;
m_originScrooledY = 0;
m_originScrooled.x = 0;
m_originScrooled.y = 0;
m_pixelScrolling = 20;
m_highSpeedMode = SCROLL_DISABLE;
}
ewol::WidgetScrooled::~WidgetScrooled(void)
@ -41,21 +42,85 @@ ewol::WidgetScrooled::~WidgetScrooled(void)
}
void ewol::WidgetScrooled::OnRegenerateDisplay(void)
{
if( ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode
|| ewol::SCROLL_ENABLE_VERTICAL ==m_highSpeedMode) {
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
myOObjectsColored->SetColor(1.0, 0.0, 0.0, 0.4);
myOObjectsColored->Disc(m_highSpeedStartPos.x, m_highSpeedStartPos.y, 10);
AddOObject(myOObjectsColored, "scolling object");
}
}
bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
{
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
EWOL_INFO("mouse-event GDK_SCROLL_UP");
m_originScrooledY -= m_pixelScrolling;
if (m_originScrooledY < 0) {
m_originScrooledY = 0;
m_originScrooled.y -= m_pixelScrolling;
if (m_originScrooled.y < 0) {
m_originScrooled.y = 0;
}
MarkToReedraw();
return true;
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
EWOL_INFO("mouse-event GDK_SCROLL_DOWN");
m_originScrooledY += m_pixelScrolling;
m_originScrooled.y += m_pixelScrolling;
if (m_maxSize.y < m_originScrooled.y) {
m_originScrooled.y = m_maxSize.y;
}
MarkToReedraw();
return true;
}else if (2 == IdInput) {
x -= m_origin.x;
y -= m_origin.y;
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_highSpeedMode = ewol::SCROLL_INIT;
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
return true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
return true;
} else if (ewol::SCROLL_INIT==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
// wait that the cursor move more than 10 px to enable it :
if( abs(x - m_highSpeedStartPos.x) > 10
|| abs(y - m_highSpeedStartPos.y) > 10 ) {
// the scrooling can start :
// select the direction :
if (x == m_highSpeedStartPos.x) {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
} else if (y == m_highSpeedStartPos.y) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
etkFloat_t coef = (y - m_highSpeedStartPos.y) / (x - m_highSpeedStartPos.x);
if (abs(coef) <= 1 ) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
}
}
if (m_highSpeedMode == ewol::SCROLL_ENABLE_HORIZONTAL) {
m_highSpeedStartPos.x = m_originScrooled.x / m_maxSize.x * m_size.x;
} else {
m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * m_size.y;
}
MarkToReedraw();
}
return true;
} if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x);
MarkToReedraw();
return true;
} if (ewol::SCROLL_ENABLE_VERTICAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
m_originScrooled.y = (int32_t)(m_maxSize.y * y / m_size.y);
MarkToReedraw();
return true;
}
} else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
return true;
}

View File

@ -30,19 +30,29 @@
#include <ewol/Widget.h>
namespace ewol {
typedef enum {
SCROLL_DISABLE,
SCROLL_INIT,
SCROLL_ENABLE_HORIZONTAL,
SCROLL_ENABLE_VERTICAL,
}highSpeedMode_te;
class WidgetScrooled :public ewol::Widget
{
protected:
int32_t m_originScrooledX;
int32_t m_originScrooledY;
coord m_originScrooled;
coord m_maxSize;
private:
uint32_t m_pixelScrolling;
etkFloat_t m_pixelScrolling;
coord m_highSpeedStartPos;
highSpeedMode_te m_highSpeedMode;
public:
WidgetScrooled(void);
virtual ~WidgetScrooled(void);
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
protected:
void SetScrollingSize(uint32_t nbPixel) { m_pixelScrolling = nbPixel; };
void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; };
};
};