From 3e79b658450e4a18ea8c34a2e13d27e1e9801389 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 14 May 2010 17:51:16 +0000
Subject: [PATCH] gui for mpeg

---
 Fltk/fileDialogs.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++
 Fltk/fileDialogs.h   |  1 +
 Fltk/menuWindow.cpp  |  4 ++-
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp
index 9bf4bcf55d..4e12b5063b 100644
--- a/Fltk/fileDialogs.cpp
+++ b/Fltk/fileDialogs.cpp
@@ -348,6 +348,69 @@ int jpegFileDialog(const char *name)
   return 0;
 }
 
+// Save mpeg dialog
+
+int mpegFileDialog(const char *name)
+{
+  struct _mpegFileDialog{
+    Fl_Window *window;
+    Fl_Round_Button *b[2];
+    Fl_Check_Button *c[1];
+    Fl_Button *ok, *cancel;
+  };
+  static _mpegFileDialog *dialog = NULL;
+
+  if(!dialog){
+    dialog = new _mpegFileDialog;
+    int h = 3 * WB + 4 * BH, w = 2 * BB + 3 * WB, y = WB;
+    dialog->window = new Fl_Double_Window(w, h, "MPEG Options");
+    dialog->window->box(GMSH_WINDOW_BOX);
+    dialog->window->set_modal();
+    {
+      Fl_Group *o = new Fl_Group(WB, y, 2 * BB + WB, 2 * BH);
+      dialog->b[0] = new Fl_Round_Button
+        (WB, y, 2 * BB + WB, BH, "Cycle through time steps"); y += BH;
+      dialog->b[0]->type(FL_RADIO_BUTTON);
+      dialog->b[1] = new Fl_Round_Button
+        (WB, y, 2 * BB + WB, BH, "Cycle through views"); y += BH;
+      dialog->b[1]->type(FL_RADIO_BUTTON);
+      o->end();
+    }
+    dialog->c[0] = new Fl_Check_Button
+      (WB, y, 2 * BB + WB, BH, "Composite all window tiles"); y += BH;
+    dialog->c[0]->type(FL_TOGGLE_BUTTON);
+    dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK");
+    dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel");
+    dialog->window->end();
+    dialog->window->hotspot(dialog->window);
+  }
+  
+  dialog->b[0]->value(!CTX::instance()->post.animCycle);
+  dialog->b[1]->value(CTX::instance()->post.animCycle);
+  dialog->c[0]->value(CTX::instance()->print.compositeWindows);
+  dialog->window->show();
+
+  while(dialog->window->shown()){
+    Fl::wait();
+    for (;;) {
+      Fl_Widget* o = Fl::readqueue();
+      if (!o) break;
+      if (o == dialog->ok) {
+        opt_post_anim_cycle(0, GMSH_SET | GMSH_GUI, (int)dialog->b[1]->value());
+        opt_print_composite_windows(0, GMSH_SET | GMSH_GUI, (int)dialog->c[0]->value());
+        CreateOutputFile(name, FORMAT_MPEG);
+        dialog->window->hide();
+        return 1;
+      }
+      if (o == dialog->window || o == dialog->cancel){
+        dialog->window->hide();
+        return 0;
+      }
+    }
+  }
+  return 0;
+}
+
 // Save gif dialog
 
 int gifFileDialog(const char *name)
diff --git a/Fltk/fileDialogs.h b/Fltk/fileDialogs.h
index 5c1b92eda9..a7f6dab3d0 100644
--- a/Fltk/fileDialogs.h
+++ b/Fltk/fileDialogs.h
@@ -22,6 +22,7 @@ int fileChooserGetFilter();
 void fileChooserGetPosition(int *x, int *y);
 
 int jpegFileDialog(const char *filename);
+int mpegFileDialog(const char *filename);
 int gifFileDialog(const char *filename);
 int geoFileDialog(const char *filename);
 int genericBitmapFileDialog(const char *filename, const char *title, int format);
diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp
index 392828b8c9..d7cb9d89e3 100644
--- a/Fltk/menuWindow.cpp
+++ b/Fltk/menuWindow.cpp
@@ -252,6 +252,7 @@ static int _save_eps(const char *name){ return gl2psFileDialog
     (name, "EPS Options", FORMAT_EPS); }
 static int _save_gif(const char *name){ return gifFileDialog(name); }
 static int _save_jpeg(const char *name){ return jpegFileDialog(name); }
+static int _save_mpeg(const char *name){ return mpegFileDialog(name); }
 static int _save_tex(const char *name){ return latexFileDialog(name); }
 static int _save_pdf(const char *name){ return gl2psFileDialog
     (name, "PDF Options", FORMAT_PDF); }
@@ -287,6 +288,7 @@ static int _save_auto(const char *name)
   case FORMAT_EPS  : return _save_eps(name);
   case FORMAT_GIF  : return _save_gif(name);
   case FORMAT_JPEG : return _save_jpeg(name);
+  case FORMAT_MPEG : return _save_mpeg(name);
   case FORMAT_TEX  : return _save_tex(name);
   case FORMAT_PDF  : return _save_pdf(name);
   case FORMAT_PNG  : return _save_png(name);
@@ -334,7 +336,7 @@ static void file_save_as_cb(Fl_Widget *w, void *data)
     {"JPEG" TT "*.jpg", _save_jpeg},
 #endif
 #if defined(HAVE_MPEG_ENCODE)
-    {"MPEG" TT "*.mpg", 0},
+    {"MPEG" TT "*.mpg", _save_mpeg},
 #endif
     {"LaTeX" TT "*.tex", _save_tex},
     {"PDF" TT "*.pdf", _save_pdf},
-- 
GitLab