修订版 | 202 (tree) |
---|---|
时间 | 2022-04-25 23:09:56 |
作者 | toshinagata1964 |
Strip chart resolution was not working correctly. Fixed.
@@ -41,9 +41,9 @@ | ||
41 | 41 | |
42 | 42 | // Used for showing cursor info when stripDraggingMode > 0 |
43 | 43 | // (i.e. while dragging the selected event(s)) |
44 | - int initialDraggedValue; // The initial strip value of the dragged event | |
44 | + float initialDraggedValue; // The initial strip value of the dragged event | |
45 | 45 | int32_t initialDraggedTick; // The initial tick value of the dragged event |
46 | - int deltaDraggedValue; | |
46 | + float deltaDraggedValue; | |
47 | 47 | int32_t deltaDraggedTick; |
48 | 48 | |
49 | 49 | // Resolution of the y value. Usually 1.0, but can be other values. |
@@ -1219,14 +1219,15 @@ | ||
1219 | 1219 | |
1220 | 1220 | - (NSString *)infoTextForMousePoint:(NSPoint)pt dragging:(BOOL)flag option:(int *)option |
1221 | 1221 | { |
1222 | - int yval; | |
1222 | + float yval; | |
1223 | 1223 | NSString *s = nil; |
1224 | + float valueResolution = resolution; | |
1224 | 1225 | if (option != NULL) |
1225 | 1226 | *option = 0; |
1226 | 1227 | if (stripDraggingMode > 0) { |
1227 | 1228 | int32_t measure, beat, tick; |
1228 | 1229 | [dataSource convertTick:initialDraggedTick + deltaDraggedTick toMeasure:&measure beat:&beat andTick:&tick]; |
1229 | - s = [NSString stringWithFormat:@"%d, %d.%d.%d", initialDraggedValue + deltaDraggedValue, measure, beat, tick]; | |
1230 | + s = [NSString stringWithFormat:@"%g, %d.%d.%d", initialDraggedValue + deltaDraggedValue, measure, beat, tick]; | |
1230 | 1231 | if (option != NULL) |
1231 | 1232 | *option = 1; |
1232 | 1233 | return s; |
@@ -1241,7 +1242,7 @@ | ||
1241 | 1242 | int editingMode = [[self dataSource] graphicEditingMode]; |
1242 | 1243 | float cy = [self convertToYValue:centerY]; |
1243 | 1244 | if (editingMode == kGraphicAddMode) { |
1244 | - s = [NSString stringWithFormat:@"%+d, ", (int)(floor(yval + 0.5 - cy))]; | |
1245 | + s = [NSString stringWithFormat:@"%+g, ", floor((yval - cy) / valueResolution + 0.5) * valueResolution]; | |
1245 | 1246 | } else if (editingMode == kGraphicScaleMode) { |
1246 | 1247 | float visibleHeight = [[self superview] bounds].size.height; |
1247 | 1248 | float fully = [self convertToYValue:(centerY + visibleHeight * 0.5)]; |
@@ -1248,11 +1249,11 @@ | ||
1248 | 1249 | if (fully > cy) |
1249 | 1250 | yval = floor(((yval - cy) / (fully - cy) + 1.0) * 100); |
1250 | 1251 | else yval = 100; |
1251 | - s = [NSString stringWithFormat:@"%d%%, ", yval]; | |
1252 | + s = [NSString stringWithFormat:@"%d%%, ", (int)yval]; | |
1252 | 1253 | } |
1253 | 1254 | } |
1254 | 1255 | if (s == nil) { |
1255 | - s = [NSString stringWithFormat:@"%d, ", yval]; | |
1256 | + s = [NSString stringWithFormat:@"%g, ", yval]; | |
1256 | 1257 | } |
1257 | 1258 | s = [s stringByAppendingString:[super infoTextForMousePoint:pt dragging:flag option:option]]; |
1258 | 1259 | if (!flag) { |
@@ -1402,6 +1403,7 @@ | ||
1402 | 1403 | if (stripDraggingMode > 0) { |
1403 | 1404 | NSPoint pt = [self convertPoint: [theEvent locationInWindow] fromView: nil]; |
1404 | 1405 | BOOL optionDown = (([theEvent modifierFlags] & NSAlternateKeyMask) != 0); |
1406 | + float valueResolution = resolution; | |
1405 | 1407 | pt.x = [dataSource quantizedPixelFromPixel: pt.x]; |
1406 | 1408 | // Support autoscroll (cf. GraphicClientView.mouseDragged) |
1407 | 1409 | /* if (autoscrollTimer != nil) { |
@@ -1449,7 +1451,7 @@ | ||
1449 | 1451 | pt.x = pt.x - draggingStartPoint.x; |
1450 | 1452 | pt.y = pt.y - draggingStartPoint.y; |
1451 | 1453 | deltaDraggedTick = (MDTickType)floor(pt.x / [dataSource pixelsPerTick] + 0.5); |
1452 | - deltaDraggedValue = (MDTickType)floor(pt.y * (maxValue - minValue) / ([self bounds].size.height - sVerticalMargin * 2) + 0.5); | |
1454 | + deltaDraggedValue = floor((pt.y * (maxValue - minValue) / ([self bounds].size.height - sVerticalMargin * 2)) / valueResolution + 0.5) * valueResolution; | |
1453 | 1455 | [self displayIfNeeded]; |
1454 | 1456 | } else [super doMouseDragged: theEvent]; |
1455 | 1457 | } |
@@ -1462,6 +1464,7 @@ | ||
1462 | 1464 | MyDocument *document; |
1463 | 1465 | MDTickType minTick, maxTick; |
1464 | 1466 | NSRect bounds; |
1467 | + float valueResolution = resolution; | |
1465 | 1468 | |
1466 | 1469 | // Pencil mode: edit the strip chart values according to the line shape and |
1467 | 1470 | // editing mode |
@@ -1481,7 +1484,7 @@ | ||
1481 | 1484 | pt.x = draggingPoint.x - draggingStartPoint.x; |
1482 | 1485 | pt.y = draggingPoint.y - draggingStartPoint.y; |
1483 | 1486 | deltaTick = (MDTickType)floor(pt.x / [dataSource pixelsPerTick] + 0.5); |
1484 | - deltaValue = (MDTickType)floor(pt.y * (maxValue - minValue) / ([self bounds].size.height - sVerticalMargin * 2) + 0.5); | |
1487 | + deltaValue = floor((pt.y * (maxValue - minValue) / ([self bounds].size.height - sVerticalMargin * 2)) / valueResolution + 0.5) * valueResolution; | |
1485 | 1488 | [dataSource dragEventsOfKind: eventKind andCode: eventCode byTick: deltaTick andValue: deltaValue sender: self optionFlag: optionDown]; |
1486 | 1489 | stripDraggingMode = 0; |
1487 | 1490 | [dataSource updateCursorInfoForView:self atPosition:draggingPoint]; |