Author: mlytwyn
Date: Sun Feb 12 19:57:48 2017
New Revision: 40339

URL: http://svn.gna.org/viewcvs/gnustep?rev=40339&view=rev
Log:
Support autoscrolling during dragging in views that need it i.e. NSTableView, 
NSOutlineView, etc

Modified:
    libs/gui/branches/gnustep_testplant_branch/Source/NSClipView.m
    libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m

Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSClipView.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSClipView.m?rev=40339&r1=40338&r2=40339&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSClipView.m      
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSClipView.m      Sun Feb 
12 19:57:48 2017
@@ -27,8 +27,10 @@
 */
 
 #import "config.h"
+#import <Foundation/NSDebug.h>
+#import <Foundation/NSException.h>
 #import <Foundation/NSNotification.h>
-#import <Foundation/NSException.h>
+#import <Foundation/NSUserDefaults.h>
 
 #import "AppKit/NSClipView.h"
 #import "AppKit/NSCursor.h"
@@ -491,6 +493,9 @@
  */
 - (BOOL) autoscroll: (NSEvent*)theEvent
 {
+  static CGFloat ScrollingMargin = 15.0;
+  
+  CGFloat scrollingMargin;
   NSPoint new;
   NSPoint delta;
   NSRect r;
@@ -500,22 +505,27 @@
       return NO;
     }
   
-  new = [_documentView convertPoint: [theEvent locationInWindow] 
-                      fromView: nil];
+  // Use defaults value if present...
+  scrollingMargin = [[NSUserDefaults standardUserDefaults]  floatForKey: 
@"GSAutoScrollingMargin"];
+  if (scrollingMargin == 0) // otherwise use static coded default...
+    scrollingMargin = ScrollingMargin;
+  
+  new = [_documentView convertPoint: [theEvent locationInWindow]
+                           fromView: nil];
 
   r = [self documentVisibleRect];
 
-  if (new.x < NSMinX(r))
-    delta.x = new.x - NSMinX(r);
-  else if (new.x > NSMaxX(r))
-    delta.x = new.x - NSMaxX(r);
+  if ((new.x > NSMinX(r)) && (new.x < NSMinX(r)+scrollingMargin))
+    delta.x = (new.x - NSMinX(r)) - scrollingMargin;
+  else if ((new.x > NSMaxX(r)-scrollingMargin) && (new.x < NSMaxX(r)))
+    delta.x = scrollingMargin - (NSMaxX(r) - new.x);
   else
     delta.x = 0;
 
-  if (new.y < NSMinY(r))
-    delta.y = new.y - NSMinY(r);
-  else if (new.y > NSMaxY(r))
-    delta.y = new.y - NSMaxY(r);
+  if ((new.y > NSMinY(r)) && (new.y < NSMinY(r)+scrollingMargin))
+    delta.y = (new.y - NSMinY(r)) - scrollingMargin;
+  else if ((new.y > NSMaxY(r)-scrollingMargin) && (new.y < NSMaxY(r)))
+    delta.y = scrollingMargin - (NSMaxY(r) - new.y);
   else
     delta.y = 0;
 

Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m?rev=40339&r1=40338&r2=40339&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m        
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSWindow.m        Sun Feb 
12 19:57:48 2017
@@ -4391,6 +4391,12 @@
                 {
                   action = NSDragOperationNone;
                 }
+              
+              // Support for autoscrolling...
+              if ([theEvent subtype] == GSAppKitDraggingUpdate)
+                {
+                  [v autoscroll: theEvent];
+                }
 
               e = [NSEvent otherEventWithType: NSAppKitDefined
                            location: [theEvent locationInWindow]


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to