In my crashy patch I forgot to add this call: reset_button->create_objects();
Now, it seems to NOT crash :} will try to make one-thing-per-patch patch soon.
diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.C b/cinelerra-5.1/plugins/titler/titlerwindow.C index f8705dfd..fcf9784f 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.C +++ b/cinelerra-5.1/plugins/titler/titlerwindow.C @@ -44,6 +44,7 @@ #include "titlerwindow.h" #include "bcfontentry.h" + static const int timeunit_formats[] = { TIME_HMS, @@ -371,6 +372,12 @@ void TitleWindow::create_objects() stroker->create_objects(); x += stroker->get_w() + margin; #endif + // 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; @@ -446,6 +453,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()); @@ -781,6 +789,47 @@ 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; +} + +TitleResetButton:: +~TitleResetButton() +{ +} + +int TitleResetButton::handle_event() +{ + client->config.title_x = 0; + client->config.title_y = 0; + client->config.title_w = 0; + client->config.title_h = 0; + client->config.loop = 0; + client->config.dropshadow =0; + client->config.fade_in = 0; + client->config.fade_out = 0; + client->config.pixels_per_second = 0; + client->config.outline_size = 0; + client->config.size = 24; + client->config.line_pitch = 24; + client->config.color = WHITE; + client->config.alpha = 0xff; +#ifdef USE_STROKER + client->config.stroke_width = 0; +#endif + client->config.loop_playback = 0; + window->send_configure_change(); + window->update_gui(); + window->flush(); + printf("reset stub! \n"); + 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) @@ -1447,11 +1496,89 @@ 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))) { + //printf("Found _(KW_NUDGE)! %s \n", N_(KW_NUDGE)); + strreplace(item_text, _(KW_NUDGE), (char*)N_(KW_NUDGE)); + } + else if (strstr(item_text, _(KW_COLOR))) { + //printf("Found _(KW_COLOR)! %s \n", N_(KW_COLOR)); + strreplace(item_text, _(KW_COLOR), (char*)N_(KW_COLOR)); + } + else if (strstr(item_text, _(KW_ALPHA))) { + //printf("Found _(KW_ALPHA)! %s \n", N_(KW_ALPHA)); + strreplace(item_text, _(KW_ALPHA), (char*)N_(KW_ALPHA)); + } + else if (strstr(item_text, _(KW_FONT))) { + //printf("Found _(KW_FONT)! \n"); + strreplace(item_text, _(KW_FONT), (char*)N_(KW_FONT)); + } + else if (strstr(item_text, _(KW_SIZE))) { + //printf("Found _(KW_SIZE)! \n"); + strreplace(item_text, _(KW_SIZE), (char*)N_(KW_SIZE)); + } + else if (strstr(item_text, _(KW_BOLD))) { + //printf("Found _(KW_BOLD)! \n"); + strreplace(item_text, _(KW_BOLD), (char*)N_(KW_BOLD)); + } + else if (strstr(item_text, _(KW_ITALIC))) { + //printf("Found _(KW_ITALIC)! \n"); + strreplace(item_text, _(KW_ITALIC), (char*)N_(KW_ITALIC)); + } + else if (strstr(item_text, _(KW_CAPS))) { + //printf("Found _(KW_CAPS)! \n"); + strreplace(item_text, _(KW_CAPS), (char*)N_(KW_CAPS)); + } + else if (strstr(item_text, _(KW_UL))) { + //printf("Found _(KW_UL)! \n"); + strreplace(item_text, _(KW_UL), (char*)N_(KW_UL)); + } + else if (strstr(item_text, _(KW_BLINK))) { + //printf("Found _(KW_BLINK)! \n"); + strreplace(item_text, _(KW_BLINK), (char*)N_(KW_BLINK)); + } + else if (strstr(item_text, _(KW_FIXED))) { + //printf("Found _(KW_FIXED)! \n"); + strreplace(item_text, _(KW_FIXED), (char*)N_(KW_FIXED)); + } + else if (strstr(item_text, _(KW_ALIAS))) { + //printf("Found _(KW_ALIAS)! \n"); + strreplace(item_text, _(KW_ALIAS), (char*)N_(KW_ALIAS)); + } + else if (strstr(item_text, _(KW_SUP))) { + //printf("Found _(KW_SUP)! \n"); + strreplace(item_text, _(KW_SUP), (char*)N_(KW_SUP)); + } + + int ofs = *item_text == '/' ? 0 : -1; switch( popup_type ) { case POPUP_FONT: { @@ -1470,8 +1597,64 @@ 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))) { + //printf("Found _(KW_NUDGE)! %s \n", N_(KW_NUDGE)); + strreplace(item_text, (char*)N_(KW_NUDGE), _(KW_NUDGE)); + } + else if (strstr(item_text, N_(KW_COLOR))) { + //printf("Found _(KW_COLOR)! %s \n", N_(KW_COLOR)); + strreplace(item_text, (char*)N_(KW_COLOR), _(KW_COLOR)); + } + else if (strstr(item_text, N_(KW_ALPHA))) { + //printf("Found _(KW_ALPHA)! %s \n", N_(KW_ALPHA)); + strreplace(item_text, (char*)N_(KW_ALPHA), _(KW_ALPHA)); + } + else if (strstr(item_text, N_(KW_FONT))) { + //printf("Found _(KW_FONT)! \n"); + strreplace(item_text, (char*)N_(KW_FONT), _(KW_FONT)); + } + else if (strstr(item_text, N_(KW_SIZE))) { + //printf("Found _(KW_SIZE)! \n"); + strreplace(item_text, (char*)N_(KW_SIZE), _(KW_SIZE)); + } + else if (strstr(item_text, N_(KW_BOLD))) { + //printf("Found _(KW_BOLD)! \n"); + strreplace(item_text, (char*)N_(KW_BOLD), _(KW_BOLD)); + } + else if (strstr(item_text, N_(KW_ITALIC))) { + //printf("Found _(KW_ITALIC)! \n"); + strreplace(item_text, (char*)N_(KW_ITALIC), _(KW_ITALIC)); + } + else if (strstr(item_text, N_(KW_CAPS))) { + //printf("Found _(KW_CAPS)! \n"); + strreplace(item_text, (char*)N_(KW_CAPS), _(KW_CAPS)); + } + else if (strstr(item_text, N_(KW_UL))) { + //printf("Found _(KW_UL)! \n"); + strreplace(item_text, (char*)N_(KW_UL), _(KW_UL)); + } + else if (strstr(item_text, N_(KW_BLINK))) { + //printf("Found _(KW_BLINK)! \n"); + strreplace(item_text, (char*)N_(KW_BLINK), _(KW_BLINK)); + } + else if (strstr(item_text, N_(KW_FIXED))) { + //printf("Found _(KW_FIXED)! \n"); + strreplace(item_text, (char*)N_(KW_FIXED), _(KW_FIXED)); + } + else if (strstr(item_text, N_(KW_ALIAS))) { + //printf("Found _(KW_ALIAS)! \n"); + strreplace(item_text, (char*)N_(KW_ALIAS), _(KW_ALIAS)); + } + else if (strstr(item_text, N_(KW_SUP))) { + //printf("Found _(KW_SUP)! \n"); + strreplace(item_text, (char*)N_(KW_SUP), _(KW_SUP)); + } + + + return window->insert_ibeam(N_(txt), ofs); } TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window) @@ -1505,7 +1688,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); } diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.h b/cinelerra-5.1/plugins/titler/titlerwindow.h index f290d7db..202b9d19 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.h +++ b/cinelerra-5.1/plugins/titler/titlerwindow.h @@ -43,6 +43,7 @@ class TitleDrag; class TitleSize; class TitlePitch; class TitleEncoding; +class TitleResetButton; class TitleColorButton; class TitleOutlineColorButton; class TitleDropShadow; @@ -140,6 +141,7 @@ public: TitlePitch *pitch; BC_Title *encoding_title; TitleEncoding *encoding; + TitleResetButton *reset_button; BC_Title *color_button_title; TitleColorButton *color_button; BC_Title *outline_button_title; @@ -179,6 +181,19 @@ public: }; +class TitleResetButton : public BC_GenericButton +{ +public: + TitleResetButton(TitleMain *client, TitleWindow *window, int x, int y); + ~TitleResetButton(); + + int handle_event(); + + TitleMain *client; + TitleWindow *window; +}; + + class TitleFontTumble : public BC_Tumbler { public:
-- Cin mailing list Cin@lists.cinelerra-gg.org https://lists.cinelerra-gg.org/mailman/listinfo/cin