ewol/ewol/widget/Widget.cpp

749 lines
25 KiB
C++

/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/widget/Widget.h>
#include <ewol/object/Manager.h>
#include <ewol/widget/Manager.h>
#include <ewol/ewol.h>
#include <gale/renderer/openGL/openGL.h>
#include <gale/renderer/openGL/openGL-include.h>
#include <ewol/context/Context.h>
#undef __class__
#define __class__ "DrawProperty"
std::ostream& ewol::operator <<(std::ostream& _os, const ewol::DrawProperty& _obj) {
_os << "{ windowsSize=" << _obj.m_windowsSize << " start=" << _obj.m_origin << " stop=" << (_obj.m_origin+_obj.m_size) << "}";
return _os;
}
void ewol::DrawProperty::limit(const vec2& _origin, const vec2& _size) {
m_size += m_origin;
m_origin.setMax(_origin);
m_size.setMin(_origin+_size);
m_size -= m_origin;
}
#undef __class__
#define __class__ "gravity"
std::string ewol::gravityToString(const enum ewol::gravity _obj) {
switch(_obj) {
case ewol::gravityCenter:
return "center";
case ewol::gravityTopLeft:
return "top-left";
case ewol::gravityTop:
return "top";
case ewol::gravityTopRight:
return "top-right";
case ewol::gravityRight:
return "right";
case ewol::gravityButtomRight:
return "buttom-right";
case ewol::gravityButtom:
return "buttom";
case ewol::gravityButtomLeft:
return "buttom-left";
case ewol::gravityLeft:
return "left";
}
return "unknow";
}
enum ewol::gravity ewol::stringToGravity(const std::string& _obj) {
if (_obj == "center") {
return ewol::gravityCenter;
} else if (_obj == "top-left") {
return ewol::gravityTopLeft;
} else if (_obj == "top") {
return ewol::gravityTop;
} else if (_obj == "top-right") {
return ewol::gravityTopRight;
} else if (_obj == "right") {
return ewol::gravityRight;
} else if (_obj == "buttom-right") {
return ewol::gravityButtomRight;
} else if (_obj == "buttom") {
return ewol::gravityButtom;
} else if (_obj == "buttom-left") {
return ewol::gravityButtomLeft;
} else if (_obj == "left") {
return ewol::gravityLeft;
}
return ewol::gravityCenter;
}
std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::gravity _obj) {
_os << ewol::gravityToString(_obj);
return _os;
}
#undef __class__
#define __class__ "Widget"
ewol::Widget::Widget() :
m_size(10,10),
m_minSize(0,0),
m_maxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)),
m_offset(0,0),
m_zoom(1.0f),
m_origin(0,0),
m_userMinSize(*this, "min-size", gale::Dimension(vec2(0,0),gale::Dimension::Pixel), "User minimum size"),
m_userMaxSize(*this, "max-size", gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel), "User maximum size"),
m_userExpand(*this, "expand", bvec2(false,false), "Request the widget Expand size wile space is available"),
m_userFill(*this, "fill", bvec2(true,true), "Fill the widget available size"),
m_hide(*this, "hide", false, "The widget start hided"),
m_gravity(*this, "gravity", ewol::gravityButtomLeft, "Gravity orientation"),
m_hasFocus(false),
m_canFocus(*this, "focus", false, "enable the widget to have the focus capacity"), // TODO : je pense que c'est une erreur, c'st surement un event to get the cocus ...
m_limitMouseEvent(3),
m_allowRepeateKeyboardEvent(true),
signalShortcut(*this, "shortcut"),
m_needRegenerateDisplay(true),
m_grabCursor(false),
m_cursorDisplay(gale::context::cursor_arrow),
signalAnnimationStart(*this, "annimation-start"),
signalAnnimationRatio(*this, "annimation-ratio"),
signalAnnimationStop(*this, "annimation-stop"),
m_annimationMode(annimationModeDisable),
m_annimationratio(0.0f),
m_annimationTypeStart(*this, "annimation-start-type", 0, "Annimation type, when adding/show a widget"),
m_annimationTimeStart(*this, "annimation-start-time", 0.1f, 0.0f, 200.0f, "Annimation time in second, when adding/show a widget"),
m_annimationTypeStop(*this, "annimation-stop-type", 0, "Annimation type, when removing/hide a widget"),
m_annimationTimeStop(*this, "annimation-stop-time", 0.1f, 0.0f, 200.0f, "Annimation time in second, when removing/hide a widget"){
addObjectType("ewol::Widget");
// TODO : Set a static interface for list ==> this methode create a multiple allocation
m_gravity.add(ewol::gravityCenter, "center");
m_gravity.add(ewol::gravityTopLeft, "top-left");
m_gravity.add(ewol::gravityTop, "top");
m_gravity.add(ewol::gravityTopRight, "top-right");
m_gravity.add(ewol::gravityRight, "right");
m_gravity.add(ewol::gravityButtomRight, "buttom-right");
m_gravity.add(ewol::gravityButtom, "buttom");
m_gravity.add(ewol::gravityButtomLeft, "buttom-left");
m_gravity.add(ewol::gravityLeft, "left");
m_annimationTypeStart.add(0, "none");
m_annimationTypeStop.add(0, "none");
}
void ewol::Widget::init() {
ewol::Object::init();
}
void ewol::Widget::init(const std::string& _name) {
ewol::Object::init(_name);
}
ewol::Widget::~Widget() {
// clean all the short-cut ...
shortCutClean();
}
void ewol::Widget::onChangeSize() {
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} update size : " << m_size);
markToRedraw();
}
bool ewol::Widget::setFocus() {
if (m_canFocus == true) {
if (m_hasFocus == false) {
m_hasFocus = true;
onGetFocus();
}
return true;
}
return false;
}
bool ewol::Widget::rmFocus() {
if (m_canFocus == true) {
if (m_hasFocus == true) {
m_hasFocus = false;
onLostFocus();
}
return true;
}
return false;
}
void ewol::Widget::keepFocus() {
getWidgetManager().focusKeep(std::dynamic_pointer_cast<ewol::Widget>(shared_from_this()));
}
void ewol::Widget::setOffset(const vec2& _newVal) {
if (m_offset != _newVal) {
m_offset = _newVal;
markToRedraw();
}
}
/*
/--> _displayProp.m_windowsSize
*------------------------------------------------------*
| |
| m_size |
| / |
| *-----------------------* |
| ' ' |
| ' _displayProp.m_size ' |
| Viewport ' / ' |
| o---------'---------o ' |
| | ' | ' |
| | ' | ' |
| | ' | ' |
| | ' | ' |
| | *-----------------------* |
| | / | |
| | m_offset | |
| | | |
| o-------------------o |
| / |
| _displayProp.m_origin |
| |
*------------------------------------------------------*
/
(0,0)
*/
void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){
// widget is hidden ...
return;
}
vec2 displayOrigin = m_origin + m_offset;
// check if the element is displayable in the windows :
if( _displayProp.m_windowsSize.x() < m_origin.x()
|| _displayProp.m_windowsSize.y() < m_origin.y() ) {
// out of the windows == > nothing to display ...
return;
}
ewol::DrawProperty tmpSize = _displayProp;
tmpSize.limit(m_origin, m_size);
if (tmpSize.m_size.x() <= 0 || tmpSize.m_size.y() <= 0) {
return;
}
glViewport( (int32_t)tmpSize.m_origin.x(),
(int32_t)tmpSize.m_origin.y(),
(int32_t)tmpSize.m_size.x(),
(int32_t)tmpSize.m_size.y());
// special case, when origin < display origin, we need to cut the display :
ivec2 downOffset = m_origin - tmpSize.m_origin;
downOffset.setMin(ivec2(0,0));
mat4 tmpTranslate = etk::matTranslate(vec3ClipInt32(vec3(-tmpSize.m_size.x()/2+m_offset.x() + downOffset.x(),
-tmpSize.m_size.y()/2+m_offset.y() + downOffset.y(),
-1.0f)));
mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0f));
mat4 tmpProjection = etk::matOrtho((int32_t)(-tmpSize.m_size.x())>>1,
(int32_t)( tmpSize.m_size.x())>>1,
(int32_t)(-tmpSize.m_size.y())>>1,
(int32_t)( tmpSize.m_size.y())>>1,
(int32_t)(-1),
(int32_t)( 1));
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
gale::openGL::push();
// set internal matrix system :
gale::openGL::setMatrix(tmpMat);
//int64_t ___startTime = ewol::getTime();
onDraw();
#ifdef old_PLOP
if( (_displayProp.m_origin.x() > m_origin.x())
|| (_displayProp.m_origin.x() + _displayProp.m_size.x() < m_size.x() + m_origin.x()) ) {
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
int32_t tmpOriginX = std::max(_displayProp.m_origin.x(), m_origin.x());
int32_t tmppp1 = _displayProp.m_origin.x() + _displayProp.m_size.x();
int32_t tmppp2 = m_origin.x() + m_size.x();
int32_t tmpclipX = std::min(tmppp1, tmppp2) - tmpOriginX;
int32_t tmpOriginY = std::max(_displayProp.m_origin.y(), m_origin.y());
tmppp1 = _displayProp.m_origin.y() + _displayProp.m_size.y();
tmppp2 = m_origin.y() + m_size.y();
//int32_t tmpclipY = std::min(tmppp1, tmppp2) - tmpOriginX;
glViewport( tmpOriginX,
tmpOriginY,
tmpclipX,
m_size.y());
mat4 tmpTranslate = etk::matTranslate(vec3((float)(-tmpclipX/2 - (tmpOriginX-m_origin.x())), (float)(-m_size.y()/2.0), -1.0f));
mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1));
mat4 tmpProjection = etk::matOrtho(-tmpclipX/2, tmpclipX/2, -m_size.y()/2, m_size.y()/2, -1, 1);
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system :
gale::openGL::setMatrix(tmpMat);
//int64_t ___startTime = ewol::getTime();
onDraw();
//float ___localTime = (float)(ewol::getTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget1 : " << ___localTime << "ms ");
} else {
EWOL_DEBUG("rasta..");
glViewport( m_origin.x(),
m_origin.y(),
m_size.x(),
m_size.y());
mat4 tmpTranslate = etk::matTranslate(vec3(-m_size.x()/2, -m_size.y()/2, -1.0f));
mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0f));
mat4 tmpProjection = etk::matOrtho(-m_size.x()/2, m_size.x()/2, -m_size.y()/2, m_size.y()/2, -1, 1);
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system :
gale::openGL::setMatrix(tmpMat);
//int64_t ___startTime = ewol::getTime();
onDraw();
//float ___localTime = (float)(ewol::getTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget2 : " << ___localTime << "ms ");
}
#endif
gale::openGL::pop();
return;
}
void ewol::Widget::periodicCallDisable() {
EWOL_VERBOSE("Perodic call disable " << getName());
getObjectManager().periodicCall.release(shared_from_this());
}
void ewol::Widget::periodicCallEnable() {
if (getObjectManager().periodicCall.isRegistered(shared_from_this()) == true) {
EWOL_VERBOSE("Perodic call enable " << getName() << " ==> rejected");
return;
} else {
EWOL_VERBOSE("Perodic call enable " << getName());
}
getObjectManager().periodicCall.bind(shared_from_this(), &ewol::Widget::periodicCall);
}
void ewol::Widget::markToRedraw() {
if (m_needRegenerateDisplay == true) {
return;
}
m_needRegenerateDisplay = true;
getWidgetManager().markDrawingIsNeeded();
}
void ewol::Widget::setZoom(float _newVal) {
if (m_zoom == _newVal) {
return;
}
m_zoom = std::avg(0.0000001f,_newVal,1000000.0f);
markToRedraw();
}
float ewol::Widget::getZoom() {
return m_zoom;
}
void ewol::Widget::setOrigin(const vec2& _pos) {
#if DEBUG_LEVEL > 2
if( m_origin.x() < -5000
|| m_origin.y() < -5000) {
EWOL_WARNING("[" << getId() << "] set origin < 5000 : " << m_origin);
}
#endif
m_origin = _pos;
}
vec2 ewol::Widget::getOrigin() {
return m_origin;
}
vec2 ewol::Widget::relativePosition(const vec2& _pos) {
return _pos - m_origin;
}
void ewol::Widget::calculateMinMaxSize() {
m_minSize = m_userMinSize->getPixel();
//EWOL_ERROR("[" << getId() << "] convert in min size : " << m_userMinSize << " out=" << m_minSize);
m_maxSize = m_userMaxSize->getPixel();
markToRedraw();
}
vec2 ewol::Widget::getCalculateMinSize() {
if (false == isHide()) {
return m_minSize;
}
return vec2(0,0);
}
vec2 ewol::Widget::getCalculateMaxSize() {
if (false == isHide()) {
return m_maxSize;
}
return vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE);
}
void ewol::Widget::setNoMinSize() {
m_userMinSize.set(gale::Dimension(vec2(0,0),gale::Dimension::Pixel));
}
void ewol::Widget::checkMinSize() {
vec2 pixelSize = m_userMinSize->getPixel();
m_minSize.setX(std::max(m_minSize.x(), pixelSize.x()));
m_minSize.setY(std::max(m_minSize.y(), pixelSize.y()));
}
void ewol::Widget::setNoMaxSize() {
m_userMaxSize.set(gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel));
}
void ewol::Widget::checkMaxSize() {
vec2 pixelSize = m_userMaxSize->getPixel();
m_maxSize.setX(std::min(m_maxSize.x(), pixelSize.x()));
m_maxSize.setY(std::min(m_maxSize.y(), pixelSize.y()));
}
vec2 ewol::Widget::getSize() {
if (false == isHide()) {
return m_size;
}
return vec2(0,0);
}
bvec2 ewol::Widget::canExpand() {
if (false == isHide()) {
return m_userExpand;
}
return bvec2(false,false);
}
const bvec2& ewol::Widget::canFill() {
return m_userFill;
}
// ----------------------------------------------------------------------------------------------------------------
// -- Shortcut : management of the shortcut
// ----------------------------------------------------------------------------------------------------------------
void ewol::Widget::shortCutAdd(const std::string& _descriptiveString, const std::string& _message) {
if (_descriptiveString.size() == 0) {
EWOL_ERROR("try to add shortcut with no descriptive string ...");
return;
}
EventShortCut* tmpElement = new EventShortCut();
if (nullptr == tmpElement) {
EWOL_ERROR("allocation error ... Memory error ...");
return;
}
if (_message.size() == 0) {
tmpElement->message = _descriptiveString;
} else {
tmpElement->message = _message;
}
// parsing of the string :
//"ctrl+shift+alt+meta+s"
if(_descriptiveString.find("ctrl") != std::string::npos) {
tmpElement->specialKey.setCtrl(true);
}
if(_descriptiveString.find("shift") != std::string::npos) {
tmpElement->specialKey.setShift(true);
}
if(_descriptiveString.find("alt") != std::string::npos) {
tmpElement->specialKey.setAlt(true);
}
if(_descriptiveString.find("meta") != std::string::npos) {
tmpElement->specialKey.setMeta(true);
}
if(_descriptiveString.find("F12") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f12;
} else if(_descriptiveString.find("F11") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f11;
} else if(_descriptiveString.find("F10") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f10;
} else if(_descriptiveString.find("F9") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f9;
} else if(_descriptiveString.find("F8") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f8;
} else if(_descriptiveString.find("F7") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f7;
} else if(_descriptiveString.find("F6") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f6;
} else if(_descriptiveString.find("F5") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f5;
} else if(_descriptiveString.find("F4") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f4;
} else if(_descriptiveString.find("F3") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f3;
} else if(_descriptiveString.find("F2") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f2;
} else if(_descriptiveString.find("F1") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_f1;
} else if(_descriptiveString.find("LEFT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_left;
} else if(_descriptiveString.find("RIGHT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_right;
} else if(_descriptiveString.find("UP") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_up;
} else if(_descriptiveString.find("DOWN") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_down;
} else if(_descriptiveString.find("PAGE_UP") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_pageUp;
} else if(_descriptiveString.find("PAGE_DOWN") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_pageDown;
} else if(_descriptiveString.find("START") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_start;
} else if(_descriptiveString.find("END") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_end;
} else if(_descriptiveString.find("PRINT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_print;
} else if(_descriptiveString.find("ARRET_DEFIL") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_stopDefil;
} else if(_descriptiveString.find("WAIT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_wait;
} else if(_descriptiveString.find("INSERT") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_insert;
} else if(_descriptiveString.find("CAPLOCK") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_capLock;
} else if(_descriptiveString.find("CONTEXT_MENU") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_contextMenu;
} else if(_descriptiveString.find("NUM_LOCK") != std::string::npos) {
tmpElement->keyboardMoveValue = gale::key::keyboard_numLock;
} else {
tmpElement->unicodeValue = _descriptiveString[_descriptiveString.size() -1];
}
// add it on the List ...
m_localShortcut.push_back(tmpElement);
}
void ewol::Widget::shortCutRemove(const std::string& _message) {
auto it(m_localShortcut.begin());
while(it != m_localShortcut.end()) {
if ( *it != nullptr
&& (*it)->message != _message) {
++it;
continue;
}
delete(*it);
*it = nullptr;
m_localShortcut.erase(it);
it = m_localShortcut.begin();
}
}
void ewol::Widget::shortCutClean() {
for (auto &it : m_localShortcut) {
delete(it);
it = nullptr;
}
m_localShortcut.clear();
}
bool ewol::Widget::onEventShortCut(const gale::key::Special& _special,
char32_t _unicodeValue,
enum gale::key::keyboard _kbMove,
bool _isDown) {
if ( _unicodeValue >= 'A'
&& _unicodeValue <= 'Z') {
_unicodeValue += 'a' - 'A';
}
//EWOL_INFO("Try to find generic shortcut ...");
for (int32_t iii=m_localShortcut.size()-1; iii >= 0; iii--) {
if (m_localShortcut[iii] != nullptr) {
if ( m_localShortcut[iii]->specialKey.getShift() == _special.getShift()
&& m_localShortcut[iii]->specialKey.getCtrl() == _special.getCtrl()
&& m_localShortcut[iii]->specialKey.getAlt() == _special.getAlt()
&& m_localShortcut[iii]->specialKey.getMeta() == _special.getMeta()
&& ( ( m_localShortcut[iii]->keyboardMoveValue == gale::key::keyboard_unknow
&& m_localShortcut[iii]->unicodeValue == _unicodeValue)
|| ( m_localShortcut[iii]->keyboardMoveValue == _kbMove
&& m_localShortcut[iii]->unicodeValue == 0)
)
) {
if (_isDown) {
signalShortcut.emit(m_localShortcut[iii]->message);
}
return true;
}
}
}
return false;
}
void ewol::Widget::grabCursor() {
if (m_grabCursor == false) {
getContext().inputEventGrabPointer(std::dynamic_pointer_cast<ewol::Widget>(shared_from_this()));
m_grabCursor = true;
}
}
void ewol::Widget::unGrabCursor() {
if (m_grabCursor == true) {
getContext().inputEventUnGrabPointer();
m_grabCursor = false;
}
}
bool ewol::Widget::getGrabStatus() {
return m_grabCursor;
}
void ewol::Widget::setCursor(enum gale::context::cursor _newCursor) {
EWOL_DEBUG("Change Cursor in " << _newCursor);
m_cursorDisplay = _newCursor;
getContext().setCursor(m_cursorDisplay);
}
enum gale::context::cursor ewol::Widget::getCursor() {
return m_cursorDisplay;
}
bool ewol::Widget::loadXML(const std::shared_ptr<const exml::Element>& _node) {
ewol::Object::loadXML(_node);
markToRedraw();
return true;
}
bool ewol::Widget::systemEventEntry(ewol::event::EntrySystem& _event) {
std::shared_ptr<ewol::Widget> up = std::dynamic_pointer_cast<ewol::Widget>(m_parent.lock());
if (up != nullptr) {
if (up->systemEventEntry(_event) == true) {
return true;
}
}
return onEventEntry(_event.m_event);
}
bool ewol::Widget::systemEventInput(ewol::event::InputSystem& _event) {
std::shared_ptr<ewol::Widget> up = std::dynamic_pointer_cast<ewol::Widget>(m_parent.lock());
if (up != nullptr) {
if (up->systemEventInput(_event) == true) {
return true;
}
}
return onEventInput(_event.m_event);
}
void ewol::Widget::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) {
ewol::Object::onParameterChangeValue(_paramPointer);
if (_paramPointer == m_canFocus) {
if (m_hasFocus == true) {
rmFocus();
}
} else if (_paramPointer == m_gravity) {
markToRedraw();
} else if (_paramPointer == m_hide) {
markToRedraw();
requestUpdateSize();
} else if (_paramPointer == m_userFill) {
markToRedraw();
requestUpdateSize();
} else if (_paramPointer == m_userExpand) {
requestUpdateSize();
markToRedraw();
} else if (_paramPointer == m_userMaxSize) {
vec2 pixelMin = m_userMinSize->getPixel();
vec2 pixelMax = m_userMaxSize->getPixel();
// check minimum & maximum compatibility :
bool error=false;
if (pixelMin.x()>pixelMax.x()) {
error=true;
}
if (pixelMin.y()>pixelMax.y()) {
error=true;
}
if (error == true) {
EWOL_ERROR("Can not set a 'min size' > 'max size' reset to maximum ...");
m_userMaxSize = gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel);
}
requestUpdateSize();
} else if (_paramPointer == m_userMinSize) {
vec2 pixelMin = m_userMinSize->getPixel();
vec2 pixelMax = m_userMaxSize->getPixel();
// check minimum & maximum compatibility :
bool error=false;
if (pixelMin.x()>pixelMax.x()) {
error=true;
}
if (pixelMin.y()>pixelMax.y()) {
error=true;
}
if (error == true) {
EWOL_ERROR("Can not set a 'min size' > 'max size' set nothing ...");
m_userMinSize = gale::Dimension(vec2(0,0),gale::Dimension::Pixel);
}
requestUpdateSize();
} else if (_paramPointer == m_annimationTypeStart) {
} else if (_paramPointer == m_annimationTimeStart) {
} else if (_paramPointer == m_annimationTypeStop) {
} else if (_paramPointer == m_annimationTimeStop) {
}
}
void ewol::Widget::requestUpdateSize() {
getContext().requestUpdateSize();
}
ewol::widget::Manager& ewol::Widget::getWidgetManager() {
return getContext().getWidgetManager();
}
std::shared_ptr<ewol::widget::Windows> ewol::Widget::getWindows() {
return getContext().getWindows();
}
void ewol::Widget::showKeyboard() {
getContext().keyboardShow();
}
void ewol::Widget::hideKeyboard() {
getContext().keyboardHide();
}
void ewol::Widget::addAnnimationType(enum ewol::Widget::annimationMode _mode, const char* _type) {
if (_mode == ewol::Widget::annimationModeDisable) {
EWOL_CRITICAL("Not suported mode ==> only for internal properties");
return;
}
/*
for (size_t iii = 0; iii < m_annimationList[_mode].size(); ++iii) {
if (m_annimationList[_mode][iii] == _type) {
return;
}
}
m_annimationList[_mode].push_back(_type);
*/
}
void ewol::Widget::setAnnimationType(enum ewol::Widget::annimationMode _mode, const std::string& _type) {
if (_mode == 0) {
m_annimationTypeStart.setString(_type);
} else {
m_annimationTypeStop.setString(_type);
}
}
void ewol::Widget::setAnnimationTime(enum ewol::Widget::annimationMode _mode, float _time) {
if (_mode == 0) {
m_annimationTimeStart.set(_time);
} else {
m_annimationTimeStop.set(_time);
}
}
bool ewol::Widget::startAnnimation(enum ewol::Widget::annimationMode _mode) {
if (_mode == ewol::Widget::annimationModeDisable) {
EWOL_CRITICAL("Not suported mode ==> only for internal properties");
return false;
}
m_annimationMode = _mode;
return onStartAnnimation(_mode);
}
bool ewol::Widget::stopAnnimation() {
m_annimationMode = ewol::Widget::annimationModeDisable;
onStopAnnimation();
return true; // ???
}