...
 
Commits (6)
......@@ -114,6 +114,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<text>&amp;Snap To</text>
<Action name="view_snap_to_guides"/>
<Action name="view_snap_to_grid"/>
<Action name="view_snap_to_pixel"/>
<Action name="view_snap_orthogonal" />
<Action name="view_snap_node" />
<Action name="view_snap_extension" />
......
......@@ -866,6 +866,17 @@
<statusTip></statusTip>
</Action>
<Action name="view_snap_to_pixel">
<icon></icon>
<text>Snap Pixel</text>
<whatsThis></whatsThis>
<toolTip>Snap Pixel</toolTip>
<iconText>Snap Pixel</iconText>
<activationFlags>1000</activationFlags>
<shortcut></shortcut>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="view_snap_intersection">
<icon></icon>
<text>Snap Intersection</text>
......
......@@ -407,7 +407,7 @@ extern "C" int main(int argc, char **argv)
if (singleApplication && app.isRunning()) {
// only pass arguments to main instance if they are not for batch processing
// any batch processing would be done in this separate instance
const bool batchRun = args.exportAs();
const bool batchRun = args.exportAs() || args.exportSequence();
if (!batchRun) {
QByteArray ba = args.serialize();
......
......@@ -69,7 +69,8 @@ public:
GuideLineSnapping = 0x40,
DocumentBoundsSnapping = 0x80,
DocumentCenterSnapping = 0x100,
CustomSnapping = 0x200
CustomSnapping = 0x200,
PixelSnapping = 0x400
};
Q_DECLARE_FLAGS(Strategies, Strategy)
......
......@@ -43,6 +43,7 @@ set(kritaui_LIB_SRCS
canvas/kis_snap_config.cpp
canvas/kis_snap_line_strategy.cpp
canvas/KisSnapPointStrategy.cpp
canvas/KisSnapPixelStrategy.cpp
canvas/KisMirrorAxisConfig.cpp
dialogs/kis_about_application.cpp
dialogs/kis_dlg_adj_layer_props.cc
......
/*
* Copyright (c) 2019 Kuntal Majumder <hellozee@disroot.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 "KisSnapPixelStrategy.h"
#include <QPainterPath>
#include "kis_global.h"
#include "kis_canvas2.h"
#include "KoSnapProxy.h"
KisSnapPixelStrategy::KisSnapPixelStrategy(KoSnapGuide::Strategy type):
KoSnapStrategy(type)
{
}
KisSnapPixelStrategy::~KisSnapPixelStrategy()
{
}
bool KisSnapPixelStrategy::snap(const QPointF &mousePosition, KoSnapProxy *proxy, qreal maxSnapDistance)
{
Q_UNUSED(maxSnapDistance);
KisCanvas2 *canvas2 = dynamic_cast<KisCanvas2*>(proxy->canvas());
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(canvas2, false);
const QPointF imagePos = canvas2->coordinatesConverter()->documentToImage(mousePosition);
const QPointF alignedDocPoint = canvas2->coordinatesConverter()->imageToDocument(imagePos.toPoint());
setSnappedPosition(alignedDocPoint);
return true;
}
QPainterPath KisSnapPixelStrategy::decoration(const KoViewConverter &converter) const
{
QSizeF unzoomedSize = converter.viewToDocument(QSizeF(5, 5));
QPainterPath decoration;
decoration.moveTo(snappedPosition() - QPointF(unzoomedSize.width(), 0));
decoration.lineTo(snappedPosition() + QPointF(unzoomedSize.width(), 0));
decoration.moveTo(snappedPosition() - QPointF(0, unzoomedSize.height()));
decoration.lineTo(snappedPosition() + QPointF(0, unzoomedSize.height()));
return decoration;
}
/*
* Copyright (c) 2019 Kuntal Majumder <hellozee@disroot.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_SNAP_PIXEL_STRATEGY_H
#define __KIS_SNAP_PIXEL_STRATEGY_H
#include <QScopedPointer>
#include "KoSnapStrategy.h"
class KisSnapPixelStrategy : public KoSnapStrategy
{
public:
KisSnapPixelStrategy(KoSnapGuide::Strategy type = KoSnapGuide::PixelSnapping);
~KisSnapPixelStrategy() override;
bool snap(const QPointF &mousePosition, KoSnapProxy * proxy, qreal maxSnapDistance) override;
QPainterPath decoration(const KoViewConverter &converter) const override;
};
#endif /* __KIS_SNAP_PIXEL_STRATEGY_H */
......@@ -97,6 +97,8 @@
#include "kis_algebra_2d.h"
#include "kis_image_signal_router.h"
#include "KisSnapPixelStrategy.h"
class Q_DECL_HIDDEN KisCanvas2::KisCanvas2Private
{
......@@ -207,6 +209,7 @@ KisCanvas2::KisCanvas2(KisCoordinatesConverter *coordConverter, KoCanvasResource
m_d->frameRenderStartCompressor.setDelay(1000 / config.fpsLimit());
m_d->frameRenderStartCompressor.setMode(KisSignalCompressor::FIRST_ACTIVE);
snapGuide()->overrideSnapStrategy(KoSnapGuide::PixelSnapping, new KisSnapPixelStrategy());
}
void KisCanvas2::setup()
......
......@@ -211,6 +211,7 @@ void KisGuidesManager::syncActionsStatus()
m_d->syncAction("view_snap_bounding_box", m_d->snapConfig.boundingBox());
m_d->syncAction("view_snap_image_bounds", m_d->snapConfig.imageBounds());
m_d->syncAction("view_snap_image_center", m_d->snapConfig.imageCenter());
m_d->syncAction("view_snap_to_pixel",m_d->snapConfig.toPixel());
}
void KisGuidesManager::Private::updateSnappingStatus(const KisGuidesConfig &value)
......@@ -236,6 +237,7 @@ void KisGuidesManager::Private::updateSnappingStatus(const KisGuidesConfig &valu
snapGuide->enableSnapStrategy(KoSnapGuide::BoundingBoxSnapping, snapConfig.boundingBox());
snapGuide->enableSnapStrategy(KoSnapGuide::DocumentBoundsSnapping, snapConfig.imageBounds());
snapGuide->enableSnapStrategy(KoSnapGuide::DocumentCenterSnapping, snapConfig.imageCenter());
snapGuide->enableSnapStrategy(KoSnapGuide::PixelSnapping, snapConfig.toPixel());
snapConfig.saveStaticData();
}
......@@ -332,6 +334,9 @@ void KisGuidesManager::setup(KisActionManager *actionManager)
action = actionManager->createAction("view_snap_image_center");
connect(action, SIGNAL(toggled(bool)), this, SLOT(setSnapImageCenter(bool)));
action = actionManager->createAction("view_snap_to_pixel");
connect(action, SIGNAL(toggled(bool)), this, SLOT(setSnapToPixel(bool)));
m_d->updateSnappingStatus(m_d->guidesConfig);
syncActionsStatus();
}
......@@ -746,6 +751,7 @@ void KisGuidesManager::slotShowSnapOptions()
menu.addSection(i18n("Snap to:"));
menu.addAction(m_d->createShortenedAction(i18n("Grid"), "view_snap_to_grid", &menu));
menu.addAction(m_d->createShortenedAction(i18n("Guides"), "view_snap_to_guides", &menu));
menu.addAction(m_d->createShortenedAction(i18n("Pixel"), "view_snap_to_pixel", &menu));
menu.addAction(m_d->createShortenedAction(i18n("Orthogonal"), "view_snap_orthogonal", &menu));
menu.addAction(m_d->createShortenedAction(i18n("Node"), "view_snap_node", &menu));
......@@ -800,3 +806,9 @@ void KisGuidesManager::setSnapImageCenter(bool value)
m_d->snapConfig.setImageCenter(value);
m_d->updateSnappingStatus(m_d->guidesConfig);
}
void KisGuidesManager::setSnapToPixel(bool value)
{
m_d->snapConfig.setToPixel(value);
m_d->updateSnappingStatus(m_d->guidesConfig);
}
......@@ -74,6 +74,7 @@ public Q_SLOTS:
void setSnapBoundingBox(bool value);
void setSnapImageBounds(bool value);
void setSnapImageCenter(bool value);
void setSnapToPixel(bool value);
void slotUploadConfigToDocument();
......
......@@ -27,7 +27,8 @@ KisSnapConfig::KisSnapConfig(bool loadValues)
m_intersection(false),
m_boundingBox(false),
m_imageBounds(true),
m_imageCenter(true)
m_imageCenter(true),
m_toPixel(false)
{
if (loadValues) {
loadStaticData();
......
......@@ -75,6 +75,13 @@ public:
m_imageCenter = value;
}
bool toPixel() const {
return m_toPixel;
}
void setToPixel(bool value) {
m_toPixel = value;
}
void saveStaticData() const;
void loadStaticData();
......@@ -86,6 +93,7 @@ private:
bool m_boundingBox;
bool m_imageBounds;
bool m_imageCenter;
bool m_toPixel;
};
#endif /* __KIS_SNAP_CONFIG_H */
......@@ -853,6 +853,7 @@ void KisConfig::loadSnapConfig(KisSnapConfig *config, bool defaultValue) const
config->setBoundingBox(m_cfg.readEntry("globalSnapBoundingBox", defaultConfig.boundingBox()));
config->setImageBounds(m_cfg.readEntry("globalSnapImageBounds", defaultConfig.imageBounds()));
config->setImageCenter(m_cfg.readEntry("globalSnapImageCenter", defaultConfig.imageCenter()));
config->setToPixel(m_cfg.readEntry("globalSnapToPixel", defaultConfig.toPixel()));
}
void KisConfig::saveSnapConfig(const KisSnapConfig &config)
......@@ -864,6 +865,7 @@ void KisConfig::saveSnapConfig(const KisSnapConfig &config)
m_cfg.writeEntry("globalSnapBoundingBox", config.boundingBox());
m_cfg.writeEntry("globalSnapImageBounds", config.imageBounds());
m_cfg.writeEntry("globalSnapImageCenter", config.imageCenter());
m_cfg.writeEntry("globalSnapToPixel", config.toPixel());
}
qint32 KisConfig::checkSize(bool defaultValue) const
......
......@@ -302,8 +302,13 @@ bool QGIFLibHandler::write ( const QImage & image )
qWarning("EGifPutImageDesc returned error %d", gif->Error);
int lc = toWrite.height();
int llen = toWrite.bytesPerLine();
// NOTE: we suppose that the pixel size is exactly 1 byte, right now we
// cannot save anything else
int llen = toWrite.width();
// qDebug("will write %d lines, %d bytes each", lc, llen);
for (int l = 0; l < lc; ++l)
{
uchar* line = toWrite.scanLine(l);
......@@ -315,6 +320,7 @@ bool QGIFLibHandler::write ( const QImage & image )
}
EGifCloseFile(gif, &err);
free(colorValues);
return true;
}
......
......@@ -37,6 +37,7 @@
#include <kis_paint_layer.h>
#include <kis_paint_device.h>
#include <kis_config.h>
#include "kis_layer_utils.h"
#include "kis_tiff_converter.h"
#include "kis_dlg_options_tiff.h"
......@@ -70,6 +71,15 @@ KisImportExportFilter::ConversionStatus KisTIFFExport::convert(KisDocument *docu
KisTIFFOptions options;
options.fromProperties(configuration);
if (!options.flatten) {
const bool hasGroupLayers =
KisLayerUtils::recursiveFindNode(document->savingImage()->root(),
[] (KisNodeSP node) {
return node->parent() && node->inherits("KisGroupLayer");
});
options.flatten = hasGroupLayers;
}
if ((cs->channels()[0]->channelValueType() == KoChannelInfo::FLOAT16
|| cs->channels()[0]->channelValueType() == KoChannelInfo::FLOAT32) && options.predictor == 2) {
// FIXME THIS IS AN HACK FIX THAT IN 2.0 !! (62456a7b47636548c6507593df3e2bdf440f7544, BUG:135649)
......@@ -112,7 +122,6 @@ KisConfigWidget *KisTIFFExport::createConfigurationWidget(QWidget *parent, const
void KisTIFFExport::initializeCapabilities()
{
addCapability(KisExportCheckRegistry::instance()->get("NodeTypeCheck/KisGroupLayer")->create(KisExportCheckBase::UNSUPPORTED));
addCapability(KisExportCheckRegistry::instance()->get("MultiLayerCheck")->create(KisExportCheckBase::SUPPORTED));
addCapability(KisExportCheckRegistry::instance()->get("sRGBProfileCheck")->create(KisExportCheckBase::SUPPORTED));
......
......@@ -411,7 +411,6 @@ ToolTransformArgs ToolTransformArgs::fromXML(const QDomElement &e)
KisDomUtils::loadValue(freeEl, "transformedCenter", &args.m_transformedCenter) &&
KisDomUtils::loadValue(freeEl, "originalCenter", &args.m_originalCenter) &&
KisDomUtils::loadValue(freeEl, "rotationCenterOffset", &args.m_rotationCenterOffset) &&
KisDomUtils::loadValue(freeEl, "transformAroundRotationCenter", &args.m_transformAroundRotationCenter) &&
KisDomUtils::loadValue(freeEl, "aX", &args.m_aX) &&
KisDomUtils::loadValue(freeEl, "aY", &args.m_aY) &&
......@@ -427,9 +426,14 @@ ToolTransformArgs ToolTransformArgs::fromXML(const QDomElement &e)
KisDomUtils::loadValue(freeEl, "keepAspectRatio", &args.m_keepAspectRatio) &&
KisDomUtils::loadValue(freeEl, "flattenedPerspectiveTransform", &args.m_flattenedPerspectiveTransform) &&
KisDomUtils::loadValue(freeEl, "filterId", &filterId);
// transformAroundRotationCenter is a new parameter introduced in Krita 4.0,
// so it might be not present in older transform masks
if (!KisDomUtils::loadValue(freeEl, "transformAroundRotationCenter", &args.m_transformAroundRotationCenter)) {
args.m_transformAroundRotationCenter = false;
}
if (result) {
args.m_filter = KisFilterStrategyRegistry::instance()->value(filterId);
result = (bool) args.m_filter;
......@@ -452,9 +456,12 @@ ToolTransformArgs ToolTransformArgs::fromXML(const QDomElement &e)
KisDomUtils::loadValue(warpEl, "alpha", &args.m_alpha);
if(args.m_mode == CAGE){
result = result &&
KisDomUtils::loadValue(warpEl, "pixelPrecision", &args.m_pixelPrecision) &&
KisDomUtils::loadValue(warpEl, "previewPixelPrecision", &args.m_previewPixelPrecision);
// Pixel precision is a parameter introduced in Krita 4.2, so we should
// expect it not being present in older files. In case it is not found,
// just use the defalt value initialized by c-tor (that is, do nothing).
(void) KisDomUtils::loadValue(warpEl, "pixelPrecision", &args.m_pixelPrecision);
(void) KisDomUtils::loadValue(warpEl, "previewPixelPrecision", &args.m_previewPixelPrecision);
}
if (result && warpType >= 0 && warpType < KisWarpTransformWorker::N_MODES) {
......@@ -475,7 +482,7 @@ ToolTransformArgs ToolTransformArgs::fromXML(const QDomElement &e)
KIS_ASSERT_RECOVER_NOOP(0 && "Unknown transform mode");
}
if (!result) {
KIS_SAFE_ASSERT_RECOVER(result) {
args = ToolTransformArgs();
}
......