[DEV] basic think of annimation widget properties
This commit is contained in:
parent
d6a26db4a5
commit
e975c52b6e
@ -20,6 +20,8 @@ const char* const widget::PopUp::configRemoveOnExternClick="out-click-remove";
|
||||
const char* const widget::PopUp::configAnimation="animation";
|
||||
const char* const widget::PopUp::configLockExpand="lock";
|
||||
|
||||
static const char* annimationIncrease = "increase";
|
||||
|
||||
static ewol::Widget* create(void) {
|
||||
return new widget::PopUp();
|
||||
}
|
||||
@ -38,9 +40,11 @@ widget::PopUp::PopUp(const std::string& _shaperName) :
|
||||
registerConfig(configShaper, "string", NULL, "The shaper properties");
|
||||
registerConfig(configRemoveOnExternClick, "bool", NULL, "Remove the widget if the use click outside");
|
||||
registerConfig(configLockExpand, "bool", NULL, "Lock expand contamination");
|
||||
registerConfig(configAnimation, "list", "none;increase", "Remove the widget if the use click outside");
|
||||
registerConfig(configAnimation, "list", "none;increase", "Annimation type");
|
||||
|
||||
setAnimationMode(animationNone);
|
||||
// Add annimations :
|
||||
addAnnimationType(ewol::Widget::annimationModeEnableAdd, annimationIncrease);
|
||||
}
|
||||
|
||||
widget::PopUp::~PopUp(void) {
|
||||
|
@ -94,6 +94,16 @@ const char* const ewol::Widget::configMinSize = "min-size";
|
||||
const char* const ewol::Widget::configMaxSize = "max-size";
|
||||
const char* const ewol::Widget::configGravity = "gravity";
|
||||
|
||||
// configuration :
|
||||
const char* const ewol::Widget::configAnnimationAddType = "annimation-start-type";
|
||||
const char* const ewol::Widget::configAnnimationAddTime = "annimation-start-time";
|
||||
const char* const ewol::Widget::configAnnimationRemoveType = "annimation-remove-type";
|
||||
const char* const ewol::Widget::configAnnimationRemoveTime = "annimation-remove-time";
|
||||
// event generated :
|
||||
const char* const ewol::Widget::eventAnnimationStart = "annimation-start";
|
||||
const char* const ewol::Widget::eventAnnimationRatio = "annimation-ratio";
|
||||
const char* const ewol::Widget::eventAnnimationStop = "annimation-stop";
|
||||
|
||||
ewol::Widget::Widget(void) :
|
||||
m_up(NULL),
|
||||
m_size(10,10),
|
||||
@ -116,7 +126,13 @@ ewol::Widget::Widget(void) :
|
||||
m_periodicCallTime(0),
|
||||
m_needRegenerateDisplay(true),
|
||||
m_grabCursor(false),
|
||||
m_cursorDisplay(ewol::cursorArrow) {
|
||||
m_cursorDisplay(ewol::cursorArrow),
|
||||
m_annimationMode(annimationModeDisable),
|
||||
m_annimationratio(0.0f) {
|
||||
m_annimationType[0] = NULL;
|
||||
m_annimationType[1] = NULL;
|
||||
m_annimationTime[0] = 0.1f; // annimation will be 100ms at the first state
|
||||
m_annimationTime[1] = 0.1f; // annimation will be 100ms at the first state
|
||||
addObjectType("ewol::Widget");
|
||||
// set all the config in the list :
|
||||
registerConfig(ewol::Widget::configFill, "bvec2", NULL, "Fill the widget available size");
|
||||
@ -126,6 +142,13 @@ ewol::Widget::Widget(void) :
|
||||
registerConfig(ewol::Widget::configMinSize, "dimension", NULL, "User minimum size");
|
||||
registerConfig(ewol::Widget::configMaxSize, "dimension", NULL, "User maximum size");
|
||||
registerConfig(ewol::Widget::configGravity, "list", "center;top-left;top;top-right;right;buttom-right;buttom;buttom-left;left", "User maximum size");
|
||||
registerConfig(ewol::Widget::configAnnimationAddType, "list", NULL /* no control */, "Annimation type, when adding/show a widget");
|
||||
registerConfig(ewol::Widget::configAnnimationAddTime, "float", NULL /* no control */, "Annimation time in second, when adding/show a widget");
|
||||
registerConfig(ewol::Widget::configAnnimationRemoveType, "list", NULL /* no control */, "Annimation type, when removing/hide a widget");
|
||||
registerConfig(ewol::Widget::configAnnimationRemoveTime, "float", NULL /* no control */, "Annimation time in second, when removing/hide a widget");
|
||||
addEventId(eventAnnimationStart);
|
||||
addEventId(eventAnnimationRatio);
|
||||
addEventId(eventAnnimationStop);
|
||||
}
|
||||
|
||||
|
||||
@ -753,6 +776,22 @@ bool ewol::Widget::onSetConfig(const ewol::EConfig& _conf) {
|
||||
m_gravity = stringToGravity(_conf.getData());
|
||||
return true;
|
||||
}
|
||||
if (_conf.getConfig() == ewol::Widget::configAnnimationAddType) {
|
||||
setAnnimationType(ewol::Widget::annimationModeEnableAdd, _conf.getData());
|
||||
return true;
|
||||
}
|
||||
if (_conf.getConfig() == ewol::Widget::configAnnimationAddTime) {
|
||||
setAnnimationTime(ewol::Widget::annimationModeEnableAdd, std::stof(_conf.getData()));
|
||||
return true;
|
||||
}
|
||||
if (_conf.getConfig() == ewol::Widget::configAnnimationRemoveType) {
|
||||
setAnnimationType(ewol::Widget::annimationModeEnableRemove, _conf.getData());
|
||||
return true;
|
||||
}
|
||||
if (_conf.getConfig() == ewol::Widget::configAnnimationRemoveTime) {
|
||||
setAnnimationTime(ewol::Widget::annimationModeEnableRemove, std::stof(_conf.getData()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -789,6 +828,32 @@ bool ewol::Widget::onGetConfig(const char* _config, std::string& _result) const
|
||||
_result = gravityToString(m_gravity);
|
||||
return true;
|
||||
}
|
||||
if (_config == ewol::Widget::configAnnimationAddType) {
|
||||
const char* type = m_annimationType[ewol::Widget::annimationModeEnableAdd];
|
||||
if (type == NULL) {
|
||||
_result = "";
|
||||
} else {
|
||||
_result = type;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_config == ewol::Widget::configAnnimationAddTime) {
|
||||
_result = std::to_string(m_annimationType[ewol::Widget::annimationModeEnableAdd]);
|
||||
return true;
|
||||
}
|
||||
if (_config == ewol::Widget::configAnnimationRemoveType) {
|
||||
const char* type = m_annimationType[ewol::Widget::annimationModeEnableRemove];
|
||||
if (type == NULL) {
|
||||
_result = "";
|
||||
} else {
|
||||
_result = type;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_config == ewol::Widget::configAnnimationRemoveTime) {
|
||||
_result = std::to_string(m_annimationType[ewol::Widget::annimationModeEnableRemove]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -812,3 +877,55 @@ void ewol::Widget::hideKeyboard(void) {
|
||||
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 == 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 (compare_no_case(m_annimationList[_mode][iii], _type) == true) {
|
||||
m_annimationType[_mode] = m_annimationList[_mode][iii];
|
||||
return;
|
||||
}
|
||||
}
|
||||
EWOL_ERROR("Can not find annimation type='" << _type << "'");
|
||||
}
|
||||
|
||||
void ewol::Widget::setAnnimationTime(enum ewol::Widget::annimationMode _mode, float _time) {
|
||||
if (_mode == ewol::Widget::annimationModeDisable) {
|
||||
EWOL_CRITICAL("Not suported mode ==> only for internal properties");
|
||||
return;
|
||||
}
|
||||
m_annimationTime[_mode] = _time;
|
||||
if (m_annimationTime[_mode] > 36000.0f) {
|
||||
EWOL_WARNING("Are you kidding ? Your annimation time : " << m_annimationTime[_mode] << " s is greater than 10 hours");
|
||||
}
|
||||
}
|
||||
|
||||
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(void) {
|
||||
m_annimationMode = ewol::Widget::annimationModeDisable;
|
||||
onStopAnnimation();
|
||||
return true; // ???
|
||||
}
|
@ -696,7 +696,75 @@ namespace ewol {
|
||||
* @brief get the curent Windows
|
||||
*/
|
||||
ewol::Windows* getWindows(void);
|
||||
}; // end of the class Widget declaration
|
||||
/*
|
||||
* Annimation section :
|
||||
*/
|
||||
public:
|
||||
// configuration :
|
||||
static const char* const configAnnimationAddType;
|
||||
static const char* const configAnnimationAddTime;
|
||||
static const char* const configAnnimationRemoveType;
|
||||
static const char* const configAnnimationRemoveTime;
|
||||
// event generated :
|
||||
static const char* const eventAnnimationStart; //!< event when start annimation
|
||||
static const char* const eventAnnimationRatio; //!< event when % of annimation change (integer)
|
||||
static const char* const eventAnnimationStop; //!< event when stop annimation
|
||||
protected:
|
||||
enum annimationMode {
|
||||
annimationModeEnableAdd,
|
||||
annimationModeEnableRemove,
|
||||
annimationModeDisable
|
||||
};
|
||||
enum annimationMode m_annimationMode; //!< true when the annimation is started
|
||||
float m_annimationratio; //!< Ratio of the annimation [0..1]
|
||||
private:
|
||||
std::vector<const char*> m_annimationList[2]; //!< List of all annimation type ADD
|
||||
const char* m_annimationType[2]; //!< type of start annimation (default NULL ==> no annimation)
|
||||
float m_annimationTime[2]; //!< time to produce start annimation
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a annimation type capabilities of this widget.
|
||||
* @param[in] _mode Configuring mode.
|
||||
* @param[in] _type Type of the annimation.
|
||||
*/
|
||||
void addAnnimationType(enum annimationMode _mode, const char* _type);
|
||||
public:
|
||||
/**
|
||||
* @brief set a annimation type.
|
||||
* @param[in] _mode Configuring mode.
|
||||
* @param[in] _type type of the annimation
|
||||
*/
|
||||
void setAnnimationType(enum annimationMode _mode, const std::string& _type);
|
||||
/**
|
||||
* @brief set a annimation time to produce.
|
||||
* @param[in] _mode Configuring mode.
|
||||
* @param[in] _time Time in second of the annimation display
|
||||
*/
|
||||
void setAnnimationTime(enum annimationMode _mode, float _time);
|
||||
/**
|
||||
* @brief Start the annimation.
|
||||
* @param[in] _mode Configuring mode.
|
||||
* @return true if an annimation will be started, false ==> no annimation and no event
|
||||
*/
|
||||
bool startAnnimation(enum annimationMode _mode);
|
||||
/**
|
||||
* @brief Stop/Break the annimation.
|
||||
* @return true if an annimation will be stoped, false ==> no curent annimation and no event wil be generated
|
||||
*/
|
||||
bool stopAnnimation(void);
|
||||
protected:
|
||||
/**
|
||||
* @brief Event when start the annimation.
|
||||
* @param[in] _mode Configuring mode.
|
||||
* @return true need to add periodic call.
|
||||
*/
|
||||
virtual bool onStartAnnimation(enum annimationMode _mode) { return false; };
|
||||
/**
|
||||
* @brief Event when Stop the annimation.
|
||||
*/
|
||||
virtual void onStopAnnimation(void) { };
|
||||
|
||||
};
|
||||
|
||||
};// end of namespace
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user