mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
extend cocoa drawing test
Test app now draws 500 "meters" at random levels @ 50Hz.
This commit is contained in:
parent
d588b86e54
commit
bb19a59315
3 changed files with 55 additions and 28 deletions
|
|
@ -1,17 +1,38 @@
|
|||
/* -*- c++ -*- */
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "meter.h"
|
||||
#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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char* argv[])
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSRect rect = NSMakeRect (100, 100, 500, 500);
|
||||
NSRect frameRect = NSMakeRect (10, 10, 480, 480);
|
||||
NSRect rect = NSMakeRect (100, 100, 1800, 399);
|
||||
NSRect frameRect = NSMakeRect (0, 0, 1800, 399);
|
||||
|
||||
NSWindow* win = [[NSWindow alloc] initWithContentRect:rect
|
||||
styleMask:NSWindowStyleMaskClosable
|
||||
|
|
@ -20,28 +41,18 @@ main (int argc, char* argv[])
|
|||
|
||||
CTView* view = [[CTView alloc] initWithFrame:frameRect];
|
||||
|
||||
layout (view);
|
||||
|
||||
[win setContentView:view];
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps : YES ];
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
[win makeKeyAndOrderFront:win];
|
||||
|
||||
[NSRunLoop currentRunLoop];
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.1 target:view selector:@selector(timedUpdate) userInfo:nil repeats:YES];
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.02 target:view selector:@selector(timedUpdate) userInfo:nil repeats:YES];
|
||||
|
||||
[[NSApplication sharedApplication] run];
|
||||
|
||||
|
||||
[pool release];
|
||||
|
||||
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
|
||||
|
||||
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue