2025-07-06 20:43:53 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include "../DrawData.hpp"
|
2025-07-19 15:57:09 +03:00
|
|
|
#include "DrawingProgramCache.hpp"
|
2026-01-29 11:48:08 +03:00
|
|
|
#include "ToolConfiguration.hpp"
|
2025-12-26 10:40:58 +03:00
|
|
|
#include "Tools/GridModifyTool.hpp"
|
2025-12-11 16:05:41 +03:00
|
|
|
#include <Helpers/NetworkingObjects/NetObjWeakPtr.hpp>
|
2025-12-26 10:40:58 +03:00
|
|
|
#include "Tools/PanCanvasTool.hpp"
|
|
|
|
|
#include "Tools/ZoomCanvasTool.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
#include "cereal/archives/portable_binary.hpp"
|
|
|
|
|
#include <include/core/SkCanvas.h>
|
|
|
|
|
#include <include/core/SkPath.h>
|
|
|
|
|
#include <include/core/SkVertices.h>
|
|
|
|
|
#include <Helpers/SCollision.hpp>
|
|
|
|
|
#include <Helpers/Hashes.hpp>
|
|
|
|
|
#include <Helpers/Random.hpp>
|
2025-12-26 10:40:58 +03:00
|
|
|
#include "Tools/DrawingProgramToolBase.hpp"
|
2025-10-09 16:16:39 +03:00
|
|
|
#include <Helpers/FileDownloader.hpp>
|
2025-12-14 18:57:40 +03:00
|
|
|
#include <Helpers/NetworkingObjects/NetObjOrderedList.hpp>
|
2025-12-25 17:18:28 +03:00
|
|
|
#include "Layers/DrawingProgramLayerManager.hpp"
|
2025-12-29 15:04:32 +03:00
|
|
|
#include "DrawingProgramSelection.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
class World;
|
|
|
|
|
|
|
|
|
|
class DrawingProgram {
|
|
|
|
|
public:
|
|
|
|
|
DrawingProgram(World& initWorld);
|
2026-01-01 22:46:02 +03:00
|
|
|
void server_init_no_file();
|
2025-07-06 20:43:53 +03:00
|
|
|
void toolbar_gui();
|
2026-04-02 12:46:16 +03:00
|
|
|
void right_click_popup_gui();
|
2025-07-06 20:43:53 +03:00
|
|
|
void tool_options_gui();
|
2026-03-29 20:23:38 +03:00
|
|
|
void right_click_popup_gui(Vector2f popupPos);
|
2025-07-06 20:43:53 +03:00
|
|
|
void update();
|
2025-09-30 11:45:03 +03:00
|
|
|
void scale_up(const WorldScalar& scaleUpAmount);
|
2025-07-06 20:43:53 +03:00
|
|
|
void draw(SkCanvas* canvas, const DrawData& drawData);
|
2025-12-15 16:49:51 +03:00
|
|
|
void write_components_server(cereal::PortableBinaryOutputArchive& a);
|
|
|
|
|
void read_components_client(cereal::PortableBinaryInputArchive& a);
|
2025-12-31 11:42:16 +03:00
|
|
|
void init_server_callbacks();
|
|
|
|
|
void init_client_callbacks();
|
2025-12-16 12:54:12 +03:00
|
|
|
void add_file_to_canvas_by_path(const std::filesystem::path& filePath, Vector2f dropPos, bool addInSameThread);
|
2026-01-06 19:06:44 +03:00
|
|
|
CanvasComponentContainer::ObjInfo* add_file_to_canvas_by_data(const std::string& fileName, std::string_view fileBuffer, Vector2f dropPos);
|
2026-01-01 23:28:26 +03:00
|
|
|
void get_used_resources(std::unordered_set<NetworkingObjects::NetObjID>& resourceSet);
|
2025-12-16 12:54:12 +03:00
|
|
|
|
2025-12-14 18:57:40 +03:00
|
|
|
void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version);
|
2025-11-16 16:39:12 +03:00
|
|
|
void save_file(cereal::PortableBinaryOutputArchive& a) const;
|
2025-07-06 20:43:53 +03:00
|
|
|
World& world;
|
|
|
|
|
|
2025-07-27 16:53:22 +03:00
|
|
|
bool prevent_undo_or_redo();
|
2025-07-19 15:57:09 +03:00
|
|
|
|
2025-12-28 17:34:33 +03:00
|
|
|
DrawingProgramCache drawCache;
|
2025-12-25 17:18:28 +03:00
|
|
|
DrawingProgramLayerManager layerMan;
|
2025-07-20 15:24:44 +03:00
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
Vector4f* get_foreground_color_ptr();
|
2025-09-29 15:15:16 +03:00
|
|
|
void switch_to_tool(DrawingProgramToolType newToolType, bool force = false);
|
2025-08-02 21:14:57 +03:00
|
|
|
void switch_to_tool_ptr(std::unique_ptr<DrawingProgramToolBase> newTool);
|
2025-12-11 16:05:41 +03:00
|
|
|
void modify_grid(const NetworkingObjects::NetObjWeakPtr<WorldGrid>& gridToModify);
|
2025-09-28 11:59:08 +03:00
|
|
|
|
2025-12-30 19:46:08 +03:00
|
|
|
void invalidate_cache_at_component(CanvasComponentContainer::ObjInfo* objToCheck);
|
|
|
|
|
void preupdate_component(CanvasComponentContainer::ObjInfo* objToCheck);
|
2025-12-31 11:42:16 +03:00
|
|
|
void send_transforms_for(const std::vector<CanvasComponentContainer::ObjInfo*>& objsToSendTransformsFor);
|
2026-02-28 22:47:35 +03:00
|
|
|
|
2026-03-02 16:36:34 +03:00
|
|
|
void on_tab_out();
|
2026-03-04 11:03:05 +03:00
|
|
|
void input_drop_text_callback(const InputManager::DropCallbackArgs& drop);
|
|
|
|
|
void input_drop_file_callback(const InputManager::DropCallbackArgs& drop);
|
2026-03-02 16:36:34 +03:00
|
|
|
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
|
|
|
|
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
|
|
|
|
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
2026-03-03 16:01:21 +03:00
|
|
|
void input_pure_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
|
|
|
|
void input_pure_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
|
|
|
|
void input_pen_button_callback(const InputManager::PenButtonCallbackArgs& button);
|
|
|
|
|
void input_pen_touch_callback(const InputManager::PenTouchCallbackArgs& touch);
|
|
|
|
|
void input_pen_motion_callback(const InputManager::PenMotionCallbackArgs& motion);
|
|
|
|
|
void input_pen_axis_callback(const InputManager::PenAxisCallbackArgs& axis);
|
2026-04-02 13:45:46 +03:00
|
|
|
|
|
|
|
|
void set_right_click_popup_location(const Vector2f& newLoc);
|
|
|
|
|
void clear_right_click_popup();
|
2025-07-06 20:43:53 +03:00
|
|
|
private:
|
2025-12-31 11:42:16 +03:00
|
|
|
void process_transform_message(const std::vector<std::pair<NetworkingObjects::NetObjID, CoordSpaceHelper>>& transforms);
|
|
|
|
|
|
2025-12-16 12:54:12 +03:00
|
|
|
void drag_drop_update();
|
|
|
|
|
void add_file_to_canvas_by_path_execute(const std::filesystem::path& filePath, Vector2f dropPos);
|
|
|
|
|
void check_updateable_components();
|
|
|
|
|
void update_downloading_dropped_files();
|
|
|
|
|
|
2026-03-29 20:23:38 +03:00
|
|
|
void selection_action_menu(Vector2f popupPos);
|
|
|
|
|
void popup_menu_action_button(const char* id, const char* text, const std::function<void()>& onClick);
|
2025-12-28 17:34:33 +03:00
|
|
|
void rebuild_cache();
|
2025-07-26 21:20:14 +03:00
|
|
|
|
2025-07-10 22:09:56 +03:00
|
|
|
std::atomic<bool> addFileInNextFrame = false;
|
2025-11-21 10:03:11 +03:00
|
|
|
std::pair<std::filesystem::path, Vector2f> addFileInfo;
|
2025-07-10 22:09:56 +03:00
|
|
|
|
2025-11-23 15:02:02 +03:00
|
|
|
float drag_point_radius();
|
2025-07-06 20:43:53 +03:00
|
|
|
void draw_drag_circle(SkCanvas* canvas, const Vector2f& pos, const SkColor4f& c, const DrawData& drawData, float radiusMultiplier = 1.0f);
|
2026-03-20 20:53:59 +03:00
|
|
|
SkPaint select_tool_line_paint(const DrawData& drawData);
|
2025-12-14 18:57:40 +03:00
|
|
|
bool is_actual_selection_tool(DrawingProgramToolType typeToCheck);
|
|
|
|
|
bool is_selection_allowing_tool(DrawingProgramToolType typeToCheck);
|
2025-08-02 12:31:16 +03:00
|
|
|
|
2025-12-29 15:04:32 +03:00
|
|
|
DrawingProgramSelection selection;
|
2025-07-24 16:35:48 +03:00
|
|
|
|
2025-10-11 15:35:17 +03:00
|
|
|
std::unique_ptr<DrawingProgramToolBase> toolToSwitchToAfterUpdate;
|
2025-12-30 19:46:08 +03:00
|
|
|
std::unordered_set<CanvasComponentContainer::ObjInfo*> updateableComponents;
|
2025-10-11 15:35:17 +03:00
|
|
|
|
2026-03-03 16:01:21 +03:00
|
|
|
void pen_tool_switch_check();
|
2026-01-07 10:34:51 +03:00
|
|
|
enum class TemporaryMoveToolSwitch {
|
|
|
|
|
NONE,
|
|
|
|
|
PAN,
|
|
|
|
|
ZOOM
|
|
|
|
|
};
|
2025-07-06 20:43:53 +03:00
|
|
|
bool temporaryEraser = false;
|
2026-01-07 10:34:51 +03:00
|
|
|
TemporaryMoveToolSwitch tempMoveToolSwitch = TemporaryMoveToolSwitch::NONE;
|
|
|
|
|
DrawingProgramToolType toolTypeAfterTempMove;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
struct GlobalControls {
|
2026-01-29 11:48:08 +03:00
|
|
|
std::optional<WorldScalar> lockedCameraScale;
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
bool leftClickHeld = false;
|
2025-09-28 11:59:08 +03:00
|
|
|
bool middleClickHeld = false;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2025-12-28 17:34:33 +03:00
|
|
|
DrawingProgramLayerManager::LayerSelector layerSelector = DrawingProgramLayerManager::LayerSelector::LAYER_BEING_EDITED;
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
int colorEditing = 0;
|
|
|
|
|
} controls;
|
|
|
|
|
|
2025-12-16 12:54:12 +03:00
|
|
|
struct DroppedDownloadingFile {
|
2025-12-30 19:46:08 +03:00
|
|
|
CanvasComponentContainer::ObjInfo* comp;
|
2025-12-16 12:54:12 +03:00
|
|
|
Vector2f windowSizeWhenDropped;
|
|
|
|
|
std::shared_ptr<FileDownloader::DownloadData> downData;
|
|
|
|
|
};
|
|
|
|
|
std::vector<DroppedDownloadingFile> droppedDownloadingFiles;
|
|
|
|
|
|
2025-09-28 11:59:08 +03:00
|
|
|
std::unique_ptr<DrawingProgramToolBase> drawTool;
|
|
|
|
|
|
2026-04-02 12:46:16 +03:00
|
|
|
std::optional<Vector2f> rightClickPopupLocation;
|
|
|
|
|
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
uint32_t nextID = 0;
|
2025-10-09 16:16:39 +03:00
|
|
|
|
2025-08-05 12:11:50 +03:00
|
|
|
friend class EyeDropperTool;
|
2025-07-06 20:43:53 +03:00
|
|
|
friend class RectDrawTool;
|
|
|
|
|
friend class EllipseDrawTool;
|
2026-01-08 11:13:49 +03:00
|
|
|
friend class LineDrawTool;
|
2025-07-06 20:43:53 +03:00
|
|
|
friend class BrushTool;
|
|
|
|
|
friend class EraserTool;
|
|
|
|
|
friend class RectSelectTool;
|
|
|
|
|
friend class TextBoxTool;
|
|
|
|
|
friend class ScreenshotTool;
|
|
|
|
|
friend class EditTool;
|
2025-08-02 20:10:33 +03:00
|
|
|
friend class ImageEditTool;
|
|
|
|
|
friend class RectDrawEditTool;
|
|
|
|
|
friend class EllipseDrawEditTool;
|
|
|
|
|
friend class TextBoxEditTool;
|
2025-07-20 15:24:44 +03:00
|
|
|
friend class DrawingProgramCache;
|
2025-07-24 19:35:51 +03:00
|
|
|
friend class DrawingProgramSelection;
|
2025-08-02 12:31:16 +03:00
|
|
|
friend class LassoSelectTool;
|
2025-09-10 15:03:06 +03:00
|
|
|
friend class GridEditTool;
|
2025-09-18 18:02:11 +03:00
|
|
|
friend class GridModifyTool;
|
2025-09-28 11:59:08 +03:00
|
|
|
friend class ZoomCanvasTool;
|
2025-09-28 15:00:19 +03:00
|
|
|
friend class PanCanvasTool;
|
2025-09-28 11:59:08 +03:00
|
|
|
friend class DrawCamera;
|
2025-12-28 17:34:33 +03:00
|
|
|
friend class DrawingProgramLayerManager;
|
|
|
|
|
friend class DrawingProgramLayer;
|
|
|
|
|
friend class DrawingProgramLayerFolder;
|
2026-01-29 11:48:08 +03:00
|
|
|
friend class ToolConfiguration;
|
2025-07-06 20:43:53 +03:00
|
|
|
};
|