Start coding of the color selector
This commit is contained in:
parent
81075dff9c
commit
19ead2de2c
216
Sources/libewol/ewol/widget/ColorBar.cpp
Normal file
216
Sources/libewol/ewol/widget/ColorBar.cpp
Normal file
@ -0,0 +1,216 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/ColorBar.cpp
|
||||
* @brief ewol ColorBar widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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/ColorBar.h>
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
|
||||
|
||||
extern const char * const ewolEventColorBarChange = "ewol-color-bar-change";
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ColorBar"
|
||||
|
||||
ewol::ColorBar::ColorBar(void)
|
||||
{
|
||||
AddEventId(ewolEventColorBarChange);
|
||||
|
||||
#ifdef __PLATFORM__Android
|
||||
m_padding.y = 12;
|
||||
m_padding.x = 12;
|
||||
#else
|
||||
m_padding.y = 4;
|
||||
m_padding.x = 4;
|
||||
#endif
|
||||
m_currentUserPos.x=0;
|
||||
m_currentUserPos.y=0;
|
||||
m_currentColor.red = 0.0;
|
||||
m_currentColor.green = 0.0;
|
||||
m_currentColor.blue = 0.0;
|
||||
m_currentColor.alpha = 1.0;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
ewol::ColorBar::~ColorBar(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ewol::ColorBar::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 80;
|
||||
m_minSize.y = 80;
|
||||
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 } }
|
||||
};
|
||||
|
||||
color_ts ewol::ColorBar::GetCurrentColor(void)
|
||||
{
|
||||
return m_currentColor;
|
||||
}
|
||||
void ewol::ColorBar::SetCurrentColor(color_ts newOne)
|
||||
{
|
||||
m_currentColor = newOne;
|
||||
m_currentColor.alpha = 1.0;
|
||||
}
|
||||
|
||||
void ewol::ColorBar::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
|
||||
int32_t tmpSizeX = m_minSize.x;
|
||||
int32_t tmpSizeY = m_minSize.y;
|
||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||
|
||||
if (true==m_userFillX) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
}
|
||||
if (true==m_userFillY) {
|
||||
tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
}
|
||||
tmpOriginX += m_padding.x;
|
||||
tmpOriginY += m_padding.y;
|
||||
tmpSizeX -= 2*m_padding.x;
|
||||
tmpSizeY -= 2*m_padding.y;
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
|
||||
tmpOriginX -= m_padding.x/2;
|
||||
tmpOriginY -= m_padding.y/2;
|
||||
tmpSizeX += m_padding.x;
|
||||
tmpSizeY += m_padding.y;
|
||||
|
||||
for(int32_t iii=0; iii<6 ; iii++) {
|
||||
|
||||
/* Step 1 :
|
||||
*
|
||||
* **
|
||||
* ****
|
||||
* ******
|
||||
* ********
|
||||
*/
|
||||
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);
|
||||
|
||||
/* Step 2 :
|
||||
* ********
|
||||
* ******
|
||||
* ****
|
||||
* **
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
/* Step 3 :
|
||||
*
|
||||
* **
|
||||
* ****
|
||||
* ******
|
||||
* ********
|
||||
*/
|
||||
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);
|
||||
|
||||
/* Step 4 :
|
||||
* ********
|
||||
* ******
|
||||
* ****
|
||||
* **
|
||||
*
|
||||
*/
|
||||
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->Rectangle( tmpOriginX + iii*(tmpSizeX/7), tmpOriginY, tmpSizeX/7, tmpSizeY);
|
||||
}
|
||||
color_ts tmpColor;
|
||||
tmpColor.red = 0.5;
|
||||
tmpColor.green = 0.5;
|
||||
tmpColor.blue = 0.5;
|
||||
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);
|
||||
|
||||
AddOObject(tmpOObjects);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ewol::ColorBar::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
|
||||
{
|
||||
//EWOL_DEBUG("Event on BT ...");
|
||||
if (1 == IdInput) {
|
||||
if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|
||||
|| ewol::EVENT_INPUT_TYPE_TRIPLE == 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;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
54
Sources/libewol/ewol/widget/ColorBar.h
Normal file
54
Sources/libewol/ewol/widget/ColorBar.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/ColorBar.h
|
||||
* @brief ewol ColorBar widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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_COLORBAR_H__
|
||||
#define __EWOL_COLORBAR_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/widget/Drawable.h>
|
||||
|
||||
extern const char * const ewolEventColorBarChange;
|
||||
|
||||
namespace ewol {
|
||||
class ColorBar :public ewol::Drawable
|
||||
{
|
||||
public:
|
||||
ColorBar(void);
|
||||
virtual ~ColorBar(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
color_ts GetCurrentColor(void);
|
||||
void SetCurrentColor(color_ts newOne);
|
||||
private:
|
||||
color_ts m_currentColor;
|
||||
coord2D_ts m_currentUserPos;
|
||||
coord2D_ts m_padding;
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
388
Sources/libewol/ewol/widgetMeta/ColorChooser.cpp
Normal file
388
Sources/libewol/ewol/widgetMeta/ColorChooser.cpp
Normal file
@ -0,0 +1,388 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widgetMeta/ColorChooser.cpp
|
||||
* @brief ewol Color chooser meta widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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/widgetMeta/ColorChooser.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
//#include <etk/Vector.h>
|
||||
#include <etk/VectorType.h>
|
||||
|
||||
extern "C" {
|
||||
// file browsing ...
|
||||
#include <dirent.h>
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ColorChooser"
|
||||
|
||||
|
||||
|
||||
|
||||
extern const char * const ewolEventFileChooserCancel = "ewol-event-file-chooser-cancel";
|
||||
|
||||
|
||||
ewol::ColorChooser::ColorChooser(void)
|
||||
{
|
||||
AddEventId(ewolEventFileChooserCancel);
|
||||
AddEventId(ewolEventFileChooserValidate);
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
// set the default Folder properties:
|
||||
UpdateCurrentFolder();
|
||||
}
|
||||
|
||||
|
||||
ewol::ColorChooser::~ColorChooser(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::ColorChooser::SetTitle(etk::UString label)
|
||||
{
|
||||
if (NULL == m_widgetTitle) {
|
||||
return;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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::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 << "\"");
|
||||
|
||||
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();
|
||||
m_hasSelectedFile = false;
|
||||
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();
|
||||
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
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::ColorChooser::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
// First step call parrent :
|
||||
ewol::PopUp::OnObjectRemove(removeObject);
|
||||
// second step find if in all the elements ...
|
||||
if(removeObject == m_widgetTitle) {
|
||||
m_widgetTitle = NULL;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
if(removeObject == m_widgetValidate) {
|
||||
m_widgetValidate = 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;
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
}
|
||||
|
70
Sources/libewol/ewol/widgetMeta/ColorChooser.h
Normal file
70
Sources/libewol/ewol/widgetMeta/ColorChooser.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widgetMeta/ColorChooser.h
|
||||
* @brief ewol Color chooser meta widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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_COLOR_CHOOSER_H__
|
||||
#define __EWOL_COLOR_CHOOSER_H__
|
||||
|
||||
#include <etk/Types.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>
|
||||
|
||||
extern const char * const ewolEventColorChooserChange;
|
||||
|
||||
namespace ewol {
|
||||
class ColorChooser : public ewol::SizerVert
|
||||
{
|
||||
public:
|
||||
ColorChooser(void);
|
||||
~ColorChooser(void);
|
||||
/**
|
||||
* @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);
|
||||
/**
|
||||
* @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);
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -29,6 +29,7 @@ FILE_LIST = ewol/ewol.cpp \
|
||||
ewol/widget/List.cpp \
|
||||
ewol/widget/Menu.cpp \
|
||||
ewol/widget/ContextMenu.cpp \
|
||||
ewol/widget/ColorBar.cpp \
|
||||
ewol/widget/PopUp.cpp \
|
||||
ewol/widget/SizerHori.cpp \
|
||||
ewol/widget/SizerVert.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user