changeset 74:cee261eba249

Minor tweaks.
author Diggory Hardy <diggory.hardy@gmail.com>
date Mon, 07 Jul 2008 15:54:47 +0100
parents 08d3b6bcf891
children 25cb7420dc91
files codeDoc/jobs.txt codeDoc/todo.txt mde/font/font.d mde/gui/Gui.d mde/gui/widget/Window.d mde/input/Config.d mde/lookup/Translation.d mde/mergetag/DefaultData.d
diffstat 8 files changed, 111 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/codeDoc/jobs.txt	Mon Jul 07 15:53:58 2008 +0100
+++ b/codeDoc/jobs.txt	Mon Jul 07 15:54:47 2008 +0100
@@ -3,19 +3,22 @@
 
 
 In progress:
+Redesigning how widgets are created and receive their data.
 
 
 
 To do (importance 0-5: 0 pointless, 1 no obvious impact now, 2 todo sometime, 3 useful, 4 important, 5 urgent):
 Also see todo.txt and FIXME/NOTE comment marks.
-4   Fonts from Options. Get yMax for font not all glyphs on line?
+4   Try to correlate names of option sections more. (i.e. symbol name, class name, name of i18n translation file)
 4   Not guaranteed to catch up-click ending callback! Appears not to be a problem...
 4   OutOfMemoryException is not currently checked for − it should be at least in critical places (use high-level catching of all errors?).
+3   Fonts from Options. Get yMax for font not all glyphs on line?
 3   glBindTexture not working with non-0 index (??)
 3   on-event draw support (mde.events and GUI need to tell mde.mde)
 3   Scheduler for drawing only windows which need redrawing.
 3   Update scheduler as outlined in FIXME.
 3   Windows building/compatibility (currently partial)
+2   Remove ability to scan, then load, mergetag sections. Not so necessary with section creator callback and allows "sliding window" type partial buffering.
 2   Options need a "level": simple options, for advanced users, for debugging only, etc.
 2   Command-line options for paths to by-pass normal path finding functionality.
 2   Consider replacing byte/short types with int type
--- a/codeDoc/todo.txt	Mon Jul 07 15:53:58 2008 +0100
+++ b/codeDoc/todo.txt	Mon Jul 07 15:54:47 2008 +0100
@@ -2,7 +2,7 @@
 License: GNU General Public License version 2 or later (see COPYING)
 
 
-* means done
+* means done:
 
 GUI:
 ->  Widgets:
@@ -14,3 +14,37 @@
     ->  lists from content lists
 ->  Content:
     ->  lists
+
+
++ shows current preference:
+
+Redesign:
+->  requirements
+    ->  widgets can receive int and string data types
+->  possibilities
+    ->  per-widget merging (i.e. separate tag(s) for each widget's data)?
+        ->  if a widget with sub-widgets is defined in a base file, but redesigned in a derived file, any unused widgets with data resolting are not created
+        ->  if design changes in a base file, while the old design was modified in a derived file, will the result be sane?
+        ->  if a locally modified gui is updated upstream (so the base files change), should:
+            ->  the local modifications persist?
+            ->  the local modifications be lost?
+            ->  the widgets be merged?
+            	->  potentially gives the best of both worlds
+            	->  should original widgets used as sub-widgets of modified widgets:
+                    ->  use original data (from base file), so they can be updated?
+                    ->  have data copied, also impacting unmodified portions of window using same widget?
+                    ->  have data copied under a new ID?
+            ->  the user be asked?
+            	->  requires copy of old data...
+    +>  widget data per-gui instead of per-window?
+    	->  identical sub-widget could be used in multiple windows more easily, when data file is hand edited
+    	->  in-gui editor will probably copy data under a new ID anyway
+    	+>  Maybe change to:
+            ->  One section per version, containing widget data
+            	->  can inherit from other sections
+            ->  Which section (version of gui design) to use saved in header
+            ->  Either/or:
+            	->  Windows defined in header by primary widget
+            	+>  Windows become ordinary sub-widgets or some parent widget, gui becomes a parent widget
+    +>  widget data no longer has "construction" and "mutable" variations
+    	+>  widgets know their IDs and update their data whenever necessary, via the gui, into a new data set, which is saved upon exit
\ No newline at end of file
--- a/mde/font/font.d	Mon Jul 07 15:53:58 2008 +0100
+++ b/mde/font/font.d	Mon Jul 07 15:54:47 2008 +0100
@@ -56,7 +56,8 @@
                 fontTex.drawTexture;
         }
         
