2011-10-20 18:24:43 +02:00
|
|
|
/**
|
|
|
|
*******************************************************************************
|
|
|
|
* @file ewolWindows.cpp
|
|
|
|
* @brief ewol window system (sources)
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @date 20/10/2011
|
|
|
|
* @par Project
|
|
|
|
* ewol
|
|
|
|
*
|
|
|
|
* @par Copyright
|
|
|
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY.
|
|
|
|
*
|
|
|
|
* Licence summary :
|
|
|
|
* You can modify and redistribute the sources code and binaries.
|
|
|
|
* You can send me the bug-fix
|
|
|
|
*
|
|
|
|
* Term of the licence in in the file licence.txt.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2011-10-21 15:07:56 +02:00
|
|
|
#include <etkTypes.h>
|
|
|
|
#include <etkString.h>
|
|
|
|
#include <ewolWidget.h>
|
|
|
|
#include <ewolWindows.h>
|
2011-10-24 14:52:11 +02:00
|
|
|
#include <ewolOObject.h>
|
2011-10-20 18:24:43 +02:00
|
|
|
|
2011-10-24 14:52:11 +02:00
|
|
|
#include <GL/gl.h>
|
2011-10-21 15:07:56 +02:00
|
|
|
|
2011-10-26 23:28:38 +02:00
|
|
|
//list of local events :
|
|
|
|
const char * eventClose = "Close Windows";
|
|
|
|
|
2011-10-21 15:07:56 +02:00
|
|
|
bool ewol::Windows::CalculateSize(double availlableX, double availlableY)
|
|
|
|
{
|
|
|
|
m_size.x = availlableX;
|
|
|
|
m_size.y = availlableY;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-26 18:03:15 +02:00
|
|
|
// TODO : Rewrite this with common event ...
|
|
|
|
bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y)
|
|
|
|
{
|
|
|
|
if( EVENT_INPUT_TYPE_UP == typeEvent
|
|
|
|
&& 1 == IdInput)
|
|
|
|
{
|
|
|
|
if (y <= 20.0) {
|
|
|
|
if (x <= 20.0) {
|
|
|
|
EWOL_INFO("Request close");
|
|
|
|
} else if (x <= 40.0) {
|
|
|
|
EWOL_INFO("Request Minimize");
|
|
|
|
} else if (x <= 60.0) {
|
|
|
|
EWOL_INFO("Request Expend/unExpend");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-21 15:07:56 +02:00
|
|
|
void ewol::Windows::SysDraw(void)
|
|
|
|
{
|
2011-10-24 14:52:11 +02:00
|
|
|
|
|
|
|
//EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
|
2011-10-21 15:07:56 +02:00
|
|
|
// set the size of the open GL system
|
|
|
|
glViewport(0,0,m_size.x,m_size.y);
|
|
|
|
|
|
|
|
// Clear the screen with transparency ...
|
|
|
|
glClearColor(0.750, 0.750, 0.750, 0.5);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
2011-10-24 17:31:03 +02:00
|
|
|
glOrtho(0., m_size.x, 0., -m_size.y, 1., 20.);
|
2011-10-21 15:07:56 +02:00
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
2011-10-24 17:31:03 +02:00
|
|
|
glTranslatef(0, -m_size.y, -5);
|
2011-10-24 17:30:13 +02:00
|
|
|
|
2011-10-24 17:31:03 +02:00
|
|
|
//http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html
|
2011-10-24 17:30:13 +02:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2011-10-24 17:31:03 +02:00
|
|
|
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
|
|
|
|
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
|
2011-10-24 17:30:13 +02:00
|
|
|
|
2011-10-24 14:52:11 +02:00
|
|
|
|
|
|
|
|
2011-10-26 18:03:15 +02:00
|
|
|
/*
|
|
|
|
// 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();
|
|
|
|
*/
|
2011-10-24 14:52:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
ewol::OObject2DColored myOObject;
|
2011-10-26 23:28:38 +02:00
|
|
|
static bool isinit = false;
|
2011-10-26 18:03:15 +02:00
|
|
|
|
|
|
|
myOObject.Rectangle( 0, 0, 20, 20, 1.0, 0.0, 0.0, 1.0); // Close
|
2011-10-26 23:28:38 +02:00
|
|
|
if (false == isinit) {
|
|
|
|
isinit=true;
|
2011-10-26 18:03:15 +02:00
|
|
|
AddEventArea({0.0,0.0}, {20, 20}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_CLICKED, eventClose);
|
2011-10-26 23:28:38 +02:00
|
|
|
}
|
2011-10-26 18:03:15 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// Other ...
|
|
|
|
myOObject.Rectangle(20, 30, 100, 50, 1.0, 0.0, 0.0, 1.0);
|
2011-10-24 14:52:11 +02:00
|
|
|
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);
|
|
|
|
|
2011-10-24 17:31:03 +02:00
|
|
|
|
2011-10-26 23:28:38 +02:00
|
|
|
//myOObject.Rectangle(-50, -50, 120, 120, 0.0, 1.0, 1.0, 0.5);
|
2011-10-24 17:31:03 +02:00
|
|
|
|
2011-10-24 14:52:11 +02:00
|
|
|
myOObject.Draw();
|
|
|
|
|
|
|
|
|
2011-10-26 23:28:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ewol::Windows::OnEventArea(const char * generateEventId, double x, double y)
|
|
|
|
{
|
|
|
|
if(eventClose == generateEventId) {
|
|
|
|
EWOL_DEBUG("Request close of the windows");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|