Request the moving element in the scrolling windows

This commit is contained in:
Edouard Dupin 2012-04-24 13:17:30 +02:00
parent 9d60aa1a55
commit affff567bf
2 changed files with 34 additions and 1 deletions

View File

@ -295,4 +295,36 @@ void ewol::WidgetScrooled::GenDraw(void)
ewol::Widget::GenDraw();
}
}
}
/**
* @brief Request a specific position for the scrolling of the current windows.
* @param[in] borderWidth Size of the border that requested the element might not to be
* @param[in] currentPosition Position that is requested to view
* @param[in] center True if the position might be at the center of the widget
* @return ---
*/
void ewol::WidgetScrooled::SetScrollingPositionDynamic(coord2D_ts borderWidth, coord2D_ts currentPosition, bool center)
{
if (true == center) {
borderWidth.x = m_size.x / 2 - borderWidth.x;
borderWidth.y = m_size.y / 2 - borderWidth.y;
}
// check scrooling in X
if( currentPosition.x < (m_originScrooled.x+borderWidth.x) ) {
m_originScrooled.x = currentPosition.x - borderWidth.x;
m_originScrooled.x = etk_max(0.0, m_originScrooled.x);
} else if( currentPosition.x > (m_originScrooled.x+m_size.x-2*borderWidth.x) ) {
m_originScrooled.x = currentPosition.x - m_size.x + 2*borderWidth.x;
m_originScrooled.x = etk_max(0.0, m_originScrooled.x);
}
// check scrooling in Y
if( currentPosition.y < (m_originScrooled.y+borderWidth.y) ) {
m_originScrooled.y = currentPosition.y - borderWidth.y;
m_originScrooled.y = etk_max(0.0, m_originScrooled.y);
} else if( currentPosition.y > (m_originScrooled.y+m_size.y-2*borderWidth.y) ) {
m_originScrooled.y = currentPosition.y - m_size.y + 2*borderWidth.y;
m_originScrooled.y = etk_max(0.0, m_originScrooled.y);
}
}

View File

@ -95,6 +95,7 @@ namespace ewol {
protected:
void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; };
void ScroolingMode(scrollingMode_te newMode) { m_scroollingMode = newMode; };
void SetScrollingPositionDynamic(coord2D_ts borderWidth, coord2D_ts currentPosition, bool center = false);
};
extern const char * const TYPE_EOBJECT_WIDGET_SCROOLED;