Changeset 46

Show
Ignore:
Timestamp:
04/19/08 21:23:06 (8 months ago)
Author:
kaarna
Message:

Faster.Added x1N(set) type methods for speed.Doublesided testing.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pihlaja/src/pihlaja/PihlajaMain.d

    r45 r46  
    202202         
    203203        super(); 
     204         
     205        isDoubleSided = true; 
    204206         
    205207        initVideo(); 
     
    418420    */ 
    419421     
    420     //rename to render() draw() or similar. 
     422     
    421423    void render() 
    422424    { 
     
    426428            applyRotation(); 
    427429            applyScale(); 
     430             
     431            applyCulling(); 
    428432            applyColour(); 
    429             applyClipping(); 
     433             
    430434     
    431435        /*GLdouble eqn[4] = [0.0, 1.0, 0.0, 0.0];    // y < 0 
     
    483487         
    484488         
     489        //TODO draw children... 
     490        //Check if it's just this simple: 
     491        applyClipping(); 
     492            doRend(); 
     493        endClipping(); 
     494         
    485495        glPopMatrix(); 
    486496    } 
     
    509519                 
    510520                glEnable(GL_TEXTURE_2D); 
     521                 
     522                //glEnable(GL_CULL_FACE); 
    511523                 
    512524        /* 
     
    608620                float hh = fs.h / TEXTURE_HEIGHT; 
    609621                 
     622             
     623                 
    610624                glColor4f( 1.0f, 1.0f, 1.0f, fs.alpha ); //Control Transparency 
    611625                glBegin (GL_QUADS); 
     
    901915         
    902916        myWindow2 = new SubWindow("Viewer"); 
     917         
     918        myWindow2.side1.container.isDoubleSided = true;//BUG WEIRD. Why do I have to do this too? 
     919         
    903920        //myWindow2.isRotate = true; 
    904921        Trace.formatln("{}", myWindow2 ); 
     
    908925        //myWindow2.colour( 0.2, 0.5, 0.3, 0.5 ); 
    909926        myWindow2.signalMouseButtonPress.attach(&clickHandler); 
     927         
     928        myWindow2.side2.a = 0.5f;//TEMP hack. Side2 alpha to 0.5. 
     929        auto isInterlacedButton = new Button("Interlaced"); 
     930        isInterlacedButton.a = 0.5f; 
     931        isInterlacedButton.signalActivate.attach(&clickHandler3); 
     932        myWindow2.add2(isInterlacedButton); 
    910933         
    911934        myWindow2.add(videoViewer); 
  • trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d

    r45 r46  
    976976    protected float _scale = 1.0f; 
    977977     
     978    //If this Rectangle is double-sided or not. 
     979    //If it is, we'll use OpenGL culling to remove 
     980    //the back. 
     981    bool isDoubleSided() { return m_isDoubleSided; } 
     982    bool isDoubleSided(bool set) { return m_isDoubleSided = set; } 
     983    bool m_isDoubleSided = false; 
     984     
    978985    //To draw an outline or not... 
    979986    bool isOutline() { return m_isOutline; } 
     
    9931000            applyScale(); 
    9941001             
     1002            applyCulling(); 
    9951003            applyTexture(); 
    9961004            applyColour(); 
     
    10461054    } 
    10471055     
     1056    void applyCulling() 
     1057    { 
     1058        if( isDoubleSided == true ) 
     1059            glDisable(GL_CULL_FACE); 
     1060        else glEnable(GL_CULL_FACE); 
     1061    } 
     1062    //TODO endCulling() ??? 
     1063     
    10481064    void applyTexture() 
    10491065    { 
     
    10751091            applyScale(); 
    10761092             
     1093            applyCulling(); 
    10771094            applyTexture(); 
    10781095            applyColour(); 
     
    14441461        return _xPos + _ix1; 
    14451462    } 
     1463    public float x1N( float set )//N versions don't do arrange and invalidate automatically. 
     1464    { 
     1465        float delt = set - x1; 
     1466        _ix1 = _ix1 + (delt*0.5);//Move _ix1 half the delta. 
     1467        _xPos = _xPos + (delt*0.5);//Move xPos half the delta. 
     1468        _ix2 = _ix2 - (delt*0.5);//Move _ix2 half the delta to the other direction. 
     1469        //arrange(); 
     1470        //invalidate(); 
     1471        return _xPos + _ix1; 
     1472    } 
    14461473    public float ix1() { return _ix1; } 
    14471474    public float ix1( float set ) //{ return _ix1 = set; } 
     
    14501477        arrange(); 
    14511478        invalidate(); 
     1479        return _ix1; 
     1480    } 
     1481    public float ix1N( float set ) //{ return _ix1 = set; } 
     1482    { 
     1483        _ix1 = set; 
     1484        //arrange(); 
     1485        //invalidate(); 
    14521486        return _ix1; 
    14531487    } 
     
    14661500        return _yPos + _iy1; 
    14671501    } 
     1502    public float y1N( float set ) 
     1503    { 
     1504        float delt = set - y1; 
     1505        _iy1 = _iy1 + (delt*0.5);//Move _iy1 half the delta. 
     1506        _yPos = _yPos + (delt*0.5);//Move yPos half the delta. 
     1507        _iy2 = _iy2 - (delt*0.5);//Move _iy2 half the delta to the other direction. 
     1508        //arrange(); 
     1509        //invalidate(); 
     1510        return _yPos + _iy1; 
     1511    } 
    14681512    public float iy1() { return _iy1; } 
    14691513    public float iy1( float set ) //{ return _iy1 = set; } 
     
    14721516        arrange(); 
    14731517        invalidate(); 
     1518        return _iy1; 
     1519    } 
     1520    public float iy1N( float set ) //{ return _iy1 = set; } 
     1521    { 
     1522        _iy1 = set; 
     1523        //arrange(); 
     1524        //invalidate(); 
    14741525        return _iy1; 
    14751526    } 
     
    14881539        return _xPos + _ix2; 
    14891540    } 
     1541    public float x2N( float set ) 
     1542    { 
     1543        float delt = set - x2; 
     1544        _ix2 = _ix2 + (delt*0.5);//Move _ix2 half the delta. 
     1545        _xPos = _xPos + (delt*0.5);//Move xPos half the delta. 
     1546        _ix1 = _ix1 - (delt*0.5);//Move _ix1 half the delta to the other direction. 
     1547        //arrange(); 
     1548        //invalidate(); 
     1549        return _xPos + _ix2; 
     1550    } 
    14901551     
    14911552    public float ix2() { return _ix2; } 
     
    14951556        arrange(); 
    14961557        invalidate(); 
     1558        return _ix2; 
     1559    } 
     1560    public float ix2N( float set ) //{ return _ix2 = set; } 
     1561    { 
     1562        _ix2 = set; 
     1563        //arrange(); 
     1564        //invalidate(); 
    14971565        return _ix2; 
    14981566    } 
     
    15071575        arrange(); 
    15081576        invalidate(); 
     1577        return _ix2 - _ix1; 
     1578    } 
     1579    public float wN( float set ) 
     1580    { 
     1581        float delt = w - set; 
     1582        _ix1 = _ix1 + (delt*0.5);//Move _ix1 half the delta. 
     1583        _ix2 = _ix2 - (delt*0.5);//Move _ix2 half the delta. 
     1584        //arrange(); 
     1585        //invalidate(); 
    15091586        return _ix2 - _ix1; 
    15101587    } 
     
    15311608        return _yPos + _iy2; 
    15321609    } 
     1610    public float y2N( float set ) 
     1611    { 
     1612        float delt = set - y2; 
     1613        _iy2 = _iy2 + (delt*0.5);//Move _iy2 half the delta. 
     1614        _yPos = _yPos + (delt*0.5);//Move yPos half the delta. 
     1615        _iy1 = _iy1 - (delt*0.5);//Move _iy1 half the delta to the other direction. 
     1616        //arrange(); 
     1617        //invalidate(); 
     1618        return _yPos + _iy2; 
     1619    } 
    15331620     
    15341621    public float iy2() { return _iy2; } 
     
    15381625        arrange(); 
    15391626        invalidate(); 
     1627        return _iy2; 
     1628    } 
     1629    public float iy2N( float set ) //{ return _iy2 = set; } 
     1630    { 
     1631        _iy2 = set; 
     1632        //arrange(); 
     1633        //invalidate(); 
    15401634        return _iy2; 
    15411635    } 
     
    15501644        arrange(); 
    15511645        invalidate(); 
     1646        return _iy2 - _iy1; 
     1647    } 
     1648    public float hN( float set ) 
     1649    { 
     1650        float delt = h - set; 
     1651        _iy1 = _iy1 + (delt*0.5);//Move _iy1 half the delta. 
     1652        _iy2 = _iy2 - (delt*0.5);//Move _iy2 half the delta. 
     1653        //arrange(); 
     1654        //invalidate(); 
    15521655        return _iy2 - _iy1; 
    15531656    } 
  • trunk/pihlaja/src/shiraz/canvas/Rectangle.d

    r45 r46  
    26322632    void arrange() 
    26332633    { 
    2634         //Trace.formatln("This size: {}", toString() ); 
     2634        //Trace.formatln("arrange() {}", fullName() ); 
    26352635     
    26362636        //checkZOrder();//This isn't entirely necessary on most 
     
    26602660                        //if( wid.hasMaxWidth == true && (w - (border*2.0)) > wid.maxWidth ) 
    26612661                        if( wid.hasMaxHeight == true && (h - (wid.padding*2.0)) > wid.maxHeight ) 
    2662                             wid.h = wid.maxHeight;//was wc() 
     2662                            wid.hN = wid.maxHeight;//was wc() 
    26632663                        //else if( wid.hasMinWidth == true && (w - (border*2.0)) < wid.minWidth ) 
    26642664                        else if( wid.hasMinHeight == true && (h - (wid.padding*2.0)) < wid.minHeight ) 
    2665                             wid.h = wid.minHeight;//was wc() 
     2665                            wid.hN = wid.minHeight;//was wc() 
    26662666                        else 
    26672667                            //wid.wc = w - (border*2.0); 
    2668                             wid.h = h - (wid.padding*2.0);//was wc() 
     2668                            wid.hN = h - (wid.padding*2.0);//was wc() 
    26692669                    } 
    26702670                    else if( wid.yPackOptions == PackOptions.SHRINK ) 
    26712671                    { 
    2672                         wid.h = h - (wid.padding*2.0); 
     2672                        wid.hN = h - (wid.padding*2.0); 
    26732673                    } 
    26742674                     
     
    26772677                        //if( wid.hasMaxWidth == true && (w - (border*2.0)) > wid.maxWidth ) 
    26782678                        if( wid.hasMaxWidth == true && (w - (wid.padding*2.0)) > wid.maxWidth ) 
    2679                             wid.w = wid.maxWidth;//was wc() 
     2679                            wid.wN = wid.maxWidth;//was wc() 
    26802680                        //else if( wid.hasMinWidth == true && (w - (border*2.0)) < wid.minWidth ) 
    26812681                        else if( wid.hasMinWidth == true && (w - (wid.padding*2.0)) < wid.minWidth ) 
    2682                             wid.w = wid.minWidth;//was wc() 
     2682                            wid.wN = wid.minWidth;//was wc() 
    26832683                        else 
    26842684                            //wid.wc = w - (border*2.0); 
    2685                             wid.w = w - (wid.padding*2.0);//was wc() 
     2685                            wid.wN = w - (wid.padding*2.0);//was wc() 
    26862686                    } 
    26872687                    else if( wid.yPackOptions == PackOptions.SHRINK ) 
    26882688                    { 
    2689                         wid.w = w - (wid.padding*2.0); 
     2689                        wid.wN = w - (wid.padding*2.0); 
    26902690                    } 
    26912691                     
     
    27912791                            //if( wid.hasMaxWidth == true && (w - (border*2.0)) > wid.maxWidth ) 
    27922792                            if( wid.hasMaxHeight == true && (h - (wid.padding*2.0)) > wid.maxHeight ) 
    2793                                 wid.h = wid.maxHeight;//was wc() 
     2793                                wid.hN = wid.maxHeight;//was wc() 
    27942794                            //else if( wid.hasMinWidth == true && (w - (border*2.0)) < wid.minWidth ) 
    27952795                            else if( wid.hasMinHeight == true && (h - (wid.padding*2.0)) < wid.minHeight ) 
    2796                                 wid.h = wid.minHeight;//was wc() 
     2796                                wid.hN = wid.minHeight;//was wc() 
    27972797                            else 
    27982798                                //wid.wc = w - (border*2.0); 
    2799                                 wid.h = h - (wid.padding*2.0);//was wc() 
     2799                                wid.hN = h - (wid.padding*2.0);//was wc() 
    28002800                        } 
    28012801                        else if( wid.yPackOptions == PackOptions.SHRINK ) 
    28022802                        { 
    2803                             wid.h = h - (wid.padding*2.0); 
     2803                            wid.hN = h - (wid.padding*2.0); 
    28042804                        } 
    28052805                         
     
    28102810                            if( wid.hasMaxWidth == true && temp_width_shared > wid.maxWidth ) 
    28112811                            { 
    2812                                 wid.w = wid.maxWidth;//was hc() 
     2812                                wid.wN = wid.maxWidth;//was hc() 
    28132813                                debug(arrange) Trace.formatln("wid.w {} set to w.maxWidth {}", cast(double)wid.w, cast(double)wid.maxWidth ); 
    28142814                            } 
    28152815                            else if( wid.hasMinWidth == true && temp_width_shared < wid.minWidth ) 
    28162816                            { 
    2817                                 wid.w = wid.minWidth;//was hc() 
     2817                                wid.wN = wid.minWidth;//was hc() 
    28182818                                debug(arrange) Trace.formatln("wid.w {} set to w.minWidth {}", cast(double)wid.w, cast(double)wid.minWidth ); 
    28192819                            } 
    28202820                            else 
    28212821                            { 
    2822                                 //wid.h = temp_height_shared;//was hc() 
    2823                                 wid.w = width_left_for_one; 
     2822                                //wid.hN = temp_height_shared;//was hc() 
     2823                                wid.wN = width_left_for_one; 
    28242824                                debug(arrange) 
    28252825                                { 
     
    28382838                            if( wid.hasMinWidth == true && temp_width_shared > wid.minWidth ) 
    28392839                            { 
    2840                                 wid.w = wid.minWidth;//was hc() 
     2840                                wid.wN = wid.minWidth;//was hc() 
    28412841                                debug(arrange) Trace.formatln("wid.w {} set to w.minWidth {}", cast(double)wid.w, cast(double)wid.minWidth ); 
    28422842                            }    
    28432843                            else if( wid.defaultWidth < temp_width_shared ) 
    28442844                            { 
    2845                                 wid.w = wid.defaultWidth; 
     2845                                wid.wN = wid.defaultWidth; 
    28462846                                debug(arrange) Trace.formatln("wid.w {} set to w.defaultWidth {}", cast(double)wid.w, cast(double)wid.defaultWidth ); 
    28472847                            } 
    28482848                            else 
    28492849                            { 
    2850                                 wid.w = temp_width_shared; 
     2850                                wid.wN = temp_width_shared; 
    28512851                                debug(arrange) Trace.formatln("wid.w {} set to temp_width_shared {}", cast(double)wid.w, cast(double)temp_width_shared ); 
    28522852                            } 
     
    29532953                            //if( wid.hasMaxWidth == true && (w - (border*2.0)) > wid.maxWidth ) 
    29542954                            if( wid.hasMaxWidth == true && (w - (wid.padding*2.0)) > wid.maxWidth ) 
    2955                                 wid.w = wid.maxWidth;//was wc() 
     2955                                wid.wN = wid.maxWidth;//was wc() 
    29562956                            //else if( wid.hasMinWidth == true && (w - (border*2.0)) < wid.minWidth ) 
    29572957                            else if( wid.hasMinWidth == true && (w - (wid.padding*2.0)) < wid.minWidth ) 
    2958                                 wid.w = wid.minWidth;//was wc() 
     2958                                wid.wN = wid.minWidth;//was wc() 
    29592959                            else 
    29602960                                //wid.wc = w - (border*2.0); 
    2961                                 wid.w = w - (wid.padding*2.0);//was wc() 
     2961                                wid.wN = w - (wid.padding*2.0);//was wc() 
    29622962                        } 
    29632963                         
     
    29652965                        { 
    29662966                            if( wid.hasMaxHeight == true && temp_height_shared > wid.maxHeight ) 
    2967                             wid.h = wid.maxHeight;//was hc() 
     2967                            wid.hN = wid.maxHeight;//was hc() 
    29682968                        else if( wid.hasMinHeight == true && temp_height_shared < wid.minHeight ) 
    2969                             wid.h = wid.minHeight;//was hc() 
     2969                            wid.hN = wid.minHeight;//was hc() 
    29702970                        else 
    2971                             //wid.h = temp_height_shared;//was hc() 
    2972                             wid.h = height_left_for_one; 
     2971                            //wid.hN = temp_height_shared;//was hc() 
     2972                            wid.hN = height_left_for_one; 
    29732973                        } 
    29742974                        /* 
    29752975                        else if( wid.yPackOptions == PackOptions.SHRINK ) 
    29762976                        { 
    2977                             wid.h = wid.defaultHeight; 
     2977                            wid.hN = wid.defaultHeight; 
    29782978                        } 
    29792979                        */ 
     
    30163016        if( parent !is null ) 
    30173017            parent.arrangeParent(); 
     3018             
     3019        invalidate(); 
    30183020    } 
    30193021     
  • trunk/pihlaja/src/shiraz/ui/Button.d

    r45 r46  
    171171            applyScale(); 
    172172             
     173            applyCulling(); 
     174             
    173175            //float zero = 0.0f; 
    174176             
  • trunk/pihlaja/src/shiraz/ui/ProgressBar.d

    r42 r46  
    5353    { 
    5454        super(); 
     55         
     56        name = "GradientRect"; 
    5557         
    5658        colour( 25.0f/255.0f, 35.0f/255.0f, 19.0f/255.0f, 1.0f); 
  • trunk/pihlaja/src/shiraz/ui/SubWindow.d

    r45 r46  
    218218            applyRotation(); 
    219219            applyScale(); 
    220             applyClipping(); 
     220             
     221            applyCulling(); 
    221222            applyTexture(); 
    222223            applyColour(); 
     
    304305            } 
    305306             
    306             doRend(); 
    307              
     307             
     308            applyClipping(); 
     309                doRend(); 
    308310            endClipping(); 
    309311             
     
    383385            applyScale(); 
    384386             
     387            applyCulling(); 
     388             
     389             
    385390            //float zero = 0.0f; 
    386391             
     
    731736             
    732737            applyClipping(); 
    733              
    734738                doRend(); 
    735              
    736739            endClipping(); 
    737740             
     
    796799         
    797800        leftSeparator = new Rectangle(); 
     801        leftSeparator.name = "leftSeparator";//TEMP 
    798802        //leftSeparator.maxWidth = 0.012f; 
    799803        leftSeparator.maxWidth = 0.025f; 
     
    815819         
    816820        rightSeparator = new Rectangle(); 
     821        rightSeparator.name = "rightSeparator";//TEMP 
    817822        //rightSeparator.maxWidth = 0.012f; 
    818823        rightSeparator.maxWidth = 0.025f; 
     
    900905            applyRotation(); 
    901906            applyScale(); 
    902             applyClipping(); 
     907             
     908            applyCulling(); 
    903909            //applyColour(); 
    904910             
     
    937943            } 
    938944             
    939              
    940             doRend(); 
    941              
     945            applyClipping(); 
     946                doRend(); 
    942947            endClipping(); 
    943948         
     
    10831088        if( input.mouse.button[MouseButton.LEFT] == true ) 
    10841089        { 
    1085             controlWidget.x2 = controlWidget.x2 + input.mouse.xRel; 
     1090            controlWidget.x2N = controlWidget.x2 + input.mouse.xRel; 
    10861091            controlWidget.y2 = controlWidget.y2 + input.mouse.yRel; 
    10871092            //myWindow4.moveTo( input.mouse.x, input.mouse.y ); 
     
    11291134        //bottomHeader.set( 0.0, h/2.0, w, 0.1 ); 
    11301135    }*/ 
     1136     
     1137    //Colour is overridden to control container widget. 
     1138    float r() { return ((container is null) ? _colour_data[0] : container.r); } 
     1139    float g() { return ((container is null) ? _colour_data[1] : container.g); } 
     1140    float b() { return ((container is null) ? _colour_data[2] : container.b); } 
     1141    float a() { return ((container is null) ? _colour_data[3] : container.a); } 
     1142     
     1143     
     1144     
     1145    float r( float set ) { return ((container is null) ? (_colour_data[0] = set) : (container.r = set)); } 
     1146    float g( float set ) { return ((container is null) ? (_colour_data[1] = set) : (container.g = set)); } 
     1147    float b( float set ) { return ((container is null) ? (_colour_data[2] = set) : (container.b = set)); } 
     1148    float a( float set ) { return ((container is null) ? (_colour_data[3] = set) : (container.a = set)); } 
     1149     
    11311150     
    11321151    //class Header? 
     
    11611180        super(); 
    11621181         
     1182        name = "Sides"; 
     1183         
    11631184        padding = 0.0f; 
    11641185         
     
    11821203            applyRotation(); 
    11831204            applyScale(); 
    1184          
     1205            
    11851206            uint i = 0; 
    11861207            foreach( Rectangle rect; itemList ) 
     
    11981219    synchronized bool mouseEvent( InputState input )//THIS , bool bypass_hittest = false ) 
    11991220    { 
    1200         if( yRot == 0.0f || yRot == 360.0f
     1221        if( yRot >= -90.0f && yRot <= 90.0f || yRot >= 270.0f && yRot <= 450.0f
    12011222        { 
    1202             if( itemList.length != 0 ) 
     1223            if( itemList.length > 0 ) 
    12031224                return itemList[0].mouseEvent(input); 
     1225        } 
     1226        else if( yRot > 90.0f && yRot < 270.0f ) 
     1227        { 
     1228            if( itemList.length > 1 ) 
     1229                return itemList[1].mouseEvent(input); 
    12041230        } 
    12051231         
     
    12811307        side1.prepend( a_widget ); 
    12821308    } 
     1309     
     1310    void add2( Rectangle a_widget ) 
     1311    { 
     1312        side2.append( a_widget ); 
     1313    } 
     1314 
     1315    void append2( Rectangle a_widget ) 
     1316    { 
     1317        side2.append( a_widget ); 
     1318    } 
     1319     
     1320    void prepend2( Rectangle a_widget ) 
     1321    { 
     1322        side2.prepend( a_widget ); 
     1323    } 
    12831324 
    12841325    PlainWindow side1; 
  • trunk/pihlaja/src/shiraz/ui/Window.d

    r45 r46  
    835835        debug(Hitting) Trace.formatln("Window.mouseEvent() START."); 
    836836        debug(Hitting) scope(exit) Trace.formatln("Window.mouseEvent() END."); 
     837     
     838        //Trace.formatln("Window.mouseEvent() START."); 
    837839     
    838840        bool was_handled = false;