Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-09 20:26:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-09 20:26:01 +0400
commit80fa54ab3cfcec7d9ce5976a1b0af1b0c92cdef0 (patch)
treef95448cf09e7dd92686a1fbcd9b8e284521c8f1c /source/blender/editors
parent4c7f7b6dbf810a2f38a162ab9ca4f0af56a0c255 (diff)
correction to last commit. aspect doesn't need to be calculated every time.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_node/drawnode.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 502786e2b3e..5f82bf3aa51 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -946,11 +946,8 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode
node->totr = rect;
}
-static void node_draw_frame_label(View2D *v2d, bNode *node)
+static void node_draw_frame_label(bNode *node, const float aspect)
{
- const float aspx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
- const float aspy = (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin);
-
/* XXX font id is crap design */
const int fontid = blf_mono_font;
NodeFrame *data = (NodeFrame *)node->storage;
@@ -960,22 +957,23 @@ static void node_draw_frame_label(View2D *v2d, bNode *node)
/* XXX a bit hacky, should use separate align values for x and y */
float width, ascender;
float x, y;
- const int font_size = data->label_size / aspx;
+ const int font_size = data->label_size / aspect;
BLI_strncpy(label, nodeLabel(node), sizeof(label));
BLF_enable(fontid, BLF_ASPECT);
- BLF_aspect(fontid, aspx, aspy, 1.0f);
+ BLF_aspect(fontid, aspect, aspect, 1.0f);
BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
/* title color */
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
width = BLF_width(fontid, label);
- ascender = BLF_ascender(fontid) * aspy;
+ ascender = BLF_ascender(fontid);
+ /* 'x' doesn't need aspect correction */
x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width;
- y = rct->ymax - NODE_DYS - ascender;
+ y = rct->ymax - NODE_DYS - (ascender * aspect);
BLF_position(fontid, x, y, 0);
BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
@@ -1032,7 +1030,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN
}
/* label */
- node_draw_frame_label(&ar->v2d, node);
+ node_draw_frame_label(node, snode->aspect);
UI_ThemeClearColor(color_id);