mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-18 12:15:27 +00:00
Improve terminal frame and expose frame size setting.
This commit is contained in:
parent
3104abd4ad
commit
4abbe332db
@ -99,7 +99,12 @@ QtObject {
|
||||
property real rbgShift: 0.0
|
||||
|
||||
property real _margin: 0.5
|
||||
property real _frameMargin: 0.5
|
||||
|
||||
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
|
||||
|
||||
readonly property int no_rasterization: 0
|
||||
readonly property int scanline_rasterization: 1
|
||||
@ -238,8 +243,7 @@ QtObject {
|
||||
"burnInQuality": burnInQuality,
|
||||
"useCustomCommand": useCustomCommand,
|
||||
"customCommand": customCommand,
|
||||
"useFastBurnIn": useFastBurnIn,
|
||||
"blinkingCursor": blinkingCursor
|
||||
"useFastBurnIn": useFastBurnIn
|
||||
}
|
||||
return stringify(settings)
|
||||
}
|
||||
@ -266,7 +270,9 @@ QtObject {
|
||||
"windowOpacity": windowOpacity,
|
||||
"fontName": fontNames[rasterization],
|
||||
"fontWidth": fontWidth,
|
||||
"margin": _margin
|
||||
"margin": _margin,
|
||||
"blinkingCursor": blinkingCursor,
|
||||
"frameMargin": _frameMargin,
|
||||
}
|
||||
return settings
|
||||
}
|
||||
@ -335,9 +341,6 @@ QtObject {
|
||||
|
||||
useFastBurnIn = settings.useFastBurnIn
|
||||
!== undefined ? settings.useFastBurnIn : useFastBurnIn
|
||||
|
||||
blinkingCursor = settings.blinkingCursor
|
||||
!== undefined ? settings.blinkingCursor : blinkingCursor
|
||||
}
|
||||
|
||||
function loadProfileString(profileString) {
|
||||
@ -379,6 +382,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()
|
||||
}
|
||||
@ -459,7 +465,9 @@ QtObject {
|
||||
"screenCurvature": 0.3,
|
||||
"staticNoise": 0.1198,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -486,7 +494,9 @@ QtObject {
|
||||
"screenCurvature": 0.3,
|
||||
"staticNoise": 0.1198,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -513,7 +523,9 @@ QtObject {
|
||||
"screenCurvature": 0.3,
|
||||
"staticNoise": 0.15,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -540,7 +552,9 @@ QtObject {
|
||||
"screenCurvature": 0,
|
||||
"staticNoise": 0.15,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -567,7 +581,9 @@ QtObject {
|
||||
"screenCurvature": 0.5,
|
||||
"staticNoise": 0.099,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.2
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -594,7 +610,9 @@ QtObject {
|
||||
"screenCurvature": 0.5,
|
||||
"staticNoise": 0.2969,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.5
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -621,7 +639,9 @@ QtObject {
|
||||
"screenCurvature": 0.4,
|
||||
"staticNoise": 0.0503,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.2
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -648,7 +668,9 @@ QtObject {
|
||||
"screenCurvature": 0.2,
|
||||
"staticNoise": 0,
|
||||
"windowOpacity": 1,
|
||||
"margin": 0.5
|
||||
"margin": 0.5,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0.1
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
@ -675,7 +697,9 @@ QtObject {
|
||||
"screenCurvature": 0,
|
||||
"staticNoise": 0.0955,
|
||||
"windowOpacity": 0.7,
|
||||
"margin": 0.1
|
||||
"margin": 0.1,
|
||||
"blinkingCursor": false,
|
||||
"frameMargin": 0
|
||||
}'
|
||||
builtin: true
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
@ -178,7 +178,7 @@ Item{
|
||||
property alias contextmenu: menuLoader.item
|
||||
|
||||
MouseArea {
|
||||
property real margin: appSettings.margin
|
||||
property real margin: appSettings.totalMargin
|
||||
|
||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||
anchors.fill: parent
|
||||
@ -219,8 +219,8 @@ Item{
|
||||
var cc = Qt.size(0.5 - x, 0.5 - y);
|
||||
var distortion = (cc.height * cc.height + cc.width * cc.width) * appSettings.screenCurvature * appSettings.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{
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ 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 virtualResolution: parent.virtualResolution
|
||||
|
||||
@ -88,6 +88,8 @@ Item {
|
||||
// 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
|
||||
|
||||
@ -190,9 +192,10 @@ Item {
|
||||
(((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 ? "
|
||||
@ -328,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);"
|
||||
: "") +
|
||||
@ -351,7 +354,7 @@ Item {
|
||||
Loader {
|
||||
id: terminalFrameLoader
|
||||
|
||||
active: screenCurvature !== 0
|
||||
active: dynamicShader.displayTerminalFrame
|
||||
|
||||
width: staticShader.width
|
||||
height: staticShader.height
|
||||
@ -363,7 +366,7 @@ Item {
|
||||
visible: false
|
||||
format: ShaderEffectSource.RGBA
|
||||
|
||||
NewTerminalFrame {
|
||||
TerminalFrame {
|
||||
id: terminalFrame
|
||||
blending: false
|
||||
anchors.fill: parent
|
||||
@ -441,18 +444,9 @@ Item {
|
||||
(ambientLight !== 0 ? "
|
||||
uniform lowp float ambientLight;" : "") +
|
||||
|
||||
"
|
||||
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;" +
|
||||
|
@ -22,7 +22,7 @@ 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)
|
||||
@ -30,9 +30,15 @@ ShaderEffect {
|
||||
|
||||
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 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
|
||||
@ -44,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;
|
||||
|
||||
@ -65,25 +72,29 @@ ShaderEffect {
|
||||
|
||||
"
|
||||
|
||||
vec2 positiveLog(vec2 x) {
|
||||
return clamp(log(x), vec2(0.0), vec2(100.0));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@ -40,7 +40,7 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user