Revision: 20379
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20379
Author:   ton
Date:     2009-05-24 15:29:29 +0200 (Sun, 24 May 2009)

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

First version of region-scaling. WIP commit, so bear with me a while!

- All fixed sized regions have a small 'drag' widget, on the left or top.
  (not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
  buttons when width is too small.

The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
  definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
  hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.

But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.

The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
  cursor change shape on every edge (and block input) is probably annoying
  too... but that can be tested.

Later more!

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h
    branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c
    branches/blender2.5/blender/source/blender/blenlib/intern/rct.c
    branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/windowmanager/wm_event_types.h

Modified: branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h     
2009-05-24 12:53:49 UTC (rev 20378)
+++ branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h     
2009-05-24 13:29:29 UTC (rev 20379)
@@ -402,7 +402,7 @@
 void VecfCubicInterpol(float *x1, float *v1, float *x2, float *v2, float t, 
float *x, float *v);
 void PointInQuad2DUV(float v0[2], float v1[2], float v2[2], float v3[2], float 
pt[2], float *uv);
 void PointInFace2DUV(int isquad, float v0[2], float v1[2], float v2[2], float 
v3[2], float pt[2], float *uv);
-int IsPointInTri2D(float v0[2], float v1[2], float v2[2], float pt[2]);
+int IsPointInTri2D(float v1[2], float v2[2], float v3[2], float pt[2]);
 int IsPointInTri2DInts(int x1, int y1, int x2, int y2, int a, int b);
 int point_in_tri_prism(float p[3], float v1[3], float v2[3], float v3[3]);
 

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c  
2009-05-24 12:53:49 UTC (rev 20378)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c  
2009-05-24 13:29:29 UTC (rev 20379)
@@ -4515,6 +4515,21 @@
        }
 }
 
+int IsPointInTri2D(float v1[2], float v2[2], float v3[2], float pt[2])
+{
+       float inp1, inp2, inp3;
+       
+       inp1= (v2[0]-v1[0])*(v1[1]-pt[1]) + (v1[1]-v2[1])*(v1[0]-pt[0]);
+       inp2= (v3[0]-v2[0])*(v2[1]-pt[1]) + (v2[1]-v3[1])*(v2[0]-pt[0]);
+       inp3= (v1[0]-v3[0])*(v3[1]-pt[1]) + (v3[1]-v1[1])*(v3[0]-pt[0]);
+       
+       if(inp1<=0.0f && inp2<=0.0f && inp3<=0.0f) return 1;
+       if(inp1>=0.0f && inp2>=0.0f && inp3>=0.0f) return 1;
+       
+       return 0;
+}
+
+#if 0
 int IsPointInTri2D(float v0[2], float v1[2], float v2[2], float pt[2])
 {
                /* not for quads, use for our abuse of LineIntersectsTriangleUV 
*/
@@ -4542,6 +4557,7 @@
                /* Doing this in 3D is not nice */
                return LineIntersectsTriangle(p1_3d, p2_3d, v0_3d, v1_3d, 
v2_3d, &lambda, uv);
 }
+#endif
 
 /*
 

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/rct.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/rct.c     
2009-05-24 12:53:49 UTC (rev 20378)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/rct.c     
2009-05-24 13:29:29 UTC (rev 20379)
@@ -88,17 +88,42 @@
 
 void BLI_init_rctf(rctf *rect, float xmin, float xmax, float ymin, float ymax)
 {
-       rect->xmin= xmin;
-       rect->xmax= xmax;
-       rect->ymin= ymin;
-       rect->ymax= ymax;
+       if(xmin <= xmax) {
+               rect->xmin= xmin;
+               rect->xmax= xmax;
+       }
+       else {
+               rect->xmax= xmin;
+               rect->xmin= xmax;
+       }
+       if(ymin <= ymax) {
+               rect->ymin= ymin;
+               rect->ymax= ymax;
+       }
+       else {
+               rect->ymax= ymin;
+               rect->ymin= ymax;
+       }
 }
+
 void BLI_init_rcti(rcti *rect, int xmin, int xmax, int ymin, int ymax)
 {
-       rect->xmin= xmin;
-       rect->xmax= xmax;
-       rect->ymin= ymin;
-       rect->ymax= ymax;
+       if(xmin <= xmax) {
+               rect->xmin= xmin;
+               rect->xmax= xmax;
+       }
+       else {
+               rect->xmax= xmin;
+               rect->xmin= xmax;
+       }
+       if(ymin <= ymax) {
+               rect->ymin= ymin;
+               rect->ymax= ymax;
+       }
+       else {
+               rect->ymax= ymin;
+               rect->ymin= ymax;
+       }
 }
 
 void BLI_translate_rcti(rcti *rect, int x, int y)

Modified: 
branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h    
    2009-05-24 12:53:49 UTC (rev 20378)
+++ 
branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h    
    2009-05-24 13:29:29 UTC (rev 20379)
@@ -38,27 +38,20 @@
 
 typedef struct AZone {
        struct AZone *next, *prev;
+       ARegion *ar;
        int type;
-       short flag;
+       /* region-azone, which of the edges */
+       short edge;
+       /* internal */
        short do_draw;
