[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38978] trunk/blender/source: fix [#27965] VSE: no visual feedback on locked strips

Campbell Barton ideasman42 at gmail.com
Wed Aug 3 11:28:16 CEST 2011


Revision: 38978
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38978
Author:   campbellbarton
Date:     2011-08-03 09:28:16 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
fix [#27965] VSE: no visual feedback on locked strips
added xpm -> opengl stipple conversion script.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/BIF_glutil.h
    trunk/blender/source/blender/editors/screen/glutil.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c

Added Paths:
-----------
    trunk/blender/source/tools/MakeGLStipple.py

Modified: trunk/blender/source/blender/editors/include/BIF_glutil.h
===================================================================
--- trunk/blender/source/blender/editors/include/BIF_glutil.h	2011-08-03 09:25:40 UTC (rev 38977)
+++ trunk/blender/source/blender/editors/include/BIF_glutil.h	2011-08-03 09:28:16 UTC (rev 38978)
@@ -52,6 +52,8 @@
 /* glStipple defines */
 extern unsigned char stipple_halftone[128];
 extern unsigned char stipple_quarttone[128];
+extern unsigned char stipple_diag_stripes_pos[128];
+extern unsigned char stipple_diag_stripes_neg[128];
 
 	/**
 	 * Draw a lined (non-looping) arc with the given

Modified: trunk/blender/source/blender/editors/screen/glutil.c
===================================================================
--- trunk/blender/source/blender/editors/screen/glutil.c	2011-08-03 09:25:40 UTC (rev 38977)
+++ trunk/blender/source/blender/editors/screen/glutil.c	2011-08-03 09:28:16 UTC (rev 38978)
@@ -92,6 +92,44 @@
 	136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0};
 
 
+GLubyte stipple_diag_stripes_pos[128] = {
+    0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe,
+	0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8,
+	0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f,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+	0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01,
+	0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07,
+	0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f,
+	0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f,
+	0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe,
+	0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8,
+	0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0,
+	0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80};
+
+
 void fdrawbezier(float vec[4][3])
 {
 	float dist;

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2011-08-03 09:25:40 UTC (rev 38977)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2011-08-03 09:28:16 UTC (rev 38978)
@@ -639,6 +639,25 @@
 	/* draw sound wave */
 	if(seq->type == SEQ_SOUND) drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx);
 
+	/* draw lock */
+	if(seq->flag & SEQ_LOCK) {
+		glEnable(GL_POLYGON_STIPPLE);
+		glEnable(GL_BLEND);
+
+		/* light stripes */
+		glColor4ub(255, 255, 255, 32);
+		glPolygonStipple(stipple_diag_stripes_pos);
+		glRectf(x1, y1, x2, y2);
+
+		/* dark stripes */
+		glColor4ub(0, 0, 0, 32);
+		glPolygonStipple(stipple_diag_stripes_neg);
+		glRectf(x1, y1, x2, y2);
+
+		glDisable(GL_POLYGON_STIPPLE);
+		glDisable(GL_BLEND);
+	}
+
 	get_seq_color3ubv(scene, seq, col);
 	if (G.moving && (seq->flag & SELECT)) {
 		if(seq->flag & SEQ_OVERLAP) {

Added: trunk/blender/source/tools/MakeGLStipple.py
===================================================================
--- trunk/blender/source/tools/MakeGLStipple.py	                        (rev 0)
+++ trunk/blender/source/tools/MakeGLStipple.py	2011-08-03 09:28:16 UTC (rev 38978)
@@ -0,0 +1,96 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8-80 compliant>
+
+# Converts 32x32 XPM images written be the gimp to GL stipples
+# takes xpm files as arguments, prints out C style definitions.
+
+import sys
+import os
+
+
+def main():
+    xpm_ls = [f for f in sys.argv[1:] if f.lower().endswith(".xpm")]
+
+    print("Converting: " + " ".join(xpm_ls))
+
+    for xpm in xpm_ls:
+        f = open(xpm, "r")
+        data = f.read()
+        f.close()
+
+        # all after first {
+        data = data.split("{", 1)[1]
+
+        # all before first }
+        data = data.rsplit("}", 1)[0]
+
+        data = data.replace("\n", "")
+
+        data = data.split(",")
+
+        w, h, c, dummy = map(int, data[0].strip("\"").split())
+
+        if w != 32 or h != 32 or c != 2:
+            print("Skipping %r, expected 32x32, monochrome, got %s" %
+                  (xpm, data[0]))
+            continue
+
+        col_1 = data[1][1]
+        col_2 = data[2][1]
+
+        data = [d[1:-1] for d in data[3:]]
+
+        bits = []
+
+        for d in data:
+            for i, c in enumerate(d):
+                bits.append('01'[(c == col_2)])
+
+        if len(bits) != 1024:
+            print("Skipping %r, expected 1024 bits, got %d" %
+                  (xpm, len(bits)))
+            continue
+
+        bits = "".join(bits)
+
+        chars = []
+
+        for i in range(0, len(bits), 8):
+            chars.append("0x%.2x" % int(bits[i:i + 8], 2))
+
+        fout = sys.stdout
+
+        var = os.path.basename(xpm)
+        var = os.path.splitext(var)[0]
+
+        fout.write("GLubyte stipple_%s[128] {\n\t" % var)
+        for i, c in enumerate(chars):
+            if i != 127:
+                fout.write("%s, " % c)
+            else:
+                fout.write("%s" % c)
+
+            if not ((i + 1) % 8):
+                fout.write("\n\t")
+        fout.write("};\n")
+
+
+if __name__ == "__main__":
+    main()




More information about the Bf-blender-cvs mailing list