diff options
| -rw-r--r-- | fluid/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | fluid/Fluid.cxx | 4 | ||||
| -rw-r--r-- | fluid/Fluid.h | 5 | ||||
| -rw-r--r-- | fluid/app/Snap_Action.cxx | 2 | ||||
| -rw-r--r-- | fluid/app/shell_command.cxx | 2 | ||||
| -rw-r--r-- | fluid/tools/autodoc.cxx | 2 | ||||
| -rw-r--r-- | fluid/widgets/App_Menu_Bar.cxx | 59 | ||||
| -rw-r--r-- | fluid/widgets/App_Menu_Bar.h | 41 |
8 files changed, 111 insertions, 6 deletions
diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt index 5d6580c71..63a82b05e 100644 --- a/fluid/CMakeLists.txt +++ b/fluid/CMakeLists.txt @@ -61,6 +61,7 @@ set(CPPFILES rsrcs/pixmaps.cxx tools/autodoc.cxx tools/filename.cxx + widgets/App_Menu_Bar.cxx widgets/Code_Editor.cxx widgets/Code_Viewer.cxx widgets/Text_Viewer.cxx @@ -112,6 +113,7 @@ set(HEADERFILES rsrcs/pixmaps.h tools/autodoc.h tools/filename.h + widgets/App_Menu_Bar.h widgets/Code_Editor.h widgets/Code_Viewer.h widgets/Text_Viewer.h diff --git a/fluid/Fluid.cxx b/fluid/Fluid.cxx index 48dd7dcfb..9a113c478 100644 --- a/fluid/Fluid.cxx +++ b/fluid/Fluid.cxx @@ -36,6 +36,7 @@ #include "panels/about_panel.h" #include "rsrcs/pixmaps.h" #include "tools/autodoc.h" +#include "widgets/App_Menu_Bar.h" #include "widgets/Node_Browser.h" #include <FL/Fl.H> @@ -44,7 +45,6 @@ #include <FL/platform.H> // for fl_open_callback #endif #include <FL/Fl_Help_Dialog.H> -#include <FL/Fl_Menu_Bar.H> #include <FL/Fl_PNG_Image.H> #include <FL/Fl_Native_File_Chooser.H> #include <FL/Fl_Printer.H> @@ -1157,7 +1157,7 @@ void Application::make_main_window() { o->box(FL_FLAT_BOX); o->tooltip("Double-click to view or change an item."); main_window->resizable(o); - main_menubar = new Fl_Menu_Bar(0,0,BROWSERWIDTH,MENUHEIGHT); + main_menubar = new fld::widget::App_Menu_Bar(0,0,BROWSERWIDTH,MENUHEIGHT); main_menubar->menu(main_menu); // quick access to all dynamic menu items save_item = (Fl_Menu_Item*)main_menubar->find_item(menu_file_save_cb); diff --git a/fluid/Fluid.h b/fluid/Fluid.h index 1857518ee..e533e6b68 100644 --- a/fluid/Fluid.h +++ b/fluid/Fluid.h @@ -50,6 +50,9 @@ namespace fld { namespace app { class Layout_List; } +namespace widget { +class App_Menu_Bar; +} /** Indicate the storage location for tools like layout suites and shell macros. @@ -117,7 +120,7 @@ public: // Member Variables // TODO: make this into a class: app::GUI Fl_Window *main_window { nullptr }; static Fl_Menu_Item main_menu[]; - Fl_Menu_Bar *main_menubar { nullptr }; + fld::widget::App_Menu_Bar *main_menubar { nullptr }; Fl_Menu_Item *save_item { nullptr }; Fl_Menu_Item *history_item { nullptr }; Fl_Menu_Item *widgetbin_item { nullptr }; diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx index d67e074cb..941d4217e 100644 --- a/fluid/app/Snap_Action.cxx +++ b/fluid/app/Snap_Action.cxx @@ -22,9 +22,9 @@ #include "nodes/Group_Node.h" #include "nodes/Window_Node.h" #include "panels/settings_panel.h" +#include "widgets/App_Menu_Bar.h" #include <FL/fl_draw.H> -#include <FL/Fl_Menu_Bar.H> #include <FL/fl_string_functions.h> #include <math.h> diff --git a/fluid/app/shell_command.cxx b/fluid/app/shell_command.cxx index 3bb252cae..e0080dfd5 100644 --- a/fluid/app/shell_command.cxx +++ b/fluid/app/shell_command.cxx @@ -102,9 +102,9 @@ #include "io/Project_Reader.h" #include "io/Project_Writer.h" #include "panels/settings_panel.h" +#include "widgets/App_Menu_Bar.h" #include <FL/Fl_Double_Window.H> -#include <FL/Fl_Menu_Bar.H> #include <FL/fl_message.H> #include <FL/fl_string_functions.h> diff --git a/fluid/tools/autodoc.cxx b/fluid/tools/autodoc.cxx index d7d8b14e4..ee9f289b0 100644 --- a/fluid/tools/autodoc.cxx +++ b/fluid/tools/autodoc.cxx @@ -27,13 +27,13 @@ #include "panels/function_panel.h" #include "panels/settings_panel.h" #include "panels/codeview_panel.h" +#include "widgets/App_Menu_Bar.h" #include "widgets/Node_Browser.h" #include <FL/Enumerations.H> #include <FL/fl_draw.H> #include <FL/Fl_Image_Surface.H> #include <FL/Fl_PNG_Image.H> -#include <FL/Fl_Menu_Bar.H> extern Fl_Double_Window *settings_window; diff --git a/fluid/widgets/App_Menu_Bar.cxx b/fluid/widgets/App_Menu_Bar.cxx new file mode 100644 index 000000000..5dc430c69 --- /dev/null +++ b/fluid/widgets/App_Menu_Bar.cxx @@ -0,0 +1,59 @@ +// +// Application Menu Bar widget for the Fast Light Tool Kit (FLTK). +// +// Copyright 2025 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 +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// +// Include necessary headers... +// + +#include "widgets/App_Menu_Bar.h" + +#include "Fluid.h" +#include "Project.h" + +using namespace fld; +using namespace fld::widget; + +extern void mergeback_cb(Fl_Widget *, void *); + +/** + Create a fld::widget::App_Menu_Bar widget. + \param[in] X, Y, W, H position and size of the widget + \param[in] L optional label + */ +App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) +: Fl_Menu_Bar(X, Y, W, H, L) +{ +} + +/** + Set menu item visibility and active state before menu pops up. + */ +int App_Menu_Bar::handle(int event) +{ + Fl_Menu_Item *mi = nullptr; + if (event == FL_BEFORE_MENU) { + mi = (Fl_Menu_Item*)find_item(mergeback_cb); + if (mi && Fluid.proj.write_mergeback_data) + mi->show(); + else + mi->hide(); + return 1; + } else { + return Fl_Menu_Bar::handle(event); + } +} + + diff --git a/fluid/widgets/App_Menu_Bar.h b/fluid/widgets/App_Menu_Bar.h new file mode 100644 index 000000000..62487334f --- /dev/null +++ b/fluid/widgets/App_Menu_Bar.h @@ -0,0 +1,41 @@ +// +// Application Menu Bar widget for the Fast Light Tool Kit (FLTK). +// +// Copyright 2025 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 +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FLUID_WIDGETS_APP_MENU_BAR_H +#define FLUID_WIDGETS_APP_MENU_BAR_H + +// +// Include necessary headers... +// + +#include <FL/Fl_Menu_Bar.H> + +namespace fld { +namespace widget { + +/** + A text viewer with an additional highlighting color scheme. + */ +class App_Menu_Bar : public Fl_Menu_Bar { +public: + App_Menu_Bar(int X, int Y, int W, int H, const char *L = nullptr); + int handle(int event) override; +}; + +} // namespace widget +} // namespace fld + +#endif // FLUID_WIDGETS_APP_MENU_BAR_H |
