replace kWidget enum with string
This commit is contained in:
94
src/node.cpp
94
src/node.cpp
@@ -1401,50 +1401,18 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node, bool skip_children
|
||||
}
|
||||
}
|
||||
|
||||
kWidget child_id = (kWidget)const_hash(x_child->Name());
|
||||
switch (child_id)
|
||||
std::string node_name = x_child->Name();
|
||||
if (node_name == "ref")
|
||||
{
|
||||
#define CASE(W,C) case W: { auto n = new C(); add_child(n); n->load_internal(x_child); break; }
|
||||
CASE(kWidget::Node, Node);
|
||||
CASE(kWidget::Border, NodeBorder);
|
||||
CASE(kWidget::Image, NodeImage);
|
||||
CASE(kWidget::ImageTexture, NodeImageTexture);
|
||||
CASE(kWidget::Icon, NodeIcon);
|
||||
CASE(kWidget::TextInput, NodeTextInput);
|
||||
CASE(kWidget::Button, NodeButton);
|
||||
CASE(kWidget::ButtonCustom, NodeButtonCustom);
|
||||
CASE(kWidget::ComboBox, NodeComboBox);
|
||||
CASE(kWidget::SliderH, NodeSliderH);
|
||||
CASE(kWidget::SliderV, NodeSliderV);
|
||||
CASE(kWidget::SliderHue, NodeSliderHue);
|
||||
CASE(kWidget::PopupMenu, NodePopupMenu);
|
||||
CASE(kWidget::Viewport, NodeViewport);
|
||||
CASE(kWidget::CheckBox, NodeCheckBox);
|
||||
CASE(kWidget::Layer, NodeLayer);
|
||||
CASE(kWidget::PanelLayer, NodePanelLayer);
|
||||
CASE(kWidget::PanelBrush, NodePanelBrush);
|
||||
CASE(kWidget::PanelColor, NodePanelColor);
|
||||
CASE(kWidget::PanelStroke, NodePanelStroke);
|
||||
CASE(kWidget::PanelGrid, NodePanelGrid);
|
||||
CASE(kWidget::PanelQuick, NodePanelQuick);
|
||||
CASE(kWidget::ColorQuad, NodeColorQuad);
|
||||
CASE(kWidget::StrokePreview, NodeStrokePreview);
|
||||
CASE(kWidget::Canvas, NodeCanvas);
|
||||
CASE(kWidget::Scroll, NodeScroll);
|
||||
CASE(kWidget::DialogBrowse, NodeDialogBrowse);
|
||||
CASE(kWidget::DialogBrowseItem, NodeDialogBrowseItem);
|
||||
CASE(kWidget::DialogCloud, NodeDialogCloud);
|
||||
CASE(kWidget::DialogCloudItem, NodeDialogCloudItem);
|
||||
CASE(kWidget::ColorWheel, NodeColorWheel);
|
||||
CASE(kWidget::ColorPicker, NodeColorPicker);
|
||||
CASE(kWidget::About, NodeAbout);
|
||||
CASE(kWidget::Changelog, NodeChangelog);
|
||||
CASE(kWidget::UserManual, NodeUserManual);
|
||||
CASE(kWidget::ToolBucket, NodeToolBucket);
|
||||
CASE(kWidget::Timeline, NodeAnimationTimeline);
|
||||
CASE(kWidget::Metadata, NodeMetadata);
|
||||
#undef CASE
|
||||
case kWidget::Text:
|
||||
auto ids = x_child->Attribute("id");
|
||||
auto id = const_hash(ids);
|
||||
auto& ref = (*m_manager)[id]->m_children[0];
|
||||
auto n = ref->clone();
|
||||
n->m_nodeID_s = ids;
|
||||
n->m_nodeID = id;
|
||||
add_child(n);
|
||||
}
|
||||
else if (node_name == "text")
|
||||
{
|
||||
auto n = new NodeText();
|
||||
add_child(n);
|
||||
@@ -1466,27 +1434,37 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node, bool skip_children
|
||||
}
|
||||
if (!text.empty())
|
||||
n->set_text(text);
|
||||
break;
|
||||
}
|
||||
case kWidget::Ref:
|
||||
{
|
||||
auto ids = x_child->Attribute("id");
|
||||
auto id = const_hash(ids);
|
||||
auto& ref = (*m_manager)[id]->m_children[0];
|
||||
auto n = ref->clone();
|
||||
n->m_nodeID_s = ids;
|
||||
n->m_nodeID = id;
|
||||
add_child(n);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
#define CASE(W,C) else if (node_name == W) { auto n = new C(); add_child(n); n->load_internal(x_child); }
|
||||
CASE("node", Node)
|
||||
CASE("border", NodeBorder)
|
||||
CASE("image", NodeImage)
|
||||
CASE("image-texture", NodeImageTexture)
|
||||
CASE("icon", NodeIcon)
|
||||
CASE("text-input", NodeTextInput)
|
||||
CASE("button", NodeButton)
|
||||
CASE("button-custom", NodeButtonCustom)
|
||||
CASE("combobox", NodeComboBox)
|
||||
CASE("slider-h", NodeSliderH)
|
||||
CASE("slider-v", NodeSliderV)
|
||||
CASE("slider-hue", NodeSliderHue)
|
||||
CASE("popup-menu", NodePopupMenu)
|
||||
CASE("viewport", NodeViewport)
|
||||
CASE("checkbox", NodeCheckBox)
|
||||
CASE("stroke-preview", NodeStrokePreview)
|
||||
CASE("canvas", NodeCanvas)
|
||||
CASE("scroll", NodeScroll)
|
||||
CASE("metadata", NodeMetadata)
|
||||
CASE("panel-quick", NodePanelQuick)
|
||||
CASE("colorwheel", NodeColorWheel)
|
||||
CASE("color-quad", NodeColorQuad)
|
||||
#undef CASE
|
||||
else
|
||||
{
|
||||
LOG("instancing UNKNOWN node: %s", x_child->Name());
|
||||
auto n = new Node();
|
||||
add_child(n);
|
||||
n->load_internal(x_child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
x_child = x_child->NextSiblingElement();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user