Files
panopainter/src/node_progress_bar.cpp
2019-09-26 17:48:38 +02:00

43 lines
1004 B
C++

#include "pch.h"
#include "log.h"
#include "node_progress_bar.h"
#include "layout.h"
Node* NodeProgressBar::clone_instantiate() const
{
return new NodeProgressBar();
}
void NodeProgressBar::init()
{
init_template_file("data/dialogs/progress-bar.xml", "progress-bar");
m_capture_children = false; // don't capture children events on mouse_capture
m_title = find<NodeText>("title");
btn_cancel = find<NodeButton>("btn-cancel");
//btn_cancel->on_click = [&](Node*) { destroy(); };
m_progress = find<NodeBorder>("progress");
m_body = find<NodeBorder>("body");
m_progress->SetWidthP(0);
}
void NodeProgressBar::increment() noexcept
{
m_count++;
if (m_total != 0)
m_progress->SetWidthP(((float)m_count / m_total) * 100.f);
}
void NodeProgressBar::set_progress(float p) noexcept
{
m_progress->SetWidthP(p * 100.f);
}
void NodeProgressBar::added(Node* parent)
{
NodeBorder::added(parent);
if (added_to_root())
mouse_capture();
}