Corection of some bug due to the inversion ==> just patch, some code might be rewrited
This commit is contained in:
parent
a97df32a66
commit
771ab20f62
@ -200,7 +200,7 @@ void ewol::List::OnRegenerateDisplay(void)
|
||||
startRaw = 0;
|
||||
}
|
||||
// Calculate the real position ...
|
||||
tmpOriginY = -m_originScrooled.y + startRaw*(minHeight + 2*m_paddingSizeY);
|
||||
tmpOriginY = -m_originScrooled.y + (startRaw+1)*(minHeight + 2*m_paddingSizeY);
|
||||
|
||||
// We display only compleate lines ...
|
||||
//EWOL_DEBUG("Request drawing list : " << startRaw << "-->" << (startRaw+displayableRaw) << " in " << nbRaw << "raws ; start display : " << m_originScrooled.y << " ==> " << tmpOriginY << " line size=" << minHeight + 2*m_paddingSizeY );
|
||||
@ -217,13 +217,13 @@ void ewol::List::OnRegenerateDisplay(void)
|
||||
color_ts bg;
|
||||
GetElement(0, iii, myTextToWrite, fg, bg);
|
||||
BGOObjects->SetColor(bg);
|
||||
BGOObjects->Rectangle(0, tmpOriginY, m_size.x, minHeight+2*m_paddingSizeY);
|
||||
BGOObjects->Rectangle(0, m_size.y - tmpOriginY, m_size.x, minHeight+2*m_paddingSizeY);
|
||||
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg);
|
||||
|
||||
Vector2D<float> textPos;
|
||||
textPos.x = tmpOriginX;
|
||||
textPos.y = tmpOriginY + m_paddingSizeY;
|
||||
textPos.y = m_size.y - tmpOriginY + m_paddingSizeY;
|
||||
tmpText->Text(textPos, drawClipping, myTextToWrite);
|
||||
|
||||
AddOObject(tmpText);
|
||||
@ -249,6 +249,9 @@ void ewol::List::OnRegenerateDisplay(void)
|
||||
bool ewol::List::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, Vector2D<float> pos)
|
||||
{
|
||||
Vector2D<float> relativePos = RelativePosition(pos);
|
||||
// corection for the openGl abstraction
|
||||
relativePos.y = m_size.y - relativePos.y;
|
||||
|
||||
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
// nothing to do ... done on upper widet ...
|
||||
|
@ -41,6 +41,7 @@ ewol::WidgetScrooled::WidgetScrooled(void)
|
||||
m_highSpeedType = ewol::INPUT_TYPE_UNKNOW;
|
||||
m_zoom = 1.0;
|
||||
m_highSpeedButton = -1;
|
||||
m_limitScrolling = 0.5;
|
||||
}
|
||||
|
||||
ewol::WidgetScrooled::~WidgetScrooled(void)
|
||||
@ -98,25 +99,23 @@ void ewol::WidgetScrooled::OnRegenerateDisplay(void)
|
||||
}
|
||||
if(m_size.y < m_maxSize.y) {
|
||||
//myOObjectsColored->Line(m_size.x-SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, m_size.x-SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
myOObjectsColored->Line(m_size.x-(SCROLL_BAR_SPACE/2), SCROLL_BAR_SPACE, m_size.x-(SCROLL_BAR_SPACE/2), m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
float lenScrollBar = m_size.y*(m_size.y-SCROLL_BAR_SPACE*2) / m_maxSize.y;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.y-SCROLL_BAR_SPACE*2));
|
||||
float originScrollBar = m_originScrooled.y / m_maxSize.y;
|
||||
myOObjectsColored->Line(m_size.x-(SCROLL_BAR_SPACE/2), SCROLL_BAR_SPACE, m_size.x-(SCROLL_BAR_SPACE/2), m_size.y, 1);
|
||||
float lenScrollBar = m_size.y*(m_size.y-SCROLL_BAR_SPACE) / m_maxSize.y;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.y-SCROLL_BAR_SPACE));
|
||||
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-SCROLL_BAR_SPACE*2-lenScrollBar);
|
||||
originScrollBar += 15;
|
||||
myOObjectsColored->Rectangle(m_size.x-SCROLL_BAR_SPACE, originScrollBar, SCROLL_BAR_SPACE, lenScrollBar);
|
||||
originScrollBar *= (m_size.y-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
myOObjectsColored->Rectangle(m_size.x-SCROLL_BAR_SPACE, m_size.y - originScrollBar - lenScrollBar, SCROLL_BAR_SPACE, lenScrollBar);
|
||||
}
|
||||
if(m_size.x < m_maxSize.x) {
|
||||
//myOObjectsColored->Line(SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, m_size.x-SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
myOObjectsColored->Line(SCROLL_BAR_SPACE, m_size.y-(SCROLL_BAR_SPACE/2), m_size.x-SCROLL_BAR_SPACE, m_size.y-(SCROLL_BAR_SPACE/2), 1);
|
||||
float lenScrollBar = m_size.x*(m_size.x-SCROLL_BAR_SPACE*2) / m_maxSize.x;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x-SCROLL_BAR_SPACE*2));
|
||||
float originScrollBar = m_originScrooled.x / m_maxSize.x;
|
||||
myOObjectsColored->Line(0, (SCROLL_BAR_SPACE/2), m_size.x-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2), 1);
|
||||
float lenScrollBar = m_size.x*(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*2-lenScrollBar);
|
||||
originScrollBar += 15;
|
||||
myOObjectsColored->Rectangle(originScrollBar, m_size.y-SCROLL_BAR_SPACE, lenScrollBar, SCROLL_BAR_SPACE);
|
||||
originScrollBar *= (m_size.x-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
myOObjectsColored->Rectangle(originScrollBar, 0, lenScrollBar, SCROLL_BAR_SPACE);
|
||||
}
|
||||
if (NULL!=myOObjectsColored) {
|
||||
AddOObject(myOObjectsColored);
|
||||
@ -136,6 +135,8 @@ void ewol::WidgetScrooled::OnRegenerateDisplay(void)
|
||||
bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::eventInputType_te typeEvent, Vector2D<float> pos)
|
||||
{
|
||||
Vector2D<float> relativePos = RelativePosition(pos);
|
||||
// corection due to the open Gl invertion ...
|
||||
relativePos.y = m_size.y - relativePos.y;
|
||||
if (SCROLL_MODE_NORMAL == m_scroollingMode) {
|
||||
if (ewol::INPUT_TYPE_MOUSE==type && ( ewol::INPUT_TYPE_UNKNOW==m_highSpeedType || ewol::INPUT_TYPE_MOUSE==m_highSpeedType )) {
|
||||
if (1 == IdInput && ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
||||
@ -149,7 +150,7 @@ bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput
|
||||
m_highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
m_originScrooled.y = (int32_t)(m_maxSize.y * (relativePos.y-SCROLL_BAR_SPACE) / (m_size.y-SCROLL_BAR_SPACE*2));
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y);
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
@ -162,22 +163,26 @@ bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput
|
||||
m_highSpeedButton = 1;
|
||||
// force direct scrolling in this case
|
||||
m_originScrooled.x = (int32_t)(m_maxSize.x * (relativePos.x-SCROLL_BAR_SPACE) / (m_size.x-SCROLL_BAR_SPACE*2));
|
||||
m_originScrooled.x = etk_avg(0, m_originScrooled.x, m_maxSize.x);
|
||||
m_originScrooled.x = etk_avg(0, m_originScrooled.x, (m_maxSize.x - m_size.x*m_limitScrolling));
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||
m_originScrooled.y -= m_pixelScrolling;
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y);
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
if(m_size.y < m_maxSize.y) {
|
||||
m_originScrooled.y -= m_pixelScrolling;
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||
m_originScrooled.y += m_pixelScrolling;
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y);
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
if(m_size.y < m_maxSize.y) {
|
||||
m_originScrooled.y += m_pixelScrolling;
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
}else if (2 == IdInput) {
|
||||
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
||||
m_highSpeedMode = ewol::SCROLL_INIT;
|
||||
@ -238,16 +243,16 @@ bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput
|
||||
}
|
||||
MarkToReedraw();
|
||||
}
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y);
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
|
||||
return true;
|
||||
} if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
m_originScrooled.x = (int32_t)(m_maxSize.x * (relativePos.x-SCROLL_BAR_SPACE) / (m_size.x-SCROLL_BAR_SPACE*2));
|
||||
m_originScrooled.x = etk_avg(0, m_originScrooled.x, m_maxSize.x);
|
||||
m_originScrooled.x = etk_avg(0, m_originScrooled.x, (m_maxSize.x - m_size.x*m_limitScrolling));
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
} if (ewol::SCROLL_ENABLE_VERTICAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
m_originScrooled.y = (int32_t)(m_maxSize.y * (relativePos.y-SCROLL_BAR_SPACE) / (m_size.y-SCROLL_BAR_SPACE*2));
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, m_maxSize.y);
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
@ -283,10 +288,8 @@ bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput
|
||||
//m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x);
|
||||
m_originScrooled.x -= relativePos.x - m_highSpeedStartPos.x;
|
||||
m_originScrooled.y -= relativePos.y - m_highSpeedStartPos.y;
|
||||
m_originScrooled.x = etk_max(m_originScrooled.x, 0);
|
||||
m_originScrooled.y = etk_max(m_originScrooled.y, 0);
|
||||
m_originScrooled.x = etk_min(m_originScrooled.x, m_maxSize.x);
|
||||
m_originScrooled.y = etk_min(m_originScrooled.y, m_maxSize.y);
|
||||
m_originScrooled.x = etk_avg(0, m_originScrooled.x, (m_maxSize.x - m_size.x*m_limitScrolling));
|
||||
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
|
||||
m_highSpeedStartPos.x = relativePos.x;
|
||||
m_highSpeedStartPos.y = relativePos.y;
|
||||
EWOL_VERBOSE("SCROOL ==> MOVE (" << m_originScrooled.x << "," << m_originScrooled.y << ")");
|
||||
|
@ -52,11 +52,12 @@ namespace ewol {
|
||||
protected:
|
||||
Vector2D<float> m_originScrooled;
|
||||
Vector2D<float> m_maxSize;
|
||||
float m_zoom; //!< current zoom on the display
|
||||
float m_zoom; //!< current zoom on the display
|
||||
float m_limitScrolling;
|
||||
private:
|
||||
scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling
|
||||
float m_pixelScrolling;
|
||||
Vector2D<float> m_highSpeedStartPos;
|
||||
float m_pixelScrolling;
|
||||
Vector2D<float> m_highSpeedStartPos;
|
||||
highSpeedMode_te m_highSpeedMode;
|
||||
int32_t m_highSpeedButton;
|
||||
ewol::inputType_te m_highSpeedType;
|
||||
@ -125,6 +126,12 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
void SetScrollingPositionDynamic(Vector2D<float> borderWidth, Vector2D<float> 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 ...
|
||||
* @return ---
|
||||
*/
|
||||
void SetLimitScrolling(float poucentageLimit) { m_limitScrolling = etk_avg(0.1, poucentageLimit,0.9); };
|
||||
};
|
||||
|
||||
extern const char * const TYPE_EOBJECT_WIDGET_SCROOLED;
|
||||
|
@ -270,6 +270,8 @@ void ewol::Parameter::MenuAdd(etk::UString label, etk::UString image, ewol::Widg
|
||||
if (NULL == myLabel) {
|
||||
EWOL_ERROR("Can not allocate widget ==> display might be in error");
|
||||
} else {
|
||||
myLabel->SetExpendY(true);
|
||||
myLabel->SetExpendX(true);
|
||||
m_wSlider->SubWidgetAdd(myLabel);
|
||||
}
|
||||
}
|
||||
@ -280,6 +282,13 @@ void ewol::Parameter::MenuAdd(etk::UString label, etk::UString image, ewol::Widg
|
||||
m_currentIdList++;
|
||||
}
|
||||
}
|
||||
void ewol::Parameter::MenuAddGroup(etk::UString label)
|
||||
{
|
||||
if (NULL != m_paramList) {
|
||||
m_paramList->MenuSeparator();
|
||||
m_paramList->MenuAddGroup(label);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::Parameter::MenuClear(void)
|
||||
{
|
||||
|
@ -77,6 +77,7 @@ namespace ewol {
|
||||
|
||||
void SetTitle(etk::UString label);
|
||||
void MenuAdd(etk::UString label, etk::UString image, ewol::Widget* associateWidget);
|
||||
void MenuAddGroup(etk::UString label);
|
||||
void MenuClear(void);
|
||||
void MenuSeparator(void);
|
||||
private:
|
||||
|
@ -207,7 +207,7 @@ void ewol::ParameterList::OnRegenerateDisplay(void)
|
||||
startRaw = 0;
|
||||
}
|
||||
// Calculate the real position ...
|
||||
tmpOriginY = -m_originScrooled.y + startRaw*(minHeight + 2*m_paddingSizeY);
|
||||
tmpOriginY = m_size.y - (-m_originScrooled.y + (startRaw+1)*(minHeight + 2*m_paddingSizeY));
|
||||
|
||||
clipping_ts drawClipping;
|
||||
drawClipping.x = 0;
|
||||
@ -226,11 +226,14 @@ void ewol::ParameterList::OnRegenerateDisplay(void)
|
||||
|
||||
Vector2D<float> textPos;
|
||||
textPos.x = (int32_t)tmpOriginX;
|
||||
if (m_list[iii]->m_group == false) {
|
||||
textPos.x += minHeight;
|
||||
}
|
||||
textPos.y = (int32_t)(tmpOriginY + m_paddingSizeY);
|
||||
tmpText->Text(textPos, drawClipping, myTextToWrite);
|
||||
|
||||
AddOObject(tmpText);
|
||||
tmpOriginY += minHeight + 2* m_paddingSizeY;
|
||||
tmpOriginY -= minHeight + 2* m_paddingSizeY;
|
||||
}
|
||||
AddOObject(BGOObjects, 0);
|
||||
|
||||
@ -258,6 +261,8 @@ bool ewol::ParameterList::OnEventInput(ewol::inputType_te type, int32_t IdInput,
|
||||
}
|
||||
if (IdInput == 1 && typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
Vector2D<float> relativePos = RelativePosition(pos);
|
||||
// corection for the openGl abstraction
|
||||
relativePos.y = m_size.y - relativePos.y;
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||
int32_t minHeight = ewol::GetHeight(fontId);
|
||||
@ -292,7 +297,7 @@ void ewol::ParameterList::OnLostFocus(void)
|
||||
|
||||
void ewol::ParameterList::MenuAdd(etk::UString& label, int32_t refId, etk::UString& image)
|
||||
{
|
||||
ewol::elementPL* tmpEmement = new ewol::elementPL(label, refId, image);
|
||||
ewol::elementPL* tmpEmement = new ewol::elementPL(label, refId, image, false);
|
||||
if (NULL != tmpEmement) {
|
||||
m_list.PushBack(tmpEmement);
|
||||
if (m_idSelected == -1 && label != "---" && refId>0) {
|
||||
@ -301,6 +306,16 @@ void ewol::ParameterList::MenuAdd(etk::UString& label, int32_t refId, etk::UStri
|
||||
MarkToReedraw();
|
||||
}
|
||||
}
|
||||
void ewol::ParameterList::MenuAddGroup(etk::UString& label)
|
||||
{
|
||||
etk::UString image = "";
|
||||
ewol::elementPL* tmpEmement = new ewol::elementPL(label, -1, image, true);
|
||||
if (NULL != tmpEmement) {
|
||||
m_list.PushBack(tmpEmement);
|
||||
MarkToReedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::ParameterList::MenuClear(void)
|
||||
{
|
||||
@ -311,12 +326,15 @@ void ewol::ParameterList::MenuClear(void)
|
||||
m_list[iii] = NULL;
|
||||
}
|
||||
}
|
||||
m_list.Clear();
|
||||
}
|
||||
|
||||
void ewol::ParameterList::MenuSeparator(void)
|
||||
{
|
||||
etk::UString label = "---";
|
||||
etk::UString image = "";
|
||||
MenuAdd(label, -1, image);
|
||||
if (m_list.Size()>0) {
|
||||
etk::UString label = "";
|
||||
etk::UString image = "";
|
||||
MenuAdd(label, -1, image);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,12 @@ namespace ewol {
|
||||
class elementPL
|
||||
{
|
||||
public :
|
||||
bool m_group;
|
||||
etk::UString m_label;
|
||||
int32_t m_refId;
|
||||
etk::UString m_image;
|
||||
elementPL(etk::UString& label, int32_t refId, etk::UString& image) :
|
||||
elementPL(etk::UString& label, int32_t refId, etk::UString& image, bool isGroup) :
|
||||
m_group(isGroup),
|
||||
m_label(label),
|
||||
m_refId(refId),
|
||||
m_image(image)
|
||||
@ -107,7 +109,7 @@ namespace ewol {
|
||||
void OnLostFocus(void);
|
||||
public:
|
||||
void MenuAdd(etk::UString& label, int32_t refId, etk::UString& image);
|
||||
void MenuRm(etk::UString& ref);
|
||||
void MenuAddGroup(etk::UString& label);
|
||||
void MenuClear(void);
|
||||
void MenuSeparator(void);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user