* patch #3876: Rotating view icon
authorMatt Ebb <matt@mke3.net>
Tue, 25 Apr 2006 12:26:46 +0000 (12:26 +0000)
committerMatt Ebb <matt@mke3.net>
Tue, 25 Apr 2006 12:26:46 +0000 (12:26 +0000)
submitted by Davide Vercelli

This replaces (as a user preference) the static icon shown in the bottom-left of the 3D View with a small rotating axis that updates live in all ortho/perspective modes

I made several modifications to the original patch. In the patch, it displayed the axis on top of the 'object info' text since when floating panels are minimised, they sit in the bottom corner and cover the axis up. This annoyance is not limited to the axis, it also covers the frame number and info text, which can be frustrating. Sending them to the bottom is not that useful either, since it's quicker (with esc) and just as much movement to close and re-open them again.

I decided to solve this problem at the cause: Now when using the disclosure triangle on floating panels, they 'minimise in place' rather than going to the bottom.

User preferences are in the 'View & controls' section to:
- Display either the 3D axis or the old icon
- The size of the axis
- the brightness of the axis (colours are taken from grid theme settings)

* patch #3801: Option to show view direction in 3D View
submitted by Daniele Fornaciari

Simple one, just adds an user pref to show the name of the view's direction as text in the top left corner.

source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/src/drawview.c
source/blender/src/interface_panel.c
source/blender/src/space.c
source/blender/src/toets.c
source/blender/src/usiblender.c

index 7ec86c9c080ac3643c96b75a2c650731fbcfb79f..9c112b7ca58a55ce74472a22acc5fe68eac7773e 100644 (file)
@@ -166,7 +166,10 @@ typedef struct UserDef {
         int memcachelimit;
         short frameserverport;
        short pad;
-       short obcenter_dia, pad1, pad2, pad3;
+       short obcenter_dia;
+       short rvisize;          /* rotating view icon size */
+       short rvibright;        /* rotating view icon brightness */
+       short pad1;
 } UserDef;
 
 extern UserDef U; /* from usiblender.c !!!! */
@@ -215,6 +218,8 @@ extern UserDef U; /* from usiblender.c !!!! */
 #define USER_ORBIT_SELECTION   16384
 #define USER_KEYINSERTAVAI             32768
 #define USER_HIDE_DOT                  65536
+#define USER_SHOW_ROTVIEWICON  131072
+#define USER_SHOW_VIEWPORTNAME 262144
 
 /* transopts */
 
