Do not disapeared apply button

This commit is contained in:
Filip Sykala 2021-10-18 19:05:52 +02:00
parent d101d031dc
commit 88f9a387e3
2 changed files with 39 additions and 35 deletions

View File

@ -24,15 +24,16 @@ GLGizmoSimplify::GLGizmoSimplify(GLCanvas3D & parent,
, m_obj_index(0) , m_obj_index(0)
, m_need_reload(false) , m_need_reload(false)
, m_show_wireframe(false) , m_show_wireframe(false)
// translation for GUI size
, tr_mesh_name(_u8L("Mesh name")) , tr_mesh_name(_u8L("Mesh name"))
, tr_triangles(_u8L("Triangles")) , tr_triangles(_u8L("Triangles"))
, tr_preview(_u8L("Preview")) , tr_preview(_u8L("Preview"))
, tr_detail_level(_u8L("Detail level")) , tr_detail_level(_u8L("Detail level"))
, tr_decimate_ratio(_u8L("Decimate ratio")) , tr_decimate_ratio(_u8L("Decimate ratio"))
// for wireframe
, m_wireframe_VBO_id(0) , m_wireframe_VBO_id(0)
, m_wireframe_IBO_id(0) , m_wireframe_IBO_id(0)
, m_wireframe_IBO_size(0)
{} {}
GLGizmoSimplify::~GLGizmoSimplify() { GLGizmoSimplify::~GLGizmoSimplify() {
@ -49,22 +50,11 @@ bool GLGizmoSimplify::on_esc_key_down() {
return true; return true;
} }
bool GLGizmoSimplify::on_init()
{
//m_grabbers.emplace_back();
//m_shortcut_key = WXK_CONTROL_C;
return true;
}
std::string GLGizmoSimplify::on_get_name() const std::string GLGizmoSimplify::on_get_name() const
{ {
return _u8L("Simplify"); return _u8L("Simplify");
} }
void GLGizmoSimplify::on_render() { }
void GLGizmoSimplify::on_render_for_picking() {}
void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limit) void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limit)
{ {
create_gui_cfg(); create_gui_cfg();
@ -220,16 +210,27 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
else free_gpu(); else free_gpu();
} }
if (m_state == State::settings) { bool is_canceling = m_state == State::canceling;
m_imgui->disabled_begin(is_canceling);
if (m_imgui->button(_L("Cancel"))) { if (m_imgui->button(_L("Cancel"))) {
if (m_state == State::settings) {
if (m_original_its.has_value()) { if (m_original_its.has_value()) {
set_its(*m_original_its); set_its(*m_original_its);
m_state = State::close_on_end; m_state = State::close_on_end;
} else { } else {
close(); close();
} }
} else {
m_state = State::canceling;
} }
} else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && is_canceling)
ImGui::SetTooltip(_L("Operation already canceling. Please wait few seconds.").c_str());
m_imgui->disabled_end(); // state canceling
ImGui::SameLine(); ImGui::SameLine();
bool is_processing = m_state != State::settings;
m_imgui->disabled_begin(is_processing);
if (m_imgui->button(_L("Apply"))) { if (m_imgui->button(_L("Apply"))) {
if (!m_is_valid_result) { if (!m_is_valid_result) {
m_state = State::close_on_end; m_state = State::close_on_end;
@ -240,12 +241,12 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
} else { // no changes made } else { // no changes made
close(); close();
} }
} } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && is_processing)
} else { ImGui::SetTooltip(_L("Can't apply when proccess preview.").c_str());
m_imgui->disabled_begin(m_state == State::canceling); m_imgui->disabled_end(); // state !settings
if (m_imgui->button(_L("Cancel"))) m_state = State::canceling;
m_imgui->disabled_end();
// draw progress bar
if (is_processing) { // apply or preview
ImGui::SameLine(m_gui_cfg->bottom_left_width); ImGui::SameLine(m_gui_cfg->bottom_left_width);
// draw progress bar // draw progress bar
char buf[32]; char buf[32];
@ -254,6 +255,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
} }
m_imgui->end(); m_imgui->end();
// refresh view when needed
if (m_need_reload) { if (m_need_reload) {
m_need_reload = false; m_need_reload = false;
bool close_on_end = (m_state == State::close_on_end); bool close_on_end = (m_state == State::close_on_end);

View File

@ -26,15 +26,17 @@ public:
virtual ~GLGizmoSimplify(); virtual ~GLGizmoSimplify();
bool on_esc_key_down(); bool on_esc_key_down();
protected: protected:
virtual bool on_init() override;
virtual std::string on_get_name() const override; virtual std::string on_get_name() const override;
virtual void on_render() override;
virtual void on_render_for_picking() override;
virtual void on_render_input_window(float x, float y, float bottom_limit) override; virtual void on_render_input_window(float x, float y, float bottom_limit) override;
virtual bool on_is_activable() const override; virtual bool on_is_activable() const override;
virtual bool on_is_selectable() const override { return false; } virtual bool on_is_selectable() const override { return false; }
virtual void on_set_state() override; virtual void on_set_state() override;
// must implement
virtual bool on_init() override { return true;};
virtual void on_render() override{};
virtual void on_render_for_picking() override{};
// GLGizmoPainterBase // GLGizmoPainterBase
virtual void render_painter_gizmo() const override{ render_wireframe(); } virtual void render_painter_gizmo() const override{ render_wireframe(); }
private: private: