mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 21:02:50 +00:00
6d5ffa9f8e
There's still some cleanup to do, but everything seems to be working nicely: `make -j` works, `make distcheck` passes. There is probably plenty of bitrot in the package directories (RPM, debian), though. The vc project files have been removed since those versions are way out of date and quakeforge is pretty much dependent on gcc now anyway. Most of the old Makefile.am files are now Makemodule.am. This should allow for new Makefile.am files that allow local building (to be added on an as-needed bases). The current remaining Makefile.am files are for standalone sub-projects.a The installable bins are currently built in the top-level build directory. This may change if the clutter gets to be too much. While this does make a noticeable difference in build times, the main reason for the switch was to take care of the growing dependency issues: now it's possible to build tools for code generation (eg, using qfcc and ruamoko programs for code-gen).
180 lines
3.4 KiB
R
180 lines
3.4 KiB
R
#include "ruamoko/qwaq/ui/button.h"
|
|
#include "ruamoko/qwaq/ui/listener.h"
|
|
|
|
@implementation Button
|
|
|
|
+(Button *)withPos:(Point)pos releasedIcon:(DrawBuffer *)released
|
|
pressedIcon:(DrawBuffer *)pressed
|
|
{
|
|
return [[[self alloc] initWithPos:pos
|
|
releasedIcon:released
|
|
pressedIcon:pressed] autorelease];
|
|
}
|
|
|
|
+(Button *)withRect:(Rect)rect
|
|
{
|
|
return [[[self alloc] initWithRect:rect] autorelease];
|
|
}
|
|
|
|
-initWithPos: (Point) pos releasedIcon: (DrawBuffer *) released
|
|
pressedIcon: (DrawBuffer *) pressed
|
|
{
|
|
Extent size = mergeExtents ([released size], [pressed size]);
|
|
|
|
if (!(self = [super initWithRect: {pos, size}])) {
|
|
return nil;
|
|
}
|
|
icon[0] = [released retain];
|
|
icon[1] = [pressed retain];
|
|
onPress = [[ListenerGroup listener] retain];
|
|
onRelease = [[ListenerGroup listener] retain];
|
|
onClick = [[ListenerGroup listener] retain];
|
|
onDrag = [[ListenerGroup listener] retain];
|
|
onAuto = [[ListenerGroup listener] retain];
|
|
onHover = [[ListenerGroup listener] retain];
|
|
return self;
|
|
}
|
|
|
|
-initWithRect: (Rect) rect
|
|
{
|
|
if (!(self = [super initWithRect: rect])) {
|
|
return nil;
|
|
}
|
|
icon[0] = nil;
|
|
icon[1] = nil;
|
|
onPress = [[ListenerGroup listener] retain];
|
|
onRelease = [[ListenerGroup listener] retain];
|
|
onClick = [[ListenerGroup listener] retain];
|
|
onDrag = [[ListenerGroup listener] retain];
|
|
onAuto = [[ListenerGroup listener] retain];
|
|
onHover = [[ListenerGroup listener] retain];
|
|
return self;
|
|
}
|
|
|
|
-(void)dealloc
|
|
{
|
|
[icon[0] release];
|
|
[icon[1] release];
|
|
[onPress release];
|
|
[onRelease release];
|
|
[onClick release];
|
|
[onDrag release];
|
|
[onAuto release];
|
|
[onHover release];
|
|
[super dealloc];
|
|
}
|
|
|
|
-draw
|
|
{
|
|
[super draw];
|
|
if (icon[pressed]) {
|
|
[textContext blitFromBuffer: icon[pressed]
|
|
to: pos
|
|
from: [icon[pressed] rect]];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-handleEvent: (qwaq_event_t *) event
|
|
{
|
|
ListenerGroup *action = nil;
|
|
|
|
[super handleEvent: event];
|
|
|
|
if (event.what & qe_mouse) {
|
|
switch ((qwaq_mouse_event) (event.what & qe_mouse)) {
|
|
case qe_mousedown:
|
|
pressed = 1;
|
|
click = 0;
|
|
dragBase = {event.mouse.x, event.mouse.y};
|
|
action = onPress;
|
|
[self grabMouse];
|
|
[self redraw];
|
|
break;
|
|
case qe_mouseup:
|
|
pressed = 0;
|
|
click = 0;
|
|
action = onRelease;
|
|
[self releaseMouse];
|
|
if ([self containsPoint: {event.mouse.x, event.mouse.y}]) {
|
|
[onClick respond: self];
|
|
}
|
|
[self redraw];
|
|
break;
|
|
case qe_mouseclick:
|
|
action = onClick;
|
|
click = event.mouse.click;
|
|
break;
|
|
case qe_mousemove:
|
|
click = 0;
|
|
if (pressed) {
|
|
dragPos = {event.mouse.x, event.mouse.y};
|
|
action = onDrag;
|
|
}
|
|
break;
|
|
case qe_mouseauto:
|
|
if (pressed
|
|
&& [self containsPoint: {event.mouse.x, event.mouse.y}]) {
|
|
click = 0;
|
|
action = onAuto;
|
|
}
|
|
break;
|
|
}
|
|
if (action) {
|
|
[action respond: self];
|
|
}
|
|
event.what = qe_none;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(ListenerGroup *) onPress
|
|
{
|
|
return onPress;
|
|
}
|
|
|
|
-(ListenerGroup *) onRelease
|
|
{
|
|
return onRelease;
|
|
}
|
|
|
|
-(ListenerGroup *) onClick
|
|
{
|
|
return onClick;
|
|
}
|
|
|
|
-(ListenerGroup *) onDrag
|
|
{
|
|
return onDrag;
|
|
}
|
|
|
|
-(ListenerGroup *) onAuto
|
|
{
|
|
return onAuto;
|
|
}
|
|
|
|
-(ListenerGroup *) onHover
|
|
{
|
|
return onHover;
|
|
}
|
|
|
|
- (int) click
|
|
{
|
|
return click;
|
|
}
|
|
|
|
- (Point) delta
|
|
{
|
|
return {dragPos.x - dragBase.x, dragPos.y - dragBase.y};
|
|
}
|
|
|
|
-move:(Point) delta
|
|
{
|
|
Point pos = self.pos;
|
|
[super move:delta];
|
|
dragBase.x += self.pos.x - pos.x;
|
|
dragBase.y += self.pos.y - pos.y;
|
|
return self;
|
|
}
|
|
|
|
@end
|