index e793ce2495e9af7a81b21a9de3f6ecea3c2f1e50..d095e8469271dd8dd82b31f678f61bd2058c31bd 100644 (file)
@@ -102,7 +102,9 @@ typedef struct View3D {
        short drawtype;
        short localview;
        int lay, layact;
-       short scenelock, around, camzoom, flag;
+       short scenelock, around, camzoom;
+       
+       short pad1;
        
        float lens, grid, gridview, pixsize, near, far;
        float camdx, camdy;             /* camera view offsets, 1.0 = viewplane moves entire width/height */
@@ -118,12 +120,18 @@ typedef struct View3D {
        
        /* user defined clipping planes */
        float clip[4][4];
+       
        struct BoundBox *clipbb;
        
        /* afterdraw, for xray & transparent */
        struct ListBase afterdraw;
        /* drawflags, denoting state */
-       short zbuf, transp, xray, pad2;
+       short zbuf, transp, xray;
+
+       short flag, flag2;
+       
+       short pad2[3];
+
 } View3D;
 
 /* View3D->flag (short) */
@@ -145,6 +153,9 @@ typedef struct View3D {
 #define V3D_CLIPPING           16384
 #define V3D_DRAW_CENTERS       32768
 
+/* View3d->flag2 (short) */
+#define V3D_OPP_DIRECTION_NAME 1
+
 /* View3D->around */
 #define V3D_CENTRE              0
 #define V3D_CENTROID    3
index b983fa828b955a8092d4730e0c8072f74935bac9..daf78661b358fd564d9f167a3f9fd3b9a8cdfc13 100644 (file)
@@ -1217,6 +1217,7 @@ void drawname(Object *ob)
 static void draw_selected_name(Object *ob)
 {
        char info[128];
+       short offset=30;
 
        if(ob->type==OB_ARMATURE) {
                bArmature *arm= ob->data;
@@ -1248,11 +1249,93 @@ static void draw_selected_name(Object *ob)
        else sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
 
        BIF_ThemeColor(TH_TEXT_HI);
-       glRasterPos2i(30,  10);
+       if (U.uiflag & USER_SHOW_ROTVIEWICON)
+               offset = 14 + (U.rvisize * 2);
+
+       glRasterPos2i(offset,  10);
        BMF_DrawString(G.fonts, info);
 }
 
 
+/* Draw a live substitute of the view icon, which is always shown */
+static void draw_view_axis(void)
+{
+       const float k = U.rvisize;   /* axis size */
+       const float toll = 0.5;      /* used to see when view is quasi-orthogonal */
+       const float start = k + 1.0; /* axis center in screen coordinates, x=y */
+       float ydisp = 0.0;          /* vertical displacement to allow obj info text */
+       
+       /* rvibright ranges approx. from original axis icon color to gizmo color */
+       const unsigned char bright = U.rvibright * 5;
+       
+       unsigned char col[3];
+       unsigned char gridcol[3];
+       
+       float vec[4];
+       float dx, dy;
+       float h, s, v;
+       
+       BIF_GetThemeColor3ubv(TH_GRID, gridcol);
+       
+       /* X */
+       vec[0] = vec[3] = 1;
+       vec[1] = vec[2] = 0;
+       QuatMulVecf(G.vd->viewquat, vec);
+       
+       make_axis_color(gridcol, col, 'x');
+       col[0] = col[0]>255-(4*bright)?255:col[0]+4*bright;
+       col[1] = col[1]>255-(bright)?255:col[1]+bright;
+       col[2] = col[2]>255-(bright)?255:col[2]+bright;
+       glColor3ubv(col);
+               
+       dx = vec[0] * k;
+       dy = vec[1] * k;
+       fdrawline(start, start + ydisp, start + dx, start + dy + ydisp);
+       if (fabs(dx) > toll || fabs(dy) > toll) {
+               glRasterPos2i(start + dx + 2, start + dy + ydisp + 2);
+               BMF_DrawString(G.fonts, "x");
+       }
+       
+       /* Y */
+       vec[1] = vec[3] = 1;
+       vec[0] = vec[2] = 0;
+       QuatMulVecf(G.vd->viewquat, vec);
+       
+       make_axis_color(gridcol, col, 'y');
+       col[0] = col[0]>255-(bright)?255:col[0]+bright;
+       col[1] = col[1]>255-(4*bright)?255:col[1]+4*bright;
+       col[2] = col[2]>255-(bright)?255:col[2]+bright;
+       glColor3ubv(col);
+       
+       dx = vec[0] * k;
+       dy = vec[1] * k;
+       fdrawline(start, start + ydisp, start + dx, start + dy + ydisp);
+       if (fabs(dx) > toll || fabs(dy) > toll) {
+               glRasterPos2i(start + dx + 2, start + dy + ydisp + 2);
+               BMF_DrawString(G.fonts, "y");
+       }
+       
+       /* Z */
+       vec[2] = vec[3] = 1;
+       vec[1] = vec[0] = 0;
+       QuatMulVecf(G.vd->viewquat, vec);
+       
+       make_axis_color(gridcol, col, 'z');
+       col[0] = col[0]>255-(bright)?255:col[0]+bright;
+       col[1] = col[1]>255-(bright)?255:col[1]+bright;
+       col[2] = col[2]>255-(4*bright)?255:col[2]+4*bright;
+       glColor3ubv(col);
+       
+       dx = vec[0] * k;
+       dy = vec[1] * k;
+       fdrawline(start, start + ydisp, start + dx, start + dy + ydisp);
+       if (fabs(dx) > toll || fabs(dy) > toll) {
+               glRasterPos2i(start + dx + 2, start + dy + ydisp + 2);
+               BMF_DrawString(G.fonts, "z");
+       }
+}
+
+       
 static void draw_view_icon(void)
 {
        BIFIconID icon;
@@ -1271,6 +1354,31 @@ static void draw_view_icon(void)
        glDisable(GL_BLEND);
 }
 
+static void draw_viewport_name(ScrArea *sa)
+{
+       char *name = NULL;
+       
+       switch(G.vd->view) {
+               case 1:
+                       name = (G.vd->flag2 & V3D_OPP_DIRECTION_NAME) ? "Back" : "Front";
+                       break;
+               case 3:
+                       name = (G.vd->flag2 & V3D_OPP_DIRECTION_NAME) ? "Left" : "Right";
+                       break;
+               case 7:
+                       name = (G.vd->flag2 & V3D_OPP_DIRECTION_NAME) ? "Bottom" : "Top";
+                       break;
+               default:
+                       name = G.vd->persp==V3D_PERSP_USE_THE_CAMERA ? "Camera" : "User";
+       }
+
+       if (name) {
+               BIF_ThemeColor(TH_TEXT_HI);
+               glRasterPos2i(10,  sa->winy-20);
+               BMF_DrawString(G.fonts, name);
+       }
+}
+
 /* ******************* view3d space & buttons ************** */
 
 static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) {
@@ -2522,7 +2630,12 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
        
        if(v3d->persp>1) drawviewborder();
        if(!(G.f & G_PLAYANIM)) drawcursor(v3d);
-       draw_view_icon();
+       if(U.uiflag & USER_SHOW_ROTVIEWICON)
+               draw_view_axis();
+       else    
+               draw_view_icon();
+       if(U.uiflag & USER_SHOW_VIEWPORTNAME)
+               draw_viewport_name(sa);
 
        ob= OBACT;
        if(ob && (U.uiflag & USER_DRAWVIEWINFO)) 
index 805b555f5a4962c30ecee7219247c98354d7d9dc..47961e22edcfc2bca24831dc21f0f1734abe21a3 100644 (file)
@@ -544,7 +544,6 @@ int uiNewPanel(ScrArea *sa, uiBlock *block, char *panelname, char *tabname, int
        if(pnl_control & UI_PNL_UNSTOW) {
                if(pa->flag & PNL_CLOSEDY) {
                        pa->flag &= ~PNL_CLOSED;
-                       stow_unstow(block); // toggles!
                }
        }
        
@@ -1735,6 +1734,7 @@ static void panel_clicked_tabs(uiBlock *block,  int mousex)
        
 }
 
+/* disabled /deprecated now, panels minimise in place */
 static void stow_unstow(uiBlock *block)
 {
        SpaceLink *sl= curarea->spacedata.first;
@@ -1832,11 +1832,6 @@ void ui_do_panel(uiBlock *block, uiEvent *uevent)
                                                else pa->flag &= ~PNL_CLOSED;
                                        }
                                }
-                               // extra, for non-butspace: open/collapse at window header
-                               if(curarea->spacetype!=SPACE_BUTS)
-                                       stow_unstow(block);
-
-                               
                        }
                        if(align==0) addqueue(block->win, REDRAW, 1);
                        else ui_animate_panels(curarea);
index 0baa511417e54a97ca30177d4eedff1fed338527..3e75320e6e7484af60da89d5bc7b5a721b1ae012 100644 (file)
@@ -2553,7 +2553,7 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        xpos,y6label,spref,buth,
                        0, 0, 0, 0, 0, "");     
                uiBlockBeginAlign(block);
