commit 9c322d3bc4f1673feef3140c729f02ca6abe94f2
parent c3e152642868ef546b1edfcc2e1c5c4ac70dab40
Author: pancake <pancake@nopcode.org>
Date:   Wed, 25 Aug 2010 05:30:41 +0200
various fixes in animation and layout of test.c
Diffstat:
3 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/gi_x11.c b/gi_x11.c
@@ -128,23 +128,22 @@ swk_gi_event(SwkWindow *w, int dowait) {
 		if(!mousemoved) {
 			ret->type = EClick;
 			switch(event.xbutton.state) {
-			case 4096:
+			case 4096: // 0x1000
 				ret->data.click.button = 4;
 				break;
-			case 2048:
+			case 2048: // 0x800
 				ret->data.click.button = 5;
 				break;
-			case 1024:
+			case 1024: // 0x400
 				ret->data.click.button = 2;
 				break;
-			case 512:
+			case 512: // 0x200
 				ret->data.click.button = 3;
 				break;
-			case 256:
+			case 256: // 0x100
 				ret->data.click.button = 1;
 				break;
 			}
-printf ("STATE=%d\n", event.xbutton.state);
 			ret->data.click.point.x = event.xbutton.x / fs;
 			ret->data.click.point.y = event.xbutton.y / fs;
 		}
@@ -294,7 +293,7 @@ swk_gi_img_new(int w, int h, int color) {
 void*
 swk_gi_img_load(const char *str) {
 	/* TODO */
-	return NULL;
+	return (void*)1;
 }
 
 void
diff --git a/swk.c b/swk.c
@@ -61,14 +61,15 @@ swk_update() {
 	if(rendering)
 		return;
 	// TODO: Handle scrollup by widget focus
-	if(w->box->r.y > w->r.h)
-		setscrollbox(-2);
+	//if(w->box->r.y > w->r.h)
+		//setscrollbox(-2);
 	rendering = 1;
 	w->_e.type = EExpose;
 	if(swk_gi_update(w)) {
 		int count = 2;
 		int orw = w->r.w;
 		SwkBox *b = w->boxes[0];
+
 		swk_fit(w);
 		swk_gi_clear();
 		//if(!w->colpos) {
@@ -98,7 +99,7 @@ swk_update() {
 					//swk_gi_line(--r.x, roy, 2, 0, ColorHI);
 					swk_gi_line((b==w->boxes[0])?w->colpos:0, roy, w->r.w, 0, ColorHI);
 				} else b->cb(&w->_e);
-				oy = b->r.y;
+				oy = b->r.h;
 			}
 			if(!w->boxes[1] || !--count)
 				break;
diff --git a/t/test.c b/t/test.c
@@ -83,11 +83,15 @@ static void animate(SwkWindow *w, int s) {
 		swk_update(w);
 		usleep(10000);
 	}
-	w->col=(w->colpos>0)?1:0;
+	w->colpos=s>0?w->r.w:0;
+	w->col=(s>0)?0:1;
+	w->box=w->boxes[s>0?1:0];
 }
 static void mybutton_about_ok(SwkEvent *e) {
 	if(e->type == EClick) {
-		e->win->boxes[e->win->col] = helloworld;
+		animate(e->win, -1);
+		e->win->boxes[0] = helloworld;
+		animate(e->win, 1);
 		swk_update(e->win);
 	}
 	swk_button(e);
@@ -96,7 +100,7 @@ static void mybutton_about_ok(SwkEvent *e) {
 static void mybutton_about(SwkEvent *e) {
 	if(e->type == EClick) {
 		animate(e->win, -1);
-		e->win->boxes[e->win->col] = about;
+		e->win->boxes[0] = about;
 		swk_update(e->win);
 	}
 	swk_button(e);
@@ -112,7 +116,7 @@ static void mybutton_shrink(SwkEvent *e) {
 
 static void mybutton_close(SwkEvent *e) {
 	if(e->type == EClick) {
-		e->win->boxes[e->win->col] = helloworld;
+		e->win->boxes[0] = helloworld;
 		swk_update(e->win);
 	}
 	swk_button(e);
@@ -124,7 +128,7 @@ static SwkBox scrollwin[] = {
 	SWK_BOX_NEWLINE(1),
 	{ .cb=mybutton_close, .text="Close" },
 	{ .cb=swk_separator },
-	SWK_BOX_NEWLINE(1),
+	SWK_BOX_NEWLINE(2),
 	{ .cb=swk_label, .text="  /etc" },
 	SWK_BOX_NEWLINE(1),
 	{ .cb=swk_button, .text="/bin" },
@@ -136,7 +140,7 @@ static SwkBox scrollwin[] = {
 
 static void mybutton_numscroll(SwkEvent *e) {
 	if(e->type == EClick) {
-		e->win->boxes[e->win->col] = scrollwin;
+		e->win->boxes[0] = scrollwin;
 		swk_update(e->win);
 	}
 	swk_button(e);
@@ -208,6 +212,10 @@ main() {
 	};
 	if(!swk_use(&w))
 		return 1;
+swk_scroll_down();
+swk_scroll_down();
+swk_scroll_down();
+swk_scroll_down();
 	swk_loop();
 	return 0;
 }