improve progress bar, refactor node destruction, simplify layers export
This commit is contained in:
@@ -1483,6 +1483,9 @@ Here's a list of what's available in this release.
|
|||||||
<button-custom id="file-submenu-export-layers" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-submenu-export-layers" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<text text="Separate Layers" grow="1" margin="0 0 0 5"/>
|
<text text="Separate Layers" grow="1" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
<button-custom id="file-submenu-export-cube" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<text text="Cube Faces" grow="1" margin="0 0 0 5"/>
|
||||||
|
</button-custom>
|
||||||
<button-custom id="file-submenu-export-depth" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-submenu-export-depth" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<text text="3D View + Depth" grow="1" margin="0 0 0 5"/>
|
<text text="3D View + Depth" grow="1" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
bool key_char(char key);
|
bool key_char(char key);
|
||||||
void toggle_ui();
|
void toggle_ui();
|
||||||
void set_stylus();
|
void set_stylus();
|
||||||
NodeMessageBox* message_box(const std::string& title, const std::string& text, bool cancel_button = false);
|
std::shared_ptr<NodeMessageBox> message_box(const std::string& title, const std::string& text, bool cancel_button = false);
|
||||||
|
|
||||||
void rec_clear();
|
void rec_clear();
|
||||||
void rec_loop();
|
void rec_loop();
|
||||||
@@ -243,7 +243,7 @@ public:
|
|||||||
void download(std::string url, std::string dest_filepath, std::function<void(float)> progress = nullptr);
|
void download(std::string url, std::string dest_filepath, std::function<void(float)> progress = nullptr);
|
||||||
bool check_license();
|
bool check_license();
|
||||||
|
|
||||||
std::shared_ptr<NodeProgressBar> show_progress(const std::string& title);
|
std::shared_ptr<NodeProgressBar> show_progress(const std::string& title, int total = 0);
|
||||||
|
|
||||||
void brush_update(bool update_color, bool update_brush);
|
void brush_update(bool update_color, bool update_brush);
|
||||||
void title_update();
|
void title_update();
|
||||||
@@ -253,6 +253,7 @@ public:
|
|||||||
int res_to_index(int res);
|
int res_to_index(int res);
|
||||||
std::string res_to_string(int res);
|
std::string res_to_string(int res);
|
||||||
void crash_test();
|
void crash_test();
|
||||||
|
void stacktrace();
|
||||||
|
|
||||||
void ui_save();
|
void ui_save();
|
||||||
void ui_restore();
|
void ui_restore();
|
||||||
@@ -394,7 +395,7 @@ public:
|
|||||||
}
|
}
|
||||||
ui_cv.notify_all();
|
ui_cv.notify_all();
|
||||||
}
|
}
|
||||||
return ui_running ? f.get() : R();
|
return ui_running ? f.get(), redraw = true : R();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_sync()
|
void ui_sync()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void App::cloud_upload()
|
|||||||
auto pb = show_progress("Uploading");
|
auto pb = show_progress("Uploading");
|
||||||
|
|
||||||
upload(doc_path, doc_filename, [this,pb](float p){
|
upload(doc_path, doc_filename, [this,pb](float p){
|
||||||
pb->m_progress->SetWidthP(p * 100.f);
|
pb->set_progress(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
@@ -70,32 +70,20 @@ void App::cloud_upload_all()
|
|||||||
gl_state gl;
|
gl_state gl;
|
||||||
std::shared_ptr<NodeProgressBar> pb;
|
std::shared_ptr<NodeProgressBar> pb;
|
||||||
if (layout.m_loaded)
|
if (layout.m_loaded)
|
||||||
{
|
pb = show_progress("Export Pano Image", names.size());
|
||||||
pb = show_progress("Export Pano Image");
|
|
||||||
}
|
|
||||||
|
|
||||||
int progress = 0;
|
|
||||||
int total = (int)names.size();
|
|
||||||
|
|
||||||
for (const auto& n : names)
|
for (const auto& n : names)
|
||||||
{
|
{
|
||||||
std::string path = data_path + "/" + n;
|
std::string path = data_path + "/" + n;
|
||||||
upload(path);
|
upload(path);
|
||||||
|
|
||||||
progress++;
|
|
||||||
float p = (float)progress / total * 100.f;
|
|
||||||
LOG("progress: %f", p);
|
|
||||||
|
|
||||||
if (layout.m_loaded)
|
if (layout.m_loaded)
|
||||||
{
|
pb->increment();
|
||||||
pb->m_progress->SetWidthP(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layout.m_loaded)
|
if (layout.m_loaded)
|
||||||
{
|
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
}
|
|
||||||
}).detach();
|
}).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "oculus_vr.h"
|
#include "oculus_vr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
|
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, int total /*= 0*/)
|
||||||
{
|
{
|
||||||
auto pb = std::make_shared<NodeProgressBar>();
|
auto pb = std::make_shared<NodeProgressBar>();
|
||||||
pb->m_manager = &layout;
|
pb->m_manager = &layout;
|
||||||
@@ -22,18 +22,25 @@ std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title)
|
|||||||
pb->loaded();
|
pb->loaded();
|
||||||
pb->m_progress->SetWidthP(0);
|
pb->m_progress->SetWidthP(0);
|
||||||
pb->m_title->set_text(title.c_str());
|
pb->m_title->set_text(title.c_str());
|
||||||
|
pb->m_total = total;
|
||||||
|
pb->m_count = 0;
|
||||||
layout[main_id]->add_child(pb);
|
layout[main_id]->add_child(pb);
|
||||||
return pb;
|
return pb;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeMessageBox* App::message_box(const std::string &title, const std::string& text, bool cancel_button)
|
std::shared_ptr<NodeMessageBox> App::message_box(const std::string &title, const std::string& text, bool cancel_button)
|
||||||
{
|
{
|
||||||
auto* m = layout[main_id]->add_child<NodeMessageBox>();
|
auto m = std::make_shared<NodeMessageBox>();
|
||||||
|
m->m_manager = &layout;
|
||||||
|
m->init();
|
||||||
|
m->create();
|
||||||
|
m->loaded();
|
||||||
m->m_title->set_text(title.c_str());
|
m->m_title->set_text(title.c_str());
|
||||||
m->m_message->set_text(text.c_str());
|
m->m_message->set_text(text.c_str());
|
||||||
m->btn_ok->m_text->set_text("Ok");
|
m->btn_ok->m_text->set_text("Ok");
|
||||||
if (!cancel_button)
|
if (!cancel_button)
|
||||||
m->btn_cancel->destroy();
|
m->btn_cancel->destroy();
|
||||||
|
layout[main_id]->add_child(m);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
113
src/canvas.cpp
113
src/canvas.cpp
@@ -1921,113 +1921,16 @@ void Canvas::export_layers(std::string file_name, std::function<void()> on_compl
|
|||||||
|
|
||||||
void Canvas::export_layers_thread(std::string file_name)
|
void Canvas::export_layers_thread(std::string file_name)
|
||||||
{
|
{
|
||||||
std::shared_ptr<NodeProgressBar> pb;
|
static std::array<const char*, 6> plane_names { "front", "right", "back", "left", "top", "bottom" };
|
||||||
if (App::I->layout.m_loaded)
|
auto pb = App::I->show_progress("Export Layers", m_layers.size());
|
||||||
|
for (int i = 0; i < m_layers.size(); i++)
|
||||||
{
|
{
|
||||||
pb = std::make_shared<NodeProgressBar>();
|
auto l = m_layers[i];
|
||||||
pb->m_manager = &App::I->layout;
|
Image img = l->gen_equirect().get_image();
|
||||||
pb->init();
|
img.save_png(fmt::format("{}/{}-layer{:02d}-{}.png", App::I->work_path, file_name, i, l->m_name));
|
||||||
pb->create();
|
pb->increment();
|
||||||
pb->loaded();
|
|
||||||
pb->m_progress->SetWidthP(0);
|
|
||||||
pb->m_title->set_text("Export Pano Layers");
|
|
||||||
App::I->layout[App::I->main_id]->add_child(pb);
|
|
||||||
}
|
|
||||||
int progress = 0;
|
|
||||||
int total = (int)(m_layers.size() + 1) * 6;
|
|
||||||
|
|
||||||
RTT m_latlong;
|
|
||||||
m_latlong.create(m_width * 4, m_height * 2); // NOTE: w and h must be equal to make sense
|
|
||||||
|
|
||||||
GLuint cube_id;
|
|
||||||
int faces[]{
|
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, // front
|
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X, // right
|
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // back
|
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, // left
|
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // top
|
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // bottom
|
|
||||||
};
|
|
||||||
App::I->render_task([&]
|
|
||||||
{
|
|
||||||
glGenTextures(1, &cube_id);
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cube_id);
|
|
||||||
for (GLuint i = 0; i < 6; i++)
|
|
||||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
|
||||||
});
|
|
||||||
|
|
||||||
int seq = 0;
|
|
||||||
for (int layer_index = 0; layer_index < m_layers.size(); layer_index++)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
App::I->render_task([&]
|
|
||||||
{
|
|
||||||
// copy layer to cubemap
|
|
||||||
m_layers[layer_index]->m_rtt[i].bindFramebuffer();
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cube_id);
|
|
||||||
glCopyTexImage2D(faces[i], 0, GL_RGBA8, 0, 0, m_width, m_height, 0);
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
|
||||||
m_layers[layer_index]->m_rtt[i].unbindFramebuffer();
|
|
||||||
});
|
|
||||||
|
|
||||||
progress++;
|
|
||||||
float p = (float)progress / total * 100.f;
|
|
||||||
LOG("progress: %f", p);
|
|
||||||
|
|
||||||
if (App::I->layout.m_loaded)
|
|
||||||
{
|
|
||||||
pb->m_progress->SetWidthP(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
App::I->render_task([&]
|
|
||||||
{
|
|
||||||
glViewport(0, 0, m_latlong.getWidth(), m_latlong.getHeight());
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
m_latlong.bindFramebuffer();
|
|
||||||
m_latlong.clear({ 1, 1, 1, 0 });
|
|
||||||
ShaderManager::use(kShader::Equirect);
|
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
|
||||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cube_id);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
m_sampler_linear.bind(0);
|
|
||||||
m_plane.draw_fill();
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
|
||||||
m_latlong.unbindFramebuffer();
|
|
||||||
});
|
|
||||||
|
|
||||||
{
|
|
||||||
auto latlong_data = std::make_unique<uint8_t[]>(m_latlong.bytes());
|
|
||||||
m_latlong.readTextureData(latlong_data.get());
|
|
||||||
static char name[128];
|
|
||||||
sprintf(name, "%s/%s-layer-%02d.png", App::I->work_path.c_str(), file_name.c_str(), seq);
|
|
||||||
seq++;
|
|
||||||
LOG("writing %s", name);
|
|
||||||
int ret = stbi_write_png(name, m_latlong.getWidth(), m_latlong.getHeight(), 4, latlong_data.get(), m_latlong.stride());
|
|
||||||
}
|
|
||||||
|
|
||||||
progress++;
|
|
||||||
float p = (float)progress / total * 100.f;
|
|
||||||
LOG("progress: %f", p);
|
|
||||||
|
|
||||||
if (App::I->layout.m_loaded)
|
|
||||||
{
|
|
||||||
pb->m_progress->SetWidthP(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
App::I->render_task([&]
|
|
||||||
{
|
|
||||||
glDeleteTextures(1, &cube_id);
|
|
||||||
m_latlong.destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (App::I->layout.m_loaded)
|
|
||||||
{
|
|
||||||
pb->destroy();
|
|
||||||
}
|
}
|
||||||
|
pb->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::export_cubes()
|
void Canvas::export_cubes()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
void LayoutManager::unload()
|
void LayoutManager::unload()
|
||||||
{
|
{
|
||||||
for (auto& l : m_layouts)
|
for (auto& l : m_layouts)
|
||||||
l.second->destroy_immediate();
|
l.second->destroy();
|
||||||
m_layouts.clear();
|
m_layouts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
src/node.cpp
28
src/node.cpp
@@ -41,6 +41,7 @@ void Node::app_redraw()
|
|||||||
{
|
{
|
||||||
App::I->redraw = true;
|
App::I->redraw = true;
|
||||||
App::I->ui_cv.notify_all();
|
App::I->ui_cv.notify_all();
|
||||||
|
App::I->render_cv.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::watch(std::function<bool(Node*)> observer)
|
void Node::watch(std::function<bool(Node*)> observer)
|
||||||
@@ -58,20 +59,17 @@ void Node::watch(std::function<bool(Node*)> observer)
|
|||||||
|
|
||||||
void Node::destroy()
|
void Node::destroy()
|
||||||
{
|
{
|
||||||
m_destroyed = true;
|
auto children_copy = m_children;
|
||||||
|
for (auto c : children_copy)
|
||||||
|
c->destroy();
|
||||||
mouse_release();
|
mouse_release();
|
||||||
key_release();
|
key_release();
|
||||||
}
|
remove_from_parent();
|
||||||
|
app_redraw();
|
||||||
void Node::destroy_immediate()
|
|
||||||
{
|
|
||||||
for (auto c : m_children)
|
|
||||||
c->destroy_immediate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* Node::root()
|
Node* Node::root()
|
||||||
{
|
{
|
||||||
|
|
||||||
Node* ret = this;
|
Node* ret = this;
|
||||||
while (ret->m_parent)
|
while (ret->m_parent)
|
||||||
ret = ret->m_parent;
|
ret = ret->m_parent;
|
||||||
@@ -657,7 +655,6 @@ Node::Node(Node&& o)
|
|||||||
m_flood_events = o.m_flood_events;
|
m_flood_events = o.m_flood_events;
|
||||||
m_force_mouse_capture = o.m_force_mouse_capture;
|
m_force_mouse_capture = o.m_force_mouse_capture;
|
||||||
m_capture_children = o.m_capture_children;
|
m_capture_children = o.m_capture_children;
|
||||||
m_destroyed = false;// o.m_destroyed;
|
|
||||||
|
|
||||||
m_scale = o.m_scale;
|
m_scale = o.m_scale;
|
||||||
m_pos_origin = o.m_pos_origin;
|
m_pos_origin = o.m_pos_origin;
|
||||||
@@ -1007,16 +1004,6 @@ void Node::update_internal(const glm::vec2& origin, const glm::mat4& proj, float
|
|||||||
m_mvp = proj * pos * scale * pivot * prescale;
|
m_mvp = proj * pos * scale * pivot * prescale;
|
||||||
m_proj = proj;
|
m_proj = proj;
|
||||||
|
|
||||||
for (int i = 0; i < m_children.size(); i++)
|
|
||||||
{
|
|
||||||
if (m_children[i]->m_destroyed)
|
|
||||||
{
|
|
||||||
m_children[i]->destroy_immediate();
|
|
||||||
remove_child(m_children[i].get());
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_size != old_size || m_zoom != zoom)
|
if (m_size != old_size || m_zoom != zoom)
|
||||||
{
|
{
|
||||||
m_zoom = zoom;
|
m_zoom = zoom;
|
||||||
@@ -1370,14 +1357,11 @@ void Node::clone_copy(Node* dest) const
|
|||||||
dest->m_mvp = m_mvp;
|
dest->m_mvp = m_mvp;
|
||||||
dest->m_mouse_inside = m_mouse_inside;
|
dest->m_mouse_inside = m_mouse_inside;
|
||||||
dest->m_capture_children = m_capture_children;
|
dest->m_capture_children = m_capture_children;
|
||||||
dest->m_destroyed = false;// m_destroyed;
|
|
||||||
dest->m_scale = m_scale;
|
dest->m_scale = m_scale;
|
||||||
dest->m_pos_origin = m_pos_origin;
|
dest->m_pos_origin = m_pos_origin;
|
||||||
dest->m_pos_offset = m_pos_offset;
|
dest->m_pos_offset = m_pos_offset;
|
||||||
dest->m_pos_offset_childred = m_pos_offset_childred;
|
dest->m_pos_offset_childred = m_pos_offset_childred;
|
||||||
dest->m_clip_uncut = m_clip_uncut;
|
dest->m_clip_uncut = m_clip_uncut;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::clone_children(Node* dest) const
|
void Node::clone_children(Node* dest) const
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ public:
|
|||||||
bool m_flood_events = false;
|
bool m_flood_events = false;
|
||||||
bool m_force_mouse_capture = false;
|
bool m_force_mouse_capture = false;
|
||||||
bool m_capture_children = true; // wether to capture children events when xx_capture() is used
|
bool m_capture_children = true; // wether to capture children events when xx_capture() is used
|
||||||
bool m_destroyed = false;
|
|
||||||
std::vector<Node*> m_capture_stack;
|
std::vector<Node*> m_capture_stack;
|
||||||
|
|
||||||
bool m_mouse_ignore = true;
|
bool m_mouse_ignore = true;
|
||||||
@@ -201,8 +200,7 @@ public:
|
|||||||
virtual void clone_children(Node* dest) const;
|
virtual void clone_children(Node* dest) const;
|
||||||
virtual void clone_finalize(Node* dest) const;;
|
virtual void clone_finalize(Node* dest) const;;
|
||||||
void watch(std::function<bool(Node*)> observer);
|
void watch(std::function<bool(Node*)> observer);
|
||||||
void destroy();
|
virtual void destroy();
|
||||||
virtual void destroy_immediate();
|
|
||||||
Node* root();
|
Node* root();
|
||||||
|
|
||||||
template<class T = Node> T* find(const char* ids)
|
template<class T = Node> T* find(const char* ids)
|
||||||
|
|||||||
@@ -643,9 +643,8 @@ void NodeCanvas::on_tick(float dt)
|
|||||||
m_outline_pan = glm::fract(m_outline_pan + dt * 0.01f);
|
m_outline_pan = glm::fract(m_outline_pan + dt * 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeCanvas::destroy_immediate()
|
void NodeCanvas::destroy()
|
||||||
{
|
{
|
||||||
Node::destroy_immediate();
|
|
||||||
m_blender_rtt.destroy();
|
m_blender_rtt.destroy();
|
||||||
m_cache_rtt.destroy();
|
m_cache_rtt.destroy();
|
||||||
m_rtt.destroy();
|
m_rtt.destroy();
|
||||||
@@ -653,4 +652,5 @@ void NodeCanvas::destroy_immediate()
|
|||||||
m_face_plane.destroy();
|
m_face_plane.destroy();
|
||||||
m_line.destroy();
|
m_line.destroy();
|
||||||
m_grid.destroy();
|
m_grid.destroy();
|
||||||
|
Node::destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
||||||
virtual kEventResult handle_event(Event* e) override;
|
virtual kEventResult handle_event(Event* e) override;
|
||||||
virtual void destroy_immediate() override;
|
virtual void destroy() override;
|
||||||
virtual void on_tick(float dt) override;
|
virtual void on_tick(float dt) override;
|
||||||
void reset_camera();
|
void reset_camera();
|
||||||
void create_buffers();
|
void create_buffers();
|
||||||
|
|||||||
@@ -442,8 +442,7 @@ void NodePanelBrushPreset::init()
|
|||||||
if (!m_current)
|
if (!m_current)
|
||||||
return;
|
return;
|
||||||
int index = m_container->get_child_index(m_current);
|
int index = m_container->get_child_index(m_current);
|
||||||
m_current->destroy_immediate();
|
m_current->destroy();
|
||||||
m_container->remove_child(m_current);
|
|
||||||
if (m_container->m_children.empty())
|
if (m_container->m_children.empty())
|
||||||
{
|
{
|
||||||
m_current = nullptr;
|
m_current = nullptr;
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ void NodePanelGrid::bake_uvs()
|
|||||||
);
|
);
|
||||||
while (pb_value < fb.getHeight())
|
while (pb_value < fb.getHeight())
|
||||||
{
|
{
|
||||||
pb->m_progress->SetWidthP((float)pb_value / (float)fb.getHeight() * 100.f);
|
pb->set_progress((float)pb_value / (float)fb.getHeight());
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
worker.join();
|
worker.join();
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ bool NodePanelStroke::import_abr(const std::string& path)
|
|||||||
brush->m_user_brush = true;
|
brush->m_user_brush = true;
|
||||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, m_brush_popup, std::placeholders::_1);
|
brush->on_click = std::bind(&NodePanelBrush::handle_click, m_brush_popup, std::placeholders::_1);
|
||||||
count++;
|
count++;
|
||||||
float prog = (float)count / (float)tot;
|
pb->set_progress((float)count / (float)tot);
|
||||||
pb->m_progress->SetWidthP(prog * 100.f);
|
|
||||||
});
|
});
|
||||||
m_brush_popup->save();
|
m_brush_popup->save();
|
||||||
|
|
||||||
@@ -105,8 +104,7 @@ bool NodePanelStroke::import_abr(const std::string& path)
|
|||||||
brush->m_user_brush = true;
|
brush->m_user_brush = true;
|
||||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, m_pattern_popup, std::placeholders::_1);
|
brush->on_click = std::bind(&NodePanelBrush::handle_click, m_pattern_popup, std::placeholders::_1);
|
||||||
count++;
|
count++;
|
||||||
float prog = (float)count / (float)tot;
|
pb->set_progress((float)count / (float)tot);
|
||||||
pb->m_progress->SetWidthP(prog * 100.f);
|
|
||||||
});
|
});
|
||||||
m_pattern_popup->save();
|
m_pattern_popup->save();
|
||||||
|
|
||||||
@@ -119,8 +117,7 @@ bool NodePanelStroke::import_abr(const std::string& path)
|
|||||||
App::I->presets->add_brush(pr);
|
App::I->presets->add_brush(pr);
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
float prog = (float)count / (float)tot;
|
pb->set_progress((float)count / (float)tot);
|
||||||
pb->m_progress->SetWidthP(prog * 100.f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
App::I->presets->save();
|
App::I->presets->save();
|
||||||
|
|||||||
@@ -20,5 +20,17 @@ void NodeProgressBar::init()
|
|||||||
btn_cancel->on_click = [&](Node*) { destroy(); };
|
btn_cancel->on_click = [&](Node*) { destroy(); };
|
||||||
m_progress = find<NodeBorder>("progress");
|
m_progress = find<NodeBorder>("progress");
|
||||||
|
|
||||||
m_progress->SetWidthP(10);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ public:
|
|||||||
NodeButton* btn_cancel;
|
NodeButton* btn_cancel;
|
||||||
NodeText* m_title;
|
NodeText* m_title;
|
||||||
NodeBorder* m_progress;
|
NodeBorder* m_progress;
|
||||||
|
int m_total = 0;
|
||||||
|
int m_count = 0;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
|
void increment() noexcept;
|
||||||
|
// set progress where p [0, 1]
|
||||||
|
void set_progress(float p) noexcept;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -589,10 +589,10 @@ void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size, fl
|
|||||||
draw_stroke();
|
draw_stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeStrokePreview::destroy_immediate()
|
void NodeStrokePreview::destroy()
|
||||||
{
|
{
|
||||||
Node::destroy_immediate();
|
|
||||||
m_tex_preview.destroy();
|
m_tex_preview.destroy();
|
||||||
|
Node::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeStrokePreview::handle_on_screen(bool old_visibility, bool new_visibility)
|
void NodeStrokePreview::handle_on_screen(bool old_visibility, bool new_visibility)
|
||||||
|
|||||||
@@ -54,6 +54,6 @@ public:
|
|||||||
void draw_stroke_immediate();
|
void draw_stroke_immediate();
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;
|
||||||
virtual void destroy_immediate() override;
|
virtual void destroy() override;
|
||||||
virtual void handle_on_screen(bool old_visibility, bool new_visibility) override;
|
virtual void handle_on_screen(bool old_visibility, bool new_visibility) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user