[DEV] correction of the scroll widget and add distance field load precompiled basic file
This commit is contained in:
parent
6be6a33789
commit
189665162e
2
external/airtaudio
vendored
2
external/airtaudio
vendored
@ -1 +1 @@
|
|||||||
Subproject commit a1f0b0f81c895b946a6db763d9845acdd2d05525
|
Subproject commit b30ff7808fe7205aa166dc4a856566a6ecfd9b85
|
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d431e72b0916391c011830a5db9d8f756c510405
|
Subproject commit a2e5f4e0cedf31ab2605b0980981bf1721c29a98
|
@ -151,7 +151,7 @@ void ewol::compositing::Image::setAngle(float _angle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::compositing::Image::print(const vec2& _size) {
|
void ewol::compositing::Image::print(const vec2& _size) {
|
||||||
printPart(_size, vec2(0,0), vec2(1,1));
|
printPart(_size, vec2(0,0), vec2(1.0,1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::compositing::Image::printPart(const vec2& _size,
|
void ewol::compositing::Image::printPart(const vec2& _size,
|
||||||
|
@ -52,6 +52,14 @@ ewol::Context& ewol::getContext(void) {
|
|||||||
return *l_curentInterface;
|
return *l_curentInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Context::setInitImage(const std::string& _fileName) {
|
||||||
|
//m_initDisplayImageName = _fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set the curent interface.
|
* @brief set the curent interface.
|
||||||
* @note this lock the main mutex
|
* @note this lock the main mutex
|
||||||
@ -154,7 +162,8 @@ void ewol::Context::processEvents(void) {
|
|||||||
case eSystemMessage::msgInit:
|
case eSystemMessage::msgInit:
|
||||||
// this is due to the openGL context
|
// this is due to the openGL context
|
||||||
/*bool returnVal = */
|
/*bool returnVal = */
|
||||||
APP_Init(*this);
|
APP_Init(*this, m_initStepId, m_initTotalStep);
|
||||||
|
m_initStepId++;
|
||||||
break;
|
break;
|
||||||
case eSystemMessage::msgRecalculateSize:
|
case eSystemMessage::msgRecalculateSize:
|
||||||
forceRedrawAll();
|
forceRedrawAll();
|
||||||
@ -288,7 +297,9 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
|
|||||||
m_FpsSystem( "Draw ", true),
|
m_FpsSystem( "Draw ", true),
|
||||||
m_FpsFlush( "Flush ", false),
|
m_FpsFlush( "Flush ", false),
|
||||||
m_windowsCurrent(NULL),
|
m_windowsCurrent(NULL),
|
||||||
m_windowsSize(320,480) {
|
m_windowsSize(320,480),
|
||||||
|
m_initStepId(0),
|
||||||
|
m_initTotalStep(1) {
|
||||||
m_commandLine.parse(_argc, _argv);
|
m_commandLine.parse(_argc, _argv);
|
||||||
EWOL_INFO(" == > Ewol system init (BEGIN)");
|
EWOL_INFO(" == > Ewol system init (BEGIN)");
|
||||||
// Reset the random system to be sure have real random values...
|
// Reset the random system to be sure have real random values...
|
||||||
@ -553,6 +564,15 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
|
|||||||
// set the curent interface :
|
// set the curent interface :
|
||||||
lockContext();
|
lockContext();
|
||||||
processEvents();
|
processEvents();
|
||||||
|
if (m_initStepId < m_initTotalStep) {
|
||||||
|
ewol::eSystemMessage *data = new ewol::eSystemMessage();
|
||||||
|
if (data == NULL) {
|
||||||
|
EWOL_ERROR("allocation error of message");
|
||||||
|
} else {
|
||||||
|
data->TypeMessage = eSystemMessage::msgInit;
|
||||||
|
m_msgSystem.post(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
// call all the widget that neded to do something periodicly
|
// call all the widget that neded to do something periodicly
|
||||||
//! ewol::widgetManager::periodicCall(currentTime);
|
//! ewol::widgetManager::periodicCall(currentTime);
|
||||||
m_widgetManager.periodicCall(currentTime);
|
m_widgetManager.periodicCall(currentTime);
|
||||||
|
@ -328,6 +328,15 @@ namespace ewol {
|
|||||||
* @return normal error int for the application error management
|
* @return normal error int for the application error management
|
||||||
*/
|
*/
|
||||||
static int main(int _argc, const char *_argv[]);
|
static int main(int _argc, const char *_argv[]);
|
||||||
|
private:
|
||||||
|
size_t m_initStepId;
|
||||||
|
size_t m_initTotalStep;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Special for init (main) set the start image when loading data
|
||||||
|
* @param[in] _fileName Name of the image to load
|
||||||
|
*/
|
||||||
|
void setInitImage(const std::string& _fileName);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief From everyware in the program, we can get the context inteface.
|
* @brief From everyware in the program, we can get the context inteface.
|
||||||
@ -337,8 +346,18 @@ namespace ewol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//!< must be define in CPP by the application ... this are the main init and unInit of the Application
|
//!< must be define in CPP by the application ... this are the main init and unInit of the Application
|
||||||
// return false if an error occured
|
/**
|
||||||
bool APP_Init(ewol::Context& _context);
|
* @brief main application function initialisation
|
||||||
|
* @param[in] _context curent context property
|
||||||
|
* @param[in] _initId current init step
|
||||||
|
* @param[out] _nbInitStep total number of step
|
||||||
|
* @return true, all OK
|
||||||
|
* @return false, an error occured
|
||||||
|
*/
|
||||||
|
bool APP_Init(ewol::Context& _context, size_t _initId, size_t& _nbInitStep);
|
||||||
|
/**
|
||||||
|
* @brief main application function un-initialisation
|
||||||
|
*/
|
||||||
void APP_UnInit(ewol::Context& _context);
|
void APP_UnInit(ewol::Context& _context);
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,5 +47,3 @@ std::string ewol::getVersion(void) {
|
|||||||
return EWOL_VERSION;
|
return EWOL_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <ewol/context/Context.h>
|
#include <ewol/context/Context.h>
|
||||||
#include <ewol/resource/DistanceFieldFont.h>
|
#include <ewol/resource/DistanceFieldFont.h>
|
||||||
#include <edtaa3/edtaa3func.h>
|
#include <edtaa3/edtaa3func.h>
|
||||||
|
#include <ejson/ejson.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "resource::DistanceFieldFont"
|
#define __class__ "resource::DistanceFieldFont"
|
||||||
@ -97,6 +98,12 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
|
|||||||
if (m_font == NULL) {
|
if (m_font == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (importFromFile() == true) {
|
||||||
|
EWOL_INFO("GET distance field from previous file");
|
||||||
|
flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_sizeRatio = ((float)SIZE_GENERATION) / ((float)m_font->getHeight(SIZE_GENERATION));
|
m_sizeRatio = ((float)SIZE_GENERATION) / ((float)m_font->getHeight(SIZE_GENERATION));
|
||||||
// TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ???
|
// TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ???
|
||||||
setImageSize(ivec2(256,32));
|
setImageSize(ivec2(256,32));
|
||||||
@ -110,6 +117,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
|
|||||||
addGlyph(iii);
|
addGlyph(iii);
|
||||||
}
|
}
|
||||||
flush();
|
flush();
|
||||||
|
//exportOnFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::resource::DistanceFieldFont::~DistanceFieldFont(void) {
|
ewol::resource::DistanceFieldFont::~DistanceFieldFont(void) {
|
||||||
@ -365,3 +373,81 @@ void ewol::resource::DistanceFieldFont::release(ewol::resource::DistanceFieldFon
|
|||||||
}
|
}
|
||||||
_object = NULL;
|
_object = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::resource::DistanceFieldFont::exportOnFile(void) {
|
||||||
|
EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
||||||
|
ejson::Document doc;
|
||||||
|
ejson::Array* tmpList = new ejson::Array();
|
||||||
|
if (tmpList == NULL) {
|
||||||
|
EWOL_ERROR("NULL pointer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (size_t iii=0; iii<m_listElement.size(); ++iii) {
|
||||||
|
ejson::Object* tmpObj = new ejson::Object();
|
||||||
|
if (tmpObj == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmpObj->addString("m_UVal", std::to_string(m_listElement[iii].m_UVal));
|
||||||
|
tmpObj->addNumber("m_glyphIndex", m_listElement[iii].m_glyphIndex);
|
||||||
|
tmpObj->addString("m_sizeTexture", (std::string)m_listElement[iii].m_sizeTexture);
|
||||||
|
tmpObj->addString("m_bearing", (std::string)m_listElement[iii].m_bearing);
|
||||||
|
tmpObj->addString("m_advance", (std::string)m_listElement[iii].m_advance);
|
||||||
|
tmpObj->addString("m_texturePosStart", (std::string)m_listElement[iii].m_texturePosStart);
|
||||||
|
tmpObj->addString("m_texturePosSize", (std::string)m_listElement[iii].m_texturePosSize);
|
||||||
|
tmpObj->addBoolean("m_exist", m_listElement[iii].m_exist);
|
||||||
|
tmpList->add(tmpObj);
|
||||||
|
}
|
||||||
|
doc.add("m_listElement", tmpList);
|
||||||
|
doc.addNumber("m_sizeRatio", m_sizeRatio);
|
||||||
|
doc.addString("m_lastGlyphPos", (std::string)m_lastGlyphPos);
|
||||||
|
doc.addNumber("m_lastRawHeigh", m_lastRawHeigh);
|
||||||
|
doc.addNumber("m_borderSize", m_borderSize);
|
||||||
|
doc.addString("m_textureBorderSize", (std::string)m_textureBorderSize);
|
||||||
|
doc.store(m_fileName + ".json");
|
||||||
|
egami::store(m_data, m_fileName + ".bmp");
|
||||||
|
egami::store(m_data, m_fileName + ".png");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ewol::resource::DistanceFieldFont::importFromFile(void) {
|
||||||
|
EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
||||||
|
// test file existance:
|
||||||
|
etk::FSNode fileJSON(m_fileName + ".json");
|
||||||
|
etk::FSNode fileBMP(m_fileName + ".bmp");
|
||||||
|
if ( fileJSON.exist() == false
|
||||||
|
|| fileBMP.exist() == false) {
|
||||||
|
EWOL_DEBUG("Does not import file for distance field system");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ejson::Document doc;
|
||||||
|
doc.load(m_fileName + ".json");
|
||||||
|
|
||||||
|
m_sizeRatio = doc.getNumberValue("m_sizeRatio", 0);
|
||||||
|
m_lastGlyphPos = doc.getStringValue("m_lastGlyphPos", "0,0");
|
||||||
|
m_lastRawHeigh = doc.getNumberValue("m_lastRawHeigh", 0);
|
||||||
|
m_borderSize = doc.getNumberValue("m_borderSize", 2);
|
||||||
|
m_textureBorderSize = doc.addString("m_textureBorderSize", "0,0");
|
||||||
|
ejson::Array* tmpList = doc.getArray("m_listElement");
|
||||||
|
if (tmpList == NULL) {
|
||||||
|
EWOL_ERROR("NULL pointer array");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_listElement.clear();
|
||||||
|
for (size_t iii=0; iii<tmpList->size(); ++iii) {
|
||||||
|
ejson::Object* tmpObj = tmpList->getObject(iii);
|
||||||
|
if (tmpObj == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
GlyphProperty prop;
|
||||||
|
prop.m_UVal = std::stoi(tmpObj->getStringValue("m_UVal", "0"));
|
||||||
|
prop.m_glyphIndex = tmpObj->getNumberValue("m_glyphIndex", 0);
|
||||||
|
prop.m_sizeTexture = tmpObj->getStringValue("m_sizeTexture", "0,0");
|
||||||
|
prop.m_bearing = tmpObj->getStringValue("m_bearing", "0,0");
|
||||||
|
prop.m_advance = tmpObj->getStringValue("m_advance", "0,0");
|
||||||
|
prop.m_texturePosStart = tmpObj->getStringValue("m_texturePosStart", "0,0");
|
||||||
|
prop.m_texturePosSize = tmpObj->getStringValue("m_texturePosSize", "0,0");
|
||||||
|
prop.m_exist = tmpObj->getBooleanValue("m_exist", false);
|
||||||
|
m_listElement.push_back(prop);
|
||||||
|
}
|
||||||
|
egami::load(m_data, m_fileName + ".bmp");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -95,6 +95,9 @@ namespace ewol {
|
|||||||
const vec2& getTextureBorderSize(void) {
|
const vec2& getTextureBorderSize(void) {
|
||||||
return m_textureBorderSize;
|
return m_textureBorderSize;
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
void exportOnFile(void);
|
||||||
|
bool importFromFile(void);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -337,7 +337,7 @@ ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::resource::TexturedFont* ewol::resource::TexturedFont::keep(const std::string& _filename) {
|
ewol::resource::TexturedFont* ewol::resource::TexturedFont::keep(const std::string& _filename) {
|
||||||
EWOL_VERBOSE("KEEP : TexturedFont : file : '" << _filename << "'");
|
EWOL_ERROR("KEEP : TexturedFont : file : '" << _filename << "'");
|
||||||
ewol::resource::TexturedFont* object = NULL;
|
ewol::resource::TexturedFont* object = NULL;
|
||||||
ewol::Resource* object2 = getManager().localKeep(_filename);
|
ewol::Resource* object2 = getManager().localKeep(_filename);
|
||||||
if (NULL != object2) {
|
if (NULL != object2) {
|
||||||
@ -351,7 +351,7 @@ ewol::resource::TexturedFont* ewol::resource::TexturedFont::keep(const std::stri
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
// need to crate a new one ...
|
// need to crate a new one ...
|
||||||
EWOL_DEBUG("CREATE: TexturedFont : file : '" << _filename << "'");
|
EWOL_ERROR("CREATE: TexturedFont : file : '" << _filename << "'");
|
||||||
object = new ewol::resource::TexturedFont(_filename);
|
object = new ewol::resource::TexturedFont(_filename);
|
||||||
if (NULL == object) {
|
if (NULL == object) {
|
||||||
EWOL_ERROR("allocation error of a resource : " << _filename);
|
EWOL_ERROR("allocation error of a resource : " << _filename);
|
||||||
@ -365,11 +365,12 @@ void ewol::resource::TexturedFont::release(ewol::resource::TexturedFont*& _objec
|
|||||||
if (NULL == _object) {
|
if (NULL == _object) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
EWOL_ERROR("RELEASE: TexturedFont : file : '" << _object->getName() << "' count=" << _object->getCounter());
|
||||||
std::string name = _object->getName();
|
std::string name = _object->getName();
|
||||||
int32_t count = _object->getCounter() - 1;
|
int32_t count = _object->getCounter() - 1;
|
||||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
|
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
|
||||||
if (getManager().release(object2) == true) {
|
if (getManager().release(object2) == true) {
|
||||||
EWOL_DEBUG("REMOVE: TexturedFont : file : '" << name << "' count=" << count);
|
EWOL_ERROR("REMOVE: TexturedFont : file : '" << name << "' count=" << count);
|
||||||
//etk::displayBacktrace(false);
|
//etk::displayBacktrace(false);
|
||||||
}
|
}
|
||||||
_object = NULL;
|
_object = NULL;
|
||||||
|
@ -53,7 +53,7 @@ namespace ewol {
|
|||||||
class GlyphProperty {
|
class GlyphProperty {
|
||||||
public:
|
public:
|
||||||
char32_t m_UVal; //!< Unicode value
|
char32_t m_UVal; //!< Unicode value
|
||||||
private:
|
public:
|
||||||
bool m_exist;
|
bool m_exist;
|
||||||
public:
|
public:
|
||||||
int32_t m_glyphIndex; //!< Glyph index in the system
|
int32_t m_glyphIndex; //!< Glyph index in the system
|
||||||
|
@ -159,6 +159,7 @@ void ewol::widget::Image::onRegenerateDisplay(void) {
|
|||||||
m_compositing.setPos(origin);
|
m_compositing.setPos(origin);
|
||||||
m_compositing.print(imageRealSize);
|
m_compositing.print(imageRealSize);
|
||||||
//EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin);
|
//EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin);
|
||||||
|
EWOL_DEBUG("Paint Image :" << m_fileName << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ namespace ewol {
|
|||||||
static const char* const configRemoveOnExternClick;
|
static const char* const configRemoveOnExternClick;
|
||||||
static const char* const configAnimation;
|
static const char* const configAnimation;
|
||||||
static const char* const configLockExpand;
|
static const char* const configLockExpand;
|
||||||
private:
|
protected:
|
||||||
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
|
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -99,18 +99,22 @@ bool ewol::widget::ProgressBar::onSetConfig(const ewol::object::Config& _conf) {
|
|||||||
}
|
}
|
||||||
if (_conf.getConfig() == configColorBg) {
|
if (_conf.getConfig() == configColorBg) {
|
||||||
m_textColorFg = _conf.getData();
|
m_textColorFg = _conf.getData();
|
||||||
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_conf.getConfig() == configColorFgOn) {
|
if (_conf.getConfig() == configColorFgOn) {
|
||||||
m_textColorBgOn = _conf.getData();
|
m_textColorBgOn = _conf.getData();
|
||||||
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_conf.getConfig() == configColorFgOff) {
|
if (_conf.getConfig() == configColorFgOff) {
|
||||||
m_textColorBgOff = _conf.getData();
|
m_textColorBgOff = _conf.getData();
|
||||||
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_conf.getConfig() == configValue) {
|
if (_conf.getConfig() == configValue) {
|
||||||
m_value = stof(_conf.getData());
|
m_value = stof(_conf.getData());
|
||||||
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -24,7 +24,9 @@ void ewol::widget::Scroll::init(ewol::widget::Manager& _widgetManager) {
|
|||||||
|
|
||||||
const char* const ewol::widget::Scroll::configLimit = "limit";
|
const char* const ewol::widget::Scroll::configLimit = "limit";
|
||||||
|
|
||||||
ewol::widget::Scroll::Scroll(void) :
|
ewol::widget::Scroll::Scroll(const std::string& _shaperName) :
|
||||||
|
m_shaperH(_shaperName),
|
||||||
|
m_shaperV(_shaperName),
|
||||||
m_limit(0.15,0.5),
|
m_limit(0.15,0.5),
|
||||||
m_pixelScrolling(20),
|
m_pixelScrolling(20),
|
||||||
m_highSpeedStartPos(0,0),
|
m_highSpeedStartPos(0,0),
|
||||||
@ -68,54 +70,56 @@ void ewol::widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Scroll::onDraw(void) {
|
void ewol::widget::Scroll::onDraw(void) {
|
||||||
m_draw.draw();
|
m_shaperH.draw();
|
||||||
|
m_shaperV.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::widget::Scroll::onRegenerateDisplay(void) {
|
void ewol::widget::Scroll::onRegenerateDisplay(void) {
|
||||||
// call upper class
|
// call upper class
|
||||||
ewol::widget::Container::onRegenerateDisplay();
|
ewol::widget::Container::onRegenerateDisplay();
|
||||||
if (true == needRedraw()) {
|
if (needRedraw() == false) {
|
||||||
// clear all previous display
|
return;
|
||||||
m_draw.clear();
|
}
|
||||||
|
// clear all previous display
|
||||||
m_draw.setColor(0xFF00007F);
|
m_shaperH.clear();
|
||||||
|
m_shaperV.clear();
|
||||||
vec2 scrollOffset(0,0);
|
ewol::Padding paddingVert = m_shaperV.getPadding();
|
||||||
vec2 scrollSize(0,0);
|
ewol::Padding paddingHori = m_shaperH.getPadding();
|
||||||
if (NULL!=m_subWidget) {
|
vec2 scrollOffset(0,0);
|
||||||
scrollOffset = m_subWidget->getOffset();
|
vec2 scrollSize(0,0);
|
||||||
scrollSize = m_subWidget->getSize();
|
if (NULL!=m_subWidget) {
|
||||||
}
|
scrollOffset = m_subWidget->getOffset();
|
||||||
m_draw.setThickness(1);
|
scrollSize = m_subWidget->getSize();
|
||||||
if( m_size.y() < scrollSize.y()
|
}
|
||||||
|| scrollOffset.y()!=0) {
|
if( m_size.y() < scrollSize.y()
|
||||||
//EWOL_DEBUG("plop : " << vec2(m_size.x()-(SCROLL_BAR_SPACE/2), 0) << " " << vec2(m_size.x()-(SCROLL_BAR_SPACE/2), m_size.y()));
|
|| scrollOffset.y()!=0) {
|
||||||
m_draw.setPos(vec2(m_size.x()-(SCROLL_BAR_SPACE/2), 0) );
|
float lenScrollBar = m_size.y()*m_size.y() / scrollSize.y();
|
||||||
m_draw.lineTo(vec2(m_size.x()-(SCROLL_BAR_SPACE/2), m_size.y()) );
|
lenScrollBar = etk_avg(10, lenScrollBar, m_size.y());
|
||||||
float lenScrollBar = m_size.y()*m_size.y() / scrollSize.y();
|
float originScrollBar = scrollOffset.y() / (scrollSize.y()-m_size.y()*m_limit.y());
|
||||||
lenScrollBar = etk_avg(10, lenScrollBar, m_size.y());
|
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||||
float originScrollBar = scrollOffset.y() / (scrollSize.y()-m_size.y()*m_limit.y());
|
originScrollBar *= (m_size.y()-lenScrollBar);
|
||||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
m_shaperV.setShape(vec2(m_size.x() - paddingVert.x(), 0),
|
||||||
originScrollBar *= (m_size.y()-lenScrollBar);
|
vec2(paddingVert.x(), m_size.y()),
|
||||||
m_draw.setPos(vec2(m_size.x()-SCROLL_BAR_SPACE, m_size.y() - originScrollBar - lenScrollBar) );
|
vec2(m_size.x() - paddingVert.xRight(), m_size.y() - originScrollBar - lenScrollBar),
|
||||||
m_draw.rectangleWidth(vec2(SCROLL_BAR_SPACE, lenScrollBar));
|
vec2(0, lenScrollBar));
|
||||||
}
|
}
|
||||||
if( m_size.x() < scrollSize.x()
|
if( m_size.x() < scrollSize.x()
|
||||||
|| scrollOffset.x()!=0) {
|
|| scrollOffset.x()!=0) {
|
||||||
m_draw.setPos(vec2(0, (SCROLL_BAR_SPACE/2)) );
|
float lenScrollBar = (m_size.x()-paddingHori.xLeft())*(m_size.x()-paddingVert.x()) / scrollSize.x();
|
||||||
m_draw.lineTo(vec2(m_size.x()-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2)) );
|
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-paddingVert.x()));
|
||||||
float lenScrollBar = m_size.x()*(m_size.x()-SCROLL_BAR_SPACE) / scrollSize.x();
|
float originScrollBar = scrollOffset.x() / (scrollSize.x()-m_size.x()*m_limit.x());
|
||||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-SCROLL_BAR_SPACE));
|
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||||
float originScrollBar = scrollOffset.x() / (scrollSize.x()-m_size.x()*m_limit.x());
|
originScrollBar *= (m_size.x()-paddingHori.xRight()-lenScrollBar);
|
||||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
m_shaperH.setShape(vec2(0, 0),
|
||||||
originScrollBar *= (m_size.x()-SCROLL_BAR_SPACE-lenScrollBar);
|
vec2(m_size.x()-paddingVert.x(), paddingHori.y()),
|
||||||
m_draw.setPos(vec2(originScrollBar, 0) );
|
vec2(originScrollBar, paddingHori.yButtom()),
|
||||||
m_draw.rectangle(vec2(lenScrollBar, SCROLL_BAR_SPACE) );
|
vec2(lenScrollBar, 0));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
||||||
|
//ewol::event::Input _event = event;
|
||||||
|
//_event.setType(ewol::key::typeFinger);
|
||||||
vec2 relativePos = relativePosition(_event.getPos());
|
vec2 relativePos = relativePosition(_event.getPos());
|
||||||
vec2 scrollOffset(0,0);
|
vec2 scrollOffset(0,0);
|
||||||
vec2 scrollSize(0,0);
|
vec2 scrollSize(0,0);
|
||||||
@ -123,6 +127,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
|||||||
scrollOffset = m_subWidget->getOffset();
|
scrollOffset = m_subWidget->getOffset();
|
||||||
scrollSize = m_subWidget->getSize();
|
scrollSize = m_subWidget->getSize();
|
||||||
}
|
}
|
||||||
|
EWOL_WARNING("Get Event on scroll : " << _event);
|
||||||
relativePos.setY(m_size.y() - relativePos.y());
|
relativePos.setY(m_size.y() - relativePos.y());
|
||||||
if( _event.getType() == ewol::key::typeMouse
|
if( _event.getType() == ewol::key::typeMouse
|
||||||
&& ( ewol::key::typeUnknow == m_highSpeedType
|
&& ( ewol::key::typeUnknow == m_highSpeedType
|
||||||
@ -282,12 +287,12 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
|||||||
&& ( ewol::key::typeUnknow == m_highSpeedType
|
&& ( ewol::key::typeUnknow == m_highSpeedType
|
||||||
|| ewol::key::typeFinger == m_highSpeedType ) ) {
|
|| ewol::key::typeFinger == m_highSpeedType ) ) {
|
||||||
if (1 == _event.getId()) {
|
if (1 == _event.getId()) {
|
||||||
//EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
|
EWOL_VERBOSE("event: " << _event);
|
||||||
if (ewol::key::statusDown == _event.getStatus()) {
|
if (ewol::key::statusDown == _event.getStatus()) {
|
||||||
m_highSpeedMode = speedModeInit;
|
m_highSpeedMode = speedModeInit;
|
||||||
m_highSpeedType = ewol::key::typeFinger;
|
m_highSpeedType = ewol::key::typeFinger;
|
||||||
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
||||||
EWOL_VERBOSE("SCROOL == > INIT");
|
EWOL_VERBOSE("SCROOL == > INIT pos=" << m_highSpeedStartPos << " && curent scrollOffset=" << scrollOffset);
|
||||||
return true;
|
return true;
|
||||||
} else if (ewol::key::statusUp == _event.getStatus()) {
|
} else if (ewol::key::statusUp == _event.getStatus()) {
|
||||||
m_highSpeedMode = speedModeDisable;
|
m_highSpeedMode = speedModeDisable;
|
||||||
@ -310,14 +315,23 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) {
|
|||||||
}
|
}
|
||||||
if ( m_highSpeedMode == speedModeEnableFinger
|
if ( m_highSpeedMode == speedModeEnableFinger
|
||||||
&& ewol::key::statusMove == _event.getStatus()) {
|
&& ewol::key::statusMove == _event.getStatus()) {
|
||||||
|
EWOL_VERBOSE("SCROOL == > INIT scrollOffset=" << scrollOffset.y() << " relativePos=" << relativePos.y() << " m_highSpeedStartPos=" << m_highSpeedStartPos.y());
|
||||||
//scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x);
|
//scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x);
|
||||||
scrollOffset.setX(scrollOffset.x() - relativePos.x() - m_highSpeedStartPos.x());
|
if (m_limit.x() != 0.0f) {
|
||||||
scrollOffset.setY(scrollOffset.y() - relativePos.y() - m_highSpeedStartPos.y());
|
scrollOffset.setX(scrollOffset.x() + (relativePos.x() - m_highSpeedStartPos.x()));
|
||||||
scrollOffset.setX(etk_avg(0, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit.x())));
|
scrollOffset.setX(etk_avg(0, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit.x())));
|
||||||
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
|
}
|
||||||
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
|
if (m_limit.y() != 0.0f) {
|
||||||
EWOL_VERBOSE("SCROOL == > MOVE (" << scrollOffset.x() << "," << scrollOffset.y() << ")");
|
scrollOffset.setY(scrollOffset.y() - (relativePos.y() - m_highSpeedStartPos.y()));
|
||||||
|
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
|
||||||
|
}
|
||||||
|
// update current position:
|
||||||
|
m_highSpeedStartPos = relativePos;
|
||||||
|
EWOL_VERBOSE("SCROOL == > MOVE " << scrollOffset);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
|
if (NULL!=m_subWidget) {
|
||||||
|
m_subWidget->setOffset(scrollOffset);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if ( m_highSpeedMode != speedModeDisable
|
} else if ( m_highSpeedMode != speedModeDisable
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/widget/Container.h>
|
#include <ewol/widget/Container.h>
|
||||||
#include <ewol/compositing/Compositing.h>
|
#include <ewol/compositing/Compositing.h>
|
||||||
#include <ewol/compositing/Drawing.h>
|
#include <ewol/compositing/Shaper.h>
|
||||||
#include <ewol/widget/Manager.h>
|
#include <ewol/widget/Manager.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
@ -37,7 +37,8 @@ namespace ewol {
|
|||||||
public:
|
public:
|
||||||
static void init(ewol::widget::Manager& _widgetManager);
|
static void init(ewol::widget::Manager& _widgetManager);
|
||||||
private:
|
private:
|
||||||
ewol::compositing::Drawing m_draw; // TODO : change in shaper ... == > better for annimation and dynamic display ...
|
ewol::compositing::Shaper m_shaperH; //!< Compositing theme Horizontal.
|
||||||
|
ewol::compositing::Shaper m_shaperV; //!< Compositing theme Vertical.
|
||||||
protected:
|
protected:
|
||||||
vec2 m_limit;
|
vec2 m_limit;
|
||||||
private:
|
private:
|
||||||
@ -47,7 +48,7 @@ namespace ewol {
|
|||||||
int32_t m_highSpeedButton;
|
int32_t m_highSpeedButton;
|
||||||
enum ewol::key::type m_highSpeedType;
|
enum ewol::key::type m_highSpeedType;
|
||||||
public:
|
public:
|
||||||
Scroll(void);
|
Scroll(const std::string& _shaperName="THEME:GUI:WidgetScrolled.json");
|
||||||
virtual ~Scroll(void);
|
virtual ~Scroll(void);
|
||||||
/**
|
/**
|
||||||
* @brief set the limit of scrolling
|
* @brief set the limit of scrolling
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
|
|
||||||
ewol::widget::WidgetScrolled::WidgetScrolled(const std::string& _shaperName) :
|
ewol::widget::WidgetScrolled::WidgetScrolled(const std::string& _shaperName) :
|
||||||
m_shaperH(_shaperName),
|
m_shaperH(_shaperName),
|
||||||
m_shaperV(_shaperName) {
|
m_shaperV(_shaperName) {
|
||||||
addObjectType("ewol::widget::WidgetScrolled");
|
addObjectType("ewol::widget::WidgetScrolled");
|
||||||
m_originScrooled.setValue(0,0);
|
m_originScrooled.setValue(0,0);
|
||||||
m_pixelScrolling = 20;
|
m_pixelScrolling = 20;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user