-       int pos;
-       short x1, y1, x2, y2;
+       /* for draw */
+       short x1, y1, x2, y2, x3, y3;
+       /* for clip */
+       rcti rect;      
 } AZone;
 
 /* actionzone type */
-#define        AZONE_TRI                       1
-#define AZONE_QUAD                     2
+#define        AZONE_AREA                      1
+#define AZONE_REGION           2
 
-/* actionzone flag */
-
-/* actionzone pos */
-#define AZONE_S                                1
-#define AZONE_SW                       2
-#define AZONE_W                                3
-#define AZONE_NW                       4
-#define AZONE_N                                5
-#define AZONE_NE                       6
-#define AZONE_E                                7
-#define AZONE_SE                       8
-
 #endif /* ED_SCREEN_TYPES_H__ */

Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/area.c    
2009-05-24 12:53:49 UTC (rev 20378)
+++ branches/blender2.5/blender/source/blender/editors/screen/area.c    
2009-05-24 13:29:29 UTC (rev 20379)
@@ -157,7 +157,16 @@
        AZone *az;
        
        for(az= sa->actionzones.first; az; az= az->next) {
-               int xs= (az->x1+az->x2)/2, ys= (az->y1+az->y2)/2;
+               int xs, ys;
+               
+               if(az->type==AZONE_AREA) {
+                       xs= (az->x1+az->x2)/2;
+                       ys= (az->y1+az->y2)/2;
+               }
+               else {
+                       xs= az->x3;
+                       ys= az->y3;
+               }
 
                /* test if inside */
                if(BLI_in_rcti(&ar->winrct, xs, ys)) {
@@ -187,6 +196,28 @@
        fdrawline(xmin, ymax-2*dy+1, xmax-2*dx+1, ymin);
 }
 
+static void region_draw_azone(ScrArea *sa, AZone *az)
+{
+       if(az->ar==NULL) return;
+       
+       UI_SetTheme(sa->spacetype, az->ar->type->regionid);
+       
+       UI_ThemeColor(TH_BACK);
+       glBegin(GL_TRIANGLES);
+       glVertex2s(az->x1, az->y1);
+       glVertex2s(az->x2, az->y2);
+       glVertex2s(az->x3, az->y3);
+       glEnd();
+       
+       UI_ThemeColorShade(TH_BACK, 50);
+       sdrawline(az->x1, az->y1, az->x3, az->y3);
+       
+       UI_ThemeColorShade(TH_BACK, -50);
+       sdrawline(az->x2, az->y2, az->x3, az->y3);
+
+}
+
+
 /* only exported for WM */
 void ED_area_overdraw(bContext *C)
 {
@@ -204,9 +235,11 @@
                AZone *az;
                for(az= sa->actionzones.first; az; az= az->next) {
                        if(az->do_draw) {
-                               if(az->type==AZONE_TRI) {
+                               if(az->type==AZONE_AREA)
                                        area_draw_azone(az->x1, az->y1, az->x2, 
az->y2);
-                               }
+                               else if(az->type==AZONE_REGION)
+                                       region_draw_azone(sa, az);
+                               
                                az->do_draw= 0;
                        }
                }
@@ -360,8 +393,124 @@
        }
 }
 
