Commit e1f37cd9 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*improved logic behind selecting iemgui objects and their highlighting

*began working on clean-up of iemgui regressions and preexisting bugs (still need to figure out inconsistency with the hiding/showing of nlets, as well as inability to displace number2 after it has received a label message)
parent 76b05c02
......@@ -491,7 +491,10 @@ void iemgui_select(t_gobj *z, t_glist *glist, int selected)
{
t_iemgui *x = (t_iemgui *)z;
t_canvas *canvas=glist_getcanvas(glist);
x->x_selected = selected;
if (selected)
x->x_selected = canvas;
else
x->x_selected = NULL;
char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol);
sys_vgui(".x%lx.c itemconfigure {x%lx&&border} -stroke %s\n", canvas, x,
x->x_selected && x->x_glist == canvas ? selection_color : fcol);
......@@ -595,7 +598,7 @@ int iem_symargstoint(t_iemgui *x)
void iem_inttofstyle(t_iemgui *x, int n)
{
x->x_font_style = (n >> 0);
x->x_selected = 0;
x->x_selected = NULL;
x->x_finemoved = 0;
x->x_put_in2out = 0;
x->x_change = 0;
......@@ -696,7 +699,7 @@ void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas) {
void scalehandle_draw(t_iemgui *x, t_glist *glist) {
if (x->x_glist == glist_getcanvas(glist)) {
if(x->x_selected) scalehandle_draw_select2(x,glist);
if(x->x_selected == x->x_glist) scalehandle_draw_select2(x,glist);
else scalehandle_draw_erase2(x,glist);
}
}
......@@ -866,7 +869,7 @@ void iemgui_label_draw_move(t_iemgui *x, t_glist *canvas) {
}
void iemgui_label_draw_config(t_iemgui *x, t_glist *canvas) {
if (x->x_selected && x->x_glist == canvas)
if (x->x_selected == canvas && x->x_glist == canvas)
sys_vgui(".x%lx.c itemconfigure %lxLABEL -font %s "
"-fill $pd_colors(selection) -text {%s} \n",
canvas, x, iemgui_font(x),
......@@ -876,10 +879,15 @@ void iemgui_label_draw_config(t_iemgui *x, t_glist *canvas) {
"-fill #%6.6x -text {%s} \n",
canvas, x, iemgui_font(x),
x->x_lcol, x->x_lab!=s_empty?x->x_lab->s_name:"");
if (x->x_lab==s_empty && x->x_selected)
{
t_scalehandle *lh = (t_scalehandle *)(x->x_lhandle);
scalehandle_draw_erase(lh,canvas);
}
}
void iemgui_label_draw_select(t_iemgui *x, t_glist *canvas) {
if (x->x_selected && x->x_glist == canvas)
if (x->x_selected == canvas && x->x_glist == canvas)
sys_vgui(".x%lx.c itemconfigure %lxLABEL "
"-fill $pd_colors(selection)\n", canvas, x);
else
......@@ -904,6 +912,8 @@ void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags) {
int a=old_sr_flags&IEM_GUI_OLD_SND_FLAG;
int b=x->x_snd!=s_empty;
fprintf(stderr,"%lx SND: old_sr_flags=%d SND_FLAG=%d || OUTCOME: OLD_SND_FLAG=%d not_empty=%d\n", (t_int)x, old_sr_flags, IEM_GUI_OLD_SND_FLAG, a, b);
if(a && !b) for (i=0; i<n; i++)
sys_vgui(".x%lx.c create prect %d %d %d %d "
"-stroke $pd_colors(iemgui_nlet) "
......@@ -915,6 +925,7 @@ void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags) {
a=old_sr_flags&IEM_GUI_OLD_RCV_FLAG;
b=x->x_rcv!=s_empty;
fprintf(stderr,"%lx RCV: old_sr_flags=%d RCV_FLAG=%d || OUTCOME: OLD_RCV_FLAG=%d not_empty=%d\n", (t_int)x, old_sr_flags, IEM_GUI_OLD_RCV_FLAG, a, b);
if(a && !b) for (i=0; i<n; i++)
sys_vgui(".x%lx.c create prect %d %d %d %d "
"-stroke $pd_colors(iemgui_nlet) "
......
......@@ -101,7 +101,7 @@ typedef struct _iemgui
// grep -w "$1" *.[ch]|wc -l
// from t_iem_fstyle_flags
unsigned int x_font_style:6; // 33 matches
unsigned int x_selected:1; // 15 matches
t_glist *x_selected; // 15 matches
unsigned int x_finemoved:1; // 7 matches (sliders and [nbx] only)
unsigned int x_put_in2out:1; // 9 matches
unsigned int x_change:1; // 28 matches // what's this and why is there also a x_changed ?
......
......@@ -57,7 +57,7 @@ void my_canvas_draw_config(t_my_canvas* x, t_glist* glist)
canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol);
char bcol[8]; sprintf(bcol, "#%6.6x", x->x_gui.x_bcol);
sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", canvas, x,
x->x_gui.x_selected && x->x_gui.x_glist == canvas ?
x->x_gui.x_selected == canvas && x->x_gui.x_glist == canvas ?
"$pd_colors(selection)" : bcol);
iemgui_label_draw_config(&x->x_gui,canvas);
}
......@@ -68,7 +68,7 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist)
if (x->x_gui.x_glist != glist_getcanvas(glist)) return;
char bcol[8]; sprintf(bcol, "#%6.6x", x->x_gui.x_bcol);
sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", canvas, x,
x->x_gui.x_selected && x->x_gui.x_glist == canvas ?
x->x_gui.x_selected == canvas && x->x_gui.x_glist == canvas ?
"$pd_colors(selection)" : bcol);
}
......
......@@ -141,7 +141,8 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
sys_vgui(
".x%lx.c itemconfigure %lxNUMBER -fill %s -text {%s} \n",
glist_getcanvas(glist), x,
x->x_gui.x_selected && !x->x_gui.x_change ? selection_color : fcol, x->x_buf);
x->x_gui.x_selected == glist_getcanvas(glist) &&
!x->x_gui.x_change ? selection_color : fcol, x->x_buf);
x->x_buf[0] = 0;
}
}
......@@ -198,7 +199,7 @@ static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist)
{
t_canvas *canvas=glist_getcanvas(glist);
char fcol[8]; sprintf(fcol, "%6.6x", x->x_gui.x_fcol);
int issel = x->x_gui.x_selected && x->x_gui.x_glist == canvas;
int issel = x->x_gui.x_selected == canvas && x->x_gui.x_glist == canvas;
sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font %s -fill %s\n",
canvas, x, iemgui_font(&x->x_gui), issel ? selection_color : fcol);
sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill %s\n",
......@@ -212,7 +213,7 @@ static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist)
static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
{
t_canvas *canvas=glist_getcanvas(glist);
int issel = x->x_gui.x_selected && x->x_gui.x_glist == canvas;
int issel = x->x_gui.x_selected == canvas && x->x_gui.x_glist == canvas;
if(x->x_gui.x_selected && x->x_gui.x_change)
{
x->x_gui.x_change = 0;
......
......@@ -217,7 +217,8 @@ static void vu_draw_config(t_vu* x, t_glist* glist)
canvas, x, i, x->x_led_size);
if((i&3)==1) sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} "
"-font %s -fill %s\n", canvas, x, i, iemgui_vu_scale_str[i/4],
iemgui_font(&x->x_gui), x->x_scale ? selection_color : lcol);
iemgui_font(&x->x_gui), x->x_gui.x_selected == canvas &&
x->x_gui.x_glist == canvas && x->x_scale ? selection_color : lcol);
}
iemgui_label_draw_config(&x->x_gui,canvas);
sys_vgui(".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -stroke #%6.6x\n",
......@@ -231,7 +232,7 @@ static void vu_draw_select(t_vu* x,t_glist* glist)
{
t_canvas *canvas=glist_getcanvas(glist);
char lcol[8]; sprintf(lcol,"#%6.6x", x->x_gui.x_lcol);
int issel = x->x_gui.x_selected && x->x_gui.x_glist==canvas;
int issel = x->x_gui.x_selected == canvas && x->x_gui.x_glist == canvas;
sys_vgui(".x%lx.c itemconfigure %lxSCALEN -fill %s\n",
canvas, x, issel ? selection_color : lcol);
}
......
......@@ -5710,9 +5710,9 @@ proc pdtk_iemgui_dialog {id mainheader \
set ::dialog($vid:loadbang) $loadbang
set ::dialog($vid:num) $num
set ::dialog($vid:steady) $steady
if {$snd == "empty"} {set ::dialog($vid:snd) [format ""]
if {$snd == "empty" || $snd == "nosndno"} {set ::dialog($vid:snd) [format ""]
} else {set ::dialog($vid:snd) [format "%s" $snd]}
if {$rcv == "empty"} {set ::dialog($vid:rcv) [format ""]
if {$rcv == "empty" || $snd == "norcvno"} {set ::dialog($vid:rcv) [format ""]
} else {set ::dialog($vid:rcv) [format "%s" $rcv]}
if {$gui_name == "empty"} {set ::dialog($vid:gui_nam) [format ""]
} else {set ::dialog($vid:gui_nam) [format "%s" $gui_name]}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment