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