Ticket #667: osd_scale-r7892.2.patch

File osd_scale-r7892.2.patch, 10.4 KB (added by gtgj@…, 20 years ago)

Revert changes to OSD menu spacing and margin. This is a separate issue and that change is not the way to fix the problem (menu spacing, margin are inconsistent at different OSD sizes).

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    412412    if (osd)
    413413    {
    414414        QRect visible, total;
    415         videoOutput->GetOSDBounds(total, visible);
    416         osd->Reinit(total.width(),   total.height(), frame_interval,
     415        float aspect;
     416        videoOutput->GetOSDBounds(total, visible, aspect);
     417        osd->Reinit(total.width(),   total.height(),
     418                    aspect,          frame_interval,
    417419                    visible.left(),  visible.top(),
    418420                    visible.width(), visible.height());
    419421    }
     
    20562058    if (!using_null_videoout)
    20572059    {
    20582060        QRect visible, total;
    2059         videoOutput->GetOSDBounds(total, visible);
    2060         osd = new OSD(total.width(),   total.height(), frame_interval,
     2061        float aspect;
     2062        videoOutput->GetOSDBounds(total, visible, aspect);
     2063        osd = new OSD(total.width(),   total.height(),
     2064                      aspect,          frame_interval,
    20612065                      visible.left(),  visible.top(),
    20622066                      visible.width(), visible.height());
    20632067
  • libs/libmythtv/osd.h

     
    4242{
    4343    Q_OBJECT
    4444 public:
    45     OSD(int width, int height, int framerate,
     45    OSD(int width, int height, float aspect, int framerate,
    4646        int dispx, int dispy, int dispw, int disph);
    4747   ~OSD(void);
    4848
     
    108108
    109109    int getTimeType(void) { return timeType; }
    110110
    111     void Reinit(int width, int height, int frint, int dispx, int dispy,
     111    void Reinit(int width, int height, float aspect, int frint,
     112                int dispx, int dispy,
    112113                int dispw, int disph);
    113114
    114115    void SetFrameInterval(int frint);
     
    152153
    153154    int vid_width;
    154155    int vid_height;
     156    float vid_aspect;
     157    float wscale;
    155158    int frameint;
    156159
    157160    QString themepath;
  • libs/libmythtv/videooutbase.cpp

     
    501501    height = imgh;
    502502}
    503503
    504 void VideoOutput::GetOSDBounds(QRect &total, QRect &visible) const
     504void VideoOutput::GetOSDBounds(QRect &total, QRect &visible, float &aspect) const
    505505{
    506506    total   = GetTotalOSDBounds();
    507507    visible = GetVisibleOSDBounds();
     508    aspect  = XJ_aspect;
     509    switch (letterbox)
     510    {
     511        case kLetterbox_16_9_Zoom:
     512            aspect = 4.0/3;
     513            break;
     514
     515        default:
     516            break;
     517    }
    508518}
    509519
    510520/**
  • libs/libmythtv/videooutbase.h

     
    146146    virtual void Zoom(int direction);
    147147 
    148148    virtual void GetDrawSize(int &xoff, int &yoff, int &width, int &height);
    149     virtual void GetOSDBounds(QRect &visible, QRect &total) const;
     149    virtual void GetOSDBounds(QRect &visible, QRect &total, float &aspect) const;
    150150
    151151    virtual int GetRefreshRate(void) = 0;
    152152
  • libs/libmythtv/ttfont.cpp

     
    525525    glyphs.clear();
    526526}
    527527
    528 TTFFont::TTFFont(char *file, int size, int video_width, int video_height,
     528TTFFont::TTFFont(char *file, int size, float wscale,
    529529                 float hmult)
    530530{
    531531   FT_Error            error;
     
    559559   fontsize = size;
    560560   library = the_library;
    561561
    562    vid_width = video_width;
    563    vid_height = video_height;
     562   m_wscale = wscale;
    564563   m_file = file;
    565564   m_hmult = hmult;
    566565
     
    609608   }
    610609
    611610   loadedfontsize = (int)(fontsize * m_hmult);
     611   xdpi = (int)(xdpi * m_wscale);
    612612
    613    if (vid_width != vid_height * 4 / 3)
    614    {
    615        xdpi = (int)(xdpi *
    616               (float)(vid_width / (float)(vid_height * 4 / 3)));
    617    }
    618 
    619613   FT_Set_Char_Size(face, 0, loadedfontsize * 64, xdpi, ydpi);
    620614
    621615   n = face->num_charmaps;
     
    650644   spacewidth = twidth - (mwidth * 2);
    651645}
    652646
    653 void TTFFont::Reinit(int width, int height, float hmult)
     647void TTFFont::Reinit(float wscale, float hmult)
    654648{
    655     vid_width = width;
    656     vid_height = height;
     649    m_wscale = wscale;
    657650    m_hmult = hmult;
    658651
    659652    KillFace();
  • libs/libmythtv/osd.cpp

     
    2727
    2828#include "osdlistbtntype.h"
    2929
    30 OSD::OSD(int width, int height, int frint,
     30OSD::OSD(int width, int height, float aspect, int frint,
    3131         int dispx, int dispy, int dispw, int disph)
    3232   : QObject()
    3333{
    3434    changed = false;
    3535    vid_width = width;
    3636    vid_height = height;
     37    vid_aspect = aspect;
    3738    frameint = frint;
    3839
    3940    editarrowleft = editarrowright = NULL;
     
    4546    yoffset = dispy;   
    4647    displaywidth = dispw;
    4748    displayheight = disph;
     49    wscale = (float)displaywidth/(vid_aspect*displayheight);
    4850
    4951    timeType = 0;
    5052    totalfadetime = 0;
     
    143145                               frameint);
    144146        AddSet(container, name);
    145147
    146         OSDTypeCC *ccpage = new OSDTypeCC(name, ccfont, xoffset, yoffset,
    147                                           displaywidth, displayheight);
     148        int sub_xoff, sub_yoff, sub_dispw, sub_disph;
     149        if (vid_aspect > 4.0f/3.0f)
     150        {
     151            // widescreen -- need to "pillarbox" captions
     152            sub_dispw = (int)(wscale * 4.0f*displayheight/3.0f);
     153            sub_disph = displayheight;
     154            sub_xoff = xoffset + (displaywidth-sub_dispw)/2;
     155            sub_yoff = yoffset;
     156        }
     157        else
     158        {
     159            sub_dispw = displaywidth;
     160            sub_disph = displayheight;
     161            sub_xoff = xoffset;
     162            sub_yoff = yoffset;
     163        }
     164
     165        OSDTypeCC *ccpage = new OSDTypeCC(name, ccfont, sub_xoff, sub_yoff,
     166                                          sub_dispw, sub_disph);
    148167        container->AddType(ccpage);
    149168    }
    150169
     
    209228    }
    210229}
    211230
    212 void OSD::Reinit(int width, int height, int frint, int dispx, int dispy,
     231void OSD::Reinit(int width, int height, float aspect, int frint,
     232                 int dispx, int dispy,
    213233                 int dispw, int disph)
    214234{
    215235    osdlock.lock();
    216236
    217237    vid_width = width;
    218238    vid_height = height;
     239    vid_aspect = aspect;
    219240    if (frint != -1)
    220241        frameint = frint;
    221242
     
    226247    yoffset = dispy;
    227248    displaywidth = dispw;
    228249    displayheight = disph;
     250    wscale = (float)displaywidth/(vid_aspect*displayheight);
    229251
    230252    QMap<QString, TTFFont *>::iterator fonts = fontMap.begin();
    231253    for (; fonts != fontMap.end(); ++fonts)
    232254    {
    233255        TTFFont *font = (*fonts);
    234256        if (font)
    235             font->Reinit(dispw, disph, hmult);
     257            font->Reinit(wscale, hmult);
    236258    }
    237259
    238260    QMap<QString, OSDSet *>::iterator sets = setMap.begin();
     
    240262    {
    241263        OSDSet *set = (*sets);
    242264        if (set)
    243             set->Reinit(vid_width, vid_height, dispx, dispy, dispw, disph,
     265        {
     266            int sub_xoff, sub_yoff, sub_dispw, sub_disph;
     267            if (set->GetName() == "cc_page" && vid_aspect > 4.0f/3.0f)
     268            {
     269                // widescreen -- need to "pillarbox" captions
     270                sub_dispw = (int)(wscale * 4.0f*displayheight/3.0f);
     271                sub_disph = displayheight;
     272                sub_xoff = xoffset + (displaywidth-sub_dispw)/2;
     273                sub_yoff = yoffset;
     274            }
     275            else
     276            {
     277                sub_dispw = displaywidth;
     278                sub_disph = displayheight;
     279                sub_xoff = xoffset;
     280                sub_yoff = yoffset;
     281            }
     282            set->Reinit(vid_width, vid_height, sub_xoff, sub_yoff, sub_dispw, sub_disph,
    244283                        wmult, hmult, frameint);
     284        }
    245285    }
    246286
    247287    delete drawSurface;
     
    274314TTFFont *OSD::LoadFont(QString name, int size)
    275315{
    276316    QString fullname = MythContext::GetConfDir() + "/" + name;
    277     TTFFont *font = new TTFFont((char *)fullname.ascii(), size, vid_width,
    278                                 vid_height, hmult);
     317    TTFFont *font = new TTFFont((char *)fullname.ascii(), size, wscale,
     318                                hmult);
    279319
    280320    if (font->isValid())
    281321        return font;
     
    283323    delete font;
    284324    fullname = gContext->GetShareDir() + name;
    285325
    286     font = new TTFFont((char *)fullname.ascii(), size, vid_width,
    287                        vid_height, hmult);
     326    font = new TTFFont((char *)fullname.ascii(), size, wscale,
     327                       hmult);
    288328
    289329    if (font->isValid())
    290330        return font;
     
    293333    if (themepath != "")
    294334    {
    295335        fullname = themepath + "/" + name;
    296         font = new TTFFont((char *)fullname.ascii(), size, vid_width,
    297                            vid_height, hmult);
     336        font = new TTFFont((char *)fullname.ascii(), size, wscale,
     337                           hmult);
    298338        if (font->isValid())
    299339            return font;
    300340    }
     
    302342    delete font;
    303343
    304344    fullname = name;
    305     font = new TTFFont((char *)fullname.ascii(), size, vid_width, vid_height,
     345    font = new TTFFont((char *)fullname.ascii(), size, wscale,
    306346                       hmult);
    307347
    308348    if (font->isValid())
  • libs/libmythtv/ttfont.h

     
    2727class TTFFont
    2828{
    2929  public:
    30      TTFFont(char *file, int size, int video_width, int video_height,
     30     TTFFont(char *file, int size, float wscale,
    3131             float hmult);
    3232    ~TTFFont();
    3333
     
    4646     void CalcWidth(const QString &text, int *width_return);
    4747
    4848     int SpaceWidth() { return spacewidth; }
    49      int Size() { return m_size; }
     49     int Size() { return loadedfontsize; }
    5050
    51      void Reinit(int width, int height, float hmult);
     51     void Reinit(float wscale, float hmult);
    5252
    5353  private:
    5454     void KillFace(void);
     
    100100     QString m_file;
    101101
    102102     int loadedfontsize;
     103     float m_wscale;
    103104     float m_hmult;
    104105};
    105106