Commit 39fd0093 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

constrained resizing with vert/horiz cursors

parent d811c6be
...@@ -106,9 +106,8 @@ typedef struct _scope ...@@ -106,9 +106,8 @@ typedef struct _scope
int x_frozen; int x_frozen;
t_clock *x_clock; t_clock *x_clock;
t_pd *x_handle; t_pd *x_handle;
int scale_offset_x;
int scale_offset_x; int scale_offset_y;
int scale_offset_y;
} t_scope; } t_scope;
typedef struct _scopehandle typedef struct _scopehandle
...@@ -118,6 +117,9 @@ typedef struct _scopehandle ...@@ -118,6 +117,9 @@ typedef struct _scopehandle
t_symbol *h_bindsym; t_symbol *h_bindsym;
char h_pathname[64]; char h_pathname[64];
char h_outlinetag[64]; char h_outlinetag[64];
int h_adjust_x;
int h_adjust_y;
int h_constrain;
int h_dragon; int h_dragon;
int h_dragx; int h_dragx;
int h_dragy; int h_dragy;
...@@ -992,49 +994,16 @@ static void scope_tick(t_scope *x) ...@@ -992,49 +994,16 @@ static void scope_tick(t_scope *x)
scope_clear(x, 1); scope_clear(x, 1);
} }
static void scopehandle__clickhook(t_scopehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) extern void canvas_apply_setundo(t_canvas *x, t_gobj *y);
static void scopehandle__clickhook(t_scopehandle *sh, t_floatarg f,
t_floatarg xxx, t_floatarg yyy)
{ {
t_scope *x = sh->h_master; t_scope *x = sh->h_master;
/* Use constrained dragging. See g_canvas.c clickhook */
//if (xxx) x->scale_offset_x = xxx; sh->h_constrain = (int)f;
//if (yyy) x->scale_offset_y = yyy; sh->h_adjust_x = xxx - (((t_object *)x)->te_xpix + x->x_width);
sh->h_adjust_y = yyy - (((t_object *)x)->te_ypix + x->x_height);
//int newstate = (int)f; canvas_apply_setundo(x->x_glist, (t_gobj *)x);
//if (sh->h_dragon && newstate == 0)
//{
// /* done dragging */
// t_canvas *cv;
// if (sh->h_dragx || sh->h_dragy)
// {
// x->x_width = x->x_width + sh->h_dragx - x->scale_offset_x;
// x->x_height = x->x_height + sh->h_dragy - x->scale_offset_y;
// }
// if (cv = scope_isvisible(x))
// {
// sys_vgui(".x%x.c delete %s\n", cv, sh->h_outlinetag);
// scope_revis(x, cv);
// sys_vgui("destroy %s\n", sh->h_pathname);
// scope_select((t_gobj *)x, x->x_glist, 1);
// canvas_fixlinesfor(x->x_glist, (t_text *)x); /* 2nd inlet */
// }
//}
//else if (!sh->h_dragon && newstate)
//{
// /* dragging */
// t_canvas *cv;
// if (cv = scope_isvisible(x))
// {
// int x1, y1, x2, y2;
// scope_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2);
// sys_vgui("lower %s\n", sh->h_pathname);
// sys_vgui(".x%x.c create rectangle %d %d %d %d\
// -outline $select_color -width %f -tags %s\n",
// cv, x1, y1, x2, y2, SCOPE_SELBDWIDTH, sh->h_outlinetag);
// }
// sh->h_dragx = 0;
// sh->h_dragy = 0;
//}
sh->h_dragon = f; sh->h_dragon = f;
} }
...@@ -1042,10 +1011,13 @@ static void scopehandle__motionhook(t_scopehandle *sh, ...@@ -1042,10 +1011,13 @@ static void scopehandle__motionhook(t_scopehandle *sh,
t_floatarg mouse_x, t_floatarg mouse_y) t_floatarg mouse_x, t_floatarg mouse_y)
{ {
t_scope *x = (t_scope *)(sh->h_master); t_scope *x = (t_scope *)(sh->h_master);
int x1, y1, x2, y2, width, height; int width = (sh->h_constrain == CURSOR_EDITMODE_RESIZE_Y) ?
scope_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2); x->x_width :
width = mouse_x - x1; (int)mouse_x - text_xpix((t_text *)x, x->x_glist) - sh->h_adjust_x;
height = mouse_y - y1; int height = (sh->h_constrain == CURSOR_EDITMODE_RESIZE_X) ?
x->x_height :
(int)mouse_y - text_ypix((t_text *)x, x->x_glist) - sh->h_adjust_y;
x->x_width = width < SCOPE_MINWIDTH ? SCOPE_MINWIDTH : width; x->x_width = width < SCOPE_MINWIDTH ? SCOPE_MINWIDTH : width;
x->x_height = height < SCOPE_MINHEIGHT ? SCOPE_MINHEIGHT : height; x->x_height = height < SCOPE_MINHEIGHT ? SCOPE_MINHEIGHT : height;
...@@ -1058,25 +1030,6 @@ static void scopehandle__motionhook(t_scopehandle *sh, ...@@ -1058,25 +1030,6 @@ static void scopehandle__motionhook(t_scopehandle *sh,
scope_vis((t_gobj *)x, x->x_glist, 0); scope_vis((t_gobj *)x, x->x_glist, 0);
scope_vis((t_gobj *)x, x->x_glist, 1); scope_vis((t_gobj *)x, x->x_glist, 1);
} }
//if (sh->h_dragon)
//{
// t_scope *x = sh->h_master;
// int dx = (int)f1, dy = (int)f2;
// int x1, y1, x2, y2, newx, newy;
// scope_getrect((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2);
// newx = x2 - x->scale_offset_x + dx;
// newy = y2 - x->scale_offset_y + dy;
// if (newx > x1 + SCOPE_MINWIDTH && newy > y1 + SCOPE_MINHEIGHT)
// {
// t_canvas *cv;
// if (cv = scope_isvisible(x))
// sys_vgui(".x%x.c coords %s %d %d %d %d\n",
// cv, sh->h_outlinetag, x1, y1, newx, newy);
// sh->h_dragx = dx;
// sh->h_dragy = dy;
// }
//}
} }
/* wrapper method for forwarding "scopehandle" data */ /* wrapper method for forwarding "scopehandle" data */
...@@ -1157,8 +1110,8 @@ static void *scope_new(t_symbol *s, int ac, t_atom *av) ...@@ -1157,8 +1110,8 @@ static void *scope_new(t_symbol *s, int ac, t_atom *av)
sprintf(sh->h_outlinetag, "h%x", (int)sh); sprintf(sh->h_outlinetag, "h%x", (int)sh);
sh->h_dragon = 0; sh->h_dragon = 0;
x->scale_offset_x = 0; x->scale_offset_x = 0;
x->scale_offset_y = 0; x->scale_offset_y = 0;
return (x); return (x);
} }
......
...@@ -696,39 +696,43 @@ static void grid_bang(t_grid *x) { ...@@ -696,39 +696,43 @@ static void grid_bang(t_grid *x) {
static void grid__clickhook(t_scalehandle *sh, int newstate) static void grid__clickhook(t_scalehandle *sh, int newstate)
{ {
t_grid *x = (t_grid *)(sh->h_master); t_grid *x = (t_grid *)(sh->h_master);
if (newstate) /* Use constrained dragging-- see g_canvas.c clickhook */
{ sh->h_constrain = newstate;
canvas_apply_setundo(x->x_glist, (t_gobj *)x); sh->h_adjust_x = sh->h_offset_x -
} (((t_object *)x)->te_xpix + x->x_width);
sh->h_adjust_y = sh->h_offset_y -
(((t_object *)x)->te_ypix + x->x_height);
canvas_apply_setundo(x->x_glist, (t_gobj *)x);
sh->h_dragon = newstate; sh->h_dragon = newstate;
} }
static void grid__motionhook(t_scalehandle *sh, static void grid__motionhook(t_scalehandle *sh,
t_floatarg mouse_x, t_floatarg mouse_y) t_floatarg mouse_x, t_floatarg mouse_y)
{ {
if (sh->h_scale) t_grid *x = (t_grid *)(sh->h_master);
int width = (sh->h_constrain == CURSOR_EDITMODE_RESIZE_Y) ?
x->x_width :
(int)mouse_x - text_xpix(&x->x_obj, x->x_glist) - sh->h_adjust_x;
int height = (sh->h_constrain == CURSOR_EDITMODE_RESIZE_X) ?
x->x_height :
(int)mouse_y - text_ypix(&x->x_obj, x->x_glist) - sh->h_adjust_y;
int minw = MIN_GRID_WIDTH,
minh = MIN_GRID_HEIGHT;
x->x_width = width < minw ? minw : width;
x->x_height = height < minh ? minh : height;
if (glist_isvisible(x->x_glist))
{ {
t_grid *x = (t_grid *)(sh->h_master); grid_draw_configure(x, x->x_glist);
int width = mouse_x - text_xpix(&x->x_obj, x->x_glist), //scalehandle_unclick_scale(sh);
height = mouse_y - text_ypix(&x->x_obj, x->x_glist), }
minw = MIN_GRID_WIDTH,
minh = MIN_GRID_HEIGHT;
x->x_width = width < minw ? minw : width;
x->x_height = height < minh ? minh : height;
if (glist_isvisible(x->x_glist))
{
grid_draw_configure(x, x->x_glist);
//scalehandle_unclick_scale(sh);
}
int properties = gfxstub_haveproperties((void *)x); int properties = gfxstub_haveproperties((void *)x);
if (properties) if (properties)
{ {
int new_w = x->x_width + sh->h_dragx; int new_w = x->x_width + sh->h_dragx;
int new_h = x->x_height + sh->h_dragy; int new_h = x->x_height + sh->h_dragy;
properties_set_field_int(properties,"width",new_w); properties_set_field_int(properties,"width",new_w);
properties_set_field_int(properties,"height",new_h); properties_set_field_int(properties,"height",new_h);
}
} }
} }
...@@ -737,8 +741,9 @@ static void grid_click_for_resizing(t_grid *x, t_floatarg f, ...@@ -737,8 +741,9 @@ static void grid_click_for_resizing(t_grid *x, t_floatarg f,
t_floatarg xxx, t_floatarg yyy) t_floatarg xxx, t_floatarg yyy)
{ {
t_scalehandle *sh = (t_scalehandle *)x->x_handle; t_scalehandle *sh = (t_scalehandle *)x->x_handle;
sh->h_offset_x = (int)xxx;
sh->h_offset_y = (int)yyy;
grid__clickhook(sh, f); grid__clickhook(sh, f);
// grid__clickhook(sh, f, xxx, yyy);
} }
/* another wrapper for forwarding "scalehandle" motion data */ /* another wrapper for forwarding "scalehandle" motion data */
......
...@@ -1477,6 +1477,9 @@ function gui_canvas_cursor(cid, pd_event_type) { ...@@ -1477,6 +1477,9 @@ function gui_canvas_cursor(cid, pd_event_type) {
case "cursor_scroll": case "cursor_scroll":
c = "all-scroll"; c = "all-scroll";
break; break;
case "cursor_editmode_resize_vert":
c = "ns-resize";
break;
} }
patch.style.cursor = c; patch.style.cursor = c;
}); });
......
...@@ -917,15 +917,15 @@ void scalehandle_drag_scale(t_scalehandle *h) { ...@@ -917,15 +917,15 @@ void scalehandle_drag_scale(t_scalehandle *h) {
static void scalehandle_clickhook(t_scalehandle *h, t_floatarg f, static void scalehandle_clickhook(t_scalehandle *h, t_floatarg f,
t_floatarg xxx, t_floatarg yyy) t_floatarg xxx, t_floatarg yyy)
{ {
h->h_offset_x=xxx; h->h_offset_x = xxx;
h->h_offset_y=yyy; h->h_offset_y = yyy;
h->h_clickfn(h,f); h->h_clickfn(h, f);
} }
static void scalehandle_motionhook(t_scalehandle *h, static void scalehandle_motionhook(t_scalehandle *h,
t_floatarg f1, t_floatarg f2) t_floatarg f1, t_floatarg f2)
{ {
h->h_motionfn(h,f1,f2); h->h_motionfn(h, f1, f2);
// Now set the offset to the new mouse position // Now set the offset to the new mouse position
h->h_offset_x = f1; h->h_offset_x = f1;
h->h_offset_y = f2; h->h_offset_y = f2;
...@@ -951,7 +951,8 @@ static void scalehandle_check_and_redraw(t_iemgui *x) ...@@ -951,7 +951,8 @@ static void scalehandle_check_and_redraw(t_iemgui *x)
//---------------------------------------------------------------- //----------------------------------------------------------------
// IEMGUI refactor (by Mathieu) // IEMGUI refactor (by Mathieu)
void iemgui_tag_selected(t_iemgui *x) { void iemgui_tag_selected(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
if (x->x_selected) if (x->x_selected)
gui_vmess("gui_gobj_select", "xx", canvas, x); gui_vmess("gui_gobj_select", "xx", canvas, x);
...@@ -959,7 +960,8 @@ void iemgui_tag_selected(t_iemgui *x) { ...@@ -959,7 +960,8 @@ void iemgui_tag_selected(t_iemgui *x) {
gui_vmess("gui_gobj_deselect", "xx", canvas, x); gui_vmess("gui_gobj_deselect", "xx", canvas, x);
} }
void iemgui_label_draw_new(t_iemgui *x) { void iemgui_label_draw_new(t_iemgui *x)
{
char col[8]; char col[8];
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
int x1=text_xpix(&x->x_obj, x->x_glist)+x->legacy_x; int x1=text_xpix(&x->x_obj, x->x_glist)+x->legacy_x;
...@@ -997,7 +999,8 @@ void iemgui_label_draw_move(t_iemgui *x) ...@@ -997,7 +999,8 @@ void iemgui_label_draw_move(t_iemgui *x)
x->x_ldy + x->legacy_y); x->x_ldy + x->legacy_y);
} }
void iemgui_label_draw_config(t_iemgui *x) { void iemgui_label_draw_config(t_iemgui *x)
{
char col[8]; char col[8];
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
if (x->x_selected == canvas && x->x_glist == canvas) if (x->x_selected == canvas && x->x_glist == canvas)
...@@ -1046,7 +1049,8 @@ void iemgui_label_draw_config(t_iemgui *x) { ...@@ -1046,7 +1049,8 @@ void iemgui_label_draw_config(t_iemgui *x) {
} }
} }
void iemgui_label_draw_select(t_iemgui *x) { void iemgui_label_draw_select(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
if (x->x_selected == canvas && x->x_glist == canvas) if (x->x_selected == canvas && x->x_glist == canvas)
{ {
...@@ -1073,9 +1077,10 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags) ...@@ -1073,9 +1077,10 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
if (x->x_glist != canvas) return; // is gop if (x->x_glist != canvas) return; // is gop
t_class *c = pd_class((t_pd *)x); t_class *c = pd_class((t_pd *)x);
if (c==my_numbox_class && ((t_my_numbox *)x)->x_hide_frame > 1) return; //sigh if (c == my_numbox_class && ((t_my_numbox *)x)->x_hide_frame > 1)
return; //sigh
if (!(old_sr_flags&4) && !glist_isvisible(canvas)) { if (!(old_sr_flags&4) && !glist_isvisible(canvas))
{
return; return;
} }
if (c==my_canvas_class) return; if (c==my_canvas_class) return;
...@@ -1090,7 +1095,9 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags) ...@@ -1090,7 +1095,9 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
n = 0; n = 0;
int a=old_sr_flags&IEM_GUI_OLD_SND_FLAG; int a=old_sr_flags&IEM_GUI_OLD_SND_FLAG;
int b=x->x_snd!=s_empty; 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); //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) if (a && !b)
{ {
...@@ -1139,7 +1146,8 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags) ...@@ -1139,7 +1146,8 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
} }
} }
void iemgui_io_draw_move(t_iemgui *x) { void iemgui_io_draw_move(t_iemgui *x)
{
char tagbuf[MAXPDSTRING]; char tagbuf[MAXPDSTRING];
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
t_class *c = pd_class((t_pd *)x); t_class *c = pd_class((t_pd *)x);
...@@ -1183,13 +1191,15 @@ void iemgui_io_draw_move(t_iemgui *x) { ...@@ -1183,13 +1191,15 @@ void iemgui_io_draw_move(t_iemgui *x) {
} }
} }
void iemgui_base_draw_new(t_iemgui *x) { void iemgui_base_draw_new(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
t_class *c = pd_class((t_pd *)x); t_class *c = pd_class((t_pd *)x);
int x1,y1,x2,y2,gr=gop_redraw; gop_redraw=0; int x1, y1, x2, y2, gr = gop_redraw;
c->c_wb->w_getrectfn((t_gobj *)x,x->x_glist,&x1,&y1,&x2,&y2); gop_redraw = 0;
c->c_wb->w_getrectfn((t_gobj *)x, x->x_glist, &x1, &y1, &x2, &y2);
//iemgui_getrect_draw(x, &x1, &y1, &x2, &y2); //iemgui_getrect_draw(x, &x1, &y1, &x2, &y2);
gop_redraw=gr; gop_redraw = gr;
char colorbuf[MAXPDSTRING]; char colorbuf[MAXPDSTRING];
sprintf(colorbuf, "#%6.6x", x->x_bcol); sprintf(colorbuf, "#%6.6x", x->x_bcol);
gui_vmess("gui_gobj_new", "xxsiii", canvas, x, gui_vmess("gui_gobj_new", "xxsiii", canvas, x,
...@@ -1206,7 +1216,8 @@ void iemgui_base_draw_new(t_iemgui *x) { ...@@ -1206,7 +1216,8 @@ void iemgui_base_draw_new(t_iemgui *x) {
canvas, x, colorbuf); canvas, x, colorbuf);
} }
void iemgui_base_draw_move(t_iemgui *x) { void iemgui_base_draw_move(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
t_class *c = pd_class((t_pd *)x); t_class *c = pd_class((t_pd *)x);
int x1,y1,x2,y2,gr=gop_redraw; gop_redraw=0; int x1,y1,x2,y2,gr=gop_redraw; gop_redraw=0;
...@@ -1217,8 +1228,8 @@ void iemgui_base_draw_move(t_iemgui *x) { ...@@ -1217,8 +1228,8 @@ void iemgui_base_draw_move(t_iemgui *x) {
canvas, x, x1, y1, x2, y2); canvas, x, x1, y1, x2, y2);
} }
void iemgui_base_draw_config(t_iemgui *x) { void iemgui_base_draw_config(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol); char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol);
char tagbuf[MAXPDSTRING]; char tagbuf[MAXPDSTRING];
...@@ -1228,44 +1239,52 @@ void iemgui_base_draw_config(t_iemgui *x) { ...@@ -1228,44 +1239,52 @@ void iemgui_base_draw_config(t_iemgui *x) {
canvas, x, bcol); canvas, x, bcol);
} }
void iemgui_draw_update(t_iemgui *x, t_glist *glist) { void iemgui_draw_update(t_iemgui *x, t_glist *glist)
{
x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_UPDATE); x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_UPDATE);
} }
void iemgui_draw_new(t_iemgui *x) { void iemgui_draw_new(t_iemgui *x)
{
x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_NEW); x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_NEW);
iemgui_label_draw_new(x); iemgui_label_draw_new(x);
iemgui_draw_io(x,7); iemgui_draw_io(x,7);
canvas_raise_all_cords(glist_getcanvas(x->x_glist)); // used to be inside x_draw // used to be inside x_draw...
canvas_raise_all_cords(glist_getcanvas(x->x_glist));
} }
void iemgui_draw_config(t_iemgui *x) { void iemgui_draw_config(t_iemgui *x)
{
x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_CONFIG); x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_CONFIG);
iemgui_label_draw_config(x); iemgui_label_draw_config(x);
//iemgui_base_draw_config(x); // can't //iemgui_base_draw_config(x); // can't
} }
void iemgui_draw_move(t_iemgui *x) { void iemgui_draw_move(t_iemgui *x)
{
x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_MOVE); x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_MOVE);
iemgui_label_draw_move(x); iemgui_label_draw_move(x);
//iemgui_base_draw_move(x); // can't //iemgui_base_draw_move(x); // can't
iemgui_io_draw_move(x); iemgui_io_draw_move(x);
} }
void iemgui_draw_erase(t_iemgui *x) { void iemgui_draw_erase(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
gui_vmess("gui_gobj_erase", "xx", canvas, x); gui_vmess("gui_gobj_erase", "xx", canvas, x);
scalehandle_draw_erase2(x); scalehandle_draw_erase2(x);
} }
void scrollbar_update(t_glist *glist) { void scrollbar_update(t_glist *glist)
{
//ico@bukvic.net 100518 update scrollbars when object potentially //ico@bukvic.net 100518 update scrollbars when object potentially
//exceeds window size //exceeds window size
t_canvas *canvas=(t_canvas *)glist_getcanvas(glist); t_canvas *canvas=(t_canvas *)glist_getcanvas(glist);
canvas_getscroll(canvas); canvas_getscroll(canvas);
} }
void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) { void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl)
{
wb->w_getrectfn = gr; wb->w_getrectfn = gr;
wb->w_displacefn = iemgui_displace; wb->w_displacefn = iemgui_displace;
wb->w_selectfn = iemgui_select; wb->w_selectfn = iemgui_select;
...@@ -1276,13 +1295,15 @@ void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) { ...@@ -1276,13 +1295,15 @@ void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) {
wb->w_displacefnwtag = iemgui_displace_withtag; wb->w_displacefnwtag = iemgui_displace_withtag;
} }
const char *iemgui_typeface(t_iemgui *x) { const char *iemgui_typeface(t_iemgui *x)
{
int f = x->x_font_style; int f = x->x_font_style;
if(f == 0) return sys_font; if(f == 0) return sys_font;
if(f == 1) return "helvetica"; if(f == 1) return "helvetica";
if(f == 2) return "times"; if(f == 2) return "times";
return "invalid-font"; return "invalid-font";
} }
// this uses a static buffer, so don't use it twice in the same sys_vgui. // 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 // the static buffer could be replaced by a malloc when sys_vgui is replaced
// by something that frees that memory. // by something that frees that memory.
...@@ -1290,7 +1311,9 @@ const char *iemgui_typeface(t_iemgui *x) { ...@@ -1290,7 +1311,9 @@ const char *iemgui_typeface(t_iemgui *x) {
separate arg so we don't have to parse on the gui side. separate arg so we don't have to parse on the gui side.
Once we check to make sure all iemguis work without it we can safely Once we check to make sure all iemguis work without it we can safely
remove it */ remove it */
const char *iemgui_font(t_iemgui *x) {
const char *iemgui_font(t_iemgui *x)
{
static char buf[64]; static char buf[64];
sprintf(buf, "{{%s} -%d %s}", iemgui_typeface(x), x->x_fontsize, sys_fontweight); sprintf(buf, "{{%s} -%d %s}", iemgui_typeface(x), x->x_fontsize, sys_fontweight);
return buf; return buf;
...@@ -1298,7 +1321,8 @@ const char *iemgui_font(t_iemgui *x) { ...@@ -1298,7 +1321,8 @@ const char *iemgui_font(t_iemgui *x) {
void iemgui_init(t_iemgui *x, t_floatarg f) {x->x_loadinit = f!=0.0;} void iemgui_init(t_iemgui *x, t_floatarg f) {x->x_loadinit = f!=0.0;}
void iemgui_class_addmethods(t_class *c) { void iemgui_class_addmethods(t_class *c)
{
class_addmethod(c, (t_method)iemgui_delta, class_addmethod(c, (t_method)iemgui_delta,
gensym("delta"), A_GIMME, 0); gensym("delta"), A_GIMME, 0);
class_addmethod(c, (t_method)iemgui_pos, class_addmethod(c, (t_method)iemgui_pos,
...@@ -1317,7 +1341,8 @@ void iemgui_class_addmethods(t_class *c) { ...@@ -1317,7 +1341,8 @@ void iemgui_class_addmethods(t_class *c) {
gensym("label_font"), A_GIMME, 0); gensym("label_font"), A_GIMME, 0);
} }
void g_iemgui_setup (void) { void g_iemgui_setup (void)
{
s_empty = gensym("empty"); s_empty = gensym("empty");