From 8e864bae21bcebb3d40c140dca44f95bb5b95e94 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 11 Dec 2021 13:15:23 +0100 Subject: Fluid PR 313: update subtype menu to show "Normal" when deactivated. Based on jdpalmer's pull request: If the subtype menu is disabled because there are no subtypes, the deactivated menu will still display the subtype of the last widget that had a subtype value. Clearing the menu when there are no subtypes fixes this minor inconsistency. --- fluid/Fl_Widget_Type.cxx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 00bc95c41..37cfa5fc3 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -1726,21 +1726,30 @@ void value_cb(Fl_Value_Input* i, void* v) { Fl_Menu_Item *Fl_Widget_Type::subtypes() {return 0;} void subtype_cb(Fl_Choice* i, void* v) { + static Fl_Menu_Item empty_type_menu[] = { + {"Normal",0,0,(void*)0}, + {0}}; + if (v == LOAD) { Fl_Menu_Item* m = current_widget->subtypes(); - if (!m) {i->deactivate(); return;} - i->menu(m); - int j; - for (j = 0;; j++) { - if (!m[j].text) {j = 0; break;} - if (current_widget->is_spinner()) { - if (m[j].argument() == ((Fl_Spinner*)current_widget->o)->type()) break; - } else { - if (m[j].argument() == current_widget->o->type()) break; + if (!m) { + i->menu(empty_type_menu); + i->value(0); + i->deactivate(); + } else { + i->menu(m); + int j; + for (j = 0;; j++) { + if (!m[j].text) {j = 0; break;} + if (current_widget->is_spinner()) { + if (m[j].argument() == ((Fl_Spinner*)current_widget->o)->type()) break; + } else { + if (m[j].argument() == current_widget->o->type()) break; + } } + i->value(j); + i->activate(); } - i->value(j); - i->activate(); i->redraw(); } else { int mod = 0; -- cgit v1.2.3