[DEV] update the GUI

This commit is contained in:
Edouard DUPIN 2018-10-09 21:31:47 +02:00
parent a044d64f02
commit 05a4627a23
15 changed files with 211 additions and 103 deletions

View File

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<sizer mode="hori" expand="true,false" fill="true" lock="true">
<button name="[{ID}]SEARCH:close">
<image src="THEME:GUI:Remove.svg" fill="true" size="7,7mm"/>
<image src="THEME_GUI:///Remove.svg" fill="true" size="7,7mm"/>
</button>
<entry name="[{ID}]SEARCH:search-entry" expand="true" fill="true"/>
<button name="[{ID}]SEARCH:search">
<image src="THEME:GUI:Search.svg" fill="true" size="7,7mm"/>
<image src="THEME_GUI:///Search.svg" fill="true" size="7,7mm"/>
</button>
<entry name="[{ID}]SEARCH:replace-entry" expand="true" fill="true"/>
<button name="[{ID}]SEARCH:replace">
<image src="{ewol}THEME:GUI:Replace.svg" fill="true" size="7,7mm"/>
<image src="THEME_GUI:///Replace.svg?lib=ewol" fill="true" size="7,7mm"/>
</button>
<button name="[{ID}]SEARCH:case" toggle="true">
<image src="{ewol}THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="{ewol}THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="THEME_GUI:///CaseSensitive.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="THEME_GUI:///CaseSensitive.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button>
<button name="[{ID}]SEARCH:wrap" toggle="true">
<image src="{ewol}THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="{ewol}THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="THEME_GUI:///WrapAround.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="THEME_GUI:///WrapAround.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button>
<button name="[{ID}]SEARCH:up-down" toggle="true">
<image src="{ewol}THEME:GUI:Up.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="{ewol}THEME:GUI:Down.svg" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="THEME_GUI:///Up.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
<image src="THEME_GUI:///Down.svg?lib=ewol" fill="true" size="7,7mm" hover="_T(Close search bar)"/>
</button>
</sizer>

View File

