Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
nerrons
purr-data
Commits
cda4ebe8
Commit
cda4ebe8
authored
Aug 14, 2014
by
Mathieu L Bouchard
Browse files
changed the meaning of iemgui_font ; fixed 3 bugs from previous commits in [hsl]
parent
276b4801
Changes
5
Hide whitespace changes
Inline
Side-by-side
pd/src/g_all_guis.c
View file @
cda4ebe8
...
...
@@ -254,7 +254,7 @@ void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
x
->
x_fontsize
=
maxi
(
atom_getintarg
(
1
,
ac
,
av
),
4
);
if
(
glist_isvisible
(
x
->
x_glist
))
{
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL -font
{{%s} -%d %s}
\n
"
,
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL -font
%s
\n
"
,
glist_getcanvas
(
x
->
x_glist
),
x
,
iemgui_font
(
x
),
x
->
x_fontsize
,
sys_fontweight
);
iemgui_shouldvis
(
x
,
IEM_GUI_DRAW_MODE_CONFIG
);
...
...
@@ -399,7 +399,7 @@ void iemgui_shouldvis(t_iemgui *x, int mode)
canvas, rtext_gettag(yr));
sys_vgui(".x%lx.c raise selected %s\n",
canvas, rtext_gettag(yr));
//
sys_vgui(".x%lx.c
raise
all_cords
\n",
canvas);
//
canvas_
raise
_
all_cords
(
canvas);
}
else
{
...
...
@@ -611,8 +611,10 @@ int iem_fstyletoint(t_iemgui *x)
extern
int
gfxstub_haveproperties
(
void
*
key
);
int
mini
(
int
a
,
int
b
)
{
return
a
<
b
?
a
:
b
;}
int
maxi
(
int
a
,
int
b
)
{
return
a
>
b
?
a
:
b
;}
int
mini
(
int
a
,
int
b
)
{
return
a
<
b
?
a
:
b
;}
int
maxi
(
int
a
,
int
b
)
{
return
a
>
b
?
a
:
b
;}
float
minf
(
float
a
,
float
b
)
{
return
a
<
b
?
a
:
b
;}
float
maxf
(
float
a
,
float
b
)
{
return
a
>
b
?
a
:
b
;}
// in all 20 cases :
// [bng], [tgl], [hradio], [vradio], [hsl], [vsl], [cnv], [nbx], [vu]
...
...
@@ -850,12 +852,10 @@ void iemgui_label_draw_new(t_iemgui *x, t_glist *canvas) {
int
x1
=
text_xpix
(
&
x
->
x_obj
,
x
->
x_glist
);
int
y1
=
text_ypix
(
&
x
->
x_obj
,
x
->
x_glist
);
sys_vgui
(
".x%lx.c create text %d %d -text {%s} -anchor w "
"-font {{%s} -%d %s} -fill #%6.6x "
"-tags {%lxLABEL x%lx text iemgui}
\n
"
,
"-font %s -fill #%6.6x -tags {%lxLABEL x%lx text iemgui}
\n
"
,
canvas
,
x1
+
x
->
x_ldx
,
y1
+
x
->
x_ldy
,
x
->
x_lab
!=
s_empty
?
x
->
x_lab
->
s_name
:
""
,
iemgui_font
(
x
),
x
->
x_fontsize
,
sys_fontweight
,
x
->
x_lcol
,
x
,
x
);
iemgui_font
(
x
),
x
->
x_lcol
,
x
,
x
);
}
void
iemgui_label_draw_move
(
t_iemgui
*
x
,
t_glist
*
canvas
)
{
...
...
@@ -867,14 +867,14 @@ 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
)
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL -font
{{%s} -%d %s}
"
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL -font
%s
"
"-fill $pd_colors(selection) -text {%s}
\n
"
,
canvas
,
x
,
iemgui_font
(
x
),
x
->
x_fontsize
,
sys_fontweight
,
canvas
,
x
,
iemgui_font
(
x
),
x
->
x_lab
!=
s_empty
?
x
->
x_lab
->
s_name
:
""
);
else
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL -font
{{%s} -%d %s}
"
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL -font
%s
"
"-fill #%6.6x -text {%s}
\n
"
,
canvas
,
x
,
iemgui_font
(
x
),
x
->
x_fontsize
,
sys_fontweight
,
canvas
,
x
,
iemgui_font
(
x
),
x
->
x_lcol
,
x
->
x_lab
!=
s_empty
?
x
->
x_lab
->
s_name
:
""
);
}
...
...
@@ -967,7 +967,7 @@ void iemgui_draw_new(t_iemgui *x, t_glist *glist) {
t_canvas
*
canvas
=
glist_getcanvas
(
glist
);
iemgui_label_draw_new
(
x
,
canvas
);
iemgui_draw_io
(
x
,
glist
,
7
);
sys_vgui
(
".x%lx.c
raise
all_cords
\n
"
,
glist_getcanvas
(
x
->
x_glist
));
// used to be inside x_draw
canvas_
raise
_
all_cords
(
glist_getcanvas
(
x
->
x_glist
));
// used to be inside x_draw
}
void
iemgui_draw_io
(
t_iemgui
*
x
,
t_glist
*
glist
,
int
old_sr_flags
)
{
...
...
@@ -999,13 +999,21 @@ void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) {
wb
->
w_displacefnwtag
=
iemgui_displace_withtag
;
}
const
char
*
iemgui_
font
(
t_iemgui
*
x
)
{
int
f
=
x
->
x_font_style
;
if
(
f
==
0
)
return
sys_font
;
const
char
*
iemgui_
typeface
(
t_iemgui
*
x
)
{
int
f
=
x
->
x_font_style
;
if
(
f
==
0
)
return
sys_font
;
if
(
f
==
1
)
return
"helvetica"
;
if
(
f
==
2
)
return
"times"
;
return
"invalid-font"
;
}
// this uses a static buffer, so don't use it twice in the same sys_vgui.
// the static buffer could be replaced by a malloc when sys_vgui is replaced
// by something that frees that memory.
const
char
*
iemgui_font
(
t_iemgui
*
x
)
{
static
char
buf
[
64
];
sprintf
(
buf
,
"{{%s} -%d %s}"
,
iemgui_typeface
(
x
),
x
->
x_fontsize
,
sys_fontweight
);
return
buf
;
}
void
iemgui_init
(
t_iemgui
*
x
,
t_floatarg
f
)
{
x
->
x_loadinit
=
f
!=
0
.
0
;}
...
...
pd/src/g_all_guis.h
View file @
cda4ebe8
...
...
@@ -30,7 +30,7 @@
#define IEM_GUI_DRAW_MODE_MOVE 1
#define IEM_GUI_DRAW_MODE_NEW 2
#define IEM_GUI_DRAW_MODE_SELECT 3
//
#define IEM_GUI_DRAW_MODE_ERASE 4 // obsolete since 2014.08
#define IEM_GUI_DRAW_MODE_ERASE 4 // obsolete since 2014.08
#define IEM_GUI_DRAW_MODE_CONFIG 5
#define IEM_GUI_DRAW_MODE_IO 6
/* also reserves 7,8,9 by adding old_sr_flags */
...
...
@@ -260,6 +260,8 @@ EXTERN void iemgui__clickhook3(t_scalehandle *sh, int newstate);
EXTERN
int
mini
(
int
a
,
int
b
);
EXTERN
int
maxi
(
int
a
,
int
b
);
EXTERN
float
minf
(
float
a
,
float
b
);
EXTERN
float
maxf
(
float
a
,
float
b
);
// other refactor by Mathieu
EXTERN
void
iemgui_tag_selected
(
t_iemgui
*
x
,
t_glist
*
canvas
);
...
...
@@ -283,6 +285,8 @@ EXTERN const char *selection_color;
static
inline
int
iemgui_has_snd
(
t_iemgui
*
x
)
{
return
x
->
x_snd
!=
s_empty
;}
static
inline
int
iemgui_has_rcv
(
t_iemgui
*
x
)
{
return
x
->
x_rcv
!=
s_empty
;}
EXTERN
const
char
*
iemgui_font
(
t_iemgui
*
x
);
EXTERN
const
char
*
iemgui_typeface
(
t_iemgui
*
x
);
EXTERN
void
iemgui_class_addmethods
(
t_class
*
c
);
EXTERN
void
scrollbar_update
(
t_glist
*
glist
);
EXTERN
void
iemgui_init
(
t_iemgui
*
x
,
t_floatarg
f
);
...
...
pd/src/g_numbox.c
View file @
cda4ebe8
...
...
@@ -169,10 +169,8 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
x
->
x_gui
.
x_fcol
,
x
,
x
);
my_numbox_ftoa
(
x
);
sys_vgui
(
".x%lx.c create text %d %d -text {%s} -anchor w "
"-font {{%s} -%d %s} -fill #%6.6x "
"-tags {%lxNUMBER x%lx noscroll text iemgui}
\n
"
,
canvas
,
x1
+
half
+
2
,
y1
+
half
+
d
,
x
->
x_buf
,
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fontsize
,
sys_fontweight
,
"-font %s -fill #%6.6x -tags {%lxNUMBER x%lx noscroll text iemgui}
\n
"
,
canvas
,
x1
+
half
+
2
,
y1
+
half
+
d
,
x
->
x_buf
,
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fcol
,
x
,
x
);
}
...
...
@@ -201,10 +199,8 @@ 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
;
sys_vgui
(
".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} "
"-fill %s
\n
"
,
canvas
,
x
,
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fontsize
,
sys_fontweight
,
issel
?
selection_color
:
fcol
);
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
"
,
canvas
,
x
,
issel
?
selection_color
:
fcol
);
...
...
@@ -478,16 +474,8 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
iemgui_dialog
(
&
x
->
x_gui
,
srl
,
argc
,
argv
);
x
->
x_numwidth
=
my_numbox_calc_fontwidth
(
x
);
my_numbox_check_minmax
(
x
,
min
,
max
);
//if (need_to_redraw) {
iemgui_draw_erase
(
&
x
->
x_gui
,
x
->
x_gui
.
x_glist
);
iemgui_shouldvis
(
&
x
->
x_gui
,
IEM_GUI_DRAW_MODE_NEW
);
/*} else {
x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
iemgui_draw_io(&x->x_gui, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
//x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
//x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE);
}*/
scalehandle_draw
(
&
x
->
x_gui
,
x
->
x_gui
.
x_glist
);
//canvas_restore_original_position(x->x_gui.x_glist, (t_gobj *)x,"bogus",-1);
scrollbar_update
(
x
->
x_gui
.
x_glist
);
...
...
pd/src/g_slider.c
View file @
cda4ebe8
...
...
@@ -213,7 +213,7 @@ void slider_check_length(t_slider *x, int w)
if
(
x
->
x_orient
)
x
->
x_gui
.
x_h
=
w
;
else
x
->
x_gui
.
x_w
=
w
;
x
->
x_center
=
(
w
-
1
)
*
50
;
if
(
x
->
x_val
>
(
w
*
100
-
100
)
)
if
(
x
->
x_val
>
(
w
-
1
)
*
100
)
{
x
->
x_pos
=
(
w
-
1
)
*
100
;
x
->
x_val
=
x
->
x_pos
;
...
...
@@ -280,8 +280,9 @@ static void slider_bang(t_slider *x)
out
=
x
->
x_min
*
exp
(
x
->
x_k
*
(
double
)(
x
->
x_val
)
*
0
.
01
);
else
{
if
(
x
->
x_is_last_float
&&
x
->
x_last
<=
x
->
x_max
&&
x
->
x_last
>=
x
->
x_min
)
x
->
x_last
>=
x
->
x_min
)
{
out
=
x
->
x_last
;
}
else
out
=
(
double
)(
x
->
x_val
)
*
0
.
01
*
x
->
x_k
+
x
->
x_min
;
}
...
...
@@ -355,17 +356,20 @@ static void slider_click(t_slider *x, t_floatarg xpos, t_floatarg ypos,
{
if
(
!
x
->
x_steady
)
x
->
x_val
=
x
->
x_orient
?
(
int
)(
100
.
0
*
(
xpos
-
text_xpix
(
&
x
->
x_gui
.
x_obj
,
x
->
x_gui
.
x_glist
)))
:
(
int
)(
100
.
0
*
(
x
->
x_gui
.
x_h
+
text_ypix
(
&
x
->
x_gui
.
x_obj
,
x
->
x_gui
.
x_glist
)
-
ypos
));
(
int
)(
100
.
0
*
(
x
->
x_gui
.
x_h
+
text_ypix
(
&
x
->
x_gui
.
x_obj
,
x
->
x_gui
.
x_glist
)
-
ypos
))
:
(
int
)(
100
.
0
*
(
xpos
-
text_xpix
(
&
x
->
x_gui
.
x_obj
,
x
->
x_gui
.
x_glist
)));
printf
(
"slider_click x->val=%d x->pos=%d
\n
"
,
x
->
x_val
,
x
->
x_pos
);
int
w
=
x
->
x_orient
?
x
->
x_gui
.
x_h
:
x
->
x_gui
.
x_w
;
x
->
x_val
=
mini
(
maxi
(
x
->
x_val
,
0
),
100
*
(
w
-
1
));
if
(
x
->
x_pos
!=
x
->
x_val
)
{
printf
(
"slider_click x->val=%d x->pos=%d
\n
"
,
x
->
x_val
,
x
->
x_pos
);
x
->
x_pos
=
x
->
x_val
;
x
->
x_gui
.
x_changed
=
1
;
x
->
x_gui
.
x_draw
(
x
,
x
->
x_gui
.
x_glist
,
IEM_GUI_DRAW_MODE_UPDATE
);
}
x
->
x_is_last_float
=
0
;
// does anyone know how this works with !steady && rcv==snd ?
slider_bang
(
x
);
glist_grab
(
x
->
x_gui
.
x_glist
,
&
x
->
x_gui
.
x_obj
.
te_g
,
(
t_glistmotionfn
)
slider_motion
,
0
,
xpos
,
ypos
);
...
...
@@ -387,6 +391,7 @@ static int slider_newclick(t_gobj *z, struct _glist *glist,
static
void
slider_set
(
t_slider
*
x
,
t_floatarg
f
)
{
double
g
;
t_floatarg
of
=
f
;
if
(
x
->
x_gui
.
x_reverse
)
f
=
maxi
(
mini
(
f
,
x
->
x_min
),
x
->
x_max
);
else
...
...
@@ -396,6 +401,7 @@ static void slider_set(t_slider *x, t_floatarg f)
else
g
=
(
f
-
x
->
x_min
)
/
x
->
x_k
;
x
->
x_val
=
(
int
)(
100
.
0
*
g
+
0
.
49999
);
printf
(
"slider_set val=%d pos=%d of=%f f=%f g=%f min=%f max=%f reverse=%d
\n
"
,
x
->
x_val
,
x
->
x_pos
,
of
,
f
,
g
,
x
->
x_min
,
x
->
x_max
,
x
->
x_gui
.
x_reverse
);
if
(
x
->
x_pos
!=
x
->
x_val
)
{
x
->
x_pos
=
x
->
x_val
;
...
...
@@ -406,11 +412,14 @@ static void slider_set(t_slider *x, t_floatarg f)
static
void
slider_float
(
t_slider
*
x
,
t_floatarg
f
)
{
printf
(
"(1)slider_float x->val=%d x->pos=%d f=%f
\n
"
,
x
->
x_val
,
x
->
x_pos
,
f
);
x
->
x_is_last_float
=
1
;
x
->
x_last
=
f
;
slider_set
(
x
,
f
);
printf
(
"(2)slider_float x->val=%d x->pos=%d
\n
"
,
x
->
x_val
,
x
->
x_pos
);
if
(
x
->
x_gui
.
x_put_in2out
)
slider_bang
(
x
);
printf
(
"(3)slider_float x->val=%d x->pos=%d
\n
"
,
x
->
x_val
,
x
->
x_pos
);
}
static
void
slider_size
(
t_slider
*
x
,
t_symbol
*
s
,
int
ac
,
t_atom
*
av
)
...
...
pd/src/g_vumeter.c
View file @
cda4ebe8
...
...
@@ -143,11 +143,10 @@ static void vu_draw_new(t_vu *x, t_glist *glist)
yyy
=
k4
+
k1
*
(
k2
-
i
);
if
((
i
&
3
)
==
1
&&
(
x
->
x_scale
))
sys_vgui
(
".x%lx.c create text %d %d -text {%s} -anchor w "
"-font
{{%s} -%d %s}
-fill #%6.6x "
"-font
%s
-fill #%6.6x "
"-tags {%lxSCALEN %lxSCALE%d x%lx text iemgui}
\n
"
,
canvas
,
end
+
1
,
yyy
+
k3
+
2
,
iemgui_vu_scale_str
[
i
/
4
],
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fontsize
,
sys_fontweight
,
x
->
x_gui
.
x_lcol
,
x
,
x
,
i
,
x
);
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_lcol
,
x
,
x
,
i
,
x
);
led_col
=
iemgui_vu_col
[
i
];
if
(
i
<=
IEM_VU_STEPS
)
sys_vgui
(
".x%lx.c create polyline %d %d %d %d "
...
...
@@ -217,10 +216,8 @@ static void vu_draw_config(t_vu* x, t_glist* glist)
sys_vgui
(
".x%lx.c itemconfigure %lxRLED%d -strokewidth %d
\n
"
,
canvas
,
x
,
i
,
x
->
x_led_size
);
if
((
i
&
3
)
==
1
)
sys_vgui
(
".x%lx.c itemconfigure %lxSCALE%d -text {%s} "
"-font {{%s} -%d %s} -fill %s
\n
"
,
canvas
,
x
,
i
,
iemgui_vu_scale_str
[
i
/
4
],
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fontsize
,
sys_fontweight
,
(
x
->
x_scale
)
?
selection_color
:
lcol
);
"-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_label_draw_config
(
&
x
->
x_gui
,
canvas
);
sys_vgui
(
".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -stroke #%6.6x
\n
"
,
...
...
@@ -450,20 +447,16 @@ static void vu_scale(t_vu *x, t_floatarg fscale)
yyy
=
k4
+
k1
*
(
k2
-
i
);
if
((
i
&
3
)
==
1
)
sys_vgui
(
".x%lx.c create text %d %d -text {%s} -anchor w "
"-font {{%s} -%d %s} -fill #%6.6x "
"-tags {%lxSCALE%d x%lx}
\n
"
,
"-font %s -fill #%6.6x -tags {%lxSCALE%d x%lx}
\n
"
,
canvas
,
end
+
1
,
yyy
+
k3
+
2
,
iemgui_vu_scale_str
[
i
/
4
],
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fontsize
,
sys_fontweight
,
x
->
x_gui
.
x_lcol
,
x
,
i
,
x
);
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_lcol
,
x
,
i
,
x
);
}
i
=
IEM_VU_STEPS
+
1
;
yyy
=
k4
+
k1
*
(
k2
-
i
);
sys_vgui
(
".x%lx.c create text %d %d -text {%s} -anchor w "
"-font {{%s} -%d %s} -fill #%6.6x "
"-tags {%lxSCALE%d x%lx}
\n
"
,
"-font %s -fill #%6.6x -tags {%lxSCALE%d x%lx}
\n
"
,
canvas
,
end
+
1
,
yyy
+
k3
+
2
,
iemgui_vu_scale_str
[
i
/
4
],
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_fontsize
,
sys_fontweight
,
x
->
x_gui
.
x_lcol
,
x
,
i
,
x
);
iemgui_font
(
&
x
->
x_gui
),
x
->
x_gui
.
x_lcol
,
x
,
i
,
x
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment