#pragma once #include #include #include #include "../Input/PointerStream.h" #include "MaterialIcons.h" #include #include "../Brush.h" #include "../Texture.h" #include "../Commands/HistoryManager.h" #include "../LayerNodes/LayerNode.h" #include "../ManagementContext/LayerManagmentContext.h" #include class Tool { protected: std::queue> inputQueue; static LayerNode* target; // editing actual data goes here Texture* preview = nullptr; // this is rendered on top of target with blend mode and behind higher layers SDL_GPUGraphicsPipeline* pipelineBlend; // the pipeline used to render the preview Texture* overlay; // use this to show gizmos or similar, will always be rendered on top static Tool* active; Brush* activeBrush = nullptr; static HistoryManager* history; public: virtual ~Tool() { } static float Color[3]; float* Size; float* Flow; float* Opacity; // Brushes as subtools std::list Brushes; bool RequestBrushlistRefresh = true; virtual bool UseBrushlist() { return false; } Brush* GetActiveBrush() { return activeBrush; } virtual void SetActiveBrush(Brush* brush) { activeBrush = brush; } static Tool* GetActive() { return active; } static void SetActive(Tool* tool); static void SetHistory(HistoryManager* history) { Tool::history = history; } virtual void OnActivate() = 0; virtual void OnDeactivate() = 0; virtual bool OnDown(std::shared_ptr stream); virtual void OnRender() = 0; virtual void OnGuiRender() {} // Rendering static void SetTarget(LayerNode* target) { Tool::target = target; } static void SetColor(float r, float g, float b) { Tool::Color[0] = r; Tool::Color[1] = g; Tool::Color[2] = b; } LayerNode* GetTarget() { return target; } Texture* GetPreview() { return preview; } virtual SDL_FRect GetPreviewBoundingBox() { return { 0, 0, (float)LayerManagementContext::FinalWidth, (float)LayerManagementContext::FinalHeight }; } virtual bool IsEraser() { return false; } // there's a better way to do this, but the pipleine abstraction isnt ready // Metadata virtual std::string GetIcon() const { return ICON_MS_FRAME_EXCLAMATION; } };