infinipaint/src/DrawingProgram/ScreenshotTool.hpp

69 lines
2.7 KiB
C++
Raw Normal View History

2025-07-06 20:43:53 +03:00
#pragma once
2025-08-02 20:10:33 +03:00
#include "DrawingProgramToolBase.hpp"
2025-07-06 20:43:53 +03:00
#include <Helpers/SCollision.hpp>
#include <filesystem>
#include "../InputManager.hpp"
#include "../CoordSpaceHelper.hpp"
class DrawingProgram;
2025-08-02 20:10:33 +03:00
class ScreenshotTool : public DrawingProgramToolBase {
2025-07-06 20:43:53 +03:00
public:
ScreenshotTool(DrawingProgram& initDrawP);
2025-08-02 20:10:33 +03:00
virtual DrawingProgramToolType get_type() override;
virtual void gui_toolbox() override;
virtual void tool_update() override;
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
2025-08-02 20:39:21 +03:00
virtual void switch_tool(DrawingProgramToolType newTool) override;
2025-08-02 20:10:33 +03:00
virtual bool prevent_undo_or_redo() override;
2025-07-06 20:43:53 +03:00
private:
void commit_rect();
void take_screenshot(const std::filesystem::path& filePath);
void take_screenshot_area_hw(const sk_sp<SkSurface>& surface, SkCanvas* canvas, void* fullImgRawData, const Vector2i& fullImageSize, const Vector2i& sectionImagePos, const Vector2i& sectionImageSize, const Vector2i& canvasSize, bool transparentBackground);
2025-08-23 17:04:53 +03:00
void take_screenshot_svg(SkCanvas* canvas, bool transparentBackground);
2025-07-06 20:43:53 +03:00
//static constexpr std::array<InputManager::SystemCursorType, 8> cursors{
// InputManager::SystemCursorType::SE_RESIZE,
// InputManager::SystemCursorType::S_RESIZE,
// InputManager::SystemCursorType::SW_RESIZE,
// InputManager::SystemCursorType::W_RESIZE,
// InputManager::SystemCursorType::NW_RESIZE,
// InputManager::SystemCursorType::N_RESIZE,
// InputManager::SystemCursorType::NE_RESIZE,
// InputManager::SystemCursorType::E_RESIZE
//};
2025-08-23 17:04:53 +03:00
enum ScreenshotType : size_t {
SCREENSHOT_JPG,
SCREENSHOT_PNG,
SCREENSHOT_WEBP,
SCREENSHOT_SVG
};
2025-07-06 20:43:53 +03:00
struct ScreenshotControls {
CoordSpaceHelper translateBeginCoords;
WorldVec translateBeginPos;
2025-07-06 20:43:53 +03:00
CoordSpaceHelper coords;
float rectX1;
float rectX2;
float rectY1;
float rectY2;
int selectionMode = 0;
int dragType = 0;
Vector2i imageSize = {0, 0};
2025-08-13 15:46:41 +03:00
int setDimensionSize = 1000;
bool setDimensionIsX = true;
2025-07-06 20:43:53 +03:00
std::array<SCollision::Circle<float>, 8> circles;
bool displayGrid = true;
bool transparentBackground = false;
2025-08-23 17:04:53 +03:00
size_t selectedType = SCREENSHOT_JPG;
std::vector<std::string> typeSelections = {".jpg", ".png", ".webp", ".svg"};
2025-07-06 20:43:53 +03:00
std::atomic<bool> setToTakeScreenshot = false;
std::filesystem::path screenshotSavePath;
} controls;
};