remove scrollview and add window.m scroll funs

This commit is contained in:
anthony 2020-11-24 20:02:12 +00:00
parent 8faae4eacc
commit 8584d90452
6 changed files with 15 additions and 5 deletions

View File

@ -6,7 +6,6 @@ struct browser_window;
@interface BrowserWindowController : NSWindowController<NSTextFieldDelegate> {
id backButton;
id forwardButton;
id scrollView;
id urlBar;
struct browser_window *browser;
id plotView;
@ -18,6 +17,8 @@ struct browser_window;
// Browser control
-(NSSize)getBrowserSize;
-(NSPoint)getBrowserScroll;
-(void)setBrowserScroll: (NSPoint)scroll;
-(void)invalidateBrowser;
-(void)invalidateBrowser: (NSRect)rect;
@end

View File

@ -16,9 +16,7 @@
}
-(void)awakeFromNib {
plotView = [[PlotView alloc] initWithFrame: NSMakeRect(0, 0, 800, 600)];
[plotView setBrowser: browser];
[[scrollView contentView] addSubview: plotView];
NSLog(@"Browser window loaded");
}
@ -35,6 +33,12 @@
-(NSSize)getBrowserSize {
return [plotView frame].size;
}
-(NSPoint)getBrowserScroll {
return [plotView visibleRect].origin;
}
-(void)setBrowserScroll: (NSPoint)scroll {
[plotView scrollPoint: scroll];
}
-(void)invalidateBrowser {
[plotView setNeedsDisplay: YES];
}

View File

@ -240,6 +240,7 @@ static const struct plotter_table gnustep_plotters = {
-(void)drawRect: (NSRect)rect {
NSLog(@"Drawing plotview");
struct redraw_context ctx = {
.interactive = true,
.background_images = true,

View File

@ -10,7 +10,7 @@
backButton,
forwardButton,
urlBar,
scrollView
plotView
);
Super = NSWindowController;
};
@ -22,7 +22,7 @@
);
Super = NSObject;
};
PlotterView = {
PlotView = {
Actions = (
);
Outlets = (

View File

@ -42,12 +42,16 @@ static nserror gnustep_window_invalidate(struct gui_window *gw, const struct rec
// Put the current scroll offset into sx and sy
static bool gnustep_window_get_scroll(struct gui_window *gw, int *sx, int *sy) {
NSLog(@"gnustep_window_get_scroll");
NSPoint scroll = [(id)gw getBrowserScroll];
*sx = scroll.x;
*sy = scroll.y;
return true;
}
// Set the current scroll offset
static nserror gnustep_window_set_scroll(struct gui_window *gw, const struct rect *rect) {
NSLog(@"gnustep_window_set_scroll");
[(id)gw setBrowserScroll: NSMakePoint(rect->x0, rect->y0)];
return NSERROR_OK;
}