16 static lives_pconnect_t *spconx;
17 static lives_cconnect_t *scconx;
19 static boolean do_chan_connected_query(
lives_conx_w *,
int okey,
int omode,
int ocnum,
boolean is_same_key);
20 static boolean do_param_connected_query(
lives_conx_w *,
int okey,
int omode,
int opnum,
boolean is_same_key);
23 static void ptable_row_add_standard_widgets(
lives_conx_w *,
int idx);
24 static void ptable_row_add_variable_widgets(
lives_conx_w *,
int idx,
int row,
int pidx);
26 static void ctable_row_add_standard_widgets(
lives_conx_w *,
int idx);
27 static void ctable_row_add_variable_widgets(
lives_conx_w *,
int idx,
int row,
int cidx);
29 static void padd_clicked(LiVESWidget *button, livespointer user_data);
30 static void cadd_clicked(LiVESWidget *button, livespointer user_data);
32 static void dfxp_changed(LiVESWidget *, livespointer conxwp);
34 static weed_plant_t *active_dummy = NULL;
36 static LiVESTreeModel *pmodel;
37 static LiVESTreeModel *cmodel;
41 #define BW (40. * widget_opts.scale)
42 #define BH (40. * widget_opts.scale)
45 static void dump_connections(
void) {
49 for (
int i = 0; i < pconx->nparams; i++) {
50 int pnum = pconx->params[i];
51 for (
int j = 0; j < pconx->nconns[i + 1]; j++) {
61 static char *get_param_name(weed_plant_t *param,
int pnum,
boolean is_in) {
62 char *name = weed_get_string_value(param, WEED_LEAF_NAME, NULL);
75 static char *get_chan_name(weed_plant_t *chan,
int cnum,
boolean is_in) {
76 char *name = weed_get_string_value(chan, WEED_LEAF_NAME, NULL);
89 static void switch_fx_state(
int hotkey) {
110 for (i = 0; i < pconx->nparams; i++) {
111 totcons += pconx->nconns[i];
112 for (; j < totcons; j++) {
113 if (pconx->ikey[j] == hotkey && pconx->imode[j] == imode && pconx->ipnum[j] ==
FX_DATA_PARAM_ACTIVE) {
116 pconx->autoscale[j] =
TRUE;
136 if (pconx->okey == hotkey && pconx->omode == omode) {
139 for (
int i = 0; i < pconx->nparams; i++) {
140 totcons += pconx->nconns[i];
141 for (; j < totcons; j++) {
144 pconx->autoscale[j] =
FALSE;
154 lives_pconnect_t *pconx =
mainw->
pconx, *pconx_next;
160 pconx_next = pconx->next;
172 static lives_pconnect_t *pconx_new(
int okey,
int omode) {
175 pconx->omode = omode;
180 static lives_pconnect_t *pconx_copy(lives_pconnect_t *spconx) {
181 lives_pconnect_t *pconx = NULL, *dpconx, *last_dpconx;
188 dpconx = pconx_new(spconx->okey, spconx->omode);
189 if (!pconx) pconx = dpconx;
190 else last_dpconx->next = dpconx;
192 dpconx->nparams = spconx->nparams;
198 dpconx->ikey = dpconx->imode = dpconx->ipnum = NULL;
199 dpconx->autoscale = NULL;
203 for (
int i = 0; i < dpconx->nparams; i++) {
204 dpconx->params[i] = spconx->params[i];
205 dpconx->nconns[i] = spconx->nconns[i];
206 dpconx->last_boolval[i] = spconx->last_boolval[i];
207 totcons += dpconx->nconns[i];
214 while (j < totcons) {
215 dpconx->ikey[j] = spconx->ikey[j];
216 dpconx->imode[j] = spconx->imode[j];
217 dpconx->ipnum[j] = spconx->ipnum[j];
218 dpconx->autoscale[j] = spconx->autoscale[j];
223 spconx = spconx->next;
224 last_dpconx = dpconx;
232 char *st1 = lives_strdup(
""), *st2;
237 if (pconx->okey == okey && pconx->omode == omode) {
238 for (
int i = 0; i < pconx->nparams; i++) {
239 if (pconx->params[i] == opnum) {
240 for (
int j = totcons; j < totcons + pconx->nconns[i]; j++) {
242 st2 =
lives_strdup_printf(
"%d %d %d %d", pconx->ikey[j] + 1, pconx->imode[j] + 1, pconx->ipnum[j],
243 pconx->autoscale[j]);
246 pconx->ipnum[j], pconx->autoscale[j]);
252 totcons += pconx->nconns[i];
262 void pconx_delete(
int okey,
int omode,
int opnum,
int ikey,
int imode,
int ipnum) {
263 lives_pconnect_t *pconx =
mainw->
pconx, *pconx_next, *pconx_prev = NULL;
266 int totcons = 0, maxcons = 0;
273 pconx_next = pconx->next;
276 g_print(
"Deletion check, want %d / %d, found %d / %d\n", okey, omode, pconx->okey, pconx->omode);
281 g_print(
"GOT MATCH\n");
292 else pconx_prev->next = pconx_next;
302 for (i = 0; i < pconx->nparams; i++) {
303 maxcons += pconx->nconns[i];
306 for (i = 0; pconx && i < pconx->nparams; i++) {
308 g_print(
"Checking oparams, want %d, got %d with %d connections\n", opnum, pconx->params[i], pconx->nconns[i]);
310 totcons += pconx->nconns[i];
317 for (; j < totcons; j++) {
319 g_print(
"For inputs, want %d / %d (%d), found %d / %d (%d)\n", ikey, imode, ipnum, pconx->ikey[j], pconx->imode[j],
326 || pconx->ipnum[j] == ipnum)) {
328 g_print(
"removing connection to %d / %d param (%d)\n", ikey, imode, ipnum);
331 for (k = j; k < maxcons; k++) {
332 pconx->ikey[k] = pconx->ikey[k + 1];
333 pconx->imode[k] = pconx->imode[k + 1];
334 pconx->ipnum[k] = pconx->ipnum[k + 1];
335 pconx->autoscale[k] = pconx->autoscale[k + 1];
345 if (pconx->nconns[i] == 0) {
347 for (k = i; k < pconx->nparams; k++) {
348 pconx->params[k] = pconx->params[k + 1];
349 pconx->last_boolval[k] = pconx->last_boolval[k + 1];
350 pconx->nconns[k] = pconx->nconns[k + 1];
353 if (pconx->nparams == 0) {
364 pconx->next = pconx_next;
383 register int i, j, totcons;
386 if (pconx->okey == key && pconx->omode == omode) {
387 pconx->omode = nmode;
391 for (i = 0; i < pconx->nparams; i++) {
392 totcons += pconx->nconns[i];
393 for (; j < totcons; j++) {
394 if (pconx->ikey[j] == key && pconx->imode[j] == omode) {
395 pconx->imode[j] = nmode;
404 static void pconx_append(lives_pconnect_t *pconx) {
406 lives_pconnect_t *last_pconx = opconx;
410 opconx = opconx->next;
413 if (last_pconx) last_pconx->next = pconx;
418 static lives_pconnect_t *pconx_find(
int okey,
int omode) {
422 if (pconx->okey == okey && pconx->omode == omode) {
431 static int pconx_get_numcons(
lives_conx_w * conxwp,
int pnum) {
437 for (
int j = 0; j < conxwp->
num_params; j++) {
438 totcons += conxwp->
dispp[j];
445 static int pconx_get_nconns(lives_pconnect_t *pconx,
int pnum) {
449 if (!pconx)
return 0;
451 for (
int j = 0; j < pconx->nparams; j++) {
453 if (pconx->params[j] == pnum)
return pconx->nconns[j];
454 }
else totcons += pconx->nconns[j];
460 static lives_pconnect_t *pconx_add_connection_private(
int okey,
int omode,
int opnum,
int ikey,
int imode,
int ipnum,
462 lives_pconnect_t *pconx;
463 int posn = 0, totcons = 0;
468 pconx = pconx_find(okey, omode);
474 pconx = pconx_new(okey, omode);
478 for (i = 0; i < pconx->nparams; i++) {
479 if (pconx->params[i] == opnum) {
483 for (j = 0; j < pconx->nparams; j++) {
486 posn += pconx->nconns[j];
488 totcons += pconx->nconns[j];
492 for (j = posn; j < posn + pconx->nconns[i]; j++) {
493 if (pconx->ikey[j] == ikey && pconx->imode[j] == imode && pconx->ipnum[j] == ipnum) {
494 pconx->autoscale[j] = autoscale;
500 if (pconx->ikey[j] > ikey || (pconx->ikey[j] == ikey && pconx->imode[j] > imode) ||
501 (pconx->ikey[j] == ikey && pconx->imode[j] == imode && pconx->ipnum[j] > ipnum))
break;
518 for (j = totcons - 1; j > posn; j--) {
519 pconx->ikey[j] = pconx->ikey[j - 1];
520 pconx->imode[j] = pconx->imode[j - 1];
521 pconx->ipnum[j] = pconx->ipnum[j - 1];
522 pconx->autoscale[j] = pconx->autoscale[j - 1];
526 pconx->ikey[posn] = ikey;
527 pconx->imode[posn] = imode;
528 pconx->ipnum[posn] = ipnum;
529 pconx->autoscale[posn] = autoscale;
539 for (i = 0; i < pconx->nparams; i++) {
540 totcons += pconx->nconns[i];
546 posn = pconx->nparams;
558 pconx->params[posn - 1] = opnum;
560 pconx->last_boolval[posn - 1] = WEED_FALSE;
562 pconx->nconns[posn - 1] = 1;
567 pconx->ikey[posn] = ikey;
568 pconx->imode[posn] = imode;
569 pconx->ipnum[posn] = ipnum;
570 pconx->autoscale[posn] = autoscale;
573 g_print(
"added another pconx from %d %d %d to %d %d %d\n", okey, omode, opnum, ikey, imode, ipnum);
588 pconx->nconns[pconx->nparams - 1] = 1;
591 pconx->params[pconx->nparams - 1] = opnum;
594 pconx->last_boolval[pconx->nparams - 1] = WEED_FALSE;
597 pconx->ikey[totcons - 1] = ikey;
600 pconx->imode[totcons - 1] = imode;
603 pconx->ipnum[totcons - 1] = ipnum;
606 pconx->autoscale[totcons - 1] = autoscale;
609 g_print(
"added new pconx from %d %d %d to %d %d %d (%d)\n", okey, omode, opnum, ikey, imode, ipnum, autoscale);
619 pconx_add_connection_private(okey, omode, opnum, ikey, imode, ipnum, autoscale);
623 static weed_plant_t *pconx_get_out_param(
boolean use_filt,
int ikey,
int imode,
int ipnum,
int *okey,
int *omode,
int *opnum,
633 weed_plant_t *inst = NULL, *filter = NULL;
654 for (i = 0; i < pconx->nparams; i++) {
655 totcons += pconx->nconns[i];
656 for (; j < totcons; j++) {
657 if (pconx->ikey[j] == ikey && pconx->imode[j] == imode && pconx->ipnum[j] == ipnum) {
658 weed_plant_t *param = NULL;
665 active_dummy = weed_plant_new(WEED_PLANT_PARAMETER);
666 weed_set_plantptr_value(active_dummy, WEED_LEAF_TEMPLATE, NULL);
669 weed_set_boolean_value(active_dummy, WEED_LEAF_VALUE, inst != NULL
670 && (!gui || !weed_plant_has_leaf(gui, WEED_LEAF_EASE_OUT)));
671 param = active_dummy;
675 weed_plant_t **outparams = weed_get_plantptr_array(filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES, NULL);
676 if (pconx->params[i] < weed_leaf_num_elements(filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES)) {
677 param = outparams[pconx->params[i]];
681 if (!inst)
return NULL;
685 if (okey) *okey = pconx->okey;
686 if (omode) *omode = pconx->omode;
687 if (opnum) *opnum = pconx->params[i];
688 if (autoscale) *autoscale = pconx->autoscale[j];
702 static boolean params_compatible(weed_plant_t *sparam, weed_plant_t *dparam) {
715 weed_plant_t *dptmpl = NULL;
717 int dtype = 0, stype = 0;
718 int ndvals = 0, nsvals = 0;
719 int ptype, dflags = 0;
721 if (dparam == active_dummy) {
723 dtype = WEED_SEED_BOOLEAN;
727 dptmpl = weed_get_plantptr_value(dparam, WEED_LEAF_TEMPLATE, NULL);
728 dtype = weed_leaf_seed_type(dparam, WEED_LEAF_VALUE);
729 ndvals = weed_leaf_num_elements(dparam, WEED_LEAF_VALUE);
732 dtype = weed_leaf_seed_type(dparam, WEED_LEAF_DEFAULT);
733 ndvals = weed_leaf_num_elements(dparam, WEED_LEAF_DEFAULT);
737 if (sparam == active_dummy) {
738 stype = WEED_SEED_BOOLEAN;
742 stype = weed_leaf_seed_type(sparam, WEED_LEAF_VALUE);
743 nsvals = weed_leaf_num_elements(sparam, WEED_LEAF_VALUE);
745 stype = weed_leaf_seed_type(sparam, WEED_LEAF_DEFAULT);
746 nsvals = weed_leaf_num_elements(sparam, WEED_LEAF_DEFAULT);
754 if (ptype == WEED_PARAM_COLOR) {
755 int cspace = weed_get_int_value(dptmpl, WEED_LEAF_COLORSPACE, NULL);
756 if (cspace == WEED_COLORSPACE_RGB) {
757 if (!(nsvals & 3))
return FALSE;
758 }
else if (nsvals & 3)
return FALSE;
762 if (ndvals > nsvals) {
763 if (!((dflags & WEED_PARAMETER_VARIABLE_SIZE) && !(dflags & WEED_PARAMETER_VALUE_PER_CHANNEL)))
return FALSE;
766 if (dtype == stype)
return TRUE;
769 case WEED_SEED_DOUBLE:
770 if (dtype == WEED_SEED_STRING)
return TRUE;
773 if (dtype == WEED_SEED_DOUBLE || dtype == WEED_SEED_STRING)
return TRUE;
775 case WEED_SEED_BOOLEAN:
776 if (dtype == WEED_SEED_DOUBLE || dtype == WEED_SEED_INT || dtype == WEED_SEED_STRING)
return TRUE;
786 static boolean pconx_convert_value_data(weed_plant_t *inst,
int pnum,
int key, weed_plant_t *dparam,
int okey,
787 weed_plant_t *sparam,
boolean autoscale,
boolean is_audio_thread,
boolean * toggle_fx) {
789 weed_plant_t *dptmpl = NULL, *sptmpl;
793 int dtype = 0, stype, nsvals, ndvals = 0;
795 int nsmin = 0, nsmax = 0;
796 int minct = 0, maxct = 0;
797 int sminct = 0, smaxct = 0;
798 int nmax = 0, nmin = 0;
799 boolean retval =
FALSE;
803 if (toggle_fx) *toggle_fx =
FALSE;
805 if (dparam == sparam && (dparam != active_dummy || !active_dummy))
return FALSE;
807 if (sparam == active_dummy) {
810 stype = WEED_SEED_BOOLEAN;
813 nsvals = weed_leaf_num_elements(sparam, WEED_LEAF_VALUE);
814 if (nsvals == 0)
return FALSE;
816 stype = weed_leaf_seed_type(sparam, WEED_LEAF_VALUE);
818 if (dparam != active_dummy) {
819 ondvals = ndvals = weed_leaf_num_elements(dparam, WEED_LEAF_VALUE);
821 dtype = weed_leaf_seed_type(dparam, WEED_LEAF_VALUE);
823 dtype = WEED_SEED_BOOLEAN;
824 ondvals = ndvals = 1;
828 if (!params_compatible(sparam, dparam))
return FALSE;
830 if (ndvals > nsvals) ndvals = nsvals;
832 if (dparam != active_dummy && sparam != active_dummy) {
833 if (weed_plant_has_leaf(sptmpl, WEED_LEAF_MIN) && weed_plant_has_leaf(sptmpl, WEED_LEAF_MAX)) {
834 nsmin = weed_leaf_num_elements(sptmpl, WEED_LEAF_MIN);
835 nsmax = weed_leaf_num_elements(sptmpl, WEED_LEAF_MAX);
839 if (dptmpl && weed_plant_has_leaf(dptmpl, WEED_LEAF_MAX)) {
840 nmax = weed_leaf_num_elements(dptmpl, WEED_LEAF_MAX);
841 nmin = weed_leaf_num_elements(dptmpl, WEED_LEAF_MIN);
845 case WEED_SEED_STRING:
847 case WEED_SEED_STRING: {
848 char **valsS, **valss;
849 if ((valsS = weed_get_string_array(sparam, WEED_LEAF_VALUE, NULL)) == NULL)
return retval;
850 if ((valss = weed_get_string_array(dparam, WEED_LEAF_VALUE, NULL)) == NULL)
return retval;
852 if (ndvals > ondvals) valss = (
char **)
lives_realloc(valss, ndvals *
sizeof(
char *));
854 for (i = 0; i < ndvals; i++) {
855 if (i >= ondvals || strcmp(valss[i], valsS[i])) {
862 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
868 weed_set_string_array(dparam, WEED_LEAF_VALUE, ndvals, valss);
870 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
878 case WEED_SEED_DOUBLE:
880 case WEED_SEED_DOUBLE: {
881 double *valsD = weed_get_double_array(sparam, WEED_LEAF_VALUE, NULL);
882 double *valsd = weed_get_double_array(dparam, WEED_LEAF_VALUE, NULL);
884 double *maxd = weed_get_double_array(dptmpl, WEED_LEAF_MAX, NULL);
885 double *mind = weed_get_double_array(dptmpl, WEED_LEAF_MIN, NULL);
887 double *mins = NULL, *maxs = NULL;
890 mins = weed_get_double_array(sptmpl, WEED_LEAF_MIN, NULL);
891 maxs = weed_get_double_array(sptmpl, WEED_LEAF_MAX, NULL);
894 if (ndvals > ondvals) valsd = (
double *)
lives_realloc(valsd, ndvals *
sizeof(
double));
896 for (i = 0; i < ndvals; i++) {
898 ratio = (valsD[i] - mins[sminct]) / (maxs[smaxct] - mins[sminct]);
899 valsD[i] = mind[minct] + (maxd[maxct] - mind[minct]) * ratio;
900 if (++smaxct == nsmax) smaxct = 0;
901 if (++sminct == nsmin) sminct = 0;
903 if (valsD[i] > maxd[maxct]) valsD[i] = maxd[maxct];
904 if (valsD[i] < mind[minct]) valsD[i] = mind[minct];
907 if (i >= ondvals || valsd[i] != valsD[i]) {
911 if (++maxct == nmax) maxct = 0;
912 if (++minct == nmin) minct = 0;
926 weed_set_double_array(dparam, WEED_LEAF_VALUE, ndvals, valsd);
932 case WEED_SEED_STRING: {
933 char *opstring, *tmp, *bit;
934 double *valsd = weed_get_double_array(sparam, WEED_LEAF_VALUE, NULL);
938 opstring = lives_strdup(
"");
939 vals = weed_get_string_value(dparam, WEED_LEAF_VALUE, NULL);
940 for (i = 0; i < nsvals; i++) {
943 tmp = lives_strconcat(opstring, bit, NULL);
945 tmp = lives_strconcat(opstring,
" ", bit, NULL);
950 if (strcmp(vals, opstring)) {
951 weed_set_string_value(dparam, WEED_LEAF_VALUE, opstring);
958 valss = weed_get_string_array(dparam, WEED_LEAF_VALUE, NULL);
960 if (ndvals > ondvals) valss = (
char **)
lives_realloc(valsd, ndvals *
sizeof(
char *));
962 for (i = 0; i < ndvals; i++) {
964 if (i >= ondvals || strcmp(valss[i], bit)) {
971 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
977 weed_set_string_array(dparam, WEED_LEAF_VALUE, ndvals, valss);
979 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
991 case WEED_SEED_STRING: {
992 char *opstring, *tmp, *bit;
993 int *valsi = weed_get_int_array(sparam, WEED_LEAF_VALUE, NULL);
998 opstring = lives_strdup(
"");
999 vals = weed_get_string_value(dparam, WEED_LEAF_VALUE, NULL);
1000 for (i = 0; i < nsvals; i++) {
1003 tmp = lives_strconcat(opstring, bit, NULL);
1005 tmp = lives_strconcat(opstring,
" ", bit, NULL);
1010 if (strcmp(vals, opstring)) {
1011 weed_set_string_value(dparam, WEED_LEAF_VALUE, opstring);
1018 valss = weed_get_string_array(dparam, WEED_LEAF_VALUE, NULL);
1020 if (ndvals > ondvals) valss = (
char **)
lives_realloc(valss, ndvals *
sizeof(
char *));
1022 for (i = 0; i < ndvals; i++) {
1024 if (i >= ondvals || strcmp(valss[i], bit)) {
1031 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
1036 weed_set_string_array(dparam, WEED_LEAF_VALUE, ndvals, valss);
1038 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
1043 case WEED_SEED_DOUBLE: {
1044 int *valsi = weed_get_int_array(sparam, WEED_LEAF_VALUE, NULL);
1045 double *valsd = weed_get_double_array(dparam, WEED_LEAF_VALUE, NULL);
1047 double *maxd = weed_get_double_array(dptmpl, WEED_LEAF_MAX, NULL);
1048 double *mind = weed_get_double_array(dptmpl, WEED_LEAF_MIN, NULL);
1051 int *mins = NULL, *maxs = NULL;
1054 mins = weed_get_int_array(sptmpl, WEED_LEAF_MIN, NULL);
1055 maxs = weed_get_int_array(sptmpl, WEED_LEAF_MAX, NULL);
1058 if (ndvals > ondvals) valsd = (
double *)
lives_realloc(valsd, ndvals *
sizeof(
double));
1060 for (i = 0; i < ndvals; i++) {
1062 ratio = (double)(valsi[i] - mins[sminct]) / (double)(maxs[smaxct] - mins[sminct]);
1063 vald = mind[minct] + (maxd[maxct] - mind[minct]) * ratio;
1064 if (++smaxct == nsmax) smaxct = 0;
1065 if (++sminct == nsmin) sminct = 0;
1067 if (vald > maxd[maxct]) vald = maxd[maxct];
1068 if (vald < mind[minct]) vald = mind[minct];
1069 }
else vald = (double)valsi[i];
1071 if (i >= ondvals || valsd[i] != vald) {
1075 if (++maxct == nmax) maxct = 0;
1076 if (++minct == nmin) minct = 0;
1090 weed_set_double_array(dparam, WEED_LEAF_VALUE, ndvals, valsd);
1097 case WEED_SEED_INT: {
1098 int *valsI, *valsi, *maxi, *mini;
1099 int *mins = NULL, *maxs = NULL;
1101 if ((valsI = weed_get_int_array(sparam, WEED_LEAF_VALUE, NULL)) == NULL)
return retval;
1102 if ((valsi = weed_get_int_array(dparam, WEED_LEAF_VALUE, NULL)) == NULL)
return retval;
1103 if ((maxi = weed_get_int_array(dptmpl, WEED_LEAF_MAX, NULL)) == NULL)
return retval;
1104 if ((mini = weed_get_int_array(dptmpl, WEED_LEAF_MIN, NULL)) == NULL)
return retval;
1107 mins = weed_get_int_array(sptmpl, WEED_LEAF_MIN, NULL);
1108 maxs = weed_get_int_array(sptmpl, WEED_LEAF_MAX, NULL);
1111 if (ndvals > ondvals) valsi = (
int *)
lives_realloc(valsi, ndvals *
sizeof(
int));
1113 for (i = 0; i < ndvals; i++) {
1115 ratio = (double)(valsI[i] - mins[sminct]) / (double)(maxs[smaxct] - mins[sminct]);
1116 valsI[i] =
myround(mini[minct] + (
double)(maxi[maxct] - mini[minct]) * ratio);
1117 if (++smaxct == nsmax) smaxct = 0;
1118 if (++sminct == nsmin) sminct = 0;
1120 if (valsI[i] > maxi[maxct]) valsI[i] = maxi[maxct];
1121 if (valsI[i] < mini[minct]) valsI[i] = mini[minct];
1124 if (i >= ondvals || valsi[i] != valsI[i]) {
1126 valsi[i] = valsI[i];
1128 if (++maxct == nmax) maxct = 0;
1129 if (++minct == nmin) minct = 0;
1143 weed_set_int_array(dparam, WEED_LEAF_VALUE, ndvals, valsi);
1152 case WEED_SEED_BOOLEAN: {
1154 if (dparam == active_dummy) {
1157 int valb = weed_get_boolean_value(sparam, WEED_LEAF_VALUE, NULL);
1158 if ((valb == WEED_TRUE && (
mainw->
rte & (
GU641 << (key))) == 0) ||
1159 (valb == WEED_FALSE && (
mainw->
rte & (
GU641 << (key)))) != 0) {
1160 if (toggle_fx) *toggle_fx =
TRUE;
1165 valsb = weed_get_boolean_array(sparam, WEED_LEAF_VALUE, NULL);
1167 case WEED_SEED_STRING: {
1168 char *opstring, *tmp, *bit;
1169 char **valss, *vals;
1172 opstring = lives_strdup(
"");
1173 vals = weed_get_string_value(dparam, WEED_LEAF_VALUE, NULL);
1174 for (i = 0; i < nsvals; i++) {
1177 tmp = lives_strconcat(opstring, bit, NULL);
1179 tmp = lives_strconcat(opstring,
" ", bit, NULL);
1184 if (strcmp(vals, opstring)) {
1185 weed_set_string_value(dparam, WEED_LEAF_VALUE, opstring);
1192 valss = weed_get_string_array(dparam, WEED_LEAF_VALUE, NULL);
1193 if (ndvals > ondvals) valss = (
char **)
lives_realloc(valss, ndvals *
sizeof(
char *));
1195 for (i = 0; i < ndvals; i++) {
1197 if (i >= ondvals || strcmp(valss[i], bit)) {
1204 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
1210 weed_set_string_array(dparam, WEED_LEAF_VALUE, ndvals, valss);
1212 for (i = 0; i < ndvals; i++)
lives_free(valss[i]);
1217 case WEED_SEED_DOUBLE: {
1218 double *valsd = weed_get_double_array(dparam, WEED_LEAF_VALUE, NULL);
1219 double *maxd = weed_get_double_array(dptmpl, WEED_LEAF_MAX, NULL);
1220 double *mind = weed_get_double_array(dptmpl, WEED_LEAF_MIN, NULL);
1223 if (ndvals > ondvals) valsd = (
double *)
lives_realloc(valsd, ndvals *
sizeof(
double));
1225 for (i = 0; i < ndvals; i++) {
1227 if (valsb[i] == WEED_TRUE) vald = maxd[maxct];
1228 else vald = mind[minct];
1230 vald = (double)valsb[i];
1231 if (vald > maxd[maxct]) vald = maxd[maxct];
1232 if (vald < mind[minct]) vald = mind[minct];
1234 if (i >= ondvals || valsd[i] != vald) {
1238 if (++maxct == nmax) maxct = 0;
1239 if (++minct == nmin) minct = 0;
1247 weed_set_double_array(dparam, WEED_LEAF_VALUE, ndvals, valsd);
1253 case WEED_SEED_INT: {
1254 int *valsi = weed_get_int_array(dparam, WEED_LEAF_VALUE, NULL);
1255 int *maxi = weed_get_int_array(dptmpl, WEED_LEAF_MAX, NULL);
1256 int *mini = weed_get_int_array(dptmpl, WEED_LEAF_MIN, NULL);
1258 if (ndvals > ondvals) valsi = (
int *)
lives_realloc(valsi, ndvals *
sizeof(
int));
1260 for (i = 0; i < ndvals; i++) {
1262 if (valsb[i] == WEED_TRUE) valsb[i] = maxi[maxct];
1263 else valsb[i] = mini[minct];
1265 if (valsb[i] > maxi[maxct]) valsb[i] = maxi[maxct];
1266 if (valsb[i] < mini[minct]) valsb[i] = mini[maxct];
1268 if (i >= ondvals || valsi[i] != valsb[i]) {
1270 valsi[i] = valsb[i];
1272 if (++maxct == nmax) maxct = 0;
1273 if (++minct == nmin) minct = 0;
1281 weed_set_int_array(dparam, WEED_LEAF_VALUE, ndvals, valsi);
1288 case WEED_SEED_BOOLEAN: {
1289 int *valsB = weed_get_boolean_array(dparam, WEED_LEAF_VALUE, NULL);
1291 if (ndvals > ondvals) valsB = (
int *)
lives_realloc(valsB, ndvals *
sizeof(
int));
1293 for (i = 0; i < ndvals; i++) {
1294 if (i >= ondvals || valsB[i] != valsb[i]) {
1296 valsB[i] = valsb[i];
1304 weed_set_boolean_array(dparam, WEED_LEAF_VALUE, ndvals, valsB);
1327 char *valstr = NULL;
1332 boolean cbval, lbval;
1336 if (!inst)
return 0;
1344 if (pconx->okey == okey && pconx->omode == omode) {
1347 for (i = 0; i < pconx->nparams; i++) {
1348 totcons += pconx->nconns[i];
1349 pidx = pconx->params[i];
1350 lbval = pconx->last_boolval[i];
1351 for (; j < totcons; j++) {
1356 switch (weed_leaf_seed_type(oparam, WEED_LEAF_VALUE)) {
1357 case WEED_SEED_BOOLEAN:
1358 cbval = weed_get_boolean_value(oparam, WEED_LEAF_VALUE, NULL);
1359 if (cbval == WEED_TRUE && lbval == WEED_FALSE) {
1363 pconx->last_boolval[i] = cbval;
1369 pconx->last_boolval[i] = WEED_TRUE;
1384 pconx = pconx->next;
1391 weed_plant_t **inparams = NULL;
1392 weed_plant_t *oparam, *inparam = NULL;
1393 weed_plant_t *inst = NULL;
1395 boolean changed, reinit_inst =
FALSE;
1397 int nparams = 0, start = 0;
1401 boolean toggle_fx =
FALSE;
1419 if (weed_plant_has_leaf(inst, WEED_LEAF_IN_PARAMETERS))
1420 inparams = weed_get_plantptr_array_counted(inst, WEED_LEAF_IN_PARAMETERS, &nparams);
1426 for (i = start; i < nparams; i++) {
1428 if ((oparam = pconx_get_out_param(
FALSE, key, mode, i, &okey, &omode, NULL, &autoscale))) {
1431 g_print(
"got pconx to %d %d %d\n", key, mode, i);
1435 if (!active_dummy) {
1436 active_dummy = weed_plant_new(WEED_PLANT_PARAMETER);
1437 weed_set_plantptr_value(active_dummy, WEED_LEAF_TEMPLATE, NULL);
1439 inparam = active_dummy;
1441 }
else inparam = inparams[i];
1445 if (oparam != active_dummy) {
1460 : inparam, okey, oparam, autoscale, is_audio_thread, &toggle_fx);
1463 if (is_audio_thread) {
1482 switch_fx_state(key + 1);
1486 if (changed && inst && key > -1) {
1496 pflags = weed_get_int_value(inparams[i], WEED_LEAF_FLAGS, NULL);
1497 if (pflags & WEED_PARAMETER_REINIT_ON_VALUE_CHANGE) reinit_inst =
TRUE;
1504 if (keyw == key && modew == mode)
1527 weed_plant_t **in_params;
1529 boolean autoscale, reinit_inst =
FALSE;
1531 int nparams = 0, pflags, i;
1534 if (!nparams)
return FALSE;
1536 in_params = weed_get_plantptr_array(inst, WEED_LEAF_IN_PARAMETERS, NULL);
1538 for (i = 0; i < nparams; i++) {
1542 weed_get_boolean_value(in_params[i],
1544 if (pconx_convert_value_data(inst, i, -1, in_params[i], -1, weed_get_plantptr_value(in_params[i],
1547 pflags = weed_get_int_value(in_params[i], WEED_LEAF_FLAGS, NULL);
1548 if (pflags & WEED_PARAMETER_REINIT_ON_VALUE_CHANGE) reinit_inst =
TRUE;
1561 lives_cconnect_t *cconx =
mainw->
cconx, *cconx_next;
1563 cconx_next = cconx->next;
1564 if (cconx->nchans > 0) {
1578 static lives_cconnect_t *cconx_new(
int okey,
int omode) {
1582 cconx->omode = omode;
1584 cconx->nconns = NULL;
1589 static lives_cconnect_t *cconx_copy(lives_cconnect_t *scconx) {
1590 lives_cconnect_t *cconx = NULL, *dcconx, *last_dcconx;
1594 register int i, j = 0;
1597 dcconx = cconx_new(scconx->okey, scconx->omode);
1598 if (!cconx) cconx = dcconx;
1599 else last_dcconx->next = dcconx;
1601 dcconx->nchans = scconx->nchans;
1606 dcconx->ikey = dcconx->imode = dcconx->icnum = NULL;
1610 for (i = 0; i < dcconx->nchans; i++) {
1611 dcconx->chans[i] = scconx->chans[i];
1612 dcconx->nconns[i] = scconx->nconns[i];
1613 totcons += dcconx->nconns[i];
1619 while (j < totcons) {
1620 dcconx->ikey[j] = scconx->ikey[j];
1621 dcconx->imode[j] = scconx->imode[j];
1622 dcconx->icnum[j] = scconx->icnum[j];
1627 scconx = scconx->next;
1628 last_dcconx = dcconx;
1636 char *st1 = lives_strdup(
""), *st2;
1641 if (cconx->okey == okey && cconx->omode == omode) {
1642 for (
int i = 0; i < cconx->nchans; i++) {
1643 if (cconx->chans[i] == ocnum) {
1644 for (
int j = totcons; j < totcons + cconx->nconns[i]; j++) {
1645 if (!*st1) st2 =
lives_strdup_printf(
"%d %d %d", cconx->ikey[j] + 1, cconx->imode[j] + 1, cconx->icnum[j]);
1647 st2 =
lives_strdup_printf(
"%s %d %d %d", st1, cconx->ikey[j] + 1, cconx->imode[j] + 1, cconx->icnum[j]);
1653 totcons += cconx->nconns[i];
1657 cconx = cconx->next;
1663 void cconx_delete(
int okey,
int omode,
int ocnum,
int ikey,
int imode,
int icnum) {
1664 lives_cconnect_t *cconx =
mainw->
cconx, *cconx_next, *cconx_prev = NULL;
1666 register int i, j = 0, k;
1668 int totcons = 0, maxcons = 0;
1671 cconx_next = cconx->next;
1672 if (okey ==
FX_DATA_WILDCARD || (cconx->okey == okey && cconx->omode == omode)) {
1678 else cconx_prev->next = cconx_next;
1686 for (i = 0; i < cconx->nchans; i++) {
1687 maxcons += cconx->nconns[i];
1690 for (i = 0; cconx && i < cconx->nchans; i++) {
1691 totcons += cconx->nconns[i];
1698 for (; j < totcons; j++) {
1699 if (cconx->ikey[j] == ikey && cconx->imode[j] == imode && (icnum ==
FX_DATA_WILDCARD || cconx->icnum[j] == icnum)) {
1701 for (k = j; k < maxcons; k++) {
1702 cconx->ikey[k] = cconx->ikey[k + 1];
1703 cconx->imode[k] = cconx->imode[k + 1];
1704 cconx->icnum[k] = cconx->icnum[k + 1];
1713 if (cconx->nconns[i] == 0) {
1715 for (k = i; k < cconx->nchans; k++) {
1716 cconx->chans[k] = cconx->chans[k + 1];
1717 cconx->nconns[k] = cconx->nconns[k + 1];
1720 if (cconx->nchans == 0) {
1729 cconx->next = cconx_next;
1747 register int i, j, totcons;
1750 if (cconx->okey == key && cconx->omode == omode) {
1751 cconx->omode = nmode;
1755 for (i = 0; i < cconx->nchans; i++) {
1756 totcons += cconx->nconns[i];
1757 for (; j < totcons; j++) {
1758 if (cconx->ikey[j] == key && cconx->imode[j] == omode) {
1759 cconx->imode[j] = nmode;
1763 cconx = cconx->next;
1768 static void cconx_append(lives_cconnect_t *cconx) {
1770 lives_cconnect_t *last_cconx = occonx;
1773 last_cconx = occonx;
1774 occonx = occonx->next;
1777 if (last_cconx) last_cconx->next = cconx;
1782 static lives_cconnect_t *cconx_find(
int okey,
int omode) {
1785 if (cconx->okey == okey && cconx->omode == omode) {
1788 cconx = cconx->next;
1794 static int cconx_get_numcons(
lives_conx_w * conxwp,
int cnum) {
1802 for (j = 0; j < conxwp->
num_alpha; j++) {
1803 totcons += conxwp->
dispc[j];
1810 static int cconx_get_nconns(lives_cconnect_t *cconx,
int cnum) {
1815 if (!cconx)
return 0;
1817 for (j = 0; j < cconx->nchans; j++) {
1819 if (cconx->chans[j] == cnum)
return cconx->nconns[j];
1820 }
else totcons += cconx->nconns[j];
1826 static lives_cconnect_t *cconx_add_connection_private(
int okey,
int omode,
int ocnum,
int ikey,
int imode,
int icnum) {
1827 lives_cconnect_t *cconx;
1828 int posn = 0, totcons = 0, i, j;
1832 cconx = cconx_find(okey, omode);
1836 cconx = cconx_new(okey, omode);
1837 cconx_append(cconx);
1841 for (i = 0; i < cconx->nchans; i++) {
1843 if (cconx->chans[i] == ocnum) {
1846 for (j = 0; j < cconx->nchans; j++) {
1849 posn += cconx->nconns[j];
1851 totcons += cconx->nconns[j];
1855 for (j = posn; j < posn + cconx->nconns[i]; j++) {
1856 if (cconx->ikey[j] == ikey && cconx->imode[j] == imode && cconx->icnum[j] == icnum) {
1861 if (cconx->ikey[j] > ikey || (cconx->ikey[j] == ikey && cconx->imode[j] > imode) ||
1862 (cconx->ikey[j] == ikey && cconx->imode[j] == imode && cconx->icnum[j] > icnum))
break;
1875 for (j = totcons - 1; j > posn; j--) {
1876 cconx->ikey[j] = cconx->ikey[j - 1];
1877 cconx->imode[j] = cconx->imode[j - 1];
1878 cconx->icnum[j] = cconx->icnum[j - 1];
1882 cconx->ikey[posn] = ikey;
1883 cconx->imode[posn] = imode;
1884 cconx->icnum[posn] = icnum;
1892 for (i = 0; i < cconx->nchans; i++) {
1893 totcons += cconx->nconns[i];
1899 posn = cconx->nchans;
1909 cconx->chans[posn - 1] = ocnum;
1911 cconx->nconns[posn - 1] = 1;
1916 cconx->ikey[posn] = ikey;
1917 cconx->imode[posn] = imode;
1918 cconx->icnum[posn] = icnum;
1921 g_print(
"added another cconx from %d %d %d to %d %d %d\n", okey, omode, ocnum, ikey, imode, icnum);
1933 cconx->nconns[cconx->nchans - 1] = 1;
1936 cconx->chans[cconx->nchans - 1] = ocnum;
1939 cconx->ikey[totcons - 1] = ikey;
1942 cconx->imode[totcons - 1] = imode;
1945 cconx->icnum[totcons - 1] = icnum;
1948 g_print(
"added new cconx from %d %d %d to %d %d %d\n", okey, omode, ocnum, ikey, imode, icnum);
1955 cconx_add_connection_private(okey, omode, ocnum, ikey, imode, icnum);
1959 static weed_plant_t *cconx_get_out_alpha(
boolean use_filt,
int ikey,
int imode,
int icnum,
int *okey,
int *omode,
int *ocnum) {
1964 weed_plant_t *inst = NULL, *filter = NULL, *orig_inst = NULL;
1975 cconx = cconx->next;
1983 cconx = cconx->next;
1987 if (!weed_plant_has_leaf(filter, WEED_LEAF_OUT_CHANNEL_TEMPLATES)) {
1989 cconx = cconx->next;
1995 for (i = 0; i < cconx->nchans; i++) {
1996 totcons += cconx->nconns[i];
1997 for (; j < totcons; j++) {
1998 if (cconx->ikey[j] == ikey && cconx->imode[j] == imode && cconx->icnum[j] == icnum) {
1999 weed_plant_t **outchans;
2000 weed_plant_t *channel = NULL;
2002 outchans = weed_get_plantptr_array(filter, WEED_LEAF_OUT_CHANNEL_TEMPLATES, NULL);
2003 if (cconx->chans[i] < weed_leaf_num_elements(filter, WEED_LEAF_OUT_CHANNEL_TEMPLATES)) {
2004 channel = outchans[cconx->chans[i]];
2009 outchans = weed_get_plantptr_array(inst, WEED_LEAF_OUT_CHANNELS, NULL);
2010 if (cconx->chans[i] < weed_leaf_num_elements(inst, WEED_LEAF_OUT_CHANNELS)) {
2011 channel = outchans[cconx->chans[i]];
2015 if (okey) *okey = cconx->okey;
2016 if (omode) *omode = cconx->omode;
2017 if (ocnum) *ocnum = cconx->chans[i];
2023 cconx = cconx->next;
2038 int iwidth, iheight, ipal, irow;
2039 int owidth, oheight, opal, orow, oflags;
2040 boolean pal_ok, needs_reinit =
FALSE;
2042 weed_plant_t *dtmpl = weed_get_plantptr_value(dchan, WEED_LEAF_TEMPLATE, NULL);
2044 uint8_t *spdata, *dpdata;
2048 ipal = weed_get_int_value(schan, WEED_LEAF_CURRENT_PALETTE, NULL);
2051 iwidth = weed_get_int_value(schan, WEED_LEAF_WIDTH, NULL);
2052 iheight = weed_get_int_value(schan, WEED_LEAF_HEIGHT, NULL);
2053 irow = weed_get_int_value(schan, WEED_LEAF_ROWSTRIDES, NULL);
2055 owidth = weed_get_int_value(dchan, WEED_LEAF_WIDTH, NULL);
2056 oheight = weed_get_int_value(dchan, WEED_LEAF_HEIGHT, NULL);
2057 opal = weed_get_int_value(dchan, WEED_LEAF_CURRENT_PALETTE, NULL);
2058 orow = weed_get_int_value(dchan, WEED_LEAF_ROWSTRIDES, NULL);
2060 spdata = (uint8_t *)weed_get_voidptr_value(schan, WEED_LEAF_PIXEL_DATA, NULL);
2063 g_print(
"spd is %p %d %d %d %d %d %d %d %d\n", spdata, ipal, opal, iwidth, owidth, iheight, oheight, irow, orow);
2064 if (spdata) g_print(
"spd2 is %p %d\n", spdata, spdata[0]);
2066 if (ipal == opal && iwidth == owidth && iheight == oheight && irow == orow) {
2068 weed_set_voidptr_value(dchan, WEED_LEAF_PIXEL_DATA, spdata);
2075 if (ipal == opal) pal_ok =
TRUE;
2078 int num_palettes = weed_leaf_num_elements(dtmpl, WEED_LEAF_PALETTE_LIST);
2079 int *palettes = weed_get_int_array(dtmpl, WEED_LEAF_PALETTE_LIST, NULL);
2081 else pal_ok =
FALSE;
2082 oflags = weed_get_int_value(dtmpl, WEED_LEAF_FLAGS, NULL);
2083 if (ipal != opal && (oflags & WEED_CHANNEL_REINIT_ON_PALETTE_CHANGE)) needs_reinit =
TRUE;
2089 weed_set_int_value(dchan, WEED_LEAF_WIDTH, iwidth);
2090 weed_set_int_value(dchan, WEED_LEAF_HEIGHT, iheight);
2091 weed_set_int_value(dchan, WEED_LEAF_CURRENT_PALETTE, ipal);
2094 weed_set_voidptr_value(dchan, WEED_LEAF_PIXEL_DATA, (
void *)spdata);
2095 weed_set_int_value(dchan, WEED_LEAF_ROWSTRIDES, irow);
2100 if (spdata) g_print(
"spd3 is %p %d\n", spdata, spdata[0]);
2106 dpdata = (uint8_t *)weed_get_voidptr_value(dchan, WEED_LEAF_PIXEL_DATA, NULL);
2108 orow = weed_get_int_value(dchan, WEED_LEAF_ROWSTRIDES, NULL);
2111 lives_memcpy((
void *)dpdata, (
void *)spdata, irow * iheight);
2114 for (i = 0; i < iheight; i++) {
2123 if (needs_reinit)
return TRUE;
2132 weed_plant_t *ichan, *ochan;
2133 weed_plant_t *inst = NULL;
2135 boolean needs_reinit =
FALSE;
2155 if ((ochan = cconx_get_out_alpha(
FALSE, key, mode, i++, NULL, NULL, NULL))) {
2162 return needs_reinit;
2168 boolean needs_reinit =
FALSE;
2174 return needs_reinit;
2179 weed_plant_t *filter;
2182 int nparams, niparams;
2183 int ikey, imode, i, j;
2189 for (i = 0; i < nparams; i++) {
2192 array = lives_strsplit(chlist,
" ", niparams * 4);
2193 for (j = 0; j < niparams; j += 4) {
2194 ikey = atoi(array[j]);
2195 imode = atoi(array[j + 1]);
2199 lives_strfreev(array);
2204 lives_strfreev(array);
2208 for (i = 0; i < nparams; i++) {
2211 array = lives_strsplit(chlist,
" ", niparams * 3);
2212 for (j = 0; j < niparams; j += 3) {
2213 ikey = atoi(array[j]);
2214 imode = atoi(array[j + 1]);
2216 lives_strfreev(array);
2220 lives_strfreev(array);
2229 weed_plant_t *filter;
2232 int nparams, niparams;
2240 for (i = 0; i < nparams; i++) {
2243 array = lives_strsplit(chlist,
" ", niparams * 4);
2244 for (j = 0; j < niparams; j += 4) {
2245 ikey = atoi(array[j]);
2246 if (ikey < 0)
continue;
2247 imode = atoi(array[j + 1]);
2251 lives_strfreev(array);
2256 lives_strfreev(array);
2260 for (i = 0; i < nparams; i++) {
2263 array = lives_strsplit(chlist,
" ", niparams * 3);
2264 for (j = 0; j < niparams; j += 3) {
2265 ikey = atoi(array[j]);
2266 if (ikey < 0)
continue;
2267 imode = atoi(array[j + 1]);
2271 lives_strfreev(array);
2276 lives_strfreev(array);
2297 static void disconbutton_clicked(LiVESButton * button, livespointer user_data) {
2301 int totparams, totchans;
2302 int pidx, pidx_last, cidx, cidx_last;
2309 for (i = 0; i < totchans; i++) {
2314 cidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
ccombo[i]),
"cidx"));
2315 cidx_last = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
ccombo[i - 1]),
"cidx"));
2320 for (i = 0; i < totparams; i++) {
2325 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[i]),
"pidx"));
2326 pidx_last = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[i - 1]),
"pidx"));
2333 static void apbutton_clicked(LiVESButton * button, livespointer user_data) {
2340 LiVESTreeModel *model;
2341 LiVESTreePath *tpath;
2343 weed_plant_t **iparams, **oparams;
2344 weed_plant_t *filter, *param, *oparam;
2346 int fidx, key, mode, totchans;
2347 int niparams, ours, addn, stparam;
2353 ours = pconx_get_numcons(conxwp, -
EXTRA_PARAMS_OUT) + pconx_get_numcons(conxwp, 0) - 1;
2355 combo = (LiVESWidget *)conxwp->
pfxcombo[ours];
2371 if (fidx == -1)
return;
2379 iparams = weed_get_plantptr_array(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES, NULL);
2380 niparams = weed_leaf_num_elements(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES);
2382 #ifdef COMBO_LIST_LIMIT
2389 WEED_LEAF_OUT_PARAMETER_TEMPLATES, NULL);
2394 stparam = conxwp->
idx[totchans + ours];
2396 if (conxwp->
ikeys[totchans + ours] < 0) {
2398 ours -= pconx_get_numcons(conxwp, 0);
2403 for (i = stparam; i < niparams; i++) {
2409 if (pconx_get_out_param(
TRUE, key - 1, mode, i, NULL, NULL, NULL, NULL))
continue;
2411 oparam = oparams[k];
2413 if (!params_compatible(oparam, param))
continue;
2415 addn = pconx_get_numcons(conxwp, k);
2419 combo = conxwp->
pcombo[ours];
2421 if (conxwp->
ikeys[ours + totchans] >= 0) {
2423 padd_clicked(conxwp->
add_button[ours + totchans], (livespointer)conxwp);
2445 static void acbutton_clicked(LiVESButton * button, livespointer user_data) {
2452 LiVESTreeModel *model;
2453 LiVESTreePath *tpath;
2455 weed_plant_t **ichans, **ochans;
2456 weed_plant_t *filter, *chan, *ochan;
2458 int fidx, key, mode;
2459 int nichans, nochans, ours, addn, stchan;
2461 int i, j = 0, k = 1;
2465 ours = cconx_get_numcons(conxwp, 0) - 1;
2467 combo = (LiVESWidget *)conxwp->
cfxcombo[ours];
2475 if (fidx == -1)
return;
2483 ichans = weed_get_plantptr_array(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES, NULL);
2484 nichans = weed_leaf_num_elements(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES);
2487 WEED_LEAF_OUT_CHANNEL_TEMPLATES, NULL);
2489 WEED_LEAF_OUT_CHANNEL_TEMPLATES);
2492 stchan = conxwp->
idx[ours];
2494 if (conxwp->
ikeys[ours] < 0) {
2496 ours -= cconx_get_numcons(conxwp, 0);
2501 for (i = 0; i < nichans; i++) {
2505 if (i == conxwp->
idx[ours])
break;
2510 for (i = stchan; i < nichans; i++) {
2516 if (cconx_get_out_alpha(
TRUE, key - 1, mode, i, NULL, NULL, NULL))
continue;
2521 if (++k >= nochans)
break;
2525 addn = cconx_get_numcons(conxwp, k);
2529 combo = conxwp->
ccombo[ours];
2531 if (conxwp->
ikeys[ours] >= 0) {
2533 cadd_clicked(conxwp->
add_button[ours], (livespointer)conxwp);
2545 if (++k >= nochans)
break;
2555 static void padd_clicked(LiVESWidget * button, livespointer user_data) {
2559 int totparams, totchans;
2560 int ours = -1, pidx;
2561 #if LIVES_TABLE_IS_GRID
2564 LiVESWidget *hbox[5], *hboxb[5], *achbox, *comhbox;
2572 for (i = 0; i < totparams; i++) {
2573 if (conxwp->
add_button[i + totchans] == button) {
2579 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[ours]),
"pidx"));
2603 for (i = conxwp->
trowsp - 3; i > ours; i--) {
2609 #if !LIVES_TABLE_IS_GRID
2614 for (i = 0; i < 5; i++) {
2618 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
2619 (LiVESAttachOptions)(0), 0, 0);
2623 ptable_row_add_standard_widgets(conxwp, totparams - 1);
2627 conxwp->
trowsp = ours + 3;
2628 ptable_row_add_standard_widgets(conxwp, ours + 1);
2633 for (i = conxwp->
trowsp - 3; i > ours; i--) {
2634 #if !LIVES_TABLE_IS_GRID
2669 conxwp->
idx[i + 1] = conxwp->
idx[i];
2674 ptable_row_add_variable_widgets(conxwp, ours + 1, ours + 2, pidx);
2676 conxwp->
ikeys[ours + 1] = conxwp->
imodes[ours + 1] = conxwp->
idx[i + 1] = 0;
2687 static void pdel_clicked(LiVESWidget * button, livespointer user_data) {
2691 int totparams, totchans;
2692 int ours = -1, pidx;
2694 #if !LIVES_TABLE_IS_GRID
2695 LiVESWidget *comhbox;
2696 LiVESWidget *hbox[4], *hboxb[4], *achbox;
2702 #if !LIVES_TABLE_IS_GRID
2709 for (i = 0; i < totparams; i++) {
2710 if (conxwp->
del_button[i + totchans] == button) {
2716 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[ours]),
"pidx"));
2739 #if !LIVES_TABLE_IS_GRID
2754 for (i = ours; i < conxwp->
trowsp - 1; i++) {
2755 #if !LIVES_TABLE_IS_GRID
2762 pidx_next = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[i + 1]),
"pidx"));
2763 if (pidx_next != pidx) {
2767 conxwp->
pclabel[totchans + i] = conxwp->
pclabel[totchans + i + 1];
2774 conxwp->
pclabel[totchans + i] = conxwp->
pclabel[totchans + i + 1];
2823 conxwp->
idx[i] = conxwp->
idx[i + 1];
2828 #if !LIVES_TABLE_IS_GRID
2864 static void cadd_clicked(LiVESWidget * button, livespointer user_data) {
2868 #if LIVES_TABLE_IS_GRID
2871 LiVESWidget *hbox[4], *hboxb[4], *comhbox;
2874 int totparams, totchans;
2875 int ours = -1, cidx;
2882 for (i = 0; i < totchans; i++) {
2889 cidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
cfxcombo[ours]),
"cidx"));
2891 conxwp->
dispc[cidx]++;
2912 for (i = conxwp->
trowsc - 3; i > ours; i--) {
2918 #if !LIVES_TABLE_IS_GRID
2923 for (i = 0; i < 4; i++) {
2927 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
2928 (LiVESAttachOptions)(0), 0, 0);
2931 ctable_row_add_standard_widgets(conxwp, totchans - 1);
2935 conxwp->
trowsc = ours + 3;
2936 ctable_row_add_standard_widgets(conxwp, ours + 1);
2941 for (i = conxwp->
trowsc - 3; i > ours; i--) {
2942 #if !LIVES_TABLE_IS_GRID
2967 conxwp->
idx[i + 1] = conxwp->
idx[i];
2972 ctable_row_add_variable_widgets(conxwp, ours + 1, ours + 2, cidx);
2974 conxwp->
ikeys[ours + 1] = -1;
2975 conxwp->
imodes[ours + 1] = conxwp->
idx[i + 1] = 0;
2977 conxwp->
dispc[cidx]++;
2986 static void cdel_clicked(LiVESWidget * button, livespointer user_data) {
2990 int totparams, totchans;
2991 int ours = -1, cidx;
2993 #if !LIVES_TABLE_IS_GRID
2994 LiVESWidget *hbox[3], *comhbox;
2995 LiVESWidget *hboxb[3];
3004 for (i = 0; i < totchans; i++) {
3011 cidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
ccombo[ours]),
"cidx"));
3015 if (conxwp->
dispc[cidx] <= 1) {
3024 conxwp->
dispc[cidx]--;
3028 #if !LIVES_TABLE_IS_GRID
3043 for (i = ours; i < conxwp->
trowsc - 1; i++) {
3044 #if !LIVES_TABLE_IS_GRID
3051 cidx_next = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
ccombo[i + 1]),
"cidx"));
3052 if (cidx_next != cidx) {
3097 conxwp->
idx[i] = conxwp->
idx[i + 1];
3102 #if !LIVES_TABLE_IS_GRID
3117 if (ours == totchans) {
3139 static void dfxc_changed(LiVESWidget * combo, livespointer user_data) {
3143 LiVESTreeModel *model;
3145 weed_plant_t **ichans;
3146 weed_plant_t *filter, *chan;
3148 LiVESList *clist = NULL;
3152 int fidx, cidx, key, mode;
3153 int nichans, nchans, ours = -1;
3165 for (i = 0; i < nchans; i++) {
3172 cidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(combo),
"cidx"));
3179 if (conxw->
acbutton && cconx_get_nconns(conxw->
cconx, 0) == 0 && cidx == 0)
3188 ichans = weed_get_plantptr_array(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES, NULL);
3189 nichans = weed_leaf_num_elements(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES);
3192 for (i = 0; i < nichans; i++) {
3197 channame = get_chan_name(chan, i,
TRUE);
3198 clist = lives_list_append(clist, channame);
3215 static void dfxp_changed(LiVESWidget * combo, livespointer user_data) {
3221 LiVESTreeModel *model;
3223 weed_plant_t **iparams = NULL;
3224 weed_plant_t *filter, *param;
3226 LiVESList *plist = NULL;
3230 char *ptype, *range;
3231 char *array_type, *text;
3233 int defelems, pflags, stype;
3234 int fidx, key, mode, pidx;
3235 int niparams = 0, nparams;
3236 int ours = -1, i, j = 0;
3244 for (i = 0; i < nparams; i++) {
3245 if (conxwp->
pfxcombo[i] == combo) {
3257 int nmatchparams = 0;
3258 weed_plant_t *ofilter;
3259 LiVESWidget *fxcombo = conxwp->
pcombo[ours];
3262 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(fxcombo),
"pidx"));
3263 ofilter = conxwp->
filter;
3266 weed_plant_t **oparams = weed_get_plantptr_array(ofilter, WEED_LEAF_OUT_PARAMETER_TEMPLATES, NULL);
3267 weed_plant_t *oparam = oparams[pidx];
3269 stype = weed_leaf_seed_type(oparam, WEED_LEAF_DEFAULT);
3272 stype = WEED_SEED_BOOLEAN;
3283 if (nmatchparams == 0 && stype == WEED_SEED_BOOLEAN) {
3285 plist = lives_list_append(plist, text);
3290 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(combo),
"pidx"));
3294 LiVESWidget *acheck = conxwp->
acheck[ours];
3307 if (conxwp->
apbutton && pconx_get_nconns(conxwp->
pconx, 0) == 0 && pidx == 0)
3318 if (weed_plant_has_leaf(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES)) {
3319 iparams = weed_get_plantptr_array(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES, NULL);
3320 niparams = weed_leaf_num_elements(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES);
3321 #ifdef COMBO_LIST_LIMIT
3334 param = iparams[j++];
3338 if (weed_plant_has_leaf(param, WEED_LEAF_GROUP) && weed_get_int_value(param, WEED_LEAF_GROUP, NULL) != 0)
continue;
3340 paramname = get_param_name(param, j - 1,
TRUE);
3344 pflags = weed_get_int_value(param, WEED_LEAF_FLAGS, NULL);
3346 if (pflags & WEED_PARAMETER_VARIABLE_SIZE) array_type = lives_strdup(
"[]");
3347 else if ((defelems = weed_leaf_num_elements(param, WEED_LEAF_DEFAULT)) > 1)
3349 else array_type = lives_strdup(
"");
3351 if (weed_plant_has_leaf(param, WEED_LEAF_MAX) && weed_plant_has_leaf(param, WEED_LEAF_MIN)) {
3352 if (stype == WEED_SEED_INT) {
3354 weed_get_int_value(param, WEED_LEAF_MIN, NULL), weed_get_int_value(param,
3355 WEED_LEAF_MAX, NULL));
3356 }
else if (stype == WEED_SEED_DOUBLE) {
3358 weed_get_double_value(param, WEED_LEAF_MIN, NULL), weed_get_double_value(param,
3359 WEED_LEAF_MAX, NULL));
3360 }
else range = lives_strdup(
"");
3361 }
else range = lives_strdup(
"");
3369 plist = lives_list_append(plist, text);
3391 weed_plant_t **iparam_ret,
int *idx_ret,
int *okey,
int *omode,
int *oopnum) {
3392 weed_plant_t **oparams = NULL, **iparams;
3393 weed_plant_t *oparam, *iparam = NULL;
3395 int niparams, idx, i, j = 0;
3400 oparams = weed_get_plantptr_array(ofilter, WEED_LEAF_OUT_PARAMETER_TEMPLATES, NULL);
3401 oparam = oparams[opnum];
3407 weed_plant_free(active_dummy);
3408 active_dummy = NULL;
3410 if (!active_dummy) {
3411 active_dummy = weed_plant_new(WEED_PLANT_PARAMETER_TEMPLATE);
3412 weed_set_boolean_value(active_dummy, WEED_LEAF_DEFAULT, WEED_FALSE);
3414 oparam = active_dummy;
3422 weed_plant_free(active_dummy);
3423 active_dummy = NULL;
3425 if (!active_dummy) {
3426 active_dummy = weed_plant_new(WEED_PLANT_PARAMETER_TEMPLATE);
3427 weed_set_boolean_value(active_dummy, WEED_LEAF_DEFAULT, WEED_FALSE);
3430 iparam = active_dummy;
3437 iparams = weed_get_plantptr_array(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES, NULL);
3438 niparams = weed_leaf_num_elements(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES);
3440 for (i = 0; i < niparams; i++) {
3441 iparam = iparams[i];
3443 if (weed_plant_has_leaf(iparam, WEED_LEAF_GROUP) && weed_get_int_value(iparam, WEED_LEAF_GROUP, NULL) != 0)
continue;
3444 if (j == ipnum)
break;
3451 if (iparam_ret) *iparam_ret = iparam;
3452 if (idx_ret) *idx_ret = idx;
3455 if (pconx_get_out_param(
TRUE, ikey, imode, ipnum, okey, omode, oopnum, NULL)) {
3461 if (!params_compatible(oparam, iparam)) {
3469 static void dpp_changed(LiVESWidget * combo, livespointer user_data) {
3477 weed_plant_t *iparam;
3481 LiVESWidget *acheck = NULL;
3482 LiVESWidget *fxcombo;
3484 LiVESTreeModel *model;
3490 boolean hasone =
FALSE;
3491 boolean setup = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(combo),
"setup"));
3493 int nparams, nchans;
3494 int okey, omode, opnum, ikey;
3496 int pidx, key, mode, ours = -1, ret;
3503 for (i = 0; i < nparams; i++) {
3504 if (conxwp->
pcombo[i] == combo) {
3510 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(combo),
"pidx"));
3515 for (i = 0; i < nchans; i++) {
3522 for (i = 0; i < nparams; i++) {
3523 if (LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[i]),
"idx")) > -1) {
3532 ikey = conxwp->
ikeys[nchans + ours];
3537 conxwp->
idx[nchans + ours]);
3541 conxwp->
ikeys[nchans + ours] = -1;
3542 conxwp->
imodes[nchans + ours] = 0;
3543 conxwp->
idx[nchans + ours] = 0;
3548 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(combo),
"idx", LIVES_INT_TO_POINTER(idx));
3564 ret =
pconx_check_connection(conxwp->
filter, pidx, key, mode, idx, setup, &iparam, &j, &okey, &omode, &opnum);
3567 do_param_incompatible_error(conxwp);
3572 if (!do_param_connected_query(conxwp, okey, omode, opnum, conxwp->
okey == okey)) {
3584 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(combo),
"idx", LIVES_INT_TO_POINTER(idx));
3586 acheck = conxwp->
acheck[ours];
3589 boolean hasrange = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(acheck),
"available"));
3605 if (iparam == active_dummy) {
3607 else paramname = (
_(
"ACTIVATE"));
3622 conxwp->
pconx = pconx_add_connection_private(conxwp->
okey, conxwp->
omode, pidx, key - 1, mode, j,
3625 conxwp->
ikeys[nchans + ours] = key;
3626 conxwp->
imodes[nchans + ours] = mode;
3627 conxwp->
idx[nchans + ours] = j;
3634 int *okey,
int *omode,
int *ocnum) {
3635 weed_plant_t **ichans;
3636 weed_plant_t *filter, *ichan = NULL;
3638 int fidx, idx, nichans, i, j = 0;
3645 ichans = weed_get_plantptr_array(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES, NULL);
3646 nichans = weed_leaf_num_elements(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES);
3649 for (i = 0; i < nichans; i++) {
3652 if (j == icnum)
break;
3660 if (ichan_ret) *ichan_ret = ichan;
3661 if (idx_ret) *idx_ret = idx;
3664 if (cconx_get_out_alpha(
TRUE, ikey, imode, i, okey, omode, ocnum)) {
3673 static void dpc_changed(LiVESWidget * combo, livespointer user_data) {
3675 weed_plant_t *ichan;
3676 LiVESTreeModel *model;
3678 LiVESWidget *fxcombo;
3682 boolean hasone =
FALSE;
3683 boolean setup = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(combo),
"setup"));
3685 int nchans, nparams;
3686 int key, mode, cidx, ours = -1, ret, j;
3687 int okey, omode, ocnum;
3694 for (i = 0; i < nchans; i++) {
3695 if (conxwp->
ccombo[i] == combo) {
3701 cidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(combo),
"cidx"));
3704 for (i = 0; i < nchans; i++) {
3710 if (!hasone)
for (i = 0; i < nparams; i++) {
3711 if (LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[i]),
"idx")) > -1) {
3723 conxwp->
ikeys[ours] = -1;
3724 conxwp->
imodes[ours] = 0;
3725 conxwp->
idx[ours] = 0;
3744 if (!do_chan_connected_query(conxwp, okey, omode, ocnum, conxwp->
okey == okey)) {
3753 channame = get_chan_name(ichan, idx,
TRUE);
3759 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(combo),
"idx", LIVES_INT_TO_POINTER(idx));
3765 conxwp->
cconx = cconx_add_connection_private(conxwp->
okey, conxwp->
omode, cidx, key - 1, mode, j);
3767 conxwp->
ikeys[ours] = key;
3768 conxwp->
imodes[ours] = mode;
3769 conxwp->
idx[ours] = j;
3775 static void on_allcheck_toggled(LiVESToggleButton * button, livespointer user_data) {
3789 static void on_acheck_toggled(LiVESToggleButton * acheck, livespointer user_data) {
3791 weed_plant_t **iparams;
3792 weed_plant_t *param, *filter;
3793 LiVESTreeModel *model;
3795 LiVESWidget *fxcombo;
3798 int ours = -1, fidx, key, mode, niparams, nparams, nchans, nx = 0;
3799 int idx, pidx, i, j = 0;
3806 for (i = nx; i < nparams; i++) {
3807 if (conxwp->
acheck[i] == (LiVESWidget *)acheck) {
3813 idx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[ours]),
"idx"));
3822 if (key < 0)
return;
3836 iparams = weed_get_plantptr_array(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES, NULL);
3837 niparams = weed_leaf_num_elements(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES);
3839 #ifdef COMBO_LIST_LIMIT
3845 for (i = 0; i < niparams; i++) {
3848 if (j == idx)
break;
3858 pidx = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(acheck),
"pidx"));
3859 conxwp->
pconx = pconx_add_connection_private(conxwp->
okey, conxwp->
omode, pidx, key - 1, mode, j, on);
3861 conxwp->
ikeys[nchans + ours] = key;
3862 conxwp->
imodes[nchans + ours] = mode;
3863 conxwp->
idx[nchans + ours] = j;
3867 static LiVESTreeModel *inparam_fx_model(
boolean is_chans,
int key) {
3868 LiVESTreeStore *tstore;
3869 LiVESTreeIter iter1, iter2;
3870 weed_plant_t *filter;
3871 char *fxname, *keystr, *text;
3876 LIVES_COL_TYPE_INT);
3886 keystr = (
_(
"OMC Macros"));
3888 lives_tree_store_set(tstore, &iter1,
KEY_COLUMN, keystr,
NAME_COLUMN, keystr,
KEYVAL_COLUMN, 0,
MODEVAL_COLUMN, 0, -1);
3903 if (i == key + 1)
continue;
3908 for (j = 0; j < nmodes; j++) {
3916 fxname = weed_get_string_value(filter, WEED_LEAF_NAME, NULL);
3922 lives_tree_store_set(tstore, &iter1,
KEY_COLUMN, keystr,
NAME_COLUMN, keystr,
KEYVAL_COLUMN, 0,
MODEVAL_COLUMN, 0, -1);
3926 lives_tree_store_set(tstore, &iter2,
KEY_COLUMN, text,
NAME_COLUMN, text,
KEYVAL_COLUMN, i,
MODEVAL_COLUMN, j, -1);
3935 return (LiVESTreeModel *)tstore;
3939 static void ptable_row_add_variable_widgets(
lives_conx_w * conxwp,
int idx,
int row,
int pidx) {
3940 weed_plant_t **oparams, *param;
3942 LiVESWidget *hbox, *hbox2;
3943 LiVESWidget *fx_entry;
3945 boolean hasrange =
FALSE;
3947 int stype, totchans;
3954 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
3955 (LiVESAttachOptions)(0), 0, 0);
3967 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
3968 (LiVESAttachOptions)(0), 0, 0);
3982 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[idx]),
"idx", LIVES_INT_TO_POINTER(-1));
3986 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
3987 (LiVESAttachOptions)(0), 0, 0);
3989 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
pfxcombo[idx]), LIVES_WIDGET_CHANGED_SIGNAL,
3990 LIVES_GUI_CALLBACK(dfxp_changed), (livespointer)conxwp);
3992 conxwp->
dpp_func[idx] = lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
pcombo[idx]), LIVES_WIDGET_CHANGED_SIGNAL,
3993 LIVES_GUI_CALLBACK(dpp_changed), (livespointer)conxwp);
3995 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(conxwp->
pcombo[idx]),
"pidx", LIVES_INT_TO_POINTER(pidx));
3998 conxwp->
acheck[idx] = NULL;
4000 if (weed_plant_has_leaf(conxwp->
filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES)) {
4001 oparams = weed_get_plantptr_array(conxwp->
filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES, NULL);
4003 param = oparams[pidx];
4004 stype = weed_leaf_seed_type(param, WEED_LEAF_DEFAULT);
4006 if (weed_plant_has_leaf(param, WEED_LEAF_MAX) && weed_plant_has_leaf(param, WEED_LEAF_MIN) && (stype == WEED_SEED_INT ||
4007 stype == WEED_SEED_DOUBLE))
4016 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
4017 (LiVESAttachOptions)(0), 0, 0);
4025 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(conxwp->
acheck[idx]),
"available", LIVES_INT_TO_POINTER(hasrange));
4027 conxwp->
acheck_func[idx] = lives_signal_sync_connect_after(LIVES_GUI_OBJECT(conxwp->
acheck[idx]), LIVES_WIDGET_TOGGLED_SIGNAL,
4028 LIVES_GUI_CALLBACK(on_acheck_toggled), (livespointer)conxwp);
4030 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(conxwp->
acheck[idx]),
"pidx", LIVES_INT_TO_POINTER(pidx));
4035 static void ctable_row_add_variable_widgets(
lives_conx_w * conxwp,
int idx,
int row,
int cidx) {
4036 LiVESWidget *hbox, *hbox2;
4037 LiVESWidget *fx_entry;
4042 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
4043 (LiVESAttachOptions)(0), 0, 0);
4055 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
4056 (LiVESAttachOptions)(0), 0, 0);
4070 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(conxwp->
ccombo[idx]),
"idx", LIVES_INT_TO_POINTER(-1));
4074 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
4075 (LiVESAttachOptions)(0), 0, 0);
4077 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
cfxcombo[idx]), LIVES_WIDGET_CHANGED_SIGNAL,
4078 LIVES_GUI_CALLBACK(dfxc_changed), (livespointer)conxwp);
4080 conxwp->
dpc_func[idx] = lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
ccombo[idx]), LIVES_WIDGET_CHANGED_SIGNAL,
4081 LIVES_GUI_CALLBACK(dpc_changed), (livespointer)conxwp);
4083 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(conxwp->
ccombo[idx]),
"cidx", LIVES_INT_TO_POINTER(cidx));
4087 static void ptable_row_add_standard_widgets(
lives_conx_w * conxwp,
int idx) {
4093 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND), (LiVESAttachOptions)(0), 0, 0);
4100 _(
"Add another connection for this output parameter"));
4104 conxwp->
trowsp, (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4106 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
add_button[idx]), LIVES_WIDGET_CLICKED_SIGNAL,
4107 LIVES_GUI_CALLBACK(padd_clicked), (livespointer)conxwp);
4117 (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4119 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
del_button[idx]), LIVES_WIDGET_CLICKED_SIGNAL,
4120 LIVES_GUI_CALLBACK(pdel_clicked), (livespointer)conxwp);
4126 static void ctable_row_add_standard_widgets(
lives_conx_w * conxwp,
int idx) {
4130 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND), (LiVESAttachOptions)(0), 0, 0);
4139 (LiVESAttachOptions)(0), (LiVESAttachOptions)(0), 0, 0);
4141 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
add_button[idx]), LIVES_WIDGET_CLICKED_SIGNAL,
4142 LIVES_GUI_CALLBACK(cadd_clicked), (livespointer)conxwp);
4152 (LiVESAttachOptions)(0),
4153 (LiVESAttachOptions)(0), 0, 0);
4155 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxwp->
del_button[idx]), LIVES_WIDGET_CLICKED_SIGNAL,
4156 LIVES_GUI_CALLBACK(cdel_clicked), (livespointer)conxwp);
4162 static LiVESWidget *conx_scroll_new(
lives_conx_w * conxwp) {
4163 weed_plant_t *chan, *param;
4166 LiVESWidget *top_vbox;
4168 LiVESWidget *scrolledwindow;
4170 char *channame, *pname, *fname;
4171 char *ptype, *range;
4172 char *array_type, *text, *tmp;
4176 int defelems, pflags, stype;
4178 int totchans, totparams, nconns;
4180 register int i, j = 0, x = 0;
4182 for (i = 0; i < conxwp->
num_alpha; i++) {
4183 nconns = cconx_get_nconns(conxwp->
cconx, i);
4184 if (nconns == 0) nconns = 1;
4185 conxwp->
dispc[i] = nconns;
4189 nconns = pconx_get_nconns(conxwp->
pconx, i);
4190 if (nconns == 0) nconns = 1;
4199 conxwp->
clabel = (LiVESWidget **)
lives_malloc((totchans + totparams) *
sizeof(LiVESWidget *));
4200 conxwp->
pclabel = (LiVESWidget **)
lives_malloc((totchans + totparams) *
sizeof(LiVESWidget *));
4209 for (i = 0; i < totchans + totparams; i++) {
4210 conxwp->
ikeys[i] = -1;
4214 lctext = (
_(
"Connected to -->"));
4222 fname = weed_get_string_value(conxwp->
filter, WEED_LEAF_NAME, NULL);
4225 weed_plant_t **ochans = weed_get_plantptr_array(conxwp->
filter, WEED_LEAF_OUT_CHANNEL_TEMPLATES, NULL);
4251 cmodel = inparam_fx_model(
TRUE, conxwp->
okey);
4253 for (i = 0; i < conxwp->
num_alpha; i++) {
4263 nconns = conxwp->
dispc[i];
4268 ctable_row_add_variable_widgets(conxwp, x, conxwp->
trowsc - 1, i);
4269 ctable_row_add_standard_widgets(conxwp, x);
4272 channame = get_chan_name(chan, j - 1,
FALSE);
4286 }
while (--nconns > 0);
4297 weed_plant_t **oparams = NULL;
4299 pmodel = inparam_fx_model(
FALSE, conxwp->
okey);
4301 if (weed_plant_has_leaf(conxwp->
filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES))
4302 oparams = weed_get_plantptr_array(conxwp->
filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES, NULL);
4334 (LiVESAttachOptions)(LIVES_FILL | LIVES_EXPAND),
4335 (LiVESAttachOptions)(0), 0, 0);
4340 lives_signal_sync_connect_after(LIVES_GUI_OBJECT(conxwp->
allcheckc), LIVES_WIDGET_TOGGLED_SIGNAL,
4341 LIVES_GUI_CALLBACK(on_allcheck_toggled),
4342 (livespointer)conxwp);
4347 nconns = conxwp->
dispp[0];
4355 ptable_row_add_standard_widgets(conxwp, x + totchans);
4361 pname = (
_(
"ACTIVATED"));
4380 }
while (--nconns > 0);
4391 ptable_row_add_variable_widgets(conxwp, x, conxwp->
trowsp - 1, i);
4392 ptable_row_add_standard_widgets(conxwp, x + totchans);
4397 pname = get_param_name(param, i,
FALSE);
4401 pflags = weed_get_int_value(param, WEED_LEAF_FLAGS, NULL);
4403 if (pflags & WEED_PARAMETER_VARIABLE_SIZE) array_type = lives_strdup(
"[]");
4404 else if ((defelems = weed_leaf_num_elements(param, WEED_LEAF_DEFAULT)) > 1)
4406 else array_type = lives_strdup(
"");
4408 if (weed_plant_has_leaf(param, WEED_LEAF_MAX) && weed_plant_has_leaf(param, WEED_LEAF_MIN)) {
4409 if (stype == WEED_SEED_INT) {
4410 range =
lives_strdup_printf(
"Range: %d to %d", weed_get_int_value(param, WEED_LEAF_MIN, NULL),
4411 weed_get_int_value(param,
4414 }
else if (stype == WEED_SEED_DOUBLE) {
4415 range =
lives_strdup_printf(
"Range: %f to %f", weed_get_double_value(param, WEED_LEAF_MIN, NULL),
4416 weed_get_double_value(param,
4419 }
else range = lives_strdup(
"");
4420 }
else range = lives_strdup(
"");
4438 }
while (--nconns > 0);
4446 return scrolledwindow;
4450 static void conxw_cancel_clicked(LiVESWidget * button, livespointer user_data) {
4479 if (!button)
return;
4489 static void conxw_ok_clicked(LiVESWidget * button, livespointer user_data) {
4497 conxw_cancel_clicked(NULL, user_data);
4506 static void set_to_keymode_vals(LiVESCombo * combo,
int xkey,
int xmode) {
4507 LiVESTreeIter iter, piter;
4508 LiVESTreeModel *model;
4519 if (key == (key > -0 ? xkey + 1 : key) && mode == xmode)
goto iter_found;
4531 lives_cconnect_t *cconx = conxwp->
cconx;
4532 lives_pconnect_t *pconx = conxwp->
pconx;
4534 LiVESWidget *cfxcombo, *ccombo;
4535 LiVESWidget *pfxcombo, *pcombo;
4536 LiVESWidget *acheck;
4538 weed_plant_t **ochans, **ichans;
4539 weed_plant_t **iparams;
4540 weed_plant_t *ofilter = conxwp->
filter, *filter;
4541 weed_plant_t *chan, *param;
4543 int ikey, imode, icnum, ipnum, nichans, niparams;
4544 int posn = 0, cidx, pidx, totchans = 0;
4547 if (!cconx)
goto show_ex_params;
4551 ochans = weed_get_plantptr_array(ofilter, WEED_LEAF_OUT_CHANNEL_TEMPLATES, NULL);
4553 for (i = 0; i < cconx->nchans; i++) {
4558 for (k = 0; k < i; k++) {
4564 l += cconx_get_numcons(conxwp, k);
4567 cidx = cconx->chans[i];
4568 for (j = posn; j < posn + cconx->nconns[i]; j++) {
4569 ikey = cconx->ikey[j];
4570 imode = cconx->imode[j];
4576 set_to_keymode_vals(LIVES_COMBO(cfxcombo), ikey, imode);
4579 ccombo = conxwp->
ccombo[l];
4580 icnum = cconx->icnum[j];
4583 ichans = weed_get_plantptr_array(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES, NULL);
4584 nichans = weed_leaf_num_elements(filter, WEED_LEAF_IN_CHANNEL_TEMPLATES);
4589 for (k = 0; k < nichans; k++) {
4592 if (k == icnum)
break;
4598 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(ccombo),
"setup", LIVES_INT_TO_POINTER(
TRUE));
4601 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(ccombo),
"idx", LIVES_INT_TO_POINTER(cidx));
4605 conxwp->
ikeys[l] = ikey;
4606 conxwp->
imodes[l] = imode;
4607 conxwp->
idx[l] = icnum;
4609 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(ccombo),
"setup", LIVES_INT_TO_POINTER(
FALSE));
4616 posn += cconx->nconns[i];
4623 if (!pconx)
goto show_ex_done;
4627 for (i = 0; i < pconx->nparams; i++) {
4628 pidx = pconx->params[i];
4635 l += pconx_get_numcons(conxwp, k);
4638 for (j = posn; j < posn + pconx->nconns[i]; j++) {
4639 ikey = pconx->ikey[j];
4640 imode = pconx->imode[j];
4646 set_to_keymode_vals(LIVES_COMBO(pfxcombo), ikey, imode);
4649 pcombo = conxwp->
pcombo[l];
4650 acheck = conxwp->
acheck[l];
4652 if (j == posn + pconx->nconns[i] - 1)
4656 boolean hasrange = LIVES_POINTER_TO_INT(lives_widget_object_get_data(LIVES_WIDGET_OBJECT(acheck),
"available"));
4665 ipnum = pconx->ipnum[j];
4673 iparams = weed_get_plantptr_array(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES, NULL);
4674 niparams = weed_leaf_num_elements(filter, WEED_LEAF_IN_PARAMETER_TEMPLATES);
4676 #ifdef COMBO_LIST_LIMIT
4684 for (k = 0; k < niparams; k++) {
4687 if (k == ipnum)
break;
4694 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(pcombo),
"setup", LIVES_INT_TO_POINTER(
TRUE));
4696 conxwp->
ikeys[totchans + l] = ikey;
4697 conxwp->
imodes[totchans + l] = imode;
4698 conxwp->
idx[totchans + l] = ipnum;
4701 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(pcombo),
"idx", LIVES_INT_TO_POINTER(pidx +
EXTRA_PARAMS_IN));
4705 lives_widget_object_set_data(LIVES_WIDGET_OBJECT(pcombo),
"setup", LIVES_INT_TO_POINTER(
FALSE));
4713 posn += pconx->nconns[i];
4725 LiVESWidget *cbox, *abox;
4726 LiVESWidget *scrolledwindow;
4728 LiVESWidget *cancelbutton;
4729 LiVESWidget *okbutton;
4731 LiVESAccelGroup *accel_group;
4738 if (!conxw.
filter)
return NULL;
4748 conxw.
cconx = cconx_find(key, mode);
4749 conxw.
pconx = pconx_find(key, mode);
4755 conxw.
num_params = weed_leaf_num_elements(conxw.
filter, WEED_LEAF_OUT_PARAMETER_TEMPLATES);
4776 LIVES_RESPONSE_NONE);
4778 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxw.
acbutton), LIVES_WIDGET_CLICKED_SIGNAL,
4779 LIVES_GUI_CALLBACK(acbutton_clicked), (livespointer)&conxw);
4784 LIVES_RESPONSE_NONE);
4786 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxw.
apbutton), LIVES_WIDGET_CLICKED_SIGNAL,
4787 LIVES_GUI_CALLBACK(apbutton_clicked), (livespointer)&conxw);
4791 LIVES_RESPONSE_NONE);
4796 lives_signal_sync_connect(LIVES_GUI_OBJECT(conxw.
disconbutton), LIVES_WIDGET_CLICKED_SIGNAL,
4797 LIVES_GUI_CALLBACK(disconbutton_clicked), (livespointer)&conxw);
4800 if (LIVES_IS_BOX(abox) && (conxw.num_alpha > 0 || conxw.num_params > 0))
add_fill_to_box(LIVES_BOX(abox));
4804 scrolledwindow = conx_scroll_new(&conxw);
4805 show_existing(&conxw);
4810 if (conxw.apbutton && pconx_get_nconns(conxw.pconx, 0) > 0)
4813 if (conxw.num_alpha > 0) {
4814 if (conxw.acbutton && cconx_get_nconns(conxw.cconx, 0) > 0)
4819 LIVES_RESPONSE_CANCEL);
4827 LIVES_KEY_Escape, (LiVESXModifierType)0, (LiVESAccelFlags)0);
4829 lives_signal_sync_connect(LIVES_GUI_OBJECT(cancelbutton), LIVES_WIDGET_CLICKED_SIGNAL,
4830 LIVES_GUI_CALLBACK(conxw_cancel_clicked),
4831 (livespointer)&conxw);
4833 lives_signal_sync_connect(LIVES_GUI_OBJECT(okbutton), LIVES_WIDGET_CLICKED_SIGNAL,
4834 LIVES_GUI_CALLBACK(conxw_ok_clicked),
4835 (livespointer)&conxw);
4846 return conxw.conx_dialog;
4850 static boolean do_chan_connected_query(
lives_conx_w * conxwp,
int key,
int mode,
int cnum,
boolean is_same) {
4852 weed_plant_t *ctmpl, **ochans;
4854 boolean resp =
FALSE;
4855 ochans = weed_get_plantptr_array(filter, WEED_LEAF_OUT_CHANNEL_TEMPLATES, NULL);
4856 ctmpl = ochans[cnum];
4858 cname = get_chan_name(ctmpl, cnum,
TRUE);
4860 msg =
lives_strdup_printf(
_(
"Input channel is already connected from key %d, mode %d\n\n(%s:%s)\n\n"),
4861 key + 1, mode, fname, cname);
4863 resp =
do_yesno_dialogf(
_(
"%sWould you like to replace the existing connection ?\n\n"), msg);
4866 do_error_dialogf(
_(
"%sYou need to remove this connection first before adding another.\n\n"), msg);
4873 static boolean do_param_connected_query(
lives_conx_w * conxwp,
int key,
int mode,
int pnum,
boolean is_same) {
4876 boolean resp =
FALSE;
4879 pname = get_param_name(ptmpl, pnum,
TRUE);
4880 }
else pname = (
_(
"ACTIVATED"));
4882 msg =
lives_strdup_printf(
_(
"Input parameter is already connected from key %d, mode %d\n\n(%s:%s)\n\n"),
4883 key + 1, mode, fname, pname);
4885 resp =
do_yesno_dialogf(
_(
"%sWould you like to replace the existing connection ?\n\n"), msg);
4888 do_error_dialogf(
_(
"%sYou need to remove this connection first before adding another.\n\n"), msg);
4895 static void do_param_incompatible_error(
lives_conx_w * conxwp) {