mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-02-22 04:49:02 +00:00
Refactor: extract all the other effects from main terminal.
This commit is contained in:
parent
9f943aa2d0
commit
68a8d7d212
@ -19,7 +19,6 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtGraphicalEffects 1.0
|
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
|
|
||||||
import QMLTermWidget 1.0
|
import QMLTermWidget 1.0
|
||||||
@ -27,7 +26,9 @@ import QMLTermWidget 1.0
|
|||||||
Item{
|
Item{
|
||||||
id: terminalContainer
|
id: terminalContainer
|
||||||
|
|
||||||
property size virtualResolution: Qt.size(kterminal.width, kterminal.height);
|
property size virtualResolution: Qt.size(kterminal.width, kterminal.height)
|
||||||
|
property alias mainTerminal: kterminal
|
||||||
|
property ShaderEffectSource mainSource: mBlur !== 0 ? blurredSourceLoader.item : kterminalSource
|
||||||
|
|
||||||
//Frame displacement properties. This makes the terminal the same size of the texture.
|
//Frame displacement properties. This makes the terminal the same size of the texture.
|
||||||
property real dtop: frame.item.displacementTop * shadersettings.window_scaling
|
property real dtop: frame.item.displacementTop * shadersettings.window_scaling
|
||||||
@ -42,10 +43,6 @@ Item{
|
|||||||
anchors.topMargin: dtop
|
anchors.topMargin: dtop
|
||||||
anchors.bottomMargin: dbottom
|
anchors.bottomMargin: dbottom
|
||||||
|
|
||||||
property variant theSource: mBlur !== 0 ? blurredSourceLoader.item : kterminalSource
|
|
||||||
property variant bloomSource: bloomSourceLoader.item
|
|
||||||
property variant staticNoiseSource: staticNoiseSource
|
|
||||||
|
|
||||||
property alias kterminal: kterminal
|
property alias kterminal: kterminal
|
||||||
|
|
||||||
signal sizeChanged
|
signal sizeChanged
|
||||||
@ -58,15 +55,9 @@ Item{
|
|||||||
property real _minBlurCoefficient: 0.70
|
property real _minBlurCoefficient: 0.70
|
||||||
property real _maxBlurCoefficient: 0.90
|
property real _maxBlurCoefficient: 0.90
|
||||||
|
|
||||||
property real mBloom: shadersettings.bloom_strength
|
|
||||||
property int mScanlines: shadersettings.rasterization
|
|
||||||
onMScanlinesChanged: restartBlurredSource()
|
|
||||||
|
|
||||||
property size terminalSize: kterminal.terminalSize
|
property size terminalSize: kterminal.terminalSize
|
||||||
property size paintedTextSize
|
property size paintedTextSize
|
||||||
|
|
||||||
onMBlurChanged: restartBlurredSource()
|
|
||||||
|
|
||||||
// Manage copy and paste
|
// Manage copy and paste
|
||||||
Connections{
|
Connections{
|
||||||
target: copyAction
|
target: copyAction
|
||||||
@ -77,11 +68,6 @@ Item{
|
|||||||
onTriggered: kterminal.pasteClipboard()
|
onTriggered: kterminal.pasteClipboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
function restartBlurredSource(){
|
|
||||||
if(!blurredSourceLoader.item) return;
|
|
||||||
blurredSourceLoader.item.restartBlurSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
//When settings are updated sources need to be redrawn.
|
//When settings are updated sources need to be redrawn.
|
||||||
Connections{
|
Connections{
|
||||||
target: shadersettings
|
target: shadersettings
|
||||||
@ -148,7 +134,6 @@ Item{
|
|||||||
|
|
||||||
kterminal.lineSpacing = lineSpacing;
|
kterminal.lineSpacing = lineSpacing;
|
||||||
//update();
|
//update();
|
||||||
restartBlurredSource();
|
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
shadersettings.terminalFontChanged.connect(handleFontChange);
|
shadersettings.terminalFontChanged.connect(handleFontChange);
|
||||||
@ -259,9 +244,13 @@ Item{
|
|||||||
livetimer.restart();
|
livetimer.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Restart blurred source settings change.
|
||||||
Connections{
|
Connections{
|
||||||
target: shadersettings
|
target: shadersettings
|
||||||
onScanline_qualityChanged: restartBlurredSource();
|
onScanline_qualityChanged: _blurredSourceEffect.restartBlurSource();
|
||||||
|
onMotion_blurChanged: _blurredSourceEffect.restartBlurSource();
|
||||||
|
onTerminalFontChanged: _blurredSourceEffect.restartBlurSource();
|
||||||
|
onRasterizationChanged: _blurredSourceEffect.restartBlurSource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,35 +297,4 @@ Item{
|
|||||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// EFFECTS //////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// BLOOM ////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Loader{
|
|
||||||
property real scaling: shadersettings.bloom_quality * shadersettings.window_scaling
|
|
||||||
id: bloomEffectLoader
|
|
||||||
active: mBloom != 0
|
|
||||||
asynchronous: true
|
|
||||||
width: parent.width * scaling
|
|
||||||
height: parent.height * scaling
|
|
||||||
sourceComponent: FastBlur{
|
|
||||||
radius: 48 * scaling
|
|
||||||
source: kterminal
|
|
||||||
transparentBorder: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loader{
|
|
||||||
id: bloomSourceLoader
|
|
||||||
active: mBloom != 0
|
|
||||||
asynchronous: true
|
|
||||||
sourceComponent: ShaderEffectSource{
|
|
||||||
id: _bloomEffectSource
|
|
||||||
sourceItem: bloomEffectLoader.item
|
|
||||||
hideSource: true
|
|
||||||
smooth: true
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,13 @@ import QtGraphicalEffects 1.0
|
|||||||
|
|
||||||
|
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
|
property ShaderEffectSource source
|
||||||
property ShaderEffectSource rasterizationSource
|
property ShaderEffectSource rasterizationSource
|
||||||
property ShaderEffectSource noiseSource
|
property ShaderEffectSource noiseSource
|
||||||
|
property ShaderEffectSource bloomSource
|
||||||
|
|
||||||
property color font_color: shadersettings.font_color
|
property color font_color: shadersettings.font_color
|
||||||
property color background_color: shadersettings.background_color
|
property color background_color: shadersettings.background_color
|
||||||
property variant source: terminal.theSource
|
|
||||||
property variant bloomSource: terminal.bloomSource
|
|
||||||
property real bloom_strength: shadersettings.bloom_strength * 2.5
|
property real bloom_strength: shadersettings.bloom_strength * 2.5
|
||||||
|
|
||||||
property real jitter: shadersettings.jitter * 0.007
|
property real jitter: shadersettings.jitter * 0.007
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
ShaderTerminal{
|
ShaderTerminal{
|
||||||
property alias title: terminal.title
|
property alias title: terminal.title
|
||||||
@ -7,6 +8,8 @@ ShaderTerminal{
|
|||||||
id: mainShader
|
id: mainShader
|
||||||
opacity: shadersettings.windowOpacity * 0.3 + 0.7
|
opacity: shadersettings.windowOpacity * 0.3 + 0.7
|
||||||
|
|
||||||
|
blending: false
|
||||||
|
|
||||||
Loader{
|
Loader{
|
||||||
id: frame
|
id: frame
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -19,7 +22,37 @@ ShaderTerminal{
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOISE ////////////////////////////////////////////////////////////////
|
source: terminal.mainSource
|
||||||
|
|
||||||
|
// EFFECTS ////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Loader{
|
||||||
|
property real scaling: shadersettings.bloom_quality * shadersettings.window_scaling
|
||||||
|
id: bloomEffectLoader
|
||||||
|
active: shadersettings.bloom_strength
|
||||||
|
asynchronous: true
|
||||||
|
width: parent.width * scaling
|
||||||
|
height: parent.height * scaling
|
||||||
|
sourceComponent: FastBlur{
|
||||||
|
radius: 48 * scaling
|
||||||
|
source: terminal.mainTerminal
|
||||||
|
transparentBorder: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loader{
|
||||||
|
id: bloomSourceLoader
|
||||||
|
active: shadersettings.bloom_strength !== 0
|
||||||
|
asynchronous: true
|
||||||
|
sourceComponent: ShaderEffectSource{
|
||||||
|
id: _bloomEffectSource
|
||||||
|
sourceItem: bloomEffectLoader.item
|
||||||
|
hideSource: true
|
||||||
|
smooth: true
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bloomSource: bloomSourceLoader.item
|
||||||
|
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: staticNoiseEffect
|
id: staticNoiseEffect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user