"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "f.mashup.cc" between
fotoxx-23.0.tar.gz and fotoxx-23.1.tar.gz

About: fotoxx is a program for photo editing and collection management.

f.mashup.cc  (fotoxx-23.0):f.mashup.cc  (fotoxx-23.1)
/******************************************************************************* * /******************************************************************************* *
Fotoxx edit photos and manage collections Fotoxx - edit photos and manage collections
Copyright 2007-2023 Michael Cornelison Copyright 2007-2023 Michael Cornelison
source code URL: https://kornelix.net source code URL: https://kornelix.net
contact: mkornelix@gmail.com contact: mkornelix@gmail.com
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. See https://www.gnu.org/licenses (at your option) any later version. See https://www.gnu.org/licenses
skipping to change at line 43 skipping to change at line 43
MASHUP MASHUP
Define a layout/background image. Define a layout/background image.
Add images, text, and lines as overlays on top of layout. Add images, text, and lines as overlays on top of layout.
Overlays have adjustable position, angle, size, transparency. Overlays have adjustable position, angle, size, transparency.
******************************************************************************** */ ******************************************************************************** */
namespace mashup namespace mashup
{ {
char projectname[100]; ch projectname[100];
// project name // project name
char projectfile[200]; ch projectfile[200];
// /.../projectname // /.../projectname
char layoutfile[XFCC]; ch layoutfile[XFCC];
// background/layout image file // background/layout image file
char tranfile[220]; ch tranfile[220];
// /.../projectname_trandata // /.../projectname_trandata
char warpfile[220]; ch warpfile[220];
// /.../projectname_warpdata // /.../projectname_warpdata
int Lww, Lhh; // layout image size int Lww, Lhh; // layout image size
int flatRGB[3]; // flat layout RGB values (no file) int flatRGB[3]; // flat layout RGB values (no file)
PXB *Lpxb; // layout image PXB PXB *Lpxb; // layout image PXB
int Nimage; // overlay image count int Nimage; // overlay image count
int Ntext; // overlay text count int Ntext; // overlay text count
int Nline; // overlay line count int Nline; // overlay line count
int updxlo, updxhi, updylo, updyhi; // update region in layout image int updxlo, updxhi, updylo, updyhi; // update region in layout image
float PRscale; // project scale for editing float PRscale; // project scale for editing
int Fupdall; // flag, update entire layout int Fupdall; // flag, update entire layout
int Fupdatebusy; // window update busy int Fupdatebusy; // window update busy
cchar *focus; // "image" "text" "line" "" ch *focus; // "image" "text" "line" ""
int focusii; // image[ii] text[ii] line[ii] or -1 int focusii; // image[ii] text[ii] line[ii] or -1
int Fnextimage = 0; // flag, image selected with [next] int Fnextimage = 0; // flag, image selected with [next]
int Mradius = 50; // paint transparency mouse radius int Mradius = 50; // paint transparency mouse radius
int Mpowcen = 10; // paint transparency mouse center power int Mpowcen = 10; // paint transparency mouse center power
int Mpowedge = 0; // paint transparency mouse edge power int Mpowedge = 0; // paint transparency mouse edge power
int Mgradual = 1; // paint transparency gradual or instant int Mgradual = 1; // paint transparency gradual or instant
zdialog *zdimage; // image edit dialog active zdialog *zdimage; // image edit dialog active
zdialog *zdtext; // text edit dialog active zdialog *zdtext; // text edit dialog active
zdialog *zdaddtext; // add text dialog active zdialog *zdaddtext; // add text dialog active
zdialog *zdline; // line edit dialog active zdialog *zdline; // line edit dialog active
zdialog *zdaddline; // add line dialog active zdialog *zdaddline; // add line dialog active
zdialog *zdtransp; // paint transparencies dialog active zdialog *zdtransp; // paint transparencies dialog active
zdialog *zdwarp; // warp image dialog active zdialog *zdwarp; // warp image dialog active
struct image_t { // overlay image data struct image_t { // overlay image data
char *file; // filespec ch *file; // filespec
PXB *pxb1; // image PXB, 1x size PXB *pxb1; // image PXB, 1x size
PXB *pxb2; // image PXB, scaled size PXB *pxb2; // image PXB, scaled size
float scale; // pxb2 scale, 0.0 to 1.0 = 1x float scale; // pxb2 scale, 0.0 to 1.0 = 1x
float theta; // angle, -PI to +PI radians float theta; // angle, -PI to +PI radians
float sinT, cosT; // trig values for theta float sinT, cosT; // trig values for theta
int ww1, hh1; // image size at 1x scale int ww1, hh1; // image size at 1x scale
int ww2, hh2; // image size at curr. scale int ww2, hh2; // image size at curr. scale
int px0, py0; // image position in layout image int px0, py0; // image position in layout image
int pxlo, pxhi, pylo, pyhi; // image extent in layout image space int pxlo, pxhi, pylo, pyhi; // image extent in layout image space
int fixed; // flag, image fixed, cannot move 22.30 int fixed; // flag, image fixed, cannot move 22.30
skipping to change at line 119 skipping to change at line 119
int px0, py0; // image position in layout image int px0, py0; // image position in layout image
int pxlo, pxhi, pylo, pyhi; // extent of line image in layout image int pxlo, pxhi, pylo, pyhi; // extent of line image in layout image
}; };
#define maxmash 50 // max. images, text, lines #define maxmash 50 // max. images, text, lines
image_t image[maxmash]; image_t image[maxmash];
text_t text[maxmash]; text_t text[maxmash];
line_t line[maxmash]; line_t line[maxmash];
void project(void); void project(void);
int project_dialog_event(zdialog *zd, cchar *event); int project_dialog_event(zdialog *zd, ch *event);
int project_open(void); int project_open(void);
void project_save(void); void project_save(void);
void project_rescale(float scale); void project_rescale(float scale);
void image_edit(void); void image_edit(void);
int image_dialog_event(zdialog *zd, cchar *event); int image_dialog_event(zdialog *zd, ch *event);
void image_rescale(int ii, float scale2); void image_rescale(int ii, float scale2);
void paintransp_dialog(void); void paintransp_dialog(void);
int paintransp_dialog_event(zdialog *zd, cchar *event); int paintransp_dialog_event(zdialog *zd, ch *event);
void paintransp_mousefunc(void); void paintransp_mousefunc(void);
void warp_dialog(void); void warp_dialog(void);
int warp_dialog_event(zdialog *zd, cchar *event); int warp_dialog_event(zdialog *zd, ch *event);
void warp_mousefunc(void); void warp_mousefunc(void);
void warp_warpfunc(void); void warp_warpfunc(void);
void * warp_warpfunc_wthread(void *arg); void * warp_warpfunc_wthread(void *arg);
void transparent_margins(void); void transparent_margins(void);
void add_image(void); void add_image(void);
void remove_image(int ii); void remove_image(int ii);
void flashimage(void); void flashimage(void);
void text_edit(void); void text_edit(void);
int text_dialog_event(zdialog *zd, cchar *event); int text_dialog_event(zdialog *zd, ch *event);
void add_text(void); void add_text(void);
void remove_text(int ii); void remove_text(int ii);
void flashtext(void); void flashtext(void);
void line_edit(void); void line_edit(void);
int line_dialog_event(zdialog *zd, cchar *event); int line_dialog_event(zdialog *zd, ch *event);
void add_line(void); void add_line(void);
void remove_line(int ii); void remove_line(int ii);
void flashline(void); void flashline(void);
void select(cchar *which, int ii); void select(ch *which, int ii);
void setlayoutupdatearea(void); void setlayoutupdatearea(void);
void mousefunc_layout(void); void mousefunc_layout(void);
void KBfunc(int key); void KBfunc(int key);
void Lupdate(void); void Lupdate(void);
void * Lupdate_thread(void *); void * Lupdate_thread(void *);
void * Lupdate_wthread(void *arg); void * Lupdate_wthread(void *arg);
} }
/******************************************************************************* */ /******************************************************************************* */
// menu function // menu function
void m_mashup(GtkWidget *, cchar *) void m_mashup(GtkWidget *, ch *)
{ {
using namespace mashup; using namespace mashup;
zdialog *zd; zdialog *zd;
int zstat, nn, err, ww, hh; int zstat, nn, err, ww, hh;
char color[20], *file; ch color[20], *file;
cchar *choice = 0, *ppc; ch *choice = 0, *ppc;
int px, py; int px, py;
uint8 *pix; uint8 *pix;
F1_help_topic = "mashup"; F1_help_topic = "mashup";
Plog(1,"m_mashup \n"); Plog(1,"m_mashup \n");
if (FGWM != 'F' && FGWM != 'G') return; if (FGWM != 'F' && FGWM != 'G') return;
if (Fblock("mashup","block edits")) return; // check pend, block if (Fblock("mashup","block edits")) return; // check pend, block
skipping to change at line 439 skipping to change at line 439
zdialog_add_widget(zd,"label","labcancel","hbcan","cancel project","space=3") ; zdialog_add_widget(zd,"label","labcancel","hbcan","cancel project","space=3") ;
zdialog_run(zd,project_dialog_event,"save"); // start dialog zdialog_run(zd,project_dialog_event,"save"); // start dialog
takeMouse(mousefunc_layout,0); // capture mouse click/drag takeMouse(mousefunc_layout,0); // capture mouse click/drag
return; return;
} }
// project dialog event and completion function // project dialog event and completion function
int mashup::project_dialog_event(zdialog *zd, cchar *event) int mashup::project_dialog_event(zdialog *zd, ch *event)
{ {
using namespace mashup; using namespace mashup;
int ii, cc, yn; int ii, cc, yn;
GError *gerror = 0; GError *gerror = 0;
char *file = 0, *file2, *pp; ch *file = 0, *file2, *pp;
cchar *rescalemess = "rescale project"; ch *rescalemess = "rescale project";
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (zd->zstat) event = "cancel"; if (zd->zstat) event = "cancel";
if (strmatch(event,"focus")) { if (strmatch(event,"focus")) {
takeMouse(mousefunc_layout,0); takeMouse(mousefunc_layout,0);
return 1; return 1;
} }
skipping to change at line 587 skipping to change at line 587
int mashup::project_open() int mashup::project_open()
{ {
using namespace mashup; using namespace mashup;
PXB *pxbtemp; PXB *pxbtemp;
int ii, nn; int ii, nn;
int ww1, hh1; int ww1, hh1;
int px, py, kk; int px, py, kk;
int nfid = -1, cc, wcc, vcc; int nfid = -1, cc, wcc, vcc;
char *pp, *pp2; ch *pp, *pp2;
char buff[XFCC]; ch buff[XFCC];
textattr_t *txattr = 0; textattr_t *txattr = 0;
lineattr_t *lnattr = 0; lineattr_t *lnattr = 0;
FILE *fid; FILE *fid;
uint8 *pix; uint8 *pix;
pp = zgetfile("Open Project",MWIN,"file",mashup_folder); // get project file from user pp = zgetfile("Open Project",MWIN,"file",mashup_folder); // get project file from user
if (! pp) return 1; if (! pp) return 1;
strncpy0(projectfile,pp,200); // project file strncpy0(projectfile,pp,200); // project file
strncpy0(tranfile,pp,200); strncpy0(tranfile,pp,200);
skipping to change at line 1012 skipping to change at line 1012
} }
// save a mashup project so that it can be edited again later // save a mashup project so that it can be edited again later
void mashup::project_save() void mashup::project_save()
{ {
using namespace mashup; using namespace mashup;
textattr_t txattr; textattr_t txattr;
lineattr_t lnattr; lineattr_t lnattr;
char *pp, text2[1200]; ch *pp, text2[1200];
FILE *fid; FILE *fid;
int nfid, ii, kk, cc, vcc, wcc; int nfid, ii, kk, cc, vcc, wcc;
if (PRscale > 1) project_rescale(1.0); // must save at 1x only if (PRscale > 1) project_rescale(1.0); // must save at 1x only
snprintf(projectfile,200,"%s/%s",mashup_folder,projectname); snprintf(projectfile,200,"%s/%s",mashup_folder,projectname);
pp = zgetfile("Save Project",MWIN,"save",projectfile); // get project name from user pp = zgetfile("Save Project",MWIN,"save",projectfile); // get project name from user
if (! pp) return; if (! pp) return;
strncpy0(projectfile,pp,200); // project file strncpy0(projectfile,pp,200); // project file
skipping to change at line 1229 skipping to change at line 1229
} }
/******************************************************************************* */ /******************************************************************************* */
// mashup image edit function // mashup image edit function
void mashup::image_edit() void mashup::image_edit()
{ {
using namespace mashup; using namespace mashup;
cchar *tipmess = "Click image to select, drag image to move."; ch *tipmess = "Click image to select, drag image to move.";
cchar *blackmargmess = "Make black margins transparent"; ch *blackmargmess = "Make black margins transparent";
cchar *imagefixed = "Image is fixed, unmovable"; ch *imagefixed = "Image is fixed, unmovable";
if (! strmatch(focus,"image")) select("",-1); // nothing selected if (! strmatch(focus,"image")) select("",-1); // nothing selected
/*** /***
_______________________________________________ _______________________________________________
| Edit Images | | Edit Images |
| | | |
| Click image to select, drag image to move. | | Click image to select, drag image to move. |
| | | |
| Current image: filename.jpg | | Current image: filename.jpg |
skipping to change at line 1343 skipping to change at line 1343
zdialog_add_ttip(zd,"Add Image","add images to layout"); zdialog_add_ttip(zd,"Add Image","add images to layout");
zdialog_run(zd,image_dialog_event,"save"); // run dialog - parallel zdialog_run(zd,image_dialog_event,"save"); // run dialog - parallel
zdialog_wait(zd); zdialog_wait(zd);
zdialog_free(zd); zdialog_free(zd);
return; return;
} }
// image dialog event and completion function // image dialog event and completion function
int mashup::image_dialog_event(zdialog *zd, cchar *event) int mashup::image_dialog_event(zdialog *zd, ch *event)
{ {
using namespace mashup; using namespace mashup;
int ii; int ii;
float scale, angle, rad = PI / 180.0; float scale, angle, rad = PI / 180.0;
image_t temp; image_t temp;
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (strmatch(event,"kill"))
// kill dialog
{
zdialog_free(zd);
zdimage = 0;
if (zdtransp) {
zdialog_free(zdtransp);
zdtransp = 0;
}
if (zdwarp) {
zdialog_free(zdwarp);
zdwarp = 0;
}
return 1;
}
if (zd->zstat) if (zd->zstat)
{ {
if (zd->zstat == 1) { // add image if (zd->zstat == 1) { // add image
zd->zstat = 0; zd->zstat = 0;
add_image(); add_image();
return 1; return 1;
} }
if (zd->zstat == 2) { // remove image if (zd->zstat == 2) { // remove image
zd->zstat = 0; zd->zstat = 0;
if (! strmatch(focus,"image")) return 1; if (! strmatch(focus,"image")) return 1;
ii = focusii; ii = focusii;
remove_image(ii); remove_image(ii);
return 1; return 1;
} }
zdimage = 0; zdialog_free(zd);
// done or [x] kill // done or [x] kill
zdimage = 0;
if (zdtransp) { if (zdtransp) {
zdialog_free(zdtransp); zdialog_free(zdtransp);
zdtransp = 0; zdtransp = 0;
} }
if (zdwarp) { if (zdwarp) {
zdialog_free(zdwarp); zdialog_free(zdwarp);
zdwarp = 0; zdwarp = 0;
} }
skipping to change at line 1572 skipping to change at line 1555
return; return;
} }
// dialog to initiate painting image variable transparency // dialog to initiate painting image variable transparency
void mashup::paintransp_dialog() void mashup::paintransp_dialog()
{ {
using namespace mashup; using namespace mashup;
cchar *ptitle = "Paint Image Transparencies"; ch *ptitle = "Paint Image Transparencies";
/*** /***
_________________________________ _________________________________
| Paint Image Transparencies | | Paint Image Transparencies |
| | | |
| Radius [123 ] [x] Gradual | | Radius [123 ] [x] Gradual |
| Power Center [100] Edge [ 10] | | Power Center [100] Edge [ 10] |
| | | |
| [ OK ] | | [ OK ] |
|_________________________________| |_________________________________|
skipping to change at line 1611 skipping to change at line 1594
zdialog_stuff(zdtransp,"gradual",Mgradual); zdialog_stuff(zdtransp,"gradual",Mgradual);
zdialog_stuff(zdtransp,"edge",Mpowedge); zdialog_stuff(zdtransp,"edge",Mpowedge);
zdialog_run(zdtransp,paintransp_dialog_event,"save"); zdialog_run(zdtransp,paintransp_dialog_event,"save");
takeMouse(paintransp_mousefunc,0); takeMouse(paintransp_mousefunc,0);
return; return;
} }
// zdialog event and completion function // zdialog event and completion function
int mashup::paintransp_dialog_event(zdialog *zd, cchar *event) int mashup::paintransp_dialog_event(zdialog *zd, ch *event)
{ {
using namespace mashup; using namespace mashup;
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (zd->zstat) { // done or cancel if (zd->zstat) { // done or cancel
zdialog_free(zd); zdialog_free(zd);
zdtransp = 0; zdtransp = 0;
takeMouse(mousefunc_layout,0); takeMouse(mousefunc_layout,0);
return 1; return 1;
skipping to change at line 1822 skipping to change at line 1805
int Fdrag; int Fdrag;
PXB *pxb2w; PXB *pxb2w;
int warpii; int warpii;
}; };
void mashup::warp_dialog() void mashup::warp_dialog()
{ {
using namespace mashup; using namespace mashup;
using namespace warp; using namespace warp;
cchar *warp_message = "Pull on the image with the mouse."; ch *warp_message = "Pull on the image with the mouse.";
/*** /***
___________________________________ ___________________________________
| Warp Image | | Warp Image |
| | | |
| Pull on the image with the mouse. | | Pull on the image with the mouse. |
| | | |
| [undo last] [undo all] | | [undo last] [undo all] |
| Warp span [___] | | Warp span [___] |
| | | |
skipping to change at line 1859 skipping to change at line 1842
pxb2w = 0; pxb2w = 0;
warpii = -1; warpii = -1;
zdialog_run(zdwarp,warp_dialog_event,"save"); // run dialog, parallel zdialog_run(zdwarp,warp_dialog_event,"save"); // run dialog, parallel
takeMouse(warp_mousefunc,0); // connect mouse function takeMouse(warp_mousefunc,0); // connect mouse function
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int mashup::warp_dialog_event(zdialog * zd, cchar *event) int mashup::warp_dialog_event(zdialog * zd, ch *event)
{ {
using namespace mashup; using namespace mashup;
using namespace warp; using namespace warp;
int ii, kk; int ii, kk;
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (zd->zstat) // done or cancel if (zd->zstat) // done or cancel
{ {
skipping to change at line 2246 skipping to change at line 2229
// select and add one or more new overlay image files // select and add one or more new overlay image files
void mashup::add_image() void mashup::add_image()
{ {
using namespace mashup; using namespace mashup;
int ii, jj, nn, cc, Nfiles = 0; int ii, jj, nn, cc, Nfiles = 0;
int ww1, hh1, ww2, hh2; int ww1, hh1, ww2, hh2;
float scale; float scale;
char **selfiles = 0, *file; ch **selfiles = 0, *file;
PXB *pxb1; PXB *pxb1;
zdialog_show(zdimage,0); // hide parent dialog zdialog_show(zdimage,0); // hide parent dialog
// gallery_select_clear(); // clear gallery_select() file list // gallery_select_clear(); // clear gallery_select() file list
gallery_select(); // select image files from gallery gallery_select(); // select image files from gallery
m_viewmode(0,"F"); // restore view mode F m_viewmode(0,"F"); // restore view mode F
zdialog_show(zdimage,1); zdialog_show(zdimage,1);
if (! GScount) return; // nothing selected if (! GScount) return; // nothing selected
selfiles = (char **) zmalloc(GScount * sizeof(char *),"mashup"); selfiles = (ch **) zmalloc(GScount * sizeof(ch *),"mashup");
for (ii = 0; ii < GScount; ii++) for (ii = 0; ii < GScount; ii++)
selfiles[ii] = GSfiles[ii]; selfiles[ii] = GSfiles[ii];
Nfiles = GScount; Nfiles = GScount;
GScount = 0; GScount = 0;
for (nn = 0; nn < Nfiles; nn++) for (nn = 0; nn < Nfiles; nn++)
{ {
if (Nimage == maxmash) { if (Nimage == maxmash) {
skipping to change at line 2410 skipping to change at line 2393
} }
/******************************************************************************* */ /******************************************************************************* */
// add text to image or revise existing text // add text to image or revise existing text
void mashup::text_edit() void mashup::text_edit()
{ {
using namespace mashup; using namespace mashup;
cchar *intro = "Enter text, [Add] to layout, edit properties."; ch *intro = "Enter text, [Add] to layout, edit properties.";
/*** /***
__________________________________________________ __________________________________________________
| Edit Text | | Edit Text |
| | | |
| Enter text, [Add] to layout, edit properties. | | Enter text, [Add] to layout, edit properties. |
| | | |
| Text [______________________________________] | | Text [______________________________________] |
| | | |
| [font] [FreeSans______________] size [ 44 ] | | [font] [FreeSans______________] size [ 44 ] |
skipping to change at line 2505 skipping to change at line 2488
zdialog_restore_inputs(zd); // restore prior inputs zdialog_restore_inputs(zd); // restore prior inputs
zdialog_run(zd,text_dialog_event,"save"); // run dialog, parallel zdialog_run(zd,text_dialog_event,"save"); // run dialog, parallel
zdialog_wait(zd); zdialog_wait(zd);
zdialog_free(zd); zdialog_free(zd);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int mashup::text_dialog_event(zdialog *zd, cchar *event) int mashup::text_dialog_event(zdialog *zd, ch *event)
{ {
using namespace mashup; using namespace mashup;
GtkWidget *font_dialog; GtkWidget *font_dialog;
char font[80], fname[70]; ch font[80], fname[70];
int ii, size; int ii, size;
char *pp; ch *pp;
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (strmatch(event,"kill")) {
// kill dialog
zdialog_free(zd);
zdtext = 0;
return 1;
}
if (zd->zstat) if (zd->zstat)
{ {
if (zd->zstat == 1) { // clear if (zd->zstat == 1) { // clear
zd->zstat = 0; zd->zstat = 0;
zdialog_stuff(zd,"text",""); zdialog_stuff(zd,"text","");
focus = ""; focus = "";
return 1; return 1;
} }
if (zd->zstat == 2) { // add if (zd->zstat == 2) { // add
skipping to change at line 2545 skipping to change at line 2522
} }
if (zd->zstat == 3) { // delete if (zd->zstat == 3) { // delete
zd->zstat = 0; zd->zstat = 0;
if (! strmatch(focus,"text")) return 1; if (! strmatch(focus,"text")) return 1;
ii = focusii; ii = focusii;
remove_text(ii); // remove selected text image remove_text(ii); // remove selected text image
return 1; return 1;
} }
zdtext = 0; zdialog_free(zd);
// done or [x] kill // done or [x] kill
zdtext = 0;
return 1; return 1;
} }
if (strmatch(event,"focus")) { // get mouse ownership if (strmatch(event,"focus")) { // get mouse ownership
takeMouse(mousefunc_layout,0); takeMouse(mousefunc_layout,0);
return 1; return 1;
} }
if (strmatch(event,"loadtext")) // load text data from file if (strmatch(event,"loadtext")) // load text data from file
load_text(zdtext); // and stuff zdialog fields load_text(zdtext); // and stuff zdialog fields
skipping to change at line 2627 skipping to change at line 2605
// add new text entry to text[ii] list // add new text entry to text[ii] list
// get text and attributes from zdialog fields // get text and attributes from zdialog fields
void mashup::add_text() void mashup::add_text()
{ {
using namespace mashup; using namespace mashup;
int ii; int ii;
zdialog *zd = zdtext; zdialog *zd = zdtext;
cchar *tip = "click position to add text"; ch *tip = "click position to add text";
if (! zd) return; if (! zd) return;
if (zdaddtext) return; if (zdaddtext) return;
if (Ntext == maxmash) { if (Ntext == maxmash) {
zmessageACK(Mwin,"exceeded %d text entries",maxmash); zmessageACK(Mwin,"exceeded %d text entries",maxmash);
return; return;
} }
Mxclick = Myclick = 0; Mxclick = Myclick = 0;
skipping to change at line 2703 skipping to change at line 2681
Fupdall = 1; Fupdall = 1;
Lupdate(); // update layout composite image Lupdate(); // update layout composite image
return; return;
} }
// flash a selected text image as bright as possible for a short moment // flash a selected text image as bright as possible for a short moment
void mashup::flashtext() void mashup::flashtext()
{ {
int ii, jj, red, green, blue; int ii, jj, red, green, blue;
char savecolor[4][20], flashcolor[20]; ch savecolor[4][20], flashcolor[20];
if (! strmatch(focus,"text")) return; if (! strmatch(focus,"text")) return;
ii = focusii; ii = focusii;
for (jj = 0; jj < 4; jj++) // save text colors for (jj = 0; jj < 4; jj++) // save text colors
strcpy(savecolor[jj],text[ii].attr.color[jj]); strcpy(savecolor[jj],text[ii].attr.color[jj]);
for (jj = 0; jj < 4; jj++) { // get complimentary colors for (jj = 0; jj < 4; jj++) { // get complimentary colors
red = 255 - atoi(substring(text[ii].attr.color[jj],'|',1)); red = 255 - atoi(substring(text[ii].attr.color[jj],'|',1));
green = 255 - atoi(substring(text[ii].attr.color[jj],'|',2)); green = 255 - atoi(substring(text[ii].attr.color[jj],'|',2));
skipping to change at line 2744 skipping to change at line 2722
} }
/******************************************************************************* */ /******************************************************************************* */
// add a line/arrow to image or revise existing line/arrow // add a line/arrow to image or revise existing line/arrow
void mashup::line_edit() void mashup::line_edit()
{ {
using namespace mashup; using namespace mashup;
cchar *intro = "Set line properties, [Add] to layout, edit."; ch *intro = "Set line properties, [Add] to layout, edit.";
/*** /***
_______________________________________________ _______________________________________________
| Edit Line/Arrow | | Edit Line/Arrow |
| | | |
| Set line properties, [Add] to layout, edit. | | Set line properties, [Add] to layout, edit. |
| | | |
| Line length [____] width [____] | | Line length [____] width [____] |
| Arrow head [x] left [x] right | | Arrow head [x] left [x] right |
| | | |
skipping to change at line 2835 skipping to change at line 2813
zdialog_restore_inputs(zd); // restore prior inputs zdialog_restore_inputs(zd); // restore prior inputs
zdialog_run(zd,line_dialog_event,"save"); // run dialog, parallel zdialog_run(zd,line_dialog_event,"save"); // run dialog, parallel
zdialog_wait(zd); zdialog_wait(zd);
zdialog_free(zd); zdialog_free(zd);
return; return;
} }
// dialog event and completion callback function // dialog event and completion callback function
int mashup::line_dialog_event(zdialog *zd, cchar *event) int mashup::line_dialog_event(zdialog *zd, ch *event)
{ {
using namespace mashup; using namespace mashup;
int ii; int ii;
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (strmatch(event,"kill")) {
// kill dialog
zdialog_free(zd);
zdline = 0;
return 1;
}
if (zd->zstat) if (zd->zstat)
{ {
if (zd->zstat == 1) { // add if (zd->zstat == 1) { // add
zd->zstat = 0; zd->zstat = 0;
add_line(); // zdialog inputs >> new line/arrow image add_line(); // zdialog inputs >> new line/arrow image
return 1; return 1;
} }
if (zd->zstat == 2) { // delete if (zd->zstat == 2) { // delete
zd->zstat = 0; zd->zstat = 0;
if (! strmatch(focus,"line")) return 1; if (! strmatch(focus,"line")) return 1;
ii = focusii; ii = focusii;
remove_line(ii); // remove selected line/arrow image remove_line(ii); // remove selected line/arrow image
return 1; return 1;
} }
zdline = 0; zdialog_free(zd);
// done or [x] kill // done or [x] kill
zdline = 0;
return 1; return 1;
} }
if (strmatch(event,"focus")) { // get mouse ownership if (strmatch(event,"focus")) { // get mouse ownership
takeMouse(mousefunc_layout,0); takeMouse(mousefunc_layout,0);
return 1; return 1;
} }
ii = focusii; ii = focusii;
if (ii < 0) return 1; if (ii < 0) return 1;
skipping to change at line 2913 skipping to change at line 2886
return 1; return 1;
} }
// add new line/arrow entry to line[ii] list // add new line/arrow entry to line[ii] list
// get line attributes from zdialog fields // get line attributes from zdialog fields
void mashup::add_line() void mashup::add_line()
{ {
using namespace mashup; using namespace mashup;
int ii, zstat; int ii;
zdialog *zd = zdline; zdialog *zd = zdline;
cchar *tip = "click position to add line"; ch *tip = "click position to add line";
if (! zd) return; if (! zd) return;
if (zdaddline) return; if (zdaddline) return;
if (Nline == maxmash) { if (Nline == maxmash) {
zmessageACK(Mwin,"exceeded %d line entries",maxmash); zmessageACK(Mwin,"exceeded %d line entries",maxmash);
return; return;
} }
Mxclick = Myclick = 0; Mxclick = Myclick = 0;
zdaddline = zdialog_new("Add Line",Mwin,"OK","Cancel",null); // get mouse click for line position zdaddline = zdialog_new("Add Line",Mwin,"OK","Cancel",null); // get mouse click for line position
zdialog_set_decorated(zdaddline,0); zdialog_set_decorated(zdaddline,0);
zdialog_add_widget(zdaddline,"label","labtip","dialog",tip,"space=3"); zdialog_add_widget(zdaddline,"label","labtip","dialog",tip,"space=3");
zdialog_run(zdaddline,0,"mouse"); zdialog_run(zdaddline,0,"mouse");
zstat = zdialog_wait(zdaddline); zdialog_wait(zdaddline);
zdialog_free(zdaddline); zdialog_free(zdaddline);
if (zstat != 1) return;
if (! (Mxclick + Myclick)) return; if (! (Mxclick + Myclick)) return;
ii = Nline++; ii = Nline++;
memset(&line[ii],0,sizeof(line_t)); memset(&line[ii],0,sizeof(line_t));
zdialog_fetch(zd,"length",line[ii].attr.length); zdialog_fetch(zd,"length",line[ii].attr.length);
zdialog_fetch(zd,"width",line[ii].attr.width); zdialog_fetch(zd,"width",line[ii].attr.width);
zdialog_fetch(zd,"larrow",line[ii].attr.larrow); zdialog_fetch(zd,"larrow",line[ii].attr.larrow);
zdialog_fetch(zd,"rarrow",line[ii].attr.rarrow); zdialog_fetch(zd,"rarrow",line[ii].attr.rarrow);
zdialog_fetch(zd,"angle",line[ii].attr.angle); zdialog_fetch(zd,"angle",line[ii].attr.angle);
skipping to change at line 2992 skipping to change at line 2964
Fupdall = 1; Fupdall = 1;
Lupdate(); // update layout composite image Lupdate(); // update layout composite image
return; return;
} }
// flash a selected line/arrow image as bright as possible for a short moment // flash a selected line/arrow image as bright as possible for a short moment
void mashup::flashline() void mashup::flashline()
{ {
int ii, jj, red, green, blue; int ii, jj, red, green, blue;
char savecolor[4][20], flashcolor[20]; ch savecolor[4][20], flashcolor[20];
if (! strmatch(focus,"line")) return; if (! strmatch(focus,"line")) return;
ii = focusii; ii = focusii;
for (jj = 0; jj < 4; jj++) // save line colors for (jj = 0; jj < 4; jj++) // save line colors
strcpy(savecolor[jj],line[ii].attr.color[jj]); strcpy(savecolor[jj],line[ii].attr.color[jj]);
for (jj = 0; jj < 4; jj++) { // get complimentary colors for (jj = 0; jj < 4; jj++) { // get complimentary colors
red = 255 - atoi(substring(line[ii].attr.color[jj],'|',1)); red = 255 - atoi(substring(line[ii].attr.color[jj],'|',1));
green = 255 - atoi(substring(line[ii].attr.color[jj],'|',2)); green = 255 - atoi(substring(line[ii].attr.color[jj],'|',2));
skipping to change at line 3030 skipping to change at line 3002
setlayoutupdatearea(); // set layout update area setlayoutupdatearea(); // set layout update area
Lupdate(); // update layout composite image Lupdate(); // update layout composite image
return; return;
} }
/******************************************************************************* */ /******************************************************************************* */
// select an image, text image, or line/arrow image - update active dialog // select an image, text image, or line/arrow image - update active dialog
// which = "image" or "text" or "line" or "" to select nothing // which = "image" or "text" or "line" or "" to select nothing
void mashup::select(cchar *which, int ii) void mashup::select(ch *which, int ii)
{ {
using namespace mashup; using namespace mashup;
char *pp; ch *pp;
float rad = 180 / PI; float rad = 180 / PI;
zdialog *zd; zdialog *zd;
if (strmatch(which,"image") && ii >= 0) if (strmatch(which,"image") && ii >= 0)
{ {
if (ii >= Nimage) zappcrash("bad image index"); if (ii >= Nimage) zappcrash("bad image index");
focus = "image"; // for KB key drags focus = "image"; // for KB key drags
focusii = ii; focusii = ii;
zd = zdimage; zd = zdimage;
skipping to change at line 3824 skipping to change at line 3796
// update layout image Fpxb from layout + overlay images // update layout image Fpxb from layout + overlay images
// paint main window // paint main window
void mashup::Lupdate() void mashup::Lupdate()
{ {
using namespace mashup; using namespace mashup;
int nupdxlo, nupdxhi, nupdylo, nupdyhi; int nupdxlo, nupdxhi, nupdylo, nupdyhi;
static int pupdxlo, pupdxhi, pupdylo, pupdyhi; // prior image update region static int pupdxlo, pupdxhi, pupdylo, pupdyhi; // prior image update region
static cchar *pfocus = "x"; static ch *pfocus = "x";
static int pfocusii = -2; // no prior selected image or text static int pfocusii = -2; // no prior selected image or text
int ww, hh; int ww, hh;
if (! Lpxb || ! Fpxb) return; if (! Lpxb || ! Fpxb) return;
if (! strmatch(focus,pfocus) || focusii != pfocusii) // focus image/text/line has changed if (! strmatch(focus,pfocus) || focusii != pfocusii) // focus image/text/line has changed
Fupdall = 1; // update entire layout Fupdall = 1; // update entire layout
pfocus = focus; // remember focus image/text/line pfocus = focus; // remember focus image/text/line
pfocusii = focusii; pfocusii = focusii;
skipping to change at line 4103 skipping to change at line 4075
int Ncols; // image columns in table (input) int Ncols; // image columns in table (input)
int Nrows; // image rows in tablle (calculated) int Nrows; // image rows in tablle (calculated)
int Ihsep, Ivsep; // image separation, horz and vert int Ihsep, Ivsep; // image separation, horz and vert
int Iww, Ihh; // image width, height without margin s int Iww, Ihh; // image width, height without margin s
typedef struct { typedef struct {
int random; // random number for sorting int random; // random number for sorting
int Ihh; // image height (calculated, variable ) int Ihh; // image height (calculated, variable )
int Ipx, Ipy; // image position in table image int Ipx, Ipy; // image position in table image
int row, col; // image row and column number int row, col; // image row and column number
char *file; // image filename ch *file; // image filename
PIXBUF *pixbuf; // scaled image pixbuf PIXBUF *pixbuf; // scaled image pixbuf
} image_t; } image_t;
#define maxNm 1000 // max. images in table #define maxNm 1000 // max. images in table
image_t image[maxNm]; // image data image_t image[maxNm]; // image data
int Nimages; // actual image count int Nimages; // actual image count
int maxNc = 100; // max. columns int maxNc = 100; // max. columns
int maxNr = 100; // max. rows int maxNr = 100; // max. rows
int colH[100]; // column heights int colH[100]; // column heights
char uniquename[100]; // unique table file name ch uniquename[100]; // unique table file name
char tablepath[500]; // suggested folder to save file ch tablepath[500]; // suggested folder to save file
} }
// menu function // menu function
void m_image_table(GtkWidget *, const char *) void m_image_table(GtkWidget *, ch *)
{ {
using namespace image_table_names; using namespace image_table_names;
int image_table_dialog_event(zdialog* zd, const char *event); int image_table_dialog_event(zdialog* zd, ch *event);
int image_table_mapimages(void); int image_table_mapimages(void);
int image_table_showtable(void); int image_table_showtable(void);
int image_table_sort(void); int image_table_sort(void);
int image_table_shuffle(void); int image_table_shuffle(void);
int image_table_spread(void); int image_table_spread(void);
int image_table_mapfile(void); int image_table_mapfile(void);
int ii, nn, err, zstat, ww, hh, makemap; int ii, nn, err, zstat, ww, hh, makemap;
int coldiff, coldiffB, coldiff2; int coldiff, coldiffB, coldiff2;
image_t imageB[maxNm]; image_t imageB[maxNm];
char text[100], *filename, *pp, *pp1, *pp2; ch text[100], *filename, *pp, *pp1, *pp2;
float R; float R;
PXB *pxb1, *pxb2; PXB *pxb1, *pxb2;
F1_help_topic = "image table"; F1_help_topic = "image table";
Plog(1,"m_image_table \n"); Plog(1,"m_image_table \n");
if (FGWM != 'F' && FGWM != 'G') return; if (FGWM != 'F' && FGWM != 'G') return;
if (Fblock("image_table","block edits")) return; // check pend, block if (Fblock("image_table","block edits")) return; // check pend, block
skipping to change at line 4452 skipping to change at line 4424
g_object_unref(image[ii].pixbuf); // free memory g_object_unref(image[ii].pixbuf); // free memory
Fblock("image_table",0); Fblock("image_table",0);
gallery(tablepath,"init",0); gallery(tablepath,"init",0);
gallery(image[0].file,"paint",0); gallery(image[0].file,"paint",0);
m_viewmode(0,"G"); m_viewmode(0,"G");
return; return;
} }
// table dialog event and completion function // table dialog event and completion function
int image_table_dialog_event(zdialog *zd, const char *event) int image_table_dialog_event(zdialog *zd, ch *event)
{ {
using namespace image_table_names; using namespace image_table_names;
char countmess[80]; ch countmess[80];
char colorbutt[20]; ch colorbutt[20];
cchar *pp; ch *pp;
if (strmatch(event,"escape")) zd->zstat = -2; // escape key if (strmatch(event,"escape")) zd->zstat = -2; // escape key
if (strmatch(event,"files")) // select images to process if (strmatch(event,"files")) // select images to process
{ {
zdialog_show(zd,0); zdialog_show(zd,0);
// gallery_select_clear(); // gallery_select_clear();
gallery_select(); // get file list gallery_select(); // get file list
snprintf(countmess,80,"%d image files selected",GScount); snprintf(countmess,80,"%d image files selected",GScount);
zdialog_stuff(zd,"labfcount",countmess); zdialog_stuff(zd,"labfcount",countmess);
skipping to change at line 4550 skipping to change at line 4522
// fill the table image from scaled images and show the table image // fill the table image from scaled images and show the table image
int image_table_showtable() int image_table_showtable()
{ {
using namespace image_table_names; using namespace image_table_names;
uint8 *Fpixels, *pixel; uint8 *Fpixels, *pixel;
int ii, px, py, Frs, col, maxcol = 0; int ii, px, py, Frs, col, maxcol = 0;
int ww, hh, stat, bott, err; int ww, hh, stat, bott, err;
char *file; ch *file;
PIXBUF *Fpixbuf, *pixbuf; PIXBUF *Fpixbuf, *pixbuf;
GError *gerror = 0; GError *gerror = 0;
for (ii = Nimages - Ncols; ii < Nimages; ii++) // loop last Ncols images for (ii = Nimages - Ncols; ii < Nimages; ii++) // loop last Ncols images
{ {
bott = image[ii].Ipy + image[ii].Ihh; // image y position + height bott = image[ii].Ipy + image[ii].Ihh; // image y position + height
if (bott > maxcol) maxcol = bott; // save max. bottom edge if (bott > maxcol) maxcol = bott; // save max. bottom edge
col = image[ii].col; col = image[ii].col;
colH[col] = bott; // save column height colH[col] = bott; // save column height
} }
skipping to change at line 4687 skipping to change at line 4659
int image_table_sort() int image_table_sort()
{ {
using namespace image_table_names; using namespace image_table_names;
int ii; int ii;
int keys[1][3] = { { 0, 4, 3 } }; // key position, length, type int keys[1][3] = { { 0, 4, 3 } }; // key position, length, type
for (ii = 0; ii < Nimages; ii++) // populate random sort key for (ii = 0; ii < Nimages; ii++) // populate random sort key
image[ii].random = 1000000 * drandz(); image[ii].random = 1000000 * drandz();
MemSort((char *) image, sizeof(image_t), Nimages, keys, 1); // sort image[] MemSort((ch *) image, sizeof(image_t), Nimages, keys, 1); // sort image[]
for (ii = 0; ii < Nimages; ii++) for (ii = 0; ii < Nimages; ii++)
{ {
image[ii].row = ii / Ncols; // new image row, column image[ii].row = ii / Ncols; // new image row, column
image[ii].col = ii - Ncols * image[ii].row; image[ii].col = ii - Ncols * image[ii].row;
} }
return 1; return 1;
} }
skipping to change at line 4750 skipping to change at line 4722
// create map file - maps the scaled image areas in the image_table file // create map file - maps the scaled image areas in the image_table file
// to the corresponding image files // to the corresponding image files
int image_table_mapfile() int image_table_mapfile()
{ {
using namespace image_table_names; using namespace image_table_names;
int ii, lox, hix, loy, hiy; int ii, lox, hix, loy, hiy;
float flox, fhix, floy, fhiy; float flox, fhix, floy, fhiy;
char tablemapfile[300]; ch tablemapfile[300];
FILE *fid; FILE *fid;
snprintf(tablemapfile,300,"%s/%s",image_table_maps_folder,uniquename); snprintf(tablemapfile,300,"%s/%s",image_table_maps_folder,uniquename);
fid = fopen(tablemapfile,"w"); fid = fopen(tablemapfile,"w");
if (! fid) { if (! fid) {
zmessageACK(Mwin,strerror(errno)); zmessageACK(Mwin,strerror(errno));
return 1; return 1;
} }
skipping to change at line 4790 skipping to change at line 4762
} }
// mouse function // mouse function
// show the image file corresponding to clicked position in image table file // show the image file corresponding to clicked position in image table file
void image_table_Lclick_func(int mousex, int mousey) void image_table_Lclick_func(int mousex, int mousey)
{ {
using namespace image_table_names; using namespace image_table_names;
typedef struct { typedef struct {
char *file; // image filename ch *file; // image filename
int lox, loy; // scaled image area in table image int lox, loy; // scaled image area in table image
int hix, hiy; int hix, hiy;
} image_t; } image_t;
image_t image[maxNm]; // image data image_t image[maxNm]; // image data
int fww, fhh, Nimages = 0; int fww, fhh, Nimages = 0;
char buff[500], tablemapfile[300]; ch buff[500], tablemapfile[300];
char *pp, *pp1, *pp2, *file; ch *pp, *pp1, *pp2, *file;
int ii, cc, nn; int ii, cc, nn;
float flox, fhix, floy, fhiy; float flox, fhix, floy, fhiy;
FILE *fid; FILE *fid;
fww = Fpxb->ww; // table image dimensions fww = Fpxb->ww; // table image dimensions
fhh = Fpxb->hh; fhh = Fpxb->hh;
pp1 = strrchr(curr_file,'/'); // extract table unique name pp1 = strrchr(curr_file,'/'); // extract table unique name
if (! pp1) goto notfound; if (! pp1) goto notfound;
pp1++; pp1++;
 End of changes. 59 change blocks. 
111 lines changed or deleted 80 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)