Changeset 46

Show
Ignore:
Timestamp:
02/16/07 22:09:34 (2 years ago)
Author:
baxissimo
Message:

Added top level add_blah_callback calls in gui.d to hook the system-level input routines. May rethink this a bit still. That may be wanted in some cases (reshape, or recording all mouse motion for example) , but probably more useful would be routines that get called as a _fallback_ when no gui widget intercepts the event.

Fixed disconnect in signalobj.d

Added disconnect routines to adapter.d

Fixed dxut to work without Derelict.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/luigi/adapter.d

    r33 r46  
    5151interface InputAdapter 
    5252{ 
    53     // These are "raw" callbacks in that they haven't yet been translated or dispatched 
    54     // to widgets.  This is all the input that comes in at the window level. 
    55     // Luigi uses these to get input which is then dispatched to widgets based on 
    56     // current focus item, location of the mouse, etc. 
     53    /** 
     54     * These are "raw" callbacks in that they haven't yet been translated or dispatched 
     55     *  to widgets.  This is all the input that comes in at the window level. 
     56     * Luigi uses these to get input which is then dispatched to widgets based on 
     57     * current focus item, location of the mouse, etc. 
     58     * See event.d for the definitons of the function types. 
     59     */ 
    5760    void addKeyCallback(KeyEventFn cb)                 ; 
    5861    void addMouseButtonCallback(MouseButtonEventFn cb) ; 
     
    6972    void addWindowSizeCallback(WindowSizeEventDg cb)   ; 
    7073    void addWindowCloseCallback(WindowCloseEventDg cb) ; 
     74 
     75 
     76    // remove raw system callback 
     77    void removeKeyCallback(KeyEventFn cb)                 ; 
     78    void removeMouseButtonCallback(MouseButtonEventFn cb) ; 
     79    void removeMouseMoveCallback(MouseMoveEventFn cb)     ; 
     80    void removeMouseWheelCallback(MouseWheelEventFn cb)   ; 
     81    void removeWindowSizeCallback(WindowSizeEventFn cb)   ; 
     82    void removeWindowCloseCallback(WindowCloseEventFn cb) ; 
     83 
     84    // And again for delegates... 
     85    void removeKeyCallback(KeyEventDg cb)                 ; 
     86    void removeMouseButtonCallback(MouseButtonEventDg cb) ; 
     87    void removeMouseMoveCallback(MouseMoveEventDg cb)     ; 
     88    void removeMouseWheelCallback(MouseWheelEventDg cb)   ; 
     89    void removeWindowSizeCallback(WindowSizeEventDg cb)   ; 
     90    void removeWindowCloseCallback(WindowCloseEventDg cb) ; 
    7191 
    7292    Size get_window_size(WindowHandle h); 
     
    135155    void addWindowSizeCallback(WindowSizeEventDg cb)   {_lsig.windowSize.connect(cb);}   
    136156    void addWindowCloseCallback(WindowCloseEventDg cb) {_lsig.windowClose.connect(cb);}  
     157 
     158    // Implementation of InputAdapter 
     159    void removeKeyCallback(KeyEventFn cb)                 {_lsig.key.disconnect(cb);} 
     160    void removeMouseButtonCallback(MouseButtonEventFn cb) {_lsig.mouseButton.disconnect(cb);} 
     161    void removeMouseMoveCallback(MouseMoveEventFn cb)     {_lsig.mouseMove.disconnect(cb);} 
     162    void removeMouseWheelCallback(MouseWheelEventFn cb)   {_lsig.mouseWheel.disconnect(cb);} 
     163    void removeWindowSizeCallback(WindowSizeEventFn cb)   {_lsig.windowSize.disconnect(cb);} 
     164    void removeWindowCloseCallback(WindowCloseEventFn cb) {_lsig.windowClose.disconnect(cb);}  
     165 
     166    // And again for delegates... 
     167    void removeKeyCallback(KeyEventDg cb)                 {_lsig.key.disconnect(cb);}          
     168    void removeMouseButtonCallback(MouseButtonEventDg cb) {_lsig.mouseButton.disconnect(cb);}  
     169    void removeMouseMoveCallback(MouseMoveEventDg cb)     {_lsig.mouseMove.disconnect(cb);}    
     170    void removeMouseWheelCallback(MouseWheelEventDg cb)   {_lsig.mouseWheel.disconnect(cb);}   
     171    void removeWindowSizeCallback(WindowSizeEventDg cb)   {_lsig.windowSize.disconnect(cb);}   
     172    void removeWindowCloseCallback(WindowCloseEventDg cb) {_lsig.windowClose.disconnect(cb);}  
    137173} 
    138174 
  • trunk/luigi/examples/example1_gld.brf

    r45 r46  
    88-full 
    99-cleanup 
    10 -version=useDerelict 
    1110-I$(DMDDIR)\baxissimo 
    12 -I$(DMDDIR)\ext 
    13 -I$(DMDDIR)\ext\schooner\gld\imports 
    14 -I$(DMDDIR)\ext\derelict\DerelictGL 
    15 -I$(DMDDIR)\ext\derelict\DerelictGLU 
    16 -I$(DMDDIR)\ext\derelict\DerelictUtil 
     11-I$(DMDDIR)\dmd\import 
     12-I$(DMDDIR)\dmd\import\schooner\win32\imports 
     13-I$(DMDDIR)\dmd\import\schooner\gl\imports 
     14-I$(DMDDIR)\dmd\import\schooner\gld\imports 
    1715example1_gld 
    1816# GLD only works as a library currently 
    19 $(DMDDIR)\ext\schooner\gld\gld.lib 
    20 $(DMDDIR)\ext\schooner\win32\win32.lib 
    21 $(DMDDIR)\ext\schooner\win32\gdi32.lib 
    22 $(DMDDIR)\ext\schooner\win32\winmm.lib 
     17$(DMDDIR)\dmd\import\schooner\gl\gl.lib 
     18$(DMDDIR)\dmd\import\schooner\gl\opengl32.lib 
     19$(DMDDIR)\dmd\import\schooner\gl\glu32.lib 
     20$(DMDDIR)\dmd\import\schooner\gld\gld.lib 
     21$(DMDDIR)\dmd\import\schooner\win32\win32.lib 
     22$(DMDDIR)\dmd\import\schooner\win32\gdi32.lib 
     23$(DMDDIR)\dmd\import\schooner\win32\winmm.lib 
  • trunk/luigi/examples/example1_gld.d

    r42 r46  
    4242 
    4343import gld; 
    44 import derelict.opengl.gl; 
    45 import derelict.opengl.glu; 
     44version (useDerelict) { 
     45    import derelict.opengl.gl; 
     46    import derelict.opengl.glu; 
     47} else { 
     48    import gl; 
     49    import glu; 
     50
     51 
    4652import std.string; 
    4753import std.stdio : writefln; 
     
    4955static this() 
    5056{ 
    51     DerelictGL.load(); 
    52     DerelictGLU.load(); 
     57    version(useDerelict) { 
     58        DerelictGL.load(); 
     59        DerelictGLU.load(); 
     60    } 
    5361    gldInit(); 
    5462} 
  • trunk/luigi/examples/example1_glfw.brf

    r45 r46  
    88-full 
    99-cleanup 
     10-version=useDerelict 
    1011-I$(DMDDIR)\baxissimo 
    11 -I$(DMDDIR)\ex
    12 -I$(DMDDIR)\ext\derelict\DerelictGL 
    13 -I$(DMDDIR)\ext\derelict\DerelictGLU 
    14 -I$(DMDDIR)\ext\derelict\DerelictUtil 
    15 -I$(DMDDIR)\ext\derelict\DerelictGLFW 
     12-I$(DMDDIR)\dmd\impor
     13-I$(DMDDIR)\dmd\import\derelict\DerelictGL 
     14-I$(DMDDIR)\dmd\import\derelict\DerelictGLU 
     15-I$(DMDDIR)\dmd\import\derelict\DerelictUtil 
     16-I$(DMDDIR)\dmd\import\derelict\DerelictGLFW 
    1617example1_glfw 
  • trunk/luigi/examples/example1_sdl.brf

    r42 r46  
    1010-version=useDerelict 
    1111-I$(DMDDIR)\baxissimo 
    12 -I$(DMDDIR)\ext 
    13 -I$(DMDDIR)\ext\schooner 
    14 -I$(DMDDIR)\ext\derelict\DerelictGL 
    15 -I$(DMDDIR)\ext\derelict\DerelictUtil 
    16 -I$(DMDDIR)\ext\derelict\DerelictSDL 
     12-I$(DMDDIR)\dmd\import 
     13-I$(DMDDIR)\dmd\import\derelict\DerelictGL 
     14-I$(DMDDIR)\dmd\import\derelict\DerelictUtil 
     15-I$(DMDDIR)\dmd\import\derelict\DerelictSDL 
    1716example1_sdl.d 
  • trunk/luigi/examples/example1d_glfw.brf

    r45 r46  
    99-full 
    1010-cleanup 
     11-version=useDerelict 
    1112-I$(DMDDIR)\baxissimo 
    12 -I$(DMDDIR)\ex
    13 -I$(DMDDIR)\ext\derelict\DerelictGL 
    14 -I$(DMDDIR)\ext\derelict\DerelictGLU 
    15 -I$(DMDDIR)\ext\derelict\DerelictUtil 
    16 -I$(DMDDIR)\ext\derelict\DerelictGLFW 
     13-I$(DMDDIR)\dmd\impor
     14-I$(DMDDIR)\dmd\import\derelict\DerelictGL 
     15-I$(DMDDIR)\dmd\import\derelict\DerelictGLU 
     16-I$(DMDDIR)\dmd\import\derelict\DerelictUtil 
     17-I$(DMDDIR)\dmd\import\derelict\DerelictGLFW 
    1718-Texample1d_glfw 
    1819example1_glfw 
  • trunk/luigi/gui.d

    r44 r46  
    207207    char[][] m_resource_path; 
    208208} 
     209 
     210 
     211/// Add a system-level input callback 
     212void add_key_callback(KeyEventFn cb)                  {Luigi().adapter.addKeyCallback(cb);} 
     213void add_mouse_button_callback(MouseButtonEventFn cb) {Luigi().adapter.addMouseButtonCallback(cb); } 
     214void add_mouse_move_callback(MouseMoveEventFn cb)     {Luigi().adapter.addMouseMoveCallback(cb);} 
     215void add_mouse_wheel_callback(MouseWheelEventFn cb)   {Luigi().adapter.addMouseWheelCallback(cb);} 
     216void add_window_size_callback(WindowSizeEventFn cb)   {Luigi().adapter.addWindowSizeCallback(cb);} 
     217void add_window_close_callback(WindowCloseEventFn cb) {Luigi().adapter.addWindowCloseCallback(cb);} 
     218 
     219void remove_key_callback(KeyEventFn cb)                  {Luigi().adapter.removeKeyCallback(cb);} 
     220//void add_mouse_button_callback(MouseButtonEventFn cb) {Luigi().adapter.addMouseButtonCallback(cb); } 
     221//void add_mouse_move_callback(MouseMoveEventFn cb)     {Luigi().adapter.addMouseMoveCallback(cb);} 
     222//void add_mouse_wheel_callback(MouseWheelEventFn cb)   {Luigi().adapter.addMouseWheelCallback(cb);} 
     223//void add_window_size_callback(WindowSizeEventFn cb)   {Luigi().adapter.addWindowSizeCallback(cb);} 
     224//void add_window_close_callback(WindowCloseEventFn cb) {Luigi().adapter.addWindowCloseCallback(cb);} 
     225 
     226 
     227/// ditto 
     228void add_key_callback(KeyEventDg cb)                  {Luigi().adapter.addKeyCallback(cb);} 
     229void add_mouse_button_callback(MouseButtonEventDg cb) {Luigi().adapter.addMouseButtonCallback(cb);} 
     230void add_mouse_move_callback(MouseMoveEventDg cb)     {Luigi().adapter.addMouseMoveCallback(cb);} 
     231void add_mouse_wheel_callback(MouseWheelEventDg cb)   {Luigi().adapter.addMouseWheelCallback(cb);} 
     232void add_window_size_callback(WindowSizeEventDg cb)   {Luigi().adapter.addWindowSizeCallback(cb);} 
     233void add_window_close_callback(WindowCloseEventDg cb) {Luigi().adapter.addWindowCloseCallback(cb);} 
     234 
    209235 
    210236 
     
    11211147        hostwin = win; 
    11221148        Size sz = Luigi().get_window_size(win); 
    1123         writefln("Window size = ", sz); 
    11241149        set_rect(Rect(0,0,sz.w,sz.h)); 
    11251150        Luigi().add_overlay(this); 
  • trunk/luigi/opengl.d

    r6 r46  
    3131module luigi.opengl; 
    3232 
     33version(useDerelict) { 
    3334public import derelict.opengl.gl; 
     35} else { 
     36public import gl; 
     37} 
    3438 
    35  
  • trunk/luigi/signalobj.d

    r23 r46  
    125125     * be implicitly converted at runtime is allowed. 
    126126     *  
    127      * So for example, the (int, char[]) FlexSigal can be connected to a  
     127     * So for example, the (int, char[]) FlexSignal can be connected to a  
    128128     * method taking a (double,char[]) because int is automatically  
    129129     * promoted to double. 
     
    187187    void disconnect(DT)(DT f) {  
    188188        static if( is(DT==slot_t) ) { 
    189             s.disconnect_exact(f); 
     189            s.disconnect(f); 
    190190        } 
    191191        else { 
     
    200200 
    201201            if (f_key in thunkMap) { 
    202                 s.disconnect_exact(thunkMap[f_key]); 
     202                s.disconnect(thunkMap[f_key]); 
    203203            } else { 
    204204                debug writefln("FlexSignal.fdisconnect: Slot not found"); 
     
    362362     
    363363    auto sig1 = new SignalObj!(int); 
    364     sig1.connect_exact(&s1.slot1); 
    365     //sig1.connect_exact(&s1.slot0); // error mismatch 
     364    sig1.connect(&s1.slot1); 
     365    //sig1.connect(&s1.slot0); // error mismatch 
    366366 
    367367    writefln(">>> SignalObject EMIT"); 
     
    435435//---------------------------------------------------------------------------- 
    436436// needed to run tests 
    437 //void main(){} 
    438  
     437version (unittestmain) { 
     438    void main(){} 
     439
     440 
  • trunk/luigi/themes/dxut.d

    r43 r46  
    3838import std.perf; 
    3939 
     40version (useDerelict) { 
    4041import derelict.opengl.extension.arb.texture_compression; 
     42} else { 
     43    private 
     44    { 
     45        PFNGLCOMPRESSEDTEXIMAGE3DARBPROC         glCompressedTexImage3DARB; 
     46        PFNGLCOMPRESSEDTEXIMAGE2DARBPROC         glCompressedTexImage2DARB; 
     47        PFNGLCOMPRESSEDTEXIMAGE1DARBPROC         glCompressedTexImage1DARB; 
     48        PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC      glCompressedTexSubImage3DARB; 
     49        PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC      glCompressedTexSubImage2DARB; 
     50        PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC      glCompressedTexSubImage1DARB; 
     51        PFNGLGETCOMPRESSEDTEXIMAGEARBPROC        glGetCompressedTexImageARB; 
     52 
     53        version(Windows) 
     54            import win32.wingdi; // for wgl funcs 
     55        else version(linux) 
     56            version = UsingGLX; 
     57        version(UsingGLX) 
     58            import x11.glx; 
     59        import string=std.string; 
     60 
     61        bool glBindExtFunc(void **ptr, char[] funcName) 
     62        { 
     63            version(Windows) 
     64                *ptr = wglGetProcAddress(string.toStringz(funcName)); 
     65            else version(UsingGLX) 
     66                *ptr = glXGetProcAddress(string.toStringz(funcName)); 
     67            return (*ptr !is null); 
     68        } 
     69    } 
     70} 
     71 
    4172static const GLint GL_COMPRESSED_RGB_S3TC_DXT1_EXT  = 0x83F0; 
    4273static const GLint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; 
     
    4475static const GLint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; 
    4576 
     77 
     78 
    4679void initialize_compressed_texture_extension() 
    4780{ 
    48     if (!ARBTextureCompression.load("GL_ARB_texture_compression"))  
     81    bool allOk = true; 
     82    version(useDerelict) { 
     83        if (!ARBTextureCompression.load("GL_ARB_texture_compression"))  
     84            allOk=false; 
     85    } 
     86    else { 
     87        if(!glBindExtFunc(cast(void**)&glCompressedTexImage3DARB, "glCompressedTexImage3DARB")) 
     88            allOk = false; 
     89        if(!glBindExtFunc(cast(void**)&glCompressedTexImage2DARB, "glCompressedTexImage2DARB")) 
     90            allOk = false; 
     91        if(!glBindExtFunc(cast(void**)&glCompressedTexImage1DARB, "glCompressedTexImage1DARB")) 
     92            allOk = false; 
     93        if(!glBindExtFunc(cast(void**)&glCompressedTexSubImage3DARB, "glCompressedTexSubImage3DARB")) 
     94            allOk = false; 
     95        if(!glBindExtFunc(cast(void**)&glCompressedTexSubImage2DARB, "glCompressedTexSubImage2DARB")) 
     96            allOk = false; 
     97        if(!glBindExtFunc(cast(void**)&glCompressedTexSubImage1DARB, "glCompressedTexSubImage1DARB")) 
     98            allOk = false; 
     99        if(!glBindExtFunc(cast(void**)&glGetCompressedTexImageARB, "glGetCompressedTexImageARB")) 
     100            allOk = false; 
     101    } 
     102    if (!allOk) { 
    49103        throw new Exception("Unable to initialize texture compression extension"); 
     104    } 
    50105} 
    51106