VirtualBox

Changeset 95100 in vbox


Ignore:
Timestamp:
May 25, 2022 12:59:54 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: macOS: HiDPI support for BETA label stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.cpp

    r93115 r95100  
    2222
    2323/* GUI include */
     24#include "UIDesktopWidgetWatchdog.h"
    2425#include "UIImageTools.h"
    2526
     
    201202}
    202203
    203 static QImage betaLabelImage(const QSize &size)
    204 {
     204static QImage betaLabelImage(QSize size, QWidget *pHint)
     205{
     206    /* Calculate device pixel ratio: */
     207    const double dDpr = pHint ? gpDesktop->devicePixelRatio(pHint) : gpDesktop->devicePixelRatio(-1);
     208    if (dDpr > 1.0)
     209        size *= dDpr;
     210
    205211    /* Beta label: */
    206212    QColor bgc(246, 179, 0);
     
    224230    /* The text: */
    225231    QFont f = p.font();
     232    if (dDpr > 1.0)
     233        f.setPointSize(f.pointSize() * dDpr);
    226234    f.setBold(true);
    227235    QPainterPath tp;
     
    254262    p1.fillRect(0, 0, size.width(), size.height(), lg);
    255263    p1.end();
     264    if (dDpr > 1.0)
     265        i1.setDevicePixelRatio(dDpr);
    256266
    257267    return i1;
    258268}
    259269
    260 QPixmap UIImageTools::betaLabel(const QSize &size /* = QSize(80, 16) */)
    261 {
    262     return QPixmap::fromImage(betaLabelImage(size));
    263 }
     270QPixmap UIImageTools::betaLabel(const QSize &size /* = QSize(80, 16) */, QWidget *pHint /* = 0 */)
     271{
     272    return QPixmap::fromImage(betaLabelImage(size, pHint));
     273}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.h

    r93115 r95100  
    4646
    4747    /** Applies BET-label of passed @a size. */
    48     SHARED_LIBRARY_STUFF QPixmap betaLabel(const QSize &size = QSize(80, 16));
     48    SHARED_LIBRARY_STUFF QPixmap betaLabel(const QSize &size = QSize(80, 16), QWidget *pHint = 0);
    4949}
    5050using namespace UIImageTools /* if header included */;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r95078 r95100  
    20312031    if (uiCommon().isBeta())
    20322032    {
    2033         QPixmap betaLabel = ::betaLabel(QSize(74, 26));
     2033        QPixmap betaLabel = ::betaLabel(QSize(74, darwinWindowTitleHeight(this) - 1));
    20342034        ::darwinLabelWindow(this, &betaLabel);
    20352035    }
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm

    r95082 r95100  
    132132}
    133133
    134 void darwinLabelWindow(NativeNSWindowRef pWindow, NativeNSImageRef pImage)
     134void darwinLabelWindow(NativeNSWindowRef pWindow, NativeNSImageRef pImage, double dDpr)
    135135{
    136136    /* Get the parent view of the close button. */
     
    142142        NSSize s1 = [wv frame].size;
    143143        /* Correctly position the label. */
    144         NSImageView *iv = [[NSImageView alloc] initWithFrame:NSMakeRect(s1.width - s.width,
    145                                                                         s1.height - s.height - 1,
    146                                                                         s.width, s.height)];
     144        NSImageView *iv = [[NSImageView alloc] initWithFrame:NSMakeRect(s1.width - s.width / dDpr,
     145                                                                        s1.height - s.height / dDpr - 1,
     146                                                                        s.width / dDpr, s.height / dDpr)];
    147147        /* Configure the NSImageView for auto moving. */
    148148        [iv setImage:pImage];
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp

    r95082 r95100  
    7575void darwinLabelWindow(QWidget *pWidget, QPixmap *pPixmap)
    7676{
    77     ::darwinLabelWindow(::darwinToNativeWindow(pWidget), ::darwinToNSImageRef(pPixmap));
     77    ::darwinLabelWindow(::darwinToNativeWindow(pWidget), ::darwinToNSImageRef(pPixmap), pPixmap->devicePixelRatio());
    7878}
    7979
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h

    r95082 r95100  
    8888void darwinSetShowsResizeIndicatorImpl(NativeNSWindowRef pWindow, bool fEnabled);
    8989void darwinSetHidesAllTitleButtonsImpl(NativeNSWindowRef pWindow);
    90 SHARED_LIBRARY_STUFF void darwinLabelWindow(NativeNSWindowRef pWindow, NativeNSImageRef pImage);
     90SHARED_LIBRARY_STUFF void darwinLabelWindow(NativeNSWindowRef pWindow, NativeNSImageRef pImage, double dDpr);
    9191void darwinSetShowsWindowTransparentImpl(NativeNSWindowRef pWindow, bool fEnabled);
    9292SHARED_LIBRARY_STUFF void darwinSetWindowHasShadow(NativeNSWindowRef pWindow, bool fEnabled);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r95078 r95100  
    347347    if (uiCommon().isBeta())
    348348    {
    349         QPixmap betaLabel = ::betaLabel(QSize(74, 26));
     349        QPixmap betaLabel = ::betaLabel(QSize(74, darwinWindowTitleHeight(this) - 1));
    350350        ::darwinLabelWindow(this, &betaLabel);
    351351    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r95078 r95100  
    7474    if (uiCommon().isBeta())
    7575    {
    76         QPixmap betaLabel = ::betaLabel(QSize(74, 26));
     76        QPixmap betaLabel = ::betaLabel(QSize(74, darwinWindowTitleHeight(this) - 1));
    7777        ::darwinLabelWindow(this, &betaLabel);
    7878    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette