1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2026-02-08 00:32:27 +00:00

Fix many smaller issues.

This commit is contained in:
Filippo Scognamiglio
2026-01-08 22:37:36 +01:00
parent e9c818242e
commit d10fe84c3a
48 changed files with 50 additions and 37 deletions

View File

@@ -49,9 +49,10 @@ OTHER_FILES += $$SHADERS $$QSB_FILES
DYNAMIC_SHADER = $$SHADERS_DIR/terminal_dynamic.frag DYNAMIC_SHADER = $$SHADERS_DIR/terminal_dynamic.frag
STATIC_SHADER = $$SHADERS_DIR/terminal_static.frag STATIC_SHADER = $$SHADERS_DIR/terminal_static.frag
RASTER_MODES = 0 1 2 3 RASTER_MODES = 0 1 2 3 4
BINARY_FLAGS = 0 1 BINARY_FLAGS = 0 1
VARIANT_SHADER_DIR = $$relative_path($$PWD/shaders, $$OUT_PWD) VARIANT_SHADER_DIR = $$relative_path($$PWD/shaders, $$OUT_PWD)
VARIANT_OUTPUTS =
for(raster_mode, RASTER_MODES) { for(raster_mode, RASTER_MODES) {
for(burn_in, BINARY_FLAGS) { for(burn_in, BINARY_FLAGS) {
@@ -64,6 +65,7 @@ for(raster_mode, RASTER_MODES) {
$${dynamic_target}.depends = $$DYNAMIC_SHADER $${dynamic_target}.depends = $$DYNAMIC_SHADER
$${dynamic_target}.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -DCRT_RASTER_MODE=$${raster_mode} -DCRT_BURN_IN=$${burn_in} -DCRT_DISPLAY_FRAME=$${display_frame} -DCRT_CHROMA=$${chroma_on} -o $${dynamic_output} $$DYNAMIC_SHADER $${dynamic_target}.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -DCRT_RASTER_MODE=$${raster_mode} -DCRT_BURN_IN=$${burn_in} -DCRT_DISPLAY_FRAME=$${display_frame} -DCRT_CHROMA=$${chroma_on} -o $${dynamic_output} $$DYNAMIC_SHADER
QMAKE_EXTRA_TARGETS += $${dynamic_target} QMAKE_EXTRA_TARGETS += $${dynamic_target}
VARIANT_OUTPUTS += $${dynamic_output}
} }
} }
} }
@@ -80,10 +82,12 @@ for(rgb_shift, BINARY_FLAGS) {
$${static_target}.depends = $$STATIC_SHADER $${static_target}.depends = $$STATIC_SHADER
$${static_target}.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -DCRT_RGB_SHIFT=$${rgb_shift} -DCRT_BLOOM=$${bloom_on} -DCRT_CURVATURE=$${curve_on} -DCRT_FRAME_SHININESS=$${shine_on} -o $${static_output} $$STATIC_SHADER $${static_target}.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -DCRT_RGB_SHIFT=$${rgb_shift} -DCRT_BLOOM=$${bloom_on} -DCRT_CURVATURE=$${curve_on} -DCRT_FRAME_SHININESS=$${shine_on} -o $${static_output} $$STATIC_SHADER
QMAKE_EXTRA_TARGETS += $${static_target} QMAKE_EXTRA_TARGETS += $${static_target}
VARIANT_OUTPUTS += $${static_output}
} }
} }
} }
} }
PRE_TARGETDEPS += $${VARIANT_OUTPUTS}
######################################### #########################################
## INTALLS ## INTALLS

View File

@@ -126,8 +126,6 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("monospaceFontManager", &monospaceFontManager); engine.rootContext()->setContextProperty("monospaceFontManager", &monospaceFontManager);
engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts()); engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts());
engine.rootContext()->setContextProperty("devicePixelRatio", app.devicePixelRatio());
// Manage import paths for Linux and OSX. // Manage import paths for Linux and OSX.
QStringList importPathList = engine.importPathList(); QStringList importPathList = engine.importPathList();
importPathList.prepend(QCoreApplication::applicationDirPath() + "/qmltermwidget"); importPathList.prepend(QCoreApplication::applicationDirPath() + "/qmltermwidget");

View File

