mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-11-04 00:52:11 +00:00 
			
		
		
		
	Allow screen margin customization.
This commit is contained in:
		@@ -88,6 +88,9 @@ QtObject{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    property real rbgShift: 0.0
 | 
					    property real rbgShift: 0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    property real _margin: 0.5
 | 
				
			||||||
 | 
					    property real margin: Utils.lint(1.0, 20.0, _margin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    readonly property int no_rasterization: 0
 | 
					    readonly property int no_rasterization: 0
 | 
				
			||||||
    readonly property int scanline_rasterization: 1
 | 
					    readonly property int scanline_rasterization: 1
 | 
				
			||||||
    readonly property int pixel_rasterization: 2
 | 
					    readonly property int pixel_rasterization: 2
 | 
				
			||||||
@@ -225,7 +228,8 @@ QtObject{
 | 
				
			|||||||
            ambientLight: ambientLight,
 | 
					            ambientLight: ambientLight,
 | 
				
			||||||
            windowOpacity: windowOpacity,
 | 
					            windowOpacity: windowOpacity,
 | 
				
			||||||
            fontName: fontNames[rasterization],
 | 
					            fontName: fontNames[rasterization],
 | 
				
			||||||
            fontWidth: fontWidth
 | 
					            fontWidth: fontWidth,
 | 
				
			||||||
 | 
					            margin: _margin
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return settings;
 | 
					        return settings;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -317,6 +321,8 @@ QtObject{
 | 
				
			|||||||
        fontNames[rasterization] = settings.fontName !== undefined ? settings.fontName : fontNames[rasterization];
 | 
					        fontNames[rasterization] = settings.fontName !== undefined ? settings.fontName : fontNames[rasterization];
 | 
				
			||||||
        fontWidth = settings.fontWidth !== undefined ? settings.fontWidth : fontWidth;
 | 
					        fontWidth = settings.fontWidth !== undefined ? settings.fontWidth : fontWidth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        _margin = settings.margin !== undefined ? settings.margin : _margin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        handleFontChanged();
 | 
					        handleFontChanged();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -386,7 +392,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0.2483,
 | 
					                  "saturationColor": 0.2483,
 | 
				
			||||||
                  "screenCurvature": 0.3,
 | 
					                  "screenCurvature": 0.3,
 | 
				
			||||||
                  "staticNoise": 0.1198,
 | 
					                  "staticNoise": 0.1198,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -413,7 +420,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0.0,
 | 
					                  "saturationColor": 0.0,
 | 
				
			||||||
                  "screenCurvature": 0.3,
 | 
					                  "screenCurvature": 0.3,
 | 
				
			||||||
                  "staticNoise": 0.1198,
 | 
					                  "staticNoise": 0.1198,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -440,7 +448,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0.5,
 | 
					                  "saturationColor": 0.5,
 | 
				
			||||||
                  "screenCurvature": 0.3,
 | 
					                  "screenCurvature": 0.3,
 | 
				
			||||||
                  "staticNoise": 0.15,
 | 
					                  "staticNoise": 0.15,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -467,7 +476,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0,
 | 
					                  "saturationColor": 0,
 | 
				
			||||||
                  "screenCurvature": 0,
 | 
					                  "screenCurvature": 0,
 | 
				
			||||||
                  "staticNoise": 0.15,
 | 
					                  "staticNoise": 0.15,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -494,7 +504,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0,
 | 
					                  "saturationColor": 0,
 | 
				
			||||||
                  "screenCurvature": 0.5,
 | 
					                  "screenCurvature": 0.5,
 | 
				
			||||||
                  "staticNoise": 0.099,
 | 
					                  "staticNoise": 0.099,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -521,7 +532,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0,
 | 
					                  "saturationColor": 0,
 | 
				
			||||||
                  "screenCurvature": 0.5,
 | 
					                  "screenCurvature": 0.5,
 | 
				
			||||||
                  "staticNoise": 0.2969,
 | 
					                  "staticNoise": 0.2969,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -548,7 +560,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0,
 | 
					                  "saturationColor": 0,
 | 
				
			||||||
                  "screenCurvature": 0.4,
 | 
					                  "screenCurvature": 0.4,
 | 
				
			||||||
                  "staticNoise": 0.0503,
 | 
					                  "staticNoise": 0.0503,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -575,7 +588,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0,
 | 
					                  "saturationColor": 0,
 | 
				
			||||||
                  "screenCurvature": 0.2,
 | 
					                  "screenCurvature": 0.2,
 | 
				
			||||||
                  "staticNoise": 0,
 | 
					                  "staticNoise": 0,
 | 
				
			||||||
                  "windowOpacity": 1
 | 
					                  "windowOpacity": 1,
 | 
				
			||||||
 | 
					                  "margin": 0.5
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -602,7 +616,8 @@ QtObject{
 | 
				
			|||||||
                  "saturationColor": 0.4983,
 | 
					                  "saturationColor": 0.4983,
 | 
				
			||||||
                  "screenCurvature": 0,
 | 
					                  "screenCurvature": 0,
 | 
				
			||||||
                  "staticNoise": 0.0955,
 | 
					                  "staticNoise": 0.0955,
 | 
				
			||||||
                  "windowOpacity": 0.7
 | 
					                  "windowOpacity": 0.7,
 | 
				
			||||||
 | 
					                  "margin": 0.1
 | 
				
			||||||
                }'
 | 
					                }'
 | 
				
			||||||
            builtin: true
 | 
					            builtin: true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,12 +36,12 @@ Loader {
 | 
				
			|||||||
        property int burnInScaling: scaleTexture * appSettings.burnInQuality
 | 
					        property int burnInScaling: scaleTexture * appSettings.burnInQuality
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        width: appSettings.lowResolutionFont
 | 
					        width: appSettings.lowResolutionFont
 | 
				
			||||||
               ? kterminal.width * Math.max(1, burnInScaling)
 | 
					               ? kterminal.totalWidth * Math.max(1, burnInScaling)
 | 
				
			||||||
               : kterminal.width * scaleTexture * appSettings.burnInQuality
 | 
					               : kterminal.totalWidth * scaleTexture * appSettings.burnInQuality
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        height: appSettings.lowResolutionFont
 | 
					        height: appSettings.lowResolutionFont
 | 
				
			||||||
                ? kterminal.height * Math.max(1, burnInScaling)
 | 
					                ? kterminal.totalHeight * Math.max(1, burnInScaling)
 | 
				
			||||||
                : kterminal.height * scaleTexture * appSettings.burnInQuality
 | 
					                : kterminal.totalHeight * scaleTexture * appSettings.burnInQuality
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ShaderEffectSource {
 | 
					        ShaderEffectSource {
 | 
				
			||||||
            id: burnInEffectSource
 | 
					            id: burnInEffectSource
 | 
				
			||||||
@@ -52,7 +52,7 @@ Loader {
 | 
				
			|||||||
            live: false
 | 
					            live: false
 | 
				
			||||||
            recursive: true
 | 
					            recursive: true
 | 
				
			||||||
            hideSource: true
 | 
					            hideSource: true
 | 
				
			||||||
            wrapMode: kterminalSource.wrapMode
 | 
					            wrapMode: ShaderEffectSource.ClampToEdge
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            format: ShaderEffectSource.RGBA
 | 
					            format: ShaderEffectSource.RGBA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ import QtQuick 2.0
 | 
				
			|||||||
import "utils.js" as Utils
 | 
					import "utils.js" as Utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ShaderEffect {
 | 
					ShaderEffect {
 | 
				
			||||||
    property color _staticFrameColor: "#dedede"
 | 
					    property color _staticFrameColor: "#ffffff"
 | 
				
			||||||
    property color _backgroundColor: appSettings.backgroundColor
 | 
					    property color _backgroundColor: appSettings.backgroundColor
 | 
				
			||||||
    property color _fontColor: appSettings.fontColor
 | 
					    property color _fontColor: appSettings.fontColor
 | 
				
			||||||
    property color _lightColor: Utils.mix(_fontColor, _backgroundColor, 0.2)
 | 
					    property color _lightColor: Utils.mix(_fontColor, _backgroundColor, 0.2)
 | 
				
			||||||
@@ -42,6 +42,10 @@ ShaderEffect {
 | 
				
			|||||||
            return min(v.x, v.y);
 | 
					            return min(v.x, v.y);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        float prod2(vec2 v) {
 | 
				
			||||||
 | 
					            return v.x * v.y;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        float sum2(vec2 v) {
 | 
					        float sum2(vec2 v) {
 | 
				
			||||||
            return v.x + v.y;
 | 
					            return v.x + v.y;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -54,6 +58,7 @@ ShaderEffect {
 | 
				
			|||||||
            float alpha = 0.0;
 | 
					            float alpha = 0.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            float outShadowLength = shadowLength;
 | 
					            float outShadowLength = shadowLength;
 | 
				
			||||||
 | 
					            float inShadowLength = shadowLength * 0.5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            float outShadow = max2(1.0 - smoothstep(vec2(-outShadowLength), vec2(0.0), coords) + smoothstep(vec2(1.0), vec2(1.0 + outShadowLength), coords));
 | 
					            float outShadow = max2(1.0 - smoothstep(vec2(-outShadowLength), vec2(0.0), coords) + smoothstep(vec2(1.0), vec2(1.0 + outShadowLength), coords));
 | 
				
			||||||
            outShadow = clamp(0.0, 1.0, sqrt(outShadow));
 | 
					            outShadow = clamp(0.0, 1.0, sqrt(outShadow));
 | 
				
			||||||
@@ -61,6 +66,10 @@ ShaderEffect {
 | 
				
			|||||||
            alpha = sum2(1.0 - smoothstep(vec2(0.0), aadelta, coords) + smoothstep(vec2(1.0) - aadelta, vec2(1.0), coords));
 | 
					            alpha = sum2(1.0 - smoothstep(vec2(0.0), aadelta, coords) + smoothstep(vec2(1.0) - aadelta, vec2(1.0), coords));
 | 
				
			||||||
            alpha = clamp(alpha, 0.0, 1.0) * mix(1.0, 0.9, outShadow);
 | 
					            alpha = clamp(alpha, 0.0, 1.0) * mix(1.0, 0.9, outShadow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            float inShadow = 1.0 - prod2(smoothstep(0.0, inShadowLength, coords) - smoothstep(1.0 - inShadowLength, 1.0, coords));
 | 
				
			||||||
 | 
					            inShadow = 0.5 * inShadow * inShadow;
 | 
				
			||||||
 | 
					            alpha = max(alpha, inShadow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            gl_FragColor = vec4(color * alpha, alpha);
 | 
					            gl_FragColor = vec4(color * alpha, alpha);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    "
 | 
					    "
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ import "utils.js" as Utils
 | 
				
			|||||||
Item{
 | 
					Item{
 | 
				
			||||||
    id: terminalContainer
 | 
					    id: terminalContainer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    property size virtualResolution: Qt.size(kterminal.width, kterminal.height)
 | 
					    property size virtualResolution: Qt.size(kterminal.totalWidth, kterminal.totalHeight)
 | 
				
			||||||
    property alias mainTerminal: kterminal
 | 
					    property alias mainTerminal: kterminal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    property ShaderEffectSource mainSource: kterminalSource
 | 
					    property ShaderEffectSource mainSource: kterminalSource
 | 
				
			||||||
@@ -69,6 +69,11 @@ Item{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    QMLTermWidget {
 | 
					    QMLTermWidget {
 | 
				
			||||||
        id: kterminal
 | 
					        id: kterminal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        property real margin: appSettings.margin / screenScaling
 | 
				
			||||||
 | 
					        property real totalWidth: 2 * margin + width
 | 
				
			||||||
 | 
					        property real totalHeight: 2 * margin + height
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        width: Math.floor(parent.width / (screenScaling * fontWidth))
 | 
					        width: Math.floor(parent.width / (screenScaling * fontWidth))
 | 
				
			||||||
        height: Math.floor(parent.height / screenScaling)
 | 
					        height: Math.floor(parent.height / screenScaling)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -167,6 +172,8 @@ Item{
 | 
				
			|||||||
    property alias contextmenu: menuLoader.item
 | 
					    property alias contextmenu: menuLoader.item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    MouseArea{
 | 
					    MouseArea{
 | 
				
			||||||
 | 
					        property real margin: appSettings.margin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
 | 
					        acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
 | 
				
			||||||
        anchors.fill: parent
 | 
					        anchors.fill: parent
 | 
				
			||||||
        cursorShape: kterminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor
 | 
					        cursorShape: kterminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor
 | 
				
			||||||
@@ -200,14 +207,14 @@ Item{
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        function correctDistortion(x, y){
 | 
					        function correctDistortion(x, y){
 | 
				
			||||||
            x = x / width;
 | 
					            x = (x - margin) / width;
 | 
				
			||||||
            y = y / height;
 | 
					            y = (y - margin) / height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var cc = Qt.size(0.5 - x, 0.5 - y);
 | 
					            var cc = Qt.size(0.5 - x, 0.5 - y);
 | 
				
			||||||
            var distortion = (cc.height * cc.height + cc.width * cc.width) * appSettings.screenCurvature * appSettings.screenCurvatureSize;
 | 
					            var distortion = (cc.height * cc.height + cc.width * cc.width) * appSettings.screenCurvature * appSettings.screenCurvatureSize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return Qt.point((x - cc.width  * (1+distortion) * distortion) * kterminal.width,
 | 
					            return Qt.point((x - cc.width  * (1+distortion) * distortion) * kterminal.totalWidth,
 | 
				
			||||||
                           (y - cc.height * (1+distortion) * distortion) * kterminal.height)
 | 
					                           (y - cc.height * (1+distortion) * distortion) * kterminal.totalHeight)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    ShaderEffectSource{
 | 
					    ShaderEffectSource{
 | 
				
			||||||
@@ -216,7 +223,8 @@ Item{
 | 
				
			|||||||
        hideSource: true
 | 
					        hideSource: true
 | 
				
			||||||
        wrapMode: ShaderEffectSource.Repeat
 | 
					        wrapMode: ShaderEffectSource.Repeat
 | 
				
			||||||
        visible: false
 | 
					        visible: false
 | 
				
			||||||
        textureSize: Qt.size(kterminal.width * scaleTexture, kterminal.height * scaleTexture);
 | 
					        textureSize: Qt.size(kterminal.totalWidth * scaleTexture, kterminal.totalHeight * scaleTexture)
 | 
				
			||||||
 | 
					        sourceRect: Qt.rect(-kterminal.margin, -kterminal.margin, kterminal.totalWidth, kterminal.totalHeight)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    BurnInEffect {
 | 
					    BurnInEffect {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -109,6 +109,11 @@ Tab{
 | 
				
			|||||||
                    onValueChanged: appSettings.windowOpacity = value
 | 
					                    onValueChanged: appSettings.windowOpacity = value
 | 
				
			||||||
                    value: appSettings.windowOpacity
 | 
					                    value: appSettings.windowOpacity
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                Label{ text: qsTr("Margin") }
 | 
				
			||||||
 | 
					                SimpleSlider{
 | 
				
			||||||
 | 
					                    onValueChanged: appSettings._margin = value
 | 
				
			||||||
 | 
					                    value: appSettings._margin
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user