add user manual in app instead of pdf

This commit is contained in:
2018-09-24 23:34:06 +02:00
parent f1ff142d91
commit 075289b765
18 changed files with 118 additions and 3 deletions

View File

@@ -140,6 +140,7 @@ public:
void init_menu_layer();
void init_menu_timelapse();
void init_menu_about();
void dialog_usermanual();
void dialog_changelog();
void dialog_about();
void dialog_newdoc();

View File

@@ -5,6 +5,7 @@
#include "node_dialog_cloud.h"
#include "node_about.h"
#include "node_changelog.h"
#include "node_usermanual.h"
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
{
@@ -19,6 +20,18 @@ std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
return pb;
}
void App::dialog_usermanual()
{
auto dialog = std::make_shared<NodeUserManual>();
dialog->m_manager = &layout;
dialog->init();
dialog->create();
dialog->loaded();
layout[main_id]->add_child(dialog);
layout[main_id]->update();
}
void App::dialog_changelog()
{
auto dialog = std::make_shared<NodeChangelog>();

View File

@@ -546,8 +546,9 @@ void App::init_menu_about()
};
popup->find<NodeButtonCustom>("about-doc")->on_click = [this](Node*) {
auto path = Asset::absolute("data/doc/test.pdf");
display_file(path);
// auto path = Asset::absolute("data/doc/test.pdf");
// display_file(path);
dialog_usermanual();
popup->mouse_release();
popup->destroy();
};

View File

@@ -33,6 +33,7 @@
#include "node_panel_grid.h"
#include "node_about.h"
#include "node_changelog.h"
#include "node_usermanual.h"
void Node::async_start()
{
@@ -903,6 +904,7 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
CASE(kWidget::ColorPicker, NodeColorPicker);
CASE(kWidget::About, NodeAbout);
CASE(kWidget::Changelog, NodeChangelog);
CASE(kWidget::UserManual, NodeUserManual);
#undef CASE
case kWidget::Ref:
{

View File

@@ -43,6 +43,7 @@ enum class kAttribute : uint16_t
Mips = const_hash("mips"),
Default = const_hash("default"),
RTL = const_hash("rtl"),
AutoSize = const_hash("autosize"),
};
enum class kWidget : uint16_t
@@ -83,6 +84,7 @@ enum class kWidget : uint16_t
ColorPicker = const_hash("color-picker"),
About = const_hash("about"),
Changelog = const_hash("changelog"),
UserManual = const_hash("usermanual"),
};
class Node

View File

@@ -40,6 +40,8 @@ void NodeImage::create()
auto tex_sz = TextureManager::get(m_tex_id).size();
m_off = xy(m_region) / tex_sz;
m_sz = (zw(m_region) - xy(m_region)) / tex_sz;
if (m_autosize)
SetAspectRatio(tex_sz.x / tex_sz.y);
}
}
@@ -72,6 +74,9 @@ void NodeImage::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* at
}
break;
}
case kAttribute::AutoSize:
m_autosize = attr->BoolValue();
break;
default:
break;
}

View File

@@ -11,6 +11,7 @@ public:
static Sampler m_sampler_mips;
bool m_use_atlas = false;
bool m_use_mipmaps = false;
bool m_autosize = false;
glm::vec4 m_region;
glm::vec2 m_off;
glm::vec2 m_sz;

26
src/node_usermanual.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include "pch.h"
#include "log.h"
#include "node_usermanual.h"
#include "layout.h"
Node* NodeUserManual::clone_instantiate() const
{
return new NodeUserManual();
}
void NodeUserManual::init()
{
SetPosition(0, 0);
SetWidthP(100);
SetHeightP(100);
SetPositioning(YGPositionTypeAbsolute);
m_template = (*m_manager)[const_hash("usermanual")]->m_children[0]->clone();
add_child(m_template);
btn_ok = m_template->find<NodeButton>("btn-ok");
btn_ok->on_click = [&](Node*) { destroy(); };
}
kEventResult NodeUserManual::handle_event(Event* e)
{
return kEventResult::Consumed;
}

13
src/node_usermanual.h Normal file
View File

@@ -0,0 +1,13 @@
#pragma once
#include "node.h"
#include "node_button.h"
class NodeUserManual : public Node
{
Node* m_template;
NodeButton* btn_ok;
public:
virtual Node* clone_instantiate() const override;
virtual void init() override;
virtual kEventResult handle_event(Event* e) override;
};