X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fsvg%2Fsvgwin.C;h=c0dc11d2b0e3c1e0097ea8dbcb506663e1ce0a94;hp=028a9307772c470aa2645bcf02f72064bda947ba;hb=refs%2Fheads%2Fmaster;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/plugins/svg/svgwin.C b/cinelerra-5.1/plugins/svg/svgwin.C index 028a9307..c0dc11d2 100644 --- a/cinelerra-5.1/plugins/svg/svgwin.C +++ b/cinelerra-5.1/plugins/svg/svgwin.C @@ -1,4 +1,3 @@ - /* * CINELERRA * Copyright (C) 2008 Adam Williams @@ -35,8 +34,6 @@ #include -#include "empty_svg.h" - struct fifo_struct { int pid; // 1 = update from client, 2 = client closes, 3 = quit @@ -44,7 +41,7 @@ struct fifo_struct { }; SvgWin::SvgWin(SvgMain *client) - : PluginClientWindow(client, 420, 210, 420, 210, 1) + : PluginClientWindow(client, xS(420), yS(210), xS(420), yS(210), 1) { this->client = client; this->editing = 0; @@ -56,19 +53,21 @@ SvgWin::~SvgWin() void SvgWin::create_objects() { + int xs10 = xS(10), xs15 = xS(15); + int ys5 = yS(5), ys10 = yS(10), ys20 = yS(20), ys15 = yS(15); BC_Title *title; - int x0 = 10, y = 10; + int x0 = xs10, y = ys10; add_tool(title = new BC_Title(x0, y, _("Out X:"))); - int x1 = x0 + title->get_w() + 10; + int x1 = x0 + title->get_w() + xs10; out_x = new SvgCoord(this, client, x1, y, &client->config.out_x); out_x->create_objects(); - int x2 = x1 + out_x->get_w() + 15; + int x2 = x1 + out_x->get_w() + xs15; add_tool(title = new BC_Title(x2, y, _("Out W:"))); - int x3 = x2 + title->get_w() + 10; + int x3 = x2 + title->get_w() + xs10; out_w = new SvgCoord(this, client, x3, y, &client->config.out_w); out_w->create_objects(); - y += out_x->get_h() + 5; + y += out_x->get_h() + ys5; add_tool(new BC_Title(x0, y, _("Out Y:"))); out_y = new SvgCoord(this, client, x1, y, &client->config.out_y); @@ -76,17 +75,17 @@ void SvgWin::create_objects() add_tool(title = new BC_Title(x2, y, _("Out H:"))); out_h = new SvgCoord(this, client, x3, y, &client->config.out_h); out_h->create_objects(); - y += out_y->get_h() + 20; + y += out_y->get_h() + ys20; add_tool(title = new BC_Title(x0, y, _("DPI:"))); dpi = new DpiValue(this, client, x1, y, &client->config.dpi); dpi->create_objects(); add_tool(dpi_button = new DpiButton(this, client, x2, y)); dpi_button->create_objects(); - y += dpi->get_h() + 20; + y += dpi->get_h() + ys20; add_tool(svg_file_title = new BC_Title(x0, y, client->config.svg_file)); - y += svg_file_title->get_h() + 5; + y += svg_file_title->get_h() + ys5; struct stat st; int64_t ms_time = stat(client->config.svg_file, &st) ? 0 : st.st_mtim.tv_sec*1000 + st.st_mtim.tv_nsec/1000000; @@ -96,12 +95,12 @@ void SvgWin::create_objects() ctime_r(&tm ,mtime); } add_tool(svg_file_mstime = new BC_Title(x0, y, mtime)); - y += svg_file_mstime->get_h() + 15; + y += svg_file_mstime->get_h() + ys15; - y = get_h() - NewSvgButton::calculate_h() - 5; + y = get_h() - NewSvgButton::calculate_h() - ys5; add_tool(new_svg_button = new NewSvgButton(client, this, x0, y)); - y = get_h() - EditSvgButton::calculate_h() - 5; - add_tool(edit_svg_button = new EditSvgButton(client, this, x0+300, y)); + y = get_h() - EditSvgButton::calculate_h() - ys5; + add_tool(edit_svg_button = new EditSvgButton(client, this, x0+xS(300), y)); show_window(); flush(); @@ -142,7 +141,7 @@ void SvgWin::update_gui(SvgConfig &config) } SvgCoord::SvgCoord(SvgWin *win, SvgMain *client, int x, int y, float *value) - : BC_TumbleTextBox(win, *value, (float)0, (float)3000, x, y, 100) + : BC_TumbleTextBox(win, *value, (float)0, (float)3000, x, y, xS(100)) { //printf("SvgWidth::SvgWidth %f\n", client->config.w); this->client = client; @@ -210,7 +209,9 @@ void NewSvgButton::run() } new_window = new NewSvgWindow(client, window, directory); new_window->create_objects(); + new_window->lock_window("NewSvgButton::run"); new_window->update_filter("*.svg"); + new_window->unlock_window(); result = new_window->run_window(); const char *filepath = new_window->get_path(0); strcpy(filename, filepath ? filepath : "" ); @@ -232,8 +233,13 @@ void NewSvgButton::run() else { FILE *out = fopen(filename,"w"); if( out ) { - unsigned long size = sizeof(empty_svg) - 4; - fwrite(empty_svg+4, size, 1, out); + extern unsigned char _binary_new_svg_start[]; + extern unsigned char _binary_new_svg_end[]; + unsigned int *ip = (unsigned int *)_binary_new_svg_start; + unsigned int hdr_sz = *ip++; + unsigned char *dp = (unsigned char *)ip + hdr_sz; + unsigned char *ep = _binary_new_svg_end; + fwrite(dp, ep - dp, 1, out); fclose(out); result = 0; } @@ -338,9 +344,9 @@ void EditSvgButton::run() if( ret != sizeof(fifo_buf) ) continue; switch( fifo_buf.action ) { case 1: break; - case 2: printf(_("Inkscape has exited\n")); + case 2: // printf(_("Inkscape has exited\n")); break; - case 3: printf(_("Plugin window has closed\n")); + case 3: // printf(_("Plugin window has closed\n")); done = 1; break; } @@ -430,7 +436,7 @@ NewSvgWindow::~NewSvgWindow() {} DpiValue::DpiValue(SvgWin *win, SvgMain *client, int x, int y, float *value) - : BC_TumbleTextBox(win, *value, (float)10, (float)1000, x, y, 100) + : BC_TumbleTextBox(win, *value, 10.f, 1000.f, x, y, xS(100), 2) { //printf("SvgWidth::SvgWidth %f\n", client->config.w); this->client = client;