mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +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
|
-setContext: (id<TextContext>) context
|
||||||
{
|
{
|
||||||
self.context = context;
|
self.context = context;
|
||||||
|
[views makeObjectsPerformSelector:@selector(setContext:)
|
||||||
|
withObject:context];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "ui/view.h"
|
#include "ui/view.h"
|
||||||
|
|
||||||
@class Button;
|
@class Button;
|
||||||
|
@class DrawBuffer;
|
||||||
@class Group;
|
@class Group;
|
||||||
@class ListenerGroup;
|
@class ListenerGroup;
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
int vertical;
|
int vertical;
|
||||||
int bgchar;
|
int bgchar;
|
||||||
Point mouseStart;
|
Point mouseStart;
|
||||||
|
DrawBuffer *buffer;
|
||||||
Button *backButton;
|
Button *backButton;
|
||||||
Button *forwardButton;
|
Button *forwardButton;
|
||||||
Button *thumbTab;
|
Button *thumbTab;
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
if (!(self = [super initWithRect:rect])) {
|
if (!(self = [super initWithRect:rect])) {
|
||||||
return nil;
|
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];
|
onScroll = [[ListenerGroup listener] retain];
|
||||||
vertical = xlen == 1;
|
vertical = xlen == 1;
|
||||||
DrawBuffer *icons[3] = {
|
DrawBuffer *icons[3] = {
|
||||||
|
@ -23,14 +24,14 @@
|
||||||
SEL thumbSel;
|
SEL thumbSel;
|
||||||
growMode = gfGrowAll;
|
growMode = gfGrowAll;
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
[icons[0]addch:acs_char (ACS_UARROW)];
|
[icons[0] addch:acs_char (ACS_UARROW)];
|
||||||
[icons[1]addch:acs_char (ACS_DARROW)];
|
[icons[1] addch:acs_char (ACS_DARROW)];
|
||||||
thumbPos = {0, 1};
|
thumbPos = {0, 1};
|
||||||
thumbSel = @selector(verticalSlide);
|
thumbSel = @selector(verticalSlide);
|
||||||
growMode &= ~gfGrowLoY;
|
growMode &= ~gfGrowLoY;
|
||||||
} else {
|
} else {
|
||||||
[icons[0]addch:acs_char (ACS_LARROW)];
|
[icons[0] addch:acs_char (ACS_LARROW)];
|
||||||
[icons[1]addch:acs_char (ACS_RARROW)];
|
[icons[1] addch:acs_char (ACS_RARROW)];
|
||||||
thumbPos = {1, 0};
|
thumbPos = {1, 0};
|
||||||
thumbSel = @selector(horizontalSlide);
|
thumbSel = @selector(horizontalSlide);
|
||||||
growMode &= ~gfGrowLoX;
|
growMode &= ~gfGrowLoX;
|
||||||
|
@ -55,6 +56,13 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)dealloc
|
||||||
|
{
|
||||||
|
[objects release];
|
||||||
|
[buffer release];
|
||||||
|
[onScroll release];
|
||||||
|
}
|
||||||
|
|
||||||
+(ScrollBar *)horizontal:(unsigned)len at:(Point)pos
|
+(ScrollBar *)horizontal:(unsigned)len at:(Point)pos
|
||||||
{
|
{
|
||||||
if (len == 1) {
|
if (len == 1) {
|
||||||
|
@ -78,6 +86,7 @@
|
||||||
|
|
||||||
-draw
|
-draw
|
||||||
{
|
{
|
||||||
|
syncprintf("scrollbar start");
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
[self mvvline:pos, bgchar, ylen];
|
[self mvvline:pos, bgchar, ylen];
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,6 +94,8 @@
|
||||||
}
|
}
|
||||||
[super draw];
|
[super draw];
|
||||||
[objects draw];
|
[objects draw];
|
||||||
|
[textContext blitFromBuffer:buffer to:pos from:[buffer rect]];
|
||||||
|
syncprintf("scrollbar end");
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue