From: smlee Date: Tue, 26 Apr 2016 07:42:42 +0000 (+0900) Subject: [Subtitle] added rewrap option for TTX subtitle. X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=004d6db4a1dda8f08f5ce63f30c102c81b7b0693 [Subtitle] added rewrap option for TTX subtitle. --- diff --git a/data/setup.xml b/data/setup.xml index 6100565..5ce6b62 100755 --- a/data/setup.xml +++ b/data/setup.xml @@ -74,11 +74,11 @@ config.subtitles.subtitle_alignment config.subtitles.subtitle_position config.subtitles.dvb_subtitles_centered + config.subtitles.subtitle_rewrap config.subtitles.subtitle_noPTSrecordingdelay config.subtitles.subtitle_bad_timing_delay config.subtitles.pango_subtitle_fontswitch config.subtitles.colourise_dialogs - config.subtitles.subtitle_rewrap config.subtitles.pango_subtitles_delay config.subtitles.pango_subtitles_fps config.subtitles.pango_autoturnon diff --git a/lib/dvb/teletext.cpp b/lib/dvb/teletext.cpp index 40650c0..6a3daa8 100644 --- a/lib/dvb/teletext.cpp +++ b/lib/dvb/teletext.cpp @@ -659,6 +659,14 @@ void eDVBTeletextParser::connectNewPage(const Slot1 1 - ? size().height() / 2 - : size().height() / 3 * 2; + int fontsize = ePythonConfigQuery::getConfigIntValue("config.subtitles.subtitle_fontsize", 34) * getDesktop(0)->size().width()/1280; + int startY = size().height() - (size().height() / 3 * 1) / 2 - ((fontsize + paddingY) * elements) / 2; int width = size().width() - startX * 2; int height = size().height() - startY; - int size_per_element = height / (elements ? elements : 1); + int size_per_element = fontsize + paddingY; bool original_position = ePythonConfigQuery::getConfigBoolValue("config.subtitles.subtitle_original_position"); + bool rewrap = ePythonConfigQuery::getConfigBoolValue("config.subtitles.subtitle_rewrap"); gRGB color; bool original_colors = false; switch (ePythonConfigQuery::getConfigIntValue("config.subtitles.subtitle_fontcolor", 0)) @@ -96,8 +97,11 @@ void eSubtitleWidget::setPage(const eDVBTeletextSubtitlePage &p) if (line != newpage.m_elements[i].m_source_line) { line = newpage.m_elements[i].m_source_line; - m_page.m_elements.push_back(eDVBTeletextSubtitlePageElement(color, "", line)); - currentelement++; + if (!rewrap) + { + m_page.m_elements.push_back(eDVBTeletextSubtitlePageElement(color, "", line)); + currentelement++; + } } m_page.m_elements[currentelement].m_text += newpage.m_elements[i].m_text; } @@ -108,11 +112,7 @@ void eSubtitleWidget::setPage(const eDVBTeletextSubtitlePage &p) if (!original_position) { int lowerborder = ePythonConfigQuery::getConfigIntValue("config.subtitles.subtitle_position", 50); - if (lowerborder == 0) - lowerborder -= 100 * getDesktop(0)->size().height()/720; - else if (lowerborder == 50) - lowerborder -= 50 * getDesktop(0)->size().height()/720; - area.setTop(size_per_element * i + startY - lowerborder); + area.setTop(size().height() - size_per_element * (m_page.m_elements.size() - i) - lowerborder * getDesktop(0)->size().height()/720); } else area.setTop(size_per_element * i + startY); @@ -318,7 +318,6 @@ int eSubtitleWidget::event(int event, void *data, void *data2) int bg_r, bg_g, bg_b, bg_a; if (ePythonConfigQuery::getConfigIntValue("config.subtitles.subtitle_bgopacity") < 0xFF) { - unsigned int padding = 10; eTextPara *para = new eTextPara(area); para->setFont(subtitleStyles[Subtitle_TTX].font); para->renderString(element.m_text.c_str(), RS_WRAP); @@ -327,14 +326,14 @@ int eSubtitleWidget::event(int event, void *data, void *data2) int bgboxWidth = bgbox.width(); int bgboxHeight = bgbox.height(); if (alignmentValue == "left") - bgbox.setLeft(area.left() - padding - borderwidth); + bgbox.setLeft(area.left() - paddingY - borderwidth); else if (alignmentValue == "right") - bgbox.setLeft(area.left() + area.width() - bgboxWidth - padding - borderwidth); + bgbox.setLeft(area.left() + area.width() - bgboxWidth - paddingY - borderwidth); else - bgbox.setLeft(area.left() + area.width() / 2 - bgboxWidth / 2 - padding - borderwidth); - bgbox.setTop(area.top() + area.height() / 2 - bgboxHeight / 2 - padding * 2 - borderwidth); - bgbox.setWidth(bgboxWidth + padding * 2 + borderwidth * 2); - bgbox.setHeight(bgboxHeight + padding * 3 + borderwidth * 2); + bgbox.setLeft(area.left() + area.width() / 2 - bgboxWidth / 2 - paddingY - borderwidth); + bgbox.setTop(area.top()); + bgbox.setWidth(bgboxWidth + paddingY * 2 + borderwidth * 2); + bgbox.setHeight(area.height()); switch (ePythonConfigQuery::getConfigIntValue("config.subtitles.subtitle_bgcolor", 0)) { diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index fc7ae83..d262448 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -187,7 +187,7 @@ def InitUsageConfig(): ("150", "50%")]) config.subtitles.subtitle_original_position = ConfigYesNo(default = True) config.subtitles.subtitle_alignment = ConfigSelection(choices = [("left", _("left")), ("center", _("center")), ("right", _("right"))], default = "center") - config.subtitles.subtitle_position = ConfigSelection( choices = ["0", "50", "100", "150", "200", "250", "300", "350", "400", "450", "500", "550", "600"], default = "50") + config.subtitles.subtitle_position = ConfigSelection( choices = ["0", "50", "100", "150", "200", "250", "300", "350", "400", "450", "500", "550", "600"], default = "100") config.subtitles.dvb_subtitles_centered = ConfigYesNo(default = False) diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py index 537aab4..715d922 100755 --- a/lib/python/Screens/AudioSelection.py +++ b/lib/python/Screens/AudioSelection.py @@ -379,6 +379,7 @@ class QuickSubtitlesConfigMenu(ConfigListScreen, Screen): getConfigMenuItem("config.subtitles.subtitle_original_position"), getConfigMenuItem("config.subtitles.subtitle_alignment"), getConfigMenuItem("config.subtitles.subtitle_position"), + getConfigMenuItem("config.subtitles.subtitle_rewrap"), getConfigMenuItem("config.subtitles.subtitle_bad_timing_delay"), getConfigMenuItem("config.subtitles.subtitle_noPTSrecordingdelay"), ]