first interface availlable for the parameter widget system

This commit is contained in:
Edouard DUPIN 2012-07-18 18:22:28 +02:00
parent 9cad5a5a9b
commit 8ef890bfae
10 changed files with 622 additions and 317 deletions

View File

@ -107,7 +107,7 @@ bool ewol::List::CalculateMinSize(void)
m_minSize.x = 3+minWidth;
m_minSize.y = 3+minHeight;
*/
m_minSize.x = 150;
m_minSize.x = 200;
m_minSize.y = 150;
return true;
}

View File

@ -83,11 +83,7 @@ namespace ewol {
protected:
// function call to display the list :
virtual color_ts GetBasicBG(void) {
color_ts bg;
bg.red = 1.0;
bg.green = 1.0;
bg.blue = 1.0;
bg.alpha = 1.0;
color_ts bg(0xFFFFFFFF);
return bg;
}
virtual uint32_t GetNuberOfColomn(void) {
@ -102,20 +98,12 @@ namespace ewol {
};
virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg) {
myTextToWrite = "";
fg.red = 0.0;
fg.green = 0.0;
fg.blue = 0.0;
fg.alpha = 1.0;
bg = 0xFFFFFFFF;
fg = 0x000000FF;
if (raw % 2) {
bg.red = 1.0;
bg.green = 1.0;
bg.blue = 1.0;
bg.alpha = 1.0;
bg = 0xFFFFFFFF;
} else {
bg.red = 0.5;
bg.green = 0.5;
bg.blue = 0.5;
bg.alpha = 1.0;
bg = 0x7F7F7FFF;
}
return false;
};

View File

@ -30,7 +30,8 @@
#undef __class__
#define __class__ "PopUp"
ewol::PopUp::PopUp(void)
ewol::PopUp::PopUp(void) :
m_subWidgetNext(NULL)
{
m_userExpendX = true;
m_userExpendY = true;
@ -166,11 +167,13 @@ void ewol::PopUp::SetExpendY(bool newExpend)
void ewol::PopUp::SubWidgetSet(ewol::Widget* newWidget)
{
if (NULL == newWidget) {
EWOL_ERROR("Try to set a sub wiget with NULL pointer ...");
return;
}
SubWidgetRemove();
m_subWidget[m_currentCreateId] = newWidget;
m_needFlipFlop = true;
//EWOL_DEBUG("SetSubWidget on Pop-Up : " << (int64_t)m_subWidget[m_currentCreateId]);
MarkToReedraw();
}
@ -251,6 +254,7 @@ ewol::Widget * ewol::PopUp::GetWidgetAtPos(Vector2D<float> pos)
void ewol::PopUp::SetDisplayRatio(float ratio)
{
m_displayRatio = ratio;
MarkToReedraw();
}
@ -266,6 +270,7 @@ void ewol::PopUp::OnFlipFlopEvent(void)
ewol::Widget::OnFlipFlopEvent();
// internal saving
if (true == needFlipFlop) {
//EWOL_VERBOSE("Flip-Flop on Pop-Up : " << (int64_t)m_subWidget[m_currentCreateId] << " <-- " << (int64_t)m_subWidget[m_currentDrawId]);
m_subWidget[m_currentCreateId] = m_subWidget[m_currentDrawId];
}
// in every case, we propagate the flip-flop EVENT

View File

@ -62,6 +62,7 @@ namespace ewol {
color_ts m_colorBackGroung;
color_ts m_colorBorder;
color_ts m_colorEmptyArea;
ewol::Widget* m_subWidgetNext;
ewol::Widget* m_subWidget[NB_BOUBLE_BUFFER];
float m_displayRatio;
public:

View File

@ -93,20 +93,26 @@ bool ewol::WSlider::CalculateSize(float availlableX, float availlableY)
if (m_windowsDestination == m_windowsSources) {
int32_t iii = m_windowsDestination;
if (NULL != m_subWidget[m_currentCreateId][iii]) {
m_subWidget[m_currentCreateId][iii]->SetOrigin(m_origin.x, m_origin.y);
m_subWidget[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y);
if (iii < m_subWidget[m_currentCreateId].Size()) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
m_subWidget[m_currentCreateId][iii]->SetOrigin(m_origin.x, m_origin.y);
m_subWidget[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y);
}
}
} else {
int32_t iii = m_windowsSources;
if (NULL != m_subWidget[m_currentCreateId][iii]) {
m_subWidget[m_currentCreateId][iii]->SetOrigin(m_origin.x - (m_size.x*(float)m_slidingProgress/1000.0), m_origin.y);
m_subWidget[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y);
if (iii < m_subWidget[m_currentCreateId].Size()) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
m_subWidget[m_currentCreateId][iii]->SetOrigin(m_origin.x - (m_size.x*(float)m_slidingProgress/1000.0), m_origin.y);
m_subWidget[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y);
}
}
iii = m_windowsDestination;
if (NULL != m_subWidget[m_currentCreateId][iii]) {
m_subWidget[m_currentCreateId][iii]->SetOrigin(m_origin.x - (m_size.x*((float)m_slidingProgress/1000.0) - m_size.x), m_origin.y);
m_subWidget[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y);
if (iii < m_subWidget[m_currentCreateId].Size()) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
m_subWidget[m_currentCreateId][iii]->SetOrigin(m_origin.x - (m_size.x*((float)m_slidingProgress/1000.0) - m_size.x), m_origin.y);
m_subWidget[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y);
}
}
}
MarkToReedraw();

