[DEV] start chage the API of the ListView to be ready to do a treeView
This commit is contained in:
parent
7e9d2e5f74
commit
7bab80da4f
@ -118,9 +118,8 @@ void ewol::widget::List::onRegenerateDisplay() {
|
||||
tmpOriginY += m_paddingSizeY;
|
||||
// TODO : remove this ...
|
||||
int32_t minHeight = 25;
|
||||
|
||||
uint32_t nbColomn = getNuberOfColomn();
|
||||
int32_t nbRaw = getNuberOfRaw();
|
||||
int32_t nbRaw = getNuberOfRaw();
|
||||
// For the scrooling windows
|
||||
m_maxSize = ivec2(m_size.x(),
|
||||
(minHeight + 2*m_paddingSizeY) * nbRaw );
|
||||
@ -165,10 +164,10 @@ void ewol::widget::List::onRegenerateDisplay() {
|
||||
m_nbVisibleRaw = 0;
|
||||
for (int32_t iii=startRaw; iii<nbRaw && displayPositionY >= 0; iii++) {
|
||||
m_nbVisibleRaw++;
|
||||
etk::String myTextToWrite;
|
||||
etk::Color<> fg;
|
||||
etk::Color<> bg;
|
||||
getElement(jjj, iii, myTextToWrite, fg, bg);
|
||||
ivec2 position(jjj, iii);
|
||||
etk::String myTextToWrite = getData(ListRole::Text, position).getSafeString();
|
||||
etk::Color<> fg = getData(ListRole::FgColor, position).getSafeColor();
|
||||
etk::Color<> bg = getData(ListRole::BgColor, position).getSafeColor();
|
||||
|
||||
ewol::compositing::Text * tmpText = ETK_NEW(ewol::compositing::Text);
|
||||
if (null != tmpText) {
|
||||
@ -227,10 +226,8 @@ bool ewol::widget::List::onEventInput(const ewol::event::Input& _event) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//EWOL_DEBUG("List event : idInput=" << IdInput << " typeEvent=" << typeEvent << " raw=" << rawID << " pos=" << pos << "");
|
||||
bool isUsed = onItemEvent(_event.getId(), _event.getStatus(), 0, rawID, _event.getPos().x(), _event.getPos().y());
|
||||
if (true == isUsed) {
|
||||
bool isUsed = onItemEvent(_event.getId(), _event.getStatus(), ivec2(0, rawID), _event.getPos());
|
||||
if (isUsed == true) {
|
||||
// TODO : this generate bugs ... I did not understand why ..
|
||||
//ewol::WidgetSharedManager::focusKeep(this);
|
||||
}
|
||||
|
@ -10,12 +10,22 @@
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/WidgetScrolled.hpp>
|
||||
#include <ewol/compositing/Compositing.hpp>
|
||||
#include <fluorine/Variant.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
class List;
|
||||
using ListShared = ememory::SharedPtr<ewol::widget::List>;
|
||||
using ListWeak = ememory::WeakPtr<ewol::widget::List>;
|
||||
|
||||
enum ListRole {
|
||||
Text = 11234,
|
||||
BgColor,
|
||||
FgColor,
|
||||
// Every other role must be set here:
|
||||
EndOfEwolRole
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
@ -55,18 +65,21 @@ namespace ewol {
|
||||
virtual uint32_t getNuberOfRaw() {
|
||||
return 0;
|
||||
};
|
||||
virtual bool getElement(int32_t _colomn, int32_t _raw, etk::String &_myTextToWrite, etk::Color<> &_fg, etk::Color<> &_bg) {
|
||||
_myTextToWrite = "";
|
||||
_bg = etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
_fg = etk::Color<>(0x00, 0x00, 0x00, 0xFF);
|
||||
if (_raw % 2) {
|
||||
_bg = etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
} else {
|
||||
_bg = etk::Color<>(0x7F, 0x7F, 0x7F, 0xFF);
|
||||
virtual fluorine::Variant getData(int32_t _role, const ivec2& _pos) {
|
||||
switch (_role) {
|
||||
case ListRole::Text:
|
||||
return "";
|
||||
case ListRole::FgColor:
|
||||
return etk::Color<>(0x00, 0x00, 0x00, 0xFF);
|
||||
case ListRole::BgColor:
|
||||
if (_pos.y() % 2 == 0) {
|
||||
return etk::Color<>(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
return etk::Color<>(0x7F, 0x7F, 0x7F, 0xFF);
|
||||
}
|
||||
return false;
|
||||
return fluorine::Variant();
|
||||
};
|
||||
virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) {
|
||||
virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, const ivec2& _pos, const vec2& _mousePosition) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
|
@ -133,39 +133,45 @@ uint32_t ewol::widget::ListFileSystem::getNuberOfRaw() {
|
||||
return m_list.size() + offset;
|
||||
}
|
||||
|
||||
bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, etk::String& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
|
||||
int32_t offset = 0;
|
||||
if (*propertyShowFolder == true) {
|
||||
if (*propertyPath == "/") {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
if (_raw == 0) {
|
||||
_myTextToWrite = ".";
|
||||
} else if ( _raw == 1
|
||||
&& propertyPath.get() != "/") {
|
||||
_myTextToWrite = "..";
|
||||
}
|
||||
fluorine::Variant ewol::widget::ListFileSystem::getData(int32_t _role, const ivec2& _pos) {
|
||||
switch (_role) {
|
||||
case ListRole::Text:
|
||||
{
|
||||
int32_t offset = 0;
|
||||
if (*propertyShowFolder == true) {
|
||||
if (*propertyPath == "/") {
|
||||
offset = 1;
|
||||
} else {
|
||||
offset = 2;
|
||||
}
|
||||
if (_pos.y() == 0) {
|
||||
return ".";
|
||||
} else if ( _pos.y() == 1
|
||||
&& propertyPath.get() != "/") {
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
if( _pos.y()-offset >= 0
|
||||
&& _pos.y()-offset < (int32_t)m_list.size()
|
||||
&& m_list[_pos.y()-offset] != null) {
|
||||
EWOL_VERBOSE("get filename for : '" << *m_list[_pos.y()-offset] << ":'" << m_list[_pos.y()-offset]->getNameFile() << "'");
|
||||
return m_list[_pos.y()-offset]->getNameFile();
|
||||
}
|
||||
}
|
||||
return "<<<ERROR>>>";
|
||||
case ListRole::FgColor:
|
||||
return m_colorProperty->get(m_colorIdText);
|
||||
case ListRole::BgColor:
|
||||
if (m_selectedLine == _pos.y()) {
|
||||
return m_colorProperty->get(m_colorIdBackgroundSelected);
|
||||
}
|
||||
if (_pos.y() % 2) {
|
||||
return m_colorProperty->get(m_colorIdBackground1);
|
||||
}
|
||||
return m_colorProperty->get(m_colorIdBackground2);
|
||||
}
|
||||
if( _raw-offset >= 0
|
||||
&& _raw-offset < (int32_t)m_list.size()
|
||||
&& m_list[_raw-offset] != null) {
|
||||
_myTextToWrite = m_list[_raw-offset]->getNameFile();
|
||||
EWOL_VERBOSE("get filename for : '" << *m_list[_raw-offset] << ":'" << _myTextToWrite << "'");
|
||||
}
|
||||
_fg = m_colorProperty->get(m_colorIdText);
|
||||
if (_raw % 2) {
|
||||
_bg = m_colorProperty->get(m_colorIdBackground1);
|
||||
} else {
|
||||
_bg = m_colorProperty->get(m_colorIdBackground2);
|
||||
}
|
||||
if (m_selectedLine == _raw) {
|
||||
_bg = m_colorProperty->get(m_colorIdBackgroundSelected);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
return fluorine::Variant();
|
||||
}
|
||||
|
||||
bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
|
||||
enum gale::key::status _typeEvent,
|
||||
|
@ -47,7 +47,7 @@ namespace ewol {
|
||||
uint32_t getNuberOfColomn() override;
|
||||
bool getTitle(int32_t _colomn, etk::String& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg) override;
|
||||
uint32_t getNuberOfRaw() override;
|
||||
bool getElement(int32_t _colomn, int32_t _raw, etk::String& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) override;
|
||||
fluorine::Variant getData(int32_t _role, const ivec2& _pos) override;
|
||||
bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) override;
|
||||
protected:
|
||||
// TODO: use shred_ptr
|
||||
|
@ -235,7 +235,8 @@ def configure(target, my_module):
|
||||
'egami',
|
||||
'edtaa3',
|
||||
'etranslate',
|
||||
'ewol-data'
|
||||
'ewol-data',
|
||||
'fluorine',
|
||||
])
|
||||
|
||||
my_module.add_path(".")
|
||||
|
Loading…
x
Reference in New Issue
Block a user