]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/new_gui.hxx
Add a new command, "dialog-new", allowing external code (e.g. Nasal
[flightgear.git] / src / GUI / new_gui.hxx
index 637f2c592687cecb968125f94a2e52ff464f8ab0..5aec7c5388ba976a046a05457da62e6690e76b7d 100644 (file)
@@ -10,7 +10,8 @@
 #include <plib/pu.h>
 
 #include <simgear/compiler.h>  // for SG_USING_STD
-#include <simgear/misc/props.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
 
 #include <vector>
 SG_USING_STD(vector);
@@ -18,7 +19,6 @@ SG_USING_STD(vector);
 #include <map>
 SG_USING_STD(map);
 
-#include <Main/fgfs.hxx>
 #include <Main/fg_props.hxx>
 
 class FGMenuBar;
@@ -35,7 +35,7 @@ class FGBinding;
  * for XML-configured dialog boxes found in $FG_ROOT/gui/dialogs/.  It
  * can show or hide the menubar, and can display any dialog by name.
  */
-class NewGUI : public FGSubsystem
+class NewGUI : public SGSubsystem
 {
 public:
 
@@ -80,6 +80,18 @@ public:
      */
     virtual void update (double delta_time_sec);
 
+    /**
+     * Creates a new dialog box, using the same property format as the
+     * gui/dialogs configuration files.  Does not display the
+     * resulting dialog.  If a pre-existing dialog of the same name
+     * exists, it will be deleted.  The node argument will be stored
+     * in the GUI subsystem using SGPropertNode_ptr reference counting.
+     * It should not be deleted by user code.
+     *
+     * @param node A property node containing the dialog definition
+     */
+    virtual void newDialog (SGPropertyNode* node);
+
     /**
      * Display a dialog box.
      *
@@ -96,12 +108,22 @@ public:
 
 
     /**
-     * Close the currently-active dialog, if any.
+     * Close the currenty active dialog.  This function is intended to
+     * be called from code (pui callbacks, for instance) that registers
+     * its dialog object as active via setActiveDialog().  Other
+     * user-level code should use the closeDialog(name) API.
      *
-     * @return true if a dialog was active, false otherwise.
+     * @return true if a dialog was active, false otherwise
      */
     virtual bool closeActiveDialog ();
 
+    /**
+     * Close a named dialog, if it is open.
+     *
+     * @param name The name of the dialog box.
+     * @return true if the dialog was active, false otherwise.
+     */
+    virtual bool closeDialog (const string &name);
 
     /**
      * Return a pointer to the current menubar.
@@ -151,7 +173,8 @@ private:
 
     FGMenuBar * _menubar;
     FGDialog * _active_dialog;
-    map<string,SGPropertyNode *> _dialog_props;
+    map<string,FGDialog *> _active_dialogs;
+    map<string,SGPropertyNode_ptr> _dialog_props;
 
 };