Tweaks to improve GUI

This commit is contained in:
Peter Rutenbar 2014-02-24 20:55:40 -05:00
parent 93cefd9451
commit 0d8fefed79
11 changed files with 122 additions and 89 deletions

4
README
View File

@ -36,7 +36,3 @@ To boot A/UX
3) xcodebuild -project gui/Shoebill.xcodeproj # to build the Cocoa GUI

View File

@ -1,4 +1,4 @@
Shoebill
========
a Macintosh II emulator that only runs A/UX
a Macintosh II emulator that runs A/UX

View File

@ -16,16 +16,12 @@
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>0.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Peter Rutenbar. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>

View File

@ -1,29 +1,13 @@
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
{\rtf1\ansi\ansicpg1252\cocoartf1265
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw9840\paperh8400
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\vieww9600\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\f0\b\fs24 \cf0 Engineering:
\f0\b\fs24 \cf0 Shoebill
\b0 \
Some people\
A Macintosh II emulator that runs A/UX\
\
\b Human Interface Design:
\b0 \
Some other people\
{\field{\*\fldinst{HYPERLINK "https://github.com/pruten/shoebill"}}{\fldrslt https://github.com/pruten/shoebill}}\
\
\b Testing:
\b0 \
Hopefully not nobody\
\
\b Documentation:
\b0 \
Whoever\
\
\b With special thanks to:
\b0 \
Mom\
}
Peter Rutenbar (pruten@gmail.com)}

View File

@ -27,10 +27,6 @@
@interface shoeAppDelegate : NSObject <NSApplicationDelegate> {
@public
NSWindowController *windowController;
}
@property (assign) IBOutlet NSWindow *window;
@end

View File

@ -28,11 +28,33 @@
@implementation shoeAppDelegate
- (void)createFirstTimeUserDefaults
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
uint32_t i;
[defaults setObject:@"" forKey:@"kernelPath"];
[defaults setObject:@"" forKey:@"romPath"];
[defaults setInteger:NSOffState forKey:@"verboseState"];
[defaults setInteger:16 forKey:@"memorySize"];
[defaults setInteger:640 forKey:@"screenWidth"];
[defaults setInteger:480 forKey:@"screenHeight"];
for (i=0; i<7; i++)
[defaults setObject:@"" forKey:[NSString stringWithFormat:@"scsiPath%u", i]];
[defaults setBool:YES forKey:@"defaultsInitialized"];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
/*windowController = [[NSWindowController alloc] initWithWindowNibName:@"shoeScreenView"];
[windowController showWindow:nil];
[windowController.window makeKeyAndOrderFront:nil];*/
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL isInitialized = [defaults boolForKey:@"defaultsInitialized"];
if (!isInitialized)
[self createFirstTimeUserDefaults];
}

View File

@ -165,7 +165,12 @@
if (type == NSFlagsChanged) {
NSUInteger modifierFlags = [event modifierFlags];
shoebill_key_modifier(modifierFlags >> 16);
return ;
// Block any key-related event while the command key is down
if (modifierFlags & NSCommandKeyMask)
return ;
[super sendEvent:event];
}
else if (type == NSKeyDown || type == NSKeyUp) {
NSString *chars = [[event charactersIgnoringModifiers] lowercaseString];
@ -183,7 +188,12 @@
}
return ;
// Block any key-related event while the command key is down
if (modifierFlags & NSCommandKeyMask)
return ;
[super sendEvent:event];
}
}
@ -280,6 +290,9 @@
- (void) startEmulator
{
if (isRunning)
return;
uint16_t width, height;
uint32_t i;
@ -310,7 +323,6 @@
- (IBAction)runMenuItem:(id)sender
{
[self startEmulator];
}

View File

@ -185,6 +185,7 @@
shoeApplication *shoeApp = (shoeApplication*) NSApp;
[self applyPressed:sender];
[shoeApp startEmulator];
[[self window] close];
}
@end

View File

