discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNUstep slowness while drawing


From: Andreas Höschler
Subject: GNUstep slowness while drawing
Date: Mon, 28 Apr 2008 21:14:37 +0200

Hi all,

I have a view subclass with

- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint locA = [self convertPoint:[theEvent locationInWindow] fromView:nil]; BOOL shiftPressed = (([theEvent modifierFlags] & NSShiftKeyMask) > 0);
   BOOL keepOn = YES;
   BOOL hasDragged = NO;

   while (keepOn)
     {
theEvent = [[self window] nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask];
      switch ([theEvent type])
        {
         case NSLeftMouseDragged:
           {
NSPoint locB = [self convertPoint:[theEvent locationInWindow] fromView:nil]; NSSize offset = NSMakeSize(locB.x - locA.x, locB.y - locA.y);
              NSRect oldRect = _selectionRect;
              _selectionRect.origin = locA;
              if (offset.width < 0)
                {
                 _selectionRect.origin.x = locB.x;
                 offset.width = -offset.width;
                }
              if (offset.height < 0)
                {
                 _selectionRect.origin.y = locB.y;
                 offset.height = -offset.height;
                }
              _selectionRect.size = offset;
              _selecting = YES;
[self setNeedsDisplayInRect:NSUnionRect(_selectionRect, oldRect)];
              hasDragged = YES;
           }
            break;

         case NSLeftMouseUp:
           {
              keepOn = NO;
           }
            break;

         default:
            break;
        }
     }
}

- (void)drawRect:(NSRect)rect
{
   [super drawRect:rect];
   if (_selecting)
     {
      [[NSColor grayColor] set];
      NSFrameRect(_selectionRect);
     }
}

This draws a rectangle following the mouse until the user releases the mouse button. On MacOSX the rectangle follows the mouse instantly. Under GNUstep I see a significant delay. Dragging rectangles makes no fun there. Any idea why this is so slow? This of course has nothing to do with rectangles in special but with slow drawing code in general. In my app I want to drag objects around with the mouse. This works under GNUstep and MacOX but on GNustep it is almost too slow to be usable. Is this a known (may be even already improved) issue? My GNUstep tree is already a year old. :-)

Thanks,

  Andreas






reply via email to

[Prev in Thread] Current Thread [Next in Thread]