mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-09 02:36:32 +02:00
Update to v096r01 release.
byuu says: Changelog: - restructured the project and removed a whole bunch of old/dead directives from higan/GNUmakefile - huge amounts of work on hiro/cocoa (compiles but ~70% of the functionality is commented out) - fixed a masking error in my ARM CPU disassembler [Lioncash] - SFC: decided to change board cic=(411,413) back to board region=(ntsc,pal) ... the former was too obtuse If you rename Boolean (it's a problem with an include from ruby, not from hiro) and disable all the ruby drivers, you can compile an OS X binary, but obviously it's not going to do anything. It's a boring WIP, I just wanted to push out the project structure change now at the start of this WIP cycle.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#if defined(Hiro_Window)
|
||||
|
||||
@implementation CocoaWindow : NSWindow
|
||||
|
||||
-(id) initWith:(phoenix::Window&)windowReference {
|
||||
-(id) initWith:(hiro::mWindow&)windowReference {
|
||||
window = &windowReference;
|
||||
|
||||
NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
|
||||
@@ -15,7 +17,7 @@
|
||||
NSBundle* bundle = [NSBundle mainBundle];
|
||||
NSDictionary* dictionary = [bundle infoDictionary];
|
||||
NSString* applicationName = [dictionary objectForKey:@"CFBundleDisplayName"];
|
||||
if(applicationName == nil) applicationName = [NSString stringWithUTF8String:phoenix::applicationState.name];
|
||||
if(applicationName == nil) applicationName = [NSString stringWithUTF8String:hiro::Application::state.name];
|
||||
|
||||
menuBar = [[NSMenu alloc] init];
|
||||
|
||||
@@ -85,21 +87,21 @@
|
||||
}
|
||||
|
||||
-(void) windowDidBecomeMain:(NSNotification*)notification {
|
||||
if(window->state.menu.size() > 0) {
|
||||
if(window->state.menuBar) {
|
||||
[NSApp setMainMenu:menuBar];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) windowDidMove:(NSNotification*)notification {
|
||||
window->p.moveEvent();
|
||||
if(auto p = window->self()) p->moveEvent();
|
||||
}
|
||||
|
||||
-(void) windowDidResize:(NSNotification*)notification {
|
||||
window->p.sizeEvent();
|
||||
if(auto p = window->self()) p->sizeEvent();
|
||||
}
|
||||
|
||||
-(BOOL) windowShouldClose:(id)sender {
|
||||
if(window->onClose) window->onClose();
|
||||
if(window->state.onClose) window->doClose();
|
||||
else window->setVisible(false);
|
||||
if(window->state.modal && !window->visible()) window->setModal(false);
|
||||
return NO;
|
||||
@@ -112,7 +114,7 @@
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
if(paths.empty()) return NO;
|
||||
if(window->onDrop) window->onDrop(paths);
|
||||
window->doDrop(paths);
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -121,18 +123,15 @@
|
||||
}
|
||||
|
||||
-(void) menuAbout {
|
||||
using phoenix::Application;
|
||||
if(Application::Cocoa::onAbout) Application::Cocoa::onAbout();
|
||||
hiro::Application::Cocoa::doAbout();
|
||||
}
|
||||
|
||||
-(void) menuPreferences {
|
||||
using phoenix::Application;
|
||||
if(Application::Cocoa::onPreferences) Application::Cocoa::onPreferences();
|
||||
hiro::Application::Cocoa::doPreferences();
|
||||
}
|
||||
|
||||
-(void) menuQuit {
|
||||
using phoenix::Application;
|
||||
if(Application::Cocoa::onQuit) Application::Cocoa::onQuit();
|
||||
hiro::Application::Cocoa::doQuit();
|
||||
}
|
||||
|
||||
-(NSTextField*) statusBar {
|
||||
@@ -141,95 +140,101 @@
|
||||
|
||||
@end
|
||||
|
||||
namespace phoenix {
|
||||
namespace hiro {
|
||||
|
||||
Window& pWindow::none() {
|
||||
auto pWindow::none() -> Window& {
|
||||
static Window* window = nullptr;
|
||||
if(window == nullptr) window = new Window;
|
||||
return *window;
|
||||
}
|
||||
|
||||
void pWindow::append(Layout& layout) {
|
||||
Geometry geometry = window.state.geometry;
|
||||
geometry.x = geometry.y = 0;
|
||||
layout.setGeometry(geometry);
|
||||
auto pWindow::construct() -> void {
|
||||
@autoreleasepool {
|
||||
cocoaWindow = [[CocoaWindow alloc] initWith:self()];
|
||||
}
|
||||
}
|
||||
|
||||
auto pWindow::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaWindow release];
|
||||
}
|
||||
}
|
||||
|
||||
auto pWindow::append(sLayout layout) -> void {
|
||||
layout->setGeometry(self().geometry().setPosition(0, 0));
|
||||
statusBarReposition();
|
||||
}
|
||||
|
||||
void pWindow::append(Menu& menu) {
|
||||
auto pWindow::append(sMenuBar menuBar) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow menuBar] addItem:menu.p.cocoaAction];
|
||||
// [[cocoaWindow menuBar] addItem:menu.p.cocoaAction];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::append(Widget& widget) {
|
||||
if(widget.font().empty() && !window.state.widgetFont.empty()) {
|
||||
widget.setFont(window.state.widgetFont);
|
||||
}
|
||||
|
||||
@autoreleasepool {
|
||||
[widget.p.cocoaView removeFromSuperview];
|
||||
[[cocoaWindow contentView] addSubview:widget.p.cocoaView positioned:NSWindowAbove relativeTo:nil];
|
||||
widget.p.setGeometry(widget.geometry());
|
||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
auto pWindow::append(sStatusBar statusBar) -> void {
|
||||
}
|
||||
|
||||
bool pWindow::focused() {
|
||||
auto pWindow::focused() const -> bool {
|
||||
@autoreleasepool {
|
||||
return [cocoaWindow isMainWindow] == YES;
|
||||
}
|
||||
}
|
||||
|
||||
Geometry pWindow::frameMargin() {
|
||||
auto pWindow::frameMargin() const -> Geometry {
|
||||
@autoreleasepool {
|
||||
NSRect frame = [cocoaWindow frameRectForContentRect:NSMakeRect(0, 0, 640, 480)];
|
||||
return {abs(frame.origin.x), frame.size.height - 480, frame.size.width - 640, abs(frame.origin.y)};
|
||||
return {abs(frame.origin.x), (int)(frame.size.height - 480), (int)(frame.size.width - 640), abs(frame.origin.y)};
|
||||
}
|
||||
}
|
||||
|
||||
Geometry pWindow::geometry() {
|
||||
/*
|
||||
auto pWindow::geometry() -> Geometry {
|
||||
@autoreleasepool {
|
||||
NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]];
|
||||
area.size.height -= statusBarHeight();
|
||||
return {area.origin.x, Desktop::size().height - area.origin.y - area.size.height, area.size.width, area.size.height};
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void pWindow::remove(Layout& layout) {
|
||||
auto pWindow::remove(sLayout layout) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::remove(Menu& menu) {
|
||||
auto pWindow::remove(sMenuBar menuBar) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow menuBar] removeItem:menu.p.cocoaAction];
|
||||
// [[cocoaWindow menuBar] removeItem:menu.p.cocoaAction];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::remove(Widget& widget) {
|
||||
auto pWindow::remove(sStatusBar statusBar) -> void {
|
||||
}
|
||||
|
||||
/*
|
||||
auto pWindow::remove(Widget& widget) -> void {
|
||||
@autoreleasepool {
|
||||
[widget.p.cocoaView removeFromSuperview];
|
||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void pWindow::setBackgroundColor(Color color) {
|
||||
auto pWindow::setBackgroundColor(Color color) -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaWindow
|
||||
setBackgroundColor:[NSColor
|
||||
colorWithCalibratedRed:color.red / 255.0
|
||||
green:color.green / 255.0
|
||||
blue:color.blue / 255.0
|
||||
alpha:color.alpha / 255.0
|
||||
colorWithCalibratedRed:color.red() / 255.0
|
||||
green:color.green() / 255.0
|
||||
blue:color.blue() / 255.0
|
||||
alpha:color.alpha() / 255.0
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setDroppable(bool droppable) {
|
||||
auto pWindow::setDroppable(bool droppable) -> void {
|
||||
@autoreleasepool {
|
||||
if(droppable) {
|
||||
[cocoaWindow registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
|
||||
@@ -239,13 +244,13 @@ void pWindow::setDroppable(bool droppable) {
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setFocused() {
|
||||
auto pWindow::setFocused() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaWindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setFullScreen(bool fullScreen) {
|
||||
auto pWindow::setFullScreen(bool fullScreen) -> void {
|
||||
@autoreleasepool {
|
||||
if(fullScreen == true) {
|
||||
[NSApp setPresentationOptions:NSApplicationPresentationFullScreen];
|
||||
@@ -259,39 +264,31 @@ void pWindow::setFullScreen(bool fullScreen) {
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setGeometry(Geometry geometry) {
|
||||
locked = true;
|
||||
auto pWindow::setGeometry(Geometry geometry) -> void {
|
||||
lock();
|
||||
|
||||
@autoreleasepool {
|
||||
[cocoaWindow
|
||||
setFrame:[cocoaWindow
|
||||
frameRectForContentRect:NSMakeRect(
|
||||
geometry.x, Desktop::size().height - geometry.y - geometry.height,
|
||||
geometry.width, geometry.height + statusBarHeight()
|
||||
geometry.x(), Desktop::size().height() - geometry.y() - geometry.height(),
|
||||
geometry.width(), geometry.height() + statusBarHeight()
|
||||
)
|
||||
]
|
||||
display:YES
|
||||
];
|
||||
|
||||
for(auto& layout : window.state.layout) {
|
||||
Geometry geometry = this->geometry();
|
||||
geometry.x = geometry.y = 0;
|
||||
layout.setGeometry(geometry);
|
||||
if(auto& layout = state().layout) {
|
||||
layout->setGeometry(self().geometry().setPosition(0, 0));
|
||||
}
|
||||
|
||||
statusBarReposition();
|
||||
}
|
||||
|
||||
locked = false;
|
||||
unlock();
|
||||
}
|
||||
|
||||
void pWindow::setMenuFont(string font) {
|
||||
}
|
||||
|
||||
void pWindow::setMenuVisible(bool visible) {
|
||||
}
|
||||
|
||||
void pWindow::setModal(bool modal) {
|
||||
auto pWindow::setModal(bool modal) -> void {
|
||||
@autoreleasepool {
|
||||
if(modal == true) {
|
||||
[NSApp runModalForWindow:cocoaWindow];
|
||||
@@ -303,7 +300,7 @@ void pWindow::setModal(bool modal) {
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setResizable(bool resizable) {
|
||||
auto pWindow::setResizable(bool resizable) -> void {
|
||||
@autoreleasepool {
|
||||
NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
|
||||
if(resizable) style |= NSResizableWindowMask;
|
||||
@@ -311,100 +308,80 @@ void pWindow::setResizable(bool resizable) {
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setStatusFont(string font) {
|
||||
/*
|
||||
auto pWindow::setStatusFont(string font) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow statusBar] setFont:pFont::cocoaFont(font)];
|
||||
}
|
||||
statusBarReposition();
|
||||
}
|
||||
|
||||
void pWindow::setStatusText(string text) {
|
||||
auto pWindow::setStatusText(string text) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow statusBar] setStringValue:[NSString stringWithUTF8String:text]];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setStatusVisible(bool visible) {
|
||||
auto pWindow::setStatusVisible(bool visible) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaWindow statusBar] setHidden:!visible];
|
||||
setGeometry(geometry());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void pWindow::setTitle(string text) {
|
||||
auto pWindow::setTitle(const string& text) -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaWindow setTitle:[NSString stringWithUTF8String:text]];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setVisible(bool visible) {
|
||||
auto pWindow::setVisible(bool visible) -> void {
|
||||
@autoreleasepool {
|
||||
if(visible) [cocoaWindow makeKeyAndOrderFront:nil];
|
||||
else [cocoaWindow orderOut:nil];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::setWidgetFont(string font) {
|
||||
auto pWindow::moveEvent() -> void {
|
||||
if(!locked() && !self().fullScreen() && self().visible()) {
|
||||
@autoreleasepool {
|
||||
NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]];
|
||||
area.size.height -= statusBarHeight();
|
||||
state().geometry.setX(area.origin.x);
|
||||
state().geometry.setY(Desktop::size().height() - area.origin.y - area.size.height);
|
||||
}
|
||||
}
|
||||
|
||||
if(!locked()) self().doMove();
|
||||
}
|
||||
|
||||
void pWindow::constructor() {
|
||||
@autoreleasepool {
|
||||
cocoaWindow = [[CocoaWindow alloc] initWith:window];
|
||||
|
||||
NSColor* color = [[cocoaWindow backgroundColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||
window.state.backgroundColor = Color(
|
||||
(uint8_t)(255 * [color redComponent]),
|
||||
(uint8_t)(255 * [color greenComponent]),
|
||||
(uint8_t)(255 * [color blueComponent]),
|
||||
(uint8_t)(255 * [color alphaComponent])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::destructor() {
|
||||
@autoreleasepool {
|
||||
[cocoaWindow release];
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::moveEvent() {
|
||||
if(locked == false && window.fullScreen() == false && window.visible() == true) {
|
||||
Geometry geometry = this->geometry();
|
||||
window.state.geometry.x = geometry.x;
|
||||
window.state.geometry.y = geometry.y;
|
||||
auto pWindow::sizeEvent() -> void {
|
||||
if(!locked() && !self().fullScreen() && self().visible()) {
|
||||
@autoreleasepool {
|
||||
NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]];
|
||||
area.size.height -= statusBarHeight();
|
||||
state().geometry.setWidth(area.size.width);
|
||||
state().geometry.setHeight(area.size.height);
|
||||
}
|
||||
}
|
||||
|
||||
if(locked == false) {
|
||||
if(window.onMove) window.onMove();
|
||||
}
|
||||
}
|
||||
|
||||
void pWindow::sizeEvent() {
|
||||
if(locked == false && window.fullScreen() == false && window.visible() == true) {
|
||||
Geometry geometry = this->geometry();
|
||||
window.state.geometry.width = geometry.width;
|
||||
window.state.geometry.height = geometry.height;
|
||||
}
|
||||
|
||||
for(auto& layout : window.state.layout) {
|
||||
Geometry geometry = this->geometry();
|
||||
geometry.x = geometry.y = 0;
|
||||
layout.setGeometry(geometry);
|
||||
if(auto& layout = state().layout) {
|
||||
layout->setGeometry(self().geometry().setPosition(0, 0));
|
||||
}
|
||||
|
||||
statusBarReposition();
|
||||
|
||||
if(locked == false) {
|
||||
if(window.onSize) window.onSize();
|
||||
}
|
||||
if(!locked()) self().doSize();
|
||||
}
|
||||
|
||||
unsigned pWindow::statusBarHeight() {
|
||||
if(!window.state.statusVisible) return 0;
|
||||
return Font::size(window.state.statusFont, " ").height + 6;
|
||||
auto pWindow::statusBarHeight() -> uint {
|
||||
if(!state().statusBar) return 0;
|
||||
//return Font::size(window.state.statusFont, " ").height + 6;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pWindow::statusBarReposition() {
|
||||
auto pWindow::statusBarReposition() -> void {
|
||||
@autoreleasepool {
|
||||
NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]];
|
||||
[[cocoaWindow statusBar] setFrame:NSMakeRect(0, 0, area.size.width, statusBarHeight())];
|
||||
@@ -412,4 +389,17 @@ void pWindow::statusBarReposition() {
|
||||
}
|
||||
}
|
||||
|
||||
auto pWindow::_append(mWidget& widget) -> void {
|
||||
@autoreleasepool {
|
||||
if(auto pWidget = widget.self()) {
|
||||
[pWidget->cocoaView removeFromSuperview];
|
||||
[[cocoaWindow contentView] addSubview:pWidget->cocoaView positioned:NSWindowAbove relativeTo:nil];
|
||||
pWidget->setGeometry(widget.geometry());
|
||||
[[cocoaWindow contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user