management of the font is now better, but it did not work corectly for now ...
This commit is contained in:
parent
b780f22d2c
commit
229b1de48d
@ -1 +1 @@
|
|||||||
Subproject commit 6f05d8dc715c3a8c022def84d63bed8bc255ca8d
|
Subproject commit b000e558d0025cb35ef3950f46f722c4167ed0ec
|
@ -28,57 +28,51 @@
|
|||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <etk/File.h>
|
#include <etk/File.h>
|
||||||
|
#include <draw/Image.h>
|
||||||
|
#include <ewol/texture/Texture.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol
|
namespace ewol
|
||||||
{
|
{
|
||||||
// TODO : Create a subNameSpace:
|
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
|
||||||
/*
|
typedef struct {
|
||||||
namespace font {
|
uniChar_t unicodeCharVal;
|
||||||
...
|
texCoord_ts posStart;
|
||||||
};
|
texCoord_ts posStop;
|
||||||
*/
|
Vector2D<float> bearing;
|
||||||
// set default folder name of the font :
|
Vector2D<float> size;
|
||||||
void SetFontFolder(etk::UString folderName);
|
int32_t advance;
|
||||||
void SetDefaultFont(etk::UString fontName, int32_t size);
|
}freeTypeFontElement_ts;
|
||||||
// unload all font loaded
|
|
||||||
void InitFont(void);
|
|
||||||
void UnInitFont(void);
|
|
||||||
// load the fonts...
|
|
||||||
int32_t LoadFont(etk::UString fontName, int32_t size); // return ID of font
|
|
||||||
int32_t GetDefaultFontId(void);
|
|
||||||
void UnloadFont(int32_t id);
|
|
||||||
|
|
||||||
// get the size of a long string in UTF8 (note that \n and \r represent unknown char...)
|
class Font {
|
||||||
int32_t GetWidth(int32_t fontID, const etk::UString& unicodeString);
|
private:
|
||||||
int32_t GetHeight(int32_t fontID);
|
etk::UString m_name;
|
||||||
int32_t DrawText(int32_t fontID,
|
uint32_t m_counter;
|
||||||
|
public:
|
||||||
|
Font(etk::UString fontName) :
|
||||||
|
m_counter(1)
|
||||||
|
{
|
||||||
|
m_name = fontName;
|
||||||
|
};
|
||||||
|
virtual ~Font(void) {};
|
||||||
|
bool HasName(etk::UString& fileName) { return fileName==m_name; };
|
||||||
|
etk::UString GetName(void) { return m_name; };
|
||||||
|
void Increment(void) { m_counter++; };
|
||||||
|
bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; };
|
||||||
|
virtual int32_t Draw(draw::Image& imageOut,
|
||||||
|
int32_t fontSize,
|
||||||
Vector2D<float> textPos,
|
Vector2D<float> textPos,
|
||||||
clipping_ts & drawClipping,
|
const etk::UString& unicodeString,
|
||||||
const etk::UString & unicodeString,
|
draw::Color& textColor) = 0;
|
||||||
int32_t & fontTextureId,
|
virtual int32_t Draw(draw::Image& imageOut,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
int32_t fontSize,
|
||||||
etk::Vector<texCoord_ts> & coordTex);
|
|
||||||
int32_t DrawText(int32_t fontID,
|
|
||||||
Vector2D<float> textPos,
|
|
||||||
clipping_ts & drawClipping,
|
|
||||||
const uniChar_t unicodeChar,
|
|
||||||
int32_t & fontTextureId,
|
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
|
||||||
etk::Vector<texCoord_ts> & coordTex);
|
|
||||||
int32_t DrawText(int32_t fontID,
|
|
||||||
Vector2D<float> textPos,
|
|
||||||
const etk::UString & unicodeString,
|
|
||||||
int32_t & fontTextureId,
|
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
|
||||||
etk::Vector<texCoord_ts> & coordTex);
|
|
||||||
int32_t DrawText(int32_t fontID,
|
|
||||||
Vector2D<float> textPos,
|
Vector2D<float> textPos,
|
||||||
const uniChar_t unicodeChar,
|
const uniChar_t unicodeChar,
|
||||||
int32_t & fontTextureId,
|
draw::Color& textColor) = 0;
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
virtual bool GenerateBitmapFont(int32_t size, int32_t& height, ewol::Texture& texture, etk::Vector<freeTypeFontElement_ts>& listElement) = 0;
|
||||||
etk::Vector<texCoord_ts> & coordTex);
|
virtual Vector2D<float> GetSize(int32_t fontSize, const etk::UString & unicodeString) = 0;
|
||||||
int32_t LoadFont(etk::File fontFileName);
|
virtual int32_t GetHeight(int32_t fontSize) = 0;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
67
Sources/libewol/ewol/font/FontFreeType.h
Normal file
67
Sources/libewol/ewol/font/FontFreeType.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/font/FontFreeType.h
|
||||||
|
* @brief ewol Font freeType system (header)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/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_FONT_FREE_TYPE_H__
|
||||||
|
#define __EWOL_FONT_FREE_TYPE_H__
|
||||||
|
|
||||||
|
#include <ewol/font/Font.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <freetype/ft2build.h>
|
||||||
|
}
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
namespace ewol
|
||||||
|
{
|
||||||
|
class FontFreeType : public ewol::Font
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
FT_Byte * m_FileBuffer;
|
||||||
|
int32_t m_FileSize;
|
||||||
|
FT_Face m_fftFace;
|
||||||
|
void Display(void);
|
||||||
|
public:
|
||||||
|
FontFreeType(etk::UString fontName);
|
||||||
|
~FontFreeType(void);
|
||||||
|
int32_t Draw(draw::Image& imageOut,
|
||||||
|
int32_t fontSize,
|
||||||
|
Vector2D<float> textPos,
|
||||||
|
const etk::UString& unicodeString,
|
||||||
|
draw::Color& textColor);
|
||||||
|
int32_t Draw(draw::Image& imageOut,
|
||||||
|
int32_t fontSize,
|
||||||
|
Vector2D<float> textPos,
|
||||||
|
const uniChar_t unicodeChar,
|
||||||
|
draw::Color& textColor);
|
||||||
|
bool GenerateBitmapFont(int32_t size, int32_t& height, ewol::Texture& texture, etk::Vector<freeTypeFontElement_ts>& listElement);
|
||||||
|
Vector2D<float> GetSize(int32_t fontSize, const etk::UString & unicodeString);
|
||||||
|
int32_t GetHeight(int32_t fontSize);
|
||||||
|
};
|
||||||
|
void FreeTypeInit(void);
|
||||||
|
void FreeTypeUnInit(void);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
182
Sources/libewol/ewol/font/FontManager.cpp
Normal file
182
Sources/libewol/ewol/font/FontManager.cpp
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/font/FontManager.cpp
|
||||||
|
* @brief ewol Font manager system (Sources)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/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.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <etk/Vector.h>
|
||||||
|
#include <ewol/Debug.h>
|
||||||
|
#include <ewol/font/FontManager.h>
|
||||||
|
#include <ewol/font/FontFreeType.h>
|
||||||
|
#include <ewol/font/TexturedFont.h>
|
||||||
|
|
||||||
|
static etk::Vector<ewol::Font*> l_fontList;
|
||||||
|
static etk::Vector<ewol::TexturedFont*> l_fontTexturedList;
|
||||||
|
static etk::UString l_folderName = "";
|
||||||
|
static etk::UString l_defaultFontName = "";
|
||||||
|
static int32_t l_defaultFontSize = 10;
|
||||||
|
|
||||||
|
void ewol::font::Init(void)
|
||||||
|
{
|
||||||
|
// nothing to do in théory then, we clean the buffers :
|
||||||
|
// NOTE : If we do domething here, then the system does not work corectly
|
||||||
|
l_fontList.Clear();
|
||||||
|
l_fontTexturedList.Clear();
|
||||||
|
l_folderName = "";
|
||||||
|
l_defaultFontName = "";
|
||||||
|
l_defaultFontSize = 10;
|
||||||
|
// Specific for free Font
|
||||||
|
ewol::FreeTypeInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::font::UnInit(void)
|
||||||
|
{
|
||||||
|
// remove textured font ...
|
||||||
|
for (int32_t iii=0; iii<l_fontTexturedList.Size(); iii++) {
|
||||||
|
if (l_fontTexturedList[iii] != NULL) {
|
||||||
|
delete(l_fontTexturedList[iii]);
|
||||||
|
l_fontTexturedList[iii] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l_fontTexturedList.Clear();
|
||||||
|
// remove fonts :
|
||||||
|
for (int32_t iii=0; iii<l_fontList.Size(); iii++) {
|
||||||
|
if (l_fontList[iii] != NULL) {
|
||||||
|
delete(l_fontList[iii]);
|
||||||
|
l_fontList[iii] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l_fontList.Clear();
|
||||||
|
// Specific for free Font
|
||||||
|
ewol::FreeTypeUnInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::font::SetFontFolder(etk::UString folderName)
|
||||||
|
{
|
||||||
|
if (l_folderName != "") {
|
||||||
|
EWOL_WARNING("Change the FontFolder, old=\"" << l_folderName << "\"");
|
||||||
|
}
|
||||||
|
EWOL_TODO("Check if folder exist");
|
||||||
|
l_folderName = folderName;
|
||||||
|
EWOL_INFO("New default font folder name=\"" << l_folderName << "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::font::SetDefaultFont(etk::UString fontName)
|
||||||
|
{
|
||||||
|
l_defaultFontName = fontName;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::UString& ewol::font::GetDefaultFont(void)
|
||||||
|
{
|
||||||
|
return l_defaultFontName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::font::SetDefaultSize(int32_t newSize)
|
||||||
|
{
|
||||||
|
l_defaultFontSize = newSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ewol::font::GetDefaultSize(void)
|
||||||
|
{
|
||||||
|
return l_defaultFontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::Font* ewol::font::Keep(etk::UString fontName)
|
||||||
|
{
|
||||||
|
etk::UString tmpFileName = l_folderName + "/" + fontName;
|
||||||
|
for (int32_t iii=l_fontList.Size()-1; iii>=0; iii--) {
|
||||||
|
if (l_fontList[iii] != NULL) {
|
||||||
|
if(l_fontList[iii]->HasName(tmpFileName)) {
|
||||||
|
l_fontList[iii]->Increment();
|
||||||
|
return l_fontList[iii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ewol::FontFreeType* tmpResources = new ewol::FontFreeType(tmpFileName);
|
||||||
|
if (NULL == tmpResources) {
|
||||||
|
EWOL_ERROR("allocation error of a resource Font : " << tmpFileName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
l_fontList.PushBack(tmpResources);
|
||||||
|
return tmpResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::font::Release(ewol::Font*& object)
|
||||||
|
{
|
||||||
|
for (int32_t iii=l_fontList.Size()-1; iii>=0; iii--) {
|
||||||
|
if (l_fontList[iii] != NULL) {
|
||||||
|
if(l_fontList[iii] == object) {
|
||||||
|
if (true == l_fontList[iii]->Decrement()) {
|
||||||
|
// delete element
|
||||||
|
delete(l_fontList[iii]);
|
||||||
|
// remove element from the list :
|
||||||
|
l_fontList.Erase(iii);
|
||||||
|
}
|
||||||
|
// insidiously remove the pointer for the caller ...
|
||||||
|
object = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::TexturedFont* ewol::font::TexturedKeep(etk::UString fontName, int32_t size)
|
||||||
|
{
|
||||||
|
etk::UString tmpFileName = l_folderName + "/" + fontName;
|
||||||
|
for (int32_t iii=l_fontTexturedList.Size()-1; iii>=0; iii--) {
|
||||||
|
if (l_fontTexturedList[iii] != NULL) {
|
||||||
|
if(l_fontTexturedList[iii]->HasName(tmpFileName, size)) {
|
||||||
|
l_fontTexturedList[iii]->Increment();
|
||||||
|
return l_fontTexturedList[iii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ewol::TexturedFont* tmpResources = new ewol::TexturedFont(tmpFileName, size);
|
||||||
|
if (NULL == tmpResources) {
|
||||||
|
EWOL_ERROR("allocation error of a resource textured Font : " << tmpFileName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
l_fontTexturedList.PushBack(tmpResources);
|
||||||
|
return tmpResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::font::TexturedRelease(ewol::TexturedFont*& object)
|
||||||
|
{
|
||||||
|
for (int32_t iii=l_fontTexturedList.Size()-1; iii>=0; iii--) {
|
||||||
|
if (l_fontTexturedList[iii] != NULL) {
|
||||||
|
if(l_fontTexturedList[iii] == object) {
|
||||||
|
if (true == l_fontTexturedList[iii]->Decrement()) {
|
||||||
|
// delete element
|
||||||
|
delete(l_fontTexturedList[iii]);
|
||||||
|
// remove element from the list :
|
||||||
|
l_fontTexturedList.Erase(iii);
|
||||||
|
}
|
||||||
|
// insidiously remove the pointer for the caller ...
|
||||||
|
object = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
Sources/libewol/ewol/font/FontManager.h
Normal file
51
Sources/libewol/ewol/font/FontManager.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/font/FontManager.h
|
||||||
|
* @brief ewol Font manager system (header)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/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_FONT_MANAGER_H__
|
||||||
|
#define __EWOL_FONT_MANAGER_H__
|
||||||
|
|
||||||
|
#include <ewol/font/Font.h>
|
||||||
|
#include <ewol/font/TexturedFont.h>
|
||||||
|
#include <ewol/font/FontFreeType.h>
|
||||||
|
|
||||||
|
namespace ewol
|
||||||
|
{
|
||||||
|
namespace font {
|
||||||
|
void Init(void);
|
||||||
|
void UnInit(void);
|
||||||
|
void SetFontFolder(etk::UString folderName);
|
||||||
|
void SetDefaultFont(etk::UString fontName);
|
||||||
|
etk::UString& GetDefaultFont(void);
|
||||||
|
void SetDefaultSize(int32_t newSize);
|
||||||
|
int32_t GetDefaultSize(void);
|
||||||
|
|
||||||
|
ewol::Font* Keep(etk::UString fontName);
|
||||||
|
void Release(ewol::Font*& object);
|
||||||
|
|
||||||
|
ewol::TexturedFont* TexturedKeep(etk::UString fontName, int32_t size);
|
||||||
|
void TexturedRelease(ewol::TexturedFont*& object);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
291
Sources/libewol/ewol/font/TexturedFont.cpp
Normal file
291
Sources/libewol/ewol/font/TexturedFont.cpp
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/font/TexturedFont.cpp
|
||||||
|
* @brief ewol Textured Font system (Sources)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/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.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <ewol/font/Font.h>
|
||||||
|
#include <ewol/font/TexturedFont.h>
|
||||||
|
#include <ewol/font/FontManager.h>
|
||||||
|
|
||||||
|
|
||||||
|
ewol::TexturedFont::TexturedFont(etk::UString fontName, int32_t size) :
|
||||||
|
m_font(NULL),
|
||||||
|
m_counter(1)
|
||||||
|
{
|
||||||
|
m_size = size;
|
||||||
|
m_font = ewol::font::Keep(fontName);
|
||||||
|
if (NULL == m_font) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// initilize the texture ...
|
||||||
|
// TODO : Do a better methode that not initialize with a stupid language ... like now ...
|
||||||
|
m_font->GenerateBitmapFont(m_size, m_height, m_texture, m_listElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
ewol::TexturedFont::~TexturedFont(void)
|
||||||
|
{
|
||||||
|
ewol::font::Release(m_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||||
|
const etk::UString& unicodeString,
|
||||||
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
|
etk::Vector<texCoord_ts> & coordTex)
|
||||||
|
{
|
||||||
|
float totalSize = 0;
|
||||||
|
Vector2D<float> tmpPos = textPos;
|
||||||
|
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
|
||||||
|
int32_t ret = Draw(tmpPos, unicodeString[iii], coord, coordTex);
|
||||||
|
tmpPos.x += ret;
|
||||||
|
totalSize += ret;
|
||||||
|
}
|
||||||
|
return totalSize;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// To display the texture ...
|
||||||
|
{
|
||||||
|
/* Bitmap position
|
||||||
|
* 0------1
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
Vector2D<float> bitmapDrawPos[4];
|
||||||
|
bitmapDrawPos[0].x = 10;
|
||||||
|
bitmapDrawPos[1].x = 400;
|
||||||
|
bitmapDrawPos[2].x = 400;
|
||||||
|
bitmapDrawPos[3].x = 10;
|
||||||
|
|
||||||
|
bitmapDrawPos[0].y = 10;
|
||||||
|
bitmapDrawPos[1].y = 10;
|
||||||
|
bitmapDrawPos[2].y = 400;
|
||||||
|
bitmapDrawPos[3].y = 400;
|
||||||
|
/* texture Position :
|
||||||
|
* 0------1
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
texCoord_ts texturePos[4];
|
||||||
|
texturePos[0].u = 0;
|
||||||
|
texturePos[1].u = 1;
|
||||||
|
texturePos[2].u = 1;
|
||||||
|
texturePos[3].u = 0;
|
||||||
|
|
||||||
|
texturePos[0].v = 0;
|
||||||
|
texturePos[1].v = 0;
|
||||||
|
texturePos[2].v = 1;
|
||||||
|
texturePos[3].v = 1;
|
||||||
|
|
||||||
|
// NOTE : Android does not support the Quads elements ...
|
||||||
|
/* Step 1 :
|
||||||
|
* ********
|
||||||
|
* ******
|
||||||
|
* ****
|
||||||
|
* **
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(texturePos[0]);
|
||||||
|
coordTex.PushBack(texturePos[1]);
|
||||||
|
coordTex.PushBack(texturePos[2]);
|
||||||
|
// set display positions :
|
||||||
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
coord.PushBack(bitmapDrawPos[1]);
|
||||||
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
|
||||||
|
/* Step 2 :
|
||||||
|
*
|
||||||
|
* **
|
||||||
|
* ****
|
||||||
|
* ******
|
||||||
|
* ********
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(texturePos[0]);
|
||||||
|
coordTex.PushBack(texturePos[2]);
|
||||||
|
coordTex.PushBack(texturePos[3]);
|
||||||
|
// set display positions :
|
||||||
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
coord.PushBack(bitmapDrawPos[3]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||||
|
const uniChar_t unicodeChar,
|
||||||
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
|
etk::Vector<texCoord_ts> & coordTex)
|
||||||
|
{
|
||||||
|
float posDrawX = textPos.x;
|
||||||
|
|
||||||
|
int32_t charIndex;
|
||||||
|
if (unicodeChar < 0x20) {
|
||||||
|
charIndex = 0;
|
||||||
|
} else if (unicodeChar < 0x80) {
|
||||||
|
charIndex = unicodeChar - 0x1F;
|
||||||
|
} else {
|
||||||
|
charIndex = 0;
|
||||||
|
for (int32_t iii=0x80-0x20; iii < m_listElement.Size(); iii++) {
|
||||||
|
if (m_listElement[iii].unicodeCharVal == unicodeChar) {
|
||||||
|
charIndex = iii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 0x01 == 0x20 == ' ';
|
||||||
|
if (unicodeChar != 0x01) {
|
||||||
|
/* Bitmap position
|
||||||
|
* xA xB
|
||||||
|
* yC *------*
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* yD *------*
|
||||||
|
*/
|
||||||
|
float dxA = posDrawX + m_listElement[charIndex].bearing.x;
|
||||||
|
float dxB = posDrawX + m_listElement[charIndex].bearing.x + m_listElement[charIndex].size.x;
|
||||||
|
float dyC = textPos.y + m_listElement[charIndex].bearing.y + m_height - m_size;
|
||||||
|
float dyD = dyC - m_listElement[charIndex].size.y;
|
||||||
|
|
||||||
|
float tuA = m_listElement[charIndex].posStart.u;
|
||||||
|
float tuB = m_listElement[charIndex].posStop.u;
|
||||||
|
float tvC = m_listElement[charIndex].posStart.v;
|
||||||
|
float tvD = m_listElement[charIndex].posStop.v;
|
||||||
|
|
||||||
|
|
||||||
|
// Clipping and drawing area
|
||||||
|
if( dxB <= dxA
|
||||||
|
|| dyD >= dyC) {
|
||||||
|
// nothing to do ...
|
||||||
|
} else {
|
||||||
|
/* Bitmap position
|
||||||
|
* 0------1
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
Vector2D<int32_t> bitmapDrawPos[4];
|
||||||
|
bitmapDrawPos[0].x = (int32_t)dxA;
|
||||||
|
bitmapDrawPos[1].x = (int32_t)dxB;
|
||||||
|
bitmapDrawPos[2].x = (int32_t)dxB;
|
||||||
|
bitmapDrawPos[3].x = (int32_t)dxA;
|
||||||
|
|
||||||
|
bitmapDrawPos[0].y = (int32_t)dyC;
|
||||||
|
bitmapDrawPos[1].y = (int32_t)dyC;
|
||||||
|
bitmapDrawPos[2].y = (int32_t)dyD;
|
||||||
|
bitmapDrawPos[3].y = (int32_t)dyD;
|
||||||
|
/* texture Position :
|
||||||
|
* 0------1
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
texCoord_ts texturePos[4];
|
||||||
|
texturePos[0].u = tuA;
|
||||||
|
texturePos[1].u = tuB;
|
||||||
|
texturePos[2].u = tuB;
|
||||||
|
texturePos[3].u = tuA;
|
||||||
|
|
||||||
|
texturePos[0].v = tvC;
|
||||||
|
texturePos[1].v = tvC;
|
||||||
|
texturePos[2].v = tvD;
|
||||||
|
texturePos[3].v = tvD;
|
||||||
|
|
||||||
|
// NOTE : Android does not support the Quads elements ...
|
||||||
|
/* Step 1 :
|
||||||
|
* ********
|
||||||
|
* ******
|
||||||
|
* ****
|
||||||
|
* **
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(texturePos[0]);
|
||||||
|
coordTex.PushBack(texturePos[1]);
|
||||||
|
coordTex.PushBack(texturePos[2]);
|
||||||
|
// set display positions :
|
||||||
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
coord.PushBack(bitmapDrawPos[1]);
|
||||||
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
|
||||||
|
/* Step 2 :
|
||||||
|
*
|
||||||
|
* **
|
||||||
|
* ****
|
||||||
|
* ******
|
||||||
|
* ********
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(texturePos[0]);
|
||||||
|
coordTex.PushBack(texturePos[2]);
|
||||||
|
coordTex.PushBack(texturePos[3]);
|
||||||
|
// set display positions :
|
||||||
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
coord.PushBack(bitmapDrawPos[3]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
posDrawX += m_listElement[charIndex].advance;
|
||||||
|
int32_t sizeOut = posDrawX - textPos.x;
|
||||||
|
textPos.x = posDrawX;
|
||||||
|
return sizeOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D<float> ewol::TexturedFont::GetSize(const etk::UString & unicodeString)
|
||||||
|
{
|
||||||
|
Vector2D<float> outputSize(0,m_height);
|
||||||
|
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
|
||||||
|
Vector2D<float> tmpp = GetSize(unicodeString[iii]);
|
||||||
|
outputSize.x += tmpp.x;
|
||||||
|
}
|
||||||
|
return outputSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Vector2D<float> ewol::TexturedFont::GetSize(const uniChar_t unicodeChar)
|
||||||
|
{
|
||||||
|
Vector2D<float> outputSize(0,m_height);
|
||||||
|
int32_t charIndex;
|
||||||
|
if (unicodeChar >= 0x80) {
|
||||||
|
charIndex = 0;
|
||||||
|
} else if (unicodeChar < 0x20) {
|
||||||
|
charIndex = 0;
|
||||||
|
} else if (unicodeChar < 0x80) {
|
||||||
|
charIndex = unicodeChar - 0x1F;
|
||||||
|
} else {
|
||||||
|
for (int32_t iii=0x80-0x20; iii < m_listElement.Size(); iii++) {
|
||||||
|
if (m_listElement[iii].unicodeCharVal == unicodeChar) {
|
||||||
|
charIndex = iii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO : Update if possible the mapping
|
||||||
|
charIndex = 0;
|
||||||
|
}
|
||||||
|
outputSize.x = m_listElement[charIndex].advance;
|
||||||
|
return outputSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
68
Sources/libewol/ewol/font/TexturedFont.h
Normal file
68
Sources/libewol/ewol/font/TexturedFont.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/font/TexturedFont.h
|
||||||
|
* @brief ewol Textured Font system (header)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/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_TEXTURED_FONT_H__
|
||||||
|
#define __EWOL_TEXTURED_FONT_H__
|
||||||
|
|
||||||
|
#include <ewol/font/Font.h>
|
||||||
|
#include <ewol/texture/Texture.h>
|
||||||
|
|
||||||
|
namespace ewol
|
||||||
|
{
|
||||||
|
class TexturedFont {
|
||||||
|
private:
|
||||||
|
int32_t m_size;
|
||||||
|
int32_t m_height;
|
||||||
|
ewol::Font* m_font;
|
||||||
|
ewol::Texture m_texture;
|
||||||
|
uint32_t m_counter;
|
||||||
|
etk::Vector<freeTypeFontElement_ts> m_listElement;
|
||||||
|
public:
|
||||||
|
TexturedFont(etk::UString fontName, int32_t size);
|
||||||
|
~TexturedFont(void);
|
||||||
|
bool HasName(etk::UString& fileName, int32_t size) { return (m_size!=size)?false:((m_font==NULL)?false:m_font->HasName(fileName)); };
|
||||||
|
void Increment(void) { m_counter++; };
|
||||||
|
bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; };
|
||||||
|
int32_t Draw(Vector2D<float> textPos,
|
||||||
|
const etk::UString& unicodeString,
|
||||||
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
|
etk::Vector<texCoord_ts> & coordTex);
|
||||||
|
int32_t Draw(Vector2D<float> textPos,
|
||||||
|
const uniChar_t unicodeChar,
|
||||||
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
|
etk::Vector<texCoord_ts> & coordTex);
|
||||||
|
Vector2D<float> GetSize(const etk::UString & unicodeString);
|
||||||
|
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
||||||
|
int32_t GetHeight(void) { return m_height; };
|
||||||
|
int32_t GetFontSize(void) { return m_size; };
|
||||||
|
ewol::Texture& GetTex(void) { return m_texture; };
|
||||||
|
etk::UString GetFontName(void) { if(NULL==m_font) { return "error"; } return m_font->GetName(); };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,105 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/oObject/2DText.cpp
|
|
||||||
* @brief ewol OpenGl Object system (Sources)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 09/11/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/oObject/2DText.h>
|
|
||||||
#include <ewol/openGl.h>
|
|
||||||
#include <ewol/texture/Texture.h>
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ "ewol::OObject2DText"
|
|
||||||
|
|
||||||
ewol::OObject2DText::OObject2DText(etk::UString FontName, int32_t size, draw::Color textColorFg)
|
|
||||||
{
|
|
||||||
m_textColorFg = textColorFg;
|
|
||||||
if (FontName == "") {
|
|
||||||
m_FontId = GetDefaultFontId();
|
|
||||||
} else {
|
|
||||||
EWOL_TODO("pas encore fait...");
|
|
||||||
//m_FontId = GetFontIdWithName(FontName);
|
|
||||||
m_FontId = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// open with default font ...
|
|
||||||
ewol::OObject2DText::OObject2DText(void)
|
|
||||||
{
|
|
||||||
m_textColorFg = 0x000000FF;
|
|
||||||
m_FontId = GetDefaultFontId();
|
|
||||||
}
|
|
||||||
|
|
||||||
ewol::OObject2DText::~OObject2DText(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::OObject2DText::Draw(void)
|
|
||||||
{
|
|
||||||
if (m_coord.Size()<=0) {
|
|
||||||
// TODO : a remètre ...
|
|
||||||
//EWOL_WARNING("Nothink to draw...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
glColor4ub(m_textColorFg.r, m_textColorFg.g, m_textColorFg.b, m_textColorFg.a);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, ewol::texture::GetGLID(m_FontTextureId));
|
|
||||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
|
||||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
|
||||||
glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] );
|
|
||||||
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
|
||||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
|
||||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
|
||||||
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
|
||||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::OObject2DText::Clear(void)
|
|
||||||
{
|
|
||||||
m_coord.Clear();
|
|
||||||
m_coordTex.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ewol::OObject2DText::Text(Vector2D<float> textPos, clipping_ts drawClipping, const etk::UString& unicodeString)
|
|
||||||
{
|
|
||||||
m_FontTextureId = 0;
|
|
||||||
if (m_FontId == -1) {
|
|
||||||
EWOL_ERROR("Font Id is not corectly defined");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ewol::DrawText(m_FontId, textPos, drawClipping, unicodeString, m_FontTextureId, m_coord, m_coordTex);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ewol::OObject2DText::Text(Vector2D<float> textPos, clipping_ts drawClipping, const uniChar_t unicodeChar)
|
|
||||||
{
|
|
||||||
m_FontTextureId = 0;
|
|
||||||
if (m_FontId == -1) {
|
|
||||||
EWOL_ERROR("Font Id is not corectly defined");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ewol::DrawText(m_FontId, textPos, drawClipping, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/oObject/2DText.h
|
|
||||||
* @brief ewol OpenGl Object system (header)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 09/11/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_O_OBJECT_2D_TEXT_H__
|
|
||||||
#define __EWOL_O_OBJECT_2D_TEXT_H__
|
|
||||||
|
|
||||||
#include <ewol/oObject/OObject.h>
|
|
||||||
#include <etk/UString.h>
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
class OObject2DText :public ewol::OObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OObject2DText(etk::UString FontName, int32_t size, draw::Color textColorFg);
|
|
||||||
OObject2DText(void);
|
|
||||||
virtual ~OObject2DText(void);
|
|
||||||
public:
|
|
||||||
virtual void Draw(void);
|
|
||||||
// set a specific text
|
|
||||||
void Clear(void);
|
|
||||||
int32_t Text(Vector2D<float> textPos, clipping_ts drawClipping, const etk::UString& unicodeString);
|
|
||||||
int32_t Text(Vector2D<float> textPos, clipping_ts drawClipping, const uniChar_t unicodeChar);
|
|
||||||
protected:
|
|
||||||
int32_t m_FontId; //!< font internal ID
|
|
||||||
draw::Color m_textColorFg; //!< text color ...
|
|
||||||
int32_t m_FontTextureId; //!< font internal Texture ID
|
|
||||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
|
||||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -25,59 +25,76 @@
|
|||||||
#include <ewol/oObject/2DTextColored.h>
|
#include <ewol/oObject/2DTextColored.h>
|
||||||
#include <ewol/openGl.h>
|
#include <ewol/openGl.h>
|
||||||
#include <ewol/texture/Texture.h>
|
#include <ewol/texture/Texture.h>
|
||||||
|
#include <ewol/font/FontManager.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol::OObject2DTextColored"
|
#define __class__ "ewol::OObject2DTextColored"
|
||||||
|
|
||||||
ewol::OObject2DTextColored::OObject2DTextColored(etk::UString FontName, int32_t size)
|
void ewol::OObject2DTextColored::SetFontProperty(etk::UString fontName, int32_t fontSize)
|
||||||
{
|
{
|
||||||
m_color = draw::color::black;
|
// remove old one
|
||||||
if (FontName == "") {
|
if (NULL != m_font) {
|
||||||
m_FontId = GetDefaultFontId();
|
ewol::font::TexturedRelease(m_font);
|
||||||
} else {
|
m_font = NULL;
|
||||||
EWOL_TODO("pas encore fait...");
|
|
||||||
//m_FontId = GetFontIdWithName(FontName);
|
|
||||||
m_FontId = -1;
|
|
||||||
}
|
}
|
||||||
/*
|
// link to new One
|
||||||
m_coord.SetIncrement(50000);
|
m_font = ewol::font::TexturedKeep(fontName, fontSize);
|
||||||
m_coordTex.SetIncrement(50000);
|
|
||||||
m_coordColor.SetIncrement(50000);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::OObject2DTextColored::OObject2DTextColored(int32_t fontID)
|
void ewol::OObject2DTextColored::SetFont(etk::UString fontName)
|
||||||
|
{
|
||||||
|
// get old size
|
||||||
|
int32_t fontSize = ewol::font::GetDefaultSize();
|
||||||
|
if (NULL != m_font) {
|
||||||
|
fontSize = m_font->GetFontSize();
|
||||||
|
}
|
||||||
|
SetFontProperty(fontName, fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::OObject2DTextColored::SetSize(int32_t fontSize)
|
||||||
|
{
|
||||||
|
// get old size
|
||||||
|
etk::UString fontName = ewol::font::GetDefaultFont();
|
||||||
|
if (NULL != m_font) {
|
||||||
|
fontName = m_font->GetFontName();
|
||||||
|
}
|
||||||
|
SetFontProperty(fontName, fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
ewol::OObject2DTextColored::OObject2DTextColored(etk::UString fontName, int32_t size) :
|
||||||
|
m_font(NULL)
|
||||||
{
|
{
|
||||||
m_color = draw::color::black;
|
m_color = draw::color::black;
|
||||||
if (fontID < 0) {
|
SetFontProperty(fontName, size);
|
||||||
m_FontId = GetDefaultFontId();
|
|
||||||
} else {
|
|
||||||
m_FontId = fontID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// open with default font ...
|
// open with default font ...
|
||||||
ewol::OObject2DTextColored::OObject2DTextColored(void)
|
ewol::OObject2DTextColored::OObject2DTextColored(void) :
|
||||||
|
m_font(NULL)
|
||||||
{
|
{
|
||||||
m_color = draw::color::black;
|
m_color = draw::color::black;
|
||||||
m_FontId = GetDefaultFontId();
|
SetFontProperty(ewol::font::GetDefaultFont(), ewol::font::GetDefaultSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ewol::OObject2DTextColored::~OObject2DTextColored(void)
|
ewol::OObject2DTextColored::~OObject2DTextColored(void)
|
||||||
{
|
{
|
||||||
|
if (NULL != m_font) {
|
||||||
|
ewol::font::TexturedRelease(m_font);
|
||||||
|
m_font = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::OObject2DTextColored::Draw(void)
|
void ewol::OObject2DTextColored::Draw(void)
|
||||||
{
|
{
|
||||||
if (m_coord.Size()<=0) {
|
if (m_coord.Size()<=0 || NULL == m_font) {
|
||||||
// TODO : a remètre ...
|
// TODO : a remètre ...
|
||||||
//EWOL_WARNING("Nothink to draw...");
|
//EWOL_WARNING("Nothink to draw...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, ewol::texture::GetGLID(m_FontTextureId));
|
glBindTexture(GL_TEXTURE_2D, m_font->GetTex().GetId());
|
||||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||||
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
|
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
|
||||||
@ -101,18 +118,18 @@ void ewol::OObject2DTextColored::Clear(void)
|
|||||||
|
|
||||||
int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const etk::UString& unicodeString)
|
int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const etk::UString& unicodeString)
|
||||||
{
|
{
|
||||||
m_FontTextureId = 0;
|
if (m_font == NULL) {
|
||||||
if (m_FontId == -1) {
|
|
||||||
EWOL_ERROR("Font Id is not corectly defined");
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t nbElementInTheArray = m_coord.Size();
|
int32_t nbElementInTheArray = m_coord.Size();
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (true==m_hasClipping) {
|
if (true==m_hasClipping) {
|
||||||
size = ewol::DrawText(m_FontId, textPos, m_clipping, unicodeString, m_FontTextureId, m_coord, m_coordTex);
|
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
||||||
} else {
|
} else {
|
||||||
size = ewol::DrawText(m_FontId, textPos, unicodeString, m_FontTextureId, m_coord, m_coordTex);
|
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
||||||
}
|
}
|
||||||
|
// set the color ...
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
m_coordColor.PushBack(m_color);
|
m_coordColor.PushBack(m_color);
|
||||||
}
|
}
|
||||||
@ -121,17 +138,16 @@ int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const etk::USt
|
|||||||
|
|
||||||
int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const uniChar_t unicodeChar)
|
int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const uniChar_t unicodeChar)
|
||||||
{
|
{
|
||||||
m_FontTextureId = 0;
|
if (m_font == NULL) {
|
||||||
if (m_FontId == -1) {
|
|
||||||
EWOL_ERROR("Font Id is not corectly defined");
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t nbElementInTheArray = m_coord.Size();
|
int32_t nbElementInTheArray = m_coord.Size();
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (true==m_hasClipping) {
|
if (true==m_hasClipping) {
|
||||||
size = ewol::DrawText(m_FontId, textPos, m_clipping, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
|
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
||||||
} else {
|
} else {
|
||||||
size = ewol::DrawText(m_FontId, textPos, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
|
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
||||||
}
|
}
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
m_coordColor.PushBack(m_color);
|
m_coordColor.PushBack(m_color);
|
||||||
@ -151,4 +167,21 @@ void ewol::OObject2DTextColored::SetColor(float red, float green, float blue, fl
|
|||||||
m_color = draw::Color(red, green, blue, alpha);
|
m_color = draw::Color(red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2D<float> ewol::OObject2DTextColored::GetSize(const uniChar_t unicodeChar)
|
||||||
|
{
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
|
return Vector2D<float>(0,0);
|
||||||
|
}
|
||||||
|
return m_font->GetSize(unicodeChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D<float> ewol::OObject2DTextColored::GetSize(const etk::UString& unicodeString)
|
||||||
|
{
|
||||||
|
if (m_font == NULL) {
|
||||||
|
EWOL_ERROR("Font Id is not corectly defined");
|
||||||
|
return Vector2D<float>(0,0);
|
||||||
|
}
|
||||||
|
return m_font->GetSize(unicodeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@
|
|||||||
#define __EWOL_O_OBJECT_2D_TEXT_COLORED_H__
|
#define __EWOL_O_OBJECT_2D_TEXT_COLORED_H__
|
||||||
|
|
||||||
#include <ewol/oObject/OObject.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/font/TexturedFont.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class OObject2DTextColored :public ewol::OObject
|
class OObject2DTextColored :public ewol::OObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OObject2DTextColored(etk::UString FontName, int32_t size);
|
OObject2DTextColored(etk::UString FontName, int32_t size);
|
||||||
OObject2DTextColored(int32_t fontID);
|
|
||||||
OObject2DTextColored(void);
|
OObject2DTextColored(void);
|
||||||
virtual ~OObject2DTextColored(void);
|
virtual ~OObject2DTextColored(void);
|
||||||
public:
|
public:
|
||||||
@ -44,15 +44,18 @@ namespace ewol {
|
|||||||
int32_t Text(Vector2D<float> textPos, const etk::UString& unicodeString);
|
int32_t Text(Vector2D<float> textPos, const etk::UString& unicodeString);
|
||||||
int32_t Text(Vector2D<float> textPos, const uniChar_t unicodeChar);
|
int32_t Text(Vector2D<float> textPos, const uniChar_t unicodeChar);
|
||||||
protected:
|
protected:
|
||||||
int32_t m_FontId; //!< font internal ID
|
ewol::TexturedFont* m_font; //!< ewol font system
|
||||||
draw::Color m_color; //!< tmp text color ...
|
draw::Color m_color; //!< tmp text color ...
|
||||||
int32_t m_FontTextureId; //!< font internal Texture ID
|
|
||||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||||
public:
|
public:
|
||||||
void SetFontID(int32_t fontID) { m_FontId = fontID; };
|
void SetFont(etk::UString fontName);
|
||||||
int32_t GetFontID(void) { return m_FontId; };
|
void SetSize(int32_t fontSize);
|
||||||
|
void SetFontProperty(etk::UString fontName, int32_t fontSize);
|
||||||
|
int32_t GetHeight(void) { return (NULL!=m_font)?m_font->GetHeight():10; };
|
||||||
|
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
||||||
|
Vector2D<float> GetSize(const etk::UString& unicodeString);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,29 +24,24 @@
|
|||||||
|
|
||||||
#include <ewol/oObject/2DTextured.h>
|
#include <ewol/oObject/2DTextured.h>
|
||||||
#include <ewol/texture/Texture.h>
|
#include <ewol/texture/Texture.h>
|
||||||
|
#include <ewol/texture/TextureManager.h>
|
||||||
#include <ewol/openGl.h>
|
#include <ewol/openGl.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol::OObject2DTextured"
|
#define __class__ "ewol::OObject2DTextured"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName)
|
|
||||||
{
|
|
||||||
EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\"");
|
|
||||||
m_textureId = ewol::texture::Load(textureName);
|
|
||||||
}
|
|
||||||
ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX, float sizeY)
|
ewol::OObject2DTextured::OObject2DTextured(etk::UString textureName, float sizeX, float sizeY)
|
||||||
{
|
{
|
||||||
EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\"");
|
EWOL_VERBOSE("Create OObject textured : \"" << textureName << "\"");
|
||||||
m_textureId = ewol::texture::Load(textureName, sizeX);
|
m_resource = ewol::textureManager::ImageKeep(textureName, Vector2D<int32_t>(sizeX,sizeY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ewol::OObject2DTextured::~OObject2DTextured(void)
|
ewol::OObject2DTextured::~OObject2DTextured(void)
|
||||||
{
|
{
|
||||||
if (-1 != m_textureId) {
|
if (NULL != m_resource) {
|
||||||
ewol::texture::UnLoad(m_textureId);
|
ewol::textureManager::ImageRelease(m_resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,14 +50,14 @@ void ewol::OObject2DTextured::Draw(void)
|
|||||||
if (m_coord.Size()<=0) {
|
if (m_coord.Size()<=0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_textureId == -1) {
|
if (NULL == m_resource) {
|
||||||
EWOL_WARNING("Texture does not exist ...");
|
EWOL_WARNING("Texture does not exist ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
//EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId));
|
//EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId));
|
||||||
glBindTexture(GL_TEXTURE_2D, ewol::texture::GetGLID(m_textureId));
|
glBindTexture(GL_TEXTURE_2D, m_resource->GetId() );
|
||||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||||
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
|
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
|
||||||
|
@ -26,14 +26,13 @@
|
|||||||
#define __EWOL_O_OBJECT_2D_TEXTURED_H__
|
#define __EWOL_O_OBJECT_2D_TEXTURED_H__
|
||||||
|
|
||||||
#include <ewol/oObject/OObject.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
#include <ewol/Texture/Texture.h>
|
#include <ewol/texture/Texture.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class OObject2DTextured :public ewol::OObject
|
class OObject2DTextured :public ewol::OObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OObject2DTextured(etk::UString textureName);
|
OObject2DTextured(etk::UString textureName, float sizeX=-1, float sizeY=-1);
|
||||||
OObject2DTextured(etk::UString textureName, float sizeX, float sizeY);
|
|
||||||
virtual ~OObject2DTextured(void);
|
virtual ~OObject2DTextured(void);
|
||||||
public:
|
public:
|
||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
@ -41,7 +40,7 @@ namespace ewol {
|
|||||||
void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0, draw::Color tmpColor=draw::color::white);
|
void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0, draw::Color tmpColor=draw::color::white);
|
||||||
void Rectangle(float x, float y, float w, float h, draw::Color tmpColor);
|
void Rectangle(float x, float y, float w, float h, draw::Color tmpColor);
|
||||||
protected:
|
protected:
|
||||||
ewol::Texture
|
ewol::Texture* m_resource; //!< texture resources
|
||||||
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||||
|
@ -73,6 +73,5 @@ namespace ewol {
|
|||||||
|
|
||||||
#include <ewol/oObject/2DTextured.h>
|
#include <ewol/oObject/2DTextured.h>
|
||||||
#include <ewol/oObject/2DColored.h>
|
#include <ewol/oObject/2DColored.h>
|
||||||
#include <ewol/oObject/2DText.h>
|
|
||||||
#include <ewol/oObject/2DTextColored.h>
|
#include <ewol/oObject/2DTextColored.h>
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <ewol/oObject/Sprite.h>
|
#include <ewol/oObject/Sprite.h>
|
||||||
#include <ewol/texture/Texture.h>
|
#include <ewol/texture/Texture.h>
|
||||||
|
#include <ewol/texture/TextureManager.h>
|
||||||
#include <ewol/openGl.h>
|
#include <ewol/openGl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@ -31,26 +32,18 @@
|
|||||||
#define __class__ "Sprite"
|
#define __class__ "Sprite"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ewol::Sprite::Sprite(etk::UString spriteName)
|
|
||||||
{
|
|
||||||
m_name = spriteName;
|
|
||||||
EWOL_VERBOSE("Create Sprite : \"" << m_name << "\"");
|
|
||||||
m_textureId = ewol::texture::Load(m_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
ewol::Sprite::Sprite(etk::UString spriteName, float sizeX, float sizeY)
|
ewol::Sprite::Sprite(etk::UString spriteName, float sizeX, float sizeY)
|
||||||
{
|
{
|
||||||
m_name = spriteName;
|
m_name = spriteName;
|
||||||
EWOL_VERBOSE("Create Sprite : \"" << m_name << "\"");
|
EWOL_VERBOSE("Create Sprite : \"" << m_name << "\"");
|
||||||
m_textureId = ewol::texture::Load(m_name, sizeX);
|
m_resource = ewol::textureManager::ImageKeep(m_name, Vector2D<int32_t>(sizeX,sizeY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ewol::Sprite::~Sprite(void)
|
ewol::Sprite::~Sprite(void)
|
||||||
{
|
{
|
||||||
if (-1 != m_textureId) {
|
if (NULL != m_resource) {
|
||||||
ewol::texture::UnLoad(m_textureId);
|
ewol::textureManager::ImageRelease(m_resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +53,13 @@ void ewol::Sprite::Draw(void)
|
|||||||
//EWOL_WARNING("Nothink to draw...");
|
//EWOL_WARNING("Nothink to draw...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_textureId == -1) {
|
if (NULL == m_resource) {
|
||||||
EWOL_WARNING("Texture does not exist ...");
|
EWOL_WARNING("Texture does not exist ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
//EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId));
|
//EWOL_WARNING("Draw with texture : " << m_textureId << " ==> ogl=" << ewol::texture::GetGLID(m_textureId));
|
||||||
glBindTexture(GL_TEXTURE_2D, ewol::texture::GetGLID(m_textureId));
|
glBindTexture(GL_TEXTURE_2D, m_resource->GetId());
|
||||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||||
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
|
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define __EWOL_O_OBJECT_SPRITE_H__
|
#define __EWOL_O_OBJECT_SPRITE_H__
|
||||||
|
|
||||||
#include <ewol/oObject/OObject.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/texture/Texture.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class Sprite :public ewol::OObject
|
class Sprite :public ewol::OObject
|
||||||
@ -33,8 +34,7 @@ namespace ewol {
|
|||||||
private:
|
private:
|
||||||
etk::UString m_name;
|
etk::UString m_name;
|
||||||
public:
|
public:
|
||||||
Sprite(etk::UString spriteName);
|
Sprite(etk::UString spriteName, float sizeX=-1, float sizeY=-1);
|
||||||
Sprite(etk::UString spriteName, float sizeX, float sizeY);
|
|
||||||
virtual ~Sprite(void);
|
virtual ~Sprite(void);
|
||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
@ -44,7 +44,7 @@ namespace ewol {
|
|||||||
void Element(Vector3D<float> pos, float size, float angle, draw::Color tmpColor);
|
void Element(Vector3D<float> pos, float size, float angle, draw::Color tmpColor);
|
||||||
bool HasName(etk::UString& name) { return name == m_name; };
|
bool HasName(etk::UString& name) { return name == m_name; };
|
||||||
protected:
|
protected:
|
||||||
int32_t m_textureId; //!< texture internal ID
|
ewol::Texture* m_resource; //!< texture resources
|
||||||
etk::Vector<Vector3D<float> > m_coord; //!< internal coord of the object
|
etk::Vector<Vector3D<float> > m_coord; //!< internal coord of the object
|
||||||
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||||
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
etk::Vector<draw::Color> m_coordColor; //!< internal color of the different point
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <ewol/os/eSystemInput.h>
|
#include <ewol/os/eSystemInput.h>
|
||||||
#include <ewol/openGl.h>
|
#include <ewol/openGl.h>
|
||||||
#include <ewol/os/Fps.h>
|
#include <ewol/os/Fps.h>
|
||||||
|
#include <ewol/font/FontManager.h>
|
||||||
|
|
||||||
static ewol::Windows* windowsCurrent = NULL;
|
static ewol::Windows* windowsCurrent = NULL;
|
||||||
static Vector2D<int32_t> windowsSize(320, 480);
|
static Vector2D<int32_t> windowsSize(320, 480);
|
||||||
@ -244,7 +245,7 @@ void eSystem::Init(void)
|
|||||||
l_managementInput.Reset();
|
l_managementInput.Reset();
|
||||||
ewol::textureManager::Init();
|
ewol::textureManager::Init();
|
||||||
ewol::widgetManager::Init();
|
ewol::widgetManager::Init();
|
||||||
ewol::InitFont();
|
ewol::font::Init();
|
||||||
ewol::shortCut::Init();
|
ewol::shortCut::Init();
|
||||||
APP_Init();
|
APP_Init();
|
||||||
isGlobalSystemInit = true;
|
isGlobalSystemInit = true;
|
||||||
@ -265,8 +266,8 @@ void eSystem::UnInit(void)
|
|||||||
// call application to uninit
|
// call application to uninit
|
||||||
APP_UnInit();
|
APP_UnInit();
|
||||||
ewol::shortCut::UnInit();
|
ewol::shortCut::UnInit();
|
||||||
ewol::UnInitFont();
|
|
||||||
ewol::widgetManager::UnInit();
|
ewol::widgetManager::UnInit();
|
||||||
|
ewol::font::UnInit();
|
||||||
ewol::EObjectMessageMultiCast::UnInit();
|
ewol::EObjectMessageMultiCast::UnInit();
|
||||||
ewol::EObjectManager::UnInit();
|
ewol::EObjectManager::UnInit();
|
||||||
ewol::textureManager::UnInit();
|
ewol::textureManager::UnInit();
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/resources/ResourcesImage.cpp
|
|
||||||
* @brief ewol Resources image system (sources)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 21/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.
|
|
||||||
*
|
|
||||||
*******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/resources/ResourcesManager.h>
|
|
||||||
|
|
||||||
ewol::ResourcesImage::ResourcesImage(etk::UString fileName, Vector2D<int32_t> size) :
|
|
||||||
m_resourceID(0),
|
|
||||||
m_counter(1),
|
|
||||||
m_image(size)
|
|
||||||
{
|
|
||||||
m_resourceID = ewol::resourcesManager::Add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ewol::ResourcesImage::~ResourcesImage(void)
|
|
||||||
{
|
|
||||||
ewol::resourcesManager::Rm(this);
|
|
||||||
}
|
|
@ -1,128 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/resources/ResourcesManager.cpp
|
|
||||||
* @brief ewol Resources manager system (Sources)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 21/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.
|
|
||||||
*
|
|
||||||
*******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <etk/Types.h>
|
|
||||||
#include <ewol/Debug.h>
|
|
||||||
#include <etk/File.h>
|
|
||||||
#include <etk/Vector.h>
|
|
||||||
#include <ewol/resources/ResourcesManager.h>
|
|
||||||
|
|
||||||
static etk::Vector<ewol::ResourcesImage *> l_imageList;
|
|
||||||
|
|
||||||
static uint32_t l_uniqueIdResources = 0;
|
|
||||||
|
|
||||||
void ewol::resourcesManager::Init(void)
|
|
||||||
{
|
|
||||||
// nothing to do in théory then, we clean the buffers :
|
|
||||||
// NOTE : If we do domething here, then the system does not work corectly
|
|
||||||
l_imageList.Clear();
|
|
||||||
l_uniqueIdResources = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::resourcesManager::UnInit(void)
|
|
||||||
{
|
|
||||||
for (int32_t iii=0; iii<l_imageList.Size(); iii++) {
|
|
||||||
if (l_imageList[iii] != NULL) {
|
|
||||||
delete(l_imageList[iii]);
|
|
||||||
l_imageList[iii] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
l_imageList.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// note : Return the UniqueID ...
|
|
||||||
uint32_t ewol::resourcesManager::Add(ewol::ResourcesImage *object)
|
|
||||||
{
|
|
||||||
if (object==NULL) {
|
|
||||||
EWOL_CRITICAL("try to add an Image Resources with NULL pointer ...");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
for (int32_t iii=0; iii<l_imageList.Size(); iii++) {
|
|
||||||
if (l_imageList[iii] != NULL) {
|
|
||||||
if (l_imageList[iii] == object) {
|
|
||||||
EWOL_CRITICAL("try to add a Image resources a second time ...");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
l_uniqueIdResources ++;
|
|
||||||
// add it in the list
|
|
||||||
l_imageList.PushBack(object);
|
|
||||||
// return his ID ...
|
|
||||||
return l_uniqueIdResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::resourcesManager::Rm(ewol::ResourcesImage *object)
|
|
||||||
{
|
|
||||||
if (object==NULL) {
|
|
||||||
EWOL_CRITICAL("try to remove a texture with NULL pointer ...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int32_t iii=l_imageList.Size()-1; iii>=0; iii--) {
|
|
||||||
if (l_imageList[iii] != NULL) {
|
|
||||||
if (l_imageList[iii] == object) {
|
|
||||||
// we find the texture :
|
|
||||||
l_imageList.Erase(iii);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EWOL_CRITICAL("Try to remove an Image resources that is not present in the resources pool");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ewol::ResourcesImage* ewol::resourcesManager::ImageKeep(etk::UString fileName, Vector2D<int32_t> size)
|
|
||||||
{
|
|
||||||
for (int32_t iii=l_imageList.Size()-1; iii>=0; iii--) {
|
|
||||||
if (l_imageList[iii] != NULL) {
|
|
||||||
if( l_imageList[iii]->HasName(fileName)
|
|
||||||
&& l_imageList[iii]->Get().GetSize() == size) {
|
|
||||||
l_imageList[iii]->Increment();
|
|
||||||
return l_imageList[iii];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ewol::ResourcesImage* tmpResources = new ewol::ResourcesImage(fileName, size);
|
|
||||||
if (NULL == tmpResources) {
|
|
||||||
EWOL_ERROR("allocation error of a resource Image : " << fileName);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
l_imageList.PushBack(tmpResources);
|
|
||||||
return tmpResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::resourcesManager::ImageRelease(ewol::ResourcesImage* object)
|
|
||||||
{
|
|
||||||
for (int32_t iii=l_imageList.Size()-1; iii>=0; iii--) {
|
|
||||||
if (l_imageList[iii] != NULL) {
|
|
||||||
if(l_imageList[iii] == object) {
|
|
||||||
if (true == l_imageList[iii]->Decrement()) {
|
|
||||||
delete(l_imageList[iii]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/resources/ResourcesManager.h
|
|
||||||
* @brief ewol Resources manager system (header)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 21/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_RESOURCES_MANAGER_H__
|
|
||||||
#define __EWOL_RESOURCES_MANAGER_H__
|
|
||||||
|
|
||||||
#include <etk/Types.h>
|
|
||||||
#include <ewol/Debug.h>
|
|
||||||
#include <etk/File.h>
|
|
||||||
#include <ewol/resources/ResourcesImage.h>
|
|
||||||
|
|
||||||
namespace ewol
|
|
||||||
{
|
|
||||||
namespace resourcesManager {
|
|
||||||
void Init(void);
|
|
||||||
void UnInit(void);
|
|
||||||
uint32_t Add(ewol::ResourcesImage* object);
|
|
||||||
void Rm(ewol::ResourcesImage* object);
|
|
||||||
//uint32_t Add(audio::Track* object);
|
|
||||||
//void Rm(audio::Track* object);
|
|
||||||
|
|
||||||
ewol::ResourcesImage* ImageKeep(etk::UString fileName, Vector2D<int32_t> size);
|
|
||||||
void ImageRelease(ewol::ResourcesImage* object);
|
|
||||||
//audio::Track* AudioKeep(etk::UString fileName, Vector2D<int32_t> size);
|
|
||||||
//void AudioRelease(audio::Track* object);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <ewol/texture/Texture.h>
|
#include <ewol/texture/Texture.h>
|
||||||
|
#include <ewol/texture/TextureManager.h>
|
||||||
#include <ewol/openGl.h>
|
#include <ewol/openGl.h>
|
||||||
#include <ewol/ewol.h>
|
#include <ewol/ewol.h>
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ void ewol::Texture::UpdateContext(void)
|
|||||||
// now the data is loaded
|
// now the data is loaded
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
} else {
|
} else {
|
||||||
EWOL_TODO("UPDATE Texture ...")
|
EWOL_TODO("UPDATE Texture ...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +129,12 @@ void ewol::Texture::Flush(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Texture::SetImageSize(Vector2D<int32_t> newSize)
|
||||||
|
{
|
||||||
|
newSize.x = nextP2(newSize.x);
|
||||||
|
newSize.y = nextP2(newSize.y);
|
||||||
|
m_data.Resize(newSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,10 +31,6 @@
|
|||||||
#include <ewol/openGl.h>
|
#include <ewol/openGl.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
// TODO : remove this deprecated element
|
|
||||||
namespace texture {
|
|
||||||
inline int32_t GetGLID(int32_t m_FontTextureId) { return 0; };
|
|
||||||
};
|
|
||||||
class Texture {
|
class Texture {
|
||||||
private:
|
private:
|
||||||
uint32_t m_uniqueId;
|
uint32_t m_uniqueId;
|
||||||
@ -59,6 +55,8 @@ namespace ewol {
|
|||||||
public:
|
public:
|
||||||
Texture(void);
|
Texture(void);
|
||||||
~Texture(void);
|
~Texture(void);
|
||||||
|
// you must set the size here, because it will be set in multiple of pow(2)
|
||||||
|
void SetImageSize(Vector2D<int32_t> newSize);
|
||||||
// get the reference on this image to draw nomething on it ...
|
// get the reference on this image to draw nomething on it ...
|
||||||
inline draw::Image& Get(void) { return m_data; };
|
inline draw::Image& Get(void) { return m_data; };
|
||||||
// Flush the data to send it at the OpenGl system
|
// Flush the data to send it at the OpenGl system
|
||||||
|
@ -22,19 +22,54 @@
|
|||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <draw/Image.h>
|
||||||
#include <ewol/texture/TextureBMP.h>
|
#include <ewol/texture/TextureBMP.h>
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int16_t bfType;
|
||||||
|
int32_t bfSize;
|
||||||
|
int32_t bfReserved;
|
||||||
|
int32_t bfOffBits;
|
||||||
|
} bitmapFileHeader_ts;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int32_t biSize;
|
||||||
|
int32_t biWidth;
|
||||||
|
int32_t biHeight;
|
||||||
|
int16_t biPlanes;
|
||||||
|
int16_t biBitCount;
|
||||||
|
int32_t biCompression;
|
||||||
|
int32_t biSizeImage;
|
||||||
|
int32_t biXPelsPerMeter;
|
||||||
|
int32_t biYPelsPerMeter;
|
||||||
|
int32_t biClrUsed;
|
||||||
|
int32_t biClrImportant;
|
||||||
|
} bitmapInfoHeader_ts;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BITS_16_R5G6B5,
|
||||||
|
BITS_16_X1R5G5B5,
|
||||||
|
BITS_24_R8G8B8,
|
||||||
|
BITS_32_X8R8G8B8,
|
||||||
|
BITS_32_A8R8G8B8
|
||||||
|
} modeBitmap_te;
|
||||||
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "texture::TextureBMP"
|
#define __class__ "texture::TextureBMP"
|
||||||
|
|
||||||
ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_dataGenerate(NULL)
|
void ewol::imageBMP::GenerateImage(etk::File & fileName, draw::Image & ouputImage)
|
||||||
{
|
{
|
||||||
m_dataMode = BITS_16_R5G6B5;
|
modeBitmap_te m_dataMode = BITS_16_R5G6B5;
|
||||||
m_width = 0;
|
int32_t m_width = 0;
|
||||||
m_height = 0;
|
int32_t m_height = 0;
|
||||||
m_size = 0;
|
bitmapFileHeader_ts m_FileHeader;
|
||||||
|
bitmapInfoHeader_ts m_InfoHeader;
|
||||||
|
|
||||||
// Get the fileSize ...
|
// Get the fileSize ...
|
||||||
/*if (fileName.Size() < (int32_t)(sizeof(bitmapFileHeader_ts) + sizeof(bitmapInfoHeader_ts) ) ) {
|
/*if (fileName.Size() < (int32_t)(sizeof(bitmapFileHeader_ts) + sizeof(bitmapInfoHeader_ts) ) ) {
|
||||||
@ -99,17 +134,21 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
}
|
}
|
||||||
m_width = m_InfoHeader.biWidth;
|
m_width = m_InfoHeader.biWidth;
|
||||||
m_height = m_InfoHeader.biHeight;
|
m_height = m_InfoHeader.biHeight;
|
||||||
|
// reallocate the image
|
||||||
|
ouputImage.Resize(Vector2D<int32_t>(m_width,m_height));
|
||||||
|
|
||||||
|
uint8_t* m_data = NULL;
|
||||||
if(0 != m_InfoHeader.biSizeImage)
|
if(0 != m_InfoHeader.biSizeImage)
|
||||||
{
|
{
|
||||||
m_data=new uint8_t[m_InfoHeader.biSizeImage];
|
m_data=new uint8_t[m_InfoHeader.biSizeImage];
|
||||||
if (fileName.fRead(m_data,m_InfoHeader.biSizeImage,1) != 1){
|
if (fileName.fRead(m_data,m_InfoHeader.biSizeImage,1) != 1){
|
||||||
EWOL_CRITICAL("Can not read the file with the good size...");
|
EWOL_CRITICAL("Can not read the file with the good size...");
|
||||||
}
|
}
|
||||||
// allocate the destination data ...
|
|
||||||
m_dataGenerate=new uint8_t[m_width*m_height*4];
|
|
||||||
}
|
}
|
||||||
fileName.fClose();
|
fileName.fClose();
|
||||||
|
|
||||||
|
draw::Color tmpColor(0,0,0,0);
|
||||||
|
|
||||||
// need now to generate RGBA data ...
|
// need now to generate RGBA data ...
|
||||||
switch(m_dataMode)
|
switch(m_dataMode)
|
||||||
{
|
{
|
||||||
@ -118,10 +157,11 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
uint16_t * pointer = (uint16_t*)m_data;
|
uint16_t * pointer = (uint16_t*)m_data;
|
||||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = (int8_t)((*pointer & 0xF800) >> 8);
|
tmpColor.r = (int8_t)((*pointer & 0xF800) >> 8);
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = (int8_t)((*pointer & 0x07E0) >> 3);
|
tmpColor.g = (int8_t)((*pointer & 0x07E0) >> 3);
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = (int8_t)(*pointer << 3);
|
tmpColor.b = (int8_t)(*pointer << 3);
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
|
tmpColor.a = 0xFF;
|
||||||
|
ouputImage.Set(Vector2D<int32_t>(xxx,yyy), tmpColor);
|
||||||
pointer++;
|
pointer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,10 +172,11 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
uint16_t * pointer = (uint16_t*)m_data;
|
uint16_t * pointer = (uint16_t*)m_data;
|
||||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = (int8_t)((*pointer & 0x7C00) >> 7);
|
tmpColor.r = (int8_t)((*pointer & 0x7C00) >> 7);
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = (int8_t)((*pointer & 0x03E0) >> 2);
|
tmpColor.g = (int8_t)((*pointer & 0x03E0) >> 2);
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = (int8_t)(*pointer << 3);
|
tmpColor.b = (int8_t)(*pointer << 3);
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
|
tmpColor.a = 0xFF;
|
||||||
|
ouputImage.Set(Vector2D<int32_t>(xxx,yyy), tmpColor);
|
||||||
pointer++;
|
pointer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,10 +187,11 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
uint8_t * pointer = m_data;
|
uint8_t * pointer = m_data;
|
||||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = *pointer++;
|
tmpColor.r = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = *pointer++;
|
tmpColor.g = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = *pointer++;
|
tmpColor.b = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
|
tmpColor.a = 0xFF;
|
||||||
|
ouputImage.Set(Vector2D<int32_t>(xxx,yyy), tmpColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,10 +202,11 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||||
pointer++;
|
pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = *pointer++;
|
tmpColor.r = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = *pointer++;
|
tmpColor.g = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = *pointer++;
|
tmpColor.b = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
|
tmpColor.a = 0xFF;
|
||||||
|
ouputImage.Set(Vector2D<int32_t>(xxx,yyy), tmpColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,10 +216,11 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
uint8_t * pointer = m_data;
|
uint8_t * pointer = m_data;
|
||||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = *pointer++;
|
tmpColor.r = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = *pointer++;
|
tmpColor.g = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = *pointer++;
|
tmpColor.b = *pointer++;
|
||||||
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = *pointer++;
|
tmpColor.a = *pointer++;
|
||||||
|
ouputImage.Set(Vector2D<int32_t>(xxx,yyy), tmpColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,55 +229,12 @@ ewol::texture::TextureBMP::TextureBMP(etk::File & fileName) : m_data(NULL), m_da
|
|||||||
EWOL_DEBUG(" mode = ERROR");
|
EWOL_DEBUG(" mode = ERROR");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ewol::texture::TextureBMP::~TextureBMP(void)
|
|
||||||
{
|
|
||||||
if (NULL != m_data) {
|
if (NULL != m_data) {
|
||||||
delete(m_data);
|
delete(m_data);
|
||||||
}
|
m_data=NULL;
|
||||||
if (NULL != m_dataGenerate) {
|
|
||||||
delete(m_dataGenerate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
bool ewol::texture::TextureBMP::LoadOK(void)
|
|
||||||
{
|
|
||||||
if (NULL != m_dataGenerate) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int32_t ewol::texture::TextureBMP::Width(void)
|
|
||||||
{
|
|
||||||
return m_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t ewol::texture::TextureBMP::Height(void)
|
|
||||||
{
|
|
||||||
return m_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t * ewol::texture::TextureBMP::Data(void)
|
|
||||||
{
|
|
||||||
return m_dataGenerate;
|
|
||||||
};
|
|
||||||
uint8_t * ewol::texture::TextureBMP::RawData(void)
|
|
||||||
{
|
|
||||||
return m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t ewol::texture::TextureBMP::DataSize(void)
|
|
||||||
{
|
|
||||||
if (NULL == m_dataGenerate) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return m_width*m_height*4;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ewol::texture::TextureBMP::Display(void)
|
void ewol::texture::TextureBMP::Display(void)
|
||||||
{
|
{
|
||||||
if (NULL == m_data) {
|
if (NULL == m_data) {
|
||||||
@ -284,3 +285,4 @@ void ewol::texture::TextureBMP::Display(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -28,65 +28,13 @@
|
|||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <etk/File.h>
|
#include <etk/File.h>
|
||||||
|
#include <draw/Image.h>
|
||||||
|
|
||||||
namespace ewol
|
namespace ewol
|
||||||
{
|
{
|
||||||
namespace texture {
|
namespace imageBMP
|
||||||
#pragma pack(push,1)
|
|
||||||
typedef struct
|
|
||||||
{
|
{
|
||||||
int16_t bfType;
|
void GenerateImage(etk::File & fileName, draw::Image & ouputImage);
|
||||||
int32_t bfSize;
|
|
||||||
int32_t bfReserved;
|
|
||||||
int32_t bfOffBits;
|
|
||||||
} bitmapFileHeader_ts;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int32_t biSize;
|
|
||||||
int32_t biWidth;
|
|
||||||
int32_t biHeight;
|
|
||||||
int16_t biPlanes;
|
|
||||||
int16_t biBitCount;
|
|
||||||
int32_t biCompression;
|
|
||||||
int32_t biSizeImage;
|
|
||||||
int32_t biXPelsPerMeter;
|
|
||||||
int32_t biYPelsPerMeter;
|
|
||||||
int32_t biClrUsed;
|
|
||||||
int32_t biClrImportant;
|
|
||||||
} bitmapInfoHeader_ts;
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
BITS_16_R5G6B5,
|
|
||||||
BITS_16_X1R5G5B5,
|
|
||||||
BITS_24_R8G8B8,
|
|
||||||
BITS_32_X8R8G8B8,
|
|
||||||
BITS_32_A8R8G8B8
|
|
||||||
} modeBitmap_te;
|
|
||||||
|
|
||||||
class TextureBMP
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
modeBitmap_te m_dataMode;
|
|
||||||
int32_t m_width;
|
|
||||||
int32_t m_height;
|
|
||||||
int32_t m_size;
|
|
||||||
uint8_t * m_data;
|
|
||||||
uint8_t * m_dataGenerate;
|
|
||||||
bitmapFileHeader_ts m_FileHeader;
|
|
||||||
bitmapInfoHeader_ts m_InfoHeader;
|
|
||||||
public:
|
|
||||||
TextureBMP(etk::File & fileName);
|
|
||||||
~TextureBMP(void);
|
|
||||||
bool LoadOK(void);
|
|
||||||
int32_t Width(void);
|
|
||||||
int32_t Height(void);
|
|
||||||
uint8_t * Data(void);
|
|
||||||
uint8_t * RawData(void);
|
|
||||||
uint32_t DataSize(void);
|
|
||||||
void Display(void);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
73
Sources/libewol/ewol/texture/TextureFile.cpp
Normal file
73
Sources/libewol/ewol/texture/TextureFile.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/texture/TextureFile.cpp
|
||||||
|
* @brief ewol tecture file (sources)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/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.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ewol/texture/TextureManager.h>
|
||||||
|
#include <ewol/texture/TextureFile.h>
|
||||||
|
#include <ewol/texture/Texture.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <ewol/texture/TextureBMP.h>
|
||||||
|
#include <parserSVG/parserSVG.h>
|
||||||
|
//#include <ewol/texture/TexturePNG.h>
|
||||||
|
|
||||||
|
|
||||||
|
ewol::TextureFile::TextureFile(etk::UString tmpfileName, Vector2D<int32_t> size) :
|
||||||
|
m_counter(1),
|
||||||
|
m_fileName(tmpfileName)
|
||||||
|
{
|
||||||
|
etk::File fileName(tmpfileName, etk::FILE_TYPE_DATA);
|
||||||
|
if (false == fileName.Exist()) {
|
||||||
|
EWOL_ERROR("File does not Exist ... " << fileName);
|
||||||
|
} else {
|
||||||
|
// get the upper paw2 ot the size requested...
|
||||||
|
if (size.x>0 && size.y>0) {
|
||||||
|
m_texture.SetImageSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::UString fileExtention = fileName.GetExtention();
|
||||||
|
if (fileExtention == "bmp") {
|
||||||
|
// generate the texture
|
||||||
|
ewol::imageBMP::GenerateImage(fileName, m_texture.Get());
|
||||||
|
} else if (fileExtention == "svg") {
|
||||||
|
svg::Parser m_element(fileName);
|
||||||
|
if (false == m_element.IsLoadOk()) {
|
||||||
|
EWOL_ERROR("Error To load SVG file " << fileName.GetCompleateName() );
|
||||||
|
} else {
|
||||||
|
m_element.GenerateAnImage(size, m_texture.Get());
|
||||||
|
}
|
||||||
|
} else if (fileExtention == "png") {
|
||||||
|
EWOL_ERROR("Extention not supported now, but soon " << fileName );
|
||||||
|
} else {
|
||||||
|
EWOL_ERROR("Extention not managed " << fileName << " Sopported extention : .bmp / .svg / .png");
|
||||||
|
}
|
||||||
|
m_texture.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::TextureFile::~TextureFile(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* @file ewol/resources/ResourcesImage.h
|
* @file ewol/texture/TextureFile.cpp
|
||||||
* @brief ewol Resources image system (header)
|
* @brief ewol tecture file (sources)
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
* @date 21/08/2012
|
* @date 22/08/2012
|
||||||
* @par Project
|
* @par Project
|
||||||
* ewol
|
* ewol
|
||||||
*
|
*
|
||||||
@ -22,28 +22,28 @@
|
|||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __EWOL_RESOURCES_IMAGE_H__
|
#ifndef __EWOL_TEXTURE_FILE_H__
|
||||||
#define __EWOL_RESOURCES_IMAGE_H__
|
#define __EWOL_TEXTURE_FILE_H__
|
||||||
|
|
||||||
#include <etk/UString.h>
|
#include <etk/UString.h>
|
||||||
#include <draw/Image.h>
|
#include <draw/Image.h>
|
||||||
|
#include <ewol/texture/Texture.h>
|
||||||
|
|
||||||
namespace ewol
|
namespace ewol
|
||||||
{
|
{
|
||||||
class ResourcesImage
|
class TextureFile
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
uint32_t m_resourceID;
|
|
||||||
uint32_t m_counter;
|
uint32_t m_counter;
|
||||||
draw::Image m_image;
|
ewol::Texture m_texture;
|
||||||
etk::UString m_fileName;
|
etk::UString m_fileName;
|
||||||
public:
|
public:
|
||||||
ResourcesImage(etk::UString fileName, Vector2D<int32_t> size);
|
TextureFile(etk::UString fileName, Vector2D<int32_t> size);
|
||||||
~ResourcesImage(void);
|
~TextureFile(void);
|
||||||
bool HasName(etk::UString& fileName) { return fileName==m_fileName; };
|
bool HasName(etk::UString& fileName) { return fileName==m_fileName; };
|
||||||
void Increment(void) { m_counter++; };
|
void Increment(void) { m_counter++; };
|
||||||
bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; };
|
bool Decrement(void) { m_counter--; return (m_counter==0)?true:false; };
|
||||||
draw::Image& Get(void) { return m_image; };
|
ewol::Texture& Get(void) { return m_texture; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -27,10 +27,11 @@
|
|||||||
#include <etk/File.h>
|
#include <etk/File.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
#include <ewol/texture/TextureManager.h>
|
#include <ewol/texture/TextureManager.h>
|
||||||
|
#include <ewol/texture/TextureFile.h>
|
||||||
|
|
||||||
|
|
||||||
static etk::Vector<ewol::Texture *object> l_textureList;
|
static etk::Vector<ewol::Texture*> l_textureList;
|
||||||
static etk::Vector<ewol::Texture *object> l_textureListToUpdate;
|
static etk::Vector<ewol::Texture*> l_textureListToUpdate;
|
||||||
|
|
||||||
static uint32_t l_uniqueIdTexture = 0;
|
static uint32_t l_uniqueIdTexture = 0;
|
||||||
static bool l_contextHasBeenRemoved = true;
|
static bool l_contextHasBeenRemoved = true;
|
||||||
@ -117,7 +118,7 @@ void ewol::textureManager::Update(ewol::Texture *object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add it ...
|
// add it ...
|
||||||
l_textureListToUpdate.pushBack(object);
|
l_textureListToUpdate.PushBack(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specific to load or update the data in the openGl context ==> system use only
|
// Specific to load or update the data in the openGl context ==> system use only
|
||||||
@ -153,3 +154,49 @@ void ewol::textureManager::OpenGlContextHasBeenDestroyed(void)
|
|||||||
l_contextHasBeenRemoved = true;
|
l_contextHasBeenRemoved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static etk::Vector<ewol::TextureFile *> l_imageList;
|
||||||
|
|
||||||
|
|
||||||
|
// this permit to keep a specific texture and prevent the multiple loading of this one ...
|
||||||
|
ewol::Texture* ewol::textureManager::ImageKeep(etk::UString fileName, Vector2D<int32_t> size)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int32_t iii=l_imageList.Size()-1; iii>=0; iii--) {
|
||||||
|
if (l_imageList[iii] != NULL) {
|
||||||
|
if( l_imageList[iii]->HasName(fileName)
|
||||||
|
&& l_imageList[iii]->Get().Get().GetWidth() == size.x
|
||||||
|
&& l_imageList[iii]->Get().Get().GetHeight() == size.y) {
|
||||||
|
l_imageList[iii]->Increment();
|
||||||
|
return &l_imageList[iii]->Get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ewol::TextureFile* tmpResources = new ewol::TextureFile(fileName, size);
|
||||||
|
if (NULL == tmpResources) {
|
||||||
|
EWOL_ERROR("allocation error of a resource Image : " << fileName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
l_imageList.PushBack(tmpResources);
|
||||||
|
return &tmpResources->Get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::textureManager::ImageRelease(ewol::Texture*& object)
|
||||||
|
{
|
||||||
|
for (int32_t iii=l_imageList.Size()-1; iii>=0; iii--) {
|
||||||
|
if (l_imageList[iii] != NULL) {
|
||||||
|
if(&l_imageList[iii]->Get() == object) {
|
||||||
|
if (true == l_imageList[iii]->Decrement()) {
|
||||||
|
// delete element
|
||||||
|
delete(l_imageList[iii]);
|
||||||
|
// remove element from the list :
|
||||||
|
l_imageList.Erase(iii);
|
||||||
|
}
|
||||||
|
// insidiously remove the pointer for the caller ...
|
||||||
|
object = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@ namespace ewol
|
|||||||
// Specific to load or update the data in the openGl context ==> system use only
|
// Specific to load or update the data in the openGl context ==> system use only
|
||||||
void UpdateContext(void);
|
void UpdateContext(void);
|
||||||
void OpenGlContextHasBeenDestroyed(void);
|
void OpenGlContextHasBeenDestroyed(void);
|
||||||
|
// this permit to keep a specific texture and prevent the multiple loading of this one ...
|
||||||
|
ewol::Texture* ImageKeep(etk::UString fileName, Vector2D<int32_t> size);
|
||||||
|
void ImageRelease(ewol::Texture*& object);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ void ewol::WIDGET_ButtonInit(void)
|
|||||||
|
|
||||||
void ewol::Button::Init(void)
|
void ewol::Button::Init(void)
|
||||||
{
|
{
|
||||||
|
m_oObjectImage=NULL;
|
||||||
AddEventId(ewolEventButtonPressed);
|
AddEventId(ewolEventButtonPressed);
|
||||||
AddEventId(ewolEventButtonDown);
|
AddEventId(ewolEventButtonDown);
|
||||||
AddEventId(ewolEventButtonUp);
|
AddEventId(ewolEventButtonUp);
|
||||||
@ -112,16 +113,14 @@ void ewol::Button::SetPadding(Vector2D<float> newPadding)
|
|||||||
|
|
||||||
bool ewol::Button::CalculateMinSize(void)
|
bool ewol::Button::CalculateMinSize(void)
|
||||||
{
|
{
|
||||||
int32_t fontId = GetDefaultFontId();
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
||||||
int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
m_minSize.x = m_padding.x*2 + minSize.x;
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
m_minSize.y = m_padding.y*2 + minSize.y;
|
||||||
m_minSize.x = m_padding.x*2 + minWidth;
|
|
||||||
m_minSize.y = m_padding.y*2 + minHeight;
|
|
||||||
// Add the image element ...
|
// Add the image element ...
|
||||||
if (true == m_hasAnImage) {
|
if (true == m_hasAnImage) {
|
||||||
//m_minSize.x += -m_padding.x + m_padding.y*2 + minHeight;
|
//m_minSize.x += -m_padding.x + m_padding.y*2 + minHeight;
|
||||||
//m_minSize.y += m_padding.y*2;
|
//m_minSize.y += m_padding.y*2;
|
||||||
m_minSize.x += m_padding.x + minHeight;
|
m_minSize.x += m_padding.x + minSize.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
@ -152,12 +151,18 @@ bool ewol::Button::GetValue(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::Button::OnDraw(DrawProperty& displayProp)
|
||||||
|
{
|
||||||
|
m_oObjectDecoration.Draw();
|
||||||
|
if (NULL != m_oObjectImage) {
|
||||||
|
m_oObjectImage->Draw();
|
||||||
|
}
|
||||||
|
m_oObjectText.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::Button::OnRegenerateDisplay(void)
|
void ewol::Button::OnRegenerateDisplay(void)
|
||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
if (true == NeedRedraw()) {
|
||||||
// clean the object list ...
|
|
||||||
ClearOObjectList();
|
|
||||||
|
|
||||||
int32_t tmpSizeX = m_minSize.x;
|
int32_t tmpSizeX = m_minSize.x;
|
||||||
int32_t tmpSizeY = m_minSize.y;
|
int32_t tmpSizeY = m_minSize.y;
|
||||||
@ -183,15 +188,9 @@ void ewol::Button::OnRegenerateDisplay(void)
|
|||||||
tmpSizeX -= 2*m_padding.x;
|
tmpSizeX -= 2*m_padding.x;
|
||||||
tmpSizeY -= 2*m_padding.y;
|
tmpSizeY -= 2*m_padding.y;
|
||||||
|
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
|
||||||
/*
|
|
||||||
int32_t fontId = GetDefaultFontId();
|
|
||||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
|
||||||
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
|
|
||||||
*/
|
|
||||||
Vector2D<float> textPos(tmpTextOriginX, tmpTextOriginY);
|
Vector2D<float> textPos(tmpTextOriginX, tmpTextOriginY);
|
||||||
|
|
||||||
ewol::OObject2DTextured * tmpImage = NULL;
|
/*ewol::OObject2DTextured * tmpImage = NULL;
|
||||||
if (true == m_hasAnImage) {
|
if (true == m_hasAnImage) {
|
||||||
int32_t fontId = GetDefaultFontId();
|
int32_t fontId = GetDefaultFontId();
|
||||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
int32_t fontHeight = ewol::GetHeight(fontId);
|
||||||
@ -200,31 +199,21 @@ void ewol::Button::OnRegenerateDisplay(void)
|
|||||||
// update the text position ...
|
// update the text position ...
|
||||||
textPos.x += m_padding.x + fontHeight;
|
textPos.x += m_padding.x + fontHeight;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
clipping_ts drawClipping;
|
clipping_ts drawClipping;
|
||||||
drawClipping.x = m_padding.x;
|
drawClipping.x = m_padding.x;
|
||||||
drawClipping.y = m_padding.y;
|
drawClipping.y = m_padding.y;
|
||||||
drawClipping.w = m_size.x - 2*m_padding.x;
|
drawClipping.w = m_size.x - 2*m_padding.x;
|
||||||
drawClipping.h = m_size.y - 2*m_padding.y;
|
drawClipping.h = m_size.y - 2*m_padding.y;
|
||||||
EWOL_DEBUG("draw tex at pos : " <<textPos << "in element size:" << m_size);
|
EWOL_DEBUG("draw tex at pos : " <<textPos << "in element size:" << m_size);
|
||||||
tmpText->Text(textPos, drawClipping, m_label);
|
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
||||||
|
|
||||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
m_oObjectDecoration.SetColor(m_textColorBg);
|
||||||
tmpOObjects->SetColor(m_textColorBg);
|
|
||||||
tmpOriginX -= m_padding.x/2;
|
tmpOriginX -= m_padding.x/2;
|
||||||
tmpOriginY -= m_padding.y/2;
|
tmpOriginY -= m_padding.y/2;
|
||||||
tmpSizeX += m_padding.x/1;
|
tmpSizeX += m_padding.x/1;
|
||||||
tmpSizeY += m_padding.y/1;
|
tmpSizeY += m_padding.y/1;
|
||||||
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
||||||
// add all needed objects ...
|
|
||||||
if (NULL != tmpOObjects) {
|
|
||||||
AddOObject(tmpOObjects);
|
|
||||||
}
|
|
||||||
if (NULL != tmpImage) {
|
|
||||||
AddOObject(tmpImage);
|
|
||||||
}
|
|
||||||
if (NULL != tmpText) {
|
|
||||||
AddOObject(tmpText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/widget/Drawable.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/widget/Widget.h>
|
||||||
|
|
||||||
extern const char * const ewolEventButtonPressed;
|
extern const char * const ewolEventButtonPressed;
|
||||||
extern const char * const ewolEventButtonDown;
|
extern const char * const ewolEventButtonDown;
|
||||||
@ -40,7 +41,7 @@ namespace ewol {
|
|||||||
TEXT_ALIGN_LEFT,
|
TEXT_ALIGN_LEFT,
|
||||||
TEXT_ALIGN_CENTER,
|
TEXT_ALIGN_CENTER,
|
||||||
} textAlignement_te;
|
} textAlignement_te;
|
||||||
class Button :public ewol::Drawable
|
class Button : public ewol::Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button(void);
|
Button(void);
|
||||||
@ -65,6 +66,9 @@ namespace ewol {
|
|||||||
void SetColorBg(draw::Color newColor) { m_textColorBg = newColor; };
|
void SetColorBg(draw::Color newColor) { m_textColorBg = newColor; };
|
||||||
void SetColorFg(draw::Color newColor) { m_textColorFg = newColor; };
|
void SetColorFg(draw::Color newColor) { m_textColorFg = newColor; };
|
||||||
private:
|
private:
|
||||||
|
ewol::OObject2DTextColored m_oObjectText;
|
||||||
|
ewol::OObject2DColored m_oObjectDecoration;
|
||||||
|
ewol::OObject2DTextured* m_oObjectImage;
|
||||||
bool m_hasAnImage;
|
bool m_hasAnImage;
|
||||||
etk::UString m_imageSelected;
|
etk::UString m_imageSelected;
|
||||||
textAlignement_te m_alignement;
|
textAlignement_te m_alignement;
|
||||||
@ -74,6 +78,7 @@ namespace ewol {
|
|||||||
draw::Color m_textColorBg; //!< Background color
|
draw::Color m_textColorBg; //!< Background color
|
||||||
public:
|
public:
|
||||||
virtual void OnRegenerateDisplay(void);
|
virtual void OnRegenerateDisplay(void);
|
||||||
|
virtual void OnDraw(DrawProperty& displayProp);
|
||||||
/**
|
/**
|
||||||
* @brief Event on an input of this Widget
|
* @brief Event on an input of this Widget
|
||||||
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
|
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
|
||||||
|
@ -95,11 +95,9 @@ void ewol::ButtonColor::SetPadding(Vector2D<float> newPadding)
|
|||||||
|
|
||||||
bool ewol::ButtonColor::CalculateMinSize(void)
|
bool ewol::ButtonColor::CalculateMinSize(void)
|
||||||
{
|
{
|
||||||
int32_t fontId = GetDefaultFontId();
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
||||||
int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
m_minSize.x = m_padding.x*2 + minSize.x;
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
m_minSize.y = m_padding.y*2 + minSize.y;
|
||||||
m_minSize.x = m_padding.x*2 + minWidth;
|
|
||||||
m_minSize.y = m_padding.y*2 + minHeight;
|
|
||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -128,12 +126,16 @@ bool ewol::ButtonColor::GetValue(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::ButtonColor::OnDraw(DrawProperty& displayProp)
|
||||||
|
{
|
||||||
|
m_oObjectDecoration.Draw();
|
||||||
|
m_oObjectText.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::ButtonColor::OnRegenerateDisplay(void)
|
void ewol::ButtonColor::OnRegenerateDisplay(void)
|
||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
if (true == NeedRedraw()) {
|
||||||
// clean the object list ...
|
|
||||||
ClearOObjectList();
|
|
||||||
|
|
||||||
int32_t tmpSizeX = m_minSize.x;
|
int32_t tmpSizeX = m_minSize.x;
|
||||||
int32_t tmpSizeY = m_minSize.y;
|
int32_t tmpSizeY = m_minSize.y;
|
||||||
@ -164,12 +166,6 @@ void ewol::ButtonColor::OnRegenerateDisplay(void)
|
|||||||
} else {
|
} else {
|
||||||
m_textColorFg = draw::color::white;
|
m_textColorFg = draw::color::white;
|
||||||
}
|
}
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
|
||||||
/*
|
|
||||||
int32_t fontId = GetDefaultFontId();
|
|
||||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
|
||||||
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
|
|
||||||
*/
|
|
||||||
Vector2D<float> textPos;
|
Vector2D<float> textPos;
|
||||||
textPos.x = tmpTextOriginX;
|
textPos.x = tmpTextOriginX;
|
||||||
textPos.y = tmpTextOriginY;
|
textPos.y = tmpTextOriginY;
|
||||||
@ -178,18 +174,14 @@ void ewol::ButtonColor::OnRegenerateDisplay(void)
|
|||||||
drawClipping.y = m_padding.y;
|
drawClipping.y = m_padding.y;
|
||||||
drawClipping.w = m_size.x - 2*m_padding.x;
|
drawClipping.w = m_size.x - 2*m_padding.x;
|
||||||
drawClipping.h = m_size.y - 2*m_padding.y;
|
drawClipping.h = m_size.y - 2*m_padding.y;
|
||||||
tmpText->Text(textPos, drawClipping, m_label);
|
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
||||||
|
|
||||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
m_oObjectDecoration.SetColor(m_textColorBg);
|
||||||
tmpOObjects->SetColor(m_textColorBg);
|
|
||||||
tmpOriginX -= m_padding.x/2;
|
tmpOriginX -= m_padding.x/2;
|
||||||
tmpOriginY -= m_padding.y/2;
|
tmpOriginY -= m_padding.y/2;
|
||||||
tmpSizeX += m_padding.x/1;
|
tmpSizeX += m_padding.x/1;
|
||||||
tmpSizeY += m_padding.y/1;
|
tmpSizeY += m_padding.y/1;
|
||||||
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
||||||
AddOObject(tmpOObjects);
|
|
||||||
|
|
||||||
AddOObject(tmpText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,14 +27,15 @@
|
|||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/widget/Drawable.h>
|
|
||||||
#include <ewol/widget/Button.h>
|
#include <ewol/widget/Button.h>
|
||||||
#include <ewol/widget/ContextMenu.h>
|
#include <ewol/widget/ContextMenu.h>
|
||||||
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/widget/Widget.h>
|
||||||
|
|
||||||
extern const char * const ewolEventButtonColorChange;
|
extern const char * const ewolEventButtonColorChange;
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class ButtonColor :public ewol::Drawable
|
class ButtonColor : public ewol::Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonColor(void);
|
ButtonColor(void);
|
||||||
@ -56,6 +57,8 @@ namespace ewol {
|
|||||||
void SetAlignement(textAlignement_te typeAlign);
|
void SetAlignement(textAlignement_te typeAlign);
|
||||||
void SetPadding(Vector2D<float> newPadding);
|
void SetPadding(Vector2D<float> newPadding);
|
||||||
private:
|
private:
|
||||||
|
ewol::OObject2DTextColored m_oObjectText;
|
||||||
|
ewol::OObject2DColored m_oObjectDecoration;
|
||||||
textAlignement_te m_alignement;
|
textAlignement_te m_alignement;
|
||||||
Vector2D<float> m_padding;
|
Vector2D<float> m_padding;
|
||||||
etk::UString m_label;
|
etk::UString m_label;
|
||||||
@ -65,6 +68,7 @@ namespace ewol {
|
|||||||
ewol::ContextMenu* m_widgetContextMenu;
|
ewol::ContextMenu* m_widgetContextMenu;
|
||||||
public:
|
public:
|
||||||
virtual void OnRegenerateDisplay(void);
|
virtual void OnRegenerateDisplay(void);
|
||||||
|
virtual void OnDraw(DrawProperty& displayProp);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Event on an input of this Widget
|
* @brief Event on an input of this Widget
|
||||||
|
@ -66,12 +66,10 @@ ewol::CheckBox::~CheckBox(void)
|
|||||||
|
|
||||||
bool ewol::CheckBox::CalculateMinSize(void)
|
bool ewol::CheckBox::CalculateMinSize(void)
|
||||||
{
|
{
|
||||||
int32_t fontId = GetDefaultFontId();
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
||||||
int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
float boxSize = etk_max(20, minSize.y) + 5;
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
m_minSize.x = boxSize+minSize.x;
|
||||||
float boxSize = etk_max(20, minHeight) + 5;
|
m_minSize.y = etk_max(boxSize, minSize.y)+3;
|
||||||
m_minSize.x = boxSize+minWidth;
|
|
||||||
m_minSize.y = etk_max(boxSize, minHeight)+3;
|
|
||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -80,6 +78,7 @@ bool ewol::CheckBox::CalculateMinSize(void)
|
|||||||
void ewol::CheckBox::SetLabel(etk::UString newLabel)
|
void ewol::CheckBox::SetLabel(etk::UString newLabel)
|
||||||
{
|
{
|
||||||
m_label = newLabel;
|
m_label = newLabel;
|
||||||
|
MarkToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::CheckBox::SetValue(bool val)
|
void ewol::CheckBox::SetValue(bool val)
|
||||||
@ -96,22 +95,23 @@ bool ewol::CheckBox::GetValue(void)
|
|||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::CheckBox::OnDraw(DrawProperty& displayProp)
|
||||||
|
{
|
||||||
|
m_oObjectDecoration.Draw();
|
||||||
|
m_oObjectText.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::CheckBox::OnRegenerateDisplay(void)
|
void ewol::CheckBox::OnRegenerateDisplay(void)
|
||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
if (true == NeedRedraw()) {
|
||||||
// clean the object list ...
|
|
||||||
ClearOObjectList();
|
|
||||||
|
|
||||||
int32_t borderWidth = 2;
|
int32_t borderWidth = 2;
|
||||||
|
|
||||||
|
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
||||||
int32_t fontId = GetDefaultFontId();
|
float boxSize = etk_max(20, minSize.y) + 5;
|
||||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
|
||||||
float boxSize = etk_max(20, fontHeight);
|
|
||||||
//int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
|
//int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||||
int32_t posy = (m_size.y - fontHeight - 6)/2 + 3;
|
int32_t posy = (m_size.y - minSize.y - 6)/2 + 3;
|
||||||
//int32_t posx = (m_size.x - fontWidth - 6)/2 + 25;
|
//int32_t posx = (m_size.x - fontWidth - 6)/2 + 25;
|
||||||
|
|
||||||
|
|
||||||
@ -124,22 +124,18 @@ void ewol::CheckBox::OnRegenerateDisplay(void)
|
|||||||
// note : pb on the clipping properties ...
|
// note : pb on the clipping properties ...
|
||||||
drawClipping.w = m_size.x;// - (boxSize+5);
|
drawClipping.w = m_size.x;// - (boxSize+5);
|
||||||
drawClipping.h = m_size.y;
|
drawClipping.h = m_size.y;
|
||||||
tmpText->Text(textPos, drawClipping, m_label);
|
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
m_oObjectDecoration.SetColor(m_textColorBg);
|
||||||
tmpOObjects->SetColor(m_textColorBg);
|
m_oObjectDecoration.Rectangle( 2.5, 2.5, boxSize, boxSize);
|
||||||
tmpOObjects->Rectangle( 2.5, 2.5, boxSize, boxSize);
|
m_oObjectDecoration.SetColor(m_textColorFg);
|
||||||
tmpOObjects->SetColor(m_textColorFg);
|
m_oObjectDecoration.RectangleBorder( 2.5, 2.5, boxSize, boxSize, borderWidth);
|
||||||
tmpOObjects->RectangleBorder( 2.5, 2.5, boxSize, boxSize, borderWidth);
|
|
||||||
if (m_value) {
|
if (m_value) {
|
||||||
tmpOObjects->Line( 2.5, 2.5, boxSize+2.5, boxSize+2.5, borderWidth);
|
m_oObjectDecoration.Line( 2.5, 2.5, boxSize+2.5, boxSize+2.5, borderWidth);
|
||||||
tmpOObjects->Line( 2.5, boxSize+2.5, boxSize+2.5, 2.5, borderWidth);
|
m_oObjectDecoration.Line( 2.5, boxSize+2.5, boxSize+2.5, 2.5, borderWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddOObject(tmpOObjects);
|
|
||||||
AddOObject(tmpText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,13 @@
|
|||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/widget/Drawable.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/widget/Widget.h>
|
||||||
|
|
||||||
extern const char* const ewolEventCheckBoxClicked;
|
extern const char* const ewolEventCheckBoxClicked;
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class CheckBox :public ewol::Drawable
|
class CheckBox : public ewol::Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CheckBox(void);
|
CheckBox(void);
|
||||||
@ -51,12 +52,15 @@ namespace ewol {
|
|||||||
void SetValue(bool val);
|
void SetValue(bool val);
|
||||||
bool GetValue(void);
|
bool GetValue(void);
|
||||||
private:
|
private:
|
||||||
|
ewol::OObject2DTextColored m_oObjectText;
|
||||||
|
ewol::OObject2DColored m_oObjectDecoration;
|
||||||
etk::UString m_label;
|
etk::UString m_label;
|
||||||
bool m_value;
|
bool m_value;
|
||||||
draw::Color m_textColorFg; //!< Text color
|
draw::Color m_textColorFg; //!< Text color
|
||||||
draw::Color m_textColorBg; //!< Background color
|
draw::Color m_textColorBg; //!< Background color
|
||||||
public:
|
public:
|
||||||
virtual void OnRegenerateDisplay(void);
|
virtual void OnRegenerateDisplay(void);
|
||||||
|
virtual void OnDraw(DrawProperty& displayProp);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Event on an input of this Widget
|
* @brief Event on an input of this Widget
|
||||||
|
@ -83,8 +83,7 @@ ewol::Entry::~Entry(void)
|
|||||||
|
|
||||||
bool ewol::Entry::CalculateMinSize(void)
|
bool ewol::Entry::CalculateMinSize(void)
|
||||||
{
|
{
|
||||||
int32_t fontId = GetDefaultFontId();
|
int32_t minHeight = m_oObjectText.GetHeight();
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
|
||||||
m_minSize.x = m_userSize;
|
m_minSize.x = m_userSize;
|
||||||
m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize);
|
m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize);
|
||||||
UpdateTextPosition();
|
UpdateTextPosition();
|
||||||
@ -106,15 +105,16 @@ etk::UString ewol::Entry::GetValue(void)
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::Entry::OnDraw(DrawProperty& displayProp)
|
||||||
|
{
|
||||||
|
m_oObjectDecoration.Draw();
|
||||||
|
m_oObjectText.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
void ewol::Entry::OnRegenerateDisplay(void)
|
void ewol::Entry::OnRegenerateDisplay(void)
|
||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
if (true == NeedRedraw()) {
|
||||||
UpdateTextPosition();
|
UpdateTextPosition();
|
||||||
// clean the object list ...
|
|
||||||
ClearOObjectList();
|
|
||||||
|
|
||||||
// TODO later : Add this in the basic element of the widget ...
|
|
||||||
|
|
||||||
int32_t tmpSizeX = m_minSize.x;
|
int32_t tmpSizeX = m_minSize.x;
|
||||||
int32_t tmpSizeY = m_minSize.y;
|
int32_t tmpSizeY = m_minSize.y;
|
||||||
@ -137,7 +137,6 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
|||||||
tmpSizeX -= 2*m_paddingSize;
|
tmpSizeX -= 2*m_paddingSize;
|
||||||
tmpSizeY -= 2*m_paddingSize;
|
tmpSizeY -= 2*m_paddingSize;
|
||||||
|
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
|
||||||
|
|
||||||
Vector2D<float> textPos;
|
Vector2D<float> textPos;
|
||||||
textPos.x = tmpTextOriginX + m_displayStartPosition;
|
textPos.x = tmpTextOriginX + m_displayStartPosition;
|
||||||
@ -147,25 +146,20 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
|||||||
drawClipping.y = 2*m_paddingSize + m_borderSize;
|
drawClipping.y = 2*m_paddingSize + m_borderSize;
|
||||||
drawClipping.w = m_size.x;// - (m_borderSize + 2*m_paddingSize);
|
drawClipping.w = m_size.x;// - (m_borderSize + 2*m_paddingSize);
|
||||||
drawClipping.h = m_size.y;
|
drawClipping.h = m_size.y;
|
||||||
tmpText->Text(textPos, drawClipping, m_data);
|
m_oObjectText.Text(textPos/*, drawClipping*/, m_data);
|
||||||
|
|
||||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
m_oObjectDecoration.SetColor(m_textColorBg);
|
||||||
tmpOObjects->SetColor(m_textColorBg);
|
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
||||||
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
m_oObjectDecoration.SetColor(m_textColorFg);
|
||||||
tmpOObjects->SetColor(m_textColorFg);
|
m_oObjectDecoration.RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, m_borderSize);
|
||||||
tmpOObjects->RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, m_borderSize);
|
|
||||||
if (true == m_displayCursor) {
|
if (true == m_displayCursor) {
|
||||||
int32_t fontId = GetDefaultFontId();
|
|
||||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
|
||||||
etk::UString tmpDisplay = m_data.Extract(0, m_displayCursorPos);
|
etk::UString tmpDisplay = m_data.Extract(0, m_displayCursorPos);
|
||||||
int32_t fontWidth = ewol::GetWidth(fontId, tmpDisplay);
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(tmpDisplay);
|
||||||
int32_t XCursorPos = fontWidth + m_borderSize + 2*m_paddingSize + m_displayStartPosition;
|
int32_t XCursorPos = minSize.x + m_borderSize + 2*m_paddingSize + m_displayStartPosition;
|
||||||
if (XCursorPos >= m_borderSize + 2*m_paddingSize) {
|
if (XCursorPos >= m_borderSize + 2*m_paddingSize) {
|
||||||
tmpOObjects->Line(XCursorPos, tmpTextOriginY, XCursorPos, tmpTextOriginY + fontHeight, 1);
|
m_oObjectDecoration.Line(XCursorPos, tmpTextOriginY, XCursorPos, tmpTextOriginY + minSize.y, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AddOObject(tmpOObjects);
|
|
||||||
AddOObject(tmpText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,15 +182,14 @@ bool ewol::Entry::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventIn
|
|||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
Vector2D<float> relPos = RelativePosition(pos);
|
Vector2D<float> relPos = RelativePosition(pos);
|
||||||
// try to find the new cursor position :
|
// try to find the new cursor position :
|
||||||
int32_t fontId = GetDefaultFontId();
|
|
||||||
etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition);
|
etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition);
|
||||||
int32_t displayHidenSize = ewol::GetWidth(fontId, tmpDisplay);
|
int32_t displayHidenSize = m_oObjectText.GetSize(tmpDisplay).x;
|
||||||
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
|
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
|
||||||
int32_t newCursorPosition = -1;
|
int32_t newCursorPosition = -1;
|
||||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||||
tmpDisplay = m_data.Extract(0, iii);
|
tmpDisplay = m_data.Extract(0, iii);
|
||||||
int32_t tmpWidth = ewol::GetWidth(fontId, tmpDisplay) - displayHidenSize;
|
int32_t tmpWidth = m_oObjectText.GetSize(tmpDisplay).x - displayHidenSize;
|
||||||
if (tmpWidth>=relPos.x-tmpTextOriginX) {
|
if (tmpWidth>=relPos.x-tmpTextOriginX) {
|
||||||
newCursorPosition = iii;
|
newCursorPosition = iii;
|
||||||
break;
|
break;
|
||||||
@ -293,14 +286,12 @@ bool ewol::Entry::OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te mov
|
|||||||
|
|
||||||
void ewol::Entry::UpdateTextPosition(void)
|
void ewol::Entry::UpdateTextPosition(void)
|
||||||
{
|
{
|
||||||
int32_t fontId = GetDefaultFontId();
|
|
||||||
|
|
||||||
int32_t tmpSizeX = m_minSize.x;
|
int32_t tmpSizeX = m_minSize.x;
|
||||||
if (true==m_userFillX) {
|
if (true==m_userFillX) {
|
||||||
tmpSizeX = m_size.x;
|
tmpSizeX = m_size.x;
|
||||||
}
|
}
|
||||||
int32_t tmpUserSize = tmpSizeX - 2*(m_borderSize + 2*m_paddingSize);
|
int32_t tmpUserSize = tmpSizeX - 2*(m_borderSize + 2*m_paddingSize);
|
||||||
int32_t totalWidth = ewol::GetWidth(fontId, m_data);
|
int32_t totalWidth = m_oObjectText.GetSize(m_data).x;
|
||||||
if (totalWidth < tmpUserSize) {
|
if (totalWidth < tmpUserSize) {
|
||||||
m_displayStartPosition = 0;
|
m_displayStartPosition = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,14 +27,15 @@
|
|||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/widget/Drawable.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/widget/Widget.h>
|
||||||
|
|
||||||
extern const char * const ewolEventEntryClick;
|
extern const char * const ewolEventEntryClick;
|
||||||
extern const char * const ewolEventEntryEnter;
|
extern const char * const ewolEventEntryEnter;
|
||||||
extern const char * const ewolEventEntryModify; // return in the data the new string inside it ...
|
extern const char * const ewolEventEntryModify; // return in the data the new string inside it ...
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class Entry :public ewol::Drawable
|
class Entry : public ewol::Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Entry(void);
|
Entry(void);
|
||||||
@ -56,6 +57,8 @@ namespace ewol {
|
|||||||
m_userSize = width;
|
m_userSize = width;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
ewol::OObject2DTextColored m_oObjectText;
|
||||||
|
ewol::OObject2DColored m_oObjectDecoration;
|
||||||
etk::UString m_data;
|
etk::UString m_data;
|
||||||
draw::Color m_textColorFg; //!< Text color
|
draw::Color m_textColorFg; //!< Text color
|
||||||
draw::Color m_textColorBg; //!< Background color
|
draw::Color m_textColorBg; //!< Background color
|
||||||
@ -68,6 +71,7 @@ namespace ewol {
|
|||||||
bool m_displayCursor;
|
bool m_displayCursor;
|
||||||
public:
|
public:
|
||||||
virtual void OnRegenerateDisplay(void);
|
virtual void OnRegenerateDisplay(void);
|
||||||
|
virtual void OnDraw(DrawProperty& displayProp);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Event on an input of this Widget
|
* @brief Event on an input of this Widget
|
||||||
|
@ -64,12 +64,9 @@ ewol::Label::~Label(void)
|
|||||||
|
|
||||||
bool ewol::Label::CalculateMinSize(void)
|
bool ewol::Label::CalculateMinSize(void)
|
||||||
{
|
{
|
||||||
int32_t fontId = GetDefaultFontId();
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
||||||
int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
m_minSize.x = 3 + minSize.x;
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
m_minSize.y = 3 + minSize.y;
|
||||||
m_minSize.x = 3+minWidth;
|
|
||||||
m_minSize.y = 3+minHeight;
|
|
||||||
MarkToRedraw();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,13 +77,15 @@ void ewol::Label::SetLabel(etk::UString newLabel)
|
|||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::Label::OnDraw(DrawProperty& displayProp)
|
||||||
|
{
|
||||||
|
m_oObjectText.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Label::OnRegenerateDisplay(void)
|
void ewol::Label::OnRegenerateDisplay(void)
|
||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
if (true == NeedRedraw()) {
|
||||||
// clean the object list ...
|
|
||||||
ClearOObjectList();
|
|
||||||
|
|
||||||
int32_t paddingSize = 3;
|
int32_t paddingSize = 3;
|
||||||
|
|
||||||
int32_t tmpOriginX = 0;
|
int32_t tmpOriginX = 0;
|
||||||
@ -101,7 +100,6 @@ void ewol::Label::OnRegenerateDisplay(void)
|
|||||||
tmpOriginX += paddingSize;
|
tmpOriginX += paddingSize;
|
||||||
tmpOriginY += paddingSize;
|
tmpOriginY += paddingSize;
|
||||||
|
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
|
||||||
|
|
||||||
Vector2D<float> textPos(tmpOriginX, tmpOriginY);
|
Vector2D<float> textPos(tmpOriginX, tmpOriginY);
|
||||||
clipping_ts drawClipping;
|
clipping_ts drawClipping;
|
||||||
@ -109,9 +107,7 @@ void ewol::Label::OnRegenerateDisplay(void)
|
|||||||
drawClipping.y = paddingSize;
|
drawClipping.y = paddingSize;
|
||||||
drawClipping.w = m_size.x - 2*paddingSize;
|
drawClipping.w = m_size.x - 2*paddingSize;
|
||||||
drawClipping.h = m_size.y - 2*paddingSize;
|
drawClipping.h = m_size.y - 2*paddingSize;
|
||||||
tmpText->Text(textPos, drawClipping, m_label);
|
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
||||||
|
|
||||||
AddOObject(tmpText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,13 @@
|
|||||||
|
|
||||||
#include <etk/Types.h>
|
#include <etk/Types.h>
|
||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/widget/Drawable.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
|
#include <ewol/widget/Widget.h>
|
||||||
|
|
||||||
extern const char * const ewolEventLabelPressed;
|
extern const char * const ewolEventLabelPressed;
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
class Label :public ewol::Drawable
|
class Label : public ewol::Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Label(void);
|
Label(void);
|
||||||
@ -49,10 +50,12 @@ namespace ewol {
|
|||||||
virtual bool CalculateMinSize(void);
|
virtual bool CalculateMinSize(void);
|
||||||
void SetLabel(etk::UString newLabel);
|
void SetLabel(etk::UString newLabel);
|
||||||
private:
|
private:
|
||||||
|
ewol::OObject2DTextColored m_oObjectText;
|
||||||
etk::UString m_label;
|
etk::UString m_label;
|
||||||
draw::Color m_textColorFg; //!< Text color
|
draw::Color m_textColorFg; //!< Text color
|
||||||
public:
|
public:
|
||||||
virtual void OnRegenerateDisplay(void);
|
virtual void OnRegenerateDisplay(void);
|
||||||
|
virtual void OnDraw(DrawProperty& displayProp);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Event on an input of this Widget
|
* @brief Event on an input of this Widget
|
||||||
|
@ -128,11 +128,13 @@ void ewol::List::OnRegenerateDisplay(void)
|
|||||||
}*/
|
}*/
|
||||||
tmpOriginX += m_paddingSizeX;
|
tmpOriginX += m_paddingSizeX;
|
||||||
tmpOriginY += m_paddingSizeY;
|
tmpOriginY += m_paddingSizeY;
|
||||||
|
// TODO : Rework this corectly ...
|
||||||
|
/*
|
||||||
int32_t fontId = GetDefaultFontId();
|
int32_t fontId = GetDefaultFontId();
|
||||||
//int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
//int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
int32_t minHeight = ewol::GetHeight(fontId);
|
||||||
|
*/
|
||||||
|
int32_t minHeight = 25;
|
||||||
|
|
||||||
//uint32_t nbColomn = GetNuberOfColomn();
|
//uint32_t nbColomn = GetNuberOfColomn();
|
||||||
int32_t nbRaw = GetNuberOfRaw();
|
int32_t nbRaw = GetNuberOfRaw();
|
||||||
@ -178,12 +180,12 @@ void ewol::List::OnRegenerateDisplay(void)
|
|||||||
BGOObjects->SetColor(bg);
|
BGOObjects->SetColor(bg);
|
||||||
BGOObjects->Rectangle(0, m_size.y - tmpOriginY, m_size.x, minHeight+2*m_paddingSizeY);
|
BGOObjects->Rectangle(0, m_size.y - tmpOriginY, m_size.x, minHeight+2*m_paddingSizeY);
|
||||||
|
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg);
|
ewol::OObject2DTextColored * tmpText = new ewol::OObject2DTextColored();
|
||||||
|
|
||||||
Vector2D<float> textPos;
|
Vector2D<float> textPos;
|
||||||
textPos.x = tmpOriginX;
|
textPos.x = tmpOriginX;
|
||||||
textPos.y = m_size.y - tmpOriginY + m_paddingSizeY;
|
textPos.y = m_size.y - tmpOriginY + m_paddingSizeY;
|
||||||
tmpText->Text(textPos, drawClipping, myTextToWrite);
|
tmpText->Text(textPos/*, drawClipping*/, myTextToWrite);
|
||||||
|
|
||||||
AddOObject(tmpText);
|
AddOObject(tmpText);
|
||||||
tmpOriginY += minHeight + 2* m_paddingSizeY;
|
tmpOriginY += minHeight + 2* m_paddingSizeY;
|
||||||
@ -215,9 +217,13 @@ bool ewol::List::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInp
|
|||||||
// nothing to do ... done on upper widet ...
|
// nothing to do ... done on upper widet ...
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// TODO : Rework this ...
|
||||||
|
/*
|
||||||
int32_t fontId = GetDefaultFontId();
|
int32_t fontId = GetDefaultFontId();
|
||||||
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
|
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
int32_t minHeight = ewol::GetHeight(fontId);
|
||||||
|
*/
|
||||||
|
int32_t minHeight =20;
|
||||||
|
|
||||||
int32_t rawID = (relativePos.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
|
int32_t rawID = (relativePos.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
|
||||||
//EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");");
|
//EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");");
|
||||||
|
@ -136,10 +136,13 @@ void ewol::ParameterList::OnRegenerateDisplay(void)
|
|||||||
tmpOriginX += m_paddingSizeX;
|
tmpOriginX += m_paddingSizeX;
|
||||||
tmpOriginY += m_paddingSizeY;
|
tmpOriginY += m_paddingSizeY;
|
||||||
|
|
||||||
|
/*
|
||||||
int32_t fontId = GetDefaultFontId();
|
int32_t fontId = GetDefaultFontId();
|
||||||
//int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
//int32_t minWidth = ewol::GetWidth(fontId, m_label);
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
int32_t minHeight = ewol::GetHeight(fontId);
|
||||||
|
*/
|
||||||
|
// TODO : Rework this ...
|
||||||
|
int32_t minHeight=20;
|
||||||
|
|
||||||
//uint32_t nbColomn = GetNuberOfColomn();
|
//uint32_t nbColomn = GetNuberOfColomn();
|
||||||
int32_t nbRaw = m_list.Size();
|
int32_t nbRaw = m_list.Size();
|
||||||
@ -181,7 +184,7 @@ void ewol::ParameterList::OnRegenerateDisplay(void)
|
|||||||
myTextToWrite = m_list[iii]->m_label;
|
myTextToWrite = m_list[iii]->m_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg);
|
ewol::OObject2DTextColored * tmpText = new ewol::OObject2DTextColored();
|
||||||
|
|
||||||
Vector2D<float> textPos;
|
Vector2D<float> textPos;
|
||||||
textPos.x = (int32_t)tmpOriginX;
|
textPos.x = (int32_t)tmpOriginX;
|
||||||
@ -189,7 +192,7 @@ void ewol::ParameterList::OnRegenerateDisplay(void)
|
|||||||
textPos.x += minHeight;
|
textPos.x += minHeight;
|
||||||
}
|
}
|
||||||
textPos.y = (int32_t)(tmpOriginY + m_paddingSizeY);
|
textPos.y = (int32_t)(tmpOriginY + m_paddingSizeY);
|
||||||
tmpText->Text(textPos, drawClipping, myTextToWrite);
|
tmpText->Text(textPos/*, drawClipping*/, myTextToWrite);
|
||||||
|
|
||||||
AddOObject(tmpText);
|
AddOObject(tmpText);
|
||||||
tmpOriginY -= minHeight + 2* m_paddingSizeY;
|
tmpOriginY -= minHeight + 2* m_paddingSizeY;
|
||||||
@ -221,10 +224,13 @@ bool ewol::ParameterList::OnEventInput(ewol::inputType_te type, int32_t IdInput,
|
|||||||
Vector2D<float> relativePos = RelativePosition(pos);
|
Vector2D<float> relativePos = RelativePosition(pos);
|
||||||
// corection for the openGl abstraction
|
// corection for the openGl abstraction
|
||||||
relativePos.y = m_size.y - relativePos.y;
|
relativePos.y = m_size.y - relativePos.y;
|
||||||
|
// TODO : Rework this ...
|
||||||
|
/*
|
||||||
int32_t fontId = GetDefaultFontId();
|
int32_t fontId = GetDefaultFontId();
|
||||||
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
|
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||||
int32_t minHeight = ewol::GetHeight(fontId);
|
int32_t minHeight = ewol::GetHeight(fontId);
|
||||||
|
*/
|
||||||
|
int32_t minHeight = 20;
|
||||||
int32_t rawID = (relativePos.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
|
int32_t rawID = (relativePos.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
|
||||||
// generate an event on a rawId if the element request change and Select it ...
|
// generate an event on a rawId if the element request change and Select it ...
|
||||||
if (rawID >=0 && rawID<m_list.Size()) {
|
if (rawID >=0 && rawID<m_list.Size()) {
|
||||||
|
@ -6,10 +6,6 @@ FILE_LIST = ewol/ewol.cpp \
|
|||||||
ewol/Debug.cpp \
|
ewol/Debug.cpp \
|
||||||
ewol/ShortCutManager.cpp
|
ewol/ShortCutManager.cpp
|
||||||
|
|
||||||
# Resources manager
|
|
||||||
FILE_LIST+= ewol/resources/ResourcesManager.cpp \
|
|
||||||
ewol/resources/ResourcesImage.cpp
|
|
||||||
|
|
||||||
# Gui interface
|
# Gui interface
|
||||||
FILE_LIST+= ewol/os/eSystem.cpp \
|
FILE_LIST+= ewol/os/eSystem.cpp \
|
||||||
ewol/os/eSystemInput.cpp
|
ewol/os/eSystemInput.cpp
|
||||||
@ -25,7 +21,6 @@ FILE_LIST+= ewol/game/GameElement.cpp \
|
|||||||
|
|
||||||
# Object abstraction for OpenGl
|
# Object abstraction for OpenGl
|
||||||
FILE_LIST+= ewol/oObject/OObject.cpp \
|
FILE_LIST+= ewol/oObject/OObject.cpp \
|
||||||
ewol/oObject/2DText.cpp \
|
|
||||||
ewol/oObject/2DTextColored.cpp \
|
ewol/oObject/2DTextColored.cpp \
|
||||||
ewol/oObject/2DColored.cpp \
|
ewol/oObject/2DColored.cpp \
|
||||||
ewol/oObject/2DTextured.cpp \
|
ewol/oObject/2DTextured.cpp \
|
||||||
@ -33,13 +28,16 @@ FILE_LIST+= ewol/oObject/OObject.cpp \
|
|||||||
|
|
||||||
# texture management
|
# texture management
|
||||||
FILE_LIST+= ewol/texture/Texture.cpp \
|
FILE_LIST+= ewol/texture/Texture.cpp \
|
||||||
|
ewol/texture/TextureFile.cpp \
|
||||||
ewol/texture/TextureManager.cpp \
|
ewol/texture/TextureManager.cpp \
|
||||||
ewol/texture/TextureBMP.cpp \
|
ewol/texture/TextureBMP.cpp \
|
||||||
ewol/texture/TexturePNG.cpp \
|
ewol/texture/TexturePNG.cpp \
|
||||||
ewol/texture/TextureSVG.cpp
|
ewol/texture/TextureSVG.cpp
|
||||||
|
|
||||||
# fonst system
|
# fonst system
|
||||||
FILE_LIST+= ewol/font/FontFreeType.cpp
|
FILE_LIST+= ewol/font/FontManager.cpp \
|
||||||
|
ewol/font/FontFreeType.cpp \
|
||||||
|
ewol/font/TexturedFont.cpp
|
||||||
|
|
||||||
# all widgets
|
# all widgets
|
||||||
FILE_LIST+= ewol/widget/Widget.cpp \
|
FILE_LIST+= ewol/widget/Widget.cpp \
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2037fb3efc117050ef7d32385f93cad3eec3e822
|
Subproject commit ec38558a103d10d6b3116dc34237201fb2934e16
|
Loading…
x
Reference in New Issue
Block a user