[Bf-blender-cvs] [4a85089abe6] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Thu Nov 2 05:38:52 CET 2017


Commit: 4a85089abe6d5abb9f6bb0d8255eba33dc030fcb
Author: Campbell Barton
Date:   Thu Nov 2 15:44:33 2017 +1100
Branches: blender2.8
https://developer.blender.org/rB4a85089abe6d5abb9f6bb0d8255eba33dc030fcb

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/interface/interface.c
index 96273f5e83c,bc2397d8e47..0d166b874cb
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@@ -2678,10 -2672,10 +2678,14 @@@ static void ui_but_free(const bContext 
  		MEM_freeN(but->tip_argN);
  	}
  
+ 	if (but->hold_argN) {
+ 		MEM_freeN(but->hold_argN);
+ 	}
+ 
 +	if (!but->editstr && but->free_search_arg) {
 +		MEM_SAFE_FREE(but->search_arg);
 +	}
 +
  	if (but->active) {
  		/* XXX solve later, buttons should be free-able without context ideally,
  		 * however they may have open tooltips or popup windows, which need to
diff --cc source/blender/editors/interface/interface_widgets.c
index e3977219eda,79571e24a4b..f419ab2d1ed
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@@ -184,36 -191,41 +191,47 @@@ static const uint g_shape_preset_checkm
  	{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
  };
  
+ #define OY -0.2 
+ #define SC 0.35
+ static const float g_shape_preset_hold_action_vert[6][2] = {
+ 	{-0.5 + SC, 1.0 + OY},  {0.5, 1.0 + OY},  {0.5, 0.0 + OY + SC},
+ };
+ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}};
+ #undef OY
+ #undef SC
+ 
+ /** \} */
+ 
  /* ************************************************* */
  
 -void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
 +void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3,
 +                       const float color[4])
  {
  	float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
 -	float color[4];
 -	int j;
 -	
 +	float draw_color[4];
 +
 +	copy_v4_v4(draw_color, color);
 +	draw_color[3] *= 0.125f;
 +
  	glEnable(GL_BLEND);
 -	glGetFloatv(GL_CURRENT_COLOR, color);
 -	color[3] *= 0.125f;
 -	glColor4fv(color);
  
 -	glEnableClientState(GL_VERTEX_ARRAY);
 -	glVertexPointer(2, GL_FLOAT, 0, tri_arr);
 +	unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +
 +	immUniformColor4fv(draw_color);
 +	immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER);
  
  	/* for each AA step */
 -	for (j = 0; j < WIDGET_AA_JITTER; j++) {
 -		glTranslate2fv(jit[j]);
 -		glDrawArrays(GL_TRIANGLES, 0, 3);
 -		glTranslatef(-jit[j][0], -jit[j][1], 0.0f);
 +	for (int j = 0; j < WIDGET_AA_JITTER; j++) {
 +		immVertex2f(pos, tri_arr[0][0] + jit[j][0], tri_arr[0][1] + jit[j][1]);
 +		immVertex2f(pos, tri_arr[1][0] + jit[j][0], tri_arr[1][1] + jit[j][1]);
 +		immVertex2f(pos, tri_arr[2][0] + jit[j][0], tri_arr[2][1] + jit[j][1]);
  	}
  
 -	glDisableClientState(GL_VERTEX_ARRAY);
 +	immEnd();
 +
 +	immUnbindProgram();
 +
  	glDisable(GL_BLEND);
  }
  
@@@ -531,46 -542,39 +552,54 @@@ static void shape_preset_init_trias_ex
  	tria->index = tris;
  }
  
