[DEV] Entry: First test of the Entry box directly generate with shader
This commit is contained in:
parent
6bfcd0513a
commit
215ee55c77
@ -77,7 +77,7 @@ void ewol::OObject2DColored::Draw(void)
|
|||||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
// color :
|
// color :
|
||||||
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||||
// Request the draw od the elements :
|
// Request the draw of the elements :
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
m_GLprogram->UnUse();
|
m_GLprogram->UnUse();
|
||||||
#else
|
#else
|
||||||
|
@ -148,7 +148,7 @@ int32_t ewol::Program::GetUniform(etk::UString tmpElement)
|
|||||||
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
|
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
|
||||||
if (tmp.m_elementId<0) {
|
if (tmp.m_elementId<0) {
|
||||||
checkGlError("glGetUniformLocation", __LINE__);
|
checkGlError("glGetUniformLocation", __LINE__);
|
||||||
EWOL_INFO("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
EWOL_ERROR("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
m_elementList.PushBack(tmp);
|
m_elementList.PushBack(tmp);
|
||||||
@ -197,13 +197,13 @@ void ewol::Program::UpdateContext(void)
|
|||||||
m_elementList[iii].m_elementId = glGetAttribLocation(m_program, m_elementList[iii].m_name.c_str());
|
m_elementList[iii].m_elementId = glGetAttribLocation(m_program, m_elementList[iii].m_name.c_str());
|
||||||
if (m_elementList[iii].m_elementId<0) {
|
if (m_elementList[iii].m_elementId<0) {
|
||||||
checkGlError("glGetAttribLocation", __LINE__);
|
checkGlError("glGetAttribLocation", __LINE__);
|
||||||
EWOL_INFO("glGetAttribLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
EWOL_ERROR("glGetAttribLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_elementList[iii].m_elementId = glGetUniformLocation(m_program, m_elementList[iii].m_name.c_str());
|
m_elementList[iii].m_elementId = glGetUniformLocation(m_program, m_elementList[iii].m_name.c_str());
|
||||||
if (m_elementList[iii].m_elementId<0) {
|
if (m_elementList[iii].m_elementId<0) {
|
||||||
checkGlError("glGetUniformLocation", __LINE__);
|
checkGlError("glGetUniformLocation", __LINE__);
|
||||||
EWOL_INFO("glGetUniformLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
EWOL_ERROR("glGetUniformLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,20 @@ void ewol::Entry::Init(void)
|
|||||||
ShortCutAdd("ctrl+v", ewolEventEntryPaste);
|
ShortCutAdd("ctrl+v", ewolEventEntryPaste);
|
||||||
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
||||||
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
etk::UString tmpString("widgetEntry.prog");
|
||||||
|
// get the shader resource :
|
||||||
|
m_GLPosition = 0;
|
||||||
|
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||||
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
|
m_GLsizeBorder = m_GLprogram->GetUniform("EW_sizeBorder");
|
||||||
|
m_GLsizePadding = m_GLprogram->GetUniform("EW_sizePadding");
|
||||||
|
m_GLsize = m_GLprogram->GetUniform("EW_size");
|
||||||
|
m_GLposText = m_GLprogram->GetUniform("EW_posText");
|
||||||
|
m_GLstate = m_GLprogram->GetUniform("EW_state");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::Entry::Entry(void)
|
ewol::Entry::Entry(void)
|
||||||
@ -118,6 +132,64 @@ etk::UString ewol::Entry::GetValue(void)
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Entry::SetPoint(float x, float y)
|
||||||
|
{
|
||||||
|
Vector2D<float> triangle(x, y);
|
||||||
|
m_coord.PushBack(triangle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::Entry::Rectangle(float x, float y, float w, float h)
|
||||||
|
{
|
||||||
|
m_coord.Clear();
|
||||||
|
/*
|
||||||
|
x += 3;
|
||||||
|
y += 3;
|
||||||
|
w -= 6;
|
||||||
|
h -= 6;
|
||||||
|
*/
|
||||||
|
/* Bitmap position
|
||||||
|
* xA xB
|
||||||
|
* yC *------*
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* yD *------*
|
||||||
|
*/
|
||||||
|
float dxA = x;
|
||||||
|
float dxB = x + w;
|
||||||
|
float dyC = y;
|
||||||
|
float dyD = y + h;
|
||||||
|
/*
|
||||||
|
if (true == m_hasClipping) {
|
||||||
|
if (dxA < m_clipping.x) {
|
||||||
|
dxA = m_clipping.x;
|
||||||
|
}
|
||||||
|
if (dxB > m_clipping.x + m_clipping.w) {
|
||||||
|
dxB = m_clipping.x + m_clipping.w;
|
||||||
|
}
|
||||||
|
if (dyC < m_clipping.y) {
|
||||||
|
dyC = m_clipping.y;
|
||||||
|
}
|
||||||
|
if (dyD > m_clipping.y + m_clipping.h) {
|
||||||
|
dyD = m_clipping.y + m_clipping.h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( dyC >= dyD
|
||||||
|
|| dxA >= dxB) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
SetPoint(dxA, dyD);
|
||||||
|
SetPoint(dxA, dyC);
|
||||||
|
SetPoint(dxB, dyC);
|
||||||
|
|
||||||
|
SetPoint(dxB, dyC);
|
||||||
|
SetPoint(dxB, dyD);
|
||||||
|
SetPoint(dxA, dyD);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
||||||
* @param[in] displayProp properties of the current display
|
* @param[in] displayProp properties of the current display
|
||||||
@ -125,6 +197,38 @@ etk::UString ewol::Entry::GetValue(void)
|
|||||||
*/
|
*/
|
||||||
void ewol::Entry::OnDraw(DrawProperty& displayProp)
|
void ewol::Entry::OnDraw(DrawProperty& displayProp)
|
||||||
{
|
{
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
if (m_GLprogram==NULL) {
|
||||||
|
EWOL_ERROR("No shader ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//glScalef(m_scaling.x, m_scaling.y, 1.0);
|
||||||
|
m_GLprogram->Use();
|
||||||
|
// set Matrix : translation/positionMatrix
|
||||||
|
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
|
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
|
// position :
|
||||||
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
|
// all entry parameters :
|
||||||
|
if (0<=m_GLsizeBorder) {
|
||||||
|
m_GLprogram->Uniform1f(m_GLsizeBorder, m_borderSize);
|
||||||
|
}
|
||||||
|
if (0<=m_GLsizePadding) {
|
||||||
|
m_GLprogram->Uniform1f(m_GLsizePadding, m_paddingSize);
|
||||||
|
}
|
||||||
|
if (0<=m_GLsize) {
|
||||||
|
m_GLprogram->Uniform2fv(m_GLsize, 1, &m_size.x);
|
||||||
|
}
|
||||||
|
if (0<=m_GLposText) {
|
||||||
|
m_GLprogram->Uniform4fv(m_GLposText, 1, m_pos);
|
||||||
|
}
|
||||||
|
if (0<=m_GLstate) {
|
||||||
|
m_GLprogram->Uniform1i(m_GLstate, 0);
|
||||||
|
}
|
||||||
|
// Request the draw of the elements :
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
|
m_GLprogram->UnUse();
|
||||||
|
#endif
|
||||||
m_oObjectDecoration.Draw();
|
m_oObjectDecoration.Draw();
|
||||||
m_oObjectText.Draw();
|
m_oObjectText.Draw();
|
||||||
}
|
}
|
||||||
@ -176,10 +280,19 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
|||||||
m_oObjectText.Text(textPos, m_data);
|
m_oObjectText.Text(textPos, m_data);
|
||||||
m_oObjectText.clippingDisable();
|
m_oObjectText.clippingDisable();
|
||||||
|
|
||||||
m_oObjectDecoration.SetColor(m_textColorBg);
|
#ifndef __VIDEO__OPENGL_ES_2
|
||||||
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
m_oObjectDecoration.SetColor(m_textColorBg);
|
||||||
m_oObjectDecoration.SetColor(m_textColorFg);
|
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
||||||
m_oObjectDecoration.RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, m_borderSize);
|
m_oObjectDecoration.SetColor(m_textColorFg);
|
||||||
|
m_oObjectDecoration.RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, m_borderSize);
|
||||||
|
#else
|
||||||
|
m_pos[0] = m_borderSize+2*drawClipping.x;
|
||||||
|
m_pos[1] = m_borderSize+2*drawClipping.y;
|
||||||
|
m_pos[2] = m_size.x - 2*(m_borderSize+2*drawClipping.x);
|
||||||
|
m_pos[3] = m_size.y - 2*(m_borderSize+2*drawClipping.y);
|
||||||
|
|
||||||
|
Rectangle(0, 0, m_size.x, m_size.y);
|
||||||
|
#endif
|
||||||
int32_t pos1 = m_displayCursorPosSelection;
|
int32_t pos1 = m_displayCursorPosSelection;
|
||||||
int32_t pos2 = m_displayCursorPos;
|
int32_t pos2 = m_displayCursorPos;
|
||||||
if(m_displayCursorPosSelection>m_displayCursorPos) {
|
if(m_displayCursorPosSelection>m_displayCursorPos) {
|
||||||
@ -187,6 +300,7 @@ void ewol::Entry::OnRegenerateDisplay(void)
|
|||||||
pos1 = m_displayCursorPos;
|
pos1 = m_displayCursorPos;
|
||||||
}
|
}
|
||||||
if(pos1!=pos2) {
|
if(pos1!=pos2) {
|
||||||
|
m_oObjectDecoration.SetColor(m_textColorFg);
|
||||||
m_oObjectDecoration.clippingSet(drawClipping);
|
m_oObjectDecoration.clippingSet(drawClipping);
|
||||||
etk::UString tmpDisplay = m_data.Extract(0, pos1);
|
etk::UString tmpDisplay = m_data.Extract(0, pos1);
|
||||||
Vector2D<int32_t> minSize = m_oObjectText.GetSize(tmpDisplay);
|
Vector2D<int32_t> minSize = m_oObjectText.GetSize(tmpDisplay);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <ewol/Debug.h>
|
#include <ewol/Debug.h>
|
||||||
#include <ewol/oObject/OObject.h>
|
#include <ewol/oObject/OObject.h>
|
||||||
#include <ewol/widget/Widget.h>
|
#include <ewol/widget/Widget.h>
|
||||||
|
#include <draw/Color.h>
|
||||||
|
|
||||||
extern const char * const ewolEventEntryClick;
|
extern const char * const ewolEventEntryClick;
|
||||||
extern const char * const ewolEventEntryEnter;
|
extern const char * const ewolEventEntryEnter;
|
||||||
@ -46,6 +47,22 @@ namespace ewol {
|
|||||||
*/
|
*/
|
||||||
class Entry : public ewol::Widget
|
class Entry : public ewol::Widget
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
|
ewol::Program* m_GLprogram;
|
||||||
|
int32_t m_GLPosition;
|
||||||
|
int32_t m_GLMatrix;
|
||||||
|
int32_t m_GLsizeBorder;
|
||||||
|
int32_t m_GLsizePadding;
|
||||||
|
int32_t m_GLsize;
|
||||||
|
float m_pos[4];
|
||||||
|
int32_t m_GLposText;
|
||||||
|
int32_t m_GLstate;
|
||||||
|
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
|
||||||
|
draw::Colorf m_color[3];
|
||||||
|
void SetPoint(float x, float y);
|
||||||
|
void Rectangle(float x, float y, float w, float h);
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
ewol::OObject2DTextColored m_oObjectText; //!< text display
|
ewol::OObject2DTextColored m_oObjectText; //!< text display
|
||||||
ewol::OObject2DColored m_oObjectDecoration; //!< background display
|
ewol::OObject2DColored m_oObjectDecoration; //!< background display
|
||||||
|
36
share/widgetEntry.frag
Normal file
36
share/widgetEntry.frag
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uniform float EW_sizeBorder;
|
||||||
|
uniform float EW_sizePadding;
|
||||||
|
uniform vec2 EW_size;
|
||||||
|
uniform vec4 EW_posText;
|
||||||
|
uniform int EW_state;
|
||||||
|
|
||||||
|
// transmit from the vertex shader
|
||||||
|
varying vec2 v_position; // intermolated position ...
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
float specialBorder = EW_sizeBorder+EW_sizePadding;
|
||||||
|
vec2 endStart = EW_size - vec2(EW_sizePadding) - vec2(EW_sizeBorder);
|
||||||
|
vec2 endStop = EW_size - vec2(EW_sizePadding);
|
||||||
|
if( v_position.x> EW_sizePadding
|
||||||
|
&& v_position.y> EW_sizePadding
|
||||||
|
&& v_position.x<= endStop.x
|
||||||
|
&& v_position.y<= endStop.y
|
||||||
|
) {
|
||||||
|
if( v_position.x<= specialBorder
|
||||||
|
|| v_position.y<= specialBorder
|
||||||
|
|| v_position.x> endStart.x
|
||||||
|
|| v_position.y> endStart.y
|
||||||
|
) {
|
||||||
|
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||||
|
} else {
|
||||||
|
gl_FragColor = vec4(1.0,1.0,1.0,0.8);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gl_FragColor = vec4(0.0);
|
||||||
|
}
|
||||||
|
}
|
2
share/widgetEntry.prog
Normal file
2
share/widgetEntry.prog
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
widgetEntry.vert
|
||||||
|
widgetEntry.frag
|
17
share/widgetEntry.vert
Normal file
17
share/widgetEntry.vert
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Input :
|
||||||
|
attribute vec2 EW_coord2d;
|
||||||
|
uniform mat4 EW_MatrixTransformation;
|
||||||
|
|
||||||
|
// output :
|
||||||
|
varying vec2 v_position; // This will be passed into the fragment shader.
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
|
// transmit position of the curent element (intermolated ...)
|
||||||
|
v_position = EW_coord2d;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user