X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Ftitler%2Ftitlerwindow.C;h=21270b6825466d21f3e743118267bf4d9005cba0;hp=6ad7e48d258dbeffe171f5193d8b7eaa8a78dc69;hb=128492e56ad719c2173a56379f423f6791f14906;hpb=2e28d225c343f02500594688bf8d0528df40600c diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.C b/cinelerra-5.1/plugins/titler/titlerwindow.C index 6ad7e48d..21270b68 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.C +++ b/cinelerra-5.1/plugins/titler/titlerwindow.C @@ -40,9 +40,12 @@ #include "pluginserver.h" #include "theme.h" #include "track.h" +#include "tracks.h" #include "titlerwindow.h" #include "bcfontentry.h" +#define DEFAULT_TIMECODEFORMAT TIME_HMSF + static const int timeunit_formats[] = { TIME_HMS, @@ -56,7 +59,8 @@ static const int timeunit_formats[] = TitleWindow::TitleWindow(TitleMain *client) : PluginClientWindow(client, - client->config.window_w, client->config.window_h, 100, 100, 1) + client->config.window_w, client->config.window_h, + xS(100), yS(100), 1) { //printf("TitleWindow::TitleWindow %d %d %d\n", __LINE__, client->config.window_w, client->config.window_h); this->client = client; @@ -118,6 +122,8 @@ TitleWindow::TitleWindow(TitleMain *client) void TitleWindow::done_event(int result) { + color_button->close_picker(); + outline_button->close_picker(); drag->drag_deactivate(); delete color_popup; color_popup = 0; delete png_popup; png_popup = 0; @@ -135,16 +141,18 @@ TitleWindow::~TitleWindow() delete timecode_format; delete title_x; delete title_y; + delete title_w; + delete title_h; } void TitleWindow::create_objects() { - int x = 10, y = 10; + int x = xS(10), y = yS(10); int margin = client->get_theme()->widget_border; char string[BCTEXTLEN]; -#define COLOR_W 50 -#define COLOR_H 30 +#define COLOR_W xS(50) +#define COLOR_H yS(30) client->build_previews(this); sizes.append(new BC_ListBoxItem("8")); @@ -233,7 +241,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; @@ -242,46 +250,46 @@ 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-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(); - int x3 = x2 + size_tumbler->get_w() + 50; + int x3 = x2 + size_tumbler->get_w() + xS(50); int y3 = pitch->get_y() + pitch->get_h(); add_tool(style_title = new BC_Title(x=x3, y, _("Style:"))); - add_tool(italic = new TitleItalic(client, this, x, y + 20)); + add_tool(italic = new TitleItalic(client, this, x, y + yS(20))); int w1 = italic->get_w(); - add_tool(bold = new TitleBold(client, this, x, y + 50)); + add_tool(bold = new TitleBold(client, this, x, y + yS(50))); if( bold->get_w() > w1 ) w1 = bold->get_w(); - add_tool(drag = new TitleDrag(client, this, x, y + 80)); + 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+110)); + add_tool(alias = new TitleAlias(client, this, x, y+yS(110))); if( alias->get_w() > w1 ) w1 = drag->get_w(); x += w1 + margin; - add_tool(justify_title = new BC_Title(x+50, y, _("Justify:"))); - add_tool(left = new TitleLeft(client, this, x, y + 20)); + add_tool(justify_title = new BC_Title(x+xS(50), y, _("Justify:"))); + add_tool(left = new TitleLeft(client, this, x, y + yS(20))); w1 = left->get_w(); - add_tool(center = new TitleCenter(client, this, x, y + 50)); + add_tool(center = new TitleCenter(client, this, x, y + yS(50))); if( center->get_w() > w1 ) w1 = center->get_w(); - add_tool(right = new TitleRight(client, this, x, y + 80)); + add_tool(right = new TitleRight(client, this, x, y + yS(80))); if( right->get_w() > w1 ) w1 = right->get_w(); x += w1 + margin; - add_tool(top = new TitleTop(client, this, x, y + 20)); - add_tool(mid = new TitleMid(client, this, x, y + 50)); - add_tool(bottom= new TitleBottom(client, this, x, y + 80)); + add_tool(top = new TitleTop(client, this, x, y + yS(20))); + add_tool(mid = new TitleMid(client, this, x, y + yS(50))); + add_tool(bottom= new TitleBottom(client, this, x, y + yS(80))); x = margin; - y = y3+10; + y = y3+yS(10); w1 = BC_Title::calculate_w(this, _("X:")); if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1; @@ -310,70 +318,82 @@ void TitleWindow::create_objects() title_h->create_objects(); x1 += title_h->get_w(); - x = x1+2*margin; + x = x1+xS(2)*margin; add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:"))); x1 += motion_title->get_w()+margin; motion = new TitleMotion(client, this, x1, y); motion->create_objects(); add_tool(loop = new TitleLoop(client, this, x, y1)); - x = margin; y = y1 + loop->get_h()+20; + x = margin; y = y1 + loop->get_h()+yS(20); add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:"))); w1 = dropshadow_title->get_w(); - dropshadow = new TitleDropShadow(client, this, x, y + 20); + dropshadow = new TitleDropShadow(client, this, x, y + yS(20)); dropshadow->create_objects(); if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w(); x += w1 + margin; add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):"))); w1 = fadein_title->get_w(); - add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20)); + add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + yS(20))); if( fade_in->get_w() > w1 ) w1 = fade_in->get_w(); x += w1 + margin; add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):"))); w1 = fadeout_title->get_w(); - add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20)); + add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + yS(20))); if( fade_out->get_w() > w1 ) w1 = fade_out->get_w(); x += w1 + margin; add_tool(speed_title = new BC_Title(x, y, _("Speed:"))); w1 = speed_title->get_w(); - y += speed_title->get_h() + 5; y1 = y; + y += speed_title->get_h() + yS(5); y1 = y; speed = new TitleSpeed(client, this, x, y); speed->create_objects(); if( speed->get_w() > w1 ) w1 = speed->get_w(); x += w1 + margin; - y2 = y + speed->get_h() + 10; + y2 = y + speed->get_h() + yS(10); - add_tool(color_button_title = new BC_Title(x3, y1+10, _("Color:"))); - x1 = x3 + color_button_title->get_w() + 30; + add_tool(color_button_title = new BC_Title(x3, y1+yS(10), _("Color:"))); + x1 = x3 + color_button_title->get_w() + xS(30); add_tool(color_button = new TitleColorButton(client, this, x1, y1)); - y1 += color_button->get_h() + 10; - add_tool(outline_button_title = new BC_Title(x3, y1+10, _("Outline:"))); + y1 += color_button->get_h() + yS(10); + add_tool(outline_button_title = new BC_Title(x3, y1+yS(10), _("Outline:"))); add_tool(outline_button = new TitleOutlineColorButton(client, this, x1, y1)); - x = 10; y = y2; + x = yS(10); y = y2; add_tool(outline_title = new BC_Title(x, y, _("Outline:"))); y1 = y + outline_title->get_h() + margin; outline = new TitleOutline(client, this, x, y1); outline->create_objects(); - x += outline->get_w() + 2*margin; + x += outline->get_w() + xS(2)*margin; #ifdef USE_STROKER add_tool(stroker_title = new BC_Title(x, y, _("Stroker:"))); stroker = new TitleStroker(client, this, x, y1); stroker->create_objects(); x += stroker->get_w() + margin; #endif - y += outline_title->get_h() + margin; - add_tool(timecode = new TitleTimecode(client, this, x1=x, y)); - x += timecode->get_w() + margin; - add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y, + // my reset button + // + add_tool(reset_button = new TitleResetButton(client, this, x3, y1+yS(30))); + reset_button->create_objects(); + + + add_tool(timecode = new TitleTimecode(client, this, x, y)); + y += timecode->get_h() + margin; + int tw = 0; + for( int i=0; iconfig.timecode_format, string))); timecode_format->create_objects(); y += timecode_format->get_h() + margin; - x = 10; + x = xS(10); add_tool(background = new TitleBackground(client, this, x, y)); x += background->get_w() + margin; add_tool(background_path = new TitleBackgroundPath(client, this, x, y)); @@ -381,19 +401,19 @@ void TitleWindow::create_objects() add_tool(background_browse = new BrowseButton( client->server->mwindow->theme, this, background_path, x, y, "", _("background media"), _("Select background media path"))); - x += background_browse->get_w() + 3*margin; + x += background_browse->get_w() + xS(3)*margin; add_tool(loop_playback = new TitleLoopPlayback(client, this, x, y)); - y += loop_playback->get_h() + 10; + y += loop_playback->get_h() + yS(10); - x = 10; + x = xS(10); add_tool(text_title = new BC_Title(x, y, _("Text:"))); - x += text_title->get_w() + 20; - int wid = BC_Title::calculate_w(this,"0")*10; + x += text_title->get_w() + xS(20); + int wid = BC_Title::calculate_w(this,"0")*xS(10); add_tool(text_chars = new TitleTextChars(x,y,wid)); y += text_title->get_h() + margin; x = margin; - text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10); + text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - yS(10)); text->create_objects(); add_tool(cur_popup = new TitleCurPopup(client, this)); @@ -403,7 +423,7 @@ void TitleWindow::create_objects() png_popup = new TitlePngPopup(client, this); show_window(1); - update(); + update_gui(); } int TitleWindow::resize_event(int w, int h) @@ -434,6 +454,7 @@ int TitleWindow::resize_event(int w, int h) pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y()); pitch->reposition_window(pitch->get_x(), pitch->get_y()); + reset_button->reposition_window(reset_button->get_x(), reset_button->get_y()); color_button_title->reposition_window(color_button_title->get_x(), color_button_title->get_y()); color_button->reposition_window(color_button->get_x(), color_button->get_y()); outline_button_title->reposition_window(outline_button_title->get_x(), outline_button_title->get_y()); @@ -449,8 +470,8 @@ int TitleWindow::resize_event(int w, int h) fade_out->reposition_window(fade_out->get_x(), fade_out->get_y()); text_title->reposition_window(text_title->get_x(), text_title->get_y()); timecode->reposition_window(timecode->get_x(), timecode->get_y()); - text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10, - BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10)); + text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - xS(10), + BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - yS(10))); justify_title->reposition_window(justify_title->get_x(), justify_title->get_y()); left->reposition_window(left->get_x(), left->get_y()); center->reposition_window(center->get_x(), center->get_y()); @@ -482,8 +503,9 @@ void TitleWindow::send_configure_change() void TitleWindow::previous_font() { int current_font = font->get_number(); - current_font--; - if( current_font < 0 ) current_font = fonts.total - 1; + if( !fonts.total ) current_font = -1; + else if( --current_font < 0 ) current_font = fonts.total - 1; + font->set_number(current_font); if( current_font < 0 || current_font >= fonts.total ) return; @@ -500,8 +522,9 @@ void TitleWindow::previous_font() void TitleWindow::next_font() { int current_font = font->get_number(); - current_font++; - if( current_font >= fonts.total ) current_font = 0; + if( !fonts.total ) current_font = -1; + else if( ++current_font >= fonts.total ) current_font = 0; + font->set_number(current_font); if( current_font < 0 || current_font >= fonts.total ) return; @@ -519,9 +542,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; @@ -554,16 +577,21 @@ void TitleWindow::update_stats() text_chars->update(client->config.wlen); } -void TitleWindow::update() +void TitleWindow::update_gui() { title_x->update((int64_t)client->config.title_x); 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); size->update(client->config.size); + pitch->update((int64_t)client->config.line_pitch); motion->update(TitleMain::motion_to_text(client->config.motion_strategy)); loop->update(client->config.loop); dropshadow->update((int64_t)client->config.dropshadow); @@ -571,7 +599,8 @@ void TitleWindow::update() 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 @@ -719,7 +748,7 @@ int TitleItalic::handle_event() TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text) - : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300) + : BC_PopupTextBox(window, &window->sizes, text, x, y, xS(64), yS(300)) { this->client = client; this->window = window; @@ -743,7 +772,7 @@ void TitleSize::update(int size) TitlePitch:: TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value) - : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64) + : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, xS(64)) { this->client = client; this->window = window; @@ -762,6 +791,62 @@ int TitlePitch::handle_event() return 1; } + + +TitleResetButton::TitleResetButton(TitleMain *client, TitleWindow *window, int x, int y) + : BC_GenericButton (x, y, _("Reset")) +{ + this->client = client; + this->window = window; + set_tooltip("Reset to default values"); +} + +TitleResetButton:: +~TitleResetButton() +{ +} + +int TitleResetButton::handle_event() +{ + strcpy(client->config.font, "fixed"); + client->config.title_x = 0; + client->config.title_y = 0; + client->config.title_w = 0; + client->config.title_h = 0; + client->config.hjustification = JUSTIFY_CENTER; + client->config.vjustification = JUSTIFY_MID; + client->config.style = FONT_ALIAS; + client->config.motion_strategy = NO_MOTION; + client->config.timecode_format = DEFAULT_TIMECODEFORMAT; + client->config.loop = 0; + client->config.dropshadow = 0; + client->config.fade_in = 0; + client->config.fade_out = 0; + client->config.pixels_per_second = 100; + client->config.outline_size = 0; + client->config.outline_color = RED; + client->config.outline_alpha = 0xff; + client->config.color_stroke = 0xff0000; + client->config.size = 48; + client->config.line_pitch = 0; + client->config.color = WHITE; + client->config.alpha = 0xff; + client->config.timecode = 0; + client->config.background = 0; + strcpy(client->config.background_path, ""); +#ifdef USE_STROKER + client->config.stroke_width = 0; +#endif + client->config.loop_playback = 0; + client->config.wlen = 0; + wchr_t wz = { 0 }; + client->config.wtext[0] = wz; + window->send_configure_change(); + window->update_gui(); + window->flush(); + return 1; +} + TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y) : ColorCircleButton(_("Text Color"), x, y, COLOR_W, COLOR_H, client->config.color, client->config.alpha, 1) @@ -780,7 +865,9 @@ void TitleColorButton::handle_done_event(int result) { if( result ) { handle_new_color(orig_color, orig_alpha); + window->lock_window("TitleColorButton::handle_done_event"); update_gui(orig_color); + window->unlock_window(); } } @@ -802,7 +889,9 @@ void TitleOutlineColorButton::handle_done_event(int result) { if( result ) { handle_new_color(orig_color, orig_alpha); + window->lock_window("TitleColorButton::handle_done_event"); update_gui(orig_color); + window->unlock_window(); } } @@ -810,7 +899,7 @@ void TitleOutlineColorButton::handle_done_event(int result) TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y) : BC_PopupTextBox(window, &window->paths, client->motion_to_text(client->config.motion_strategy), - x, y, 120, 100) + x, y, xS(120), yS(100)) { this->client = client; this->window = window; @@ -848,8 +937,8 @@ int TitleTimecode::handle_event() } TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window, - int x, int y, const char *text) - : BC_PopupMenu(x, y, 100, text, 1) + int x, int y, int tw, const char *text) + : BC_PopupMenu(x, y, BC_PopupMenu::calculate_w(tw)+xS(10), text, 1) { this->client = client; this->window = window; @@ -886,7 +975,7 @@ int TitleTimecodeFormat::update(int timecode_format) TitleFade::TitleFade(TitleMain *client, TitleWindow *window, double *value, int x, int y) - : BC_TextBox(x, y, 80, 1, (float)*value) + : BC_TextBox(x, y, xS(80), 1, (float)*value) { this->client = client; this->window = window; @@ -928,13 +1017,14 @@ void TitleWindow::check_style(const char *font_name, int update) int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0; if( bold->get_value() ) style |= BC_FONT_BOLD; if( italic->get_value() ) style |= BC_FONT_ITALIC; + if( alias->get_value() ) style |= FONT_ALIAS; client->config.style = style; } } TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y) : BC_PopupTextBox(window, &window->fonts, client->config.font, - x, y, 340, 300, LISTBOX_ICON_LIST) + x, y, xS(340), yS(300), LISTBOX_ICON_LIST) { this->client = client; this->window = window; @@ -971,10 +1061,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(); @@ -997,7 +1087,7 @@ int TitleTextChars::update(int n) TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.dropshadow, - -1000, 1000, x, y, 70) + -1000, 1000, x, y, xS(70)) { this->client = client; this->window = window; @@ -1012,7 +1102,7 @@ int TitleDropShadow::handle_event() TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.outline_size, - 0.f, 1000.f, x, y, 70) + 0.f, 1000.f, x, y, xS(70)) { this->client = client; this->window = window; @@ -1028,7 +1118,7 @@ int TitleOutline::handle_event() TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.stroke_width, - 0.f, 1000.f, x, y, 70) + 0.f, 1000.f, x, y, xS(70)) { this->client = client; this->window = window; @@ -1048,7 +1138,7 @@ int TitleStroker::handle_event() TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.title_x, - -32767.f, 32767.f, x, y, 50) + -32767.f, 32767.f, x, y, xS(50)) { this->client = client; this->window = window; @@ -1063,7 +1153,7 @@ int TitleX::handle_event() TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.title_y, - -32767.f, 32767.f, x, y, 50) + -32767.f, 32767.f, x, y, xS(50)) { this->client = client; this->window = window; @@ -1078,7 +1168,7 @@ int TitleY::handle_event() TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.title_w, - 0, 32767, x, y, 50) + 0, 32767, x, y, xS(50)) { this->client = client; this->window = window; @@ -1092,7 +1182,7 @@ int TitleW::handle_event() TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.title_h, - 0, 32767, x, y, 50) + 0, 32767, x, y, xS(50)) { this->client = client; this->window = window; @@ -1106,7 +1196,7 @@ int TitleH::handle_event() TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y) : BC_TumbleTextBox(window, client->config.pixels_per_second, - 0.f, 1000.f, x, y, 100) + 0.f, 1000.f, x, y, xS(100)) { this->client = client; this->window = window; @@ -1210,7 +1300,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) { @@ -1220,7 +1310,10 @@ TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y) Track *TitleDrag::get_drag_track() { - return 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() { @@ -1229,7 +1322,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; @@ -1244,6 +1337,7 @@ void TitleDrag::update_gui() int TitleDrag::handle_event() { int ret = DragCheckBox::handle_event(); + client->drag = get_value(); window->send_configure_change(); return ret; } @@ -1263,7 +1357,7 @@ int TitleBackground::handle_event() } TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y) - : BC_TextBox(x, y, 240, 1, client->config.background_path) + : BC_TextBox(x, y, xS(240), 1, client->config.background_path) { this->client = client; this->window = window; @@ -1419,17 +1513,81 @@ TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *t TitleCurSubMenuItem::~TitleCurSubMenuItem() { } + +// from https://stackoverflow.com/questions/779875/what-function-is-to-replace-a-substring-from-a-string-in-c +void strreplace(char *src, char *str, char *rep) +{ + char *p = strstr(src, str); + if (p) + { + int len = strlen(src)+strlen(rep)-strlen(str); + char r[len]; + memset(r, 0, len); + if ( p >= src ){ + strncpy(r, src, p-src); + r[p-src]='\0'; + strncat(r, rep, strlen(rep)); + strncat(r, p+strlen(str), p+strlen(str)-src+strlen(src)); + strcpy(src, r); + strreplace(p+strlen(rep), str, rep); + } + } +} + + int TitleCurSubMenuItem::handle_event() { TitleCurPopup *popup = submenu->cur_item->popup; TitleWindow *window = popup->window; - const char *item_text = get_text(); + char *item_text = N_(get_text()); + + if (strstr(item_text, _(KW_NUDGE))) { + strreplace(item_text, _(KW_NUDGE), (char*)N_(KW_NUDGE)); + } + else if (strstr(item_text, _(KW_COLOR))) { + strreplace(item_text, _(KW_COLOR), (char*)N_(KW_COLOR)); + } + else if (strstr(item_text, _(KW_ALPHA))) { + strreplace(item_text, _(KW_ALPHA), (char*)N_(KW_ALPHA)); + } + else if (strstr(item_text, _(KW_FONT))) { + strreplace(item_text, _(KW_FONT), (char*)N_(KW_FONT)); + } + else if (strstr(item_text, _(KW_SIZE))) { + strreplace(item_text, _(KW_SIZE), (char*)N_(KW_SIZE)); + } + else if (strstr(item_text, _(KW_BOLD))) { + strreplace(item_text, _(KW_BOLD), (char*)N_(KW_BOLD)); + } + else if (strstr(item_text, _(KW_ITALIC))) { + strreplace(item_text, _(KW_ITALIC), (char*)N_(KW_ITALIC)); + } + else if (strstr(item_text, _(KW_CAPS))) { + strreplace(item_text, _(KW_CAPS), (char*)N_(KW_CAPS)); + } + else if (strstr(item_text, _(KW_UL))) { + strreplace(item_text, _(KW_UL), (char*)N_(KW_UL)); + } + else if (strstr(item_text, _(KW_BLINK))) { + strreplace(item_text, _(KW_BLINK), (char*)N_(KW_BLINK)); + } + else if (strstr(item_text, _(KW_FIXED))) { + strreplace(item_text, _(KW_FIXED), (char*)N_(KW_FIXED)); + } + else if (strstr(item_text, _(KW_ALIAS))) { + strreplace(item_text, _(KW_ALIAS), (char*)N_(KW_ALIAS)); + } + else if (strstr(item_text, _(KW_SUP))) { + strreplace(item_text, _(KW_SUP), (char*)N_(KW_SUP)); + } + + int ofs = *item_text == '/' ? 0 : -1; switch( popup_type ) { case POPUP_FONT: { int px, py; window->get_pop_cursor(px ,py); - window->fonts_popup->activate(px, py, 300,200); + window->fonts_popup->activate(px, py, xS(300),yS(200)); return 1; } case POPUP_COLOR: { window->color_popup->activate(); @@ -1442,8 +1600,51 @@ int TitleCurSubMenuItem::handle_event() break; } char txt[BCSTRLEN]; - sprintf(txt, "<%s>", item_text); - return window->insert_ibeam(txt, ofs); + sprintf(txt, "<%s>", N_(item_text)); + //printf("Item text: %s \n", N_(item_text)); + + if (strstr(item_text, N_(KW_NUDGE))) { + strreplace(item_text, (char*)N_(KW_NUDGE), _(KW_NUDGE)); + } + else if (strstr(item_text, N_(KW_COLOR))) { + strreplace(item_text, (char*)N_(KW_COLOR), _(KW_COLOR)); + } + else if (strstr(item_text, N_(KW_ALPHA))) { + strreplace(item_text, (char*)N_(KW_ALPHA), _(KW_ALPHA)); + } + else if (strstr(item_text, N_(KW_FONT))) { + strreplace(item_text, (char*)N_(KW_FONT), _(KW_FONT)); + } + else if (strstr(item_text, N_(KW_SIZE))) { + strreplace(item_text, (char*)N_(KW_SIZE), _(KW_SIZE)); + } + else if (strstr(item_text, N_(KW_BOLD))) { + strreplace(item_text, (char*)N_(KW_BOLD), _(KW_BOLD)); + } + else if (strstr(item_text, N_(KW_ITALIC))) { + strreplace(item_text, (char*)N_(KW_ITALIC), _(KW_ITALIC)); + } + else if (strstr(item_text, N_(KW_CAPS))) { + strreplace(item_text, (char*)N_(KW_CAPS), _(KW_CAPS)); + } + else if (strstr(item_text, N_(KW_UL))) { + strreplace(item_text, (char*)N_(KW_UL), _(KW_UL)); + } + else if (strstr(item_text, N_(KW_BLINK))) { + strreplace(item_text, (char*)N_(KW_BLINK), _(KW_BLINK)); + } + else if (strstr(item_text, N_(KW_FIXED))) { + strreplace(item_text, (char*)N_(KW_FIXED), _(KW_FIXED)); + } + else if (strstr(item_text, N_(KW_ALIAS))) { + strreplace(item_text, (char*)N_(KW_ALIAS), _(KW_ALIAS)); + } + else if (strstr(item_text, N_(KW_SUP))) { + strreplace(item_text, (char*)N_(KW_SUP), _(KW_SUP)); + } + + + return window->insert_ibeam(N_(txt), ofs); } TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window) @@ -1477,7 +1678,7 @@ int TitleFontsPopup::handle_event() BC_ListBoxItem *item = get_selection(0, 0); if( !item ) return 1; const char *item_text = item->get_text(); - char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", _(KW_FONT), item_text); + char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", N_(KW_FONT), item_text); return window->insert_ibeam(txt); } @@ -1505,7 +1706,9 @@ void TitleColorPopup::handle_done_event(int result) { if( !result ) { char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", _(KW_COLOR), color_value); + window->lock_window("TitleColorPopup::handle_done_event"); window->insert_ibeam(txt); + window->unlock_window(); } } @@ -1526,8 +1729,10 @@ 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(); } BC_Window *TitlePngPopup::new_gui() @@ -1536,7 +1741,7 @@ BC_Window *TitlePngPopup::new_gui() int x, y; mwindow->gui->get_abs_cursor(x, y); BC_Window *gui = new BrowseButtonWindow(mwindow->theme, - x-25, y-100, window, "", _("Png file"), _("Png path"), 0); + x-xS(25), y-yS(100), window, "", _("Png file"), _("Png path"), 0); gui->create_objects(); return gui; }