diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp index 57ff593b2a6fa07dc6dbe96f49fbc15643e2b739..34bb09685055699db97b2c7dc6c9087dad530729 100644 --- a/Fltk/onelabGroup.cpp +++ b/Fltk/onelabGroup.cpp @@ -303,7 +303,8 @@ bool onelab::localNetworkClient::run() drawContext::global()->draw(); if(n != PView::list.size()){ FlGui::instance()->rebuildTree(); - FlGui::instance()->openModule("Post-processing"); + if(!FlGui::instance()->onelab->isManuallyClosed("0Gmsh modules/Post-processing")) + FlGui::instance()->openModule("Post-processing"); } } break; @@ -680,26 +681,23 @@ static void setClosed(const std::string &path, std::vector<T> &ps, } } -static void onelab_tree_cb(Fl_Widget *w, void *data) +static void setOpenedClosed(Fl_Tree_Item *item, int reason) { - Fl_Tree *tree = (Fl_Tree*)w; - Fl_Tree_Item *item = (Fl_Tree_Item*)tree->callback_item(); - std::string path = FlGui::instance()->onelab->getPath(item); std::vector<onelab::number> numbers; std::vector<onelab::string> strings; std::vector<onelab::region> regions; std::vector<onelab::function> functions; - - switch(tree->callback_reason()){ - case FL_TREE_REASON_SELECTED: break; - case FL_TREE_REASON_DESELECTED: break; + std::string path = FlGui::instance()->onelab->getPath(item); + switch(reason){ case FL_TREE_REASON_OPENED: + FlGui::instance()->onelab->removeFromManuallyClosed(path); setClosed(path, numbers, "0"); setClosed(path, strings, "0"); setClosed(path, regions, "0"); setClosed(path, functions, "0"); break; case FL_TREE_REASON_CLOSED: + FlGui::instance()->onelab->insertInManuallyClosed(path); setClosed(path, numbers, "1"); setClosed(path, strings, "1"); setClosed(path, regions, "1"); @@ -710,6 +708,29 @@ static void onelab_tree_cb(Fl_Widget *w, void *data) } } +static void onelab_tree_cb(Fl_Widget *w, void *data) +{ + Fl_Tree *tree = (Fl_Tree*)w; + Fl_Tree_Item *item = (Fl_Tree_Item*)tree->callback_item(); + setOpenedClosed(item, tree->callback_reason()); +} + +static void onelab_subtree_cb(Fl_Widget *w, void *data) +{ + Fl_Tree_Item *n = (Fl_Tree_Item*)data; + int reason; + if(n->is_open()){ + reason = FL_TREE_REASON_CLOSED; + n->close(); + } + else{ + reason = FL_TREE_REASON_OPENED; + n->open(); + } + setOpenedClosed(n, reason); + FlGui::instance()->onelab->redrawTree(); +} + onelabGroup::onelabGroup(int x, int y, int w, int h, const char *l) : Fl_Group(x,y,w,h,l), _stop(false) { @@ -1145,13 +1166,6 @@ Fl_Widget *onelabGroup::_addParameterWidget(onelab::function &p, Fl_Tree_Item *n } } -static void onelab_subtree_cb(Fl_Widget *w, void *data) -{ - Fl_Tree_Item *n = (Fl_Tree_Item*)data; - n->open_toggle(); - FlGui::instance()->onelab->redrawTree(); -} - void onelabGroup::rebuildTree() { _itemWidth = (int)(0.4 * _tree->w()); diff --git a/Fltk/onelabGroup.h b/Fltk/onelabGroup.h index ee7c35fe5bdaec9f7f7632763bd1383c55c13bd7..462726af4c2e2f772d017cff35b3a48812112adc 100644 --- a/Fltk/onelabGroup.h +++ b/Fltk/onelabGroup.h @@ -27,6 +27,7 @@ class onelabGroup : public Fl_Group{ std::string _title; bool _stop; int _itemWidth; + std::set<std::string> _manuallyClosed; template <class T> void _addParameter(T &p); Fl_Widget *_addParameterWidget(onelab::number &p, Fl_Tree_Item *n, bool highlight, Fl_Color c); @@ -55,6 +56,18 @@ class onelabGroup : public Fl_Group{ _tree->item_pathname(path, 1024, item); return std::string(path); } + void insertInManuallyClosed(const std::string &path) + { + _manuallyClosed.insert(path); + } + void removeFromManuallyClosed(const std::string &path) + { + _manuallyClosed.erase(path); + } + bool isManuallyClosed(const std::string &path) + { + return _manuallyClosed.find(path) != _manuallyClosed.end(); + } viewButton *getViewButton(int num); void addSolver(const std::string &name, const std::string &exe, const std::string &hostName, int index);