Fixes FLUID shortcut generation

and makes the C++ code human readable
This commit is contained in:
Matthias Melcher 2024-02-10 14:28:27 +01:00
parent f4af40fe55
commit 1ed14867e6
2 changed files with 25 additions and 12 deletions

View File

@ -396,14 +396,20 @@ void Fl_Menu_Item_Type::write_item(Fd_Code_Writer& f) {
f.write_c("\"\"");
if (((Fl_Button*)o)->shortcut()) {
int s = ((Fl_Button*)o)->shortcut();
if (g_project.use_FL_COMMAND && (s & (FL_CTRL|FL_META))) {
f.write_c(", ");
if (s & FL_COMMAND) f.write_c("FL_COMMAND|");
if (s & FL_CONTROL) f.write_c("FL_CONTROL|");
f.write_c("0x%x, ", s & ~(FL_CTRL|FL_META));
f.write_c(", ");
if (g_project.use_FL_COMMAND) {
if (s & FL_COMMAND) { f.write_c("FL_COMMAND|"); s &= ~FL_COMMAND; }
if (s & FL_CONTROL) { f.write_c("FL_CONTROL|"); s &= ~FL_CONTROL; }
} else {
f.write_c(", 0x%x, ", s);
if (s & FL_CTRL) { f.write_c("FL_CTRL|"); s &= ~FL_CTRL; }
if (s & FL_META) { f.write_c("FL_META|"); s &= ~FL_META; }
}
if (s & FL_SHIFT) { f.write_c("FL_SHIFT|"); s &= ~FL_SHIFT; }
if (s & FL_ALT) { f.write_c("FL_ALT|"); s &= ~FL_ALT; }
if ((s < 127) && isprint(s))
f.write_c("'%c', ", s);
else
f.write_c("0x%x, ", s);
} else {
f.write_c(", 0, ");
}

View File

@ -3102,14 +3102,21 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) {
else if (is_a(ID_Value_Input)) shortcut = ((Fl_Value_Input*)o)->shortcut();
else if (is_a(ID_Text_Display)) shortcut = ((Fl_Text_Display*)o)->shortcut();
if (shortcut) {
if (g_project.use_FL_COMMAND && (shortcut & (FL_CTRL|FL_META))) {
f.write_c("%s%s->shortcut(", f.indent(), var);
if (shortcut & FL_COMMAND) f.write_c("FL_COMMAND|");
if (shortcut & FL_CONTROL) f.write_c("FL_CONTROL|");
f.write_c("0x%x);\n", shortcut & ~(FL_CTRL|FL_META));
int s = shortcut;
f.write_c("%s%s->shortcut(", f.indent(), var);
if (g_project.use_FL_COMMAND) {
if (s & FL_COMMAND) { f.write_c("FL_COMMAND|"); s &= ~FL_COMMAND; }
if (s & FL_CONTROL) { f.write_c("FL_CONTROL|"); s &= ~FL_CONTROL; }
} else {
f.write_c("%s%s->shortcut(0x%x);\n", f.indent(), var, shortcut);
if (s & FL_CTRL) { f.write_c("FL_CTRL|"); s &= ~FL_CTRL; }
if (s & FL_META) { f.write_c("FL_META|"); s &= ~FL_META; }
}
if (s & FL_SHIFT) { f.write_c("FL_SHIFT|"); s &= ~FL_SHIFT; }
if (s & FL_ALT) { f.write_c("FL_ALT|"); s &= ~FL_ALT; }
if ((s < 127) && isprint(s))
f.write_c("'%c');\n", s);
else
f.write_c("0x%x);\n", s);
}
if (is_a(ID_Button)) {