View File

@ -22,175 +22,134 @@
*******************************************************************************
*/
#include <ewol/widgetMeta/FileChooser.h>
#include <ewol/widgetMeta/Parameter.h>
#include <ewol/widget/SizerHori.h>
#include <ewol/widget/SizerVert.h>
#include <ewol/widget/List.h>
#include <ewol/widget/Spacer.h>
#include <ewol/widget/Image.h>
#include <ewol/WidgetManager.h>
//#include <etk/Vector.h>
#include <etk/VectorType.h>
extern "C" {
// file browsing ...
#include <dirent.h>
}
#undef __class__
#define __class__ "FileChooser(FolderList)"
#include <ewol/ewol.h>
#undef __class__
#define __class__ "FileChooser"
#define __class__ "Parameter"
extern const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel";
extern const char * const ewolEventFileChooserValidate = "ewol-event-file-chooser-validate";
extern const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files";
extern const char * const ewolEventFileChooserEntryFolder = "ewol-event-file-chooser-modify-entry-folder";
extern const char * const ewolEventFileChooserEntryFolderEnter = "ewol-event-file-chooser-modify-entry-folder-enter";
extern const char * const ewolEventFileChooserEntryFile = "ewol-event-file-chooser-modify-entry-file";
extern const char * const ewolEventFileChooserEntryFileEnter = "ewol-event-file-chooser-modify-entry-file-enter";
extern const char * const ewolEventFileChooserListFolder = "ewol-event-file-chooser-modify-list-folder";
extern const char * const ewolEventFileChooserListFile = "ewol-event-file-chooser-modify-list-file";
extern const char * const ewolEventFileChooserListFileValidate = "ewol-event-file-chooser-modify-list-file-validate";
extern const char * const ewolEventFileChooserHome = "ewol-event-file-chooser-home";
extern const char * const ewolEventParameterValidate = "ewol-event-parameter-validate";
extern const char * const ewolEventParameterClose = "ewol-event-parameter-close";
static const char * const l_eventMenuSelected = "local-event-menu-selected";
ewol::FileChooser::FileChooser(void)
ewol::Parameter::Parameter(void) :
m_currentIdList(0),
m_widgetTitle(NULL),
m_widgetCancel(NULL),
m_paramList(NULL)
{
AddEventId(ewolEventFileChooserCancel);
AddEventId(ewolEventFileChooserValidate);
m_widgetTitle = NULL;
m_widgetValidate = NULL;
m_widgetCancel = NULL;
m_widgetCurrentFolder = NULL;
m_widgetCurrentFileName = NULL;
m_widgetListFolder = NULL;
m_widgetListFile = NULL;
m_widgetCheckBox = NULL;
AddEventId(ewolEventParameterClose);
ewol::SizerVert * mySizerVert = NULL;
ewol::SizerHori * mySizerHori = NULL;
ewol::Spacer * mySpacer = NULL;
//ewol::Label * myLabel = NULL;
ewol::Image * myImage = 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();
if (NULL == mySizerVert) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
EWOL_INFO("add widget");
mySizerVert->LockExpendContamination(true);
// set it in the pop-up-system :
// set it in the pop-up-system :
SubWidgetSet(mySizerVert);
m_widgetTitle = new ewol::Label("File chooser ...");
if (NULL == m_widgetTitle) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySizerVert->SubWidgetAdd(m_widgetTitle);
}
mySpacer = new ewol::Spacer();
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
//mySpacer->SetExpendX(true);
//mySpacer->SetSize(10);
mySizerVert->SubWidgetAdd(mySpacer);
}
mySizerHori = new ewol::SizerHori();
if (NULL == mySizerHori) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySizerVert->SubWidgetAdd(mySizerHori);
myImage = new ewol::Image("icon/Folder.svg");
myImage->SetFillY(true);
mySizerHori->SubWidgetAdd(myImage);
m_widgetCurrentFolder = new ewol::Entry(m_folder);
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFolder);
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFolderEnter);
m_widgetCurrentFolder->SetExpendX(true);
m_widgetCurrentFolder->SetFillX(true);
m_widgetCurrentFolder->SetWidth(200);
mySizerHori->SubWidgetAdd(m_widgetCurrentFolder);
myImage = new ewol::Image("icon/Home.svg");
myImage->RegisterOnEvent(this, ewolEventImagePressed, ewolEventFileChooserHome);
myImage->SetFillY(true);
mySizerHori->SubWidgetAdd(myImage);
mySizerHori = new ewol::SizerHori();
mySizerVert->SubWidgetAdd(mySizerHori);
myImage = new ewol::Image("icon/File.svg");
myImage->SetFillY(true);
mySizerHori->SubWidgetAdd(myImage);
m_widgetCurrentFileName = new ewol::Entry(m_file);
m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFile);
m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFileEnter);
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);
m_widgetListFolder = new ListFileSystem();
m_widgetListFolder->SetShowFolder(true);
m_widgetListFolder->SetShowFiles(false);
m_widgetListFolder->SetShowHiddenFiles(false);
m_widgetListFolder->RegisterOnEvent(this, ewolEventFSFolderValidate, ewolEventFileChooserListFolder);
m_widgetListFolder->SetExpendY(true);
m_widgetListFolder->SetFillY(true);
mySizerHori->SubWidgetAdd(m_widgetListFolder);
mySpacer = new ewol::Spacer();
mySpacer->SetSize(2);
mySizerHori->SubWidgetAdd(mySpacer);
m_widgetListFile = new ListFileSystem();
m_widgetListFile->SetShowFolder(false);
m_widgetListFile->SetShowFiles(true);
m_widgetListFile->SetShowHiddenFiles(false);
m_widgetListFile->RegisterOnEvent(this, ewolEventFSFileSelect, ewolEventFileChooserListFile);
m_widgetListFile->RegisterOnEvent(this, ewolEventFSFileValidate, ewolEventFileChooserListFileValidate);
m_widgetListFile->SetExpendX(true);
m_widgetListFile->SetFillX(true);
m_widgetListFile->SetExpendY(true);
m_widgetListFile->SetFillY(true);
mySizerHori->SubWidgetAdd(m_widgetListFile);
mySpacer = new ewol::Spacer();
mySpacer->SetSize(2);
mySizerHori->SubWidgetAdd(mySpacer);
m_paramList = new ewol::ParameterList();
if (NULL == m_paramList) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
m_paramList->RegisterOnEvent(this, ewolEventParameterListSelect, l_eventMenuSelected);
m_paramList->SetFillY(true);
m_paramList->SetExpendY(true);
mySizerHori->SubWidgetAdd(m_paramList);
}
m_wSlider = new ewol::WSlider();
if (NULL == m_wSlider) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
m_wSlider->SetExpendX(true);
m_wSlider->SetExpendY(true);
mySizerHori->SubWidgetAdd(m_wSlider);
}
}
mySizerHori = new ewol::SizerHori();
if (NULL == mySizerHori) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
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();
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpendX(true);
mySizerHori->SubWidgetAdd(mySpacer);
m_widgetValidate = new ewol::Button("Validate");
m_widgetValidate->SetImage("icon/Load.svg");
m_widgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserValidate);
mySizerHori->SubWidgetAdd(m_widgetValidate);
m_widgetCancel = new ewol::Button("Cancel");
}
m_widgetCancel = new ewol::Button("Close");
if (NULL == m_widgetCancel) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
m_widgetCancel->SetImage("icon/Remove.svg");
m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel);
m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventParameterClose);
mySizerHori->SubWidgetAdd(m_widgetCancel);
// set the default Folder properties:
UpdateCurrentFolder();
}
}
}
MarkToReedraw();
//m_needFlipFlop = true;
}
ewol::FileChooser::~FileChooser(void)
ewol::Parameter::~Parameter(void)
{
}
//!< EObject name :
extern const char * const ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER = "FileChooser";
extern const char * const ewol::TYPE_EOBJECT_WIDGET_PARAMETER = "Parameter";
/**
* @brief Check if the object has the specific type.
@ -198,19 +157,19 @@ extern const char * const ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER = "FileChooser"
* @param[in] objectType type of the object we want to check
* @return true if the object is compatible, otherwise false
*/
bool ewol::FileChooser::CheckObjectType(const char * const objectType)
bool ewol::Parameter::CheckObjectType(const char * const objectType)
{
if (NULL == objectType) {
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER << "\" != NULL(pointer) ");
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_PARAMETER << "\" != NULL(pointer) ");
return false;
}
if (objectType == ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER) {
if (objectType == ewol::TYPE_EOBJECT_WIDGET_PARAMETER) {
return true;
} else {
if(true == ewol::PopUp::CheckObjectType(objectType)) {
return true;
}
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER << "\" != \"" << objectType << "\"");
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_PARAMETER << "\" != \"" << objectType << "\"");
return false;
}
}
@ -221,14 +180,14 @@ bool ewol::FileChooser::CheckObjectType(const char * const objectType)
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const ewol::FileChooser::GetObjectType(void)
const char * const ewol::Parameter::GetObjectType(void)
{
return ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER;
return ewol::TYPE_EOBJECT_WIDGET_PARAMETER;
}
void ewol::FileChooser::SetTitle(etk::UString label)
void ewol::Parameter::SetTitle(etk::UString label)
{
if (NULL == m_widgetTitle) {
return;
@ -236,37 +195,6 @@ void ewol::FileChooser::SetTitle(etk::UString label)
m_widgetTitle->SetLabel(label);
}
void ewol::FileChooser::SetValidateLabel(etk::UString label)
{
if (NULL == m_widgetValidate) {
return;
}
m_widgetValidate->SetLabel(label);
}
void ewol::FileChooser::SetCancelLabel(etk::UString label)
{
if (NULL == m_widgetCancel) {
return;
}
m_widgetCancel->SetLabel(label);
}
void ewol::FileChooser::SetFolder(etk::UString folder)
{
m_folder = folder + "/";
UpdateCurrentFolder();
}
void ewol::FileChooser::SetFileName(etk::UString filename)
{
m_file = filename;
if (NULL == m_widgetCurrentFileName) {
return;
}
m_widgetCurrentFileName->SetValue(filename);
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
@ -275,126 +203,33 @@ void ewol::FileChooser::SetFileName(etk::UString filename)
* @param[in] data Data registered by this class
* @return ---
*/
void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
void ewol::Parameter::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 ...
} else if (ewolEventFileChooserEntryFile == eventId) {
//==> change the file name
m_file = data;
// Update the selected file in the list :
if (m_widgetListFile != NULL) {
m_widgetListFile->SetSelect(m_file);
}
} else if (ewolEventFileChooserCancel == eventId) {
//==> Auto remove ...
GenerateEventId(eventId);
ewol::PopUp::OnReceiveMessage(CallerObject, eventId, data);
EWOL_DEBUG("event on the parameter : " << eventId << " data=\"" << data << "\"");
if (eventId == ewolEventParameterClose) {
// inform that the parameter windows is closed
GenerateEventId(ewolEventParameterClose);
// Close this widget ...
MarkToRemove();
} else if (ewolEventFileChooserHidenFileChange == eventId) {
if (data == "true") {
if (NULL!=m_widgetListFolder) {
m_widgetListFolder->SetShowHiddenFiles(true);
}
if (NULL!=m_widgetListFile) {
m_widgetListFile->SetShowHiddenFiles(true);
}
} else {
if (NULL!=m_widgetListFolder) {
m_widgetListFolder->SetShowHiddenFiles(false);
}
if (NULL!=m_widgetListFile) {
m_widgetListFile->SetShowHiddenFiles(false);
}
} else if (eventId == l_eventMenuSelected) {
if (NULL != m_wSlider) {
m_wSlider->SubWidgetSelectSet(1);
}
} else if (ewolEventFileChooserListFolder == eventId) {
//==> this is an internal event ...
EWOL_VERBOSE(" old PATH : \"" << m_folder << "\" + \"" << data << "\"");
m_folder = m_folder + data;
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
char * ok;
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
ok = realpath(m_folder.Utf8Data(), buf);
if (!ok) {
EWOL_ERROR("Error to get the real path");
m_folder = "/";
} else {
m_folder = buf;
}
if (m_folder != "/" ) {
m_folder += "/";
}
SetFileName("");
UpdateCurrentFolder();
} else if (ewolEventFileChooserListFile == eventId) {
SetFileName(data);
GenerateEventId(eventId);
} else if( eventId == ewolEventFileChooserListFileValidate
|| (eventId == ewolEventFileChooserValidate && m_file != "" )
|| (eventId == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) {
// select the File ==> generate a validate
SetFileName(data);
GenerateEventId(ewolEventFileChooserValidate);
MarkToRemove();
} else if(ewolEventFileChooserHome == eventId) {
etk::UString tmpUserFolder = etk::GetUserHomeFolder();
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
char * ok;
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");
ok = realpath(tmpUserFolder.Utf8Data(), buf);
if (!ok) {
EWOL_ERROR("Error to get the real path");
m_folder = "/";
} else {
m_folder = buf;
}
if (m_folder != "/" ) {
m_folder += "/";
}
SetFileName("");
UpdateCurrentFolder();
}
return;
};
void ewol::FileChooser::UpdateCurrentFolder(void)
{
if (NULL != m_widgetListFile) {
m_widgetListFile->SetFolder(m_folder);
}
if (NULL != m_widgetListFolder) {
m_widgetListFolder->SetFolder(m_folder);
}
if (NULL != m_widgetCurrentFolder) {
m_widgetCurrentFolder->SetValue(m_folder);
}
MarkToReedraw();
}
etk::UString ewol::FileChooser::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
* @note : Sub classes must call this class
* @return ---
*/
void ewol::FileChooser::OnObjectRemove(ewol::EObject * removeObject)
void ewol::Parameter::OnObjectRemove(ewol::EObject * removeObject)
{
// First step call parrent :
ewol::PopUp::OnObjectRemove(removeObject);
@ -403,33 +238,56 @@ void ewol::FileChooser::OnObjectRemove(ewol::EObject * removeObject)
m_widgetTitle = NULL;
m_needFlipFlop = true;
}
if(removeObject == m_widgetValidate) {
m_widgetValidate = NULL;
if(removeObject == m_paramList) {
m_paramList = NULL;
m_needFlipFlop = true;
}
if(removeObject == m_widgetCancel) {
m_widgetCancel = NULL;
m_needFlipFlop = true;
}
if(removeObject == m_widgetCurrentFolder) {
m_widgetCurrentFolder = 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_wSlider) {
m_wSlider = NULL;
m_needFlipFlop = true;
}
}
void ewol::Parameter::MenuAdd(etk::UString label, etk::UString image, ewol::Widget* associateWidget)
{
if (NULL != m_paramList) {
m_paramList->MenuAdd(label, m_currentIdList, image);
if (NULL != m_wSlider) {
if (NULL != associateWidget) {
m_wSlider->SubWidgetAdd(associateWidget);
} else {
ewol::Label * myLabel = new ewol::Label((etk::UString("No widget set ... ") + m_currentIdList));
if (NULL == myLabel) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
m_wSlider->SubWidgetAdd(myLabel);
}
}
if (m_currentIdList == 0) {
m_wSlider->SubWidgetSelectSet(0);
}
}
m_currentIdList++;
}
}
void ewol::Parameter::MenuClear(void)
{
if (NULL != m_paramList) {
m_paramList->MenuClear();
m_currentIdList = 0;
}
}
void ewol::Parameter::MenuSeparator(void)
{
if (NULL != m_paramList) {
m_paramList->MenuSeparator();
}
}

View File

@ -22,18 +22,21 @@
*******************************************************************************
*/
#ifndef __EWOL_FILE_CHOOSER_H__
#define __EWOL_FILE_CHOOSER_H__
#ifndef __EWOL_WIDGET_PARAMETER_H__
#define __EWOL_WIDGET_PARAMETER_H__
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/Debug.h>
#include <ewol/widget/PopUp.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/WSlider.h>
#include <ewol/widgetMeta/ParameterList.h>
extern const char * const ewolEventParameterSelection;
extern const char * const ewolEventParameterClose;
namespace ewol {
class Parameter : public ewol::PopUp
@ -72,21 +75,22 @@ namespace ewol {
*/
virtual void OnObjectRemove(ewol::EObject * removeObject);
void MenuAdd(etk::UString label, etk::UString ref, etk::String image);
void MenuRm(etk::UString ref);
void SetTitle(etk::UString label);
void MenuAdd(etk::UString label, etk::UString image, ewol::Widget* associateWidget);
void MenuClear(void);
void MenuSeparator(void);
void MenuGroup(etk::UString title, etk::UString image);
void MenuGroupEnd(void);
void SetSubWidget(ewol::Widget* newWidget);
private:
int32_t m_currentIdList;
ewol::Label* m_widgetTitle;
ewol::Button* m_widgetCancel;
ewol::ParameterList* m_paramList;
ewol::WSlider* m_wSlider;
};
extern const char * const TYPE_EOBJECT_WIDGET_FILE_CHOOSER;
extern const char * const TYPE_EOBJECT_WIDGET_PARAMETER;
};
#define EWOL_CAST_WIDGET_FILE_CHOOSER(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER,ewol::FileChooser,curentPointer)
#define EWOL_CAST_WIDGET_PARAMETER(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_PARAMETER,ewol::Parameter,curentPointer)
#endif

View File

@ -0,0 +1,322 @@
/**
*******************************************************************************
* @file ewol/widget/ListFile.cpp
* @brief ewol File lister widget system (Sources)
* @author Edouard DUPIN
* @date 12/07/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/widgetMeta/ParameterList.h>
#include <etk/tool.h>
#undef __class__
#define __class__ "ParameterList"
extern const char * const ewolEventParameterListSelect = "ewol-event-parameter-list-select";
//!< EObject name :
extern const char * const ewol::TYPE_EOBJECT_WIDGET_PARAMETER_LIST = "ParameterList";
#include <ewol/widget/List.h>
#include <ewol/OObject.h>
#include <ewol/WidgetManager.h>
#undef __class__
#define __class__ "List"
ewol::ParameterList::ParameterList(void)
{
AddEventId(ewolEventParameterListSelect);
m_idSelected = -1;
m_paddingSizeX = 2;
#ifdef __PLATFORM__Android
m_paddingSizeY = 10;
#else
m_paddingSizeY = 2;
#endif
SetCanHaveFocus(true);
}
ewol::ParameterList::~ParameterList(void)
{
//clean all the object
for (int32_t jjj=0; jjj<NB_BOUBLE_BUFFER; jjj++) {
for (int32_t iii=0; iii<m_listOObject[jjj].Size(); iii++) {
delete(m_listOObject[jjj][iii]);
m_listOObject[jjj][iii] = NULL;
}
m_listOObject[jjj].Clear();
}
MenuClear();
}
/**
* @brief Check if the object has the specific type.
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type of the object we want to check
* @return true if the object is compatible, otherwise false
*/
bool ewol::ParameterList::CheckObjectType(const char * const objectType)
{
if (NULL == objectType) {
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_PARAMETER_LIST << "\" != NULL(pointer) ");
return false;
}
if (objectType == ewol::TYPE_EOBJECT_WIDGET_PARAMETER_LIST) {
return true;
} else {
if(true == ewol::WidgetScrooled::CheckObjectType(objectType)) {
return true;
}
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_PARAMETER_LIST << "\" != \"" << objectType << "\"");
return false;
}
}
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
const char * const ewol::ParameterList::GetObjectType(void)
{
return ewol::TYPE_EOBJECT_WIDGET_PARAMETER_LIST;
}
bool ewol::ParameterList::CalculateMinSize(void)
{
/*int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
m_minSize.x = 3+minWidth;
m_minSize.y = 3+minHeight;
*/
m_minSize.x = 150;
m_minSize.y = 150;
return true;
}
void ewol::ParameterList::AddOObject(ewol::OObject* 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[m_currentCreateId].Size() ) {
m_listOObject[m_currentCreateId].PushBack(newObject);
} else {
m_listOObject[m_currentCreateId].Insert(pos, newObject);
}
m_needFlipFlop = true;
}
void ewol::ParameterList::ClearOObjectList(void)
{
for (int32_t iii=0; iii<m_listOObject[m_currentCreateId].Size(); iii++) {
delete(m_listOObject[m_currentCreateId][iii]);
m_listOObject[m_currentCreateId][iii] = NULL;
}
m_listOObject[m_currentCreateId].Clear();
}
void ewol::ParameterList::OnDraw(void)
{
for (int32_t iii=0; iii<m_listOObject[m_currentDrawId].Size(); iii++) {
if (NULL != m_listOObject[m_currentDrawId][iii]) {
m_listOObject[m_currentDrawId][iii]->Draw();
}
}
WidgetScrooled::OnDraw();
}
void ewol::ParameterList::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
// clean the object list ...
ClearOObjectList();
//EWOL_DEBUG("OnRegenerateDisplay(" << m_size.x << "," << m_size.y << ")");
int32_t tmpOriginX = 0;
int32_t tmpOriginY = 0;
/*
if (true==m_userFillX) {
tmpOriginX = 0;
}
if (true==m_userFillY) {
tmpOriginY = 0;
}*/
tmpOriginX += m_paddingSizeX;
tmpOriginY += m_paddingSizeY;
int32_t fontId = GetDefaultFontId();
//int32_t minWidth = ewol::GetWidth(fontId, m_label);
int32_t minHeight = ewol::GetHeight(fontId);
//uint32_t nbColomn = GetNuberOfColomn();
int32_t nbRaw = m_list.Size();
// For the scrooling windows
m_maxSize.x = m_size.x;
m_maxSize.y = (minHeight + 2*m_paddingSizeY) * nbRaw;
etk::VectorType<int32_t> listSizeColomn;
// set background color :
ewol::OObject2DColored * BGOObjects = new ewol::OObject2DColored();
BGOObjects->SetColor(0xFFFFFFFF);
BGOObjects->Rectangle(0, 0, m_size.x, m_size.y);
uint32_t displayableRaw = m_size.y / (minHeight + 2*m_paddingSizeY) +2;
int32_t startRaw = m_originScrooled.y / (minHeight + 2*m_paddingSizeY);
if (startRaw >= nbRaw-1 ) {
startRaw = nbRaw - 1;
}
if (startRaw<0) {
startRaw = 0;
}
// Calculate the real position ...
tmpOriginY = -m_originScrooled.y + startRaw*(minHeight + 2*m_paddingSizeY);
clipping_ts drawClipping;
drawClipping.x = 0;
drawClipping.y = 0;
drawClipping.w = m_size.x - (2*m_paddingSizeX);
drawClipping.h = m_size.y;
for(int32_t iii=startRaw; iii<nbRaw && iii<(startRaw+displayableRaw); iii++) {
etk::UString myTextToWrite = "???";
color_ts fg(0x000000FF);
if (m_list[iii] != NULL) {
myTextToWrite = m_list[iii]->m_label;
}
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg);
Vector2D<float> textPos;
textPos.x = (int32_t)tmpOriginX;
textPos.y = (int32_t)(tmpOriginY + m_paddingSizeY);
tmpText->Text(textPos, drawClipping, myTextToWrite);
AddOObject(tmpText);
tmpOriginY += minHeight + 2* m_paddingSizeY;
}
AddOObject(BGOObjects, 0);
// call the herited class...
WidgetScrooled::OnRegenerateDisplay();
m_needFlipFlop = true;
}
}
/**
* @brief Event on an input of this Widget
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Absolute position of the event
* @return true the event is used
* @return false the event is not used
*/
bool ewol::ParameterList::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, Vector2D<float> pos)
{
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widet ...
return true;
}
if (IdInput == 1 && typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
Vector2D<float> relativePos = RelativePosition(pos);
int32_t fontId = GetDefaultFontId();
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t minHeight = ewol::GetHeight(fontId);
int32_t rawID = (relativePos.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
// generate an event on a rawId if the element request change and Select it ...
if (rawID >=0 && rawID<m_list.Size()) {
if (m_list[rawID]!=NULL) {
if (m_list[rawID]->m_refId>=0) {
GenerateEventId(ewolEventParameterListSelect, m_list[rawID]->m_refId);
m_idSelected = rawID;
MarkToReedraw();
return true;
}
}
}
}
return false;
}
void ewol::ParameterList::OnGetFocus(void)
{
EWOL_DEBUG("Ewol::List Get Focus");
}
void ewol::ParameterList::OnLostFocus(void)
{
EWOL_DEBUG("Ewol::List Lost Focus");
}
void ewol::ParameterList::MenuAdd(etk::UString& label, int32_t refId, etk::UString& image)
{
ewol::elementPL* tmpEmement = new ewol::elementPL(label, refId, image);
if (NULL != tmpEmement) {
m_list.PushBack(tmpEmement);
if (m_idSelected == -1 && label != "---" && refId>0) {
m_idSelected = m_list.Size()-1;
}
MarkToReedraw();
}
}
void ewol::ParameterList::MenuClear(void)
{
m_idSelected = -1;
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (NULL != m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
}
}
}
void ewol::ParameterList::MenuSeparator(void)
{
etk::UString label = "---";
etk::UString image = "";
MenuAdd(label, -1, image);
}

