Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sanket Bhukan
purr-data
Commits
2abcab84
Commit
2abcab84
authored
8 years ago
by
Jonathan Wilkes
Browse files
Options
Downloads
Patches
Plain Diff
simplify the interface by just using the object addy as the key, and remove old code
parent
fa82bd92
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
externals/ggee/gui/image.c
+11
-51
11 additions, 51 deletions
externals/ggee/gui/image.c
with
11 additions
and
51 deletions
externals/ggee/gui/image.c
+
11
−
51
View file @
2abcab84
...
@@ -56,39 +56,10 @@ t_symbol *image_trytoopen(t_image* x)
...
@@ -56,39 +56,10 @@ t_symbol *image_trytoopen(t_image* x)
}
}
}
}
void
image_doopen_old
(
t_image
*
x
)
{
char
fname
[
FILENAME_MAX
];
FILE
*
file
;
if
(
x
->
x_fname
==
&
s_
)
{
x
->
x_fname
=
gensym
(
"@pd_extra/ggee/empty_image.png"
);
}
t_glist
*
glist
=
glist_getcanvas
(
x
->
x_glist
);
canvas_makefilename
(
glist_getcanvas
(
x
->
x_glist
),
x
->
x_fname
->
s_name
,
fname
,
FILENAME_MAX
);
// try to open the file
if
(
file
=
fopen
(
fname
,
"r"
))
{
fclose
(
file
);
}
else
{
x
->
x_fname
=
gensym
(
"@pd_extra/ggee/empty_image.png"
);
canvas_makefilename
(
glist_getcanvas
(
x
->
x_glist
),
x
->
x_fname
->
s_name
,
fname
,
FILENAME_MAX
);
}
sys_vgui
(
".x%x.c itemconfigure %xS -image
\n
"
,
glist
,
x
);
sys_vgui
(
"catch {image delete $img%x}
\n
"
,
x
);
sys_vgui
(
"set img%x [image create photo -file {%s}]
\n
"
,
x
,
fname
);
sys_vgui
(
"if { [catch {image width $img%x} fid] } { pd [concat %s _imagesize 0 0
\\
;] }
\n
"
,
x
,
x
->
x_receive
->
s_name
);
sys_vgui
(
".x%x.c itemconfigure %xS -image $img%x
\n
"
,
glist
,
x
,
x
);
sys_vgui
(
"pd [concat %s _imagesize [image width $img%x] [image height $img%x]
\\
;]
\n
"
,
x
->
x_receive
->
s_name
,
x
,
x
);
}
static
void
image_drawme
(
t_image
*
x
,
t_glist
*
glist
,
int
firstime
)
static
void
image_drawme
(
t_image
*
x
,
t_glist
*
glist
,
int
firstime
)
{
{
if
(
firstime
)
if
(
firstime
)
{
{
char
key
[
MAXPDSTRING
];
t_symbol
*
fname
=
image_trytoopen
(
x
);
t_symbol
*
fname
=
image_trytoopen
(
x
);
// make a new gobj, border, etc.
// make a new gobj, border, etc.
gui_vmess
(
"gui_gobj_new"
,
"xxsiii"
,
gui_vmess
(
"gui_gobj_new"
,
"xxsiii"
,
...
@@ -99,33 +70,26 @@ static void image_drawme(t_image *x, t_glist *glist, int firstime)
...
@@ -99,33 +70,26 @@ static void image_drawme(t_image *x, t_glist *glist, int firstime)
text_ypix
(
&
x
->
x_obj
,
glist
),
text_ypix
(
&
x
->
x_obj
,
glist
),
glist_istoplevel
(
glist
));
glist_istoplevel
(
glist
));
if
(
fname
)
{
if
(
fname
)
{
// set the key to (x%lx, x)
gui_vmess
(
"gui_load_image"
,
"xxs"
,
sprintf
(
key
,
"x%lx"
,
(
long
unsigned
int
)
x
);
glist_getcanvas
(
glist
),
x
,
fname
->
s_name
);
// set a new image in the cache for this image
gui_vmess
(
"gui_load_image"
,
"xss"
,
glist_getcanvas
(
glist
),
key
,
fname
->
s_name
);
}
}
else
else
{
{
char
key2
[
MAXPDSTRING
];
gui_vmess
(
"gui_load_default_image"
,
"xx"
,
// set the key to (x%lxx%lxdefault, image_class, image_class)
glist_getcanvas
(
glist
),
x
);
sprintf
(
key
,
"x%lx"
,
(
long
unsigned
int
)
image_class
);
sprintf
(
key2
,
"x%lx"
,
(
long
unsigned
int
)
image_class
);
strcat
(
key
,
key2
);
strcat
(
key
,
"default"
);
}
}
// draw the new canvas image
// draw the new canvas image
gui_vmess
(
"gui_gobj_draw_image"
,
"xx
s
s"
,
gui_vmess
(
"gui_gobj_draw_image"
,
"xx
x
s"
,
glist_getcanvas
(
glist
),
glist_getcanvas
(
glist
),
x
,
x
,
key
,
x
,
"center"
);
"center"
);
//sys_vgui("catch {.x%lx.c delete %xS}\n", glist_getcanvas(glist), x);
//sys_vgui("catch {.x%lx.c delete %xS}\n", glist_getcanvas(glist), x);
//sys_vgui(".x%x.c create image %d %d -tags %xS\n",
//sys_vgui(".x%x.c create image %d %d -tags %xS\n",
// glist_getcanvas(glist),text_xpix(&x->x_obj, glist),
// glist_getcanvas(glist),text_xpix(&x->x_obj, glist),
// text_ypix(&x->x_obj, glist), x);
// text_ypix(&x->x_obj, glist), x);
gui_vmess
(
"gui_image_size_callback"
,
"x
s
s"
,
gui_vmess
(
"gui_image_size_callback"
,
"x
x
s"
,
glist_getcanvas
(
glist
),
key
,
x
->
x_receive
->
s_name
);
glist_getcanvas
(
glist
),
x
,
x
->
x_receive
->
s_name
);
}
}
else
else
{
{
...
@@ -143,9 +107,10 @@ static void image_drawme(t_image *x, t_glist *glist, int firstime)
...
@@ -143,9 +107,10 @@ static void image_drawme(t_image *x, t_glist *glist, int firstime)
void
image_erase
(
t_image
*
x
,
t_glist
*
glist
)
void
image_erase
(
t_image
*
x
,
t_glist
*
glist
)
{
{
sys_vgui
(
"catch {.x%x.c delete %xS}
\n
"
,
glist_getcanvas
(
glist
),
x
);
gui_vmess
(
"gui_gobj_erase"
,
"xx"
,
glist_getcanvas
(
glist
),
x
);
//sys_vgui("catch {.x%x.c delete %xS}\n",glist_getcanvas(glist), x);
sys_vgui
(
"catch {image delete $img%x}
\n
"
,
x
);
sys_vgui
(
"catch {image delete $img%x}
\n
"
,
x
);
sys_vgui
(
"catch {.x%x.c delete %xSEL}
\n
"
,
glist_getcanvas
(
glist
),
x
);
//
sys_vgui("catch {.x%x.c delete %xSEL}\n",glist_getcanvas(glist), x);
}
}
static
t_symbol
*
get_filename
(
t_int
argc
,
t_atom
*
argv
)
static
t_symbol
*
get_filename
(
t_int
argc
,
t_atom
*
argv
)
...
@@ -549,9 +514,4 @@ void image_setup(void)
...
@@ -549,9 +514,4 @@ void image_setup(void)
image_setwidget
();
image_setwidget
();
class_setwidget
(
image_class
,
&
image_widgetbehavior
);
class_setwidget
(
image_class
,
&
image_widgetbehavior
);
class_setsavefn
(
image_class
,
&
image_save
);
class_setsavefn
(
image_class
,
&
image_save
);
/* cache a default image (question mark) for case where no image argument
is given. The key is ("x%lxx%lxdefault", image_class, image_class),
to protect against namespace clashes with the complicated interface
of moonlib/image */
gui_vmess
(
"gui_load_default_image"
,
"sx"
,
"dummy"
,
image_class
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment