changeset: 31:37c83bbb01dc
tag: tip
user: pancake <pancake_AT_nopcode.org>
date: Thu Apr 29 00:08:08 2010 +0200
files: README config.def.h gi_sdl.c swk.c swk.h test.c
description:
fix img_free
fix line width in swk_label
some changes in config.h
diff -r f140304792f8 -r 37c83bbb01dc README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Thu Apr 29 00:08:08 2010 +0200
@@ -0,0 +1,64 @@
+SWK - simple widget kit
+=======================
+
+ pacman -S sdl sdl_ttf sdl_image
+
+Usability guideline
+===================
+Default keybindings are defined in config.h
+
+TODO
+====
+* support for clipboard (implemented in gi_ backend)
+* simple way to define callback for buttons instead of reimplementing widget
+* scroll on focus
+* mouse bindings
+* allow widgets to define their boundaries to force size
+* add support to resize images
+* only focus buttons and entries
+* add function to click button 1, 2, 3, ...
+* allow to load images from memory instead of files
+* default image path
+
+Text format UI design
+=====================
+
+ \n -> newline
+ \t -> swk_filler
+ ".." -> swk_label
+ ---* -> swk_separator
+ ===* -> newline(-1)
+ [..] -> button
+ (..) -> option
+ <.*> -> image
+
+Example description:
+--------------------
+
+ {HelloWorld
+ "Press a button"
+ ----------------
+ (save password)
+ (store options)
+ [Ok] [Cancel]
+ ================
+ "This is new"
+ <image.png>
+ }
+
+Test program:
+-------------
+
+ void onclick() {
+ if(e->type != EClick || e->box->text==NULL)
+ return;
+ if(!strcmp(e->box->text, "Ok")) {
+ }
+ }
+ SwkWindow *w = swk_ui(
+ "{HelloWorld\n
+ "\"Press a button\"\n"
+ "--\n"
+ "[Ok] [Cancel]\n==\n");
+ w->cb = onclick;
+ swk_ui_free(w);
diff -r f140304792f8 -r 37c83bbb01dc config.def.h
--- a/config.def.h Wed Apr 28 23:05:51 2010 +0200
+++ b/config.def.h Thu Apr 29 00:08:08 2010 +0200
@@ -4,7 +4,7 @@
#ifdef N900
#define FONTSIZE 32
#else
-#define FONTSIZE 14
+#define FONTSIZE 28
#endif
/* appearance */
@@ -17,8 +17,8 @@
//#define SWK_COLOR(r,g,b) r##g##b
#define HICOLOR SWK_COLOR(0,66,ff)
+#define BGCOLOR SWK_COLOR(20,20,20)
#define FGCOLOR SWK_COLOR(e0,e0,e0)
-#define BGCOLOR SWK_COLOR(00,00,00)
#define TFCOLOR SWK_COLOR(cc,cc,cc)
/* key bindings */
@@ -31,7 +31,7 @@
{ Ctrl, 10 , swk_focus_next },
{ Ctrl, 11 , swk_focus_prev },
{ Ctrl, 12 , swk_focus_activate },
- { 0, 225, swk_focus_activate }, // n900 enter
+ { 0, 225, swk_focus_activate }, // n900 enter
{ 0 , KUp, swk_focus_prev },
{ 0 , KDown, swk_focus_next },
{ 0 , 13 , swk_focus_activate },
diff -r f140304792f8 -r 37c83bbb01dc gi_sdl.c
--- a/gi_sdl.c Wed Apr 28 23:05:51 2010 +0200
+++ b/gi_sdl.c Thu Apr 29 00:08:08 2010 +0200
@@ -264,7 +264,6 @@
}
/* images */
-
void
swk_gi_img(Rect r, void *img) {
SDL_Surface *s = (SDL_Surface*)img;
@@ -277,9 +276,9 @@
return IMG_Load(str);
}
-void*
-swk_gi_img_free(const char *str) {
- return IMG_Load(str);
+void
+swk_gi_img_free(void *s) {
+ SDL_FreeSurface(s);
}
void
diff -r f140304792f8 -r 37c83bbb01dc swk.c
--- a/swk.c Wed Apr 28 23:05:51 2010 +0200
+++ b/swk.c Thu Apr 29 00:08:08 2010 +0200
@@ -290,6 +290,7 @@
r = e->box->r;
r.w+=6;
swk_gi_text(r, e->box->text);
+ r.w-=6;
if(e->win->box == e->box)
swk_gi_line(r.x, r.y+1, r.w, 0, ColorHI);
break;
diff -r f140304792f8 -r 37c83bbb01dc swk.h
--- a/swk.h Wed Apr 28 23:05:51 2010 +0200
+++ b/swk.h Thu Apr 29 00:08:08 2010 +0200
@@ -125,6 +125,6 @@
/* images */
void swk_gi_img(Rect r, void *img);
void* swk_gi_img_load(const char *str);
-void* swk_gi_img_free(const char *str);
+void swk_gi_img_free(void *s);
void swk_gi_img_set(void *img, int x, int y, int color);
int swk_gi_img_get(void *img, int x, int y);
diff -r f140304792f8 -r 37c83bbb01dc test.c
--- a/test.c Wed Apr 28 23:05:51 2010 +0200
+++ b/test.c Thu Apr 29 00:08:08 2010 +0200
@@ -40,7 +40,7 @@
}
static SwkBox about[] = {
- SWK_BOX_NEWLINE(-1),
+ SWK_BOX_NEWLINE(0),
{ .cb=swk_label, .text="About this program...", },
SWK_BOX_NEWLINE(1),
{ .cb=swk_separator },
Received on Wed Apr 28 2010 - 22:14:33 UTC
This archive was generated by hypermail 2.2.0 : Wed Apr 28 2010 - 22:24:03 UTC