diff --git a/Sources/libewol/ewol/Widget.cpp b/Sources/libewol/ewol/Widget.cpp index 310937b0..d6f1c934 100644 --- a/Sources/libewol/ewol/Widget.cpp +++ b/Sources/libewol/ewol/Widget.cpp @@ -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 eqn4[4] = {-1.0, 0.0, 0.0, m_size.x-TEST_CLIPPING_SIZE}; // upper 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); diff --git a/Sources/libewol/ewol/widget/WidgetShortCut.cpp b/Sources/libewol/ewol/widget/WidgetShortCut.cpp new file mode 100644 index 00000000..bb4b1c28 --- /dev/null +++ b/Sources/libewol/ewol/widget/WidgetShortCut.cpp @@ -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::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; +} + diff --git a/Sources/libewol/ewol/widget/WidgetShortCut.h b/Sources/libewol/ewol/widget/WidgetShortCut.h new file mode 100644 index 00000000..1494aa7f --- /dev/null +++ b/Sources/libewol/ewol/widget/WidgetShortCut.h @@ -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 + + +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 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 +