Fluid: hiding MergeBack form the main menu.
Hiding menuitem if option is not available. Also testing the new FL_BEFORE_MENU event.
This commit is contained in:
parent
fc91880faf
commit
219c623b4b
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 };
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
59
fluid/widgets/App_Menu_Bar.cxx
Normal file
59
fluid/widgets/App_Menu_Bar.cxx
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
41
fluid/widgets/App_Menu_Bar.h
Normal file
41
fluid/widgets/App_Menu_Bar.h
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user