Change the color of the current selected dot

This commit is contained in:
Edouard Dupin 2012-03-11 18:11:21 +01:00
parent 7031b0248d
commit 688f7a28f0
3 changed files with 75 additions and 24 deletions

View File

@ -129,9 +129,13 @@ const char * const drawerEventRequestOpenFile = "Drawer Request Open Fil
const char * const drawerEventRequestOpenFileClosed = "Drawer Close Open File";
const char * const drawerEventRequestOpenFileSelected = "Drawer Open Selected File";
const char * const drawerEventColorHasChange = "Drawer-select-color-change";
class MainWindows :public ewol::Windows
{
private:
widgetDrawer* m_drawer;
public:
MainWindows(void)
{
@ -182,6 +186,7 @@ class MainWindows :public ewol::Windows
tmpColor.blue = 0.0;
tmpColor.alpha = 1.0;
mybtColor->SetCurrentColor(tmpColor);
mybtColor->RegisterOnEvent(this, ewolEventButtonColorChange, drawerEventColorHasChange);
mySizerVert2->SubWidgetAdd(mybtColor);
mybtColor = new ewol::ButtonColor();
@ -202,14 +207,14 @@ class MainWindows :public ewol::Windows
mybtColor->SetCurrentColor(tmpColor);
mySizerVert2->SubWidgetAdd(mybtColor);
widgetDrawer * monDrawer = new widgetDrawer();
monDrawer->SetFontSize(11);
monDrawer->SetFontNameNormal("freefont/FreeSerif.ttf");
monDrawer->SetExpendX(true);
monDrawer->SetExpendY(true);
monDrawer->SetFillX(true);
monDrawer->SetFillY(true);
mySizer->SubWidgetAdd(monDrawer);
m_drawer = new widgetDrawer();
m_drawer->SetFontSize(11);
m_drawer->SetFontNameNormal("freefont/FreeSerif.ttf");
m_drawer->SetExpendX(true);
m_drawer->SetExpendY(true);
m_drawer->SetFillX(true);
m_drawer->SetFillY(true);
mySizer->SubWidgetAdd(m_drawer);
};
@ -229,6 +234,8 @@ class MainWindows :public ewol::Windows
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
ewol::Windows::OnReceiveMessage(CallerObject, eventId, data);
DRAW_INFO("Receive Event from the main windows ... : widgetid=" << CallerObject << " ==> " << eventId << " ==> data=\"" << data << "\"" );
if (eventId == drawerEventRequestOpenFile) {
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
@ -247,9 +254,33 @@ class MainWindows :public ewol::Windows
// get the filename :
etk::UString tmpData = tmpWidget->GetCompleateFileName();
DRAW_DEBUG("Request opening the file : " << tmpData);
} else if (eventId == drawerEventColorHasChange) {
// the button color has change ==> we really change the current color ...
if (NULL != CallerObject) {
ewol::ButtonColor * tmpColorButton = static_cast<ewol::ButtonColor*>(CallerObject);
color_ts tmpColor = tmpColorButton->GetCurrentColor();
if (NULL != m_drawer) {
m_drawer->SetColorOnSelected(tmpColor);
}
}
}
return;
};
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
virtual void OnObjectRemove(ewol::EObject * removeObject)
{
ewol::Windows::OnObjectRemove(removeObject);
if (removeObject == m_drawer) {
m_drawer = NULL;
m_needFlipFlop = true;
}
}
};
static MainWindows * basicWindows = NULL;

View File

@ -52,6 +52,12 @@ widgetDrawer::widgetDrawer(void)
m_textColorBg.green = 0.0;
m_textColorBg.blue = 0.0;
m_textColorBg.alpha = 0.25;
m_triangleColor.red = 0.0;
m_triangleColor.green = 1.0;
m_triangleColor.blue = 0.0;
m_triangleColor.alpha = 1.0;
RegisterMultiCast(drawMsgGuiLinkNew);
SetCanHaveFocus(true);
}
@ -349,20 +355,9 @@ void widgetDrawer::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
tmpLink.dot[0] = m_selectedList[0];
tmpLink.dot[1] = m_selectedList[1];
tmpLink.dot[2] = m_selectedList[2];
tmpLink.color[0].red = 0.0;
tmpLink.color[0].green = 0.0;
tmpLink.color[0].blue = 1.0;
tmpLink.color[0].alpha = 1.0;
tmpLink.color[1].red = 0.0;
tmpLink.color[1].green = 1.0;
tmpLink.color[1].blue = 0.0;
tmpLink.color[1].alpha = 1.0;
tmpLink.color[2].red = 1.0;
tmpLink.color[2].green = 0.0;
tmpLink.color[2].blue = 0.0;
tmpLink.color[2].alpha = 1.0;
tmpLink.color[0] = m_triangleColor;
tmpLink.color[1] = m_triangleColor;
tmpLink.color[2] = m_triangleColor;
m_linkList.PushBack(tmpLink);
MarkToReedraw();
}
@ -380,4 +375,27 @@ void widgetDrawer::SetFontNameNormal(etk::UString fontName)
if (fontID >= 0) {
m_fontNormal = fontID;
}
}
void widgetDrawer::SetColorOnSelected(color_ts newColor)
{
m_triangleColor = newColor;
// Remove all selected points ...
for(int32_t iii=0; iii<m_dotList.Size() ; iii++) {
if (true == DotIsSelected(iii)) {
// Remove all link who have a selected point :
for(int32_t jjj=0 ; jjj<m_linkList.Size() ; jjj++) {
if(m_linkList[jjj].dot[0] == iii) {
m_linkList[jjj].color[0] = newColor;
}
if(m_linkList[jjj].dot[1] == iii) {
m_linkList[jjj].color[1] = newColor;
}
if(m_linkList[jjj].dot[2] == iii) {
m_linkList[jjj].color[2] = newColor;
}
}
}
}
MarkToReedraw();
}

View File

@ -43,8 +43,9 @@ class widgetDrawer :public ewol::Widget
virtual ~widgetDrawer(void);
virtual bool CalculateMinSize(void);
private:
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color
color_ts m_triangleColor; //!< color for the next element of the triangle
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color
// drawing elements :
ewol::OObject2DTextColored m_OObjectTextNormal[NB_BOUBLE_BUFFER];
ewol::OObject2DColored m_OObjectsColored[NB_BOUBLE_BUFFER];
@ -84,6 +85,7 @@ class widgetDrawer :public ewol::Widget
public:
void SetFontSize(int32_t size);
void SetFontNameNormal(etk::UString fontName);
void SetColorOnSelected(color_ts newColor);
protected:
virtual void OnDraw(void);
private: