summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--inc/cursesview.h9
-rw-r--r--src/cursesview.c16
-rwxr-xr-xsrc/essais/compil.sh7
4 files changed, 23 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index fdbd50d..fccc821 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ Makefile src/%.c inc/%.h: ;
.PHONY: clean
clean:
- -rm -f obj/*.o deps/*.d bin/*
+ -rm -f obj/*.o deps/*.d bin/$(BIN)
cont:
while true; do clear; date; LANG=C make; echo "make returns '$$?'";\
diff --git a/inc/cursesview.h b/inc/cursesview.h
new file mode 100644
index 0000000..f4d343a
--- /dev/null
+++ b/inc/cursesview.h
@@ -0,0 +1,9 @@
+#ifndef CURSESVIEW_H
+#define CURSESVIEW_H
+
+#include "slices_evt.h"
+
+void cursesMainLoop(slices_evt_t *slicesEvt);
+
+#endif /*CURSESVIEW_H*/
+
diff --git a/src/cursesview.c b/src/cursesview.c
index 0d46daf..36e125e 100644
--- a/src/cursesview.c
+++ b/src/cursesview.c
@@ -31,7 +31,7 @@ void cursesMainLoop(slices_evt_t *slicesEvt) {
#ifdef NCURSES_MOUSE_VERSION
int dispatched, res;
- int (*dispatchTo)(MEVENT mevent, WINDOW *winDebug);
+ int (*mouseEventListener)(MEVENT mevent, WINDOW *winDebug);
MEVENT mevent;
PANEL *p;
#endif
@@ -98,9 +98,8 @@ void cursesMainLoop(slices_evt_t *slicesEvt) {
// If we found a panel, dispatch the event if a listener is set
if (p != NULL) {
dispatched=0;
- dispatchTo=(int (*)(MEVENT mevent, WINDOW *winDebug)) panel_userptr(p);
-
- if (dispatchTo != NULL) dispatched=dispatchTo(mevent, wins[0]);
+ mouseEventListener=(int (*)(MEVENT mevent, WINDOW *winDebug)) panel_userptr(p);
+ if (mouseEventListener != NULL) dispatched=mouseEventListener(mevent, wins[0]);
if ( ! dispatched ) {
// If no listener or event not consumed, use the default behavior : set the panel on top
if ( (mevent.bstate & BUTTON1_CLICKED) == BUTTON1_CLICKED) {
@@ -131,6 +130,8 @@ void cursesMainLoop(slices_evt_t *slicesEvt) {
}
// TODO : faire une structure avec tous les éléments graphiques utiles au listener et tout passer par référence de la mainloop à ce listener
+#define DEFAULT_ZOOM_FACTOR 2.f
+
int winUpdateSliceDumpMouseEventListener(MEVENT mevent, WINDOW *winDebug) {
bool resb;
int pX, pY, maxX, maxY;
@@ -143,12 +144,13 @@ int winUpdateSliceDumpMouseEventListener(MEVENT mevent, WINDOW *winDebug) {
resb=wmouse_trafo(winUpdateSliceDump, &pY, &pX, false);
if ( resb == TRUE ) {
getmaxyx(winUpdateSliceDump, maxY, maxX);
- pos=(pY*maxX+pX)/(maxY*maxX);
+ pos=(0.0f+pY*maxX+pX)/(maxY*maxX);
delta=sliceDumpEnd-sliceDumpBegin;
- sliceDumpBegin+=delta*pos/2;
- sliceDumpEnd-=delta*(1-pos)/2;
+ sliceDumpBegin+=delta*pos/DEFAULT_ZOOM_FACTOR*(DEFAULT_ZOOM_FACTOR-1);
+ sliceDumpEnd-=delta*(1-pos)/DEFAULT_ZOOM_FACTOR*(DEFAULT_ZOOM_FACTOR-1);
}
+//FIXME : pb avec le zoom factor
sprintf(buf, "Debug : pos==%f, sliceDumpEnd==%lli, sliceDumpBegin=%lli, delta==%lli", pos, sliceDumpEnd, sliceDumpBegin, delta);
wattron(winDebug, COLOR_PAIR(4));
mvwprintw(winDebug, 2, 0, buf);
diff --git a/src/essais/compil.sh b/src/essais/compil.sh
index 18d7681..a867c5a 100755
--- a/src/essais/compil.sh
+++ b/src/essais/compil.sh
@@ -1,3 +1,4 @@
-gcc -Wall -o test -g -lncurses test.c
-gcc -Wall -o test2 -g -lncurses -lpanel test2.c
-gcc -Wall -o test3 -g -lncurses -lpanel test3.c
+#!/bin/bash
+gcc -Wall -o ../../bin/test -g -lncurses test.c
+gcc -Wall -o ../../bin/test2 -g -lncurses -lpanel test2.c
+gcc -Wall -o ../../bin/test3 -g -lncurses -lpanel test3.c