mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[qwaq] Implement window dragging
Other than the stray panel_free, that was surprisingly easy. However, do need to check that the window can be moved otherwise window pos and panel pos will get out of sync.
This commit is contained in:
parent
fe4f831512
commit
3a28d84c3f
1 changed files with 21 additions and 0 deletions
|
@ -1,8 +1,11 @@
|
|||
#include <Array.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "event.h"
|
||||
#include "qwaq-button.h"
|
||||
#include "qwaq-curses.h"
|
||||
#include "qwaq-group.h"
|
||||
#include "qwaq-listener.h"
|
||||
#include "qwaq-window.h"
|
||||
#include "qwaq-view.h"
|
||||
|
||||
|
@ -24,6 +27,15 @@
|
|||
|
||||
objects = [[Group alloc] initWithContext: textContext owner: self];
|
||||
|
||||
string titlestr = "drag me";
|
||||
DrawBuffer *title = [DrawBuffer buffer: {xlen, 1}];
|
||||
[title mvaddstr: {(xlen - strlen(titlestr)) / 2, 0}, titlestr];
|
||||
|
||||
Button *b = [[Button alloc] initWithPos: {0, 0} releasedIcon: title
|
||||
pressedIcon: title];
|
||||
[[b onDrag] addListener: self message: @selector(dragWindow:)];
|
||||
[self addView: b];
|
||||
|
||||
buf = [DrawBuffer buffer: {3, 3}];
|
||||
[buf mvaddstr: {0, 0}, "XOX"];
|
||||
[buf mvaddstr: {0, 1}, "OXO"];
|
||||
|
@ -31,6 +43,15 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) dragWindow: (Button *) sender
|
||||
{
|
||||
Point delta = [sender delta];
|
||||
xpos += delta.x;
|
||||
ypos += delta.y;
|
||||
move_panel (panel, xpos, ypos);
|
||||
[owner redraw];
|
||||
}
|
||||
|
||||
-setContext: (id<TextContext>) context
|
||||
{
|
||||
return self;
|
||||
|
|
Loading…
Reference in a new issue