Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#pragma once
#include <memory>#include <queue>#include <SDL3/SDL.h>#include "../Input/PointerStream.h"#include "MaterialIcons.h"#include <string>#include "../Brush.h"#include "../Texture.h"#include "../Commands/HistoryManager.h"#include "../LayerNodes/LayerNode.h"#include "../ManagementContext/LayerManagmentContext.h"#include <imgui.h>
class Tool {protected: std::queue<std::shared_ptr<PointerStream>> 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<Brush*> 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<PointerStream> 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; }};