Changeset 1297
- Timestamp:
- 11/01/07 13:55:14 (10 months ago)
- Location:
- trunk/src/buzelib
- Files:
-
- 6 modified
-
Document.cpp (modified) (1 diff)
-
FileBrowserView.cpp (modified) (2 diffs)
-
MachineView.cpp (modified) (14 diffs)
-
MachineView.h (modified) (5 diffs)
-
MainFrm.cpp (modified) (1 diff)
-
WaveTableView.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/buzelib/Document.cpp
r1293 r1297 56 56 streamplayer->initialize(0, 0, 0, 0, 0); 57 57 player->master->addAudioInput(streamplayer, 0x4000, 0x4000); 58 streamplayer->nonSongPlugin = true; 58 59 } else { 59 60 streamplayer = 0; 60 } 61 62 if (!streamplayer) 63 printf("Cant can't create streamplayer plugin instance.\n"); else 64 streamplayer->nonSongPlugin = true; 61 printf("Cant can't create streamplayer plugin instance.\n"); 62 } 65 63 } 66 64 -
trunk/src/buzelib/FileBrowserView.cpp
r1293 r1297 204 204 if (selectedFiles.size() == 0) return 0; 205 205 206 if (!mainFrame->document->streamplayer) return 0; 207 206 208 CFileInfo* fileInfo = selectedFiles[0]; 207 209 if (mainFrame->document->isNotePlaying(mainFrame->document->streamplayer, note)) return 0; … … 233 235 if (note == -1) return 0; 234 236 237 if (!mainFrame->document->streamplayer) return 0; 235 238 mainFrame->document->playMachineNote(mainFrame->document->streamplayer, zzub::note_value_off, note); 236 239 return 0; -
trunk/src/buzelib/MachineView.cpp
r1281 r1297 16 16 #include <iomanip> 17 17 #include <strstream> 18 #include <limits> 18 19 #include "Utils/Keymaps.h" 19 20 … … 39 40 isConnecting = false; 40 41 isPanSlider = false; 41 redrawMode = MachineViewAll;42 42 mbuttonState = false; 43 43 isLButtonDown = false; … … 45 45 moveType = MachineViewMoveNothing; 46 46 SetRect(&prevDragRect, -1, -1, -1, -1); 47 48 dirtyOffscreenBitmap = true; 49 dirtyMachines = dirtySelectionRectangle = dirtyStatus = dirtyVolumeSlider = false; 47 50 } 48 51 … … 455 458 } 456 459 460 void minMaxRect(RECT* rcOut, RECT* rcIn) { 461 if (rcIn->left < rcOut->left) 462 rcOut->left = rcIn->left; 463 if (rcIn->top < rcOut->top) 464 rcOut->top = rcIn->top; 465 if (rcIn->right > rcOut->right) 466 rcOut->right = rcIn->right; 467 if (rcIn->bottom > rcOut->bottom) 468 rcOut->bottom = rcIn->bottom; 469 } 470 457 471 LRESULT CMachineView::OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { 458 472 459 //if (draggingMachine && isConnecting) {460 473 if (moveType==MachineViewMoveConnectMachines) { 461 474 if (((wParam&MK_SHIFT) != 0) || mbuttonState ) { … … 472 485 } else 473 486 if (moveType==MachineViewMovePanSlider) { 474 // if (draggingMachine && isPanSlider) {475 487 // adjust panning = calculate pan value 476 488 POINT pt={(signed short)LOWORD(lParam),(signed short)HIWORD(lParam)}; … … 495 507 } else 496 508 if (moveType==MachineViewMoveSelectedMachines) { 497 // if (draggingMachine) {498 509 POINT ppt={offX, offY}; 499 510 POINT pt={(signed short)LOWORD(lParam),(signed short)HIWORD(lParam)}; … … 507 518 if (fabs(mdx)==0 && fabs(mdy)==0) return 0; 508 519 509 // todo: her skal vi egentlig sette posisjon på alle valgte maskiner 510 // så, vi finner deltaet som denne maskinen flytter seg 520 RECT rcInvalidate = { 521 0x10000000, 0x10000000, 522 -0x10000000, -0x10000000, 523 }; 524 525 // move the selected machines, and find the smallest area on screen 526 // that needs to be repainted 511 527 for (int i=0; i<document->getSelectedMachines(); i++) { 512 document->getSelectedMachine(i)->x+=mdx; 513 document->getSelectedMachine(i)->y+=mdy; 514 } 515 invalidateMachines(); 516 offX=pt.x; 517 offY=pt.y; 528 RECT selrc; 529 zzub::metaplugin* selplugin = document->getSelectedMachine(i); 530 getMachineRect(selplugin, &selrc); 531 InflateRect(&selrc, 3, 3); 532 minMaxRect(&rcInvalidate, &selrc); 533 534 selplugin->x += mdx; 535 selplugin->y += mdy; 536 537 getMachineRect(selplugin, &selrc); 538 InflateRect(&selrc, 3, 3); 539 minMaxRect(&rcInvalidate, &selrc); 540 541 // make sure the invalidation rect covers all machines we are connected to 542 for (int j = 0; j < selplugin->inConnections.size(); j++) { 543 metaplugin* selconnplugin = selplugin->inConnections[j]->plugin_in; 544 if (selconnplugin->nonSongPlugin) continue; 545 546 getMachineRect(selconnplugin, &selrc); 547 InflateRect(&selrc, 3, 3); 548 minMaxRect(&rcInvalidate, &selrc); 549 } 550 551 for (int j = 0; j < selplugin->outConnections.size(); j++) { 552 metaplugin* selconnplugin = selplugin->outConnections[j]->plugin_out; 553 if (selconnplugin->nonSongPlugin) continue; 554 555 getMachineRect(selconnplugin, &selrc); 556 InflateRect(&selrc, 3, 3); 557 minMaxRect(&rcInvalidate, &selrc); 558 } 559 } 560 dirtyMachines = true; 561 InvalidateRect(&rcInvalidate, FALSE); 562 offX = pt.x; 563 offY = pt.y; 518 564 } else 519 565 if (moveType==MachineViewMoveVolumeSlider) { 520 //if (isVolumeSlider) {521 // change connection amp522 566 POINT pt={(signed short)LOWORD(lParam),(signed short)HIWORD(lParam)}; 523 567 int dist=offY-pt.y; … … 539 583 } else 540 584 if (moveType==MachineViewMoveAllMachines) { 541 // if (isLButtonDown && isCtrlDown()) {542 585 POINT ppt={offX, offY}; 543 586 POINT pt={(signed short)LOWORD(lParam),(signed short)HIWORD(lParam)}; … … 672 715 673 716 LRESULT CMachineView::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 717 674 718 CPaintDC screenDC(m_hWnd); 675 676 if (redrawMode==MachineViewSelectionRectangle) { 677 // if we only update the selection rectangle, draw directly to mr screen 678 paintSelectionRect(screenDC); 679 } else { 680 CMemDC dc(screenDC); 681 682 if (redrawMode&MachineViewBoxes) 683 paintMachines(dc); 684 685 if (redrawMode&MachineViewStatus) 686 paintMachineStatus(dc); 687 688 if (redrawMode&MachineViewVolume) 689 paintVolume(dc); 690 691 if (redrawMode&MachineViewSelectionRectangle) 692 paintSelectionRect(dc); 693 } 694 695 719 720 CDC offscreenDC; 721 offscreenDC.CreateCompatibleDC(screenDC); 722 723 RECT rcClip; 724 screenDC.GetClipBox(&rcClip); 725 726 if (dirtyOffscreenBitmap) { 727 if (offscreenBitmap.m_hBitmap) 728 offscreenBitmap.DeleteObject(); 729 730 RECT rcClient; 731 GetClientRect(&rcClient); 732 offscreenBitmap.CreateCompatibleBitmap(screenDC, rcClient.right, rcClient.bottom); 733 734 dirtyMachines = true; 735 dirtyOffscreenBitmap = false; 736 737 } 738 739 CBitmapHandle oldbitmap = offscreenDC.SelectBitmap(offscreenBitmap); 740 741 if (dirtyMachines) { 742 offscreenDC.FillSolidRect(rcClip.left, rcClip.top, rcClip.right - rcClip.left, rcClip.bottom - rcClip.top, backgroundColor); 743 paintMachines(offscreenDC); 744 dirtyStatus = true; 745 } 746 747 if (dirtyStatus) 748 paintMachineStatus(offscreenDC); 749 750 if (dirtyVolumeSlider) 751 paintVolume(offscreenDC); 752 753 if (dirtySelectionRectangle) 754 paintSelectionRect(offscreenDC); 755 756 757 dirtyMachines = dirtySelectionRectangle = dirtyStatus = dirtyVolumeSlider = false; 758 759 screenDC.BitBlt( 760 rcClip.left, rcClip.top, rcClip.right - rcClip.left, rcClip.bottom - rcClip.top, 761 offscreenDC, rcClip.left, rcClip.top, SRCCOPY); 762 763 offscreenDC.SelectBitmap(oldbitmap); 764 765 return 0; 766 } 767 768 LRESULT CMachineView::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { 769 dirtyOffscreenBitmap = true; 770 Invalidate(FALSE); 696 771 return 0; 697 772 } … … 725 800 prevDragRect = rc; 726 801 } 727 728 729 730 802 731 803 void CMachineView::showMachineContext(POINT pt, metaplugin* machine) { … … 1024 1096 1025 1097 void CMachineView::invalidateMachines() { 1026 redrawMode=MachineViewAll;1098 dirtyMachines = true; 1027 1099 Invalidate(FALSE); 1028 UpdateWindow();1029 redrawMode=MachineViewAll;1030 1100 } 1031 1101 1032 1102 void CMachineView::invalidateConnectionVolume() { 1033 redrawMode=MachineViewVolume;1034 1035 connection* conn =document->getSelectedConnection();1103 dirtyVolumeSlider = true; 1104 1105 connection* conn = document->getSelectedConnection(); 1036 1106 1037 1107 RECT vsr; 1038 1108 getVolumeSliderRect(conn, &vsr); 1039 1109 InvalidateRect(&vsr, FALSE); 1040 1041 UpdateWindow();1042 redrawMode=MachineViewAll;1043 1044 1110 } 1045 1111 1046 1112 void CMachineView::invalidateSelectionRectangle() { 1047 redrawMode=MachineViewSelectionRectangle; 1048 1113 dirtySelectionRectangle = true; 1049 1114 Invalidate(FALSE); 1050 1051 UpdateWindow();1052 redrawMode=MachineViewAll;1053 1054 1115 } 1055 1116 1056 1117 void CMachineView::invalidateStatus() { 1057 redrawMode=MachineViewStatus;1058 1059 for (size_t i =0; i<player->getMachines(); i++) {1060 metaplugin* machine =player->getMachine(i);1118 dirtyStatus = true; 1119 1120 for (size_t i = 0; i < player->getMachines(); i++) { 1121 metaplugin* machine = player->getMachine(i); 1061 1122 if (!machine) continue; 1062 1123 if (machine->nonSongPlugin) continue; … … 1065 1126 InvalidateRect(&rc, FALSE); 1066 1127 } 1067 1068 UpdateWindow();1069 redrawMode=MachineViewAll;1070 1071 1128 } 1072 1129 1073 1130 void CMachineView::invalidateMachine(metaplugin* machine) { 1131 dirtyMachines = true; 1132 1074 1133 RECT rc; 1075 1134 getMachineRect(machine, &rc); 1076 redrawMode=MachineViewBoxes;1077 1135 InvalidateRect(&rc, FALSE); 1078 1136 } … … 1243 1301 getMachineRect(plugin, &mRect); 1244 1302 1245 int fontIndex=(scale/MAX_MACHINE_SCALE)*((float)MAX_MACHINE_FONTS-0.5);1246 CFont prevFont=dc.SelectFont(machineFont[fontIndex]);1247 1248 UINT prevAlign=dc.SetTextAlign(TA_CENTER);1249 int prevBkMode=dc.SetBkMode(TRANSPARENT);1250 1251 1303 // draw outer box 1252 1304 CPenHandle oldPen = dc.SelectPen(borderPen); 1253 1305 CBrushHandle oldBrush = dc.SelectBrush(getMachineBrush(plugin)); 1254 dc.Rectangle(mRect.left, mRect.top, mRect.right, mRect.bottom);1255 1306 1256 1307 MachineSkin* skin = mainFrame->getSkin(plugin->loader->plugin_info->uri); … … 1262 1313 ::GetObject(skin->skin, sizeof(BITMAP), &bm); 1263 1314 dc.StretchBlt(mRect.left, mRect.top, halfWidth*2, halfHeight*2, bitmapDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); 1264 } 1265 1266 connection* masterConnection=player->getMaster()->getConnection(plugin); 1267 // hvis denne går til master, så tegner vi connection-panning-fixing: 1268 if (masterConnection) { 1269 // draw panning box inside normal box 1270 dc.SelectBrush(getMachinePanningBrush(plugin)); 1271 dc.Rectangle(mRect.left+2, mRect.bottom-(10.0*scale), mRect.right-2, mRect.bottom-2); 1272 1273 // and the little pan-slider: 1274 1275 RECT pRect; 1276 dc.SelectBrush(panHandleBrush); 1277 getPanSliderRect(masterConnection, &pRect); 1278 dc.Rectangle(&pRect); 1279 } 1280 1281 string label=plugin->getName(); 1282 if (player->getSoloMachine()!=0 && player->getSoloMachine()!=plugin) 1283 label="["+label+"]"; 1284 1285 if (plugin->isMuted()) 1286 label="("+label+")"; 1287 1288 float fontSize=(scale+1)*8; 1289 1290 int adjustY=plugin->minimized?-fontSize:0; 1291 1292 if (skin && skin->skin && !plugin->minimized) 1293 dc.SetTextColor(skin->textColor); else 1294 dc.SetTextColor(0); 1295 dc.TextOut(mRect.left+halfWidth, mRect.top+halfHeight-(fontSize/2)+adjustY, label.c_str(), label.length()); 1296 1297 if (!ledOnly && document->isSelectedMachine(plugin)) { 1298 RECT fRect = mRect; 1299 fRect.left -= 2; 1300 fRect.top -= 2; 1301 fRect.right += 2; 1302 fRect.bottom += 2; 1303 dc.SetTextColor(0); 1304 dc.DrawFocusRect(&fRect); 1305 InflateRect(&fRect, 1, 1); 1306 dc.DrawFocusRect(&fRect); 1315 } else { 1316 dc.Rectangle(mRect.left, mRect.top, mRect.right, mRect.bottom); 1317 } 1318 1319 if (!ledOnly) { 1320 1321 connection* masterConnection=player->getMaster()->getConnection(plugin); 1322 // hvis denne går til master, så tegner vi connection-panning-fixing: 1323 if (masterConnection) { 1324 // draw panning box inside normal box 1325 dc.SelectBrush(getMachinePanningBrush(plugin)); 1326 dc.Rectangle(mRect.left+2, mRect.bottom-(10.0*scale), mRect.right-2, mRect.bottom-2); 1327 1328 // and the little pan-slider: 1329 1330 RECT pRect; 1331 dc.SelectBrush(panHandleBrush); 1332 getPanSliderRect(masterConnection, &pRect); 1333 dc.Rectangle(&pRect); 1334 } 1335 1336 // draw machine label 1337 int fontIndex=(scale/MAX_MACHINE_SCALE)*((float)MAX_MACHINE_FONTS-0.5); 1338 CFont prevFont=dc.SelectFont(machineFont[fontIndex]); 1339 1340 UINT prevAlign=dc.SetTextAlign(TA_CENTER); 1341 int prevBkMode=dc.SetBkMode(TRANSPARENT); 1342 1343 1344 string label=plugin->getName(); 1345 if (player->getSoloMachine()!=0 && player->getSoloMachine()!=plugin) 1346 label="["+label+"]"; 1347 1348 if (plugin->isMuted()) 1349 label="("+label+")"; 1350 1351 float fontSize=(scale+1)*8; 1352 1353 int adjustY=plugin->minimized?-fontSize:0; 1354 1355 if (skin && skin->skin && !plugin->minimized) 1356 dc.SetTextColor(skin->textColor); else 1357 dc.SetTextColor(0); 1358 dc.TextOut(mRect.left+halfWidth, mRect.top+halfHeight-(fontSize/2)+adjustY, label.c_str(), label.length()); 1359 1360 1361 if (document->isSelectedMachine(plugin)) { 1362 RECT fRect = mRect; 1363 fRect.left -= 2; 1364 fRect.top -= 2; 1365 fRect.right += 2; 1366 fRect.bottom += 2; 1367 dc.SetTextColor(0); 1368 dc.DrawFocusRect(&fRect); 1369 InflateRect(&fRect, 1, 1); 1370 dc.DrawFocusRect(&fRect); 1371 } 1372 dc.SetTextAlign(prevAlign); 1373 dc.SetBkMode(prevBkMode); 1374 dc.SelectFont(prevFont); 1307 1375 } 1308 1376 1309 1377 dc.SelectPen(oldPen); 1310 1378 dc.SelectBrush(oldBrush); 1311 dc.SetTextAlign(prevAlign);1312 dc.SetBkMode(prevBkMode);1313 dc.SelectFont(prevFont);1314 1379 1315 1380 } 1316 1381 1317 1382 void CMachineView::paintMachines(CDC& dc) { 1318 RECT rc;1319 GetClientRect(&rc);1320 dc.FillSolidRect(0,0, rc.right, rc.bottom, backgroundColor);1321 1383 1322 1384 CPenHandle oldPen = dc.SelectPen(linePen); -
trunk/src/buzelib/MachineView.h
r1281 r1297 9 9 class CMainFrame; 10 10 class ClientViewListener; 11 12 enum MachineViewRedraw {13 MachineViewBoxes=1,14 MachineViewStatus=2,15 MachineViewVolume=4,16 MachineViewSelectionRectangle=8,17 18 MachineViewAll=MachineViewBoxes|MachineViewStatus,19 MachineViewAllSelection=MachineViewBoxes|MachineViewStatus|MachineViewSelectionRectangle20 };21 11 22 12 enum MachineViewMouseMoveType { … … 38 28 ClientViewListener* clientViewListener; 39 29 zzub::player* player; 40 MachineViewRedraw redrawMode;41 30 42 31 zzub::metaplugin* draggingMachine; … … 77 66 CBrush ampHandleBrush; 78 67 68 bool dirtyMachines, dirtyStatus, dirtySelectionRectangle, dirtyVolumeSlider; 69 bool dirtyOffscreenBitmap; 70 CBitmap offscreenBitmap; 79 71 public: 80 72 double scale; … … 88 80 MESSAGE_HANDLER(WM_PAINT, OnPaint) 89 81 MESSAGE_HANDLER(WM_CHAR, OnChar) 82 MESSAGE_HANDLER(WM_SIZE, OnSize) 90 83 MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) 91 84 MESSAGE_HANDLER(WM_KEYUP, OnKeyUp) … … 125 118 LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 126 119 LRESULT OnFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 120 LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 127 121 LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); 128 122 LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); -
trunk/src/buzelib/MainFrm.cpp
r1295 r1297 2338 2338 return 0; 2339 2339 zzub::wave_level* wavelevel = wave->get_level(level); 2340 sf_write f_short(sf, (const short*)wave->get_sample_ptr(level), wave->get_sample_count(level));2340 sf_write_raw(sf, wave->get_sample_ptr(level), wave->get_sample_count(level) * ( wave->get_bits_per_sample(level) / 8 * sfinfo.channels ) ); 2341 2341 sf_close(sf); // so close it 2342 2342 return 1; -
trunk/src/buzelib/WaveTableView.cpp
r1294 r1297 446 446 if (index < 0) return 0; 447 447 448 if (!document->streamplayer) return 0; 448 449 if (document->isNotePlaying(document->streamplayer, note)) return 0; 449 450 … … 457 458 if (note == -1) return 0; 458 459 460 if (!document->streamplayer) return 0; 459 461 document->playMachineNote(document->streamplayer, zzub::note_value_off, note); 460 462 return 0;
