Ticket #12424: 0001-Centre-zoomed-images.patch

File 0001-Centre-zoomed-images.patch, 3.5 KB (added by Roger Siddons <dizygotheca@…>, 5 years ago)

Patch 1

  • mythtv/libs/libmythui/mythuianimation.cpp

    From 00ff0c97de90cd83a89e475069a590adb1c32c1e Mon Sep 17 00:00:00 2001
    From: Roger Siddons <dizygotheca@ntlworld.com>
    Date: Sun, 25 Jan 2015 00:16:01 +0000
    Subject: [PATCH 1/4] Centre zoomed images
    
    Images that are smaller than a widget are centred, but the image zoom is currently ignored. This results in a slideshow image being displaced when it is zoomed.
    This patch improves the problem but it may not be a complete solution as the image still wobbles when being zoomed.
    
    diff --git a/mythtv/libs/libmythui/mythuianimation.cpp b/mythtv/libs/libmythui/mythuianimation.cpp
    index 2b66467..39fbec7 100644
    a b  
    44
    55#include <QDomDocument>
    66
     7QRect UIEffects::GetExtent(const QSize &size)
     8{
     9    int x = 0, y = 0;
     10    int zoomedWidth = size.width() * hzoom;
     11    int zoomedHeight = size.height() * vzoom;
     12
     13    switch (centre)
     14    {
     15    case TopLeft:
     16    case Top:
     17    case TopRight:
     18        y = -zoomedHeight / 2; break;
     19    case Left:
     20    case Middle:
     21    case Right:
     22        y = -size.height() / 2; break;
     23    case BottomLeft:
     24    case Bottom:
     25    case BottomRight:
     26        y = size.height() - zoomedHeight / 2; break;
     27    }
     28
     29    switch (centre)
     30    {
     31    case TopLeft:
     32    case Left:
     33    case BottomLeft:
     34        x = -zoomedWidth / 2; break;
     35    case Top:
     36    case Middle:
     37    case Bottom:
     38        x = -size.width() / 2; break;
     39    case TopRight:
     40    case Right:
     41    case BottomRight:
     42        x = size.width() - zoomedWidth / 2; break;
     43    }
     44
     45    return QRect(x, y, zoomedWidth, zoomedHeight);
     46}
     47
    748MythUIAnimation::MythUIAnimation(MythUIType* parent, Trigger trigger, Type type)
    849    : m_parent(parent), m_type(type), m_trigger(trigger),
    950      m_centre(UIEffects::Middle), m_active(false), m_looped(false),
  • mythtv/libs/libmythui/mythuianimation.h

    diff --git a/mythtv/libs/libmythui/mythuianimation.h b/mythtv/libs/libmythui/mythuianimation.h
    index 3c605da..9afa361 100644
    a b class UIEffects 
    3131        return QPointF(x, y);
    3232    }
    3333
     34    QRect GetExtent(const QSize &size);
     35
    3436    int    alpha;
    3537    float  hzoom;
    3638    float  vzoom;
  • mythtv/libs/libmythui/mythuiimage.cpp

    diff --git a/mythtv/libs/libmythui/mythuiimage.cpp b/mythtv/libs/libmythui/mythuiimage.cpp
    index 1637b2a..03dcc80 100644
    a b void MythUIImage::DrawSelf(MythPainter *p, int xoffset, int yoffset, 
    12781278        if (!m_imageProperties.forceSize.isNull())
    12791279            area.setSize(area.size().expandedTo(currentImage->size()));
    12801280
    1281         // Centre image in available space
    1282         int x = 0;
    1283         int y = 0;
     1281        // Centre image in available space, accounting for zoom
     1282        int x = 0, y = 0;
     1283        QRect visibleImage = m_Effects.GetExtent(currentImageArea.size());
    12841284
    1285         if (area.width() > currentImageArea.width())
    1286             x = (area.width() - currentImageArea.width()) / 2;
     1285        if (area.width() > visibleImage.width())
     1286            x = area.width() / 2 + visibleImage.topLeft().x();
    12871287
    1288         if (area.height() > currentImageArea.height())
    1289             y = (area.height() - currentImageArea.height()) / 2;
     1288        if (area.height() > visibleImage.height())
     1289            y = area.height() / 2 + visibleImage.topLeft().y();
    12901290
    1291         if (x > 0 || y > 0)
     1291        if ((x > 0 || y > 0))
    12921292            area.translate(x, y);
    12931293
    12941294        QRect srcRect;