ScreenTools.qml 1.75 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9 10
pragma Singleton

import QtQuick 2.2
import QtQuick.Controls 1.2

import QGroundControl.ScreenToolsController 1.0

Item {
    signal repaintRequested

11
    readonly property real defaultFontPixelSize:    _textMeasure.fontHeight * ScreenToolsController.defaultFontPixelSizeRatio
Don Gagne's avatar
Don Gagne committed
12
    readonly property real defaultFontPixelHeight:  defaultFontPixelSize
13
    readonly property real defaultFontPixelWidth:   _textMeasure.fontWidth
Don Gagne's avatar
Don Gagne committed
14
    readonly property real smallFontPixelSize:      defaultFontPixelSize * ScreenToolsController.smallFontPixelSizeRatio
15 16 17

    // On OSX ElCapitan with Qt 5.4.0 any font pixel size above 19 shows garbage test. No idea why at this point.
    // Will remove Math.min when problem is figure out.
Don Gagne's avatar
Don Gagne committed
18 19
    readonly property real mediumFontPixelSize:     Math.min(defaultFontPixelSize * ScreenToolsController.mediumFontPixelSizeRatio, ScreenToolsController.isMobile ? 10000 : 19)
    readonly property real largeFontPixelSize:      Math.min(defaultFontPixelSize * ScreenToolsController.largeFontPixelSizeRatio, ScreenToolsController.isMobile ? 10000 : 19)
Don Gagne's avatar
Don Gagne committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33

    property bool isAndroid:        ScreenToolsController.isAndroid
    property bool isiOS:            ScreenToolsController.isiOS
    property bool isMobile:         ScreenToolsController.isMobile

    function mouseX() {
        return ScreenToolsController.mouseX()
    }

    function mouseY() {
        return ScreenToolsController.mouseY()
    }

    Text {
34 35 36 37 38
        id:     _textMeasure
        text:   "X"

        property real fontWidth:    contentWidth * (ScreenToolsController.testHighDPI ? 2 : 1)
        property real fontHeight:   contentHeight * (ScreenToolsController.testHighDPI ? 2 : 1)
Don Gagne's avatar
Don Gagne committed
39 40 41 42 43 44 45
    }

    Connections {
        target: ScreenToolsController
        onRepaintRequested: repaintRequested()
    }
}