added mousewheel support
authorRob Haarsma <phaseIV@zonnet.nl>
Mon, 27 Jan 2003 23:57:43 +0000 (23:57 +0000)
committerRob Haarsma <phaseIV@zonnet.nl>
Mon, 27 Jan 2003 23:57:43 +0000 (23:57 +0000)
source/blender/include/mydevice.h
source/blender/src/filesel.c
source/blender/src/ghostwinlay.c

index 43e42c8a49a394bb6c78c486bee54e7d4b9166fb..3bbaafd0c1a7b99fca3ee29b74c2d52eebb0b8db 100644 (file)
@@ -45,6 +45,8 @@
 #define RIGHTMOUSE     0x003   
 #define MOUSEX         0x004   
 #define MOUSEY         0x005   
+#define WHEELUPMOUSE   0x00a   
+#define WHEELDOWNMOUSE 0x00b   
 
 /* timers */
 
index 60948b8291e460c24602ce37bca7a6db63180329..d3bc996c7db1efd98956f46c2ab165576337005a 100644 (file)
@@ -1153,6 +1153,27 @@ static void do_filescroll(SpaceFile *sfile)
        
 }
 
+static void do_filescrollwheel(SpaceFile *sfile, int move)
+{
+       // by phase
+       int lines, rt;
+
+       calc_file_rcts(sfile);
+
+       lines = (int)(textrct.ymax-textrct.ymin)/FILESEL_DY;
+       rt = lines * sfile->collums;
+
+       if(sfile->totfile > rt) {
+               sfile->ofs+= move;
+               if( sfile->ofs + rt > sfile->totfile + 1)
+                       sfile->ofs = sfile->totfile - rt + 1;
+       }
+
+       if(sfile->ofs<0) {
+               sfile->ofs= 0;
+       }
+}
+
 void activate_fileselect(int type, char *title, char *file, void (*func)(char *))
 {
        SpaceFile *sfile;
@@ -1715,6 +1736,19 @@ void winqreadfilespace(unsigned short event, short val, char ascii)
                        do_filesel_buttons(val, sfile);
                        break;          
                
+               case WHEELDOWNMOUSE:
+                       do_filescrollwheel(sfile, 3); //U.wheellinescroll);
+                       act= find_active_file(sfile, mval[0], mval[1]);
+                       set_active_file(sfile, act);
+                       do_draw= 1;
+                       break;
+               case WHEELUPMOUSE:
+                       do_filescrollwheel(sfile, -3); //U.wheellinescroll);
+                       act= find_active_file(sfile, mval[0], mval[1]);
+                       set_active_file(sfile, act);
+                       do_draw= 1;
+                       break;
+
                case LEFTMOUSE:
                case MIDDLEMOUSE:
                        if(mval[0]>scrollrct.xmin && mval[0]<scrollrct.xmax && mval[1]>scrollrct.ymin && mval[1]<scrollrct.ymax) {
index a8863816a0125ca52028ce17cb0484ac3586f6d6..2d46de955380e7cec714d40ed7500816dea167ac 100644 (file)
@@ -435,6 +435,20 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) {
                        break;
                }
        
+               case GHOST_kEventWheel:
+               {
+                       GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) data;
+                       if (wheelData->z > 0)
+                       {
+                               window_handle(win, WHEELUPMOUSE, 1);
+                       }
+                       else
+                       {
+                               window_handle(win, WHEELDOWNMOUSE, 1);
+                       }
+                       }
+                       break;
+
                case GHOST_kEventWindowDeactivate:
                case GHOST_kEventWindowActivate: {
                        win->active= (type==GHOST_kEventWindowActivate);