• R/O
  • SSH
  • HTTPS

alchemusica: 提交


Commit MetaInfo

修订版202 (tree)
时间2022-04-25 23:09:56
作者toshinagata1964

Log Message

Strip chart resolution was not working correctly. Fixed.

更改概述

差异

--- trunk/Classes/StripChartView.h (revision 201)
+++ trunk/Classes/StripChartView.h (revision 202)
@@ -41,9 +41,9 @@
4141
4242 // Used for showing cursor info when stripDraggingMode > 0
4343 // (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
4545 int32_t initialDraggedTick; // The initial tick value of the dragged event
46- int deltaDraggedValue;
46+ float deltaDraggedValue;
4747 int32_t deltaDraggedTick;
4848
4949 // Resolution of the y value. Usually 1.0, but can be other values.
--- trunk/Classes/StripChartView.m (revision 201)
+++ trunk/Classes/StripChartView.m (revision 202)
@@ -1219,14 +1219,15 @@
12191219
12201220 - (NSString *)infoTextForMousePoint:(NSPoint)pt dragging:(BOOL)flag option:(int *)option
12211221 {
1222- int yval;
1222+ float yval;
12231223 NSString *s = nil;
1224+ float valueResolution = resolution;
12241225 if (option != NULL)
12251226 *option = 0;
12261227 if (stripDraggingMode > 0) {
12271228 int32_t measure, beat, tick;
12281229 [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];
12301231 if (option != NULL)
12311232 *option = 1;
12321233 return s;
@@ -1241,7 +1242,7 @@
12411242 int editingMode = [[self dataSource] graphicEditingMode];
12421243 float cy = [self convertToYValue:centerY];
12431244 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];
12451246 } else if (editingMode == kGraphicScaleMode) {
12461247 float visibleHeight = [[self superview] bounds].size.height;
12471248 float fully = [self convertToYValue:(centerY + visibleHeight * 0.5)];
@@ -1248,11 +1249,11 @@
12481249 if (fully > cy)
12491250 yval = floor(((yval - cy) / (fully - cy) + 1.0) * 100);
12501251 else yval = 100;
1251- s = [NSString stringWithFormat:@"%d%%, ", yval];
1252+ s = [NSString stringWithFormat:@"%d%%, ", (int)yval];
12521253 }
12531254 }
12541255 if (s == nil) {
1255- s = [NSString stringWithFormat:@"%d, ", yval];
1256+ s = [NSString stringWithFormat:@"%g, ", yval];
12561257 }
12571258 s = [s stringByAppendingString:[super infoTextForMousePoint:pt dragging:flag option:option]];
12581259 if (!flag) {
@@ -1402,6 +1403,7 @@
14021403 if (stripDraggingMode > 0) {
14031404 NSPoint pt = [self convertPoint: [theEvent locationInWindow] fromView: nil];
14041405 BOOL optionDown = (([theEvent modifierFlags] & NSAlternateKeyMask) != 0);
1406+ float valueResolution = resolution;
14051407 pt.x = [dataSource quantizedPixelFromPixel: pt.x];
14061408 // Support autoscroll (cf. GraphicClientView.mouseDragged)
14071409 /* if (autoscrollTimer != nil) {
@@ -1449,7 +1451,7 @@
14491451 pt.x = pt.x - draggingStartPoint.x;
14501452 pt.y = pt.y - draggingStartPoint.y;
14511453 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;
14531455 [self displayIfNeeded];
14541456 } else [super doMouseDragged: theEvent];
14551457 }
@@ -1462,6 +1464,7 @@
14621464 MyDocument *document;
14631465 MDTickType minTick, maxTick;
14641466 NSRect bounds;
1467+ float valueResolution = resolution;
14651468
14661469 // Pencil mode: edit the strip chart values according to the line shape and
14671470 // editing mode
@@ -1481,7 +1484,7 @@
14811484 pt.x = draggingPoint.x - draggingStartPoint.x;
14821485 pt.y = draggingPoint.y - draggingStartPoint.y;
14831486 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;
14851488 [dataSource dragEventsOfKind: eventKind andCode: eventCode byTick: deltaTick andValue: deltaValue sender: self optionFlag: optionDown];
14861489 stripDraggingMode = 0;
14871490 [dataSource updateCursorInfoForView:self atPosition:draggingPoint];
Show on old repository browser