mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[qwaq] Get the cursor mostly working
It's a little flakey with respect to redraws and changes of focus, but I think that's just updating the cursor state in more places.
This commit is contained in:
parent
d36a75e3de
commit
48bf6fff13
2 changed files with 43 additions and 23 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include "ruamoko/qwaq/ui/group.h"
|
#include "ruamoko/qwaq/ui/group.h"
|
||||||
#include "ruamoko/qwaq/ui/scrollbar.h"
|
#include "ruamoko/qwaq/ui/scrollbar.h"
|
||||||
#include "ruamoko/qwaq/ui/view.h"
|
#include "ruamoko/qwaq/ui/view.h"
|
||||||
|
#include "ruamoko/qwaq/debugger/debug.h"
|
||||||
|
|
||||||
@implementation View
|
@implementation View
|
||||||
|
|
||||||
|
@ -122,32 +123,41 @@ setScrollBar (View *self, ScrollBar **sb, ScrollBar *scrollbar)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(window_t) window
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void updateScreenCursor (View *view);
|
||||||
|
|
||||||
|
-updateScreenCursor
|
||||||
|
{
|
||||||
|
updateScreenCursor (self);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
updateScreenCursor (View *view)
|
updateScreenCursor (View *view)
|
||||||
{
|
{
|
||||||
// XXX this does not work
|
if (view.state & sfInFocus) {
|
||||||
/* while ((view.state & sfInFocus) && view.owner) {
|
if (view.owner) {
|
||||||
View *owner = (View *) view.owner;
|
View *owner = [view.owner owner];
|
||||||
if (view.cursor.x >= 0 && view.cursor.x < view.xlen
|
if (view.cursorPos.x >= 0 && view.cursorPos.x < view.xlen
|
||||||
&& view.cursor.y >= 0 && view.cursor.y < view.ylen) {
|
&& view.cursorPos.y >= 0 && view.cursorPos.y < view.ylen) {
|
||||||
owner.cursor.x = view.cursor.x + view.xpos;
|
owner.cursorPos.x = view.cursorPos.x + view.xpos;
|
||||||
owner.cursor.y = view.cursor.y + view.ypos;
|
owner.cursorPos.y = view.cursorPos.y + view.ypos;
|
||||||
owner.cursorState = view.cursorState;
|
owner.cursorState = view.cursorState;
|
||||||
} else {
|
} else {
|
||||||
owner.cursorState = 0;
|
owner.cursorState = 0;
|
||||||
}
|
}
|
||||||
view = owner;
|
[owner updateScreenCursor];
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (view.state & sfInFocus) {
|
|
||||||
if (view.cursorPos.x >= 0 && view.cursorPos.x < view.xlen
|
|
||||||
&& view.cursorPos.y >= 0 && view.cursorPos.y < view.ylen) {
|
|
||||||
curs_set (view.cursorState);
|
|
||||||
move(view.cursorPos.x, view.cursorPos.y);
|
|
||||||
} else {
|
} else {
|
||||||
curs_set (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
curs_set (cursorState);
|
||||||
|
wmove (get_window (view), cursorPos.x, cursorPos.y);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
-hideCursor
|
-hideCursor
|
||||||
|
@ -164,7 +174,7 @@ updateScreenCursor (View *view)
|
||||||
{
|
{
|
||||||
cursorState = visible;
|
cursorState = visible;
|
||||||
if ((state & (sfInFocus | sfDrawn)) == (sfInFocus | sfDrawn)) {
|
if ((state & (sfInFocus | sfDrawn)) == (sfInFocus | sfDrawn)) {
|
||||||
updateScreenCursor (self);
|
[self updateScreenCursor];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +183,7 @@ updateScreenCursor (View *view)
|
||||||
{
|
{
|
||||||
cursorPos = pos;
|
cursorPos = pos;
|
||||||
if ((state & (sfInFocus | sfDrawn)) == (sfInFocus | sfDrawn)) {
|
if ((state & (sfInFocus | sfDrawn)) == (sfInFocus | sfDrawn)) {
|
||||||
updateScreenCursor (self);
|
[self updateScreenCursor];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +191,7 @@ updateScreenCursor (View *view)
|
||||||
-draw
|
-draw
|
||||||
{
|
{
|
||||||
state |= sfDrawn;
|
state |= sfDrawn;
|
||||||
updateScreenCursor (self);
|
[self updateScreenCursor];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +199,7 @@ updateScreenCursor (View *view)
|
||||||
{
|
{
|
||||||
if (state & sfDrawn) {
|
if (state & sfDrawn) {
|
||||||
state &= ~sfDrawn;
|
state &= ~sfDrawn;
|
||||||
updateScreenCursor (self);
|
[self updateScreenCursor];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -432,6 +442,7 @@ updateScreenCursor (View *view)
|
||||||
-takeFocus
|
-takeFocus
|
||||||
{
|
{
|
||||||
state |= sfInFocus;
|
state |= sfInFocus;
|
||||||
|
[self updateScreenCursor];
|
||||||
[onReceiveFocus respond:self];
|
[onReceiveFocus respond:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -439,6 +450,7 @@ updateScreenCursor (View *view)
|
||||||
-loseFocus
|
-loseFocus
|
||||||
{
|
{
|
||||||
state &= ~sfInFocus;
|
state &= ~sfInFocus;
|
||||||
|
[self updateScreenCursor];
|
||||||
[onReleaseFocus respond:self];
|
[onReleaseFocus respond:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,14 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-updateScreenCursor
|
||||||
|
{
|
||||||
|
window_t window = [(id)textContext window];
|
||||||
|
curs_set (cursorState);
|
||||||
|
wmove (window, cursorPos.x, cursorPos.y);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
-setTitle:(string) title
|
-setTitle:(string) title
|
||||||
{
|
{
|
||||||
[titleBar setTitle:title];
|
[titleBar setTitle:title];
|
||||||
|
|
Loading…
Reference in a new issue