ardour/cocoatea/cocoatea.mm

64 lines
1.5 KiB
Text
Raw Normal View History

2024-11-14 14:55:44 -07:00
/* -*- c++ -*- */
#include <vector>
2024-11-14 14:55:44 -07:00
#include <AppKit/AppKit.h>
#include "meter.h"
2024-11-14 14:55:44 -07:00
#include "view.h"
std::vector<Meter*> meters;
void
layout (NSView* view)
{
double width = 10;
double height = 50;
double padding = 5;
for (int line = 0; line < 6; ++line) {
for (int n = 0; n < 100; ++n) {
double r = (random() % 255) / 256.;
double g = (random() % 255) / 256.;
double b = (random() % 255) / 256.;
meters.push_back (new Meter (view, n * (width + padding), line * (height + padding), width, height, r, g, b, 1.0));
}
}
}
2024-11-14 14:55:44 -07:00
int
main (int argc, char* argv[])
{
2024-11-15 17:54:14 -07:00
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSRect rect = NSMakeRect (100, 100, 1800, 399);
NSRect frameRect = NSMakeRect (0, 0, 1800, 399);
2024-11-14 14:55:44 -07:00
2024-11-19 12:20:26 -07:00
NSUInteger style_mask = (NSTitledWindowMask |
NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask);
2024-11-14 14:55:44 -07:00
NSWindow* win = [[NSWindow alloc] initWithContentRect:rect
2024-11-19 12:20:26 -07:00
styleMask:style_mask
2024-11-14 14:55:44 -07:00
backing:NSBackingStoreBuffered
defer:NO];
CTView* view = [[CTView alloc] initWithFrame:frameRect];
layout (view);
[view setWantsLayer:NO];
2024-11-14 14:55:44 -07:00
[win setContentView:view];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
2024-11-14 14:55:44 -07:00
[win makeKeyAndOrderFront:win];
[NSTimer scheduledTimerWithTimeInterval:0.02 target:view selector:@selector(timedUpdate) userInfo:nil repeats:YES];
2024-11-14 14:55:44 -07:00
[[NSApplication sharedApplication] run];
2024-11-15 17:54:14 -07:00
[pool release];
2024-11-14 14:55:44 -07:00
return 0;
}