[DEV] better display of the treeview...

This commit is contained in:
Edouard DUPIN 2018-08-29 22:15:58 +02:00
parent bba1477118
commit 962da14ed1
4 changed files with 29 additions and 11 deletions

View File

@ -6,5 +6,6 @@
{ name:"backgroungSelected", foreground:"#2f0ba4" }, { name:"backgroungSelected", foreground:"#2f0ba4" },
{ name:"textNormal", foreground:"#EEEEEE" }, { name:"textNormal", foreground:"#EEEEEE" },
{ name:"textModify", foreground:"#FF0000" }, { name:"textModify", foreground:"#FF0000" },
{ name:"textNotOpen", foreground:"#808080"},
] ]
} }

View File

@ -5,6 +5,7 @@
{ name:"backgroundhide", foreground:"#606060" }, { name:"backgroundhide", foreground:"#606060" },
{ name:"backgroungSelected", foreground:"#3da3f9"}, { name:"backgroungSelected", foreground:"#3da3f9"},
{ name:"textNormal", foreground:"#000000"}, { name:"textNormal", foreground:"#000000"},
{ name:"textModify", foreground:"#FF0000"} { name:"textModify", foreground:"#FF0000"},
{ name:"textNotOpen", foreground:"#808080"}
] ]
} }

View File

