diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-01-05 13:51:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-05 13:51:30 +0100 |
| commit | 8826dca1066361b474139bcc5aeed2e3a5246ed0 (patch) | |
| tree | 6819629ff3f9f014269c7cee090ab20a824af6ad /fluid | |
| parent | 4d1a508c7e4d28fd53129da79f068a275d7160bd (diff) | |
Add close buttons for individual tabs in Fl_Tabs (#628)
Add close buttons for Fl_Tabs
Introducing callback reasons
FLUID shows all FL_WHEN_... options
Adding Fl_Tabs overflow types
Improved test/tabs to show new features
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/CodeEditor.cxx | 2 | ||||
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 59 | ||||
| -rw-r--r-- | fluid/Shortcut_Button.cxx | 34 |
3 files changed, 68 insertions, 27 deletions
diff --git a/fluid/CodeEditor.cxx b/fluid/CodeEditor.cxx index d4b4dee91..40fe667fc 100644 --- a/fluid/CodeEditor.cxx +++ b/fluid/CodeEditor.cxx @@ -197,7 +197,7 @@ int CodeEditor::auto_indent(int, CodeEditor* e) { } e->show_insert_position(); e->set_changed(); - if (e->when()&FL_WHEN_CHANGED) e->do_callback(); + if (e->when()&FL_WHEN_CHANGED) e->do_callback(FL_REASON_CHANGED); free(text); diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index cab346b5d..08396e85c 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -1110,12 +1110,20 @@ void down_box_cb(Fl_Choice* i, void *v) { //////////////////////////////////////////////////////////////// Fl_Menu_Item whenmenu[] = { + // set individual bits {"FL_WHEN_CHANGED",0,0,(void*)FL_WHEN_CHANGED, FL_MENU_TOGGLE}, {"FL_WHEN_NOT_CHANGED",0,0,(void*)FL_WHEN_NOT_CHANGED, FL_MENU_TOGGLE}, {"FL_WHEN_RELEASE",0,0,(void*)FL_WHEN_RELEASE, FL_MENU_TOGGLE}, {"FL_WHEN_ENTER_KEY",0,0,(void*)FL_WHEN_ENTER_KEY, FL_MENU_TOGGLE}, + {"FL_WHEN_CLOSED",0,0,(void*)FL_WHEN_CLOSED, FL_MENU_TOGGLE|FL_MENU_DIVIDER}, + // set bit combinations + {"FL_WHEN_NEVER",0,0,(void*)FL_WHEN_NEVER}, + {"FL_WHEN_RELEASE_ALWAYS",0,0,(void*)FL_WHEN_RELEASE_ALWAYS}, + {"FL_WHEN_ENTER_KEY_ALWAYS",0,0,(void*)FL_WHEN_ENTER_KEY_ALWAYS}, + {"FL_WHEN_ENTER_KEY_CHANGED",0,0,(void*)FL_WHEN_ENTER_KEY_CHANGED}, {0}}; + static Fl_Menu_Item whensymbolmenu[] = { /* 0 */ {"FL_WHEN_NEVER",0,0,(void*)FL_WHEN_NEVER}, /* 1 */ {"FL_WHEN_CHANGED",0,0,(void*)FL_WHEN_CHANGED}, @@ -1136,23 +1144,48 @@ static Fl_Menu_Item whensymbolmenu[] = { {0} }; +// Return a text string representing the Fl_When value n +const char* when_symbol_name(int n) { + static char sym[128]; + if (n == FL_WHEN_CLOSED) { + strcpy(sym, "FL_WHEN_CLOSED"); + } else { + strcpy(sym, whensymbolmenu[n&15].label()); + if (n & FL_WHEN_CLOSED) + strcat(sym, " | FL_WHEN_CLOSED"); + } + return sym; +} + +// Set the check marks in the "when()" menu according to the Fl_When value n +void set_whenmenu(int n) { + if (n&FL_WHEN_CHANGED) whenmenu[0].set(); else whenmenu[0].clear(); + if (n&FL_WHEN_NOT_CHANGED) whenmenu[1].set(); else whenmenu[1].clear(); + if (n&FL_WHEN_RELEASE) whenmenu[2].set(); else whenmenu[2].clear(); + if (n&FL_WHEN_ENTER_KEY) whenmenu[3].set(); else whenmenu[3].clear(); + if (n&FL_WHEN_CLOSED) whenmenu[4].set(); else whenmenu[4].clear(); +} + void when_cb(Fl_Menu_Button* i, void *v) { if (v == LOAD) { if (current_widget->is_menu_item()) {i->deactivate(); return;} else i->activate(); - int n = current_widget->o->when() & 15; - if (n&1) whenmenu[0].set(); else whenmenu[0].clear(); - if (n&2) whenmenu[1].set(); else whenmenu[1].clear(); - if (n&4) whenmenu[2].set(); else whenmenu[2].clear(); - if (n&8) whenmenu[3].set(); else whenmenu[3].clear(); - w_when_box->label(whensymbolmenu[n].label()); + int n = current_widget->o->when(); + set_whenmenu(n); + w_when_box->copy_label(when_symbol_name(n)); } else { int mod = 0; int n = 0; - if (whenmenu[0].value()) n |= 1; - if (whenmenu[1].value()) n |= 2; - if (whenmenu[2].value()) n |= 4; - if (whenmenu[3].value()) n |= 8; - w_when_box->label(whensymbolmenu[n].label()); + if (i->mvalue() && ((i->mvalue()->flags & FL_MENU_TOGGLE) == 0) ) { + n = (int)i->mvalue()->argument(); + set_whenmenu(n); + } else { + if (whenmenu[0].value()) n |= FL_WHEN_CHANGED; + if (whenmenu[1].value()) n |= FL_WHEN_NOT_CHANGED; + if (whenmenu[2].value()) n |= FL_WHEN_RELEASE; + if (whenmenu[3].value()) n |= FL_WHEN_ENTER_KEY; + if (whenmenu[4].value()) n |= FL_WHEN_CLOSED; + } + w_when_box->copy_label(when_symbol_name(n)); for (Fl_Type *o = Fl_Type::first; o; o = o->next) { if (o->selected && o->is_widget()) { Fl_Widget_Type* q = (Fl_Widget_Type*)o; @@ -3074,8 +3107,7 @@ void Fl_Widget_Type::write_widget_code() { if (ww==FL_WHEN_NOT_CHANGED) ww = FL_WHEN_NEVER; if (ww != tplate->when() || subclass()) - write_c("%s%s->when(%s);\n", indent(), var, - item_name(whensymbolmenu, ww)); + write_c("%s%s->when(%s);\n", indent(), var, when_symbol_name(ww)); if (!o->visible() && o->parent()) write_c("%s%s->hide();\n", indent(), var); if (!o->active()) @@ -3552,6 +3584,7 @@ void Fl_Widget_Type::copy_properties() { w->labelsize(o->labelsize()); w->labelcolor(o->labelcolor()); w->align(o->align()); + w->when(o->when()); // copy all attributes specific to widgets derived from Fl_Button if (is_button()) { diff --git a/fluid/Shortcut_Button.cxx b/fluid/Shortcut_Button.cxx index 134029082..e0ce2c9b2 100644 --- a/fluid/Shortcut_Button.cxx +++ b/fluid/Shortcut_Button.cxx @@ -1,7 +1,7 @@ // // Widget type code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -86,9 +86,10 @@ int Shortcut_Button::handle(int e) { } /** \class Widget_Bin_Button - A button for the widget bin that allows the user to drag widgets into a window. - Dragging and dropping a new widget makes it easy for the user to position - a widget inside a window or group. + The Widget_Bin_Button button is a button that can be used in the widget bin to + allow the user to drag and drop widgets into a window or group. This feature + makes it easy for the user to position a widget at a specific location within + the window or group. */ /** @@ -124,8 +125,9 @@ int Widget_Bin_Button::handle(int inEvent) } /** \class Widget_Bin_Window_Button - This button is used by the widget bin to create new windows by drag'n'drop. - The new window will be created wherever the user drops it on the desktop. + The Widget_Bin_Window_Button button is used in the widget bin to create new + windows by dragging and dropping. When the button is dragged and dropped onto + the desktop, a new window will be created at the drop location. */ /** @@ -179,9 +181,10 @@ int Widget_Bin_Window_Button::handle(int inEvent) } /** \class Fluid_Coord_Input - An Input field for widget coordinates and sizes. - This widget adds basic math capability to the text input field and a number - of variables that can be used in the formula. + The Fluid_Coord_Input widget is an input field for entering widget coordinates + and sizes. It includes basic math capabilities and allows the use of variables + in formulas. This widget is useful for specifying precise positions and + dimensions for widgets in a graphical user interface. */ /** @@ -298,10 +301,15 @@ int Fluid_Coord_Input::eval(uchar *&s, int prio) const { /** Evaluate a formula into an integer. - The interpreter understands unary plus and minus, basic integer math - (+, -, *, /), brackets, and can handle a user defined list of variables - by name. There is no error checking. We assume that the formula is - entered correctly. + + The Fluid_Coord_Input widget includes a formula interpreter that allows you + to evaluate a string containing a mathematical formula and obtain the result + as an integer. The interpreter supports unary plus and minus, basic integer + math operations (such as addition, subtraction, multiplication, and division), + and brackets. It also allows you to define a list of variables by name and use + them in the formula. The interpreter does not perform error checking, so it is + assumed that the formula is entered correctly. + \param s formula as a C string \return the calculated value */ |
