Add command to insert space after syllab

This commit is contained in:
RhiobeT 2019-09-11 15:55:14 +02:00
parent 7c69b2a9fc
commit 1774b59220
6 changed files with 49 additions and 1 deletions

View File

@ -262,3 +262,11 @@ void AssKaraoke::SetLineTimes(int start_time, int end_time) {
} }
syls[idx].duration = end_time - syls[idx].start_time; syls[idx].duration = end_time - syls[idx].start_time;
} }
std::string AssKaraoke::GetStrippedText(int syl_idx) const {
return syls[syl_idx].text;
}
void AssKaraoke::SetStrippedText(int syl_idx, std::string new_text) {
syls[syl_idx].text = new_text;
}

View File

@ -82,5 +82,10 @@ public:
/// Set the tag type for all karaoke tags in this line /// Set the tag type for all karaoke tags in this line
void SetTagType(std::string const& new_type); void SetTagType(std::string const& new_type);
/// Get syllab's text stripped of k tag
std::string GetStrippedText(int syl_idx) const;
/// Set syllab's text stripped of k tag
void SetStrippedText(int syl_idx, std::string new_text);
DEFINE_SIGNAL_ADDERS(AnnounceSyllablesChanged, AddSyllablesChangedListener) DEFINE_SIGNAL_ADDERS(AnnounceSyllablesChanged, AddSyllablesChangedListener)
}; };

View File

@ -165,6 +165,12 @@ public:
/// controlling the mouse cursor. /// controlling the mouse cursor.
virtual bool IsNearbyMarker(int ms, int sensitivity, bool alt_down) const = 0; virtual bool IsNearbyMarker(int ms, int sensitivity, bool alt_down) const = 0;
/// @brief Return the text of the currently selected syllab
virtual std::string GetCurrentSylText() const { return ""; }
/// @ brief Set the text for the currently selected syllab
virtual void SetCurrentSylText(std::string new_text) {}
/// @brief The user pressed the left mouse button on the audio /// @brief The user pressed the left mouse button on the audio
/// @param ms The time in milliseconds the user clicked /// @param ms The time in milliseconds the user clicked
/// @param ctrl_down Is the user currently holding the ctrl key down? /// @param ctrl_down Is the user currently holding the ctrl key down?

View File

@ -149,6 +149,8 @@ public:
std::vector<AudioMarker*> OnLeftClick(int ms, bool, bool, int sensitivity, int) override; std::vector<AudioMarker*> OnLeftClick(int ms, bool, bool, int sensitivity, int) override;
std::vector<AudioMarker*> OnRightClick(int ms, bool ctrl_down, int, int) override; std::vector<AudioMarker*> OnRightClick(int ms, bool ctrl_down, int, int) override;
void OnMarkerDrag(std::vector<AudioMarker*> const& marker, int new_position, int) override; void OnMarkerDrag(std::vector<AudioMarker*> const& marker, int new_position, int) override;
std::string GetCurrentSylText() const override;
void SetCurrentSylText(std::string new_text) override;
AudioTimingControllerKaraoke(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed); AudioTimingControllerKaraoke(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed);
}; };
@ -579,3 +581,12 @@ void AudioTimingControllerKaraoke::GetLabels(TimeRange const& range, std::vector
return range.overlaps(l.range); return range.overlaps(l.range);
}), back_inserter(out)); }), back_inserter(out));
} }
std::string AudioTimingControllerKaraoke::GetCurrentSylText() const {
return kara->GetStrippedText(cur_syl);
}
void AudioTimingControllerKaraoke::SetCurrentSylText(std::string new_text) {
kara->SetStrippedText(cur_syl, new_text);
AnnounceChanges(true);
}

View File

@ -465,6 +465,20 @@ struct time_opt_tap_to_time final : public Command {
} }
}; };
struct time_add_space final : public Command {
CMD_NAME("time/add_space")
STR_MENU("Add Space")
STR_DISP("Add Space")
STR_HELP("Add a space at the end of the current syllab")
void operator()(agi::Context *c) override {
if (c->audioController->GetTimingController()) {
AudioTimingController *tc = c->audioController->GetTimingController();
tc->SetCurrentSylText(tc->GetCurrentSylText() + " ");
// tc->Next(AudioTimingController::TIMING_UNIT);
}
}
};
} }
namespace cmd { namespace cmd {
@ -490,5 +504,6 @@ namespace cmd {
reg(agi::make_unique<time_snap_start_video>()); reg(agi::make_unique<time_snap_start_video>());
reg(agi::make_unique<time_start_decrease>()); reg(agi::make_unique<time_start_decrease>());
reg(agi::make_unique<time_start_increase>()); reg(agi::make_unique<time_start_increase>());
reg(agi::make_unique<time_add_space>());
} }
} }

View File

@ -110,6 +110,9 @@
"time/prev" : [ "time/prev" : [
"A", "A",
"Left" "Left"
],
"time/add_space" : [
"Ctrl-Space"
] ]
}, },
"Default" : { "Default" : {
@ -226,7 +229,7 @@
"Ctrl-3" "Ctrl-3"
], ],
"video/focus_seek" : [ "video/focus_seek" : [
"Ctrl-Space" "Alt-Space"
], ],
"video/frame/next" : [ "video/frame/next" : [
"Ctrl-KP_6" "Ctrl-KP_6"