Permalink
Browse files

Subtitles: Encapsulate zoom get/set into the SubtitleScreen class.

This sets the stage for allowing AV subtitle zoom adjustment, and
possibly independent zoom factors for each subtitle type.
  • Loading branch information...
1 parent edb7b6c commit 0bb37900b40ce063b2cfd74261ac6683887cee7b @stichnot stichnot committed May 21, 2012
@@ -111,6 +111,7 @@ static const QString kSubWindowName("osd_subtitle");
static const QString kSubFamily608 ("608");
static const QString kSubFamily708 ("708");
static const QString kSubFamilyText ("text");
+static const QString kSubFamilyAV ("AV");
static const QString kSubFamilyTeletext("teletext");
static const QString kSubAttrItalics ("italics");
@@ -586,6 +587,10 @@ void SubtitleScreen::EnableSubtitles(int type, bool forced_only)
case kDisplayCC708:
m_family = kSubFamily708;
break;
+ case kDisplayAVSubtitle:
+ m_family = kSubFamilyAV;
+ m_textFontZoom = m_textFontZoomPrev = 100;
+ break;
}
}
@@ -620,7 +625,6 @@ bool SubtitleScreen::Create(void)
void SubtitleScreen::Pulse(void)
{
- m_textFontZoom = gCoreContext->GetNumSetting("OSDCC708TextZoom", 100);
ExpireSubtitles();
DisplayAVSubtitles(); // allow forced subtitles to work
@@ -1246,6 +1250,20 @@ MythFontProperties* SubtitleScreen::GetFont(CC708CharacterAttribute attr,
teletext, m_textFontZoom, m_fontStretch);
}
+void SubtitleScreen::SetZoom(int percent)
+{
+ m_textFontZoom = percent;
+ if (m_family != kSubFamilyAV)
+ {
+ gCoreContext->SaveSetting("OSDCC708TextZoom", percent);
+ }
+}
+
+int SubtitleScreen::GetZoom(void)
+{
+ return m_textFontZoom;
+}
+
static QString srtColorString(QColor color)
{
return QString("#%1%2%3")
@@ -39,6 +39,9 @@ class SubtitleScreen : public MythScreenType
void ExpireSubtitles(void);
void DisplayDVDButton(AVSubtitle* dvdButton, QRect &buttonPos);
+ void SetZoom(int percent);
+ int GetZoom(void);
+
QSize CalcTextSize(const QString &text,
const CC708CharacterAttribute &format,
bool teletext,
@@ -25,6 +25,7 @@ using namespace std;
#include "remoteutil.h"
#include "tvremoteutil.h"
#include "mythplayer.h"
+#include "subtitlescreen.h"
#include "DetectLetterbox.h"
#include "programinfo.h"
#include "vsync.h"
@@ -8410,9 +8411,14 @@ void TV::ChangeSubtitleZoom(PlayerContext *ctx, int dir)
return;
}
+ OSD *osd = GetOSDLock(ctx);
+ SubtitleScreen *subs = NULL;
+ if (osd)
+ subs = osd->InitSubtitles();
+ ReturnOSDLock(ctx, osd);
subtitleZoomAdjustment = true;
bool showing = ctx->player->GetCaptionsEnabled();
- int newval = gCoreContext->GetNumSetting("OSDCC708TextZoom", 100) + dir;
+ int newval = (subs ? subs->GetZoom() : 100) + dir;
newval = max(50, newval);
newval = min(200, newval);
ctx->UnlockDeletePlayer(__FILE__, __LINE__);
@@ -8424,7 +8430,8 @@ void TV::ChangeSubtitleZoom(PlayerContext *ctx, int dir)
kOSDFunctionalType_SubtitleZoomAdjust,
"%", newval * 1000 / 200, kOSDTimeout_Long);
SetUpdateOSDPosition(false);
- gCoreContext->SaveSetting("OSDCC708TextZoom", newval);
+ if (subs)
+ subs->SetZoom(newval);
}
}

0 comments on commit 0bb3790

Please sign in to comment.