mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-07 01:49:47 +00:00
fix focus
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@133 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -91,6 +91,7 @@ struct _MwMenu {
|
|||||||
int keep;
|
int keep;
|
||||||
MwWidget wsub;
|
MwWidget wsub;
|
||||||
MwMenu* sub;
|
MwMenu* sub;
|
||||||
|
int wait;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ static void create(MwWidget handle) {
|
|||||||
m->name = NULL;
|
m->name = NULL;
|
||||||
m->wsub = NULL;
|
m->wsub = NULL;
|
||||||
m->sub = NULL;
|
m->sub = NULL;
|
||||||
|
m->wait = 0;
|
||||||
handle->internal = m;
|
handle->internal = m;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
@@ -74,6 +75,7 @@ static void draw(MwWidget handle) {
|
|||||||
|
|
||||||
MwDrawFrame(handle, &r, base, 0);
|
MwDrawFrame(handle, &r, base, 0);
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
|
if(!handle->pressed) m->wait = 0;
|
||||||
for(i = 0; i < arrlen(m->sub); i++) {
|
for(i = 0; i < arrlen(m->sub); i++) {
|
||||||
int incr = m->sub[i]->name[0] == '?' ? 1 : 0;
|
int incr = m->sub[i]->name[0] == '?' ? 1 : 0;
|
||||||
int tw = MwTextWidth(handle, m->sub[i]->name + incr);
|
int tw = MwTextWidth(handle, m->sub[i]->name + incr);
|
||||||
@@ -92,7 +94,7 @@ static void draw(MwWidget handle) {
|
|||||||
r.height = th + 10;
|
r.height = th + 10;
|
||||||
|
|
||||||
in_area = (r.x <= handle->mouse_point.x && r.y <= handle->mouse_point.y && handle->mouse_point.x <= (int)(r.x + r.width) && handle->mouse_point.y <= (int)(r.y + r.height)) ? 1 : 0;
|
in_area = (r.x <= handle->mouse_point.x && r.y <= handle->mouse_point.y && handle->mouse_point.x <= (int)(r.x + r.width) && handle->mouse_point.y <= (int)(r.y + r.height)) ? 1 : 0;
|
||||||
if(handle->pressed && in_area) {
|
if(!m->wait && handle->pressed && in_area) {
|
||||||
MwDrawFrame(handle, &r, base, 0);
|
MwDrawFrame(handle, &r, base, 0);
|
||||||
if(m->sub[i]->wsub == NULL && arrlen(m->sub[i]->sub) > 0) {
|
if(m->sub[i]->wsub == NULL && arrlen(m->sub[i]->sub) > 0) {
|
||||||
MwPoint p2;
|
MwPoint p2;
|
||||||
@@ -102,10 +104,11 @@ static void draw(MwWidget handle) {
|
|||||||
|
|
||||||
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, 0, 0, 0);
|
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, 0, 0, 0);
|
||||||
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2);
|
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2);
|
||||||
} else if(m->sub[i]->keep) {
|
} else if(m->sub[i]->wsub != NULL && m->sub[i]->keep) {
|
||||||
MwDestroyWidget(m->sub[i]->wsub);
|
MwDestroyWidget(m->sub[i]->wsub);
|
||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
m->sub[i]->keep = 0;
|
m->sub[i]->keep = 0;
|
||||||
|
m->wait = 1;
|
||||||
}
|
}
|
||||||
} else if(!handle->pressed && m->sub[i]->wsub != NULL) {
|
} else if(!handle->pressed && m->sub[i]->wsub != NULL) {
|
||||||
if(in_area) {
|
if(in_area) {
|
||||||
@@ -116,7 +119,7 @@ static void draw(MwWidget handle) {
|
|||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
m->sub[i]->keep = 0;
|
m->sub[i]->keep = 0;
|
||||||
}
|
}
|
||||||
} else if(m->sub[i]->keep && m->sub[i]->wsub != NULL) {
|
} else if(handle->pressed && m->sub[i]->keep && m->sub[i]->wsub != NULL) {
|
||||||
MwDestroyWidget(m->sub[i]->wsub);
|
MwDestroyWidget(m->sub[i]->wsub);
|
||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
m->sub[i]->keep = 0;
|
m->sub[i]->keep = 0;
|
||||||
@@ -152,6 +155,7 @@ MwMenu MwMenuAdd(MwWidget handle, MwMenu menu, const char* name) {
|
|||||||
new->sub = NULL;
|
new->sub = NULL;
|
||||||
new->wsub = NULL;
|
new->wsub = NULL;
|
||||||
new->keep = 0;
|
new->keep = 0;
|
||||||
|
new->wait = 0;
|
||||||
|
|
||||||
strcpy(new->name, name);
|
strcpy(new->name, name);
|
||||||
|
|
||||||
|
|||||||
@@ -72,11 +72,22 @@ static void draw(MwWidget handle) {
|
|||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void click(MwWidget handle) {
|
||||||
|
MwWidget w = handle;
|
||||||
|
jmp_buf jmp;
|
||||||
|
while(w->parent->widget_class != MwMenuClass) w = w->parent;
|
||||||
|
MwGetBeforeStep(w, &jmp);
|
||||||
|
|
||||||
|
MwDestroyWidget(w);
|
||||||
|
|
||||||
|
longjmp(jmp, 1);
|
||||||
|
}
|
||||||
|
|
||||||
MwClassRec MwSubMenuClassRec = {
|
MwClassRec MwSubMenuClassRec = {
|
||||||
create, /* create */
|
create, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
click, /* click */
|
||||||
NULL /* parent_resize */
|
NULL /* parent_resize */
|
||||||
};
|
};
|
||||||
MwClass MwSubMenuClass = &MwSubMenuClassRec;
|
MwClass MwSubMenuClass = &MwSubMenuClassRec;
|
||||||
|
|||||||
Reference in New Issue
Block a user