missing shortCut

This commit is contained in:
Edouard Dupin 2012-02-20 10:19:17 +01:00
parent 36534c0882
commit 1c0c59b0ca
3 changed files with 180 additions and 9 deletions

View File

@ -240,7 +240,8 @@ void ewol::Widget::SetCanHaveFocus(bool canFocusState)
//#define TEST_CLIPPING_SIZE (3)
//#define TEST_CLIPPING_SIZE (0)
#ifdef __PLATFORM__Android
#if 1
//def __PLATFORM__Android
# define clipping_type GLfloat
# define clipping_function glClipPlanef
#else
@ -253,19 +254,18 @@ bool ewol::Widget::GenDraw(void)
#if 1
glTranslatef(m_origin.x,m_origin.y, 0);
//GLfloat
clipping_type eqn1[4] = {0.0, 1.0, 0.0, -TEST_CLIPPING_SIZE}; // less the Y pos ...
clipping_type eqn2[4] = {0.0, -1.0, 0.0, m_size.y-TEST_CLIPPING_SIZE}; // upper the y pos ...
clipping_type eqn3[4] = {1.0, 0.0, 0.0, -TEST_CLIPPING_SIZE}; // less the x pos ...
clipping_type eqn1[4] = { 0.0, 1.0, 0.0, -TEST_CLIPPING_SIZE}; // less the Y pos ...
clipping_type eqn2[4] = { 0.0, -1.0, 0.0, m_size.y-TEST_CLIPPING_SIZE-50}; // upper the y pos ...
clipping_type eqn3[4] = { 1.0, 0.0, 0.0, -TEST_CLIPPING_SIZE}; // less the x pos ...
clipping_type eqn4[4] = {-1.0, 0.0, 0.0, m_size.x-TEST_CLIPPING_SIZE}; // upper the x pos ...
//EWOL_DEBUG("widget size (" << m_size.x << "," << m_size.y << ")" );
/* clip lower half -- y < 0 */
glEnable(GL_CLIP_PLANE0);
clipping_function(GL_CLIP_PLANE0, eqn1);
glEnable(GL_CLIP_PLANE1);
clipping_function(GL_CLIP_PLANE1, eqn2);
glEnable(GL_CLIP_PLANE2);
clipping_function(GL_CLIP_PLANE2, eqn3);
glEnable(GL_CLIP_PLANE3);
clipping_function(GL_CLIP_PLANE0, eqn1);
clipping_function(GL_CLIP_PLANE1, eqn2);
clipping_function(GL_CLIP_PLANE2, eqn3);
clipping_function(GL_CLIP_PLANE3, eqn4);
#else
glTranslatef(m_origin.x,m_origin.y, 0);

View File

@ -0,0 +1,113 @@
/**
*******************************************************************************
* @file ewol/widget/WidgetShortCut.cpp
* @brief basic ewol short Cut widget (Sources)
* @author Edouard DUPIN
* @date 19/02/2012
* @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.
*
*******************************************************************************
*/
#include <ewol/widget/WidgetShortCut.h>
ewol::WidgetShortCut::WidgetShortCut(void)
{
// nothing to do ...
}
ewol::WidgetShortCut::~WidgetShortCut(void)
{
//clean all the object
m_inputShortCutEvent.Clear();
}
bool ewol::WidgetShortCut::AddEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue, const char * generateEventId)
{
eventShortCut_ts newEvent;
newEvent.generateEventId = generateEventId;
newEvent.shift = shift;
newEvent.control = control;
newEvent.alt = alt;
newEvent.meta = meta;
newEvent.UnicodeValue = unicodeValue;
m_inputShortCutEvent.PushBack(newEvent);
return true;
}
bool ewol::WidgetShortCut::AddEventShortCut(char * descriptiveString, const char * generateEventId)
{
if( NULL==descriptiveString
|| 0==strlen(descriptiveString))
{
return false;
}
bool shift = false;
bool control = false;
bool alt = false;
bool meta = false;
uint32_t UnicodeValue = 0;
// parsing of the string :
//"ctrl+shift+alt+meta+s"
char * tmp = strstr(descriptiveString, "ctrl");
if(NULL != tmp) {
control = true;
}
tmp = strstr(descriptiveString, "shift");
if(NULL != tmp) {
shift = true;
}
tmp = strstr(descriptiveString, "alt");
if(NULL != tmp) {
alt = true;
}
tmp = strstr(descriptiveString, "meta");
if(NULL != tmp) {
meta = true;
}
UnicodeValue = descriptiveString[strlen(descriptiveString) -1];
// add with generic Adding function ...
return AddEventShortCut(shift, control, alt, meta, UnicodeValue, generateEventId);
}
bool ewol::WidgetShortCut::GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue)
{
bool ended = false;
//EWOL_WARNING("Input event : " << IdInput << " pos(" << x << "," << y << ")");
for(int32_t iii=m_inputShortCutEvent.Size()-1; iii>=0; iii--) {
if( m_inputShortCutEvent[iii].shift == shift
&& m_inputShortCutEvent[iii].control == control
&& m_inputShortCutEvent[iii].alt == alt
&& m_inputShortCutEvent[iii].meta == meta
&& m_inputShortCutEvent[iii].UnicodeValue == unicodeValue)
{
if (true == GenEventInputExternal(m_inputShortCutEvent[iii].generateEventId, -1, -1)) {
ended = true;
break;
}
}
}
return ended;
}

View File

@ -0,0 +1,58 @@
/**
*******************************************************************************
* @file ewol/widget/WidgetShortCut.h
* @brief basic ewol shortCut widget (header)
* @author Edouard DUPIN
* @date 19/02/2012
* @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.
*
*******************************************************************************
*/
#ifndef __EWOL_WIDGET_SHORT_CUT_H__
#define __EWOL_WIDGET_SHORT_CUT_H__
#include <ewol/Widget.h>
namespace ewol {
typedef struct {
const char * generateEventId; // event generate ID (to be unique it was pointer on the string name)
bool shift;
bool control;
bool alt;
bool meta;
uint32_t UnicodeValue;
} eventShortCut_ts;
class WidgetShortCut : virtual public ewol::Widget {
public:
WidgetShortCut(void);
virtual ~WidgetShortCut(void);
private:
etk::VectorType<eventShortCut_ts> m_inputShortCutEvent; //!< generic short-cut event
protected:
bool AddEventShortCut(bool shift, bool control, bool alt, bool pomme, uint32_t unicodeValue, const char * generateEventId);
bool AddEventShortCut(char * descriptiveString, const char * generateEventId);
public:
virtual bool GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue);
};
};
#endif