[qwaq] Add support for invisible buttons

Useful for window controls.
This commit is contained in:
Bill Currie 2020-03-23 22:00:05 +09:00
parent afda214487
commit 19a4efed16
3 changed files with 23 additions and 4 deletions

View file

@ -22,6 +22,7 @@
}
-initWithPos: (Point) pos releasedIcon: (DrawBuffer *) released
pressedIcon: (DrawBuffer *) pressed;
-initWithRect: (Rect) rect; // invisible button
-(ListenerGroup *) onPress;
-(ListenerGroup *) onRelease;
-(ListenerGroup *) onClick;

View file

@ -21,12 +21,30 @@
return self;
}
-initWithRect: (Rect) rect
{
if (!(self = [super initWithRect: rect])) {
return nil;
}
icon[0] = nil;
icon[1] = nil;
onPress = [[ListenerGroup alloc] init];
onRelease = [[ListenerGroup alloc] init];
onClick = [[ListenerGroup alloc] init];
onDrag = [[ListenerGroup alloc] init];
onAuto = [[ListenerGroup alloc] init];
onHover = [[ListenerGroup alloc] init];
return self;
}
-draw
{
[super draw];
[textContext blitFromBuffer: icon[pressed]
to: pos
from: [icon[pressed] rect]];
if (icon[pressed]) {
[textContext blitFromBuffer: icon[pressed]
to: pos
from: [icon[pressed] rect]];
}
return self;
}

View file

@ -602,7 +602,7 @@ cmd_resizeterm (qwaq_resources_t *res)
static void
dump_command (qwaq_resources_t *res, int len)
{
if (1) {
if (0) {
qwaq_commands cmd = RB_PEEK_DATA (res->command_queue, 0);
Sys_Printf ("%s[%d]", qwaq_command_names[cmd], len);
for (int i = 2; i < len; i++) {