[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11458] trunk/blender/source/blender: == Outliner - Patch #4364 ==
Joshua Leung
aligorith at gmail.com
Wed Aug 1 13:38:47 CEST 2007
Revision: 11458
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11458
Author: aligorith
Date: 2007-08-01 13:38:47 +0200 (Wed, 01 Aug 2007)
Log Message:
-----------
== Outliner - Patch #4364 ==
Now the Outliner can be scrolled horizontally too. This was the first patch I ever submitted, but it's gone through many revisions due to ugly Blender bugs that needed to be fixed.
Code Notes:
* I discovered an ancient bug which would cause Blender to hang when loading a file saved with horizontal scrollbars turned on for the Outliner/OOPS.
* Therefore, I've added special B_SCROLLO and HOR_SCROLLO defines for use by the Outliner only. These are used in place of B_SCROLL and HOR_SCROLL so that older Blender's won't choke on this stuff. Thanks for this suggestion Ton.
* The hanging occurred in draw_scroll in draw_ipo.c
Modified Paths:
--------------
trunk/blender/source/blender/makesdna/DNA_screen_types.h
trunk/blender/source/blender/src/drawipo.c
trunk/blender/source/blender/src/outliner.c
trunk/blender/source/blender/src/space.c
Modified: trunk/blender/source/blender/makesdna/DNA_screen_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_screen_types.h 2007-08-01 10:33:01 UTC (rev 11457)
+++ trunk/blender/source/blender/makesdna/DNA_screen_types.h 2007-08-01 11:38:47 UTC (rev 11458)
@@ -147,7 +147,9 @@
#define VERT_SCROLL 3
#define T_SCROLL 4
#define B_SCROLL 8
-#define HOR_SCROLL 12
+#define HOR_SCROLL 12
+#define B_SCROLLO 16 /* special hack for outliner hscroll - prevent hanging */
+#define HOR_SCROLLO 20 /* in older versions of blender */
/* Panel->snap - for snapping to screen edges */
#define PNL_SNAP_NONE 0
Modified: trunk/blender/source/blender/src/drawipo.c
===================================================================
--- trunk/blender/source/blender/src/drawipo.c 2007-08-01 10:33:01 UTC (rev 11457)
+++ trunk/blender/source/blender/src/drawipo.c 2007-08-01 11:38:47 UTC (rev 11458)
@@ -512,6 +512,7 @@
/* correct winx for scroll */
if(v2d->scroll & L_SCROLL) winx-= SCROLLB;
if(v2d->scroll & B_SCROLL) winy-= SCROLLH;
+ if(v2d->scroll & B_SCROLLO) winy-= SCROLLH; /* B_SCROLL and B_SCROLLO are basically same thing */
/* header completely closed window */
if(winy<=0) return;
@@ -652,7 +653,7 @@
cur->xmin+= dx;
cur->xmax+= dx;
}
- else if(cur->xmax > tot->xmax) {
+ else if((v2d->keeptot!=2) && (cur->xmax > tot->xmax)) {
dx= cur->xmax-tot->xmax;
cur->xmin-= dx;
cur->xmax-= dx;
@@ -753,7 +754,7 @@
v2d->mask.xmax= v2d->vert.xmin;
}
- if(v2d->scroll & B_SCROLL) {
+ if((v2d->scroll & B_SCROLL) || (v2d->scroll & B_SCROLLO)) {
v2d->hor= v2d->mask;
v2d->hor.ymax= SCROLLH;
v2d->mask.ymin= SCROLLH;
@@ -856,7 +857,7 @@
light= 20;
lighter= 50;
- if(G.v2d->scroll & HOR_SCROLL) {
+ if((G.v2d->scroll & HOR_SCROLL) || (G.v2d->scroll & HOR_SCROLLO)) {
BIF_ThemeColorShade(TH_SHADE1, light);
glRecti(hor.xmin, hor.ymin, hor.xmax, hor.ymax);
@@ -890,7 +891,13 @@
val= ipogrid_startx;
while(fac < hor.xmax) {
- if(curarea->spacetype==SPACE_OOPS);
+ if(curarea->spacetype==SPACE_OOPS) {
+ /* Under no circumstances may the outliner/oops display numbers on its scrollbar
+ * Unfortunately, versions of Blender without this patch will hang on loading files with
+ * horizontally scrollable Outliners.
+ */
+ break;
+ }
else if(curarea->spacetype==SPACE_SEQ) {
SpaceSeq * sseq = curarea->spacedata.first;
if (sseq->flag & SEQ_DRAWFRAMES) {
@@ -2491,13 +2498,7 @@
}
cursor = BC_NSEW_SCROLLCURSOR;
-
- /* no x move in outliner */
- if(curarea->spacetype==SPACE_OOPS && G.v2d->scroll) {
- facx= 0.0;
- cursor = BC_NS_SCROLLCURSOR;
- }
-
+
/* no y move in audio & time */
if ELEM(curarea->spacetype, SPACE_SOUND, SPACE_TIME) {
facy= 0.0;
Modified: trunk/blender/source/blender/src/outliner.c
===================================================================
--- trunk/blender/source/blender/src/outliner.c 2007-08-01 10:33:01 UTC (rev 11457)
+++ trunk/blender/source/blender/src/outliner.c 2007-08-01 11:38:47 UTC (rev 11458)
@@ -261,6 +261,20 @@
}
}
+static void outliner_width(SpaceOops *soops, ListBase *lb, int *w)
+{
+ TreeElement *te= lb->first;
+ while(te) {
+ TreeStoreElem *tselem= TREESTORE(te);
+ if(tselem->flag & TSE_CLOSED) {
+ if (te->xend > *w)
+ *w = te->xend;
+ }
+ outliner_width(soops, &te->subtree, w);
+ te= te->next;
+ }
+}
+
static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index)
{
TreeElement *te= lb->first, *tes;
@@ -2042,7 +2056,7 @@
{
SpaceOops *so= sa->spacedata.first;
TreeElement *te;
- int ytop;
+ int xdelta, ytop;
if(OBACT == NULL) return;
@@ -2053,6 +2067,12 @@
if(ytop>0) ytop= 0;
so->v2d.cur.ymax= ytop;
so->v2d.cur.ymin= ytop-(so->v2d.mask.ymax-so->v2d.mask.ymin);
+
+ /* make te->xs ==> te->xend center of view */
+ xdelta = te->xs - so->v2d.cur.xmin;
+ so->v2d.cur.xmin += xdelta;
+ so->v2d.cur.xmax += xdelta;
+
so->storeflag |= SO_TREESTORE_REDRAW;
scrarea_queue_redraw(sa);
}
@@ -2062,7 +2082,7 @@
{
SpaceOops *so= sa->spacedata.first;
TreeElement *te;
- int ytop;
+ int xdelta, ytop;
te= outliner_find_id(so, &so->tree, (ID *)OBACT);
if(te) {
@@ -2071,6 +2091,12 @@
if(ytop>0) ytop= 0;
so->v2d.cur.ymax= ytop;
so->v2d.cur.ymin= ytop-(so->v2d.mask.ymax-so->v2d.mask.ymin);
+
+ /* make te->xs ==> te->xend center of view */
+ xdelta = te->xs - so->v2d.cur.xmin;
+ so->v2d.cur.xmin += xdelta;
+ so->v2d.cur.xmax += xdelta;
+
so->storeflag |= SO_TREESTORE_REDRAW;
scrarea_queue_redraw(sa);
}
@@ -2149,7 +2175,7 @@
TreeElement *te= NULL;
TreeElement *last_find;
TreeStoreElem *tselem;
- int ytop, prevFound=0;
+ int ytop, xdelta, prevFound=0;
char name[33];
/* get last found tree-element based on stored search_tse */
@@ -2196,6 +2222,11 @@
soops->v2d.cur.ymax= ytop;
soops->v2d.cur.ymin= ytop-(soops->v2d.mask.ymax-soops->v2d.mask.ymin);
+ /* make te->xs ==> te->xend center of view */
+ xdelta = te->xs - soops->v2d.cur.xmin;
+ soops->v2d.cur.xmin += xdelta;
+ soops->v2d.cur.xmax += xdelta;
+
/* store selection */
soops->search_tse= *tselem;
@@ -3174,7 +3205,7 @@
/* selection status */
if(tselem->flag & TSE_SELECTED) {
- glRecti(0, *starty+1, (int)soops->v2d.mask.xmax, *starty+OL_H-1);
+ glRecti(0, *starty+1, (int)soops->v2d.cur.xmax, *starty+OL_H-1);
}
*starty-= OL_H;
if((tselem->flag & TSE_CLOSED)==0) outliner_draw_selection(soops, &te->subtree, starty);
@@ -3225,7 +3256,7 @@
ystart= OL_H*(ystart/(OL_H));
while(ystart > soops->v2d.cur.ymin) {
- glRecti(0, ystart, (int)soops->v2d.mask.xmax, ystart+OL_H);
+ glRecti(0, ystart, (int)soops->v2d.cur.xmax, ystart+OL_H);
ystart-= 2*OL_H;
}
}
@@ -3236,35 +3267,35 @@
/* background underneath */
BIF_ThemeColor(TH_BACK);
- glRecti((int)soops->v2d.mask.xmax-(OL_TOGW+SCROLLB), soops->v2d.cur.ymin, (int)soops->v2d.mask.xmax, soops->v2d.tot.ymax);
+ glRecti((int)soops->v2d.cur.xmax-OL_TOGW, soops->v2d.cur.ymin, (int)soops->v2d.cur.xmax, soops->v2d.cur.ymax);
BIF_ThemeColorShade(TH_BACK, 6);
ystart= soops->v2d.tot.ymax;
ystart= OL_H*(ystart/(OL_H));
while(ystart > soops->v2d.cur.ymin) {
- glRecti((int)soops->v2d.mask.xmax-(OL_TOGW+SCROLLB), ystart, (int)soops->v2d.mask.xmax, ystart+OL_H);
+ glRecti((int)soops->v2d.cur.xmax-OL_TOGW, ystart, (int)soops->v2d.cur.xmax, ystart+OL_H);
ystart-= 2*OL_H;
}
BIF_ThemeColorShadeAlpha(TH_BACK, -15, -200);
/* view */
- fdrawline(soops->v2d.mask.xmax-(OL_TOG_RESTRICT_VIEWX+SCROLLB),
- soops->v2d.tot.ymax,
- soops->v2d.mask.xmax-(OL_TOG_RESTRICT_VIEWX+SCROLLB),
+ fdrawline(soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX,
+ soops->v2d.cur.ymax,
+ soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX,
soops->v2d.cur.ymin);
/* render */
- fdrawline(soops->v2d.mask.xmax-(OL_TOG_RESTRICT_SELECTX+SCROLLB),
- soops->v2d.tot.ymax,
- soops->v2d.mask.xmax-(OL_TOG_RESTRICT_SELECTX+SCROLLB),
+ fdrawline(soops->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX,
+ soops->v2d.cur.ymax,
+ soops->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX,
soops->v2d.cur.ymin);
/* render */
- fdrawline(soops->v2d.mask.xmax-(OL_TOG_RESTRICT_RENDERX+SCROLLB),
- soops->v2d.tot.ymax,
- soops->v2d.mask.xmax-(OL_TOG_RESTRICT_RENDERX+SCROLLB),
+ fdrawline(soops->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX,
+ soops->v2d.cur.ymax,
+ soops->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX,
soops->v2d.cur.ymin);
}
@@ -3419,12 +3450,76 @@
scrarea_queue_redraw(curarea);
}
+static void outliner_draw_restrictbuts(uiBlock *block, SpaceOops *soops, ListBase *lb)
+{
+ uiBut *bt;
+ TreeElement *te;
+ TreeStoreElem *tselem;
+ Object *ob;
+
+ for(te= lb->first; te; te= te->next) {
+ tselem= TREESTORE(te);
+ if(te->ys >= soops->v2d.cur.ymin && te->ys <= soops->v2d.cur.ymax) {
+ /* objects have toggle-able restriction flags */
+ if(tselem->type==0 && te->idcode==ID_OB) {
+ ob = (Object *)tselem->id;
+
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_VIEW, REDRAWALL, ICON_RESTRICT_VIEW_OFF,
+ (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
+ uiButSetFunc(bt, restrictbutton_view_cb, ob, NULL);
+ uiButSetFlag(bt, UI_NO_HILITE);
+
+ bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_SELECT, REDRAWALL, ICON_RESTRICT_SELECT_OFF,
+ (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
+ uiButSetFunc(bt, restrictbutton_sel_cb, ob, NULL);
+ uiButSetFlag(bt, UI_NO_HILITE);
+
+ bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_RENDER, REDRAWALL, ICON_RESTRICT_RENDER_OFF,
+ (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow renderability");
+ uiButSetFunc(bt, restrictbutton_rend_cb, NULL, NULL);
+ uiButSetFlag(bt, UI_NO_HILITE);
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
+ }
+ /* scene render layers and passes have toggle-able flags too! */
+ else if(tselem->type==TSE_R_LAYER) {
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+
+ bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, REDRAWBUTSSCENE, ICON_CHECKBOX_HLT-1,
+ (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, te->ys, 17, OL_H-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer");
+ uiButSetFunc(bt, restrictbutton_r_lay_cb, NULL, NULL);
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
+ }
+ else if(tselem->type==TSE_R_PASS) {
+ int *layflag= te->directdata;
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+
+ /* NOTE: tselem->nr is short! */
+ bt= uiDefIconButBitI(block, ICONTOG, tselem->nr, REDRAWBUTSSCENE, ICON_CHECKBOX_HLT-1,
+ (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Render this Pass");
+ uiButSetFunc(bt, restrictbutton_r_lay_cb, NULL, NULL);
+
+ layflag++; /* is lay_xor */
+ if(ELEM6(tselem->nr, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_RADIO))
+ bt= uiDefIconButBitI(block, TOG, tselem->nr, REDRAWBUTSSCENE, (*layflag & tselem->nr)?ICON_DOT:ICON_BLANK1,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list