mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
[qwaq] Clamp window motion to owner's bounds
This commit is contained in:
parent
f329ca83b6
commit
ac23156ecd
3 changed files with 44 additions and 3 deletions
|
@ -20,6 +20,9 @@
|
|||
-initWithContext: (id<TextContext>) context owner: (View *) owner;
|
||||
-insert: (View *) view;
|
||||
-remove: (View *) view;
|
||||
-(Rect) rect;
|
||||
-(Point) origin;
|
||||
-(Extent) size;
|
||||
-draw;
|
||||
-redraw;
|
||||
-handleEvent: (qwaq_event_t *) event;
|
||||
|
|
|
@ -46,6 +46,30 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-(Rect) rect
|
||||
{
|
||||
if (owner) {
|
||||
return [owner rect];
|
||||
}
|
||||
return {[self origin], [self size]};
|
||||
}
|
||||
|
||||
-(Point) origin
|
||||
{
|
||||
if (owner) {
|
||||
return [owner origin];
|
||||
}
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
-(Extent) size
|
||||
{
|
||||
if (owner) {
|
||||
return [owner size];
|
||||
}
|
||||
return [context size];
|
||||
}
|
||||
|
||||
static BOOL
|
||||
not_dont_draw (id aView, void *aGroup)
|
||||
{
|
||||
|
|
|
@ -46,9 +46,23 @@
|
|||
- (void) dragWindow: (Button *) sender
|
||||
{
|
||||
Point delta = [sender delta];
|
||||
xpos += delta.x;
|
||||
ypos += delta.y;
|
||||
move_panel (panel, xpos, ypos);
|
||||
Point p = {xpos + delta.x, ypos + delta.y};
|
||||
Extent bounds = [owner size];
|
||||
if (p.x < 0) {
|
||||
p.x = 0;
|
||||
}
|
||||
if (p.x + xlen > bounds.width) {
|
||||
p.x = bounds.width - xlen;
|
||||
}
|
||||
if (p.y < 0) {
|
||||
p.y = 0;
|
||||
}
|
||||
if (p.y + ylen > bounds.height) {
|
||||
p.y = bounds.height - ylen;
|
||||
}
|
||||
xpos = p.x;
|
||||
ypos = p.y;
|
||||
move_panel (panel, p.x, p.y);
|
||||
[owner redraw];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue