55 lines
1.3 KiB
C++
55 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()
|
|
{
|
|
auto tpl = static_cast<const NodeBorder*>(init_template("dialog-resize"));
|
|
m_color = tpl->m_color;
|
|
m_border_color = tpl->m_border_color;;
|
|
m_thinkness = tpl->m_thinkness;;
|
|
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 = ui::Canvas::I->m_width;
|
|
static char txt[128];
|
|
sprintf(txt, "Current: %dpx", resolution);
|
|
text->set_text(txt);
|
|
btn_cancel->on_click = [this](Node*) {
|
|
destroy();
|
|
};
|
|
}
|
|
|
|
void NodeDialogResize::loaded()
|
|
{
|
|
// ui::Image thumb = ui::Canvas::I->thumbnail_read(data_path);
|
|
// auto image_tex = find<NodeImageTexture>("thumb-tex");
|
|
// image_tex->tex.create(thumb);
|
|
}
|
|
|
|
int NodeDialogResize::get_resolution()
|
|
{
|
|
return combo ? res_map[combo->m_current_index] : 512;
|
|
}
|