From 9f9ef1b180e1a75808d2977594b22f79da63828a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 14 Nov 2024 14:55:44 -0700 Subject: [PATCH] skeleton for cocoa standalone tester --- cocoatea/cocatea.mm | 7 ++++++ cocoatea/cocoatea.mm | 42 +++++++++++++++++++++++++++++++++++ cocoatea/view.h | 8 +++++++ cocoatea/view.mm | 53 ++++++++++++++++++++++++++++++++++++++++++++ cocoatea/wscript | 32 ++++++++++++++++++++++++++ wscript | 1 + 6 files changed, 143 insertions(+) create mode 100644 cocoatea/cocatea.mm create mode 100644 cocoatea/cocoatea.mm create mode 100644 cocoatea/view.h create mode 100644 cocoatea/view.mm create mode 100644 cocoatea/wscript diff --git a/cocoatea/cocatea.mm b/cocoatea/cocatea.mm new file mode 100644 index 0000000000..fef5e938a1 --- /dev/null +++ b/cocoatea/cocatea.mm @@ -0,0 +1,7 @@ +#include + +int +main (int argc, char* argv[]) +{ + [NSApplication sharedApplication]; +} diff --git a/cocoatea/cocoatea.mm b/cocoatea/cocoatea.mm new file mode 100644 index 0000000000..6b230b7c9d --- /dev/null +++ b/cocoatea/cocoatea.mm @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ + +#include + +#include "view.h" + + +int +main (int argc, char* argv[]) +{ + NSRect rect = NSMakeRect (100, 100, 500, 500); + NSRect frameRect = NSMakeRect (10, 10, 480, 480); + + NSWindow* win = [[NSWindow alloc] initWithContentRect:rect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + + CTView* view = [[CTView alloc] initWithFrame:frameRect]; + + [win setContentView:view]; + [[NSApplication sharedApplication] activateIgnoringOtherApps : YES ]; + [win makeKeyAndOrderFront:win]; + + NSRunLoop *runloop = [NSRunLoop currentRunLoop]; + NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:view selector:@selector(timedUpdate) userInfo:nil repeats:YES]; + + [[NSApplication sharedApplication] run]; + + return 0; +} + + +/* + + 1, derive a new View type that will have our drawing methods + 2. add time to the run loop to trigger redraws + + figure out how to draw + + + */ diff --git a/cocoatea/view.h b/cocoatea/view.h new file mode 100644 index 0000000000..4fdfe09bad --- /dev/null +++ b/cocoatea/view.h @@ -0,0 +1,8 @@ +#include + +@interface CTView : NSView +{ + +} + +@end diff --git a/cocoatea/view.mm b/cocoatea/view.mm new file mode 100644 index 0000000000..880e5c7098 --- /dev/null +++ b/cocoatea/view.mm @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +#include +#include "view.h" + +@implementation CTView + +-(BOOL)acceptsFirstResponder +{ + printf ("acceptsFirstResponder\n"); + return YES; +} + +-(void) timedUpdate +{ + printf ("ping\n"); + [self setNeedsDisplay:TRUE]; +} + +-(BOOL)becomeFirstResponder +{ + printf ("becomeFirstResponder\n"); + return YES; +} + +-(BOOL)resignFirstResponder +{ + printf ("resignFirstResponder\n"); + return YES; +} + +-(void) keyDown: (NSEvent *) theEvent +{ + printf ("keyDown\n"); + [self interpretKeyEvents: [NSArray arrayWithObject: theEvent]]; +} + +-(void)noop: (id)sender +{ + printf ("noop\n"); +} + +-(BOOL)isFlipped +{ + return YES; +} + +-(void)drawRect: (NSRect)rect +{ + printf ("here we are!\n"); +} + +@end + diff --git a/cocoatea/wscript b/cocoatea/wscript new file mode 100644 index 0000000000..1a9c72315f --- /dev/null +++ b/cocoatea/wscript @@ -0,0 +1,32 @@ +#!/usr/bin/env python +import os +import sys + +cocoatea_sources = [ + 'cocoatea.mm', + 'view.mm' +] + +def options(opt): + pass + +def configure(conf): + pass + +def build(bld): + # just the normal executable version of the GTK GUI + obj = bld (features = 'cxx c cxxprogram') + # this program does not do the whole hidden symbols thing + obj.cxxflags = [ '-fvisibility=default' ] + obj.source = cocoatea_sources + obj.target = 'cocoatea' + obj.includes = ['.'] + obj.use = [] + + obj.defines = [ + 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', + 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', + ] + obj.install_path = bld.env['LIBDIR'] + obj.uselib = 'OSX' + diff --git a/wscript b/wscript index 44702d2e9b..194d96877c 100644 --- a/wscript +++ b/wscript @@ -387,6 +387,7 @@ children = [ 'headless', 'luasession', 'session_utils', + 'cocoatea', # shared helper binaries (plugin-scanner, exec-wrapper) 'libs/fst', 'libs/vfork',