[qwaq] Fix a bunch of issues with the scrollbar

Leaking memory. And worse, it wasn't drawing its buttons (group wasn't
setting view contexts) and then the buttons were in the wrong place, so
had to add a backing buffer for the buttons.
This commit is contained in:
Bill Currie 2020-03-30 22:01:17 +09:00
parent dbbdb31cb1
commit 02f8cc9760
3 changed files with 20 additions and 5 deletions

View file

@ -38,6 +38,8 @@
-setContext: (id<TextContext>) context
{
self.context = context;
[views makeObjectsPerformSelector:@selector(setContext:)
withObject:context];
return self;
}

View file

@ -4,6 +4,7 @@
#include "ui/view.h"
@class Button;
@class DrawBuffer;
@class Group;
@class ListenerGroup;
@ -12,6 +13,7 @@
int vertical;
int bgchar;
Point mouseStart;
DrawBuffer *buffer;
Button *backButton;
Button *forwardButton;
Button *thumbTab;

View file

@ -10,7 +10,8 @@
if (!(self = [super initWithRect:rect])) {
return nil;
}
objects = [[Group withContext:textContext owner:self] retain];
buffer = [[DrawBuffer buffer:size] retain];
objects = [[Group withContext:buffer owner:self] retain];
onScroll = [[ListenerGroup listener] retain];
vertical = xlen == 1;
DrawBuffer *icons[3] = {
@ -55,6 +56,13 @@
return self;
}
-(void)dealloc
{
[objects release];
[buffer release];
[onScroll release];
}
+(ScrollBar *)horizontal:(unsigned)len at:(Point)pos
{
if (len == 1) {
@ -78,6 +86,7 @@
-draw
{
syncprintf("scrollbar start");
if (vertical) {
[self mvvline:pos, bgchar, ylen];
} else {
@ -85,6 +94,8 @@
}
[super draw];
[objects draw];
[textContext blitFromBuffer:buffer to:pos from:[buffer rect]];
syncprintf("scrollbar end");
return self;
}