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
Wynn
purr-data
Commits
39fd0093
Commit
39fd0093
authored
Jan 15, 2019
by
Jonathan Wilkes
Browse files
constrained resizing with vert/horiz cursors
parent
d811c6be
Changes
9
Hide whitespace changes
Inline
Side-by-side
externals/miXed/cyclone/sickle/Scope.c
View file @
39fd0093
...
...
@@ -106,9 +106,8 @@ typedef struct _scope
int
x_frozen
;
t_clock
*
x_clock
;
t_pd
*
x_handle
;
int
scale_offset_x
;
int
scale_offset_y
;
int
scale_offset_x
;
int
scale_offset_y
;
}
t_scope
;
typedef
struct
_scopehandle
...
...
@@ -118,6 +117,9 @@ typedef struct _scopehandle
t_symbol
*
h_bindsym
;
char
h_pathname
[
64
];
char
h_outlinetag
[
64
];
int
h_adjust_x
;
int
h_adjust_y
;
int
h_constrain
;
int
h_dragon
;
int
h_dragx
;
int
h_dragy
;
...
...
@@ -992,49 +994,16 @@ static void scope_tick(t_scope *x)
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;
//if (xxx) x->scale_offset_x = xxx;
//if (yyy) x->scale_offset_y = yyy;
//int newstate = (int)f;
//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;
//}
/* Use constrained dragging. See g_canvas.c clickhook */
sh->h_constrain = (int)f;
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);
canvas_apply_setundo(x->x_glist, (t_gobj *)x);
sh->h_dragon = f;
}
...
...
@@ -1042,10 +1011,13 @@ static void scopehandle__motionhook(t_scopehandle *sh,
t_floatarg mouse_x, t_floatarg mouse_y)
{
t_scope *x = (t_scope *)(sh->h_master);
int
x1
,
y1
,
x2
,
y2
,
width
,
height
;
scope_getrect
((
t_gobj
*
)
x
,
x
->
x_glist
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
width
=
mouse_x
-
x1
;
height
=
mouse_y
-
y1
;
int width = (sh->h_constrain == CURSOR_EDITMODE_RESIZE_Y) ?
x->x_width :
(int)mouse_x - text_xpix((t_text *)x, x->x_glist) - sh->h_adjust_x;
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_height = height < SCOPE_MINHEIGHT ? SCOPE_MINHEIGHT : height;
...
...
@@ -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, 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 */
...
...
@@ -1157,8 +1110,8 @@ static void *scope_new(t_symbol *s, int ac, t_atom *av)
sprintf(sh->h_outlinetag, "
h
%
x
", (int)sh);
sh->h_dragon = 0;
x
->
scale_offset_x
=
0
;
x
->
scale_offset_y
=
0
;
x->scale_offset_x = 0;
x->scale_offset_y = 0;
return (x);
}
...
...
externals/unauthorized/grid.c
View file @
39fd0093
...
...
@@ -696,39 +696,43 @@ static void grid_bang(t_grid *x) {
static
void
grid__clickhook
(
t_scalehandle
*
sh
,
int
newstate
)
{
t_grid
*
x
=
(
t_grid
*
)(
sh
->
h_master
);
if
(
newstate
)
{
canvas_apply_setundo
(
x
->
x_glist
,
(
t_gobj
*
)
x
);
}
/* Use constrained dragging-- see g_canvas.c clickhook */
sh
->
h_constrain
=
newstate
;
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
;
}
static
void
grid__motionhook
(
t_scalehandle
*
sh
,
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
);
int
width
=
mouse_x
-
text_xpix
(
&
x
->
x_obj
,
x
->
x_glist
),
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);
}
grid_draw_configure
(
x
,
x
->
x_glist
);
//scalehandle_unclick_scale(sh);
}
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
int
new_w
=
x
->
x_width
+
sh
->
h_dragx
;
int
new_h
=
x
->
x_height
+
sh
->
h_dragy
;
properties_set_field_int
(
properties
,
"width"
,
new_w
);
properties_set_field_int
(
properties
,
"height"
,
new_h
);
}
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
int
new_w
=
x
->
x_width
+
sh
->
h_dragx
;
int
new_h
=
x
->
x_height
+
sh
->
h_dragy
;
properties_set_field_int
(
properties
,
"width"
,
new_w
);
properties_set_field_int
(
properties
,
"height"
,
new_h
);
}
}
...
...
@@ -737,8 +741,9 @@ static void grid_click_for_resizing(t_grid *x, t_floatarg f,
t_floatarg
xxx
,
t_floatarg
yyy
)
{
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, xxx, yyy);
}
/* another wrapper for forwarding "scalehandle" motion data */
...
...
pd/nw/pdgui.js
View file @
39fd0093
...
...
@@ -1477,6 +1477,9 @@ function gui_canvas_cursor(cid, pd_event_type) {
case
"
cursor_scroll
"
:
c
=
"
all-scroll
"
;
break
;
case
"
cursor_editmode_resize_vert
"
:
c
=
"
ns-resize
"
;
break
;
}
patch
.
style
.
cursor
=
c
;
});
...
...
pd/src/g_all_guis.c
View file @
39fd0093
...
...
@@ -917,15 +917,15 @@ void scalehandle_drag_scale(t_scalehandle *h) {
static
void
scalehandle_clickhook
(
t_scalehandle
*
h
,
t_floatarg
f
,
t_floatarg
xxx
,
t_floatarg
yyy
)
{
h
->
h_offset_x
=
xxx
;
h
->
h_offset_y
=
yyy
;
h
->
h_clickfn
(
h
,
f
);
h
->
h_offset_x
=
xxx
;
h
->
h_offset_y
=
yyy
;
h
->
h_clickfn
(
h
,
f
);
}
static
void
scalehandle_motionhook
(
t_scalehandle
*
h
,
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
h
->
h_offset_x
=
f1
;
h
->
h_offset_y
=
f2
;
...
...
@@ -951,7 +951,8 @@ static void scalehandle_check_and_redraw(t_iemgui *x)
//----------------------------------------------------------------
// 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
);
if
(
x
->
x_selected
)
gui_vmess
(
"gui_gobj_select"
,
"xx"
,
canvas
,
x
);
...
...
@@ -959,7 +960,8 @@ void iemgui_tag_selected(t_iemgui *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
];
t_canvas
*
canvas
=
glist_getcanvas
(
x
->
x_glist
);
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)
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
];
t_canvas
*
canvas
=
glist_getcanvas
(
x
->
x_glist
);
if
(
x
->
x_selected
==
canvas
&&
x
->
x_glist
==
canvas
)
...
...
@@ -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
);
if
(
x
->
x_selected
==
canvas
&&
x
->
x_glist
==
canvas
)
{
...
...
@@ -1073,9 +1077,10 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
t_canvas
*
canvas
=
glist_getcanvas
(
x
->
x_glist
);
if
(
x
->
x_glist
!=
canvas
)
return
;
// is gop
t_class
*
c
=
pd_class
((
t_pd
*
)
x
);
if
(
c
==
my_numbox_class
&&
((
t_my_numbox
*
)
x
)
->
x_hide_frame
>
1
)
return
;
//sigh
if
(
!
(
old_sr_flags
&
4
)
&&
!
glist_isvisible
(
canvas
))
{
if
(
c
==
my_numbox_class
&&
((
t_my_numbox
*
)
x
)
->
x_hide_frame
>
1
)
return
;
//sigh
if
(
!
(
old_sr_flags
&
4
)
&&
!
glist_isvisible
(
canvas
))
{
return
;
}
if
(
c
==
my_canvas_class
)
return
;
...
...
@@ -1090,7 +1095,9 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
n
=
0
;
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);
//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
)
{
...
...
@@ -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
];
t_canvas
*
canvas
=
glist_getcanvas
(
x
->
x_glist
);
t_class
*
c
=
pd_class
((
t_pd
*
)
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_class
*
c
=
pd_class
((
t_pd
*
)
x
);
int
x1
,
y1
,
x2
,
y2
,
gr
=
gop_redraw
;
gop_redraw
=
0
;
c
->
c_wb
->
w_getrectfn
((
t_gobj
*
)
x
,
x
->
x_glist
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
int
x1
,
y1
,
x2
,
y2
,
gr
=
gop_redraw
;
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);
gop_redraw
=
gr
;
gop_redraw
=
gr
;
char
colorbuf
[
MAXPDSTRING
];
sprintf
(
colorbuf
,
"#%6.6x"
,
x
->
x_bcol
);
gui_vmess
(
"gui_gobj_new"
,
"xxsiii"
,
canvas
,
x
,
...
...
@@ -1206,7 +1216,8 @@ void iemgui_base_draw_new(t_iemgui *x) {
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_class
*
c
=
pd_class
((
t_pd
*
)
x
);
int
x1
,
y1
,
x2
,
y2
,
gr
=
gop_redraw
;
gop_redraw
=
0
;
...
...
@@ -1217,8 +1228,8 @@ void iemgui_base_draw_move(t_iemgui *x) {
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
);
char
fcol
[
8
];
sprintf
(
fcol
,
"#%6.6x"
,
x
->
x_fcol
);
char
tagbuf
[
MAXPDSTRING
];
...
...
@@ -1228,44 +1239,52 @@ void iemgui_base_draw_config(t_iemgui *x) {
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
);
}
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
);
iemgui_label_draw_new
(
x
);
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
);
iemgui_label_draw_config
(
x
);
//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
);
iemgui_label_draw_move
(
x
);
//iemgui_base_draw_move(x); // can't
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
);
gui_vmess
(
"gui_gobj_erase"
,
"xx"
,
canvas
,
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
//exceeds window size
t_canvas
*
canvas
=
(
t_canvas
*
)
glist_getcanvas
(
glist
);
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_displacefn
=
iemgui_displace
;
wb
->
w_selectfn
=
iemgui_select
;
...
...
@@ -1276,13 +1295,15 @@ void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) {
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
;
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.
...
...
@@ -1290,7 +1311,9 @@ const char *iemgui_typeface(t_iemgui *x) {
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
remove it */
const
char
*
iemgui_font
(
t_iemgui
*
x
)
{
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
;
...
...
@@ -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_class_addmethods
(
t_class
*
c
)
{
void
iemgui_class_addmethods
(
t_class
*
c
)
{
class_addmethod
(
c
,
(
t_method
)
iemgui_delta
,
gensym
(
"delta"
),
A_GIMME
,
0
);
class_addmethod
(
c
,
(
t_method
)
iemgui_pos
,
...
...
@@ -1317,7 +1341,8 @@ void iemgui_class_addmethods(t_class *c) {
gensym
(
"label_font"
),
A_GIMME
,
0
);
}
void
g_iemgui_setup
(
void
)
{
void
g_iemgui_setup
(
void
)
{
s_empty
=
gensym
(
"empty"
);
scalehandle_class
=
class_new
(
gensym
(
"_scalehandle"
),
0
,
0
,
sizeof
(
t_scalehandle
),
CLASS_PD
,
0
);
...
...
@@ -1333,16 +1358,21 @@ const char *border_color = "$pd_colors(iemgui_border)";
#define GET_OUTLET t_outlet *out = x->x_obj.ob_outlet;
/* can't use int o because there's not obj_nth_outlet function */
#define SEND_BY_SYMBOL (iemgui_has_snd(x) && x->x_snd->s_thing && (!chk_putin || x->x_put_in2out))
void
iemgui_out_bang
(
t_iemgui
*
x
,
int
o
,
int
chk_putin
)
{
void
iemgui_out_bang
(
t_iemgui
*
x
,
int
o
,
int
chk_putin
)
{
GET_OUTLET
outlet_bang
(
out
);
if
(
SEND_BY_SYMBOL
)
pd_bang
(
x
->
x_snd
->
s_thing
);
}
void
iemgui_out_float
(
t_iemgui
*
x
,
int
o
,
int
chk_putin
,
t_float
f
)
{
void
iemgui_out_float
(
t_iemgui
*
x
,
int
o
,
int
chk_putin
,
t_float
f
)
{
GET_OUTLET
outlet_float
(
out
,
f
);
if
(
SEND_BY_SYMBOL
)
pd_float
(
x
->
x_snd
->
s_thing
,
f
);
}
void
iemgui_out_list
(
t_iemgui
*
x
,
int
o
,
int
chk_putin
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
GET_OUTLET
outlet_list
(
out
,
s
,
argc
,
argv
);
if
(
SEND_BY_SYMBOL
)
pd_list
(
x
->
x_snd
->
s_thing
,
s
,
argc
,
argv
);
}
void
iemgui_out_list
(
t_iemgui
*
x
,
int
o
,
int
chk_putin
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
GET_OUTLET
outlet_list
(
out
,
s
,
argc
,
argv
);
if
(
SEND_BY_SYMBOL
)
pd_list
(
x
->
x_snd
->
s_thing
,
s
,
argc
,
argv
);
}
pd/src/g_canvas.c
View file @
39fd0093
...
...
@@ -2317,43 +2317,32 @@ void canvasgop_checksize(t_canvas *x)
}
}
extern
int
glob_shift
;
void
canvasgop__clickhook
(
t_scalehandle
*
sh
,
int
newstate
)
{
post
(
"clickhook"
);
t_canvas
*
x
=
(
t_canvas
*
)(
sh
->
h_master
);
if
(
!
glob_shift
)
post
(
"note: use <shift-click> to constrain dragging"
);
/* Set constrain to zero. Then when the motion starts in
canvasgop__motionhook, we'll check to see what is the
first direction that the pointer moves. If the shift key
is depressed at that time then constrained dragging will
be constrained to that first direction. */
sh
->
h_constrain
=
0
;
/* We're using newstate as a sentinel value to figure out whether we
are clicking a red gop rectangle = 1, or whether we are clicking the
bottom right-hand corner of a gop object on the parent = 2.
When h_scale is not zero, we know we can check for our sentinel value.
(Otherwise the click is for moving the gop red rect.) */
if
(
sh
->
h_scale
)
sh
->
h_scale
=
newstate
;
/* So ugly: if the user is dragging the bottom right-hand corner of
a gop subcanvas on the parent, we already set an undo event for it.
So we only add one here if we're dragging the gop red rectangle. */
if
(
sh
->
h_scale
!=
2
)
/* moving/resizing a red gop rect */
canvas_undo_add
(
x
,
8
,
"apply"
,
canvas_undo_set_canvas
(
x
));
/* Now set constrain to newstate, which is one of:
CURSOR_EDITMODE_RESIZE_X - horizontal resizing
CURSOR_EDITMODE_RESIZE_Y - vertical resizing
CURSOR_EDITMODE_RESIZE - free resizing */
sh
->
h_constrain
=
newstate
;
if
(
sh
->
h_scale
==
1
)
/* resize gop hook for (red) gop rect */
/* We're abusing h_scale to differentiate between clicking gop red
rectangle and clicking the corner of a subcanvas on the parent */
if
(
sh
->
h_scale
==
1
)
/* clicking corner of gop subcanvas on parent */
{
/* This is for clicking on the bottom right-hand corner of the
gop canvas when it's displayed on the parent canvas. */
sh
->
h_adjust_x
=
sh
->
h_offset_x
-
(((
t_object
*
)
x
)
->
te_xpix
+
x
->
gl_pixwidth
);
sh
->
h_adjust_y
=
sh
->
h_offset_y
-
(((
t_object
*
)
x
)
->
te_ypix
+
x
->
gl_pixheight
);
}
else
if
(
sh
->
h_scale
==
2
)
/* resize gop hook for (red) gop rect */
{
/*
This is for resizing the gop by clicking the (red) gop rectangle
that shows up when gop is enabled on a canvas. We u
se a
sentinel
value of "1" to differentiate between click
ing
on
the gop
canvas
itself. */
/*
So ugly: if the user is dragging the bottom right-hand corner of
a gop subcanvas on the parent, we already
se
t
a
n undo event for it.
So we only add one here for dragg
ing the gop
red rectangle. */
canvas_undo_add
(
x
,
8
,
"apply"
,
canvas_undo_set_canvas
(
x
));
/* Store an adjustment for difference between the initial
pointer position-- which is within five pixels or so-- and the
bottom right-hand corner. Otherwise we'd get a "jump" from the
...
...
@@ -2371,18 +2360,6 @@ post("clickhook");
just move the scalehandle stuff directly to the GUI... */
//sys_vgui("lower %s\n", sh->h_pathname);
}
// combine these two if there's no difference in the code
else
if
(
sh
->
h_scale
==
2
)
{
/* This is for clicking on the bottom right-hand corner of the
gop canvas when it's displayed on the parent canvas. */
sh
->
h_adjust_x
=
sh
->
h_offset_x
-
(((
t_object
*
)
x
)
->
te_xpix
+
x
->
gl_pixwidth
);
sh
->
h_adjust_y
=
sh
->
h_offset_y
-
(((
t_object
*
)
x
)
->
te_ypix
+
x
->
gl_pixheight
);
post
(
"adjust x is %d"
,
sh
->
h_adjust_x
);
post
(
"adjust y is %d"
,
sh
->
h_adjust_y
);
}
else
/* move_gop hook */
{
/* Same as above... */
...
...
@@ -2390,9 +2367,6 @@ post("adjust y is %d", sh->h_adjust_y);
}
}
#define HORIZ 1
#define VERT -1
void
canvasgop__motionhook
(
t_scalehandle
*
sh
,
t_floatarg
mouse_x
,
t_floatarg
mouse_y
)
{
...
...
@@ -2400,38 +2374,7 @@ void canvasgop__motionhook(t_scalehandle *sh, t_floatarg mouse_x,
int
dx
=
(
int
)
mouse_x
-
sh
->
h_offset_x
,
dy
=
(
int
)
mouse_y
-
sh
->
h_offset_y
;
if
(
glob_shift
&&
!
sh
->
h_constrain
)
{
if
(
dx
)
sh
->
h_constrain
=
HORIZ
;
/* only move/resize horizontally */
else
if
(
dy
)
sh
->
h_constrain
=
VERT
;
/* vertically */
}
if
(
sh
->
h_scale
==
1
)
/* resize_gop red rect hook */
{
int
width
=
(
sh
->
h_constrain
==
VERT
)
?
x
->
gl_pixwidth
:
(
int
)
mouse_x
-
x
->
gl_xmargin
-
sh
->
h_adjust_x
;
int
height
=
(
sh
->
h_constrain
==
HORIZ
)
?
x
->
gl_pixheight
:
(
int
)
mouse_y
-
x
->
gl_ymargin
-
sh
->
h_adjust_y
;
x
->
gl_pixwidth
=
width
=
maxi
(
SCALE_GOP_MINWIDTH
,
width
);
x
->
gl_pixheight
=
height
=
maxi
(
SCALE_GOP_MINHEIGHT
,
height
);
gui_vmess
(
"gui_canvas_redrect_coords"
,
"xiiii"
,
x
,
x
->
gl_xmargin
,
x
->
gl_ymargin
,
x
->
gl_xmargin
+
width
,
x
->
gl_ymargin
+
height
);
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
properties_set_field_int
(
properties
,
"x_pix"
,
x
->
gl_pixwidth
+
sh
->
h_dragx
);