• R/O
  • SSH
  • HTTPS

alchemusica: 提交


Commit MetaInfo

修订版25 (tree)
时间2012-06-19 00:48:59
作者toshinagata1964

Log Message

Selection mode of the piano roll window is being reworked. (May be still imcomplete)

更改概述

差异

--- trunk/Classes/GraphicSplitterView.m (revision 24)
+++ trunk/Classes/GraphicSplitterView.m (revision 25)
@@ -17,6 +17,7 @@
1717
1818 #import "GraphicSplitterView.h"
1919 #import "GraphicWindowController.h"
20+#import "NSCursorAdditions.h"
2021 #import "MDObjects.h"
2122
2223 @implementation GraphicSplitterView
@@ -180,6 +181,11 @@
180181 } while (type == NSLeftMouseDragged);
181182 }
182183
184+- (void)doMouseMoved:(NSEvent *)theEvent
185+{
186+ [[NSCursor verticalMoveCursor] set];
187+}
188+
183189 - (void)createSubmenus
184190 {
185191 }
--- trunk/Classes/GraphicClientView.h (revision 24)
+++ trunk/Classes/GraphicClientView.h (revision 25)
@@ -26,7 +26,7 @@
2626 @interface GraphicClientView : NSView {
2727 id dataSource; // The data source
2828 float minValue, maxValue;
29- int localSelectionMode; // Get value from -[GraphicWindowController graphicSelectionMode] in mouseDown handler and keep value. Some client (like TimeChartView) may want to override the selection mode.
29+ int localGraphicTool; // Get value from -[GraphicWindowController graphicTool] in mouseDown handler and keep value. Some client (like TimeChartView) may want to override the selection mode.
3030 BOOL isDragging;
3131 BOOL isLoupeDragging;
3232 unsigned int initialModifierFlags;
--- trunk/Classes/GraphicClientView.m (revision 24)
+++ trunk/Classes/GraphicClientView.m (revision 25)
@@ -181,7 +181,7 @@
181181 NSPoint pt1, pt2;
182182 NSRect rect;
183183 if (selectPoints != nil && [selectPoints count] > 1) {
184- if (localSelectionMode == kGraphicRectangleSelectionMode || localSelectionMode == kGraphicIbeamSelectionMode) {
184+ if (localGraphicTool == kGraphicRectangleSelectTool || localGraphicTool == kGraphicIbeamSelectTool || localGraphicTool == kGraphicPencilTool) {
185185 pt1 = [[selectPoints objectAtIndex: 0] pointValue];
186186 pt2 = [[selectPoints objectAtIndex: 1] pointValue];
187187 rect.origin = pt1;
@@ -190,7 +190,7 @@
190190 rect.size.width = -rect.size.width;
191191 rect.origin.x = pt2.x;
192192 }
193- if (localSelectionMode == kGraphicRectangleSelectionMode) {
193+ if (localGraphicTool == kGraphicRectangleSelectTool) {
194194 rect.size.height = pt2.y - pt1.y;
195195 if (rect.size.height < 0) {
196196 rect.size.height = -rect.size.height;
@@ -257,42 +257,9 @@
257257
258258 - (BOOL)isPointInSelectRegion: (NSPoint)point
259259 {
260-#if 1
261260 if (selectionPath != nil)
262261 return [selectionPath containsPoint: point];
263262 else return NO;
264-#else
265- NSPoint pt1, pt2;
266- if (localSelectionMode == kGraphicRectangleSelectionMode || localSelectionMode == kGraphicIbeamSelectionMode) {
267- if (selectPoints != nil && [selectPoints count] >= 2) {
268- float w0, w1;
269- pt1 = [[selectPoints objectAtIndex: 0] pointValue];
270- pt2 = [[selectPoints objectAtIndex: 1] pointValue];
271- if (pt1.x < pt2.x) {
272- w0 = pt1.x;
273- w1 = pt2.x;
274- } else {
275- w0 = pt2.x;
276- w1 = pt1.x;
277- }
278- if (point.x < w0 || point.x > w1)
279- return NO;
280- if (localSelectionMode == kGraphicRectangleSelectionMode) {
281- if (pt1.y < pt2.y) {
282- w0 = pt1.y;
283- w1 = pt2.y;
284- } else {
285- w0 = pt2.y;
286- w1 = pt1.y;
287- }
288- if (point.y < w0 || point.y > w1)
289- return NO;
290- }
291- return YES;
292- } else return NO;
293- }
294- return NO;
295-#endif
296263 }
297264
298265 - (void)autoscrollTimerCallback: (NSTimer *)timer
@@ -332,7 +299,7 @@
332299 initialModifierFlags = [theEvent modifierFlags];
333300 currentModifierFlags = initialModifierFlags;
334301 isDragging = isLoupeDragging = NO;
335- localSelectionMode = [dataSource graphicSelectionMode]; // May be overridden in doMouseDown:
302+ localGraphicTool = [dataSource graphicTool]; // May be overridden in doMouseDown:
336303 [self doMouseDown: theEvent];
337304 }
338305
@@ -380,12 +347,16 @@
380347 if (pt.y > bounds.origin.y + bounds.size.height)
381348 pt.y = bounds.origin.y + bounds.size.height;
382349 val = [NSValue valueWithPoint: pt];
383- if (localSelectionMode == kGraphicRectangleSelectionMode || localSelectionMode == kGraphicIbeamSelectionMode) {
384- if ([selectPoints count] == 1)
385- [selectPoints addObject: val];
386- else
387- [selectPoints replaceObjectAtIndex: 1 withObject: val];
388- }
350+ /* This is for linear (rectangle or ibeam) selection; also for pencil editing of strip chart */
351+ if (localGraphicTool == kGraphicRectangleSelectTool || localGraphicTool == kGraphicIbeamSelectTool || localGraphicTool == kGraphicPencilTool) {
352+ if ([selectPoints count] == 1)
353+ [selectPoints addObject: val];
354+ else
355+ [selectPoints replaceObjectAtIndex: 1 withObject: val];
356+ } else {
357+ /* If marquee selection tool or free-hand pencil tool is to be implemented,
358+ the last point should be added to selectPoints here */
359+ }
389360 [self doMouseDragged: theEvent];
390361 [self displayIfNeeded];
391362 }
--- trunk/Classes/StripChartView.m (revision 24)
+++ trunk/Classes/StripChartView.m (revision 25)
@@ -298,8 +298,8 @@
298298 pt.y = floor(bounds.origin.x + bounds.size.height / 2) + 0.5;
299299 [[NSColor lightGrayColor] set];
300300 [NSBezierPath strokeLineFromPoint: pt toPoint: NSMakePoint(pt.x + bounds.size.width, pt.y)];
301-
302-// if ([self isDragging])
301+
302+ if ([self isDragging])
303303 [self drawSelectRegion];
304304 }
305305
@@ -582,16 +582,15 @@
582582 NSRect r;
583583 NSBezierPath *path;
584584
585-
586585 n = [[self dataSource] graphicTool];
587- if (n == kGraphicSelectTool && localSelectionMode != kGraphicRectangleSelectionMode) {
586+ if (lineShape == 0 && (n == kGraphicIbeamSelectTool || n == kGraphicRectangleSelectTool)) {
588587 [super drawSelectRegion];
589588 return;
590589 }
591590
592- // Pencil mode or rectangle selection mode (without hitting existing chart) causes pencil editing
591+ // Pencil mode
593592 // Set the line shape (>0): this is the indicator for pencil editing (used in the mouseUp handler)
594- lineShape = [[self dataSource] graphicLineShape];
593+// lineShape = [[self dataSource] graphicLineShape];
595594
596595 // selectPoints is an instance variable of GraphicClientView
597596 n = [selectPoints count];
@@ -1035,10 +1034,10 @@
10351034 long pos;
10361035 MDEvent *ep;
10371036 int n, tool;
1038- NSPoint pt = [theEvent locationInWindow];
1039- pt = [self convertPoint: pt fromView: nil];
1037+ NSPoint pt = [NSEvent mouseLocation]; /* Use mouseLocation in case this is called from flagsChanged: handler (not implemented yet) */
1038+ pt = [self convertPoint: [[self window] convertScreenToBase:pt] fromView: nil];
10401039 tool = [[self dataSource] graphicTool];
1041- if (tool == kGraphicPencilTool) {
1040+ if (tool == kGraphicPencilTool || (tool == kGraphicRectangleSelectTool && ([theEvent modifierFlags] & NSCommandKeyMask) != 0)) {
10421041 [[NSCursor pencilCursor] set];
10431042 return;
10441043 }
@@ -1065,11 +1064,14 @@
10651064 NSRect bounds;
10661065 NSPoint pt;
10671066
1068- if ([[self dataSource] graphicTool] == kGraphicPencilTool) {
1067+ if (localGraphicTool == kGraphicRectangleSelectTool && ([theEvent modifierFlags] & NSCommandKeyMask) != 0)
1068+ localGraphicTool = kGraphicPencilTool;
1069+ if (localGraphicTool == kGraphicPencilTool) {
10691070 // Invoke the common dragging procedure without checking mouse hitting on the existing chart
10701071 // The overridden method drawSelectRegion: implements the specific treatment
10711072 // for this class.
10721073 [super doMouseDown: theEvent];
1074+ lineShape = [[self dataSource] graphicLineShape];
10731075 return;
10741076 }
10751077
@@ -1187,6 +1189,7 @@
11871189 // editing mode
11881190 if (lineShape > 0) {
11891191 [self doPencilEdit];
1192+ lineShape = 0;
11901193 return;
11911194 }
11921195
--- trunk/Classes/PianoRollView.m (revision 24)
+++ trunk/Classes/PianoRollView.m (revision 25)
@@ -608,12 +608,15 @@
608608 long track;
609609 long pos;
610610 MDEvent *ep;
611- int n;
611+ int n, tool;
612612 NSPoint pt = [theEvent locationInWindow];
613613 pt = [self convertPoint: pt fromView: nil];
614614 n = [self findNoteUnderPoint: pt track: &track position: &pos mdEvent: &ep];
615+ tool = [[self dataSource] graphicTool];
615616 if (n > 0)
616617 [self setDraggingCursor: n];
618+ else if (tool == kGraphicPencilTool || (tool == kGraphicRectangleSelectTool && ([theEvent modifierFlags] & NSCommandKeyMask) != 0))
619+ [[NSCursor pencilCursor] set];
617620 else [super doMouseMoved: theEvent];
618621 }
619622
@@ -651,6 +654,10 @@
651654 float ys = [self yScale];
652655 NSPoint pt = [self convertPoint: [theEvent locationInWindow] fromView: nil];
653656 // shiftDown = (([theEvent modifierFlags] & NSShiftKeyMask) != 0);
657+
658+ if (localGraphicTool == kGraphicRectangleSelectTool && ([theEvent modifierFlags] & NSCommandKeyMask) != 0)
659+ localGraphicTool = kGraphicPencilTool;
660+
654661 draggingMode = [self findNoteUnderPoint: pt track: &mouseDownTrack position: &mouseDownPos mdEvent: &ep];
655662 pt.x = [dataSource quantizedPixelFromPixel: pt.x];
656663 draggingStartPoint = draggingPoint = pt;
@@ -660,7 +667,7 @@
660667 playingVelocity = MDGetNoteOnVelocity(ep);
661668 [self playMIDINoteWithVelocity: playingVelocity];
662669 return;
663- } else if ([[self dataSource] graphicTool] == kGraphicPencilTool) {
670+ } else if (localGraphicTool == kGraphicPencilTool) {
664671 pencilOn = YES;
665672 [self invalidateDraggingRegion];
666673 [self displayIfNeeded];
--- trunk/Classes/GraphicWindowController.h (revision 24)
+++ trunk/Classes/GraphicWindowController.h (revision 25)
@@ -40,13 +40,14 @@
4040 kGraphicDraw = 4 // allow inserting new events (with pencil tools)
4141 };
4242
43-// Graphic Tool (returned by graphicTool: )
43+// Graphic Tool (returned by graphicTool)
4444 enum {
45- kGraphicSelectTool = 1,
45+ kGraphicRectangleSelectTool = 1,
46+ kGraphicIbeamSelectTool,
4647 kGraphicPencilTool
4748 };
4849
49-// Line shape (returned by graphicLineShape: )
50+// Line shape (returned by graphicLineShape)
5051 enum {
5152 kGraphicLinearShape = 1,
5253 kGraphicParabolaShape,
@@ -55,15 +56,16 @@
5556 kGraphicRandomShape
5657 };
5758
58-// Selection mode (returned by selectionMode: )
59+/*
60+// Selection mode (returned by graphicSelectionMode)
5961 enum {
6062 kGraphicRectangleSelectionMode = 0,
6163 kGraphicIbeamSelectionMode,
6264 kGraphicMarqueeSelectionMode
6365 };
66+*/
6467
65-
66-// Editing mode for strip chart (returned by graphicEditingMode: )
68+// Editing mode for strip chart (returned by graphicEditingMode)
6769 enum {
6870 kGraphicSetMode = 1,
6971 kGraphicAddMode,
@@ -121,7 +123,7 @@
121123 int graphicTool;
122124 int graphicLineShape;
123125 int graphicEditingMode;
124- int graphicSelectionMode;
126+// int graphicSelectionMode;
125127
126128 // Client view that received the last mouse event
127129 int lastMouseClientViewIndex;
@@ -220,7 +222,7 @@
220222 - (int)graphicTool;
221223 - (int)graphicLineShape;
222224 - (int)graphicEditingMode;
223-- (int)graphicSelectionMode;
225+//- (int)graphicSelectionMode;
224226 - (GraphicClientView *)clientViewAtIndex: (int)index;
225227
226228 // Action methods for track table
--- trunk/Classes/GraphicWindowController.m (revision 24)
+++ trunk/Classes/GraphicWindowController.m (revision 25)
@@ -1899,7 +1899,7 @@
18991899 [myPopUpButton setFrame: frame];
19001900 [myPopUpButton setBezelStyle: NSShadowlessSquareBezelStyle];
19011901
1902- graphicTool = kGraphicSelectTool;
1902+ graphicTool = kGraphicRectangleSelectTool;
19031903 graphicLineShape = kGraphicLinearShape;
19041904 graphicEditingMode = kGraphicSetMode;
19051905
@@ -2143,24 +2143,18 @@
21432143 case kIbeamButtonTag:
21442144 [[[[self window] contentView] viewWithTag: kSelectButtonTag] setState: NSOffState];
21452145 [[[[self window] contentView] viewWithTag: kPencilButtonTag] setState: NSOffState];
2146- // [[[[self window] contentView] viewWithTag: kShapePopUpTag] setEnabled: NO];
2147- // [[[[self window] contentView] viewWithTag: kModePopUpTag] setEnabled: NO];
2148- graphicTool = kGraphicSelectTool;
2149- graphicSelectionMode = kGraphicIbeamSelectionMode;
2146+ graphicTool = kGraphicIbeamSelectTool;
2147+ // graphicSelectionMode = kGraphicIbeamSelectionMode;
21502148 break;
21512149 case kSelectButtonTag:
21522150 [[[[self window] contentView] viewWithTag: kIbeamButtonTag] setState: NSOffState];
21532151 [[[[self window] contentView] viewWithTag: kPencilButtonTag] setState: NSOffState];
2154- // [[[[self window] contentView] viewWithTag: kShapePopUpTag] setEnabled: NO];
2155- // [[[[self window] contentView] viewWithTag: kModePopUpTag] setEnabled: NO];
2156- graphicTool = kGraphicSelectTool;
2157- graphicSelectionMode = kGraphicRectangleSelectionMode;
2152+ graphicTool = kGraphicRectangleSelectTool;
2153+ // graphicSelectionMode = kGraphicRectangleSelectionMode;
21582154 break;
21592155 case kPencilButtonTag:
21602156 [[[[self window] contentView] viewWithTag: kIbeamButtonTag] setState: NSOffState];
21612157 [[[[self window] contentView] viewWithTag: kSelectButtonTag] setState: NSOffState];
2162- // [[[[self window] contentView] viewWithTag: kShapePopUpTag] setEnabled: YES];
2163- // [[[[self window] contentView] viewWithTag: kModePopUpTag] setEnabled: YES];
21642158 graphicTool = kGraphicPencilTool;
21652159 break;
21662160 }
@@ -2222,11 +2216,6 @@
22222216 return graphicEditingMode;
22232217 }
22242218
2225-- (int)graphicSelectionMode
2226-{
2227- return graphicSelectionMode;
2228-}
2229-
22302219 static BOOL
22312220 mouseMovedInView(NSView *view, NSEvent *theEvent)
22322221 {
@@ -2239,6 +2228,7 @@
22392228 if (NSMouseInRect(pt, rect, [view isFlipped])) {
22402229 if ([view respondsToSelector: @selector(doMouseMoved:)])
22412230 [(id)view doMouseMoved: theEvent];
2231+ else [[NSCursor arrowCursor] set];
22422232 return YES;
22432233 } else return NO;
22442234 }
@@ -2252,9 +2242,11 @@
22522242 [self mouseEvent:theEvent receivedByClientView:records[i].client];
22532243 break;
22542244 }
2255- if (mouseMovedInView(records[i].ruler, theEvent) || mouseMovedInView(records[i].splitter, theEvent))
2245+ if (mouseMovedInView(records[i].splitter, theEvent) || mouseMovedInView(records[i].ruler, theEvent))
22562246 break;
22572247 }
2248+ if (i == myClientViewsCount)
2249+ [[NSCursor arrowCursor] set];
22582250 }
22592251
22602252 - (void)mouseEntered: (NSEvent *)theEvent
--- trunk/Classes/TimeChartView.m (revision 24)
+++ trunk/Classes/TimeChartView.m (revision 25)
@@ -332,7 +332,8 @@
332332 } else {
333333 [super doMouseDown: theEvent];
334334 }
335- localSelectionMode = kGraphicIbeamSelectionMode;
335+ if (localGraphicTool == kGraphicRectangleSelectTool)
336+ localGraphicTool = kGraphicIbeamSelectTool;
336337 }
337338
338339 - (void)doMouseDragged: (NSEvent *)theEvent
Show on old repository browser