Revision: 17690
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17690
Author:   ton
Date:     2008-12-03 14:14:01 +0100 (Wed, 03 Dec 2008)

Log Message:
-----------
2.5 fixes

- View2d bug: it was taking sliders into account for setting the 
  window matrix, which it shouldn't (glViewport does). This caused
  error offset in drawing, like for current-frame scrolling.

- Current frame scrolling in TimeWindow back on window level.
  (used to crash, but that was fixed in WM)

- Made UI_view2d_region_to_view accept ints, no shorts

- removed debug function in interface_ops.c

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_ops.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h      
2008-12-03 09:06:30 UTC (rev 17689)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h      
2008-12-03 13:14:01 UTC (rev 17690)
@@ -99,7 +99,7 @@
 void UI_view2d_free_scrollers(View2DScrollers *scrollers);
 
 /* coordinate conversion */
-void UI_view2d_region_to_view(struct View2D *v2d, short x, short y, float 
*viewx, float *viewy);
+void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, 
float *viewy);
 void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short 
*regionx, short *regiony);
 void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short 
*regionx, short *region_y);
 

Modified: 
branches/blender2.5/blender/source/blender/editors/interface/interface_ops.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/interface/interface_ops.c    
    2008-12-03 09:06:30 UTC (rev 17689)
+++ 
branches/blender2.5/blender/source/blender/editors/interface/interface_ops.c    
    2008-12-03 13:14:01 UTC (rev 17690)
@@ -3080,25 +3080,14 @@
        return 0;
 }
 