@ -44,12 +44,14 @@ appl::widget::BufferTree::BufferTree() :
m_colorBackgroundSelect = m_paintingProperties->request("backgroungSelected"); m_colorBackgroundSelect = m_paintingProperties->request("backgroungSelected");
m_colorTextNormal = m_paintingProperties->request("textNormal"); m_colorTextNormal = m_paintingProperties->request("textNormal");
m_colorTextModify = m_paintingProperties->request("textModify"); m_colorTextModify = m_paintingProperties->request("textModify");
m_colorTextNotOpen = m_paintingProperties->request("textNotOpen");
} }
void appl::widget::BufferTree::init() { void appl::widget::BufferTree::init() {
ewol::widget::TreeView::init(); ewol::widget::TreeView::init();
//propertyHide.set(true); //propertyHide.set(true);
propertyCanFocus.set(true); propertyCanFocus.set(true);
propertyTextIsDecorated.set(false);
if (m_bufferManager != null) { if (m_bufferManager != null) {
m_bufferManager->signalNewBuffer2.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer); m_bufferManager->signalNewBuffer2.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer);
m_bufferManager->signalSelectBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer); m_bufferManager->signalSelectBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer);
@ -69,7 +71,9 @@ static etk::String getCommonPathPart(const etk::String& _left, const etk::String
return out; return out;
} }
void appl::widget::BufferTree::updateFlatTree() {
void appl::widget::BufferTree::generateFlatTree() {
// Brut Force Mode... // Brut Force Mode...
etk::String upperParent = ""; etk::String upperParent = "";
etk::Vector<appl::BufferShared> tmpNewBuffer; etk::Vector<appl::BufferShared> tmpNewBuffer;
@ -90,13 +94,15 @@ void appl::widget::BufferTree::updateFlatTree() {
upperParent = getCommonPathPart(upperParent, nodeName.getNameFolder()); upperParent = getCommonPathPart(upperParent, nodeName.getNameFolder());
APPL_ERROR("Update: " << nodeName.getFileSystemName() << " " << nodeName.getNameFolder() << " root=" << upperParent); APPL_ERROR("Update: " << nodeName.getFileSystemName() << " " << nodeName.getNameFolder() << " root=" << upperParent);
} }
APPL_ERROR("update tree: " << upperParent);
// Now we have the root path... // Now we have the root path...
// Need to feed all elements needed // Need to feed all elements needed.
etk::FSNode nodeRoot = etk::FSNode(upperParent).getFileName(); etk::FSNode nodeRoot = upperParent;
m_tree = etk::TreeNode<appl::TreeElement>::create(TreeElement(upperParent, true, true)); m_tree = etk::TreeNode<appl::TreeElement>::create(TreeElement(etk::FSNode(upperParent).getFileName(), true, true));
etk::Vector<etk::FSNode*> child = nodeRoot.folderGetSubList(false, true, true, false); etk::Vector<etk::FSNode*> child = nodeRoot.folderGetSubList(false, true, true, false);
APPL_ERROR(" nbChilds: " << child.size());
for (auto& it: child) { for (auto& it: child) {
APPL_WARNING("add element: " << *it); APPL_ERROR("add element: " << *it);
if (it->getNodeType() == etk::typeNode_folder) { if (it->getNodeType() == etk::typeNode_folder) {
auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(it->getNameFile(), true, false)); auto elem = etk::TreeNode<appl::TreeElement>::create(TreeElement(it->getNameFile(), true, false));
m_tree->addChild(elem); m_tree->addChild(elem);
@ -106,7 +112,10 @@ void appl::widget::BufferTree::updateFlatTree() {
} }
// TODO: ETK_FREE(etk::FSNode, it); // TODO: ETK_FREE(etk::FSNode, it);
} }
updateFlatTree();
}
void appl::widget::BufferTree::updateFlatTree() {
m_flatTree.setRoot(m_tree, m_flatTree.setRoot(m_tree,
[&](const TreeElement& _value){ [&](const TreeElement& _value){
return true; return true;
@ -114,7 +123,6 @@ void appl::widget::BufferTree::updateFlatTree() {
[&](const TreeElement& _value){ [&](const TreeElement& _value){
return _value.m_isExpand; return _value.m_isExpand;
}); });
markToRedraw(); markToRedraw();
} }
@ -140,7 +148,7 @@ void appl::widget::BufferTree::removeAllElement() {
} }
void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) { void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
updateFlatTree(); generateFlatTree();
/* /*
ememory::SharedPtr<appl::Buffer> buffer = m_bufferManager->get(_value); ememory::SharedPtr<appl::Buffer> buffer = m_bufferManager->get(_value);
if (buffer == null) { if (buffer == null) {
@ -228,7 +236,6 @@ void appl::widget::BufferTree::onCallbackIsModify() {
} }
etk::Color<> appl::widget::BufferTree::getBasicBG() { etk::Color<> appl::widget::BufferTree::getBasicBG() {
return etk::Color<>(0xAF,0xAF,0xAF,0xFF);
return (*m_paintingProperties)[m_colorBackground1].getForeground(); return (*m_paintingProperties)[m_colorBackground1].getForeground();
} }
@ -236,6 +243,12 @@ ivec2 appl::widget::BufferTree::getMatrixSize() const {
return ivec2(1, m_flatTree.size()); return ivec2(1, m_flatTree.size());
} }
void appl::widget::BufferTree::onItemExpandEvent(const ivec2& _pos) {
APPL_WARNING("Event on expand on " << _pos);
m_flatTree[_pos.y()]->getData().m_isExpand = m_flatTree[_pos.y()]->getData().m_isExpand?false:true;
updateFlatTree();
}
fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2& _pos) { fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2& _pos) {
auto elem = m_flatTree[_pos.y()]; auto elem = m_flatTree[_pos.y()];
appl::TreeElement& value = elem->getData(); appl::TreeElement& value = elem->getData();
@ -245,7 +258,7 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::FgColor: case ewol::widget::ListRole::FgColor:
if (value.m_buffer == null) { if (value.m_buffer == null) {
//APPL_ERROR( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground()); //APPL_ERROR( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground());
return (*m_paintingProperties)[m_colorTextModify].getForeground(); return (*m_paintingProperties)[m_colorTextNotOpen].getForeground();
} }
if (value.m_buffer->isModify() == false) { if (value.m_buffer->isModify() == false) {
return (*m_paintingProperties)[m_colorTextNormal].getForeground(); return (*m_paintingProperties)[m_colorTextNormal].getForeground();

View File

@ -46,10 +46,12 @@ namespace appl {
int32_t m_colorBackgroundSelect; int32_t m_colorBackgroundSelect;
int32_t m_colorTextNormal; int32_t m_colorTextNormal;
int32_t m_colorTextModify; int32_t m_colorTextModify;
int32_t m_colorTextNotOpen;
private: private:
int32_t m_selectedIdRequested; int32_t m_selectedIdRequested;
int32_t m_selectedID; int32_t m_selectedID;
void updateFlatTree(); void updateFlatTree();
void generateFlatTree();
ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree; ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree;
etk::FlatTree<TreeElement> m_flatTree; etk::FlatTree<TreeElement> m_flatTree;
ememory::SharedPtr<appl::Buffer> m_selection; ememory::SharedPtr<appl::Buffer> m_selection;
@ -70,6 +72,7 @@ namespace appl {
ivec2 getMatrixSize() const override; ivec2 getMatrixSize() const override;
fluorine::Variant getData(int32_t _role, const ivec2& _pos) override; fluorine::Variant getData(int32_t _role, const ivec2& _pos) override;
bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) override; bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) override;
void onItemExpandEvent(const ivec2& _pos) override;
private: //callback function: private: //callback function:
void onCallbackChangeName(); void onCallbackChangeName();
void onCallbackIsSave(); void onCallbackIsSave();