Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
 - Fix Wide Subtitle Boxes
 - Fix Character Count not updating when changing active lines
  • Loading branch information
Ristellise committed Aug 19, 2021
1 parent 6a13904 commit 4c6146f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
32 changes: 0 additions & 32 deletions src/dialog_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
#include "persist_location.h"
#include "project.h"
#include "subs_edit_ctrl.h"
#ifdef WITH_WXSTC
#include "subs_edit_ctrl_stc.h"
#endif
#include "selection_controller.h"
#include "video_controller.h"

Expand Down Expand Up @@ -72,9 +70,7 @@ DialogTranslation::DialogTranslation(agi::Context* c)
, active_line_connection(c->selectionController->AddActiveLineListener(&DialogTranslation::OnActiveLineChanged, this))
, active_line(c->selectionController->GetActiveLine())
, line_count(c->ass->Events.size())
#ifdef WITH_WXSTC
, use_stc(OPT_GET("Subtitle/Use STC")->GetBool())
#endif
{
SetIcon(GETICON(translation_toolbutton_16));

Expand All @@ -98,7 +94,6 @@ DialogTranslation::DialogTranslation(agi::Context* c)
}

{
#ifdef WITH_WXSTC
if (use_stc) {
translated_text_stc = new SubsStyledTextEditCtrl(this, wxSize(320, 80), 0, nullptr);
translated_text_stc->SetWrapMode(wxSTC_WRAP_WORD);
Expand All @@ -107,25 +102,18 @@ DialogTranslation::DialogTranslation(agi::Context* c)
translated_text_stc->Bind(wxEVT_CHAR_HOOK, &DialogTranslation::OnKeyDown, this);
}
else {
#endif
translated_text_tc = new SubsTextEditCtrl(this, wxSize(320, 80), 0, nullptr);
translated_text_tc->SetFocus();
translated_text_tc->Bind(wxEVT_CHAR_HOOK, &DialogTranslation::OnKeyDown, this);
#ifdef WITH_WXSTC
}
#endif

wxSizer* translated_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Translation"));
#ifdef WITH_WXSTC
if (use_stc) {
translated_box->Add(translated_text_stc, 1, wxEXPAND, 0);
}
else {
#endif
translated_box->Add(translated_text_tc, 1, wxEXPAND, 0);
#ifdef WITH_WXSTC
}
#endif
translation_sizer->Add(translated_box, 1, wxTOP | wxEXPAND, 5);
}
main_sizer->Add(translation_sizer, 1, wxALL | wxEXPAND, 5);
Expand Down Expand Up @@ -288,32 +276,24 @@ void DialogTranslation::UpdateDisplay() {

if (seek_video->IsChecked()) c->videoController->JumpToTime(active_line->Start);

#ifdef WITH_WXSTC
if (use_stc) {
translated_text_stc->ClearAll();
translated_text_stc->SetFocus();
}
else {
#endif
translated_text_tc->Clear();
translated_text_tc->SetFocus();
#ifdef WITH_WXSTC
}
#endif
}

void DialogTranslation::Commit(bool next) {
std::string new_value;
#ifdef WITH_WXSTC
if (use_stc) {
new_value = translated_text_stc->GetTextRaw().data();
}
else {
#endif
new_value = translated_text_tc->GetValue().utf8_str();
#ifdef WITH_WXSTC
}
#endif
boost::replace_all(new_value, "\r\n", "\\N");
boost::replace_all(new_value, "\r", "\\N");
boost::replace_all(new_value, "\n", "\\N");
Expand All @@ -337,12 +317,10 @@ void DialogTranslation::Commit(bool next) {

void DialogTranslation::InsertOriginal() {
auto const& text = blocks[cur_block]->GetText();
#ifdef WITH_WXSTC
if (use_stc) {
translated_text_stc->AddTextRaw(text.data(), text.size());
}
else {
#endif
long ins = translated_text_tc->GetInsertionPoint();
wxString data_first_half = translated_text_tc->GetRange(0, ins) + to_wx(text);
wxString data_full = data_first_half + translated_text_tc->GetRange(ins, translated_text_tc->GetLastPosition());
Expand All @@ -352,9 +330,7 @@ void DialogTranslation::InsertOriginal() {
translated_text_tc->SetValue(data_full);
translated_text_tc->SetSelection(ins, ins);
translated_text_tc->Thaw();
#ifdef WITH_WXSTC
}
#endif
}

void DialogTranslation::OnKeyDown(wxKeyEvent& evt) {
Expand All @@ -363,28 +339,20 @@ void DialogTranslation::OnKeyDown(wxKeyEvent& evt) {

void DialogTranslation::OnPlayVideoButton(wxCommandEvent&) {
c->videoController->PlayLine();
#ifdef WITH_WXSTC
if (use_stc) {
translated_text_stc->SetFocus();
}
else {
#endif
translated_text_tc->SetFocus();
#ifdef WITH_WXSTC
}
#endif
}

void DialogTranslation::OnPlayAudioButton(wxCommandEvent&) {
cmd::call("audio/play/selection", c);
#ifdef WITH_WXSTC
if (use_stc) {
translated_text_stc->SetFocus();
}
else {
#endif
translated_text_tc->SetFocus();
#ifdef WITH_WXSTC
}
#endif
}
2 changes: 0 additions & 2 deletions src/dialog_translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ class DialogTranslation final : public wxDialog {

wxStaticText* line_number_display;
wxStyledTextCtrl* original_text;
#ifdef WITH_WXSTC
const bool use_stc;
SubsStyledTextEditCtrl* translated_text_stc;
#endif
wxTextCtrl* translated_text_tc;
wxCheckBox* seek_video;

Expand Down
2 changes: 1 addition & 1 deletion src/subs_edit_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
wxEventBlocker blocker(this);
line = new_line;
commit_id = -1;

UpdateCharacterCount(line->Text);
UpdateFields(AssFile::COMMIT_DIAG_FULL, false);
}

Expand Down

0 comments on commit 4c6146f

Please sign in to comment.