+/* ************************************************************ */
+
+
+#define AZONESPOT              12
+static void area_azone_initialize(ScrArea *sa) 
+{
+       AZone *az;
+       
+       /* reinitalize entirely, regions add azones too */
+       BLI_freelistN(&sa->actionzones);
+       
+       /* set area action zones */
+       az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+       BLI_addtail(&(sa->actionzones), az);
+       az->type= AZONE_AREA;
+       az->x1= sa->totrct.xmin;
+       az->y1= sa->totrct.ymin;
+       az->x2= sa->totrct.xmin + AZONESPOT-1;
+       az->y2= sa->totrct.ymin + AZONESPOT-1;
+       BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
+       
+       az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+       BLI_addtail(&(sa->actionzones), az);
+       az->type= AZONE_AREA;
+       az->x1= sa->totrct.xmax+1;
+       az->y1= sa->totrct.ymax+1;
+       az->x2= sa->totrct.xmax-AZONESPOT+1;
+       az->y2= sa->totrct.ymax-AZONESPOT+1;
+       BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
+}
+
+static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) 
+{
+       AZone *az, *azt;
+       
+       az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+       BLI_addtail(&(sa->actionzones), az);
+       az->type= AZONE_REGION;
+       az->ar= ar;
+       az->edge= edge;
+       
+       if(edge=='t') {
+               az->x1= ar->winrct.xmin+AZONESPOT;
+               az->y1= ar->winrct.ymax;
+               az->x2= ar->winrct.xmin+2*AZONESPOT;
+               az->y2= ar->winrct.ymax;
+               az->x3= (az->x1+az->x2)/2;
+               az->y3= az->y2+AZONESPOT/2;
+               BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y3);
+       }
+       else if(edge=='b') {
+               az->x1= ar->winrct.xmin+AZONESPOT;
+               az->y1= ar->winrct.ymin;
+               az->x2= ar->winrct.xmin+2*AZONESPOT;
+               az->y2= ar->winrct.ymin;
+               az->x3= (az->x1+az->x2)/2;
+               az->y3= az->y2-AZONESPOT/2;
+               BLI_init_rcti(&az->rect, az->x1, az->x2, az->y3, az->y1);
+       }
+       else if(edge=='l') {
+               az->x1= ar->winrct.xmin;
+               az->y1= ar->winrct.ymax-AZONESPOT;
+               az->x2= ar->winrct.xmin;
+               az->y2= ar->winrct.ymax-2*AZONESPOT;
+               az->x3= az->x2-AZONESPOT/2;
+               az->y3= (az->y1+az->y2)/2;
+               BLI_init_rcti(&az->rect, az->x3, az->x1, az->y1, az->y2);
+       }
+       else { // if(edge=='r') {
+               az->x1= ar->winrct.xmax;
+               az->y1= ar->winrct.ymax-AZONESPOT;
+               az->x2= ar->winrct.xmax;
+               az->y2= ar->winrct.ymax-2*AZONESPOT;
+               az->x3= az->x2+AZONESPOT/2;
+               az->y3= (az->y1+az->y2)/2;
+               BLI_init_rcti(&az->rect, az->x1, az->x3, az->y1, az->y2);
+       }
+       
+       /* if more azones on 1 spot, set offset */
+       for(azt= sa->actionzones.first; azt; azt= azt->next) {
+               if(az!=azt) {
+                       if(az->x1==azt->x1 && az->y1==azt->y1) {
+                               if(edge=='t' || edge=='b') {
+                                       az->x1+= AZONESPOT;
+                                       az->x2+= AZONESPOT;
+                                       az->x3+= AZONESPOT;
+                                       BLI_init_rcti(&az->rect, az->x1, 
az->x2, az->y1, az->y3);
+                               }
+                               else {
+                                       az->y1-= AZONESPOT;
+                                       az->y2-= AZONESPOT;
+                                       az->y3-= AZONESPOT;
+                                       BLI_init_rcti(&az->rect, az->x1, 
az->x3, az->y1, az->y2);
+                               }
+                       }
+               }
+       }
+       
+}
+
+
 /* *************************************************************** */
 
+static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
+{
+        /* edge code (t b l r) is where azone will be drawn */
+       
+       if(alignment==RGN_ALIGN_TOP)
+               region_azone_initialize(sa, ar, 'b');
+       else if(alignment==RGN_ALIGN_BOTTOM)
+               region_azone_initialize(sa, ar, 't');
+       else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
+               region_azone_initialize(sa, ar, 'l');
+       else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
+               region_azone_initialize(sa, ar, 'r');
+                                                               
+}
+
 /* dir is direction to check, not the splitting edge direction! */
 static int rct_fits(rcti *rect, char dir, int size)
 {
@@ -373,7 +522,7 @@
        }
 }
 
-static void region_rect_recursive(ARegion *ar, rcti *remainder, int quad)
+static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, 
int quad)
 {
        rcti *remainder_prev= remainder;
        int prefsizex, prefsizey;
@@ -382,6 +531,7 @@
        if(ar==NULL)
                return;
        
+       /* no returns in function, winrct gets set in the end again */
        BLI_init_rcti(&ar->winrct, 0, 0, 0, 0);
        
        /* for test; allow split of previously defined region */
@@ -540,7 +690,27 @@
                        ar->prev->winy= ar->prev->winrct.ymax - 
ar->prev->winrct.ymin + 1;
                }
        }
-       region_rect_recursive(ar->next, remainder, quad);
+
+       /* set winrect for azones */
+       if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
+               ar->winrct= *remainder;
+               
+               if(alignment==RGN_ALIGN_TOP)
+                       ar->winrct.ymin= ar->winrct.ymax;
+               else if(alignment==RGN_ALIGN_BOTTOM)

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to