27#include <QApplication>
37#define LOC QString("VideoBounds: ")
40{
return {
static_cast<int>(src.left() * scale),
41 static_cast<int>(src.top() * scale),
42 static_cast<int>(src.width() * scale),
43 static_cast<int>(src.height() * scale) }; }
46static float snap(
float value,
float snapto,
float diff);
78 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Already have a display");
118 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window using all screens %1x%2")
119 .arg(screen->virtualGeometry().width()).arg(screen->virtualGeometry().height()));
123 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window using screen '%1' %2x%3")
124 .arg(screen->name()).arg(screen->geometry().width()).arg(screen->geometry().height()));
251 float tmp = 1.0F - (2.0F * vscanf);
298 float tmp = 1.0F - (2.0F * hscanf);
329 QPoint chgloc = QPoint(
tmp.width(),
tmp.height());
354 bool aspects_match = abs(aspect_diff / disp_aspect) <= 0.02F;
357 bool nomatch_without_fill = (!aspects_match) && !nomatch_with_fill;
366 else if (nomatch_with_fill)
378 else if (nomatch_without_fill)
453 float Aspect, QRect WindowRect)
482 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window Rect: %1x%2+%3+%4")
485 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Display Rect: %1x%2+%3+%4 Aspect: %5")
489 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Video Rect: %1x%2+%3+%4 Aspect: %5")
517 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New video aspect ratio: '%1'")
518 .arg(
static_cast<double>(Aspect)));
530 QSize newvideodispdim =
Fix1088(VideoDispDim);
538 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
539 QString(
"New video parameters: Size %1x%2 DisplaySize: %3x%4 Aspect: %5")
549 QSize result = Dimensions;
551 if (result.width() == 1920 || result.width() == 1440)
553 if (result.height() == 1088)
554 result.setHeight(1080);
555 else if (result.height() == 544)
556 result.setHeight(540);
599 if (!(qFuzzyCompare(oldvert + 100.0F,
m_dbVertScale + 100.0F) &&
602 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Over/underscan. V: %1, H: %2")
612 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"New display aspect: %1")
613 .arg(
static_cast<double>(DisplayAspect)));
624 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New window rect: %1x%2+%3+%4")
625 .arg(rect.width()).arg(rect.height()).arg(rect.left()).arg(rect.top()));
649 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New ITV display rect: %1x%2+%3+%4 (Scale: %5)")
665 if ((Rotation < -180) || (Rotation > 180))
669 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New rotation: %1").arg(
m_rotation));
697 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New embedding rect: %1x%2+%3+%4 (Scale: %5)")
707 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Stopped embedding");
730 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New video aspect override: '%1'")
759 return visible.subtracted(video);
772 const float zf = 0.02F;
858 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New zoom: Offset %1x%2 HScale %3 VScale %4")
882 const float zf = 0.02F;
895 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New custom zoom: Offset %1x%2 HScale %3 VScale %4")
919 if (fabs(raw - 1.333333F) < 0.05F)
923 if (fabs(raw - 1.777777F) < 0.05F)
929static float snap(
float value,
float snapto,
float diff)
931 if ((value + diff > snapto) && (value - diff < snapto))
void SaveSetting(const QString &key, int newValue)
int GetNumSetting(const QString &key, int defaultval=0)
bool GetBoolSetting(const QString &key, bool defaultval=false)
double GetAspectRatio(QString &Source, bool IgnoreModeOverride=false)
Returns current screen aspect ratio.
void PhysicalDPIChanged(qreal DPI)
QScreen * GetCurrentScreen()
Return a pointer to the screen to use.
void CurrentScreenChanged(QScreen *qScreen)
static bool SpanAllScreens()
Return true if the MythTV windows should span all screens.
static int GetScreenCount()
void RefreshVideoBoundsState()
Send out latest state to listeners.
void SetITVResize(QRect Rect)
void SetRotation(int Rotation)
Set the rotation in degrees.
void Rotate(void)
Adjust various settings to facilitate portrait mode calculations.
bool IsEmbedding(void) const
QSize m_videoDispDim
Pixel dimensions of video display area.
static const float kManualZoomMaxHorizontalZoom
virtual void EmbedPlayback(bool Embed, QRect Rect)
float m_manualHorizScale
Manually applied horizontal scaling.
float m_dbVertScale
Vertical Overscan/Underscan percentage.
QSize m_videoDim
Pixel dimensions of video buffer.
float m_dbHorizScale
Horizontal Overscan/Underscan percentage.
QRect m_displayVideoRect
Pixel rectangle in display window into which video_rect maps to.
void VideoRectsChanged(const QRect &DisplayVideoRect, const QRect &VideoRect)
void SaveBottomLine(void)
static const float kManualZoomMinVerticalZoom
void MoveResize(void)
performs all the calculations for video framing and any resizing.
static QSize Fix1088(QSize Dimensions)
static const float kManualZoomMaxVerticalZoom
QRect m_windowRect
Rectangle describing QWidget bounds.
AspectOverrideMode m_dbAspectOverride
void UpdateOSDMessage(const QString &Message)
void VideoBoundsStateChanged(MythVideoBoundsState VideoState)
QRect m_videoRect
Pixel rectangle in video frame to display.
void SourceChanged(QSize VideoDim, QSize VideoDispDim, float Aspect)
Update for new source video dimensions and aspect ratio.
bool m_embedding
State variables.
void WindowRectChanged(const QRect &WindowRect)
void VisibleRectChanged(const QRect &DisplayVisibleRect)
void ToggleAdjustFill(AdjustFillMode AdjustFillMode=kAdjustFill_Toggle)
Sets up letterboxing for various standard video frame and monitor dimensions, then calls MoveResize()...
float m_videoAspectOverride
Normally this is the same as videoAspect, but may not be if the user has toggled the aspect override ...
void SetDisplayAspect(float DisplayAspect)
bool VideoIsFullScreen(void) const
Check whether the video display rect covers the entire window/framebuffer.
void SetVideoScalingAllowed(bool Change)
Disable or enable underscan/overscan.
QRect m_tmpDisplayVisibleRect
Used to save the display_visible_rect for restoration after video embedding ends.
void ToggleAspectOverride(AspectOverrideMode AspectMode=kAspect_Toggle)
Enforce different aspect ratio than detected, then calls VideoAspectRatioChanged(float) to apply them...
void ApplyLetterboxing(void)
AspectOverrideMode m_videoAspectOverrideMode
AspectOverrideMode to use to modify overriden_video_aspect.
void SetVideoAspectRatio(float Aspect)
Sets MythVideoBounds::video_aspect to aspect, and sets MythVideoBounds::overriden_video_aspect if asp...
float m_videoAspect
Physical aspect ratio of video.
void ApplyManualScaleAndMove(void)
Apply scales and moves from "Zoom Mode" settings.
void ToggleMoveBottomLine(void)
void PopulateGeometry(void)
QRegion GetBoundingRegion(void) const
Return the region of DisplayVisibleRect that lies outside of DisplayVideoRect.
float m_displayAspect
Physical aspect ratio of playback window.
AdjustFillMode m_adjustFill
Zoom mode.
float m_manualVertScale
Manually applied vertical scaling.
bool InitBounds(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect WindowRect)
QRect m_rawWindowRect
Rectangle describing QWidget bounds - not adjusted for high DPI scaling (macos)
static const int kManualZoomMaxMove
QRect m_rawItvDisplayVideoRect
void SetDisplay(MythDisplay *mDisplay)
QPoint m_manualMove
Manually applied percentage move.
void SetWindowSize(QSize Size)
void VideoAspectRatioChanged(float Aspect)
Calls SetVideoAspectRatio(float aspect), then calls MoveResize() to apply changes.
QRect m_itvDisplayVideoRect
void ResizeDisplayWindow(QRect Rect, bool SaveVisibleRect)
Resize Display Window.
void ScreenChanged(QScreen *screen)
void Zoom(ZoomDirection Direction)
Sets up zooming into to different parts of the video.
StereoscopicMode m_stereoOverride
void PhysicalDPIChanged(qreal)
void PrintMoveResizeDebug(void)
bool m_dbScalingAllowed
disable this to prevent overscan/underscan
void SetStereoOverride(StereoscopicMode Mode)
void ApplyDBScaleAndMove(void)
Apply scales and moves for "Overscan" and "Underscan" DB settings.
void VideoSizeChanged(const QSize &VideoDim, const QSize &VideoDispDim)
float GetDisplayAspect(void) const
QRect m_displayVisibleRect
Visible portion of display window in pixels.
QRect m_embeddingRect
Embedded video rectangle.
static const float kManualZoomMinHorizontalZoom
AdjustFillMode m_dbAdjustFill
QPoint m_dbMove
Percentage move from database.
static HostComboBoxSetting * AdjustFill()
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static float snap(float value, float snapto, float diff)
static QRect SCALED_RECT(QRect src, qreal scale)
static float fix_aspect(float raw)
Correct for rounding errors.
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
QString GetZoomString(float HorizScale, float VertScale, QPoint Move)
float get_aspect_override(AspectOverrideMode Aspectmode, float Original)
@ kAdjustFill_HorizontalFill
@ kAdjustFill_VerticalFill
@ kAdjustFill_VerticalStretch
@ kAdjustFill_HorizontalStretch
QString StereoscopictoString(StereoscopicMode Mode)