mirror of https://github.com/bsnes-emu/bsnes.git
More macOS Cocoa improvements.
This commit is contained in:
parent
cdf4784468
commit
4d2244ed5f
|
@ -294,6 +294,13 @@ auto Program::reset() -> void {
|
|||
|
||||
auto Program::unload() -> void {
|
||||
if(!emulator->loaded()) return;
|
||||
//todo: video.clear() is not working on macOS/OpenGL 3.2
|
||||
if(auto [output, length] = video.acquire(1, 1); output) {
|
||||
*output = 0;
|
||||
video.release();
|
||||
video.output();
|
||||
}
|
||||
audio.clear();
|
||||
rewindReset(); //free up memory that is no longer needed
|
||||
movieStop(); //in case a movie is currently being played or recorded
|
||||
cheatEditor.saveCheats();
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
menuRadioItem = &menuRadioItemReference;
|
||||
|
||||
[self setTarget:self];
|
||||
[self setOnStateImage:[NSImage imageNamed:@"NSMenuRadio"]];
|
||||
//todo: the default image is a check mark, which is not indicative of radio states.
|
||||
//however, NSMenuRadio does not respect macOS' dark theme, and is barely visible.
|
||||
//[self setOnStateImage:[NSImage imageNamed:@"NSMenuRadio"]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ auto NSMakeColor(const hiro::Color& color) -> NSColor* {
|
|||
}
|
||||
|
||||
auto NSMakeCursor(const hiro::MouseCursor& mouseCursor) -> NSCursor* {
|
||||
if(mouseCursor == MouseCursor::Hand) return [NSCursor pointingHandCursor];
|
||||
if(mouseCursor == MouseCursor::HorizontalResize) return [NSCursor resizeLeftRightCursor];
|
||||
if(mouseCursor == MouseCursor::VerticalResize) return [NSCursor resizeUpDownCursor];
|
||||
if(mouseCursor == hiro::MouseCursor::Hand) return [NSCursor pointingHandCursor];
|
||||
if(mouseCursor == hiro::MouseCursor::HorizontalResize) return [NSCursor resizeLeftRightCursor];
|
||||
if(mouseCursor == hiro::MouseCursor::VerticalResize) return [NSCursor resizeUpDownCursor];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
}
|
||||
|
||||
-(void) resetCursorRects {
|
||||
if(auto mouseCursor = NSMakeCursor(label->mouseCursor())) {
|
||||
if(auto mouseCursor = NSMakeCursor(canvas->mouseCursor())) {
|
||||
[self addCursorRect:self.bounds cursor:mouseCursor];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,10 @@
|
|||
}
|
||||
|
||||
-(void) drawRect:(NSRect)dirtyRect {
|
||||
auto geometry = label->geometry();
|
||||
NSRect rect = {{geometry.x(), geometry.y()}, {geometry.width(), geometry.height()}};
|
||||
|
||||
if(auto backgroundColor = label->backgroundColor()) {
|
||||
NSColor* color = NSMakeColor(backgroundColor);
|
||||
[color setFill];
|
||||
NSRectFill(rect);
|
||||
NSRectFill(dirtyRect);
|
||||
}
|
||||
|
||||
NSFont* font = hiro::pFont::create(label->font(true));
|
||||
|
@ -43,6 +40,8 @@
|
|||
auto alignment = label->alignment();
|
||||
if(!alignment) alignment = {0.0, 0.5};
|
||||
|
||||
auto geometry = label->geometry();
|
||||
NSRect rect = {{geometry.x(), geometry.y()}, {geometry.width(), geometry.height()}};
|
||||
rect.origin.x = max(0, (geometry.width() - size.width()) * alignment.horizontal());
|
||||
rect.origin.y = max(0, (geometry.height() - size.height()) * alignment.vertical());
|
||||
rect.size.width = min(geometry.width(), size.width());
|
||||
|
@ -128,8 +127,8 @@ auto pLabel::construct() -> void {
|
|||
pWidget::construct();
|
||||
|
||||
setAlignment(state().alignment);
|
||||
setBackgroundColor(state().backgroundColor());
|
||||
setForegroundColor(state().foregroundColor());
|
||||
setBackgroundColor(state().backgroundColor);
|
||||
setForegroundColor(state().foregroundColor);
|
||||
setText(state().text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
}
|
||||
|
||||
-(void) resetCursorRects {
|
||||
if(auto mouseCursor = NSMakeCursor(label->mouseCursor())) {
|
||||
if(auto mouseCursor = NSMakeCursor(viewport->mouseCursor())) {
|
||||
[self addCursorRect:self.bounds cursor:mouseCursor];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,11 @@ template<typename... P> inline auto invoke(const string& name, P&&... p) -> void
|
|||
*argp++ = nullptr;
|
||||
|
||||
if(execvp(name, (char* const*)argv) < 0) {
|
||||
#if defined(PLATFORM_MACOS)
|
||||
execlp("open", "open", (const char*)name, nullptr);
|
||||
#else
|
||||
execlp("xdg-open", "xdg-open", (const char*)name, nullptr);
|
||||
#endif
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue