From 962da14ed13873012d206a5760362109d0e86920 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 29 Aug 2018 22:15:58 +0200 Subject: [PATCH] [DEV] better display of the treeview... --- data/theme/colorBlack/bufferList.json | 1 + data/theme/colorWhite/bufferList.json | 3 ++- sources/appl/widget/BufferTree.cpp | 33 +++++++++++++++++++-------- sources/appl/widget/BufferTree.hpp | 3 +++ 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/data/theme/colorBlack/bufferList.json b/data/theme/colorBlack/bufferList.json index 949cdc1..0b16d92 100644 --- a/data/theme/colorBlack/bufferList.json +++ b/data/theme/colorBlack/bufferList.json @@ -6,5 +6,6 @@ { name:"backgroungSelected", foreground:"#2f0ba4" }, { name:"textNormal", foreground:"#EEEEEE" }, { name:"textModify", foreground:"#FF0000" }, + { name:"textNotOpen", foreground:"#808080"}, ] } diff --git a/data/theme/colorWhite/bufferList.json b/data/theme/colorWhite/bufferList.json index d8f6e91..ff748c6 100644 --- a/data/theme/colorWhite/bufferList.json +++ b/data/theme/colorWhite/bufferList.json @@ -5,6 +5,7 @@ { name:"backgroundhide", foreground:"#606060" }, { name:"backgroungSelected", foreground:"#3da3f9"}, { name:"textNormal", foreground:"#000000"}, - { name:"textModify", foreground:"#FF0000"} + { name:"textModify", foreground:"#FF0000"}, + { name:"textNotOpen", foreground:"#808080"} ] } \ No newline at end of file diff --git a/sources/appl/widget/BufferTree.cpp b/sources/appl/widget/BufferTree.cpp index 63a2b2c..175c50a 100644 --- a/sources/appl/widget/BufferTree.cpp +++ b/sources/appl/widget/BufferTree.cpp @@ -44,12 +44,14 @@ appl::widget::BufferTree::BufferTree() : m_colorBackgroundSelect = m_paintingProperties->request("backgroungSelected"); m_colorTextNormal = m_paintingProperties->request("textNormal"); m_colorTextModify = m_paintingProperties->request("textModify"); + m_colorTextNotOpen = m_paintingProperties->request("textNotOpen"); } void appl::widget::BufferTree::init() { ewol::widget::TreeView::init(); //propertyHide.set(true); propertyCanFocus.set(true); + propertyTextIsDecorated.set(false); if (m_bufferManager != null) { m_bufferManager->signalNewBuffer2.connect(sharedFromThis(), &appl::widget::BufferTree::onNewBuffer); 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; } -void appl::widget::BufferTree::updateFlatTree() { + + +void appl::widget::BufferTree::generateFlatTree() { // Brut Force Mode... etk::String upperParent = ""; etk::Vector tmpNewBuffer; @@ -90,13 +94,15 @@ void appl::widget::BufferTree::updateFlatTree() { upperParent = getCommonPathPart(upperParent, nodeName.getNameFolder()); APPL_ERROR("Update: " << nodeName.getFileSystemName() << " " << nodeName.getNameFolder() << " root=" << upperParent); } + APPL_ERROR("update tree: " << upperParent); // Now we have the root path... - // Need to feed all elements needed - etk::FSNode nodeRoot = etk::FSNode(upperParent).getFileName(); - m_tree = etk::TreeNode::create(TreeElement(upperParent, true, true)); + // Need to feed all elements needed. + etk::FSNode nodeRoot = upperParent; + m_tree = etk::TreeNode::create(TreeElement(etk::FSNode(upperParent).getFileName(), true, true)); etk::Vector child = nodeRoot.folderGetSubList(false, true, true, false); + APPL_ERROR(" nbChilds: " << child.size()); for (auto& it: child) { - APPL_WARNING("add element: " << *it); + APPL_ERROR("add element: " << *it); if (it->getNodeType() == etk::typeNode_folder) { auto elem = etk::TreeNode::create(TreeElement(it->getNameFile(), true, false)); m_tree->addChild(elem); @@ -106,7 +112,10 @@ void appl::widget::BufferTree::updateFlatTree() { } // TODO: ETK_FREE(etk::FSNode, it); } - + updateFlatTree(); +} + +void appl::widget::BufferTree::updateFlatTree() { m_flatTree.setRoot(m_tree, [&](const TreeElement& _value){ return true; @@ -114,7 +123,6 @@ void appl::widget::BufferTree::updateFlatTree() { [&](const TreeElement& _value){ return _value.m_isExpand; }); - markToRedraw(); } @@ -140,7 +148,7 @@ void appl::widget::BufferTree::removeAllElement() { } void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr& _buffer) { - updateFlatTree(); + generateFlatTree(); /* ememory::SharedPtr buffer = m_bufferManager->get(_value); if (buffer == null) { @@ -228,7 +236,6 @@ void appl::widget::BufferTree::onCallbackIsModify() { } etk::Color<> appl::widget::BufferTree::getBasicBG() { - return etk::Color<>(0xAF,0xAF,0xAF,0xFF); return (*m_paintingProperties)[m_colorBackground1].getForeground(); } @@ -236,6 +243,12 @@ ivec2 appl::widget::BufferTree::getMatrixSize() const { 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) { auto elem = m_flatTree[_pos.y()]; 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: if (value.m_buffer == null) { //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) { return (*m_paintingProperties)[m_colorTextNormal].getForeground(); diff --git a/sources/appl/widget/BufferTree.hpp b/sources/appl/widget/BufferTree.hpp index e881b7a..f762308 100644 --- a/sources/appl/widget/BufferTree.hpp +++ b/sources/appl/widget/BufferTree.hpp @@ -46,10 +46,12 @@ namespace appl { int32_t m_colorBackgroundSelect; int32_t m_colorTextNormal; int32_t m_colorTextModify; + int32_t m_colorTextNotOpen; private: int32_t m_selectedIdRequested; int32_t m_selectedID; void updateFlatTree(); + void generateFlatTree(); ememory::SharedPtr> m_tree; etk::FlatTree m_flatTree; ememory::SharedPtr m_selection; @@ -70,6 +72,7 @@ namespace appl { ivec2 getMatrixSize() const 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; + void onItemExpandEvent(const ivec2& _pos) override; private: //callback function: void onCallbackChangeName(); void onCallbackIsSave();