This commit is contained in:
parent
d05e121bf1
commit
ab1dfc2e60
2 changed files with 30 additions and 2 deletions
|
|
@ -219,6 +219,8 @@ struct _MwSubWindow {
|
||||||
int y;
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
MwPoint cursor_start;
|
||||||
|
MwPoint base;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwMouse {
|
struct _MwMouse {
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,17 @@ static MwWidget mwSubWindowGetFrameImpl(MwWidget handle) {
|
||||||
return sw->frame;
|
return sw->frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
|
MwSubWindow sw = handle->internal;
|
||||||
|
MwMouse* m = ptr;
|
||||||
|
|
||||||
|
if(m->button == MwMOUSE_LEFT) {
|
||||||
|
MwGetCursorCoord(handle, &sw->cursor_start);
|
||||||
|
sw->base.x = MwGetInteger(handle, MwNx);
|
||||||
|
sw->base.y = MwGetInteger(handle, MwNy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
||||||
(void)va;
|
(void)va;
|
||||||
|
|
||||||
|
|
@ -354,6 +365,21 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tick(MwWidget handle) {
|
||||||
|
MwSubWindow sw = handle->internal;
|
||||||
|
|
||||||
|
if(handle->pressed) {
|
||||||
|
MwPoint p;
|
||||||
|
|
||||||
|
MwGetCursorCoord(handle, &p);
|
||||||
|
|
||||||
|
MwVaApply(handle,
|
||||||
|
MwNx, sw->base.x + p.x - sw->cursor_start.x,
|
||||||
|
MwNy, sw->base.y + p.y - sw->cursor_start.y,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MwClassRec MwSubWindowClassRec = {
|
MwClassRec MwSubWindowClassRec = {
|
||||||
wcreate, /* create */
|
wcreate, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
|
|
@ -363,10 +389,10 @@ MwClassRec MwSubWindowClassRec = {
|
||||||
prop_change, /* prop_change */
|
prop_change, /* prop_change */
|
||||||
NULL, /* mouse_move */
|
NULL, /* mouse_move */
|
||||||
NULL, /* mouse_up */
|
NULL, /* mouse_up */
|
||||||
NULL, /* mouse_down */
|
mouse_down, /* mouse_down */
|
||||||
NULL, /* key */
|
NULL, /* key */
|
||||||
func_handler, /* execute */
|
func_handler, /* execute */
|
||||||
NULL, /* tick */
|
tick, /* tick */
|
||||||
resize, /* resize */
|
resize, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue