[DEV] better integration of shortcut

This commit is contained in:
Edouard DUPIN 2016-11-10 21:04:26 +01:00
parent 00a7134a89
commit c3a5f9ae64
6 changed files with 59 additions and 80 deletions

View File

@ -16,11 +16,6 @@ ewol::Compositing::Compositing() {
} }
ewol::Compositing::~Compositing() {
// nothing to do
}
void ewol::Compositing::resetMatrix() { void ewol::Compositing::resetMatrix() {
m_matrixApply.identity(); m_matrixApply.identity();
} }

View File

@ -21,7 +21,7 @@ namespace ewol {
/** /**
* @brief Generic destructor * @brief Generic destructor
*/ */
virtual ~Compositing(); virtual ~Compositing() = default;
/** /**
* @brief Virtal pure function that request the draw of all openGl elements * @brief Virtal pure function that request the draw of all openGl elements
*/ */

View File

@ -121,6 +121,11 @@ namespace ewol {
static size_t m_valUID; //!< Static used for the unique ID definition static size_t m_valUID; //!< Static used for the unique ID definition
private: private:
bool m_objectHasBeenInit; //!< Know if the init function has bben called bool m_objectHasBeenInit; //!< Know if the init function has bben called
public:
/**
* @brief Destructor
*/
virtual ~Object();
protected: protected:
/** /**
* @brief Constructor. * @brief Constructor.
@ -132,10 +137,6 @@ namespace ewol {
* @brief Factory * @brief Factory
*/ */
DECLARE_FACTORY(Object); DECLARE_FACTORY(Object);
/**
* @brief Destructor
*/
virtual ~Object();
bool objectHasBeenCorectlyInit(); bool objectHasBeenCorectlyInit();
protected: protected:
ewol::ObjectWeak m_parent; //!< Reference on the current parrent. ewol::ObjectWeak m_parent; //!< Reference on the current parrent.

View File

@ -28,7 +28,7 @@ namespace ewol {
void setLabel(std::string _newLabel); void setLabel(std::string _newLabel);
// drawing capabilities .... // drawing capabilities ....
private: private:
std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display... std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
std::vector<ivec2 > m_lineSize; std::vector<ivec2 > m_lineSize;
public: public:
void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1); void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1);

View File

@ -80,10 +80,6 @@ ewol::Widget::Widget() :
propertyAnnimationTypeStop.add(0, "none"); propertyAnnimationTypeStop.add(0, "none");
} }
ewol::Widget::~Widget() {
// clean all the short-cut ...
shortCutClean();
}
void ewol::Widget::onChangeSize() { void ewol::Widget::onChangeSize() {
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} update size : " << m_size); EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} update size : " << m_size);
@ -356,111 +352,100 @@ void ewol::Widget::shortCutAdd(const std::string& _descriptiveString, const std:
EWOL_ERROR("try to add shortcut with no descriptive string ..."); EWOL_ERROR("try to add shortcut with no descriptive string ...");
return; return;
} }
EventShortCut* tmpElement = new EventShortCut(); EventShortCut tmpElement;
if (nullptr == tmpElement) {
EWOL_ERROR("allocation error ... Memory error ...");
return;
}
if (_message.size() == 0) { if (_message.size() == 0) {
tmpElement->message = _descriptiveString; tmpElement.message = _descriptiveString;
} else { } else {
tmpElement->message = _message; tmpElement.message = _message;
} }
// parsing of the string : // parsing of the string :
//"ctrl+shift+alt+meta+s" //"ctrl+shift+alt+meta+s"
if(_descriptiveString.find("ctrl") != std::string::npos) { if(_descriptiveString.find("ctrl") != std::string::npos) {
tmpElement->specialKey.setCtrl(true); tmpElement.specialKey.setCtrl(true);
} }
if(_descriptiveString.find("shift") != std::string::npos) { if(_descriptiveString.find("shift") != std::string::npos) {
tmpElement->specialKey.setShift(true); tmpElement.specialKey.setShift(true);
} }
if(_descriptiveString.find("alt") != std::string::npos) { if(_descriptiveString.find("alt") != std::string::npos) {
tmpElement->specialKey.setAlt(true); tmpElement.specialKey.setAlt(true);
} }
if(_descriptiveString.find("meta") != std::string::npos) { if(_descriptiveString.find("meta") != std::string::npos) {
tmpElement->specialKey.setMeta(true); tmpElement.specialKey.setMeta(true);
} }
if(_descriptiveString.find("F12") != std::string::npos) { if(_descriptiveString.find("F12") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f12; tmpElement.keyboardMoveValue = gale::key::keyboard::f12;
} else if(_descriptiveString.find("F11") != std::string::npos) { } else if(_descriptiveString.find("F11") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f11; tmpElement.keyboardMoveValue = gale::key::keyboard::f11;
} else if(_descriptiveString.find("F10") != std::string::npos) { } else if(_descriptiveString.find("F10") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f10; tmpElement.keyboardMoveValue = gale::key::keyboard::f10;
} else if(_descriptiveString.find("F9") != std::string::npos) { } else if(_descriptiveString.find("F9") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f9; tmpElement.keyboardMoveValue = gale::key::keyboard::f9;
} else if(_descriptiveString.find("F8") != std::string::npos) { } else if(_descriptiveString.find("F8") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f8; tmpElement.keyboardMoveValue = gale::key::keyboard::f8;
} else if(_descriptiveString.find("F7") != std::string::npos) { } else if(_descriptiveString.find("F7") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f7; tmpElement.keyboardMoveValue = gale::key::keyboard::f7;
} else if(_descriptiveString.find("F6") != std::string::npos) { } else if(_descriptiveString.find("F6") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f6; tmpElement.keyboardMoveValue = gale::key::keyboard::f6;
} else if(_descriptiveString.find("F5") != std::string::npos) { } else if(_descriptiveString.find("F5") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f5; tmpElement.keyboardMoveValue = gale::key::keyboard::f5;
} else if(_descriptiveString.find("F4") != std::string::npos) { } else if(_descriptiveString.find("F4") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f4; tmpElement.keyboardMoveValue = gale::key::keyboard::f4;
} else if(_descriptiveString.find("F3") != std::string::npos) { } else if(_descriptiveString.find("F3") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f3; tmpElement.keyboardMoveValue = gale::key::keyboard::f3;
} else if(_descriptiveString.find("F2") != std::string::npos) { } else if(_descriptiveString.find("F2") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f2; tmpElement.keyboardMoveValue = gale::key::keyboard::f2;
} else if(_descriptiveString.find("F1") != std::string::npos) { } else if(_descriptiveString.find("F1") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::f1; tmpElement.keyboardMoveValue = gale::key::keyboard::f1;
} else if(_descriptiveString.find("LEFT") != std::string::npos) { } else if(_descriptiveString.find("LEFT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::left; tmpElement.keyboardMoveValue = gale::key::keyboard::left;
} else if(_descriptiveString.find("RIGHT") != std::string::npos) { } else if(_descriptiveString.find("RIGHT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::right; tmpElement.keyboardMoveValue = gale::key::keyboard::right;
} else if(_descriptiveString.find("UP") != std::string::npos) { } else if(_descriptiveString.find("UP") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::up; tmpElement.keyboardMoveValue = gale::key::keyboard::up;
} else if(_descriptiveString.find("DOWN") != std::string::npos) { } else if(_descriptiveString.find("DOWN") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::down; tmpElement.keyboardMoveValue = gale::key::keyboard::down;
} else if(_descriptiveString.find("PAGE_UP") != std::string::npos) { } else if(_descriptiveString.find("PAGE_UP") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::pageUp; tmpElement.keyboardMoveValue = gale::key::keyboard::pageUp;
} else if(_descriptiveString.find("PAGE_DOWN") != std::string::npos) { } else if(_descriptiveString.find("PAGE_DOWN") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::pageDown; tmpElement.keyboardMoveValue = gale::key::keyboard::pageDown;
} else if(_descriptiveString.find("START") != std::string::npos) { } else if(_descriptiveString.find("START") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::start; tmpElement.keyboardMoveValue = gale::key::keyboard::start;
} else if(_descriptiveString.find("END") != std::string::npos) { } else if(_descriptiveString.find("END") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::end; tmpElement.keyboardMoveValue = gale::key::keyboard::end;
} else if(_descriptiveString.find("PRINT") != std::string::npos) { } else if(_descriptiveString.find("PRINT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::print; tmpElement.keyboardMoveValue = gale::key::keyboard::print;
} else if(_descriptiveString.find("ARRET_DEFIL") != std::string::npos) { } else if(_descriptiveString.find("ARRET_DEFIL") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::stopDefil; tmpElement.keyboardMoveValue = gale::key::keyboard::stopDefil;
} else if(_descriptiveString.find("WAIT") != std::string::npos) { } else if(_descriptiveString.find("WAIT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::wait; tmpElement.keyboardMoveValue = gale::key::keyboard::wait;
} else if(_descriptiveString.find("INSERT") != std::string::npos) { } else if(_descriptiveString.find("INSERT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::insert; tmpElement.keyboardMoveValue = gale::key::keyboard::insert;
} else if(_descriptiveString.find("CAPLOCK") != std::string::npos) { } else if(_descriptiveString.find("CAPLOCK") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::capLock; tmpElement.keyboardMoveValue = gale::key::keyboard::capLock;
} else if(_descriptiveString.find("CONTEXT_MENU") != std::string::npos) { } else if(_descriptiveString.find("CONTEXT_MENU") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::contextMenu; tmpElement.keyboardMoveValue = gale::key::keyboard::contextMenu;
} else if(_descriptiveString.find("NUM_LOCK") != std::string::npos) { } else if(_descriptiveString.find("NUM_LOCK") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard::numLock; tmpElement.keyboardMoveValue = gale::key::keyboard::numLock;
} else { } else {
tmpElement->unicodeValue = _descriptiveString[_descriptiveString.size() -1]; tmpElement.unicodeValue = _descriptiveString[_descriptiveString.size() -1];
} }
// add it on the List ... // add it on the List ...
m_localShortcut.push_back(tmpElement); m_localShortcut.push_back(std::move(tmpElement));
} }
void ewol::Widget::shortCutRemove(const std::string& _message) { void ewol::Widget::shortCutRemove(const std::string& _message) {
auto it(m_localShortcut.begin()); auto it(m_localShortcut.begin());
while(it != m_localShortcut.end()) { while(it != m_localShortcut.end()) {
if ( *it != nullptr if (it->message != _message) {
&& (*it)->message != _message) {
++it; ++it;
continue; continue;
} }
delete(*it);
*it = nullptr;
m_localShortcut.erase(it); m_localShortcut.erase(it);
it = m_localShortcut.begin(); it = m_localShortcut.begin();
} }
} }
void ewol::Widget::shortCutClean() { void ewol::Widget::shortCutClean() {
for (auto &it : m_localShortcut) {
delete(it);
it = nullptr;
}
m_localShortcut.clear(); m_localShortcut.clear();
} }
@ -474,22 +459,20 @@ bool ewol::Widget::onEventShortCut(const gale::key::Special& _special,
} }
//EWOL_INFO("Try to find generic shortcut ..."); //EWOL_INFO("Try to find generic shortcut ...");
for (int32_t iii=m_localShortcut.size()-1; iii >= 0; iii--) { for (int32_t iii=m_localShortcut.size()-1; iii >= 0; iii--) {
if (m_localShortcut[iii] != nullptr) { if ( m_localShortcut[iii].specialKey.getShift() == _special.getShift()
if ( m_localShortcut[iii]->specialKey.getShift() == _special.getShift() && m_localShortcut[iii].specialKey.getCtrl() == _special.getCtrl()
&& m_localShortcut[iii]->specialKey.getCtrl() == _special.getCtrl() && m_localShortcut[iii].specialKey.getAlt() == _special.getAlt()
&& m_localShortcut[iii]->specialKey.getAlt() == _special.getAlt() && m_localShortcut[iii].specialKey.getMeta() == _special.getMeta()
&& m_localShortcut[iii]->specialKey.getMeta() == _special.getMeta() && ( ( m_localShortcut[iii].keyboardMoveValue == gale::key::keyboard::unknow
&& ( ( m_localShortcut[iii]->keyboardMoveValue == gale::key::keyboard::unknow && m_localShortcut[iii].unicodeValue == _unicodeValue)
&& m_localShortcut[iii]->unicodeValue == _unicodeValue) || ( m_localShortcut[iii].keyboardMoveValue == _kbMove
|| ( m_localShortcut[iii]->keyboardMoveValue == _kbMove && m_localShortcut[iii].unicodeValue == 0)
&& m_localShortcut[iii]->unicodeValue == 0) )
) ) {
) { if (_isDown) {
if (_isDown) { signalShortcut.emit(m_localShortcut[iii].message);
signalShortcut.emit(m_localShortcut[iii]->message);
}
return true;
} }
return true;
} }
} }
return false; return false;

View File

@ -91,7 +91,7 @@ namespace ewol {
/** /**
* @brief Destructor of the widget classes * @brief Destructor of the widget classes
*/ */
virtual ~Widget(); virtual ~Widget() = default;
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- Widget size: // -- Widget size:
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
@ -388,7 +388,7 @@ namespace ewol {
public: public:
esignal::Signal<std::string> signalShortcut; //!< signal handle of the message esignal::Signal<std::string> signalShortcut; //!< signal handle of the message
private: private:
std::vector<EventShortCut*> m_localShortcut; //!< list of all shortcut in the widget std::vector<EventShortCut> m_localShortcut; //!< list of all shortcut in the widget
protected: protected:
/** /**
* @brief add a specific shortcut with his description * @brief add a specific shortcut with his description