@ -99,8 +99,6 @@ void MainWindows::init() {
ewol::widget::SizerShared mySizerHori;
ememory::SharedPtr<appl::TextViewer> myTextView;
ememory::SharedPtr<appl::TextViewer> myTextView2;
appl::widget::BufferListShared myBufferList;
appl::widget::BufferTreeShared myBufferTree;
ewol::widget::MenuShared myMenu;
// load buffer manager:
@ -115,28 +113,29 @@ void MainWindows::init() {
mySizerHori->propertyName.set("plop 222222222");
mySizerHori->propertyMode.set(ewol::widget::Sizer::modeHori);
mySizerVert->subWidgetAdd(mySizerHori);
if (false) {
myBufferList = appl::widget::BufferList::create();
myBufferList->propertyName.set("plop 3333333");
myBufferList->propertyExpand.set(bvec2(false,true));
myBufferList->propertyFill.set(bvec2(true,true));
//myBufferList->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(myBufferList);
} else {
myBufferTree = appl::widget::BufferTree::create();
myBufferTree->propertyName.set("plop 3333333");
myBufferTree->propertyExpand.set(bvec2(false,true));
myBufferTree->propertyFill.set(bvec2(true,true));
myBufferTree->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(myBufferTree);
}
m_viewBuffer = appl::widget::BufferList::create();
m_viewBuffer->propertyName.set("appl-buffer-view");
m_viewBuffer->propertyExpand.set(bvec2(false,true));
m_viewBuffer->propertyFill.set(bvec2(true,true));
//m_viewBuffer->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(m_viewBuffer);
m_viewTree = appl::widget::BufferTree::create();
m_viewTree->propertyHide.set(true);
m_viewTree->propertyName.set("appl-tree-view");
m_viewTree->propertyExpand.set(bvec2(false,true));
m_viewTree->propertyFill.set(bvec2(true,true));
m_viewTree->propertyMinSize.set(gale::Dimension(vec2(300,2), gale::distance::pixel));
mySizerHori->subWidgetAdd(m_viewTree);
ewol::widget::SpacerShared mySpacer = ewol::widget::Spacer::create();
mySpacer->propertyName.set("appl-Buffer-viewer-separator");
mySpacer->propertyColor.set(etk::color::black);
mySpacer->propertyMinSize.set(gale::Dimension(vec2(2,2), gale::distance::pixel));
mySpacer->propertyExpand.set(bvec2(false,true));
mySpacer->propertyFill.set(bvec2(true,true));
mySpacer->propertyHide.set(true);
//mySpacer->propertyHide.set(true);
mySizerHori->subWidgetAdd(mySpacer);
mySizerVert2 = ewol::widget::Sizer::create();
@ -188,27 +187,32 @@ void MainWindows::init() {
int32_t idMenuFile = myMenu->addTitle("_T{File}");
myMenu->add(idMenuFile, "_T{New}", "", "menu:new");
myMenu->addSpacer(idMenuFile);
myMenu->add(idMenuFile, "_T{Open}", "THEME:GUI:Load.svg", "menu:open");
myMenu->add(idMenuFile, "_T{Close}", "THEME:GUI:Close.svg", "menu:close");
myMenu->add(idMenuFile, "_T{Open}", "THEME_GUI:///Load.svg", "menu:open");
myMenu->add(idMenuFile, "_T{Close}", "THEME_GUI:///Close.svg", "menu:close");
myMenu->add(idMenuFile, "_T{Close (all)}", "", "menu:close-all");
myMenu->add(idMenuFile, "_T{Save}", "THEME:GUI:Save.svg", "menu:save");
myMenu->add(idMenuFile, "_T{Save}", "THEME_GUI:///Save.svg", "menu:save");
myMenu->add(idMenuFile, "_T{Save As ...}", "", "menu:save-as");
myMenu->addSpacer(idMenuFile);
myMenu->add(idMenuFile, "_T{Properties}", "THEME:GUI:Parameter.svg", "menu:property");
myMenu->add(idMenuFile, "_T{Properties}", "THEME_GUI:///Parameter.svg", "menu:property");
myMenu->addSpacer(idMenuFile);
myMenu->add(idMenuFile, "_T{Exit}", "", "menu:exit");
int32_t idMenuEdit = myMenu->addTitle("_T{Edit}");
myMenu->add(idMenuEdit, "_T{Goto line ...}","", "menu:goto-line");
myMenu->addSpacer();
int32_t idMenuSearch = myMenu->addTitle("_T{Search}");
myMenu->add(idMenuSearch, "_T{Search}", "THEME:GUI:Search.svg", "menu:search");
myMenu->add(idMenuSearch, "_T{Replace}", "THEME:GUI:Replace.svg", "menu:replace");
myMenu->add(idMenuSearch, "_T{Search}", "THEME_GUI:///Search.svg", "menu:search");
myMenu->add(idMenuSearch, "_T{Replace}", "THEME_GUI:///Replace.svg", "menu:replace");
myMenu->addSpacer(idMenuSearch);
myMenu->add(idMenuSearch, "_T{Find (previous)}","", "menu:find:previous");
myMenu->add(idMenuSearch, "_T{Find (next)}", "", "menu:find:next");
myMenu->add(idMenuSearch, "_T{Find (all)}", "", "menu:find:all");
myMenu->add(idMenuSearch, "_T{Un-Select}", "", "menu:find:none");
int32_t idMenugDisplay = myMenu->addTitle("_T{Display}");
myMenu->add(idMenugDisplay, "_T{Tree view}", "", "menu:view:tree");
myMenu->add(idMenugDisplay, "_T{Buffer view}", "", "menu:view:buffer");
myMenu->add(idMenugDisplay, "_T{Tree view: Show un-needed}", "", "menu:view:tree:ShowUnneeded");
myMenu->add(idMenugDisplay, "_T{Tree view: Hide un-needed}", "", "menu:view:tree:HideUnneeded");
myMenu->addSpacer(idMenugDisplay);
myMenu->add(idMenugDisplay, "_T{Color Black}", "", "menu:color:color/black/");
myMenu->add(idMenugDisplay, "_T{Color White}", "", "menu:color:color/white/");
myMenu->add(idMenugDisplay, "_T{Shape square}", "", "menu:shape:shape/square/");
@ -229,6 +233,8 @@ void MainWindows::init() {
mySizerHori->subWidgetAdd(m_widgetLabelFileName);
// add generic shortcut ...
shortCutAdd("ctrl+b", "menu:view:toggle");
shortCutAdd("ctrl+o", "menu:open");
shortCutAdd("ctrl+n", "menu:new");
@ -321,6 +327,19 @@ void MainWindows::onCallbackMenuEvent(const etk::String& _value) {
m_widgetSearch->selectReplace();
}
}
} else if (_value == "menu:view:buffer") {
m_viewTree->propertyHide.set(true);
m_viewBuffer->propertyHide.set(false);
} else if (_value == "menu:view:tree") {
m_viewTree->propertyHide.set(false);
m_viewBuffer->propertyHide.set(true);
} else if (_value == "menu:view:toggle") {
m_viewTree->propertyHide.set(m_viewTree->propertyHide.get() == false);
m_viewBuffer->propertyHide.set(m_viewBuffer->propertyHide.get() == false);
} else if (_value == "menu:view:tree:ShowUnneeded") {
propertySetOnWidgetNamed("appl-tree-view", "show-un-needed", "true");
} else if (_value == "menu:view:tree:HideUnneeded") {
propertySetOnWidgetNamed("appl-tree-view", "show-un-needed", "false");
} else if (_value == "menu:find:previous") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:next") {

View File

@ -14,10 +14,13 @@
#include <appl/BufferManager.hpp>
#include <appl/Gui/Search.hpp>
#include <appl/Gui/ViewerManager.hpp>
class MainWindows : public ewol::widget::Windows {
private:
ewol::widget::LabelShared m_widgetLabelFileName;
appl::widget::SearchShared m_widgetSearch;
ewol::WidgetShared m_viewTree;
ewol::WidgetShared m_viewBuffer;
esignal::Connection m_connectionSave;
esignal::Connection m_connectionModify;
esignal::Connection m_connectionSaveName;

View File

@ -20,7 +20,7 @@ appl::widget::Search::Search() :
}
void appl::widget::Search::init() {
ewol::widget::Composer::init();
loadFromFile("DATA:GUI-Search.xml", getId());
loadFromFile("DATA:///GUI-Search.xml", getId());
m_viewerManager = appl::ViewerManager::create();
// link event
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]SEARCH:close", signalPressed, sharedFromThis(), &appl::widget::Search::OnCallbackHide);

View File

@ -14,7 +14,7 @@ appl::TagFileList::TagFileList() :
m_selectedLine = -1;
setMouseLimit(1);
// Load color properties: (use file list to be generic ...)
m_colorProperty = ewol::resource::ColorFile::create("THEME_COLOR://ListFileSystem.json");
m_colorProperty = ewol::resource::ColorFile::create("THEME_COLOR:///ListFileSystem.json");
if (m_colorProperty != null) {
m_colorIdText = m_colorProperty->request("text");
m_colorIdBackground1 = m_colorProperty->request("background1");

View File

@ -49,13 +49,13 @@ void appl::TagFileSelection::init() {
" <spacer expand='true,false'/>\n"
" <button name='PLUGIN-CTAGS-jump' expand='false' fill='true'>"
" <sizer mode='hori'>\n"
" <image src='THEME:GUI:Load.svg' fill='true' size='10,10mm'/>\n"
" <image src='THEME_GUI:///Load.svg' fill='true' size='10,10mm'/>\n"
" <label>Jump</label>\n"
" </sizer>\n"
" </button>\n"
" <button name='PLUGIN-CTAGS-cancel' expand='false' fill='true'>"
" <sizer mode='hori'>\n"
" <image src='THEME:GUI:Remove.svg' fill='true' size='10,10mm'/>\n"
" <image src='THEME_GUI:///Remove.svg' fill='true' size='10,10mm'/>\n"
" <label>Cancel</label>\n"
" </sizer>\n"
" </button>\n"

View File

@ -38,7 +38,7 @@ appl::TextViewer::TextViewer() :
m_viewerManager = appl::ViewerManager::create();
// load color properties
m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:textViewer.json");
m_paintingProperties = appl::GlyphPainting::create("THEME_COLOR:///textViewer.json");
// get all id properties ...
m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung");
m_colorSpace = m_paintingProperties->request("CODE_space");

View File

@ -31,7 +31,7 @@ namespace appl {
public:
// Constructeur
Highlight();
void init(const etk::Uri& _uriXML, const etk::Uri& _uriColorFile = "THEME_COLOR://textViewer.json");
void init(const etk::Uri& _uriXML, const etk::Uri& _uriColorFile = "THEME_COLOR:///textViewer.json");
public:
DECLARE_RESOURCE_URI_FACTORY(Highlight);
virtual ~Highlight();

View File

@ -27,21 +27,25 @@ void appl::highlightManager::init() {
}
APPL_DEBUG("HighlightManager == > INIT");
// TODO: Add search in the etk::Uri uri("DATA_USER://languages/");
etk::Uri uri("DATA://languages/");
etk::Uri uri("DATA:///languages/");
// get the subfolder list:
etk::Vector<etk::Uri> list = etk::uri::listRecursive(uri); // TODO: filter only the folder
APPL_DEBUG("find " << list.size() << " element(s) in " << uri );
for (auto &it: list) {
// TODO: etk::uri::isDirectory(it) ==> not implemented ...
if (etk::path::isDirectory(it.getPath()) == false) {
APPL_DEBUG(" - " << it );
APPL_DEBUG(" " << it.getPath() << " " << etk::uri::isDirectory(it));
if (etk::uri::isDirectory(it) == false) {
continue;
}
ememory::SharedPtr<appl::Highlight> myHightLight = appl::Highlight::create(it.getPath() / "highlight.xml");
etk::Uri uriXml = uri;
uriXml.setPath(it.getPath() / "highlight.xml");
ememory::SharedPtr<appl::Highlight> myHightLight = appl::Highlight::create(uriXml);
if (myHightLight != null) {
// Check if the language name already exist
for (auto &it2 : hlList) {
if ( it2 != null
&& it2->getTypeName() == myHightLight->getTypeName() ) {
APPL_WARNING("LANGUAGE : replace pattern name: '" << myHightLight->getTypeName() << "' with file '" << it.getPath() / "highlight.xml" << "' replace: " << it2->getName());
APPL_WARNING("LANGUAGE : replace pattern name: '" << myHightLight->getTypeName() << "' with file '" << uriXml << "' replace: " << it2->getName());
}
}
hlList.pushBack(myHightLight);

View File

@ -24,8 +24,8 @@ void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
if (menu != null) {
m_menuIdTitle = menu->addTitle("_T{Edit}");
if (m_menuIdTitle != -1) {
m_menuIdUndo = menu->add(m_menuIdTitle, "_T{Undo}", "THEME:GUI:Undo.svg", "appl::TextPluginHistory::menu:undo");
m_menuIdRedo = menu->add(m_menuIdTitle, "_T{Redo}", "THEME:GUI:Redo.svg", "appl::TextPluginHistory::menu:redo");
m_menuIdUndo = menu->add(m_menuIdTitle, "_T{Undo}", "THEME_GUI:///Undo.svg", "appl::TextPluginHistory::menu:undo");
m_menuIdRedo = menu->add(m_menuIdTitle, "_T{Redo}", "THEME_GUI:///Redo.svg", "appl::TextPluginHistory::menu:redo");
}
}
// add event :

View File

@ -11,7 +11,7 @@
#include <etk/theme/theme.hpp>
#include <ejson/ejson.hpp>
static etk::Uri g_baseDBName = "USER_DATA://genericConfig.json";
static etk::Uri g_baseDBName = "USER_DATA:///genericConfig.json";
class myParamGlobal : public ewol::Object {
@ -137,7 +137,7 @@ globals::ParameterGlobalsGui::ParameterGlobalsGui() {
void globals::ParameterGlobalsGui::init() {
ewol::widget::Composer::init();
loadFromFile("DATA:GUI-Parameter-global.xml", getId());
loadFromFile("DATA:///GUI-Parameter-global.xml", getId());
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-param:auto-indent", "value", etk::toString(isSetAutoIndent()));
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]appl-param:display-space-char", "value", etk::toString(isSetDisplaySpaceChar()));

View File

@ -60,7 +60,7 @@ class MainApplication : public ewol::context::Application {
#endif
// set the application icon ...
_context.setIcon("DATA:icon.png");
_context.setIcon("DATA:///icon.png");
APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)");
}

View File

@ -11,23 +11,6 @@
#include <appl/Gui/MainWindows.hpp>
#include <ewol/object/Object.hpp>
// TODO : write it better
static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
etk::Vector<appl::dataBufferStruct> tmpList = _list;
_list.clear();
for(size_t iii=0; iii<tmpList.size(); iii++) {
size_t findPos = 0;
for(size_t jjj=0; jjj<_list.size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (tmpList[iii].m_bufferName.getFileName() > _list[jjj].m_bufferName.getFileName()) {
findPos = jjj+1;
}
}
//EWOL_DEBUG("position="<<findPos);
_list.insert(_list.begin()+findPos, tmpList[iii]);
}
}
appl::widget::BufferList::BufferList() :
m_openOrderMode(false) {
addObjectType("appl::BufferList");
@ -36,7 +19,7 @@ appl::widget::BufferList::BufferList() :
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
// load color properties
m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:bufferList.json");
m_paintingProperties = appl::GlyphPainting::create("THEME_COLOR:///bufferList.json");
// get all id properties ...
m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -47,7 +30,7 @@ appl::widget::BufferList::BufferList() :
void appl::widget::BufferList::init() {
ewol::widget::List::init();
propertyHide.set(true);
//propertyHide.set(true);
propertyCanFocus.set(true);
if (m_bufferManager != null) {
m_bufferManager->signalNewBuffer.connect(sharedFromThis(), &appl::widget::BufferList::onCallbackNewBuffer);
@ -106,6 +89,7 @@ void appl::widget::BufferList::onCallbackNewBuffer(const ememory::SharedPtr<appl
} else {
insertAlphabetic(tmp);
}
/*
if (m_list.size() <= 1) {
propertyHide.set(true);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "true");
@ -113,6 +97,7 @@ void appl::widget::BufferList::onCallbackNewBuffer(const ememory::SharedPtr<appl
propertyHide.set(false);
propertySetOnWidgetNamed("appl-Buffer-viewer-separator", "hide", "false");
}
*/
markToRedraw();
}
@ -159,11 +144,13 @@ void appl::widget::BufferList::onCallbackBufferRemoved(const ememory::SharedPtr<
++it;
}
}
/*
if (m_list.size() <= 1) {
propertyHide.set(true);
} else {
propertyHide.set(false);
}
*/
markToRedraw();
}
void appl::widget::BufferList::onCallbackIsSave() {

View File

@ -10,25 +10,14 @@
//#include <ColorizeManager.hpp>
#include <appl/Gui/MainWindows.hpp>
#include <ewol/object/Object.hpp>
// TODO : write it better
static void SortElementList(etk::Vector<appl::dataBufferStruct>& _list) {
etk::Vector<appl::dataBufferStruct> tmpList = _list;
_list.clear();
for(size_t iii=0; iii<tmpList.size(); iii++) {
size_t findPos = 0;
for(size_t jjj=0; jjj<_list.size(); jjj++) {
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
if (tmpList[iii].m_bufferName.getFileName() > _list[jjj].m_bufferName.getFileName()) {
findPos = jjj+1;
}
}
//EWOL_DEBUG("position="<<findPos);
_list.insert(_list.begin()+findPos, tmpList[iii]);
}
}
#include <ewol/compositing/Image.hpp>
#include <etk/algorithm.hpp>
appl::widget::BufferTree::BufferTree() :
propertyShowUnNeeded(this, "show-un-needed",
false,
"show element that is not open",
&appl::widget::BufferTree::onChangePropertyShowUnNeeded),
m_openOrderMode(false) {
addObjectType("appl::BufferTree");
m_selectedID = -1;
@ -36,7 +25,7 @@ appl::widget::BufferTree::BufferTree() :
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
// load color properties
m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:bufferList.json");
m_paintingProperties = appl::GlyphPainting::create("THEME_COLOR:///bufferList.json");
// get all id properties ...
m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -57,6 +46,9 @@ void appl::widget::BufferTree::init() {
m_bufferManager->signalSelectFile.connect(sharedFromThis(), &appl::widget::BufferTree::onSelectBuffer);
m_bufferManager->signalRemoveBuffer.connect(sharedFromThis(), &appl::widget::BufferTree::onRemoveBuffer);
}
addComposeElemnent("image_folder", ememory::makeShared<ewol::compositing::Image>("THEME_GUI:///Folder.svg?lib=ewol"));
addComposeElemnent("image_file", ememory::makeShared<ewol::compositing::Image>("THEME_GUI:///File.svg?lib=ewol"));
}
static etk::String getCommonPathPart(const etk::Path& _left, const etk::Path& _right) {
@ -68,6 +60,10 @@ static etk::String getCommonPathPart(const etk::Path& _left, const etk::Path& _r
}
break;
}
size_t pos = out.rfind('/');
if (pos != etk::String::npos) {
out = out.extract(0, pos);
}
return out;
}
@ -83,6 +79,10 @@ void appl::widget::BufferTree::generateFlatTree() {
updateFlatTree();
}
static bool localSort(const etk::Path& _left, const etk::Path& _right) {
return _left.getString().toUpper() <= _right.getString().toUpper();
}
void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node) {
if (_node == null) {
return;
@ -96,7 +96,8 @@ void appl::widget::BufferTree::populateNodeIfNeeded(ememory::SharedPtr<etk::Tree
// already populated...
return;
}
etk::Vector<etk::Path> child = etk::path::list(value.m_path);
etk::Vector<etk::Path> child = etk::path::list(value.m_path, etk::path::LIST_FOLDER|etk::path::LIST_FILE);
etk::algorithm::quickSort(child, localSort);
APPL_ERROR(" nbChilds: " << child.size() << " for path: " << value.m_path);
for (auto& it: child) {
APPL_ERROR("add element: " << it);
@ -114,6 +115,10 @@ void appl::widget::BufferTree::goUpper() {
}
// generate new futur root node ...
etk::Path path = m_tree->getData().m_path.getParent();
if (path == m_tree->getData().m_path) {
APPL_ERROR("No more parent in upper ... '" << path << "'");
return;
}
auto treeElement = etk::TreeNode<appl::TreeElement>::create(TreeElement(path, true));
// Add all sub-items
populateNodeIfNeeded(treeElement);
@ -121,6 +126,7 @@ void appl::widget::BufferTree::goUpper() {
for (auto& it: treeElement->getChilds()) {
if (it->getData().m_nodeName == m_tree->getData().m_nodeName) {
it = m_tree;
it->setParent(treeElement);
break;
}
}
@ -130,18 +136,76 @@ void appl::widget::BufferTree::goUpper() {
updateFlatTree();
}
bool appl::widget::BufferTree::updateChildOpen(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node) {
if (_node == null) {
return false;
}
appl::TreeElement& value = _node->getData();
if (value.m_isFolder == false) {
// nothing to reset...
return value.m_buffer != null;
}
value.m_haveChildOpen = false;
for (auto& it: _node->getChilds()) {
if (updateChildOpen(it) == true) {
value.m_haveChildOpen = true;
}
}
return value.m_haveChildOpen;
}
void appl::widget::BufferTree::updateFlatTree() {
m_flatTree.setRoot(m_tree,
[&](const TreeElement& _value){
return true;
},
[&](const TreeElement& _value){
return _value.m_isExpand;
});
// Enable parent with child open:
updateChildOpen(m_tree);
// flat tree element enable
if (propertyShowUnNeeded.get() == false) {
m_flatTree.setRoot(m_tree,
[&](const TreeElement& _value){
if ( _value.m_isFolder == true
&& _value.m_haveChildOpen == true) {
return true;
}
if ( _value.m_buffer != null) {
return true;
}
return false;
},
[&](const TreeElement& _value){
return _value.m_isExpand;
});
} else {
m_flatTree.setRoot(m_tree,
[&](const TreeElement& _value){
return true;
},
[&](const TreeElement& _value){
return _value.m_isExpand;
});
}
markToRedraw();
}
void appl::widget::BufferTree::expandToPath(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node, const etk::Path& _path) {
if (_node == null) {
return;
}
appl::TreeElement& value = _node->getData();
if (value.m_isFolder == false) {
return;
}
if (_path.getString().startWith(value.m_path.getString() + "/") == false) {
return;
}
// force expand
value.m_isExpand = true;
populateNodeIfNeeded(_node);
for (auto& it: _node->getChilds()) {
expandToPath(it, _path);
}
}
appl::widget::BufferTree::~BufferTree() {
removeAllElement();
@ -191,15 +255,17 @@ etk::Path appl::widget::BufferTree::getRootPath() {
}
void appl::widget::BufferTree::onNewBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer) {
APPL_ERROR("New Buffer open: '" << _buffer->getFileName() << "'");
APPL_INFO("New Buffer open: '" << _buffer->getFileName() << "'");
if (m_tree == null) {
generateFlatTree();
} else {
etk::Path rootPath = getRootPath();
while (rootPath != m_tree->getData().m_path ) {
APPL_ERROR("rootPath=" << rootPath << " != " << m_tree->getData().m_path);
goUpper();
}
}
expandToPath(m_tree, _buffer->getFileName());
auto listElements = m_tree->findIf([&](const etk::TreeNode<TreeElement>& _node) {
APPL_WARNING("Compare : '" << _node.getData().m_path << "' =?= '" << _buffer->getFileName() << "'");
if (_node.getData().m_path == _buffer->getFileName()) {
@ -321,6 +387,10 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::Text:
return value.m_nodeName;
case ewol::widget::ListRole::FgColor:
// Folder with child open element
if (value.m_haveChildOpen == true) {
return (*m_paintingProperties)[m_colorTextNormal].getForeground();
}
if (value.m_buffer == null) {
//APPL_ERROR( m_colorBackgroundHide << " => " << (*m_paintingProperties)[m_colorBackgroundHide].getForeground());
return (*m_paintingProperties)[m_colorTextNotOpen].getForeground();
@ -332,6 +402,10 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::BgColor:
//return fluorine::Variant();
//APPL_ERROR( m_colorBackground1 << " => " << (*m_paintingProperties)[m_colorBackground1].getForeground());
if ( value.m_buffer == m_selection
&& m_selection != null) {
return (*m_paintingProperties)[m_colorBackgroundSelect].getForeground();
}
if (_pos.y() % 2) {
return (*m_paintingProperties)[m_colorBackground1].getForeground();
}
@ -339,19 +413,22 @@ fluorine::Variant appl::widget::BufferTree::getData(int32_t _role, const ivec2&
case ewol::widget::ListRole::Icon:
/*
if (elem->countToRoot() == 0) {
return "{ewol}THEME:GUI:Home.svg";
return "THEME_GUI:///Home.svg?lib=ewol";
}*/
if (value.m_isFolder == true) {
return "{ewol}THEME:GUI:Folder.svg";
return "image_folder";
} else {
return "{ewol}THEME:GUI:File.svg";
return "image_file";
}
return "";
case ewol::widget::ListRole::DistanceToRoot:
return uint_t(elem->countToRoot());
case ewol::widget::ListRole::HaveChild:
return elem->haveChild();
if (elem->haveChild() == true) {
return true;
}
return value.m_haveChild;
case ewol::widget::ListRole::IsExpand:
return value.m_isExpand;
case ewol::widget::ListRole::IsSelected:
@ -379,14 +456,21 @@ bool appl::widget::BufferTree::onItemEvent(const ewol::event::Input& _event, con
updateFlatTree();
return true;
} else if (value.m_buffer == null) {
// TODO: Open the file...
if (m_bufferManager != null) {
APPL_INFO("Select file: '" << value.m_path << "' in list");
m_bufferManager->open(value.m_path);
value.m_buffer = m_bufferManager->get(value.m_path);
}
return true;
}
}
if (_event.getStatus() == gale::key::status::pressSingle) {
APPL_INFO("Event on List: " << _event << " pos=" << _pos );
if (value.m_buffer != null) {
// TODO: Display the current buffer...
if (m_bufferManager != null) {
APPL_INFO("Select file: '" << value.m_path << "' in list");
m_bufferManager->open(value.m_path);
}
return true;
}
}
@ -406,4 +490,7 @@ bool appl::widget::BufferTree::onItemEvent(const ewol::event::Input& _event, con
return false;
}
void appl::widget::BufferTree::onChangePropertyShowUnNeeded() {
updateFlatTree();
markToRedraw();
}

View File

@ -23,11 +23,13 @@ namespace appl {
m_buffer(null),
m_isSelected(false),
m_isExpand(_isExpand) {
m_haveChild = etk::path::haveChild(_path);
}
etk::Path m_path;
etk::String m_nodeName; // must be here ==> the buffer is optionnal..
bool m_isFolder;
bool m_haveChildOpen = false;
bool m_haveChild = false;
ememory::SharedPtr<appl::Buffer> m_buffer;
bool m_isSelected = false;
bool m_isExpand = false;
@ -39,6 +41,8 @@ namespace appl {
using BufferTreeWeak = ememory::WeakPtr<BufferTree>;
class BufferTree : public ewol::widget::TreeView {
public:
eproperty::Value<bool> propertyShowUnNeeded; //!< Size of the icon.
private:
ememory::SharedPtr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
private:
@ -55,8 +59,11 @@ namespace appl {
int32_t m_selectedID;
void updateFlatTree();
void generateFlatTree();
// Recursive update of the child opening or not
bool updateChildOpen(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node);
etk::Path getRootPath();
void populateNodeIfNeeded(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node);
void expandToPath(ememory::SharedPtr<etk::TreeNode<appl::TreeElement>> _node, const etk::Path& _path);
void goUpper();
ememory::SharedPtr<etk::TreeNode<TreeElement>> m_tree;
etk::FlatTree<TreeElement> m_flatTree;
@ -87,6 +94,7 @@ namespace appl {
void onSelectBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void onRemoveBuffer(const ememory::SharedPtr<appl::Buffer>& _buffer);
void calculateMinMaxSize() override;
void onChangePropertyShowUnNeeded();
};
}
}