-               uiDefButBitI(block, TOG, USER_TOOLTIPS, 0, "ToolTips",
+               uiDefButBitI(block, TOG, USER_TOOLTIPS, 0, "Tool Tips",
                        (xpos+edgsp),y5,spref,buth,
                        &(U.flag), 0, 0, 0, 0,
                        "Display tooltips (help tags) over buttons");
@@ -2573,10 +2573,10 @@ void drawinfospace(ScrArea *sa, void *spacedata)
 #else 
                U.curssize=0; /*Small Cursor always for OS X for now */
 #endif
-               uiDefButBitI(block, TOG, USER_PLAINMENUS, B_PLAINMENUS, "Plain menus",
+               uiDefButBitI(block, TOG, USER_SHOW_VIEWPORTNAME, B_DRAWINFO, "View Name",
                        (xpos+edgsp),y1,spref,buth,
                        &(U.uiflag), 0, 0, 0, 0,
-                       "Use column layout for toolbox and do not flip contents in any menu");
+                       "Show the name of the view's direction in each 3D View");
                uiBlockEndAlign(block);
 
                uiDefBut(block, LABEL,0,"Menus:",
@@ -2615,11 +2615,11 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        (xpos+edgsp+spref+midsp),y1,(mpref/2),buth,
                        &(U.uiflag), 0, 0, 0, 0,
                        "Make floating panels invoked by a hotkey (eg. N Key) open at the previous location");
-               
-               uiDefButBitI(block, TOG, USER_LOCKAROUND, B_DRAWINFO, "Global Pivot",
-                       (xpos+edgsp+spref+midsp+(mpref/2)),y1,(mpref/2),buth,
+               uiDefButBitI(block, TOG, USER_PLAINMENUS, B_PLAINMENUS, "Plain Menus",
+                       (xpos+edgsp+(2*spref)+(2*midsp)),y1,spref,buth,
                        &(U.uiflag), 0, 0, 0, 0,
-                       "Lock the same rotation/scaling pivot in all 3D Views");        
+                       "Use a column layout for toolbox and do not flip the contents of any menu");
+               uiBlockEndAlign(block);
                
                uiDefBut(block, LABEL,0,"Snap to grid:",
                        (xpos+(2*edgsp)+spref+midsp+mpref),y6label,mpref,buth,
@@ -2639,6 +2639,11 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        "Snap objects and sub-objects to grid units when scaling");
                uiBlockEndAlign(block);
                
+               uiDefButBitI(block, TOG, USER_LOCKAROUND, B_DRAWINFO, "Global Pivot",
+                       (xpos+edgsp+mpref+spref+(2*midsp)),y1,spref,buth,
+                       &(U.uiflag), 0, 0, 0, 0,
+                       "Lock the same rotation/scaling pivot in all 3D Views");        
+               
                uiDefBut(block, LABEL,0,"View zoom:",
                        (xpos+(2*edgsp)+mpref+(2*spref)+(2*midsp)),y6label,mpref,buth,
                        0, 0, 0, 0, 0, "");
@@ -2682,6 +2687,23 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        &(U.uiflag), 0, 0, 0, 0,
                        "Keep the active object in place when orbiting the views (Object Mode)");
                uiBlockEndAlign(block);
