improve text node xml
This commit is contained in:
@@ -262,6 +262,7 @@ public:
|
||||
void dialog_ppbr_export();
|
||||
void dialog_export_mp4();
|
||||
void dialog_timelapse_export();
|
||||
void dialog_whatsnew();
|
||||
|
||||
void cloud_upload();
|
||||
void cloud_upload_all();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "app.h"
|
||||
#include "action.h"
|
||||
#include "settings.h"
|
||||
#include "node_dialog_open.h"
|
||||
#include "node_dialog_browse.h"
|
||||
#include "node_dialog_resize.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "node_changelog.h"
|
||||
#include "node_usermanual.h"
|
||||
#include "node_dialog_export_ppbr.h"
|
||||
#include "node_remote_page.h"
|
||||
|
||||
#include <codec_api.h>
|
||||
#define MP4V2_NO_STDINT_DEFS
|
||||
@@ -838,3 +840,32 @@ void App::dialog_export_mp4()
|
||||
pb->destroy();
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void App::dialog_whatsnew()
|
||||
{
|
||||
auto whatsnew = std::make_shared<NodeRemotePage>();
|
||||
whatsnew->m_manager = &layout;
|
||||
whatsnew->init();
|
||||
whatsnew->load_url("https://panopainter.com/app-content/whatsnew.xml", [this, whatsnew](bool success) {
|
||||
if (success)
|
||||
{
|
||||
int last_id = Settings::value_or<Serializer::Integer>("whatsnew-id", 0);
|
||||
if (whatsnew->m_page_id <= g_version_build && whatsnew->m_page_id > last_id)
|
||||
{
|
||||
whatsnew->set_title(fmt::format("What's new in version {}", g_version_number));
|
||||
layout[main_id]->add_child(whatsnew);
|
||||
}
|
||||
whatsnew->add_button("Reload", 120, [this, whatsnew](Node*) {
|
||||
whatsnew->reload();
|
||||
});
|
||||
whatsnew->add_button("Read Later", 120, [this, whatsnew](Node*) {
|
||||
whatsnew->destroy();
|
||||
});
|
||||
whatsnew->add_button("Close", 100, [this, whatsnew](Node*) {
|
||||
Settings::set<Serializer::Integer>("whatsnew-id", whatsnew->m_page_id);
|
||||
Settings::save();
|
||||
whatsnew->destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1100,7 +1100,7 @@ void App::init_menu_about()
|
||||
text->set_text(label);
|
||||
}
|
||||
item->on_click = [this, popup](Node*) {
|
||||
dialog_changelog();
|
||||
dialog_whatsnew();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
@@ -1334,31 +1334,7 @@ void App::initLayout()
|
||||
}
|
||||
}
|
||||
|
||||
auto whatsnew = std::make_shared<NodeRemotePage>();
|
||||
whatsnew->m_manager = &layout;
|
||||
whatsnew->init();
|
||||
whatsnew->load_url("http://localhost:8080/app-content/whatsnew.xml", [this, whatsnew] (bool success) {
|
||||
if (success)
|
||||
{
|
||||
int last_id = Settings::value_or<Serializer::Integer>("whatsnew-id", 0);
|
||||
if (whatsnew->m_page_id <= g_version_build && whatsnew->m_page_id > last_id)
|
||||
{
|
||||
whatsnew->set_title(fmt::format("What's new in version {}", g_version_number));
|
||||
layout[main_id]->add_child(whatsnew);
|
||||
}
|
||||
whatsnew->add_button("Reload", 120, [this, whatsnew](Node*) {
|
||||
whatsnew->reload();
|
||||
});
|
||||
whatsnew->add_button("Read Later", 120, [this, whatsnew](Node*) {
|
||||
whatsnew->destroy();
|
||||
});
|
||||
whatsnew->add_button("Close", 100, [this, whatsnew](Node*) {
|
||||
Settings::set<Serializer::Integer>("whatsnew-id", whatsnew->m_page_id);
|
||||
Settings::save();
|
||||
whatsnew->destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
dialog_whatsnew();
|
||||
|
||||
brush_update(true, true);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ bool LayoutManager::parse(const std::string& xml_string) noexcept
|
||||
{
|
||||
auto old = std::move(m_layouts);
|
||||
|
||||
tinyxml2::XMLDocument xml;
|
||||
tinyxml2::XMLDocument xml(true, tinyxml2::COLLAPSE_WHITESPACE);
|
||||
auto ret = xml.Parse(xml_string.c_str(), xml_string.size());
|
||||
if (ret != tinyxml2::XMLError::XML_SUCCESS)
|
||||
{
|
||||
|
||||
25
src/node.cpp
25
src/node.cpp
@@ -1404,7 +1404,6 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
||||
CASE(kWidget::Image, NodeImage);
|
||||
CASE(kWidget::ImageTexture, NodeImageTexture);
|
||||
CASE(kWidget::Icon, NodeIcon);
|
||||
CASE(kWidget::Text, NodeText);
|
||||
CASE(kWidget::TextInput, NodeTextInput);
|
||||
CASE(kWidget::Button, NodeButton);
|
||||
CASE(kWidget::ButtonCustom, NodeButtonCustom);
|
||||
@@ -1439,6 +1438,30 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
||||
CASE(kWidget::Timeline, NodeAnimationTimeline);
|
||||
CASE(kWidget::Metadata, NodeMetadata);
|
||||
#undef CASE
|
||||
case kWidget::Text:
|
||||
{
|
||||
auto n = new NodeText();
|
||||
add_child(n);
|
||||
n->load_internal(x_child);
|
||||
std::string text;
|
||||
auto node = x_child->FirstChild();
|
||||
while (node)
|
||||
{
|
||||
if (auto e = node->ToElement())
|
||||
{
|
||||
if (strcmp(e->Name(), "br") == 0)
|
||||
text.append("\n");
|
||||
}
|
||||
else if (auto t = node->ToText())
|
||||
{
|
||||
text.append(t->Value());
|
||||
}
|
||||
node = node->NextSibling();
|
||||
}
|
||||
if (!text.empty())
|
||||
n->set_text(text);
|
||||
break;
|
||||
}
|
||||
case kWidget::Ref:
|
||||
{
|
||||
auto ids = x_child->Attribute("id");
|
||||
|
||||
Reference in New Issue
Block a user