[Bf-blender-cvs] [b2b1aa2f8ea] master: Fix T57090: selected node group input sockets circles not drawing in sidebar UIList

Philipp Oeser noreply at git.blender.org
Tue May 28 12:27:24 CEST 2019


Commit: b2b1aa2f8ead62cb376342b11348fe8495ae736d
Author: Philipp Oeser
Date:   Mon May 27 23:10:35 2019 +0200
Branches: master
https://developer.blender.org/rBb2b1aa2f8ead62cb376342b11348fe8495ae736d

Fix T57090: selected node group input sockets circles not drawing in
sidebar UIList

nodesockets were actually drawn, but immediately drawn over by widgets
from the widget draw batch cache.

solution here is to "widgify" nodesocket drawing as well.

Reviewers: brecht

Maniphest Tasks: T57090

Differential Revision: https://developer.blender.org/D4963

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

M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_widgets.c

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

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 640d5127446..022c3b3cb51 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2255,104 +2255,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar),
   GPU_blend(false);
 }
 
-void ui_draw_but_NODESOCKET(ARegion *ar,
-                            uiBut *but,
-                            const uiWidgetColors *UNUSED(wcol),
-                            const rcti *recti)
-{
-  static const float size = 5.0f;
-
-  /* 16 values of sin function */
-  const float si[16] = {
-      0.00000000f,
-      0.39435585f,
-      0.72479278f,
-      0.93775213f,
-      0.99871650f,
-      0.89780453f,
-      0.65137248f,
-      0.29936312f,
-      -0.10116832f,
-      -0.48530196f,
-      -0.79077573f,
-      -0.96807711f,
-      -0.98846832f,
-      -0.84864425f,
-      -0.57126821f,
-      -0.20129852f,
-  };
-  /* 16 values of cos function */
-  const float co[16] = {
-      1.00000000f,
-      0.91895781f,
-      0.68896691f,
-      0.34730525f,
-      -0.05064916f,
-      -0.44039415f,
-      -0.75875812f,
-      -0.95413925f,
-      -0.99486932f,
-      -0.87434661f,
-      -0.61210598f,
-      -0.25065253f,
-      0.15142777f,
-      0.52896401f,
-      0.82076344f,
-      0.97952994f,
-  };
-
-  int scissor[4];
-
-  /* need scissor test, can draw outside of boundary */
-  GPU_scissor_get_i(scissor);
-
-  rcti scissor_new = {
-      .xmin = recti->xmin,
-      .ymin = recti->ymin,
-      .xmax = recti->xmax,
-      .ymax = recti->ymax,
-  };
-
-  rcti scissor_region = {0, ar->winx, 0, ar->winy};
-
-  BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
-  GPU_scissor(scissor_new.xmin,
-              scissor_new.ymin,
-              BLI_rcti_size_x(&scissor_new),
-              BLI_rcti_size_y(&scissor_new));
-
-  float x = 0.5f * (recti->xmin + recti->xmax);
-  float y = 0.5f * (recti->ymin + recti->ymax);
-
-  GPUVertFormat *format = immVertexFormat();
-  uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-  immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-  immUniformColor4ubv(but->col);
-
-  GPU_blend(true);
-  immBegin(GPU_PRIM_TRI_FAN, 16);
-  for (int a = 0; a < 16; a++) {
-    immVertex2f(pos, x + size * si[a], y + size * co[a]);
-  }
-  immEnd();
-
-  immUniformColor4ub(0, 0, 0, 150);
-  GPU_line_width(1);
-  GPU_line_smooth(true);
-  immBegin(GPU_PRIM_LINE_LOOP, 16);
-  for (int a = 0; a < 16; a++) {
-    immVertex2f(pos, x + size * si[a], y + size * co[a]);
-  }
-  immEnd();
-  GPU_line_smooth(false);
-  GPU_blend(false);
-
-  immUnbindProgram();
-
-  /* restore scissortest */
-  GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
-}
-
 /* ****************************************************** */
 
 /* TODO: high quality UI drop shadows using GLSL shader and single draw call
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 8a2b28ee2d4..fc65129ebf7 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -741,10 +741,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar,
                               uiBut *but,
                               const struct uiWidgetColors *wcol,
                               const rcti *rect);
-void ui_draw_but_NODESOCKET(ARegion *ar,
-                            uiBut *but,
-                            const struct uiWidgetColors *wcol,
-                            const rcti *rect);
 
 /* interface_handlers.c */
 PointerRNA *ui_handle_afterfunc_add_operator(struct wmOperatorType *ot,
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 71629d6297c..f654fbcdc1e 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -106,6 +106,7 @@ typedef enum {
   UI_WTYPE_SCROLL,
   UI_WTYPE_LISTITEM,
   UI_WTYPE_PROGRESSBAR,
+  UI_WTYPE_NODESOCKET,
 } uiWidgetTypeEnum;
 
 /* Button state argument shares bits with 'uiBut.flag'.
@@ -3624,6 +3625,41 @@ static void widget_progressbar(
   rect->xmax += (BLI_rcti_size_x(&rect_prog) / 2);
 }
 
+static void widget_nodesocket(
+    uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
+{
+  uiWidgetBase wtb;
+  int radi = 5;
+  char old_inner[3], old_outline[3];
+
+  widget_init(&wtb);
+
+  copy_v3_v3_char(old_inner, wcol->inner);
+  copy_v3_v3_char(old_outline, wcol->outline);
+
+  wcol->inner[0] = but->col[0];
+  wcol->inner[1] = but->col[1];
+  wcol->inner[2] = but->col[2];
+  wcol->outline[0] = 0;
+  wcol->outline[1] = 0;
+  wcol->outline[2] = 0;
+  wcol->outline[3] = 150;
+
+  int cent_x = BLI_rcti_cent_x(rect);
+  int cent_y = BLI_rcti_cent_y(rect);
+  rect->xmin = cent_x - radi;
+  rect->xmax = cent_x + radi;
+  rect->ymin = cent_y - radi;
+  rect->ymax = cent_y + radi;
+
+  wtb.draw_outline = true;
+  round_box_edges(&wtb, UI_CNR_ALL, rect, (float)radi);
+  widgetbase_draw(&wtb, wcol);
+
+  copy_v3_v3_char(wcol->inner, old_inner);
+  copy_v3_v3_char(wcol->outline, old_outline);
+}
+
 static void widget_numslider(
     uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
 {
@@ -4376,6 +4412,10 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
       wt.custom = widget_progressbar;
       break;
 
+    case UI_WTYPE_NODESOCKET:
+      wt.custom = widget_nodesocket;
+      break;
+
     case UI_WTYPE_MENU_ITEM_RADIAL:
       wt.wcol_theme = &btheme->tui.wcol_pie_menu;
       wt.custom = widget_menu_radial_itembut;
@@ -4698,7 +4738,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
         break;
 
       case UI_BTYPE_NODE_SOCKET:
-        ui_draw_but_NODESOCKET(ar, but, &tui->wcol_regular, rect);
+        wt = widget_type(UI_WTYPE_NODESOCKET);
         break;
 
       default:



More information about the Bf-blender-cvs mailing list