186
200
//---------------------------------------------------
188
202
iCItem to(items.lower_bound(x2));
191
// Draw items from other parts behind all others.
192
// Only for items with events (not arranger parts).
193
for(iCItem i = items.begin(); i != to; ++i)
195
CItem* ci = i->second;
196
// NOTE Optimization: For each item call this once now, then use cached results later via cachedHasHiddenEvents().
197
ci->part()->hasHiddenEvents();
198
if(!ci->event().empty() && ci->part() != curPart)
199
drawItem(p, ci, rect);
202
// Draw unselected parts behind selected.
203
for (iCItem i = items.begin(); i != to; ++i)
205
CItem* ci = i->second;
206
if((!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
207
&& !(ci->event().empty() && (ci->part()->events()->arefCount() > 1 || ci->part()->cachedHasHiddenEvents()))) // p4.0.29
209
drawItem(p, ci, rect);
213
// Draw selected parts in front of unselected.
214
for (iCItem i = items.begin(); i != to; ++i)
216
CItem* ci = i->second;
217
if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
218
//if((ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
219
// || (ci->event().empty() && (ci->part()->events()->arefCount() > 1 || ci->part()->cachedHasHiddenEvents())))
221
drawItem(p, ci, rect);
227
203
for(iCItem i = items.begin(); i != to; ++i)
229
205
CItem* ci = i->second;
257
228
sz = list2.size();
258
229
for(i = 0; i != sz; ++i)
259
230
drawItem(p, list2[i], rect);
261
//for(i = 0; i != sz; ++i)
262
// drawItem(p, list3[i], rect);
263
231
sz = list4.size();
264
232
for(i = 0; i != sz; ++i)
265
233
drawItem(p, list4[i], rect);
235
// Draw items being moved, a special way in their original location.
267
236
to = moving.lower_bound(x2);
268
237
for (iCItem i = moving.begin(); i != to; ++i)
270
238
drawItem(p, i->second, rect);
240
// Draw special top item for new recordings etc.
273
241
drawTopItem(p,rect);
243
// Draw special new item for first-time placement.
244
// It is not in the item list yet. It will be added when mouse released.
246
drawItem(p, newCItem, rect);
311
drawCanvas(p, QRect(x, y, w, h));
283
QRect new_rect(x, y, w, h);
284
drawCanvas(p, new_rect);
314
287
//---------------------------------------------------
315
288
// draw Canvas Items
316
289
//---------------------------------------------------
319
// Draw items from other parts behind all others.
320
// Only for items with events (not arranger parts).
321
for(iCItem i = items.begin(); i != items.end(); ++i)
323
CItem* ci = i->second;
324
// NOTE Optimization: For each item call this once now, then use cached results later via cachedHasHiddenEvents().
325
ci->part()->hasHiddenEvents();
326
if(!ci->event().empty() && ci->part() != curPart)
327
drawItem(p, ci, rect);
330
// Draw unselected parts behind selected.
331
for (iCItem i = items.begin(); i != items.end(); ++i) {
332
CItem* ci = i->second;
333
if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
335
drawItem(p, ci, rect);
339
// Draw selected parts in front of unselected.
340
for (iCItem i = items.begin(); i != items.end(); ++i) {
341
CItem* ci = i->second;
342
if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
343
//if((ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
344
// || (ci->event().empty() && (ci->part()->events()->arefCount() > 1 || ci->part()->cachedHasHiddenEvents())))
346
drawItem(p, ci, rect);
352
291
for(iCItem i = items.begin(); i != items.end(); ++i)
354
293
CItem* ci = i->second;
382
316
sz = list2.size();
383
317
for(i = 0; i != sz; ++i)
384
318
drawItem(p, list2[i], rect);
386
//for(i = 0; i != sz; ++i)
387
// drawItem(p, list3[i], rect);
388
319
sz = list4.size();
389
320
for(i = 0; i != sz; ++i)
390
321
drawItem(p, list4[i], rect);
323
// Draw items being moved, a special way in their original location.
392
324
for (iCItem i = moving.begin(); i != moving.end(); ++i)
394
325
drawItem(p, i->second, rect);
396
drawTopItem(p, QRect(x,y,w,h));
327
// Draw special top item for new recordings etc.
328
drawTopItem(p, new_rect);
330
// Draw special new item for first-time placement.
331
// It is not in the item list yet. It will be added when mouse released.
333
drawItem(p, newCItem, rect);
426
362
p.setPen(Qt::blue);
428
364
if (pos[1] >= unsigned(x) && pos[1] < unsigned(x2)) {
429
//p.drawLine(pos[1], y, pos[1], y2);
430
365
mx = mapx(pos[1]);
431
366
p.drawLine(mx, my, mx, my2);
433
368
if (pos[2] >= unsigned(x) && pos[2] < unsigned(x2)) {
434
//p.drawLine(pos[2], y, pos[2], y2);
435
369
mx = mapx(pos[2]);
436
370
p.drawLine(mx, my, mx, my2);
438
372
p.setPen(Qt::red);
439
373
if (pos[0] >= unsigned(x) && pos[0] < unsigned(x2)) {
440
//p.drawLine(pos[0], y, pos[0], y2);
441
374
mx = mapx(pos[0]);
442
375
p.drawLine(mx, my, mx, my2);
378
if(drag == DRAG_ZOOM)
379
p.drawPixmap(mapFromGlobal(global_start), *zoomAtIcon);
446
382
//p.setWorldMatrixEnabled(true);
447
383
p.setWorldMatrixEnabled(wmtxen);
490
426
if (shift) { // scroll horizontally
491
427
int delta = -ev->delta() / WHEEL_DELTA;
492
428
int xpixelscale = 5*MusECore::fast_log10(rmapxDev(1));
494
429
if (xpixelscale <= 0)
497
431
int scrollstep = WHEEL_STEPSIZE * (delta);
498
///if (ev->state() == Qt::ShiftModifier)
499
// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
500
432
scrollstep = scrollstep / 10;
502
433
int newXpos = xpos + xpixelscale * scrollstep;
508
436
emit horizontalScroll((unsigned)newXpos);
510
438
} else if (ctrl) { // zoom horizontally
511
emit horizontalZoom(ev->delta()>0, ev->x());
439
emit horizontalZoom(ev->delta()>0, ev->globalPos());
512
440
} else { // scroll vertically
513
441
int delta = ev->delta() / WHEEL_DELTA;
514
442
int ypixelscale = rmapyDev(1);
516
443
if (ypixelscale <= 0)
519
445
int scrollstep = WHEEL_STEPSIZE * (-delta);
520
///if (ev->state() == Qt::ShiftModifier)
521
// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
522
446
scrollstep = scrollstep / 2;
524
447
int newYpos = ypos + ypixelscale * scrollstep;
530
450
emit verticalScroll((unsigned)newYpos);
536
454
void Canvas::redirectedWheelEvent(QWheelEvent* ev)
634
553
if (!mousePress(event))
637
///keyState = event->state();
638
keyState = ((QInputEvent*)event)->modifiers();
556
keyState = event->modifiers();
639
557
button = event->button();
641
558
//printf("viewMousePressEvent buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
643
560
// special events if right button is clicked while operations
644
561
// like moving or drawing lasso is performed.
645
///if (event->stateAfter() & Qt::RightButton) {
646
if (event->buttons() & Qt::RightButton & ~(event->button())) {
562
if (event->buttons() & Qt::RightButton & ~(button)) {
647
563
//printf("viewMousePressEvent special buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
662
578
// ignore event if (another) button is already active:
663
///if (keyState & (Qt::LeftButton|Qt::RightButton|Qt::MidButton)) {
664
if (event->buttons() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) {
579
if (event->buttons() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(button)) {
665
580
//printf("viewMousePressEvent ignoring buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
668
584
bool alt = keyState & Qt::AltModifier;
669
585
bool ctrl = keyState & Qt::ControlModifier;
670
587
start = event->pos();
589
global_start = event->globalPos();
590
ev_global_pos = global_start;
672
592
//---------------------------------------------------
673
593
// set curItem to item mouse is pointing
735
if(MusEGlobal::config.borderlessMouse)
737
QRect r = QApplication::desktop()->screenGeometry();
738
ignore_mouse_move = true; // Avoid recursion.
739
QCursor::setPos( QPoint(r.width()/2, r.height()/2) );
748
if(MusEGlobal::config.borderlessMouse)
750
QRect r = QApplication::desktop()->screenGeometry();
751
ignore_mouse_move = true; // Avoid recursion.
752
QCursor::setPos( QPoint(r.width()/2, r.height()/2) );
754
// Update the small zoom drawing area
755
QPoint pt = mapFromGlobal(global_start);
756
update(pt.x(), pt.y(), zoomIcon->width(), zoomIcon->height());
807
766
void Canvas::scrollTimerDone()
809
768
//printf("Canvas::scrollTimerDone drag:%d doScroll:%d\n", drag, doScroll);
811
if (drag != DRAG_OFF && doScroll)
769
if (doScroll && drag != DRAG_OFF && drag != DRAG_ZOOM)
813
771
//printf("Canvas::scrollTimerDone drag != DRAG_OFF && doScroll\n");
772
int modifiers = QApplication::keyboardModifiers();
773
bool ctrl = modifiers & Qt::ControlModifier;
774
bool meta = modifiers & Qt::MetaModifier;
775
bool alt = modifiers & Qt::AltModifier;
776
bool right_button = QApplication::mouseButtons() & Qt::RightButton;
777
bool scrollDoResize = ((!ctrl && !right_button) || meta || alt) && virt(); // Non-virt width is meaningless, such as drums.
815
780
bool doHMove = false;
816
781
bool doVMove = false;
817
int hoff = rmapx(xOffset())+mapx(xorg)-1;
819
782
switch(hscrollDir)
821
784
case HSCROLL_RIGHT:
836
emit horizontalScrollNoLimit(hoff);
799
emit horizontalScrollNoLimit(xpos + scrollSpeed);
837
800
canScrollLeft = true;
838
ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed));
801
dx = rmapxDev(scrollSpeed);
802
ev_pos.setX(ev_pos.x() + dx);
842
806
if(canScrollRight)
845
emit horizontalScroll(hoff);
809
emit horizontalScroll(xpos + scrollSpeed);
846
810
if(xpos <= curxpos)
848
811
canScrollRight = false;
852
814
canScrollLeft = true;
853
ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed));
815
dx = rmapxDev(scrollSpeed);
816
ev_pos.setX(ev_pos.x() + dx);
863
823
case HSCROLL_LEFT:
864
824
if(canScrollLeft)
868
emit horizontalScroll(hoff);
827
emit horizontalScroll(xpos - scrollSpeed);
869
828
if(xpos >= curxpos)
871
829
canScrollLeft = false;
875
832
canScrollRight = true;
876
ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) - scrollSpeed));
833
dx = -rmapxDev(scrollSpeed);
834
ev_pos.setX(ev_pos.x() + dx);
887
int voff = rmapy(yOffset())+mapy(yorg);
889
842
switch(vscrollDir)
891
844
case VSCROLL_DOWN:
892
845
if(canScrollDown)
896
emit verticalScroll(voff);
848
emit verticalScroll(ypos + scrollSpeed);
897
849
if(ypos <= curypos)
899
850
canScrollDown = false;
903
853
canScrollUp = true;
904
ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) + scrollSpeed));
854
dy = rmapyDev(scrollSpeed);
855
ev_pos.setY(ev_pos.y() + dy);
917
emit verticalScroll(voff);
864
emit verticalScroll(ypos - scrollSpeed);
918
865
if(ypos >= curypos)
920
866
canScrollUp = false;
924
869
canScrollDown = true;
925
ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) - scrollSpeed));
870
dy = -rmapyDev(scrollSpeed);
871
ev_pos.setY(ev_pos.y() + dy);
981
952
//printf("Canvas::scrollTimerDone starting scrollTimer: Currently active?%d\n", scrollTimer->isActive());
983
// p3.3.43 Make sure to yield to other events (for up to 3 seconds), otherwise other events
984
// take a long time to reach us, causing scrolling to take a painfully long time to stop.
985
// FIXME: Didn't help at all.
986
//qApp->processEvents();
987
// No, try up to 100 ms for each yield.
988
//qApp->processEvents(100);
990
//scrollTimer->start( 40, TRUE ); // X ms single-shot timer
991
// OK, changing the timeout from 40 to 80 helped.
992
//scrollTimer->start( 80, TRUE ); // X ms single-shot timer
954
// Make sure to yield to other events, otherwise other events take a long time to reach us,
955
// causing scrolling to take a painfully long time to stop. Try up to 100 ms for each yield:
956
//qApp->processEvents(100); // FIXME: Didn't help at all.
993
957
scrollTimer->setSingleShot(true);
994
scrollTimer->start(80);
958
scrollTimer->start(80); // OK, setting a timeout 80 helped.
998
962
//printf("Canvas::scrollTimerDone !(drag != DRAG_OFF && doScroll) deleting scrollTimer\n");
1000
963
delete scrollTimer;
1001
964
scrollTimer=NULL;
1006
968
//---------------------------------------------------------
1007
969
// viewMouseMoveEvent
1008
970
//---------------------------------------------------------
1010
972
void Canvas::viewMouseMoveEvent(QMouseEvent* event)
974
if(ignore_mouse_move)
976
ignore_mouse_move = false;
980
//fprintf(stderr, "xpos=%d xorg=%d xmag=%d event->x=%d ->gx:%d mapx(xorg)=%d rmapx0=%d xOffset=%d rmapx(xOffset()=%d\n",
981
// xpos, xorg, xmag, event->x(), event->globalX(), mapx(xorg), rmapx(0), xOffset(), rmapx(xOffset()));
982
//fprintf(stderr, "ypos=%d yorg=%d ymag=%d event->y=%d ->gy:%d mapy(yorg)=%d rmapy0=%d yOffset=%d rmapy(yOffset()=%d\n",
983
// ypos, yorg, ymag, event->y(), event->globalY(), mapy(yorg), rmapy(0), yOffset(), rmapy(yOffset()));
985
QRect screen_rect = QApplication::desktop()->screenGeometry();
986
QPoint screen_center = QPoint(screen_rect.width()/2, screen_rect.height()/2);
987
QPoint glob_dist = event->globalPos() - ev_global_pos;
988
QPoint glob_zoom_dist = MusEGlobal::config.borderlessMouse ? (event->globalPos() - screen_center) : glob_dist;
989
QPoint last_dist = event->pos() - ev_pos;
1013
ev_pos = event->pos();
1014
QPoint dist = ev_pos - start;
1015
int ax = ABS(rmapx(dist.x()));
1016
int ay = ABS(rmapy(dist.y()));
1017
bool moving = (ax >= 2) || (ay > 2);
991
ev_pos = event->pos();
992
QPoint dist = ev_pos - start;
993
int ax = ABS(rmapx(dist.x()));
994
int ay = ABS(rmapy(dist.y()));
995
bool moving = (ax >= 2) || (ay > 2);
996
int modifiers = event->modifiers();
997
bool ctrl = modifiers & Qt::ControlModifier;
998
bool shift = modifiers & Qt::ShiftModifier;
999
bool meta = modifiers & Qt::MetaModifier;
1000
bool alt = modifiers & Qt::AltModifier;
1001
bool right_button = event->buttons() & Qt::RightButton;
1019
1003
// set scrolling variables: doScroll, scrollRight
1020
if (drag != DRAG_OFF) {
1004
// No auto scroll in zoom mode or normal pan mode.
1005
if (drag != DRAG_OFF && drag != DRAG_ZOOM && (drag != DRAG_PAN || !MusEGlobal::config.borderlessMouse)) {
1023
1006
int ex = rmapx(event->x())+mapx(0);
1024
if(ex < 40 && canScrollLeft)
1025
hscrollDir = HSCROLL_LEFT;
1007
if(ex < 15 && (canScrollLeft || drag == DRAG_PAN))
1008
hscrollDir = (drag == DRAG_PAN ? HSCROLL_RIGHT : HSCROLL_LEFT);
1027
if(ex > (width() - 40))
1010
if(ex > (width() - 15))
1038
1021
case DRAG_MOVE:
1039
1022
case DRAG_COPY:
1040
1023
case DRAG_CLONE:
1041
hscrollDir = HSCROLL_RIGHT;
1025
hscrollDir = (drag == DRAG_PAN ? HSCROLL_LEFT : HSCROLL_RIGHT);
1044
1028
if(canScrollRight)
1045
hscrollDir = HSCROLL_RIGHT;
1029
hscrollDir = (drag == DRAG_PAN ? HSCROLL_LEFT : HSCROLL_RIGHT);
1047
1031
hscrollDir = HSCROLL_NONE;
1051
1035
hscrollDir = HSCROLL_NONE;
1052
1037
int ey = rmapy(event->y())+mapy(0);
1053
if(ey < 15 && canScrollUp)
1054
vscrollDir = VSCROLL_UP;
1038
if(ey < 15 && (canScrollUp || drag == DRAG_PAN))
1039
vscrollDir = (drag == DRAG_PAN ? VSCROLL_DOWN : VSCROLL_UP);
1056
if(ey > (height() - 15) && canScrollDown)
1057
vscrollDir = VSCROLL_DOWN;
1041
if(ey > (height() - 15) && (canScrollDown || drag == DRAG_PAN))
1042
vscrollDir = (drag == DRAG_PAN ? VSCROLL_UP : VSCROLL_DOWN);
1059
1044
vscrollDir = VSCROLL_NONE;
1060
1046
if(hscrollDir != HSCROLL_NONE || vscrollDir != VSCROLL_NONE)
1150
1132
dt = MOVE_CLONE;
1152
startMoving(ev_pos, dt);
1134
startMoving(ev_pos, dt, !(keyState & Qt::ShiftModifier));
1155
1137
case DRAG_MOVE:
1156
1138
case DRAG_COPY:
1157
1139
case DRAG_CLONE:
1159
1140
if(!scrollTimer)
1160
moveItems(ev_pos, 0);
1141
moveItems(ev_pos, 0, !shift);
1163
1144
case DRAGX_MOVE:
1164
1145
case DRAGX_COPY:
1165
1146
case DRAGX_CLONE:
1166
1147
if(!scrollTimer)
1167
moveItems(ev_pos, 1);
1148
moveItems(ev_pos, 1, false);
1170
1151
case DRAGY_MOVE:
1171
1152
case DRAGY_COPY:
1172
1153
case DRAGY_CLONE:
1173
1154
if(!scrollTimer)
1174
moveItems(ev_pos, 2);
1155
moveItems(ev_pos, 2, false);
1160
if (last_dist.x()) {
1161
if(((ctrl || right_button) && !meta && !alt) || !virt()) // Non-virt width is meaningless, such as drums.
1163
int nx = ev_pos.x() - newCItem->width(); // Keep the cursor at the right edge.
1168
nx = raster(QPoint(nx, 0)).x(); // 0 is dummy, we want only x
1172
newCItem->move(QPoint(nx, newCItem->y()));
1176
int w = ev_pos.x() - newCItem->x();
1179
newCItem->setWidth(w);
1182
if (last_dist.y()) {
1183
int x = newCItem->x();
1185
int ny = pitch2y(y2pitch(y)) - yItemOffset();
1186
QPoint pt = QPoint(x, ny);
1188
newCItem->setHeight(y2height(y));
1189
itemMoved(newCItem, pt);
1191
if (last_dist.x() || last_dist.y())
1178
1196
case DRAG_RESIZE:
1181
curItem->setWidth(1);
1183
curItem->setWidth(dist.x());
1197
if (last_dist.x()) {
1198
int w = ev_pos.x() - curItem->x();
1201
curItem->setWidth(w);
1187
1206
case DRAG_DELETE:
1188
1207
deleteItem(ev_pos);
1212
bool changed = false;
1213
if((!shift || (shift && ctrl)) && glob_zoom_dist.x() != 0 && (!doScroll || hscrollDir == HSCROLL_NONE)) // Don't interfere if auto-scrolling
1215
emit horizontalScroll(xpos - glob_zoom_dist.x());
1218
if((!ctrl || (shift && ctrl)) && glob_zoom_dist.y() != 0 && (!doScroll || vscrollDir == VSCROLL_NONE)) // Don't interfere if auto-scrolling
1220
emit verticalScroll(ypos - glob_zoom_dist.y());
1223
if(MusEGlobal::config.borderlessMouse && changed)
1225
ignore_mouse_move = true; // Avoid recursion.
1226
QCursor::setPos(screen_center);
1232
if(glob_zoom_dist.x() != 0)
1233
emit horizontalZoom(glob_zoom_dist.x(), global_start);
1234
//if(glob_zoom_dist.y() != 0)
1235
// emit verticalZoom(glob_zoom_dist.y(), global_start); // TODO
1236
if(MusEGlobal::config.borderlessMouse && (glob_zoom_dist.x() != 0 || glob_zoom_dist.y() != 0))
1238
ignore_mouse_move = true; // Avoid recursion.
1239
QCursor::setPos(screen_center);
1247
ev_global_pos = event->globalPos();
1249
if(drag != DRAG_ZOOM && (drag != DRAG_PAN || !MusEGlobal::config.borderlessMouse))
1198
1253
//---------------------------------------------------------
1243
1295
itemReleased(curItem, curItem->pos());
1245
1297
case DRAG_COPY:
1246
endMoveItems(pos, MOVE_COPY, 0);
1298
endMoveItems(pos, MOVE_COPY, 0, !shift);
1248
1300
case DRAGX_COPY:
1249
endMoveItems(pos, MOVE_COPY, 1);
1301
endMoveItems(pos, MOVE_COPY, 1, false);
1251
1303
case DRAGY_COPY:
1252
endMoveItems(pos, MOVE_COPY, 2);
1304
endMoveItems(pos, MOVE_COPY, 2, false);
1254
1306
case DRAG_MOVE:
1255
endMoveItems(pos, MOVE_MOVE, 0);
1307
endMoveItems(pos, MOVE_MOVE, 0, !shift);
1257
1309
case DRAGX_MOVE:
1258
endMoveItems(pos, MOVE_MOVE, 1);
1310
endMoveItems(pos, MOVE_MOVE, 1, false);
1260
1312
case DRAGY_MOVE:
1261
endMoveItems(pos, MOVE_MOVE, 2);
1313
endMoveItems(pos, MOVE_MOVE, 2, false);
1263
1315
case DRAG_CLONE:
1264
endMoveItems(pos, MOVE_CLONE, 0);
1316
endMoveItems(pos, MOVE_CLONE, 0, !shift);
1266
1318
case DRAGX_CLONE:
1267
endMoveItems(pos, MOVE_CLONE, 1);
1319
endMoveItems(pos, MOVE_CLONE, 1, false);
1269
1321
case DRAGY_CLONE:
1270
endMoveItems(pos, MOVE_CLONE, 2);
1322
endMoveItems(pos, MOVE_CLONE, 2, false);
1274
1326
case DRAG_RESIZE:
1275
resizeItem(curItem, false, ctrl);
1327
resizeItem(curItem, shift, ctrl);
1278
newItem(curItem, false);
1332
items.add(newCItem);
1335
itemReleased(curItem, curItem->pos());
1336
newItem(curItem, shift);
1281
1340
case DRAG_LASSO_START:
1282
1341
lasso.setRect(-1, -1, -1, -1);
1298
1357
case DRAG_DELETE:
1361
if(MusEGlobal::config.borderlessMouse)
1364
ignore_mouse_move = true; // Avoid recursion.
1365
QCursor::setPos(global_start);
1370
if(MusEGlobal::config.borderlessMouse)
1373
ignore_mouse_move = true; // Avoid recursion.
1374
QCursor::setPos(global_start);
1301
1378
//printf("Canvas::viewMouseReleaseEvent setting drag to DRAG_OFF\n");
1380
// Just in case it was somehow forgotten:
1383
if(newCItem->event().empty() && newCItem->part()) // Was it a new part, with no event?
1384
delete newCItem->part();
1389
if(drag == DRAG_ZOOM) // Update the small zoom drawing area
1392
QPoint pt = mapFromGlobal(global_start);
1393
update(pt.x(), pt.y(), zoomIcon->width(), zoomIcon->height());
1303
1396
drag = DRAG_OFF;
1304
1397
if (redrawFlag)
1307
1400
mouseRelease(pos);
1310
1403
//---------------------------------------------------------
1431
1520
case DRAG_MOVE:
1432
1521
case DRAG_COPY:
1433
1522
case DRAG_CLONE:
1434
QWidget::setCursor(QCursor(Qt::SizeAllCursor));
1523
// Bug in KDE cursor theme? On some distros this cursor is actually another version of a closed hand! From 'net:
1524
// "It might be a problem in the distribution as Qt uses the cursor that is provided by X.org/xcursor extension with name "size_all".
1525
// We fixed this issue by setting the KDE cursor theme to "System theme" "
1526
QWidget::setCursor(QCursor(Qt::SizeAllCursor));
1437
1529
case DRAG_RESIZE:
1438
1530
QWidget::setCursor(QCursor(Qt::SizeHorCursor));
1534
if(MusEGlobal::config.borderlessMouse)
1535
QWidget::setCursor(QCursor(Qt::BlankCursor)); // Hide it.
1537
QWidget::setCursor(QCursor(Qt::ClosedHandCursor));
1541
if(MusEGlobal::config.borderlessMouse)
1542
QWidget::setCursor(QCursor(Qt::BlankCursor)); // Hide it.
1441
1545
case DRAG_DELETE:
1442
1546
case DRAG_COPY_START:
1443
1547
case DRAG_CLONE_START:
1508
1627
//---------------------------------------------------------
1509
1628
// genCanvasPopup
1629
// Add the list of available tools to a popup menu
1630
// menu parameter can be NULL meaning create a menu here
1510
1631
//---------------------------------------------------------
1512
QMenu* Canvas::genCanvasPopup()
1633
QMenu* Canvas::genCanvasPopup(QMenu* menu)
1514
1635
if (canvasTools == 0)
1516
QMenu* canvasPopup = new QMenu(this);
1637
QMenu* r_menu = menu;
1639
r_menu = new QMenu(this);
1517
1640
QAction* act0 = 0;
1519
for (unsigned i = 0; i < 9; ++i) {
1642
r_menu->addAction(new MenuTitleItem(tr("Tools:"), r_menu));
1644
for (unsigned i = 0; i < gNumberOfTools; ++i) {
1520
1645
if ((canvasTools & (1 << i))==0)
1522
QAction* act = canvasPopup->addAction(QIcon(**toolList[i].icon), tr(toolList[i].tip));
1523
act->setData(1<<i); // ddskrjo
1647
QAction* act = r_menu->addAction(QIcon(**toolList[i].icon), tr(toolList[i].tip));
1649
if (MusEGui::toolShortcuts.contains(1 << i)) {
1650
act->setShortcut(MusEGui::shortcuts[MusEGui::toolShortcuts[1 << i]].key);
1653
act->setData(TOOLS_ID_BASE + i);
1654
act->setCheckable(true);
1655
act->setChecked((1 << i) == _tool);
1527
canvasPopup->setActiveAction(act0);
1659
if(!menu) // Don't interefere with supplied menu's current item
1660
r_menu->setActiveAction(act0);
1531
1664
//---------------------------------------------------------