This commit is contained in:
parent
21dcb02428
commit
90128dc6b2
3 changed files with 24 additions and 17 deletions
|
|
@ -125,6 +125,7 @@ struct _MwMenu {
|
||||||
MwWidget wsub;
|
MwWidget wsub;
|
||||||
MwMenu* sub;
|
MwMenu* sub;
|
||||||
void* opaque;
|
void* opaque;
|
||||||
|
int cleaned;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwEntry {
|
struct _MwEntry {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,8 @@ static void destroy(MwWidget handle) {
|
||||||
p2.y = p.y + th / 2 + 5; \
|
p2.y = p.y + th / 2 + 5; \
|
||||||
\
|
\
|
||||||
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, MwGetInteger(handle, MwNheight), 0, 0); \
|
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, MwGetInteger(handle, MwNheight), 0, 0); \
|
||||||
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2, 0);
|
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2, 0); \
|
||||||
|
m->sub[i]->cleaned = 0;
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
|
|
@ -139,13 +140,15 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
NEW_SUBMENU;
|
NEW_SUBMENU;
|
||||||
} else if(m->sub[i]->wsub != NULL && 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->sub[i]->cleaned = 1;
|
||||||
}
|
}
|
||||||
} else if(m->sub[i]->keep && m->sub[i]->wsub != NULL) {
|
} else if(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;
|
||||||
|
m->sub[i]->cleaned = 1;
|
||||||
}
|
}
|
||||||
END_MENU_LOOP;
|
END_MENU_LOOP;
|
||||||
|
|
||||||
|
|
@ -170,15 +173,16 @@ static void mouse_move(MwWidget handle) {
|
||||||
BEGIN_MENU_LOOP;
|
BEGIN_MENU_LOOP;
|
||||||
if(matched && m->sub[i]->wsub != NULL) {
|
if(matched && 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;
|
||||||
|
m->sub[i]->cleaned = 0;
|
||||||
}
|
}
|
||||||
END_MENU_LOOP;
|
END_MENU_LOOP;
|
||||||
|
|
||||||
MENU_LOOP_INIT;
|
MENU_LOOP_INIT;
|
||||||
BEGIN_MENU_LOOP;
|
BEGIN_MENU_LOOP;
|
||||||
if(matched && in_area) {
|
if(matched && in_area) {
|
||||||
if(m->sub[i]->wsub == NULL && arrlen(m->sub[i]->sub) > 0) {
|
if(m->sub[i]->wsub == NULL && arrlen(m->sub[i]->sub) > 0 && !m->sub[i]->cleaned) {
|
||||||
NEW_SUBMENU;
|
NEW_SUBMENU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,8 +207,9 @@ static void mouse_up(MwWidget handle, void* ptr) {
|
||||||
}
|
}
|
||||||
} else if(m->sub[i]->wsub != NULL) {
|
} else if(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;
|
||||||
|
m->sub[i]->cleaned = 0;
|
||||||
}
|
}
|
||||||
END_MENU_LOOP;
|
END_MENU_LOOP;
|
||||||
|
|
||||||
|
|
@ -212,12 +217,13 @@ static void mouse_up(MwWidget handle, void* ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static MwMenu mwMenuAddImpl(MwWidget handle, MwMenu menu, const char* name) {
|
static MwMenu mwMenuAddImpl(MwWidget handle, MwMenu menu, const char* name) {
|
||||||
MwMenu m = menu == NULL ? handle->internal : menu;
|
MwMenu m = menu == NULL ? handle->internal : menu;
|
||||||
MwMenu new = malloc(sizeof(*new));
|
MwMenu new = malloc(sizeof(*new));
|
||||||
new->name = MwStringDuplicate(name);
|
new->name = MwStringDuplicate(name);
|
||||||
new->sub = NULL;
|
new->sub = NULL;
|
||||||
new->wsub = NULL;
|
new->wsub = NULL;
|
||||||
new->keep = 0;
|
new->keep = 0;
|
||||||
|
new->cleaned = 0;
|
||||||
|
|
||||||
arrput(m->sub, new);
|
arrput(m->sub, new);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ static void recursion(MwWidget handle, MwTreeViewEntry* tree, MwTreeViewEntry**
|
||||||
r.height = MwTextHeight(handle, Font, "M");
|
r.height = MwTextHeight(handle, Font, "M");
|
||||||
r.width = r.height * tree->pixmap->common.width / tree->pixmap->common.height;
|
r.width = r.height * tree->pixmap->common.width / tree->pixmap->common.height;
|
||||||
|
|
||||||
r.x = p->x;
|
r.x = p->x + (MwGetInteger(handle->parent, MwNleftPadding) - r.width) / 2;
|
||||||
r.y = p->y - MwTextHeight(handle, Font, "M") / 2;
|
r.y = p->y - MwTextHeight(handle, Font, "M") / 2;
|
||||||
|
|
||||||
if(draw) MwLLDrawPixmap(handle->lowlevel, &r, tree->pixmap);
|
if(draw) MwLLDrawPixmap(handle->lowlevel, &r, tree->pixmap);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue