aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/theme_builder/components/conditions/CompoundConditionEditor.cpp4
-rw-r--r--src/ui/ThemeResourceDictionary.cpp2
-rw-r--r--src/xml/XmlNode.cpp16
-rw-r--r--src/xml/XmlParser.cpp21
4 files changed, 35 insertions, 8 deletions
diff --git a/src/theme_builder/components/conditions/CompoundConditionEditor.cpp b/src/theme_builder/components/conditions/CompoundConditionEditor.cpp
index a0985eff..01c5db4c 100644
--- a/src/theme_builder/components/conditions/CompoundConditionEditor.cpp
+++ b/src/theme_builder/components/conditions/CompoundConditionEditor.cpp
@@ -24,7 +24,7 @@ CompoundConditionEditorChild::CompoundConditionEditorChild(
remove_button_.SetIconWithSvgPathDataStringResourceKey(u"icon.close",
{0, 0, 16, 16});
remove_button_.SetPreferredSize({24, 24});
- remove_button_.SetPadding(ui::Thickness(4));
+ remove_button_.SetPadding(ui::Thickness(2));
remove_button_.SetIconFillColor(ui::colors::red);
container_.AddChild(condition_editor_->GetRootControl());
@@ -50,7 +50,7 @@ CompoundConditionEditor::CompoundConditionEditor() {
add_child_button_.GetButton()->SetIconWithSvgPathDataStringResourceKey(
u"icon.plus-square", {0, 0, 16, 16});
add_child_button_.GetButton()->SetPreferredSize({24, 24});
- add_child_button_.GetButton()->SetPadding(ui::Thickness(4));
+ add_child_button_.GetButton()->SetPadding(ui::Thickness(2));
add_child_button_.GetButton()->SetIconFillColor(ui::colors::green);
add_child_button_.SetMenuItems({u"And Condition", u"Or Condition",
u"Click State Condition", u"Focus Condition",
diff --git a/src/ui/ThemeResourceDictionary.cpp b/src/ui/ThemeResourceDictionary.cpp
index d9483f6c..97b4a74a 100644
--- a/src/ui/ThemeResourceDictionary.cpp
+++ b/src/ui/ThemeResourceDictionary.cpp
@@ -50,7 +50,7 @@ void ThemeResourceDictionary::UpdateResourceMap(xml::XmlElementNode* xml_root) {
CRU_LOG_DEBUG(u"Ignore unknown element {} of theme.", c->GetTag());
}
} else {
- CRU_LOG_WARN(u"Ignore text node of theme.");
+ CRU_LOG_DEBUG(u"Ignore text or comment node of theme.");
}
}
}
diff --git a/src/xml/XmlNode.cpp b/src/xml/XmlNode.cpp
index cfa87dd6..41bbed4d 100644
--- a/src/xml/XmlNode.cpp
+++ b/src/xml/XmlNode.cpp
@@ -9,6 +9,10 @@ XmlElementNode* XmlNode::AsElement() {
XmlTextNode* XmlNode::AsText() { return static_cast<XmlTextNode*>(this); }
+XmlCommentNode* XmlNode::AsComment() {
+ return static_cast<XmlCommentNode*>(this);
+}
+
const XmlElementNode* XmlNode::AsElement() const {
return static_cast<const XmlElementNode*>(this);
}
@@ -17,6 +21,10 @@ const XmlTextNode* XmlNode::AsText() const {
return static_cast<const XmlTextNode*>(this);
}
+const XmlCommentNode* XmlNode::AsComment() const {
+ return static_cast<const XmlCommentNode*>(this);
+}
+
XmlElementNode::~XmlElementNode() {
for (auto child : children_) {
delete child;
@@ -57,4 +65,12 @@ XmlNode* XmlElementNode::Clone() const {
return node;
}
+
+XmlCommentNode::~XmlCommentNode() {}
+
+XmlNode* XmlCommentNode::Clone() const {
+ XmlCommentNode* node = new XmlCommentNode(text_);
+
+ return node;
+}
} // namespace cru::xml
diff --git a/src/xml/XmlParser.cpp b/src/xml/XmlParser.cpp
index babb6b00..313015d5 100644
--- a/src/xml/XmlParser.cpp
+++ b/src/xml/XmlParser.cpp
@@ -22,7 +22,7 @@ char16_t XmlParser::Read1() {
String XmlParser::ReadWithoutAdvance(int count) {
if (current_position_ + count > xml_.size()) {
- return u"";
+ count = xml_.size() - current_position_;
}
return xml_.substr(current_position_, count);
}
@@ -108,6 +108,19 @@ XmlElementNode* XmlParser::DoParse() {
}
current_ = current_->GetParent();
+ } else if (ReadWithoutAdvance(3) == u"!--") {
+ current_position_ += 3;
+
+ String text;
+ while (true) {
+ auto str = ReadWithoutAdvance(3);
+ if (str == u"-->") break;
+ if (str.empty()) throw XmlParsingException(u"Unexpected end of xml");
+ text += Read1();
+ }
+
+ current_position_ += 3;
+ current_->AddChild(new XmlCommentNode(text.Trim()));
} else {
ReadSpacesAndDiscard();
@@ -173,10 +186,8 @@ XmlElementNode* XmlParser::DoParse() {
throw XmlParsingException(u"Unexpected end of xml");
}
- if (pseudo_root_node_->GetChildren().size() != 1 ||
- pseudo_root_node_->GetChildren()[0]->GetType() !=
- XmlNode::Type::Element) {
- throw XmlParsingException(u"Expected 1 element node as root.");
+ if (pseudo_root_node_->GetChildren().size() != 1) {
+ throw XmlParsingException(u"Expected 1 node as root.");
}
return static_cast<XmlElementNode*>(pseudo_root_node_->GetChildren()[0]);