Skip to content

Commit

Permalink
Moved template panel into UI folder
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Nov 16, 2024
1 parent 4813b0b commit 5b83ff0
Show file tree
Hide file tree
Showing 16 changed files with 1,178 additions and 659 deletions.
4 changes: 2 additions & 2 deletions fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(CPPFILES
ui/about_panel.cxx
ui/main_panel.cxx
ui/panel.cxx
ui/template_panel.cxx
widgets/bin_buttons.cxx
widgets/code_viewers.cxx
widgets/coord_input.cxx
Expand All @@ -60,7 +61,6 @@ set(CPPFILES
pixmaps.cxx
shell_command.cxx
codeview_panel.cxx
template_panel.cxx
widget_browser.cxx
widget_panel.cxx
)
Expand All @@ -77,6 +77,7 @@ set(HEADERFILES
ui/about_panel.h
ui/main_panel.h
ui/panel.h
ui/template_panel.h
streams/code_writer.h
streams/project_reader.h
streams/project_writer.h
Expand Down Expand Up @@ -105,7 +106,6 @@ set(HEADERFILES
pixmaps.h
shell_command.h
codeview_panel.h
template_panel.h
widget_browser.h
widget_panel.h
)
Expand Down
17 changes: 17 additions & 0 deletions fluid/application/application.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "project/project.h"
#include "fluid.h"
#include "widget_browser.h"
#include "ui/template_panel.h"

#include <FL/fl_ask.H>
#include "../src/flstring.h"
Expand Down Expand Up @@ -244,3 +245,19 @@ char* Application::cutfname(int which) {
return name[which];
}

/**
Open the template browser and load a new file from templates.
If the current project was modified, FLUID will give the user the opportunity
to save the old project first.
\return false if the operation was canceled or failed otherwise
*/
bool Application::new_project_from_template() {
// clear the current project first
if (new_project() == false)
return false;

// Now let the panel do the work.
return fluid::ui::template_panel.load_template();
}
2 changes: 2 additions & 0 deletions fluid/application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class Application {
const Fl_String &get_tmpdir();
/// Return the path and filename of a temporary file for cut or duplicated data.
static char* cutfname(int which = 0);
/// Pop up the template dialog and create a new project from a template.
bool new_project_from_template();
};

}; // namespace FLUID
Expand Down
18 changes: 7 additions & 11 deletions fluid/fluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "application/application.h"
#include "project/project.h"
#include "ui/main_panel.h"
#include "ui/template_panel.h"
#include "Fl_Type.h"
#include "Fl_Function_Type.h"
#include "Fl_Group_Type.h"
Expand All @@ -43,7 +44,7 @@
#include "settings_panel.h"
#include "function_panel.h"
#include "codeview_panel.h"
#include "template_panel.h"
#include "ui/template_panel.h"
#include "ui/about_panel.h"
#include "autodoc.h"

Expand Down Expand Up @@ -227,6 +228,8 @@ static void external_editor_timer(void*) {
// Fluid.project.save(v != NULL, v != (void *)2);
// }

#if 0

/**
Save a design template.
\todo We should document the concept of templates.
Expand Down Expand Up @@ -297,7 +300,6 @@ void save_as_template() {
return;
}

#if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
// Get the screenshot, if any...
Fl_Type *t;

Expand Down Expand Up @@ -325,17 +327,9 @@ void save_as_template() {
return;
}

# if 0 // The original PPM output code...
strcpy(ext, ".ppm");
fp = fl_fopen(filename, "wb");
fprintf(fp, "P6\n%d %d 255\n", w, h);
fwrite(pixels, w * h, 3, fp);
fclose(fp);
# endif // 0

delete[] pixels;
#endif // HAVE_LIBPNG && HAVE_LIBZ
}
#endif

//-> application::callbacks
/**
Expand Down Expand Up @@ -401,6 +395,7 @@ void quit_fluid() {
exit(0);
}

#if 0
//-> application::callbacks
/**
Open the template browser and load a new file from templates.
Expand Down Expand Up @@ -510,6 +505,7 @@ bool new_project_from_template() {

return true;
}
#endif

#ifdef __APPLE__
/**
Expand Down
9 changes: 9 additions & 0 deletions fluid/project/project.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "project/project.h"
#include "application/application.h"
#include "ui/main_panel.h"
#include "ui/template_panel.h"
#include "fluid.h"
#include "streams/project_reader.h"
#include "streams/project_writer.h"
Expand Down Expand Up @@ -679,3 +680,11 @@ void Project::write_strings() {
}
}
}

/**
Save a design template.
\todo We should document the concept of templates.
*/
void Project::save_as_template() {
fluid::ui::template_panel.add(this);
}
2 changes: 2 additions & 0 deletions fluid/project/project.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class Project {
const char *filename { nullptr };
/// Used as a counter to set the .fl project dir as the current directory.
char in_project_dir { 0 };
/// open a dialog box to save this project as a template
void save_as_template();
};

} // namespace fluid
Expand Down
Loading

0 comments on commit 5b83ff0

Please sign in to comment.