Changeset 78:79a1809421aa

Show
Ignore:
Timestamp:
07/29/08 13:14:53 (5 months ago)
Author:
Diggory Hardy <diggory.hardy@gmail.com>
branch:
default
Message:

Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • data/conf/gui.mtt

    r77 r78  
    55<WidgetData|root=[0xB004,3,3],["square","blank","square","blank","content","blank","square","blank","square"]> 
    66<WidgetData|square=[0x1,6,6],[]> 
    7 <WidgetData|content=[0xB004,3,2],["blank","button","blank","blank","blank","opts"]> 
     7<WidgetData|content=[0xB004,4,2],["blank","button","blank","blank","blank","opts","blank","blank"]> 
    88<WidgetData|button=[0x4010,200,200],[]> 
    99<WidgetData|blank=[0x3001],[]> 
  • mde/gui/WidgetData.d

    r77 r78  
    180180        scope(exit) mutex.unlock; 
    181181         
    182         if (noChanges) 
     182        // Make all widgets save any changed data; return if no changes: 
     183        if (!child.saveChanges ("root")) 
    183184            return; 
    184185         
     
    235236    /** For making changes. */ 
    236237    void setData (widgetID id, WidgetData d) { 
    237         noChanges = false; 
    238238        changes[id] = d;        // also updates WidgetDataSet in data. 
    239239    } 
     
    265265    scope mt.DataSet changesDS; // changes and sections from user file (used for saving) 
    266266    bool loadUserFile = true;   // still need to load user file for saving? 
    267     bool noChanges = true;      // do we have any changes to save? 
    268267     
    269268    scope IChildWidget child;   // The primary widget. 
  • mde/gui/widget/Ifaces.d

    r77 r78  
    175175{ 
    176176//BEGIN Load and save 
     177    /** When this is called, if the widget has any changed data to save it should call 
     178     * IWidgetManager.setData (id, data) to set it and return true. Otherwise it should return 
     179     * false. 
     180     *  
     181     * If the widget has subwidgets, it should also be recursively called on these (passing their  
     182     * ids). */ 
     183    bool saveChanges (widgetID id); 
     184     
    177185    /** Called when the renderer is changed (at least when the changes affect dimensions). 
    178186     * Also called after widget creation, before any other methods are called. 
  • mde/gui/widget/Widget.d

    r77 r78  
    5757    this (IWidgetManager mgr, WidgetData data) { 
    5858        this.mgr = mgr; 
     59    } 
     60     
     61    // Don't save any data: fine for many widgets. 
     62    bool saveChanges (widgetID) { 
     63        return false; 
    5964    } 
    6065     
  • mde/gui/widget/layout.d

    r77 r78  
    6262            data.strings.length != rows * cols) 
    6363            throw new WidgetDataException; 
     64        this.data = data; 
    6465         
    6566        // Get all sub-widgets 
     
    8081        adjustCache; 
    8182    } 
    82     /+FIXME 
    83     /** Return construction data to recreate this GridLayoutWidget. */ 
    84     int[] getCreationData () { 
    85         int[] ret; 
    86         ret.length = 3 + subWidgets.length; 
    87          
    88         ret [0..3] = [widgetType, rows, cols];  // first data 
    89          
    90         foreach (i,widget; subWidgets)          // sub widgets 
    91             ret[i+3] = window.addCreationData (widget); 
    92          
    93         return ret; 
    94     }+/ 
     83     
     84    // Save column/row sizes. Currently always do so. 
     85    bool saveChanges (widgetID id) { 
     86        with (data) { 
     87            foreach (i, widget; subWidgets) // recurse on subwidgets 
     88                widget.saveChanges (strings[i]); 
     89             
     90            ints = ints[0..3] ~ cast(int[])col.width ~ cast(int[])row.width; 
     91        } 
     92        mgr.setData (id, data); 
     93        return true; 
     94    } 
     95protected: 
     96    WidgetData data; 
    9597} 
    9698 
     
    124126        adjustCache; 
    125127    } 
    126      
    127     /+FIXME 
    128     int[] getCreationData () { 
    129         return [widgetType]; 
    130     }+/ 
    131128     
    132129private: 
     
    184181        } 
    185182    } 
    186     /+ FIXME - saving 
    187     /** Returns sub-widget mutable data along with column widths and row heights, as used by 
    188      *  adjust(). */ 
    189     int[] getMutableData () { 
    190         int[] ret; 
    191         foreach (widget; subWidgets) 
    192             ret ~= widget.getMutableData; 
    193          
    194         return ret ~ cast(int[])col.width ~ cast(int[])row.width; 
    195     }+/ 
    196183    //END Creation & saving 
    197184     
  • mde/setup/paths.d

    r75 r78  
    152152            for (int i = pathsLen - 1; i >= 0; --i) { 
    153153                FilePath file = findFile (paths[i]~filename); 
    154                 if (file !is null) { 
     154                if (file !is null) 
    155155                    ret ~= file; 
    156                     if (readOrder == PRIORITY.HIGH_ONLY) break; 
    157                 } 
     156                if (readOrder == PRIORITY.HIGH_ONLY) break; 
    158157            } 
    159158        }