#pragma once #include "FluidSim/Machine.hpp" #include "FluidSim/Desktop/WorkshopLayout.hpp" #include #include #include namespace fluidsim::port::desktop { struct LogicEditorHooks { MachineDocument& document; const MachineSnapshot* live{}; bool shift{}; std::function&)> edit; std::function boolean_control; std::function number_control; std::function release_buttons; std::function select_physical,focus_physical; std::function status; std::function example; }; class LogicEditor { public: LogicEditor(); ~LogicEditor(); void reset_document(); void deactivate(const LogicEditorHooks&); bool editing_text()const; bool active_gesture()const; std::uint32_t selected_node()const; void select_node(std::uint32_t,const MachineDocument&); void select_part_reference(std::uint32_t,const MachineDocument&); void fit(const LogicGraph&,sf::FloatRect,bool selection_only=false); void reveal(std::uint32_t,const MachineDocument&,sf::FloatRect); sf::Vector2f project(LogicPosition,sf::FloatRect)const; LogicPosition unproject(sf::Vector2f,sf::FloatRect)const; sf::FloatRect node_rect(const LogicNode&,sf::FloatRect)const; sf::Vector2f pin_position(const LogicNode&,const std::string&,sf::FloatRect)const; // Panels can be owned independently in split view; the canvas is always live. bool event(const sf::Event&,const LogicEditorHooks&,const WorkshopLayout&,sf::FloatRect canvas,bool panels); void draw(sf::RenderWindow&,const sf::Font*,const LogicEditorHooks&,const WorkshopLayout&,sf::FloatRect canvas,bool panels); private: struct Impl; std::unique_ptr impl_; }; }