Skip to content
Snippets Groups Projects
Commit 183680d7 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

replace model chooser by simple menu

parent 9245e3b9
No related branches found
No related tags found
No related merge requests found
...@@ -89,64 +89,6 @@ int arrowEditor(const char *title, double &a, double &b, double &c) ...@@ -89,64 +89,6 @@ int arrowEditor(const char *title, double &a, double &b, double &c)
return 0; return 0;
} }
// Model chooser
static void model_switch_cb(Fl_Widget* w, void *data)
{
Fl_Select_Browser *b = (Fl_Select_Browser *)w;
if(b->value()){
GModel::current(b->value() - 1);
SetBoundingBox();
for(unsigned int i = 0; i < GModel::list.size(); i++)
GModel::list[i]->setVisibility(0);
GModel::current()->setVisibility(1);
}
if(w->window()) w->window()->hide();
CTX::instance()->mesh.changed = ENT_ALL;
FlGui::instance()->setGraphicTitle(GModel::current()->getFileName());
FlGui::instance()->resetVisibility();
drawContext::global()->draw();
}
int modelChooser()
{
struct _menu{
Fl_Menu_Window *window;
Fl_Hold_Browser *browser;
Fl_Check_Button *butt;
};
static _menu *menu = 0;
const int WW = 200;
if(!menu){
menu = new _menu;
menu->window = new Fl_Menu_Window(WW, 6 * BH);
if(CTX::instance()->nonModalWindows) menu->window->set_non_modal();
menu->window->border(0);
Fl_Box *l = new Fl_Box(0, 0, WW, BH, "Select active model:");
l->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
menu->browser = new Fl_Hold_Browser(0, BH, WW, 5 * BH);
menu->browser->callback(model_switch_cb);
menu->browser->when(FL_WHEN_RELEASE_ALWAYS);
menu->window->end();
}
menu->window->hotspot(menu->window);
menu->browser->clear();
for(unsigned int i = 0; i < GModel::list.size(); i++){
char tmp[256];
sprintf(tmp, "Model [%d] <<%s>>", i, GModel::list[i]->getName().c_str());
menu->browser->add(tmp);
if(GModel::list[i] == GModel::current()) menu->browser->value(i + 1);
}
if(menu->window->non_modal() && !menu->window->shown())
menu->window->show(); // fix ordering
menu->window->show();
return 0;
}
// Connection and pattern choosers // Connection and pattern choosers
class historyBrowser : public Fl_Hold_Browser { class historyBrowser : public Fl_Hold_Browser {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
int arrowEditor(const char *title, double &a, double &b, double &c); int arrowEditor(const char *title, double &a, double &b, double &c);
int modelChooser();
std::string connectionChooser(); std::string connectionChooser();
std::string patternChooser(); std::string patternChooser();
......
...@@ -2394,22 +2394,59 @@ void quick_access_cb(Fl_Widget *w, void *data) ...@@ -2394,22 +2394,59 @@ void quick_access_cb(Fl_Widget *w, void *data)
} }
} }
void status_options_cb(Fl_Widget *w, void *data) static void model_switch_cb(Fl_Widget* w, void *data)
{ {
const char *str = (const char*)data; int index = (intptr_t)data;
if(!strcmp(str, "model")){ // model selection GModel::current(index);
modelChooser(); SetBoundingBox();
for(unsigned int i = 0; i < GModel::list.size(); i++)
GModel::list[i]->setVisibility(0);
GModel::current()->setVisibility(1);
CTX::instance()->mesh.changed = ENT_ALL;
FlGui::instance()->setGraphicTitle(GModel::current()->getFileName());
FlGui::instance()->resetVisibility();
drawContext::global()->draw();
} }
else if(!strcmp(str, "?")){ // display options
void status_options_cb(Fl_Widget *w, void *data)
{
if(!data) return;
std::string what((const char*)data);
if(what == "model"){ // model selection
std::vector<char*> tofree;
std::vector<Fl_Menu_Item> menu;
int selected = 0;
for(unsigned int i = 0; i < GModel::list.size(); i++){
char tmp[256];
sprintf(tmp, "Model [%d] <<%s>> ", i, GModel::list[i]->getName().c_str());
char *str = strdup(tmp);
Fl_Menu_Item menuItem = {str, 0, model_switch_cb, (void*)i, FL_MENU_RADIO};
if(GModel::list[i] == GModel::current()){
selected = i;
menuItem.flags |= FL_MENU_VALUE;
}
menu.push_back(menuItem);
tofree.push_back(str);
}
Fl_Menu_Item it = {0};
menu.push_back(it);
Fl_Menu_Item *m = (Fl_Menu_Item*)(&menu[0])->popup(Fl::event_x(), Fl::event_y(),
0, &menu[selected], 0);
if(m) m->do_callback(0);
for(unsigned int i = 0; i < tofree.size(); i++) free(tofree[i]);
drawContext::global()->draw();
}
else if(what == "?"){ // display options
help_options_cb(0, 0); help_options_cb(0, 0);
FlGui::instance()->help->options->show(); FlGui::instance()->help->options->show();
} }
else if(!strcmp(str, "p")){ // toggle projection mode else if(what == "p"){ // toggle projection mode
opt_general_orthographic(0, GMSH_SET | GMSH_GUI, opt_general_orthographic(0, GMSH_SET | GMSH_GUI,
!opt_general_orthographic(0, GMSH_GET, 0)); !opt_general_orthographic(0, GMSH_GET, 0));
drawContext::global()->draw(); drawContext::global()->draw();
} }
else if(!strcmp(str, "quick_access")){ // quick access menu else if(what == "quick_access"){ // quick access menu
static Fl_Menu_Item menu[] = { static Fl_Menu_Item menu[] = {
{ "Axes", 0, quick_access_cb, (void*)"axes", { "Axes", 0, quick_access_cb, (void*)"axes",
FL_MENU_TOGGLE }, FL_MENU_TOGGLE },
...@@ -2507,7 +2544,7 @@ void status_options_cb(Fl_Widget *w, void *data) ...@@ -2507,7 +2544,7 @@ void status_options_cb(Fl_Widget *w, void *data)
if(picked && picked->callback()) picked->do_callback(0, picked->user_data()); if(picked && picked->callback()) picked->do_callback(0, picked->user_data());
drawContext::global()->draw(); drawContext::global()->draw();
} }
else if(!strcmp(str, "S")){ // mouse selection else if(what == "S"){ // mouse selection
if(CTX::instance()->mouseSelection){ if(CTX::instance()->mouseSelection){
opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0); opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0);
for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++) for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment