Extract about menu action planning
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "node_progress_bar.h"
|
||||
#include "node_dialog_picker.h"
|
||||
#include "node_panel_floating.h"
|
||||
#include "app_core/about_menu.h"
|
||||
#include "app_core/app_preferences.h"
|
||||
#include "app_core/brush_ui.h"
|
||||
#include "app_core/canvas_tool_ui.h"
|
||||
@@ -1495,76 +1496,131 @@ void App::init_menu_about()
|
||||
layout[main_id]->add_child(popup);
|
||||
|
||||
popup->find<NodeButtonCustom>("about-app")->on_click = [this, popup](Node*) {
|
||||
dialog_about();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
const auto plan = pp::app::plan_about_menu_command(
|
||||
pp::app::AboutMenuCommand::about_app,
|
||||
g_version_major,
|
||||
g_version_minor,
|
||||
g_version_fix);
|
||||
if (plan.action == pp::app::AboutMenuAction::show_about_dialog)
|
||||
dialog_about();
|
||||
if (plan.closes_root_popup)
|
||||
{
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
}
|
||||
};
|
||||
|
||||
popup->find<NodeButtonCustom>("about-doc")->on_click = [this, popup](Node*) {
|
||||
// auto path = Asset::absolute("data/doc/test.pdf");
|
||||
// display_file(path);
|
||||
dialog_usermanual();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
const auto plan = pp::app::plan_about_menu_command(
|
||||
pp::app::AboutMenuCommand::help_guide,
|
||||
g_version_major,
|
||||
g_version_minor,
|
||||
g_version_fix);
|
||||
if (plan.action == pp::app::AboutMenuAction::show_user_manual)
|
||||
dialog_usermanual();
|
||||
if (plan.closes_root_popup)
|
||||
{
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
}
|
||||
};
|
||||
|
||||
if (auto item = popup->find<NodeButtonCustom>("about-news"))
|
||||
{
|
||||
if (auto text = item->find<NodeText>("menu-label"))
|
||||
{
|
||||
static char label[128];
|
||||
sprintf(label, "What's new in %d.%d.%d?", g_version_major, g_version_minor, g_version_fix);
|
||||
text->set_text(label);
|
||||
const auto plan = pp::app::plan_about_menu_command(
|
||||
pp::app::AboutMenuCommand::whats_new,
|
||||
g_version_major,
|
||||
g_version_minor,
|
||||
g_version_fix);
|
||||
text->set_text(plan.label.c_str());
|
||||
}
|
||||
item->on_click = [this, popup](Node*) {
|
||||
dialog_whatsnew(true);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
const auto plan = pp::app::plan_about_menu_command(
|
||||
pp::app::AboutMenuCommand::whats_new,
|
||||
g_version_major,
|
||||
g_version_minor,
|
||||
g_version_fix);
|
||||
if (plan.action == pp::app::AboutMenuAction::show_whats_new_dialog)
|
||||
dialog_whatsnew(true);
|
||||
if (plan.closes_root_popup)
|
||||
{
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (auto b = popup->find<NodeButtonCustom>("about-crash"))
|
||||
{
|
||||
b->on_click = [this, popup](Node*) {
|
||||
LOG("crashing");
|
||||
crash_test();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
const auto plan = pp::app::plan_about_menu_command(
|
||||
pp::app::AboutMenuCommand::induce_crash,
|
||||
g_version_major,
|
||||
g_version_minor,
|
||||
g_version_fix);
|
||||
if (plan.action == pp::app::AboutMenuAction::trigger_crash_test)
|
||||
{
|
||||
LOG("crashing");
|
||||
crash_test();
|
||||
}
|
||||
if (plan.closes_root_popup)
|
||||
{
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (auto b = popup->find<NodeButtonCustom>("about-perf"))
|
||||
{
|
||||
b->on_click = [this, popup](Node*) {
|
||||
LOG("perf");
|
||||
static char str[256];
|
||||
render_task([&]
|
||||
const auto plan = pp::app::plan_about_menu_command(
|
||||
pp::app::AboutMenuCommand::performance_test,
|
||||
g_version_major,
|
||||
g_version_minor,
|
||||
g_version_fix,
|
||||
true,
|
||||
Canvas::I != nullptr);
|
||||
if (plan.action == pp::app::AboutMenuAction::run_performance_test)
|
||||
{
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
Canvas::I->stroke_start({ 0, 0, 0 }, 0.9f);
|
||||
for (int i = 0; i < 100; i++)
|
||||
LOG("perf");
|
||||
std::string message;
|
||||
const int performance_iterations = plan.performance_iterations;
|
||||
render_task([&]
|
||||
{
|
||||
Canvas::I->stroke_update({ 100, 100, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 200, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 100, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 100, 200, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 300, 300, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 500, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 500, 500, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 400, 400, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 0, 200, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 0, 0 }, 0.9f);
|
||||
Canvas::I->stroke_draw();
|
||||
}
|
||||
Canvas::I->stroke_end();
|
||||
auto diff = std::chrono::high_resolution_clock::now() - start;
|
||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(diff).count();
|
||||
LOG("%lld ms", ms);
|
||||
sprintf(str, "Time %lld ms", ms);
|
||||
});
|
||||
message_box("Performance test", str);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
Canvas::I->stroke_start({ 0, 0, 0 }, 0.9f);
|
||||
for (int i = 0; i < performance_iterations; i++)
|
||||
{
|
||||
Canvas::I->stroke_update({ 100, 100, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 200, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 100, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 100, 200, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 300, 300, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 500, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 500, 500, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 400, 400, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 0, 200, 0 }, 0.9f);
|
||||
Canvas::I->stroke_update({ 200, 0, 0 }, 0.9f);
|
||||
Canvas::I->stroke_draw();
|
||||
}
|
||||
Canvas::I->stroke_end();
|
||||
auto diff = std::chrono::high_resolution_clock::now() - start;
|
||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(diff).count();
|
||||
LOG("%lld ms", ms);
|
||||
message = "Time " + std::to_string(ms) + " ms";
|
||||
});
|
||||
message_box("Performance test", message);
|
||||
}
|
||||
if (plan.closes_root_popup)
|
||||
{
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user