diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp index 49ca7370f64645fa8f2d4eb5f655b7cb3c692f09..ad65c6943a5699d96fb92f09d9c072d9f3273cc2 100644 --- a/Fltk/onelabGroup.cpp +++ b/Fltk/onelabGroup.cpp @@ -322,6 +322,24 @@ static void setClosed(const std::string &path, std::vector<T> &ps, } } +static std::string getViewPathName(int num) +{ + if(num < 0 || num >= (int)PView::list.size()) return ""; + PViewOptions *opt = PView::list[num]->getOptions(); + std::ostringstream path; + path << "0Modules/Post-processing/"; + if(opt->group.size()) path << opt->group << "/"; + path << "View" << num; + return path.str(); +} + +static std::string getViewPath(int num) +{ + std::string s = getViewPathName(num); + std::string::size_type last = s.find_last_of('/'); + return s.substr(0, last); +} + static void setOpenedClosed(Fl_Tree_Item *item, int reason) { std::vector<onelab::number> numbers; @@ -336,6 +354,9 @@ static void setOpenedClosed(Fl_Tree_Item *item, int reason) setClosed(path, strings, "0"); setClosed(path, regions, "0"); setClosed(path, functions, "0"); + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(getViewPath(i) == path) PView::list[i]->getOptions()->closed = 0; + } break; case FL_TREE_REASON_CLOSED: FlGui::instance()->onelab->insertInManuallyClosed(path); @@ -343,6 +364,9 @@ static void setOpenedClosed(Fl_Tree_Item *item, int reason) setClosed(path, strings, "1"); setClosed(path, regions, "1"); setClosed(path, functions, "1"); + for(unsigned int i = 0; i < PView::list.size(); i++){ + if(getViewPath(i) == path) PView::list[i]->getOptions()->closed = 1; + } break; default: break; @@ -572,20 +596,9 @@ void onelabGroup::_addSolverMenu(int num) _tree->end(); } -static std::string _getViewPathName(int num) -{ - if(num < 0 || num >= (int)PView::list.size()) return ""; - PViewOptions *opt = PView::list[num]->getOptions(); - std::ostringstream path; - path << "0Modules/Post-processing/"; - if(opt->group.size()) path << opt->group << "/"; - path << "View" << num; - return path.str(); -} - void onelabGroup::_addViewMenu(int num) { - std::string path = _getViewPathName(num); + std::string path = getViewPathName(num); if(path.empty()) return; Fl_Tree_Item *n = _tree->add(path.c_str()); int ww = (int)(_baseWidth - (n->depth() + 1) * _indent); @@ -603,7 +616,7 @@ void onelabGroup::_addViewMenu(int num) viewButton *onelabGroup::getViewButton(int num) { - std::string path = _getViewPathName(num); + std::string path = getViewPathName(num); if(path.empty()) return 0; Fl_Tree_Item *n = _tree->find_item(path.c_str()); if(n){ @@ -615,7 +628,7 @@ viewButton *onelabGroup::getViewButton(int num) void onelabGroup::openCloseViewButton(int num) { - std::string path = _getViewPathName(num); + std::string path = getViewPathName(num); if(path.empty()) return; Fl_Tree_Item *n = _tree->find_item(path.c_str()); if(n){ diff --git a/Fltk/viewButton.cpp b/Fltk/viewButton.cpp index f58afa13f6397e91749cac95e0c40c0582d5b471..4a6e77a2166c76d54940efd4f45c33595b7dbde6 100644 --- a/Fltk/viewButton.cpp +++ b/Fltk/viewButton.cpp @@ -268,8 +268,8 @@ viewButton::viewButton(int x, int y, int w, int h, int num, Fl_Color col) PViewData *data = view->getData(); PViewOptions *opt = view->getOptions(); - // "-4" to leave a bit of white space to the right - _toggle = new Fl_Check_Button(x, y, w - popw - 4, h); + int ws = FL_NORMAL_SIZE - 2; // right margin to allow for scrollbar + _toggle = new Fl_Check_Button(x, y, w - popw - ws, h); _toggle->box(FL_FLAT_BOX); _toggle->color(col); _toggle->callback(view_toggle_cb, (void *)num); @@ -281,13 +281,13 @@ viewButton::viewButton(int x, int y, int w, int h, int num, Fl_Color col) strcpy(_tooltip, data->getFileName().c_str()); _toggle->tooltip(_tooltip); - _butt = new Fl_Button(x + w - popw - 4, y, popw, h, "@>"); + _butt = new Fl_Button(x + w - popw - ws, y, popw, h, "@>"); _butt->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP); _butt->tooltip("Show view options (Shift+w)"); _butt->box(FL_FLAT_BOX); _butt->color(col); _butt->selection_color(col); - _popup = new Fl_Menu_Button(x + w - popw - 4, y, popw, h); + _popup = new Fl_Menu_Button(x + w - popw - ws, y, popw, h); _popup->type(Fl_Menu_Button::POPUP123); _popup->add("Options", 'o',