Changeset 18

Show
Ignore:
Timestamp:
11/27/06 01:43:45 (2 years ago)
Author:
baxissimo
Message:

Added gld adapter and renamed all instances of 'adaptor' to 'adapter'.
Adaptor is a legal spelling variant according to m-w.com, but it lost out
badly to "adapter" in a GoogleFight?.

Files:

Legend:

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

    r13 r18  
    33 Copyright: 
    44 
    5   luigi/adaptor/base.d -- input adaptor basics for the 'Luigi' user 
     5  luigi/adapter/base.d -- input adaptor basics for the 'Luigi' user 
    66  interface library. 
    77 
     
    2626  William Baxter wbaxter@gmail.com 
    2727*/ 
    28 module luigi.adaptor.base; 
     28module luigi.adapter.base; 
    2929 
    3030//import sslot.signal; 
     
    3434 
    3535 
    36 /** The InputAdaptor interface allows the GUI to connect to various windowing toolkits. 
     36/** The InputAdapter interface allows the GUI to connect to various windowing toolkits. 
    3737    Luigi wants to be able to get input from whatever source possible, be it GLFW, GLUT, SDL, 
    38     native Win32, GTK, wxWidgets, or whatever.  Implementations of the input adapto
     38    native Win32, GTK, wxWidgets, or whatever.  Implementations of the input adapte
    3939    allow Luigi and applications to pretend that all toolkits work the same way, regardless 
    4040    of the back-end chosen.  In particular Luigi puts a facade of a Signals-and-Slots type  
     
    4343    One common way simple toolkits like GLUT deliver input to applications is via callbacks. 
    4444    They usually allow one, and only one, function to be called. 
    45     A concrete InputAdaptor for one of these will override all callback methods and emit 
     45    A concrete InputAdapter for one of these will override all callback methods and emit 
    4646    signals identifying all the events. 
    4747 
    48     To implement a new adaptor, derive from the InputAdaptor interface, and mixin the  
    49     InputAdaptorMix.  This sets up the external interface and the signals. 
     48    To implement a new adapter, derive from the InputAdapter interface, and mixin the  
     49    InputAdapterMix.  This sets up the external interface and the signals. 
    5050    Now all you have to do is  
    5151 */ 
    52 interface InputAdapto
     52interface InputAdapte
    5353{ 
    5454    // These are "raw" callbacks in that they haven't yet been translated or dispatched 
     
    8080 
    8181    // Other candidates: Create window, Move/Resize window, Set window title 
    82     // maybe need a separate WindowSys adaptor? 
     82    // maybe need a separate WindowSys adapter? 
    8383    // I don't want to be in the business of wrapping the OS, or becoming another GLUT. 
    8484    // Just the minimal things needed to run an on-screen UI.  Let them use GLUT for  
     
    8787} 
    8888 
    89 template InputAdaptorMix() 
     89template InputAdapterMix() 
    9090{ 
    9191    //------------------------------------------------------- 
    92     // Use 'sig.*.emit' to emit signals from your InputAdaptor implementation. 
     92    // Use 'sig.*.emit' to emit signals from your InputAdapter implementation. 
    9393    // Use example:   
    9494    //       KeyEvent ev; 
     
    9696    //       sig.key.emit(ev); 
    9797 
    98     // You MUST call this from your Adaptor's constructor! 
    99     void initInputAdaptor() { 
     98    // You MUST call this from your Adapter's constructor! 
     99    void initInputAdapter() { 
    100100        with (_lsig) { 
    101101            key = new KeyEventSignal; 
     
    109109 
    110110    //------------------------------------------------------- 
    111     // The rest shouldn't concernt InputAdaptor implementors 
     111    // The rest shouldn't concernt InputAdapter implementors 
    112112    private struct _LuigiSignals { 
    113113        KeyEventSignal         key; 
     
    121121    alias _lsig sig; 
    122122 
    123     // Implementation of InputAdapto
     123    // Implementation of InputAdapte
    124124    void addKeyCallback(KeyEventFn cb)                 {_lsig.key.connect(cb);} 
    125125    void addMouseButtonCallback(MouseButtonEventFn cb) {_lsig.mouseButton.connect(cb);} 
     
    143143/** Gather input from multiple places */ 
    144144/* 
    145 class CompoundInputAdaptor : InputAdapto
     145class CompoundInputAdapter : InputAdapte
    146146{ 
    147     InputAdaptor[] adaptors; 
     147    InputAdapter[] adapters; 
    148148} 
    149149*/ 
  • trunk/luigi/adaptor/glfw.d

    r13 r18  
    33 Copyright: 
    44 
    5   luigi/adaptor/glfw.d 
    6      -- GLFW input adaptor for the 'Luigi' user interface library. 
     5  luigi/adapter/glfw.d 
     6     -- GLFW input adapter for the 'Luigi' user interface library. 
    77 
    88  Copyright (C) 2006 William V. Baxter III 
     
    2626  William Baxter wbaxter@gmail.com 
    2727*/ 
    28 module luigi.adaptor.glfw; 
     28module luigi.adapter.glfw; 
    2929 
    3030import luigi.base; 
    3131import luigi.event; 
    32 import luigi.adaptor.base; 
     32import luigi.adapter.base; 
    3333import derelict.glfw.glfw; 
    3434//import sslot.signal; 
     
    110110 
    111111 
    112 class GLFWAdaptor : InputAdapto
     112class GLFWAdapter : InputAdapte
    113113{ 
    114     // Singleton access via static opCall GLFWAdaptor() 
    115     static GLFWAdaptor opCall() { 
    116         static GLFWAdaptor myinstance = null; 
     114    // Singleton access via static opCall GLFWAdapter() 
     115    static GLFWAdapter opCall() { 
     116        static GLFWAdapter myinstance = null; 
    117117        if (!myinstance) { 
    118             myinstance = new GLFWAdaptor; 
     118            myinstance = new GLFWAdapter; 
    119119            myinstance.init(); 
    120120        } 
     
    122122    } 
    123123    // Singleton access via 'inst' property 
    124     static GLFWAdaptor inst() { 
    125         return GLFWAdaptor(); 
     124    static GLFWAdapter inst() { 
     125        return GLFWAdapter(); 
    126126    } 
    127127 
     
    270270    // Singleton, so constructor is private 
    271271    this() { 
    272         initInputAdaptor(); 
     272        initInputAdapter(); 
    273273    } 
    274274    void init() { 
     
    283283 
    284284public: 
    285     mixin InputAdaptorMix; 
     285    mixin InputAdapterMix; 
    286286 
    287287} 
    288288 
    289289 
    290 alias GLFWAdaptor DefaultAdaptor; 
     290alias GLFWAdapter DefaultAdapter; 
  • trunk/luigi/example1.d

    r15 r18  
    1 //--------------------------------------------------------------------- 
    21/* 
    3  Copyright: 
    4  
     2  --------------------------------------------------------------------- 
    53  luigi/example1.d -- An example program using the Luigi user 
    64                      interface library. 
    75 
     6  An example/test program for Luigi. 
     7  Uses the GLFW windowing toolkit via luigi.adapter.glfw. 
     8  --------------------------------------------------------------------- 
    89  Copyright (C) 2006 William V. Baxter III 
    910 
     
    2526 
    2627  William Baxter wbaxter@gmail.com 
     28 
     29  --------------------------------------------------------------------- 
     30  Written in the D programming language (http://www.digitalmars.com/d) 
     31  --------------------------------------------------------------------- 
    2732*/ 
    2833import luigui = luigi.gui; 
    29 import luigi.adaptor.glfw; 
     34import luigi.adapter.glfw; 
    3035static import luigi.themes.dxut; 
    3136 
     
    6166{ 
    6267    bool dosync = true; 
     68    char[] theme = "std"; 
    6369     
    6470    //---------------- PARSE ARGS ----------------------- 
    65     foreach( a; argv ) { 
     71    for( int i=1; i<argv.length; i++ ) { 
     72        auto a = argv[i]; 
    6673        if (a == "-nosync") dosync = false; 
    6774        else if (a == "-help") { usage(argv[0]); return; } 
     75        else if (a == "-theme") { 
     76            theme = argv[++i]; 
     77        } 
    6878    } 
    6979 
     
    7585    // Enable sticky keys 
    7686    glfwEnable( GLFW_STICKY_KEYS ); 
     87    glfwEnable( GLFW_KEY_REPEAT ); 
    7788 
    7889    // Disable vertical sync if requested (on cards that support it) 
     
    8798    luigui.Overlay gui; 
    8899    with(luigui) { 
    89         Luigi().adaptor = GLFWAdaptor(); 
    90         Luigi().theme = new luigi.themes.dxut.DXUTTheme(); 
     100        Luigi().adapter = GLFWAdapter(); 
     101        if (theme == "dxut") { 
     102            Luigi().theme = new luigi.themes.dxut.DXUTTheme(); 
     103        } 
    91104        gui = new Overlay; 
    92105     
  • trunk/luigi/gui.d

    r17 r18  
    5555import luigi.theme; 
    5656import luigi.arranger; 
    57 import luigi.adaptor.base; 
     57import luigi.adapter.base; 
    5858//import sslot.signal; 
    5959import luigi.signalobj; 
    6060 
    61 //import adaptor = luigi.adaptor.glfw; 
     61//import adapter = luigi.adapter.glfw; 
    6262 
    6363import drawsys = luigi.gldraw; 
     
    7575/**  
    7676 * The singleton master object.   
    77  * Holds GUI globals including the theme, the input adaptor, and keeps track 
     77 * Holds GUI globals including the theme, the input adapter, and keeps track 
    7878 * of all the top-level Frames and Overlays. 
    7979*/ 
     
    9797 
    9898        if (!m_inputsys) { 
    99             throw new GUIException("Must set Luigi().adaptor before creating Overlays"); 
     99            throw new GUIException("Must set Luigi().adapter before creating Overlays"); 
    100100        } 
    101101 
     
    115115    } 
    116116 
    117     void adaptor(InputAdaptor inputsys) { 
     117    void adapter(InputAdapter inputsys) { 
    118118        m_inputsys = inputsys; 
    119119    } 
     
    130130 
    131131    Overlay[] m_guis; 
    132     InputAdaptor m_inputsys; 
     132    InputAdapter m_inputsys; 
    133133    Theme m_theme; 
    134134} 
  • trunk/luigi/themes/dxut.d

    r17 r18  
    8484    } 
    8585 
    86     //---------------------------------------------------------------------- 
     86    //----THEME DATA-------------------------------------------------------- 
    8787    class ThemeData { 
     88        // per-widget elements needed so we can blend objects independently 
    8889        Element[] elements; 
    8990    } 
     
    103104        return get_theme_data(w).elements; 
    104105    } 
    105     //---------------------------------------------------------------------- 
    106  
     106 
     107    //----GRPAHICS STATE------------------------------------------------------ 
     108    override void begin_drawing(Rect r) { 
     109        m_timer.stop(); 
     110        m_elapsedTime = m_timer.milliseconds / 1000.0; 
     111        m_timer.start(); 
     112         
     113        gldraw.push_graphics_state(r); 
     114        glPushAttrib(GL_TEXTURE_BIT); 
     115 
     116        glEnable(GL_BLEND); 
     117        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
     118        glBindTexture(GL_TEXTURE_2D,m_texid); 
     119        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
     120 
     121        glMatrixMode(GL_TEXTURE); 
     122        glPushMatrix(); 
     123        glLoadIdentity(); 
     124        glScalef(1./m_texw, 1./m_texh,1); 
     125        glMatrixMode(GL_MODELVIEW); 
     126 
     127    } 
     128    override void end_drawing() { 
     129        glPopAttrib(); // TEXTURE_BIT 
     130        gldraw.pop_graphics_state(); 
     131        glMatrixMode(GL_TEXTURE); 
     132        glPopMatrix(); 
     133        glMatrixMode(GL_MODELVIEW); 
     134    } 
    107135 
    108136    //============================================================================ 
    109     // Built-in Drawing and size routines 
     137    // Widget drawing and size routines 
    110138 
    111139    //----HELPERS----------------------------------------------------------------- 
     
    142170    } 
    143171 
    144     //----GRPAHICS STATE------------------------------------------------------ 
    145     void begin_drawing(Rect r) { 
    146         m_timer.stop(); 
    147         m_elapsedTime = m_timer.milliseconds / 1000.0; 
    148         m_timer.start(); 
    149          
    150         gldraw.push_graphics_state(r); 
    151         glPushAttrib(GL_TEXTURE_BIT); 
    152  
    153         glEnable(GL_BLEND); 
    154         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
    155         glBindTexture(GL_TEXTURE_2D,m_texid); 
    156         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
    157  
    158         glMatrixMode(GL_TEXTURE); 
    159         glPushMatrix(); 
    160         glLoadIdentity(); 
    161         glScalef(1./m_texw, 1./m_texh,1); 
    162         glMatrixMode(GL_MODELVIEW); 
    163  
    164     } 
    165     void end_drawing() { 
    166         glPopAttrib(); // TEXTURE_BIT 
    167         gldraw.pop_graphics_state(); 
    168         glMatrixMode(GL_TEXTURE); 
    169         glPopMatrix(); 
    170         glMatrixMode(GL_MODELVIEW); 
    171     } 
    172172    //----LABEL--------------------------------------------------------------- 
    173173    void label_register() { 
     
    180180        Element e; 
    181181        // button layer 
     182        e.set_texture( m_texid, [0,0,136,54] ); 
    182183        e.fontColor.states[ WidgetState.Disabled ] = Color(200,200,200,200); 
    183         e.set_texture( m_texid, [0,0,136,54] ); 
    184184        e.set_font( m_default_font ); 
    185185        e.texColor.states[ WidgetState.Normal ] = Color(255, 255, 255, 150);