Commit 67f4e5a2 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Merge branch 'master' into krita-testing-wolthera

parents 519f9c1f 159a6126
From 84a774e00e9d2535fdb8c798d7789130a9a008f6 Mon Sep 17 00:00:00 2001
From: Michael Abrahams <miabraha@gmail.com>
Date: Wed, 22 Jun 2016 13:37:06 -0400
Subject: [PATCH 3/4] Hack for fullscreen workaround
https://bugreports.qt.io/browse/QTBUG-41309
---
src/plugins/platforms/windows/qwindowswindow.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 9c6cb53..d0829e3 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1769,7 +1769,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE;
const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
setFlag(SynchronousGeometryChangeEvent);
- SetWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
+ SetWindowPos(m_data.hwnd, HWND_TOP, r.left()-1, r.top()-1, r.width()+2, r.height()+2, swpf);
if (!wasSync)
clearFlag(SynchronousGeometryChangeEvent);
QWindowSystemInterface::handleGeometryChange(window(), r);
--
2.7.4.windows.1
......@@ -9,6 +9,7 @@ ExternalProject_Add(
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/qtgui-private-headers.diff
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Don-t-request-the-MIME-image-every-time-Windows-asks.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Hack-always-return-we-support-DIBV5.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/0003-Hack-for-fullscreen-workaround.patch
INSTALL_DIR ${EXTPREFIX_qt}
CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtenginio -skip qtgraphicaleffects -skip qtlocation -skip qtmultimedia -skip qtsensors -skip qtserialport -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtxmlpatterns -no-sql-sqlite -nomake examples -nomake tools -no-compile-examples -no-dbus -no-iconv -no-angle -no-ssl -no-openssl -no-wmf-backend -no-qml-debug -no-libproxy -no-system-proxies -no-nis -no-icu -no-mtdev -opensource -confirm-license -release -opengl desktop -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -prefix ${EXTPREFIX_qt}
......
......@@ -4,7 +4,12 @@ message(STATUS "Using CMake version: ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
set(MIN_QT_VERSION 5.4.0)
if (WIN32)
set(MIN_QT_VERSION 5.6.0)
else()
set(MIN_QT_VERSION 5.4.0)
endif()
set(MIN_FRAMEWORKS_VERSION 5.7.0)
if (POLICY CMP0002)
......
......@@ -137,6 +137,9 @@
#include <mutex>
#ifdef Q_OS_WIN
#include <QtPlatformHeaders/QWindowsWindowFunctions>
#endif
class ToolDockerFactory : public KoDockFactoryBase
{
......@@ -495,6 +498,11 @@ KisMainWindow::KisMainWindow()
d->viewManager->updateGUI();
d->viewManager->updateIcons();
#ifdef Q_OS_WIN
auto w = qApp->activeWindow();
if (w) QWindowsWindowFunctions::setHasBorderInFullScreen(w->windowHandle(), true);
#endif
QTimer::singleShot(1000, this, SLOT(checkSanity()));
{
......@@ -505,6 +513,9 @@ KisMainWindow::KisMainWindow()
d->tabSwitchCompressor.reset(
new KisSignalCompressorWithParam<int>(500, callback, KisSignalCompressor::FIRST_INACTIVE));
}
}
void KisMainWindow::setNoCleanup(bool noCleanup)
......@@ -1779,9 +1790,6 @@ void KisMainWindow::slotToolbarToggled(bool toggle)
void KisMainWindow::viewFullscreen(bool fullScreen)
{
KisConfig cfg;
#ifdef Q_OS_WIN
cfg.setFullscreenMode(false);
#else
cfg.setFullscreenMode(fullScreen);
if (fullScreen) {
......@@ -1789,7 +1797,6 @@ void KisMainWindow::viewFullscreen(bool fullScreen)
} else {
setWindowState(windowState() & ~Qt::WindowFullScreen); // reset
}
#endif
}
void KisMainWindow::slotProgress(int value)
......@@ -2317,9 +2324,8 @@ void KisMainWindow::createActions()
actionManager->createStandardAction(KStandardAction::Open, this, SLOT(slotFileOpen()));
actionManager->createStandardAction(KStandardAction::Quit, this, SLOT(slotFileQuit()));
actionManager->createStandardAction(KStandardAction::ConfigureToolbars, this, SLOT(slotConfigureToolbars()));
#ifndef Q_OS_WIN
actionManager->createStandardAction(KStandardAction::FullScreen, this, SLOT(viewFullscreen(bool)));
#endif
d->recentFiles = KStandardAction::openRecent(this, SLOT(slotFileOpenRecent(QUrl)), actionCollection());
connect(d->recentFiles, SIGNAL(recentListCleared()), this, SLOT(saveRecentFiles()));
KSharedConfigPtr configPtr = KSharedConfig::openConfig();
......
......@@ -1050,7 +1050,7 @@ void KisViewManager::switchCanvasOnly(bool toggled)
action->setChecked(!toggled);
}
}
#ifndef Q_OS_WIN
if (cfg.hideTitlebarFullscreen() && !cfg.fullscreenMode()) {
if(toggled) {
main->setWindowState( main->windowState() | Qt::WindowFullScreen);
......@@ -1058,7 +1058,7 @@ void KisViewManager::switchCanvasOnly(bool toggled)
main->setWindowState( main->windowState() & ~Qt::WindowFullScreen);
}
}
#endif
if (cfg.hideMenuFullscreen()) {
if (!toggled) {
if (main->menuBar()->dynamicPropertyNames().contains("wasvisible")) {
......
......@@ -766,9 +766,6 @@ FullscreenSettingsTab::FullscreenSettingsTab(QWidget* parent) : WdgFullscreenSet
chkMenu->setChecked(cfg.hideMenuFullscreen());
chkScrollbars->setChecked(cfg.hideScrollbarsFullscreen());
chkStatusbar->setChecked(cfg.hideStatusbarFullscreen());
#ifdef Q_OS_WINDOWS
chkTitlebar->setVisible(false);
#endif
chkTitlebar->setChecked(cfg.hideTitlebarFullscreen());
chkToolbar->setChecked(cfg.hideToolbarFullscreen());
......
......@@ -1115,11 +1115,7 @@ void KisConfig::setHideStatusbarFullscreen(const bool value) const
bool KisConfig::hideTitlebarFullscreen(bool defaultValue) const
{
#ifdef Q_OS_WIN
return false;
#else
return (defaultValue ? true : m_cfg.readEntry("hideTitleBarFullscreen", true));
#endif
}
void KisConfig::setHideTitlebarFullscreen(const bool value) const
......
......@@ -58,7 +58,7 @@ KisColorSmudgeOpSettingsWidget::KisColorSmudgeOpSettingsWidget(QWidget* parent):
addPaintOpOption(new KisCurveOptionWidget(new KisSmudgeRadiusOption(), i18n("0.0"), i18n("1.0")), i18n("Smudge Radius"));
addPaintOpOption(new KisCurveOptionWidget(new KisRateOption("ColorRate", KisPaintOpOption::GENERAL, false), i18n("0.0"), i18n("1.0")), i18n("Color Rate"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation"));
addPaintOpOption(new KisPressureScatterOptionWidget(), i18n("Scatter"));
addPaintOpOption(new KisOverlayModeOptionWidget(), i18n("Overlay Mode"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureGradientOption(), i18n("0%"), i18n("100%")), i18n("Gradient"));
......
......@@ -41,7 +41,9 @@ void KisRateOption::apply(KisPainter& painter, const KisPaintInformation& info,
return;
}
qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * computeValue(info); // scale m_rate into the range scaleMin - scaleMax
qreal value = computeSizeLikeValue(info);
qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * value; // scale m_rate into the range scaleMin - scaleMax
quint8 opacity = qBound(OPACITY_TRANSPARENT_U8, (quint8)(rate * 255.0), OPACITY_OPAQUE_U8);
painter.setOpacity(opacity);
}
......@@ -41,7 +41,9 @@ void KisSmudgeOption::apply(KisPainter& painter, const KisPaintInformation& info
return;
}
qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * computeValue(info); // scale m_rate into the range scaleMin - scaleMax
qreal value = computeSizeLikeValue(info);
qreal rate = scaleMin + (scaleMax - scaleMin) * multiplicator * value; // scale m_rate into the range scaleMin - scaleMax
quint8 opacity = qBound(OPACITY_TRANSPARENT_U8, (quint8)(rate * 255.0), OPACITY_OPAQUE_U8);
painter.setOpacity(opacity);
......
......@@ -55,7 +55,10 @@ void KisSmudgeRadiusOption::apply(KisPainter& painter,
qreal posy,
KisPaintDeviceSP dev) const
{
double sliderValue = computeValue(info);
if (!isChecked()) return;
qreal sliderValue = computeSizeLikeValue(info);
int smudgeRadius = ((sliderValue * diameter) * 0.5) / 100.0;
......
......@@ -27,8 +27,6 @@ KisCurvesOpacityOption::KisCurvesOpacityOption()
qreal KisCurvesOpacityOption::apply(const KisPaintInformation & info, qreal opacity) const
{
if (!isChecked()) {
return opacity;
}
return computeValue(info) * opacity;
if (!isChecked()) return opacity;
return computeSizeLikeValue(info) * opacity;
}
......@@ -27,8 +27,6 @@ KisLineWidthOption::KisLineWidthOption()
double KisLineWidthOption::apply(const KisPaintInformation & info, double lineWidth) const
{
if (!isChecked()) {
return lineWidth;
}
return computeValue(info) * lineWidth;
if (!isChecked()) return lineWidth;
return computeSizeLikeValue(info) * lineWidth;
}
......@@ -62,7 +62,7 @@ KisBrushOpSettingsWidget::KisBrushOpSettingsWidget(QWidget* parent)
addPaintOpOption(new KisCurveOptionWidget(new KisPressureSoftnessOption(), i18n("Soft"), i18n("Hard")), i18n("Softness"));
addPaintOpOption(new KisPressureSharpnessOptionWidget(), i18n("Sharpness"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation"));
addPaintOpOption(new KisPressureScatterOptionWidget(), i18n("Scatter"));
// Colors options
......
......@@ -41,7 +41,7 @@ KisDeformPaintOpSettingsWidget::KisDeformPaintOpSettingsWidget(QWidget* parent)
addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation"));
addPaintOpOption(new KisAirbrushOption(), i18n("Airbrush"));
}
......
......@@ -49,7 +49,7 @@ KisFilterOpSettingsWidget::KisFilterOpSettingsWidget(QWidget* parent)
addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation"));
addPaintOpOption(new KisPressureMirrorOptionWidget(), i18n("Mirror"));
m_filterOption = new KisFilterOption();
......
......@@ -41,7 +41,7 @@ KisHairyPaintOpSettingsWidget:: KisHairyPaintOpSettingsWidget(QWidget* parent)
addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("0°"), i18n("360°")), i18n("Rotation"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureRotationOption(), i18n("-180°"), i18n("180°")), i18n("Rotation"));
addPaintOpOption(new KisPaintActionTypeOption(), i18n("Painting Mode"));
}
......
......@@ -32,5 +32,5 @@ KisHatchingPressureCrosshatchingOption::KisHatchingPressureCrosshatchingOption()
double KisHatchingPressureCrosshatchingOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 0.5;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -33,5 +33,5 @@ KisHatchingPressureSeparationOption::KisHatchingPressureSeparationOption()
double KisHatchingPressureSeparationOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 0.5;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -33,5 +33,5 @@ KisHatchingPressureThicknessOption::KisHatchingPressureThicknessOption()
double KisHatchingPressureThicknessOption::apply(const KisPaintInformation & info) const
{
if (!isChecked()) return 0.5;
return computeValue(info);
return computeSizeLikeValue(info);
}
......@@ -222,7 +222,8 @@ KisDynamicSensorSP KisCurveOption::sensor(DynamicSensorType sensorType, bool act
bool KisCurveOption::isRandom() const
{
return (bool) sensor(FUZZY, true);
return bool(sensor(FUZZY_PER_DAB, true)) ||
bool(sensor(FUZZY_PER_STROKE, true));
}
bool KisCurveOption::isCurveUsed() const
......@@ -326,49 +327,49 @@ void KisCurveOption::setValue(qreal value)
m_value = qBound(m_minValue, value, m_maxValue);
}
double KisCurveOption::computeValue(const KisPaintInformation& info) const
KisCurveOption::ValueComponents KisCurveOption::computeValueComponents(const KisPaintInformation& info) const
{
if (!m_useCurve) {
if (m_separateCurveValue) {
return 1.0;
}
else {
return m_value;
}
}
else {
qreal t = 1.0;
ValueComponents components;
if (m_useCurve) {
QVector<KisDynamicSensorSP> additiveSensors;
Q_FOREACH (KisDynamicSensorSP s, m_sensorMap.values()) {
if (s->isActive()) {
if (!s->isAdditive()) {
t *= s->parameter(info);
if (s->isAdditive()) {
components.additive += s->parameter(info);
components.hasAdditive = true;
} else if (s->isAbsoluteRotation()) {
components.absoluteOffset = s->parameter(info);
components.hasAbsoluteOffset =true;
} else {
// additive sensors should be
// processed in the end
additiveSensors.append(s);
components.scaling *= s->parameter(info);
components.hasScaling = true;
}
}
}
}
// add up addivite sensors to the result
Q_FOREACH (KisDynamicSensorSP s, additiveSensors) {
qreal t0 = t;
Q_UNUSED(t0)
qreal v = s->parameter(info);
if (!m_separateCurveValue) {
components.constant = m_value;
}
t = fmod(t + v, 1.0);
}
components.minSizeLikeValue = m_minValue;
components.maxSizeLikeValue = m_maxValue;
if (m_separateCurveValue) {
return t;
}
else {
return m_minValue + (m_value - m_minValue) * t;
}
}
return components;
}
qreal KisCurveOption::computeSizeLikeValue(const KisPaintInformation& info) const
{
const ValueComponents components = computeValueComponents(info);
return components.sizeLikeValue();
}
qreal KisCurveOption::computeRotationLikeValue(const KisPaintInformation& info, qreal baseValue) const
{
const ValueComponents components = computeValueComponents(info);
return components.rotationLikeValue(baseValue);
}
QList<KisDynamicSensorSP> KisCurveOption::sensors()
......
......@@ -81,11 +81,83 @@ public:
void setCurve(DynamicSensorType sensorType, bool useSameCurve, const KisCubicCurve &curve);
void setValue(qreal value);
struct ValueComponents {
ValueComponents()
: constant(1.0),
scaling(1.0),
additive(0.0),
absoluteOffset(0.0),
hasAbsoluteOffset(false),
hasScaling(false),
hasAdditive(false)
{
}
qreal constant;
qreal scaling;
qreal additive;
qreal absoluteOffset;
bool hasAbsoluteOffset;
bool hasScaling;
bool hasAdditive;
qreal minSizeLikeValue;
qreal maxSizeLikeValue;
qreal rotationLikeValue(qreal baseAngle) const {
const qreal offset =
hasAbsoluteOffset ? absoluteOffset : baseAngle;
const qreal realScalingPart = hasScaling ? KisDynamicSensor::scalingToAdditive(scaling) : 0.0;
const qreal realAdditivePart = hasAdditive ? additive : 0;
return
wrapInRange(
2 * offset + constant * realScalingPart + realAdditivePart,
-1.0, 1.0);
}
qreal sizeLikeValue() const {
const qreal offset =
hasAbsoluteOffset ? absoluteOffset : 1.0;
const qreal realScalingPart = hasScaling ? scaling : 1.0;
const qreal realAdditivePart = hasAdditive ? KisDynamicSensor::additiveToScaling(additive) : 1.0;
return qBound(minSizeLikeValue,
constant * offset * realScalingPart * realAdditivePart,
maxSizeLikeValue);
}
private:
static inline qreal wrapInRange(qreal x, qreal min, qreal max) {
const qreal range = max - min;
x -= min;
if (x < 0.0) {
x = range + fmod(x, range);
}
if (x > range) {
x = fmod(x, range);
}
return x + min;
}
};
/**
* Uses the curves set on the sensors to compute a single
* double value that can control the parameters of a brush.
*
* This value is derives from the falues stored in
* ValuesComponents opject.
*/
double computeValue(const KisPaintInformation& info) const;
ValueComponents computeValueComponents(const KisPaintInformation& info) const;
qreal computeSizeLikeValue(const KisPaintInformation &info) const;
qreal computeRotationLikeValue(const KisPaintInformation& info, qreal baseValue) const;
protected:
......
......@@ -85,8 +85,11 @@ KisDynamicSensorSP KisDynamicSensor::id2Sensor(const KoID& id)
else if (id.id() == TimeId.id()) {
return new KisDynamicSensorTime();
}
else if (id.id() == FuzzyId.id()) {
return new KisDynamicSensorFuzzy();
else if (id.id() == FuzzyPerDabId.id()) {
return new KisDynamicSensorFuzzy(false);
}
else if (id.id() == FuzzyPerStrokeId.id()) {
return new KisDynamicSensorFuzzy(true);
}
else if (id.id() == FadeId.id()) {
return new KisDynamicSensorFade();
......@@ -136,8 +139,11 @@ DynamicSensorType KisDynamicSensor::id2Type(const KoID &id)
else if (id.id() == TimeId.id()) {
return TIME;
}
else if (id.id() == FuzzyId.id()) {
return FUZZY;
else if (id.id() == FuzzyPerDabId.id()) {
return FUZZY_PER_DAB;
}
else if (id.id() == FuzzyPerStrokeId.id()) {
return FUZZY_PER_STROKE;
}
else if (id.id() == FadeId.id()) {
return FADE;
......@@ -154,8 +160,10 @@ DynamicSensorType KisDynamicSensor::id2Type(const KoID &id)
KisDynamicSensorSP KisDynamicSensor::type2Sensor(DynamicSensorType sensorType)
{
switch (sensorType) {
case FUZZY:
return new KisDynamicSensorFuzzy();
case FUZZY_PER_DAB:
return new KisDynamicSensorFuzzy(false);
case FUZZY_PER_STROKE:
return new KisDynamicSensorFuzzy(true);
case SPEED:
return new KisDynamicSensorSpeed();
case FADE:
......@@ -192,7 +200,8 @@ KisDynamicSensorSP KisDynamicSensor::type2Sensor(DynamicSensorType sensorType)
QString KisDynamicSensor::minimumLabel(DynamicSensorType sensorType)
{
switch (sensorType) {
case FUZZY:
case FUZZY_PER_DAB:
case FUZZY_PER_STROKE:
return QString();
case FADE:
return i18n("0");
......@@ -229,7 +238,8 @@ QString KisDynamicSensor::minimumLabel(DynamicSensorType sensorType)
QString KisDynamicSensor::maximumLabel(DynamicSensorType sensorType, int max)
{
switch (sensorType) {
case FUZZY:
case FUZZY_PER_DAB:
case FUZZY_PER_STROKE:
return QString();
case FADE:
if (max < 0)
......@@ -306,7 +316,8 @@ QList<KoID> KisDynamicSensor::sensorsIds()
<< RotationId
<< DistanceId
<< TimeId
<< FuzzyId
<< FuzzyPerDabId
<< FuzzyPerStrokeId
<< FadeId
<< PerspectiveId
<< TangentialPressureId;
......@@ -329,7 +340,8 @@ QList<DynamicSensorType> KisDynamicSensor::sensorsTypes()
<< ROTATION
<< DISTANCE
<< TIME
<< FUZZY
<< FUZZY_PER_DAB
<< FUZZY_PER_STROKE
<< FADE
<< PERSPECTIVE
<< TANGENTIAL_PRESSURE;
......@@ -339,8 +351,10 @@ QList<DynamicSensorType> KisDynamicSensor::sensorsTypes()
QString KisDynamicSensor::id(DynamicSensorType sensorType)
{
switch (sensorType) {
case FUZZY:
case FUZZY_PER_DAB:
return "fuzzy";
case FUZZY_PER_STROKE:
return "fuzzystroke";
case FADE:
return "fade";
case DISTANCE:
......@@ -402,11 +416,15 @@ void KisDynamicSensor::fromXML(const QDomElement& e)
qreal KisDynamicSensor::parameter(const KisPaintInformation& info)
{
qreal val = value(info);
const qreal val = value(info);
if (m_customCurve) {
int offset = qRound(256.0 * qAbs(val));
qreal scaledVal = isAdditive() ? additiveToScaling(val) : val;
int offset = qRound(256.0 * qAbs(scaledVal));
qreal newValue = m_curve.floatTransfer(257)[qBound(0, offset, 256)];
return KisAlgebra2D::copysign(newValue, val);
scaledVal = KisAlgebra2D::copysign(newValue, scaledVal);
return isAdditive() ? scalingToAdditive(scaledVal) : scaledVal;
}
else {
return val;
......@@ -444,6 +462,11 @@ bool KisDynamicSensor::isAdditive() const
return false;
}
bool KisDynamicSensor::isAbsoluteRotation() const
{
return false;
}
void KisDynamicSensor::setActive(bool active)
{
m_active = active;
......
......@@ -37,7 +37,8 @@
class QWidget;
class KisPaintInformation;
const KoID FuzzyId("fuzzy", ki18n("Fuzzy")); ///< generate a random number
const KoID FuzzyPerDabId("fuzzy", ki18n("Fuzzy Dab")); ///< generate a random number
const KoID FuzzyPerStrokeId("fuzzystroke", ki18n("Fuzzy Stroke")); ///< generate a random number
const KoID SpeedId("speed", ki18n("Speed")); ///< generate a number depending on the speed of the cursor
const KoID FadeId("fade", ki18n("Fade")); ///< generate a number that increase every time you call it (e.g. per dab)
const KoID DistanceId("distance", ki18n("Distance")); ///< generate a number that increase with distance
......@@ -66,7 +67,8 @@ class KisDynamicSensor;
typedef KisSharedPtr<KisDynamicSensor> KisDynamicSensorSP;
enum DynamicSensorType {
FUZZY,
FUZZY_PER_DAB,
FUZZY_PER_STROKE,
SPEED,
FADE,
DISTANCE,
......@@ -175,6 +177,7 @@ public:
virtual bool dependsOnCanvasRotation() const;
virtual bool isAdditive() const;
virtual bool isAbsoluteRotation() const;
inline DynamicSensorType sensorType() const { return m_type; }
......@@ -184,6 +187,16 @@ public:
*/
int length() { return m_length; }
public:
static inline qreal scalingToAdditive(qreal x) {
return -1.0 + 2.0 * x;
}
static inline qreal additiveToScaling(qreal x) {
return 0.5 * (1.0 + x);
}
protected:
virtual qreal value(const KisPaintInformation& info) = 0;
......
......@@ -40,7 +40,7 @@ KoColor KisPressureDarkenOption::apply(KisPainter * painter, const KisPaintInfor
KoColor origColor = darkened;
// Darken docs aren't really clear about what exactly the amount param can have as value...
quint32 darkenAmount = (qint32)(255 - 255 * computeValue(info));
quint32 darkenAmount = (qint32)(255 - 255 * computeSizeLikeValue(info));
KoColorTransformation* darkenTransformation = darkened.colorSpace()->createDarkenAdjustment(darkenAmount, false, 0.0);
if (!darkenTransformation) return origColor;
......@@ -55,7 +55,9 @@ void KisPressureDarkenOption::apply(KisColorSource* colorSource, const KisPaintI
{
if (!isChecked()) return;
quint32 darkenAmount = (qint32)(255 - 255 * computeValue(info));
// Darken docs aren't really clear about what exactly the amount param can have as value...
quint32 darkenAmount = (qint32)(255 - 255 * computeSizeLikeValue(info));
KoColorTransformation* darkenTransformation = colorSource->colorSpace()->createDarkenAdjustment(darkenAmount, false, 0.0);
if (!darkenTransformation) return;
colorSource->applyColorTransformation(darkenTransformation);
......