diff --git a/plugins/generators/CMakeLists.txt b/plugins/generators/CMakeLists.txt index 1a560d4b66..8893ded464 100644 --- a/plugins/generators/CMakeLists.txt +++ b/plugins/generators/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(solid) add_subdirectory(pattern) add_subdirectory(simplexnoise) +add_subdirectory(screentone) diff --git a/plugins/generators/screentone/CMakeLists.txt b/plugins/generators/screentone/CMakeLists.txt new file mode 100644 index 0000000000..c583971eca --- /dev/null +++ b/plugins/generators/screentone/CMakeLists.txt @@ -0,0 +1,11 @@ +set(kritascreentonegenerator_SOURCES + screentonegenerator.cpp + kis_wdg_screentone.cpp + ) +ki18n_wrap_ui(kritascreentonegenerator_SOURCES + wdgscreentoneoptions.ui + ) + +add_library(kritascreentonegenerator MODULE ${kritascreentonegenerator_SOURCES}) +target_link_libraries(kritascreentonegenerator kritaui) +install(TARGETS kritascreentonegenerator DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/plugins/generators/screentone/kis_wdg_screentone.cpp b/plugins/generators/screentone/kis_wdg_screentone.cpp new file mode 100644 index 0000000000..6a1ae7494c --- /dev/null +++ b/plugins/generators/screentone/kis_wdg_screentone.cpp @@ -0,0 +1,116 @@ +/* + * KDE. Krita Project. + * + * Copyright (c) 2020 Deif Lou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_wdg_screentone.h" +#include "ui_wdgscreentoneoptions.h" + +#include +#include +#include + +KisWdgScreentone::KisWdgScreentone(KisFilter* /*nfilter*/, QWidget* parent) + : KisConfigWidget(parent), + updateCompressor(250, KisSignalCompressor::Mode::POSTPONE) +{ + m_widget = new Ui_WdgScreentoneOptions(); + m_widget->setupUi(this); + connect(m_widget->m_comboBoxShape, SIGNAL(currentIndexChanged(int)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderSize, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderSoftness, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderHorizontalDisplacement, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderVerticalDisplacement, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderHorizontalSpacing, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderVerticalSpacing, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(m_widget->m_sliderRotation, SIGNAL(valueChanged(qreal)), &updateCompressor, SLOT(start())); + connect(&updateCompressor, SIGNAL(timeout()), this, SIGNAL(sigConfigurationItemChanged())); + m_widget->m_comboBoxShape->addItem(i18n("Dot")); + m_widget->m_comboBoxShape->addItem(i18n("Diamond")); + m_widget->m_comboBoxShape->addItem(i18n("Line")); + m_widget->m_comboBoxShape->addItem(i18n("Wavy Line")); + m_widget->m_sliderSize->setRange(0.0f, 100.0f, 2); + m_widget->m_sliderSize->setValue(50.0f); + m_widget->m_sliderSize->setSuffix(i18n(" %")); + m_widget->m_sliderSoftness->setRange(0.0f, 100.0f, 2); + m_widget->m_sliderSoftness->setValue(50.0f); + m_widget->m_sliderSoftness->setSuffix(i18n(" %")); + m_widget->m_sliderHorizontalDisplacement->setRange(0.0f, 500.0f, 2); + m_widget->m_sliderHorizontalDisplacement->setValue(0.0f); + m_widget->m_sliderHorizontalDisplacement->setSuffix(i18n(" px")); + m_widget->m_sliderVerticalDisplacement->setRange(0.0f, 500.0f, 2); + m_widget->m_sliderVerticalDisplacement->setValue(0.0f); + m_widget->m_sliderVerticalDisplacement->setSuffix(i18n(" px")); + m_widget->m_sliderHorizontalSpacing->setRange(1.0f, 500.0f, 2); + m_widget->m_sliderHorizontalSpacing->setValue(10.0f); + m_widget->m_sliderHorizontalSpacing->setSuffix(i18n(" px")); + m_widget->m_sliderVerticalSpacing->setRange(1.0f, 500.0f, 2); + m_widget->m_sliderVerticalSpacing->setValue(10.0f); + m_widget->m_sliderVerticalSpacing->setSuffix(i18n(" px")); + m_widget->m_sliderRotation->setRange(0.0f, 360.0f, 2); + m_widget->m_sliderRotation->setValue(0.0f); + m_widget->m_sliderRotation->setSuffix(i18n(" %")); +} + +KisWdgScreentone::~KisWdgScreentone() +{ + delete m_widget; +} + +void KisWdgScreentone::setConfiguration(const KisPropertiesConfigurationSP config) +{ + QVariant value; + if (config->getProperty("shape", value)) { + m_widget->m_comboBoxShape->setCurrentIndex(value.toInt()); + } + if (config->getProperty("size", value)) { + m_widget->m_sliderSize->setValue(value.toDouble()); + } + if (config->getProperty("softness", value)) { + m_widget->m_sliderSoftness->setValue(value.toDouble()); + } + if (config->getProperty("horizontal_displacement", value)) { + m_widget->m_sliderHorizontalDisplacement->setValue(value.toDouble()); + } + if (config->getProperty("vertical_displacement", value)) { + m_widget->m_sliderVerticalDisplacement->setValue(value.toDouble()); + } + if (config->getProperty("horizontal_spacing", value)) { + m_widget->m_sliderHorizontalSpacing->setValue(value.toDouble()); + } + if (config->getProperty("vertical_spacing", value)) { + m_widget->m_sliderVerticalSpacing->setValue(value.toDouble()); + } + if (config->getProperty("rotation", value)) { + m_widget->m_sliderRotation->setValue(value.toDouble()); + } +} + +KisPropertiesConfigurationSP KisWdgScreentone::configuration() const +{ + KisFilterConfigurationSP config = new KisFilterConfiguration("screentone", 1, KisGlobalResourcesInterface::instance()); + config->setProperty("shape", m_widget->m_comboBoxShape->currentIndex()); + config->setProperty("size", m_widget->m_sliderSize->value()); + config->setProperty("softness", m_widget->m_sliderSoftness->value()); + config->setProperty("horizontal_displacement", m_widget->m_sliderHorizontalDisplacement->value()); + config->setProperty("vertical_displacement", m_widget->m_sliderVerticalDisplacement->value()); + config->setProperty("horizontal_spacing", m_widget->m_sliderHorizontalSpacing->value()); + config->setProperty("vertical_spacing", m_widget->m_sliderVerticalSpacing->value()); + config->setProperty("rotation", m_widget->m_sliderRotation->value()); + return config; +} diff --git a/plugins/generators/screentone/kis_wdg_screentone.h b/plugins/generators/screentone/kis_wdg_screentone.h new file mode 100644 index 0000000000..0aa115516a --- /dev/null +++ b/plugins/generators/screentone/kis_wdg_screentone.h @@ -0,0 +1,49 @@ +/* + * KDE. Krita Project. + * + * Copyright (c) 2020 Deif Lou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_WDG_SCREENTONE_H +#define KIS_WDG_SCREENTONE_H + +#include +#include + +class Ui_WdgScreentoneOptions; +class KisFilter; + +class KisWdgScreentone : public KisConfigWidget +{ + Q_OBJECT +public: + KisWdgScreentone(KisFilter* nfilter, QWidget* parent = 0); + ~KisWdgScreentone() override; +public: + inline const Ui_WdgScreentoneOptions* widget() const { + return m_widget; + } + void setConfiguration(const KisPropertiesConfigurationSP) override; + KisPropertiesConfigurationSP configuration() const override; + +private: + Ui_WdgScreentoneOptions* m_widget; + KisSignalCompressor updateCompressor; + +}; + +#endif diff --git a/plugins/generators/screentone/kritascreentonegenerator.json b/plugins/generators/screentone/kritascreentonegenerator.json new file mode 100644 index 0000000000..412301b244 --- /dev/null +++ b/plugins/generators/screentone/kritascreentonegenerator.json @@ -0,0 +1,9 @@ +{ + "Id": "Screentone Generator", + "Type": "Service", + "X-KDE-Library": "kritascreentonegenerator", + "X-KDE-ServiceTypes": [ + "Krita/Generator" + ], + "X-Krita-Version": "28" +} diff --git a/plugins/generators/screentone/screentonegenerator.cpp b/plugins/generators/screentone/screentonegenerator.cpp new file mode 100644 index 0000000000..202ae38bde --- /dev/null +++ b/plugins/generators/screentone/screentonegenerator.cpp @@ -0,0 +1,76 @@ +/* + * KDE. Krita Project. + * + * Copyright (c) 2020 Deif Lou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "screentonegenerator.h" +#include "ui_wdgscreentoneoptions.h" +#include "kis_wdg_screentone.h" + +#include +#include +#include +#include +#include +#include + +K_PLUGIN_FACTORY_WITH_JSON(KritaScreentoneGeneratorFactory, "kritascreentonegenerator.json", registerPlugin();) + +KisScreentoneGeneratorHandle::KisScreentoneGeneratorHandle(QObject *parent, const QVariantList &) + : QObject(parent) +{ + KisGeneratorRegistry::instance()->add(new KisScreentoneGenerator()); + +} + +KisScreentoneGeneratorHandle::~KisScreentoneGeneratorHandle() +{ +} + +KisScreentoneGenerator::KisScreentoneGenerator() : KisGenerator(id(), KoID("basic"), i18n("&Screentone...")) +{ + setColorSpaceIndependence(FULLY_INDEPENDENT); + setSupportsPainting(true); +} + +void KisScreentoneGenerator::generate(KisProcessingInformation dst, const QSize &size, const KisFilterConfigurationSP config, KoUpdater *progressUpdater) const +{ +} + +KisFilterConfigurationSP KisScreentoneGenerator::defaultConfiguration(KisResourcesInterfaceSP resourcesInterface) const +{ + KisFilterConfigurationSP config = factoryConfiguration(resourcesInterface); + config->setProperty("shape", 0); + config->setProperty("size", 50.0); + config->setProperty("softness", 50.0); + config->setProperty("horizontal_displacement", 0.0); + config->setProperty("vertical_displacement", 0.0); + config->setProperty("horizontal_spacing", 10.0); + config->setProperty("vertical_spacing", 10.0); + config->setProperty("rotation", 0.0); + return config; +} + +KisConfigWidget * KisScreentoneGenerator::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, bool) const +{ + Q_UNUSED(dev); + return new KisWdgScreentone((KisFilter*)this, (QWidget*)parent); +} + +#include "screentonegenerator.moc" + diff --git a/plugins/generators/screentone/screentonegenerator.h b/plugins/generators/screentone/screentonegenerator.h new file mode 100644 index 0000000000..45e5dd9bae --- /dev/null +++ b/plugins/generators/screentone/screentonegenerator.h @@ -0,0 +1,59 @@ +/* + * KDE. Krita Project. + * + * Copyright (c) 2020 Deif Lou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef SCREENTONEGENERATOR_H +#define SCREENTONEGENERATOR_H + +#include +#include "generator/kis_generator.h" + +class KisConfigWidget; + +class KisScreentoneGeneratorHandle : public QObject +{ + Q_OBJECT +public: + KisScreentoneGeneratorHandle(QObject *parent, const QVariantList &); + ~KisScreentoneGeneratorHandle() override; +}; + +class KisScreentoneGenerator : public KisGenerator +{ +public: + KisScreentoneGenerator(); + + using KisGenerator::generate; + + virtual void generate(KisProcessingInformation dst, + const QSize& size, + const KisFilterConfigurationSP config, + KoUpdater* progressUpdater + ) const override; + + static inline KoID id() { + return KoID("screentone", i18n("Screentone")); + } + + KisFilterConfigurationSP defaultConfiguration(KisResourcesInterfaceSP resourcesInterface) const override; + KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, bool useForMasks) const override; + +}; + +#endif diff --git a/plugins/generators/screentone/wdgscreentoneoptions.ui b/plugins/generators/screentone/wdgscreentoneoptions.ui new file mode 100644 index 0000000000..4970842472 --- /dev/null +++ b/plugins/generators/screentone/wdgscreentoneoptions.ui @@ -0,0 +1,230 @@ + + + WdgScreentoneOptions + + + + 0 + 0 + 459 + 434 + + + + + 0 + 0 + + + + + 0 + 175 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 8 + + + 8 + + + 0 + + + + + Shape: + + + + + + + + 0 + 0 + + + + + + + + Size: + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + Softness: + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + Horizontal Spacing: + + + + + + + + 0 + 0 + + + + + + + + Vertical Spacing: + + + + + + + + 0 + 0 + + + + + + + + Rotation: + + + + + + + Horizontal Displacement: + + + + + + + + 0 + 0 + + + + + + + + Vertical Displacement: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KisDoubleSliderSpinBox + QWidget +
kis_slider_spin_box.h
+ 1 +
+
+ + +