mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
Refactoring
This commit is contained in:
parent
fbd35ac6a8
commit
f82241b56f
@ -25,18 +25,13 @@ void ebiten_WindowClosed(void* nativeWindow);
|
||||
styleMask:style];
|
||||
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
||||
NSSize screenSize = [screen visibleFrame].size;
|
||||
// Reference: Mac OS X Human Interface Guidelines: UI Element Guidelines:
|
||||
// Windows
|
||||
// http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html
|
||||
NSRect contentRect =
|
||||
NSMakeRect((screenSize.width - windowRect.size.width) / 2,
|
||||
(screenSize.height - windowRect.size.height) * 2 / 3,
|
||||
size.width, size.height);
|
||||
NSRect contentRect = NSMakeRect(0, 0, size.width, size.height);
|
||||
self = [super initWithContentRect:contentRect
|
||||
styleMask:style
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
if (self != nil) {
|
||||
[self center];
|
||||
[self setReleasedWhenClosed:YES];
|
||||
[self setDelegate:self];
|
||||
[self setDocumentEdited:YES];
|
||||
|
@ -10,12 +10,16 @@ void initMenu(void) {
|
||||
|
||||
NSMenu* menuBar = [NSMenu new];
|
||||
[NSApp setMainMenu: menuBar];
|
||||
[menuBar release];
|
||||
|
||||
NSMenuItem* rootMenuItem = [NSMenuItem new];
|
||||
[menuBar addItem:rootMenuItem];
|
||||
[rootMenuItem release];
|
||||
|
||||
NSMenu* appMenu = [NSMenu new];
|
||||
[rootMenuItem setSubmenu:appMenu];
|
||||
[appMenu release];
|
||||
|
||||
[appMenu addItemWithTitle:[@"Quit " stringByAppendingString:processName]
|
||||
action:@selector(performClose:)
|
||||
keyEquivalent:@"q"];
|
||||
@ -49,21 +53,19 @@ void* CreateGLContext(void* sharedGLContext) {
|
||||
|
||||
void* CreateWindow(size_t width, size_t height, const char* title, void* glContext_) {
|
||||
NSOpenGLContext* glContext = (NSOpenGLContext*)glContext_;
|
||||
|
||||
NSSize size = NSMakeSize(width, height);
|
||||
EbitenWindow* window = [[EbitenWindow alloc]
|
||||
initWithSize:size
|
||||
glContext:glContext];
|
||||
[glContext release];
|
||||
|
||||
NSString* nsTitle = [[NSString alloc]
|
||||
initWithUTF8String:title];
|
||||
[window setTitle: nsTitle];
|
||||
[nsTitle release];
|
||||
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
|
||||
[glContext setView:[window contentView]];
|
||||
[glContext release];
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user