Add [esc] to interupt preview in simplify
This commit is contained in:
parent
80ccb77b00
commit
a9bd989eda
@ -41,6 +41,14 @@ GLGizmoSimplify::~GLGizmoSimplify() {
|
||||
free_gpu();
|
||||
}
|
||||
|
||||
bool GLGizmoSimplify::on_esc_key_down() {
|
||||
if (m_state == State::settings || m_state == State::canceling)
|
||||
return false;
|
||||
|
||||
m_state = State::canceling;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLGizmoSimplify::on_init()
|
||||
{
|
||||
//m_grabbers.emplace_back();
|
||||
@ -207,7 +215,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
||||
ImGui::Text(_L("%d triangles").c_str(), m_configuration.wanted_count);
|
||||
m_imgui->disabled_end(); // use_count
|
||||
|
||||
if (ImGui::Checkbox(_L("Show wireframe").c_str(), &m_show_wireframe)) {
|
||||
if (ImGui::Checkbox(_u8L("Show wireframe").c_str(), &m_show_wireframe)) {
|
||||
if (m_show_wireframe) init_wireframe();
|
||||
else free_gpu();
|
||||
}
|
||||
@ -221,17 +229,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
||||
close();
|
||||
}
|
||||
}
|
||||
ImGui::SameLine(m_gui_cfg->bottom_left_width);
|
||||
|
||||
m_imgui->disabled_begin(m_configuration.live_preview || m_is_valid_result);
|
||||
if (m_imgui->button(_L("Preview"))) {
|
||||
m_state = State::preview;
|
||||
// simplify but not apply on mesh
|
||||
process();
|
||||
}
|
||||
m_imgui->disabled_end();
|
||||
ImGui::SameLine();
|
||||
|
||||
if (m_imgui->button(_L("Apply"))) {
|
||||
if (!m_is_valid_result) {
|
||||
m_state = State::close_on_end;
|
||||
@ -243,11 +241,6 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
||||
close();
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Checkbox(_L("Live").c_str(), &m_configuration.live_preview)) {
|
||||
if (m_configuration.live_preview && !m_is_valid_result)
|
||||
live_preview();
|
||||
}
|
||||
} else {
|
||||
m_imgui->disabled_begin(m_state == State::canceling);
|
||||
if (m_imgui->button(_L("Cancel"))) m_state = State::canceling;
|
||||
@ -292,9 +285,8 @@ void GLGizmoSimplify::close() {
|
||||
|
||||
void GLGizmoSimplify::live_preview() {
|
||||
m_is_valid_result = false;
|
||||
if (!m_configuration.live_preview) return;
|
||||
|
||||
if (m_state != State::settings) {
|
||||
// already canceling process
|
||||
if (m_state == State::canceling) return;
|
||||
|
||||
// wait until cancel
|
||||
@ -435,6 +427,9 @@ void GLGizmoSimplify::create_gui_cfg() {
|
||||
cfg.input_width = cfg.bottom_left_width * 1.5;
|
||||
cfg.window_offset_x = (cfg.bottom_left_width + cfg.input_width)/2;
|
||||
cfg.window_offset_y = ImGui::GetTextLineHeightWithSpacing() * 5;
|
||||
|
||||
float checkbox_width = ImGui::GetFrameHeight();
|
||||
|
||||
m_gui_cfg = cfg;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class GLGizmoSimplify: public GLGizmoBase, public GLGizmoTransparentRender // GL
|
||||
public:
|
||||
GLGizmoSimplify(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
virtual ~GLGizmoSimplify();
|
||||
bool on_esc_key_down();
|
||||
protected:
|
||||
virtual bool on_init() override;
|
||||
virtual std::string on_get_name() const override;
|
||||
@ -74,8 +75,6 @@ private:
|
||||
|
||||
struct Configuration
|
||||
{
|
||||
bool live_preview = false;
|
||||
|
||||
bool use_count = false;
|
||||
// minimal triangle count
|
||||
float decimate_ratio = 50.f; // in percent
|
||||
|
@ -924,6 +924,10 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
||||
case WXK_NUMPAD_DOWN: case WXK_DOWN: { do_move(-1.0); break; }
|
||||
default: { break; }
|
||||
}
|
||||
} else if (m_current == Simplify && keyCode == WXK_ESCAPE) {
|
||||
GLGizmoSimplify *simplify = dynamic_cast<GLGizmoSimplify *>(get_current());
|
||||
if (simplify != nullptr)
|
||||
processed = simplify->on_esc_key_down();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user