diff --git a/src/app.h b/src/app.h index 02d28ba..3830a7e 100644 --- a/src/app.h +++ b/src/app.h @@ -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(); diff --git a/src/app_dialogs.cpp b/src/app_dialogs.cpp index 8cc5d76..e2eeb7b 100644 --- a/src/app_dialogs.cpp +++ b/src/app_dialogs.cpp @@ -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 #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(); + 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("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("whatsnew-id", whatsnew->m_page_id); + Settings::save(); + whatsnew->destroy(); + }); + } + }); +} \ No newline at end of file diff --git a/src/app_layout.cpp b/src/app_layout.cpp index db52f95..49a9f31 100644 --- a/src/app_layout.cpp +++ b/src/app_layout.cpp @@ -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(); - 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("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("whatsnew-id", whatsnew->m_page_id); - Settings::save(); - whatsnew->destroy(); - }); - } - }); + dialog_whatsnew(); brush_update(true, true); diff --git a/src/layout.cpp b/src/layout.cpp index 05dec28..b121015 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -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) { diff --git a/src/node.cpp b/src/node.cpp index 58ce054..d342abc 100644 --- a/src/node.cpp +++ b/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");