Add really basic sliders
This commit is contained in:
parent
19ead2de2c
commit
500e0d929a
@ -26,6 +26,8 @@
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/widgetMeta/ColorChooser.h>
|
||||
#include <ewol/ewol.h>
|
||||
|
||||
|
||||
extern const char * const ewolEventButtonColorChange = "ewol-Button-Color-Change";
|
||||
@ -50,15 +52,12 @@ void ewol::ButtonColor::Init(void)
|
||||
m_padding.x = 4;
|
||||
#endif
|
||||
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
|
||||
m_textColorBg.red = 0.0;
|
||||
m_textColorBg.green = 0.0;
|
||||
m_textColorBg.blue = 0.0;
|
||||
m_textColorBg.alpha = 0.25;
|
||||
m_widgetContextMenu = NULL;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
@ -151,6 +150,17 @@ void ewol::ButtonColor::OnRegenerateDisplay(void)
|
||||
tmpSizeX -= 2*m_padding.x;
|
||||
tmpSizeY -= 2*m_padding.y;
|
||||
|
||||
if ((m_textColorBg.red>0.5) || (m_textColorBg.green>0.5) || (m_textColorBg.blue > 0.8) ) {
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
} else {
|
||||
m_textColorFg.red = 1.0;
|
||||
m_textColorFg.green = 1.0;
|
||||
m_textColorFg.blue = 1.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
}
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
||||
/*
|
||||
int32_t fontId = GetDefaultFontId();
|
||||
@ -189,8 +199,29 @@ bool ewol::ButtonColor::OnEventInput(int32_t IdInput, eventInputType_te typeEven
|
||||
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
|
||||
// nothing to do ...
|
||||
GenerateEventId(ewolEventButtonPressed);
|
||||
//GenerateEventId(ewolEventButtonPressed);
|
||||
// Display the pop-up menu ...
|
||||
|
||||
// create a context menu :
|
||||
m_widgetContextMenu = new ewol::ContextMenu();
|
||||
if (NULL == m_widgetContextMenu) {
|
||||
EWOL_ERROR("Allocation Error");
|
||||
return true;
|
||||
}
|
||||
// Get the button widget :
|
||||
coord2D_ts newPosition;
|
||||
newPosition.x = m_origin.x + m_size.x/2;
|
||||
newPosition.y = m_origin.y;
|
||||
|
||||
m_widgetContextMenu->SetPositionMark(ewol::CONTEXT_MENU_MARK_BOTTOM, newPosition );
|
||||
|
||||
ewol::ColorChooser * myColorChooser = new ewol::ColorChooser();
|
||||
// set it in the pop-up-system :
|
||||
m_widgetContextMenu->SubWidgetSet(myColorChooser);
|
||||
myColorChooser->RegisterOnEvent(this, ewolEventColorChooserChange, ewolEventColorChooserChange);
|
||||
ewol::PopUpWidgetPush(m_widgetContextMenu);
|
||||
MarkToReedraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -211,3 +242,32 @@ void ewol::ButtonColor::SetCurrentColor(color_ts color)
|
||||
//set the new label ...
|
||||
SetLabel(colorText);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::ButtonColor::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
if (eventId == ewolEventColorChooserChange) {
|
||||
//==> this is an internal event ...
|
||||
ewol::ColorChooser * myColorChooser = static_cast<ewol::ColorChooser *>(CallerObject);
|
||||
|
||||
color_ts tmpColor = myColorChooser->GetColor();
|
||||
|
||||
m_selectedColor = tmpColor;
|
||||
m_textColorBg = m_selectedColor;
|
||||
char colorText[256];
|
||||
sprintf(colorText, "#%02X%02X%02X%02X",
|
||||
(uint8_t)(tmpColor.red * 0xFF),
|
||||
(uint8_t)(tmpColor.green * 0xFF),
|
||||
(uint8_t)(tmpColor.blue * 0xFF),
|
||||
(uint8_t)(tmpColor.alpha * 0xFF));
|
||||
//set the new label ...
|
||||
SetLabel(colorText);
|
||||
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/widget/Drawable.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/ContextMenu.h>
|
||||
|
||||
extern const char * const ewolEventButtonColorChange;
|
||||
|
||||
@ -48,18 +49,27 @@ namespace ewol {
|
||||
void SetAlignement(textAlignement_te typeAlign);
|
||||
void SetPadding(coord2D_ts newPadding);
|
||||
private:
|
||||
textAlignement_te m_alignement;
|
||||
coord2D_ts m_padding;
|
||||
etk::UString m_label;
|
||||
color_ts m_textColorFg; //!< Text color
|
||||
color_ts m_textColorBg; //!< Background color
|
||||
color_ts m_selectedColor; //!< user current selected Color
|
||||
textAlignement_te m_alignement;
|
||||
coord2D_ts m_padding;
|
||||
etk::UString m_label;
|
||||
color_ts m_textColorFg; //!< Text color
|
||||
color_ts m_textColorBg; //!< Background color
|
||||
color_ts m_selectedColor; //!< user current selected Color
|
||||
ewol::ContextMenu* m_widgetContextMenu;
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
|
||||
color_ts GetCurrentColor(void) { return m_selectedColor; };
|
||||
void SetCurrentColor(color_ts color);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -67,15 +67,17 @@ bool ewol::ColorBar::CalculateMinSize(void)
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
static color_ts s_listColor[7][3] = {
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {1.0, 0.0, 0.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } },
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {1.0, 1.0, 0.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } },
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {0.0, 1.0, 0.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } },
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {0.0, 1.0, 1.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } },
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {0.0, 0.0, 1.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } },
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {1.0, 0.0, 1.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } },
|
||||
{ { 1.0, 1.0, 1.0, 1.0 }, {1.0, 0.0, 0.0, 1.0 }, {0.0, 0.0, 0.0, 1.0 } }
|
||||
static color_ts s_listColorWhite = {1.0, 1.0, 1.0, 1.0 };
|
||||
static color_ts s_listColorBlack = {0.0, 0.0, 0.0, 1.0 };
|
||||
#define NB_BAND_COLOR (6)
|
||||
static color_ts s_listColor[NB_BAND_COLOR+1] = {
|
||||
{1.0, 0.0, 0.0, 1.0 },
|
||||
{1.0, 1.0, 0.0, 1.0 },
|
||||
{0.0, 1.0, 0.0, 1.0 },
|
||||
{0.0, 1.0, 1.0, 1.0 },
|
||||
{0.0, 0.0, 1.0, 1.0 },
|
||||
{1.0, 0.0, 1.0, 1.0 },
|
||||
{1.0, 0.0, 0.0, 1.0 }
|
||||
};
|
||||
|
||||
color_ts ewol::ColorBar::GetCurrentColor(void)
|
||||
@ -119,7 +121,7 @@ void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
tmpSizeX += m_padding.x;
|
||||
tmpSizeY += m_padding.y;
|
||||
|
||||
for(int32_t iii=0; iii<6 ; iii++) {
|
||||
for(int32_t iii=0; iii<NB_BAND_COLOR ; iii++) {
|
||||
|
||||
/* Step 1 :
|
||||
*
|
||||
@ -128,12 +130,12 @@ void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
* ******
|
||||
* ********
|
||||
*/
|
||||
tmpOObjects->SetColor(s_listColor[iii][0]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/6), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1][1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/6), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii][1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/6), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColorWhite);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
|
||||
/* Step 2 :
|
||||
* ********
|
||||
@ -142,13 +144,12 @@ void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
* **
|
||||
*
|
||||
*/
|
||||
tmpOObjects->SetColor(s_listColor[iii][0]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/6), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1][0]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/6), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1][1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/6), tmpOriginY+tmpSizeY/2);
|
||||
|
||||
tmpOObjects->SetColor(s_listColorWhite);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColorWhite);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
/* Step 3 :
|
||||
*
|
||||
* **
|
||||
@ -156,13 +157,12 @@ void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
* ******
|
||||
* ********
|
||||
*/
|
||||
tmpOObjects->SetColor(s_listColor[iii][1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/6), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1][2]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/6), tmpOriginY+tmpSizeY);
|
||||
tmpOObjects->SetColor(s_listColor[iii][2]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/6), tmpOriginY+tmpSizeY);
|
||||
|
||||
tmpOObjects->SetColor(s_listColor[iii]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColorBlack);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY);
|
||||
tmpOObjects->SetColor(s_listColorBlack);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY);
|
||||
/* Step 4 :
|
||||
* ********
|
||||
* ******
|
||||
@ -170,19 +170,38 @@ void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
* **
|
||||
*
|
||||
*/
|
||||
tmpOObjects->SetColor(s_listColor[iii][1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/6), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1][1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/6), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1][2]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/6), tmpOriginY+tmpSizeY);
|
||||
tmpOObjects->SetColor(s_listColor[iii]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColorBlack);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY);
|
||||
/*
|
||||
tmpOObjects->SetColor(s_listColorWhite);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+0.5)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
|
||||
//tmpOObjects->Rectangle( tmpOriginX + iii*(tmpSizeX/7), tmpOriginY, tmpSizeX/7, tmpSizeY);
|
||||
tmpOObjects->SetColor(s_listColor[iii]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + iii*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColor[iii+1]);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+1)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY/2);
|
||||
tmpOObjects->SetColor(s_listColorBlack);
|
||||
tmpOObjects->SetPoint(tmpOriginX + (iii+0.5)*(tmpSizeX/NB_BAND_COLOR), tmpOriginY+tmpSizeY);
|
||||
*/
|
||||
}
|
||||
color_ts tmpColor;
|
||||
tmpColor.red = 0.5;
|
||||
tmpColor.green = 0.5;
|
||||
tmpColor.blue = 0.5;
|
||||
if (m_currentUserPos.y > 0.5) {
|
||||
tmpColor.red = 1.0;
|
||||
tmpColor.green = 1.0;
|
||||
tmpColor.blue = 1.0;
|
||||
} else {
|
||||
tmpColor.red = 0.0;
|
||||
tmpColor.green = 0.0;
|
||||
tmpColor.blue = 0.0;
|
||||
}
|
||||
tmpColor.alpha = 1.0;
|
||||
tmpOObjects->SetColor(tmpColor);
|
||||
tmpOObjects->Circle(m_currentUserPos.x*m_size.x, m_currentUserPos.y*m_size.y, 3.0, 1.0);
|
||||
@ -198,16 +217,66 @@ bool ewol::ColorBar::OnEventInput(int32_t IdInput, eventInputType_te typeEvent,
|
||||
if (1 == IdInput) {
|
||||
if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
|
||||
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
// nothing to do ...
|
||||
//GenerateEventId(ewolEventButtonPressed);
|
||||
m_currentUserPos.x=pos.local.x/m_size.x;
|
||||
m_currentUserPos.y=pos.local.y/m_size.y;
|
||||
MarkToReedraw();
|
||||
//==> try to estimate color
|
||||
int32_t bandID = (int32_t)(pos.local.x/6);
|
||||
etkFloat_t relativePos = pos.local.x - (pos.local.x/6) * bandID;
|
||||
|
||||
EWOL_VERBOSE("event on (" << pos.local.x << "," << pos.local.y << ")");
|
||||
int32_t bandID = (int32_t)(pos.local.x/(m_size.x/6));
|
||||
etkFloat_t relativePos = pos.local.x - (m_size.x/6) * bandID;
|
||||
etkFloat_t poroportionnalPos = relativePos/(m_size.x/6);
|
||||
EWOL_VERBOSE("bandId=" << bandID << " relative pos=" << relativePos);
|
||||
color_ts estimateColor;
|
||||
estimateColor.alpha = 1.0;
|
||||
if (s_listColor[bandID].red == s_listColor[bandID+1].red) {
|
||||
estimateColor.red = s_listColor[bandID].red;
|
||||
} else if (s_listColor[bandID].red < s_listColor[bandID+1].red) {
|
||||
estimateColor.red = s_listColor[bandID].red + (s_listColor[bandID+1].red-s_listColor[bandID].red)*poroportionnalPos;
|
||||
} else {
|
||||
estimateColor.red = s_listColor[bandID+1].red + (s_listColor[bandID].red-s_listColor[bandID+1].red)*(1-poroportionnalPos);
|
||||
}
|
||||
if (s_listColor[bandID].green == s_listColor[bandID+1].green) {
|
||||
estimateColor.green = s_listColor[bandID].green;
|
||||
} else if (s_listColor[bandID].green < s_listColor[bandID+1].green) {
|
||||
estimateColor.green = s_listColor[bandID].green + (s_listColor[bandID+1].green-s_listColor[bandID].green)*poroportionnalPos;
|
||||
} else {
|
||||
estimateColor.green = s_listColor[bandID+1].green + (s_listColor[bandID].green-s_listColor[bandID+1].green)*(1-poroportionnalPos);
|
||||
}
|
||||
if (s_listColor[bandID].blue == s_listColor[bandID+1].blue) {
|
||||
estimateColor.blue = s_listColor[bandID].blue;
|
||||
} else if (s_listColor[bandID].blue < s_listColor[bandID+1].blue) {
|
||||
estimateColor.blue = s_listColor[bandID].blue + (s_listColor[bandID+1].blue-s_listColor[bandID].blue)*poroportionnalPos;
|
||||
} else {
|
||||
estimateColor.blue = s_listColor[bandID+1].blue + (s_listColor[bandID].blue-s_listColor[bandID+1].blue)*(1-poroportionnalPos);
|
||||
}
|
||||
// step 2 generate the white and black ...
|
||||
if (pos.local.y == (m_size.y/2)) {
|
||||
// nothing to do ... just get the current color ...
|
||||
} else if (pos.local.y < (m_size.y/2)) {
|
||||
etkFloat_t poroportionnalWhite = 1.0-pos.local.y/(m_size.y/2);
|
||||
estimateColor.red = estimateColor.red + (1.0 - estimateColor.red )*poroportionnalWhite;
|
||||
estimateColor.green = estimateColor.green + (1.0 - estimateColor.green)*poroportionnalWhite;
|
||||
estimateColor.blue = estimateColor.blue + (1.0 - estimateColor.blue )*poroportionnalWhite;
|
||||
} else {
|
||||
etkFloat_t poroportionnalBlack = (pos.local.y-(m_size.y/2))/(m_size.y/2);
|
||||
estimateColor.red = estimateColor.red - (estimateColor.red )*poroportionnalBlack;
|
||||
estimateColor.green = estimateColor.green - (estimateColor.green)*poroportionnalBlack;
|
||||
estimateColor.blue = estimateColor.blue - (estimateColor.blue )*poroportionnalBlack;
|
||||
}
|
||||
/*
|
||||
char colorText[256];
|
||||
sprintf(colorText, "#%02X%02X%02X%02X",
|
||||
(uint8_t)(estimateColor.red * 0xFF),
|
||||
(uint8_t)(estimateColor.green * 0xFF),
|
||||
(uint8_t)(estimateColor.blue * 0xFF),
|
||||
(uint8_t)(estimateColor.alpha * 0xFF));
|
||||
EWOL_DEBUG("new color : " << colorText);
|
||||
*/
|
||||
m_currentColor = estimateColor;
|
||||
GenerateEventId(ewolEventColorBarChange);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -91,8 +91,11 @@ bool ewol::ContextMenu::CalculateSize(etkFloat_t availlableX, etkFloat_t availla
|
||||
subWidgetOrigin.x = (int32_t)(m_arrowPos.x - subWidgetSize.x/2);
|
||||
subWidgetOrigin.y = (int32_t)(m_arrowPos.y + m_offset);
|
||||
break;
|
||||
case ewol::CONTEXT_MENU_MARK_RIGHT:
|
||||
case ewol::CONTEXT_MENU_MARK_BOTTOM:
|
||||
subWidgetOrigin.x = (int32_t)(m_arrowPos.x - subWidgetSize.x/2);
|
||||
subWidgetOrigin.y = (int32_t)(m_arrowPos.y - m_offset - subWidgetSize.y);
|
||||
break;
|
||||
case ewol::CONTEXT_MENU_MARK_RIGHT:
|
||||
case ewol::CONTEXT_MENU_MARK_LEFT:
|
||||
default:
|
||||
subWidgetOrigin.x = (int32_t)(m_size.x - m_origin.x - subWidgetSize.x)/2 + m_origin.x;
|
||||
@ -224,8 +227,20 @@ void ewol::ContextMenu::OnRegenerateDisplay(void)
|
||||
BGOObjects->SetPoint(m_arrowPos.x-laking, m_arrowPos.y+laking);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case ewol::CONTEXT_MENU_MARK_BOTTOM:
|
||||
BGOObjects->SetPoint(m_arrowPos.x, m_arrowPos.y);
|
||||
if (m_arrowPos.x <= tmpOrigin.x ) {
|
||||
int32_t laking = m_offset - m_padding.y;
|
||||
BGOObjects->SetPoint(m_arrowPos.x+laking, m_arrowPos.y-laking);
|
||||
BGOObjects->SetPoint(m_arrowPos.x, m_arrowPos.y-laking);
|
||||
} else {
|
||||
int32_t laking = m_offset - m_padding.y;
|
||||
BGOObjects->SetPoint(m_arrowPos.x+laking, m_arrowPos.y-laking);
|
||||
BGOObjects->SetPoint(m_arrowPos.x-laking, m_arrowPos.y-laking);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
case ewol::CONTEXT_MENU_MARK_RIGHT:
|
||||
case ewol::CONTEXT_MENU_MARK_LEFT:
|
||||
EWOL_TODO("later");
|
||||
|
144
Sources/libewol/ewol/widget/Slider.cpp
Normal file
144
Sources/libewol/ewol/widget/Slider.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/Slider.cpp
|
||||
* @brief ewol Slider widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 06/03/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Slider.h>
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
|
||||
|
||||
extern const char * const ewolEventSliderChange = "ewol-event-slider-change";
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Slider"
|
||||
|
||||
|
||||
ewol::Slider::Slider(void)
|
||||
{
|
||||
AddEventId(ewolEventSliderChange);
|
||||
|
||||
m_value = 0;
|
||||
m_min = 0;
|
||||
m_max = 10;
|
||||
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
|
||||
m_textColorBg.red = 0.0;
|
||||
m_textColorBg.green = 0.0;
|
||||
m_textColorBg.blue = 0.0;
|
||||
m_textColorBg.alpha = 0.25;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
ewol::Slider::~Slider(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ewol::Slider::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 40;
|
||||
m_minSize.y = 15;
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ewol::Slider::SetValue(int32_t val)
|
||||
{
|
||||
m_value = etk_max(etk_min(val, m_max), m_min);
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
int32_t ewol::Slider::GetValue(void)
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
void ewol::Slider::SetMin(int32_t val)
|
||||
{
|
||||
m_min = val;
|
||||
m_value = etk_max(etk_min(m_value, m_max), m_min);
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
void ewol::Slider::SetMax(int32_t val)
|
||||
{
|
||||
m_max = val;
|
||||
m_value = etk_max(etk_min(m_value, m_max), m_min);
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
void ewol::Slider::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
// draw a line :
|
||||
tmpOObjects->Line(4, m_size.y/2, m_size.x-4, m_size.y/2, 1);
|
||||
|
||||
tmpOObjects->Disc(4+((etkFloat_t)(m_value-m_min)/(etkFloat_t)(m_max-m_min))*(etkFloat_t)(m_size.x-8), m_size.y/2, 4);
|
||||
|
||||
AddOObject(tmpOObjects);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Slider::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
|
||||
{
|
||||
//EWOL_DEBUG("Event on Slider ...");
|
||||
if (1 == IdInput) {
|
||||
if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
// get the new position :
|
||||
EWOL_DEBUG("Event on Slider (" << pos.local.x << "," << pos.local.y << ")");
|
||||
m_value = m_min + (etkFloat_t)(pos.local.x - 4) / (etkFloat_t)(m_size.x-8) * (etkFloat_t)(m_max-m_min);
|
||||
m_value = etk_max(etk_min(m_value, m_max), m_min);
|
||||
EWOL_DEBUG(" new value : " << m_value << "¤ [" << m_min << ".." << m_max << "]");
|
||||
GenerateEventId(ewolEventSliderChange);
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
58
Sources/libewol/ewol/widget/Slider.h
Normal file
58
Sources/libewol/ewol/widget/Slider.h
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/Slider.h
|
||||
* @brief ewol Slider widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 06/03/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_SLIDER_H__
|
||||
#define __EWOL_SLIDER_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/widget/Drawable.h>
|
||||
|
||||
extern const char * const ewolEventSliderChange;
|
||||
|
||||
namespace ewol {
|
||||
class Slider :public ewol::Drawable
|
||||
{
|
||||
public:
|
||||
Slider(void);
|
||||
virtual ~Slider(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
void SetValue(int32_t val);
|
||||
int32_t GetValue(void);
|
||||
void SetMin(int32_t val);
|
||||
void SetMax(int32_t val);
|
||||
private:
|
||||
int32_t m_value;
|
||||
int32_t m_min;
|
||||
int32_t m_max;
|
||||
color_ts m_textColorFg; //!< Text color
|
||||
color_ts m_textColorBg; //!< Background color
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -42,117 +42,68 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
extern const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel";
|
||||
extern const char * const ewolEventColorChooserChange = "ewol-event-color-chooser-change";
|
||||
|
||||
|
||||
const char * const eventColorBarHasChange = "event-color-bar-has-change";
|
||||
const char * const eventColorSpecificHasChange = "event-color-specific-has-change";
|
||||
|
||||
|
||||
ewol::ColorChooser::ColorChooser(void)
|
||||
{
|
||||
AddEventId(ewolEventFileChooserCancel);
|
||||
AddEventId(ewolEventFileChooserValidate);
|
||||
AddEventId(ewolEventColorChooserChange);
|
||||
|
||||
m_hasSelectedFile = false;
|
||||
|
||||
m_widgetTitle = NULL;
|
||||
m_widgetValidate = NULL;
|
||||
m_widgetCancel = NULL;
|
||||
m_widgetCurrentFolder = NULL;
|
||||
m_widgetCurrentFileName = NULL;
|
||||
m_widgetListFolder = NULL;
|
||||
m_widgetListFile = NULL;
|
||||
m_widgetCheckBox = NULL;
|
||||
m_widgetColorBar = NULL;
|
||||
m_widgetRed = NULL;
|
||||
m_widgetGreen = NULL;
|
||||
m_widgetBlue = NULL;
|
||||
m_widgetAlpha = NULL;
|
||||
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
ewol::Spacer * mySpacer = NULL;
|
||||
FileChooserFileList * myListFile = NULL;
|
||||
FileChooserFolderList * myListFolder = NULL;
|
||||
ewol::Label * myLabel = NULL;
|
||||
#ifdef __PLATFORM__Android
|
||||
m_folder = "/mnt/sdcard/";
|
||||
SetDisplayRatio(0.90);
|
||||
#else
|
||||
m_folder = "/home/";
|
||||
SetDisplayRatio(0.80);
|
||||
#endif
|
||||
m_file = "";
|
||||
|
||||
mySizerVert = new ewol::SizerVert();
|
||||
mySizerVert->LockExpendContamination(true);
|
||||
// set it in the pop-up-system :
|
||||
SubWidgetSet(mySizerVert);
|
||||
LockExpendContamination(true);
|
||||
m_widgetColorBar = new ewol::ColorBar();
|
||||
m_widgetColorBar->RegisterOnEvent(this, ewolEventColorBarChange, eventColorBarHasChange);
|
||||
m_widgetColorBar->SetFillY(true);
|
||||
m_widgetColorBar->SetFillX(true);
|
||||
/*
|
||||
m_widgetColorBar->SetWidth(200);
|
||||
m_widgetColorBar->SetHeigh(200);
|
||||
*/
|
||||
SubWidgetAdd(m_widgetColorBar);
|
||||
|
||||
m_widgetTitle = new ewol::Label("File chooser ...");
|
||||
mySizerVert->SubWidgetAdd(m_widgetTitle);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myLabel = new ewol::Label("Folder : ");
|
||||
myLabel->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myLabel);
|
||||
m_widgetCurrentFolder = new ewol::Entry(m_folder);
|
||||
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFolder);
|
||||
m_widgetCurrentFolder->SetExpendX(true);
|
||||
m_widgetCurrentFolder->SetFillX(true);
|
||||
m_widgetCurrentFolder->SetWidth(200);
|
||||
mySizerHori->SubWidgetAdd(m_widgetCurrentFolder);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myLabel = new ewol::Label("File Name : ");
|
||||
myLabel->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myLabel);
|
||||
m_widgetCurrentFileName = new ewol::Entry(m_file);
|
||||
m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFile);
|
||||
m_widgetCurrentFileName->SetExpendX(true);
|
||||
m_widgetCurrentFileName->SetFillX(true);
|
||||
m_widgetCurrentFileName->SetWidth(200);
|
||||
mySizerHori->SubWidgetAdd(m_widgetCurrentFileName);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
mySpacer = new ewol::Spacer();
|
||||
mySpacer->SetSize(2);
|
||||
mySizerHori->SubWidgetAdd(mySpacer);
|
||||
myListFolder = new FileChooserFolderList();
|
||||
m_widgetListFolder = myListFolder;
|
||||
myListFolder->RegisterOnEvent(this, ewolEventFileChooserSelectFolder, ewolEventFileChooserSelectFolder);
|
||||
myListFolder->SetExpendY(true);
|
||||
myListFolder->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myListFolder);
|
||||
mySpacer = new ewol::Spacer();
|
||||
mySpacer->SetSize(2);
|
||||
mySizerHori->SubWidgetAdd(mySpacer);
|
||||
myListFile = new FileChooserFileList();
|
||||
m_widgetListFile = myListFile;
|
||||
myListFile->RegisterOnEvent(this, ewolEventFileChooserSelectFile, ewolEventFileChooserSelectFile);
|
||||
myListFile->RegisterOnEvent(this, ewolEventFileChooserValidateFile, ewolEventFileChooserValidateFile);
|
||||
myListFile->SetExpendX(true);
|
||||
myListFile->SetFillX(true);
|
||||
myListFile->SetExpendY(true);
|
||||
myListFile->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myListFile);
|
||||
mySpacer = new ewol::Spacer();
|
||||
mySpacer->SetSize(2);
|
||||
mySizerHori->SubWidgetAdd(mySpacer);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
m_widgetCheckBox = new ewol::CheckBox("Show hiden files");
|
||||
m_widgetCheckBox->RegisterOnEvent(this, ewolEventCheckBoxClicked, ewolEventFileChooserHidenFileChange);
|
||||
m_widgetCheckBox->SetValue(false);
|
||||
mySizerHori->SubWidgetAdd(m_widgetCheckBox);
|
||||
mySpacer = new ewol::Spacer();
|
||||
mySpacer->SetExpendX(true);
|
||||
mySizerHori->SubWidgetAdd(mySpacer);
|
||||
m_widgetValidate = new ewol::Button("Open");
|
||||
m_widgetCheckBox->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserValidate);
|
||||
mySizerHori->SubWidgetAdd(m_widgetValidate);
|
||||
m_widgetCancel = new ewol::Button("Cancel");
|
||||
m_widgetCheckBox->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel);
|
||||
mySizerHori->SubWidgetAdd(m_widgetCancel);
|
||||
m_widgetRed = new ewol::Slider();
|
||||
m_widgetRed->RegisterOnEvent(this, ewolEventSliderChange, eventColorSpecificHasChange);
|
||||
m_widgetRed->SetExpendX(true);
|
||||
m_widgetRed->SetFillX(true);
|
||||
m_widgetRed->SetMin(0);
|
||||
m_widgetRed->SetMax(255);
|
||||
SubWidgetAdd(m_widgetRed);
|
||||
m_widgetGreen = new ewol::Slider();
|
||||
m_widgetGreen->RegisterOnEvent(this, ewolEventSliderChange, eventColorSpecificHasChange);
|
||||
m_widgetGreen->SetExpendX(true);
|
||||
m_widgetGreen->SetFillX(true);
|
||||
m_widgetGreen->SetMin(0);
|
||||
m_widgetGreen->SetMax(255);
|
||||
SubWidgetAdd(m_widgetGreen);
|
||||
m_widgetBlue = new ewol::Slider();
|
||||
m_widgetBlue->RegisterOnEvent(this, ewolEventSliderChange, eventColorSpecificHasChange);
|
||||
m_widgetBlue->SetExpendX(true);
|
||||
m_widgetBlue->SetFillX(true);
|
||||
m_widgetBlue->SetMin(0);
|
||||
m_widgetBlue->SetMax(255);
|
||||
SubWidgetAdd(m_widgetBlue);
|
||||
m_widgetAlpha = new ewol::Slider();
|
||||
m_widgetAlpha->RegisterOnEvent(this, ewolEventSliderChange, eventColorSpecificHasChange);
|
||||
m_widgetAlpha->SetExpendX(true);
|
||||
m_widgetAlpha->SetFillX(true);
|
||||
m_widgetAlpha->SetMin(0);
|
||||
m_widgetAlpha->SetMax(255);
|
||||
SubWidgetAdd(m_widgetAlpha);
|
||||
|
||||
// set the default Folder properties:
|
||||
UpdateCurrentFolder();
|
||||
m_currentColor.red = 1.0;
|
||||
m_currentColor.green = 1.0;
|
||||
m_currentColor.blue = 1.0;
|
||||
m_currentColor.alpha = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@ -161,44 +112,30 @@ ewol::ColorChooser::~ColorChooser(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::ColorChooser::SetTitle(etk::UString label)
|
||||
void ewol::ColorChooser::SetColor(color_ts newColor)
|
||||
{
|
||||
if (NULL == m_widgetTitle) {
|
||||
return;
|
||||
m_currentColor = newColor;
|
||||
if (NULL != m_widgetRed) {
|
||||
m_widgetRed->SetValue(m_currentColor.red * 255.);
|
||||
}
|
||||
if (NULL != m_widgetGreen) {
|
||||
m_widgetGreen->SetValue(m_currentColor.green * 255.);
|
||||
}
|
||||
if (NULL != m_widgetBlue) {
|
||||
m_widgetBlue->SetValue(m_currentColor.blue * 255.);
|
||||
}
|
||||
if (NULL != m_widgetAlpha) {
|
||||
m_widgetAlpha->SetValue(m_currentColor.alpha * 255.);
|
||||
}
|
||||
if (NULL != m_widgetColorBar) {
|
||||
m_widgetColorBar->SetCurrentColor(m_currentColor);
|
||||
}
|
||||
m_widgetTitle->SetLabel(label);
|
||||
}
|
||||
|
||||
void ewol::ColorChooser::SetValidateLabel(etk::UString label)
|
||||
{
|
||||
if (NULL == m_widgetValidate) {
|
||||
return;
|
||||
}
|
||||
m_widgetValidate->SetLabel(label);
|
||||
}
|
||||
|
||||
void ewol::ColorChooser::SetCancelLabel(etk::UString label)
|
||||
color_ts ewol::ColorChooser::GetColor(void)
|
||||
{
|
||||
if (NULL == m_widgetCancel) {
|
||||
return;
|
||||
}
|
||||
m_widgetCancel->SetLabel(label);
|
||||
}
|
||||
|
||||
void ewol::ColorChooser::SetFolder(etk::UString folder)
|
||||
{
|
||||
m_folder = folder;
|
||||
UpdateCurrentFolder();
|
||||
}
|
||||
|
||||
void ewol::ColorChooser::SetFileName(etk::UString filename)
|
||||
{
|
||||
m_file = filename;
|
||||
if (NULL == m_widgetCurrentFileName) {
|
||||
return;
|
||||
}
|
||||
m_widgetCurrentFileName->SetValue(filename);
|
||||
return m_currentColor;
|
||||
}
|
||||
|
||||
|
||||
@ -211,136 +148,35 @@ void ewol::ColorChooser::SetFileName(etk::UString filename)
|
||||
*/
|
||||
void ewol::ColorChooser::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
EWOL_INFO("Receive Event from the LIST ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
if (ewolEventFileChooserEntryFolder == eventId) {
|
||||
//==> change the folder name
|
||||
// TODO : Change the folder, if it exit ...
|
||||
return;
|
||||
} else if (ewolEventFileChooserEntryFile == eventId) {
|
||||
//==> change the file name
|
||||
if (NULL != m_widgetCurrentFileName) {
|
||||
m_file = m_widgetCurrentFileName->GetValue();
|
||||
}
|
||||
// TODO : Remove file selection
|
||||
return;
|
||||
} else if (ewolEventFileChooserCancel == eventId) {
|
||||
//==> Auto remove ...
|
||||
GenerateEventId(eventId);
|
||||
MarkToRemove();
|
||||
return;
|
||||
} else if (ewolEventFileChooserHidenFileChange == eventId) {
|
||||
// regenerate the display ...
|
||||
UpdateCurrentFolder();
|
||||
return;
|
||||
} else if (ewolEventFileChooserSelectFolder == eventId) {
|
||||
//==> this is an internal event ...
|
||||
FileChooserFolderList * myListFolder = static_cast<FileChooserFolderList *>(m_widgetListFolder);
|
||||
etk::UString tmpString = myListFolder->GetSelectedLine();
|
||||
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << tmpString << "\"");
|
||||
m_folder = m_folder + tmpString;
|
||||
char buf[MAX_FILE_NAME];
|
||||
memset(buf, 0, MAX_FILE_NAME);
|
||||
char * ok;
|
||||
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
|
||||
//EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
if (eventColorBarHasChange == eventId) {
|
||||
//==> colorBar has change ...
|
||||
|
||||
ok = realpath(m_folder.Utf8Data(), buf);
|
||||
if (!ok) {
|
||||
EWOL_ERROR("Error to get the real path");
|
||||
m_folder = "/";
|
||||
} else {
|
||||
m_folder = buf;
|
||||
if (NULL != m_widgetColorBar) {
|
||||
m_currentColor = m_widgetColorBar->GetCurrentColor();
|
||||
}
|
||||
if (m_folder != "/" ) {
|
||||
m_folder += "/";
|
||||
if (NULL != m_widgetRed) {
|
||||
m_widgetRed->SetValue(m_currentColor.red * 255.);
|
||||
}
|
||||
SetFileName("");
|
||||
UpdateCurrentFolder();
|
||||
m_hasSelectedFile = false;
|
||||
if (NULL != m_widgetGreen) {
|
||||
m_widgetGreen->SetValue(m_currentColor.green * 255.);
|
||||
}
|
||||
if (NULL != m_widgetBlue) {
|
||||
m_widgetBlue->SetValue(m_currentColor.blue * 255.);
|
||||
}
|
||||
if (NULL != m_widgetAlpha) {
|
||||
m_widgetAlpha->SetValue(m_currentColor.alpha * 255.);
|
||||
}
|
||||
GenerateEventId(ewolEventColorChooserChange);
|
||||
return;
|
||||
} else if (ewolEventFileChooserSelectFile == eventId) {
|
||||
m_hasSelectedFile = true;
|
||||
FileChooserFileList * myListFile = static_cast<FileChooserFileList *>(m_widgetListFile);
|
||||
etk::UString file = myListFile->GetSelectedLine();
|
||||
SetFileName(file);
|
||||
GenerateEventId(eventId);
|
||||
} else if( ewolEventFileChooserValidateFile == eventId
|
||||
|| (ewolEventFileChooserValidate == eventId && true == m_hasSelectedFile) ) {
|
||||
// select the File ==> generate a validate
|
||||
GenerateEventId(ewolEventFileChooserValidate);
|
||||
MarkToRemove();
|
||||
} else if (eventColorSpecificHasChange == eventId) {
|
||||
//==> Entry has change ...
|
||||
return;
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void ewol::ColorChooser::UpdateCurrentFolder(void)
|
||||
{
|
||||
if (NULL == m_widgetListFile) {
|
||||
return;
|
||||
}
|
||||
if (NULL == m_widgetListFolder) {
|
||||
return;
|
||||
}
|
||||
FileChooserFileList * myListFile = static_cast<FileChooserFileList *>(m_widgetListFile);
|
||||
FileChooserFolderList * myListFolder = static_cast<FileChooserFolderList *>(m_widgetListFolder);
|
||||
|
||||
myListFile->ClearElements();
|
||||
myListFolder->ClearElements();
|
||||
bool ShowHidenFile = true;
|
||||
if (NULL != m_widgetCheckBox) {
|
||||
ShowHidenFile = m_widgetCheckBox->GetValue();
|
||||
} else {
|
||||
EWOL_ERROR("Can not get the hiden property of the file choozer...");
|
||||
}
|
||||
|
||||
if (NULL != m_widgetCurrentFolder) {
|
||||
m_widgetCurrentFolder->SetValue(m_folder);
|
||||
}
|
||||
myListFolder->AddElement(etk::UString("."));
|
||||
if (m_folder != "/" ) {
|
||||
myListFolder->AddElement(etk::UString(".."));
|
||||
}
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
dir = opendir(m_folder.Utf8Data());
|
||||
if (dir != NULL) {
|
||||
// for each element in the drectory...
|
||||
while ((ent = readdir(dir)) != NULL) {
|
||||
etk::UString tmpString(ent->d_name);
|
||||
if (DT_REG == ent->d_type) {
|
||||
if (false == tmpString.StartWith(".") || true==ShowHidenFile) {
|
||||
myListFile->AddElement(tmpString);
|
||||
}
|
||||
} else if (DT_DIR == ent->d_type) {
|
||||
//EWOL_DEBUG(" find Folder : \"" << tmpString << "\"(" << tmpString.Size() << ") ?= \"" << ent->d_name << "\"(" << strlen(ent->d_name) );
|
||||
if (tmpString != "." && tmpString != "..") {
|
||||
if (false == tmpString.StartWith(".") || true==ShowHidenFile) {
|
||||
myListFolder->AddElement(tmpString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
} else {
|
||||
EWOL_ERROR("could not open directory : \"" << m_folder << "\"");
|
||||
}
|
||||
myListFile->EndGenerating();
|
||||
myListFolder->EndGenerating();
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
etk::UString ewol::ColorChooser::GetCompleateFileName(void)
|
||||
{
|
||||
etk::UString tmpString = m_folder;
|
||||
tmpString += "/";
|
||||
tmpString += m_file;
|
||||
return tmpString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
@ -350,38 +186,26 @@ etk::UString ewol::ColorChooser::GetCompleateFileName(void)
|
||||
void ewol::ColorChooser::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
// First step call parrent :
|
||||
ewol::PopUp::OnObjectRemove(removeObject);
|
||||
ewol::SizerVert::OnObjectRemove(removeObject);
|
||||
// second step find if in all the elements ...
|
||||
if(removeObject == m_widgetTitle) {
|
||||
m_widgetTitle = NULL;
|
||||
if(removeObject == m_widgetRed) {
|
||||
m_widgetRed = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetValidate) {
|
||||
m_widgetValidate = NULL;
|
||||
if(removeObject == m_widgetGreen) {
|
||||
m_widgetGreen = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetCancel) {
|
||||
m_widgetCancel = NULL;
|
||||
if(removeObject == m_widgetBlue) {
|
||||
m_widgetBlue = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetCurrentFolder) {
|
||||
m_widgetCurrentFolder = NULL;
|
||||
if(removeObject == m_widgetAlpha) {
|
||||
m_widgetAlpha = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetCurrentFileName) {
|
||||
m_widgetCurrentFileName = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetListFolder) {
|
||||
m_widgetListFolder = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetListFile) {
|
||||
m_widgetListFile = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetCheckBox) {
|
||||
m_widgetCheckBox = NULL;
|
||||
if(removeObject == m_widgetColorBar) {
|
||||
m_widgetColorBar = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,9 @@
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/ColorBar.h>
|
||||
#include <ewol/widget/Slider.h>
|
||||
|
||||
extern const char * const ewolEventColorChooserChange;
|
||||
|
||||
@ -60,10 +62,12 @@ namespace ewol {
|
||||
void SetColor(color_ts newColor);
|
||||
color_ts GetColor(void);
|
||||
private:;
|
||||
ewol::Entry* m_widgetColor;
|
||||
ewol::ColorBar* m_widgetColorBar;
|
||||
//ewol::Slider* m_widgetAlpha;
|
||||
//ewol::PreciseColor* m_widgetColorPrecise;
|
||||
ewol::Slider* m_widgetRed;
|
||||
ewol::Slider* m_widgetGreen;
|
||||
ewol::Slider* m_widgetBlue;
|
||||
ewol::Slider* m_widgetAlpha;
|
||||
color_ts m_currentColor;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -33,8 +33,10 @@ FILE_LIST = ewol/ewol.cpp \
|
||||
ewol/widget/PopUp.cpp \
|
||||
ewol/widget/SizerHori.cpp \
|
||||
ewol/widget/SizerVert.cpp \
|
||||
ewol/widget/Slider.cpp \
|
||||
ewol/widget/Spacer.cpp \
|
||||
ewol/widgetMeta/FileChooser.cpp \
|
||||
ewol/widgetMeta/ColorChooser.cpp \
|
||||
ewol/widgetMeta/Keyboard.cpp \
|
||||
ewol/themeManager.cpp \
|
||||
ewol/theme/Theme.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user