-        /** Load the freetype library. */
+        /** Load the freetype library from the file fileName. */
+        private const fileName = "fonts";
         void initialize () {
             if (!confDir.exists (fileName))
                 throw new fontException ("No font settings file (fonts.[mtt|mtb])");
@@ -105,7 +106,7 @@
                 reader.read;
                 
                 // get fallback name
-                char[]* p = "fallback" in reader.dataset.header.Arg!(char[]).Arg;
+                char[]* p = "fallback" in reader.dataset.header.Arg!(char[]);
                 if (p is null)
                     throw new fontException ("No fallback font style specified");
                 fallbackName = *p;
@@ -123,7 +124,6 @@
             // Also note that get() doesn't make sure the fallback is loaded before returning it.
             fallback.load;
         }
-        private const fileName = "fonts";
         
         //FIXME: don't use GC for FontStyle resources
         /** Cleanup: delete all fonts. */
--- a/mde/gui/Gui.d	Mon Jul 07 15:53:58 2008 +0100
+++ b/mde/gui/Gui.d	Mon Jul 07 15:54:47 2008 +0100
@@ -76,7 +76,7 @@
         }
         
         // Get the renderer
-        char[]* p = RENDERER in reader.dataset.header.Arg!(char[]).Arg;
+        char[]* p = "Renderer" in reader.dataset.header.Arg!(char[]);
         if (p is null || *p is null) {
             logger.warn ("no renderer specified: defaulting to Simple");
             rendName = "Simple";
@@ -110,7 +110,7 @@
         
         // Add header:
         ds.header = new mt.DefaultData;
-        ds.header.Arg!(char[]).Arg[RENDERER] = rendName;
+        ds.header.Arg!(char[])["Renderer"] = rendName;
         
         // Add windows to be saved:
         foreach (window; windows)
@@ -127,9 +127,6 @@
             return;
         }
     }
