Mercurial > projects > mde
diff mde/gui/widget/Ifaces.d @ 111:1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Removed prefinalize and finalize and added setup as the new second initialization phase, which can be re-run.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 06 Dec 2008 17:41:42 +0000 |
parents | 6acd96f8685f |
children | fe061009029d |
line wrap: on
line diff
--- a/mde/gui/widget/Ifaces.d Fri Dec 05 11:29:39 2008 +0000 +++ b/mde/gui/widget/Ifaces.d Sat Dec 06 17:41:42 2008 +0000 @@ -133,35 +133,39 @@ * + Widget uses the initialisation data: * + [widgetID, x, y] * + where x is ... and y is ... +/ - * this (IWidgetManager mgr, WidgetData data); + * this (IWidgetManager mgr, widgetID id, WidgetData data); * * /// The CTOR may take an IContent reference: - * this (IWidgetManager mgr, WidgetData data, IContent content); + * this (IWidgetManager mgr, widgetID id, WidgetData data, IContent content); * ---------------------------------- - * Where mgr is the widget manager and data is + * Where mgr is the widget manager, id is the _id passed to makeWidget() and data is * initialisation data. The method should throw a WidgetDataException (created without * parameters) if the data has wrong length or is otherwise invalid. * - * All widgets should set their own size in this() or finalize(), although some parents may set - * child-widgets' size during their creation. Widgets may rely on setPosition() being called after - * finalize(). - * - * Also see finalize(). + * All widgets should set their own size in this() or setup() (must be setup() if it could change), + * although some parents may set child-widgets' size during their creation. *************************************************************************************************/ //NOTE: add another this() without the data for default initialization, for the GUI editor? interface IChildWidget : IWidget { //BEGIN Load and save - // NOTE - change? - /** Called on all widgets after all widgets have been created in a deepest first order. + /** 2nd stage of initialization for widgets; also called on some changes. * - * finalize must be called before any other methods on the widget, which means this() cannot - * call sub-widgets' methods, but finalize() can. */ - void prefinalize (); - void finalize (); /// ditto - - /** Widget should return a list of all its children. */ - IChildWidget[] children (); + * Widgets should call recursively on their children, redo anything indicated by flags, and + * adjust their size and other cached data dependant on any thing which may have changed. + * Widgets may rely on setPosition being called afterwards. + * + * Params: + * n = Indicates this is the (n+1)-th time the function has been called. + * flags = if (flags & 1) the renderer has been changed, + * if (flags & 2) translation strings are being reloaded. + * These flags are always true on first run. + * + * Returns: + * The method should return true if the dimensions (may) have been changed. This may not be + * the case on the first run (when n == 0)!. + */ + bool setup (uint n, uint flags); /** When this is called, if the widget has any changed data to save it should call * IWidgetManager.setData (id, data) to set it and return true. Otherwise it should return @@ -171,14 +175,6 @@ * ids). */ bool saveChanges (); - /** Called when the renderer is changed (at least when the changes affect dimensions). - * Also called after widget creation, before any other methods are called. - * - * Returns: true when widget's dimensions (may) have changed. - * - * Should be propegated down to all child widgets. */ - bool rendererChanged (); - /+ Use when widget editing is available? Requires widgets to know their parents. /** Called when a child widget's size has changed. * @@ -186,13 +182,6 @@ void childChanged (); +/ - /** Called if translated strings have been reloaded and widgets need to reload theirs. - * - * Returns: true when widget's dimensions (may) have changed. - * - * Should be propegated down to all child widgets. */ - bool reloadStrings (); - //END Load and save //BEGIN Size and position @@ -232,7 +221,7 @@ void setWidth (wdim nw, int dir); void setHeight (wdim nh, int dir); /// ditto - /** Set the current position (i.e. called on init and move). */ + /** Set the current position (called after setup and to move widget). */ void setPosition (wdim x, wdim y); //END Size and position