Changeset 33

Show
Ignore:
Timestamp:
12/04/06 02:17:31 (2 years ago)
Author:
baxissimo
Message:

Got SDL adapter working.
Also made a doc.brf for compiling docs.

Files:

Legend:

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

    r32 r33  
    135135    void addWindowSizeCallback(WindowSizeEventDg cb)   {_lsig.windowSize.connect(cb);}   
    136136    void addWindowCloseCallback(WindowCloseEventDg cb) {_lsig.windowClose.connect(cb);}  
    137  
    138137} 
    139138 
  • trunk/luigi/adapters/gld.d

    r29 r33  
    8787    case GLD_KEY_HOME: return Key.Home; 
    8888    case GLD_KEY_END: return Key.End; 
    89     case GLD_KEY_KP_0: return Key.KP_0; 
    90     case GLD_KEY_KP_1: return Key.KP_1; 
    91     case GLD_KEY_KP_2: return Key.KP_2; 
    92     case GLD_KEY_KP_3: return Key.KP_3; 
    93     case GLD_KEY_KP_4: return Key.KP_4; 
    94     case GLD_KEY_KP_5: return Key.KP_5; 
    95     case GLD_KEY_KP_6: return Key.KP_6; 
    96     case GLD_KEY_KP_7: return Key.KP_7; 
    97     case GLD_KEY_KP_8: return Key.KP_8; 
    98     case GLD_KEY_KP_9: return Key.KP_9; 
     89    case GLD_KEY_KP_0: return Key.KP0; 
     90    case GLD_KEY_KP_1: return Key.KP1; 
     91    case GLD_KEY_KP_2: return Key.KP2; 
     92    case GLD_KEY_KP_3: return Key.KP3; 
     93    case GLD_KEY_KP_4: return Key.KP4; 
     94    case GLD_KEY_KP_5: return Key.KP5; 
     95    case GLD_KEY_KP_6: return Key.KP6; 
     96    case GLD_KEY_KP_7: return Key.KP7; 
     97    case GLD_KEY_KP_8: return Key.KP8; 
     98    case GLD_KEY_KP_9: return Key.KP9; 
    9999    case GLD_KEY_KP_DIVIDE: return Key.KP_Divide; 
    100100    case GLD_KEY_KP_MULTIPLY: return Key.KP_Multiply; 
     
    102102    case GLD_KEY_KP_ADD: return Key.KP_Add; 
    103103    case GLD_KEY_KP_DECIMAL: return Key.KP_Decimal; 
    104     case GLD_KEY_KP_EQUAL: return Key.KP_Equal
     104    case GLD_KEY_KP_EQUAL: return Key.KP_Equals
    105105    case GLD_KEY_KP_ENTER: return Key.KP_Enter; 
    106106    default: 
  • trunk/luigi/adapters/glfw.d

    r29 r33  
    3232import luigi.adapter; 
    3333import derelict.glfw.glfw; 
    34 //import sslot.signal; 
    3534import luigi.signalobj; 
    3635 
     
    8786    case GLFW_KEY_HOME: return Key.Home; 
    8887    case GLFW_KEY_END: return Key.End; 
    89     case GLFW_KEY_KP_0: return Key.KP_0; 
    90     case GLFW_KEY_KP_1: return Key.KP_1; 
    91     case GLFW_KEY_KP_2: return Key.KP_2; 
    92     case GLFW_KEY_KP_3: return Key.KP_3; 
    93     case GLFW_KEY_KP_4: return Key.KP_4; 
    94     case GLFW_KEY_KP_5: return Key.KP_5; 
    95     case GLFW_KEY_KP_6: return Key.KP_6; 
    96     case GLFW_KEY_KP_7: return Key.KP_7; 
    97     case GLFW_KEY_KP_8: return Key.KP_8; 
    98     case GLFW_KEY_KP_9: return Key.KP_9; 
     88    case GLFW_KEY_KP_0: return Key.KP0; 
     89    case GLFW_KEY_KP_1: return Key.KP1; 
     90    case GLFW_KEY_KP_2: return Key.KP2; 
     91    case GLFW_KEY_KP_3: return Key.KP3; 
     92    case GLFW_KEY_KP_4: return Key.KP4; 
     93    case GLFW_KEY_KP_5: return Key.KP5; 
     94    case GLFW_KEY_KP_6: return Key.KP6; 
     95    case GLFW_KEY_KP_7: return Key.KP7; 
     96    case GLFW_KEY_KP_8: return Key.KP8; 
     97    case GLFW_KEY_KP_9: return Key.KP9; 
    9998    case GLFW_KEY_KP_DIVIDE: return Key.KP_Divide; 
    10099    case GLFW_KEY_KP_MULTIPLY: return Key.KP_Multiply; 
     
    102101    case GLFW_KEY_KP_ADD: return Key.KP_Add; 
    103102    case GLFW_KEY_KP_DECIMAL: return Key.KP_Decimal; 
    104     case GLFW_KEY_KP_EQUAL: return Key.KP_Equal
     103    case GLFW_KEY_KP_EQUAL: return Key.KP_Equals
    105104    case GLFW_KEY_KP_ENTER: return Key.KP_Enter; 
    106105    default: 
  • trunk/luigi/event.d

    r17 r33  
    123123    LAlt,    Alt = LAlt, 
    124124    RAlt, 
     125    LMeta, 
     126    RMeta, 
     127    LSuper, 
     128    RSuper, 
     129    Mode, 
     130    Compose, 
    125131    Tab, 
    126132    Enter, 
     
    132138    Home, 
    133139    End, 
    134     KP_0, 
    135     KP_1, 
    136     KP_2, 
    137     KP_3, 
    138     KP_4, 
    139     KP_5, 
    140     KP_6, 
    141     KP_7, 
    142     KP_8, 
    143     KP_9, 
     140    KP0, 
     141    KP1, 
     142    KP2, 
     143    KP3, 
     144    KP4, 
     145    KP5, 
     146    KP6, 
     147    KP7, 
     148    KP8, 
     149    KP9, 
    144150    KP_Divide, 
    145151    KP_Multiply, 
     
    147153    KP_Add, 
    148154    KP_Decimal, 
    149     KP_Equal
     155    KP_Equals
    150156    KP_Enter, 
     157 
     158    NumLock, 
     159    CapsLock, 
     160    ScrollLock, 
     161 
     162    Help, 
     163    Print, 
     164    SysReq, 
     165    Break, 
     166    Menu, 
     167    Power, 
     168    Euro, 
     169    Undo, 
    151170} 
    152171 
  • trunk/luigi/example1_gld.brf

    r18 r33  
    33-I$(DMDDIR)\baxissimo 
    44-I$(DMDDIR)\ext 
    5  
    65-version=useDerelict 
    76-full 
  • trunk/luigi/gldraw.d

    r15 r33  
    365365} 
    366366 
     367void checkGLErrors(char[] file = null, int line = 0) 
     368{ 
     369    GLenum err; 
     370    while ( (err=glGetError()) != GL_NO_ERROR)  
     371    { 
     372        char[] errstr; 
     373        if (file) errstr = std.string.format("OpenGL error: %s(%s): ", file, line); 
     374        switch(err) { 
     375        case GL_INVALID_ENUM: 
     376            // An unacceptable value is specified for an enumerated 
     377            // argument. The offending command is ignored, having no 
     378            // side effect other than to set the error flag. 
     379            errstr ~= "Invalid enum"; 
     380            break; 
     381        case GL_INVALID_VALUE: 
     382            //A numeric argument is out of range. The offending command is 
     383            //ignored, having no side effect other than to set the error 
     384            //flag. 
     385            errstr ~= "Invalid value";  
     386            break; 
     387        case GL_INVALID_OPERATION: 
     388            //The specified operation is not allowed in the current 
     389            //state. The offending command is ignored, having no side 
     390            //effect other than to set the error flag. 
     391            errstr ~= "Invalid operation";  
     392            break; 
     393 
     394        case GL_STACK_OVERFLOW: 
     395            // This command would cause a stack overflow. The 
     396            // offending command is ignored, having no side effect 
     397            // other than to set the error flag. 
     398            errstr ~= "Stack overflow";  
     399            break; 
     400 
     401        case GL_STACK_UNDERFLOW: 
     402            //  This command would cause a stack underflow. The 
     403            //  offending command is ignored, having no side effect 
     404            //  other than to set the error flag. 
     405            errstr ~= "Stack underflow";  
     406            break; 
     407 
     408        case GL_OUT_OF_MEMORY: 
     409            //  There is not enough memory left to execute the 
     410            //  command. The state of the GL is undefined, except for 
     411            //  the state of the error flags, after this error is 
     412            //  recorded. 
     413            errstr ~= "Out of memory"; 
     414            break; 
     415        default: 
     416            errstr ~= std.string.format("Unknown error code: %s", err); 
     417        } 
     418        writefln(errstr); 
     419    } 
     420} 
     421 
     422 
    367423//---------------------------------------------------------------------------- 
    368424void push_graphics_state(Rect viewport) { 
     
    374430                 ); 
    375431    glDisable(GL_DEPTH_TEST); 
     432    glDisable(GL_LIGHTING); 
     433    glDisable(GL_CULL_FACE); 
     434    glDisable(GL_TEXTURE_2D); 
    376435    glEnable(GL_BLEND); 
     436    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
     437 
    377438    glViewport(0,0,lrint(viewport.w),lrint(viewport.h)); 
    378439    glMatrixMode(GL_PROJECTION); 
     440    glPushMatrix(); 
    379441    glLoadIdentity(); 
    380442    // Note! We put the origin at top left to match window sys conventions 
     
    383445            -1,1); 
    384446    glMatrixMode(GL_MODELVIEW); 
     447    glPushMatrix(); 
    385448    glLoadIdentity(); 
    386449} 
     
    393456    glPopMatrix(); 
    394457    // TODO restore viewport? 
    395 
     458    version(Debug) { 
     459        checkGLErrors(__FILE__,__LINE__); 
     460    } 
     461
  • trunk/luigi/gui.d

    r32 r33  
    443443    } 
    444444 
     445    /** Sets the keyboard focus of this widget's hierarchy to newfocus. 
     446     *  If newfocus is null any current focus item in this widget tree  
     447     *  will be unfocused. 
     448     */ 
     449    bool set_focus(Widget newfocus) 
     450    in {  get_root()._focus_sanity_check(); } body 
     451    { 
     452        if (newfocus) { 
     453            if (!newfocus.focusable) return false; 
     454            if (newfocus.m_focused) return true; 
     455        } 
     456 
     457        // unfocus the current guy first 
     458        Widget oldFocus = get_focus(); 
     459        if (oldFocus && !oldFocus._can_lose_focus()) { 
     460            return false; 
     461        } 
     462        else if (oldFocus) { 
     463            oldFocus._unfocus_rup(); 
     464        } 
     465         
     466        // Stop here if there's no new focus item 
     467        if (!newfocus) return true; 
     468 
     469        // now give focus to the new guy. 
     470        // Set his m_focused flag and percolate m_childFocused flags up the chain. 
     471        _FocusEvent ev; 
     472        ev.previous = oldFocus; 
     473        newfocus.on_focus(&ev); 
     474        if (!ev.alive) { 
     475            newfocus.m_focused = true; 
     476            if (newfocus.parent) newfocus.parent._set_child_focused_rup(); 
     477        } 
     478        return newfocus.m_focused; 
     479    } 
     480 
     481 
    445482    /** Set the keyboard focus to this item. 
    446483        Returns true if successful, false otherwise. 
     
    449486    in {  get_root()._focus_sanity_check(); } body 
    450487    { 
    451         if (!focusable) return false; 
    452         if (m_focused) return true; 
    453  
    454         // unfocus the current guy first 
    455         Widget oldFocus = get_focus(); 
    456         if (oldFocus && !oldFocus._can_lose_focus()) { 
    457             return false; 
    458         } 
    459         else if (oldFocus) { 
    460             oldFocus._unfocus_rup(); 
    461         } 
    462          
    463         // now focus this guy. 
    464         // Set his m_focused flag and percolate m_childFocused flags up the chain. 
    465         _FocusEvent ev; 
    466         ev.previous = oldFocus; 
    467         this.on_focus(&ev); 
    468         if (!ev.alive) { 
    469             m_focused = true; 
    470             if (parent) parent._set_child_focused_rup(); 
    471         } 
    472         return m_focused; 
     488        return set_focus(this); 
    473489    } 
    474490 
     
    10491065 
    10501066    /** Constructor.  Not every toolkit supports multiple windows (e.g. GLFW,SDL). 
    1051         If yours doesn't then you won't need the parameter. 
     1067        If yours doesn't then you may not need the parameter. 
    10521068    */ 
    10531069    this(WindowHandle win = null) { 
     
    10551071        hostwin = win; 
    10561072        Size sz = Luigi().get_window_size(win); 
     1073        writefln("Window size = ", sz); 
    10571074        set_rect(Rect(0,0,sz.w,sz.h)); 
    10581075        Luigi().add_overlay(this); 
     
    10671084    } 
    10681085 
     1086    /** Return the input adapter in current use.  Equivalent to Luigi().adapter. */ 
     1087    InputAdapter adapter() { 
     1088        return Luigi().adapter; 
     1089    } 
     1090 
    10691091protected: 
    10701092    override bool _set_mouse_grabber(Widget w) 
     
    10961118        if (focus) { 
    10971119            Luigi().theme.on_key(focus,ev); 
     1120        } else { 
     1121            ev.alive = true; 
    10981122        } 
    10991123        if ((!focus || ev.alive) && ev.is_press)  
     
    11021126            // (and also sys hotkeys? Ctrl-X etc) 
    11031127 
    1104             if (ev.key==Key.Tab) { 
     1128            if (ev.key==Key.Escape && focus && ev.alive) { 
     1129                // Lose gui focus 
     1130                set_focus(null); 
     1131                ev.alive = false; 
     1132            } 
     1133            else if (ev.key==Key.Tab) 
     1134            { 
    11051135                if (ev.mods == KeyMods.None) { 
    11061136                    focus_next(); 
     1137                    ev.alive = false; 
    11071138                } 
    11081139                else if (ev.mods == KeyMods.Shift) { 
    11091140                    focus_prev(); 
     1141                    ev.alive = false; 
    11101142                } 
    11111143            } 
     1144        } 
     1145        else if (!focus) { 
     1146            ev.alive = true; 
    11121147        } 
    11131148    } 
     
    11261161            _xform_event_to_widget(target, ev); 
    11271162            Luigi().theme.on_mouse_button(target, ev); 
     1163        } 
     1164        else { 
     1165            ev.alive = true; 
    11281166        } 
    11291167    } 
     
    11791217    } 
    11801218 
    1181    
     1219     
    11821220 
    11831221private: 
     
    13211359    } 
    13221360} 
     1361 
     1362/// An alternate spelling for Checkbox, because I can never remember which it is. 
     1363alias Checkbox CheckBox; 
    13231364 
    13241365class TextField : Widget 
     
    15321573} 
    15331574 
     1575/// An alternate spelling for TextField, because I can never remember which it is. 
     1576alias TextField Textfield; 
     1577 
    15341578/** 
    15351579 * Slider represents a floating point value.  Since it uses a double for