[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60092] trunk/blender/source/blender/ editors/space_outliner/outliner_draw.c: fix/workaround [#36709] Renaming multiple objects in the outliner halts the interface
Campbell Barton
ideasman42 at gmail.com
Fri Sep 13 00:55:42 CEST 2013
Revision: 60092
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60092
Author: campbellbarton
Date: 2013-09-12 22:55:42 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
fix/workaround [#36709] Renaming multiple objects in the outliner halts the interface
Only show one edit button at a time (editing multiple buttons at once I never saw in other ui toolkits and its unclear what you change).
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
Modified: trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_draw.c 2013-09-12 22:48:46 UTC (rev 60091)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_draw.c 2013-09-12 22:55:42 UTC (rev 60092)
@@ -1045,48 +1045,37 @@
}
-static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb)
+static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, TreeElement *te)
{
uiBut *bt;
- TreeElement *te;
TreeStoreElem *tselem;
int spx, dx, len;
-
- for (te = lb->first; te; te = te->next) {
- tselem = TREESTORE(te);
- if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
-
- if (tselem->flag & TSE_TEXTBUT) {
-
- /* If we add support to rename Sequence.
- * need change this.
- */
- // prevent crash when trying to rename 'pose' entry of armature
- if (tselem->type == TSE_POSE_BASE) continue;
-
- if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name);
- else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name);
- else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name);
- else len = MAX_ID_NAME - 2;
-
- dx = (int)UI_GetStringWidth(te->name);
- if (dx < 5 * UI_UNIT_X) dx = 5 * UI_UNIT_X;
- spx = te->xs + 1.8f * UI_UNIT_X;
- if (spx + dx + 0.5f * UI_UNIT_X > ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax - spx - 0.5f * UI_UNIT_X;
+ tselem = TREESTORE(te);
- bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, te->ys, dx + UI_UNIT_X, UI_UNIT_Y - 1, (void *)te->name,
- 1.0, (float)len, 0, 0, "");
- uiButSetRenameFunc(bt, namebutton_cb, tselem);
-
- /* returns false if button got removed */
- if (false == uiButActiveOnly(C, ar, block, bt)) {
- tselem->flag &= ~TSE_TEXTBUT;
- }
- }
- }
-
- if (TSELEM_OPEN(tselem, soops)) outliner_buttons(C, block, ar, soops, &te->subtree);
+ BLI_assert(tselem->flag & TSE_TEXTBUT);
+ /* If we add support to rename Sequence.
+ * need change this.
+ */
+
+ if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name);
+ else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name);
+ else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name);
+ else len = MAX_ID_NAME - 2;
+
+ spx = te->xs + 1.8f * UI_UNIT_X;
+ dx = ar->v2d.cur.xmax - (spx + 3.2f * UI_UNIT_X);
+
+ bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, te->ys, dx, UI_UNIT_Y - 1, (void *)te->name,
+ 1.0, (float)len, 0, 0, "");
+ uiButSetRenameFunc(bt, namebutton_cb, tselem);
+
+ /* returns false if button got removed */
+ if (false == uiButActiveOnly(C, ar, block, bt)) {
+ tselem->flag &= ~TSE_TEXTBUT;
+
+ /* bad! (notifier within draw) without this, we don't get a refesh */
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
}
}
@@ -1484,7 +1473,7 @@
static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops,
- TreeElement *te, int startx, int *starty)
+ TreeElement *te, int startx, int *starty, TreeElement **te_edit)
{
TreeElement *ten;
TreeStoreElem *tselem;
@@ -1497,6 +1486,10 @@
int xmax = ar->v2d.cur.xmax;
unsigned char alpha = 128;
+ if ((tselem->flag & TSE_TEXTBUT) && (*te_edit == NULL)) {
+ *te_edit = te;
+ }
+
/* icons can be ui buts, we don't want it to overlap with restrict */
if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0)
xmax -= OL_TOGW + UI_UNIT_X;
@@ -1677,7 +1670,7 @@
*starty -= UI_UNIT_Y;
for (ten = te->subtree.first; ten; ten = ten->next)
- outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty);
+ outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty, te_edit);
}
else {
for (ten = te->subtree.first; ten; ten = ten->next)
@@ -1761,7 +1754,8 @@
}
-static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops)
+static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegion *ar,
+ SpaceOops *soops, TreeElement **te_edit)
{
TreeElement *te;
int starty, startx;
@@ -1793,7 +1787,7 @@
starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
startx = 0;
for (te = soops->tree.first; te; te = te->next) {
- outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty);
+ outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty, te_edit);
}
}
@@ -1863,6 +1857,7 @@
SpaceOops *soops = CTX_wm_space_outliner(C);
uiBlock *block;
int sizey = 0, sizex = 0, sizex_rna = 0;
+ TreeElement *te_edit = NULL;
outliner_build_tree(mainvar, scene, soops); // always
@@ -1916,7 +1911,7 @@
/* draw outliner stuff (background, hierachy lines and names) */
outliner_back(ar);
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
- outliner_draw_tree((bContext *)C, block, scene, ar, soops);
+ outliner_draw_tree((bContext *)C, block, scene, ar, soops, &te_edit);
if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
/* draw rna buttons */
@@ -1933,7 +1928,9 @@
}
/* draw edit buttons if nessecery */
- outliner_buttons(C, block, ar, soops, &soops->tree);
+ if (te_edit) {
+ outliner_buttons(C, block, ar, te_edit);
+ }
uiEndBlock(C, block);
uiDrawBlock(C, block);
More information about the Bf-blender-cvs
mailing list