+               
+
+               uiBlockBeginAlign(block);
+               uiDefButBitI(block, TOG, USER_SHOW_ROTVIEWICON, B_DRAWINFO, "Mini Axis",
+                        (xpos+edgsp+(2*mpref)+(2*midsp)),y1,(mpref/3),buth,
+                        &(U.uiflag), 0, 0, 0, 0,
+                        "Show a small rotating 3D axis in the bottom left corner of the 3D View");
+               uiDefButS(block, NUM, B_DRAWINFO, "Size:",
+                       (xpos+edgsp+(2*mpref)+(2*midsp)+(mpref/3)),y1,(mpref/3),buth,
+                       &U.rvisize, 10, 64, 0, 0,
+                       "The axis icon's size");
+               uiDefButS(block, NUM, B_DRAWINFO, "Bright:",
+                       (xpos+edgsp+(2*mpref)+(2*midsp)+2*(mpref/3)),y1,(mpref/3),buth,
+                       &U.rvibright, 0, 10, 0, 0,
+                       "The brightness of the icon");
+               uiBlockEndAlign(block);
+               
 
                uiDefBut(block, LABEL,0,"Select with:",
                        (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y6label,mpref,buth,
@@ -2762,15 +2784,10 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                                  &(U.tw_hotspot), 4, 40, 0, 0, "Hotspot in pixels for clicking widget handles");
                uiBlockEndAlign(block);
                
-               
-               uiDefBut(block, LABEL,0,"Object center diameter",
-                                (xpos+(2*edgsp)+(5*mpref)+(5*midsp)),y3label,mpref,buth,
-                                0, 0, 0, 0, 0, "");
-               uiBlockBeginAlign(block);
-               uiDefButS(block, NUM, B_REDRCURW3D, "Size",
-                                 (xpos+(2*edgsp)+(5*mpref)+(5*midsp)),y2,mpref,buth,
+               uiDefButS(block, NUM, B_REDRCURW3D, "Object Center Size: ",
+                                  (xpos+edgsp+(5*mpref)+(6*midsp)),y3,mpref,buth,
                                  &(U.obcenter_dia), 4, 10, 0, 0,
-                                 "Diameter in Pixels for Object/Lamp center drawing");
+                                 "Diameter in Pixels for Object/Lamp center display");
                
                
        } else if (U.userpref == 1) { /* edit methods */
@@ -2793,11 +2810,11 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        (xpos+(2*edgsp)+mpref),y3label, mpref,buth,
                        0, 0, 0, 0, 0, "");
                uiBlockBeginAlign(block);