@ -24,6 +24,7 @@
*/
#import "shoeScreenView.h"
#import "shoeScreenWindow.h"
#import "shoeAppDelegate.h"
#import "shoeApplication.h"
#import <Foundation/Foundation.h>
@ -198,21 +199,6 @@ static void _do_clut_translation(shoebill_card_video_t *ctx)
[[self openGLContext] flushBuffer];
}
- (void) warpToCenter
{
// Convert the cocoa window frame to quartz global coordinates
NSRect winrect = [[self window] frame];
NSScreen *mainScreen = (NSScreen*)[[NSScreen screens] objectAtIndex:0];
winrect.origin.y = NSMaxY([mainScreen frame]) - NSMaxY(winrect);
CGRect cgwinrect = NSRectToCGRect(winrect);
// Find the center of the window
cgwinrect.origin.x += cgwinrect.size.width / 2.0;
cgwinrect.origin.y += cgwinrect.size.height / 2.0;
CGWarpMouseCursorPosition(cgwinrect.origin);
}
- (void)viewDidMoveToWindow
{
[[self window] setAcceptsMouseMovedEvents:YES];
@ -229,22 +215,14 @@ static void _do_clut_translation(shoebill_card_video_t *ctx)
- (void)mouseMoved:(NSEvent *)theEvent
{
if (shoeApp->doCaptureMouse) {
shoeScreenWindow *win = (shoeScreenWindow*)[self window];
assert(shoeApp->isRunning);
//NSPoint point = [theEvent locationInWindow];
//NSPoint point = [self convertPoint:windowPoint fromView:self];
/*NSRect winFrame = [[self window] frame];
NSPoint winCenter;
winCenter.x = winFrame.size.width / 2.0;
winCenter.y = winFrame.size.height / 2.0;*/
/*int32_t delta_x = (int32_t)(point.x - winCenter.x);
int32_t delta_y = -(int32_t)(point.y - winCenter.y);*/
int32_t delta_x, delta_y;
CGGetLastMouseDelta(&delta_x, &delta_y);
shoebill_mouse_move_delta(delta_x, delta_y);
[self warpToCenter];
[win warpToCenter];
}
}
@ -253,7 +231,7 @@ static void _do_clut_translation(shoebill_card_video_t *ctx)
[self mouseMoved:theEvent];
}
- (void) say:(NSString*)str
/*- (void) say:(NSString*)str
{
NSAlert *theAlert = [NSAlert
alertWithMessageText:nil
@ -263,21 +241,31 @@ static void _do_clut_translation(shoebill_card_video_t *ctx)
informativeTextWithFormat:@"%@", str
];
[theAlert runModal];
}
}*/
- (void)mouseDown:(NSEvent *)theEvent
{
if (shoeApp->doCaptureMouse) {
assert(shoeApp->isRunning);
shoebill_mouse_click(1);
// Warp experiment
//[self say:[NSString stringWithFormat:@"view origin x=%f, y=%f, window origin x=%f, y=%f", rect.origin.x, rect.origin.y, winrect.origin.x, winrect.origin.y]];
// ctrl - left click doesn't get reported as rightMouseDown
// on Mavericks (and maybe other OS X versions?)
if ([theEvent modifierFlags] & NSControlKeyMask) {
shoeScreenWindow *win = (shoeScreenWindow*)[self window];
[win uncaptureMouse];
}
else
shoebill_mouse_click(1);
}
else {
shoeScreenWindow *win = (shoeScreenWindow*)[self window];
if ([win isKeyWindow]) {
shoeApp->doCaptureKeys = YES;
[win captureMouse];
}
}
}
- (void)mouseUp:(NSEvent *)theEvent
@ -288,4 +276,12 @@ static void _do_clut_translation(shoebill_card_video_t *ctx)
}
}
- (void)rightMouseDown:(NSEvent *)theEvent
{
if (shoeApp->doCaptureMouse) {
shoeScreenWindow *win = (shoeScreenWindow*)[self window];
[win uncaptureMouse];
}
}
@end

View File

@ -31,6 +31,9 @@
uint8_t slotnum;
}
- (void)configure:(uint8_t) _slotnum;
- (void)reevaluateKeyWindowness;
- (void) configure:(uint8_t) _slotnum;
- (void) reevaluateKeyWindowness;
- (void) warpToCenter;
- (void) captureMouse;
- (void) uncaptureMouse;
@end

View File

@ -45,13 +45,10 @@
if ([self isKeyWindow]) {
shoeApp->doCaptureKeys = YES;
shoeApp->doCaptureMouse = YES;
CGDisplayHideCursor(0);
}
else {
shoeApp->doCaptureKeys = NO;
shoeApp->doCaptureMouse = NO;
CGDisplayShowCursor(0);
[self uncaptureMouse];
}
}
@ -61,9 +58,8 @@
if (shoeApp->isRunning) {
shoeApp->doCaptureKeys = YES;
shoeApp->doCaptureMouse = YES;
CGDisplayHideCursor(0);
}
[super becomeKeyWindow];
}
@ -73,11 +69,42 @@
if (shoeApp->isRunning) {
shoeApp->doCaptureKeys = NO;
shoeApp->doCaptureMouse = NO;
CGDisplayShowCursor(0);
[self uncaptureMouse];
}
[super resignKeyWindow];
}
- (void) warpToCenter
{
// Convert the cocoa window frame to quartz global coordinates
NSRect winrect = [self frame];
NSScreen *mainScreen = (NSScreen*)[[NSScreen screens] objectAtIndex:0];
winrect.origin.y = NSMaxY([mainScreen frame]) - NSMaxY(winrect);
CGRect cgwinrect = NSRectToCGRect(winrect);
// Find the center of the window
cgwinrect.origin.x += cgwinrect.size.width / 2.0;
cgwinrect.origin.y += cgwinrect.size.height / 2.0;
CGWarpMouseCursorPosition(cgwinrect.origin);
}
- (void) uncaptureMouse
{
shoeApplication *shoeApp = (shoeApplication*)NSApp;
shoeApp->doCaptureMouse = NO;
CGDisplayShowCursor(0);
[self setTitle:@"Shoebill - Screen 1"];
}
- (void) captureMouse
{
shoeApplication *shoeApp = (shoeApplication*)NSApp;
shoeApp->doCaptureMouse = YES;
CGDisplayHideCursor(0);
[self warpToCenter];
[self setTitle:@"Shoebill - Screen 1 (Ctrl-click to escape)"];
}
@end