keyboard correction, change clipping methode of the oobject

This commit is contained in:
Edouard Dupin 2012-02-23 18:07:01 +01:00
parent 551684fe8e
commit 514f666a15
9 changed files with 37 additions and 91 deletions

View File

@ -42,14 +42,15 @@ namespace ewol {
class OObject class OObject
{ {
protected:
bool m_hasClipping;
clipping_ts m_clipping;
public: public:
OObject(void); OObject(void);
virtual ~OObject(void); virtual ~OObject(void);
public: void SetClipping(clipping_ts clip) {m_clipping = clip; m_hasClipping = true;};
void RmClipping(void) {m_hasClipping = false;};
virtual void Draw(void) = 0; virtual void Draw(void) = 0;
public:
// use to crop element outside the display
virtual void UpdateSize(etkFloat_t sizeX, etkFloat_t sizeY) { };
}; };
}; };

View File

@ -283,49 +283,6 @@ void SutherlandHodgman(etk::VectorType<coord2D_ts> & input, etk::VectorType<coor
} }
void ewol::OObject2DColored::UpdateSize(etkFloat_t sizeX, etkFloat_t sizeY)
{
// copy the data
etk::VectorType<coord2D_ts> coord = m_coord;
etk::VectorType<color_ts> color = m_coordColor;
// Clear the generated display ...
m_coord.Clear();
m_coordColor.Clear();
// Check if the triangle is in the area...
int32_t nbTriangle = coord.Size()/3;
for (int32_t iii=0; iii<nbTriangle; iii++) {
if( coord[iii*3+0].x >= 0.0 && coord[iii*3+0].x < sizeX
&& coord[iii*3+0].y >= 0.0 && coord[iii*3+0].y < sizeY
&& coord[iii*3+1].x >= 0.0 && coord[iii*3+1].x < sizeX
&& coord[iii*3+1].y >= 0.0 && coord[iii*3+1].y < sizeY
&& coord[iii*3+2].x >= 0.0 && coord[iii*3+2].x < sizeX
&& coord[iii*3+2].y >= 0.0 && coord[iii*3+2].y < sizeY)
{
// point 1-2-3 inside
m_coord.PushBack(coord[iii*3+0]);
m_coordColor.PushBack(color[iii*3+0]);
m_coord.PushBack(coord[iii*3+1]);
m_coordColor.PushBack(color[iii*3+1]);
m_coord.PushBack(coord[iii*3+2]);
m_coordColor.PushBack(color[iii*3+2]);
} else {
etk::VectorType<coord2D_ts> tmpCoord;
etk::VectorType<coord2D_ts> tmpCoordOut;
tmpCoord.PushBack(coord[iii*3+0]);
tmpCoord.PushBack(coord[iii*3+1]);
tmpCoord.PushBack(coord[iii*3+2]);
SutherlandHodgman(tmpCoord, tmpCoordOut, 0, 0, sizeX, sizeY);
tmpCoord.Clear();
generatePolyGone(tmpCoordOut, tmpCoord);
for (int32_t jjj=0; jjj<tmpCoord.Size(); jjj++) {
m_coord.PushBack(tmpCoord[jjj]);
m_coordColor.PushBack(color[iii*3+0]);
}
}
}
}
void ewol::OObject2DColored::GenerateTriangle(void) void ewol::OObject2DColored::GenerateTriangle(void)
{ {
m_triElement = 0; m_triElement = 0;
@ -435,27 +392,7 @@ void ewol::OObject2DColored::Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, e
SetPoint(sx - offsetx, sy - offsety); SetPoint(sx - offsetx, sy - offsety);
} }
void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h) void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h)
{
ResetCount();
if( 0 >= h
|| 0 >= w) {
return;
}
SetPoint(x , y + h);
SetPoint(x , y);
SetPoint(x + w, y);
SetPoint(x + w, y);
SetPoint(x + w, y + h);
SetPoint(x , y + h);
}
void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, clipping_ts& drawClipping)
{ {
ResetCount(); ResetCount();
@ -471,24 +408,24 @@ void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w,
etkFloat_t dyC = y; etkFloat_t dyC = y;
etkFloat_t dyD = y + h; etkFloat_t dyD = y + h;
//EWOL_INFO("Rectangle size : (" << x << "," << y << ") in clipping (" << drawClipping.x << "," << drawClipping.y << ") ==> (" << drawClipping.w << "," << drawClipping.h << ")"); if (true == m_hasClipping) {
if (dxA < drawClipping.x) { if (dxA < m_clipping.x) {
dxA = drawClipping.x; dxA = m_clipping.x;
} }
if (dxB > drawClipping.x + drawClipping.w) { if (dxB > m_clipping.x + m_clipping.w) {
dxB = drawClipping.x + drawClipping.w; dxB = m_clipping.x + m_clipping.w;
} }
if (dyC < drawClipping.y) { if (dyC < m_clipping.y) {
dyC = drawClipping.y; dyC = m_clipping.y;
} }
if (dyD > drawClipping.y + drawClipping.h) { if (dyD > m_clipping.y + m_clipping.h) {
dyD = drawClipping.y + drawClipping.h; dyD = m_clipping.y + m_clipping.h;
}
} }
if( dyC >= dyD if( dyC >= dyD
|| dxA >= dxB) { || dxA >= dxB) {
return; return;
} }
SetPoint(dxA, dyD); SetPoint(dxA, dyD);
SetPoint(dxA, dyC); SetPoint(dxA, dyC);
SetPoint(dxB, dyC); SetPoint(dxB, dyC);

View File

@ -52,15 +52,11 @@ namespace ewol {
void SetPoint(etkFloat_t x, etkFloat_t y); void SetPoint(etkFloat_t x, etkFloat_t y);
void Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey, etkFloat_t thickness); void Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey, etkFloat_t thickness);
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h); void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h);
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, clipping_ts& drawClipping);
void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness); void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness);
void Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness); void Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness);
void CirclePart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness, etkFloat_t angleStart, etkFloat_t angleStop); void CirclePart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness, etkFloat_t angleStart, etkFloat_t angleStop);
void Disc(etkFloat_t x, etkFloat_t y, etkFloat_t radius); void Disc(etkFloat_t x, etkFloat_t y, etkFloat_t radius);
void DiscPart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t angleStart, etkFloat_t angleStop); void DiscPart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t angleStart, etkFloat_t angleStop);
public:
// Ewol internal ... : done to update at the origin of the widget ...
virtual void UpdateSize(etkFloat_t sizeX, etkFloat_t sizeY);
}; };
}; };

