view mde/util.d @ 179:1f9d00f392bd default tip

Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now. Optimised when ServiceContentList.opCall is called, I think without breaking anything.
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 15 Sep 2009 20:09:59 +0200
parents 2a364c7d82c9
children
line wrap: on
line source

module mde.util;

/// Not my code: http://www.dsource.org/projects/tango/ticket/1174#comment:7
R delegate(T) toDg(R, T...)(R function(T) fp) {
    if (!fp) return null;
    struct dg {
        R opCall(T t) {
            return (cast(R function(T)) this) (t);
        }
    }
    R delegate(T) t;
    t.ptr = fp;
    t.funcptr = &dg.opCall;
    return t;
}