[Bf-blender-cvs] [7c02008e74a] blender2.8: Fix button triangle for "hold action" not working

Julian Eisel noreply at git.blender.org
Sun Apr 15 21:38:09 CEST 2018


Commit: 7c02008e74a5dc4b663fcf8eb18b6baac6ed3bb2
Author: Julian Eisel
Date:   Sun Apr 15 21:14:10 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7c02008e74a5dc4b663fcf8eb18b6baac6ed3bb2

Fix button triangle for "hold action" not working

There is quite some mess going on in that most of the old triangle
drawing code is still there, but does almost nothing effectively.
Instead values are hardcoded in the shader, however it doesn't support
the drawing options the triangle functions expose.
E.g. the 'where' variable to set triangle direction doesn't work.

===================================================================

M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl

===================================================================

diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 043dfc9fd99..bb9bfdd4429 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -721,6 +721,7 @@ enum {
 	ROUNDBOX_TRIA_SCROLL,
 	ROUNDBOX_TRIA_MENU,
 	ROUNDBOX_TRIA_CHECK,
+	ROUNDBOX_TRIA_HOLD_ACTION_ARROW,
 
 	ROUNDBOX_TRIA_MAX, /* don't use */
 };
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5a210d01f27..e2fd903243a 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -221,8 +221,8 @@ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}}
  **/
 
 /* offset in triavec[] in shader per type */
-static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {0, 0, 6, 22, 28};
-static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {0, 3, 16, 3, 6};
+static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {0, 0, 6, 22, 28, 34};
+static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {0, 3, 16, 3, 6, 3};
 
 static struct {
 	Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX];
@@ -288,7 +288,7 @@ static uint32_t set_tria_vertex(
 
 static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data)
 {
-	const int tria_num = (tria == ROUNDBOX_TRIA_CHECK) ? 1 : 2;
+	const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW) ? 1 : 2;
 	/* for each tria */
 	for (int t = 0; t < tria_num; ++t) {
 		for (int j = 0; j < WIDGET_AA_JITTER; j++) {
@@ -315,7 +315,7 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria)
 		vcount += ((WIDGET_CURVE_RESOLU * 2) * 2) * WIDGET_AA_JITTER; /* emboss */
 		if (tria) {
 			vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria1 */
-			if (tria != ROUNDBOX_TRIA_CHECK) {
+			if (!ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW)) {
 				vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */
 			}
 		}
@@ -832,6 +832,12 @@ static void shape_preset_init_number_arrows(uiWidgetTrias *tria, const rcti *rec
 
 static void shape_preset_init_hold_action(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
 {
+	tria->type = ROUNDBOX_TRIA_HOLD_ACTION_ARROW;
+	/* With the current changes to use batches for widget drawing, the code
+	 * below is doing almost nothing effectively. 'where' doesn't work either,
+	 * shader is currently hardcoded to work for the button triangle pointing
+	 * at the lower right. The same limitation applies to other trias as well.
+	 * XXX Should be addressed. */
 	shape_preset_init_trias_ex(
 	        tria, rect, triasize, where,
 	        g_shape_preset_hold_action_vert, ARRAY_SIZE(g_shape_preset_hold_action_vert),
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
index 0c351a3bce4..1c8c0ad3850 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
@@ -47,7 +47,7 @@ const vec2 jit[9] = vec2[9](
 
 /* We can reuse the CORNER_* bits for tria */
 #define TRIA_VEC_RANGE BIT_RANGE(6)
-const vec2 triavec[34] = vec2[34](
+const vec2 triavec[37] = vec2[37](
 	/* horizontal tria */
 	vec2(-0.352077, 0.532607), vec2(-0.352077, -0.549313), vec2( 0.330000, -0.008353),
 	vec2( 0.352077, 0.532607), vec2( 0.352077, -0.549313), vec2(-0.330000, -0.008353),
@@ -66,7 +66,14 @@ const vec2 triavec[34] = vec2[34](
 	vec2(0.0, -0.82), vec2(-0.33, -0.16), vec2(0.33, -0.16),
 	/* check mark */
 	vec2(-0.578579, 0.253369),  vec2(-0.392773, 0.412794),  vec2(-0.004241, -0.328551),
-	vec2(-0.003001, 0.034320),  vec2(1.055313, 0.864744),   vec2(0.866408, 1.026895)
+	vec2(-0.003001, 0.034320),  vec2(1.055313, 0.864744),   vec2(0.866408, 1.026895),
+	/* hold action arrow */
+#define OY -0.2
+#define SC 0.35
+//	vec2(-0.5 + SC, 1.0 + OY),  vec2( 0.5, 1.0 + OY),  vec2( 0.5, 0.0 + OY + SC),
+	vec2( 0.5 - SC, 1.0 + OY),  vec2(-0.5, 1.0 + OY),  vec2(-0.5, 0.0 + OY + SC)
+#undef OY
+#undef SC
 );
 
 uniform mat4 ModelViewProjectionMatrix;
@@ -183,4 +190,4 @@ void main()
 	v += jit[(vflag >> JIT_OFS) & JIT_RANGE];
 
 	gl_Position = ModelViewProjectionMatrix * vec4(v, 0.0, 1.0);
-}
\ No newline at end of file
+}



More information about the Bf-blender-cvs mailing list