From 6b9afcfb7c9c17dee8bc6e7ff91c19da8184ce36 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 3 Oct 2023 09:07:55 -0400 Subject: [PATCH] MacPDF: Create window UI in code instead of in xib No intentional behavior change. --- Meta/Lagom/Contrib/MacPDF/CMakeLists.txt | 1 - Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm | 1 + Meta/Lagom/Contrib/MacPDF/MacPDFDocument.xib | 32 ------------------- .../Contrib/MacPDF/MacPDFWindowController.mm | 19 ++++++----- 4 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 Meta/Lagom/Contrib/MacPDF/MacPDFDocument.xib diff --git a/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt b/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt index b5695ae6fa..8b3ea1bab4 100644 --- a/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt +++ b/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt @@ -10,7 +10,6 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) add_compile_options(-DAK_DONT_REPLACE_STD) set(RESOURCES - MacPDFDocument.xib MainMenu.xib ) diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm b/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm index fa685404ca..bc8ab778d0 100644 --- a/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm @@ -81,6 +81,7 @@ { _windowController = [[MacPDFWindowController alloc] initWithDocument:self]; [self addWindowController:_windowController]; + [self windowIsReady]; } - (void)windowIsReady diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.xib b/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.xib deleted file mode 100644 index c2768cbc8f..0000000000 --- a/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.xib +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm index e22d8c5183..21ddf43193 100644 --- a/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm @@ -19,20 +19,23 @@ - (instancetype)initWithDocument:(MacPDFDocument*)document { - if (self = [super initWithWindowNibName:@"MacPDFDocument" owner:self]; !self) + auto const style_mask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; + NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 600, 800) + styleMask:style_mask + backing:NSBackingStoreBuffered + defer:YES]; + + if (self = [super initWithWindow:window]; !self) return nil; + _pdfView = [[MacPDFView alloc] initWithFrame:NSZeroRect]; + window.contentView = _pdfView; + [_pdfView setDelegate:self]; + _pdfDocument = document; return self; } -- (void)windowDidLoad -{ - [super windowDidLoad]; - [_pdfView setDelegate:self]; - [_pdfDocument windowIsReady]; -} - - (void)pdfDidInitialize { [_pdfView setDocument:_pdfDocument.pdf->make_weak_ptr()];