add changelog dialog and display_file api (implemented in osx and ios)
This commit is contained in:
@@ -94,6 +94,7 @@ public:
|
||||
struct engine* and_engine;
|
||||
#endif
|
||||
void pick_image(std::function<void(std::string path)> callback);
|
||||
void display_file(std::string path);
|
||||
void showKeyboard();
|
||||
void hideKeyboard();
|
||||
void initLog();
|
||||
@@ -139,6 +140,7 @@ public:
|
||||
void init_menu_layer();
|
||||
void init_menu_timelapse();
|
||||
void init_menu_about();
|
||||
void dialog_changelog();
|
||||
void dialog_about();
|
||||
void dialog_newdoc();
|
||||
void dialog_save();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "node_dialog_browse.h"
|
||||
#include "node_dialog_cloud.h"
|
||||
#include "node_about.h"
|
||||
#include "node_changelog.h"
|
||||
|
||||
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
|
||||
{
|
||||
@@ -18,6 +19,18 @@ std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
|
||||
return pb;
|
||||
}
|
||||
|
||||
void App::dialog_changelog()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeChangelog>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
|
||||
layout[main_id]->add_child(dialog);
|
||||
layout[main_id]->update();
|
||||
}
|
||||
|
||||
void App::dialog_about()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeAbout>();
|
||||
@@ -29,6 +42,7 @@ void App::dialog_about()
|
||||
layout[main_id]->add_child(dialog);
|
||||
layout[main_id]->update();
|
||||
}
|
||||
|
||||
void App::dialog_newdoc()
|
||||
{
|
||||
auto show_dialog = [this] {
|
||||
|
||||
@@ -63,6 +63,26 @@ void App::pick_image(std::function<void(std::string path)> callback)
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::display_file(std::string path)
|
||||
{
|
||||
#ifdef __IOS__
|
||||
[ios_view display_file:path];
|
||||
#elif __OSX__
|
||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:path.c_str()]];
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// std::string path = [osx_view pick_file];
|
||||
// if (!path.empty())
|
||||
// callback(path);
|
||||
// });
|
||||
#elif __ANDROID__
|
||||
//displayKeyboard(and_app, false);
|
||||
#elif _WIN32
|
||||
// std::string path = win32_open_file();
|
||||
// if (!path.empty())
|
||||
// callback(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool App::mouse_down(int button, float x, float y, float pressure, kEventSource source)
|
||||
{
|
||||
redraw = true;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "node_text.h"
|
||||
#include "node_progress_bar.h"
|
||||
#include "node_dialog_picker.h"
|
||||
#include "node_about.h"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
@@ -547,6 +546,8 @@ 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);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
@@ -560,6 +561,7 @@ void App::init_menu_about()
|
||||
text->set_text(label);
|
||||
}
|
||||
item->on_click = [this](Node*) {
|
||||
dialog_changelog();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "node_dialog_picker.h"
|
||||
#include "node_panel_grid.h"
|
||||
#include "node_about.h"
|
||||
#include "node_changelog.h"
|
||||
|
||||
void Node::async_start()
|
||||
{
|
||||
@@ -901,6 +902,7 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
||||
CASE(kWidget::ColorWheel, NodeColorWheel);
|
||||
CASE(kWidget::ColorPicker, NodeColorPicker);
|
||||
CASE(kWidget::About, NodeAbout);
|
||||
CASE(kWidget::Changelog, NodeChangelog);
|
||||
#undef CASE
|
||||
case kWidget::Ref:
|
||||
{
|
||||
|
||||
@@ -82,6 +82,7 @@ enum class kWidget : uint16_t
|
||||
ColorWheel = const_hash("colorwheel"),
|
||||
ColorPicker = const_hash("color-picker"),
|
||||
About = const_hash("about"),
|
||||
Changelog = const_hash("changelog"),
|
||||
};
|
||||
|
||||
class Node
|
||||
|
||||
26
src/node_changelog.cpp
Normal file
26
src/node_changelog.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_changelog.h"
|
||||
#include "layout.h"
|
||||
|
||||
Node* NodeChangelog::clone_instantiate() const
|
||||
{
|
||||
return new NodeChangelog();
|
||||
}
|
||||
|
||||
void NodeChangelog::init()
|
||||
{
|
||||
SetPosition(0, 0);
|
||||
SetWidthP(100);
|
||||
SetHeightP(100);
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
m_template = (*m_manager)[const_hash("changelog")]->m_children[0]->clone();
|
||||
add_child(m_template);
|
||||
btn_ok = m_template->find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
}
|
||||
|
||||
kEventResult NodeChangelog::handle_event(Event* e)
|
||||
{
|
||||
return kEventResult::Consumed;
|
||||
}
|
||||
13
src/node_changelog.h
Normal file
13
src/node_changelog.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "node.h"
|
||||
#include "node_button.h"
|
||||
|
||||
class NodeChangelog : 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;
|
||||
};
|
||||
Reference in New Issue
Block a user