NO-OP: whitespace
[ardour.git] / libs / gtkmm2ext / nsglview.mm
index 9f6ae629a1952f277ff376179ee14cda74cd9722..d2eace78da28b11ed90eb6f9bb6e18f8d7da226c 100644 (file)
 #include <OpenGL/gl.h>
 #import  <Cocoa/Cocoa.h>
 
+/* the gtk-quartz library which ardour links against
+ * is patched to pass events directly through to
+ * NSView child-views (AU Plugin GUIs).
+ *
+ * In this particular case however we do want the
+ * events to reach the GTK widget instead of the
+ * NSView subview.
+ *
+ * If a NSVIew tag equals to the given magic-number,
+ * Gdk events propagate.
+ */
 #ifndef ARDOUR_CANVAS_NSVIEW_TAG
-#define ARDOUR_CANVAS_NSVIEW_TAG 0xa2d0c2c4
+#define ARDOUR_CANVAS_NSVIEW_TAG 0x0
 #endif
 
 __attribute__ ((visibility ("hidden")))
@@ -44,6 +55,7 @@ __attribute__ ((visibility ("hidden")))
        int _height;
        Cairo::RefPtr<Cairo::ImageSurface> surf;
        Gtkmm2ext::CairoCanvas *cairo_canvas;
+       NSInteger _tag;
 }
 
 @property (readwrite) NSInteger tag;
@@ -52,6 +64,7 @@ __attribute__ ((visibility ("hidden")))
 - (void) dealloc;
 - (void) setCairoCanvas:(Gtkmm2ext::CairoCanvas*)c;
 - (void) reshape;
+- (void) setNeedsDisplayInRect:(NSRect)rect;
 - (void) drawRect:(NSRect)rect;
 - (BOOL) canBecomeKeyWindow:(id)sender;
 - (BOOL) acceptsFirstResponder:(id)sender;
@@ -164,6 +177,15 @@ __attribute__ ((visibility ("hidden")))
        _height = height;
 }
 
+- (void) setNeedsDisplayInRect:(NSRect)rect
+{
+       [super setNeedsDisplayInRect:rect];
+#ifdef DEBUG_NSVIEW_EXPOSURE
+       printf ("needsDisplay: %5.1f %5.1f   %5.1f %5.1f\n",
+                       rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+#endif
+}
+
 - (void) drawRect:(NSRect)rect
 {
        [[self openGLContext] makeCurrentContext];
@@ -205,6 +227,11 @@ __attribute__ ((visibility ("hidden")))
        }
        ctx->fill ();
 
+#ifdef DEBUG_NSVIEW_EXPOSURE
+       printf ("drawRect:     %.1f %.1f  %.1f %1.f\n",
+                       cairo_rect.x, cairo_rect.y, cairo_rect.width, cairo_rect.height);
+#endif
+
        cairo_canvas->render (ctx, &cairo_rect);
 
        surf->flush ();
@@ -246,6 +273,7 @@ __attribute__ ((visibility ("hidden")))
        glFlush();
        glSwapAPPLE();
        [NSOpenGLContext clearCurrentContext];
+       [super setNeedsDisplay:NO];
 }
 @end
 
@@ -253,6 +281,13 @@ __attribute__ ((visibility ("hidden")))
 void*
 Gtkmm2ext::nsglview_create (Gtkmm2ext::CairoCanvas* canvas)
 {
+/* the API is currently only used on intel mac
+ * for big-endian  RGBA <> RGBA byte order of the texture
+ * will have to be swapped.
+ */
+#ifdef __ppc__
+       return 0;
+#endif
        ArdourCanvasOpenGLView* gl_view = [ArdourCanvasOpenGLView new];
        if (!gl_view) {
                return 0;
@@ -282,6 +317,9 @@ Gtkmm2ext::nsglview_queue_draw (void* glv, int x, int y, int w, int h)
 {
        ArdourCanvasOpenGLView* gl_view = (ArdourCanvasOpenGLView*) glv;
        [gl_view setNeedsDisplayInRect:NSMakeRect(x, y, w, h)];
+#ifdef DEBUG_NSVIEW_EXPOSURE
+       printf ("Queue Draw    %5d %5d  %5d %5d\n", x, y, w, h);
+#endif
 }
 
 void