diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-29 13:56:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-29 14:04:32 +0300 |
commit | eb150ef3375975cdfe9cba3e9acd42bc1fe38dce (patch) | |
tree | 6cfdfea4613a46f8bfb307390a2da5259cb41939 /source/blender/editors/space_node/drawnode.c | |
parent | c44d7b0340e6b21444b3218d58857a88b6b32fdd (diff) |
Node UI: add support to show text-blocks in frames
Some node setups benefit from being documented like this.
Diffstat (limited to 'source/blender/editors/space_node/drawnode.c')
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index f1dfa4f1e8f..b5e70085f34 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -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); } |