windows: normalise display methode
This commit is contained in:
parent
8bf5263e22
commit
109c363c84
@ -52,7 +52,6 @@ class Plop :public ewol::Windows
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Plop * myWindowsExample = new Plop();
|
|
||||||
|
|
||||||
ewol::Init(argc, argv);
|
ewol::Init(argc, argv);
|
||||||
|
|
||||||
@ -61,6 +60,10 @@ int main(int argc, char *argv[])
|
|||||||
//fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt");
|
//fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Plop * myWindowsExample = new Plop();
|
||||||
|
|
||||||
|
|
||||||
// create the specific windows
|
// create the specific windows
|
||||||
ewol::DisplayWindows(myWindowsExample);
|
ewol::DisplayWindows(myWindowsExample);
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ namespace ewol
|
|||||||
private:
|
private:
|
||||||
void ClearAll(int32_t x, int32_t y, int32_t w, int32_t h)
|
void ClearAll(int32_t x, int32_t y, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
EWOL_DEBUG("Find default font glyph : (" << x << "," << y << ") (" << w << "," << h << ") ");
|
//EWOL_DEBUG("Find default font glyph : (" << x << "," << y << ") (" << w << "," << h << ") ");
|
||||||
for (int32_t iii=0; iii< 0x80; iii++) {
|
for (int32_t iii=0; iii< 0x80; iii++) {
|
||||||
m_listOfElement[iii].posStart.u = (double)x / 512.0;
|
m_listOfElement[iii].posStart.u = (double)x / 512.0;
|
||||||
m_listOfElement[iii].posStart.v = (double)y / 512.0;
|
m_listOfElement[iii].posStart.v = (double)y / 512.0;
|
||||||
@ -161,7 +161,7 @@ namespace ewol
|
|||||||
};
|
};
|
||||||
void SetGlyphID(int32_t utf8Value, int32_t lineID, int32_t x, int32_t y, int32_t w, int32_t h)
|
void SetGlyphID(int32_t utf8Value, int32_t lineID, int32_t x, int32_t y, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
EWOL_DEBUG("Add font glyph : "<< utf8Value << " (" << x << "," << y << ") (" << w << "," << h << ") ");
|
//EWOL_DEBUG("Add font glyph : "<< utf8Value << " (" << x << "," << y << ") (" << w << "," << h << ") ");
|
||||||
if (utf8Value < 0x80) {
|
if (utf8Value < 0x80) {
|
||||||
m_listOfElement[utf8Value].posStart.u = (double)x / 512.0;
|
m_listOfElement[utf8Value].posStart.u = (double)x / 512.0;
|
||||||
m_listOfElement[utf8Value].posStart.v = (double)y / 512.0;
|
m_listOfElement[utf8Value].posStart.v = (double)y / 512.0;
|
||||||
|
@ -39,6 +39,7 @@ ewol::Widget::Widget(void)
|
|||||||
m_maxSize.y = -1.0;
|
m_maxSize.y = -1.0;
|
||||||
m_expendX = false;
|
m_expendX = false;
|
||||||
m_expendY = false;
|
m_expendY = false;
|
||||||
|
m_genericDraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::Widget::~Widget(void)
|
ewol::Widget::~Widget(void)
|
||||||
@ -108,6 +109,7 @@ bool ewol::Widget::GenEventShortCut(bool shift, bool control, bool alt, bool pom
|
|||||||
|
|
||||||
bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const char * generateEventId)
|
bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const char * generateEventId)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if( origin.x < 0.0
|
if( origin.x < 0.0
|
||||||
|| origin.y < 0.0)
|
|| origin.y < 0.0)
|
||||||
{
|
{
|
||||||
@ -132,7 +134,7 @@ bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const
|
|||||||
EWOL_WARNING("end area out of size");
|
EWOL_WARNING("end area out of size");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
event_ts newEvent;
|
event_ts newEvent;
|
||||||
newEvent.generateEventId = generateEventId;
|
newEvent.generateEventId = generateEventId;
|
||||||
newEvent.widgetCall = -1; // by default no widget is called
|
newEvent.widgetCall = -1; // by default no widget is called
|
||||||
@ -166,8 +168,55 @@ bool ewol::Widget::ExternLinkOnEvent(const char * eventName, int32_t widgetId)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name)
|
||||||
|
{
|
||||||
|
if (NULL == newObject) {
|
||||||
|
EWOL_ERROR("Try to add an empty object in the Widget generic display system : name=\"" << name << "\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newObject->SetName(name);
|
||||||
|
m_listOObject.PushBack(newObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ewol::OObject* ewol::Widget::GetOObject(etk::String name)
|
||||||
|
{
|
||||||
|
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
|
||||||
|
if (m_listOObject[iii]->GetName() == name) {
|
||||||
|
return m_listOObject[iii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::Widget::RmOObjectElem(etk::String name)
|
||||||
|
{
|
||||||
|
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
|
||||||
|
if (m_listOObject[iii]->GetName() == name) {
|
||||||
|
delete(m_listOObject[iii]);
|
||||||
|
m_listOObject[iii] = NULL;
|
||||||
|
m_listOObject.Erase(iii);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::Widget::ClearOObjectList(void)
|
||||||
|
{
|
||||||
|
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
|
||||||
|
delete(m_listOObject[iii]);
|
||||||
|
m_listOObject[iii] = NULL;
|
||||||
|
}
|
||||||
|
m_listOObject.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool ewol::Widget::GenericDraw(void)
|
bool ewol::Widget::GenericDraw(void)
|
||||||
{
|
{
|
||||||
|
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
|
||||||
|
if (NULL != m_listOObject[iii]) {
|
||||||
|
m_listOObject[iii]->Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <etkTypes.h>
|
#include <etkTypes.h>
|
||||||
#include <ewolDebug.h>
|
#include <ewolDebug.h>
|
||||||
|
#include <ewolOObject.h>
|
||||||
#include <etkVectorType.h>
|
#include <etkVectorType.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -237,21 +238,25 @@ namespace ewol {
|
|||||||
// -- this will automaticly regenerate the same view in openGL
|
// -- this will automaticly regenerate the same view in openGL
|
||||||
// ----------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
int32_t MultipleDisplayCurrentId;
|
|
||||||
//estd::VectorType<event_ts> m_inputEvent;
|
|
||||||
bool m_genericDraw;
|
bool m_genericDraw;
|
||||||
|
etk::VectorType<ewol::OObject*> m_listOObject; //!< generic element to display...
|
||||||
bool GenericDraw(void);
|
bool GenericDraw(void);
|
||||||
protected:
|
protected:
|
||||||
|
void AddOObject(ewol::OObject* newObject, etk::String name = "");
|
||||||
|
ewol::OObject* GetOObject(etk::String name);
|
||||||
|
void RmOObjectElem(etk::String name);
|
||||||
|
void ClearOObjectList(void);
|
||||||
void SetNotGenericDraw(void) { m_genericDraw = false; };
|
void SetNotGenericDraw(void) { m_genericDraw = false; };
|
||||||
void SetGenericDraw(void) { m_genericDraw = true; };
|
void SetGenericDraw(void) { m_genericDraw = true; };
|
||||||
//void FlipFlopNext(void); //!< jump at the next display registered
|
|
||||||
virtual bool OnDraw(void) { return true; };
|
virtual bool OnDraw(void) { return true; };
|
||||||
public:
|
public:
|
||||||
bool GenDraw(void)
|
bool GenDraw(void)
|
||||||
{
|
{
|
||||||
if (true == m_genericDraw) {
|
if (true == m_genericDraw) {
|
||||||
|
//EWOL_DEBUG("Draw generic...");
|
||||||
return GenericDraw();
|
return GenericDraw();
|
||||||
} else {
|
} else {
|
||||||
|
//EWOL_DEBUG("Draw Custum...");
|
||||||
return OnDraw();
|
return OnDraw();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,31 @@ const char * ewolEventWindowsClose = "ewol Windows close";
|
|||||||
const char * ewolEventWindowsMinimize = "ewol Windows minimize";
|
const char * ewolEventWindowsMinimize = "ewol Windows minimize";
|
||||||
const char * ewolEventWindowsExpend = "ewol Windows expend/unExpend";
|
const char * ewolEventWindowsExpend = "ewol Windows expend/unExpend";
|
||||||
|
|
||||||
|
|
||||||
|
ewol::Windows::Windows(void)
|
||||||
|
{
|
||||||
|
ewol::OObject2DColored * myOObject = new ewol::OObject2DColored();
|
||||||
|
myOObject->Rectangle( 0, 0, 20, 20, 1.0, 0.0, 0.0, 1.0); // Close
|
||||||
|
myOObject->Rectangle(20, 0, 20, 20, 0.0, 1.0, 0.0, 1.0); // Reduce
|
||||||
|
myOObject->Rectangle(40, 0, 20, 20, 0.0, 0.0, 1.0, 1.0); // Expend - Un-expend
|
||||||
|
|
||||||
|
AddEventArea({ 0.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventWindowsClose);
|
||||||
|
AddEventArea({20.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventWindowsMinimize);
|
||||||
|
AddEventArea({40.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventWindowsExpend);
|
||||||
|
|
||||||
|
AddOObject(myOObject, "leftBoutton");
|
||||||
|
|
||||||
|
color_ts textColorFg;
|
||||||
|
textColorFg.red = .0;
|
||||||
|
textColorFg.green = .0;
|
||||||
|
textColorFg.blue = .0;
|
||||||
|
textColorFg.alpha = 1.0;
|
||||||
|
ewol::OObject2DText * myOObjectText = new ewol::OObject2DText(62, 2, "Monospace", 17 , FONT_MODE_BOLD, textColorFg, "My Title ...");
|
||||||
|
AddOObject(myOObjectText, "Title");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ewol::Windows::CalculateSize(double availlableX, double availlableY)
|
bool ewol::Windows::CalculateSize(double availlableX, double availlableY)
|
||||||
{
|
{
|
||||||
m_size.x = availlableX;
|
m_size.x = availlableX;
|
||||||
@ -100,98 +125,9 @@ void ewol::Windows::SysDraw(void)
|
|||||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
|
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
|
||||||
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
|
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
|
||||||
|
|
||||||
|
GenDraw();
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
return;
|
||||||
/*
|
|
||||||
// create one display list
|
|
||||||
indexListe = glGenLists(1);
|
|
||||||
// compile the display list, store a triangle in it
|
|
||||||
glNewList(indexListe, GL_COMPILE);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
float plop2 = 0.2;
|
|
||||||
//glVertex3fv(v0);
|
|
||||||
glColor3f(1., 0., 0.); glVertex3f( plop2*m_size.x, plop2*m_size.y, 0.);
|
|
||||||
glColor3f(0., 1., 0.); glVertex3f( (1.0-plop2)*m_size.x, plop2*m_size.y, 0.);
|
|
||||||
glColor3f(0., 0., 1.); glVertex3f( (1.0-plop2)*m_size.x, (1.0-plop2)*m_size.y, 0.);
|
|
||||||
glColor3f(1., 1., 0.); glVertex3f( plop2*m_size.x, (1.0-plop2)*m_size.y, 0.);
|
|
||||||
glEnd();
|
|
||||||
glEndList();
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static ewol::OObject2DColored myOObject;
|
|
||||||
static ewol::OObject2DTextured myOObjectTex_r5g6b5 ("dataTest/test_16b_r5g6b5.bmp");
|
|
||||||
static ewol::OObject2DTextured myOObjectTex_x1r5g5b5("dataTest/test_16b_x1r5g5b5.bmp");
|
|
||||||
static ewol::OObject2DTextured myOObjectTex_r8g8b8 ("dataTest/test_24b_r8g8b8.bmp");
|
|
||||||
static ewol::OObject2DTextured myOObjectTex_x8r8g8b8("dataTest/test_32b_x8r8g8b8.bmp");
|
|
||||||
static ewol::OObject2DTextured myOObjectTex_a8r8g8b8("dataTest/test_32b_a8r8g8b8.bmp");
|
|
||||||
color_ts textColorFg;
|
|
||||||
textColorFg.red = .0;
|
|
||||||
textColorFg.green = .0;
|
|
||||||
textColorFg.blue = .0;
|
|
||||||
textColorFg.alpha = 1.0;
|
|
||||||
static ewol::OObject2DText myOObjectText(200, 300, "Monospace", 22, FONT_MODE_NORMAL, textColorFg, "Exemple de test ...");
|
|
||||||
static bool isinit = false;
|
|
||||||
static int32_t fontID = 0;
|
|
||||||
|
|
||||||
if (false == isinit) {
|
|
||||||
isinit=true;
|
|
||||||
myOObject.Rectangle( 0, 0, 20, 20, 1.0, 0.0, 0.0, 1.0); // Close
|
|
||||||
myOObject.Rectangle(20, 0, 20, 20, 0.0, 1.0, 0.0, 1.0); // Reduce
|
|
||||||
myOObject.Rectangle(40, 0, 20, 20, 0.0, 0.0, 1.0, 1.0); // Expend - Un-expend
|
|
||||||
|
|
||||||
AddEventArea({ 0.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventWindowsClose);
|
|
||||||
AddEventArea({20.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventWindowsMinimize);
|
|
||||||
AddEventArea({40.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventWindowsExpend);
|
|
||||||
|
|
||||||
// Other ...
|
|
||||||
myOObject.Rectangle(20, 30, 100, 50, 1.0, 0.0, 0.0, 1.0);
|
|
||||||
myOObject.Rectangle(50, 50, 50, 50, 0.0, 1.0, 0.0, 1.0);
|
|
||||||
myOObject.Rectangle(80, 80, 100, 50, 0.0, 0.0, 1.0, 1.0);
|
|
||||||
myOObject.Rectangle(50, 00, 300, 300, 0.2, 0.2, 0.2, 0.5);
|
|
||||||
/*
|
|
||||||
myOObject.Rectangle(200, 300, 900, 54, 0.0, 0.0, 0.0, 1.0);
|
|
||||||
myOObject.Rectangle(200, 300, 900, 13, 0.0, 1.0, 0.0, 1.0);
|
|
||||||
myOObject.Rectangle(200, 343, 900, 11, 1.0, 0.0, 0.0, 1.0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
myOObjectTex_r5g6b5.Rectangle( 300, 0, 100, 100);
|
|
||||||
myOObjectTex_x1r5g5b5.Rectangle(300, 100, 100, 100);
|
|
||||||
myOObjectTex_r8g8b8.Rectangle( 300, 200, 100, 100);
|
|
||||||
myOObjectTex_x8r8g8b8.Rectangle(400, 0, 100, 100);
|
|
||||||
myOObjectTex_a8r8g8b8.Rectangle(400, 100, 100, 100);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
myOObject.Draw();
|
|
||||||
myOObjectTex_r5g6b5.Draw();
|
|
||||||
myOObjectTex_x1r5g5b5.Draw();
|
|
||||||
myOObjectTex_r8g8b8.Draw();
|
|
||||||
myOObjectTex_x8r8g8b8.Draw();
|
|
||||||
myOObjectTex_a8r8g8b8.Draw();
|
|
||||||
myOObjectText.Draw();
|
|
||||||
/*
|
|
||||||
coord3D_ts drawPosition = { 200.0, 300.0, 0.0};
|
|
||||||
color_ts textColorFg = { 1.0, 1.0, 1.0, 1.0};
|
|
||||||
ewol::DrawText(fontID, FONT_MODE_NORMAL, 54, drawPosition, textColorFg,"APet9_$*:/?,>< \"#',;KkgGyYf");
|
|
||||||
|
|
||||||
drawPosition = { 200.0, 350.0, 0.0};
|
|
||||||
textColorFg = { 1.0, 0.0, 0.0, 1.0};
|
|
||||||
ewol::DrawText(fontID, FONT_MODE_BOLD, 25, drawPosition, textColorFg,"APet9_$*:/?,>< \"#',;KkgGyYf");
|
|
||||||
|
|
||||||
drawPosition = { 200.0, 400.0, 0.0};
|
|
||||||
textColorFg = { 0.0, 1.0, 0.0, 1.0};
|
|
||||||
ewol::DrawText(fontID, FONT_MODE_ITALIC, 15, drawPosition, textColorFg,"APet9_$*:/?,>< \"#',;KkgGyYf");
|
|
||||||
|
|
||||||
drawPosition = { 200.0, 450.0, 0.0};
|
|
||||||
textColorFg = { 0.0, 0.0, 1.0, 1.0};
|
|
||||||
ewol::DrawText(fontID, FONT_MODE_BOLD_ITALIC, 105, drawPosition, textColorFg,"APet9_$*:/?,>< \"#',;KkgGyYf");
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace ewol {
|
|||||||
class Windows :public ewol::Widget
|
class Windows :public ewol::Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Windows(void) {};
|
Windows(void);
|
||||||
virtual ~Windows(void) {};
|
virtual ~Windows(void) {};
|
||||||
// internal event at ewol system :
|
// internal event at ewol system :
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user