-    private static const {
-        auto RENDERER = "Renderer";
-    }
     //END Loading code
     
     /** Draw each window.
--- a/mde/gui/widget/Window.d	Mon Jul 07 15:53:58 2008 +0100
+++ b/mde/gui/widget/Window.d	Mon Jul 07 15:54:47 2008 +0100
@@ -100,22 +100,22 @@
     //BEGIN Mergetag code
     void addTag (char[] tp, mt.ID id, char[] dt) {
         // Priority is HIGH_LOW, so don't overwrite data which has already been loaded.
-        if (tp == INTAINT) {
-            if (id == WDGD && widgetData == null) {
+        if (tp == "int[][int]") {
+            if (id == "widgetData" && widgetData == null) {
                 widgetData = cast(int[][widgetID]) parseTo!(int[][int]) (dt);
             }
-        } else if (tp == CHARAINT) {
-            if (id == WS && widgetStrings == null) {
+        } else if (tp == "char[][int]") {
+            if (id == "widgetStrings" && widgetStrings == null) {
                 widgetStrings = parseTo!(char[][int]) (dt);
             }
-        } else if (tp == INTA) {
-            if (id == MD && mutableData == null) {
+        } else if (tp == "int[]") {
+            if (id == "mutableData" && mutableData == null) {
                 mutableData = parseTo!(int[]) (dt);
             }
-        } else if (tp == INT) {
-            if (id == X && x == -1) {
+        } else if (tp == "int") {
+            if (id == "x" && x == -1) {
                 x = cast(wdim) parseTo!(int) (dt);
-            } else if (id == Y && y == -1) {
+            } else if (id == "y" && y == -1) {
                 y = cast(wdim) parseTo!(int) (dt);
             }
         }
@@ -127,25 +127,14 @@
         /+ NOTE: currently editing is impossible...
         if (edited) {   // only save the widget creation data if it's been adjusted:
             addCreationData (widget);   // generate widget save data
-            dlg (INTAINT, WDGD, parseFrom!(int[][int]) (widgetData));
-            dlg (CHARAINT, WS, parseFrom!(char[][int]) (widgetStrings));
+            dlg ("int[][int]", "widgetData", parseFrom!(int[][int]) (widgetData));
+            dlg ("char[][int]", "widgetStrings", parseFrom!(char[][int]) (widgetStrings));
         }+/
         // Save mutable data:
-        dlg (INTA, MD, parseFrom!(int[]) (widget.getMutableData));
+        dlg ("int[]", "mutableData", parseFrom!(int[]) (widget.getMutableData));
         // Save the window position:
-        dlg (INT, X, parseFrom!(int) (x));
-        dlg (INT, Y, parseFrom!(int) (y));
-    }
-    private static const {
-        auto CHARAINT = "char[][int]";
-        auto INTAINT = "int[][int]";
-        auto INTA = "int[]";
-        auto INT = "int";
-        auto WDGD = "widgetData";
-        auto MD = "mutableData";
-        auto WS = "widgetStrings";
-        auto X = "x";
-        auto Y = "y";
+        dlg ("int", "x", parseFrom!(int) (x));
+        dlg ("int", "y", parseFrom!(int) (y));
     }
     //END Mergetag code
     //END Methods for GUI
--- a/mde/input/Config.d	Mon Jul 07 15:53:58 2008 +0100
+++ b/mde/input/Config.d	Mon Jul 07 15:54:47 2008 +0100
@@ -141,10 +141,8 @@
             file.dataSecCreator =
             delegate MT.IDataSection (MT.ID) {	return new Config;	};
             
-            // D2.0: enum MT.ID CONFIGS = "Configs";
-            const MT.ID CONFIGS = cast(MT.ID)"Configs";
             // Restrict config sections if this tag exists:
-            auto file_configs_p = CONFIGS in file.dataset.header._charAA;
+            auto file_configs_p = cast(MT.ID)"Configs" in file.dataset.header._charAA;
             MT.ID[] file_configs = null;
             if (file_configs_p) {
                 file_configs = cast(MT.ID[]) *file_configs_p;
@@ -178,17 +176,13 @@
         }
     }
     
-    // D2.0: private enum QUEUE : MT.ID { BUTTON = "B", AXIS = "A", MOUSE = "M" }
-    private struct QUEUE {
-        static const MT.ID BUTTON = cast(MT.ID)"B", AXIS = cast(MT.ID)"A", MOUSE = cast(MT.ID)"M";
-    }
     private this() {}	// Private since this class should only be created from here.
     
     void addTag (char[] tp, MT.ID id, char[] dt) {
         if (tp == "uint[][uint]") {
-            if (id == QUEUE.BUTTON) button = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt);
-            else if (id == QUEUE.AXIS) axis = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt);
-            else if (id == QUEUE.MOUSE) relMotion = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt);
+            	 if (id == "B") button    = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt);
+            else if (id == "A") axis      = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt);
+            else if (id == "M") relMotion = cast(outQueue[][uint]) parseTo!(uint[][][uint]) (dt);
             else logger.warn ("Unexpected tag encountered with ID " ~ cast(char[])id);
         } // FIXME: add support for name and inheritants.
     }
--- a/mde/lookup/Translation.d	Mon Jul 07 15:53:58 2008 +0100
+++ b/mde/lookup/Translation.d	Mon Jul 07 15:54:47 2008 +0100
@@ -37,8 +37,8 @@
 */
 module mde.lookup.Translation;
 
-import mde.options;
-import mde.resource.paths;
+import mde.lookup.Options;
+import mde.setup.paths;
 import mde.exception;
 
 import mde.mergetag.DataSet;
@@ -59,23 +59,41 @@
     final char[] name;      /// The module/package/... which the instance is for
     final char[] L10n;      /// The localization loaded (e.g. en-GB)
     