@@ -105,7 +105,7 @@ QtObject {
property real screenRadius: Utils.lint(4.0, 40.0, _screenRadius) property real screenRadius: Utils.lint(4.0, 40.0, _screenRadius)
property real _margin: 0.5 property real _margin: 0.5
property real margin: Utils.lint(1.0, 40.0, _margin) + 0.5 * screenRadius property real margin: Utils.lint(1.0, 40.0, _margin) + 0.25 * screenRadius
readonly property int no_rasterization: 0 readonly property int no_rasterization: 0
readonly property int scanline_rasterization: 1 readonly property int scanline_rasterization: 1
@@ -178,9 +178,10 @@ QtObject {
var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth
var fontFamily = fontManager.item.family var fontFamily = fontManager.item.family
var isSystemFont = fontManager.item.isSystemFont var isSystemFont = fontManager.item.isSystemFont
var lowResolutionFont = fontManager.item.lowResolutionFont;
var fallbackFontFamily = "" var fallbackFontFamily = ""
lowResolutionFont = fontManager.item.lowResolutionFont appSettings.lowResolutionFont = fontManager.item.lowResolutionFont
if (!isSystemFont) { if (!isSystemFont) {
fontLoader.source = fontSourcePath fontLoader.source = fontSourcePath
@@ -197,14 +198,14 @@ QtObject {
} }
} }
terminalFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth, fallbackFontFamily) terminalFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth, fallbackFontFamily, lowResolutionFont)
} }
onFontSourceChanged: updateFont() onFontSourceChanged: updateFont()
onRasterizationChanged: updateFont() onRasterizationChanged: updateFont()
onFontNameChanged: updateFont() onFontNameChanged: updateFont()
signal terminalFontChanged(string fontFamily, int pixelSize, int lineSpacing, real screenScaling, real fontWidth, string fallbackFontFamily) signal terminalFontChanged(string fontFamily, int pixelSize, int lineSpacing, real screenScaling, real fontWidth, string fallbackFontFamily, bool lowResolutionFont)
signal initializedSettings signal initializedSettings

View File

