mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-10 03:13:28 +00:00
better selection
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@335 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -126,6 +126,7 @@ struct _MwListBox {
|
|||||||
char** list;
|
char** list;
|
||||||
int selected;
|
int selected;
|
||||||
unsigned long click_time;
|
unsigned long click_time;
|
||||||
|
int pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwSizeHints {
|
struct _MwSizeHints {
|
||||||
|
|||||||
@@ -39,6 +39,36 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
|||||||
y += MwTextHeight(handle, "M");
|
y += MwTextHeight(handle, "M");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MwForceRender(lb->frame);
|
||||||
|
lb->pressed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void frame_mouse_up(MwWidget handle, void* user, void* call) {
|
||||||
|
MwListBox lb = handle->parent->internal;
|
||||||
|
MwLLMouse* m = call;
|
||||||
|
if(m->button == MwLLMouseLeft) {
|
||||||
|
lb->pressed = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
||||||
|
MwListBox lb = handle->parent->internal;
|
||||||
|
MwPoint* p = call;
|
||||||
|
if(lb->pressed) {
|
||||||
|
int st = 0;
|
||||||
|
int i;
|
||||||
|
int y = MwDefaultBorderWidth;
|
||||||
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
st = get_first_entry(lb);
|
||||||
|
for(i = 0; i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) {
|
||||||
|
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M"))) {
|
||||||
|
lb->selected = st + i;
|
||||||
|
}
|
||||||
|
y += MwTextHeight(handle, "M");
|
||||||
|
}
|
||||||
|
|
||||||
MwForceRender(lb->frame);
|
MwForceRender(lb->frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +134,8 @@ static void resize(MwWidget handle) {
|
|||||||
lb->frame = MwVaCreateWidget(MwFrameClass, "frame", handle, 0, 0, w - 16, h, NULL);
|
lb->frame = MwVaCreateWidget(MwFrameClass, "frame", handle, 0, 0, w - 16, h, NULL);
|
||||||
lb->frame->draw_inject = frame_draw;
|
lb->frame->draw_inject = frame_draw;
|
||||||
MwAddUserHandler(lb->frame, MwNmouseDownHandler, frame_mouse_down, NULL);
|
MwAddUserHandler(lb->frame, MwNmouseDownHandler, frame_mouse_down, NULL);
|
||||||
|
MwAddUserHandler(lb->frame, MwNmouseUpHandler, frame_mouse_up, NULL);
|
||||||
|
MwAddUserHandler(lb->frame, MwNmouseMoveHandler, frame_mouse_move, NULL);
|
||||||
} else {
|
} else {
|
||||||
MwVaApply(lb->frame,
|
MwVaApply(lb->frame,
|
||||||
MwNx, 0,
|
MwNx, 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user