Compare commits
4 Commits
fix-qml-st
...
unstable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d99b1d29c | ||
|
|
4abbe332db | ||
|
|
3104abd4ad | ||
|
|
7714f7b503 |
39
app/qml/ApplicationConstants.qml
Normal file
39
app/qml/ApplicationConstants.qml
Normal file
@@ -0,0 +1,39 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013-2021 "Filippo Scognamiglio"
|
||||
* https://github.com/Swordfish90/cool-retro-term
|
||||
*
|
||||
* This file is part of cool-retro-term.
|
||||
*
|
||||
* cool-retro-term is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
import QtQuick 2.2
|
||||
|
||||
QtObject {
|
||||
readonly property string version: appVersion
|
||||
readonly property int profileVersion: 2
|
||||
|
||||
readonly property real screenCurvatureSize: 0.4
|
||||
readonly property real minimumFontScaling: 0.25
|
||||
readonly property real maximumFontScaling: 2.50
|
||||
|
||||
readonly property real minBurnInFadeTime: 160
|
||||
readonly property real maxBurnInFadeTime: 1600
|
||||
|
||||
readonly property int no_rasterization: 0
|
||||
readonly property int scanline_rasterization: 1
|
||||
readonly property int pixel_rasterization: 2
|
||||
readonly property int subpixel_rasterization: 3
|
||||
|
||||
readonly property real baseFontScaling: 0.75
|
||||
}
|
||||
@@ -23,18 +23,8 @@ import QtQuick.Controls 2.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
QtObject {
|
||||
readonly property string version: appVersion
|
||||
readonly property int profileVersion: 2
|
||||
|
||||
// STATIC CONSTANTS ////////////////////////////////////////////////////////
|
||||
readonly property real screenCurvatureSize: 0.4
|
||||
readonly property real minimumFontScaling: 0.25
|
||||
readonly property real maximumFontScaling: 2.50
|
||||
|
||||
readonly property real minBurnInFadeTime: 160
|
||||
readonly property real maxBurnInFadeTime: 1600
|
||||
|
||||
// GENERAL SETTINGS ///////////////////////////////////////////////////////
|
||||
// APPLICATION SETTINGS ///////////////////////////////////////////////////////
|
||||
property int x: 100
|
||||
property int y: 100
|
||||
property int width: 1024
|
||||
@@ -56,8 +46,6 @@ QtObject {
|
||||
property real burnInQuality: 0.5
|
||||
property bool useFastBurnIn: Qt.platform.os === "osx" ? false : true
|
||||
|
||||
property bool blinkingCursor: false
|
||||
|
||||
onWindowScalingChanged: handleFontChanged()
|
||||
|
||||
// PROFILE SETTINGS ///////////////////////////////////////////////////////
|
||||
@@ -99,18 +87,20 @@ QtObject {
|
||||
property real rbgShift: 0.0
|
||||
|
||||
property real _margin: 0.5
|
||||
property real margin: Utils.lint(1.0, 20.0, _margin)
|
||||
property real _frameMargin: 0.5
|
||||
|
||||
readonly property int no_rasterization: 0
|
||||
readonly property int scanline_rasterization: 1
|
||||
readonly property int pixel_rasterization: 2
|
||||
property real margin: Utils.lint(1.0, 20.0, _margin)
|
||||
property real frameMargin: Utils.lint(1.0, 50.0, _frameMargin)
|
||||
|
||||
property real totalMargin: frameMargin + margin
|
||||
|
||||
property int rasterization: no_rasterization
|
||||
|
||||
property bool blinkingCursor: false
|
||||
|
||||
// FONTS //////////////////////////////////////////////////////////////////
|
||||
readonly property real baseFontScaling: 0.75
|
||||
property real fontScaling: 1.0
|
||||
property real totalFontScaling: baseFontScaling * fontScaling
|
||||
property real totalFontScaling: appConstants.baseFontScaling * fontScaling
|
||||
|
||||
property real fontWidth: 1.0
|
||||
|
||||
@@ -126,21 +116,28 @@ QtObject {
|
||||
property Loader fontManager: Loader {
|
||||
states: [
|
||||
State {
|
||||
when: rasterization == no_rasterization
|
||||
when: rasterization == appConstants.no_rasterization
|
||||
PropertyChanges {
|
||||
target: fontManager
|
||||
source: "Fonts.qml"
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: rasterization == scanline_rasterization
|
||||
when: rasterization == appConstants.scanline_rasterization
|
||||
PropertyChanges {
|
||||
target: fontManager
|
||||
source: "FontScanlines.qml"
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: rasterization == pixel_rasterization
|
||||
when: rasterization == appConstants.pixel_rasterization
|
||||
PropertyChanges {
|
||||
target: fontManager
|
||||
source: "FontPixels.qml"
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: rasterization == appConstants.subpixel_rasterization
|
||||
PropertyChanges {
|
||||
target: fontManager
|
||||
source: "FontPixels.qml"
|
||||
@@ -166,12 +163,12 @@ QtObject {
|
||||
}
|
||||
|
||||
function incrementScaling() {
|
||||
fontScaling = Math.min(fontScaling + 0.05, maximumFontScaling)
|
||||
fontScaling = Math.min(fontScaling + 0.05, appConstants.maximumFontScaling)
|
||||
handleFontChanged()
|
||||
}
|
||||
|
||||
function decrementScaling() {
|
||||
fontScaling = Math.max(fontScaling - 0.05, minimumFontScaling)
|
||||
fontScaling = Math.max(fontScaling - 0.05, appConstants.minimumFontScaling)
|
||||
handleFontChanged()
|
||||
}
|
||||
|
||||
@@ -230,8 +227,7 @@ QtObject {
|
||||
"burnInQuality": burnInQuality,
|
||||
"useCustomCommand": useCustomCommand,
|
||||
"customCommand": customCommand,
|
||||
"useFastBurnIn": useFastBurnIn,
|
||||
"blinkingCursor": blinkingCursor
|
||||
"useFastBurnIn": useFastBurnIn
|
||||
}
|
||||
return stringify(settings)
|
||||
}
|
||||
@@ -258,7 +254,9 @@ QtObject {
|
||||
"windowOpacity": windowOpacity,
|
||||
"fontName": fontNames[rasterization],
|
||||
"fontWidth": fontWidth,
|
||||
"margin": _margin
|
||||
"margin": _margin,
|
||||
"blinkingCursor": blinkingCursor,
|
||||
"frameMargin": _frameMargin,
|
||||
}
|
||||
return settings
|
||||
}
|
||||
@@ -327,9 +325,6 @@ QtObject {
|
||||
|
||||
useFastBurnIn = settings.useFastBurnIn
|
||||
!== undefined ? settings.useFastBurnIn : useFastBurnIn
|
||||
|
||||
blinkingCursor = settings.blinkingCursor
|
||||
!== undefined ? settings.blinkingCursor : blinkingCursor
|
||||
}
|
||||
|
||||
function loadProfileString(profileString) {
|
||||
@@ -371,6 +366,9 @@ QtObject {
|
||||
fontWidth = settings.fontWidth !== undefined ? settings.fontWidth : fontWidth
|
||||
|
||||
_margin = settings.margin !== undefined ? settings.margin : _margin
|
||||
_frameMargin = settings.frameMargin !== undefined ? settings.frameMargin : _frameMargin
|
||||
|
||||
blinkingCursor = settings.blinkingCursor !== undefined ? settings.blinkingCursor : blinkingCursor
|
||||
|
||||
handleFontChanged()
|
||||
}
|
||||
@@ -451,7 +449,9 @@ QtObject {
|
||||
"screenCurvature": 0.3,
|
||||
"staticNoise": 0.1198,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -478,7 +478,9 @@ QtObject {
|
||||
"screenCurvature": 0.3,
|
||||
"staticNoise": 0.1198,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -505,7 +507,9 @@ QtObject {
|
||||
"screenCurvature": 0.3,
|
||||
"staticNoise": 0.15,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -532,7 +536,9 @@ QtObject {
|
||||
"screenCurvature": 0,
|
||||
"staticNoise": 0.15,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -559,7 +565,9 @@ QtObject {
|
||||
"screenCurvature": 0.5,
|
||||
"staticNoise": 0.099,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.2
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -586,7 +594,9 @@ QtObject {
|
||||
"screenCurvature": 0.5,
|
||||
"staticNoise": 0.2969,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.5
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -613,7 +623,9 @@ QtObject {
|
||||
"screenCurvature": 0.4,
|
||||
"staticNoise": 0.0503,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.2
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -640,7 +652,9 @@ QtObject {
|
||||
"screenCurvature": 0.2,
|
||||
"staticNoise": 0,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@@ -667,7 +681,9 @@ QtObject {
|
||||
"screenCurvature": 0,
|
||||
"staticNoise": 0.0955,
|
||||
"windowOpacity": 0.7,
|
||||
"margin": 0.1
|
||||
"margin": 0.1,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ Loader {
|
||||
property real delay: (1.0 / appSettings.fps) * 1000
|
||||
property real burnIn: appSettings.burnIn
|
||||
property real burnInFadeTime: 1 / Utils.lint(_minBurnInFadeTime, _maxBurnInFadeTime, burnIn)
|
||||
property real _minBurnInFadeTime: appSettings.minBurnInFadeTime
|
||||
property real _maxBurnInFadeTime: appSettings.maxBurnInFadeTime
|
||||
property real _minBurnInFadeTime: appConstants.minBurnInFadeTime
|
||||
property real _maxBurnInFadeTime: appConstants.maxBurnInFadeTime
|
||||
|
||||
active: appSettings.useFastBurnIn && appSettings.burnIn !== 0
|
||||
|
||||
@@ -89,6 +89,10 @@ Loader {
|
||||
}
|
||||
}
|
||||
|
||||
ShaderLibrary {
|
||||
id: shaderLibrary
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: burnInShaderEffect
|
||||
|
||||
@@ -118,9 +122,7 @@ Loader {
|
||||
|
||||
uniform highp float prevLastUpdate;" +
|
||||
|
||||
"float rgb2grey(vec3 v){
|
||||
return dot(v, vec3(0.21, 0.72, 0.04));
|
||||
}" +
|
||||
shaderLibrary.rgb2grey +
|
||||
|
||||
"void main() {
|
||||
vec2 coords = qt_TexCoord0;
|
||||
|
||||
@@ -73,7 +73,7 @@ Item{
|
||||
id: kterminal
|
||||
|
||||
property int textureResolutionScale: appSettings.lowResolutionFont ? devicePixelRatio : 1
|
||||
property int margin: appSettings.margin / screenScaling
|
||||
property int margin: appSettings.totalMargin / screenScaling
|
||||
property int totalWidth: Math.floor(parent.width / (screenScaling * fontWidth))
|
||||
property int totalHeight: Math.floor(parent.height / screenScaling)
|
||||
|
||||
@@ -177,8 +177,8 @@ Item{
|
||||
}
|
||||
property alias contextmenu: menuLoader.item
|
||||
|
||||
MouseArea{
|
||||
property real margin: appSettings.margin
|
||||
MouseArea {
|
||||
property real margin: appSettings.totalMargin
|
||||
|
||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||
anchors.fill: parent
|
||||
@@ -217,10 +217,10 @@ Item{
|
||||
y = (y - margin) / height;
|
||||
|
||||
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 * appConstants.screenCurvatureSize;
|
||||
|
||||
return Qt.point((x - cc.width * (1+distortion) * distortion) * kterminal.totalWidth,
|
||||
(y - cc.height * (1+distortion) * distortion) * kterminal.totalHeight)
|
||||
return Qt.point((x - cc.width * (1+distortion) * distortion) * (kterminal.totalWidth),
|
||||
(y - cc.height * (1+distortion) * distortion) * (kterminal.totalHeight))
|
||||
}
|
||||
}
|
||||
ShaderEffectSource{
|
||||
|
||||
@@ -156,7 +156,7 @@ ColumnLayout {
|
||||
}
|
||||
CheckBox {
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr("Burnin optimization (Might display timing artifacts)")
|
||||
text: qsTr("Burnin optimization (might display timing artifacts)")
|
||||
checked: appSettings.useFastBurnIn
|
||||
onCheckedChanged: appSettings.useFastBurnIn = checked
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ ColumnLayout {
|
||||
|
||||
var version = profileObject.version
|
||||
!== undefined ? profileObject.version : 1
|
||||
if (version !== appSettings.profileVersion)
|
||||
if (version !== appConstants.profileVersion)
|
||||
throw "This profile is not supported on this version of CRT."
|
||||
|
||||
delete profileObject.name
|
||||
@@ -160,7 +160,7 @@ ColumnLayout {
|
||||
var profileSettings = JSON.parse(
|
||||
profileObject.obj_string)
|
||||
profileSettings["name"] = profileObject.text
|
||||
profileSettings["version"] = appSettings.profileVersion
|
||||
profileSettings["version"] = appConstants.profileVersion
|
||||
|
||||
var result = fileIO.write(url, JSON.stringify(
|
||||
profileSettings,
|
||||
@@ -206,6 +206,13 @@ ColumnLayout {
|
||||
onValueChanged: appSettings._margin = value
|
||||
value: appSettings._margin
|
||||
}
|
||||
Label {
|
||||
text: qsTr("Frame size")
|
||||
}
|
||||
SimpleSlider {
|
||||
onValueChanged: appSettings._frameMargin = value
|
||||
value: appSettings._frameMargin
|
||||
}
|
||||
Label {
|
||||
text: qsTr("Opacity")
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ ColumnLayout {
|
||||
property string selectedElement: model[currentIndex]
|
||||
|
||||
Layout.fillWidth: true
|
||||
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")]
|
||||
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels"), qsTr("Sub-Pixels")]
|
||||
currentIndex: appSettings.rasterization
|
||||
onCurrentIndexChanged: {
|
||||
appSettings.rasterization = currentIndex
|
||||
@@ -83,8 +83,8 @@ ColumnLayout {
|
||||
onValueChanged: appSettings.fontScaling = value
|
||||
value: appSettings.fontScaling
|
||||
stepSize: 0.05
|
||||
from: appSettings.minimumFontScaling
|
||||
to: appSettings.maximumFontScaling
|
||||
from: appConstants.minimumFontScaling
|
||||
to: appConstants.maximumFontScaling
|
||||
}
|
||||
SizedLabel {
|
||||
text: Math.round(fontScalingChanger.value * 100) + "%"
|
||||
|
||||
91
app/qml/ShaderLibrary.qml
Normal file
91
app/qml/ShaderLibrary.qml
Normal file
@@ -0,0 +1,91 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
QtObject {
|
||||
property string rasterizationShader:
|
||||
(appSettings.rasterization === appConstants.no_rasterization ? "
|
||||
lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) {
|
||||
return texel;
|
||||
}" : "") +
|
||||
|
||||
(appSettings.rasterization === appConstants.scanline_rasterization ? "
|
||||
#define INTENSITY 0.30
|
||||
#define BRIGHTBOOST 0.30
|
||||
|
||||
lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) {
|
||||
lowp vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * texel)) * texel;
|
||||
lowp vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * texel)) * texel;
|
||||
|
||||
vec2 coords = fract(screenCoords * virtualResolution) * 2.0 - vec2(1.0);
|
||||
lowp float mask = 1.0 - abs(coords.y);
|
||||
|
||||
lowp vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask);
|
||||
return mix(texel, rasterizationColor, intensity);
|
||||
}" : "") +
|
||||
|
||||
(appSettings.rasterization === appConstants.pixel_rasterization ? "
|
||||
#define INTENSITY 0.30
|
||||
#define BRIGHTBOOST 0.30
|
||||
|
||||
lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) {
|
||||
lowp vec3 result = texel;
|
||||
|
||||
lowp vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * texel)) * texel;
|
||||
lowp vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * texel)) * texel;
|
||||
|
||||
vec2 coords = fract(screenCoords * virtualResolution) * 2.0 - vec2(1.0);
|
||||
coords = coords * coords;
|
||||
lowp float mask = 1.0 - coords.x - coords.y;
|
||||
|
||||
lowp vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask);
|
||||
return mix(texel, rasterizationColor, intensity);
|
||||
}" : "") +
|
||||
|
||||
(appSettings.rasterization === appConstants.subpixel_rasterization ? "
|
||||
#define INTENSITY 0.30
|
||||
#define BRIGHTBOOST 0.30
|
||||
#define SUBPIXELS 3.0
|
||||
const vec3 offsets = vec3(3.141592654) * vec3(1.0/2.0,1.0/2.0 - 2.0/3.0,1.0/2.0-4.0/3.0);
|
||||
|
||||
lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) {
|
||||
vec2 omega = vec2(3.141592654) * vec2(2.0) * virtualResolution;
|
||||
vec2 angle = screenCoords * omega;
|
||||
vec3 xfactors = (SUBPIXELS + sin(angle.x + offsets)) / (SUBPIXELS + 1.0);
|
||||
|
||||
lowp vec3 result = texel * xfactors;
|
||||
lowp vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * result)) * result;
|
||||
lowp vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * result)) * result;
|
||||
|
||||
vec2 coords = fract(screenCoords * virtualResolution) * 2.0 - vec2(1.0);
|
||||
lowp float mask = 1.0 - abs(coords.y);
|
||||
|
||||
lowp vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask);
|
||||
return mix(texel, rasterizationColor, intensity);
|
||||
}" : "") +
|
||||
|
||||
"\n\n"
|
||||
|
||||
property string min2: "
|
||||
float min2(vec2 v) {
|
||||
return min(v.x, v.y);
|
||||
}\n\n"
|
||||
|
||||
property string rgb2grey: "
|
||||
float rgb2grey(vec3 v) {
|
||||
return dot(v, vec3(0.21, 0.72, 0.04));
|
||||
}\n\n"
|
||||
|
||||
property string max2: "
|
||||
float max2(vec2 v) {
|
||||
return max(v.x, v.y);
|
||||
}\n\n"
|
||||
|
||||
property string prod2: "
|
||||
float prod2(vec2 v) {
|
||||
return v.x * v.y;
|
||||
}\n\n"
|
||||
|
||||
property string sum2: "
|
||||
float sum2(vec2 v) {
|
||||
return v.x + v.y;
|
||||
}\n\n"
|
||||
}
|
||||
@@ -32,17 +32,25 @@ Item {
|
||||
property color fontColor: appSettings.fontColor
|
||||
property color backgroundColor: appSettings.backgroundColor
|
||||
|
||||
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
|
||||
property real screenCurvature: appSettings.screenCurvature * appConstants.screenCurvatureSize
|
||||
|
||||
property real chromaColor: appSettings.chromaColor
|
||||
|
||||
property real ambientLight: appSettings.ambientLight * 0.2
|
||||
|
||||
property size virtual_resolution
|
||||
property size virtualResolution
|
||||
property size screenResolution
|
||||
|
||||
property real _screenDensity: Math.min(
|
||||
screenResolution.width / virtualResolution.width,
|
||||
screenResolution.height / virtualResolution.height
|
||||
)
|
||||
|
||||
ShaderEffect {
|
||||
id: dynamicShader
|
||||
|
||||
property ShaderLibrary shaderLibrary: ShaderLibrary { }
|
||||
|
||||
property ShaderEffectSource screenBuffer: frameBuffer
|
||||
property ShaderEffectSource burnInSource: burnInEffect.source
|
||||
property ShaderEffectSource frameSource: terminalFrameLoader.item
|
||||
@@ -71,10 +79,16 @@ Item {
|
||||
property size jitterDisplacement: Qt.size(0.007 * jitter, 0.002 * jitter)
|
||||
property real shadowLength: 0.25 * screenCurvature * Utils.lint(0.50, 1.5, ambientLight)
|
||||
property real staticNoise: appSettings.staticNoise
|
||||
property size scaleNoiseSize: Qt.size((width) / (noiseTexture.width * appSettings.windowScaling * appSettings.totalFontScaling),
|
||||
(height) / (noiseTexture.height * appSettings.windowScaling * appSettings.totalFontScaling))
|
||||
property size scaleNoiseSize: Qt.size((width * 0.75) / (noiseTexture.width * appSettings.windowScaling * appSettings.totalFontScaling),
|
||||
(height * 0.75) / (noiseTexture.height * appSettings.windowScaling * appSettings.totalFontScaling))
|
||||
|
||||
property size virtual_resolution: parent.virtual_resolution
|
||||
property size virtualResolution: parent.virtualResolution
|
||||
|
||||
// Rasterization might display oversamping issues if virtual resolution is close to physical display resolution.
|
||||
// We progressively disable rasterization from 4x up to 2x resolution.
|
||||
property real rasterizationIntensity: Utils.smoothstep(2.0, 4.0, _screenDensity)
|
||||
|
||||
property real displayTerminalFrame: appSettings._frameMargin > 0 || appSettings.screenCurvature > 0
|
||||
|
||||
property real time: timeManager.time
|
||||
property ShaderEffectSource noiseSource: noiseShaderSource
|
||||
@@ -164,7 +178,8 @@ Item {
|
||||
uniform highp vec4 backgroundColor;
|
||||
uniform lowp float shadowLength;
|
||||
|
||||
uniform highp vec2 virtual_resolution;" +
|
||||
uniform highp vec2 virtualResolution;
|
||||
uniform lowp float rasterizationIntensity;\n" +
|
||||
|
||||
(burnIn !== 0 ? "
|
||||
uniform sampler2D burnInSource;
|
||||
@@ -174,13 +189,13 @@ Item {
|
||||
uniform sampler2D slowBurnInSource;" : "") +
|
||||
(staticNoise !== 0 ? "
|
||||
uniform highp float staticNoise;" : "") +
|
||||
(((staticNoise !== 0 || jitter !== 0)
|
||||
||(fallBack && (flickering || horizontalSync))) ? "
|
||||
(((staticNoise !== 0 || jitter !== 0) ||(fallBack && (flickering || horizontalSync))) ? "
|
||||
uniform lowp sampler2D noiseSource;
|
||||
uniform highp vec2 scaleNoiseSize;" : "") +
|
||||
(screenCurvature !== 0 ? "
|
||||
uniform highp float screenCurvature;
|
||||
(displayTerminalFrame ? "
|
||||
uniform lowp sampler2D frameSource;" : "") +
|
||||
(screenCurvature !== 0 ? "
|
||||
uniform highp float screenCurvature;" : "") +
|
||||
(glowingLine !== 0 ? "
|
||||
uniform highp float glowingLine;" : "") +
|
||||
(chromaColor !== 0 ? "
|
||||
@@ -203,17 +218,14 @@ Item {
|
||||
|
||||
(glowingLine !== 0 ? "
|
||||
float randomPass(vec2 coords){
|
||||
return fract(smoothstep(-120.0, 0.0, coords.y - (virtual_resolution.y + 120.0) * fract(time * 0.00015)));
|
||||
return fract(smoothstep(-120.0, 0.0, coords.y - (virtualResolution.y + 120.0) * fract(time * 0.00015)));
|
||||
}" : "") +
|
||||
|
||||
"float min2(vec2 v) {
|
||||
return min(v.x, v.y);
|
||||
}
|
||||
|
||||
float rgb2grey(vec3 v){
|
||||
return dot(v, vec3(0.21, 0.72, 0.04));
|
||||
}
|
||||
shaderLibrary.min2 +
|
||||
shaderLibrary.rgb2grey +
|
||||
shaderLibrary.rasterizationShader +
|
||||
|
||||
"
|
||||
float isInScreen(vec2 v) {
|
||||
return min2(step(0.0, v) - step(1.0, v));
|
||||
}
|
||||
@@ -291,7 +303,7 @@ Item {
|
||||
color += noiseVal * noise * (1.0 - distance * 1.3);" : "") +
|
||||
|
||||
(glowingLine !== 0 ? "
|
||||
color += randomPass(coords * virtual_resolution) * glowingLine;" : "") +
|
||||
color += randomPass(coords * virtualResolution) * glowingLine;" : "") +
|
||||
|
||||
"vec3 txt_color = texture2D(screenBuffer, txt_coords).rgb;" +
|
||||
|
||||
@@ -309,6 +321,8 @@ Item {
|
||||
|
||||
"txt_color += fontColor.rgb * vec3(color);" +
|
||||
|
||||
"txt_color = applyRasterization(staticCoords, txt_color, virtualResolution, rasterizationIntensity);\n" +
|
||||
|
||||
"vec3 finalColor = txt_color;" +
|
||||
|
||||
(flickering !== 0 ? "
|
||||
@@ -317,7 +331,7 @@ Item {
|
||||
(ambientLight !== 0 ? "
|
||||
finalColor += vec3(ambientLight) * (1.0 - distance) * (1.0 - distance);" : "") +
|
||||
|
||||
(screenCurvature !== 0 ?
|
||||
(displayTerminalFrame ?
|
||||
"vec4 frameColor = texture2D(frameSource, qt_TexCoord0);
|
||||
finalColor = mix(finalColor, frameColor.rgb, frameColor.a);"
|
||||
: "") +
|
||||
@@ -340,7 +354,7 @@ Item {
|
||||
Loader {
|
||||
id: terminalFrameLoader
|
||||
|
||||
active: screenCurvature !== 0
|
||||
active: dynamicShader.displayTerminalFrame
|
||||
|
||||
width: staticShader.width
|
||||
height: staticShader.height
|
||||
@@ -352,7 +366,7 @@ Item {
|
||||
visible: false
|
||||
format: ShaderEffectSource.RGBA
|
||||
|
||||
NewTerminalFrame {
|
||||
TerminalFrame {
|
||||
id: terminalFrame
|
||||
blending: false
|
||||
anchors.fill: parent
|
||||
@@ -360,6 +374,10 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
ShaderLibrary {
|
||||
id: shaderLibrary
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: staticShader
|
||||
|
||||
@@ -385,7 +403,7 @@ Item {
|
||||
|
||||
property real ambientLight: parent.ambientLight
|
||||
|
||||
property size virtual_resolution: parent.virtual_resolution
|
||||
property size virtualResolution: parent.virtualResolution
|
||||
|
||||
blending: false
|
||||
visible: false
|
||||
@@ -408,7 +426,7 @@ Item {
|
||||
uniform highp vec4 backgroundColor;
|
||||
uniform lowp float screen_brightness;
|
||||
|
||||
uniform highp vec2 virtual_resolution;" +
|
||||
uniform highp vec2 virtualResolution;" +
|
||||
|
||||
(bloom !== 0 ? "
|
||||
uniform highp sampler2D bloomSource;
|
||||
@@ -426,36 +444,9 @@ Item {
|
||||
(ambientLight !== 0 ? "
|
||||
uniform lowp float ambientLight;" : "") +
|
||||
|
||||
"highp float getScanlineIntensity(vec2 coords) {
|
||||
float result = 1.0;" +
|
||||
|
||||
(appSettings.rasterization != appSettings.no_rasterization ?
|
||||
"float val = 0.0;
|
||||
vec2 rasterizationCoords = fract(coords * virtual_resolution);
|
||||
val += smoothstep(0.0, 0.5, rasterizationCoords.y);
|
||||
val -= smoothstep(0.5, 1.0, rasterizationCoords.y);
|
||||
result *= mix(0.5, 1.0, val);" : "") +
|
||||
|
||||
(appSettings.rasterization == appSettings.pixel_rasterization ?
|
||||
"val = 0.0;
|
||||
val += smoothstep(0.0, 0.5, rasterizationCoords.x);
|
||||
val -= smoothstep(0.5, 1.0, rasterizationCoords.x);
|
||||
result *= mix(0.5, 1.0, val);" : "") + "
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float min2(vec2 v) {
|
||||
return min(v.x, v.y);
|
||||
}
|
||||
|
||||
float sum2(vec2 v) {
|
||||
return v.x + v.y;
|
||||
}
|
||||
|
||||
float rgb2grey(vec3 v){
|
||||
return dot(v, vec3(0.21, 0.72, 0.04));
|
||||
}" +
|
||||
shaderLibrary.min2 +
|
||||
shaderLibrary.sum2 +
|
||||
shaderLibrary.rgb2grey +
|
||||
|
||||
"vec3 convertWithChroma(vec3 inColor) {
|
||||
vec3 outColor = inColor;" +
|
||||
@@ -468,6 +459,7 @@ Item {
|
||||
" return outColor;
|
||||
}" +
|
||||
|
||||
shaderLibrary.rasterizationShader +
|
||||
|
||||
"void main() {" +
|
||||
"vec2 cc = vec2(0.5) - qt_TexCoord0;" +
|
||||
@@ -490,8 +482,6 @@ Item {
|
||||
txt_color.b = leftColor.b * 0.30 + rightColor.b * 0.10 + txt_color.b * 0.60;
|
||||
" : "") +
|
||||
|
||||
"txt_color *= getScanlineIntensity(txt_coords);" +
|
||||
|
||||
"txt_color += vec3(0.0001);" +
|
||||
"float greyscale_color = rgb2grey(txt_color);" +
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ Loader {
|
||||
property real fps: appSettings.fps !== 0 ? appSettings.fps : 60
|
||||
property real burnInFadeTime: Utils.lint(minBurnInFadeTime, maxBurnInFadeTime, burnIn)
|
||||
property real burnInCoefficient: 1000 / (fps * burnInFadeTime)
|
||||
property real minBurnInFadeTime: appSettings.minBurnInFadeTime
|
||||
property real maxBurnInFadeTime: appSettings.maxBurnInFadeTime
|
||||
property real minBurnInFadeTime: appConstants.minBurnInFadeTime
|
||||
property real maxBurnInFadeTime: appConstants.maxBurnInFadeTime
|
||||
|
||||
id: burnInSourceEffect
|
||||
|
||||
|
||||
@@ -26,13 +26,19 @@ ShaderTerminal {
|
||||
property alias title: terminal.title
|
||||
property alias terminalSize: terminal.terminalSize
|
||||
|
||||
property real devicePixelRatio: terminalWindow.screen.devicePixelRatio
|
||||
|
||||
id: mainShader
|
||||
opacity: appSettings.windowOpacity * 0.3 + 0.7
|
||||
|
||||
source: terminal.mainSource
|
||||
burnInEffect: terminal.burnInEffect
|
||||
slowBurnInEffect: terminal.slowBurnInEffect
|
||||
virtual_resolution: terminal.virtualResolution
|
||||
virtualResolution: terminal.virtualResolution
|
||||
screenResolution: Qt.size(
|
||||
terminalWindow.width * devicePixelRatio * appSettings.windowScaling,
|
||||
terminalWindow.height * devicePixelRatio * appSettings.windowScaling
|
||||
)
|
||||
|
||||
TimeManager {
|
||||
id: timeManager
|
||||
|
||||
@@ -22,17 +22,27 @@ import QtQuick 2.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
ShaderEffect {
|
||||
property color _staticFrameColor: "#ffffff"
|
||||
property color _staticFrameColor: "#fff"
|
||||
property color _backgroundColor: appSettings.backgroundColor
|
||||
property color _fontColor: appSettings.fontColor
|
||||
property color _lightColor: Utils.mix(_fontColor, _backgroundColor, 0.2)
|
||||
property real _ambientLight: Utils.lint(0.2, 0.8, appSettings.ambientLight)
|
||||
|
||||
property color frameColor: Utils.mix(_staticFrameColor, _lightColor, _ambientLight)
|
||||
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
|
||||
property real shadowLength: 0.5 * screenCurvature * Utils.lint(0.50, 1.5, _ambientLight)
|
||||
property real screenCurvature: appSettings.screenCurvature * appConstants.screenCurvatureSize
|
||||
|
||||
property size aadelta: Qt.size(1.0 / width, 1.0 / height)
|
||||
// Coefficient of the log curve used to approximate shadowing
|
||||
property real screenShadowCoeff: Utils.lint(20.0, 10.0, _ambientLight)
|
||||
property real frameShadowCoeff: Utils.lint(20.0, 10.0, _ambientLight)
|
||||
|
||||
property size margin: Qt.size(
|
||||
appSettings.frameMargin / width * appSettings.windowScaling,
|
||||
appSettings.frameMargin / height * appSettings.windowScaling
|
||||
)
|
||||
|
||||
ShaderLibrary {
|
||||
id: shaderLibrary
|
||||
}
|
||||
|
||||
fragmentShader: "
|
||||
#ifdef GL_ES
|
||||
@@ -40,10 +50,11 @@ ShaderEffect {
|
||||
#endif
|
||||
|
||||
uniform lowp float screenCurvature;
|
||||
uniform lowp float shadowLength;
|
||||
uniform lowp float screenShadowCoeff;
|
||||
uniform lowp float frameShadowCoeff;
|
||||
uniform highp float qt_Opacity;
|
||||
uniform lowp vec4 frameColor;
|
||||
uniform mediump vec2 aadelta;
|
||||
uniform mediump vec2 margin;
|
||||
|
||||
varying highp vec2 qt_TexCoord0;
|
||||
|
||||
@@ -52,42 +63,38 @@ ShaderEffect {
|
||||
float dist = dot(cc, cc) * screenCurvature;
|
||||
return (coords + cc * (1.0 + dist) * dist);
|
||||
}
|
||||
" +
|
||||
|
||||
float max2(vec2 v) {
|
||||
return max(v.x, v.y);
|
||||
shaderLibrary.max2 +
|
||||
shaderLibrary.min2 +
|
||||
shaderLibrary.prod2 +
|
||||
shaderLibrary.sum2 +
|
||||
|
||||
"
|
||||
|
||||
vec2 positiveLog(vec2 x) {
|
||||
return clamp(log(x), vec2(0.0), vec2(100.0));
|
||||
}
|
||||
|
||||
float min2(vec2 v) {
|
||||
return min(v.x, v.y);
|
||||
}
|
||||
|
||||
float prod2(vec2 v) {
|
||||
return v.x * v.y;
|
||||
}
|
||||
|
||||
float sum2(vec2 v) {
|
||||
return v.x + v.y;
|
||||
}
|
||||
|
||||
void main(){
|
||||
void main() {
|
||||
vec2 staticCoords = qt_TexCoord0;
|
||||
vec2 coords = distortCoordinates(staticCoords);
|
||||
vec2 coords = distortCoordinates(staticCoords) * (vec2(1.0) + margin * 2.0) - margin;
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
vec2 vignetteCoords = staticCoords * (1.0 - staticCoords.yx);
|
||||
float vignette = pow(prod2(vignetteCoords) * 15.0, 0.25);
|
||||
|
||||
vec3 color = frameColor.rgb * vec3(1.0 - vignette);
|
||||
float alpha = 0.0;
|
||||
|
||||
float outShadowLength = shadowLength;
|
||||
float inShadowLength = shadowLength * 0.5;
|
||||
float frameShadow = max2(positiveLog(-coords * frameShadowCoeff + vec2(1.0)) + positiveLog(coords * frameShadowCoeff - (vec2(frameShadowCoeff) - vec2(1.0))));
|
||||
frameShadow = max(sqrt(frameShadow), 0.0);
|
||||
color *= frameShadow;
|
||||
alpha = sum2(1.0 - step(vec2(0.0), coords) + step(vec2(1.0), coords));
|
||||
alpha = clamp(alpha, 0.0, 1.0);
|
||||
alpha *= mix(1.0, 0.9, frameShadow);
|
||||
|
||||
float outShadow = max2(1.0 - smoothstep(vec2(-outShadowLength), vec2(0.0), coords) + smoothstep(vec2(1.0), vec2(1.0 + outShadowLength), coords));
|
||||
outShadow = clamp(sqrt(outShadow), 0.0, 1.0);
|
||||
color += frameColor.rgb * outShadow;
|
||||
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);
|
||||
|
||||
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);
|
||||
float screenShadow = 1.0 - prod2(positiveLog(coords * screenShadowCoeff + vec2(1.0)) * positiveLog(-coords * screenShadowCoeff + vec2(screenShadowCoeff + 1.0)));
|
||||
alpha = max(0.8 * screenShadow, alpha);
|
||||
|
||||
gl_FragColor = vec4(color * alpha, alpha);
|
||||
}
|
||||
@@ -127,6 +127,9 @@ ApplicationWindow {
|
||||
aboutDialog.raise()
|
||||
}
|
||||
}
|
||||
ApplicationConstants {
|
||||
id: appConstants
|
||||
}
|
||||
ApplicationSettings {
|
||||
id: appSettings
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@
|
||||
<file>fonts/1977-commodore-pet/PetMe.ttf</file>
|
||||
<file>BurnInEffect.qml</file>
|
||||
<file>fonts/modern-terminus/TerminusTTF-4.46.0.ttf</file>
|
||||
<file>NewTerminalFrame.qml</file>
|
||||
<file>TerminalFrame.qml</file>
|
||||
<file>SlowBurnIn.qml</file>
|
||||
<file>menus/WindowMenu.qml</file>
|
||||
<file>menus/FullContextMenu.qml</file>
|
||||
<file>menus/ShortContextMenu.qml</file>
|
||||
<file>ShaderLibrary.qml</file>
|
||||
<file>ApplicationConstants.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -31,13 +31,18 @@ function lint(a, b, t) {
|
||||
return (1 - t) * a + (t) * b;
|
||||
}
|
||||
|
||||
function mix(c1, c2, alpha){
|
||||
function mix(c1, c2, alpha) {
|
||||
return Qt.rgba(c1.r * alpha + c2.r * (1-alpha),
|
||||
c1.g * alpha + c2.g * (1-alpha),
|
||||
c1.b * alpha + c2.b * (1-alpha),
|
||||
c1.a * alpha + c2.a * (1-alpha))
|
||||
}
|
||||
|
||||
function smoothstep(min, max, value) {
|
||||
let x = Math.max(0, Math.min(1, (value - min) / (max - min)));
|
||||
return x * x * (3 - 2 * x);
|
||||
}
|
||||
|
||||
function strToColor(s){
|
||||
var r = parseInt(s.substring(1,3), 16) / 256;
|
||||
var g = parseInt(s.substring(3,5), 16) / 256;
|
||||
|
||||
Submodule qmltermwidget updated: 5c47d1f494...65e75bc6ea
Reference in New Issue
Block a user