@@ -54,8 +54,6 @@ QtObject {
property bool isSystemFont: fontlist.get(selectedFontIndex).isSystemFont property bool isSystemFont: fontlist.get(selectedFontIndex).isSystemFont
property string family: fontlist.get(selectedFontIndex).family
// There are two kind of fonts: low resolution and high resolution. // There are two kind of fonts: low resolution and high resolution.
// Low resolution font sets the lowResolutionFont property to true. // Low resolution font sets the lowResolutionFont property to true.
// They are rendered at a fixed pixel size and the texture is upscaled // They are rendered at a fixed pixel size and the texture is upscaled

View File

@@ -98,7 +98,7 @@ Item{
QMLTermWidget { QMLTermWidget {
id: kterminal id: kterminal
property int textureResolutionScale: appSettings.lowResolutionFont ? devicePixelRatio : 1 property int textureResolutionScale: appSettings.lowResolutionFont ? Screen.devicePixelRatio : 1
property int margin: appSettings.margin / screenScaling property int margin: appSettings.margin / screenScaling
property int totalWidth: Math.floor(parent.width / (screenScaling * fontWidth)) property int totalWidth: Math.floor(parent.width / (screenScaling * fontWidth))
property int totalHeight: Math.floor(parent.height / screenScaling) property int totalHeight: Math.floor(parent.height / screenScaling)
@@ -108,8 +108,8 @@ Item{
textureSize: Qt.size(width / textureResolutionScale, height / textureResolutionScale) textureSize: Qt.size(width / textureResolutionScale, height / textureResolutionScale)
width: ensureMultiple(rawWidth, devicePixelRatio) width: ensureMultiple(rawWidth, Screen.devicePixelRatio)
height: ensureMultiple(rawHeight, devicePixelRatio) height: ensureMultiple(rawHeight, Screen.devicePixelRatio)
/** Ensure size is a multiple of factor. This is needed for pixel perfect scaling on highdpi screens. */ /** Ensure size is a multiple of factor. This is needed for pixel perfect scaling on highdpi screens. */
function ensureMultiple(size, factor) { function ensureMultiple(size, factor) {
@@ -118,8 +118,9 @@ Item{
colorScheme: "cool-retro-term" colorScheme: "cool-retro-term"
antialiasText: !appSettings.lowResolutionFont
smooth: !appSettings.lowResolutionFont smooth: !appSettings.lowResolutionFont
enableBold: false enableBold: !appSettings.lowResolutionFont
fullCursorHeight: true fullCursorHeight: true
blinkingCursor: appSettings.blinkingCursor blinkingCursor: appSettings.blinkingCursor
@@ -146,8 +147,7 @@ Item{
} }
} }
function handleFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth, fallbackFontFamily) { function handleFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth, fallbackFontFamily, lowResolutionFont) {
kterminal.antialiasText = !appSettings.lowResolutionFont;
var updatedFont = Qt.font({ var updatedFont = Qt.font({
family: fontFamily, family: fontFamily,
pixelSize: pixelSize pixelSize: pixelSize
@@ -213,7 +213,7 @@ Item{
MouseArea { MouseArea {
property real margin: appSettings.margin property real margin: appSettings.margin
property real frameSize: appSettings.frameSize property real frameSize: appSettings.frameSize * terminalWindow.normalizedWindowScale
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
anchors.fill: parent anchors.fill: parent
@@ -256,7 +256,9 @@ Item{
y = y * (1 + frameSize * 2) - frameSize; y = y * (1 + frameSize * 2) - frameSize;
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
* terminalWindow.normalizedWindowScale;
return Qt.point((x - cc.width * (1+distortion) * distortion) * (kterminal.totalWidth), return Qt.point((x - cc.width * (1+distortion) * distortion) * (kterminal.totalWidth),
(y - cc.height * (1+distortion) * distortion) * (kterminal.totalHeight)) (y - cc.height * (1+distortion) * distortion) * (kterminal.totalHeight))

View File

@@ -79,7 +79,7 @@ ColumnLayout {
model: appSettings.filteredFontList model: appSettings.filteredFontList
textRole: "text" textRole: "text"
onActivated: { onActivated: {
var font = appSettings.filteredFontList.get(index) var font = appSettings.filteredFontList.get(currentIndex)
// If selecting a high-res font while not in Modern mode, // If selecting a high-res font while not in Modern mode,
// switch to Modern to render at full resolution. // switch to Modern to render at full resolution.

View File

@@ -54,7 +54,8 @@ Item {
property color fontColor: appSettings.fontColor property color fontColor: appSettings.fontColor
property color backgroundColor: appSettings.backgroundColor property color backgroundColor: appSettings.backgroundColor
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize * terminalWindow.normalizedWindowScale
property real frameSize: appSettings.frameSize * terminalWindow.normalizedWindowScale
property real chromaColor: appSettings.chromaColor property real chromaColor: appSettings.chromaColor
@@ -108,7 +109,7 @@ Item {
property real time: timeManager ? timeManager.time : 0 property real time: timeManager ? timeManager.time : 0
property ShaderEffectSource noiseSource: noiseShaderSource property ShaderEffectSource noiseSource: noiseShaderSource
property real frameSize: appSettings.frameSize property real frameSize: parent.frameSize
property real frameShininess: appSettings.frameShininess property real frameShininess: appSettings.frameShininess
property real bloom: parent.bloomSource ? appSettings.bloom * 2.5 : 0 property real bloom: parent.bloomSource ? appSettings.bloom * 2.5 : 0
@@ -181,7 +182,7 @@ Item {
property real screen_brightness: Utils.lint(0.5, 1.5, appSettings.brightness) property real screen_brightness: Utils.lint(0.5, 1.5, appSettings.brightness)
property real frameShininess: appSettings.frameShininess property real frameShininess: appSettings.frameShininess
property real frameSize: appSettings.frameSize property real frameSize: parent.frameSize
blending: false blending: false
visible: false visible: false

View File

@@ -27,7 +27,6 @@ ShaderTerminal {
property alias terminalSize: terminal.terminalSize property alias terminalSize: terminal.terminalSize
signal sessionFinished() signal sessionFinished()
property real devicePixelRatio: terminalWindow.screen.devicePixelRatio
property bool loadBloomEffect: appSettings.bloom > 0 || appSettings._frameShininess > 0 property bool loadBloomEffect: appSettings.bloom > 0 || appSettings._frameShininess > 0
id: mainShader id: mainShader
@@ -37,8 +36,8 @@ ShaderTerminal {
burnInEffect: terminal.burnInEffect burnInEffect: terminal.burnInEffect
virtualResolution: terminal.virtualResolution virtualResolution: terminal.virtualResolution
screenResolution: Qt.size( screenResolution: Qt.size(
terminalWindow.width * devicePixelRatio * appSettings.windowScaling, terminalWindow.width * Screen.devicePixelRatio * appSettings.windowScaling,
terminalWindow.height * devicePixelRatio * appSettings.windowScaling terminalWindow.height * Screen.devicePixelRatio * appSettings.windowScaling
) )
bloomSource: bloomSourceLoader.item bloomSource: bloomSourceLoader.item

View File

@@ -33,15 +33,15 @@ ShaderEffect {
0.125 + 0.750 * ambientLight 0.125 + 0.750 * ambientLight
) )
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize * terminalWindow.normalizedWindowScale
property real frameShininess: appSettings.frameShininess property real frameShininess: appSettings.frameShininess
property real frameSize: appSettings.frameSize property real frameSize: appSettings.frameSize * terminalWindow.normalizedWindowScale
property real screenRadius: appSettings.screenRadius property real screenRadius: appSettings.screenRadius
property size viewportSize: Qt.size(width, height) property size viewportSize: Qt.size(width / appSettings.windowScaling, height / appSettings.windowScaling)
property real ambientLight: appSettings.ambientLight property real ambientLight: appSettings.ambientLight

View File

@@ -106,7 +106,6 @@ Item {
model: tabsModel model: tabsModel
TerminalContainer { TerminalContainer {
property bool isCurrentItem: StackLayout.isCurrentItem property bool isCurrentItem: StackLayout.isCurrentItem
onIsCurrentItemChanged: { onIsCurrentItemChanged: {
if (isCurrentItem) { if (isCurrentItem) {
activate() activate()

View File

@@ -68,6 +68,7 @@ ApplicationWindow {
} }
property string wintitle: appSettings.wintitle property string wintitle: appSettings.wintitle
property real normalizedWindowScale: 1024 / ((0.5 * width + 0.5 * height))
color: "#00000000" color: "#00000000"

View File

@@ -81,6 +81,14 @@
<file>../shaders/terminal_dynamic_raster3_burn1_frame0_chroma1.frag.qsb</file> <file>../shaders/terminal_dynamic_raster3_burn1_frame0_chroma1.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster3_burn1_frame1_chroma0.frag.qsb</file> <file>../shaders/terminal_dynamic_raster3_burn1_frame1_chroma0.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster3_burn1_frame1_chroma1.frag.qsb</file> <file>../shaders/terminal_dynamic_raster3_burn1_frame1_chroma1.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn0_frame0_chroma0.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn0_frame0_chroma1.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn0_frame1_chroma0.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn0_frame1_chroma1.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn1_frame0_chroma0.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn1_frame0_chroma1.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn1_frame1_chroma0.frag.qsb</file>
<file>../shaders/terminal_dynamic_raster4_burn1_frame1_chroma1.frag.qsb</file>
<file>../shaders/terminal_static_rgb0_bloom0_curve0_shine0.frag.qsb</file> <file>../shaders/terminal_static_rgb0_bloom0_curve0_shine0.frag.qsb</file>
<file>../shaders/terminal_static_rgb0_bloom0_curve0_shine1.frag.qsb</file> <file>../shaders/terminal_static_rgb0_bloom0_curve0_shine1.frag.qsb</file>
<file>../shaders/terminal_static_rgb0_bloom0_curve1_shine0.frag.qsb</file> <file>../shaders/terminal_static_rgb0_bloom0_curve1_shine0.frag.qsb</file>

View File

@@ -25,14 +25,12 @@ void main() {
vec4 accColor = texture(burnInSource, coords); vec4 accColor = texture(burnInSource, coords);
float prevMask = accColor.a; float prevMask = accColor.a;
float currMask = rgb2grey(txtColor);
float blurDecay = clamp((burnInLastUpdate - prevLastUpdate) * burnInTime, 0.0, 1.0); float blurDecay = clamp((burnInLastUpdate - prevLastUpdate) * burnInTime, 0.0, 1.0);
blurDecay = max(0.0, blurDecay - prevMask); blurDecay = max(0.0, blurDecay - prevMask);
float blurValue = rgb2grey(accColor.rgb) - blurDecay; vec3 color = max(accColor.rgb - vec3(blurDecay), txtColor);
float txtValue = rgb2grey(txtColor);
float colorValue = max(blurValue, txtValue); float currMask = step(rgb2grey(color), rgb2grey(txtColor));
vec3 color = vec3(colorValue);
fragColor = vec4(color, currMask) * qt_Opacity; fragColor = vec4(color, currMask) * qt_Opacity;
} }

Binary file not shown.

View File

@@ -65,7 +65,7 @@ vec2 distortCoordinates(vec2 coords){
} }
vec3 applyRasterization(vec2 screenCoords, vec3 texel, vec2 virtualRes, float intensity) { vec3 applyRasterization(vec2 screenCoords, vec3 texel, vec2 virtualRes, float intensity) {
#if CRT_RASTER_MODE == 0 #if CRT_RASTER_MODE == 0 || CRT_RASTER_MODE == 4
return texel; return texel;
#else #else
if (intensity <= 0.0) { if (intensity <= 0.0) {
@@ -162,7 +162,7 @@ void main() {
#if CRT_BURN_IN == 1 #if CRT_BURN_IN == 1
vec4 txt_blur = texture(burnInSource, staticCoords); vec4 txt_blur = texture(burnInSource, staticCoords);
float blurDecay = clamp((time - burnInLastUpdate) * burnInTime, 0.0, 1.0); float blurDecay = clamp((time - burnInLastUpdate) * burnInTime, 0.0, 1.0);
vec3 burnInColor = 0.65 * (txt_blur.rgb - vec3(blurDecay)); vec3 burnInColor = 0.65 * (txt_blur.rgb - vec3(blurDecay)) * (1.0 - txt_blur.a);
txt_color = max(txt_color, burnInColor); txt_color = max(txt_color, burnInColor);
#endif #endif

View File

@@ -12,6 +12,7 @@ layout(std140, binding = 0) uniform ubuf {
float screenRadius; float screenRadius;
vec2 viewportSize; vec2 viewportSize;
float ambientLight; float ambientLight;
float frameShininess;
}; };
float min2(vec2 v) { return min(v.x, v.y); } float min2(vec2 v) { return min(v.x, v.y); }
@@ -65,8 +66,10 @@ void main() {
float frameShadow = (e * 0.66 + w * 0.66 + n * 0.33 + s) * depth; float frameShadow = (e * 0.66 + w * 0.66 + n * 0.33 + s) * depth;
frameShadow *= smoothstep(0.0, edgeSoftPixels * 10.0, distPixels); frameShadow *= smoothstep(0.0, edgeSoftPixels * 10.0, distPixels);
float frameAlpha = 1.0 - frameShininess * 0.4;
float inScreen = smoothstep(0.0, edgeSoftPixels, -distPixels); float inScreen = smoothstep(0.0, edgeSoftPixels, -distPixels);
float alpha = mix(mix(0.7, 0.9, ambientLight), mix(0.0, 0.2, ambientLight), inScreen); float alpha = mix(frameAlpha, mix(0.0, 0.2, ambientLight), inScreen);
float glass = clamp(ambientLight * pow(prod2(coords * (1.0 - coords.yx)) * 50.0, 0.25) * inScreen, 0.0, 1.0); float glass = clamp(ambientLight * pow(prod2(coords * (1.0 - coords.yx)) * 50.0, 0.25) * inScreen, 0.0, 1.0);
vec3 color = mix(frameColor.rgb * frameShadow, vec3(glass), inScreen); vec3 color = mix(frameColor.rgb * frameShadow, vec3(glass), inScreen);

Binary file not shown.

View File

@@ -12,6 +12,7 @@ layout(std140, binding = 0) uniform ubuf {
float screenRadius; float screenRadius;
vec2 viewportSize; vec2 viewportSize;
float ambientLight; float ambientLight;
float frameShininess;
}; };
layout(location = 0) out vec2 qt_TexCoord0; layout(location = 0) out vec2 qt_TexCoord0;

Binary file not shown.

View File

@@ -84,7 +84,7 @@ void main() {
#endif #endif
#if CRT_FRAME_SHININESS == 1 #if CRT_FRAME_SHININESS == 1
vec3 reflectionColor = mix(bloomColor, finalColor, frameShininess * 0.5); vec3 reflectionColor = mix(bloomColor * bloomAlpha * 2.0, finalColor, frameShininess * 0.5);
finalColor = mix(finalColor, reflectionColor, isReflection); finalColor = mix(finalColor, reflectionColor, isReflection);
#endif #endif