52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include "pch.h"
|
|
#include "log.h"
|
|
#include "node_dialog_resize.h"
|
|
#include "canvas.h"
|
|
#include "node_image_texture.h"
|
|
#include "app.h"
|
|
#include <array>
|
|
|
|
Node* NodeDialogResize::clone_instantiate() const
|
|
{
|
|
return new NodeDialogResize();
|
|
}
|
|
|
|
void NodeDialogResize::clone_finalize(Node* dest) const
|
|
{
|
|
NodeDialogResize* n = static_cast<NodeDialogResize*>(dest);
|
|
n->init_controls();
|
|
}
|
|
|
|
void NodeDialogResize::init()
|
|
{
|
|
init_template_file("data/dialogs/doc-resize.xml", "dialog-resize");
|
|
init_controls();
|
|
}
|
|
|
|
void NodeDialogResize::init_controls()
|
|
{
|
|
btn_ok = find<NodeButton>("btn-ok");
|
|
btn_cancel = find<NodeButton>("btn-cancel");
|
|
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);
|
|
btn_cancel->on_click = [this](Node*) {
|
|
destroy();
|
|
};
|
|
}
|
|
|
|
void NodeDialogResize::loaded()
|
|
{
|
|
// Image thumb = Canvas::I->thumbnail_read(data_path);
|
|
// auto image_tex = find<NodeImageTexture>("thumb-tex");
|
|
// image_tex->tex.create(thumb);
|
|
}
|
|
|
|
int NodeDialogResize::get_resolution()
|
|
{
|
|
return combo ? App::I->res_from_index(combo->m_current_index) : 512;
|
|
}
|