2025-12-25 17:18:28 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include "DrawingProgramLayerListItem.hpp"
|
|
|
|
|
#include "DrawingProgramLayerManagerGUI.hpp"
|
2025-12-30 19:46:08 +03:00
|
|
|
#include <unordered_set>
|
2025-12-25 17:18:28 +03:00
|
|
|
|
|
|
|
|
class DrawingProgramLayerManager {
|
|
|
|
|
private:
|
|
|
|
|
DrawingProgram& drawP;
|
|
|
|
|
friend class DrawingProgramLayerManagerGUI;
|
2025-12-26 10:10:19 +03:00
|
|
|
friend class DrawingProgramLayerListItem;
|
|
|
|
|
friend class DrawingProgramLayer;
|
|
|
|
|
friend class DrawingProgramLayerFolder;
|
2025-12-25 17:18:28 +03:00
|
|
|
NetworkingObjects::NetObjOwnerPtr<DrawingProgramLayerListItem> layerTreeRoot;
|
2025-12-26 10:10:19 +03:00
|
|
|
NetworkingObjects::NetObjWeakPtr<DrawingProgramLayerListItem> editingLayer;
|
2025-12-31 11:59:53 +03:00
|
|
|
void set_initial_editing_layer();
|
2025-12-25 17:18:28 +03:00
|
|
|
public:
|
2025-12-28 17:34:33 +03:00
|
|
|
enum class LayerSelector {
|
|
|
|
|
ALL_VISIBLE_LAYERS,
|
|
|
|
|
LAYER_BEING_EDITED
|
|
|
|
|
};
|
2025-12-26 10:10:19 +03:00
|
|
|
|
2025-12-25 17:18:28 +03:00
|
|
|
DrawingProgramLayerManager(DrawingProgram& drawProg);
|
|
|
|
|
void init();
|
2025-12-26 10:10:19 +03:00
|
|
|
void draw(SkCanvas* canvas, const DrawData& drawData);
|
2025-12-25 17:18:28 +03:00
|
|
|
void write_components_server(cereal::PortableBinaryOutputArchive& a);
|
|
|
|
|
void read_components_client(cereal::PortableBinaryInputArchive& a);
|
2025-12-26 10:10:19 +03:00
|
|
|
bool is_a_layer_being_edited();
|
2025-12-31 10:06:26 +03:00
|
|
|
template <typename List> void erase_component_container(const List& compsToErase) {
|
|
|
|
|
std::unordered_map<DrawingProgramLayerListItem*, std::vector<CanvasComponentContainer::ObjInfoIterator>> idsToEraseInSpecificLayers;
|
|
|
|
|
for(auto& c : compsToErase)
|
|
|
|
|
idsToEraseInSpecificLayers[c->obj->parentLayer].emplace_back(c->obj->objInfo);
|
|
|
|
|
for(auto& [layerListItem, netObjSetToErase] : idsToEraseInSpecificLayers) {
|
|
|
|
|
auto& layerComponentList = layerListItem->get_layer().components;
|
|
|
|
|
layerComponentList->erase_list(layerComponentList, netObjSetToErase);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-29 19:57:36 +03:00
|
|
|
uint32_t edited_layer_component_count();
|
2025-12-30 19:46:08 +03:00
|
|
|
CanvasComponentContainer::ObjInfoIterator get_edited_layer_end_iterator();
|
|
|
|
|
bool component_passes_layer_selector(CanvasComponentContainer::ObjInfo* c, LayerSelector layerSelector);
|
2025-12-28 17:34:33 +03:00
|
|
|
|
|
|
|
|
bool layer_tree_root_exists();
|
|
|
|
|
const DrawingProgramLayerListItem& get_layer_root();
|
2025-12-31 11:42:16 +03:00
|
|
|
uint32_t total_component_count();
|
2025-12-28 17:34:33 +03:00
|
|
|
|
2025-12-30 19:46:08 +03:00
|
|
|
CanvasComponentContainer::ObjInfo* add_component_to_layer_being_edited(CanvasComponentContainer* newObj);
|
|
|
|
|
std::vector<CanvasComponentContainer::ObjInfoIterator> add_many_components_to_layer_being_edited(const std::vector<std::pair<CanvasComponentContainer::ObjInfoIterator, CanvasComponentContainer*>>& newObjs);
|
|
|
|
|
std::vector<CanvasComponentContainer::ObjInfo*> get_flattened_component_list() const;
|
2025-12-29 19:57:36 +03:00
|
|
|
std::vector<DrawingProgramLayerListItem*> get_flattened_layer_list();
|
2025-12-25 17:18:28 +03:00
|
|
|
DrawingProgramLayerManagerGUI listGUI;
|
|
|
|
|
};
|