[hackers] [swk] added horitzontal dragging support to move column position || pancake

From: <hg_AT_suckless.org>
Date: Fri, 11 Jun 2010 09:29:50 +0000 (UTC)

changeset: 49:12c8213191f8
user: pancake <pancake_AT_nopcode.org>
date: Fri Jun 11 10:46:31 2010 +0200
files: TODO config.n900.h gi_sdl.c swk.c
description:
added horitzontal dragging support to move column position
dim colpos range between [0:w->r.w]
sync config.n900.h

diff -r 5de9df30c240 -r 12c8213191f8 TODO
--- a/TODO Fri Jun 11 00:47:22 2010 +0200
+++ b/TODO Fri Jun 11 10:46:31 2010 +0200
@@ -17,6 +17,12 @@
   * default image path (?)
   * transitions (to change from one window to another)
 
+absolute/relative
+=================
+ * column split position (w->colpos)
+ * scrolling box
+ * font size
+
 USABILITY GUIDELINE
 ===================
   * useful
diff -r 5de9df30c240 -r 12c8213191f8 config.n900.h
--- a/config.n900.h Fri Jun 11 00:47:22 2010 +0200
+++ b/config.n900.h Fri Jun 11 10:46:31 2010 +0200
@@ -1,7 +1,9 @@
 #define PORTRAIT 0
+#define SCROLLSPEED 2
+#define COLSPLIT 20
 
 #define FONTBOLD 1
-#define FONTSIZE 32
+#define FONTSIZE 28
 #define TOUCHSCREEN 1
 
 #if PORTRAIT
diff -r 5de9df30c240 -r 12c8213191f8 gi_sdl.c
--- a/gi_sdl.c Fri Jun 11 00:47:22 2010 +0200
+++ b/gi_sdl.c Fri Jun 11 10:46:31 2010 +0200
@@ -118,7 +118,7 @@
 
 SwkEvent *
 swk_gi_event(SwkWindow *w, int dowait) {
- static int mousedowny, mousedown = 0;
+ static int mousedowny, mousedownx, mousedown = 0;
         static int mousemoved = 0;
         SDL_Event event;
         SwkEvent *ret = &w->_e;
@@ -139,11 +139,12 @@
                 ret->data.expose.w = ret->data.expose.h = 0;
                 break;
         case SDL_MOUSEMOTION:
+ // TODO: move this stuff into swk.c.. shoudlnt be backend dependent
                 //fprintf(stderr, "event: motion (%d,%d)\n", event.motion.x,event.motion.y);
                 if(mousedown) {
- if(mousedowny==-1) // touchscreen trick
- mousedowny = event.motion.y;
- else mousemoved = 1;
+ // touchscreen spaguetti trick
+ if(mousedowny==-1) mousedowny = event.motion.y; else mousemoved = 1;
+ if(mousedownx==-1) mousedownx = event.motion.x; else mousemoved = 1;
                         if(event.motion.y>mousedowny+fs) {
                                 mousedowny = event.motion.y;
                                 swk_scroll_up(w);
@@ -152,6 +153,14 @@
                                 mousedowny = event.motion.y;
                                 swk_scroll_down(w);
                         }
+ if(event.motion.x>mousedownx+fs) {
+ mousedownx = event.motion.x;
+ swk_column_move_right();
+ } else
+ if(event.motion.x<mousedownx-fs) {
+ mousedownx = event.motion.x;
+ swk_column_move_left();
+ }
                         ret->type = EExpose;
                         ret->data.expose.x = ret->data.expose.y = \
                         ret->data.expose.w = ret->data.expose.h = 0;
diff -r 5de9df30c240 -r 12c8213191f8 swk.c
--- a/swk.c Fri Jun 11 00:47:22 2010 +0200
+++ b/swk.c Fri Jun 11 10:46:31 2010 +0200
@@ -106,13 +106,15 @@
 
 void
 swk_column_move_left() {
- w->colpos--;
+ if(w->colpos>0)
+ w->colpos--;
         swk_update(w);
 }
 
 void
 swk_column_move_right() {
- w->colpos++;
+ if(w->colpos<w->r.w)
+ w->colpos++;
         swk_update(w);
 }
 
@@ -160,7 +162,7 @@
 
 static int
 countrows(SwkBox *b) {
- int row = 17; // hacky value to center widgets
+ int row = 17; // XXX hacky value to center widgets
         for(; b->cb; b++)
                 if(IS_SCROLLBOX(b))
                         row += (int)(size_t)b->data;
Received on Fri Jun 11 2010 - 09:29:50 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 11 2010 - 09:36:04 UTC