[DEV] shader loading corection and touch scrooling corection
This commit is contained in:
parent
d535450eb5
commit
6ea4035942
@ -2,7 +2,6 @@
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
struct displayProperty {
|
||||
vec2 size;
|
||||
vec2 origin;
|
||||
@ -10,31 +9,21 @@ struct displayProperty {
|
||||
vec2 insideSize;
|
||||
};
|
||||
|
||||
struct widgetStateProperty {
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
};
|
||||
|
||||
uniform displayProperty EW_widgetProperty;
|
||||
uniform widgetStateProperty EW_status;
|
||||
|
||||
|
||||
// transmit from the vertex shader
|
||||
varying vec2 v_position; // interpolated position ...
|
||||
varying vec4 v_colorTansition;
|
||||
|
||||
// internal static define
|
||||
vec4 S_colorBg = vec4(0.0);
|
||||
vec4 S_colorFg[3];
|
||||
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
|
||||
float S_sizePadding = 3.0;
|
||||
float S_sizeBorder = 1.0;
|
||||
|
||||
|
||||
void main(void) {
|
||||
S_colorFg[0] = vec4(1.0,1.0,1.0,0.8);
|
||||
S_colorFg[1] = vec4(1.0,1.0,1.0,0.4);
|
||||
S_colorFg[2] = vec4(0.0,0.0,1.0,0.1);
|
||||
|
||||
// prevent origin moving ...
|
||||
vec2 position = v_position - EW_widgetProperty.origin;
|
||||
|
||||
@ -56,8 +45,7 @@ void main(void) {
|
||||
gl_FragColor = S_colorBorder;
|
||||
} else {
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
gl_FragColor = S_colorFg[int(EW_status.stateOld)]*(1.0-EW_status.transition)
|
||||
+ S_colorFg[int(EW_status.stateNew)]*EW_status.transition;
|
||||
gl_FragColor = v_colorTansition;
|
||||
}
|
||||
} else {
|
||||
gl_FragColor = S_colorBg;
|
||||
|
@ -3,15 +3,48 @@ precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
struct widgetStateProperty {
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
};
|
||||
|
||||
// Input :
|
||||
attribute vec2 EW_coord2d;
|
||||
uniform mat4 EW_MatrixTransformation;
|
||||
uniform widgetStateProperty EW_status;
|
||||
|
||||
// output :
|
||||
varying vec2 v_position; // This will be passed into the fragment shader.
|
||||
varying vec4 v_colorTansition;
|
||||
|
||||
// internal :
|
||||
vec4 S_colorFg[3];
|
||||
|
||||
void main(void) {
|
||||
S_colorFg[0] = vec4(1.0,1.0,1.0,0.8);
|
||||
S_colorFg[1] = vec4(1.0,1.0,1.0,0.4);
|
||||
S_colorFg[2] = vec4(0.0,0.0,1.0,0.1);
|
||||
|
||||
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
// transmit position of the curent element (intermolated ...)
|
||||
v_position = EW_coord2d;
|
||||
|
||||
|
||||
vec4 colorOld = S_colorFg[0];
|
||||
if(EW_status.stateOld==1) {
|
||||
colorOld = S_colorFg[1];
|
||||
} else if(EW_status.stateOld==2) {
|
||||
colorOld = S_colorFg[2];
|
||||
}
|
||||
vec4 colorNew = S_colorFg[0];
|
||||
if(EW_status.stateNew==1) {
|
||||
colorNew = S_colorFg[1];
|
||||
} else if(EW_status.stateNew==2) {
|
||||
colorNew = S_colorFg[2];
|
||||
}
|
||||
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
v_colorTansition = colorOld*(1.0-EW_status.transition)
|
||||
+ colorNew*EW_status.transition;
|
||||
}
|
||||
|
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
||||
Subproject commit f2edd2def61f19ec5db846a522fb056a9c7cee0c
|
||||
Subproject commit b9a79c1dfceb04fc2e488832260a26c03055bd98
|
@ -304,7 +304,7 @@ static int32_t nextP2(int32_t value)
|
||||
|
||||
bool ewol::resource::Keep(const etk::UString& _filename, ewol::TextureFile*& _object, ivec2 _size)
|
||||
{
|
||||
EWOL_VERBOSE(" keep image file : " << _filename << " " << _size);
|
||||
EWOL_INFO("KEEP : TextureFile : file : " << _filename << " basic size=" << _size);
|
||||
if (_size.x()==0) {
|
||||
_size.setX(-1);
|
||||
//EWOL_ERROR("Error Request the image size.x() =0 ???");
|
||||
@ -324,20 +324,15 @@ bool ewol::resource::Keep(const etk::UString& _filename, ewol::TextureFile*& _ob
|
||||
if (_size.x()>0 && _size.y()>0) {
|
||||
EWOL_VERBOSE(" ==> specific size : " << _size);
|
||||
#ifdef __TARGET_OS__Android
|
||||
ivec2 size2(nextP2(_size.x()), nextP2(_size.y()));
|
||||
TmpFilename += ":";
|
||||
TmpFilename += size2.x();
|
||||
TmpFilename += "x";
|
||||
TmpFilename += size2.y();
|
||||
#else
|
||||
TmpFilename += ":";
|
||||
TmpFilename += _size.x();
|
||||
TmpFilename += "x";
|
||||
TmpFilename += _size.y();
|
||||
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
|
||||
#endif
|
||||
TmpFilename += ":";
|
||||
TmpFilename += _size.x();
|
||||
TmpFilename += "x";
|
||||
TmpFilename += _size.y();
|
||||
}
|
||||
|
||||
EWOL_INFO("KEEP : TextureFile : file : \"" << TmpFilename << "\" basic size=" << _size);
|
||||
EWOL_INFO("KEEP : TextureFile : file : \"" << TmpFilename << "\" new size=" << _size);
|
||||
_object = static_cast<ewol::TextureFile*>(LocalKeep(TmpFilename));
|
||||
if (NULL != _object) {
|
||||
return true;
|
||||
|
@ -196,14 +196,14 @@ ewol::eSystemInput::~eSystemInput(void)
|
||||
}
|
||||
|
||||
|
||||
int32_t ewol::eSystemInput::localGetDestinationId(ewol::keyEvent::type_te type, ewol::Widget* destWidget, int32_t realInputId)
|
||||
int32_t ewol::eSystemInput::localGetDestinationId(ewol::keyEvent::type_te _type, ewol::Widget* _destWidget, int32_t _realInputId)
|
||||
{
|
||||
if (type == ewol::keyEvent::typeFinger) {
|
||||
if (_type == ewol::keyEvent::typeFinger) {
|
||||
int32_t lastMinimum = 0;
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
if (true==m_eventInputSaved[iii].isUsed) {
|
||||
if (m_eventInputSaved[iii].curentWidgetEvent == destWidget) {
|
||||
if (iii != realInputId) {
|
||||
if (m_eventInputSaved[iii].curentWidgetEvent == _destWidget) {
|
||||
if (iii != _realInputId) {
|
||||
lastMinimum = etk_max(lastMinimum, m_eventInputSaved[iii].destinationInputId);
|
||||
}
|
||||
}
|
||||
@ -211,12 +211,13 @@ int32_t ewol::eSystemInput::localGetDestinationId(ewol::keyEvent::type_te type,
|
||||
}
|
||||
return lastMinimum+1;
|
||||
}
|
||||
return realInputId;
|
||||
return _realInputId;
|
||||
}
|
||||
|
||||
// note if id<0 ==> the it was finger event ...
|
||||
void ewol::eSystemInput::Motion(ewol::keyEvent::type_te type, int pointerID, vec2 pos)
|
||||
{
|
||||
EVENT_DEBUG("motion event : " << type << " " << pointerID << " " << pos);
|
||||
if (MAX_MANAGE_INPUT<=pointerID) {
|
||||
// reject pointer ==> out of IDs...
|
||||
return;
|
||||
|
@ -41,14 +41,14 @@ ewol::Program::Program(const etk::UString& filename) :
|
||||
EWOL_CRITICAL("Error while getting a specific shader filename : " << tmpFilename);
|
||||
return;
|
||||
} else {
|
||||
EWOL_DEBUG("Add shader on program : "<< tmpFilename);
|
||||
EWOL_DEBUG("Add shader on program : "<< tmpFilename << "vert");
|
||||
m_shaderList.PushBack(tmpShader);
|
||||
}
|
||||
if (false == ewol::resource::Keep(tmpFilename+"frag", tmpShader)) {
|
||||
EWOL_CRITICAL("Error while getting a specific shader filename : " << tmpFilename);
|
||||
return;
|
||||
} else {
|
||||
EWOL_DEBUG("Add shader on program : "<< tmpFilename);
|
||||
EWOL_DEBUG("Add shader on program : "<< tmpFilename << "frag");
|
||||
m_shaderList.PushBack(tmpShader);
|
||||
}
|
||||
} else {
|
||||
|
@ -15,15 +15,15 @@
|
||||
#undef __class__
|
||||
#define __class__ "Shader"
|
||||
|
||||
ewol::Shader::Shader(const etk::UString& filename):
|
||||
ewol::Resource(filename),
|
||||
ewol::Shader::Shader(const etk::UString& _filename):
|
||||
ewol::Resource(_filename),
|
||||
m_exist(false),
|
||||
m_fileData(NULL),
|
||||
m_shader(0),
|
||||
m_type(0)
|
||||
{
|
||||
m_resourceLevel = 0;
|
||||
EWOL_DEBUG("OGL : load SHADER \"" << filename << "\"");
|
||||
EWOL_DEBUG("OGL : load SHADER \"" << _filename << "\"");
|
||||
// load data from file "all the time ..."
|
||||
|
||||
if (true == m_name.EndWith(".frag") ) {
|
||||
@ -89,7 +89,12 @@ void ewol::Shader::UpdateContext(void)
|
||||
if (m_type == GL_VERTEX_SHADER){
|
||||
tmpShaderType = "GL_VERTEX_SHADER";
|
||||
}
|
||||
EWOL_ERROR("Could not compile \"" << tmpShaderType << "\": " << l_bufferDisplayError);
|
||||
EWOL_ERROR("Could not compile \"" << tmpShaderType << "\" name='" << m_name << "'");
|
||||
EWOL_ERROR("Error " << l_bufferDisplayError);
|
||||
etk::Vector<etk::UString> lines = etk::UString(m_fileData).Split('\n');
|
||||
for (esize_t iii=0 ; iii<lines.Size() ; iii++) {
|
||||
EWOL_ERROR("file " << (iii+1) << "|" << lines[iii]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace ewol
|
||||
* @brief Contructor of an opengl Shader
|
||||
* @param[in] filename Standard file name format. see @ref etk::FSNode
|
||||
*/
|
||||
Shader(const etk::UString& filename);
|
||||
Shader(const etk::UString& _filename);
|
||||
/**
|
||||
* @brief Destructor, remove the current Shader
|
||||
*/
|
||||
|
@ -79,16 +79,16 @@ void widget::List::CalculateMinMaxSize(void)
|
||||
}
|
||||
|
||||
|
||||
void widget::List::AddOObject(ewol::Compositing* newObject, int32_t pos)
|
||||
void widget::List::AddOObject(ewol::Compositing* _newObject, int32_t _pos)
|
||||
{
|
||||
if (NULL == newObject) {
|
||||
if (NULL == _newObject) {
|
||||
EWOL_ERROR("Try to add an empty object in the Widget generic display system");
|
||||
return;
|
||||
}
|
||||
if (pos < 0 || pos >= m_listOObject.Size() ) {
|
||||
m_listOObject.PushBack(newObject);
|
||||
if (_pos < 0 || _pos >= m_listOObject.Size() ) {
|
||||
m_listOObject.PushBack(_newObject);
|
||||
} else {
|
||||
m_listOObject.Insert(pos, newObject);
|
||||
m_listOObject.Insert(_pos, _newObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <ewol/compositing/Compositing.h>
|
||||
|
||||
namespace widget {
|
||||
class List :public widget::WidgetScrooled
|
||||
class List : public widget::WidgetScrooled
|
||||
{
|
||||
public:
|
||||
List(void);
|
||||
@ -24,13 +24,13 @@ namespace widget {
|
||||
virtual const char * const GetObjectType(void) { return "ewol::List"; };
|
||||
virtual ~List(void);
|
||||
virtual void CalculateMinMaxSize(void);
|
||||
void SetLabel(etk::UString newLabel);
|
||||
void SetLabel(etk::UString _newLabel);
|
||||
// Drawing capabilities ....
|
||||
private:
|
||||
etk::Vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
|
||||
etk::Vector<ivec2 > m_lineSize;
|
||||
public:
|
||||
void AddOObject(ewol::Compositing* newObject, int32_t pos=-1);
|
||||
void AddOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
|
||||
void ClearOObjectList(void);
|
||||
// list properties ...
|
||||
private:
|
||||
|
@ -80,6 +80,7 @@ void widget::WidgetScrooled::OnRegenerateDisplay(void)
|
||||
|
||||
bool widget::WidgetScrooled::OnEventInput(const ewol::EventInput& _event)
|
||||
{
|
||||
EWOL_VERBOSE("event XXX " << _event);
|
||||
vec2 relativePos = RelativePosition(_event.GetPos());
|
||||
// corection due to the open Gl invertion ...
|
||||
relativePos.setY(m_size.y() - relativePos.y());
|
||||
@ -232,17 +233,17 @@ bool widget::WidgetScrooled::OnEventInput(const ewol::EventInput& _event)
|
||||
&& ( ewol::keyEvent::typeUnknow==m_highSpeedType
|
||||
|| ewol::keyEvent::typeFinger==m_highSpeedType ) ) {
|
||||
if (1 == _event.GetId()) {
|
||||
//EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
|
||||
EWOL_VERBOSE("event 1 " << _event);
|
||||
if (ewol::keyEvent::statusDown == _event.GetStatus()) {
|
||||
m_highSpeedMode = widget::SCROLL_INIT;
|
||||
m_highSpeedType = ewol::keyEvent::typeFinger;
|
||||
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
EWOL_VERBOSE("SCROOL ==> INIT");
|
||||
EWOL_DEBUG("SCROOL ==> INIT");
|
||||
return true;
|
||||
} else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
|
||||
m_highSpeedMode = widget::SCROLL_DISABLE;
|
||||
m_highSpeedType = ewol::keyEvent::typeUnknow;
|
||||
EWOL_VERBOSE("SCROOL ==> DISABLE");
|
||||
EWOL_DEBUG("SCROOL ==> DISABLE");
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
} else if (widget::SCROLL_INIT==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
|
||||
@ -252,25 +253,25 @@ bool widget::WidgetScrooled::OnEventInput(const ewol::EventInput& _event)
|
||||
// the scrooling can start :
|
||||
// select the direction :
|
||||
m_highSpeedMode = widget::SCROLL_ENABLE_FINGER;
|
||||
EWOL_VERBOSE("SCROOL ==> ENABLE");
|
||||
EWOL_DEBUG("SCROOL ==> ENABLE");
|
||||
MarkToRedraw();
|
||||
}
|
||||
return true;
|
||||
} if (widget::SCROLL_ENABLE_FINGER==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
|
||||
//m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x);
|
||||
m_originScrooled.setX(m_originScrooled.x() - relativePos.x() - m_highSpeedStartPos.x());
|
||||
m_originScrooled.setY(m_originScrooled.y() - relativePos.y() - m_highSpeedStartPos.y());
|
||||
m_originScrooled.setX(m_originScrooled.x() - (relativePos.x() - m_highSpeedStartPos.x()));
|
||||
m_originScrooled.setY(m_originScrooled.y() - (relativePos.y() - m_highSpeedStartPos.y()));
|
||||
m_originScrooled.setX(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
|
||||
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
|
||||
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||
EWOL_VERBOSE("SCROOL ==> MOVE (" << m_originScrooled.x() << "," << m_originScrooled.y() << ")");
|
||||
EWOL_DEBUG("SCROOL ==> MOVE m_originScrooled=" << m_originScrooled << " " << relativePos << " " << m_highSpeedStartPos);
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (widget::SCROLL_DISABLE!=m_highSpeedMode && ewol::keyEvent::statusLeave == _event.GetStatus()) {
|
||||
m_highSpeedMode = widget::SCROLL_DISABLE;
|
||||
m_highSpeedType = ewol::keyEvent::typeUnknow;
|
||||
EWOL_VERBOSE("SCROOL ==> DISABLE");
|
||||
EWOL_DEBUG("SCROOL ==> DISABLE");
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user