From 25ed5db3248c82394606060c972b00bd48d1e3ff Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Sat, 7 Jun 2014 11:33:37 +0200 Subject: [PATCH 01/13] Fix input redirection --- app/Terminal.qml | 13 ++++++++++++- app/app.qmlproject.user | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Terminal.qml b/app/Terminal.qml index fb6a7ad..6f3e25c 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -30,6 +30,8 @@ Item{ property variant bloomSource: bloomSourceLoader.item property variant scanlineSource: scanlineSourceLoader.item + property alias kterminal: kterminal + //The blur effect has to take into account the framerate property real fpsAttenuation: 60 / shadersettings.fps property real mBlur: shadersettings.motion_blur @@ -161,10 +163,19 @@ Item{ } } - function correctDistortion(x, y){ + //Frame displacement properties + property real dtop: frame.item.displacementTop + property real dleft:frame.item.displacementLeft + property real dright: frame.item.displacementRight + property real dbottom: frame.item.displacementBottom + + function correctDistortion(x, y){ x = x / width; y = y / height; + x = (-dleft + x * (width + dleft + dright)) / width + y = (-dtop + y * (height + dtop + dbottom)) / height + var cc = Qt.size(0.5 - x, 0.5 - y); var distortion = (cc.height * cc.height + cc.width * cc.width) * shadersettings.screen_distortion; diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 8ca1b8a..1b7131c 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 8fd7161ec89ea06b6e30ca755c9c2c05e62213b5 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Sat, 7 Jun 2014 12:03:34 +0200 Subject: [PATCH 02/13] Made normal and rasterized images look more consisntent. --- app/ShaderManager.qml | 12 +++------ app/Terminal.qml | 60 +++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index 2c3a413..6b8cb82 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -26,7 +26,7 @@ ShaderEffect { property color background_color: shadersettings.background_color property variant source: terminal.theSource property variant bloomSource: terminal.bloomSource - property variant scanlineSource: terminal.scanlineSource + property variant rasterizationSource: terminal.rasterizationSource property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height) property real bloom: shadersettings.bloom_strength @@ -96,10 +96,8 @@ ShaderEffect { varying highp vec2 qt_TexCoord0; uniform highp vec4 font_color; - uniform highp vec4 background_color;" + - - (rasterization != shadersettings.no_rasterization ? " - uniform highp sampler2D scanlineSource;" : "") + + uniform highp vec4 background_color; + uniform highp sampler2D rasterizationSource;" + (bloom !== 0 ? " uniform highp sampler2D bloomSource;" : "") + @@ -174,9 +172,7 @@ ShaderEffect { "vec3 finalColor = mix(background_color, font_color, color).rgb;" + "finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" + - - (rasterization != shadersettings.no_rasterization ? " - finalColor *= texture2D(scanlineSource, coords).r;" : "") + + "finalColor *= texture2D(rasterizationSource, coords).r;" + (brightness_flickering !== 0 ? " finalColor *= brightness;" : "") + diff --git a/app/Terminal.qml b/app/Terminal.qml index 6f3e25c..5946f07 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -28,10 +28,14 @@ Item{ id: terminalContainer property variant theSource: finalSource property variant bloomSource: bloomSourceLoader.item - property variant scanlineSource: scanlineSourceLoader.item + property variant rasterizationSource: rasterizationEffectSource property alias kterminal: kterminal + signal sizeChanged + onWidthChanged: sizeChanged() + onHeightChanged: sizeChanged() + //The blur effect has to take into account the framerate property real fpsAttenuation: 60 / shadersettings.fps property real mBlur: shadersettings.motion_blur @@ -106,9 +110,9 @@ Item{ var scanline_spacing = shadersettings.font.lineSpacing; var line_spacing = Math.round(scanline_spacing * scanline_height); -// console.log("Font height: " + fontMetrics.paintedHeight) -// console.log("Scanline Height: " + scanline_height) -// console.log("Line Spacing: " + line_spacing) + // console.log("Font height: " + fontMetrics.paintedHeight) + // console.log("Scanline Height: " + scanline_height) + // console.log("Line Spacing: " + line_spacing) terminalContainer.scanlineHeight = scanline_height; terminalContainer.scanlineWidth = scanline_width; @@ -169,7 +173,7 @@ Item{ property real dright: frame.item.displacementRight property real dbottom: frame.item.displacementBottom - function correctDistortion(x, y){ + function correctDistortion(x, y){ x = x / width; y = y / height; @@ -282,40 +286,36 @@ Item{ smooth: false } } - //Scanlines - Loader{ - id: scanlineEffectLoader - active: mScanlines != shadersettings.no_rasterization + //Rasterization mask + ShaderEffect { + id: rasterizationEffect anchors.fill: parent - sourceComponent: ShaderEffect { - property size virtual_resolution: terminalContainer.virtual_resolution + property size virtual_resolution: terminalContainer.virtual_resolution - fragmentShader: - "uniform lowp float qt_Opacity;" + + fragmentShader: + "uniform lowp float qt_Opacity;" + - "varying highp vec2 qt_TexCoord0; + "varying highp vec2 qt_TexCoord0; uniform highp vec2 virtual_resolution; float getScanlineIntensity(vec2 coords) { - float result = abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" + - (mScanlines == shadersettings.pixel_rasterization ? - "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " + float result = 1.0;" + + (mScanlines != shadersettings.no_rasterization ? + "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") + + (mScanlines == shadersettings.pixel_rasterization ? + "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " return result; }" + - "void main() {" + - "gl_FragColor = vec4(getScanlineIntensity(qt_TexCoord0));" + - "}" - } + "void main() {" + + "gl_FragColor = vec4(getScanlineIntensity(qt_TexCoord0));" + + "}" } - Loader{ - id: scanlineSourceLoader - active: mScanlines != shadersettings.no_rasterization - sourceComponent: ShaderEffectSource{ - sourceItem: scanlineEffectLoader.item - sourceRect: frame.sourceRect - hideSource: true - smooth: true - } + ShaderEffectSource{ + id: rasterizationEffectSource + sourceItem: rasterizationEffect + sourceRect: frame.sourceRect + hideSource: true + smooth: true } } From 6c461acf28284defe99fcad02adaf1d4b5cccd3b Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Sat, 7 Jun 2014 15:32:21 +0200 Subject: [PATCH 03/13] Saving some GPU memory by using one channel textures where possible. --- app/ShaderManager.qml | 4 ++-- app/Terminal.qml | 9 +++++---- app/app.qmlproject.user | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index 6b8cb82..ce3dedd 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -159,7 +159,7 @@ ShaderEffect { noise += horizontal_distortion;" : "") : "") + - "float color = texture2D(source, coords).r;" + + "float color = texture2D(source, coords).a;" + (noise_strength !== 0 ? " color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") + @@ -172,7 +172,7 @@ ShaderEffect { "vec3 finalColor = mix(background_color, font_color, color).rgb;" + "finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" + - "finalColor *= texture2D(rasterizationSource, coords).r;" + + "finalColor *= texture2D(rasterizationSource, coords).a;" + (brightness_flickering !== 0 ? " finalColor *= brightness;" : "") + diff --git a/app/Terminal.qml b/app/Terminal.qml index 5946f07..38686a1 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -73,7 +73,6 @@ Item{ kterminal.copyClipboard(); } - KTerminal { id: kterminal anchors.fill: parent @@ -218,6 +217,7 @@ Item{ id: finalSource sourceItem: blurredterminal sourceRect: frame.sourceRect + format: ShaderEffectSource.Alpha } ShaderEffect { id: blurredterminal @@ -252,13 +252,13 @@ Item{ "float color = texture2D(source, coords + delta).r * 256.0;" + (mBlur !== 0 ? - "float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 256.0;" + + "float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).a * 256.0;" + "blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" + "color = step(1.0, color) * color + step(color, 1.0) * blurredSourceColor;" : "") + - "gl_FragColor = vec4(vec3(floor(color) / 256.0), 1.0);" + + "gl_FragColor.a = vec4(floor(color) / 256.0);" + "}" } ////////////////////////////////////////////////////////////////////// @@ -308,7 +308,7 @@ Item{ }" + "void main() {" + - "gl_FragColor = vec4(getScanlineIntensity(qt_TexCoord0));" + + "gl_FragColor.a = getScanlineIntensity(qt_TexCoord0);" + "}" } ShaderEffectSource{ @@ -317,5 +317,6 @@ Item{ sourceRect: frame.sourceRect hideSource: true smooth: true + format: ShaderEffectSource.Alpha } } diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 1b7131c..82a8fa2 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 2423957cc862e6ad6e08146cd062e72e78962767 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Wed, 11 Jun 2014 00:54:47 +0200 Subject: [PATCH 04/13] Improved noise --- app/ShaderManager.qml | 27 +++++++---------------- app/Terminal.qml | 48 ++++++++++++++++++++++++++++++++++++++++- app/app.qmlproject.user | 2 +- 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index ce3dedd..0643a48 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -27,10 +27,12 @@ ShaderEffect { property variant source: terminal.theSource property variant bloomSource: terminal.bloomSource property variant rasterizationSource: terminal.rasterizationSource + property variant noiseSource: terminal.staticNoiseSource property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height) property real bloom: shadersettings.bloom_strength property int rasterization: shadersettings.rasterization + property real rasterization_strength: 0.5 property real noise_strength: shadersettings.noise_strength property real screen_distorsion: shadersettings.screen_distortion @@ -51,6 +53,8 @@ ShaderEffect { property real time: timetimer.time property variant randomFunctionSource: randfuncsource + blending: false + function str(num){ return num.toFixed(8); } @@ -102,7 +106,8 @@ ShaderEffect { (bloom !== 0 ? " uniform highp sampler2D bloomSource;" : "") + (noise_strength !== 0 ? " - uniform highp float noise_strength;" : "") + + uniform highp float noise_strength; + uniform lowp sampler2D noiseSource;" : "") + (screen_distorsion !== 0 ? " uniform highp float screen_distorsion;" : "")+ (glowing_line_strength !== 0 ? " @@ -112,22 +117,6 @@ ShaderEffect { (horizontal_sincronization !== 0 ? " varying lowp float horizontal_distortion;" : "") + - " - highp float rand(vec2 co) - { - highp float a = 12.9898; - highp float b = 78.233; - highp float c = 43758.5453; - highp float dt= dot(co.xy ,vec2(a,b)); - highp float sn= mod(dt,3.14); - return fract(sin(sn) * c); - } - - float stepNoise(vec2 p){ - vec2 newP = p * txt_Size * 0.5; - return rand(floor(newP) + fract(time / 100.0)); - }" + - (glowing_line_strength !== 0 ? " float randomPass(vec2 coords){ return fract(smoothstep(-0.2, 0.0, coords.y - 3.0 * fract(time * 0.0001))) * glowing_line_strength; @@ -162,7 +151,7 @@ ShaderEffect { "float color = texture2D(source, coords).a;" + (noise_strength !== 0 ? " - color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") + + color += texture2D(noiseSource, qt_TexCoord0 * 0.25 + fract(time / 100.0)).a * noise * (1.0 - distance * distance * 2.0);" : "") + (glowing_line_strength !== 0 ? " color += randomPass(coords) * glowing_line_strength;" : "") + @@ -172,7 +161,7 @@ ShaderEffect { "vec3 finalColor = mix(background_color, font_color, color).rgb;" + "finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" + - "finalColor *= texture2D(rasterizationSource, coords).a;" + + "finalColor *= (texture2D(rasterizationSource, coords).a) / "+rasterization_strength+";" + (brightness_flickering !== 0 ? " finalColor *= brightness;" : "") + diff --git a/app/Terminal.qml b/app/Terminal.qml index 38686a1..68b4fc9 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -29,6 +29,7 @@ Item{ property variant theSource: finalSource property variant bloomSource: bloomSourceLoader.item property variant rasterizationSource: rasterizationEffectSource + property variant staticNoiseSource: staticNoiseSource property alias kterminal: kterminal @@ -227,7 +228,7 @@ Item{ property size virtual_resolution: parent.virtual_resolution property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0), mScanlines != shadersettings.no_rasterization ? deltay : 0) - z: 2 + blending: false fragmentShader: "uniform lowp float qt_Opacity;" + @@ -286,12 +287,57 @@ Item{ smooth: false } } + + //Rasterization mask + ShaderEffect { + id: staticNoiseEffect + anchors.fill: parent + property size virtual_resolution: terminalContainer.virtual_resolution + + blending: false + + fragmentShader: + "uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + uniform highp vec2 virtual_resolution;" + + + "highp float rand(vec2 co) + { + highp float a = 12.9898; + highp float b = 78.233; + highp float c = 43758.5453; + highp float dt= dot(co.xy ,vec2(a,b)); + highp float sn= mod(dt,3.14); + return fract(sin(sn) * c); + } + + float stepNoise(vec2 p){ + vec2 newP = p * virtual_resolution; + return rand(newP); + }" + + + "void main() {" + + "gl_FragColor.a = stepNoise(qt_TexCoord0);" + + "}" + } + ShaderEffectSource{ + id: staticNoiseSource + sourceItem: staticNoiseEffect + textureSize: Qt.size(parent.width, parent.height) + wrapMode: ShaderEffectSource.Repeat + smooth: true + hideSource: true + format: ShaderEffectSource.Alpha + } + //Rasterization mask ShaderEffect { id: rasterizationEffect anchors.fill: parent property size virtual_resolution: terminalContainer.virtual_resolution + blending: false + fragmentShader: "uniform lowp float qt_Opacity;" + diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 82a8fa2..8966cde 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 21c7f2c23e73f609724bc162e0e204be1d660350 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Fri, 20 Jun 2014 01:54:14 +0200 Subject: [PATCH 05/13] Smooth static noise and fixes --- app/ShaderManager.qml | 6 +++--- app/Terminal.qml | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index 0643a48..9cf0198 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -32,7 +32,6 @@ ShaderEffect { property real bloom: shadersettings.bloom_strength property int rasterization: shadersettings.rasterization - property real rasterization_strength: 0.5 property real noise_strength: shadersettings.noise_strength property real screen_distorsion: shadersettings.screen_distortion @@ -151,7 +150,8 @@ ShaderEffect { "float color = texture2D(source, coords).a;" + (noise_strength !== 0 ? " - color += texture2D(noiseSource, qt_TexCoord0 * 0.25 + fract(time / 100.0)).a * noise * (1.0 - distance * distance * 2.0);" : "") + + float noiseVal = texture2D(noiseSource, qt_TexCoord0 + vec2(fract(time / 51.0), fract(time / 237.0))).a; + color += noiseVal * noise * (1.0 - distance * 1.3);" : "") + (glowing_line_strength !== 0 ? " color += randomPass(coords) * glowing_line_strength;" : "") + @@ -161,7 +161,7 @@ ShaderEffect { "vec3 finalColor = mix(background_color, font_color, color).rgb;" + "finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" + - "finalColor *= (texture2D(rasterizationSource, coords).a) / "+rasterization_strength+";" + + "finalColor *= texture2D(rasterizationSource, coords).a;" + (brightness_flickering !== 0 ? " finalColor *= brightness;" : "") + diff --git a/app/Terminal.qml b/app/Terminal.qml index 68b4fc9..9c6b9c7 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -250,16 +250,16 @@ Item{ (mScanlines == shadersettings.pixel_rasterization ? " coords.x = floor(virtual_resolution.x * coords.x) / virtual_resolution.x;" : "") : "") + - - "float color = texture2D(source, coords + delta).r * 256.0;" + + "coords = coords + delta;" + + "float color = texture2D(source, coords).r * 256.0;" + (mBlur !== 0 ? - "float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).a * 256.0;" + + "float blurredSourceColor = texture2D(blurredSource, coords).a * 256.0;" + "blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" + "color = step(1.0, color) * color + step(color, 1.0) * blurredSourceColor;" : "") + - "gl_FragColor.a = vec4(floor(color) / 256.0);" + + "gl_FragColor.a = floor(color) / 256.0;" + "}" } ////////////////////////////////////////////////////////////////////// @@ -301,7 +301,7 @@ Item{ varying highp vec2 qt_TexCoord0; uniform highp vec2 virtual_resolution;" + - "highp float rand(vec2 co) + "highp float noise(vec2 co) { highp float a = 12.9898; highp float b = 78.233; @@ -311,13 +311,20 @@ Item{ return fract(sin(sn) * c); } - float stepNoise(vec2 p){ - vec2 newP = p * virtual_resolution; - return rand(newP); + vec2 sw(vec2 p) {return vec2( floor(p.x) , floor(p.y) );} + vec2 se(vec2 p) {return vec2( ceil(p.x) , floor(p.y) );} + vec2 nw(vec2 p) {return vec2( floor(p.x) , ceil(p.y) );} + vec2 ne(vec2 p) {return vec2( ceil(p.x) , ceil(p.y) );} + + float smoothNoise(vec2 p) { + vec2 inter = smoothstep(0., 1., fract(p)); + float s = mix(noise(sw(p)), noise(se(p)), inter.x); + float n = mix(noise(nw(p)), noise(ne(p)), inter.x); + return mix(s, n, inter.y); }" + "void main() {" + - "gl_FragColor.a = stepNoise(qt_TexCoord0);" + + "gl_FragColor.a = smoothNoise(qt_TexCoord0 * virtual_resolution);" + "}" } ShaderEffectSource{ From 431ec6d1335589f5abf5c29055d4ab679a9f6da7 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Fri, 20 Jun 2014 12:30:42 +0200 Subject: [PATCH 06/13] Added jitter effect. --- app/SettingsWindow.qml | 5 +++++ app/ShaderManager.qml | 13 +++++++++++-- app/ShaderSettings.qml | 7 ++++++- app/app.qmlproject.user | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/SettingsWindow.qml b/app/SettingsWindow.qml index 08fdf6f..4d816f7 100644 --- a/app/SettingsWindow.qml +++ b/app/SettingsWindow.qml @@ -270,6 +270,11 @@ Window { onValueChanged: shadersettings.noise_strength = value _value: shadersettings.noise_strength } + SettingComponent{ + name: "Jitter" + onValueChanged: shadersettings.jitter = value + _value: shadersettings.jitter + } SettingComponent{ name: "Glow" onValueChanged: shadersettings.glowing_line_strength = value; diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index 9cf0198..a61c4eb 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -33,6 +33,8 @@ ShaderEffect { property int rasterization: shadersettings.rasterization + property real jitter: shadersettings.jitter * 0.007 + property real noise_strength: shadersettings.noise_strength property real screen_distorsion: shadersettings.screen_distortion property real glowing_line_strength: shadersettings.glowing_line_strength @@ -105,7 +107,8 @@ ShaderEffect { (bloom !== 0 ? " uniform highp sampler2D bloomSource;" : "") + (noise_strength !== 0 ? " - uniform highp float noise_strength; + uniform highp float noise_strength;" : "") + + (noise_strength !== 0 || jitter !== 0 ? " uniform lowp sampler2D noiseSource;" : "") + (screen_distorsion !== 0 ? " uniform highp float screen_distorsion;" : "")+ @@ -147,7 +150,13 @@ ShaderEffect { noise += horizontal_distortion;" : "") : "") + - "float color = texture2D(source, coords).a;" + + (jitter !== 0 ? " + vec2 offset = vec2(texture2D(noiseSource, coords + fract(time / 57.0)).a, + texture2D(noiseSource, coords + fract(time / 251.0)).a) - 0.5; + vec2 txt_coords = coords + offset * "+str(jitter)+";" + : "vec2 txt_coords = coords;") + + + "float color = texture2D(source, txt_coords).a;" + (noise_strength !== 0 ? " float noiseVal = texture2D(noiseSource, qt_TexCoord0 + vec2(fract(time / 51.0), fract(time / 237.0))).a; diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 3908e53..71820dd 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -60,6 +60,8 @@ Item{ property real motion_blur: 0.65 property real bloom_strength: 0.6 + property real jitter: 0.15 + property real horizontal_sincronization: 0.1 property real brightness_flickering: 0.12 @@ -240,7 +242,8 @@ Item{ font_index: font_index, motion_blur: motion_blur, bloom_strength: bloom_strength, - rasterization: rasterization + rasterization: rasterization, + jitter: jitter } return JSON.stringify(settings); } @@ -304,6 +307,8 @@ Item{ font_index = settings.font_index !== undefined ? settings.font_index : font_index; rasterization = settings.rasterization !== undefined ? settings.rasterization : rasterization; + + jitter = settings.jitter !== undefined ? settings.jitter : jitter } function storeCustomProfiles(){ diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 8966cde..b6e39ae 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 69843f3ef8148431809249fe4b994f02c3b404f1 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Fri, 20 Jun 2014 17:00:49 +0200 Subject: [PATCH 07/13] Added font: commodore PET double height. --- app/ShaderSettings.qml | 13 +++++++++++++ app/app.qmlproject.user | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 71820dd..679d173 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -147,6 +147,19 @@ Item{ ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8}, ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}] } + ListElement{ + text: "Commodore PET 2Y (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" + lineSpacing: 2 + metrics: [ + ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0}, + ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6}, + ListElement{pixelSize: 32; virtualWidth: 4; virtualHeight: 8}, + ListElement{pixelSize: 40; virtualWidth: 4; virtualHeight: 8}, + ListElement{pixelSize: 48; virtualWidth: 4; virtualHeight: 8}, + ListElement{pixelSize: 56; virtualWidth: 4; virtualHeight: 8}, + ListElement{pixelSize: 64; virtualWidth: 4; virtualHeight: 8}] + } ListElement{ text: "Apple ][ (1977)" source: "fonts/1977-apple2/PrintChar21.ttf" diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index b6e39ae..50ee390 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 1693e51d89f9ff71fa6aa7c39831fd5e747682cc Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Mon, 23 Jun 2014 16:25:41 +0200 Subject: [PATCH 08/13] Reorganized rasterization. Now everything is independent. --- app/FontPixels.qml | 51 ++++++ app/FontScanlines.qml | 59 +++++++ app/Fonts.qml | 67 ++++++++ app/SettingsWindow.qml | 12 +- app/ShaderSettings.qml | 190 ++++++--------------- app/Terminal.qml | 32 ++-- app/app.qmlproject.user | 2 +- konsole-qml-plugin/src/TerminalDisplay.cpp | 3 + 8 files changed, 253 insertions(+), 163 deletions(-) create mode 100644 app/FontPixels.qml create mode 100644 app/FontScanlines.qml create mode 100644 app/Fonts.qml diff --git a/app/FontPixels.qml b/app/FontPixels.qml new file mode 100644 index 0000000..33475bd --- /dev/null +++ b/app/FontPixels.qml @@ -0,0 +1,51 @@ +import QtQuick 2.0 + +Item{ + property int selectedFontIndex + property int selectedScalingIndex + property alias fontlist: fontlist + property var _font: fontlist.get(selectedFontIndex) + property var _scaling: fontScalingList[selectedScalingIndex] + property var source: _font.source + property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0] + property int pixelSize: _font.pixelSize * _scaling + property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing + property size virtualCharSize: Qt.size(_font.virtualCharWidth, + _font.virtualCharHeight) + + ListModel{ + id: fontlist + ListElement{ + text: "Commodore PET (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" + lineSpacing: 2 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Apple ][ (1977)" + source: "fonts/1977-apple2/PrintChar21.ttf" + lineSpacing: 2 + virtualCharWidth: 7 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Atari 400-800 (1979)" + source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" + lineSpacing: 3 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Commodore 64 (1982)" + source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" + lineSpacing: 3 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + } +} diff --git a/app/FontScanlines.qml b/app/FontScanlines.qml new file mode 100644 index 0000000..6446031 --- /dev/null +++ b/app/FontScanlines.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 + +Item{ + property int selectedFontIndex + property int selectedScalingIndex + property alias fontlist: fontlist + property var _font: fontlist.get(selectedFontIndex) + property var _scaling: fontScalingList[selectedScalingIndex] + property var source: _font.source + property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0] + property int pixelSize: _font.pixelSize * _scaling + property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing + property size virtualCharSize: Qt.size(_font.virtualCharWidth, + _font.virtualCharHeight) + + ListModel{ + id: fontlist + ListElement{ + text: "Commodore PET (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" + lineSpacing: 2 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Commodore PET 2Y (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" + lineSpacing: 2 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Apple ][ (1977)" + source: "fonts/1977-apple2/PrintChar21.ttf" + lineSpacing: 2 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Atari 400-800 (1979)" + source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" + lineSpacing: 3 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + ListElement{ + text: "Commodore 64 (1982)" + source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" + lineSpacing: 3 + virtualCharWidth: 8 + virtualCharHeight: 8 + pixelSize: 32 + } + } +} diff --git a/app/Fonts.qml b/app/Fonts.qml new file mode 100644 index 0000000..64dbdb7 --- /dev/null +++ b/app/Fonts.qml @@ -0,0 +1,67 @@ +import QtQuick 2.0 + +Item{ + property int selectedFontIndex + property int selectedScalingIndex + property alias fontlist: fontlist + property var source: fontlist.get(selectedFontIndex).source + property var _font: fontlist.get(selectedFontIndex) + property var _scaling: fontScalingList[selectedScalingIndex] + property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0] + property int pixelSize: _font.pixelSize * _scaling + property int lineSpacing: pixelSize * _font.lineSpacing + + //In this configuration lineSpacing is proportional to pixelSize. + + ListModel{ + id: fontlist + ListElement{ + text: "Terminus (Modern)" + source: "fonts/modern-terminus/TerminusTTF-Bold-4.38.2.ttf" + lineSpacing: 0.2 + pixelSize: 35 + } + ListElement{ + text: "Commodore PET (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" + lineSpacing: 0.2 + pixelSize: 24 + } + ListElement{ + text: "Commodore PET 2Y (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" + lineSpacing: 0.2 + pixelSize: 32 + } + ListElement{ + text: "Apple ][ (1977)" + source: "fonts/1977-apple2/PrintChar21.ttf" + lineSpacing: 0.2 + pixelSize: 24 + } + ListElement{ + text: "Atari 400-800 (1979)" + source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" + lineSpacing: 0.3 + pixelSize: 24 + } + ListElement{ + text: "Commodore 64 (1982)" + source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" + lineSpacing: 0.3 + pixelSize: 24 + } + ListElement{ + text: "Atari ST (1985)" + source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf" + lineSpacing: 0.2 + pixelSize: 32 + } + ListElement{ + text: "IBM DOS (1985)" + source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf" + lineSpacing: 0.2 + pixelSize: 32 + } + } +} diff --git a/app/SettingsWindow.qml b/app/SettingsWindow.qml index 4d816f7..b2b1d84 100644 --- a/app/SettingsWindow.qml +++ b/app/SettingsWindow.qml @@ -89,16 +89,16 @@ Window { Text{text: qsTr("Font style:")} ComboBox{ Layout.fillWidth: true - model: shadersettings.fonts_list - currentIndex: shadersettings.font_index - onCurrentIndexChanged: shadersettings.font_index = currentIndex + model: shadersettings.fontlist + currentIndex: shadersettings.fontIndex + onCurrentIndexChanged: shadersettings.fontIndex = currentIndex } Text{text: qsTr("Font scaling:")} ComboBox{ Layout.fillWidth: true - model: shadersettings._font_scalings - currentIndex: shadersettings.font_scaling_index - onCurrentIndexChanged: shadersettings.font_scaling_index = currentIndex + model: shadersettings.fontScalingList + currentIndex: shadersettings.fontScalingIndex + onCurrentIndexChanged: shadersettings.fontScalingIndex = currentIndex } Item{Layout.fillHeight: true} ColorButton{ diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 679d173..1fc2036 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -70,6 +70,7 @@ Item{ readonly property int pixel_rasterization: 2 property int rasterization: no_rasterization + onRasterizationChanged: handleFontChanged() property string frame_source: frames_list.get(frames_index).source property int frames_index: 1 @@ -77,10 +78,56 @@ Item{ signal terminalFontChanged - property var _font_scalings: [0.5, 0.75, 1.0, 1.25, 1.50, 1.75, 2.0] - property var font: currentfont - property int font_index: 0 - property var fonts_list: fontlist + Loader{ + id: fontManager + onSourceChanged: console.log(source) + + states: [ + State { when: rasterization == no_rasterization + PropertyChanges {target: fontManager; source: "Fonts.qml" } }, + State { when: rasterization == scanline_rasterization + PropertyChanges {target: fontManager; source: "FontScanlines.qml" } }, + State { when: rasterization == pixel_rasterization; + PropertyChanges {target: fontManager; source: "FontPixels.qml" } } + ] + + onLoaded: handleFontChanged() + } + + Text{id: fontMetrics; text: "B"; visible: false} + + FontLoader{ + property int pixelSize + property real lineSpacing + property size paintedSize + property size virtualCharSize + id: currentfont + source: fontlist.get(fontIndex).source + } + + property var fontlist: fontManager.item.fontlist + property var fontScalingList: fontManager.item.fontScalingList + property alias font: currentfont + property int fontIndex: 0 + property int fontScalingIndex: 0 + + onFontIndexChanged: {fontManager.item.selectedFontIndex = fontIndex; handleFontChanged()} + onFontScalingIndexChanged: {fontManager.item.selectedScalingIndex = fontScalingIndex; handleFontChanged()} + + function handleFontChanged(){ + currentfont.source = fontManager.item.source; + currentfont.pixelSize = fontManager.item.pixelSize; + currentfont.lineSpacing = fontManager.item.lineSpacing; + fontMetrics.font = currentfont.name; + fontMetrics.font.pixelSize = currentfont.pixelSize; + currentfont.paintedSize = Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight) + console.log(Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight)) + currentfont.virtualCharSize = fontManager.item.virtualCharSize !== undefined ? + fontManager.item.virtualCharSize : + Qt.size(currentfont.paintedSize.width * 0.5, + currentfont.paintedSize.height * 0.5); + terminalFontChanged(); + } property bool frame_reflections: true property real frame_reflection_strength: ((frame_reflections && framelist.get(frames_index).reflections) ? 1.0 : 0.0) * 0.15 @@ -89,28 +136,6 @@ Item{ property int profiles_index: 0 onProfiles_indexChanged: loadProfile(profiles_index); - onFont_indexChanged: handleFontChanged(); - onFont_scaling_indexChanged: handleFontChanged(); - - function handleFontChanged(){ - var f = fontlist.get(font_index); - var metrics = f.metrics.get(font_scaling_index); - currentfont.source = f.source; - currentfont.pixelSize = metrics.pixelSize; - currentfont.lineSpacing = f.lineSpacing; - currentfont.virtualResolution = Qt.size(metrics.virtualWidth, - metrics.virtualHeight); - terminalFontChanged(); - } - - FontLoader{ - property int pixelSize - property real lineSpacing - property size virtualResolution - id: currentfont - source: fontlist.get(font_index).source - } - ListModel{ id: framelist ListElement{text: "No frame"; source: "./frames/NoFrame.qml"; reflections: false} @@ -118,115 +143,6 @@ Item{ ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true} } - property int font_scaling_index: 0 - ListModel{ - id: fontlist - ListElement{ - text: "Terminus (Modern)" - source: "fonts/modern-terminus/TerminusTTF-Bold-4.38.2.ttf" - lineSpacing: 2 - metrics: [ - ListElement{pixelSize: 18; virtualWidth: 0; virtualHeight: 6}, - ListElement{pixelSize: 24; virtualWidth: 0; virtualHeight: 8}, - ListElement{pixelSize: 35; virtualWidth: 5; virtualHeight: 12}, - ListElement{pixelSize: 43; virtualWidth: 6; virtualHeight: 11}, - ListElement{pixelSize: 54; virtualWidth: 7; virtualHeight: 11}, - ListElement{pixelSize: 64; virtualWidth: 8; virtualHeight: 11}, - ListElement{pixelSize: 75; virtualWidth: 8; virtualHeight: 11}] - } - ListElement{ - text: "Commodore PET (1977)" - source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" - lineSpacing: 2 - metrics: [ - ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6}, - ListElement{pixelSize: 24; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 32; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 40; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}] - } - ListElement{ - text: "Commodore PET 2Y (1977)" - source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" - lineSpacing: 2 - metrics: [ - ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6}, - ListElement{pixelSize: 32; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 40; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 48; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 56; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 64; virtualWidth: 4; virtualHeight: 8}] - } - ListElement{ - text: "Apple ][ (1977)" - source: "fonts/1977-apple2/PrintChar21.ttf" - lineSpacing: 2 - metrics: [ - ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6}, - ListElement{pixelSize: 24; virtualWidth: 7; virtualHeight: 8}, - ListElement{pixelSize: 32; virtualWidth: 7; virtualHeight: 8}, - ListElement{pixelSize: 40; virtualWidth: 7; virtualHeight: 8}, - ListElement{pixelSize: 48; virtualWidth: 7; virtualHeight: 8}, - ListElement{pixelSize: 56; virtualWidth: 7; virtualHeight: 8}] - } - ListElement{ - text: "Atari 400-800 (1979)" - source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" - lineSpacing: 3 - metrics: [ - ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6}, - ListElement{pixelSize: 24; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 32; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 40; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}] - } - ListElement{ - text: "Commodore 64 (1982)" - source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" - lineSpacing: 3 - metrics: [ - ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6}, - ListElement{pixelSize: 24; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 32; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 40; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8}, - ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}] - } - ListElement{ - text: "Atari ST (1985)" - source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf" - lineSpacing: 2 - metrics: [ - ListElement{pixelSize: 16; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 23; virtualWidth: 0; virtualHeight: 7}, - ListElement{pixelSize: 32; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 40; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 48; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 56; virtualWidth: 4; virtualHeight: 8}, - ListElement{pixelSize: 64; virtualWidth: 8; virtualHeight: 16}] - } - ListElement{ - text: "IBM DOS (1985)" - source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf" - lineSpacing: 2 - metrics: [ - ListElement{pixelSize: 18; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 25; virtualWidth: 0; virtualHeight: 0}, - ListElement{pixelSize: 32; virtualWidth: 6; virtualHeight: 8}, - ListElement{pixelSize: 36; virtualWidth: 6; virtualHeight: 12}, - ListElement{pixelSize: 48; virtualWidth: 9; virtualHeight: 16}, - ListElement{pixelSize: 56; virtualWidth: 9; virtualHeight: 16}, - ListElement{pixelSize: 64; virtualWidth: 9; virtualHeight: 16}] - } - } - Storage{id: storage} function composeSettingsString(){ @@ -297,7 +213,7 @@ Item{ fps = settings.fps !== undefined ? settings.fps: fps window_scaling = settings.window_scaling ? settings.window_scaling : window_scaling - font_scaling_index = settings.font_scaling_index !== undefined ? settings.font_scaling_index: font_scaling_index; + //font_scaling_index = settings.font_scaling_index !== undefined ? settings.font_scaling_index: font_scaling_index; } function loadProfileString(profileString){ @@ -317,7 +233,7 @@ Item{ frames_index = settings.frames_index !== undefined ? settings.frames_index : frames_index; - font_index = settings.font_index !== undefined ? settings.font_index : font_index; + //font_index = settings.font_index !== undefined ? settings.font_index : font_index; rasterization = settings.rasterization !== undefined ? settings.rasterization : rasterization; diff --git a/app/Terminal.qml b/app/Terminal.qml index 9c6b9c7..7f9e912 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -44,9 +44,8 @@ Item{ property real _minBlurCoefficient: 0.75 property real _maxBlurCoefficient: 0.95 - property real scanlineWidth: 1 - property real scanlineHeight: 1 - property size virtual_resolution: Qt.size(width / scanlineWidth, height / scanlineHeight) + property size virtualPxSize: Qt.size(1,1) + property size virtual_resolution: Qt.size(width / virtualPxSize.width, height / virtualPxSize.height) property real deltay: 0.5 / virtual_resolution.height property real deltax: 0.5 / virtual_resolution.width @@ -91,33 +90,28 @@ Item{ } } - Text{id: fontMetrics; text: "B"; visible: false} - function handleFontChange(){ - var scaling_factor = shadersettings.window_scaling; - var font_size = shadersettings.font.pixelSize * scaling_factor; + var newFont = shadersettings.font; + var font_size = newFont.pixelSize * shadersettings.window_scaling; font.pixelSize = font_size; - font.family = shadersettings.font.name; + font.family = newFont.name; - fontMetrics.font = font; - - var vertical_density = shadersettings.font.virtualResolution.height; - var horizontal_density = shadersettings.font.virtualResolution.width; - - var scanline_height = fontMetrics.paintedHeight / vertical_density; - var scanline_width = fontMetrics.paintedWidth / horizontal_density; + var virtualCharSize = newFont.virtualCharSize; + var virtualPxSize = Qt.size(newFont.paintedSize.width / virtualCharSize.width, + newFont.paintedSize.height / virtualCharSize.height) var scanline_spacing = shadersettings.font.lineSpacing; - var line_spacing = Math.round(scanline_spacing * scanline_height); + var line_spacing = Math.round(scanline_spacing); + + console.log(kterminal.paintedFontSize) // console.log("Font height: " + fontMetrics.paintedHeight) // console.log("Scanline Height: " + scanline_height) // console.log("Line Spacing: " + line_spacing) - terminalContainer.scanlineHeight = scanline_height; - terminalContainer.scanlineWidth = scanline_width; + terminalContainer.virtualPxSize = virtualPxSize; - setLineSpacing(line_spacing); + setLineSpacing(newFont.lineSpacing); restartBlurredSource(); } Component.onCompleted: { diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 50ee390..4eaaea6 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/konsole-qml-plugin/src/TerminalDisplay.cpp b/konsole-qml-plugin/src/TerminalDisplay.cpp index ae5391a..e350b8c 100644 --- a/konsole-qml-plugin/src/TerminalDisplay.cpp +++ b/konsole-qml-plugin/src/TerminalDisplay.cpp @@ -416,6 +416,9 @@ void KTerminalDisplay::setVTFont(const QFont& f) // Disabling kerning saves some computation when rendering text. font.setKerning(false); + // Konsole cannot handle non-integer font metrics + font.setStyleStrategy(QFont::StyleStrategy(font.styleStrategy() | QFont::ForceIntegerMetrics)); + //QWidget::setFont(font); m_font = font; fontChange(font); From b0aad13ba7b4a14dc8677463a50e5054e1cfc004 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Mon, 23 Jun 2014 22:47:35 +0200 Subject: [PATCH 09/13] Redisigned and refactored settings window. --- ...ttingComponent.qml => CheckableSlider.qml} | 10 +- app/ColorButton.qml | 32 +- app/Glossy.qml | 21 ++ app/SettingsEffectsTab.qml | 53 ++++ app/SettingsGeneralTab.qml | 109 +++++++ app/SettingsWindow.qml | 280 +----------------- app/ShaderSettings.qml | 6 +- app/SimpleSlider.qml | 19 +- app/app.qmlproject.user | 2 +- 9 files changed, 239 insertions(+), 293 deletions(-) rename app/{SettingComponent.qml => CheckableSlider.qml} (86%) create mode 100644 app/Glossy.qml create mode 100644 app/SettingsEffectsTab.qml create mode 100644 app/SettingsGeneralTab.qml diff --git a/app/SettingComponent.qml b/app/CheckableSlider.qml similarity index 86% rename from app/SettingComponent.qml rename to app/CheckableSlider.qml index abeb827..c6044bc 100644 --- a/app/SettingComponent.qml +++ b/app/CheckableSlider.qml @@ -56,6 +56,14 @@ RowLayout { } Text{ id: textfield - text: Math.round(((value - min_value) / (max_value - min_value)) * 100) + "%" + property string unformattedText: Math.round(((value - min_value) / (max_value - min_value)) * 100) + text: formatNumber(unformattedText) + } + function formatNumber(num) { + var n = "" + num; + while (n.length < 3) { + n = " " + n; + } + return n + "%"; } } diff --git a/app/ColorButton.qml b/app/ColorButton.qml index 1b966df..248924c 100644 --- a/app/ColorButton.qml +++ b/app/ColorButton.qml @@ -22,7 +22,8 @@ import QtQuick 2.2 import QtQuick.Dialogs 1.1 Item { - property color button_color; + property color button_color + property string name ColorDialog { id: colorDialog @@ -35,25 +36,22 @@ Item { onAccepted: button_color = color; } Rectangle{ - radius: 10 anchors.fill: parent + radius: 10 color: button_color - - Text{ - id: text_color - anchors.centerIn: parent - z: 1.1 - text: button_color - } - - Rectangle{ - anchors.centerIn: parent - width: text_color.width * 1.4 - height: text_color.height * 1.4 - radius: 10 - border.color: "black" - border.width: 2 + border.color: "black" + Glossy {} + Rectangle { + anchors.fill: parent + anchors.margins: parent.height * 0.25 + radius: parent.radius color: "white" + opacity: 0.5 + } + Text{ + anchors.centerIn: parent + z: parent.z + 1 + text: name + ": " + button_color } } MouseArea{ diff --git a/app/Glossy.qml b/app/Glossy.qml new file mode 100644 index 0000000..3ac9c14 --- /dev/null +++ b/app/Glossy.qml @@ -0,0 +1,21 @@ +import QtQuick 2.2 + +Rectangle { + anchors.centerIn: parent + width: parent.width - parent.border.width + height: parent.height - parent.border.width + radius:parent.radius - parent.border.width/2 + smooth: true + + border.width: parent.border.width/2 + border.color: "#22FFFFFF" + + gradient: Gradient { + GradientStop { position: 0; color: "#88FFFFFF" } + GradientStop { position: .1; color: "#55FFFFFF" } + GradientStop { position: .5; color: "#33FFFFFF" } + GradientStop { position: .501; color: "#11000000" } + GradientStop { position: .8; color: "#11FFFFFF" } + GradientStop { position: 1; color: "#55FFFFFF" } + } +} diff --git a/app/SettingsEffectsTab.qml b/app/SettingsEffectsTab.qml new file mode 100644 index 0000000..a6e398a --- /dev/null +++ b/app/SettingsEffectsTab.qml @@ -0,0 +1,53 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 + +Tab{ + GroupBox{ + title: qsTr("Effects") + anchors.fill: parent + ColumnLayout{ + anchors.fill: parent + CheckableSlider{ + name: qsTr("Bloom") + onValueChanged: shadersettings.bloom_strength = value + _value: shadersettings.bloom_strength + } + CheckableSlider{ + name: qsTr("Motion Blur") + onValueChanged: shadersettings.motion_blur = value + _value: shadersettings.motion_blur + } + CheckableSlider{ + name: qsTr("Noise") + onValueChanged: shadersettings.noise_strength = value + _value: shadersettings.noise_strength + } + CheckableSlider{ + name: qsTr("Jitter") + onValueChanged: shadersettings.jitter = value + _value: shadersettings.jitter + } + CheckableSlider{ + name: qsTr("Glow") + onValueChanged: shadersettings.glowing_line_strength = value; + _value: shadersettings.glowing_line_strength + } + CheckableSlider{ + name: qsTr("Screen distortion") + onValueChanged: shadersettings.screen_distortion = value; + _value: shadersettings.screen_distortion; + } + CheckableSlider{ + name: qsTr("Brightness flickering") + onValueChanged: shadersettings.brightness_flickering= value; + _value: shadersettings.brightness_flickering; + } + CheckableSlider{ + name: qsTr("Horizontal flickering") + onValueChanged: shadersettings.horizontal_sincronization = value; + _value: shadersettings.horizontal_sincronization; + } + } + } +} diff --git a/app/SettingsGeneralTab.qml b/app/SettingsGeneralTab.qml new file mode 100644 index 0000000..900fec7 --- /dev/null +++ b/app/SettingsGeneralTab.qml @@ -0,0 +1,109 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 + +Tab{ + ColumnLayout{ + anchors.fill: parent + GroupBox{ + Layout.fillWidth: true + title: qsTr("Profile") + ColumnLayout{ + anchors.fill: parent + ComboBox{ + id: profilesbox + Layout.fillWidth: true + model: shadersettings.profiles_list + currentIndex: shadersettings.profiles_index + } + RowLayout{ + Layout.fillWidth: true + Button{ + Layout.fillWidth: true + text: qsTr("Load") + onClicked: { + shadersettings.profiles_index = profilesbox.currentIndex + shadersettings.loadCurrentProfile(); + } + } + Button{ + Layout.fillWidth: true + text: qsTr("Store current") + onClicked: insertname.show() + } + Button{ + Layout.fillWidth: true + text: qsTr("Remove Selected") + enabled: !shadersettings.profiles_list.get(profilesbox.currentIndex).builtin + onClicked: { + shadersettings.profiles_list.remove(profilesbox.currentIndex) + profilesbox.currentIndex = profilesbox.currentIndex - 1 + } + } + } + InsertNameDialog{ + id: insertname + onNameSelected: shadersettings.addNewCustomProfile(name) + } + } + } + GroupBox{ + title: qsTr("Lights") + Layout.fillWidth: true + GridLayout{ + anchors.fill: parent + columns: 2 + Text{ text: qsTr("Brightness") } + SimpleSlider{ + onValueChanged: shadersettings.brightness = value + value: shadersettings.brightness + } + Text{ text: qsTr("Contrast") } + SimpleSlider{ + onValueChanged: shadersettings.contrast = value + value: shadersettings.contrast + } + Text{ text: qsTr("Ambient") } + SimpleSlider{ + onValueChanged: shadersettings.ambient_light = value; + value: shadersettings.ambient_light + } + } + } + GroupBox{ + title: qsTr("Performace") + Layout.fillWidth: true + Layout.columnSpan: 2 + anchors.left: parent.left + anchors.right: parent.right + GridLayout{ + anchors.fill: parent + rows: 2 + columns: 3 + Text{text: qsTr("Animation FPS")} + Slider{ + Layout.fillWidth: true + id: slider + stepSize: 1 + maximumValue: 60 + minimumValue: 0 + onValueChanged: shadersettings.fps = value; + value: shadersettings.fps + } + Text{text: slider.value} + Text{text: qsTr("Texture quality")} + Slider{ + Layout.fillWidth: true + id: txtslider + stepSize: 0.01 + maximumValue: 1 + minimumValue: 0 + onValueChanged: shadersettings.window_scaling = value; + value: shadersettings.window_scaling + updateValueWhileDragging: false + } + Text{text: Math.round(txtslider.__handlePos * 100) + "%"} + } + } + } +} diff --git a/app/SettingsWindow.qml b/app/SettingsWindow.qml index b2b1d84..db23dff 100644 --- a/app/SettingsWindow.qml +++ b/app/SettingsWindow.qml @@ -28,281 +28,29 @@ Window { id: settings_window title: qsTr("Settings") width: 640 - height: 480 + height: 420 + + property int tabmargins: 15 modality: Qt.ApplicationModal TabView{ anchors.fill: parent anchors.margins: 10 - Tab{ - title: qsTr("Appearance") + SettingsGeneralTab{ + title: qsTr("General") anchors.fill: parent - anchors.margins: 15 - GridLayout{ - anchors.fill: parent - columns: 2 - GroupBox{ - anchors.left: parent.left - anchors.right: parent.right - Layout.columnSpan: 2 - title: qsTr("Profile") - RowLayout{ - anchors.fill: parent - ComboBox{ - id: profilesbox - Layout.fillWidth: true - model: shadersettings.profiles_list - currentIndex: shadersettings.profiles_index - } - Button{ - text: "Load" - onClicked: shadersettings.profiles_index = profilesbox.currentIndex - } - Button{ - text: "Add" - onClicked: insertname.show() - } - Button{ - text: "Remove" - enabled: !shadersettings.profiles_list.get(profilesbox.currentIndex).builtin - onClicked: { - shadersettings.profiles_list.remove(profilesbox.currentIndex) - profilesbox.currentIndex = profilesbox.currentIndex - 1 - } - } - InsertNameDialog{ - id: insertname - onNameSelected: shadersettings.addNewCustomProfile(name) - } - } - } - - GroupBox{ - id: fontbox - title: qsTr("Font") - Layout.fillHeight: true - Layout.fillWidth: true - GridLayout{ - anchors.fill: parent - columns: 2 - Text{text: qsTr("Font style:")} - ComboBox{ - Layout.fillWidth: true - model: shadersettings.fontlist - currentIndex: shadersettings.fontIndex - onCurrentIndexChanged: shadersettings.fontIndex = currentIndex - } - Text{text: qsTr("Font scaling:")} - ComboBox{ - Layout.fillWidth: true - model: shadersettings.fontScalingList - currentIndex: shadersettings.fontScalingIndex - onCurrentIndexChanged: shadersettings.fontScalingIndex = currentIndex - } - Item{Layout.fillHeight: true} - ColorButton{ - height: 50 - Layout.fillWidth: true - Layout.columnSpan: 2 - onButton_colorChanged: shadersettings._font_color = button_color; - button_color: shadersettings._font_color; - } - } - } - GroupBox{ - title: qsTr("Background") - Layout.fillHeight: true - Layout.fillWidth: true - GridLayout{ - anchors.fill: parent - columns: 2 - Text{text: "Frame texture"} - ComboBox{ - id: framescombobox - Layout.fillWidth: true - model: shadersettings.frames_list - currentIndex: shadersettings.frames_index - onCurrentIndexChanged: shadersettings.frames_index = currentIndex - } - CheckBox{ - Layout.columnSpan: 2 - Layout.fillWidth: true - checked: shadersettings.frame_reflections - text: qsTr("Frame reflections") - onCheckedChanged: shadersettings.frame_reflections = checked - enabled: framescombobox.model.get(framescombobox.currentIndex).reflections - } - - Item{Layout.fillHeight: true} - ColorButton{ - height: 50 - Layout.fillWidth: true - Layout.columnSpan: 2 - - onButton_colorChanged: shadersettings._background_color= button_color - button_color: shadersettings._background_color; - } - } - } - GroupBox{ - title: qsTr("Lights") - Layout.fillWidth: true - Layout.columnSpan: 2 - anchors.left: parent.left - anchors.right: parent.right - GridLayout{ - Layout.columnSpan: 2 - columns: 2 - rows: 2 - anchors.left: parent.left - anchors.right: parent.right - Text{text: qsTr("Contrast")} - SimpleSlider{ - onValueChanged: shadersettings.contrast = value - value: shadersettings.contrast - } - Text{text: qsTr("Brightness")} - SimpleSlider{ - onValueChanged: shadersettings.brightness = value - value: shadersettings.brightness - } - } - } - GroupBox{ - title: qsTr("Performace") - Layout.fillWidth: true - Layout.columnSpan: 2 - anchors.left: parent.left - anchors.right: parent.right - GridLayout{ - columns: 3 - Layout.columnSpan: 2 - anchors {left: parent.left; right: parent.right} - Text{text: "Animation FPS"} - Slider{ - Layout.fillWidth: true - id: slider - stepSize: 1 - maximumValue: 60 - minimumValue: 0 - onValueChanged: shadersettings.fps = value; - value: shadersettings.fps - } - Text{text: slider.value} - Text{text: "Texture quality"} - Slider{ - Layout.fillWidth: true - id: txtslider - stepSize: 0.01 - maximumValue: 1 - minimumValue: 0 - onValueChanged: shadersettings.window_scaling = value; - value: shadersettings.window_scaling - updateValueWhileDragging: false - } - Text{text: Math.round(txtslider.value * 100) + "%"} - } - } - } + anchors.margins: tabmargins } - - Tab{ - title: qsTr("Eye-candy") + SettingsTerminalTab{ + title: qsTr("Terminal") anchors.fill: parent - anchors.margins: 15 - - ColumnLayout{ - anchors.fill: parent - GroupBox{ - title: qsTr("Rasterization") - anchors.left: parent.left - anchors.right: parent.right - ColumnLayout{ - anchors.left: parent.left - anchors.right: parent.right - RowLayout{ - anchors.left: parent.left - anchors.right: parent.right - ExclusiveGroup { id: rasterizationgroup } - RadioButton { - text: qsTr("No Rasterization") - exclusiveGroup: rasterizationgroup - checked: shadersettings.rasterization === shadersettings.no_rasterization - onCheckedChanged: if(checked) - shadersettings.rasterization = shadersettings.no_rasterization - } - RadioButton { - text: qsTr("Scanlines") - exclusiveGroup: rasterizationgroup - checked: shadersettings.rasterization === shadersettings.scanline_rasterization - onCheckedChanged: if(checked) - shadersettings.rasterization = shadersettings.scanline_rasterization - } - RadioButton { - text: qsTr("Pixels") - exclusiveGroup: rasterizationgroup - checked: shadersettings.rasterization === shadersettings.pixel_rasterization - onCheckedChanged: if(checked) - shadersettings.rasterization = shadersettings.pixel_rasterization - } - } - } - } - GroupBox{ - title: qsTr("Effects") - anchors.left: parent.left - anchors.right: parent.right - ColumnLayout{ - anchors.fill: parent - SettingComponent{ - name: "Bloom" - onValueChanged: shadersettings.bloom_strength = value - _value: shadersettings.bloom_strength - } - SettingComponent{ - name: "Motion Blur" - onValueChanged: shadersettings.motion_blur = value - _value: shadersettings.motion_blur - } - SettingComponent{ - name: "Noise" - onValueChanged: shadersettings.noise_strength = value - _value: shadersettings.noise_strength - } - SettingComponent{ - name: "Jitter" - onValueChanged: shadersettings.jitter = value - _value: shadersettings.jitter - } - SettingComponent{ - name: "Glow" - onValueChanged: shadersettings.glowing_line_strength = value; - _value: shadersettings.glowing_line_strength - } - SettingComponent{ - name: "Ambient light" - onValueChanged: shadersettings.ambient_light = value; - _value: shadersettings.ambient_light - } - SettingComponent{ - name: "Screen distortion" - onValueChanged: shadersettings.screen_distortion = value; - _value: shadersettings.screen_distortion; - } - SettingComponent{ - name: "Brightness flickering" - onValueChanged: shadersettings.brightness_flickering= value; - _value: shadersettings.brightness_flickering; - } - SettingComponent{ - name: "Horizontal flickering" - onValueChanged: shadersettings.horizontal_sincronization = value; - _value: shadersettings.horizontal_sincronization; - } - } - } - } + anchors.margins: tabmargins + } + SettingsEffectsTab{ + title: qsTr("Effects") + anchors.fill: parent + anchors.margins: tabmargins } } } diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 1fc2036..a9f0065 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -121,7 +121,6 @@ Item{ fontMetrics.font = currentfont.name; fontMetrics.font.pixelSize = currentfont.pixelSize; currentfont.paintedSize = Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight) - console.log(Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight)) currentfont.virtualCharSize = fontManager.item.virtualCharSize !== undefined ? fontManager.item.virtualCharSize : Qt.size(currentfont.paintedSize.width * 0.5, @@ -134,7 +133,6 @@ Item{ property alias profiles_list: profileslist property int profiles_index: 0 - onProfiles_indexChanged: loadProfile(profiles_index); ListModel{ id: framelist @@ -269,6 +267,10 @@ Item{ return JSON.stringify(customProfiles); } + function loadCurrentProfile(){ + loadProfile(profiles_index); + } + function loadProfile(index){ var profile = profileslist.get(index); loadProfileString(profile.obj_string); diff --git a/app/SimpleSlider.qml b/app/SimpleSlider.qml index cabc9d8..f362e06 100644 --- a/app/SimpleSlider.qml +++ b/app/SimpleSlider.qml @@ -23,21 +23,28 @@ import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 RowLayout { - property string name - property double value: 0.0 - property double stepSize: 0.01 + property alias value: slider.value + property alias stepSize: slider.stepSize + property alias minimumValue: slider.minimumValue + property alias maximumValue: slider.maximumValue + property real maxMultiplier: 100 id: setting_component spacing: 10 Slider{ id: slider stepSize: parent.stepSize - onValueChanged: setting_component.value = slider.value; Layout.fillWidth: true - value: setting_component.value } Text{ id: textfield - text: Math.round(value * 100) + "%" + text: formatNumber(Math.round(value * maxMultiplier)) + } + function formatNumber(num) { + var n = "" + num; + while (n.length < 3) { + n = " " + n; + } + return n + "%"; } } diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 4eaaea6..942e70e 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 9795b5d9d2116311895c69fa449b8c177df3c42a Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Tue, 24 Jun 2014 11:34:33 +0200 Subject: [PATCH 10/13] Ooops... Forgot to add one file to git.. --- app/SettingsTerminalTab.qml | 100 ++++++++++++++++++++++++++++++++++++ app/ShaderSettings.qml | 10 ++-- app/app.qmlproject.user | 2 +- 3 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 app/SettingsTerminalTab.qml diff --git a/app/SettingsTerminalTab.qml b/app/SettingsTerminalTab.qml new file mode 100644 index 0000000..1dbf86c --- /dev/null +++ b/app/SettingsTerminalTab.qml @@ -0,0 +1,100 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 + +Tab{ + ColumnLayout{ + anchors.fill: parent + GroupBox{ + title: qsTr("Rasterization Mode") + Layout.fillWidth: true + ComboBox { + id: rasterizationBox + anchors.fill: parent + model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")] + currentIndex: shadersettings.rasterization + onCurrentIndexChanged: shadersettings.rasterization = currentIndex + } + } + GroupBox{ + title: qsTr("Font") + Layout.fillWidth: true + GridLayout{ + anchors.fill: parent + columns: 2 + Text{ text: qsTr("Name") } + ComboBox{ + id: fontChanged + Layout.fillWidth: true + model: shadersettings.fontlist + currentIndex: shadersettings.fontIndexes[shadersettings.rasterization] + onCurrentIndexChanged: { + shadersettings.fontIndexes[shadersettings.rasterization] = currentIndex; + shadersettings.handleFontChanged(); + } + } + Text{ text: qsTr("Scaling") } + RowLayout{ + Layout.fillWidth: true + Slider{ + id: scalingChanger + Layout.fillWidth: true + minimumValue: 0 + maximumValue: shadersettings.fontScalingList.length - 1 + stepSize: 1 + value: shadersettings.fontScalingIndexes[shadersettings.rasterization] + onValueChanged: { + shadersettings.fontScalingIndexes[shadersettings.rasterization] = value; + console.log(shadersettings.fontScalingIndexes); + shadersettings.handleFontChanged(); + } + } + Text{ + text: shadersettings.fontScalingList[scalingChanger.value].toFixed(2) + } + } + } + } + GroupBox{ + title: qsTr("Colors") + Layout.fillWidth: true + RowLayout{ + anchors.fill: parent + ColorButton{ + name: qsTr("Font") + height: 50 + Layout.fillWidth: true + onButton_colorChanged: shadersettings._font_color = button_color + button_color: shadersettings._font_color + } + ColorButton{ + name: qsTr("Background") + height: 50 + Layout.fillWidth: true + onButton_colorChanged: shadersettings._background_color = button_color + button_color: shadersettings._background_color + } + } + } + GroupBox{ + title: qsTr("Frame") + Layout.fillWidth: true + RowLayout{ + anchors.fill: parent + ComboBox{ + id: framescombobox + Layout.fillWidth: true + model: shadersettings.frames_list + currentIndex: shadersettings.frames_index + onCurrentIndexChanged: shadersettings.frames_index = currentIndex + } + CheckBox{ + checked: shadersettings.frame_reflections + text: qsTr("Reflections") + onCheckedChanged: shadersettings.frame_reflections = checked + enabled: framescombobox.model.get(framescombobox.currentIndex).reflections + } + } + } + } +} diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index a9f0065..f8fca92 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -102,19 +102,19 @@ Item{ property size paintedSize property size virtualCharSize id: currentfont - source: fontlist.get(fontIndex).source } property var fontlist: fontManager.item.fontlist property var fontScalingList: fontManager.item.fontScalingList property alias font: currentfont - property int fontIndex: 0 - property int fontScalingIndex: 0 - onFontIndexChanged: {fontManager.item.selectedFontIndex = fontIndex; handleFontChanged()} - onFontScalingIndexChanged: {fontManager.item.selectedScalingIndex = fontScalingIndex; handleFontChanged()} + property var fontIndexes: [0,1,1] + property var fontScalingIndexes: [5,1,1] function handleFontChanged(){ + if(!fontManager.item) return; + fontManager.item.selectedFontIndex = fontIndexes[rasterization]; + fontManager.item.selectedScalingIndex = fontScalingIndexes[rasterization]; currentfont.source = fontManager.item.source; currentfont.pixelSize = fontManager.item.pixelSize; currentfont.lineSpacing = fontManager.item.lineSpacing; diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 942e70e..d41435c 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 372bceb18693a5d7fa3429f7d56cd418ccd74cfe Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Wed, 25 Jun 2014 14:29:10 +0200 Subject: [PATCH 11/13] Settings window seems to work nicely. --- app/SettingsTerminalTab.qml | 30 ++++++++++++----- app/ShaderSettings.qml | 66 +++++++++++++++---------------------- app/Terminal.qml | 41 ++++++++++++----------- app/app.qmlproject.user | 2 +- app/main.qml | 1 + 5 files changed, 71 insertions(+), 69 deletions(-) diff --git a/app/SettingsTerminalTab.qml b/app/SettingsTerminalTab.qml index 1dbf86c..b09476d 100644 --- a/app/SettingsTerminalTab.qml +++ b/app/SettingsTerminalTab.qml @@ -10,28 +10,38 @@ Tab{ Layout.fillWidth: true ComboBox { id: rasterizationBox + property string selectedElement: model[currentIndex] anchors.fill: parent model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")] currentIndex: shadersettings.rasterization - onCurrentIndexChanged: shadersettings.rasterization = currentIndex + onCurrentIndexChanged: { + scalingChanger.enabled = false; + shadersettings.rasterization = currentIndex + fontChanger.updateIndex(); + scalingChanger.updateIndex(); + scalingChanger.enabled = true; + } } } GroupBox{ - title: qsTr("Font") + title: qsTr("Font") + " (" + rasterizationBox.selectedElement + ")" Layout.fillWidth: true GridLayout{ anchors.fill: parent columns: 2 Text{ text: qsTr("Name") } ComboBox{ - id: fontChanged + id: fontChanger Layout.fillWidth: true model: shadersettings.fontlist - currentIndex: shadersettings.fontIndexes[shadersettings.rasterization] - onCurrentIndexChanged: { - shadersettings.fontIndexes[shadersettings.rasterization] = currentIndex; + currentIndex: updateIndex() + onActivated: { + shadersettings.fontIndexes[shadersettings.rasterization] = index; shadersettings.handleFontChanged(); } + function updateIndex(){ + currentIndex = shadersettings.fontIndexes[shadersettings.rasterization]; + } } Text{ text: qsTr("Scaling") } RowLayout{ @@ -42,12 +52,16 @@ Tab{ minimumValue: 0 maximumValue: shadersettings.fontScalingList.length - 1 stepSize: 1 - value: shadersettings.fontScalingIndexes[shadersettings.rasterization] + tickmarksEnabled: true + value: updateIndex() onValueChanged: { + if(!enabled) return; //Ugly and hacky solution. Look for a better solution. shadersettings.fontScalingIndexes[shadersettings.rasterization] = value; - console.log(shadersettings.fontScalingIndexes); shadersettings.handleFontChanged(); } + function updateIndex(){ + value = shadersettings.fontScalingIndexes[shadersettings.rasterization]; + } } Text{ text: shadersettings.fontScalingList[scalingChanger.value].toFixed(2) diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index f8fca92..bb76002 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -70,17 +70,23 @@ Item{ readonly property int pixel_rasterization: 2 property int rasterization: no_rasterization - onRasterizationChanged: handleFontChanged() + + ListModel{ + id: framelist + ListElement{text: "No frame"; source: "./frames/NoFrame.qml"; reflections: false} + ListElement{text: "Simple white frame"; source: "./frames/WhiteSimpleFrame.qml"; reflections: true} + ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true} + } property string frame_source: frames_list.get(frames_index).source property int frames_index: 1 property var frames_list: framelist - signal terminalFontChanged + + signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, size virtualCharSize) Loader{ id: fontManager - onSourceChanged: console.log(source) states: [ State { when: rasterization == no_rasterization @@ -94,38 +100,23 @@ Item{ onLoaded: handleFontChanged() } - Text{id: fontMetrics; text: "B"; visible: false} - - FontLoader{ - property int pixelSize - property real lineSpacing - property size paintedSize - property size virtualCharSize - id: currentfont - } - property var fontlist: fontManager.item.fontlist property var fontScalingList: fontManager.item.fontScalingList - property alias font: currentfont - property var fontIndexes: [0,1,1] + property var fontIndexes: [1,1,1] property var fontScalingIndexes: [5,1,1] function handleFontChanged(){ if(!fontManager.item) return; fontManager.item.selectedFontIndex = fontIndexes[rasterization]; fontManager.item.selectedScalingIndex = fontScalingIndexes[rasterization]; - currentfont.source = fontManager.item.source; - currentfont.pixelSize = fontManager.item.pixelSize; - currentfont.lineSpacing = fontManager.item.lineSpacing; - fontMetrics.font = currentfont.name; - fontMetrics.font.pixelSize = currentfont.pixelSize; - currentfont.paintedSize = Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight) - currentfont.virtualCharSize = fontManager.item.virtualCharSize !== undefined ? - fontManager.item.virtualCharSize : - Qt.size(currentfont.paintedSize.width * 0.5, - currentfont.paintedSize.height * 0.5); - terminalFontChanged(); + + var fontSource = fontManager.item.source; + var pixelSize = fontManager.item.pixelSize; + var lineSpacing = fontManager.item.lineSpacing; + var virtualCharSize = fontManager.item.virtualCharSize; + + terminalFontChanged(fontSource, pixelSize, lineSpacing, virtualCharSize); } property bool frame_reflections: true @@ -134,13 +125,6 @@ Item{ property alias profiles_list: profileslist property int profiles_index: 0 - ListModel{ - id: framelist - ListElement{text: "No frame"; source: "./frames/NoFrame.qml"; reflections: false} - ListElement{text: "Simple white frame"; source: "./frames/WhiteSimpleFrame.qml"; reflections: true} - ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true} - } - Storage{id: storage} function composeSettingsString(){ @@ -151,7 +135,8 @@ Item{ brightness: brightness, contrast: contrast, ambient_light: ambient_light, - font_scaling_index: font_scaling_index, + fontScalingIndexes: fontScalingIndexes, + fontIndexes: fontIndexes } return JSON.stringify(settings); } @@ -166,11 +151,11 @@ Item{ screen_distortion: screen_distortion, glowing_line_strength: glowing_line_strength, frames_index: frames_index, - font_index: font_index, motion_blur: motion_blur, bloom_strength: bloom_strength, rasterization: rasterization, - jitter: jitter + jitter: jitter, + fontIndex: fontIndexes[rasterization] } return JSON.stringify(settings); } @@ -211,7 +196,8 @@ Item{ fps = settings.fps !== undefined ? settings.fps: fps window_scaling = settings.window_scaling ? settings.window_scaling : window_scaling - //font_scaling_index = settings.font_scaling_index !== undefined ? settings.font_scaling_index: font_scaling_index; + fontIndexes = settings.fontIndexes ? settings.fontIndexes : fontIndexes + fontScalingIndexes = settings.fontScalingIndexes ? settings.fontScalingIndexes : fontScalingIndexes } function loadProfileString(profileString){ @@ -231,11 +217,11 @@ Item{ frames_index = settings.frames_index !== undefined ? settings.frames_index : frames_index; - //font_index = settings.font_index !== undefined ? settings.font_index : font_index; - rasterization = settings.rasterization !== undefined ? settings.rasterization : rasterization; - jitter = settings.jitter !== undefined ? settings.jitter : jitter + jitter = settings.jitter !== undefined ? settings.jitter : jitter; + + fontIndexes[rasterization] = settings.fontIndex ? settings.fontIndex : fontIndexes[rasterization]; } function storeCustomProfiles(){ diff --git a/app/Terminal.qml b/app/Terminal.qml index 7f9e912..8e5d572 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -56,8 +56,6 @@ Item{ property size terminalSize: kterminal.terminalSize property size paintedTextSize - onPaintedTextSizeChanged: console.log(paintedTextSize) - //Force reload of the blursource when settings change onMBlurChanged: restartBlurredSource() @@ -76,8 +74,6 @@ Item{ KTerminal { id: kterminal anchors.fill: parent - font.pixelSize: shadersettings.font.pixelSize - font.family: shadersettings.font.name colorScheme: "MyWhiteOnBlack" @@ -90,33 +86,38 @@ Item{ } } - function handleFontChange(){ - var newFont = shadersettings.font; - var font_size = newFont.pixelSize * shadersettings.window_scaling; - font.pixelSize = font_size; - font.family = newFont.name; + FontLoader{ id: fontLoader } + Text{id: fontMetrics; text: "B"; visible: false} - var virtualCharSize = newFont.virtualCharSize; - var virtualPxSize = Qt.size(newFont.paintedSize.width / virtualCharSize.width, - newFont.paintedSize.height / virtualCharSize.height) + function getPaintedSize(pixelSize){ + fontMetrics.font.family = fontLoader.name; + fontMetrics.font.pixelSize = pixelSize; + return Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight); + } + function isValid(size){ + return size.width >= 0 && size.height >= 0; + } - var scanline_spacing = shadersettings.font.lineSpacing; - var line_spacing = Math.round(scanline_spacing); + function handleFontChange(fontSource, pixelSize, lineSpacing, virtualCharSize){ + fontLoader.source = fontSource; + font.pixelSize = pixelSize * shadersettings.window_scaling; + font.family = fontLoader.name; - console.log(kterminal.paintedFontSize) + var paintedSize = getPaintedSize(pixelSize); + var charSize = isValid(virtualCharSize) + ? virtualCharSize + : Qt.size(paintedSize.width / 2, paintedSize.height / 2); - // console.log("Font height: " + fontMetrics.paintedHeight) - // console.log("Scanline Height: " + scanline_height) - // console.log("Line Spacing: " + line_spacing) + var virtualPxSize = Qt.size(paintedSize.width / charSize.width, + paintedSize.height / charSize.height) terminalContainer.virtualPxSize = virtualPxSize; - setLineSpacing(newFont.lineSpacing); + setLineSpacing(lineSpacing); restartBlurredSource(); } Component.onCompleted: { shadersettings.terminalFontChanged.connect(handleFontChange); - handleFontChange(); forceActiveFocus(); } } diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index d41435c..458140c 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/app/main.qml b/app/main.qml index 41d49d7..8b6ed88 100644 --- a/app/main.qml +++ b/app/main.qml @@ -159,4 +159,5 @@ ApplicationWindow{ terminalSize: terminal.terminalSize } } + Component.onCompleted: shadersettings.handleFontChanged(); } From e108258e522db8a3165fc2e1a982e6d0bb5d4ea2 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Wed, 25 Jun 2014 17:43:57 +0200 Subject: [PATCH 12/13] Small changes in scaling and fonts. --- app/FontPixels.qml | 2 +- app/FontScanlines.qml | 10 +++++----- app/Fonts.qml | 2 +- app/app.qmlproject.user | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/FontPixels.qml b/app/FontPixels.qml index 33475bd..455346d 100644 --- a/app/FontPixels.qml +++ b/app/FontPixels.qml @@ -7,7 +7,7 @@ Item{ property var _font: fontlist.get(selectedFontIndex) property var _scaling: fontScalingList[selectedScalingIndex] property var source: _font.source - property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0] + property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0, 2.25, 2.5] property int pixelSize: _font.pixelSize * _scaling property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing property size virtualCharSize: Qt.size(_font.virtualCharWidth, diff --git a/app/FontScanlines.qml b/app/FontScanlines.qml index 6446031..14dfe58 100644 --- a/app/FontScanlines.qml +++ b/app/FontScanlines.qml @@ -7,7 +7,7 @@ Item{ property var _font: fontlist.get(selectedFontIndex) property var _scaling: fontScalingList[selectedScalingIndex] property var source: _font.source - property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0] + property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0, 2.25, 2.50] property int pixelSize: _font.pixelSize * _scaling property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing property size virtualCharSize: Qt.size(_font.virtualCharWidth, @@ -16,16 +16,16 @@ Item{ ListModel{ id: fontlist ListElement{ - text: "Commodore PET (1977)" - source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" + text: "Commodore PET 2Y (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" lineSpacing: 2 virtualCharWidth: 8 virtualCharHeight: 8 pixelSize: 32 } ListElement{ - text: "Commodore PET 2Y (1977)" - source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" + text: "Commodore PET (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" lineSpacing: 2 virtualCharWidth: 8 virtualCharHeight: 8 diff --git a/app/Fonts.qml b/app/Fonts.qml index 64dbdb7..5e85aa2 100644 --- a/app/Fonts.qml +++ b/app/Fonts.qml @@ -7,7 +7,7 @@ Item{ property var source: fontlist.get(selectedFontIndex).source property var _font: fontlist.get(selectedFontIndex) property var _scaling: fontScalingList[selectedScalingIndex] - property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0] + property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] property int pixelSize: _font.pixelSize * _scaling property int lineSpacing: pixelSize * _font.lineSpacing diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 458140c..44d99a7 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget From 893870f8a3ec119f6b9290f5c9b81cf92db48441 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Fri, 27 Jun 2014 03:00:31 +0200 Subject: [PATCH 13/13] Fixed errors with profiles, new ones added. --- app/FontScanlines.qml | 2 +- app/SettingsGeneralTab.qml | 1 + app/ShaderSettings.qml | 63 +++++++++++++++++++++++++------------- app/app.qmlproject.user | 2 +- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/app/FontScanlines.qml b/app/FontScanlines.qml index 14dfe58..7ab57c7 100644 --- a/app/FontScanlines.qml +++ b/app/FontScanlines.qml @@ -19,7 +19,7 @@ Item{ text: "Commodore PET 2Y (1977)" source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" lineSpacing: 2 - virtualCharWidth: 8 + virtualCharWidth: 4 virtualCharHeight: 8 pixelSize: 32 } diff --git a/app/SettingsGeneralTab.qml b/app/SettingsGeneralTab.qml index 900fec7..fe40028 100644 --- a/app/SettingsGeneralTab.qml +++ b/app/SettingsGeneralTab.qml @@ -24,6 +24,7 @@ Tab{ onClicked: { shadersettings.profiles_index = profilesbox.currentIndex shadersettings.loadCurrentProfile(); + shadersettings.handleFontChanged(); } } Button{ diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index bb76002..dc6b2fe 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -25,7 +25,7 @@ Item{ property real ambient_light: 0.2 property real contrast: 0.85 - property real brightness: 0.75 + property real brightness: 0.5 //On resize shows an overlay with the current size property bool show_terminal_size: true @@ -50,20 +50,20 @@ Item{ //Probably there is a better way to cast string to colors. property string _background_color: "#000000" - property string _font_color: "#ff9400" + property string _font_color: "#ff8100" property color font_color: mix(strToColor(_font_color), strToColor(_background_color), 0.7 + (contrast * 0.3)) property color background_color: mix(strToColor(_background_color), strToColor(_font_color), 0.7 + (contrast * 0.3)) property real noise_strength: 0.1 - property real screen_distortion: 0.15 - property real glowing_line_strength: 0.4 - property real motion_blur: 0.65 - property real bloom_strength: 0.6 + property real screen_distortion: 0.1 + property real glowing_line_strength: 0.2 + property real motion_blur: 0.40 + property real bloom_strength: 0.65 - property real jitter: 0.15 + property real jitter: 0.18 - property real horizontal_sincronization: 0.1 - property real brightness_flickering: 0.12 + property real horizontal_sincronization: 0.08 + property real brightness_flickering: 0.1 readonly property int no_rasterization: 0 readonly property int scanline_rasterization: 1 @@ -103,7 +103,7 @@ Item{ property var fontlist: fontManager.item.fontlist property var fontScalingList: fontManager.item.fontScalingList - property var fontIndexes: [1,1,1] + property var fontIndexes: [0,0,0] property var fontScalingIndexes: [5,1,1] function handleFontChanged(){ @@ -180,7 +180,8 @@ Item{ storage.setSetting("_CURRENT_SETTINGS", settingsString); storage.setSetting("_CURRENT_PROFILE", profileString); - console.log("Storing settings :" + settingsString + profileString); + console.log("Storing settings: " + settingsString); + console.log("Storing profile: " + profileString); } function loadSettingsString(settingsString){ @@ -191,13 +192,13 @@ Item{ contrast = settings.contrast !== undefined ? settings.contrast : contrast; brightness = settings.brightness !== undefined ? settings.brightness : brightness - show_terminal_size = settings.show_terminal_size ? settings.show_terminal_size : show_terminal_size + show_terminal_size = settings.show_terminal_size !== undefined ? settings.show_terminal_size : show_terminal_size fps = settings.fps !== undefined ? settings.fps: fps - window_scaling = settings.window_scaling ? settings.window_scaling : window_scaling + window_scaling = settings.window_scaling !== undefined ? settings.window_scaling : window_scaling - fontIndexes = settings.fontIndexes ? settings.fontIndexes : fontIndexes - fontScalingIndexes = settings.fontScalingIndexes ? settings.fontScalingIndexes : fontScalingIndexes + fontIndexes = settings.fontIndexes !== undefined ? settings.fontIndexes : fontIndexes + fontScalingIndexes = settings.fontScalingIndexes !== undefined ? settings.fontScalingIndexes : fontScalingIndexes } function loadProfileString(profileString){ @@ -221,7 +222,7 @@ Item{ jitter = settings.jitter !== undefined ? settings.jitter : jitter; - fontIndexes[rasterization] = settings.fontIndex ? settings.fontIndex : fontIndexes[rasterization]; + fontIndexes[rasterization] = settings.fontIndex !== undefined ? settings.fontIndex : fontIndexes[rasterization]; } function storeCustomProfiles(){ @@ -280,18 +281,38 @@ Item{ ListModel{ id: profileslist ListElement{ - text: "Default" - obj_string: '{"background_color":"#000000","bloom_strength":0.6,"brightness_flickering":0.12,"font_color":"#ff9400","font_index":0,"frames_index":1,"glowing_line_strength":0.4,"horizontal_sincronization":0.1,"motion_blur":0.65,"noise_strength":0.1,"rasterization":1,"screen_distortion":0.15}' + text: "Default Amber" + obj_string: '{"background_color":"#000000","bloom_strength":0.65,"brightness_flickering":0.1,"fontIndex":0,"font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.45,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1}' builtin: true } ListElement{ - text: "Commodore 64" - obj_string: '{"ambient_light":0.2,"background_color":"#5048b2","font_color":"#8bcad1","font_index":2,"font_scaling":1,"frames_index":1,"glowing_line_strength":0.2,"noise_strength":0.05,"scanlines":0.0,"screen_distortion":0.1,"brightness_flickering":0.03}' + text: "Default Green" + obj_string: '{"background_color":"#000000","bloom_strength":0.4,"brightness_flickering":0.1,"fontIndex":0,"font_color":"#0ccc68","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.45,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1}' + builtin: true + } + ListElement{ + text: "Default Scanlines" + obj_string: '{"background_color":"#000000","bloom_strength":0.4,"brightness_flickering":0.1,"fontIndex":0,"font_color":"#00ff5b","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.07,"jitter":0.11,"motion_blur":0.4,"noise_strength":0.05,"rasterization":1,"screen_distortion":0.1}' + builtin: true + } + ListElement{ + text: "Default Pixelated" + obj_string: '{"background_color":"#000000","bloom_strength":0.65,"brightness_flickering":0.1,"fontIndex":0,"font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.1,"jitter":0,"motion_blur":0.45,"noise_strength":0.14,"rasterization":2,"screen_distortion":0.05}' + builtin: true + } + ListElement{ + text: "Apple ][" + obj_string: '{"background_color":"#000000","bloom_strength":0.5,"brightness_flickering":0.2,"fontIndex":2,"font_color":"#2fff91","frames_index":1,"glowing_line_strength":0.22,"horizontal_sincronization":0.08,"jitter":0.1,"motion_blur":0.65,"noise_strength":0.08,"rasterization":1,"screen_distortion":0.18}' + builtin: true + } + ListElement{ + text: "Vintage" + obj_string: '{"background_color":"#000000","bloom_strength":0.4,"brightness_flickering":0.54,"fontIndex":0,"font_color":"#00ff3e","frames_index":2,"glowing_line_strength":0.3,"horizontal_sincronization":0.2,"jitter":0.4,"motion_blur":0.75,"noise_strength":0.2,"rasterization":1,"screen_distortion":0.1}' builtin: true } ListElement{ text: "IBM Dos" - obj_string: '{"ambient_light":0.4,"background_color":"#000000","font_color":"#ffffff","font_index":3,"font_scaling":1,"frames_index":1,"glowing_line_strength":0,"noise_strength":0,"scanlines":0.0,"screen_distortion":0.05,"brightness_flickering":0.00}' + obj_string: '{"background_color":"#000000","bloom_strength":0.4,"brightness_flickering":0.07,"fontIndex":7,"font_color":"#ffffff","frames_index":1,"glowing_line_strength":0.13,"horizontal_sincronization":0,"jitter":0.08,"motion_blur":0.3,"noise_strength":0.03,"rasterization":0,"screen_distortion":0.1}' builtin: true } } diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 44d99a7..24e654f 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget