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
Aayush
purr-data
Commits
b009d585
Commit
b009d585
authored
Jan 31, 2016
by
Jonathan Wilkes
Browse files
clean up g_numbox.c, and revert some of the GUI variable name changes from the previous two commits
parent
1244f96f
Changes
2
Hide whitespace changes
Inline
Side-by-side
pd/nw/pdgui.js
View file @
b009d585
...
...
@@ -1840,9 +1840,9 @@ function gui_hide_selection_rectangle(cid) {
// iemguis
function
gui_create_bng
(
c
,
id
,
cx
,
cy
,
radius
)
{
var
g
=
get_gobj
(
c
,
id
),
circle
=
create_item
(
c
,
"
circle
"
,
{
function
gui_create_bng
(
cid
,
tag
,
cx
,
cy
,
radius
)
{
var
g
=
get_gobj
(
cid
,
tag
),
circle
=
create_item
(
c
id
,
"
circle
"
,
{
cx
:
cx
,
cy
:
cy
,
r
:
radius
,
...
...
@@ -1850,7 +1850,7 @@ function gui_create_bng(c, id, cx, cy, radius) {
fill
:
"
none
"
,
stroke
:
"
black
"
,
"
stroke-width
"
:
1
,
id
:
id
+
"
button
"
id
:
tag
+
"
button
"
});
g
.
appendChild
(
circle
);
}
...
...
@@ -1861,13 +1861,13 @@ function x2h(x_val) {
return
"
#
"
+
x_val
.
slice
(
1
);
}
function
gui_bng_button_color
(
c
,
id
,
x_color
)
{
var
button
=
get_item
(
c
,
id
+
"
button
"
);
function
gui_bng_button_color
(
cid
,
tag
,
x_color
)
{
var
button
=
get_item
(
cid
,
tag
+
"
button
"
);
configure_item
(
button
,
{
fill
:
x2h
(
x_color
)
});
}
function
gui_bng_configure
(
c
,
id
,
x_color
,
cx
,
cy
,
r
)
{
var
b
=
get_item
(
c
,
id
+
"
button
"
);
function
gui_bng_configure
(
cid
,
tag
,
x_color
,
cx
,
cy
,
r
)
{
var
b
=
get_item
(
cid
,
tag
+
"
button
"
);
configure_item
(
b
,
{
cx
:
cx
,
cy
:
cy
,
...
...
@@ -1955,7 +1955,7 @@ function numbox_data_string(w, h) {
}
// Todo: send fewer parameters from c
function
gui_create_numbox
(
cid
,
tag
,
bg
color
,
x
,
y
,
w
,
h
,
is_toplevel
)
{
function
gui_create_numbox
(
cid
,
tag
,
x_
color
,
x
,
y
,
w
,
h
,
is_toplevel
)
{
// numbox doesn't have a standard iemgui border,
// so we must create its gobj manually
var
g
=
gui_text_create_gobj
(
cid
,
tag
,
"
iemgui
"
,
x
,
y
,
is_toplevel
),
...
...
@@ -1964,7 +1964,7 @@ function gui_create_numbox(cid, tag, bgcolor, x, y, w, h, is_toplevel) {
data
=
numbox_data_string
(
w
,
h
);
border
=
create_item
(
cid
,
"
path
"
,
{
d
:
data
,
fill
:
bg
color
,
fill
:
x2h
(
x_
color
)
,
stroke
:
"
black
"
,
"
stroke-width
"
:
1
,
id
:
(
tag
+
"
border
"
),
...
...
@@ -1980,7 +1980,7 @@ function gui_numbox_coords(cid, tag, w, h) {
});
}
function
gui_numbox_drawtext
(
cid
,
tag
,
text
,
font_size
,
color
,
xpos
,
ypos
,
basex
,
basey
)
{
function
gui_numbox_drawtext
(
cid
,
tag
,
text
,
font_size
,
x_
color
,
xpos
,
ypos
,
basex
,
basey
)
{
// kludge alert -- I'm not sure why I need to add half to the ypos
// below. But it works for most font sizes.
var
g
=
get_gobj
(
cid
,
tag
),
...
...
@@ -1989,7 +1989,7 @@ function gui_numbox_drawtext(cid,tag,text,font_size,color,xpos,ypos,basex,basey)
(
xpos
-
basex
)
+
"
,
"
+
((
ypos
-
basey
+
(
ypos
-
basey
)
*
0.5
)
|
0
)
+
"
)
"
,
"
font-size
"
:
font_size
,
fill
:
color
,
fill
:
x2h
(
x_
color
)
,
id
:
tag
+
"
text
"
}),
text_node
=
patchwin
[
cid
].
window
.
document
.
createTextNode
(
text
);
...
...
@@ -1997,12 +1997,12 @@ function gui_numbox_drawtext(cid,tag,text,font_size,color,xpos,ypos,basex,basey)
g
.
appendChild
(
svg_text
);
}
function
gui_update_numbox
(
cid
,
tag
,
fcolor
,
bgcolor
,
font_name
,
font_size
,
font_weight
)
{
function
gui_update_numbox
(
cid
,
tag
,
x_
fcolor
,
x_
bgcolor
,
font_name
,
font_size
,
font_weight
)
{
var
b
=
get_item
(
cid
,
tag
+
"
border
"
),
text
=
get_item
(
cid
,
tag
+
"
text
"
),
label
=
get_item
(
cid
,
tag
+
"
label
"
);
configure_item
(
b
,
{
fill
:
bgcolor
});
configure_item
(
text
,
{
fill
:
fcolor
,
"
font-size
"
:
font_size
});
configure_item
(
b
,
{
fill
:
x2h
(
x_
bgcolor
)
});
configure_item
(
text
,
{
fill
:
x2h
(
x_
fcolor
)
,
"
font-size
"
:
font_size
});
// Update the label if one exists
if
(
label
)
{
gui_iemgui_label_font
(
cid
,
tag
,
font_name
,
font_weight
,
font_size
);
...
...
@@ -2428,45 +2428,45 @@ function gui_iemgui_label_show_drag_handle(cid, tag, state, x, y) {
}
}
function
gui_create_mycanvas
(
c
,
id
,
x_color
,
x1
,
y1
,
x2_vis
,
y2_vis
,
x2
,
y2
)
{
function
gui_create_mycanvas
(
cid
,
tag
,
x_color
,
x1
,
y1
,
x2_vis
,
y2_vis
,
x2
,
y2
)
{
var
rect_vis
,
rect
,
g
;
rect_vis
=
create_item
(
c
,
"
rect
"
,
{
rect_vis
=
create_item
(
c
id
,
"
rect
"
,
{
width
:
x2_vis
-
x1
,
height
:
y2_vis
-
y1
,
fill
:
x2h
(
x_color
),
stroke
:
x2h
(
x_color
),
id
:
id
+
"
rect
"
id
:
tag
+
"
rect
"
}
);
// we use a drag_handle-- unlike a 'border' it takes
// the same color as the visible rectangle when deselected
rect
=
create_item
(
c
,
"
rect
"
,
{
rect
=
create_item
(
c
id
,
"
rect
"
,
{
width
:
x2
-
x1
,
height
:
y2
-
y1
,
fill
:
"
none
"
,
stroke
:
x2h
(
x_color
),
id
:
id
+
"
drag_handle
"
,
id
:
tag
+
"
drag_handle
"
,
"
class
"
:
"
border mycanvas_border
"
}
);
g
=
get_gobj
(
c
,
id
);
g
=
get_gobj
(
cid
,
tag
);
g
.
appendChild
(
rect_vis
);
g
.
appendChild
(
rect
);
}
function
gui_update_mycanvas
(
c
,
id
,
x_color
,
selected
)
{
var
r
=
get_item
(
c
,
id
+
"
rect
"
),
h
=
get_item
(
c
,
id
+
"
drag_handle
"
);
function
gui_update_mycanvas
(
cid
,
tag
,
x_color
,
selected
)
{
var
r
=
get_item
(
cid
,
tag
+
"
rect
"
),
h
=
get_item
(
cid
,
tag
+
"
drag_handle
"
);
configure_item
(
r
,
{
fill
:
x2h
(
x_color
),
stroke
:
x2h
(
x_color
)
});
}
function
gui_mycanvas_coords
(
c
,
id
,
vis_width
,
vis_height
,
select_width
,
select_height
)
{
var
r
=
get_item
(
c
,
id
+
"
rect
"
),
h
=
get_item
(
c
,
id
+
"
drag_handle
"
);
function
gui_mycanvas_coords
(
cid
,
tag
,
vis_width
,
vis_height
,
select_width
,
select_height
)
{
var
r
=
get_item
(
cid
,
tag
+
"
rect
"
),
h
=
get_item
(
cid
,
tag
+
"
drag_handle
"
);
configure_item
(
r
,
{
width
:
vis_width
,
height
:
vis_height
});
configure_item
(
h
,
{
width
:
select_width
,
height
:
select_height
});
}
...
...
pd/src/g_numbox.c
View file @
b009d585
...
...
@@ -137,20 +137,21 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
x
->
x_buf
[
sl
+
1
]
=
0
;
if
(
sl
>=
x
->
x_gui
.
x_w
)
cp
+=
sl
-
x
->
x_gui
.
x_w
+
1
;
gui_vmess
(
"gui_text_set"
,
"xxs"
,
glist_getcanvas
(
glist
),
x
,
cp
);
gui_vmess
(
"gui_text_set"
,
"xxs"
,
glist_getcanvas
(
glist
),
x
,
cp
);
x
->
x_buf
[
sl
]
=
0
;
}
else
{
//printf("draw_update 2\n");
char
fcol
[
8
];
sprintf
(
fcol
,
"#%6.6x
"
,
x
->
x_gui
.
x_change
?
IEM_GUI_COLOR_EDITED
:
x
->
x_gui
.
x_fcol
);
my_numbox_ftoa
(
x
);
gui_vmess
(
"gui_text_set"
,
"xxs"
,
glist_getcanvas
(
glist
),
x
,
x
->
x_buf
);
x
->
x_buf
[
0
]
=
0
;
my_numbox_ftoa
(
x
);
/* mmm... side-effects */
gui_vmess
(
"gui_text_set"
,
"xxs
"
,
glist_getcanvas
(
glist
),
x
,
x
->
x_buf
);
x
->
x_buf
[
0
]
=
0
;
/* mmm... more side-effects... no clue why we'd need
to mutate a struct member in order to draw stuff */
}
}
...
...
@@ -160,12 +161,11 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
int
half
=
x
->
x_gui
.
x_h
/
2
,
d
=
1
+
x
->
x_gui
.
x_h
/
34
;
int
x1
=
text_xpix
(
&
x
->
x_gui
.
x_obj
,
glist
),
x2
=
x1
+
x
->
x_numwidth
;
int
y1
=
text_ypix
(
&
x
->
x_gui
.
x_obj
,
glist
),
y2
=
y1
+
x
->
x_gui
.
x_h
;
char
bcol
[
8
];
sprintf
(
bcol
,
"#%6.6x"
,
x
->
x_gui
.
x_bcol
);
gui_vmess
(
"gui_create_numbox"
,
"xx
s
iiiii"
,
gui_vmess
(
"gui_create_numbox"
,
"xx
x
iiiii"
,
canvas
,
x
,
bcol
,
x
->
x_gui
.
x_
bcol
,
x1
,
y1
,
x2
-
x1
,
...
...
@@ -181,11 +181,13 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
// x->x_gui.x_fcol, x, x);
}
my_numbox_ftoa
(
x
);
char
colorbuf
[
MAXPDSTRING
];
sprintf
(
colorbuf
,
"#%6.6x"
,
x
->
x_gui
.
x_fcol
);
gui_vmess
(
"gui_numbox_drawtext"
,
"xxsisiiii"
,
canvas
,
x
,
x
->
x_buf
,
x
->
x_gui
.
x_fontsize
,
colorbuf
,
x1
+
half
+
2
,
y1
+
half
+
d
,
x1
,
y1
);
gui_vmess
(
"gui_numbox_drawtext"
,
"xxsixiiii"
,
canvas
,
x
,
x
->
x_buf
,
x
->
x_gui
.
x_fontsize
,
x
->
x_gui
.
x_fcol
,
x1
+
half
+
2
,
y1
+
half
+
d
,
x1
,
y1
);
}
/* Not sure that this is needed anymore */
...
...
@@ -223,14 +225,15 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
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
==
canvas
&&
x
->
x_gui
.
x_glist
==
canvas
;
char
bgcol
[
MAXPDSTRING
];
sprintf
(
bgcol
,
"#%6.6x"
,
x
->
x_gui
.
x_bcol
);
gui_vmess
(
"gui_update_numbox"
,
"xxsssii"
,
canvas
,
x
,
fcol
,
bgcol
,
iemgui_typeface
,
x
->
x_gui
.
x_fontsize
,
sys_fontweight
);
gui_vmess
(
"gui_update_numbox"
,
"xxxxsii"
,
canvas
,
x
,
x
->
x_gui
.
x_fcol
,
x
->
x_gui
.
x_bcol
,
iemgui_typeface
,
x
->
x_gui
.
x_fontsize
,
sys_fontweight
);
}
static
void
my_numbox_draw_select
(
t_my_numbox
*
x
,
t_glist
*
glist
)
...
...
@@ -323,11 +326,8 @@ static void my_numbox__motionhook(t_scalehandle *sh,
x
->
x_numwidth
=
my_numbox_calc_fontwidth
(
x
);
canvas_dirty
(
x
->
x_gui
.
x_glist
,
1
);
if
(
glist_isvisible
(
x
->
x_gui
.
x_glist
))
{
my_numbox_draw_move
(
x
,
x
->
x_gui
.
x_glist
);
my_numbox_draw_config
(
x
,
x
->
x_gui
.
x_glist
);
my_numbox_draw_update
((
t_gobj
*
)
x
,
x
->
x_gui
.
x_glist
);
...
...
@@ -338,9 +338,6 @@ static void my_numbox__motionhook(t_scalehandle *sh,
//gobj_vis(x, x->x_gui.x_glist, 1);
scalehandle_unclick_scale
(
sh
);
}
int
properties
=
gfxstub_haveproperties
((
void
*
)
x
);
if
(
properties
)
{
...
...
@@ -613,7 +610,6 @@ static void my_numbox_log_height(t_my_numbox *x, t_floatarg lh)
x
->
x_k
=
exp
(
log
(
x
->
x_max
/
x
->
x_min
)
/
(
double
)(
x
->
x_log_height
));
else
x
->
x_k
=
1
.
0
;
}
static
void
my_numbox_hide_frame
(
t_my_numbox
*
x
,
t_floatarg
lh
)
...
...
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