- static void widget_num_tria(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+ static void shape_preset_init_number_arrows(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+ {
+ 	shape_preset_init_trias_ex(
+ 	        tria, rect, triasize, where,
+ 	        g_shape_preset_number_arrow_vert, ARRAY_SIZE(g_shape_preset_number_arrow_vert),
+ 	        g_shape_preset_number_arrow_face, ARRAY_SIZE(g_shape_preset_number_arrow_face));
+ }
+ 
+ static void shape_preset_init_hold_action(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
  {
- 	widget_draw_tria_ex(
+ 	shape_preset_init_trias_ex(
  	        tria, rect, triasize, where,
- 	        num_tria_vert, ARRAY_SIZE(num_tria_vert),
- 	        num_tria_face, ARRAY_SIZE(num_tria_face));
+ 	        g_shape_preset_hold_action_vert, ARRAY_SIZE(g_shape_preset_hold_action_vert),
+ 	        g_shape_preset_hold_action_face, ARRAY_SIZE(g_shape_preset_hold_action_face));
  }
  
- static void widget_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+ static void shape_preset_init_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
  {
- 	widget_draw_tria_ex(
+ 	shape_preset_init_trias_ex(
  	        tria, rect, triasize, where,
- 	        scroll_circle_vert, ARRAY_SIZE(scroll_circle_vert),
- 	        scroll_circle_face, ARRAY_SIZE(scroll_circle_face));
+ 	        g_shape_preset_scroll_circle_vert, ARRAY_SIZE(g_shape_preset_scroll_circle_vert),
+ 	        g_shape_preset_scroll_circle_face, ARRAY_SIZE(g_shape_preset_scroll_circle_face));
  }
  
- static void widget_trias_draw(uiWidgetTrias *tria, unsigned int pos)
 -static void shape_preset_draw_trias(uiWidgetTrias *tria)
++static void shape_preset_draw_trias(uiWidgetTrias *tria, uint pos)
 +{
 +	immBegin(GWN_PRIM_TRIS, tria->tot * 3);
 +	for (int i = 0; i < tria->tot; ++i)
 +		for (int j = 0; j < 3; ++j)
 +			immVertex2fv(pos, tria->vec[tria->index[i][j]]);
 +	immEnd();
 +}
 +
 +static void widget_draw_vertex_buffer(unsigned int pos, unsigned int col, int mode,
 +                                      const float quads_pos[WIDGET_SIZE_MAX][2],
 +                                      const unsigned char quads_col[WIDGET_SIZE_MAX][4],
 +                                      unsigned int totvert)
  {
 -	glEnableClientState(GL_VERTEX_ARRAY);
 -	glVertexPointer(2, GL_FLOAT, 0, tria->vec);
 -	glDrawElements(GL_TRIANGLES, tria->tot * 3, GL_UNSIGNED_INT, tria->index);
 -	glDisableClientState(GL_VERTEX_ARRAY);
 +	immBegin(mode, totvert);
 +	for (int i = 0; i < totvert; ++i) {
 +		if (quads_col)
 +			immAttrib4ubv(col, quads_col[i]);
 +		immVertex2fv(pos, quads_pos[i]);
 +	}
 +	immEnd();
  }
  
- static void widget_menu_trias(uiWidgetTrias *tria, const rcti *rect)
+ static void shape_preset_trias_from_rect_menu(uiWidgetTrias *tria, const rcti *rect)
  {
  	float centx, centy, size;
  	int a;
@@@ -802,18 -812,17 +833,18 @@@ static void widgetbase_draw(uiWidgetBas
  
  		/* for each AA step */
  		for (j = 0; j < WIDGET_AA_JITTER; j++) {
 -			glTranslate2fv(jit[j]);
 +			gpuTranslate2fv(jit[j]);
  
 -			if (wtb->tria1.tot) {
 -				shape_preset_draw_trias(&wtb->tria1);
 -			}
 -			if (wtb->tria2.tot) {
 -				shape_preset_draw_trias(&wtb->tria2);
 -			}
 +			if (wtb->tria1.tot)
- 				widget_trias_draw(&wtb->tria1, pos);
++				shape_preset_draw_trias(&wtb->tria1, pos);
 +
 +			if (wtb->tria2.tot)
- 				widget_trias_draw(&wtb->tria2, pos);
- 		
++				shape_preset_draw_trias(&wtb->tria2, pos);
+ 
 -			glTranslatef(-jit[j][0], -jit[j][1], 0.0f);
 +			gpuTranslate2f(-jit[j][0], -jit[j][1]);
  		}
 +
 +		immUnbindProgram();
  	}
  
  	glDisable(GL_BLEND);
@@@ -3467,45 -3392,26 +3499,64 @@@ static void widget_roundbut(uiWidgetCol
  
  	widgetbase_draw(&wtb, wcol);
  }
+ #endif
+ 
+ static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+ {
+ 	uiWidgetBase wtb;
+ 	const float rad = 0.25f * U.widget_unit;
+ 
+ 	widget_init(&wtb);
+ 
+ 	if (state & UI_STATE_HOLD_ACTION) {
+ 		/* Show that keeping pressed performs another action (typically a menu). */
+ 		shape_preset_init_hold_action(&wtb.tria1, rect, 0.75f, 'r');
+ 	}
+ 
+ 	/* half rounded */
+ 	round_box_edges(&wtb, roundboxalign, rect, rad);
+ 
+ 	widgetbase_draw(&wtb, wcol);
+ }
  
 +static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
 +{
 +	const uiStyle *style = UI_style_get();
 +	const float rad = 0.15f * U.widget_unit;
 +	const int fontid = style->widget.uifont_id;
 +	const bool is_active = (but->flag & UI_SELECT);
 +
 +	uiWidgetBase wtb;
 +	unsigned char theme_col_tab_highlight[3];
 +
 +	/* create outline highlight colors */
 +	if (is_active) {
 +		interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner_sel,
 +		                     (unsigned char *)wcol->outline, 0.2f);
 +	}
 +	else {
 +		interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner,
 +		                     (unsigned char *)wcol->outline, 0.12f);
 +	}
 +
 +	widget_init(&wtb);
 +
 +	/* half rounded */
 +	round_box_edges(&wtb, roundboxalign, rect, rad);
 +
 +	/* draw inner */
 +	wtb.draw_outline = 0;
 +	widgetbase_draw(&wtb, wcol);
 +
 +	/* draw outline (3d look) */
 +	ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (unsigned char *)wcol->inner);
 +
 +	/* text shadow */
 +	BLF_enable(fontid, BLF_SHADOW);
 +	BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
 +	BLF_shadow_offset(fontid, 0, -1);
 +}
 +
  static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
  {
  	uiWidgetBase wtb;
@@@ -3590,14 -3491,9 +3641,14 @@@ static uiWidgetType *widget_type(uiWidg
  			
  		case UI_WTYPE_EXEC:
  			wt.wcol_theme = &btheme->tui.wcol_tool;
- 			wt.draw = widget_roundbut;
+ 			wt.draw = widget_roundbut_exec;
  			break;
  
 +		case UI_WTYPE_TAB:
 +			wt.custom = widget_tab;
 +			wt.wcol_theme = &btheme->tui.wcol_tab;
 +			break;
 +
  		case UI_WTYPE_TOOLTIP:
  			wt.wcol_theme = &btheme->tui.wcol_tooltip;
  			wt.draw = widget_menu_back;
@@@ -4340,6 -4239,9 +4399,8 @@@ void ui_draw_preview_item(uiFontStyle *
  		BLI_strncpy(drawstr, name, sizeof(drawstr));
  		UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
  
 -		glColor4ubv((unsigned char *)wt->wcol.text);
 -		UI_fontstyle_draw(fstyle, &trect, drawstr);
 +		UI_fontstyle_draw(fstyle, &trect, drawstr, (unsigned char *)wt->wcol.text);
  	}
  }
+ 
+ /** \} */



More information about the Bf-blender-cvs mailing list