[DEV] update some interface

This commit is contained in:
Edouard DUPIN 2015-09-02 21:11:02 +02:00
parent ad0018be8d
commit ea4515f63c
6 changed files with 84 additions and 23 deletions

View File

@ -257,7 +257,10 @@ bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) {
m_nextStatusRequested = -1;
}
}
float timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0;
float timeRelativity = 0.0f;
if (m_config != nullptr) {
timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0;
}
m_stateTransition += _event.getDeltaCall() / timeRelativity;
//m_stateTransition += _event.getDeltaCall();
m_stateTransition = std::avg(0.0f, m_stateTransition, 1.0f);
@ -471,10 +474,11 @@ void ewol::compositing::Shaper::setShape(const vec2& _origin, const vec2& _size,
EWOL_ERROR(" inside = " << inside);
*/
int32_t mode = 0;
bool displayOutside = false;
if (m_config != nullptr) {
mode = m_config->getNumber(m_confIdMode);
displayOutside = m_config->getBoolean(m_confIdDisplayOutside);
}
bool displayOutside = m_config->getBoolean(m_confIdDisplayOutside);
m_nbVertexToDisplay = 0;
if (displayOutside == true) {
addVertexLine(enveloppe.yTop(), border.yTop(),

View File

@ -106,33 +106,40 @@ void ewol::Context::onCreate(gale::Context& _context) {
#endif
*/
EWOL_INFO(" == > Ewol system init (END)");
if (m_application == nullptr) {
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl == nullptr) {
return;
}
m_application->onCreate(*this);
appl->onCreate(*this);
}
void ewol::Context::onStart(gale::Context& _context) {
if (m_application == nullptr) {
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl == nullptr) {
// TODO : Request exit of the application .... with error ...
return;
}
m_application->onStart(*this);
appl->onStart(*this);
}
void ewol::Context::onResume(gale::Context& _context) {
m_application->onResume(*this);
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl == nullptr) {
return;
}
appl->onResume(*this);
}
void ewol::Context::onRegenerateDisplay(gale::Context& _context) {
//EWOL_INFO("REGENERATE_DISPLAY");
// check if the user selected a windows
if (m_windowsCurrent == nullptr) {
std::shared_ptr<ewol::widget::Windows> window = m_windowsCurrent;
if (window == nullptr) {
EWOL_INFO("No windows ...");
return;
}
// Redraw all needed elements
m_windowsCurrent->onRegenerateDisplay();
window->onRegenerateDisplay();
if (m_widgetManager.isDrawingNeeded() == true) {
markDrawingIsNeeded();
}
@ -144,18 +151,27 @@ void ewol::Context::onDraw(gale::Context& _context) {
// clean internal data...
m_objectManager.cleanInternalRemoved();
// real draw...
if (m_windowsCurrent == nullptr) {
std::shared_ptr<ewol::widget::Windows> window = m_windowsCurrent;
if (window == nullptr) {
return;
}
m_windowsCurrent->sysDraw();
window->sysDraw();
}
void ewol::Context::onPause(gale::Context& _context) {
m_application->onPause(*this);
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl == nullptr) {
return;
}
appl->onPause(*this);
}
void ewol::Context::onStop(gale::Context& _context) {
m_application->onStop(*this);
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl == nullptr) {
return;
}
appl->onStop(*this);
}
void ewol::Context::onDestroy(gale::Context& _context) {
@ -164,9 +180,12 @@ void ewol::Context::onDestroy(gale::Context& _context) {
m_windowsCurrent.reset();
// clean all widget and sub widget with their resources:
m_objectManager.cleanInternalRemoved();
// call application to uninit
m_application->onDestroy(*this);
m_application.reset();
std::shared_ptr<ewol::context::Application> appl = m_application;
if (appl != nullptr) {
// call application to uninit
appl->onDestroy(*this);
m_application.reset();
}
// internal clean elements
m_objectManager.cleanInternalRemoved();
EWOL_INFO("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");

View File

@ -53,8 +53,12 @@ ewol::resource::Texture::~Texture() {
}
#include <egami/wrapperBMP.h>
void ewol::resource::Texture::updateContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
bool ewol::resource::Texture::updateContext() {
std11::unique_lock<std11::recursive_mutex> lock(m_mutex, std11::defer_lock);
if (lock.try_lock() == false) {
//Lock error ==> try later ...
return false;
}
if (false == m_loaded) {
// Request a new texture at openGl :
glGenTextures(1, &m_texId);
@ -85,6 +89,7 @@ void ewol::resource::Texture::updateContext() {
m_data.getTextureDataPointer() );
// now the data is loaded
m_loaded = true;
return true;
}
void ewol::resource::Texture::removeContext() {

View File

@ -42,7 +42,7 @@ namespace ewol {
};
// flush the data to send it at the openGl system
void flush();
void updateContext();
bool updateContext();
void removeContext();
void removeContextToLate();
const ivec2& getOpenGlSize() const {

View File

@ -26,7 +26,8 @@ ewol::widget::Image::Image() :
m_keepRatio(*this, "ratio", true, "Keep ratio of the image"),
m_posStart(*this, "part-start", vec2(0.0f, 0.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"),
m_posStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"),
m_distanceFieldMode(*this, "distance-field", false, "Distance field mode") {
m_distanceFieldMode(*this, "distance-field", false, "Distance field mode"),
m_smooth(*this, "smooth", true, "Smooth display of the image") {
addObjectType("ewol::widget::Image");
m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:Image.json");
if (m_colorProperty != nullptr) {
@ -65,7 +66,7 @@ void ewol::widget::Image::onRegenerateDisplay() {
vec2 imageBoder = m_border->getPixel();
vec2 origin = imageBoder;
imageBoder *= 2.0f;
vec2 imageRealSize = m_minSize - imageBoder;
vec2 imageRealSize = m_realllll - imageBoder;
vec2 imageRealSizeMax = m_size - imageBoder;
vec2 ratioSizeDisplayRequested = m_posStop.get() - m_posStart.get();
@ -101,7 +102,11 @@ void ewol::widget::Image::onRegenerateDisplay() {
}
// set the somposition properties :
m_compositing.setPos(origin);
if (m_smooth.get() == true) {
m_compositing.setPos(origin);
} else {
m_compositing.setPos(ivec2(origin));
}
m_compositing.printPart(imageRealSize, m_posStart, m_posStop);
//EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin);
EWOL_VERBOSE("Paint Image :" << m_fileName << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize);
@ -111,6 +116,7 @@ void ewol::widget::Image::onRegenerateDisplay() {
void ewol::widget::Image::calculateMinMaxSize() {
vec2 imageBoder = m_border->getPixel()*2.0f;
vec2 imageSize = m_imageSize->getPixel();
vec2 size = m_userMinSize->getPixel();
if (imageSize!=vec2(0,0)) {
m_minSize = imageBoder+imageSize;
m_maxSize = m_minSize;
@ -124,6 +130,9 @@ void ewol::widget::Image::calculateMinMaxSize() {
m_maxSize = imageBoder+m_userMaxSize->getPixel();
m_minSize.setMin(m_maxSize);
}
m_realllll = m_minSize;
m_minSize.setMax(size);
m_maxSize.setMax(m_minSize);
//EWOL_DEBUG("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << imageSizeReal);
markToRedraw();
}
@ -167,6 +176,10 @@ bool ewol::widget::Image::loadXML(const std::shared_ptr<const exml::Element>& _n
if (tmpAttributeValue.size() != 0) {
m_border = tmpAttributeValue;
}
tmpAttributeValue = _node->getAttribute("smooth");
if (tmpAttributeValue.size() != 0) {
m_smooth = etk::string_to_bool(tmpAttributeValue);
}
//EWOL_DEBUG("Load label:" << node->ToElement()->getText());
if (_node->size() != 0) {
setFile(_node->getText());
@ -195,5 +208,7 @@ void ewol::widget::Image::onParameterChangeValue(const ewol::parameter::Ref& _pa
requestUpdateSize();
} else if (_paramPointer == m_distanceFieldMode) {
markToRedraw();
} else if (_paramPointer == m_smooth) {
markToRedraw();
}
}

View File

@ -84,6 +84,7 @@ namespace ewol {
};
protected:
ewol::parameter::Value<gale::Dimension> m_imageSize; //!< border to add at the image.
vec2 m_realllll;
public:
/**
* @brief set tge Border size around the image
@ -142,7 +143,7 @@ namespace ewol {
vec2 getStopPos() const {
return m_posStop;
};
public:
protected:
ewol::parameter::Value<bool> m_distanceFieldMode; //!< to have a parameter
public:
/**
@ -159,6 +160,23 @@ namespace ewol {
bool getDistanceField() const {
return m_compositing.getDistanceFieldMode();
}
protected:
ewol::parameter::Value<bool> m_smooth; //!< display is done in the pixed approximation if false
public:
/**
* @brief Set smooth rendering mode
* @param[in] _value enable smooting of the display
*/
void setSmooth(bool _value) {
m_smooth.set(_value);
}
/**
* @brief Get smooth rendering mode
* @return Status of the smooting render mode.
*/
bool getSmooth() const {
return m_smooth;
}
protected: // Derived function
virtual void onDraw();
virtual void onParameterChangeValue(const ewol::parameter::Ref& _paramPointer);