diff options
Diffstat (limited to 'chalk/plugins/viewplugins/substrate')
10 files changed, 603 insertions, 0 deletions
diff --git a/chalk/plugins/viewplugins/substrate/Makefile.am b/chalk/plugins/viewplugins/substrate/Makefile.am new file mode 100644 index 00000000..5331a04e --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/Makefile.am @@ -0,0 +1,26 @@ +chalkrcdir = $(kde_datadir)/chalkplugins +chalkrc_DATA = substrate.rc + +EXTRA_DIST = $(chalkrc_DATA) + + +INCLUDES = -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../core \ + -I$(srcdir)/../../../chalkcolor/ \ + -I$(srcdir)/../../../ui \ + -I$/../../../ui \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +kde_module_LTLIBRARIES = chalksubstrate.la + +chalksubstrate_la_SOURCES = substrate.cc dlg_substrate.cc wdgsubstrate.ui kis_repeating_substrate.cc +noinst_HEADERS = wdgsubstrate.h dlg_substrate.h kis_repeating_substrate.h substrate.h + +chalksubstrate_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) chalkblurfilter_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -lkdecore -lkdeui -lkjs -lkdefx -lkio -lkparts -L../../../../chalk/chalkcolor/.libs -lchalkcolor -L../../../../chalk/core/.libs -lchalkimage \ + -L../../../../chalk/ui/.libs -lchalkui -L../../../../lib/kofficeui/.libs -lkofficeui +chalksubstrate_la_LIBADD = ../../../libchalkcommon.la + +kde_services_DATA = chalksubstrate.desktop + +METASOURCES = AUTO diff --git a/chalk/plugins/viewplugins/substrate/chalksubstrate.desktop b/chalk/plugins/viewplugins/substrate/chalksubstrate.desktop new file mode 100644 index 00000000..8d8a7f7b --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/chalksubstrate.desktop @@ -0,0 +1,35 @@ +[Desktop Entry] +Name=Substrate +Name[bg]=Основа +Name[ca]=Substrat +Name[da]=Substrat +Name[de]=Träger +Name[el]=Υπόστρωμα +Name[es]=Sustrato +Name[et]=Substraat +Name[fa]=زیربنا +Name[fy]=Substraat +Name[ga]=Foshraith +Name[gl]=Substrato +Name[hu]=Szubsztrát +Name[it]=Substrato +Name[ja]=下地 +Name[nb]=Substrat +Name[nds]=Wassboden +Name[ne]=जीवाधार +Name[nl]=Substraat +Name[pl]=Wycięcie +Name[pt]=Substrato +Name[pt_BR]=Substrato +Name[ru]=Подложка +Name[sk]=Substrát +Name[sl]=Substrat +Name[sr]=Супстрат +Name[sr@Latn]=Supstrat +Name[sv]=Substrat +Name[uk]=Підложка +Name[zh_TW]=基底 +ServiceTypes=Chalk/ViewPlugin +Type=Service +X-KDE-Library=chalksubstrate +X-Chalk-Version=2 diff --git a/chalk/plugins/viewplugins/substrate/dlg_substrate.cc b/chalk/plugins/viewplugins/substrate/dlg_substrate.cc new file mode 100644 index 00000000..dcecce48 --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/dlg_substrate.cc @@ -0,0 +1,59 @@ +/* + * dlg_substrate.cc - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> + * + * 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 <klocale.h> + +#include "dlg_substrate.h" +#include "wdgsubstrate.h" + + +DlgSubstrate::DlgSubstrate( TQWidget * tqparent, + const char * name) + : super (tqparent, name, true, i18n("Color Range"), Ok | Cancel, Ok) +{ + m_previewPix = TQPixmap(); + m_page = new WdgSubstrate(this, "substrate"); + Q_CHECK_PTR(m_page); + setCaption(i18n("Substrate")); + setMainWidget(m_page); + resize(m_page -> size()); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); +} + +DlgSubstrate::~DlgSubstrate() +{ + delete m_page; +} + +void DlgSubstrate::setPixmap(TQPixmap pix) +{ + m_previewPix = pix; + m_previewPix.detach(); +} + +void DlgSubstrate::okClicked() +{ + accept(); +} + +#include "dlg_substrate.moc" + diff --git a/chalk/plugins/viewplugins/substrate/dlg_substrate.h b/chalk/plugins/viewplugins/substrate/dlg_substrate.h new file mode 100644 index 00000000..82051ad3 --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/dlg_substrate.h @@ -0,0 +1,62 @@ +/* + * dlg_substrate.h -- part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> + * + * 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 DLG_SUBSTRATE +#define DLG_SUBSTRATE + +#include <tqpixmap.h> + +#include <kdialogbase.h> + +#include "wdgsubstrate.h" + + +/** + * This dialog allows the user to modify a layer or a selection + * by adding more colour in a particular channel or lighten or + * darken an image. + */ +class DlgSubstrate: public KDialogBase { + + typedef KDialogBase super; + Q_OBJECT + TQ_OBJECT + +public: + + DlgSubstrate(TQWidget * tqparent = 0, + const char* name = 0); + ~DlgSubstrate(); + + /** + * Set the initial preview pixmap + */ + void setPixmap(TQPixmap pix); + +private slots: + + void okClicked(); + +private: + + WdgSubstrate * m_page; + TQPixmap m_previewPix; +}; + +#endif // DLG_SUBSTRATE diff --git a/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cc b/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cc new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cc diff --git a/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.h b/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.h new file mode 100644 index 00000000..1a229dc1 --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org) + * + * 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_SUBSTRATE_H +#define KIS_SUBSTRATE_H + +#include <tqrect.h> +#include <ksharedptr.h> + +class KisImage; + +/// All values are normalized to a range between 0 and 1. +/// XXX: Do we need more? +struct KisSubstratePixel { + float height; // absolute height of the current position + float smoothness; // determines how easily the painting tool "slips" over the surface + float absorbency; // determines how much wetness the substrate can absorb. XXX: How about speed of absorbing? + float r; //.Red component of reflectivity + float g; // Green component of reflectivity + float b; // Blue component of reflectivity + float transmittance; // Similar to alpha. XXX: Ask Leonardo about this. +}; + +/** + * This abstract class defines the properties of a substrate -- that is, the simulation + * of the paper or canvas for natural media. + * + * Subclass this interface to define a specific type of substrate: repeating, + * or full-size, with specific and cool ways of generating the surface, or + * maybe based on scans of real substrates. + */ +class KisSubstrate : public KShared { + +public: + + KisSubstrate(KisImage * /*img*/) : KShared() {}; + virtual ~KisSubstrate() {}; + + + /** + * Copy the pixel values in the specified rect into an array of Substrate. + * Make sure the array is big enough! + */ + virtual void getPixels(KisSubstratePixel * /*substrate*/, const TQRect & /*rc*/) = 0; + + /** + * Return a pointer to the substrate at the specified position. Note that + * you cannot do pointe arithmetic with this value: the position of the + * neighbouring pixels cannot be determined from this value + */ + virtual KisSubstratePixel * getPixel(uint x, uint y) = 0; + +}; + +#endif diff --git a/chalk/plugins/viewplugins/substrate/substrate.cc b/chalk/plugins/viewplugins/substrate/substrate.cc new file mode 100644 index 00000000..8aa4d32e --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/substrate.cc @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org) + * + * 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 <math.h> + +#include <stdlib.h> + +#include <tqslider.h> +#include <tqpoint.h> + +#include <klocale.h> +#include <kiconloader.h> +#include <kinstance.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <ktempfile.h> +#include <kdebug.h> +#include <kgenericfactory.h> + +#include <kis_doc.h> +#include <kis_image.h> +#include <kis_layer.h> +#include <kis_global.h> +#include <kis_types.h> +#include <kis_view.h> + +#include "substrate.h" +#include "dlg_substrate.h" + +typedef KGenericFactory<SubstratePlugin> SubstrateFactory; +K_EXPORT_COMPONENT_FACTORY( chalksubstrate, SubstrateFactory( "chalk" ) ) + +SubstratePlugin::SubstratePlugin(TQObject *tqparent, const char *name, const TQStringList &) + : KParts::Plugin(tqparent, name) +{ + + if ( tqparent->inherits("KisView") ) + { + setInstance(SubstrateFactory::instance()); + setXMLFile(locate("data","chalkplugins/substrate.rc"), true); + + (void) new KAction(i18n("&Substrate..."), 0, 0, this, TQT_SLOT(slotSubstrateActivated()), actionCollection(), "substrate"); + + m_view = (KisView*) tqparent; + } +} + +SubstratePlugin::~SubstratePlugin() +{ +} + +void SubstratePlugin::slotSubstrateActivated() +{ + DlgSubstrate * dlgSubstrate = new DlgSubstrate(m_view, "Substrate"); + Q_CHECK_PTR(dlgSubstrate); + if (dlgSubstrate -> exec() == TQDialog::Accepted) { + // Retrieve changes made by dialog + // Apply changes to layer (selection) + } + delete dlgSubstrate; +} + +#include "substrate.moc" + diff --git a/chalk/plugins/viewplugins/substrate/substrate.h b/chalk/plugins/viewplugins/substrate/substrate.h new file mode 100644 index 00000000..409a00f3 --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/substrate.h @@ -0,0 +1,45 @@ +/* + * substrate.h -- Part of Chalk + * + * Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org) + * + * 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 SUBSTATE_H +#define SUBSTATE_H + +#include <kparts/plugin.h> + +class KisView; + +class SubstratePlugin : public KParts::Plugin +{ + Q_OBJECT + TQ_OBJECT +public: + SubstratePlugin(TQObject *tqparent, const char *name, const TQStringList &); + virtual ~SubstratePlugin(); + +private slots: + void slotSubstrateActivated(); + +private: + KisView * m_view; + KisPainter * m_painter; + +}; + +#endif // SUBSTATE_H diff --git a/chalk/plugins/viewplugins/substrate/substrate.rc b/chalk/plugins/viewplugins/substrate/substrate.rc new file mode 100644 index 00000000..cf8b8537 --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/substrate.rc @@ -0,0 +1,8 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui library="chalksubstrate" version="1"> +<MenuBar> + <Menu name="Image"><text>Image</text> + <Action name="substrate"/> + </Menu> +</MenuBar> +</kpartgui> diff --git a/chalk/plugins/viewplugins/substrate/wdgsubstrate.ui b/chalk/plugins/viewplugins/substrate/wdgsubstrate.ui new file mode 100644 index 00000000..be0713ed --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/wdgsubstrate.ui @@ -0,0 +1,221 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>WdgSubstrate</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>478</width> + <height>358</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>grpCustom</cstring> + </property> + <property name="title"> + <string>Custom Canvas Definition</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>tqlayout3</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQComboBox" row="0" column="1" rowspan="1" colspan="2"> + <item> + <property name="text"> + <string>Custom</string> + </property> + </item> + <property name="name"> + <cstring>cmbPredefinedCanvases</cstring> + </property> + </widget> + <widget class="KColorButton" row="2" column="2"> + <property name="name"> + <cstring>bnBackground</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Save custom substrate as:</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>lblPredefined</cstring> + </property> + <property name="text"> + <string>&Pre-defined canvas types:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>cmbPredefinedCanvases</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>lblColor</cstring> + </property> + <property name="text"> + <string>&Basic color:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>bnBackground</cstring> + </property> + </widget> + <widget class="TQLineEdit" row="1" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>lineEdit1</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>tqlayout2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQSlider" row="3" column="1"> + <property name="name"> + <cstring>slAbsorbency</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="TQSlider" row="2" column="1"> + <property name="name"> + <cstring>slFiber</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="TQLabel" row="1" column="2"> + <property name="name"> + <cstring>textLabel9</cstring> + </property> + <property name="text"> + <string>Grainy</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>lblSmoothness</cstring> + </property> + <property name="text"> + <string>&Smooth:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>slSlippery</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>lblAbsorbency</cstring> + </property> + <property name="text"> + <string>&Water repellant:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>slAbsorbency</cstring> + </property> + </widget> + <widget class="TQSlider" row="0" column="1"> + <property name="name"> + <cstring>slSlippery</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>lblHeight</cstring> + </property> + <property name="text"> + <string>&Flat:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>slHeight</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>lblFiber</cstring> + </property> + <property name="text"> + <string>Fine &fiber:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>slFiber</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="2"> + <property name="name"> + <cstring>lblRough</cstring> + </property> + <property name="text"> + <string>Rough</string> + </property> + </widget> + <widget class="TQSlider" row="1" column="1"> + <property name="name"> + <cstring>slHeight</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="TQLabel" row="3" column="2"> + <property name="name"> + <cstring>textLabel11</cstring> + </property> + <property name="text"> + <string>Absorbent</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="2"> + <property name="name"> + <cstring>textLabel10</cstring> + </property> + <property name="text"> + <string>Coarse</string> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<tqlayoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kcolorbutton.h</includehint> +</includehints> +</UI> |