#include "pch.h"
#include "log.h"
#include "app.h"
#include "node_icon.h"
#include "node_dialog_open.h"
#include "node_progress_bar.h"
#include "mp4enc.h"
#include "app_core/app_frame.h"
#include "app_core/app_shutdown.h"
#include "app_core/app_status.h"
#include "app_core/app_startup.h"
#include "app_core/app_thread.h"
#include "app_core/canvas_tool_ui.h"
#include "app_core/document_cloud.h"
#include "app_core/document_recording.h"
#include "app_core/document_route.h"
#include "legacy_app_runtime_shell_services.h"
#include "legacy_app_startup_services.h"
#include "legacy_document_open_services.h"
#include "legacy_preference_storage.h"
#include "platform_api/platform_services.h"

#ifdef __APPLE__
#include <Foundation/Foundation.h>
#include "objc_utils.h"
#endif

App* App::I = nullptr; // singleton

void App::create()
{
    pp::panopainter::execute_legacy_app_create(*this);
}

void App::open_document(std::string path)
{
    pp::panopainter::execute_legacy_document_open(*this, std::move(path));
}

bool App::request_close()
{
    return pp::panopainter::execute_legacy_app_request_close(*this);
}

void App::initAssets()
{
    pp::panopainter::execute_legacy_app_init_assets(*this);
}

void App::initLog()
{
    pp::panopainter::execute_legacy_app_init_log(*this);
}

namespace pp::panopainter
{
    bool update_legacy_app_ui_observer(App& app, Node* n);
}

void App::init()
{
    pp::panopainter::execute_legacy_app_init(*this);
}

bool App::update_ui_observer(Node *n)
{
    return pp::panopainter::update_legacy_app_ui_observer(*this, n);
}

void App::renderdoc_frame_start()
{
    pp::panopainter::execute_legacy_app_renderdoc_frame_start(*this);
}

void App::renderdoc_frame_end()
{
    pp::panopainter::execute_legacy_app_renderdoc_frame_end(*this);
}

void App::render_thread_main()
{
    pp::panopainter::execute_legacy_app_render_thread_main(*this);
}

void App::ui_thread_tick()
{
    pp::panopainter::execute_legacy_app_ui_thread_tick(*this);
}

void App::ui_thread_main()
{
    pp::panopainter::execute_legacy_app_ui_thread_main(*this);
}

void App::render_thread_start()
{
    pp::panopainter::execute_legacy_app_render_thread_start(*this);
}

void App::render_thread_stop()
{
    pp::panopainter::execute_legacy_app_render_thread_stop(*this);
}

void App::ui_thread_start()
{
    pp::panopainter::execute_legacy_app_ui_thread_start(*this);
}

void App::ui_thread_stop()
{
    pp::panopainter::execute_legacy_app_ui_thread_stop(*this);
}
