Bug Fix Text source

This commit is contained in:
Bruno Herbelin
2023-11-13 18:30:20 +01:00
parent 58371c36d3
commit 885b92a0a1
3 changed files with 19 additions and 13 deletions

View File

@@ -1873,8 +1873,12 @@ void ImGuiVisitor::visit(TextSource &s)
botom = ImGui::GetCursorPos(); botom = ImGui::GetCursorPos();
// Action on the filename // Action on the filename
ImGui::SetCursorPos(ImVec2(top.x, botom.y - ImGui::GetFrameHeight())); ImGui::SetCursorPos(ImVec2(top.x, botom.y - ImGui::GetFrameHeight()));
if (ImGuiToolkit::IconButton(3, 5, "Open")) if (ImGuiToolkit::IconButton(ICON_FA_EDIT, "Open in editor"))
SystemToolkit::open(_contents.c_str()); SystemToolkit::open(_contents.c_str());
ImGui::SetCursorPos(
ImVec2(top.x + 0.95 * ImGui::GetFrameHeight(), botom.y - ImGui::GetFrameHeight()));
if (ImGuiToolkit::IconButton(ICON_FA_REDO_ALT, "Reload"))
tc->reopen();
} }
// general case of free text : text editor // general case of free text : text editor
else { else {

View File

@@ -16,10 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
**/ **/
#include <string>
#include <atomic>
#include <mutex>
#include <future>
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/pbutils/pbutils.h> #include <gst/pbutils/pbutils.h>
@@ -77,7 +73,7 @@ bool TextContents::SubtitleDiscoverer(const std::string &path)
TextContents::TextContents() TextContents::TextContents()
: Stream(), src_(nullptr), txt_(nullptr), : Stream(), src_(nullptr), txt_(nullptr),
fontdesc_("arial 24"), color_(0xffffffff), outline_(2), outline_color_(4278190080), fontdesc_(""), color_(0xffffffff), outline_(2), outline_color_(4278190080),
halignment_(1), valignment_(2), xalignment_(0.f), yalignment_(0.f) halignment_(1), valignment_(2), xalignment_(0.f), yalignment_(0.f)
{ {
} }
@@ -146,6 +142,7 @@ void TextContents::execute_open()
txt_ = gst_bin_get_by_name(GST_BIN(pipeline_), "txt"); txt_ = gst_bin_get_by_name(GST_BIN(pipeline_), "txt");
if (txt_) { if (txt_) {
// if there is a src in the pipeline, it should be a file
if (src_) { if (src_) {
// set the location of the file // set the location of the file
g_object_set(G_OBJECT(src_), "location", text_.c_str(), NULL); g_object_set(G_OBJECT(src_), "location", text_.c_str(), NULL);
@@ -155,6 +152,13 @@ void TextContents::execute_open()
g_object_set(G_OBJECT(txt_), "text", text_.c_str(), NULL); g_object_set(G_OBJECT(txt_), "text", text_.c_str(), NULL);
} }
// Auto default font
if (fontdesc_.empty()) {
fontdesc_ = "sans ";
fontdesc_ += std::to_string( height_ / 10 );
}
// set text properties
g_object_set(G_OBJECT(txt_), g_object_set(G_OBJECT(txt_),
"font-desc", "font-desc",
fontdesc_.c_str(), fontdesc_.c_str(),
@@ -281,10 +285,8 @@ void TextContents::setOutline(uint o)
// apply if ready // apply if ready
if (txt_) { if (txt_) {
g_object_set(G_OBJECT(txt_), g_object_set(G_OBJECT(txt_),
"draw-outline", "draw-outline", outline_ > 0,
outline_ > 0, "draw-shadow", outline_ > 1,
"draw-shadow",
outline_ > 1,
NULL); NULL);
} }
} }

View File

@@ -1547,7 +1547,7 @@ enum SourceToolbarFlags_
void UserInterface::RenderSourceToolbar(bool *p_open, int* p_border, int *p_mode) { void UserInterface::RenderSourceToolbar(bool *p_open, int* p_border, int *p_mode) {
if (!p_open || !p_border || !p_mode) if (!p_open || !p_border || !p_mode || !Mixer::manager().session()->ready())
return; return;
Source *s = Mixer::manager().currentSource(); Source *s = Mixer::manager().currentSource();
@@ -3873,12 +3873,12 @@ void Navigator::RenderNewPannel(const ImVec2 &iconsize)
ImGui::TextDisabled("Explore online"); ImGui::TextDisabled("Explore online");
if (ImGui::Selectable(ICON_FA_EXTERNAL_LINK_ALT " Pango syntax")) if (ImGui::Selectable(ICON_FA_EXTERNAL_LINK_ALT " Pango syntax"))
SystemToolkit::open("https://docs.gtk.org/Pango/pango_markup.html"); SystemToolkit::open("https://docs.gtk.org/Pango/pango_markup.html");
if (ImGui::Selectable(ICON_FA_EXTERNAL_LINK_ALT " SubRip files")) if (ImGui::Selectable(ICON_FA_EXTERNAL_LINK_ALT " SubRip file format"))
SystemToolkit::open("https://en.wikipedia.org/wiki/SubRip"); SystemToolkit::open("https://en.wikipedia.org/wiki/SubRip");
ImGui::EndCombo(); ImGui::EndCombo();
} }
ImGui::SameLine(0, IMGUI_SAME_LINE); ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGuiToolkit::Indication("More text layout options are available after source creation.", ICON_FA_INFO_CIRCLE); ImGuiToolkit::Indication("Format and layout options will be available after source creation.", ICON_FA_INFO_CIRCLE);
ImGui::SetCursorPos(pos_bot); ImGui::SetCursorPos(pos_bot);
// resolution // resolution