mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[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:
parent
dbbdb31cb1
commit
02f8cc9760
3 changed files with 20 additions and 5 deletions
|
@ -38,6 +38,8 @@
|
|||
-setContext: (id<TextContext>) context
|
||||
{
|
||||
self.context = context;
|
||||
[views makeObjectsPerformSelector:@selector(setContext:)
|
||||
withObject:context];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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] = {
|
||||
|
@ -23,14 +24,14 @@
|
|||
SEL thumbSel;
|
||||
growMode = gfGrowAll;
|
||||
if (vertical) {
|
||||
[icons[0]addch:acs_char (ACS_UARROW)];
|
||||
[icons[1]addch:acs_char (ACS_DARROW)];
|
||||
[icons[0] addch:acs_char (ACS_UARROW)];
|
||||
[icons[1] addch:acs_char (ACS_DARROW)];
|
||||
thumbPos = {0, 1};
|
||||
thumbSel = @selector(verticalSlide);
|
||||
growMode &= ~gfGrowLoY;
|
||||
} else {
|
||||
[icons[0]addch:acs_char (ACS_LARROW)];
|
||||
[icons[1]addch:acs_char (ACS_RARROW)];
|
||||
[icons[0] addch:acs_char (ACS_LARROW)];
|
||||
[icons[1] addch:acs_char (ACS_RARROW)];
|
||||
thumbPos = {1, 0};
|
||||
thumbSel = @selector(horizontalSlide);
|
||||
growMode &= ~gfGrowLoX;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue