[DEBUG] widget scrolling correction
This commit is contained in:
parent
03d797a133
commit
f5650f16f6
@ -34,44 +34,36 @@ widget::WidgetScrooled::~WidgetScrooled(void) {
|
||||
#define SCROLL_BAR_SPACE (15)
|
||||
|
||||
void widget::WidgetScrooled::onRegenerateDisplay(void) {
|
||||
clearOObjectList();
|
||||
m_drawing.clear();
|
||||
if (m_scroollingMode == scroolModeGame) {
|
||||
|
||||
} else {
|
||||
ewol::Drawing* tmpDraw = NULL;
|
||||
if(m_size.y() < m_maxSize.y() || m_size.x() < m_maxSize.x()) {
|
||||
tmpDraw = new ewol::Drawing();
|
||||
tmpDraw->setColor(0xFF00007F);
|
||||
}
|
||||
if (NULL == tmpDraw) {
|
||||
return;
|
||||
}
|
||||
tmpDraw->setThickness(1);
|
||||
m_drawing.setColor(0xFF00007F);
|
||||
m_drawing.setThickness(1);
|
||||
if( m_size.y() < m_maxSize.y()
|
||||
|| m_originScrooled.y()!=0) {
|
||||
tmpDraw->setPos(vec3(m_size.x()-(SCROLL_BAR_SPACE/2), 0, 0) );
|
||||
tmpDraw->lineTo(vec3(m_size.x()-(SCROLL_BAR_SPACE/2), m_size.y(), 0 ) );
|
||||
m_drawing.setPos(vec3(m_size.x()-(SCROLL_BAR_SPACE/2), 0, 0) );
|
||||
m_drawing.lineTo(vec3(m_size.x()-(SCROLL_BAR_SPACE/2), m_size.y(), 0 ) );
|
||||
float lenScrollBar = m_size.y()*m_size.y() / m_maxSize.y();
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, m_size.y());
|
||||
float originScrollBar = m_originScrooled.y() / (m_maxSize.y()-m_size.y()*m_limitScrolling);
|
||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||
originScrollBar *= (m_size.y()-lenScrollBar);
|
||||
tmpDraw->setPos(vec3(m_size.x()-SCROLL_BAR_SPACE, m_size.y() - originScrollBar - lenScrollBar, 0) );
|
||||
tmpDraw->rectangleWidth(vec3(SCROLL_BAR_SPACE, lenScrollBar, 0));
|
||||
m_drawing.setPos(vec3(m_size.x()-SCROLL_BAR_SPACE, m_size.y() - originScrollBar - lenScrollBar, 0) );
|
||||
m_drawing.rectangleWidth(vec3(SCROLL_BAR_SPACE, lenScrollBar, 0));
|
||||
}
|
||||
if( m_size.x() < m_maxSize.x()
|
||||
|| m_originScrooled.x()!=0) {
|
||||
tmpDraw->setPos(vec3(0, (SCROLL_BAR_SPACE/2), 0) );
|
||||
tmpDraw->lineTo(vec3(m_size.x()-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2), 0 ) );
|
||||
float lenScrollBar = m_size.x()*(m_size.x()-SCROLL_BAR_SPACE) / m_maxSize.x();
|
||||
m_drawing.setPos(vec3(0, (SCROLL_BAR_SPACE/2), 0) );
|
||||
m_drawing.lineTo(vec3(m_size.x()-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2), 0 ) );
|
||||
float lenScrollBar = (m_size.x()-SCROLL_BAR_SPACE)*(m_size.x()-SCROLL_BAR_SPACE) / m_maxSize.x();
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-SCROLL_BAR_SPACE));
|
||||
float originScrollBar = m_originScrooled.x() / (m_maxSize.x()-m_size.x()*m_limitScrolling);
|
||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||
originScrollBar *= (m_size.x()-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
tmpDraw->setPos(vec3(originScrollBar, 0, 0) );
|
||||
tmpDraw->rectangle(vec3(lenScrollBar, SCROLL_BAR_SPACE, 0) );
|
||||
m_drawing.setPos(vec3(originScrollBar, 0, 0) );
|
||||
m_drawing.rectangleWidth(vec3(lenScrollBar, SCROLL_BAR_SPACE, 0) );
|
||||
}
|
||||
addOObject(tmpDraw);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +117,9 @@ bool widget::WidgetScrooled::onEventInput(const ewol::EventInput& _event) {
|
||||
zoom = etk_avg(0.1, zoom, 5000);
|
||||
setZoom(zoom);
|
||||
} else */{
|
||||
if(m_size.y() < m_maxSize.y()) {
|
||||
if(m_size.y() < m_maxSize.y()
|
||||
|| m_originScrooled.y() != 0
|
||||
|| m_size.y()*m_limitScrolling < m_maxSize.y() ) {
|
||||
m_originScrooled.setY(m_originScrooled.y()-m_pixelScrolling);
|
||||
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
|
||||
markToRedraw();
|
||||
@ -140,7 +134,9 @@ bool widget::WidgetScrooled::onEventInput(const ewol::EventInput& _event) {
|
||||
zoom = etk_avg(0.1, zoom, 5000);
|
||||
setZoom(zoom);
|
||||
} else */{
|
||||
if(m_size.y() < m_maxSize.y()) {
|
||||
if(m_size.y() < m_maxSize.y()
|
||||
|| m_originScrooled.y()!=0
|
||||
|| m_size.y()*m_limitScrolling < m_maxSize.y() ) {
|
||||
m_originScrooled.setY(m_originScrooled.y()+m_pixelScrolling);
|
||||
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
|
||||
markToRedraw();
|
||||
@ -150,7 +146,9 @@ bool widget::WidgetScrooled::onEventInput(const ewol::EventInput& _event) {
|
||||
} else if ( _event.getId() == 11
|
||||
&& _event.getStatus() == ewol::keyEvent::statusUp) {
|
||||
// Scrool Left
|
||||
if(m_size.x() < m_maxSize.x()) {
|
||||
if(m_size.x() < m_maxSize.x()
|
||||
|| m_originScrooled.x()!=0
|
||||
|| m_size.x()*m_limitScrolling < m_maxSize.x() ) {
|
||||
m_originScrooled.setX(m_originScrooled.x()-m_pixelScrolling);
|
||||
m_originScrooled.setX(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
|
||||
markToRedraw();
|
||||
@ -159,7 +157,9 @@ bool widget::WidgetScrooled::onEventInput(const ewol::EventInput& _event) {
|
||||
} else if ( _event.getId() == 10
|
||||
&& _event.getStatus() == ewol::keyEvent::statusUp) {
|
||||
// Scrool Right
|
||||
if(m_size.x() < m_maxSize.x()) {
|
||||
if(m_size.x() < m_maxSize.x()
|
||||
|| m_originScrooled.x()!=0
|
||||
|| m_size.x()*m_limitScrolling < m_maxSize.x() ) {
|
||||
m_originScrooled.setX(m_originScrooled.x()+m_pixelScrolling);
|
||||
m_originScrooled.setX(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
|
||||
markToRedraw();
|
||||
@ -339,32 +339,9 @@ bool widget::WidgetScrooled::onEventInput(const ewol::EventInput& _event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void widget::WidgetScrooled::addOObject(ewol::Compositing* _newObject, int32_t _pos) {
|
||||
if (NULL == _newObject) {
|
||||
EWOL_ERROR("Try to add an empty object in the Widget generic display system");
|
||||
return;
|
||||
}
|
||||
if (_pos < 0 || _pos >= m_listOObject.size() ) {
|
||||
m_listOObject.push_back(_newObject);
|
||||
} else {
|
||||
m_listOObject.insert(m_listOObject.begin()+_pos, _newObject);
|
||||
}
|
||||
}
|
||||
|
||||
void widget::WidgetScrooled::clearOObjectList(void) {
|
||||
for (int32_t iii=0; iii<m_listOObject.size(); iii++) {
|
||||
delete(m_listOObject[iii]);
|
||||
m_listOObject[iii] = NULL;
|
||||
}
|
||||
m_listOObject.clear();
|
||||
}
|
||||
|
||||
void widget::WidgetScrooled::onDraw(void) {
|
||||
for (int32_t iii=0; iii<m_listOObject.size(); iii++) {
|
||||
if (NULL != m_listOObject[iii]) {
|
||||
m_listOObject[iii]->draw();
|
||||
}
|
||||
}
|
||||
m_drawing.draw();
|
||||
}
|
||||
|
||||
void widget::WidgetScrooled::systemDraw(const ewol::DrawProperty& _displayProp) {
|
||||
@ -403,7 +380,7 @@ void widget::WidgetScrooled::systemDraw(const ewol::DrawProperty& _displayProp)
|
||||
ewol::openGL::pop();
|
||||
}
|
||||
|
||||
void widget::WidgetScrooled::setScrollingPositionDynamic(vec2 _borderWidth, vec2 _currentPosition, bool _center) {
|
||||
void widget::WidgetScrooled::setScrollingPositionDynamic(vec2 _borderWidth, const vec2& _currentPosition, bool _center) {
|
||||
if (true == _center) {
|
||||
_borderWidth.setValue(m_size.x() / 2 - _borderWidth.x(),
|
||||
m_size.y() / 2 - _borderWidth.y() );
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/widget/Scroll.h>
|
||||
#include <ewol/compositing/Compositing.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
|
||||
namespace widget {
|
||||
/**
|
||||
@ -27,13 +27,11 @@ namespace widget {
|
||||
scroolModeGame, //!< Zoom enable, no move left and right
|
||||
};
|
||||
private:
|
||||
std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
|
||||
void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
|
||||
void clearOObjectList(void);
|
||||
ewol::Drawing m_drawing; //!< generic element to display...
|
||||
protected:
|
||||
vec2 m_originScrooled;
|
||||
vec2 m_maxSize;
|
||||
float m_limitScrolling;
|
||||
vec2 m_originScrooled; //!< pixel distance from the origin of the display (Bottum left)
|
||||
vec2 m_maxSize; //!< Maximum size of the Widget ==> to display scrollbar
|
||||
float m_limitScrolling; //!< Mimit scrolling represent the propertion of the minimel scrolling activate (0.2 ==> 20% migt all time be visible)
|
||||
private:
|
||||
enum scrollingMode m_scroollingMode; //!< mode of management of the scrooling
|
||||
float m_pixelScrolling;
|
||||
@ -42,7 +40,13 @@ namespace widget {
|
||||
int32_t m_highSpeedButton;
|
||||
enum ewol::keyEvent::type m_highSpeedType;
|
||||
public:
|
||||
/**
|
||||
* @brief Scroll Widget main constructor to be herited from an other widget (this is not a stand-alone widget)
|
||||
*/
|
||||
WidgetScrooled(void);
|
||||
/**
|
||||
* @brief Scroll widget destructor.
|
||||
*/
|
||||
virtual ~WidgetScrooled(void);
|
||||
protected: // Derived function
|
||||
virtual void onDraw(void);
|
||||
@ -67,7 +71,7 @@ namespace widget {
|
||||
* @brief set the specific mawimum size of the widget
|
||||
* @param[in] _localSize new Maximum size
|
||||
*/
|
||||
void setMaxSize(vec2 _localSize) {
|
||||
void setMaxSize(const vec2& _localSize) {
|
||||
m_maxSize = _localSize;
|
||||
};
|
||||
/**
|
||||
@ -76,13 +80,13 @@ namespace widget {
|
||||
* @param[in] _currentPosition Position that is requested to view
|
||||
* @param[in] _center True if the position might be at the center of the widget
|
||||
*/
|
||||
void setScrollingPositionDynamic(vec2 _borderWidth, vec2 _currentPosition, bool _center = false);
|
||||
void setScrollingPositionDynamic(vec2 _borderWidth, const vec2& _currentPosition, bool _center = false);
|
||||
/**
|
||||
* @brief set the scrolling limit when arriving at he end of the widget
|
||||
* @param[in] _poucentageLimit pourcent of the limit of view nothing in the widget when arriving at the end ...
|
||||
*/
|
||||
void setLimitScrolling(float _poucentageLimit) {
|
||||
m_limitScrolling = etk_avg(0.1, _poucentageLimit,0.9);
|
||||
m_limitScrolling = etk_avg(0.1f, _poucentageLimit,0.9f);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user