forked from bartvdbraak/blender
Node UI: add support to show text-blocks in frames
Some node setups benefit from being documented like this.
This commit is contained in:
parent
c44d7b0340
commit
eb150ef337
@ -299,6 +299,7 @@ class NODE_PT_active_node_generic(Panel):
|
||||
|
||||
layout.prop(node, "name", icon='NODE')
|
||||
layout.prop(node, "label", icon='NODE')
|
||||
layout.prop(node, "text")
|
||||
|
||||
|
||||
class NODE_PT_active_node_color(Panel):
|
||||
|
@ -508,10 +508,14 @@ void BKE_text_unlink(Main *bmain, Text *text)
|
||||
bNodeTree *ntree;
|
||||
bNode *node;
|
||||
Material *mat;
|
||||
Lamp *la;
|
||||
Tex *te;
|
||||
World *wo;
|
||||
FreestyleLineStyle *linestyle;
|
||||
Scene *sce;
|
||||
SceneRenderLayer *srl;
|
||||
FreestyleModuleConfig *module;
|
||||
short update;
|
||||
bool update;
|
||||
|
||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||
/* game controllers */
|
||||
@ -563,23 +567,97 @@ void BKE_text_unlink(Main *bmain, Text *text)
|
||||
}
|
||||
|
||||
/* nodes */
|
||||
for (la = bmain->lamp.first; la; la = la->id.next) {
|
||||
ntree = la->nodetree;
|
||||
if (!ntree)
|
||||
continue;
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_FRAME) {
|
||||
if ((Text *)node->id == text) {
|
||||
node->id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
|
||||
ntree = linestyle->nodetree;
|
||||
if (!ntree)
|
||||
continue;
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_FRAME) {
|
||||
if ((Text *)node->id == text) {
|
||||
node->id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (mat = bmain->mat.first; mat; mat = mat->id.next) {
|
||||
ntree = mat->nodetree;
|
||||
if (!ntree)
|
||||
continue;
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == SH_NODE_SCRIPT) {
|
||||
if (ELEM(node->type, SH_NODE_SCRIPT, NODE_FRAME)) {
|
||||
if ((Text *)node->id == text) {
|
||||
node->id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (te = bmain->tex.first; mat; mat = mat->id.next) {
|
||||
ntree = te->nodetree;
|
||||
if (!ntree)
|
||||
continue;
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_FRAME) {
|
||||
if ((Text *)node->id == text) {
|
||||
node->id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (wo = bmain->world.first; wo; wo = wo->id.next) {
|
||||
ntree = wo->nodetree;
|
||||
if (!ntree)
|
||||
continue;
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_FRAME) {
|
||||
if ((Text *)node->id == text) {
|
||||
node->id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
|
||||
ntree = sce->nodetree;
|
||||
if (!ntree)
|
||||
continue;
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_FRAME) {
|
||||
Text *ntext = (Text *)node->id;
|
||||
if (ntext == text) node->id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Freestyle (while looping oer the scene) */
|
||||
for (srl = sce->r.layers.first; srl; srl = srl->next) {
|
||||
for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
|
||||
if (module->script == text)
|
||||
module->script = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == SH_NODE_SCRIPT) {
|
||||
Text *ntext = (Text *)node->id;
|
||||
if (ntext == text) node->id = NULL;
|
||||
if (ELEM(node->type, SH_NODE_SCRIPT, NODE_FRAME)) {
|
||||
if ((Text *)node->id == text) {
|
||||
node->id = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -600,16 +678,6 @@ void BKE_text_unlink(Main *bmain, Text *text)
|
||||
}
|
||||
}
|
||||
|
||||
/* Freestyle */
|
||||
for (sce = bmain->scene.first; sce; sce = sce->id.next) {
|
||||
for (srl = sce->r.layers.first; srl; srl = srl->next) {
|
||||
for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
|
||||
if (module->script == text)
|
||||
module->script = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text->id.us = 0;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
#include "DNA_text_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_curve.h"
|
||||
@ -389,6 +390,7 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp
|
||||
float width, ascender;
|
||||
float x, y;
|
||||
const int font_size = data->label_size / aspect;
|
||||
const float margin = NODE_DY / 4;
|
||||
|
||||
nodeLabel(ntree, node, label, sizeof(label));
|
||||
|
||||
@ -404,11 +406,42 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp
|
||||
|
||||
/* 'x' doesn't need aspect correction */
|
||||
x = BLI_rctf_cent_x(rct) - (0.5f * width);
|
||||
y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
|
||||
y = rct->ymax - ((margin / aspect) + (ascender * aspect));
|
||||
|
||||
BLF_position(fontid, x, y, 0);
|
||||
BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
|
||||
|
||||
/* draw text body */
|
||||
if (node->id) {
|
||||
Text *text = (Text *)node->id;
|
||||
TextLine *line;
|
||||
const float line_spacing = (BLF_height_max(fontid) * aspect) * 0.7f;
|
||||
|
||||
/* 'x' doesn't need aspect correction */
|
||||
x = rct->xmin + margin;
|
||||
y = rct->ymax - ((margin / aspect) + (ascender * aspect));
|
||||
y -= line_spacing;
|
||||
|
||||
BLF_enable(fontid, BLF_CLIPPING);
|
||||
BLF_clipping(
|
||||
fontid,
|
||||
rct->xmin,
|
||||
rct->ymin,
|
||||
rct->xmin + ((rct->xmax - rct->xmin) / aspect) - margin,
|
||||
rct->ymax);
|
||||
|
||||
for (line = text->lines.first; line; line = line->next) {
|
||||
BLF_position(fontid, x, y, 0);
|
||||
BLF_draw(fontid, line->line, line->len);
|
||||
y -= line_spacing;
|
||||
if (y < rct->ymin) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BLF_disable(fontid, BLF_CLIPPING);
|
||||
}
|
||||
|
||||
BLF_disable(fontid, BLF_ASPECT);
|
||||
}
|
||||
|
||||
|
@ -3038,6 +3038,13 @@ static void def_frame(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "id");
|
||||
RNA_def_property_struct_type(prop, "Text");
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Text", "");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "NodeFrame", "storage");
|
||||
|
||||
prop = RNA_def_property(srna, "shrink", PROP_BOOLEAN, PROP_NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user