27#include <QApplication>
30#include "libmythbase/mythconfig.h"
38#define LOC QString("VideoBounds: ")
41{
return {
static_cast<int>(src.left() * scale),
42 static_cast<int>(src.top() * scale),
43 static_cast<int>(src.width() * scale),
44 static_cast<int>(src.height() * scale) }; }
47static float snap(
float value,
float snapto,
float diff);
79 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Already have a display");
119 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window using all screens %1x%2")
120 .arg(screen->virtualGeometry().width()).arg(screen->virtualGeometry().height()));
124 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window using screen '%1' %2x%3")
125 .arg(screen->name()).arg(screen->geometry().width()).arg(screen->geometry().height()));
252 float tmp = 1.0F - (2.0F * vscanf);
299 float tmp = 1.0F - (2.0F * hscanf);
330 QPoint chgloc = QPoint(
tmp.width(),
tmp.height());
355 bool aspects_match = abs(aspect_diff / disp_aspect) <= 0.02F;
358 bool nomatch_without_fill = (!aspects_match) && !nomatch_with_fill;
367 else if (nomatch_with_fill)
379 else if (nomatch_without_fill)
454 float Aspect, QRect WindowRect)
483 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Window Rect: %1x%2+%3+%4")
486 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Display Rect: %1x%2+%3+%4 Aspect: %5")
490 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Video Rect: %1x%2+%3+%4 Aspect: %5")
518 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New video aspect ratio: '%1'")
519 .arg(
static_cast<double>(Aspect)));
531 QSize newvideodispdim =
Fix1088(VideoDispDim);
539 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
540 QString(
"New video parameters: Size %1x%2 DisplaySize: %3x%4 Aspect: %5")
550 QSize result = Dimensions;
552 if (result.width() == 1920 || result.width() == 1440)
554 if (result.height() == 1088)
555 result.setHeight(1080);
556 else if (result.height() == 544)
557 result.setHeight(540);
600 if (!(qFuzzyCompare(oldvert + 100.0F,
m_dbVertScale + 100.0F) &&
603 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Over/underscan. V: %1, H: %2")
613 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"New display aspect: %1")
614 .arg(
static_cast<double>(DisplayAspect)));
625 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New window rect: %1x%2+%3+%4")
626 .arg(rect.width()).arg(rect.height()).arg(rect.left()).arg(rect.top()));
650 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New ITV display rect: %1x%2+%3+%4 (Scale: %5)")
666 if ((Rotation < -180) || (Rotation > 180))
670 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New rotation: %1").arg(
m_rotation));
698 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New embedding rect: %1x%2+%3+%4 (Scale: %5)")
708 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Stopped embedding");
731 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New video aspect override: '%1'")
760 return visible.subtracted(video);
773 const float zf = 0.02F;
859 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New zoom: Offset %1x%2 HScale %3 VScale %4")
883 const float zf = 0.02F;
896 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"New custom zoom: Offset %1x%2 HScale %3 VScale %4")
920 if (fabs(raw - 1.333333F) < 0.05F)
924 if (fabs(raw - 1.777777F) < 0.05F)
930static float snap(
float value,
float snapto,
float diff)
932 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)