Files
OmaPhoto/tests/SelectionFixtures.h
雷电芽衣andClaude c864304695
Release / deb (push) Canceled after 0s
Release / rpm (push) Canceled after 0s
Release / arch (push) Canceled after 0s
Release / publish (push) Canceled after 0s
OmaPhoto 1.0.0: the Linux port of Compositor
A layered image editor for Linux and Omarchy, ported from Compositor
(github.com/robbietilton/Compositor), whose Swift source is its
specification. It reads and writes Compositor's .comp projects.

Packages for Ubuntu, Fedora and Arch come from the release workflow;
scripts/install/ holds one install script per distribution family,
and flake.nix serves NixOS.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-26 00:44:52 -04:00

55 lines
1.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "SessionFixtures.h"
#include <QtTest>
#include <memory>
// Shared by the selection tests: a session, outlines, coverage.
inline std::unique_ptr<EditorSession> selectionSession(int width = 100, int height = 100)
{
auto session = std::make_unique<EditorSession>();
session->createDocument(width, height, true);
session->selectTool(NavigationTool::lasso);
return session;
}
inline void lasso(EditorSession &session, const std::vector<QPointF> &points, SelectionMode mode = SelectionMode::replace)
{
session.beginLasso(points[0], mode);
for (std::size_t index = 1; index < points.size(); ++index)
session.extendLasso(points[index]);
session.finishLasso();
}
inline std::vector<QPointF> square(double x, double y, double size)
{
return {QPointF(x, y), QPointF(x + size, y), QPointF(x + size, y + size), QPointF(x, y + size)};
}
// Coverage 0–255 at a document pixel.
inline int coverage(const EditorSession &session, int x, int y)
{
const CanvasDocument &document = session.document().value();
const QImage image = session.selection().value().coverage(document.width, document.height);
return image.constScanLine(y)[x];
}
inline QRectF bounds(const EditorSession &session)
{
return session.selection().value().path.boundingRect();
}
// A 100×40 red image, the edit tests' whole layer.
inline ImportedImage filledRed()
{
QImage image(100, 40, QImage::Format_RGBA8888_Premultiplied);
image.fill(Qt::red);
return ImportedImage(image, image, "Red");
}
inline QPainterPath rectPath(const QRectF &rect)
{
QPainterPath path;
path.addRect(rect);
return path;
}