[hackers] [swk] do not overlap widgets when vertical fill used || pancake

From: <hg_AT_suckless.org>
Date: Tue, 27 Apr 2010 00:15:52 +0000 (UTC)

changeset: 21:60dd05d78919
tag: tip
user: pancake <pancake_AT_nopcode.org>
date: Tue Apr 27 02:09:26 2010 +0200
files: gi_sdl.c swk.c test.c
description:
do not overlap widgets when vertical fill used
add second screen in test program

diff -r 908e06f5611b -r 60dd05d78919 gi_sdl.c
--- a/gi_sdl.c Tue Apr 27 01:42:50 2010 +0200
+++ b/gi_sdl.c Tue Apr 27 02:09:26 2010 +0200
@@ -79,8 +79,8 @@
         screen = SDL_GetVideoSurface();
         if (screen == NULL)
                 return 0;
- w->r.w = screen->w / FS;
- w->r.h = screen->h / FS;
+ w->r.w = (screen->w / FS)-1;
+ w->r.h = (screen->h / FS)-1;
         return 1;
 }
 
diff -r 908e06f5611b -r 60dd05d78919 swk.c
--- a/swk.c Tue Apr 27 01:42:50 2010 +0200
+++ b/swk.c Tue Apr 27 02:09:26 2010 +0200
@@ -81,7 +81,7 @@
 
 void
 swk_fit(SwkWindow *w) {
- int x, y = 0;
+ int x, yi, y = 0;
         SwkBox *b, *b2;
         for(b=b2=w->boxes; b->cb; b++) {
                 if(b->r.w==-1 && b->r.h==-1) {
@@ -93,11 +93,9 @@
                         } else {
                                 swk_fit_row(w, b2, b, y);
                                 b2 = b+1;
- y += 1+(w->r.h-countrows(b2));
- if (y<0) {
- fprintf(stderr, "overflow: must scroll\n");
- y=0;
- }
+ yi = (w->r.h-countrows(b2));
+ if (yi<2) y += 2;
+ else y += yi;
                         }
                 }
         }
diff -r 908e06f5611b -r 60dd05d78919 test.c
--- a/test.c Tue Apr 27 01:42:50 2010 +0200
+++ b/test.c Tue Apr 27 02:09:26 2010 +0200
@@ -5,6 +5,9 @@
 static char text[64];
 static SwkBox helloworld[];
 static SwkBox *opt = NULL;
+static void mybutton(SwkEvent *e);
+static void mybutton_about(SwkEvent *e);
+static void mybutton_about_ok(SwkEvent *e);
 
 static void mybutton(SwkEvent *e) {
         if (e->type == EClick) {
@@ -19,6 +22,33 @@
         swk_button(e);
 }
 
+static SwkBox about[] = {
+ { .cb=swk_label, .text="About this program...", },
+ SWK_BOX_NEWLINE(1),
+ { .cb=swk_separator },
+ { .cb=swk_label, .text="This program aims to be\nfor hackers\nand developers\n" },
+ SWK_BOX_NEWLINE(-1),
+ { .cb=swk_filler },
+ { .cb=mybutton_about_ok, .text="Ok" },
+ { .cb=NULL }
+};
+
+static void mybutton_about_ok(SwkEvent *e) {
+ if (e->type == EClick) {
+ e->win->boxes = helloworld;
+ swk_update(e->win);
+ }
+ swk_button(e);
+}
+
+static void mybutton_about(SwkEvent *e) {
+ if (e->type == EClick) {
+ e->win->boxes = about;
+ swk_update(e->win);
+ }
+ swk_button(e);
+}
+
 static SwkBox helloworld[] = {
         { .cb=swk_label, .text="Press a button", },
         SWK_BOX_NEWLINE(1),
@@ -42,6 +72,7 @@
         { .cb=swk_option, .text="pasta barata", .data=&opt },
         SWK_BOX_NEWLINE(5),
         { .cb=swk_label, .text="--swktest", },
+ { .cb=mybutton_about, .text="about" },
         { .cb=NULL }
 };
 
Received on Tue Apr 27 2010 - 00:15:52 UTC

This archive was generated by hypermail 2.2.0 : Tue Apr 27 2010 - 00:24:03 UTC