From 109c363c842646692cc20ad32a3ad0337f49a72a Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Mon, 31 Oct 2011 13:01:33 +0100 Subject: [PATCH] windows: normalise display methode --- Sources/Main.cpp | 5 +- Sources/ewolFont.cpp | 4 +- Sources/ewolWidget.cpp | 51 ++++++++++++++++- Sources/ewolWidget.h | 11 +++- Sources/ewolWindows.cpp | 120 ++++++++++------------------------------ Sources/ewolWindows.h | 2 +- 6 files changed, 93 insertions(+), 100 deletions(-) diff --git a/Sources/Main.cpp b/Sources/Main.cpp index b36bd409..9c0debed 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -52,7 +52,6 @@ class Plop :public ewol::Windows */ int main(int argc, char *argv[]) { - Plop * myWindowsExample = new Plop(); ewol::Init(argc, argv); @@ -61,6 +60,10 @@ int main(int argc, char *argv[]) //fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt"); } + + Plop * myWindowsExample = new Plop(); + + // create the specific windows ewol::DisplayWindows(myWindowsExample); diff --git a/Sources/ewolFont.cpp b/Sources/ewolFont.cpp index dcd352b1..43b4b135 100644 --- a/Sources/ewolFont.cpp +++ b/Sources/ewolFont.cpp @@ -150,7 +150,7 @@ namespace ewol private: 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++) { m_listOfElement[iii].posStart.u = (double)x / 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) { - EWOL_DEBUG("Add font glyph : "<< utf8Value << " (" << x << "," << y << ") (" << w << "," << h << ") "); + //EWOL_DEBUG("Add font glyph : "<< utf8Value << " (" << x << "," << y << ") (" << w << "," << h << ") "); if (utf8Value < 0x80) { m_listOfElement[utf8Value].posStart.u = (double)x / 512.0; m_listOfElement[utf8Value].posStart.v = (double)y / 512.0; diff --git a/Sources/ewolWidget.cpp b/Sources/ewolWidget.cpp index 8e5ddc6f..4bf78490 100644 --- a/Sources/ewolWidget.cpp +++ b/Sources/ewolWidget.cpp @@ -39,6 +39,7 @@ ewol::Widget::Widget(void) m_maxSize.y = -1.0; m_expendX = false; m_expendY = false; + m_genericDraw = true; } 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) { + /* if( origin.x < 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"); return false; } - + */ event_ts newEvent; newEvent.generateEventId = generateEventId; 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; iiiGetName() == name) { + return m_listOObject[iii]; + } + } + return NULL; +} + +void ewol::Widget::RmOObjectElem(etk::String name) +{ + for (int32_t iii=0; iiiGetName() == name) { + delete(m_listOObject[iii]); + m_listOObject[iii] = NULL; + m_listOObject.Erase(iii); + return; + } + } +} + +void ewol::Widget::ClearOObjectList(void) +{ + for (int32_t iii=0; iiiDraw(); + } + } return true; } diff --git a/Sources/ewolWidget.h b/Sources/ewolWidget.h index edd0392c..6d56499d 100644 --- a/Sources/ewolWidget.h +++ b/Sources/ewolWidget.h @@ -27,6 +27,7 @@ #include #include +#include #include namespace ewol { @@ -237,21 +238,25 @@ namespace ewol { // -- this will automaticly regenerate the same view in openGL // ---------------------------------------------------------------------------------------------------------------- private: - int32_t MultipleDisplayCurrentId; - //estd::VectorType m_inputEvent; bool m_genericDraw; + etk::VectorType m_listOObject; //!< generic element to display... bool GenericDraw(void); 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 SetGenericDraw(void) { m_genericDraw = true; }; - //void FlipFlopNext(void); //!< jump at the next display registered virtual bool OnDraw(void) { return true; }; public: bool GenDraw(void) { if (true == m_genericDraw) { + //EWOL_DEBUG("Draw generic..."); return GenericDraw(); } else { + //EWOL_DEBUG("Draw Custum..."); return OnDraw(); } }; diff --git a/Sources/ewolWindows.cpp b/Sources/ewolWindows.cpp index 6b2d9df6..aa5db0c0 100644 --- a/Sources/ewolWindows.cpp +++ b/Sources/ewolWindows.cpp @@ -41,6 +41,31 @@ const char * ewolEventWindowsClose = "ewol Windows close"; const char * ewolEventWindowsMinimize = "ewol Windows minimize"; 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) { 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_SRC_COLOR); - - - - /* - // 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"); - */ - + GenDraw(); + glDisable(GL_BLEND); + return; } diff --git a/Sources/ewolWindows.h b/Sources/ewolWindows.h index d6d5799f..5fb01e10 100644 --- a/Sources/ewolWindows.h +++ b/Sources/ewolWindows.h @@ -35,7 +35,7 @@ namespace ewol { class Windows :public ewol::Widget { public: - Windows(void) {}; + Windows(void); virtual ~Windows(void) {}; // internal event at ewol system : public: