mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
MacPDF: Make clicking outline items have an effect
Clicking an item in the outline now opens that page. This requires giving the outline view a delegate, which for some reason also has th effect of indenting expandable items ¯\_(ツ)_/¯ The vertical alignment of text still looks off, though.
This commit is contained in:
parent
185301c027
commit
e7d41480fc
Notes:
sideshowbarker
2024-07-17 04:09:56 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/e7d41480fc Pull-request: https://github.com/SerenityOS/serenity/pull/21386
2 changed files with 15 additions and 1 deletions
|
@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@class MacPDFDocument;
|
||||
|
||||
@interface MacPDFWindowController : NSWindowController <MacPDFViewDelegate, NSToolbarDelegate>
|
||||
@interface MacPDFWindowController : NSWindowController <MacPDFViewDelegate, NSOutlineViewDelegate, NSToolbarDelegate>
|
||||
|
||||
- (instancetype)initWithDocument:(MacPDFDocument*)document;
|
||||
- (IBAction)showGoToPageDialog:(id)sender;
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
// FIXME: Only set data source when sidebar is open.
|
||||
_outlineDataSource = [[MacPDFOutlineViewDataSource alloc] initWithOutline:_pdfDocument.pdf->outline()];
|
||||
_outlineView.dataSource = _outlineDataSource;
|
||||
_outlineView.delegate = self;
|
||||
}
|
||||
|
||||
- (IBAction)showGoToPageDialog:(id)sender
|
||||
|
@ -175,4 +176,17 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - NSOutlineViewDelegate
|
||||
|
||||
- (void)outlineViewSelectionDidChange:(NSNotification*)notification
|
||||
{
|
||||
NSInteger row = _outlineView.selectedRow;
|
||||
if (row == -1)
|
||||
return;
|
||||
|
||||
OutlineItemWrapper* item = [_outlineView itemAtRow:row];
|
||||
if (auto page = [item page]; page.has_value())
|
||||
[_pdfView goToPage:page.value()];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Reference in a new issue