-#include "wm_event_system.h"
-static void testing123(bContext *C)
-{
-       wmEventHandler *handler;
-       
-       for(handler= C->window->handlers.first; handler; handler= 
handler->next) {
-               if(handler->op)
-                       printf("handler has op %s\n", 
handler->op->type->idname);
-       }
-}
-
 /* moves focus on button/menu from mousemove-based to hotkey */
 static void menu_block_handle_activate_button(bContext *C, wmEvent *event, 
ARegion *butregion, uiBut *but, int activateflag)
 {
        wmOperatorType *ot;
 
        ot= WM_operatortype_find("ED_UI_OT_button_activate");
-       testing123(C);
-// XXX WM_operator_cancel(C, &butregion->modalops, ot);
+
+       // XXX  WM_operator_cancel(C, &butregion->modalops, ot);
        but->activateflag= activateflag;
 
        SWAP(ARegion*, C->region, butregion); /* XXX 2.50 bad state 
manipulation? */

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-03 09:06:30 UTC (rev 17689)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c       
2008-12-03 13:14:01 UTC (rev 17690)
@@ -326,32 +326,18 @@
 /* View Matrix Setup */
 
 /* Set view matrices to use 'cur' rect as viewing frame for View2D drawing 
- *     - Scrollbars are taken into account when making this matrix, given that 
most regions have them
+ *     - this assumes viewport/scissor been set for the region, taking 
scrollbars into account
  */
 void UI_view2d_view_ortho(const bContext *C, View2D *v2d)
 {
-       float ofsx1, ofsy1, ofsx2, ofsy2;
-       
-       ofsx1= ofsy1= ofsx2= ofsy2= 0.0f;
-       
-       /* calculate offset factor required on each axis */
-       if (v2d->scroll & L_SCROLL)
-               ofsy1= (float)SCROLLB;
-       if (v2d->scroll & R_SCROLL)
-               ofsy2= (float)SCROLLB;
-       if (v2d->scroll & T_SCROLL)
-               ofsx1= (float)SCROLLH;
-       if (v2d->scroll & B_SCROLL)
-               ofsx2= (float)SCROLLH;
-       
        /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are 
not applied, 
         * as they were causing some unwanted offsets when drawing 
         */
-       wmOrtho2(C->window, v2d->cur.xmin-ofsx1, v2d->cur.xmax-ofsx2, 
v2d->cur.ymin-ofsy1, v2d->cur.ymax-ofsx2);
+       wmOrtho2(C->window, v2d->cur.xmin, v2d->cur.xmax, v2d->cur.ymin, 
v2d->cur.ymax);
 }
 
-/* Set view matices to only use one axis of 'cur' only
- *     - Scrollbars on appropriate axis will be taken into account
+/* Set view matrices to only use one axis of 'cur' only
+ *     - this assumes viewport/scissor been set for the region, taking 
scrollbars into account
  *
  *     - xaxis         = if non-zero, only use cur x-axis, otherwise use 
cur-yaxis (mostly this will be used for x)
  */
@@ -359,30 +345,18 @@
 {
        ARegion *region= C->region;
        int winx, winy;
-       float ofsx1, ofsy1, ofsx2, ofsy2;
        
        /* calculate extents of region */
        winx= region->winrct.xmax - region->winrct.xmin;
        winy= region->winrct.ymax - region->winrct.ymin;
-       ofsx1= ofsy1= ofsx2= ofsy2= 0.0f;
        
-       /* calculate offset factor required on each axis */
-       if (v2d->scroll & L_SCROLL)
-               ofsy1= (float)SCROLLB;
-       if (v2d->scroll & R_SCROLL)
-               ofsy2= (float)SCROLLB;
-       if (v2d->scroll & T_SCROLL)
-               ofsx1= (float)SCROLLH;
-       if (v2d->scroll & B_SCROLL)
-               ofsx2= (float)SCROLLH;
-       
        /* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are 
not applied, 
         * as they were causing some unwanted offsets when drawing 
         */
        if (xaxis)
-               wmOrtho2(C->window, v2d->cur.xmin-ofsx1, v2d->cur.xmax-ofsx2, 
0, winy);
+               wmOrtho2(C->window, v2d->cur.xmin, v2d->cur.xmax, 0, winy);
        else
-               wmOrtho2(C->window, 0, winx, v2d->cur.ymin-ofsy1, 
v2d->cur.ymax-ofsx2);
+               wmOrtho2(C->window, 0, winx, v2d->cur.ymin, v2d->cur.ymax);
 } 
 
 
@@ -777,7 +751,7 @@
  *     - x,y                   = coordinates to convert
  *     - viewx,viewy           = resultant coordinates
  */
-void UI_view2d_region_to_view(View2D *v2d, short x, short y, float *viewx, 
float *viewy)
+void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *viewx, float 
*viewy)
 {
        float div, ofs;
 
@@ -785,14 +759,14 @@
                div= v2d->mask.xmax - v2d->mask.xmin;
                ofs= v2d->mask.xmin;
                
-               *viewx= v2d->cur.xmin + (v2d->cur.xmax-v2d->cur.xmin) * (x - 
ofs) / div;
+               *viewx= v2d->cur.xmin + (v2d->cur.xmax-v2d->cur.xmin) * 
((float)x - ofs) / div;
        }
 
        if (viewy) {
                div= v2d->mask.ymax - v2d->mask.ymin;
                ofs= v2d->mask.ymin;
                
-               *viewy= v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * (y - 
ofs) / div;
+               *viewy= v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * 
((float)y - ofs) / div;
        }
 }
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c    
2008-12-03 09:06:30 UTC (rev 17689)
+++ branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c    
2008-12-03 13:14:01 UTC (rev 17690)
@@ -27,6 +27,7 @@
  */
 
 #include <stdlib.h>
+#include <math.h>
 
 #include "MEM_guardedalloc.h"
 
@@ -107,7 +108,6 @@
 
 static int frame_from_event(bContext *C, wmEvent *event)
 {
-       SpaceTime *stime= C->area->spacedata.first;
        ARegion *region= C->region;
        int x, y;
        float viewx;
@@ -116,7 +116,7 @@
        y= event->y - region->winrct.ymin;
        UI_view2d_region_to_view(&region->v2d, x, y, &viewx, NULL);
 
-       return (int)(viewx+0.5f);
+       return (int)floor(viewx+0.5f);
 }
 
 static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -126,7 +126,7 @@
        change_frame_apply(C, op);
 
        /* add temp handler */
-       WM_event_add_modal_handler(C, &C->region->handlers, op);// XXX should 
be for window, but we crash otherwise
+       WM_event_add_modal_handler(C, &C->window->handlers, op);
 
        return OPERATOR_RUNNING_MODAL;
 }


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to