#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("title"); btn_cancel = find("btn-cancel"); //btn_cancel->on_click = [&](Node*) { destroy(); }; m_progress = find("progress"); m_body = find("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(); }