mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-31 10:11:20 +00:00
Scanlines now follow font scaling.
This commit is contained in:
parent
110f91afa5
commit
05edbb9504
@ -96,11 +96,11 @@ Window {
|
|||||||
Text{text: qsTr("Font scaling:")}
|
Text{text: qsTr("Font scaling:")}
|
||||||
SpinBox{
|
SpinBox{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
decimals: 1
|
decimals: 2
|
||||||
stepSize: 0.1
|
stepSize: 0.25
|
||||||
value: shadersettings.font_scaling
|
value: shadersettings.font_scaling
|
||||||
minimumValue: 0.5
|
minimumValue: 0.5
|
||||||
maximumValue: 1.5
|
maximumValue: 2.0
|
||||||
onValueChanged: shadersettings.font_scaling = value;
|
onValueChanged: shadersettings.font_scaling = value;
|
||||||
}
|
}
|
||||||
Item{Layout.fillHeight: true}
|
Item{Layout.fillHeight: true}
|
||||||
|
@ -27,11 +27,15 @@ ShaderEffect {
|
|||||||
property variant source: theSource
|
property variant source: theSource
|
||||||
property variant bloomSource: bloomSource
|
property variant bloomSource: bloomSource
|
||||||
property size txt_Size: Qt.size(width, height)
|
property size txt_Size: Qt.size(width, height)
|
||||||
|
|
||||||
property real bloom: shadersettings.bloom_strength
|
property real bloom: shadersettings.bloom_strength
|
||||||
|
|
||||||
property int rasterization: shadersettings.rasterization
|
property int rasterization: shadersettings.rasterization
|
||||||
property real rasterization_strength: shadersettings.rasterization_strength
|
property real rasterization_strength: shadersettings.rasterization_strength
|
||||||
|
property real _lines: frame.sourceRect.height / terminal.paintedFontSize.height
|
||||||
|
property real _columns: frame.sourceRect.width / terminal.paintedFontSize.height
|
||||||
|
property real verticalPixelDensity: shadersettings.font.verticalPixelDensity
|
||||||
|
property real horizontalPixelDensity: shadersettings.font.horizontalPixelDensity
|
||||||
|
property size num_scanlines: Qt.size(_columns * horizontalPixelDensity, _lines * verticalPixelDensity)
|
||||||
|
|
||||||
property real noise_strength: shadersettings.noise_strength
|
property real noise_strength: shadersettings.noise_strength
|
||||||
property real screen_distorsion: shadersettings.screen_distortion
|
property real screen_distorsion: shadersettings.screen_distortion
|
||||||
@ -49,9 +53,6 @@ ShaderEffect {
|
|||||||
|
|
||||||
property real brightness: shadersettings.brightness * 1.5 + 0.5
|
property real brightness: shadersettings.brightness * 1.5 + 0.5
|
||||||
|
|
||||||
property real deltay: 3 / parent.height
|
|
||||||
property real deltax: 3 / parent.width
|
|
||||||
|
|
||||||
property real time: timetimer.time
|
property real time: timetimer.time
|
||||||
property variant randomFunctionSource: randfuncsource
|
property variant randomFunctionSource: randfuncsource
|
||||||
|
|
||||||
@ -114,9 +115,7 @@ ShaderEffect {
|
|||||||
varying highp vec2 originalCoord;
|
varying highp vec2 originalCoord;
|
||||||
|
|
||||||
uniform highp vec4 font_color;
|
uniform highp vec4 font_color;
|
||||||
uniform highp vec4 background_color;
|
uniform highp vec4 background_color;" +
|
||||||
uniform highp float deltax;
|
|
||||||
uniform highp float deltay;" +
|
|
||||||
|
|
||||||
(bloom !== 0 ? "
|
(bloom !== 0 ? "
|
||||||
uniform highp sampler2D bloomSource;" : "") +
|
uniform highp sampler2D bloomSource;" : "") +
|
||||||
@ -133,9 +132,9 @@ ShaderEffect {
|
|||||||
|
|
||||||
(rasterization !== shadersettings.no_rasterization ? "
|
(rasterization !== shadersettings.no_rasterization ? "
|
||||||
float getScanlineIntensity(vec2 coord){
|
float getScanlineIntensity(vec2 coord){
|
||||||
float result = step(0.4, fract(coord.y * txt_Size.y * 0.5));" +
|
float result = abs(sin(coord.y * "+(num_scanlines.height * Math.PI).toFixed(2)+"));" +
|
||||||
(rasterization === shadersettings.pixel_rasterization ? "
|
(rasterization === shadersettings.pixel_rasterization ? "
|
||||||
result *= step(0.4, fract(coord.x * txt_Size.x * 0.5));" : "") +
|
result *= abs(sin(coord.x * "+(num_scanlines.width * Math.PI).toFixed(2)+"));" : "") +
|
||||||
"return result;
|
"return result;
|
||||||
}" : "") +
|
}" : "") +
|
||||||
|
|
||||||
@ -186,16 +185,23 @@ ShaderEffect {
|
|||||||
noise += horizontal_distortion;" : "")
|
noise += horizontal_distortion;" : "")
|
||||||
: "") +
|
: "") +
|
||||||
|
|
||||||
"float color = texture2D(source, coords).r;" +
|
(rasterization !== shadersettings.no_rasterization ? "
|
||||||
|
vec2 txt_coords = coords;
|
||||||
|
txt_coords.y = floor(coords.y * "+num_scanlines.height.toFixed(1)+") / "+num_scanlines.height.toFixed(1)+";" +
|
||||||
|
(rasterization === shadersettings.pixel_rasterization ?
|
||||||
|
"txt_coords.x = floor(coords.x * "+num_scanlines.width.toFixed(1)+") / "+num_scanlines.width.toFixed(1)+";" : "")
|
||||||
|
: " vec2 txt_coords = coords;") +
|
||||||
|
|
||||||
|
"float color = texture2D(source, txt_coords).r;" +
|
||||||
|
|
||||||
(noise_strength !== 0 ? "
|
(noise_strength !== 0 ? "
|
||||||
color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") +
|
color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") +
|
||||||
|
|
||||||
(glowing_line_strength !== 0 ? "
|
(glowing_line_strength !== 0 ? "
|
||||||
color += randomPass(coords) * glowing_line_strength;" : "") +
|
color += randomPass(txt_coords) * glowing_line_strength;" : "") +
|
||||||
|
|
||||||
(rasterization !== shadersettings.no_rasterization ? "
|
(rasterization !== shadersettings.no_rasterization ? "
|
||||||
color = mix(color, color * getScanlineIntensity(originalCoord), "+ rasterization_strength.toFixed(1) +");"
|
color = mix(color, color * getScanlineIntensity(coords), "+ rasterization_strength.toFixed(1) +");"
|
||||||
: "") +
|
: "") +
|
||||||
|
|
||||||
(bloom !== 0 ? "
|
(bloom !== 0 ? "
|
||||||
|
@ -100,6 +100,8 @@ Item{
|
|||||||
FontLoader{
|
FontLoader{
|
||||||
property int pixelSize: fontlist.get(font_index).pixelSize
|
property int pixelSize: fontlist.get(font_index).pixelSize
|
||||||
property real lineSpacing: fontlist.get(font_index).lineSpacing
|
property real lineSpacing: fontlist.get(font_index).lineSpacing
|
||||||
|
property real verticalPixelDensity: fontlist.get(font_index).verticalPixelDensity
|
||||||
|
property real horizontalPixelDensity: fontlist.get(font_index).horizontalPixelDensity
|
||||||
id: currentfont
|
id: currentfont
|
||||||
source: fontlist.get(font_index).source
|
source: fontlist.get(font_index).source
|
||||||
}
|
}
|
||||||
@ -116,44 +118,58 @@ Item{
|
|||||||
ListElement{
|
ListElement{
|
||||||
text: "Terminus (Modern)"
|
text: "Terminus (Modern)"
|
||||||
source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf"
|
source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf"
|
||||||
pixelSize: 30
|
pixelSize: 32
|
||||||
lineSpacing: 0.1
|
lineSpacing: 0.12
|
||||||
|
verticalPixelDensity: 12
|
||||||
|
horizontalPixelDensity: 12
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Commodore PET (1977)"
|
text: "Commodore PET (1977)"
|
||||||
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
|
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
|
||||||
pixelSize: 22
|
pixelSize: 25
|
||||||
lineSpacing: 0.2
|
lineSpacing: 0.1
|
||||||
|
verticalPixelDensity: 9
|
||||||
|
horizontalPixelDensity: 9
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Apple ][ (1977)"
|
text: "Apple ][ (1977)"
|
||||||
source: "fonts/1977-apple2/PrintChar21.ttf"
|
source: "fonts/1977-apple2/PrintChar21.ttf"
|
||||||
pixelSize: 24
|
pixelSize: 25
|
||||||
lineSpacing: 0.2
|
lineSpacing: 0.1
|
||||||
|
verticalPixelDensity: 9
|
||||||
|
horizontalPixelDensity: 10
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Atari 400-800 (1979)"
|
text: "Atari 400-800 (1979)"
|
||||||
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
|
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
|
||||||
pixelSize: 22
|
pixelSize: 25
|
||||||
lineSpacing: 0.25
|
lineSpacing: 0.22
|
||||||
|
verticalPixelDensity: 10
|
||||||
|
horizontalPixelDensity: 10
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Commodore 64 (1982)"
|
text: "Commodore 64 (1982)"
|
||||||
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
|
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
|
||||||
pixelSize: 22
|
pixelSize: 25
|
||||||
lineSpacing: 0.25
|
lineSpacing: 0.22
|
||||||
|
verticalPixelDensity: 10
|
||||||
|
horizontalPixelDensity: 10
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Atari ST (1985)"
|
text: "Atari ST (1985)"
|
||||||
source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf"
|
source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf"
|
||||||
pixelSize: 26
|
pixelSize: 26
|
||||||
lineSpacing: 0.2
|
lineSpacing: 0.15
|
||||||
|
verticalPixelDensity: 11
|
||||||
|
horizontalPixelDensity: 12
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "IBM DOS (1985)"
|
text: "IBM DOS (1985)"
|
||||||
source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf"
|
source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf"
|
||||||
pixelSize: 30
|
pixelSize: 32
|
||||||
lineSpacing: 0.1
|
lineSpacing: 0.17
|
||||||
|
verticalPixelDensity: 15
|
||||||
|
horizontalPixelDensity: 15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ Item{
|
|||||||
property real mBloom: shadersettings.bloom_strength
|
property real mBloom: shadersettings.bloom_strength
|
||||||
|
|
||||||
property size terminalSize
|
property size terminalSize
|
||||||
|
property size _paintedFontSize
|
||||||
|
property size paintedFontSize: _paintedFontSize ? _paintedFontSize : 0
|
||||||
|
|
||||||
//Force reload of the blursource when settings change
|
//Force reload of the blursource when settings change
|
||||||
onMBloomChanged: restartBlurredSource()
|
onMBloomChanged: restartBlurredSource()
|
||||||
@ -66,12 +68,13 @@ Item{
|
|||||||
|
|
||||||
sourceComponent: KTerminal {
|
sourceComponent: KTerminal {
|
||||||
id: ktermitem
|
id: ktermitem
|
||||||
font.pixelSize: shadersettings.fontSize
|
font.pixelSize: shadersettings.font.pixelSize
|
||||||
font.family: shadersettings.font.name
|
font.family: shadersettings.font.name
|
||||||
|
|
||||||
colorScheme: "MyWhiteOnBlack"
|
colorScheme: "MyWhiteOnBlack"
|
||||||
|
|
||||||
onTerminalSizeChanged: terminalContainer.terminalSize = ktermitem.terminalSize
|
onTerminalSizeChanged: terminalContainer.terminalSize = ktermitem.terminalSize
|
||||||
|
onPaintedFontSizeChanged: terminalContainer._paintedFontSize = ktermitem.paintedFontSize
|
||||||
|
|
||||||
session: KSession {
|
session: KSession {
|
||||||
id: ksession
|
id: ksession
|
||||||
@ -86,8 +89,8 @@ Item{
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var scaling_factor = shadersettings.font_scaling * shadersettings.window_scaling;
|
var scaling_factor = shadersettings.font_scaling * shadersettings.window_scaling;
|
||||||
var font_size = shadersettings.font.pixelSize * scaling_factor;
|
var font_size = Math.ceil(shadersettings.font.pixelSize * scaling_factor);
|
||||||
var line_spacing = Math.round(shadersettings.font.lineSpacing * font_size);
|
var line_spacing = Math.ceil(shadersettings.font.lineSpacing * font_size);
|
||||||
font.pixelSize = font_size;
|
font.pixelSize = font_size;
|
||||||
font.family = shadersettings.font.name;
|
font.family = shadersettings.font.name;
|
||||||
setLineSpacing(line_spacing);
|
setLineSpacing(line_spacing);
|
||||||
@ -194,7 +197,6 @@ Item{
|
|||||||
|
|
||||||
"void main() {" +
|
"void main() {" +
|
||||||
"float color = texture2D(source, qt_TexCoord0).r * 256.0;" +
|
"float color = texture2D(source, qt_TexCoord0).r * 256.0;" +
|
||||||
|
|
||||||
(mBlur !== 0 ?
|
(mBlur !== 0 ?
|
||||||
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 256.0;" +
|
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 256.0;" +
|
||||||
"blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" +
|
"blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" +
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.0.1, 2014-05-27T21:59:57. -->
|
<!-- Written by QtCreator 3.0.1, 2014-05-29T01:07:57. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
@ -380,6 +380,7 @@ void KTerminalDisplay::fontChange(const QFont&)
|
|||||||
_fontAscent = fm.ascent();
|
_fontAscent = fm.ascent();
|
||||||
|
|
||||||
emit changedFontMetricSignal( _fontHeight, _fontWidth );
|
emit changedFontMetricSignal( _fontHeight, _fontWidth );
|
||||||
|
emit paintedFontSizeChanged();
|
||||||
propagateSize();
|
propagateSize();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class KONSOLEPRIVATE_EXPORT KTerminalDisplay : public QQuickPaintedItem
|
|||||||
Q_PROPERTY(bool activeFocusOnClick READ autoFocus WRITE setAutoFocus NOTIFY changedAutoFocus)
|
Q_PROPERTY(bool activeFocusOnClick READ autoFocus WRITE setAutoFocus NOTIFY changedAutoFocus)
|
||||||
Q_PROPERTY(bool ShowIMEOnClick READ autoVKB WRITE setAutoVKB NOTIFY changedAutoVKB)
|
Q_PROPERTY(bool ShowIMEOnClick READ autoVKB WRITE setAutoVKB NOTIFY changedAutoVKB)
|
||||||
Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY terminalSizeChanged)
|
Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY terminalSizeChanged)
|
||||||
|
Q_PROPERTY(QSize paintedFontSize READ getFontSize NOTIFY paintedFontSizeChanged)
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -194,10 +194,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Return size of the terminal as columns lines.
|
* Return size of the terminal as columns lines.
|
||||||
*/
|
*/
|
||||||
QSize getTerminalSize(){
|
QSize getTerminalSize() {
|
||||||
return QSize(columns(), lines());
|
return QSize(columns(), lines());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize getFontSize() {
|
||||||
|
return QSize(fontWidth(), fontHeight());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets which characters, in addition to letters and numbers,
|
* Sets which characters, in addition to letters and numbers,
|
||||||
* are regarded as being part of a word for the purposes
|
* are regarded as being part of a word for the purposes
|
||||||
@ -417,6 +421,7 @@ signals:
|
|||||||
void clicked();
|
void clicked();
|
||||||
|
|
||||||
void terminalSizeChanged();
|
void terminalSizeChanged();
|
||||||
|
void paintedFontSizeChanged();
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -61,6 +61,7 @@ Module {
|
|||||||
Property { name: "activeFocusOnClick"; type: "bool" }
|
Property { name: "activeFocusOnClick"; type: "bool" }
|
||||||
Property { name: "ShowIMEOnClick"; type: "bool" }
|
Property { name: "ShowIMEOnClick"; type: "bool" }
|
||||||
Property { name: "terminalSize"; type: "QSize" }
|
Property { name: "terminalSize"; type: "QSize" }
|
||||||
|
Property { name: "paintedFontSize"; type: "QSize"}
|
||||||
Signal {
|
Signal {
|
||||||
name: "changedScheme"
|
name: "changedScheme"
|
||||||
Parameter { name: "scheme"; type: "string" }
|
Parameter { name: "scheme"; type: "string" }
|
||||||
@ -112,6 +113,7 @@ Module {
|
|||||||
Parameter { name: "session"; type: "KSession"; isPointer: true }
|
Parameter { name: "session"; type: "KSession"; isPointer: true }
|
||||||
}
|
}
|
||||||
Signal { name: "terminalSizeChanged" }
|
Signal { name: "terminalSizeChanged" }
|
||||||
|
Singal { name: "paintedFontSizeChanged" }
|
||||||
Signal { name: "updatedImage" }
|
Signal { name: "updatedImage" }
|
||||||
Method { name: "forcedFocus" }
|
Method { name: "forcedFocus" }
|
||||||
Method {
|
Method {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user