Extract export menu action planning
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "app_core/canvas_tool_ui.h"
|
||||
#include "app_core/document_layer.h"
|
||||
#include "app_core/document_canvas.h"
|
||||
#include "app_core/document_export.h"
|
||||
#include "app_core/document_import.h"
|
||||
#include "app_core/app_status.h"
|
||||
#include "app_core/history_ui.h"
|
||||
@@ -78,6 +79,50 @@ bool apply_brush_preset_plan(App& app, const std::shared_ptr<Brush>& brush)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool apply_document_export_menu_plan(App& app, pp::app::DocumentExportMenuKind kind)
|
||||
{
|
||||
const auto requires_license = pp::app::document_export_menu_requires_license(kind);
|
||||
const auto plan = pp::app::plan_document_export_menu_action(
|
||||
kind,
|
||||
app.canvas != nullptr,
|
||||
!requires_license || app.check_license());
|
||||
|
||||
switch (plan.action)
|
||||
{
|
||||
case pp::app::DocumentExportMenuAction::show_jpeg_dialog:
|
||||
app.dialog_export(".jpg");
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_png_dialog:
|
||||
app.dialog_export(".png");
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_layers_dialog:
|
||||
app.dialog_export_layers();
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_cube_faces_dialog:
|
||||
app.dialog_export_cube_faces();
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_depth_dialog:
|
||||
app.dialog_export_depth();
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_animation_frames_dialog:
|
||||
app.dialog_export_anim_frames();
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_animation_mp4_dialog:
|
||||
app.dialog_export_mp4();
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_timelapse_dialog:
|
||||
app.dialog_timelapse_export();
|
||||
return true;
|
||||
case pp::app::DocumentExportMenuAction::show_license_disabled:
|
||||
app.message_box("License", "This function is disabled in demo mode.");
|
||||
return false;
|
||||
case pp::app::DocumentExportMenuAction::unavailable_no_canvas:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void App::title_update()
|
||||
@@ -801,7 +846,7 @@ void App::init_menu_file()
|
||||
};
|
||||
if (auto b = popup->find<NodeButtonCustom>("file-export"))
|
||||
b->on_click = [this, popup](Node*) {
|
||||
dialog_export(".jpg");
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::jpeg);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
@@ -816,49 +861,49 @@ void App::init_menu_file()
|
||||
subpopup->SetPosition(pos.x, pos.y);
|
||||
layout[main_id]->add_child(subpopup);
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-png")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export(".png");
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::png);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-layers")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export_layers();
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::layers);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-cube")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export_cube_faces();
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::cube_faces);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-depth")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export_depth();
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::depth);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-anim")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export_anim_frames();
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::animation_frames);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-anim-mp4")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_export_mp4();
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::animation_mp4);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
subpopup->destroy();
|
||||
};
|
||||
subpopup->find<NodeButtonCustom>("file-submenu-export-timelapse")->on_click = [this, subpopup, popup](Node*) {
|
||||
dialog_timelapse_export();
|
||||
apply_document_export_menu_plan(*this, pp::app::DocumentExportMenuKind::timelapse);
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
subpopup->mouse_release();
|
||||
|
||||
Reference in New Issue
Block a user