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:
authorJoshua Leung <aligorith@gmail.com>2009-06-02 05:40:53 +0400
committerJoshua Leung <aligorith@gmail.com>2009-06-02 05:40:53 +0400
commit37f47ef3862a85d4d95fe5b18ab3d6b9c88ccdd3 (patch)
treea648a61fbbc313c2833a5e4eb3c8d8d75da3c090 /source/blender/editors/interface/view2d.c
parent33267f58581ea8f9d89028958c6e64a8d048d4db (diff)
parenta117731aa23c25d699c405325c7bb7ac5680a5e7 (diff)
NLA SoC: Merge from 2.5 20441 to 20570 (HEAD)
There were a few conflicts/missing files. Hopefully everything updated ok...
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r--source/blender/editors/interface/view2d.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 639f83d0d09..19c95ce7ce0 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1956,3 +1956,85 @@ 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];
+ rcti rect;
+} 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) {
+ /* use calloc, rect has to be zeroe'd */
+ 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);
+ }
+}
+
+/* no clip (yet) */
+void UI_view2d_text_cache_rectf(View2D *v2d, rctf *rect, char *str)
+{
+ View2DString *v2s= MEM_callocN(sizeof(View2DString), "View2DString");
+
+ UI_view2d_to_region_no_clip(v2d, rect->xmin, rect->ymin, &v2s->rect.xmin, &v2s->rect.ymin);
+ UI_view2d_to_region_no_clip(v2d, rect->xmax, rect->ymax, &v2s->rect.xmax, &v2s->rect.ymax);
+
+ BLI_addtail(&strings, v2s);
+ BLI_strncpy(v2s->str, str, 128);
+ 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);
+ if(v2s->rect.xmin==v2s->rect.xmax)
+ BLF_draw_default((float)v2s->mval[0], (float)v2s->mval[1], 0.0, v2s->str);
+ else {
+ int xofs=0, yofs;
+
+ yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
+ if(yofs<1) yofs= 1;
+
+ BLF_clipping(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
+ BLF_enable(BLF_CLIPPING);
+
+ BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, v2s->str);
+
+ BLF_disable(BLF_CLIPPING);
+ }
+ }
+
+ // wmPopMatrix();
+
+ if(strings.first)
+ BLI_freelistN(&strings);
+}
+
+
+/* ******************************************************** */
+
+