mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-24 11:41:30 +11:00
Mac fixes
* Removed resizing of window as that isn't supported * Fixed issue that content view would be too small and top of window wouldn't be visible * Removed some code that isn't needed Bump lib version to 0.2.3
This commit is contained in:
parent
3f1b8e244a
commit
d6cbb705c1
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "minifb"
|
name = "minifb"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Daniel Collin <daniel@collin.com>"]
|
authors = ["Daniel Collin <daniel@collin.com>"]
|
||||||
description = "Cross-platform window setup for bitmap rendering"
|
description = "Cross-platform window setup for bitmap rendering"
|
||||||
|
|
|
@ -18,9 +18,9 @@ void* mfb_open(const char* name, int width, int height, int scale)
|
||||||
s_init = true;
|
s_init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int styles = NSResizableWindowMask | NSClosableWindowMask | NSTitledWindowMask;
|
unsigned int styles = NSClosableWindowMask | NSTitledWindowMask;
|
||||||
|
NSRect rectangle = NSMakeRect(0, 0, width * scale, (height * scale));
|
||||||
|
|
||||||
NSRect rectangle = NSMakeRect(0, 0, width * scale, height * scale);
|
|
||||||
OSXWindow* window = [[OSXWindow alloc] initWithContentRect:rectangle styleMask:styles backing:NSBackingStoreBuffered defer:NO];
|
OSXWindow* window = [[OSXWindow alloc] initWithContentRect:rectangle styleMask:styles backing:NSBackingStoreBuffered defer:NO];
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
|
|
|
@ -5,38 +5,6 @@
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
- (id)initWithContentRect:(NSRect)contentRect
|
|
||||||
styleMask:(NSUInteger)windowStyle
|
|
||||||
backing:(NSBackingStoreType)bufferingType
|
|
||||||
defer:(BOOL)deferCreation
|
|
||||||
{
|
|
||||||
self = [super
|
|
||||||
initWithContentRect:contentRect
|
|
||||||
styleMask:windowStyle
|
|
||||||
backing:bufferingType
|
|
||||||
defer:deferCreation];
|
|
||||||
if (self)
|
|
||||||
{
|
|
||||||
[self setOpaque:YES];
|
|
||||||
[self setBackgroundColor:[NSColor clearColor]];
|
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
addObserver:self
|
|
||||||
selector:@selector(mainWindowChanged:)
|
|
||||||
name:NSWindowDidBecomeMainNotification
|
|
||||||
object:self];
|
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
addObserver:self
|
|
||||||
selector:@selector(mainWindowChanged:)
|
|
||||||
name:NSWindowDidResignMainNotification
|
|
||||||
object:self];
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
@ -142,9 +110,7 @@
|
||||||
- (void)setContentView:(NSView *)aView
|
- (void)setContentView:(NSView *)aView
|
||||||
{
|
{
|
||||||
if ([childContentView isEqualTo:aView])
|
if ([childContentView isEqualTo:aView])
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
NSRect bounds = [self frame];
|
NSRect bounds = [self frame];
|
||||||
bounds.origin = NSZeroPoint;
|
bounds.origin = NSZeroPoint;
|
||||||
|
@ -163,6 +129,8 @@
|
||||||
if (childContentView)
|
if (childContentView)
|
||||||
[childContentView removeFromSuperview];
|
[childContentView removeFromSuperview];
|
||||||
|
|
||||||
|
NSRect t = [self contentRectForFrameRect:bounds];
|
||||||
|
|
||||||
childContentView = aView;
|
childContentView = aView;
|
||||||
[childContentView setFrame:[self contentRectForFrameRect:bounds]];
|
[childContentView setFrame:[self contentRectForFrameRect:bounds]];
|
||||||
[childContentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[childContentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
@ -200,13 +168,6 @@
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
+ (NSRect)frameRectForContentRect:(NSRect)windowContentRect styleMask:(NSUInteger)windowStyle
|
|
||||||
{
|
|
||||||
return NSInsetRect(windowContentRect, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
- (void)updateSize
|
- (void)updateSize
|
||||||
{
|
{
|
||||||
OSXWindowFrameView* frameView = [super contentView];
|
OSXWindowFrameView* frameView = [super contentView];
|
||||||
|
|
|
@ -4,23 +4,6 @@
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
- (NSRect)resizeRect
|
|
||||||
{
|
|
||||||
const CGFloat resizeBoxSize = 16.0;
|
|
||||||
const CGFloat contentViewPadding = 5.5;
|
|
||||||
|
|
||||||
NSRect contentViewRect = [[self window] contentRectForFrameRect:[[self window] frame]];
|
|
||||||
NSRect resizeRect = NSMakeRect(
|
|
||||||
NSMaxX(contentViewRect) + contentViewPadding,
|
|
||||||
NSMinY(contentViewRect) - resizeBoxSize - contentViewPadding,
|
|
||||||
resizeBoxSize,
|
|
||||||
resizeBoxSize);
|
|
||||||
|
|
||||||
return resizeRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void)drawRect:(NSRect)rect
|
||||||
{
|
{
|
||||||
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
|
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
|
||||||
|
|
Loading…
Reference in a new issue