Extract layout bootstrap and thin NodeCanvas startup shells
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "app.h"
|
||||
#include "node_panel_grid.h"
|
||||
#include "node_icon.h"
|
||||
#include "node_dialog_open.h"
|
||||
#include "node_text.h"
|
||||
#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"
|
||||
@@ -18,10 +13,6 @@
|
||||
#include "legacy_document_layer_services.h"
|
||||
#include "legacy_preference_storage.h"
|
||||
#include "font.h"
|
||||
#include "node_remote_page.h"
|
||||
#include "node_shorcuts.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace pp::panopainter {
|
||||
void bind_legacy_main_toolbar(App& app);
|
||||
@@ -30,6 +21,7 @@ void bind_legacy_edit_menu(App& app);
|
||||
void bind_legacy_about_menu(App& app);
|
||||
void bind_legacy_layer_menu(App& app);
|
||||
void bind_legacy_tools_menu(App& app);
|
||||
void init_layout_bootstrap(App& app);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -120,137 +112,7 @@ void App::init_menu_layer()
|
||||
|
||||
void App::initLayout()
|
||||
{
|
||||
LOG("initializing layout statics");
|
||||
NodeBorder::static_init();
|
||||
NodeImage::static_init();
|
||||
NodeIcon::static_init();
|
||||
NodeStrokePreview::static_init();
|
||||
|
||||
static std::vector<std::shared_ptr<Layer>> saved_layers;
|
||||
layout.on_reloading = [&] {
|
||||
saved_layers = std::move(Canvas::I->m_layers);
|
||||
ui_save();
|
||||
NodeStrokePreview::empty_queue();
|
||||
};
|
||||
|
||||
layout.on_loaded = [&] (bool reloaded) {
|
||||
LOG("initializing layout updating after load %d x %d zoom %f", (int)width, (int)height, zoom);
|
||||
layout[main_id]->update(width, height, zoom);
|
||||
|
||||
LOG("initializing layout components");
|
||||
|
||||
init_sidebar();
|
||||
|
||||
if (reloaded)
|
||||
{
|
||||
for (const auto& l : saved_layers)
|
||||
layers->add_layer(l->m_name.c_str(), false, true, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
layers->add_layer("Default", false, true);
|
||||
Canvas::I->m_unsaved = false;
|
||||
}
|
||||
|
||||
init_toolbar_draw();
|
||||
init_toolbar_main();
|
||||
init_menu_file();
|
||||
init_menu_edit();
|
||||
init_menu_layer();
|
||||
init_menu_tools();
|
||||
init_menu_about();
|
||||
|
||||
// set version string
|
||||
if (auto* version_label = layout[main_id]->find<NodeText>("version"))
|
||||
{
|
||||
version_label->set_text(g_version);
|
||||
}
|
||||
|
||||
const auto renderer_features = ShaderManager::render_device_features();
|
||||
const auto renderer_diagnostics = pp::app::plan_renderer_diagnostics({
|
||||
.framebuffer_fetch = renderer_features.framebuffer_fetch,
|
||||
.float32_render_targets = renderer_features.float32_render_targets,
|
||||
.float32_linear_filtering = renderer_features.float32_linear_filtering,
|
||||
.float16_render_targets = renderer_features.float16_render_targets,
|
||||
});
|
||||
|
||||
if (auto x = layout[main_id]->find<NodeBorder>("ext-fbf"))
|
||||
{
|
||||
x->m_color = renderer_diagnostics.framebuffer_fetch.supported ?
|
||||
glm::vec4(0, 1, 0, 1) :
|
||||
glm::vec4(1, 0, 0, 1);
|
||||
}
|
||||
|
||||
if (auto x = layout[main_id]->find<NodeBorder>("ext-flt"))
|
||||
{
|
||||
if (renderer_diagnostics.floating_point_targets.supported)
|
||||
{
|
||||
if (auto t = x->find<NodeText>("ext-flt-text"))
|
||||
{
|
||||
t->set_text(std::string(renderer_diagnostics.floating_point_targets.label));
|
||||
}
|
||||
x->m_color = glm::vec4(0, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
x->m_color = glm::vec4(1, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
dialog_whatsnew(false);
|
||||
|
||||
brush_update(true, true);
|
||||
|
||||
// hacky thing to make the toolbar buttons not steal events when moving cursor fast
|
||||
if (auto* toolbar = layout[main_id]->find<Node>("toolbar"))
|
||||
toolbar->m_flood_events = true;
|
||||
|
||||
NodeImage* n = new NodeImage;
|
||||
n->m_path = "data/ui/p-black.png";
|
||||
n->m_tex_id = const_hash("data/ui/p-black.png");
|
||||
n->SetSize(30, 45);
|
||||
n->create();
|
||||
|
||||
NodeButtonCustom* butt = new NodeButtonCustom;
|
||||
butt->create();
|
||||
butt->add_child(n);
|
||||
butt->SetPositioning(YGPositionTypeAbsolute);
|
||||
butt->set_color({ 0, 0, 0, 0 });
|
||||
//n->SetPosition(100, 100);
|
||||
YGNodeStyleSetPosition(butt->y_node, YGEdgeBottom, 8);
|
||||
YGNodeStyleSetPosition(butt->y_node, YGEdgeLeft, 10);
|
||||
//butt->SetSize(30, 45);
|
||||
layout[main_id]->add_child(butt);
|
||||
|
||||
butt->on_click = [this](Node*){
|
||||
toggle_ui();
|
||||
};
|
||||
|
||||
ui_restore();
|
||||
|
||||
redraw = true;
|
||||
};
|
||||
|
||||
LOG("initializing layout xml");
|
||||
if (layout.m_loaded)
|
||||
{
|
||||
LOG("restore layout");
|
||||
layout.restore_context();
|
||||
}
|
||||
else
|
||||
layout.load("data/layout.xml");
|
||||
LOG("initializing layout completed");
|
||||
|
||||
LOG("initializing layout designer xml");
|
||||
layout_designer.on_loaded = [&](bool reloaded) {
|
||||
layout_designer.create();
|
||||
//layout_designer[main_id]->add_child(layout_designer.instantiate("shortcuts"));
|
||||
auto p = layout_designer[main_id]->add_child<NodeShortcuts>();
|
||||
//p->SetPosition(300, 300);
|
||||
//p->SetSize(600, 400);
|
||||
//p->m_container->add_child<NodePanelAnimation>();
|
||||
};
|
||||
//layout_designer.load("data/dialogs/shortcuts.xml");
|
||||
pp::panopainter::init_layout_bootstrap(*this);
|
||||
}
|
||||
|
||||
void App::set_ui_scale(float scale)
|
||||
|
||||
Reference in New Issue
Block a user