Extract document resize planning

This commit is contained in:
2026-06-03 10:03:34 +02:00
parent 21c448d6f1
commit 5d5bb24711
9 changed files with 226 additions and 7 deletions

View File

@@ -1,9 +1,9 @@
#include "pch.h"
#include "log.h"
#include "node_dialog_resize.h"
#include "app_core/document_resize.h"
#include "canvas.h"
#include "node_image_texture.h"
#include "app.h"
#include <array>
Node* NodeDialogResize::clone_instantiate() const
@@ -30,9 +30,12 @@ void NodeDialogResize::init_controls()
combo = find<NodeComboBox>("resolution");
text = find<NodeText>("current-res");
resolution = Canvas::I->m_width;
static char txt[128];
sprintf(txt, "Current: %s", App::I->res_to_string(resolution).c_str());
text->set_text(txt);
const auto state = pp::app::make_document_resize_dialog_state(resolution);
text->set_text(state.current_resolution_text.c_str());
if (combo && state.current_resolution_index >= 0
&& state.current_resolution_index < static_cast<int>(combo->m_items.size())) {
combo->m_current_index = state.current_resolution_index;
}
btn_cancel->on_click = [this](Node*) {
destroy();
};
@@ -47,5 +50,6 @@ void NodeDialogResize::loaded()
int NodeDialogResize::get_resolution()
{
return combo ? App::I->res_from_index(combo->m_current_index) : 512;
const auto plan = pp::app::plan_document_resize(combo ? combo->m_current_index : 0);
return plan ? plan.value().resolution : pp::app::document_resolution_values.front();
}