View File

@ -25,6 +25,7 @@
#include <ewol/Widget.h> #include <ewol/Widget.h>
#include <ewol/WidgetManager.h> #include <ewol/WidgetManager.h>
#include <ewol/WidgetMessageMultiCast.h> #include <ewol/WidgetMessageMultiCast.h>
#include <ewol/ewol.h>
#include <ewol/importgl.h> #include <ewol/importgl.h>
char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type) char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type)
@ -252,8 +253,8 @@ bool ewol::Widget::GenDraw(void)
etkFloat_t testSizeX = m_size.x-TEST_CLIPPING_SIZE*2; etkFloat_t testSizeX = m_size.x-TEST_CLIPPING_SIZE*2;
etkFloat_t testSizeY = m_size.y-TEST_CLIPPING_SIZE*2; etkFloat_t testSizeY = m_size.y-TEST_CLIPPING_SIZE*2;
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x + TEST_CLIPPING_SIZE, glViewport( m_origin.x + TEST_CLIPPING_SIZE,
600 - m_size.y - m_origin.y + TEST_CLIPPING_SIZE, ewol::GetCurrentHeight() - m_size.y - m_origin.y + TEST_CLIPPING_SIZE,
testSizeX, testSizeX,
testSizeY); testSizeY);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);

View File

@ -37,6 +37,17 @@ ewol::Windows* gui_uniqueWindows = NULL;
etkFloat_t gui_width = 320; etkFloat_t gui_width = 320;
etkFloat_t gui_height = 480; etkFloat_t gui_height = 480;
int32_t ewol::GetCurrentWidth(void)
{
return gui_width;
}
int32_t ewol::GetCurrentHeight(void)
{
return gui_height;
}
void ewol::RmPopUp(int32_t widgetID) void ewol::RmPopUp(int32_t widgetID)
{ {
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {

View File

@ -59,6 +59,9 @@ namespace ewol {
void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data); void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data);
void Add(char * descriptiveString, const char * generateEventId, etk::UString& data); void Add(char * descriptiveString, const char * generateEventId, etk::UString& data);
}; };
int32_t GetCurrentWidth(void);
int32_t GetCurrentHeight(void);
}; };
int64_t GetCurrentTime(void); int64_t GetCurrentTime(void);

View File

@ -49,10 +49,6 @@ void ewol::Drawable::AddOObject(ewol::OObject* newObject, int32_t pos)
EWOL_ERROR("Try to add an empty object in the Widget generic display system"); EWOL_ERROR("Try to add an empty object in the Widget generic display system");
return; return;
} }
// TODO : Chow why I use this ...
//EWOL_INFO("UPDATE AT size : (" << m_size.x << "," << m_size.y << ")");
newObject->UpdateSize(m_size.x, m_size.y);
if (pos < 0 || pos >= m_listOObject[m_currentCreateId].Size() ) { if (pos < 0 || pos >= m_listOObject[m_currentCreateId].Size() ) {
m_listOObject[m_currentCreateId].PushBack(newObject); m_listOObject[m_currentCreateId].PushBack(newObject);
} else { } else {

View File

@ -79,6 +79,7 @@ bool ewol::Label::CalculateMinSize(void)
void ewol::Label::SetLabel(etk::UString newLabel) void ewol::Label::SetLabel(etk::UString newLabel)
{ {
m_label = newLabel; m_label = newLabel;
MarkToReedraw();
} }

View File

@ -246,7 +246,7 @@ bool ewol::Keyboard::CalculateSize(etkFloat_t availlableX, etkFloat_t availlable
subWidgetSize.x = (int32_t)subWidgetSize.x; subWidgetSize.x = (int32_t)subWidgetSize.x;
subWidgetSize.y = (int32_t)subWidgetSize.y; subWidgetSize.y = (int32_t)subWidgetSize.y;
m_subWidget->SetOrigin(0, 0); m_subWidget->SetOrigin(m_origin.x, m_origin.y);
m_subWidget->CalculateSize(subWidgetSize.x, subWidgetSize.y); m_subWidget->CalculateSize(subWidgetSize.x, subWidgetSize.y);
} }
MarkToReedraw(); MarkToReedraw();