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:
authorTon Roosendaal <ton@blender.org>2009-06-01 20:22:53 +0400
committerTon Roosendaal <ton@blender.org>2009-06-01 20:22:53 +0400
commitcb96aa47dbcefa8be8db63dc8fc2607b16b2d5d1 (patch)
treeda0a2de7e32c2bc47423d4f448ff48b12acf807f /source/blender/editors/interface/view2d.c
parentdbbe06b690c8c133cfd5be87db22cc10cf987f8d (diff)
2.5
Added support for cached text drawing in View2D. Cache is needed to prevent the viewmatrix being set/restored on each text drawing. Adding a string: void UI_view2d_text_cache_add(View2D *v2d, float x, float y, char *str) Drawing: void UI_view2d_text_cache_draw(ARegion *ar) Nothing else needed; just make sure cache-draw is always called at end of a view2d drawing function, to clear cache memory. On todo for next: a version with a rectf boundary to clip text within.
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r--source/blender/editors/interface/view2d.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index f2fc2deefbb..fc1de788f5f 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1939,3 +1939,55 @@ short UI_view2d_mouse_in_scrollers (const bContext *C, View2D *v2d, int x, int y
return 0;
}
+/* ******************* view2d text drawing cache ******************** */
+
+/* assumes caches are used correctly, so for time being no local storage in v2d */
+static ListBase strings= {NULL, NULL};
+
+typedef struct View2DString {
+ struct View2DString *next, *prev;
+ float col[4];
+ char str[128];
+ short mval[2];
+} View2DString;
+
+
+void UI_view2d_text_cache_add(View2D *v2d, float x, float y, char *str)
+{
+ int mval[2];
+
+ UI_view2d_view_to_region(v2d, x, y, mval, mval+1);
+
+ if(mval[0]!=V2D_IS_CLIPPED && mval[1]!=V2D_IS_CLIPPED) {
+ View2DString *v2s= MEM_callocN(sizeof(View2DString), "View2DString");
+
+ BLI_addtail(&strings, v2s);
+ BLI_strncpy(v2s->str, str, 128);
+ v2s->mval[0]= mval[0];
+ v2s->mval[1]= mval[1];
+ glGetFloatv(GL_CURRENT_COLOR, v2s->col);
+ }
+}
+
+void UI_view2d_text_cache_draw(ARegion *ar)
+{
+ View2DString *v2s;
+
+ // wmPushMatrix();
+ ED_region_pixelspace(ar);
+
+ for(v2s= strings.first; v2s; v2s= v2s->next) {
+ glColor3fv(v2s->col);
+ BLF_draw_default((float)v2s->mval[0], (float)v2s->mval[1], 0.0, v2s->str);
+ }
+
+ // wmPopMatrix();
+
+ if(strings.first)
+ BLI_freelistN(&strings);
+}
+
+
+/* ******************************************************** */
+
+