-    /** Get the translation for the given identifier, and optionally the description.
-    * If no entry exists, the identifier will be returned. */
-    char[] getEntry (char[] id, out char[] description) {
+    alias entry opCall;	    /// Convenience alias
+    
+    /** Get the translation for the given identifier.
+    * If no entry exists, the identifier will be returned.
+    *
+    * Optionally, the description can be returned. */
+    char[] entry (char[] id) {
         Entry* p = id in entries;
-        if (p) {    // FIXME: check: a SEGFAULT?
+        if (p) {
+            return p.str;
+        } else {
+            return id;
+        }
+    }
+    /** ditto */
+    char[] entry (char[] id, out char[] description) {
+        Entry* p = id in entries;
+        if (p) {
             description = p.desc;
             return p.str;
-        } else
+        } else {
             return id;
+        }
     }
-        /** ditto */
-    char[] getEntry (char[] id) {
+    
+    /** Alternative usage: return a Translation.Entry struct. */
+    Entry getStruct (char[] id) {
         Entry* p = id in entries;
-        if (p !is null) {    // FIXME: check: a SEGFAULT?
-            return p.str;
-        } else
-            return id;
+        if (p) {
+            return *p;
+        } else {
+            Entry ret;
+            ret.str  = id;
+            return ret;
+        }
     }
     
     /** Load the translation for the requested module/package/...
@@ -174,6 +192,15 @@
     // This class is read-only and has no need of being saved.
     void writeAll (ItemDelg) {}
     
+    /** This struct is used to store each translation entry.
+     *
+     * Note that although each entry also has a version field, this is not loaded for general use.
+     */
+    struct Entry {
+        char[] str;         // The translated string
+        char[] desc;        // An optional description
+    }
+    
 private:
     /* Sets name and L10n.
     *
@@ -186,15 +213,6 @@
     //BEGIN Data
     static Logger logger;
     
-    /* This struct is used to store each translation entry.
-    *
-    * Note that although each entry also has a version field, this is not loaded for general use.
-    */
-    struct Entry {
-        char[] str;         // The translated string
-        char[] desc;        // An optional description
-    }
-    
     Entry[char[]] entries;  // all entries
     
     ID[] depends;           // dependancy sections (only used while loading)
@@ -221,15 +239,15 @@
         Translation transl = load ("i18nUnitTest");
         
         // Simple get-string, check dependancy's entry doesn't override
-        assert (transl.getEntry ("Str1") == "Test 1");
+        assert (transl.entry ("Str1") == "Test 1");
         
         // Entry included from dependancy with description
         char[] desc;
-        assert (transl.getEntry ("Str2", desc) == "Test 3");
+        assert (transl.entry ("Str2", desc) == "Test 3");
         assert (desc == "Description");
         
         // No entry: fallback to identifier string
-        assert (transl.getEntry ("Str3") == "Str3");
+        assert (transl.entry ("Str3") == "Str3");
         
         // No checks for version info since it's not functionality of this module.
         // Only check extra entries are allowed but ignored.
--- a/mde/mergetag/DefaultData.d	Mon Jul 07 15:53:58 2008 +0100
+++ b/mde/mergetag/DefaultData.d	Mon Jul 07 15:54:47 2008 +0100
@@ -167,12 +167,13 @@
     * But if the symbol doesn't exist the complier will throw an error anyway, e.g.:
     * Error: identifier '_boolAA' is not defined
     */
-    template Arg(T : T[]) {
-        const ArgString = Arg!(T).ArgString ~ `A`;
-        mixin(`alias `~ArgString~` Arg;`);
+    template ArgName (T : T[]) {
+        const char[] ArgName = ArgName!(T)~`A`;
+    }
+    template ArgName (T) {
+        const char[] ArgName = `_`~T.stringof;
     }
     template Arg(T) {
-        const ArgString = `_` ~ T.stringof;
-        mixin(`alias `~ArgString~` Arg;`);
+        mixin(`alias `~ArgName!(T)~` Arg;`);
     }
 }