Browse Source

removed uielement

meemknight 2 years ago
parent
commit
42791c108a

+ 17 - 2
Pika/core/sharedRuntime/pikaImgui/pikaImgui.cpp

@@ -143,7 +143,23 @@ void pika::pikaImgui::imguiEndFrame(PikaContext pikaContext)
 
 bool pika::pikaImgui::redButton(const char *label, const ImVec2 &size_arg)
 {
-	::ImGui::PushStyleColor(ImGuiCol_Button, {1,0,0,1});
+	return colouredButton(label, {1,0,0,1}, size_arg);
+}
+
+bool pika::pikaImgui::greenButton(const char *label, const ImVec2 &size_arg)
+{
+	return colouredButton(label, {0,1,0,1}, size_arg);
+}
+
+bool pika::pikaImgui::blueButton(const char *label, const ImVec2 &size_arg)
+{
+	return colouredButton(label, {0,0,1,1}, size_arg);
+}
+
+bool pika::pikaImgui::colouredButton(const char *label, glm::vec4 color,
+	const ImVec2 &size_arg)
+{
+	::ImGui::PushStyleColor(ImGuiCol_Button, {color.r, color.g, color.b, color.a});
 	auto rez = ::ImGui::Button(label, size_arg);
 	::ImGui::PopStyleColor();
 	return rez;
@@ -228,7 +244,6 @@ void pika::pikaImgui::displayMemorySizeValue(size_t value)
 
 }
 
