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
2dff3561
Commit
2dff3561
authored
Aug 06, 2014
by
Mathieu L Bouchard
Browse files
4th refactor of scalehandle
parent
7f7328df
Changes
12
Hide whitespace changes
Inline
Side-by-side
pd/src/g_all_guis.c
View file @
2dff3561
...
...
@@ -13,6 +13,7 @@
#include <ctype.h>
#include "m_pd.h"
#include "g_canvas.h"
#include "m_imp.h"
#include "t_tk.h"
#include "g_all_guis.h"
#include <math.h>
...
...
@@ -895,6 +896,11 @@ char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj)
//----------------------------------------------------------------
// SCALEHANDLE COMMON CODE
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
;}
// in all 20 cases :
// [bng], [tgl], [hradio], [vradio], [hsl], [vsl], [cnv], [nbx], [vu]
// for both scale & label, plus canvas' scale & move.
...
...
@@ -944,6 +950,15 @@ const char *nlet_tag, const char *class_tag) {
h
->
h_vis
=
1
;
}
void
scalehandle_draw_select2
(
t_iemgui
*
x
,
t_glist
*
canvas
,
const
char
*
class_tag
)
{
char
*
nlet_tag
=
iem_get_tag
(
canvas
,
(
t_iemgui
*
)
x
);
scalehandle_draw_select
(
x
->
x_handle
,
canvas
,
x
->
x_w
-
1
,
x
->
x_h
-
1
,
nlet_tag
,
class_tag
);
if
(
strcmp
(
x
->
x_lab
->
s_name
,
"empty"
)
!=
0
)
{
scalehandle_draw_select
(
x
->
x_lhandle
,
canvas
,
x
->
x_ldx
,
x
->
x_ldy
,
nlet_tag
,
class_tag
);
}
}
void
scalehandle_draw_erase
(
t_scalehandle
*
h
,
t_glist
*
canvas
)
{
sys_vgui
(
"destroy %s
\n
"
,
h
->
h_pathname
);
sys_vgui
(
".x%lx.c delete %lx%s
\n
"
,
canvas
,
h
->
h_master
,
h
->
h_scale
?
"SCALE"
:
"LABELH"
);
...
...
@@ -970,8 +985,8 @@ t_scalehandle *scalehandle_new(t_class *c, t_iemgui *x, int scale) {
sprintf
(
h
->
h_outlinetag
,
"h%lx"
,
(
t_int
)
h
);
h
->
h_dragon
=
0
;
h
->
h_scale
=
scale
;
h
->
h_offset_x
=
0
;
h
->
h_offset_y
=
0
;
//
h->h_offset_x = 0;
// unused (maybe keep for later)
//
h->h_offset_y = 0;
// unused (maybe keep for later)
h
->
h_vis
=
0
;
return
h
;
}
...
...
@@ -996,8 +1011,8 @@ void scalehandle_dragon_label(t_scalehandle *h, float f1, float f2) {
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
int
new_x
=
x
->
x_ldx
-
h
->
h_offset_x
+
h
->
h_dragx
;
int
new_y
=
x
->
x_ldy
-
h
->
h_offset_y
+
h
->
h_dragy
;
int
new_x
=
x
->
x_ldx
+
h
->
h_dragx
;
int
new_y
=
x
->
x_ldy
+
h
->
h_dragy
;
properties_set_field_int
(
properties
,
"label.xy.x_entry"
,
new_x
);
properties_set_field_int
(
properties
,
"label.xy.y_entry"
,
new_y
);
}
...
...
@@ -1006,10 +1021,84 @@ void scalehandle_dragon_label(t_scalehandle *h, float f1, float f2) {
int
xpos
=
text_xpix
(
&
x
->
x_obj
,
x
->
x_glist
);
int
ypos
=
text_ypix
(
&
x
->
x_obj
,
x
->
x_glist
);
t_canvas
*
canvas
=
glist_getcanvas
(
x
->
x_glist
);
sys_vgui
(
".x%lx.c coords %lxLABEL %d %d
\n
"
,
canvas
,
x
,
xpos
+
x
->
x_ldx
+
h
->
h_dragx
-
h
->
h_offset_x
,
ypos
+
x
->
x_ldy
+
h
->
h_dragy
-
h
->
h_offset_y
);
sys_vgui
(
".x%lx.c coords %lxLABEL %d %d
\n
"
,
canvas
,
x
,
xpos
+
x
->
x_ldx
+
h
->
h_dragx
,
ypos
+
x
->
x_ldy
+
h
->
h_dragy
);
}
}
}
void
scalehandle_unclick_label
(
t_scalehandle
*
h
)
{
t_iemgui
*
x
=
(
t_iemgui
*
)
h
->
h_master
;
canvas_apply_setundo
(
x
->
x_glist
,
(
t_gobj
*
)
x
);
if
(
h
->
h_dragx
||
h
->
h_dragy
)
{
x
->
x_ldx
+=
h
->
h_dragx
;
x
->
x_ldy
+=
h
->
h_dragy
;
canvas_dirty
(
x
->
x_glist
,
1
);
}
if
(
glist_isvisible
(
x
->
x_glist
))
{
iemgui_select
((
t_gobj
*
)
x
,
x
->
x_glist
,
1
);
canvas_fixlinesfor
(
x
->
x_glist
,
(
t_text
*
)
x
);
sys_vgui
(
"pdtk_canvas_getscroll .x%lx.c
\n
"
,
x
->
x_glist
);
}
}
void
scalehandle_click_label
(
t_scalehandle
*
h
)
{
t_iemgui
*
x
=
(
t_iemgui
*
)
h
->
h_master
;
if
(
glist_isvisible
(
x
->
x_glist
))
{
sys_vgui
(
"lower %s
\n
"
,
h
->
h_pathname
);
t_scalehandle
*
othersh
=
x
->
x_handle
;
sys_vgui
(
"lower .x%lx.h%lx
\n
"
,
(
t_int
)
glist_getcanvas
(
x
->
x_glist
),
(
t_int
)
othersh
);
}
h
->
h_dragx
=
0
;
h
->
h_dragy
=
0
;
}
extern
t_class
*
my_canvas_class
;
void
scalehandle_getrect_master
(
t_scalehandle
*
h
,
int
*
x1
,
int
*
y1
,
int
*
x2
,
int
*
y2
)
{
t_iemgui
*
x
=
(
t_iemgui
*
)
h
->
h_master
;
t_class
*
c
=
pd_class
((
t_pd
*
)
x
);
c
->
c_wb
->
w_getrectfn
((
t_gobj
*
)
x
,
x
->
x_glist
,
x1
,
y1
,
x2
,
y2
);
//printf("%s\n",c->c_name->s_name);
if
(
c
==
my_canvas_class
)
{
t_my_canvas
*
xx
=
(
t_my_canvas
*
)
x
;
*
x2
=*
x1
+
xx
->
x_vis_w
;
*
y2
=*
y1
+
xx
->
x_vis_h
;
}
}
void
scalehandle_click_scale
(
t_scalehandle
*
h
)
{
int
x1
,
y1
,
x2
,
y2
;
t_iemgui
*
x
=
(
t_iemgui
*
)
h
->
h_master
;
scalehandle_getrect_master
(
h
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
if
(
glist_isvisible
(
x
->
x_glist
))
{
sys_vgui
(
"lower %s
\n
"
,
h
->
h_pathname
);
sys_vgui
(
".x%x.c create prect %d %d %d %d -stroke $pd_colors(selection) -strokewidth 1 -tags %s
\n
"
,
x
->
x_glist
,
x1
,
y1
,
x2
,
y2
,
h
->
h_outlinetag
);
}
h
->
h_dragx
=
0
;
h
->
h_dragy
=
0
;
}
void
scalehandle_unclick_scale
(
t_scalehandle
*
h
)
{
t_iemgui
*
x
=
(
t_iemgui
*
)
h
->
h_master
;
sys_vgui
(
".x%x.c delete %s
\n
"
,
x
->
x_glist
,
h
->
h_outlinetag
);
iemgui_select
((
t_gobj
*
)
x
,
x
->
x_glist
,
1
);
canvas_fixlinesfor
(
x
->
x_glist
,
(
t_text
*
)
x
);
sys_vgui
(
"pdtk_canvas_getscroll .x%lx.c
\n
"
,
x
->
x_glist
);
}
void
scalehandle_drag_scale
(
t_scalehandle
*
h
)
{
int
x1
,
y1
,
x2
,
y2
;
t_iemgui
*
x
=
(
t_iemgui
*
)
h
->
h_master
;
scalehandle_getrect_master
(
h
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
if
(
glist_isvisible
(
x
->
x_glist
))
{
sys_vgui
(
".x%x.c coords %s %d %d %d %d
\n
"
,
x
->
x_glist
,
h
->
h_outlinetag
,
x1
,
y1
,
x2
+
h
->
h_dragx
,
y2
+
h
->
h_dragy
);
}
}
pd/src/g_all_guis.h
View file @
2dff3561
...
...
@@ -405,6 +405,7 @@ EXTERN void canvas_apply_setundo(t_canvas *x, t_gobj *y);
// scalehandle code, as refactored by Mathieu
EXTERN
void
scalehandle_bind
(
t_scalehandle
*
h
);
EXTERN
void
scalehandle_draw_select
(
t_scalehandle
*
h
,
t_glist
*
canvas
,
int
px
,
int
py
,
const
char
*
nlet_tag
,
const
char
*
class_tag
);
EXTERN
void
scalehandle_draw_select2
(
t_iemgui
*
x
,
t_glist
*
canvas
,
const
char
*
class_tag
);
EXTERN
void
scalehandle_draw_erase
(
t_scalehandle
*
h
,
t_glist
*
canvas
);
EXTERN
void
scalehandle_draw_erase2
(
t_iemgui
*
x
,
t_glist
*
canvas
);
EXTERN
void
scalehandle_draw_new
(
t_scalehandle
*
x
,
t_glist
*
canvas
);
...
...
@@ -412,3 +413,12 @@ EXTERN t_scalehandle *scalehandle_new(t_class *c, t_iemgui *x, int scale);
EXTERN
void
scalehandle_free
(
t_scalehandle
*
h
);
EXTERN
void
properties_set_field_int
(
long
props
,
const
char
*
gui_field
,
int
value
);
EXTERN
void
scalehandle_dragon_label
(
t_scalehandle
*
h
,
float
f1
,
float
f2
);
EXTERN
void
scalehandle_unclick_label
(
t_scalehandle
*
h
);
EXTERN
void
scalehandle_click_label
(
t_scalehandle
*
h
);
EXTERN
void
scalehandle_click_scale
(
t_scalehandle
*
h
);
EXTERN
void
scalehandle_unclick_scale
(
t_scalehandle
*
h
);
EXTERN
void
scalehandle_drag_scale
(
t_scalehandle
*
h
);
EXTERN
int
mini
(
int
a
,
int
b
);
EXTERN
int
maxi
(
int
a
,
int
b
);
pd/src/g_bang.c
View file @
2dff3561
...
...
@@ -224,32 +224,20 @@ void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
void
bng_draw_select
(
t_bng
*
x
,
t_glist
*
glist
)
{
t_canvas
*
canvas
=
glist_getcanvas
(
glist
);
t_scalehandle
*
sh
=
(
t_scalehandle
*
)(
x
->
x_gui
.
x_handle
);
t_scalehandle
*
lh
=
(
t_scalehandle
*
)(
x
->
x_gui
.
x_lhandle
);
//if (glist_isvisible(canvas)) {
if
(
x
->
x_gui
.
x_fsf
.
x_selected
)
{
/* check if we are drawing inside a gop abstraction visible
on parent canvas -- if so, disable highlighting */
if
(
x
->
x_gui
.
x_glist
==
glist_getcanvas
(
glist
))
{
char
*
nlet_tag
=
iem_get_tag
(
glist
,
(
t_iemgui
*
)
x
);
sys_vgui
(
".x%lx.c itemconfigure %lxBASE "
"-stroke $pd_colors(selection)
\n
"
,
canvas
,
x
);
sys_vgui
(
".x%lx.c itemconfigure %lxBUT "
"-stroke $pd_colors(selection)
\n
"
,
canvas
,
x
);
sys_vgui
(
".x%lx.c itemconfigure %lxLABEL "
"-fill $pd_colors(selection)
\n
"
,
canvas
,
x
);
scalehandle_draw_select
(
sh
,
canvas
,
x
->
x_gui
.
x_w
-
1
,
x
->
x_gui
.
x_h
-
1
,
nlet_tag
,
"BNG"
);
if
(
strcmp
(
x
->
x_gui
.
x_lab
->
s_name
,
"empty"
)
!=
0
)
{
scalehandle_draw_select
(
lh
,
canvas
,
x
->
x_gui
.
x_ldx
,
x
->
x_gui
.
x_ldy
,
nlet_tag
,
"BNG"
);
}
scalehandle_draw_select2
(
&
x
->
x_gui
,
glist
,
"BNG"
);
}
sys_vgui
(
".x%lx.c addtag selected withtag %lxBNG
\n
"
,
canvas
,
x
);
}
...
...
@@ -270,120 +258,34 @@ void bng_draw_select(t_bng* x, t_glist* glist)
static
void
bng__clickhook
(
t_scalehandle
*
sh
,
t_floatarg
f
,
t_floatarg
xxx
,
t_floatarg
yyy
)
{
t_bng
*
x
=
(
t_bng
*
)(
sh
->
h_master
);
if
(
xxx
)
{
sh
->
h_offset_x
=
xxx
;
}
if
(
yyy
)
{
sh
->
h_offset_y
=
yyy
;
}
int
newstate
=
(
int
)
f
;
if
(
sh
->
h_dragon
&&
newstate
==
0
&&
sh
->
h_scale
)
{
/* done dragging */
/* first set up the undo apply */
canvas_apply_setundo
(
x
->
x_gui
.
x_glist
,
(
t_gobj
*
)
x
);
if
(
sh
->
h_dragx
||
sh
->
h_dragy
)
{
if
(
sh
->
h_dragx
>
sh
->
h_dragy
)
sh
->
h_dragx
=
sh
->
h_dragy
;
else
sh
->
h_dragy
=
sh
->
h_dragx
;
x
->
x_gui
.
x_w
=
x
->
x_gui
.
x_w
+
sh
->
h_dragx
-
sh
->
h_offset_x
;
if
(
x
->
x_gui
.
x_w
<
SCALE_BNG_MINWIDTH
)
x
->
x_gui
.
x_w
=
SCALE_BNG_MINWIDTH
;
x
->
x_gui
.
x_h
=
x
->
x_gui
.
x_h
+
sh
->
h_dragy
-
sh
->
h_offset_y
;
if
(
x
->
x_gui
.
x_h
<
SCALE_BNG_MINHEIGHT
)
x
->
x_gui
.
x_h
=
SCALE_BNG_MINHEIGHT
;
x
->
x_gui
.
x_w
+=
sh
->
h_dragx
;
x
->
x_gui
.
x_h
+=
sh
->
h_dragy
;
canvas_dirty
(
x
->
x_gui
.
x_glist
,
1
);
}
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
properties_set_field_int
(
properties
,
"dim.w_ent"
,
x
->
x_gui
.
x_w
);
}
if
(
glist_isvisible
(
x
->
x_gui
.
x_glist
))
{
sys_vgui
(
".x%x.c delete %s
\n
"
,
x
->
x_gui
.
x_glist
,
sh
->
h_outlinetag
);
bng_draw_move
(
x
,
x
->
x_gui
.
x_glist
);
iemgui_select
((
t_gobj
*
)
x
,
x
->
x_gui
.
x_glist
,
1
);
canvas_fixlinesfor
(
x
->
x_gui
.
x_glist
,
(
t_text
*
)
x
);
sys_vgui
(
"pdtk_canvas_getscroll .x%lx.c
\n
"
,
x
->
x_gui
.
x_glist
);
scalehandle_unclick_scale
(
sh
);
}
}
else
if
(
!
sh
->
h_dragon
&&
newstate
&&
sh
->
h_scale
)
{
/* dragging */
if
(
glist_isvisible
(
x
->
x_gui
.
x_glist
))
{
sys_vgui
(
"lower %s
\n
"
,
sh
->
h_pathname
);
sys_vgui
(
".x%x.c create prect %d %d %d %d\
-stroke $pd_colors(selection) -strokewidth 1 -tags %s
\n
"
,
x
->
x_gui
.
x_glist
,
x
->
x_gui
.
x_obj
.
te_xpix
,
x
->
x_gui
.
x_obj
.
te_ypix
,
x
->
x_gui
.
x_obj
.
te_xpix
+
x
->
x_gui
.
x_w
,
x
->
x_gui
.
x_obj
.
te_ypix
+
x
->
x_gui
.
x_h
,
sh
->
h_outlinetag
);
}
sh
->
h_dragx
=
0
;
sh
->
h_dragy
=
0
;
scalehandle_click_scale
(
sh
);
}
else
if
(
sh
->
h_dragon
&&
newstate
==
0
&&
!
sh
->
h_scale
)
{
/* done dragging */
/* first set up the undo apply */
canvas_apply_setundo
(
x
->
x_gui
.
x_glist
,
(
t_gobj
*
)
x
);
if
(
sh
->
h_dragx
||
sh
->
h_dragy
)
{
x
->
x_gui
.
x_ldx
=
x
->
x_gui
.
x_ldx
+
sh
->
h_dragx
-
sh
->
h_offset_x
;
x
->
x_gui
.
x_ldy
=
x
->
x_gui
.
x_ldy
+
sh
->
h_dragy
-
sh
->
h_offset_y
;
canvas_dirty
(
x
->
x_gui
.
x_glist
,
1
);
}
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
properties_set_field_int
(
properties
,
"dim.w_ent"
,
x
->
x_gui
.
x_w
);
}
if
(
glist_isvisible
(
x
->
x_gui
.
x_glist
))
{
sys_vgui
(
".x%x.c delete %s
\n
"
,
x
->
x_gui
.
x_glist
,
sh
->
h_outlinetag
);
bng_draw_move
(
x
,
x
->
x_gui
.
x_glist
);
iemgui_select
((
t_gobj
*
)
x
,
x
->
x_gui
.
x_glist
,
1
);
canvas_fixlinesfor
(
x
->
x_gui
.
x_glist
,
(
t_text
*
)
x
);
sys_vgui
(
"pdtk_canvas_getscroll .x%lx.c
\n
"
,
x
->
x_gui
.
x_glist
);
}
scalehandle_unclick_label
(
sh
);
}
else
if
(
!
sh
->
h_dragon
&&
newstate
&&
!
sh
->
h_scale
)
{
/* dragging */
if
(
glist_isvisible
(
x
->
x_gui
.
x_glist
))
{
sys_vgui
(
"lower %s
\n
"
,
sh
->
h_pathname
);
t_scalehandle
*
othersh
=
x
->
x_gui
.
x_handle
;
sys_vgui
(
"lower .x%lx.h%lx
\n
"
,
(
t_int
)
glist_getcanvas
(
x
->
x_gui
.
x_glist
),
(
t_int
)
othersh
);
}
sh
->
h_dragx
=
0
;
sh
->
h_dragy
=
0
;
scalehandle_click_label
(
sh
);
}
sh
->
h_dragon
=
newstate
;
}
...
...
@@ -394,44 +296,16 @@ static void bng__motionhook(t_scalehandle *sh,
if
(
sh
->
h_dragon
&&
sh
->
h_scale
)
{
t_bng
*
x
=
(
t_bng
*
)(
sh
->
h_master
);
int
dx
=
(
int
)
f1
,
dy
=
(
int
)
f2
;
int
newx
,
newy
;
if
(
dx
>
dy
)
{
dx
=
dy
;
sh
->
h_offset_x
=
sh
->
h_offset_y
;
}
else
{
dy
=
dx
;
sh
->
h_offset_y
=
sh
->
h_offset_x
;
}
newx
=
x
->
x_gui
.
x_obj
.
te_xpix
+
x
->
x_gui
.
x_w
-
sh
->
h_offset_x
+
dx
;
newy
=
x
->
x_gui
.
x_obj
.
te_ypix
+
x
->
x_gui
.
x_h
-
sh
->
h_offset_y
+
dy
;
if
(
newx
<
x
->
x_gui
.
x_obj
.
te_xpix
+
SCALE_BNG_MINWIDTH
)
newx
=
x
->
x_gui
.
x_obj
.
te_xpix
+
SCALE_BNG_MINWIDTH
;
if
(
newy
<
x
->
x_gui
.
x_obj
.
te_ypix
+
SCALE_BNG_MINHEIGHT
)
newy
=
x
->
x_gui
.
x_obj
.
te_ypix
+
SCALE_BNG_MINHEIGHT
;
if
(
glist_isvisible
(
x
->
x_gui
.
x_glist
))
{
sys_vgui
(
".x%x.c coords %s %d %d %d %d
\n
"
,
x
->
x_gui
.
x_glist
,
sh
->
h_outlinetag
,
x
->
x_gui
.
x_obj
.
te_xpix
,
x
->
x_gui
.
x_obj
.
te_ypix
,
newx
,
newy
);
}
sh
->
h_dragx
=
dx
;
sh
->
h_dragy
=
dy
;
int
d
=
maxi
((
int
)
f1
,(
int
)
f2
);
d
=
maxi
(
d
,
IEM_GUI_MINSIZE
-
x
->
x_gui
.
x_w
);
sh
->
h_dragx
=
d
;
sh
->
h_dragy
=
d
;
scalehandle_drag_scale
(
sh
);
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
int
new_w
=
x
->
x_gui
.
x_w
-
sh
->
h_offset_x
+
sh
->
h_dragx
;
int
new_w
=
x
->
x_gui
.
x_w
+
sh
->
h_dragx
;
properties_set_field_int
(
properties
,
"dim.w_ent"
,
new_w
);
}
}
...
...
pd/src/g_canvas.c
View file @
2dff3561
...
...
@@ -730,15 +730,11 @@ void canvas_drawredrect(t_canvas *x, int doit)
{
if
(
doit
)
{
//fprintf(stderr,"GOP %d %d\n", x->gl_pixwidth, x->gl_pixheight);
int
x1
=
x
->
gl_xmargin
,
y1
=
x
->
gl_ymargin
;
int
x2
=
x1
+
x
->
gl_pixwidth
,
y2
=
y1
+
x
->
gl_pixheight
;
sys_vgui
(
".x%lx.c create line\
%d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP
\n
"
,
glist_getcanvas
(
x
),
x
->
gl_xmargin
,
x
->
gl_ymargin
,
x
->
gl_xmargin
+
x
->
gl_pixwidth
,
x
->
gl_ymargin
,
x
->
gl_xmargin
+
x
->
gl_pixwidth
,
x
->
gl_ymargin
+
x
->
gl_pixheight
,
x
->
gl_xmargin
,
x
->
gl_ymargin
+
x
->
gl_pixheight
,
x
->
gl_xmargin
,
x
->
gl_ymargin
);
glist_getcanvas
(
x
),
x1
,
y1
,
x2
,
y1
,
x2
,
y2
,
x1
,
y2
,
x1
,
y1
);
//dpsaha@vt.edu for drawing the GOP_blobs
if
(
x
->
gl_goprect
&&
x
->
gl_edit
)
canvas_draw_gop_resize_hooks
(
x
);
...
...
@@ -756,10 +752,6 @@ void canvas_map(t_canvas *x, t_floatarg f)
t_gobj
*
y
;
if
(
flag
)
{
//fprintf(stderr,"canvas_map 1\n");
//if (!glist_isvisible(x))
//{
//fprintf(stderr,"canvas_map 1 isvisible\n");
t_selection
*
sel
;
if
(
!
x
->
gl_havewindow
)
{
...
...
@@ -1896,8 +1888,6 @@ void canvasgop_draw_move(t_canvas *x, int doit)
{
canvas_redraw
(
x
);
}
//fprintf(stderr,"%d %d\n", (x->gl_owner ? 1:0),
// glist_isvisible(x->gl_owner));
if
(
x
->
gl_owner
&&
glist_isvisible
(
x
->
gl_owner
))
{
...
...
@@ -1929,13 +1919,8 @@ extern void graph_checkgop_rect(t_gobj *z, t_glist *glist,
void
canvasgop__clickhook
(
t_scalehandle
*
sh
,
t_floatarg
f
,
t_floatarg
xxx
,
t_floatarg
yyy
)
{
int
x1
=
0
,
y1
=
0
,
x2
=
0
,
y2
=
0
;
//for getrect
t_canvas
*
x
=
(
t_canvas
*
)(
sh
->
h_master
);
if
(
xxx
)
sh
->
h_offset_x
=
xxx
;
if
(
yyy
)
sh
->
h_offset_y
=
yyy
;
int
newstate
=
(
int
)
f
;
if
(
sh
->
h_dragon
&&
newstate
==
0
)
{
...
...
@@ -1948,39 +1933,30 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
if
(
sh
->
h_dragx
||
sh
->
h_dragy
)
{
x
->
gl_pixwidth
=
x
->
gl_pixwidth
+
sh
->
h_dragx
-
sh
->
h_offset_x
;
if
(
x
->
gl_pixwidth
<
SCALE_GOP_MINWIDTH
)
x
->
gl_pixwidth
=
SCALE_GOP_MINWIDTH
;
x
->
gl_pixheight
=
x
->
gl_pixheight
+
sh
->
h_dragy
-
sh
->
h_offset_y
;
if
(
x
->
gl_pixheight
<
SCALE_GOP_MINHEIGHT
)
x
->
gl_pixheight
=
SCALE_GOP_MINHEIGHT
;
// check if the text is not hidden
// if so make minimum width and height based retrieved
// from getrect
x
->
gl_pixwidth
+=
sh
->
h_dragx
;
x
->
gl_pixheight
+=
sh
->
h_dragy
;
// check if the text is not hidden. if so, make minimum
// width and height based retrieved from getrect.
if
(
!
x
->
gl_hidetext
)
{
int
x1
=
0
,
y1
=
0
,
x2
=
0
,
y2
=
0
;
if
(
x
->
gl_owner
)
{
gobj_getrect
((
t_gobj
*
)
x
,
x
->
gl_owner
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
if
(
x2
-
x1
>
x
->
gl_pixwidth
)
x
->
gl_pixwidth
=
x2
-
x1
;
if
(
y2
-
y1
>
x
->
gl_pixheight
)
x
->
gl_pixheight
=
y2
-
y1
;
}
else
{
graph_checkgop_rect
((
t_gobj
*
)
x
,
x
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
if
(
x2
-
x1
>
x
->
gl_pixwidth
)
x
->
gl_pixwidth
=
x2
-
x1
;
if
(
y2
-
y1
>
x
->
gl_pixheight
)
x
->
gl_pixheight
=
y2
-
y1
;
}
if
(
x2
-
x1
>
x
->
gl_pixwidth
)
x
->
gl_pixwidth
=
x2
-
x1
;
if
(
y2
-
y1
>
x
->
gl_pixheight
)
x
->
gl_pixheight
=
y2
-
y1
;
}
canvas_dirty
(
x
,
1
);
}
// can't remove this update because the text size check above is not in motionhook
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
properties_set_field_int
(
properties
,
"n.canvasdialog.x.f2.entry3"
,
x
->
gl_pixwidth
);
...
...
@@ -1996,24 +1972,14 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
}
}
else
//enter if move_gop hook
{
/* first set up the undo apply */
//canvas_canvas_setundo(x);
{
// this block is similar to scalehandle_unclick_label but not enough
canvas_undo_add
(
x
,
8
,
"apply"
,
canvas_undo_set_canvas
(
x
));
if
(
sh
->
h_dragx
||
sh
->
h_dragy
)
{
x
->
gl_xmargin
=
x
->
gl_xmargin
+
sh
->
h_dragx
-
sh
->
h_offset_
x
;
x
->
gl_ymargin
=
x
->
gl_ymargin
+
sh
->
h_dragy
-
sh
->
h_offset_
y
;
x
->
gl_xmargin
+=
sh
->
h_drag
x
;
x
->
gl_ymargin
+=
sh
->
h_drag
y
;
canvas_dirty
(
x
,
1
);
}
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
properties_set_field_int
(
properties
,
"n.canvasdialog.x.f2.entry4"
,
x
->
gl_xmargin
);
properties_set_field_int
(
properties
,
"n.canvasdialog.y.f2.entry4"
,
x
->
gl_ymargin
);
}
if
(
glist_isvisible
(
x
))
{
canvasgop_draw_move
(
x
,
1
);
...
...
@@ -2028,15 +1994,12 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
{
sys_vgui
(
"lower %s
\n
"
,
sh
->
h_pathname
);
//delete GOP rect where it started from
sys_vgui
(
".x%lx.c delete GOP
\n
"
,
x
);
sys_vgui
(
".x%lx.c delete GOP
\n
"
,
x
);
sys_vgui
(
".x%x.c create rectangle %d %d %d %d\
-outline $pd_colors(selection) -width 1 -tags %s
\n
"
,
\
x
,
x
->
gl_xmargin
,
x
->
gl_ymargin
,
\
x
->
gl_xmargin
+
x
->
gl_pixwidth
,
\
-outline $pd_colors(selection) -width 1 -tags %s
\n
"
,
x
,
x
->
gl_xmargin
,
x
->
gl_ymargin
,
x
->
gl_xmargin
+
x
->
gl_pixwidth
,
x
->
gl_ymargin
+
x
->
gl_pixheight
,
sh
->
h_outlinetag
);
sh
->
h_dragx
=
0
;
sh
->
h_dragy
=
0
;
}
else
//enter if move_gop hook
{
...
...
@@ -2044,10 +2007,9 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
sys_vgui
(
"lower %s
\n
"
,
sh
->
h_pathname
);
//delete GOP_resblob when moving the whole GOP
sys_vgui
(
".x%lx.c delete GOP_resblob
\n
"
,
x
);
sh
->
h_dragx
=
0
;
sh
->
h_dragy
=
0
;
}
sh
->
h_dragx
=
0
;
sh
->
h_dragy
=
0
;
}
sh
->
h_dragon
=
newstate
;
}
...
...
@@ -2061,41 +2023,47 @@ void canvasgop__motionhook(t_scalehandle *sh,t_floatarg f1, t_floatarg f2)
if
(
sh
->
h_dragon
)
{
if
(
sh
->
h_scale
)
//enter if resize_gop hook
{
newx
=
x
->
gl_xmargin
+
x
->
gl_pixwidth
-
sh
->
h_offset_x
+
dx
;
newy
=
x
->
gl_ymargin
+
x
->
gl_pixheight
-
sh
->
h_offset_y
+
dy
;
if
(
newx
<
x
->
gl_xmargin
+
SCALE_GOP_MINWIDTH
)
newx
=
x
->
gl_xmargin
+
SCALE_GOP_MINWIDTH
;
if
(
newy
<
x
->
gl_ymargin
+
SCALE_GOP_MINHEIGHT
)
newy
=
x
->
gl_ymargin
+
SCALE_GOP_MINHEIGHT
;
{
int
sx
=
maxi
(
SCALE_GOP_MINWIDTH
,
x
->
gl_pixwidth
+
dx
);
int
sy
=
maxi
(
SCALE_GOP_MINHEIGHT
,
x
->
gl_pixheight
+
dy
);
//int x1=0, y1=0, x2=0, y2=0;
// if text is not hidden, use it as min height & width.
/*if (!x->gl_hidetext)
{
if (x->gl_owner)
gobj_getrect((t_gobj*)x, x->gl_owner, &x1, &y1, &x2, &y2);
else
graph_checkgop_rect((t_gobj*)x, x, &x1, &y1, &x2, &y2);
sx = maxi(sx,x2-x1);
sy = maxi(sy,y2-y1);
}*/
// does not work, needs a gobj_getrect that does not use pixwidth & pixheight
newx
=
x
->
gl_xmargin
+
sx
;
newy
=
x
->
gl_ymargin
+
sy
;
sys_vgui
(
".x%x.c coords %s %d %d %d %d
\n
"
,
x
,
sh
->
h_outlinetag
,
x
->
gl_xmargin
,
x
->
gl_ymargin
,
newx
,
newy
);
x
,
sh
->
h_outlinetag
,
x
->
gl_xmargin
,
x
->
gl_ymargin
,
newx
,
newy
);
sh
->
h_dragx
=
dx
;
sh
->
h_dragy
=
dy
;
sh
->
h_dragx
=
sx
-
x
->
gl_pixwidth
;
sh
->
h_dragy
=
sy
-
x
->
gl_pixheight
;
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
int
new_w
=
x
->
gl_pixwidth
-
sh
->
h_offset_x
+
sh
->
h_dragx
;
int
new_h
=
x
->
gl_pixheight
-
sh
->
h_offset_y
+
sh
->
h_drag
y
;
properties_set_field_int
(
properties
,
"n.canvasdialog.x.f2.entry3"
,
new_w
);
properties_set_field_int
(
properties
,
"n.canvasdialog.y.f2.entry3"
,
new_h
);
properties_set_field_int
(
properties
,
"n.canvasdialog.x.f2.entry3"
,
x
->
gl_pixwidth
+
sh
->
h_drag
x
)
;
properties_set_field_int
(
properties
,
"n.canvasdialog.y.f2.entry3"
,
x
->
gl_pixheight
+
sh
->
h_dragy
);
}
}
else
//enter if move_gop hook
{
newx
=
x
->
gl_xmargin
-
sh
->
h_offset_x
+
dx
;
newy
=
x
->
gl_ymargin
-
sh
->
h_offset_y
+
dy
;
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
properties_set_field_int
(
properties
,
"n.canvasdialog.x.f2.entry4"
,
newx
);
properties_set_field_int
(
properties
,
"n.canvasdialog.y.f2.entry4"
,
newy
);
properties_set_field_int
(
properties
,