cin_db Makefile tweak, awdw vicon stop draw lock rework,
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / titler / titlerwindow.C
index 4b91787c2968297f59eb2165a1597e7434cd8c45..f8705dfd6d8fe2763767de452ad377b2d73b8fb8 100644 (file)
@@ -40,6 +40,7 @@
 #include "pluginserver.h"
 #include "theme.h"
 #include "track.h"
+#include "tracks.h"
 #include "titlerwindow.h"
 #include "bcfontentry.h"
 
@@ -138,6 +139,8 @@ TitleWindow::~TitleWindow()
        delete timecode_format;
        delete title_x;
        delete title_y;
+       delete title_w;
+       delete title_h;
 }
 
 void TitleWindow::create_objects()
@@ -236,7 +239,7 @@ void TitleWindow::create_objects()
        add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
        x += font_tumbler->get_w() + margin;
 
-       int x1 = x, y1 = y;
+       int x1 = x+xS(20), y1 = y;
        add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
        sprintf(string, "%.2f", client->config.size);
        x1 += size_title->get_w() + margin;
@@ -245,7 +248,7 @@ void TitleWindow::create_objects()
        int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
        add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
 
-       add_tool(pitch_title = new BC_Title(x-xS(5), y2+margin, _("Pitch:")));
+       add_tool(pitch_title = new BC_Title(x-xS(16), y2+margin, _("Line Pitch:")));
        pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
        pitch->create_objects();
 
@@ -258,13 +261,13 @@ void TitleWindow::create_objects()
        add_tool(bold = new TitleBold(client, this, x, y + yS(50)));
        if( bold->get_w() > w1 ) w1 = bold->get_w();
 
+       if( client->drag && drag->drag_activate() ) {
+               eprintf("drag enabled, but compositor already grabbed\n");
+               client->drag = 0;
+       }
        add_tool(drag = new TitleDrag(client, this, x, y + yS(80)));
        drag->create_objects();
        if( drag->get_w() > w1 ) w1 = drag->get_w();
-       if( client->config.drag ) {
-               if( drag->drag_activate() )
-                       eprintf("drag enabled, but compositor already grabbed\n");
-       }
 
        add_tool(alias = new TitleAlias(client, this, x, y+yS(110)));
        if( alias->get_w() > w1 ) w1 = drag->get_w();
@@ -530,9 +533,9 @@ int TitleWindow::insert_ibeam(const char *txt, int ofs)
 {
        int ibeam = cur_ibeam;
        int ilen = strlen(txt)+1;
-       wchar_t wtxt[ilen];
+       wchr_t wtxt[ilen];
        int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
-               (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchar_t);
+               (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchr_t);
        client->insert_text(wtxt, ibeam);
        while( len > 0 && !wtxt[len] ) --len;
        int adv = len+1 + ofs;
@@ -571,6 +574,10 @@ void TitleWindow::update_gui()
        title_y->update((int64_t)client->config.title_y);
        title_w->update((int64_t)client->config.title_w);
        title_h->update((int64_t)client->config.title_h);
+       drag->drag_x = client->config.title_x;
+       drag->drag_y = client->config.title_y;
+       drag->drag_w = client->config.title_w;
+       drag->drag_h = client->config.title_h;
        italic->update(client->config.style & BC_FONT_ITALIC);
        bold->update(client->config.style & BC_FONT_BOLD);
        alias->update(client->config.style & FONT_ALIAS);
@@ -582,7 +589,8 @@ void TitleWindow::update_gui()
        fade_out->update((float)client->config.fade_out);
        font->update(client->config.font);
        check_style(client->config.font,0);
-       text->update(client->config.wtext ? &client->config.wtext[0] : L"");
+       wchr_t wz[1] = { 0 };
+       text->update(client->config.wtext ? &client->config.wtext[0] : wz);
        speed->update(client->config.pixels_per_second);
        outline->update((int64_t)client->config.outline_size);
 #ifdef USE_STROKER
@@ -987,10 +995,10 @@ int TitleText::button_press_event()
 int TitleText::handle_event()
 {
        window->fonts_popup->deactivate();
-       const wchar_t *wtext = get_wtext();
-       long wlen = wcslen(wtext);
+       const wchr_t *wtext = get_wtext();
+       long wlen = wstrlen(wtext);
        client->config.demand(wlen);
-       wcsncpy(client->config.wtext, wtext, client->config.wsize);
+       wstrncpy(client->config.wtext, wtext, client->config.wsize);
        client->config.wlen = wlen;
        window->update_stats();
        window->send_configure_change();
@@ -1226,7 +1234,7 @@ int TitleBottom::handle_event()
 }
 
 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
- : DragCheckBox(client->server->mwindow, x, y, _("Drag"), &client->config.drag,
+ : DragCheckBox(client->server->mwindow, x, y, _("Drag"), &client->drag,
                client->config.title_x, client->config.title_y,
                client->config.title_w, client->config.title_h)
 {
@@ -1236,8 +1244,10 @@ TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
 
 Track *TitleDrag::get_drag_track()
 {
-       return !client->server->plugin ? 0 :
-               client->server->plugin->track;
+       PluginServer *server = client->server;
+       int plugin_id = server->plugin_id;
+       Plugin *plugin = server->edl->tracks->plugin_exists(plugin_id);
+       return !plugin ? 0 : plugin->track;
 }
 int64_t TitleDrag::get_drag_position()
 {
@@ -1246,7 +1256,7 @@ int64_t TitleDrag::get_drag_position()
 
 void TitleDrag::update_gui()
 {
-       client->config.drag = get_value();
+       client->drag = get_value();
        client->config.title_x = drag_x;
        client->config.title_y = drag_y;
        client->config.title_w = drag_w+0.5;
@@ -1261,6 +1271,7 @@ void TitleDrag::update_gui()
 int TitleDrag::handle_event()
 {
        int ret = DragCheckBox::handle_event();
+       client->drag = get_value();
        window->send_configure_change();
        return ret;
 }
@@ -1545,7 +1556,7 @@ void TitlePngPopup::handle_done_event(int result)
        if( result ) return;
        BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
        const char *path = gui->get_submitted_path();
-       char txt[BCSTRLEN];  sprintf(txt, "<%s %s>", _(KW_PNG), path);
+       char txt[BCTEXTLEN];  sprintf(txt, "<%s %s>", _(KW_PNG), path);
        window->lock_window("TitlePngPopup::handle_done_event");
        window->insert_ibeam(txt);
        window->unlock_window();