#pragma once #include "platform.h" namespace ks { enum class LineStyle { Solid, Dotted, Dashed, DashDot }; enum class LineEnds { End, Start, Both, None }; enum class ScreenshotShape { None, Rectangle, Circle, Ellipse }; struct ScreenshotOffset { double x, y; }; struct ScreenshotMark { POINT from, to; int number; int radius = 15; int thickness = 3; int fromNumber = 0, toNumber = 0; std::vector points; COLORREF color = RGB(225,42,50); bool freehand = false; LineStyle style = LineStyle::Solid; LineEnds ends = LineEnds::End; ScreenshotShape shape = ScreenshotShape::None; std::wstring text, fontName=L"Segoe UI"; int fontSize=24, fontWeight=FW_NORMAL; bool fontItalic=false; double rotation=0; std::wstring label; ScreenshotOffset labelOffset{0,-24}; // Along the line and perpendicular to it, in image pixels. bool labelRotationManual=false; bool isText() const { return !text.empty(); } bool isHighlight() const { return !points.empty() && !freehand; } bool isLine() const { return !number && !isText() && !isHighlight() && shape==ScreenshotShape::None; } }; class ScreenshotHistory { std::deque> past, future; public: void remember(const std::vector &); bool undo(std::vector &); bool redo(std::vector &); bool canUndo() const { return !past.empty(); } bool canRedo() const { return !future.empty(); } }; void resolveScreenshotLinks(std::vector &); void linkScreenshotEndpoint(ScreenshotMark &, bool start, POINT drop, const std::vector &, double tolerance); enum class MarkPart { None, Body, Start, End, Radius, Thickness, Rotation, Label }; POINT screenshotThicknessHandle(const ScreenshotMark &, double clearance = 16); ScreenshotMark cloneScreenshotMark(const ScreenshotMark &, const std::vector &, int width, int height); int nextScreenshotNumber(const std::vector &); MarkPart hitScreenshotMark(const ScreenshotMark &, POINT, double tolerance); ScreenshotMark dragScreenshotMark(const ScreenshotMark &, MarkPart, POINT origin, POINT position, int width, int height, bool snapRotation=false); POINT constrainScreenshotShape(ScreenshotShape, POINT anchor, POINT position, int width, int height); RECT screenshotTextBounds(const ScreenshotMark &); POINT screenshotTextRotationHandle(const ScreenshotMark &, double clearance=24); ScreenshotMark screenshotArrowLabel(const ScreenshotMark &); // Render at source resolution; never reads or writes the system clipboard. Clip screenshotClip(HDC source, int width, int height, const std::vector &marks); }