mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-09 02:43:30 +00:00
smooth movement
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@587 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -109,6 +109,8 @@ struct _MwViewport {
|
||||
MwWidget hscroll;
|
||||
MwWidget frame;
|
||||
MwWidget inframe;
|
||||
int vchanged;
|
||||
int hchanged;
|
||||
};
|
||||
|
||||
struct _MwListBoxEntry {
|
||||
@@ -124,6 +126,7 @@ struct _MwListBox {
|
||||
unsigned long click_time;
|
||||
int pressed;
|
||||
int* width;
|
||||
int changed;
|
||||
};
|
||||
|
||||
struct _MwDirectoryEntry {
|
||||
@@ -150,7 +153,7 @@ struct _MwClass {
|
||||
MwHandlerMouse mouse_down;
|
||||
MwHandlerKey key;
|
||||
MwHandlerExecute execute;
|
||||
void* reserved2;
|
||||
MwHandler tick;
|
||||
void* reserved3;
|
||||
void* reserved4;
|
||||
void* reserved5;
|
||||
|
||||
@@ -166,6 +166,10 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||
}
|
||||
h->prop_event = 1;
|
||||
|
||||
if(h->widget_class != NULL && h->widget_class->tick != NULL){
|
||||
MwAddTickList(h);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -302,6 +306,7 @@ void MwLoop(MwWidget handle) {
|
||||
if(v != 0) break;
|
||||
|
||||
for(i = 0; i < arrlen(handle->tick_list); i++) {
|
||||
MwDispatch(handle->tick_list[i], tick);
|
||||
MwDispatchUserHandler(handle->tick_list[i], MwNtickHandler, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ MwClassRec MwButtonClassRec = {
|
||||
MwForceRender2, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -48,7 +48,7 @@ MwClassRec MwCheckBoxClassRec = {
|
||||
MwForceRender2, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -139,7 +139,7 @@ MwClassRec MwEntryClassRec = {
|
||||
MwForceRender2, /* mouse_down */
|
||||
key, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -52,7 +52,7 @@ MwClassRec MwFrameClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -40,7 +40,7 @@ MwClassRec MwImageClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -57,7 +57,7 @@ MwClassRec MwLabelClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -112,7 +112,7 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
(void)user;
|
||||
(void)call;
|
||||
|
||||
MwForceRender(lb->frame);
|
||||
lb->changed = 1;
|
||||
}
|
||||
|
||||
static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||
@@ -312,6 +312,7 @@ static int create(MwWidget handle) {
|
||||
lb->selected = -1;
|
||||
lb->click_time = 0;
|
||||
lb->width = NULL;
|
||||
lb->changed = 0;
|
||||
|
||||
MwSetInteger(handle, MwNleftPadding, 0);
|
||||
MwSetInteger(handle, MwNhasHeading, 0);
|
||||
@@ -505,6 +506,15 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
||||
}
|
||||
}
|
||||
|
||||
static void tick(MwWidget handle){
|
||||
MwListBox lb = handle->internal;
|
||||
|
||||
if(lb->changed){
|
||||
lb->changed = 0;
|
||||
MwForceRender(lb->frame);
|
||||
}
|
||||
}
|
||||
|
||||
MwClassRec MwListBoxClassRec = {
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
@@ -517,7 +527,7 @@ MwClassRec MwListBoxClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
tick, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -209,7 +209,7 @@ MwClassRec MwMenuClassRec = {
|
||||
mouse_down, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -140,7 +140,7 @@ MwClassRec MwNumberEntryClassRec = {
|
||||
mouse_down, /* mouse_down */
|
||||
key, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -180,7 +180,7 @@ MwClassRec MwOpenGLClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -56,7 +56,7 @@ MwClassRec MwProgressBarClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -57,7 +57,7 @@ MwClassRec MwRadioBoxClassRec = {
|
||||
MwForceRender2, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -254,7 +254,7 @@ MwClassRec MwScrollBarClassRec = {
|
||||
mouse_down, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -208,7 +208,7 @@ MwClassRec MwSubMenuClassRec = {
|
||||
MwForceRender2, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -3,28 +3,20 @@
|
||||
|
||||
static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
MwViewport vp = user;
|
||||
int v = MwGetInteger(handle, MwNvalue);
|
||||
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNheight);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
|
||||
(void)handle;
|
||||
(void)call;
|
||||
if(v < 0) v = 0;
|
||||
MwVaApply(vp->inframe,
|
||||
MwNy, -v,
|
||||
NULL);
|
||||
|
||||
vp->vchanged = 1;
|
||||
}
|
||||
|
||||
static void hscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
MwViewport vp = user;
|
||||
int v = MwGetInteger(handle, MwNvalue);
|
||||
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNwidth);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
|
||||
(void)handle;
|
||||
(void)call;
|
||||
if(v < 0) v = 0;
|
||||
MwVaApply(vp->inframe,
|
||||
MwNx, -v,
|
||||
NULL);
|
||||
|
||||
vp->hchanged = 1;
|
||||
}
|
||||
|
||||
static void resize(MwWidget handle) {
|
||||
@@ -91,6 +83,9 @@ static int create(MwWidget handle) {
|
||||
|
||||
MwSetDefault(handle);
|
||||
|
||||
vp->vchanged = 0;
|
||||
vp->hchanged = 0;
|
||||
|
||||
resize(handle);
|
||||
|
||||
return 0;
|
||||
@@ -146,6 +141,37 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
||||
}
|
||||
}
|
||||
|
||||
static void tick(MwWidget handle){
|
||||
MwViewport vp = handle->internal;
|
||||
|
||||
if(vp->vchanged){
|
||||
vp->vchanged = 0;
|
||||
|
||||
int v = MwGetInteger(vp->vscroll, MwNvalue);
|
||||
int mv = MwGetInteger(vp->vscroll, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNheight);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
|
||||
if(v < 0) v = 0;
|
||||
MwVaApply(vp->inframe,
|
||||
MwNy, -v,
|
||||
NULL);
|
||||
}
|
||||
if(vp->hchanged){
|
||||
vp->vchanged = 0;
|
||||
|
||||
int v = MwGetInteger(vp->hscroll, MwNvalue);
|
||||
int mv = MwGetInteger(vp->hscroll, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNwidth);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
|
||||
if(v < 0) v = 0;
|
||||
MwVaApply(vp->inframe,
|
||||
MwNx, -v,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
MwClassRec MwViewportClassRec = {
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
@@ -158,7 +184,7 @@ MwClassRec MwViewportClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
tick, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -524,7 +524,7 @@ MwClassRec MwVulkanClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
@@ -44,7 +44,7 @@ MwClassRec MwWindowClassRec = {
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL,
|
||||
NULL, /* tick */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
Reference in New Issue
Block a user