Commit 23c85dc9 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Fixed/New:

*creating abstractions from menu does not dirty the canvas
*add minimum and currentvalue in addition to maximum of the signal magicglass
*first tests in improving consistency of fonts between vanilla and iemgui objects (in progress)
parent 17fcf215
......@@ -449,7 +449,7 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a
f = 4;
iemgui->x_fontsize = f;
if(glist_isvisible(iemgui->x_glist))
sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s}\n",
sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s}\n",
glist_getcanvas(iemgui->x_glist), x, iemgui->x_font,
iemgui->x_fontsize, sys_fontweight);
}
......
......@@ -251,6 +251,7 @@ void magicGlass_show(t_magicGlass *x)
//fprintf(stderr,"magicglass_show\n");
if (!x->x_visible) {
x->x_sampleCount = 0;
x->x_minSample = 999999;
x->x_maxSample = -999999;
x->x_string[0] = 0;
x->x_visible = 1;
......@@ -264,6 +265,7 @@ void magicGlass_hide(t_magicGlass *x)
if (x->x_visible) {
magicGlass_undraw(x);
x->x_sampleCount = 0;
x->x_minSample = 999999;
x->x_maxSample = -999999;
x->x_string[0] = 0;
x->x_visible = 0;
......@@ -319,6 +321,7 @@ void magicGlass_setDsp(t_magicGlass *x, int i)
{
x->x_dspOn = 1;
x->x_sampleCount = 0;
x->x_minSample = 999999;
x->x_maxSample = -999999;
}
else
......@@ -341,12 +344,22 @@ t_int *magicGlass_perform(t_int *w)
{
if (in[i] > x->x_maxSample)
x->x_maxSample = in[i];
if (in[i] < x->x_minSample)
x->x_minSample = in[i];
x->x_sampleCount++;
if (x->x_sampleCount >= MG_SAMPLE_COUNT)
{
sprintf(x->x_string, "~ %g", x->x_maxSample);
char l[64], m[64], h[64];
sprintf(l, "%s%#g", (x->x_minSample < 0.0f ? "" : " "), x->x_minSample);
l[6] = '\0';
sprintf(m, "%s%#g", (in[i] < 0.0f ? "" : " "), in[i]);
m[6] = '\0';
sprintf(h, "%s%#g", (x->x_maxSample < 0.0f ? "" : " "), x->x_maxSample);
h[6] = '\0';
sprintf(x->x_string, "~ %s %s %s", l, m, h);
magicGlass_updateText(x, 0);
x->x_maxSample = -999999;
//x->x_minSample = 999999;
//x->x_maxSample = -999999;
x->x_sampleCount = 0;
}
}
......
......@@ -16,6 +16,7 @@ typedef struct _magicGlass
float x_sigF;
int x_dspOn;
int x_viewOn;
float x_minSample;
float x_maxSample;
int x_sampleCount;
t_clock *x_clearClock;
......
......@@ -2104,6 +2104,7 @@ proc put_K12_objects {name object} {
global pointer_y_local
if { $k12_mode == 1 } {
pd [concat $name dirty 1 \;]
pd [concat $name obj_abstraction K12/$object 0 20 \;]
}
}
......@@ -5646,30 +5647,44 @@ set font_fixed_metrics {
30 18 37
36 22 44
}
proc get_font_for_size {size} {
return "::pd_font_${size}"
}
set font_measured_metrics {}
# creates all the base fonts (i.e. pd_font_8 thru pd_font_36) so that they fit
# into the metrics given by $::font_fixed_metrics for any given font/weight
proc fit_font_into_metrics {} {
# TODO the fonts picked seem too small, probably on fixed width
foreach {size width height} $::font_fixed_metrics {
set pixelheight [expr -1 * $height]
font create tmpfont -family $::font_family -weight $::font_weight \
-size $pixelheight
while {[font measure tmpfont M] > $width || \
[font metrics tmpfont -linespace] > $height} {
# this actually makes it smaller since pixel heights are negative
incr pixelheight 1
font configure tmpfont -size $pixelheight
set myfont [get_font_for_size $size]
font create $myfont -family $::font_family -weight $::font_weight \
-size [expr {-$height}]
set height2 $height
set giveup 0
while {[font measure $myfont M] > $width || \
[font metrics $myfont -linespace] > $height} {
incr height2 -1
font configure $myfont -size [expr {-$height2}]
if {$height2 * 2 <= $height} {
set giveup 1
set ::font_measured_metrics $::font_fixed_metrics
break
}
}
set ::font_measured_metrics \
"$::font_measured_metrics $size\
[font measure $myfont M] [font metrics $myfont -linespace]"
if {$giveup} {
::pdwindow::post [format \
[_ "WARNING: %s failed to find font size (%s) that fits into %sx%s!\n"]\
[lindex [info level 0] 0] $size $width $height]
continue
}
font create [get_font_for_size $size] \
-family $::font_family -weight $::font_weight -size $pixelheight
font delete tmpfont
}
}
proc get_font_for_size {size} {
return "::pd_font_${size}"
}
proc find_default_font {} {
set testfonts {"DejaVu Sans Mono" "Bitstream Vera Sans Mono" \
"Inconsolata" "Courier 10 Pitch" "Andale Mono" "Droid Sans Mono"}
......
......@@ -120,6 +120,9 @@ typedef struct _fontinfo
static t_fontinfo sys_fontlist[] = { \
{8, 6, 10, 1, 1, 1}, {10, 7, 13, 1, 1, 1}, {12, 9, 16, 1, 1, 1},
{16, 10, 20, 1, 1, 1}, {24, 15, 25, 1, 1, 1}, {36, 25, 45, 1, 1, 1}};
//0.43 values
// {8, 6, 10, 0, 0, 0}, {10, 7, 13, 0, 0, 0}, {12, 9, 16, 0, 0, 0},
// {16, 10, 20, 0, 0, 0}, {24, 15, 25, 0, 0, 0}, {36, 25, 45, 0, 0, 0}};
#define NFONT (sizeof(sys_fontlist)/sizeof(*sys_fontlist))
static t_fontinfo *sys_findfont(int fontsize)
......
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