-
 void pika::pikaImgui::displayMemorySizeToggle()
 {
 	ImGui::Combo("Sizes type##pika", &sizesType, "Bytes\0KB\0MB\0GB\0");

+ 3 - 0
Pika/core/sharedRuntime/pikaImgui/pikaImgui.h

@@ -69,6 +69,9 @@ namespace pika
 
 
 		bool redButton(const char *label, const ImVec2 &size_arg = {});
+		bool greenButton(const char *label, const ImVec2 &size_arg = {});
+		bool blueButton(const char *label, const ImVec2 &size_arg = {});
+		bool colouredButton(const char *label, glm::vec4 color, const ImVec2 &size_arg = {});
 
 		bool BeginChildFrameColoured(ImGuiID id,
 			glm::vec4 color,

+ 50 - 118
Pika/pluggins/pluggins/sushiViewer/sushiViewer.cpp

@@ -66,45 +66,27 @@ void SushiViewer::displaySushiTransformImgui(::sushi::Transform & e, glm::vec4 p
 	ImGui::EndChildFrame();
 }
 
-void SushiViewer::displaySushiUiElementImgui(::sushi::SushiUiElement &e, glm::vec4 parent)
+void SushiViewer::displaySushiParentElementImgui(::sushi::SushiParent &e, glm::vec4 parent,
+	bool displayChildren)
 {
-	if (ImGui::BeginChildFrame(e.id, {0, 500}, true))
-	{
-		ImGui::PushID(e.id);
-		ImGui::Text("Ui element editor: %s id: %u", e.name, e.id);
-
-		char data[16] = {};
-		static_assert(sizeof(data) == sizeof(e.name));
-		std::strncpy(data, e.name, sizeof(e.name) - 1);
-		ImGui::InputText("Rename", data, sizeof(e.name));
-		if (std::strcmp(data, e.name))
-		{
-			sushiContext.rename(&e, data);
-		}
+	ImGui::PushID(e.id);
 
-		ImGui::Separator();
-		if (pika::pikaImgui::redButton("Delete"))
-		{
-			toDelete.push_back(e.id);
-		}
-		ImGui::Separator();
-
-		displaySushiTransformImgui(e.transform, parent, e.id + 20000);
-		ImGui::Separator();
-		displaySushiBackgroundImgui(e.background, e.id + 10000);
-		ImGui::PopID();
-	}
-	ImGui::EndChildFrame();
-}
+	glm::vec4 color = {0.2f,0.2f,0.2f,1.f};
+	if (displayChildren) { color = {0.2,0.3,0.7,0.9}; }
 
-void SushiViewer::displaySushiParentElementImgui(::sushi::SushiParent &e, glm::vec4 parent)
-{
-	if (pika::pikaImgui::BeginChildFrameColoured(2, {0.2,0.3,0.7,0.9}, { 0, 700 }, true))
+	if (pika::pikaImgui::BeginChildFrameColoured(e.id, color, { 0, 700 }, true))
 	{
-		ImGui::PushID(e.id);
 
 		ImGui::Text("Parent editor: %s, id: %u", e.name, e.id);
 
+		if (img.elementId != e.id)
+		{
+			if (pika::pikaImgui::blueButton("Select"))
+			{
+				img.elementId = e.id;
+			}
+		}
+
 		char data[16] = {};
 		static_assert(sizeof(data) == sizeof(e.name));
 		std::strncpy(data, e.name, sizeof(e.name) - 1);
@@ -134,30 +116,30 @@ void SushiViewer::displaySushiParentElementImgui(::sushi::SushiParent &e, glm::v
 		transform.anchorPoint = sushi::Transform::center; 
 		transform.sizePercentage = glm::vec2(0.5f);
 
-		if (ImGui::Button("Add element"))
-		{
-			img.elementId = sushiContext.addElement(e, "New Element", transform, sushi::Background());
-		}
-
-		if (ImGui::Button("Add parent"))
+		if (displayChildren)
 		{
-			img.elementId = sushiContext.addParent(e, "New Parent", transform, sushi::Background({0.5,0.2,0.2,1.f}));
-		}
+			if (pika::pikaImgui::greenButton("Add parent"))
+			{
+				img.elementId = sushiContext.addParent(e, "New Item", transform,
+					sushi::Background({0.5,0.2,0.2,1.f}));
+			}
 
-		ImGui::Separator();
-		if(!e.allUiElements.empty())
-			{ImGui::Text("Ui Elements:");}
-		int id = 30;
-		for (auto &i : e.allUiElements)
-		{
-			ImGui::PushID(id++);
-			displaySushiUiElementImgui(i, e.outData.absTransform);
-			ImGui::PopID();
-		}
+			if (!e.parents.empty())
+			{
+				ImGui::Separator();
+				{ ImGui::Text("Children:"); }
+				for (auto &i : e.parents)
+				{
+					displaySushiParentElementImgui(i, e.outData.absTransform, 0);
+				}
+			}
+		};
 
-		ImGui::PopID();
 	}
 	ImGui::EndChildFrame();
+
+	ImGui::PopID();
+
 }
 
 //takes the id of a parent and returns his parent
@@ -181,7 +163,7 @@ sushi::SushiParent *findParentOfParent(sushi::SushiParent &parent, unsigned int
 	return 0;
 }
 
-void visit(sushi::SushiParent &parent, unsigned int id, sushi::SushiUiElement* &selectedElement,
+void visit(sushi::SushiParent &parent, unsigned int id,
 sushi::SushiParent* &selectedParent
 	)
 {
@@ -191,26 +173,16 @@ sushi::SushiParent* &selectedParent
 		return;
 	}
 
-	for (auto &i : parent.allUiElements)
-	{
-		if (i.id == id)
-		{
-			selectedElement = &i;
-			selectedParent = &parent;
-			return;
-		}
-	}
-
 	for (auto &i : parent.parents)
 	{
-		visit(i, id, selectedElement, selectedParent);
-		if (selectedElement || selectedParent) { break; }
+		visit(i, id, selectedParent);
+		if (selectedParent) { break; }
 	}
 
 	return;
 };
 
-void visitSelect(sushi::SushiParent &parent, unsigned int &id, sushi::SushiUiElement *&selectedElement,
+void visitSelect(sushi::SushiParent &parent, unsigned int &id,
 	sushi::SushiParent *&selectedParent, glm::vec2 mousePos
 )
 {
@@ -224,24 +196,9 @@ void visitSelect(sushi::SushiParent &parent, unsigned int &id, sushi::SushiUiEle
 		selectedParent = &parent;
 	}
 
-	for (auto &i : parent.allUiElements)
-	{
-		if (sushi::pointInBox(mousePos, i.outData.absTransform))
-		{
-			id = i.id;
-		}
-
-		if (i.id == id)
-		{
-			selectedElement = &i;
-			selectedParent = &parent;
-		}
-	}
-
 	for (auto &i : parent.parents)
 	{
-		visitSelect(i, id, selectedElement, selectedParent, mousePos);
-		if (selectedElement || selectedParent) { break; }
+		visitSelect(i, id, selectedParent, mousePos);
 	}
 
 	return;
@@ -277,7 +234,6 @@ bool SushiViewer::update(pika::Input input, pika::WindowState windowState, Reque
 	}
 
 
-	sushi::SushiUiElement *selectedElement = 0;
 	sushi::SushiParent *selectedParent = 0;
 	sushi::SushiParent *parentOfParent = 0;
 
@@ -331,12 +287,12 @@ bool SushiViewer::update(pika::Input input, pika::WindowState windowState, Reque
 		
 		if (input.lMouse.held() && !img.dragging)
 		{		
-			visitSelect(sushiContext.root, img.elementId, selectedElement, selectedParent,
+			visitSelect(sushiContext.root, img.elementId, selectedParent,
 				{input.mouseX, input.mouseY});
 		}
 		else
 		{
-			visit(sushiContext.root, img.elementId, selectedElement, selectedParent);
+			visit(sushiContext.root, img.elementId, selectedParent);
 		}
 
 		//ImGui::InputInt("Element: ", &img.elementSelected);
@@ -345,16 +301,6 @@ bool SushiViewer::update(pika::Input input, pika::WindowState windowState, Reque
 		//img.elementSelected = glm::clamp(img.elementSelected, -1, (int)(elementsSize - 1));
 		//
 
-
-		if (selectedElement && selectedParent)
-		{
-			if (ImGui::Button("Select parent"))
-			{
-				img.elementId = selectedParent->id;
-			}
-
-			displaySushiUiElementImgui(*selectedElement, selectedParent->outData.absTransform);
-		}else
 		if (selectedParent)
 		{
 			parentOfParent = findParentOfParent(sushiContext.root, img.elementId);
@@ -363,12 +309,16 @@ bool SushiViewer::update(pika::Input input, pika::WindowState windowState, Reque
 			if (parentOfParent)
 			{
 				parentRect = parentOfParent->outData.absTransform;
+
+				if (ImGui::Button("Select parent"))
+				{
+					img.elementId = parentOfParent->id;
+				}
 			}
 
-			displaySushiParentElementImgui(*selectedParent, parentRect);
+			displaySushiParentElementImgui(*selectedParent, parentRect, true);
 		}
 
-
 	
 	}
 	ImGui::End();
@@ -501,33 +451,15 @@ bool SushiViewer::update(pika::Input input, pika::WindowState windowState, Reque
 
 	sushi::Transform *selectedTransform = 0;
 
-	//render element
-	if (selectedElement)
+	//render parent gyzmos
+	if (selectedParent) 
 	{
-		glm::vec4 parentTransform = {0,0,renderer.windowW, renderer.windowH};
-		if (selectedParent) { parentTransform = selectedParent->outData.absTransform; }
-
-		drawGyzmos(selectedElement->outData.absTransform, selectedElement->transform, 
-			parentTransform);
-
-		if (selectedParent)
+		if (parentOfParent)
 		{
-			//todo add alias render box
-			renderer.renderRectangleOutline(selectedParent->outData.absTransform,
+			renderer.renderRectangleOutline(parentOfParent->outData.absTransform,
 				{0.5,0.5,0,0.5}, 4.0f);
 		}
 
-		selectedTransform = &selectedElement->transform;
-	}else
-	if (selectedParent) //rende
-	{
-
-		for (auto &i : selectedParent->allUiElements)
-		{
-			drawGyzmos(i.outData.absTransform, i.transform,
-				selectedParent->outData.absTransform, 0.2);
-		}
-
 		for (auto &i : selectedParent->parents)
 		{
 			drawGyzmos(i.outData.absTransform, i.transform,

+ 2 - 3
Pika/pluggins/pluggins/sushiViewer/sushiViewer.h

@@ -28,6 +28,7 @@ struct SushiViewer: public Container
 
 	struct ImGuiStuff
 	{
+		//set this to something to automatically change the current element
 		unsigned int elementId = 0;
 
 		bool dragging = 0;
@@ -37,9 +38,7 @@ struct SushiViewer: public Container
 		
 	}img;
 
-	void displaySushiParentElementImgui(::sushi::SushiParent &e, glm::vec4 parent);
-
-	void displaySushiUiElementImgui(::sushi::SushiUiElement &e, glm::vec4 parent);
+	void displaySushiParentElementImgui(::sushi::SushiParent &e, glm::vec4 parent, bool displayChildren);
 
 	void displaySushiTransformImgui(::sushi::Transform &e, glm::vec4 parent, int id);
 

+ 3 - 1
Pika/resources/logs.txt

@@ -1 +1,3 @@
-#2023-09-07 15:05:17: Created container: SushiViewer
+#2023-09-08 13:58:59: Reloaded dll
+#2023-09-08 13:59:03: Created container: SushiViewer
+#2023-09-08 14:00:55: Destroyed continer: SushiViewer #1

BIN
Pika/resources/sushi/test.sushi


+ 7 - 105
Pika/thirdparty/sushi/include/sushi/sushi.h

@@ -9,27 +9,6 @@ namespace sushi
 {
 
 	//this can also be a window or a button or whatever you want
-	struct SushiUiElement
-	{
-		SushiUiElement() {};
-		SushiUiElement(const char *name, int id)
-		{
-			this->id = id;
-			std::strncpy(this->name, name, sizeof(this->name) - 1);
-		};
-
-		char name[16] = {};
-		unsigned int id = 0;
-		Transform transform;
-		Background background;
-
-		void update(gl2d::Renderer2D &renderer,
-			sushi::SushiInput &input, glm::vec4 parentTransform);
-
-		OutData outData;
-
-	};
-
 	struct SushiParent
 	{
 		SushiParent() {};
@@ -59,8 +38,6 @@ namespace sushi
 
 		int layoutType = 0;
 
-		std::vector<SushiUiElement> allUiElements;
-
 		std::vector<SushiParent> parents;
 
 		std::vector<unsigned int> orderedElementsIds;
@@ -72,12 +49,6 @@ namespace sushi
 
 		bool deleteByIdInternal(unsigned int id);
 
-		void addElementInternal(
-			const char *name,
-			Transform &transform,
-			Background &background,
-			unsigned int id);
-
 		void addParentInternal(
 			const char *name,
 			Transform &transform,
@@ -85,70 +56,10 @@ namespace sushi
 			unsigned int id);
 	};
 
-	//parent or ui
-	struct SushiElement
-	{
-		SushiElement() {};
-		SushiElement(void *ptr, int type):ptr(ptr), type(type) {};
-		SushiElement(SushiUiElement *ptr):ptr(ptr), type(TypeUiElement) {};
-		SushiElement(SushiParent *ptr):ptr(ptr), type(TypeParent) {};
-
-		void *ptr = 0;
-		int type = 0;
-
-		enum Type
-		{
-			TypeUiElement = 1,
-			TypeParent = 2,
-		};
-
-		SushiUiElement *getUiElement()
-		{
-			if (type == TypeUiElement)
-			{
-				return (SushiUiElement *)ptr;
-			}
-			else { return 0; }
-		}
-
-		SushiParent *getParent()
-		{
-			if (type == TypeParent)
-			{
-				return (SushiParent *)ptr;
-			}
-			else { return 0; }
-		}
-
-		bool isUiElement() { return type == TypeUiElement; }
-		bool isParent() { return type == TypeParent; }
-		bool hasValue() { return (type != 0) && (ptr != nullptr); }
-		std::string getName()
-		{
-			if (hasValue())
-			{
-				if (isParent())
-				{
-					return getParent()->name;
-				}else if (isUiElement())
-				{
-					return getUiElement()->name;
-				}
-			}
-			else
-			{
-				return "";
-			}
-		}
-
-	};
-
 	struct SushyBinaryFormat
 	{
 		std::vector<char> data;
 
-		void addUiElementInternal(sushi::SushiUiElement &el);
-
 		void addPieceInternal(sushi::Transform &transform);
 
 		void addPieceInternal(sushi::Background &background);
@@ -165,7 +76,7 @@ namespace sushi
 
 		void addUIntArrayPieceInternal(std::vector<unsigned int> &arr);
 
-		bool save(SushiElement element);
+		void save(SushiParent &parent, bool isMainParent);
 
 		void traverseAddInternal(SushiParent &parent);
 
@@ -185,12 +96,6 @@ namespace sushi
 		void update(gl2d::Renderer2D &renderer, 
 			sushi::SushiInput &input);
 
-		unsigned int addElement(
-			SushiParent &parent,
-			const char *name,
-			Transform &transform,
-			Background &background);
-
 		unsigned int addParent(
 			SushiParent &parent,
 			const char *name,
@@ -199,20 +104,17 @@ namespace sushi
 
 		bool deleteById(unsigned int id);
 
-		std::unordered_multimap<std::string, SushiElement> cachedData;
-
-		void signalElementToCacheInternl(SushiElement el);
-
-		void signalElementToCacheToRemoveInternal(SushiElement el);
+		//todo push backs can invalidate data so just recreate the entire cache
+		std::unordered_multimap<std::string, SushiParent*> cachedData; 
 
 		//can't search for root
-		SushiElement genUniqueElement(std::string name);
+		SushiParent *genUniqueParent(std::string name);
 
 		//can't search for root
-		std::pair<std::unordered_multimap<std::string, SushiElement>::iterator,
-			std::unordered_multimap<std::string, SushiElement>::iterator> getElements(std::string name);
+		std::pair<std::unordered_multimap<std::string, SushiParent*>::iterator,
+			std::unordered_multimap<std::string, SushiParent*>::iterator> genParents(std::string name);
 
-		void rename(SushiElement el, char *newName);
+		void rename(SushiParent *el, char *newName);
 
 		SushyBinaryFormat save();
 

+ 86 - 226
Pika/thirdparty/sushi/src/sushi.cpp

@@ -10,8 +10,7 @@ namespace sushi
 
 	enum: int
 	{
-		markerUiElement = 1,
-		markerParent,
+		markerParent = 1,
 		markerChildrenIdList,
 		markerMainParent,
 	};
@@ -26,12 +25,6 @@ namespace sushi
 		addBinaryDataInternal(&background, sizeof(background));
 	}
 
-	void SushyBinaryFormat::addUiElementInternal(sushi::SushiUiElement &el)
-	{
-		addMarkerInternal(markerUiElement);
-		addBinaryDataInternal(&el, sizeof(el));
-	}
-	
 	void SushyBinaryFormat::addUIntArrayPieceInternal(std::vector<unsigned int> &arr)
 	{
 		size_t s = arr.size();
@@ -82,12 +75,6 @@ namespace sushi
 	{
 		addParentInternal(parent);
 
-		auto &ui = parent.allUiElements;
-		for (auto &e : ui)
-		{
-			addUiElementInternal(e);
-		}
-
 		auto &parents = parent.parents;
 		for (auto &e : parents)
 		{
@@ -99,12 +86,6 @@ namespace sushi
 	{
 		addMainParentInternal(parent);
 
-		auto &ui = parent.allUiElements;
-		for (auto &e : ui)
-		{
-			addUiElementInternal(e);
-		}
-
 		auto &parents = parent.parents;
 		for (auto &e : parents)
 		{
@@ -113,51 +94,47 @@ namespace sushi
 	}
 
 
-	bool SushyBinaryFormat::save(SushiElement element)
+	void SushyBinaryFormat::save(SushiParent &parent, bool isMainParent)
 	{
 		data.clear();
 		//todo reserve
 		
-		if (element.isUiElement())
+		if (isMainParent)
 		{
-			addUiElementInternal(*element.getUiElement());
-			return true;
-		}
-		else if (element.isParent())
-		{
-			traverseAddInternal(*element.getParent());
+			traverseAddInternalMainParent(parent);
 		}
 		else
 		{
-			return false;
+			traverseAddInternal(parent);
 		}
-	}
-
-#pragma endregion
-
 
-	void SushyContext::signalElementToCacheInternl(SushiElement el)
-	{
-		if (!el.hasValue())return;
-		cachedData.insert({el.getName(), el});
 	}
 
-	void SushyContext::signalElementToCacheToRemoveInternal(SushiElement el)
-	{
-		if (!el.hasValue())return;
-
-		auto range = cachedData.equal_range(el.getName());
-		for (auto it = range.first; it != range.second; ++it)
-		{
-			if (it->second.ptr == el.ptr)
-			{
-				cachedData.erase(it);
-				break;
-			}
-		}
-	}
+#pragma endregion
 
-	SushiElement SushyContext::genUniqueElement(std::string name)
+	//todo
+	//void SushyContext::signalElementToCacheInternl(SushiElement el)
+	//{
+	//	if (!el.hasValue())return;
+	//	cachedData.insert({el.getName(), el});
+	//}
+	//
+	//void SushyContext::signalElementToCacheToRemoveInternal(SushiElement el)
+	//{
+	//	if (!el.hasValue())return;
+	//
+	//	auto range = cachedData.equal_range(el.getName());
+	//	for (auto it = range.first; it != range.second; ++it)
+	//	{
+	//		if (it->second.ptr == el.ptr)
+	//		{
+	//			cachedData.erase(it);
+	//			break;
+	//		}
+	//	}
+	//}
+
+	SushiParent *SushyContext::genUniqueParent(std::string name)
 	{
 		auto range = cachedData.equal_range(name);
 
@@ -171,48 +148,28 @@ namespace sushi
 		}
 		else
 		{
-			return {};
+			return nullptr;
 		}
 	}
 
-	std::pair<std::unordered_multimap<std::string, SushiElement>::iterator,
-		std::unordered_multimap<std::string, SushiElement>::iterator> SushyContext::getElements(std::string name)
+	std::pair<std::unordered_multimap<std::string, SushiParent *>::iterator,
+		std::unordered_multimap<std::string, SushiParent *>::iterator> SushyContext::genParents(std::string name)
 	{
 		auto range = cachedData.equal_range(name);
 		return range;
 	}
 
-	void SushyContext::rename(SushiElement el, char *newName)
+	void SushyContext::rename(SushiParent *el, char *newName)
 	{
-		if (!el.hasValue()) { return; }
+		if (!el) { return; }
 
-		signalElementToCacheToRemoveInternal(el);
-
-		if (el.isParent())
-		{
-			std::strncpy(el.getParent()->name, newName, sizeof(el.getParent()->name) - 1);
-		}
-		else if(el.isUiElement())
-		{
-			std::strncpy(el.getUiElement()->name, newName, sizeof(el.getUiElement()->name) - 1);
-		}
-
-		signalElementToCacheInternl(el);
-		
-	}
-
-	unsigned int SushyContext::addElement(
-		SushiParent &parent,
-		const char *name,
-		Transform &transform,
-		Background &background)
-	{
+		//todo cache
+		//signalElementToCacheToRemoveInternal(el);
 
+		std::strncpy(el->name, newName, sizeof(el->name) - 1);
 
-
-		unsigned int id = currentIdCounter++;
-		parent.addElementInternal(name, transform, background, id);
-		return id;
+		//todo cache
+		//signalElementToCacheInternl(el);
 	}
 
 	unsigned int SushyContext::addParent(
@@ -268,39 +225,28 @@ namespace sushi
 
 		//backgrouund
 		background.render(renderer, drawRegion);
-		auto uiElSize = allUiElements.size();
-		auto subUiElSize = parents.size();
-		auto ordererElementsSize = orderedElementsIds.size();
+		auto parentsSize = parents.size();
+		auto orderedElementsSize = orderedElementsIds.size();
 
-		std::vector<sushi::SushiElement> toDraw;
-		toDraw.reserve(ordererElementsSize);
+		//todo signal error here
+		assert(parentsSize == orderedElementsSize);
 
-		for (int i = 0; i < ordererElementsSize; i++)
+		std::vector<sushi::SushiParent*> toDraw;
+		toDraw.reserve(orderedElementsSize);
+
+		for (int i = 0; i < orderedElementsSize; i++)
 		{
 			int id = orderedElementsIds[i];
 
-			for (int i = 0; i < uiElSize; i++)
-			{
-				if(allUiElements[i].id == id)
-				{
-					toDraw.push_back(sushi::SushiElement(&allUiElements[i]));
-					//allUiElements[i].update(renderer, input, drawRegion);
-					goto end;
-				}
-			}
-
-			for (int i = 0; i < subUiElSize; i++)
+			for (int i = 0; i < parentsSize; i++)
 			{
 				if (parents[i].id == id)
 				{
-					toDraw.push_back(sushi::SushiElement(&parents[i]));
+					toDraw.push_back(&parents[i]);
 					//parents[i].update(renderer, input, drawRegion);
-					goto end;
+					break;
 				}
 			}
-
-			end:
-			;
 		}
 
 		auto toDrawSize = toDraw.size();
@@ -311,14 +257,7 @@ namespace sushi
 		{
 			for (int i = 0; i < toDrawSize; i++)
 			{
-				if (toDraw[i].getParent())
-				{
-					toDraw[i].getParent()->update(renderer, input, drawRegion);
-				}
-				else if (toDraw[i].getUiElement())
-				{
-					toDraw[i].getUiElement()->update(renderer, input, drawRegion);
-				}
+				toDraw[i]->update(renderer, input, drawRegion);
 			}
 		}
 		break;
@@ -331,14 +270,7 @@ namespace sushi
 				newPos.w /= toDrawSize;
 				newPos.y += newPos.w * i;
 
-				if (toDraw[i].getParent())
-				{
-					toDraw[i].getParent()->update(renderer, input, newPos);
-				}
-				else if (toDraw[i].getUiElement())
-				{
-					toDraw[i].getUiElement()->update(renderer, input, newPos);
-				}
+				toDraw[i]->update(renderer, input, newPos);
 			}
 		}
 		break;
@@ -351,14 +283,7 @@ namespace sushi
 				newPos.z /= toDrawSize;
 				newPos.x += newPos.z * i;
 
-				if (toDraw[i].getParent())
-				{
-					toDraw[i].getParent()->update(renderer, input, newPos);
-				}
-				else if (toDraw[i].getUiElement())
-				{
-					toDraw[i].getUiElement()->update(renderer, input, newPos);
-				}
+				toDraw[i]->update(renderer, input, newPos);
 			}
 		}
 		break;
@@ -371,15 +296,6 @@ namespace sushi
 
 	}
 
-	void SushiUiElement::update(gl2d::Renderer2D &renderer, 
-		sushi::SushiInput &input, glm::vec4 parentTransform)
-	{
-		glm::vec4 rectRez = transform.applyTransform(parentTransform);
-		outData.set(rectRez);
-
-		background.render(renderer, rectRez);
-	}
-
 	bool SushiParent::deleteByIdInternal(unsigned int id)
 	{
 		for (int i = 0; i < orderedElementsIds.size(); i++)
@@ -390,15 +306,6 @@ namespace sushi
 			}
 		}
 
-		for (int i = 0; i < allUiElements.size(); i++)
-		{
-			if (allUiElements[i].id == id)
-			{
-				allUiElements.erase(allUiElements.begin() + i);
-				return 1;
-			}
-		}
-
 		for (int i = 0; i < parents.size(); i++)
 		{
 			if (parents[i].id == id)
@@ -416,22 +323,6 @@ namespace sushi
 		return 0;
 	}
 
-	void SushiParent::addElementInternal(
-		const char *name,
-		Transform &transform,
-		Background &background,
-		unsigned int id)
-	{
-		sushi::SushiUiElement element;
-		element.id = id;
-		element.background = background;
-		element.transform = transform;
-		std::strncpy(element.name, name, sizeof(element.name) - 1);
-
-		allUiElements.push_back(element);
-		orderedElementsIds.push_back(id);
-	}
-
 	void SushiParent::addParentInternal(
 		const char *name,
 		Transform &transform,
@@ -461,7 +352,6 @@ namespace sushi
 
 	struct LoadeData
 	{
-		std::vector<SushiUiElement> elements;
 		std::vector<SushiParent> parents;
 		std::optional<SushiParent> mainParent = std::nullopt;
 	};
@@ -492,11 +382,6 @@ namespace sushi
 			return marker;
 		};
 
-		auto getNextUiElementPiece = [&](SushiUiElement *buff) -> bool
-		{
-			return readBinaryData(buff, sizeof(SushiUiElement));
-		};
-
 		auto getNextTransformPiece = [&](Transform *buff) -> bool
 		{
 			return readBinaryData(buff, sizeof(Transform));
@@ -541,13 +426,7 @@ namespace sushi
 		{
 			int firstM = getNextMarker();
 
-			if (firstM == markerUiElement)
-			{
-				SushiUiElement el;
-				if (!getNextUiElementPiece(&el)) { return 0; }
-				rezult.elements.push_back(el);
-			}
-			else if (firstM == markerParent)
+			if (firstM == markerParent)
 			{
 				SushiParent el;
 				if (!getNextParentPiece(el)) { return 0; }
@@ -588,24 +467,15 @@ namespace sushi
 		
 		//todo if no loaded.mainParent we will make the first found parent root
 
+		if (!loaded.parents.empty())
 		{
-			//no parents, we can just add the elements here
-			if (loaded.parents.empty())
+		#pragma region find first parent
+			SushiParent *firstParent = 0;
+			if (loaded.mainParent)
 			{
-				for (auto &e : loaded.elements)
-				{
-					addElement(*parentToAddTo, e.name, e.transform, e.background);
-				}
+				firstParent = &(*loaded.mainParent);
 			}
 			else
-			{
-			#pragma region find first parent
-				SushiParent *firstParent = 0;
-				if (loaded.mainParent)
-				{
-					firstParent = &(*loaded.mainParent);
-				}
-				else
 				{
 					//determine the main parent
 					std::unordered_set<unsigned int> allparentsids;
@@ -649,62 +519,52 @@ namespace sushi
 					}
 
 				}
-			#pragma endregion
+		#pragma endregion
 
-				if (!firstParent) { return 0; }
+			if (!firstParent) { return 0; }
 
-				struct ParentPair
-				{
-					SushiParent *element = 0;
-					SushiParent *parentToAddTo = 0;
-				};
+			struct ParentPair
+			{
+				SushiParent *element = 0;
+				SushiParent *parentToAddTo = 0;
+			};
 
-				std::vector<ParentPair> parentsToAdd;
-				parentsToAdd.push_back({firstParent, parentToAddTo});
+			std::vector<ParentPair> parentsToAdd;
+			parentsToAdd.push_back({firstParent, parentToAddTo});
 
-				while (parentsToAdd.size())
-				{
-					auto currentP = *parentsToAdd.begin();
-					parentsToAdd.erase(parentsToAdd.begin());
+			while (parentsToAdd.size())
+			{
+				auto currentP = *parentsToAdd.begin();
+				parentsToAdd.erase(parentsToAdd.begin());
 
-					addParent(*currentP.parentToAddTo, currentP.element->name, currentP.element->transform,
-						currentP.element->background);
+				addParent(*currentP.parentToAddTo, currentP.element->name, currentP.element->transform,
+					currentP.element->background);
 
-					bool found = 0;
-					for (auto &id : currentP.element->orderedElementsIds)
+				bool found = 0;
+				for (auto &id : currentP.element->orderedElementsIds)
+				{
+
+					if (!found)
 					{
-						for (auto &e : loaded.elements)
+						for (auto &e : loaded.parents)
 						{
 							if (e.id == id)
 							{
-								addElement(*currentP.element, e.name, e.transform, e.background);
+								parentsToAdd.push_back({&e,currentP.element});
 								found = true;
 								break;
 							}
 						}
-
-						if (!found)
-						{
-							for (auto &e : loaded.parents)
-							{
-								if (e.id == id)
-								{
-									parentsToAdd.push_back({&e,currentP.element});
-									found = true;
-									break;
-								}
-							}
-						}
-						if (found) { break; }
 					}
-
-					if (!found) { return 0; }
-
+					if (found) { break; }
 				}
 
+				if (!found) { return 0; }
+
 			}
 
-		};
+		}
+
 		
 		
 		return 1;