Changeset 1307

Show
Ignore:
Timestamp:
11/09/07 18:54:51 (11 months ago)
Author:
calvin
Message:

zonajs patch: recent files in file menu.
added basic drag+drop+save gear/index.txt in "all machines"-view (disabled by default), added property for wave level sample rate

Location:
trunk/src/buzelib
Files:
20 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/buzelib/BuzeConfiguration.cpp

    r1304 r1307  
    186186} 
    187187 
     188std::string CConfiguration::getRecentSong(int index) { 
     189        string recent; 
     190 
     191        if (!getConfigString("Settings", "RecentSong" + stringFromInt(index), &recent)) 
     192                return ""; 
     193        return recent; 
     194} 
     195 
     196void CConfiguration::insertRecentSong(std::string fileName) { 
     197        std::vector<std::string> recs; 
     198        std::string str; 
     199        int i; 
     200 
     201        for (i = 0; i < getMaxRecentSongs(); ++i) { 
     202                str.clear(); 
     203                getConfigString("Settings", "RecentSong" + stringFromInt(i), &(str)); 
     204                if (str == fileName) { 
     205                        if(!i) 
     206                                return; 
     207                        continue; 
     208                } 
     209                if (str.size()) 
     210                        recs.push_back(str); 
     211        } 
     212 
     213        recs.insert(recs.begin(), fileName); 
     214 
     215        // resave all recent songs 
     216 
     217        for(i = 0; i < getMaxRecentSongs() && i < recs.size(); ++i) { 
     218                setConfigString("Settings", "RecentSong" + stringFromInt(i), recs[i]); 
     219        } 
     220} 
     221 
     222int CConfiguration::getMaxRecentSongs() { 
     223        DWORD dw = 10; 
     224        getConfigNumber("Settings", "MaxRecentSongs", &dw); 
     225        if(dw > 100) 
     226                dw = 100; 
     227        return dw; 
     228} 
     229 
     230void CConfiguration::setMaxRecentSongs(int max) { 
     231        setConfigNumber("Settings", "MaxRecentSongs", max); 
     232} 
     233 
    188234std::string CConfiguration::getExternalWaveEditor() { 
    189235        string cmd; 
  • trunk/src/buzelib/BuzeConfiguration.h

    r1304 r1307  
    2828        std::string getTheme(); 
    2929        void setTheme(std::string theme); 
     30 
     31        std::string getRecentSong(int index); 
     32        void insertRecentSong(std::string fileName); 
     33        int getMaxRecentSongs(); 
     34        void setMaxRecentSongs(int max); 
    3035 
    3136        void setMachineParameterVisibility(std::string uri, int parameterIndex, bool state); 
  • trunk/src/buzelib/Document.cpp

    r1297 r1307  
    10211021} 
    10221022 
     1023void CDocument::setWaveLevelSampleRate(zzub::wave_level* entry, int rate) { 
     1024        entry->samples_per_second = rate; 
     1025        updateAllViews(0, UpdateSelectedWaveEntry, entry); 
     1026 
     1027} 
     1028 
     1029int CDocument::getWaveLevelSampleRate(zzub::wave_level* entry) { 
     1030        return entry->samples_per_second; 
     1031} 
     1032 
    10231033 
    10241034 
  • trunk/src/buzelib/Document.h

    r1293 r1307  
    243243        void setWaveLevelType(zzub::wave_level* entry, int bits); 
    244244        int getWaveLevelType(zzub::wave_level* entry); 
     245        void setWaveLevelSampleRate(zzub::wave_level* entry, int rate); 
     246        int getWaveLevelSampleRate(zzub::wave_level* entry); 
    245247 
    246248        // machine loading properties 
  • trunk/src/buzelib/MachineDropTarget.cpp

    r1273 r1307  
    2626CDropTarget::CDropTarget(CDropTargetWindow* dtw):CIDropTarget(dtw->hWndTarget) { 
    2727        dropTargetWindow = dtw; 
     28} 
     29 
     30bool CDropTarget::OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) { 
     31        return dropTargetWindow->OnDragOver(pt, pFmtEtc, medium, pdwEffect); 
     32} 
     33 
     34void CDropTarget::OnDragLeave() { 
     35        dropTargetWindow->OnDragLeave(); 
    2836} 
    2937 
  • trunk/src/buzelib/MachineDropTarget.h

    r1218 r1307  
    66 
    77    virtual bool OnDrop(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) = 0; 
     8        virtual bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) = 0; 
     9        virtual void OnDragLeave() = 0; 
    810}; 
    911 
     
    1315        CDropTarget(CDropTargetWindow* dtw); 
    1416        virtual bool OnDrop(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect); 
    15  
     17        virtual bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect); 
     18        virtual void OnDragLeave(); 
    1619}; 
    1720 
  • trunk/src/buzelib/MachineFolderView.cpp

    r1273 r1307  
    3939} 
    4040 
     41HTREEITEM g_hCurrentDragItem = 0; 
     42extern MachineMenu* g_effectMenu; 
     43extern MachineMenu* g_generatorMenu; 
     44 
    4145LRESULT MachineFolderView::OnBeginDrag(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) { 
    4246 
    4347        NMTREEVIEW* pnmtv = (NMTREEVIEW*)pnmh; 
    4448 
    45         const char* machineFileName = (const char*)treeCtrl.GetItemData(pnmtv->itemNew.hItem); 
     49        g_hCurrentDragItem = pnmtv->itemNew.hItem; 
     50        const char* machineFileName = (const char*)treeCtrl.GetItemData(g_hCurrentDragItem); 
    4651        if (machineFileName == 0) return 0; 
    4752 
     
    7984} 
    8085 
    81 void MachineFolderView::bindMachineItems(MachineMenu* item, HTREEITEM parent) { 
     86int MachineFolderView::bindMachineItems(MachineMenu* item, HTREEITEM parent) { 
     87 
     88        DWORD dwEnabled = 0; 
     89        mainFrame->document->configuration->getConfigNumber("Settings", "IndexEditing", &dwEnabled); 
     90 
     91        int machineCounter = 0; 
    8292 
    8393        for (size_t i = 0; i < item->items.size(); i++) { 
     
    113123                    strcat(fileName, mi->instrumentName.c_str()); 
    114124                } 
     125                                machineCounter++; 
    115126                        } 
    116127 
     
    118129                        treeCtrl.SetItemData(treeItem, (DWORD)fileName); 
    119130 
    120                         if (ii->type == 0) 
    121                                 bindMachineItems((MachineMenu*)ii, treeItem); 
    122                 } 
    123         } 
     131                        ii->userData = treeItem; 
     132 
     133                        if (ii->type == 0) { 
     134                                int bindCount = bindMachineItems((MachineMenu*)ii, treeItem); 
     135                                // keep even machine menus because we might want to drop something into them 
     136 
     137                                if (!bindCount && dwEnabled!=0) { 
     138                                        HTREEITEM placeholder = treeCtrl.InsertItem( "(drop on me)", treeItem, TVI_LAST); 
     139                                        treeCtrl.SetItemData(treeItem, (DWORD)0); 
     140                                } 
     141                                machineCounter += bindCount; 
     142                        } 
     143                } 
     144        } 
     145        return machineCounter; 
    124146} 
    125147 
     
    154176LRESULT MachineFolderView::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 
    155177        using namespace std; 
    156         treeCtrl.Create(this->m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS|TVS_HASBUTTONS, WS_EX_CLIENTEDGE, IDC_MACHINETREE); 
     178        treeCtrl.Create(this->m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_HASBUTTONS | TVS_TRACKSELECT, WS_EX_CLIENTEDGE, IDC_MACHINETREE); 
    157179 
    158180        CImageList il; 
     
    163185        CreateThread(0, 0, PopulateMachinesThread, this, 0, &dwId); 
    164186 
    165         /* 
    166     bindMachineItems(&mainFrame->document->machineIndex.root, hMachines);        
    167  
    168         treeCtrl.Expand(hMachines); 
    169  
    170         for (int i = 0; i<player->getMachineLoaders(); i++) { 
    171                 pluginloader* loader = player->getMachineLoader(i); 
    172                 HTREEITEM hmachineItem; 
    173                 if (loader->getType() == plugin_type_effect) 
    174                         hmachineItem = treeCtrl.InsertItem( loader->getName(), hEffectItem, TVI_LAST); else 
    175                         hmachineItem = treeCtrl.InsertItem( loader->getName(), hGeneratorItem, TVI_LAST);  
    176                 treeCtrl.SetItemData(hmachineItem, (DWORD)loader->getUri()); 
    177         }*/ 
    178  
    179     /* 
    180     if (!createDropTarget(*this)) return 0; 
     187        if (!createDropTarget(*this)) return 0; 
    181188        FORMATETC ftetc = {0};  
    182189        ftetc.cfFormat = CF_TEXT;  
     
    187194        ftetc.cfFormat=CF_HDROP;  
    188195        dropTarget->AddSuportedFormat(ftetc); 
    189 */ 
     196 
    190197        return 0; 
    191198} 
     
    220227 
    221228LRESULT MachineFolderView::OnViewProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 
    222     return 0; 
     229        return 0; 
    223230} 
    224231 
    225232LRESULT MachineFolderView::OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { 
    226     /* 
    227     not called while dragging - update CIDropTarget 
    228  
    229     POINT pt = { LOWORD(lParam), HIWORD(lParam) }; 
    230     UINT flags; 
     233        return 0; 
     234} 
     235 
     236LRESULT MachineFolderView::OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 
     237        return 0; 
     238} 
     239 
     240 
     241// copyitem / copybranch by Zafir Anjum 
     242// http://www.codeguru.com/cpp/controls/treeview/dragdrop/article.php/c695/ 
     243 
     244HTREEITEM CopyItem(CTreeViewCtrl& treeView, HTREEITEM hItem, HTREEITEM htiNewParent, HTREEITEM htiAfter = TVI_LAST) { 
     245        TV_INSERTSTRUCT tvstruct; 
     246        HTREEITEM hNewItem; 
     247 
     248        // get information of the source item 
     249        tvstruct.item.hItem = hItem; 
     250        tvstruct.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; 
     251        treeView.GetItem(&tvstruct.item);   
     252        char itemText[1024]; 
     253        treeView.GetItemText( hItem, itemText, 1024 ); 
     254 
     255        tvstruct.item.cchTextMax = strlen(itemText); 
     256        tvstruct.item.pszText = itemText; 
     257 
     258        // Insert the item at proper location 
     259        tvstruct.hParent = htiNewParent; 
     260        tvstruct.hInsertAfter = htiAfter; 
     261        tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; 
     262        hNewItem = treeView.InsertItem(&tvstruct); 
     263 
     264        // Now copy item data and item state. 
     265        treeView.SetItemData( hNewItem, treeView.GetItemData( hItem )); 
     266        treeView.SetItemState( hNewItem, treeView.GetItemState( hItem, TVIS_STATEIMAGEMASK ), TVIS_STATEIMAGEMASK ); 
     267 
     268        return hNewItem; 
     269} 
     270 
     271HTREEITEM CopyBranch(CTreeViewCtrl& treeView, HTREEITEM htiBranch, HTREEITEM htiNewParent, HTREEITEM htiAfter = TVI_LAST) { 
     272        HTREEITEM hChild; 
     273 
     274        HTREEITEM hNewItem = CopyItem(treeView, htiBranch, htiNewParent, htiAfter); 
     275        hChild = treeView.GetChildItem(htiBranch); 
     276        while (hChild != NULL) { 
     277        // recursively transfer all the items 
     278        CopyBranch(treeView, hChild, hNewItem);   
     279        hChild = treeView.GetNextSiblingItem( hChild ); 
     280        } 
     281        return hNewItem; 
     282} 
     283 
     284CMenuHandle FindMenuItem(CMenuHandle menuItem, std::string text, int& pos) { 
     285        char menuText[1024]; 
     286 
     287        pos = -1; 
     288        for (UINT i = 0; i < menuItem.GetMenuItemCount(); i++) { 
     289                menuItem.GetMenuString(i, menuText, 1024, MF_BYPOSITION); 
     290                if (text == menuText) { 
     291                        pos = i; 
     292                        return menuItem; 
     293                } 
     294                CMenuHandle submenu = menuItem.GetSubMenu(i); 
     295                if (submenu.m_hMenu == 0) continue; 
     296 
     297                submenu = FindMenuItem(submenu, text, pos); 
     298                if (submenu.m_hMenu != 0) return submenu; 
     299 
     300        } 
     301        return CMenuHandle(); 
     302} 
     303 
     304void* GetMenuItemData(CMenuHandle menu, int pos) { 
     305        MENUITEMINFO mii; 
     306        memset(&mii, 0, sizeof(MENUITEMINFO)); 
     307        mii.cbSize = sizeof(MENUITEMINFO); 
     308        mii.fMask = MIIM_DATA; 
     309        menu.GetMenuItemInfo(pos, TRUE, &mii); 
     310        return (void*)mii.dwItemData; 
     311} 
     312 
     313CMenuHandle FindMenuItemByData(CMenuHandle menuItem, void* data, int& pos) { 
     314        char menuText[1024]; 
     315 
     316        pos = -1; 
     317        for (UINT i = 0; i < menuItem.GetMenuItemCount(); i++) { 
     318                void* itemData = GetMenuItemData(menuItem, i); 
     319                if (itemData == data) { 
     320                        pos = i; 
     321                        return menuItem; 
     322                } 
     323                CMenuHandle submenu = menuItem.GetSubMenu(i); 
     324                if (submenu.m_hMenu == 0) continue; 
     325 
     326                submenu = FindMenuItemByData(submenu, data, pos); 
     327                if (submenu.m_hMenu != 0) return submenu; 
     328 
     329        } 
     330        return CMenuHandle(); 
     331} 
     332 
     333int CountTreeItems(CTreeViewCtrl& tree, HTREEITEM hItem = NULL, BOOL recurse = TRUE) { 
     334        int count = 0; 
     335        if (hItem == NULL) 
     336                hItem = tree.GetSelectedItem(); 
     337 
     338        if (tree.ItemHasChildren(hItem)) { 
     339                hItem = tree.GetNextItem(hItem, TVGN_CHILD); 
     340                while (hItem) { 
     341                        count++; 
     342                        if (recurse) 
     343                                count += CountTreeItems(tree, hItem, recurse); 
     344                        hItem = tree.GetNextItem(hItem, TVGN_NEXT); 
     345                } 
     346        } 
     347        return count; 
     348} 
     349 
     350#include "Utils/MachineIndex.h" 
     351 
     352extern void InsertMenuItemFromIndexItem(IndexItem* ii, CMenuHandle parentMenu, int pos); 
     353 
     354bool MachineFolderView::OnDropMachine(std::string machineName, std::string instrumentName, int x, int y) { 
     355        treeCtrl.RemoveInsertMark(); 
     356 
     357        DWORD dwEnabled = 0; 
     358        mainFrame->document->configuration->getConfigNumber("Settings", "IndexEditing", &dwEnabled); 
     359        if (!dwEnabled) return true; 
     360 
     361        POINT pt = { x, y }; 
     362        UINT flags; 
     363        HTREEITEM dropItem = treeCtrl.HitTest(pt, &flags); 
     364        if (dropItem == 0) return true; 
     365 
     366        // TODO: if dropped item is an expandable thing and its expanded, we want to add the dragItem as the first child here 
     367 
     368        IndexItem* dropIndex = mainFrame->document->machineIndex.root.getItemByData(dropItem); 
     369        IndexItem* dragIndex = mainFrame->document->machineIndex.root.getItemByData(g_hCurrentDragItem); 
     370 
     371        if (dropIndex == dragIndex) return true; 
     372 
     373        // are we dropping in a machine list? 
     374        if (dropIndex && dropIndex->type == 0) { 
     375                MachineMenu* mm = (MachineMenu*)dropIndex; 
     376                // are we dropping on a preloaded machine? 
     377                if (mm->preloadReplaced != 0) return true; 
     378        } else 
     379        if (dropIndex && dropIndex->type == 1) { 
     380                if (dropIndex->parent->type == 0) { 
     381                        MachineMenu* mm = (MachineMenu*)dropIndex->parent; 
     382                        // are we dropping inside a preloaded machine? 
     383                        if (mm->preloadReplaced != 0) return true; 
     384                } 
     385        } 
     386 
     387        HTREEITEM dropParent = treeCtrl.GetParentItem(dropItem); 
     388        HTREEITEM dragParent = treeCtrl.GetParentItem(g_hCurrentDragItem); 
     389 
     390        char dragItemText[1024]; 
     391        treeCtrl.GetItemText(g_hCurrentDragItem, dragItemText, 1024); 
     392        char dropItemText[1024]; 
     393        treeCtrl.GetItemText(dropItem, dropItemText, 1024); 
     394 
     395        treeCtrl.SetRedraw(FALSE); 
     396 
     397        HTREEITEM dragCopy = CopyBranch(treeCtrl, g_hCurrentDragItem, dropParent, dropItem); 
     398        if (dragIndex != 0) { 
     399                treeCtrl.DeleteItem(g_hCurrentDragItem); 
     400                int dragFromSiblings = CountTreeItems(treeCtrl, dragParent); 
     401                if (dragFromSiblings == 0) { 
     402                        HTREEITEM placeholder = treeCtrl.InsertItem("(drop on me)", dragParent, TVI_LAST); 
     403                        treeCtrl.SetItemData(dragParent, (DWORD)0); 
     404                } 
     405        } 
     406 
     407        bool created = false; 
     408        if (dragIndex == 0) { 
     409                // we dragged an item from out-of-index into the index, so we create a new item for it 
     410                zzub::pluginloader* loader = mainFrame->player->getMachineLoader(machineName); 
     411 
     412                MachineItem* mi = new MachineItem(); 
     413                mi->label = loader->plugin_info->name; 
     414                mi->fileName = loader->plugin_info->name; 
     415                mi->fullMachineName = machineName; 
     416                mi->instrumentName = instrumentName; 
     417                dragIndex = mi; 
     418 
     419                created = true; 
     420        } 
     421        dragIndex->userData = dragCopy; 
     422 
     423        if (!created) dragIndex->parent->removeItem(dragIndex); 
     424        if (dropIndex != 0) { 
     425                dropIndex->parent->insertAfter(dragIndex, dropIndex); 
     426        } else { 
     427                // need to find parent of where we are dropping, in case it is a drop target 
     428                if ((std::string)dropItemText == "(drop on me)") { 
     429                        treeCtrl.DeleteItem(dropItem); 
     430                } 
     431                IndexItem* parentIndex = mainFrame->document->machineIndex.root.getItemByData(dropParent); 
     432                if (parentIndex == 0) return true; 
     433                parentIndex->append(dragIndex); 
     434        } 
     435 
     436        treeCtrl.SetRedraw(TRUE); 
     437 
     438        IndexItem* generatorParent = g_generatorMenu->parent; 
     439        IndexItem* effectParent = g_effectMenu->parent; 
     440 
     441        // temporarily remove the Unsorted Generators and Unsorted Effects 
     442        generatorParent->removeItem(g_generatorMenu); 
     443        effectParent->removeItem(g_effectMenu); 
     444 
     445        // we could also revert the PlaceGeneratorHere-thing but its not needed 
     446        mainFrame->document->machineIndex.save(_Module.mapPath("Gear/index.txt").c_str()); 
     447 
     448        generatorParent->append(g_generatorMenu); 
     449        effectParent->append(g_effectMenu); 
     450 
     451        g_hCurrentDragItem = 0; 
     452 
     453        // rebuild right-click menu in machine view because we are now out of sync 
     454 
     455        int machines = 0; 
     456        if (mainFrame->createMachineMenu.IsMenu()) mainFrame->createMachineMenu.DestroyMenu(); 
     457        mainFrame->createMachineMenu.CreatePopupMenu(); 
     458        mainFrame->insertMachineMenu(mainFrame->createMachineMenu.m_hMenu, mainFrame->document->machineIndex.root, machines); 
     459 
     460        return true; 
     461} 
     462 
     463bool MachineFolderView::OnDragOver(const POINTL& ptl, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) { 
     464        POINT pt = { ptl.x, ptl.y }; 
     465        treeCtrl.ScreenToClient(&pt); 
     466        UINT flags; 
    231467        HTREEITEM item = treeCtrl.HitTest(pt, &flags); 
    232     if (item != 0) { 
    233         treeCtrl.SetInsertMark(item, TRUE);//TVM_SETINSERTMARK  
    234     }*/ 
    235     return 0; 
    236 } 
    237  
    238 LRESULT MachineFolderView::OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 
    239     return 0; 
    240 } 
    241  
    242  
    243 bool MachineFolderView::OnDropMachine(std::string machineName, std::string instrumentName, int x, int y) { 
    244  
    245     return true; 
    246 } 
     468        if (item == 0) return true; 
     469                 
     470        treeCtrl.SetInsertMark(item, TRUE); 
     471 
     472        return true; 
     473} 
     474 
     475void MachineFolderView::OnDragLeave() { 
     476        treeCtrl.RemoveInsertMark(); 
     477} 
  • trunk/src/buzelib/MachineFolderView.h

    r1273 r1307  
    5454        MachineFolderView(CMainFrame* mainFrm, ClientViewListener* clientViewListener); 
    5555        ~MachineFolderView(void); 
    56         void bindMachineItems(MachineMenu* item, HTREEITEM parent); 
     56        int bindMachineItems(MachineMenu* item, HTREEITEM parent); 
    5757 
    5858        void loadFromIndex(); 
     
    7070        LRESULT OnViewProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 
    7171    bool OnDropMachine(std::string machineName, std::string instrumentName, int x, int y); 
     72        bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect); 
     73        void OnDragLeave(); 
    7274 
    7375public: 
  • trunk/src/buzelib/MachineView.cpp

    r1304 r1307  
    16901690} 
    16911691 
     1692bool CMachineView::OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) {  
     1693        // TODO: maybe check if we are over a connection, a group machine or something 
     1694        return true;  
     1695} 
     1696 
     1697void CMachineView::OnDragLeave() {  
     1698} 
     1699 
    16921700bool CMachineView::OnDropMachine(std::string machineName, std::string instrumentName, int x, int y) { 
    16931701 
  • trunk/src/buzelib/MachineView.h

    r1302 r1307  
    147147        void OnUpdate(CView* pSender, LPARAM lHint, LPVOID pHint); 
    148148 
     149        bool OnDragOver(const POINTL& pt, FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect); 
     150        void OnDragLeave(); 
    149151        bool OnDropMachine(std::string machineName, std::string instrumentName, int x, int y); 
    150152 
  • trunk/src/buzelib/MainFrm.cpp

    r1304 r1307  
    13501350 
    13511351        initializeThemes(); 
     1352        initializeRecent(); 
    13521353 
    13531354        if (!deserializeFromFile(_Module.mapPath("Gear/gui.xml"))) { 
     
    15471548                document->setCurrentFile(fileName); 
    15481549                setWindowTitle(document->currentFileName); 
     1550                setMostRecent(fileName); 
    15491551        } 
    15501552        //player->getMaster()->releaseEvent(progressEventID); 
     
    21362138} 
    21372139 
     2140void SetMenuItemData(CMenuHandle menu, int pos, void* data) { 
     2141        MENUITEMINFO mii; 
     2142        memset(&mii, 0, sizeof(MENUITEMINFO)); 
     2143        mii.cbSize = sizeof(MENUITEMINFO); 
     2144        mii.fMask = MIIM_DATA; 
     2145        mii.dwItemData = (DWORD)data; 
     2146        menu.SetMenuItemInfo(pos, TRUE, &mii); 
     2147} 
     2148 
    21382149 
    21392150int CMainFrame::insertMachineMenu(CMenuHandle parentMenu, MachineMenu& parentMachineMenu, int& index) { 
    21402151 
    2141         int visibleCounter=0; 
    2142         int maxEntriesPerPage=40; 
    2143  
    2144         bool prevWasSep=false; 
     2152        int visibleCounter = 0; 
     2153        int maxEntriesPerPage; 
    21452154 
    21462155        CWindow desktop(GetDesktopWindow()); 
     
    21482157        RECT rcClient; 
    21492158        desktop.GetClientRect(&rcClient); 
    2150         maxEntriesPerPage=(rcClient.bottom-100)/16; 
    2151  
    2152         for (size_t i=0; i<parentMachineMenu.items.size(); i++) { 
     2159        maxEntriesPerPage = (rcClient.bottom-100)/16; 
     2160 
     2161        for (size_t i = 0; i < parentMachineMenu.items.size(); i++) { 
    21532162 
    21542163                DWORD extraFlags = ((visibleCounter%maxEntriesPerPage)==(maxEntriesPerPage-1)?MF_MENUBARBREAK:0); 
    21552164 
    2156                 IndexItem* ii=parentMachineMenu.items[i]; 
    2157                 if (ii->hide==true) continue; 
    2158                 if (ii->type==0) { 
    2159                         MachineMenu& mmenu=*(MachineMenu*)ii; 
     2165                IndexItem* ii = parentMachineMenu.items[i]; 
     2166                if (ii->hide == true) continue; 
     2167                if (ii->type == 0) { 
     2168                        MachineMenu& mmenu = *(MachineMenu*)ii; 
    21602169 
    21612170                        CMenuHandle newMenu; 
    21622171                        newMenu.CreatePopupMenu(); 
    21632172 
    2164                         // TODO: only insert if there are any child nodes worth mentioning 
    2165                         if (!insertMachineMenu(newMenu.m_hMenu, mmenu, index)) continue; 
     2173                        // only insert if there are any child nodes worth mentioning 
     2174                        int insertedCount = insertMachineMenu(newMenu.m_hMenu, mmenu, index); 
     2175                        if (!insertedCount) continue; 
    21662176 
    21672177                        parentMenu.InsertMenu(-1, MF_BYPOSITION|MF_POPUP|extraFlags, (UINT_PTR)newMenu.m_hMenu, ii->label.c_str()); 
    2168                         visibleCounter++; 
    2169                         prevWasSep=false; 
     2178                        SetMenuItemData(parentMenu, parentMenu.GetMenuItemCount() - 1, ii); 
     2179                        visibleCounter +=