FLUID mark project change when changing window visibility

This commit is contained in:
Matthias Melcher
2023-07-11 14:27:02 +02:00
parent 676bad861a
commit 71088b7fe2
4 changed files with 42 additions and 9 deletions
+37 -5
View File
@@ -140,13 +140,29 @@ static int overlays_invisible;
class Overlay_Window : public Fl_Overlay_Window { class Overlay_Window : public Fl_Overlay_Window {
void draw() FL_OVERRIDE; void draw() FL_OVERRIDE;
void draw_overlay() FL_OVERRIDE; void draw_overlay() FL_OVERRIDE;
static void close_cb(Overlay_Window *self, void*);
public: public:
Fl_Window_Type *window; Fl_Window_Type *window;
int handle(int) FL_OVERRIDE; int handle(int) FL_OVERRIDE;
Overlay_Window(int W,int H) : Fl_Overlay_Window(W,H) {Fl_Group::current(0);} Overlay_Window(int W,int H) : Fl_Overlay_Window(W,H) {
Fl_Group::current(0);
callback((Fl_Callback*)close_cb);
}
void resize(int,int,int,int) FL_OVERRIDE; void resize(int,int,int,int) FL_OVERRIDE;
uchar *read_image(int &ww, int &hh); uchar *read_image(int &ww, int &hh);
}; };
/**
\brief User closes the window, so we mark the .fl file as changed.
Mark the .fl file a changed, but don;t mark the source files as changed.
\param self pointer to this window
*/
void Overlay_Window::close_cb(Overlay_Window *self, void*) {
if (self->visible())
set_modflag(1, -2);
self->hide();
}
void Overlay_Window::draw() { void Overlay_Window::draw() {
const int CHECKSIZE = 8; const int CHECKSIZE = 8;
// see if box is clear or a frame or rounded: // see if box is clear or a frame or rounded:
@@ -265,9 +281,11 @@ void Fl_Window_Type::move_child(Fl_Type* cc, Fl_Type* before) {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Double-click on window widget shows the window, or if already shown, /**
// it shows the control panel. \brief Show the Window Type editor window without setting the modified flag.
void Fl_Window_Type::open() { \see Fl_Window_Type::open()
*/
void Fl_Window_Type::open_() {
Overlay_Window *w = (Overlay_Window *)o; Overlay_Window *w = (Overlay_Window *)o;
if (w->shown()) { if (w->shown()) {
w->show(); w->show();
@@ -281,6 +299,20 @@ void Fl_Window_Type::open() {
w->image(Fl::scheme_bg_); w->image(Fl::scheme_bg_);
} }
/**
\brief Show the Window Type editor window and set the modified flag if needed.
Double-click on window widget shows the window, or if already shown, it shows
the control panel.
\see Fl_Window_Type::open_()
*/
void Fl_Window_Type::open() {
Overlay_Window *w = (Overlay_Window *)o;
if (!w->visible()) {
set_modflag(1, -2);
}
open_();
}
// Read an image of the window // Read an image of the window
uchar *Fl_Window_Type::read_image(int &ww, int &hh) { uchar *Fl_Window_Type::read_image(int &ww, int &hh) {
Overlay_Window *w = (Overlay_Window *)o; Overlay_Window *w = (Overlay_Window *)o;
@@ -1059,7 +1091,7 @@ void Fl_Window_Type::read_property(Fd_Project_Reader &f, const char *c) {
} else if (!strcmp(c,"non_modal")) { } else if (!strcmp(c,"non_modal")) {
non_modal = 1; non_modal = 1;
} else if (!strcmp(c, "visible")) { } else if (!strcmp(c, "visible")) {
if (Fl::first_window()) open(); // only if we are using user interface if (Fl::first_window()) open_(); // only if we are using user interface
} else if (!strcmp(c,"noborder")) { } else if (!strcmp(c,"noborder")) {
((Fl_Window*)o)->border(0); ((Fl_Window*)o)->border(0);
} else if (!strcmp(c,"xclass")) { } else if (!strcmp(c,"xclass")) {
+1
View File
@@ -67,6 +67,7 @@ protected:
int recalc; // set by fix_overlay() int recalc; // set by fix_overlay()
void moveallchildren(); void moveallchildren();
int pixmapID() FL_OVERRIDE { return 1; } int pixmapID() FL_OVERRIDE { return 1; }
void open_();
public: public:
+2 -2
View File
@@ -107,7 +107,7 @@ decl {void scheme_cb(Fl_Scheme_Choice *, void *);} {public local
Function {make_settings_window()} {open Function {make_settings_window()} {open
} { } {
Fl_Window settings_window { Fl_Window settings_window {
label {GUI Settings} open label {GUI Settings} open selected
xywh {617 332 340 580} type Double align 80 resizable xywh {617 332 340 580} type Double align 80 resizable
code0 {o->size_range(o->w(), o->h());} non_modal visible code0 {o->size_range(o->w(), o->h());} non_modal visible
} { } {
@@ -198,7 +198,7 @@ redraw_browser();}
callback {strncpy(G_external_editor_command, editor_command_input->value(), sizeof(G_external_editor_command)-1); callback {strncpy(G_external_editor_command, editor_command_input->value(), sizeof(G_external_editor_command)-1);
G_external_editor_command[sizeof(G_external_editor_command)-1] = 0; G_external_editor_command[sizeof(G_external_editor_command)-1] = 0;
fluid_prefs.set("external_editor_command", G_external_editor_command); fluid_prefs.set("external_editor_command", G_external_editor_command);
redraw_browser();} selected redraw_browser();}
tooltip {The editor command to open your external text editor. tooltip {The editor command to open your external text editor.
Include any necessary flags to ensure your editor does not background itself. Include any necessary flags to ensure your editor does not background itself.
Examples: Examples:
+2 -2
View File
@@ -1781,7 +1781,7 @@ void set_filename(const char *c) {
\param[in] mf 0 to clear the modflag, 1 to mark the design "modified", -1 to \param[in] mf 0 to clear the modflag, 1 to mark the design "modified", -1 to
ignore this parameter ignore this parameter
\param[in] mfc default -1 to let \c mf control \c modflag_c, 0 to mark the \param[in] mfc default -1 to let \c mf control \c modflag_c, 0 to mark the
code files current, 1 to mark it out of date. code files current, 1 to mark it out of date. -2 to ignore changes to mf.
*/ */
void set_modflag(int mf, int mfc) { void set_modflag(int mf, int mfc) {
const char *basename; const char *basename;
@@ -1796,7 +1796,7 @@ void set_modflag(int mf, int mfc) {
if (mfc==-1 && mf==1) if (mfc==-1 && mf==1)
mfc = mf; mfc = mf;
} }
if (mfc!=-1) { if (mfc>=0) {
modflag_c = mfc; modflag_c = mfc;
} }