Added back infinite zoom scale up code
This commit is contained in:
parent
108da82fd4
commit
85cc0c2457
26 changed files with 191 additions and 62 deletions
|
|
@ -32,6 +32,7 @@
|
|||
#include "Layers/DrawingProgramLayer.hpp"
|
||||
#include "Layers/DrawingProgramLayerListItem.hpp"
|
||||
#include <Helpers/Parallel.hpp>
|
||||
#include "../ScaleUpCanvas.hpp"
|
||||
|
||||
#include "Tools/EraserTool.hpp"
|
||||
|
||||
|
|
@ -49,11 +50,10 @@ void DrawingProgram::init() {
|
|||
}
|
||||
|
||||
void DrawingProgram::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
//for(auto& c : components->get_data())
|
||||
// c->obj->scale_up(scaleUpAmount);
|
||||
//selection.deselect_all();
|
||||
//force_rebuild_cache();
|
||||
//switch_to_tool(drawTool->get_type() == DrawingProgramToolType::GRIDMODIFY ? DrawingProgramToolType::EDIT : drawTool->get_type(), true);
|
||||
selection.deselect_all();
|
||||
layerMan.scale_up(scaleUpAmount);
|
||||
rebuild_cache();
|
||||
switch_to_tool(drawTool->get_type() == DrawingProgramToolType::GRIDMODIFY ? DrawingProgramToolType::EDIT : drawTool->get_type(), true);
|
||||
}
|
||||
|
||||
void DrawingProgram::write_components_server(cereal::PortableBinaryOutputArchive& a) {
|
||||
|
|
@ -69,6 +69,14 @@ void DrawingProgram::init_server_callbacks() {
|
|||
world.netServer->add_recv_callback(SERVER_TRANSFORM_MANY_COMPONENTS, [&](std::shared_ptr<NetServer::ClientData> client, cereal::PortableBinaryInputArchive& message) {
|
||||
std::vector<std::pair<NetworkingObjects::NetObjID, CoordSpaceHelper>> transforms;
|
||||
message(transforms);
|
||||
|
||||
auto clientData = world.netObjMan.get_obj_temporary_ref_from_id<ClientData>(NetworkingObjects::NetObjID(client->customID));
|
||||
if(clientData->get_grid_size() < world.ownClientData->get_grid_size()) {
|
||||
WorldScalar scaleUpAmount = get_canvas_scale_up_amount(world.ownClientData->get_grid_size(), clientData->get_grid_size());
|
||||
for(auto& [netID, coord] : transforms)
|
||||
coord.inverseScale *= scaleUpAmount;
|
||||
}
|
||||
|
||||
process_transform_message(transforms);
|
||||
world.netServer->send_items_to_all_clients(RELIABLE_COMMAND_CHANNEL, CLIENT_TRANSFORM_MANY_COMPONENTS, transforms);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -51,3 +51,8 @@ void DrawingProgramLayer::get_flattened_component_list(std::vector<CanvasCompone
|
|||
for(auto& p : *components)
|
||||
objList.emplace_back(&p);
|
||||
}
|
||||
|
||||
void DrawingProgramLayer::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
for(auto& p : *components)
|
||||
p.obj->scale_up(scaleUpAmount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class DrawingProgramLayer {
|
|||
void commit_update_dont_invalidate_cache(DrawingProgramLayerManager& layerMan) const;
|
||||
void get_flattened_component_list(std::vector<CanvasComponentContainer::ObjInfo*>& objList) const;
|
||||
void set_to_erase();
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
CanvasComponentContainer::NetListOwnerPtr components;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -49,3 +49,8 @@ NetworkingObjects::NetObjWeakPtr<DrawingProgramLayerListItem> DrawingProgramLaye
|
|||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void DrawingProgramLayerFolder::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
for(auto& p : *folderList)
|
||||
p.obj->scale_up(scaleUpAmount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class DrawingProgramLayerFolder {
|
|||
void get_flattened_component_list(std::vector<CanvasComponentContainer::ObjInfo*>& objList) const;
|
||||
void set_to_erase();
|
||||
NetworkingObjects::NetObjWeakPtr<DrawingProgramLayerListItem> get_initial_editing_layer() const;
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
NetworkingObjects::NetObjOwnerPtr<NetworkingObjects::NetObjOrderedList<DrawingProgramLayerListItem>> folderList;
|
||||
bool isFolderOpen = false;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,13 @@ uint32_t DrawingProgramLayerListItem::get_component_count() const {
|
|||
return layerData->components->size();
|
||||
}
|
||||
|
||||
void DrawingProgramLayerListItem::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
if(folderData)
|
||||
folderData->scale_up(scaleUpAmount);
|
||||
else
|
||||
layerData->scale_up(scaleUpAmount);
|
||||
}
|
||||
|
||||
bool DrawingProgramLayerListItem::is_folder() const {
|
||||
return folderData != nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class DrawingProgramLayerListItem {
|
|||
const std::string& get_name() const;
|
||||
void get_flattened_component_list(std::vector<CanvasComponentContainer::ObjInfo*>& objList) const;
|
||||
void get_flattened_layer_list(std::vector<DrawingProgramLayerListItem*>& objList);
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
void set_alpha(DrawingProgramLayerManager& layerMan, float newAlpha) const;
|
||||
float get_alpha() const;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ void DrawingProgramLayerManager::init() {
|
|||
}
|
||||
}
|
||||
|
||||
void DrawingProgramLayerManager::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
layerTreeRoot->scale_up(scaleUpAmount);
|
||||
}
|
||||
|
||||
void DrawingProgramLayerManager::write_components_server(cereal::PortableBinaryOutputArchive& a) {
|
||||
layerTreeRoot.write_create_message(a);
|
||||
}
|
||||
|
|
@ -92,3 +96,4 @@ CanvasComponentContainer::ObjInfo* DrawingProgramLayerManager::add_component_to_
|
|||
return nullptr;
|
||||
return &(*editLayerPtr->get_layer().components->push_back_and_send_create(editLayerPtr->get_layer().components, newObj));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class DrawingProgramLayerManager {
|
|||
void write_components_server(cereal::PortableBinaryOutputArchive& a);
|
||||
void read_components_client(cereal::PortableBinaryInputArchive& a);
|
||||
bool is_a_layer_being_edited();
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
template <typename List> void erase_component_container(const List& compsToErase) {
|
||||
std::unordered_map<DrawingProgramLayerListItem*, std::vector<CanvasComponentContainer::ObjInfoIterator>> idsToEraseInSpecificLayers;
|
||||
for(auto& c : compsToErase)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue