Changeset 21

Show
Ignore:
Timestamp:
07/26/07 08:18:16 (1 year ago)
Author:
satelliittipupu
Message:

EditGroups? are now better. Saving and loading editGroups works too.

Files:

Legend:

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

    r20 r21  
    6464 
    6565    //mixin PlaybackBin; //No. Not this. 
     66     
     67    public char[] id() { return m_id; } 
     68    public char[] id( char[] set ) { return m_id = set; } 
     69    protected char[] m_id; 
    6670 
    6771    //Notice that the order is x, W, y, h and not the usual x, y, W, h. Width is the second argument. 
     
    7175        debug(Edit) Stdout("Edit.this() START.").newline; 
    7276        debug(Edit) scope(exit) Stdout("Edit.this() END.").newline; 
     77 
     78        id = Integer.toUtf8( cast(size_t)cast(void*)this ); 
    7379 
    7480        m_scene = set_scene; 
     
    219225    { 
    220226        xw.startElement("Edit"); 
     227            xw.addAttribute( "id", id ); 
    221228            xw.addAttribute( "name", name ); 
    222229            xw.addAttribute( "start", Float.toUtf8(start) ); 
     
    228235            xw.addAttribute( "mediaStart", Float.toUtf8(mediaStart) ); 
    229236            xw.addAttribute( "mediaDuration", Float.toUtf8(mediaDuration) ); 
    230             xw.addAttribute( "materialID", material.id ); 
     237            xw.addAttribute( "materialId", material.id ); 
     238            if( editGroup !is null ) 
     239                xw.addAttribute( "editGroupId", editGroup.id() ); 
     240            else xw.addAttribute( "editGroupId", "@none" ); 
    231241        xw.endElement("Edit"); 
    232242    } 
     
    254264            debug(loading) Stdout("updateAll() Wen't fine.").newline; 
    255265        } 
     266         
     267        updatePipelineStart(); 
     268        updatePipelineDuration(); 
    256269    } 
    257270 
     
    608621    }*/ 
    609622 
    610     //public char[] loadedMaterialID
     623    //public char[] loadedMaterialId
    611624    Material material(){ return m_material; } 
    612625    Material material( Material set ) 
     
    707720    }*/ 
    708721 
    709     LinkSeq!(Edit) editGroup() { return m_editGroup; } 
    710     LinkSeq!(Edit) editGroup( LinkSeq!(Edit) set ) { return m_editGroup = set; } 
    711  
     722    class EditGroup : protected LinkSeq!(Edit) 
     723    { 
     724     
     725        this() 
     726        { 
     727            id = Integer.toUtf8( cast(size_t)cast(void*)this ); 
     728            super(); 
     729            //m_editSeq = new LinkSeq!(Edit); 
     730        } 
     731         
     732        /* 
     733        //Just an idea, but it's not really a good one. 
     734         
     735        void save003( XMLWriter!() xw ) 
     736        { 
     737            xw.startElement("EditGroup"); 
     738                xw.addAttribute( "id", id ); 
     739                foreach( Edit ed; editSeq ) 
     740                { 
     741                    xw.startElement("EditId"); 
     742                    xw.addAttribute( "id", ed.id ); 
     743                    xw.addAttribute( "name", ed.name ); 
     744                    xw.endElement("EditId"); 
     745                } 
     746            xw.endElement("EditGroup"); 
     747             
     748        } 
     749        */ 
     750     
     751        /* 
     752        public LinkSeq!(Edit) editGroup() { return m_editGroup; } 
     753        public LinkSeq!(Edit) editGroup( LinkSeq!(Edit) set ) { return m_editGroup = set; } 
     754        protected LinkSeq!(Edit) m_editGroup; 
     755        */ 
     756         
     757        int opApply(int delegate(inout Edit) dg) 
     758        { 
     759            return super.opApply(dg); 
     760        } 
     761         
     762        public void append(Edit set) 
     763        { 
     764            //editSeq.append(set); 
     765            super.append(set); 
     766        } 
     767         
     768        public void merge( EditGroup set ) 
     769        { 
     770            //LinkSeq!(Edit) set_edit_group_mem = set.editSeq(); 
     771            //EditGroup set_edit_group_mem = set; 
     772 
     773            foreach( Edit item; set )//_edit_group_mem ) 
     774            { 
     775                //editSeq.append( item ); 
     776                super.append( item ); 
     777                item.editGroup = this; 
     778            } 
     779            //delete set_edit_group_mem; 
     780            delete set; 
     781        } 
     782         
     783        //public LinkSeq!(Edit) editSeq() { return m_editSeq; } 
     784        //public LinkSeq!(Edit) editSeq( LinkSeq!(Edit) set ) { return m_editSeq = set; } 
     785        //protected LinkSeq!(Edit) m_editSeq; 
     786     
     787        public char[] id() { return m_id; } 
     788        public char[] id( char[] set ) { return m_id = set; } 
     789        protected char[] m_id; 
     790    } 
     791 
     792    public EditGroup editGroup() { return m_editGroup; } 
     793    public EditGroup editGroup( EditGroup set ) { return m_editGroup = set; } 
     794    protected EditGroup m_editGroup; 
     795 
     796    /** 
     797        This is used when loading. It checks for existing editGroups 
     798        with the id, and if none is found it will create a new one with 
     799        the id. 
     800    */ 
     801    void addToEditGroupById( char[] gid ) 
     802    { 
     803        debug(EditGroup) Stdout("Edit.addToEditGroupById(char[]) START.").newline; 
     804        debug(EditGroup) scope(exit) Stdout("Edit.addToEditGroupById(char[]) END.").newline; 
     805         
     806        if( gid == "@none" ) 
     807            return; 
     808             
     809        if( editGroup !is null ) 
     810        { 
     811            debug(EditGroup) Stdout("Edit.addToEditGroupById() There already is an editGroup. This shouldn't happen.").newline; 
     812            //TODO throw an exception, and catch it graphically in main? 
     813        } 
     814         
     815        foreach( Edit ed; scene.edit ) 
     816        { 
     817            EditGroup grup = ed.editGroup; 
     818            if( grup !is null ) 
     819            { 
     820                if( grup.id == gid ) 
     821                { 
     822                    ed.addToEditGroup( this ); 
     823                    return;//I bet it's enough to find the first 
     824                    //group with this id. There should be only one... I hope. 
     825                } 
     826            } 
     827        } 
     828         
     829        //No editGroup found with that id. Create a new one. 
     830        editGroup = new EditGroup(); 
     831        editGroup.id = gid;//This might theoretically screw up stuff, 
     832        //if the loaded id's would overlap with some newly created ones. 
     833        //So we should really use some UID system... TODO I bet Tango has them 
     834        //in it's newest version. 
     835        editGroup.append( this ); 
     836         
     837    } 
     838 
     839    /** 
     840        Make this and set to be in the same editGroup and create the 
     841        group if needed. 
     842    */ 
    712843    void addToEditGroup( Edit set ) 
    713844    { 
     
    721852                { 
    722853                    debug(EditGroup) Stdout("Edit.addToEditGroup(Edit ed) neither of them has an editGroup. We'll create a new one."); 
    723                     editGroup = new LinkSeq!(Edit); 
     854                    editGroup = new EditGroup();//LinkSeq!(Edit); 
    724855                    set.editGroup = editGroup; 
    725856 
     
    735866                } 
    736867            } 
    737             else //set already has a chain
     868            else //set already has an editGroup
    738869            { 
    739870                if( editGroup is null )//but this doesn't, so we'll just add this to set.chain. 
     
    746877                else if( set.editGroup is editGroup ) 
    747878                { 
    748                     //We don't do anything, because they are in the same sceneChain
     879                    //We don't do anything, because they are in the same editGroup
    749880                    debug(EditGroup) Stdout( "Edit.addToEditGroup() set.editGroup is editGroup. They already are synced into the same group.'" ); 
    750881                } 
     
    756887                    //because it will get changed away in the 
    757888                    //foreach loops. Atleast it should: 
    758                     LinkSeq!(Edit) set_edit_group_mem = set.editGroup(); 
    759  
    760                     foreach( Edit item; set_edit_group_mem ) 
    761                     { 
    762                         editGroup.append( item ); 
    763                         item.editGroup = editGroup; 
    764                     } 
    765                     delete set_edit_group_mem; 
     889                    editGroup.merge( set.editGroup() ); 
    766890                } 
    767891            } 
     
    799923    //the properties correctly. 
    800924 
    801     LinkSeq!(Edit) m_editGroup; 
    802      
    803925    public uint numberOfVisibleHandles() { return m_numberOfVisibleHandles; } 
    804926    public uint numberOfVisibleHandles( uint set ) 
  • trunk/pihlaja/src/pihlaja/core/material.d

    r20 r21  
    289289            xw.addAttribute( "name", name ); 
    290290            if( linkMovie !is null ) 
    291                 xw.addAttribute( "linkMovieID", linkMovie.id() ); 
    292             else xw.addAttribute( "linkMovieID", "@none" ); 
     291                xw.addAttribute( "linkMovieId", linkMovie.id() ); 
     292            else xw.addAttribute( "linkMovieId", "@none" ); 
    293293            xw.addAttribute( "mediaStart", Float.toUtf8(mediaStart) ); 
    294294            xw.addAttribute( "mediaDuration", Float.toUtf8(mediaDuration) ); 
     
    307307            if( linkMovie is null ) 
    308308            { 
    309                 linkMovie = pr.getMovieByID( linkMovieID ); 
     309                linkMovie = pr.getMovieById( linkMovieId ); 
    310310                if( linkMovie is null ) 
    311311                { 
    312                     Stdout("Material.updateAll() ERROR: Still can't find linkMovie with the linkMovieID. Project loading has failed. linkMovieID:")(linkMovieID).newline; 
     312                    Stdout("Material.updateAll() ERROR: Still can't find linkMovie with the linkMovieId. Project loading has failed. linkMovieId:")(linkMovieId).newline; 
    313313                } 
    314314                else 
     
    578578    { 
    579579        if( set !is null ) 
    580             linkMovieID = set.id(); 
     580            linkMovieId = set.id(); 
    581581        return m_linkMovie = set; 
    582582    } 
    583583    public Movie linkMovie() { return m_linkMovie; } 
    584584    protected Movie m_linkMovie; 
    585     public char[] linkMovieID
     585    public char[] linkMovieId
    586586     
    587587    //This might be a good idea to keep a list of Edits that use this Material: 
  • trunk/pihlaja/src/pihlaja/core/project.d

    r20 r21  
    647647    } 
    648648     
    649     Movie getMovieByID( char[] find_id ) 
    650     { 
    651         debug(Project) Stdout("Project.getMovieByID(char[] find_id) START.").newline; 
    652         debug(Project) scope(exit) Stdout("Project.getMovieByID(char[] find_id) END.").newline; 
     649    Movie getMovieById( char[] find_id ) 
     650    { 
     651        debug(Project) Stdout("Project.getMovieById(char[] find_id) START.").newline; 
     652        debug(Project) scope(exit) Stdout("Project.getMovieById(char[] find_id) END.").newline; 
    653653         
    654654        Movie res; 
     
    660660        if( res !is null ) 
    661661        { 
    662             debug(Project) Stdout("Project.getMovieByID(char[] find_id) Movie ")( res.name )(" found with id: ")( find_id ).newline; 
     662            debug(Project) Stdout("Project.getMovieById(char[] find_id) Movie ")( res.name )(" found with id: ")( find_id ).newline; 
    663663            return res; 
    664664        } 
    665665        else 
    666666        { 
    667             debug(Project) Stdout("Project.getMovieByID(char[] find_id) No Movie found with id: ")(find_id).newline; 
     667            debug(Project) Stdout("Project.getMovieById(char[] find_id) No Movie found with id: ")(find_id).newline; 
    668668        } 
    669669        return null; 
    670670    } 
    671671     
    672     Movie selectedMovieID( char[] find_id ) 
    673     { 
    674         debug(Project) Stdout("Project.selectedMovieID(char[] find_id) START.").newline; 
    675         debug(Project) scope(exit) Stdout("Project.selectedMovieID(char[] find_id) END.").newline; 
    676          
    677         Movie res = getMovieByID( find_id ); 
     672    Movie selectedMovieId( char[] find_id ) 
     673    { 
     674        debug(Project) Stdout("Project.selectedMovieId(char[] find_id) START.").newline; 
     675        debug(Project) scope(exit) Stdout("Project.selectedMovieId(char[] find_id) END.").newline; 
     676         
     677        Movie res = getMovieById( find_id ); 
    678678         
    679679        if( res !is null ) 
    680680        { 
    681             debug(Project) Stdout("Project.selectedMovieID(char[] find_id) Movie ")( res.name )(" found with id: ")( find_id ).newline; 
     681            debug(Project) Stdout("Project.selectedMovieId(char[] find_id) Movie ")( res.name )(" found with id: ")( find_id ).newline; 
    682682            selectedMovie( res ); 
    683683        } 
    684684        else 
    685685        { 
    686             debug(Project) Stdout("Project.selectedMovieID(char[] find_id) No Movie found with id: ")(find_id).newline; 
     686            debug(Project) Stdout("Project.selectedMovieId(char[] find_id) No Movie found with id: ")(find_id).newline; 
    687687        } 
    688688        return res; 
     
    13441344                xw.addAttribute( "projectDir", projectDir ); 
    13451345                xw.addAttribute( "lastVersionFilename", lastVersionFilename ); 
    1346                 xw.addAttribute( "selectedMovieID", sel_mov_id ); 
     1346                xw.addAttribute( "selectedMovieId", sel_mov_id ); 
    13471347                 
    13481348                foreach( Material mat; material ) 
     
    16041604    } 
    16051605     
    1606     Material getMaterialByID( char[] find_id ) 
     1606    Material getMaterialById( char[] find_id ) 
    16071607    { 
    16081608        debug(Project) Stdout("Project.getMaterialById(char[] find_id) START.").newline; 
     
    17071707    //It is incremented everytime saving occurs. 
    17081708     
    1709     public Movie currentlyDraggedMovieID( char[] find_id ) 
    1710     { 
    1711         return m_currentlyDraggedMovie = getMovieByID( find_id ); 
     1709    public Movie currentlyDraggedMovieId( char[] find_id ) 
     1710    { 
     1711        return m_currentlyDraggedMovie = getMovieById( find_id ); 
    17121712         
    17131713        /* 
     
    17161716        if( res !is null ) 
    17171717        { 
    1718             //debug(Project) Stdout("Project.selectedMovieID(char[] find_id) Movie ")( res.name )(" found with id: ")( find_id ).newline; 
     1718            //debug(Project) Stdout("Project.selectedMovieId(char[] find_id) Movie ")( res.name )(" found with id: ")( find_id ).newline; 
    17191719            m_currentlyDraggedMovie = res; 
    17201720        } 
    17211721        else 
    17221722        { 
    1723             //debug(Project) Stdout("Project.selectedMovieID(char[] find_id) No Movie found with id: ")(find_id).newline; 
     1723            //debug(Project) Stdout("Project.selectedMovieId(char[] find_id) No Movie found with id: ")(find_id).newline; 
    17241724        }*/ 
    17251725    } 
  • trunk/pihlaja/src/pihlaja/core/scene.d

    r18 r21  
    15381538        sceneChain.append( this ); 
    15391539         
    1540         mainColour.set( 0.2, 0.5, 0.2, 1.0 ); 
     1540        mainColour.set( 0.2, 0.5, 0.2, 0.8 ); 
     1541        //This transparency of the StartScene is a quick hack to show 
     1542        //the underlying half circle of the node link. 
    15411543        applyMainColour(); 
    15421544         
     
    50585060    SceneRuler ruler; 
    50595061 
    5060     EditContainer!(Edit) edit; 
     5062    public EditContainer!(Edit) edit; 
    50615063    LinkSeq!(Edit) selectedEdits;//TODO: this should be changed into some kind of a Hash thing. 
    50625064    public TrackContainer!(Track) track;//This is duplicating the data found from "this".RTree 
  • trunk/pihlaja/src/pihlaja/ui/materialstreeview.d

    r18 r21  
    151151        debug(Discoverer) Stdout("drag name: ")( col_name.getString() )(" id: ")( col_id.getString() ).newline; 
    152152         
    153         Movie drmov = project.currentlyDraggedMovieID( col_id.getString() ); 
     153        Movie drmov = project.currentlyDraggedMovieId( col_id.getString() ); 
    154154         
    155155        if( drmov.movieType == MovieType.NORMAL ) 
     
    187187                debug(Discoverer) Stdout("tree name: ")( col_name.getString() )(" id: ")( col_id.getString() ).newline; 
    188188                 
    189                 Movie mov = project.getMovieByID( col_id.getString() ); 
     189                Movie mov = project.getMovieById( col_id.getString() ); 
    190190                 
    191191                m_treeStore.setValue( iter, MaterialColumnType.DURATION, g_toTimecode( mov.duration() ) ); 
     
    221221        debug(Discoverer) Stdout("activated name: ")( col_name.getString() )(" id: ")( col_id.getString() ).newline; 
    222222         
    223         project.selectedMovieID( col_id.getString() ); 
     223        project.selectedMovieId( col_id.getString() ); 
    224224    } 
    225225     
     
    368368        ++col; 
    369369         
    370         column = new TreeViewColumn("ID", new CellRendererText(), "text", col); 
     370        column = new TreeViewColumn("Id", new CellRendererText(), "text", col); 
    371371        treeView.appendColumn(column); 
    372372        column.setResizable(true); 
  • trunk/pihlaja/src/pihlaja/ui/projectwindow.d

    r20 r21  
    828828             
    829829            //Project 
    830             char[] l_selectedMovieID = ""; 
     830            char[] l_selectedMovieId = ""; 
    831831             
    832832            //Material: 
     
    836836            char[] l_materialType = ""; 
    837837            char[] l_filename = ""; 
    838             char[] l_linkMovieID = ""; 
     838            char[] l_linkMovieId = ""; 
    839839            char[] l_mediaStart = ""; 
    840840            char[] l_mediaDuration = ""; 
     
    876876            //char[] l_mediaStart = ""; 
    877877            //char[] l_mediaDuration = ""; 
    878             char[] l_materialID = ""; 
    879              
     878            char[] l_materialId = "@none"; 
     879            char[] l_editGroupId = "@none"; 
     880                         
    880881            this( Project set_project ) 
    881882            { 
     
    918919                            l_currentMaterial.id = l_id; 
    919920                            l_currentMaterial.loadedName = l_name; 
    920                             l_currentMaterial.linkMovieID = l_linkMovieID
     921                            l_currentMaterial.linkMovieId = l_linkMovieId
    921922                            l_currentMaterial.mediaDuration = Float.toFloat!(T)(l_mediaDuration); 
    922923                            l_project.addMaterial(l_currentMaterial); 
     
    944945                        foreach( mat; material ) 
    945946                        { 
    946                             if( mat.linkMovieID == l_id ) 
     947                            if( mat.linkMovieId == l_id ) 
    947948                            { 
    948949                                if( mat.trackType == TrackType.VIDEO ) 
     
    10921093                        if( l_currentScene !is null ) 
    10931094                        { 
    1094                             Material ed_mat = l_project.getMaterialByID( l_materialID ); 
     1095                            Material ed_mat = l_project.getMaterialById( l_materialId ); 
    10951096                            l_currentEdit = new Edit( l_currentScene, ed_mat, Float.toFloat!(T)(l_start), Float.toFloat!(T)(l_duration) ); 
    1096                             //currentEdit.loadedMaterialID = materialID
     1097                            //currentEdit.loadedMaterialId = materialId
    10971098                            l_currentScene.addEdit( l_currentEdit, l_currentTrack ); 
     1099                            l_currentEdit.addToEditGroupById( l_editGroupId ); 
    10981100                            l_element = ""; 
    10991101                        } 
     
    11031105                        } 
    11041106                    break; 
    1105                  
     1107                    /*case "EditGroup": 
     1108                        debug(loading) Stdout("Creating a new EditGroup.").newline; 
     1109                        if( l_currentScene !is null ) 
     1110                        { 
     1111                             
     1112                        } 
     1113                    break;*/ 
    11061114                 
    11071115                }//end switch set_name 
     
    11241132                    default: break; 
    11251133                    //Project 
    1126                     case "selectedMovieID": 
    1127                         l_selectedMovieID = value; 
     1134                    case "selectedMovieId": 
     1135                    case "selectedMovieID"://deprecated 
     1136                        l_selectedMovieId = value; 
    11281137                    break; 
    11291138                    //Material 
     
    11371146                        l_filename = value; 
    11381147                    break; 
    1139                     case "linkMovieID": 
    1140                         l_linkMovieID = value; 
     1148                    case "linkMovieId": 
     1149                    case "linkMovieID"://deprecated 
     1150                        l_linkMovieId = value; 
    11411151                    break; 
    11421152                    case "mediaStart": 
     
    12051215                    break; 
    12061216                    //Edit 
     1217                     
    12071218                    case "start": 
    12081219                        l_start = value; 
     
    12111222                        l_duration = value; 
    12121223                    break; 
    1213                     case "materialID": 
    1214                         l_materialID = value; 
    1215                     break; 
     1224                    case "materialId": 
     1225                    case "materialID"://deprecated 
     1226                        l_materialId = value; 
     1227                    break; 
     1228                    case "editGroupId": 
     1229                        l_editGroupId = value; 
     1230                    break; 
     1231                         
    12161232                } 
    12171233            } 
     
    12281244                    break; 
    12291245                    //case "Movie": 
    1230                     //  l_project.selectedMovieID( l_id ); 
     1246                    //  l_project.selectedMovieId( l_id ); 
    12311247                        //l_selectedMovie 
    12321248                    //break; 
    12331249                    case "Project": 
    1234                         Movie sel_mov = l_project.selectedMovieID( l_selectedMovieID ); 
     1250                        Movie sel_mov = l_project.selectedMovieId( l_selectedMovieId ); 
    12351251                        version(Removed) sel_mov.selectStartScene(); 
    12361252                         
     
    14691485    { 
    14701486        //showFileChooser(); 
    1471         save(); 
     1487        //save(); 
    14721488        //onMenuActivate(menuItem); 
     1489         
     1490        if( save() == true ) 
     1491            statusbar( "Saving complete. Saved version " ~ Integer.toUtf8( currentVersion ) ); 
     1492        else statusbar( "Saving FAILED for some reason. Current version " ~ Integer.toUtf8( currentVersion ) ); 
    14731493    } 
    14741494     
     
    14761496    { 
    14771497        //showFileChooser(); 
    1478         save(); 
     1498        //save(); 
    14791499        //onMenuActivate(menuItem); 
     1500         
     1501        if( save() == true ) 
     1502            statusbar( "Saving complete. Saved version " ~ Integer.toUtf8( currentVersion ) ); 
     1503        else statusbar( "Saving FAILED for some reason. Current version " ~ Integer.toUtf8( currentVersion ) ); 
    14801504    } 
    14811505