-               uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps:",
+               uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps: ",
                        (xpos+edgsp+mpref+midsp),y2,mpref,buth,
                        &(U.undosteps), 0, 64, 0, 0, "Number of undo steps available (smaller values conserve memory)");
 
-               uiDefButBitI(block, TOG, USER_GLOBALUNDO, B_DRAWINFO, "Global undo",
+               uiDefButBitI(block, TOG, USER_GLOBALUNDO, B_DRAWINFO, "Global Undo",
                        (xpos+edgsp+mpref+midsp),y1,mpref,buth,
                        &(U.uiflag), 2, 64, 0, 0, "Global undo works by keeping a full copy of the file itself in memory, so takes extra memory");
                uiBlockEndAlign(block);
index f470e0a43e8749dfb46aa83d19cb440ad8e884aa..b043bc853704accaa564cf33d5a1de1c4a4162d7 100644 (file)
@@ -138,6 +138,10 @@ void persptoetsen(unsigned short event)
                }
        }
        else if((G.qual & (LR_SHIFTKEY | LR_CTRLKEY)) && (event != PAD0)) {
+               
+               /* indicate that this view is inverted */
+               G.vd->flag2 |= V3D_OPP_DIRECTION_NAME;
+               
                if(event==PAD0) {
                        /* G.vd->persp= 3; */
                }
@@ -197,6 +201,8 @@ void persptoetsen(unsigned short event)
                }
        }
        else {
+               /* indicate that this view is not inverted */
+               G.vd->flag2 &= ~V3D_OPP_DIRECTION_NAME;
 
                if(event==PAD7) {
                        G.vd->viewquat[0]= 1.0;
index 265919a4937ba69580586783b74638478cb466de..4c660a5c4a6f12cfcbbfd5c51986aacd46594f2f 100644 (file)
@@ -292,6 +292,15 @@ static void init_userdef_file(void)
                                SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
                        }
                }
+               
+               /* set defaults for 3D View rotating axis indicator */ 
+               /* since size can't be set to 0, this indicates it's not saved in .B.blend */
+               if (U.rvisize == 0) {
+                       U.rvisize = 18;
+                       U.rvibright = 2;
+                       U.uiflag |= USER_SHOW_ROTVIEWICON;
+               }
+               
        }
        
        if (U.undosteps==0) U.undosteps=32;