View File

@ -0,0 +1,119 @@
/**
*******************************************************************************
* @file ewol/widget/ListFile.h
* @brief ewol File lister widget system (header)
* @author Edouard DUPIN
* @date 12/07/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_WIDGET_PARAMETER_LIST_H__
#define __EWOL_WIDGET_PARAMETER_LIST_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/widget/Drawable.h>
extern const char * const ewolEventParameterListSelect;
namespace ewol {
extern const char * const TYPE_EOBJECT_WIDGET_PARAMETER_LIST;
class elementPL
{
public :
etk::UString m_label;
int32_t m_refId;
etk::UString m_image;
elementPL(etk::UString& label, int32_t refId, etk::UString& image) :
m_label(label),
m_refId(refId),
m_image(image)
{ };
~elementPL(void) {};
};
class ParameterList :public ewol::WidgetScrooled
{
private:
int32_t m_idSelected;
etk::VectorType<ewol::elementPL *> m_list;
public:
ParameterList(void);
/**
* @brief Check if the object has the specific type.
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type of the object we want to check
* @return true if the object is compatible, otherwise false
*/
virtual bool CheckObjectType(const char * const objectType);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
* @param[in] objectType type description
* @return true if the object is compatible, otherwise false
*/
virtual const char * const GetObjectType(void);
virtual ~ParameterList(void);
virtual bool CalculateMinSize(void);
void SetLabel(etk::UString newLabel);
// Drawing capabilities ....
private:
etk::VectorType<ewol::OObject*> m_listOObject[NB_BOUBLE_BUFFER]; //!< generic element to display...
public:
void AddOObject(ewol::OObject* newObject, int32_t pos=-1);
void ClearOObjectList(void);
protected:
void OnDraw(void);
// list properties ...
private:
int32_t m_paddingSizeX;
int32_t m_paddingSizeY;
int32_t m_displayStartRaw; //!< Current starting diaplayed raw
int32_t m_displayCurrentNbLine; //!< Number of line in the display
public:
void OnRegenerateDisplay(void);
/**
* @brief Event on an input of this Widget
* @param[in] type Type of the input (ewol::INPUT_TYPE_MOUSE/ewol::INPUT_TYPE_FINGER ...)
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Absolute position of the event
* @return true the event is used
* @return false the event is not used
*/
bool OnEventInput(ewol::inputType_te type, int32_t IdInput, eventInputType_te typeEvent, Vector2D<float> pos);
protected:
void OnGetFocus(void);
void OnLostFocus(void);
public:
void MenuAdd(etk::UString& label, int32_t refId, etk::UString& image);
void MenuRm(etk::UString& ref);
void MenuClear(void);
void MenuSeparator(void);
};
};
#define EWOL_CAST_WIDGET_PARAMETER_LIST(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_PARAMETER_LIST,ParameterList,curentPointer)
#endif

View File

@ -53,6 +53,8 @@ FILE_LIST = ewol/ewol.cpp \
ewol/widget/WidgetScrolled.cpp \
ewol/widgetMeta/FileChooser.cpp \
ewol/widgetMeta/ColorChooser.cpp \
ewol/widgetMeta/Parameter.cpp \
ewol/widgetMeta/ParameterList.cpp \
ewol/theme/Theme.cpp \
ewol/Audio/audio.cpp \
ewol/Audio/decWav.cpp